From 56b28f9781bf9cc65813ad49df324c1365a1321c Mon Sep 17 00:00:00 2001 From: Chao Chen <209239467+surlymochan@users.noreply.github.com> Date: Sun, 18 Oct 2026 12:42:33 +0800 Subject: [PATCH 1/2] fix(pstack): read transcript mtimes with GNU stat and date in worktree-audit (cherry picked from commit a617232f249ba6ec135cc603aa19adab40fb1fa4) --- .../skills/poteto-mode/scripts/worktree-audit.sh | 12 ++++++++++-- pstack/skills/poteto-mode/scripts/worktree-audit.sh | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/harness/pstack/claude-code/skills/poteto-mode/scripts/worktree-audit.sh b/harness/pstack/claude-code/skills/poteto-mode/scripts/worktree-audit.sh index 743c4e925..47e08919d 100755 --- a/harness/pstack/claude-code/skills/poteto-mode/scripts/worktree-audit.sh +++ b/harness/pstack/claude-code/skills/poteto-mode/scripts/worktree-audit.sh @@ -47,6 +47,14 @@ origin/*) git fetch origin "+refs/heads/${base#origin/}:refs/remotes/$base" --qu esac git rev-parse --verify --quiet "$base^{commit}" >/dev/null 2>&1 || { echo "error: base ref not found: $base" >&2; exit 1; } +# GNU coreutils (Linux, Homebrew gnubin) reads `stat -f` as file system status +# and `date -r` as a file, so pick the stat and date flags once. +if stat -c %Y / >/dev/null 2>&1; then + stat_fmt=(-c '%Y %n'); fmt_day() { date -d "@$1" '+%Y-%m-%d'; } +else + stat_fmt=(-f '%m %N'); fmt_day() { date -r "$1" '+%Y-%m-%d'; } +fi + # PR state by branch, fetched once as [{number, state, head}] with a lowercase # state. Origin when its CLI can read this repo's PRs, otherwise gh. Empty when # neither can. @@ -105,9 +113,9 @@ git worktree list --porcelain | awk '/^worktree /{print $2}' | while read -r wt; last="-"; last_ts=0 if [ -d "$transcripts" ]; then f=$(rg -l -e "${wt}/" -e "${wt}\"" "$transcripts" 2>/dev/null \ - | xargs stat -f '%m %N' 2>/dev/null | sort -rn | head -1) + | xargs stat "${stat_fmt[@]}" 2>/dev/null | sort -rn | head -1) if [ -n "$f" ]; then last_ts=$(echo "$f" | awk '{print $1}') - last=$(date -r "$last_ts" '+%Y-%m-%d' 2>/dev/null); fi + last=$(fmt_day "$last_ts" 2>/dev/null); fi fi recent=$([ "$last_ts" -gt 0 ] 2>/dev/null && [ $(( (now - last_ts) / 86400 )) -le 4 ] && echo yes || echo no) diff --git a/pstack/skills/poteto-mode/scripts/worktree-audit.sh b/pstack/skills/poteto-mode/scripts/worktree-audit.sh index 743c4e925..47e08919d 100755 --- a/pstack/skills/poteto-mode/scripts/worktree-audit.sh +++ b/pstack/skills/poteto-mode/scripts/worktree-audit.sh @@ -47,6 +47,14 @@ origin/*) git fetch origin "+refs/heads/${base#origin/}:refs/remotes/$base" --qu esac git rev-parse --verify --quiet "$base^{commit}" >/dev/null 2>&1 || { echo "error: base ref not found: $base" >&2; exit 1; } +# GNU coreutils (Linux, Homebrew gnubin) reads `stat -f` as file system status +# and `date -r` as a file, so pick the stat and date flags once. +if stat -c %Y / >/dev/null 2>&1; then + stat_fmt=(-c '%Y %n'); fmt_day() { date -d "@$1" '+%Y-%m-%d'; } +else + stat_fmt=(-f '%m %N'); fmt_day() { date -r "$1" '+%Y-%m-%d'; } +fi + # PR state by branch, fetched once as [{number, state, head}] with a lowercase # state. Origin when its CLI can read this repo's PRs, otherwise gh. Empty when # neither can. @@ -105,9 +113,9 @@ git worktree list --porcelain | awk '/^worktree /{print $2}' | while read -r wt; last="-"; last_ts=0 if [ -d "$transcripts" ]; then f=$(rg -l -e "${wt}/" -e "${wt}\"" "$transcripts" 2>/dev/null \ - | xargs stat -f '%m %N' 2>/dev/null | sort -rn | head -1) + | xargs stat "${stat_fmt[@]}" 2>/dev/null | sort -rn | head -1) if [ -n "$f" ]; then last_ts=$(echo "$f" | awk '{print $1}') - last=$(date -r "$last_ts" '+%Y-%m-%d' 2>/dev/null); fi + last=$(fmt_day "$last_ts" 2>/dev/null); fi fi recent=$([ "$last_ts" -gt 0 ] 2>/dev/null && [ $(( (now - last_ts) / 86400 )) -le 4 ] && echo yes || echo no) From a5344860df7920fa9aeed494ad3404e27d697d20 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Fri, 16 Oct 2026 17:34:30 -0400 Subject: [PATCH 2/2] fix(pstack): recognize matching inline code delimiters Signed-off-by: Rudy Celekli (cherry picked from commit d748979368488a87b4a7cbd369f178202d23acf0) --- .../skills/poteto-mode/scripts/check-plan.mjs | 2 +- .../skills/poteto-mode/scripts/check-plan.test.ts | 14 ++++++++++++++ pstack/skills/poteto-mode/scripts/check-plan.mjs | 2 +- .../skills/poteto-mode/scripts/check-plan.test.ts | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) 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 c8626766c..c3ddc3989 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(/(? { 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 c8626766c..c3ddc3989 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(/(? { 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"); +});