pass "gen-plan direct mode does not mark plan as converged"
else
fail "gen-plan direct mode does not mark plan as converged""PLAN_CONVERGENCE_STATUS=partially_converged in direct-mode branch""missing or still marked converged"
fi
if[[-f"$GEN_PLAN_CMD"]]&&grep-n-A12"Optional Direct Work Start""$GEN_PLAN_CMD" | grep-q"GEN_PLAN_MODE=discussion";then
assert_file_contains "$REFINE_PLAN_CMD"'"Bash(${CLAUDE_PLUGIN_ROOT}/scripts/validate-refine-plan-io.sh:*)"'"refine-plan.md allowlist includes validate-refine-plan-io.sh"
assert_file_contains "$REFINE_PLAN_CMD"'"AskUserQuestion"'"refine-plan.md allows AskUserQuestion for discussion mode"
assert_file_contains "$REFINE_PLAN_CMD"'hide-from-slash-command-tool: "true"'"refine-plan.md is hidden from slash command tool"
assert_file_contains "$REFINE_PLAN_CMD""Read and execute below with ultrathink.""refine-plan.md requires ultrathink execution mode"
fi
echo""
echo"PT-3: Planning-only and workflow constraints"
assert_file_contains "$REFINE_PLAN_CMD""## Hard Constraint: Planning-Only Refinement""refine-plan.md declares planning-only hard constraint"
assert_file_contains "$REFINE_PLAN_CMD""This command MUST ONLY refine plan artifacts.""refine-plan.md forbids repository implementation work"
assert_file_contains "$REFINE_PLAN_CMD"'Keep `--alt-language` out of the validator invocation'"refine-plan.md excludes --alt-language from validator invocation"
assert_file_contains "$REFINE_PLAN_CMD"'- Exit code 1: Report `Input file not found` and stop'"refine-plan.md documents validator exit code 1"
assert_file_contains "$REFINE_PLAN_CMD"'- Exit code 2: Report `Input file is empty` and stop'"refine-plan.md documents validator exit code 2"
assert_file_contains "$REFINE_PLAN_CMD"'- Exit code 3: Report `Input file has no comment blocks` and stop'"refine-plan.md documents validator exit code 3"
assert_file_contains "$REFINE_PLAN_CMD"'- Exit code 4: Report `Input file is missing required gen-plan sections` and stop'"refine-plan.md documents validator exit code 4"
assert_file_contains "$REFINE_PLAN_CMD"'- Exit code 5: Report `Output directory does not exist or is not writable - please fix it` and stop'"refine-plan.md documents validator exit code 5"
assert_file_contains "$REFINE_PLAN_CMD"'- Exit code 6: Report `QA directory is not writable` and stop'"refine-plan.md documents validator exit code 6"
assert_file_contains "$REFINE_PLAN_CMD"'- Exit code 7: Report `Invalid arguments` and show the validator usage, then stop'"refine-plan.md documents validator exit code 7"
echo""
echo"PT-5: Comment extraction requirements"
assert_file_contains "$REFINE_PLAN_CMD""Support both inline and multi-line blocks for all formats:""refine-plan.md supports inline and multiline comment extraction"
assert_file_contains "$REFINE_PLAN_CMD"'Inline: `Text before CMT: comment text ENDCMT text after`'"refine-plan.md documents single-line comment extraction"
assert_file_contains "$REFINE_PLAN_CMD""CMT:""refine-plan.md includes multiline comment marker example"
assert_file_contains "$REFINE_PLAN_CMD"'Ignore comment markers inside HTML comments.'"refine-plan.md documents HTML comment exclusion"
assert_file_contains "$REFINE_PLAN_CMD""Preserve surrounding non-comment text when removing inline comment blocks from the working plan text.""refine-plan.md preserves inline surrounding text"
assert_file_contains "$REFINE_PLAN_CMD"'- `nearest_heading` or `Preamble` when no heading exists yet'"refine-plan.md records nearest heading or Preamble"
assert_file_contains "$REFINE_PLAN_CMD"'- `location_label` for QA output'"refine-plan.md records location labels"
assert_file_contains "$REFINE_PLAN_CMD"'- `form` = `inline` or `multiline`'"refine-plan.md records comment form"
assert_file_contains "$REFINE_PLAN_CMD"'- `context_excerpt` from the nearest non-comment source text'"refine-plan.md records context excerpts"
assert_file_contains "$REFINE_PLAN_CMD"'Nested comment start marker while already inside a comment block'"refine-plan.md documents nested CMT parse errors"
assert_file_contains "$REFINE_PLAN_CMD"'Comment end marker encountered while not inside a comment block or wrong end marker for the format'"refine-plan.md documents stray ENDCMT parse errors"
assert_file_contains "$REFINE_PLAN_CMD""End of file reached while still inside a comment block""refine-plan.md documents missing ENDCMT parse errors"
assert_file_contains "$REFINE_PLAN_CMD"'- `question`'"refine-plan.md includes question classification"
assert_file_contains "$REFINE_PLAN_CMD"'- `change_request`'"refine-plan.md includes change_request classification"
assert_file_contains "$REFINE_PLAN_CMD"'- `research_request`'"refine-plan.md includes research_request classification"
assert_file_contains "$REFINE_PLAN_CMD"'- `question`: asks why, how, what, explain, clarify, or says the plan is unclear'"refine-plan.md documents question heuristics"
assert_file_contains "$REFINE_PLAN_CMD"'- `change_request`: asks to add, remove, delete, rewrite, restore, rename, split, merge, or otherwise modify the plan'"refine-plan.md documents change_request heuristics"
assert_file_contains "$REFINE_PLAN_CMD"'- `research_request`: asks to investigate the repository, compare existing patterns, confirm current behavior, or gather evidence before deciding'"refine-plan.md documents research_request heuristics"
assert_file_contains "$REFINE_PLAN_CMD"'Create deterministic processing sub-items in textual order: `CMT-N.1`, `CMT-N.2`, ...'"refine-plan.md splits multi-intent comments into sub-items"
assert_file_contains "$REFINE_PLAN_CMD"'- `research_request`'"refine-plan.md includes dominant classification precedence values"
assert_file_contains "$REFINE_PLAN_CMD"'In `discussion` mode: use `AskUserQuestion` to confirm the classification before continuing'"refine-plan.md asks the user to resolve ambiguity in discussion mode"
assert_file_contains "$REFINE_PLAN_CMD"'In `direct` mode: choose the most action-driving interpretation and record the assumption in the QA document'"refine-plan.md resolves ambiguity heuristically in direct mode"
assert_file_contains "$REFINE_PLAN_CMD"'If omitted, set `OUTPUT_FILE=INPUT_FILE` for in-place mode.'"refine-plan.md defaults output to in-place mode"
assert_file_contains "$REFINE_PLAN_CMD"'Compute `IN_PLACE_MODE=true` when `OUTPUT_FILE` equals `INPUT_FILE`'"refine-plan.md derives IN_PLACE_MODE"
assert_file_contains "$REFINE_PLAN_CMD"'Compute `QA_FILE` from the input basename, not the output basename:'"refine-plan.md derives QA file from input basename"
assert_file_contains "$REFINE_PLAN_CMD"'Do not introduce `--language` or `--qa-output`'"refine-plan.md constrains v1 CLI surface"
echo"PT-8: Alternative language and filename rules"
assert_file_contains "$REFINE_PLAN_CMD"'Resolve configuration by following the same precedence and merge semantics defined in `${CLAUDE_PLUGIN_ROOT}/scripts/lib/config-loader.sh`.'"refine-plan.md reuses config-loader merge semantics"
assert_file_contains "$REFINE_PLAN_CMD"'`CONFIG_ALT_LANGUAGE_RAW` from `alternative_plan_language`'"refine-plan.md reads alternative_plan_language from config"
assert_file_contains "$REFINE_PLAN_CMD"'Do not depend on deprecated `chinese_plan`. `refine-plan` only uses `alternative_plan_language`.'"refine-plan.md ignores deprecated chinese_plan"
assert_file_contains "$REFINE_PLAN_CMD"'2. Config `alternative_plan_language`'"refine-plan.md falls back to config alt-language"
assert_file_contains "$REFINE_PLAN_CMD"'3. Treat `English` / `en` as a no-op: no translated variant is generated.'"refine-plan.md treats English as no-op for variants"
assert_file_contains "$REFINE_PLAN_CMD"'4. If the CLI value is unsupported, report `Unsupported --alt-language "<value>"` and stop.'"refine-plan.md rejects unsupported CLI alt-language"
assert_file_contains "$REFINE_PLAN_CMD""5. If the config value is unsupported, log a warning and disable variant generation.""refine-plan.md warns on unsupported config alt-language"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| Chinese[[:space:]]+\\| zh[[:space:]]+\\| `_zh`[[:space:]]+\\|$'"refine-plan.md includes Chinese language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| Korean[[:space:]]+\\| ko[[:space:]]+\\| `_ko`[[:space:]]+\\|$'"refine-plan.md includes Korean language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| Japanese[[:space:]]+\\| ja[[:space:]]+\\| `_ja`[[:space:]]+\\|$'"refine-plan.md includes Japanese language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| Spanish[[:space:]]+\\| es[[:space:]]+\\| `_es`[[:space:]]+\\|$'"refine-plan.md includes Spanish language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| French[[:space:]]+\\| fr[[:space:]]+\\| `_fr`[[:space:]]+\\|$'"refine-plan.md includes French language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| German[[:space:]]+\\| de[[:space:]]+\\| `_de`[[:space:]]+\\|$'"refine-plan.md includes German language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| Portuguese[[:space:]]+\\| pt[[:space:]]+\\| `_pt`[[:space:]]+\\|$'"refine-plan.md includes Portuguese language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| Russian[[:space:]]+\\| ru[[:space:]]+\\| `_ru`[[:space:]]+\\|$'"refine-plan.md includes Russian language mapping"
assert_file_contains_regex "$REFINE_PLAN_CMD"'^\\| Arabic[[:space:]]+\\| ar[[:space:]]+\\| `_ar`[[:space:]]+\\|$'"refine-plan.md includes Arabic language mapping"
assert_file_contains "$REFINE_PLAN_CMD"'- `plan.md` -> `plan_zh.md`'"refine-plan.md documents plan variant naming"
assert_file_contains "$REFINE_PLAN_CMD"'If `ALT_PLAN_LANGUAGE` is empty or equals the main language, do not create variant files.'"refine-plan.md skips unnecessary variants"
echo""
echo"PT-9: Atomic write transaction requirements"
assert_file_contains "$REFINE_PLAN_CMD""Prepare all final content in memory first:""refine-plan.md prepares outputs in memory before writing"
assert_file_contains "$REFINE_PLAN_CMD""Write each output to a temporary file in the same directory as its final destination.""refine-plan.md writes temp files in destination directories"
assert_file_contains "$REFINE_PLAN_CMD""Delete all temp files""refine-plan.md deletes temp files on failure"
assert_file_contains "$REFINE_PLAN_CMD""Leave existing final outputs untouched""refine-plan.md preserves final outputs on temp write failure"
assert_file_contains "$REFINE_PLAN_CMD""Replace auxiliary outputs before replacing the main in-place plan file, so the primary plan is updated last.""refine-plan.md updates the main plan last"
assert_file_contains "$REFINE_PLAN_CMD""No stale temp files remain""refine-plan.md requires temp cleanup after success"
echo""
echo"PT-10: QA template coverage"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""# Refine Plan QA""refine-plan QA template has title"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""## Summary""refine-plan QA template includes Summary section"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""## Comment Ledger""refine-plan QA template includes Comment Ledger section"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""## Answers""refine-plan QA template includes Answers section"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""## Research Findings""refine-plan QA template includes Research Findings section"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""## Plan Changes Applied""refine-plan QA template includes Plan Changes Applied section"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""## Remaining Decisions""refine-plan QA template includes Remaining Decisions section"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""## Refinement Metadata""refine-plan QA template includes Refinement Metadata section"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""| CMT-ID | Classification | Location | Original Text (excerpt) | Disposition |""refine-plan QA template includes ledger columns"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""- **Input Plan:** <path/to/input-plan.md>""refine-plan QA template records input plan path"
assert_file_contains "$REFINE_PLAN_QA_TEMPLATE""- **Output Plan:** <path/to/refined-plan.md>""refine-plan QA template records output plan path"
if[["$(dominant_classification "Why do we need two config layers here?")"=="question"]];then
pass "reference classifier maps question comments to question"
else
fail "reference classifier maps question comments to question""question""$(dominant_classification "Why do we need two config layers here?")"
fi
if[["$(dominant_classification "Delete task5 and fold its work into task4.")"=="change_request"]];then
pass "reference classifier maps change requests to change_request"
else
fail "reference classifier maps change requests to change_request""change_request""$(dominant_classification "Delete task5 and fold its work into task4.")"
fi
if[["$(dominant_classification "Investigate how config loading works in this repo before deciding whether AC-3 should change.")"=="research_request"]];then
pass "reference classifier maps research requests to research_request"
else
fail "reference classifier maps research requests to research_request""research_request""$(dominant_classification "Investigate how config loading works in this repo before deciding whether AC-3 should change.")"
fi
if[["$(dominant_classification "Investigate the repo and delete task5 if the evidence shows it is redundant.")"=="research_request"]];then
pass "reference classifier gives research_request dominant precedence over change_request"
else
fail "reference classifier gives research_request dominant precedence over change_request""research_request""$(dominant_classification "Investigate the repo and delete task5 if the evidence shows it is redundant.")"
fi
if[["$(dominant_classification "Delete task5 because it is unclear why it exists.")"=="change_request"]];then
pass "reference classifier gives change_request precedence over question"
else
fail "reference classifier gives change_request precedence over question""change_request""$(dominant_classification "Delete task5 because it is unclear why it exists.")"
fail "validate-refine-plan-io: unterminated CMT blocks report missing ENDCMT""missing end marker""$VALIDATOR_OUTPUT"
fi
if echo"$VALIDATOR_OUTPUT" | grep-q'context: "CMT: this block never closes"';then
pass "validate-refine-plan-io: unterminated CMT blocks include the opening-line context excerpt"
else
fail "validate-refine-plan-io: unterminated CMT blocks include the opening-line context excerpt"'context: "CMT: this block never closes"'"$VALIDATOR_OUTPUT"