Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A Claude Code plugin that provides iterative development with independent AI rev

The loop has two phases: **Implementation** (Claude works, Codex reviews summaries) and **Code Review** (Codex checks code quality with severity markers). Issues feed back into implementation until resolved.


## Install

```bash
Expand All @@ -45,7 +46,7 @@ Requires [codex CLI](https://github.com/openai/codex) for review. See the full [
/humanize:gen-plan --input draft.md --output docs/plan.md
```

2. **Refine an annotated plan** before implementation when reviewers add `CMT:` ... `ENDCMT` comments:
2. **Refine an annotated plan** before implementation when reviewers add comments (`CMT:` ... `ENDCMT`, `<cmt>` ... `</cmt>`, or `<comment>` ... `</comment>`):
```bash
/humanize:refine-plan --input docs/plan.md
```
Expand Down
43 changes: 29 additions & 14 deletions commands/refine-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The refined plan MUST reuse the existing `gen-plan` schema. Do not invent new to
1. **Execution Mode Setup**: Parse CLI arguments and derive output paths
2. **Load Project Config**: Resolve `alternative_plan_language` and mode defaults using `config-loader.sh` semantics
3. **IO Validation**: Run `validate-refine-plan-io.sh`
4. **Comment Extraction**: Scan the annotated plan and extract valid `CMT:` / `ENDCMT` blocks
4. **Comment Extraction**: Scan the annotated plan and extract valid comment blocks (`CMT:`/`ENDCMT`, `<cmt>`/`</cmt>`, `<comment>`/`</comment>`)
5. **Comment Classification**: Classify each extracted comment for downstream handling
6. **Comment Processing**: Answer questions, apply requested plan edits, and perform targeted research
7. **Plan Refinement**: Produce the comment-free refined plan while preserving the `gen-plan` structure
Expand Down Expand Up @@ -167,7 +167,7 @@ Handle exit codes exactly:
- Exit code 0: Continue to Phase 2
- Exit code 1: Report `Input file not found` and stop
- Exit code 2: Report `Input file is empty` and stop
- Exit code 3: Report `Input file has no CMT:/ENDCMT blocks` and stop
- Exit code 3: Report `Input file has no comment blocks` and stop
- Exit code 4: Report `Input file is missing required gen-plan sections` and stop
- Exit code 5: Report `Output directory does not exist or is not writable - please fix it` and stop
- Exit code 6: Report `QA directory is not writable` and stop
Expand Down Expand Up @@ -196,17 +196,32 @@ Track these states while scanning the validated input in document order:

Extraction rules:

1. Recognize `CMT:` as the start marker and `ENDCMT` as the end marker.
2. Support both inline and multi-line blocks:
1. Support three comment formats:
- Classic: `CMT:` as start marker and `ENDCMT` as end marker
- Short tag: `<cmt>` as start marker and `</cmt>` as end marker
- Long tag: `<comment>` as start marker and `</comment>` as end marker
2. Support both inline and multi-line blocks for all formats:
- Inline: `Text before CMT: comment text ENDCMT text after`
- Inline: `Text before <cmt>comment text</cmt> text after`
- Inline: `Text before <comment>comment text</comment> text after`
- Multi-line:
```markdown
CMT:
comment text
ENDCMT
```
3. Ignore `CMT:` and `ENDCMT` sequences inside fenced code blocks.
4. Ignore `CMT:` and `ENDCMT` sequences inside HTML comments.
```markdown
<cmt>
comment text
</cmt>
```
```markdown
<comment>
comment text
</comment>
```
3. Ignore comment markers inside fenced code blocks.
4. Ignore comment markers inside HTML comments.
5. Update `NEAREST_HEADING` whenever a Markdown heading is encountered outside fenced code and HTML comments.
6. Preserve surrounding non-comment text when removing inline comment blocks from the working plan text.
7. Assign raw comment IDs in document order as `CMT-1`, `CMT-2`, ... only for non-empty blocks.
Expand All @@ -217,7 +232,7 @@ Extraction rules:
For each non-empty comment block, capture:

- `id` (`CMT-N`)
- `original_text` exactly as written between `CMT:` and `ENDCMT`
- `original_text` exactly as written between the comment markers
- `normalized_text` with surrounding whitespace trimmed
- `start_line`, `start_column`
- `end_line`, `end_column`
Expand All @@ -230,8 +245,8 @@ For each non-empty comment block, capture:

These are fatal extraction errors:

1. Nested `CMT:` while already inside a comment block
2. `ENDCMT` encountered while not inside a comment block
1. Nested comment start marker while already inside a comment block
2. Comment end marker encountered while not inside a comment block or wrong end marker for the format
3. End of file reached while still inside a comment block

Every fatal parse error MUST report:
Expand All @@ -243,9 +258,9 @@ Every fatal parse error MUST report:

Examples of acceptable messages:

- `Comment parse error: nested CMT block at line 48, column 3 near "## Acceptance Criteria" (context: "CMT: split AC-2...")`
- `Comment parse error: stray ENDCMT at line 109, column 1 near "## Task Breakdown" (context: "ENDCMT")`
- `Comment parse error: missing ENDCMT for block opened at line 72, column 5 near "## Dependencies and Sequence"`
- `Comment parse error: nested comment block at line 48, column 3 near "## Acceptance Criteria" (context: "<cmt>split AC-2...")`
- `Comment parse error: stray comment end marker at line 109, column 1 near "## Task Breakdown" (context: "</comment>")`
- `Comment parse error: missing end marker for block opened at line 72, column 5 near "## Dependencies and Sequence"`

### Outputs from Phase 2

Expand Down Expand Up @@ -403,7 +418,7 @@ Optional sections that MUST be preserved when present in the input:

### Refinement Rules

1. Remove every resolved `CMT:` / `ENDCMT` tag and all enclosed comment text from the refined plan.
1. Remove every resolved comment marker and all enclosed comment text from the refined plan.
2. Do not add any new top-level schema section.
3. Preserve `AC-X` / `AC-X.Y` formatting.
4. Preserve task IDs unless a comment explicitly requests a structural change.
Expand All @@ -429,7 +444,7 @@ Rules:
Before generating the QA document, verify:

1. All required sections are still present
2. No `CMT:` or `ENDCMT` markers remain
2. No comment markers remain
3. Every referenced `AC-*` exists
4. Every task dependency references an existing task ID or `-`
5. Every task row has exactly one valid routing tag: `coding` or `analyze`
Expand Down
38 changes: 32 additions & 6 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The quiz is advisory, not a gate. You always have the option to proceed. But tha
```bash
/humanize:gen-plan --input draft.md --output docs/plan.md
```
2. If the plan is reviewed with `CMT:` ... `ENDCMT` annotations, refine it and generate a QA ledger:
2. If the plan is reviewed with comment annotations, refine it and generate a QA ledger:
```bash
/humanize:refine-plan --input docs/plan.md
```
Expand Down Expand Up @@ -127,7 +127,7 @@ Workflow:
5. Generates a structured plan.md with acceptance criteria
6. Optionally starts `/humanize:start-rlcr-loop` if `--auto-start-rlcr-if-converged` conditions are met

If reviewers later annotate the generated plan with `CMT:` ... `ENDCMT` blocks, run
If reviewers later annotate the generated plan with comment blocks, run
`/humanize:refine-plan --input <plan.md>` before starting or resuming implementation.

### refine-plan
Expand Down Expand Up @@ -169,9 +169,10 @@ how each comment was handled.

**Annotated comment block format:**

`refine-plan` looks for reviewer comments wrapped in `CMT:` and `ENDCMT` markers. Both inline
and multi-line comment blocks are supported:
`refine-plan` supports three comment formats for reviewer annotations. Both inline
and multi-line comment blocks are supported in all formats:

**Classic format (CMT:/ENDCMT):**
```markdown
Text before CMT: clarify why AC-3 is split here ENDCMT text after
```
Expand All @@ -183,11 +184,36 @@ If the dependency is unclear, add a pending decision instead of guessing.
ENDCMT
```

**Short tag format (<cmt></cmt>):**
```markdown
Text before <cmt>clarify why AC-3 is split here</cmt> text after
```

```markdown
<cmt>
Please investigate whether this task should depend on task4 or task5.
If the dependency is unclear, add a pending decision instead of guessing.
</cmt>
```

**Long tag format (<comment></comment>):**
```markdown
Text before <comment>clarify why AC-3 is split here</comment> text after
```

```markdown
<comment>
Please investigate whether this task should depend on task4 or task5.
If the dependency is unclear, add a pending decision instead of guessing.
</comment>
```

Rules:
- At least one non-empty `CMT:` block must exist in the input file.
- `CMT:` and `ENDCMT` markers inside fenced code blocks or HTML comments are ignored.
- At least one non-empty comment block must exist in the input file.
- Comment markers inside fenced code blocks or HTML comments are ignored.
- Empty comment blocks are removed but do not create QA ledger entries.
- The input plan must still follow the `gen-plan` section schema.
- All three formats can be mixed within the same file.

**QA output structure:**

Expand Down
Loading
Loading