Skip to content

fix(pstack): treat fences inside nested list items as code in plan checks - #1241

Open
divya0795 wants to merge 1 commit into
cursor:mainfrom
divya0795:fix/check-plan-nested-list-fences
Open

divya0795 wants to merge 1 commit into
cursor:mainfrom
divya0795:fix/check-plan-nested-list-fences

Conversation

@divya0795

Copy link
Copy Markdown

What

check-plan.mjs treats a fenced code block inside a nested list item as plan prose. Its style rules then fire on the code, and - [ ] lines inside the code are counted as boxes. A valid plan can fail the check because of an example inside it.

This follows #536, which taught the checker about fences but only matched fences indented 0–3 spaces:

// pstack/skills/poteto-mode/scripts/check-plan.mjs:49 and :54
const match = text.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
const match = text.match(/^ {0,3}(`+|~+)[ \t]*$/);

A fence inside a nested list item sits at the item's content indent, which is 4+ spaces (or a tab), and CommonMark and GitHub still render it as a code block. For example:

**Build.**
- [ ] Add the retry policy.
  - [ ] Config shape:

    ```yaml
    retry: 3
    ```

Run on unfixed main with Node 22.23.5. The input is the plan skeleton with the model filled in, which passes with 0 problems, plus the block above under Build.:

<Task as a verb phrase> (<PR id>)  boxes=29  files=3 build=3 …
1 PR sections, 1 problems
nested-fence.md:76: mid-sentence colon

retry: 3 is read as prose and fails the mid-sentence-colon rule. Box counts are also inflated, because - [ ] lines inside such a block count as boxes.

Fix

Accept any leading spaces or tabs on opening and closing fences (^ {0,3} → ^[ \t]*). Everything else is unchanged: fence character and length matching, and the backtick info-string rule.

Tests

The new tests are in check-plan.test.ts:

  • A fence at 4 spaces, 6 spaces or a tab inside a nested list item, whose body contains a heading, a colon sentence and a - [ ] line, is accepted. This fails on unfixed main (Expected: 0, Received: 1).
  • Prose after such a fence is still checked (mid-sentence colon, exit 1).

Unfixed vs patched, on the test file's valid plan plus each case (Node 22.23.5):

Case Unfixed Patched
valid plan only exit 0 exit 0
nested list item, 4-space fence exit 1, mid-sentence colon exit 0
nested list item, tab fence exit 1, mid-sentence colon exit 0
top-level fence at 3 spaces exit 0 exit 0
prose after a nested fence exit 1, mid-sentence colon exit 1, mid-sentence colon
unclosed 0-space fence, then bad prose exit 0 exit 0
0-space fence closed by a 4-space closer exit 0 exit 0
heading outside any fence after Close exit 1, not an appendix exit 1, not an appendix
unclosed indented fence, then bad prose exit 1, mid-sentence colon exit 0

The last row is the one intended change in behavior. An unclosed indented fence now runs to the end of the file, the same way an unclosed unindented fence already does (the row above it).

I also ran the checker before and after the change on all 314 tracked .md files under pstack/, dyl-stack/ and harness/. The output is identical for every one.

Checks (darwin arm64, Node 22.23.5, bun 1.3.13)

  • bun test watch-pr check-plan.test.ts: 63 pass, 0 fail (61 before, plus 2 new)
  • bun run typecheck: clean
  • node scripts/validate-plugins.mjs: "All plugins validated successfully."
  • node scripts/generate-pstack-harness-trees.mjs --check: "harness/pstack is up to date." (the mirror is regenerated in this PR)
  • node --test pstack/skills/*/scripts/test/*.test.ts: 340 tests, 269 pass, 70 skipped (no Java), 1 fail. This matches main exactly; the failure is the macOS relative-symlink launcher test from statechart: relative-symlink launcher test fails on macOS because /var is a symlink #1164.

🤖 Generated with Claude Code

…ecks

check-plan only recognized fences indented 0-3 spaces. A fence inside a
nested list item sits at the item's content indent (4+ spaces or a tab),
which CommonMark and GitHub still render as a code block, so the checker
read its contents as plan prose: style rules fired on the code and
`- [ ]` lines inside it were counted as boxes.

Accept any leading whitespace on opening and closing fences, and cover
both nested-fence plans and prose after them in the CLI tests. The
harness mirror is regenerated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant