Skip to content

Fix worktree audit paths - #49

Merged
caelaxie merged 3 commits into
mainfrom
fix/codex-worktree-audit-paths
Nov 18, 2026
Merged

caelaxie merged 3 commits into
mainfrom
fix/codex-worktree-audit-paths

Conversation

@caelaxie

@caelaxie caelaxie commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

The cleanup audit split worktree paths on whitespace. A checkout named feature branch could be read as feature, so a tracked edit there was reported clean.

The script now reads git worktree list --porcelain -z and passes each full path to git. This carried patch stays over the 2f87c85 pin until cursor/plugins ships its own fix for that split. On that sync, take upstream's script verbatim and remove the note in UPSTREAM.md.

No linked issue.

Open in Web Open in Cursor 

@caelaxie caelaxie left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change request (comment review, github blocks request-changes on own pr).

the bug is real, but it isn't a codex one. upstream cursor/plugins main (same as the 2f87c85 pin) still has awk '/^worktree /{print $2}', so every harness gets the truncated path. a port carries only what codex strictly needs; a harness-agnostic fix forks the script from upstream and every future sync has to re-merge it.

  • bar 1, minimum changes: land the nul-delimited path fix upstream in cursor/plugins pstack/skills/poteto-mode/scripts/worktree-audit.sh, then pick it up here in a normal sync. the only sanctioned codex divergence in this file stays the PSTACK_TRANSCRIPTS_DIR line.
  • if you want it carried here before upstream takes it, cut it to the path fix only (read -z, use the full path) and drop the unrelated rewrites: the reworded pr-state comment, mktemp -d + trap, the %q tab/newline escaping, and the stat/rg -F rewrite. record it in UPSTREAM.md as a temporary carried patch to drop on the next sync, rather than a new COMPATIBILITY.md that reads as a codex contract.
  • tests/test_worktree_audit.py + the ci step test upstream behavior, not codex install; they belong with the upstream fix.
  • linkage: no issue to close or ref. fine if none exists, but say so.

ci: install green on a1640ec. no blockers on proof.

[ "$wt" = "$main_wt" ] && continue
# Git lists the main worktree first. Keep the full path from each NUL-delimited field.
first=true
while IFS= read -r -d '' field; do

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

harness-agnostic fix: upstream has the same print $2 split. fix it in cursor/plugins, then sync. not a codex-required divergence.

# state. Origin when its CLI can read this repo's PRs, otherwise gh. Empty when
# neither can.
prs=$(mktemp)
audit_tmp=$(mktemp -d) || exit 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor unrelated to the path bug (mktemp -d + trap replaces upstream prs=$(mktemp) / rm -f). drop to stay verbatim.

trap 'rm -rf "$audit_tmp"' EXIT
git worktree list --porcelain -z > "$audit_tmp/worktrees" || exit 1

# Look up PR state once, using Origin when available and gh otherwise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewords the upstream comment. restore: # 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.

esac

# Keep one TSV row even for paths containing a tab or newline.
[[ $wt == *[$'\t\r\n']* ]] && printf -v wt '%q' "$wt"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tab/newline escaping is beyond the reported bug and beyond codex needs. drop.

recent=$([ "$last_ts" -gt 0 ] 2>/dev/null && [ $(( (now - last_ts) / 86400 )) -le 4 ] && echo yes || echo no)

case "$dirty" in wip:*) bucket=hold-wip ;; *)
case "$dirty" in unknown) bucket=review ;; wip:*) bucket=hold-wip ;; *)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new unknown -> review bucket changes upstream classification behavior. upstream it, don't fork it here.

Comment thread COMPATIBILITY.md Outdated
@@ -0,0 +1,7 @@
# Codex worktree audit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this documents a generic upstream bug, not a codex compatibility fact. the transcripts note already lives in the adapter/UPSTREAM.md. drop this file with the fix moved upstream, or note a temporary carried patch in UPSTREAM.md.

The audit passes each full path from git worktree list --porcelain -z. UPSTREAM.md records that carried patch until cursor/plugins ships its own fix for the split.

Co-authored-by: Kaitian Xie <[email protected]>
@cursor

cursor Bot commented Nov 18, 2026

Copy link
Copy Markdown

trimmed to the nul path read. manual repro detected the tracked edit in feature branch as wip:1 hold-wip, and feature stayed clean. bash -n and shellcheck passed. harness installed 61 skills and the installed .agents matched the checkout byte for byte. sha 41c8f82.

@cursor cursor Bot changed the title Fix worktree audit paths and document Codex differences Fix worktree audit paths Nov 18, 2026

@caelaxie caelaxie left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change request on 41c8f82 (comment review, github blocks request-changes on own pr).

the script change is the requested minimum. versus main it only switches git worktree list --porcelain / awk '{print $2}' to --porcelain -z and the full worktree field, including main_wt. versus upstream 2f87c854 that is the only new delta; the existing PSTACK_TRANSCRIPTS_DIR line is unchanged. the earlier mktemp/trap, pr-state reword, %q escaping, unknown o review bucket, python test, ci step, and COMPATIBILITY.md are gone. the first UPSTREAM.md paragraph correctly records a temporary carried patch to drop on the next sync. install ci is green on this head, and proof comment 6976919037 matches this sha.

one leftover: the extra PSTACK_TRANSCRIPTS_DIR sentence is not part of this path fix. that harness fact already lives in .agents/skills/poteto-mode/references/codex.md. delete that sentence. when you tell a future sync to take upstream's script, keep the existing PSTACK_TRANSCRIPTS_DIR line rather than restating it here or taking the file truly verbatim.

no merge until that note is removed.

Comment thread UPSTREAM.md Outdated

`.agents/skills/poteto-mode/scripts/worktree-audit.sh` carries a patch over the pin. The patch reads worktree paths with `git worktree list --porcelain -z` and passes each full path to git. The pinned script splits those paths on whitespace. Keep the patch until cursor/plugins ships its own fix for that split. On that sync, take upstream's script verbatim and remove the patch and this note.

The script reads Codex transcripts from `PSTACK_TRANSCRIPTS_DIR` instead of `~/.cursor/projects/<slug>/agent-transcripts`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sentence is not tied to the path-split patch. the adapter already says worktree-audit.sh may use PSTACK_TRANSCRIPTS_DIR and otherwise omits chat recency. delete this line.

in the paragraph above, don't say "take upstream's script verbatim" in a way that would drop the existing PSTACK_TRANSCRIPTS_DIR adaptation. keep that one sanctioned line, take the rest from upstream, and remove the carried-path note when the pin includes the nul-delimited fix.

The Codex transcript directory is already described in the adapter.

Co-authored-by: Kaitian Xie <[email protected]>
@cursor

cursor Bot commented Nov 18, 2026

Copy link
Copy Markdown

dropped the transcripts sentence from upstream.md. harness: marketplace add and plugin add pstack@codex-pstack, 61 skills, installed .agents matched the checkout byte for byte. sha 8744663.

@caelaxie caelaxie left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass on 8744663.

the only delta since review 5955567927 at 41c8f82 is the removal of the extra PSTACK_TRANSCRIPTS_DIR sentence from UPSTREAM.md. the carried-patch paragraph and worktree-audit.sh are unchanged. versus current main the diff is still +7/-2: the nul-delimited path read (including main_wt) and the temporary carried-patch note. the Benny skip line is untouched.

install ci is green on this exact head (https://github.com/pstack-ports/codex-pstack/actions/runs/44293809743/job/134765510850). proof comment 6977083001 matches this sha: marketplace add, plugin add, 61 skills, installed .agents byte-identical with the checkout. body says no linked issue, which is correct. not a draft.

a later sync should keep the existing PSTACK_TRANSCRIPTS_DIR line from the adapter when it takes upstream, then drop the carried-path note once the pin includes the nul-delimited fix.

squash-merging.

@caelaxie
caelaxie merged commit 6084ab9 into main Nov 18, 2026
1 check passed
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.

2 participants