diff --git a/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs b/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs index c3ddc39899..2f3f4118ef 100755 --- a/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs +++ b/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs @@ -46,12 +46,12 @@ if (raw[0] === "---") { const lines = []; let fence = null; const openingFence = (text) => { - const match = text.match(/^ {0,3}(`{3,}|~{3,})(.*)$/); + const match = text.match(/^[ \t]*(`{3,}|~{3,})(.*)$/); if (!match || (match[1][0] === "`" && match[2].includes("`"))) return null; return { char: match[1][0], length: match[1].length }; }; const closingFence = (text, opening) => { - const match = text.match(/^ {0,3}(`+|~+)[ \t]*$/); + const match = text.match(/^[ \t]*(`+|~+)[ \t]*$/); return Boolean( match && match[1][0] === opening.char && diff --git a/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.test.ts b/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.test.ts index cd1debfa31..8769c59cee 100644 --- a/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.test.ts +++ b/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.test.ts @@ -69,6 +69,19 @@ test("accepts ordinary, indented, and longer closing fences", () => { runPlan("```markdown\n## Example only\n````\n", 0); }); +test("treats fences inside nested list items as code", () => { + const body = "## Example only\nThis prose has a mid-sentence colon: inside code\n- [ ] Not a box.\n"; + for (const indent of [" ", " ", "\t"]) { + const indented = body.replace(/^/gm, indent); + runPlan(`- [ ] Outer.\n - [ ] Inner.\n\n${indent}\`\`\`yaml\n${indented}${indent}\`\`\`\n`, 0); + } +}); + +test("checks prose after a fence inside a nested list item", () => { + const result = runPlan("- [ ] Outer.\n - [ ] Inner.\n\n ```yaml\n retry: 3\n ```\nThis prose has a mid-sentence colon: bad.\n", 1); + expect(result.stderr).toContain("mid-sentence colon"); +}); + test("accepts nested backticks and tilde info strings", () => { runPlan("````markdown\n```markdown\n## Example only\n```\n````\n", 0); runPlan("~~~markdown `info`\n## Example only\n ~~~\n", 0); diff --git a/pstack/skills/poteto-mode/scripts/check-plan.mjs b/pstack/skills/poteto-mode/scripts/check-plan.mjs index c3ddc39899..2f3f4118ef 100755 --- a/pstack/skills/poteto-mode/scripts/check-plan.mjs +++ b/pstack/skills/poteto-mode/scripts/check-plan.mjs @@ -46,12 +46,12 @@ if (raw[0] === "---") { const lines = []; let fence = null; const openingFence = (text) => { - const match = text.match(/^ {0,3}(`{3,}|~{3,})(.*)$/); + const match = text.match(/^[ \t]*(`{3,}|~{3,})(.*)$/); if (!match || (match[1][0] === "`" && match[2].includes("`"))) return null; return { char: match[1][0], length: match[1].length }; }; const closingFence = (text, opening) => { - const match = text.match(/^ {0,3}(`+|~+)[ \t]*$/); + const match = text.match(/^[ \t]*(`+|~+)[ \t]*$/); return Boolean( match && match[1][0] === opening.char && diff --git a/pstack/skills/poteto-mode/scripts/check-plan.test.ts b/pstack/skills/poteto-mode/scripts/check-plan.test.ts index cd1debfa31..8769c59cee 100644 --- a/pstack/skills/poteto-mode/scripts/check-plan.test.ts +++ b/pstack/skills/poteto-mode/scripts/check-plan.test.ts @@ -69,6 +69,19 @@ test("accepts ordinary, indented, and longer closing fences", () => { runPlan("```markdown\n## Example only\n````\n", 0); }); +test("treats fences inside nested list items as code", () => { + const body = "## Example only\nThis prose has a mid-sentence colon: inside code\n- [ ] Not a box.\n"; + for (const indent of [" ", " ", "\t"]) { + const indented = body.replace(/^/gm, indent); + runPlan(`- [ ] Outer.\n - [ ] Inner.\n\n${indent}\`\`\`yaml\n${indented}${indent}\`\`\`\n`, 0); + } +}); + +test("checks prose after a fence inside a nested list item", () => { + const result = runPlan("- [ ] Outer.\n - [ ] Inner.\n\n ```yaml\n retry: 3\n ```\nThis prose has a mid-sentence colon: bad.\n", 1); + expect(result.stderr).toContain("mid-sentence colon"); +}); + test("accepts nested backticks and tilde info strings", () => { runPlan("````markdown\n```markdown\n## Example only\n```\n````\n", 0); runPlan("~~~markdown `info`\n## Example only\n ~~~\n", 0);