Skip to content

ctx add decision inserts content inside HTML comment block in DECISIONS.md #10

@v0lkan

Description

@v0lkan

Bug

ctx add decision inserts the decision entry inside the HTML comment block that contains the template/format guide, making the decision invisible when rendered.

Reproduction

Starting from a fresh DECISIONS.md scaffolded by ctx (which has this structure):

# Decisions

<!-- INDEX:START -->
| Date | Decision |
|------|--------|
<!-- INDEX:END -->

<!-- DECISION FORMATS

## Quick Format (Y-Statement)
...

## Full Format
...

## [YYYY-MM-DD] Decision Title
**Status**: ...
**Context**: ...
...

-->

Run:

ctx add decision "My important decision" \
  --context "What prompted it" \
  --rationale "Why this choice" \
  --consequences "What changes"

Expected: Decision is inserted after the closing --> of the DECISION FORMATS comment block.

Actual: Decision is inserted inside the comment block (before the -->), so it doesn't render in any markdown viewer.

Root Cause (likely)

The insertion logic probably pattern-matches on ## Full Format or the template heading and appends after it, without checking whether the insertion point is inside an HTML comment (<!-- ... -->).

Impact

  • The INDEX table at the top updates correctly (visible)
  • The actual decision body is invisible when rendered
  • Users don't notice until they view the rendered page — the raw file looks fine at a glance since the --> is far below

Suggested Fix

Before inserting, check whether the target insertion point is between <!-- and -->. If so, insert after the closing --> instead.

Alternatively, close the comment block before the template example:

<!-- DECISION FORMATS
Quick Format: ...
Full Format: ...
-->

## [YYYY-MM-DD] Decision Title
...

This way the template example heading doesn't collide with real decision headings during pattern matching.

Workaround

Manually move the decision entry below the --> closing tag.

Environment

  • ctx version: latest (main branch)
  • OS: macOS 15.3.2 (Sequoia)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions