Skip to content

Cursor plugin specification and official plugins

TypeScript

fix(pstack): recognize matching inline code delimiters (#803)

lauren86c2448db179
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 c8626766..c3ddc398 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
@@ -72,7 +72,7 @@ for (let i = start; i < raw.length; i++) {
lines.push({ n, text, code });
if (code) continue;
const prose = text
- .replace(/`[^`]*`/g, "`")
+ .replace(/(?<!`)(`+)(?!`)(.*?)(?<!`)\1(?!`)/g, "`")
.replace(/!\[[^\]]*\]\([^)]*\)/g, "")
.replace(/\]\([^)]*\)/g, "]");
if (/[\u2013\u2014]/.test(prose)) fail(n, "long dash");
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 fd966c2b..cd1debfa 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
@@ -94,3 +94,17 @@ test("rejects backtick info strings containing a backtick", () => {
const result = runPlan("```markdown `invalid`\n## Example only\n```\n", 1);
expect(result.stderr).toContain('"## Example only" after Close the program is not an appendix');
});
+
+test("ignores prose punctuation inside matching multi-backtick code spans", () => {
+ for (const count of [2, 3, 4]) {
+ const delimiter = "`".repeat(count);
+ runPlan(`Use ${delimiter}echo \`x\`: “quoted” — example${delimiter}.\n`, 0);
+ }
+});
+
+test("checks prose following a multi-backtick span and unmatched delimiters", () => {
+ const outside = runPlan("Use ``echo `x`: y``. Bad: prose.\n", 1);
+ expect(outside.stderr).toContain("mid-sentence colon");
+ const unmatched = runPlan("Use ``unclosed: bad` here.\n", 1);
+ expect(unmatched.stderr).toContain("mid-sentence colon");
+});
diff --git a/pstack/skills/poteto-mode/scripts/check-plan.mjs b/pstack/skills/poteto-mode/scripts/check-plan.mjs
index c8626766..c3ddc398 100755
--- a/pstack/skills/poteto-mode/scripts/check-plan.mjs
+++ b/pstack/skills/poteto-mode/scripts/check-plan.mjs
@@ -72,7 +72,7 @@ for (let i = start; i < raw.length; i++) {
lines.push({ n, text, code });
if (code) continue;
const prose = text
- .replace(/`[^`]*`/g, "`")
+ .replace(/(?<!`)(`+)(?!`)(.*?)(?<!`)\1(?!`)/g, "`")
.replace(/!\[[^\]]*\]\([^)]*\)/g, "")
.replace(/\]\([^)]*\)/g, "]");
if (/[\u2013\u2014]/.test(prose)) fail(n, "long dash");
diff --git a/pstack/skills/poteto-mode/scripts/check-plan.test.ts b/pstack/skills/poteto-mode/scripts/check-plan.test.ts
index fd966c2b..cd1debfa 100644
--- a/pstack/skills/poteto-mode/scripts/check-plan.test.ts
+++ b/pstack/skills/poteto-mode/scripts/check-plan.test.ts
@@ -94,3 +94,17 @@ test("rejects backtick info strings containing a backtick", () => {
const result = runPlan("```markdown `invalid`\n## Example only\n```\n", 1);
expect(result.stderr).toContain('"## Example only" after Close the program is not an appendix');
});
+
+test("ignores prose punctuation inside matching multi-backtick code spans", () => {
+ for (const count of [2, 3, 4]) {
+ const delimiter = "`".repeat(count);
+ runPlan(`Use ${delimiter}echo \`x\`: “quoted” — example${delimiter}.\n`, 0);
+ }
+});
+
+test("checks prose following a multi-backtick span and unmatched delimiters", () => {
+ const outside = runPlan("Use ``echo `x`: y``. Bad: prose.\n", 1);
+ expect(outside.stderr).toContain("mid-sentence colon");
+ const unmatched = runPlan("Use ``unclosed: bad` here.\n", 1);
+ expect(unmatched.stderr).toContain("mid-sentence colon");
+});