Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "t3-pstack",
"source": "./plugins/pstack",
"description": "pstack for T3 Code: rigorous agent workflows whose panels and fan-outs run across model families through T3. Original pstack by Lauren Tan (poteto).",
"version": "2.2.7"
"version": "2.2.8"
}
]
}
16 changes: 16 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

This file is the release changelog, with one `## <version> - <title>` entry per release, newest first. The Cursor-to-T3 rewrite rules live in [`tools/substitutions.json`](tools/substitutions.json), and the [sync boundary](CONTRIBUTING.md#the-sync-boundary) in `CONTRIBUTING.md` defines how a change to upstream's skill content is declared.

## 2.2.8 - The worktree audit reads git refs by their full name and holds a branch's open PR

The worktree audit marks a worktree `safe` to prune when its HEAD is merged into the base or its branch has a PR that is not open. Three lookups could read unmerged or open work as safe.

**A local ref named `origin/main` decided the merge check.** The `MERGED` column ran `git merge-base --is-ancestor` against the base by its short name, such as `origin/main`, `origin/master`, or a `-b origin/<branch>`. Git resolves a short name through `refs/tags/` and `refs/heads/` before `refs/remotes/`, so a local branch or tag named `origin/main` won over the remote-tracking ref. In a throwaway repository with one unpushed commit on a worktree branch `topic`, 2.2.7 read that worktree `no` and `review`. After `git branch origin/main topic`, or `git tag origin/main topic`, it read `YES` and `safe`, with or without `-b origin/main`, while `git merge-base --is-ancestor topic refs/remotes/origin/main` said no. A clone sets `origin/HEAD`, and for a shadowed name `git symbolic-ref --short` printed `remotes/origin/main`, which these refs do not shadow. So the default base was exposed when `origin/HEAD` was missing, and `-b origin/<branch>` always was, as was `-b upstream/main` with a local ref named `upstream/main`. The audit now reads a base that starts with a remote's name by its `refs/remotes/` name, and the same repository reads `no` and `review`. A `-b` that names a local ref, such as `-b main`, works as before. The `REMOTE` column made the same lookup for `origin/<branch>`, so a local branch named `origin/topic` at the worktree's HEAD read `pushed` for a commit that was never pushed. It now reads `ahead1`. `REMOTE` does not change the bucket.

**A newer closed PR hid an older open one.** The audit reads PR state once from `gh pr list --state all`, or from Origin's CLI when it can, and both list newest first. For each branch it took the first record, so a newer closed or merged PR for the same branch hid an older open one, as when one branch has PRs against two bases. With a stub `gh` on `PATH` that lists `#12` closed and then `#11` open for `topic`, 2.2.7 printed `#12/closed` and bucketed the worktree `safe`. The audit now takes the first record whose state is `open` or `draft`, Origin's state for a draft PR, which the bucket already holds. Without one it keeps the first record, as before. The same repository prints `#11/open` and `hold-open-pr`, through `gh` and through a stub Origin CLI alike.

**A tag named like the branch hid its PR.** The audit named each worktree's branch with `git symbolic-ref --short HEAD`, which prints `heads/topic` when a tag `topic` also exists. No PR record has that head, so a merged branch with an open PR read `-` and `safe`. It now strips `refs/heads/` from the full name and reads `#11/open` and `hold-open-pr`.

Ethan found the first two in the JavaScript audit of Michael Denyer's pstack-claude and fixed them there in [#423](https://github.com/michael-denyer/pstack-claude/pull/423) and [#424](https://github.com/michael-denyer/pstack-claude/pull/424). This release makes the same fixes in the port's bash script, which `tools/forks.json` declares as a fork of Lauren's, and a review of this change found the third and the `upstream/main` case. Lauren's script has all three lookups, at the pin and at cursor/plugins `main` as of `6b03002`. `tests/worktree-audit.test.mjs` adds seven tests. A local branch and a local tag named `origin/main` and `upstream/main` each leave unmerged work `no` and `review`, with the default base, with `-b origin/main`, with `-b upstream/main`, and with `origin/HEAD` set. A local branch named `origin/topic` leaves an unpushed commit `ahead1`. An older open PR from `gh` and an older draft PR from Origin each hold their worktree behind a newer closed PR, beside a branch whose newest PR is merged and stays `safe`. A tag named like a merged branch leaves its open PR holding the worktree. `-b main` checks against the local branch. All but the last fail on 2.2.7.

The audit still asks for at most 1,000 PRs, so an open PR older than the author's 1,000 newest in the repository goes unread.

This release syncs nothing from Lauren's pstack, so all three components stay pinned at cursor/plugins `c742dd6`. At that pin each component's dry run reports no undeclared fork and no substitution that matches nothing. Neither hooks file changes. This is a patch release, and no setting or workflow has to change. On Codex, run `npx -y github:chhoumann/t3-pstack update` after it, as after every release.

## 2.2.7 - An Autopilot-full owner's brief says it is not a leaf, so the owner starts its own reviewers

2.2.6 made each Autopilot-full PR owner a `delegate_task` child, and it made every `delegate_task` child a leaf, which does the work itself and starts no subagent unless its brief names one. Step 2 said only that the owner's brief "lets the owner delegate as the playbooks say", which names no subagent. In a run of 2.2.6 on this Mac's T3, the root read the leaf rule and wrote "You are a leaf. Do all the work yourself and start no subagents." into the owner's brief. The owner then ran `/no-comments` in its own thread where that skill starts Comment Sicko, and skipped show-me-your-work's cross-model review of its trail. Both times its reason was that it starts no subagents.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ npx -y github:chhoumann/t3-pstack update
npx -y github:chhoumann/t3-pstack doctor
```

`npx -y github:chhoumann/t3-pstack` runs the installer from the latest commit on `main`. Each Claude Code home's marketplace auto-updates from `main` too, and each Codex home's marketplace stays on the release tag the installer pinned. To run one release's installer, name its tag, as in `npx -y github:chhoumann/t3-pstack#v2.2.7 doctor`.
`npx -y github:chhoumann/t3-pstack` runs the installer from the latest commit on `main`. Each Claude Code home's marketplace auto-updates from `main` too, and each Codex home's marketplace stays on the release tag the installer pinned. To run one release's installer, name its tag, as in `npx -y github:chhoumann/t3-pstack#v2.2.8 doctor`.

`install` and `update` are the same command, and a second run changes nothing. With Node 20 or later, it installs or updates the `t3-pstack@t3-pstack` plugin in every Claude Code and Codex config home T3 can run: `~/.claude` and `~/.codex`, `$CLAUDE_CONFIG_DIR` and `$CODEX_HOME`, and the home of each `claudeAgent` and `codex` instance in T3's settings, disabled ones included. Name any other home with `--claude-home <dir>` or `--codex-home <dir>`. Each home's `t3-pstack` marketplace must come from `chhoumann/t3-pstack`, or from `--source <owner/repo|git URL|dir>` on the same run, and a home whose marketplace has another source is left as it is. A run never switches a home's source, so a home already on `chhoumann/t3-pstack` stays on it under another `--source`, and `doctor` warns and prints the commands that move it. A local directory needs a path such as `./t3-pstack`, since `owner/repo` always means GitHub. On Codex it also trusts t3-pstack's session-start hook, once its hooks file is the one this release pins. Codex runs a plugin's hook only once it is trusted, and T3's Codex sessions never ask, so without this step the hook never runs. Codex 0.164 and later tie that trust to every file in the installed plugin, so each release turns the hook off until the installer trusts it again. So the installer pins each Codex home's `t3-pstack` marketplace to the release's tag, such as `v2.2.7`, and Codex's own auto-upgrade leaves that tag where it is. A release reaches a Codex home only when `update` runs, and that run trusts the hook again. A local directory has no tag, so a marketplace from one stays unpinned. Run `update` after each release.
`install` and `update` are the same command, and a second run changes nothing. With Node 20 or later, it installs or updates the `t3-pstack@t3-pstack` plugin in every Claude Code and Codex config home T3 can run: `~/.claude` and `~/.codex`, `$CLAUDE_CONFIG_DIR` and `$CODEX_HOME`, and the home of each `claudeAgent` and `codex` instance in T3's settings, disabled ones included. Name any other home with `--claude-home <dir>` or `--codex-home <dir>`. Each home's `t3-pstack` marketplace must come from `chhoumann/t3-pstack`, or from `--source <owner/repo|git URL|dir>` on the same run, and a home whose marketplace has another source is left as it is. A run never switches a home's source, so a home already on `chhoumann/t3-pstack` stays on it under another `--source`, and `doctor` warns and prints the commands that move it. A local directory needs a path such as `./t3-pstack`, since `owner/repo` always means GitHub. On Codex it also trusts t3-pstack's session-start hook, once its hooks file is the one this release pins. Codex runs a plugin's hook only once it is trusted, and T3's Codex sessions never ask, so without this step the hook never runs. Codex 0.164 and later tie that trust to every file in the installed plugin, so each release turns the hook off until the installer trusts it again. So the installer pins each Codex home's `t3-pstack` marketplace to the release's tag, such as `v2.2.8`, and Codex's own auto-upgrade leaves that tag where it is. A release reaches a Codex home only when `update` runs, and that run trusts the hook again. A local directory has no tag, so a marketplace from one stays unpinned. Run `update` after each release.

`doctor` reports on the same homes and changes nothing itself: each marketplace's source, each Codex marketplace's pin, the installed version, whether its files are all there, whether it is enabled, the Codex hook's trust, Claude Code records that pin an old version, plain copies of the plugin's skills, and the model sheet. It exits 1 on any problem and prints a fix for each.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.7
2.2.8
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "t3-pstack",
"private": true,
"version": "2.2.7",
"version": "2.2.8",
"description": "The installer and development tooling for t3-pstack, Lauren Tan's pstack rewritten in place for T3 Code. The plugin itself lives in plugins/pstack.",
"author": {
"name": "Christian Bager Bach Houmann",
Expand Down
2 changes: 1 addition & 1 deletion plugins/pstack/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "t3-pstack",
"displayName": "t3-pstack (pstack for T3 Code)",
"version": "2.2.7",
"version": "2.2.8",
"description": "pstack for T3 Code: Lauren Tan's pstack with its Cursor mechanics rewritten in place for T3, so subagents, panels, schedules, and PR watches dispatch through T3's orchestration and panels mix Claude, GPT, and Grok.",
"author": {
"name": "Christian Bager Bach Houmann",
Expand Down
2 changes: 1 addition & 1 deletion plugins/pstack/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "t3-pstack",
"version": "2.2.7",
"version": "2.2.8",
"description": "pstack for T3 Code on a Codex host: Lauren Tan's pstack with its Cursor mechanics rewritten in place for T3, so subagents, panels, schedules, and PR watches dispatch through T3's orchestration.",
"author": {
"name": "Christian Bager Bach Houmann",
Expand Down
30 changes: 21 additions & 9 deletions plugins/pstack/skills/poteto-mode/scripts/worktree-audit.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
# Worktree prune audit, read-only unless --fetch is given. Classifies every git
# worktree by size, merge state, uncommitted work, ignored files outside build
Expand Down Expand Up @@ -39,8 +39,9 @@
main_wt=$(git worktree list --porcelain | awk '/^worktree /{print substr($0, 10); exit}')

if [ -z "$base" ]; then
for cand in "$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null)" origin/main origin/master; do
[ -n "$cand" ] && git rev-parse --verify --quiet "$cand^{commit}" >/dev/null && { base="$cand"; break; }
origin_head=$(git symbolic-ref --quiet refs/remotes/origin/HEAD 2>/dev/null)
for cand in "${origin_head#refs/remotes/}" origin/main origin/master; do
[ -n "$cand" ] && git rev-parse --verify --quiet "refs/remotes/$cand^{commit}" >/dev/null && { base="$cand"; break; }
done
[ -z "$base" ] && { echo "error: no base ref (origin/HEAD, origin/main, origin/master all missing); pass -b <ref>" >&2; exit 1; }
echo "warn: no -b given; MERGED checks against $base" >&2
Expand All @@ -55,7 +56,14 @@
|| echo "warn: could not fetch $base; merged column may be stale" >&2 ;;
esac
fi
git rev-parse --verify --quiet "$base^{commit}" >/dev/null 2>&1 \
# A local branch or tag named origin/main wins git's shorthand lookup over
# refs/remotes/origin/main, so a base under a remote's name is read by its
# full name.
base_ref="$base"
while IFS= read -r name; do
case "$base" in "$name"/*) base_ref="refs/remotes/$base" ;; esac
done < <(git remote)
git rev-parse --verify --quiet "$base_ref^{commit}" >/dev/null 2>&1 \
|| { echo "error: base ref not found: $base; --fetch fetches an origin/* base" >&2; exit 1; }

disposable='(\.build|\.cache|\.dart_tool|\.DS_Store|\.gradle|\.lake|\.lycheecache|\.mypy_cache|\.next|\.nuxt'
Expand Down Expand Up @@ -106,7 +114,7 @@

# Squash-merged branches are not ancestors of the base, so PR state is the
# real signal; merge-base only catches fast-forward/rebase merges.
git merge-base --is-ancestor "$head" "$base" 2>/dev/null && merged=YES || merged=no
git merge-base --is-ancestor "$head" "$base_ref" 2>/dev/null && merged=YES || merged=no

# `git worktree remove` deletes ignored files without asking, and a .env or
# .claude/settings.local.json may exist nowhere else. An explicit
Expand All @@ -131,16 +139,20 @@
[ "$reflog_only" != 0 ] && dirty="${dirty:+$dirty,}reflog:$reflog_only"
[ -z "$dirty" ] && dirty=clean

branch=$(git -C "$wt" symbolic-ref --quiet --short HEAD 2>/dev/null || echo "")
branch=$(git -C "$wt" symbolic-ref --quiet HEAD 2>/dev/null || echo "")
branch=${branch#refs/heads/}
if [ -z "$branch" ]; then remote=detached
elif git -C "$wt" show-ref --verify --quiet "refs/remotes/origin/$branch"; then
[ "$(git -C "$wt" rev-parse "origin/$branch" 2>/dev/null)" = "$head" ] \
[ "$(git -C "$wt" rev-parse "refs/remotes/origin/$branch" 2>/dev/null)" = "$head" ] \
&& remote=pushed \
|| remote="ahead$(git -C "$wt" rev-list --count "origin/$branch..HEAD" 2>/dev/null)"
|| remote="ahead$(git -C "$wt" rev-list --count "refs/remotes/origin/$branch..HEAD" 2>/dev/null)"
else remote=no-remote; fi

pr=$([ -n "$branch" ] && jq -r --arg b "$branch" \
'.[] | select(.head==$b) | "#\(.number)/\(.state)"' "$prs" 2>/dev/null | head -1)
# PRs come newest first, so a newer closed or merged PR for the branch
# would hide an older one that is still open. An open record wins.
pr=$([ -n "$branch" ] && jq -r --arg b "$branch" '[.[] | select(.head==$b)]
| (map(select(.state=="open" or .state=="draft")) + .)[0] // empty
| "#\(.number)/\(.state)"' "$prs" 2>/dev/null)
[ -z "$pr" ] && pr="-"

# Most recent chat whose transcript operated in this worktree. Match path
Expand Down
80 changes: 79 additions & 1 deletion tests/worktree-audit.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function runAudit({ root, repo, bin }, ...args) {
.map((line) => line.split("\t"))
.map((cells) => [
cells[8].split("/").at(-1),
{ merged: cells[2], dirty: cells[3], pr: cells[5], lastChat: cells[6], bucket: cells[7] },
{ merged: cells[2], dirty: cells[3], remote: cells[4], pr: cells[5], lastChat: cells[6], bucket: cells[7] },
]),
);
}
Expand Down Expand Up @@ -115,6 +115,84 @@ printf '%s' '[{"number":7,"state":"MERGED","headRefName":"shipped"},{"number":8,
});
});

// gh and Origin both list a branch's PRs newest first, so a newer closed or
// merged PR comes before an older one that is still open. gh reports a draft
// as OPEN, and Origin reports it as draft.
for (const [cli, open] of [["gh", "open"], ["origin", "draft"]]) {
test(`an older ${open} PR from ${cli} holds its worktree when a newer closed PR comes first`, () => {
const fixture = createFixture();
for (const branch of ["reopened", "superseded"]) commit(addWorktree(fixture, branch), branch);
const records = [
[14, "closed", "reopened"],
[13, "merged", "superseded"],
[12, open, "reopened"],
[11, "closed", "superseded"],
].map(([number, state, head]) =>
cli === "gh"
? { number, state: state.toUpperCase(), headRefName: head }
: { number, status: state, headRef: head },
);
writeFileSync(join(fixture.bin, cli), `#!/bin/sh\nprintf '%s' '${JSON.stringify(records)}'\n`);
chmodSync(join(fixture.bin, cli), 0o755);
const rows = runAudit(fixture);
expect([rows.reopened.pr, rows.reopened.bucket]).toEqual([`#12/${open}`, "hold-open-pr"]);
expect([rows.superseded.pr, rows.superseded.bucket]).toEqual(["#13/merged", "safe"]);
});
}

test("a tag named like the branch does not hide the branch's open PR", () => {
const fixture = createFixture();
commit(addWorktree(fixture, "topic"), "landed");
git(fixture.repo, "merge", "-q", "--ff-only", "topic");
git(fixture.repo, "push", "-q", "origin", "main");
git(fixture.repo, "tag", "topic", "topic");
writeFileSync(
join(fixture.bin, "gh"),
`#!/bin/sh\nprintf '%s' '[{"number":11,"state":"OPEN","headRefName":"topic"}]'\n`,
);
chmodSync(join(fixture.bin, "gh"), 0o755);
const { topic } = runAudit(fixture);
expect([topic.merged, topic.pr, topic.bucket]).toEqual(["YES", "#11/open", "hold-open-pr"]);
});

for (const kind of ["branch", "tag"]) {
test(`a local ${kind} named like a remote-tracking base cannot make unmerged work read as merged`, () => {
const fixture = createFixture();
commit(addWorktree(fixture, "topic"), "unmerged");
git(fixture.repo, "remote", "add", "upstream", join(fixture.root, "remote.git"));
git(fixture.repo, "fetch", "-q", "upstream");
for (const name of ["origin/main", "upstream/main"]) git(fixture.repo, kind, name, "topic");
for (const args of [[], ["-b", "origin/main"], ["-b", "upstream/main"]]) {
const { topic } = runAudit(fixture, ...args);
expect([topic.merged, topic.bucket]).toEqual(["no", "review"]);
}
for (const target of ["refs/remotes/origin/main", "refs/remotes/upstream/main"]) {
git(fixture.repo, "symbolic-ref", "refs/remotes/origin/HEAD", target);
const { topic } = runAudit(fixture);
expect([topic.merged, topic.bucket]).toEqual(["no", "review"]);
}
});
}

test("a local branch named origin/<branch> cannot make an unpushed commit read as pushed", () => {
const fixture = createFixture();
const topic = addWorktree(fixture, "topic");
commit(topic, "pushed");
git(topic, "push", "-q", "origin", "topic");
commit(topic, "local only");
git(fixture.repo, "branch", "origin/topic", "topic");
expect(runAudit(fixture).topic.remote).toBe("ahead1");
});

test("-b takes a local branch as the base", () => {
const fixture = createFixture();
commit(addWorktree(fixture, "landed"), "landed");
commit(addWorktree(fixture, "unmerged"), "unmerged");
git(fixture.repo, "merge", "-q", "--ff-only", "landed");
const rows = runAudit(fixture, "-b", "main");
expect([rows.landed.merged, rows.unmerged.merged]).toEqual(["YES", "no"]);
});

test("lists every worktree when the checkout and its worktrees sit under a path with spaces", () => {
const fixture = createFixture("worktree audit ");
writeFileSync(join(addWorktree(fixture, "notes"), "notes.md"), "run log\n");
Expand Down
Loading
Loading