@justjoshn/pi-pstack 0.15.36-pi.11 → 0.15.36-pi.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.15.36-pi.13] - 2026-11-04
4
+
5
+ - Parse leading word intervals and preserve multiline prompts in `/loop`.
6
+ - Run different loop prompts independently. Return loop IDs and require an explicit ID for ambiguous wake or stop operations.
7
+ - Restore writable tools after leaving a planning branch with no recorded tool loadout.
8
+ - Preserve plan todo dependencies and project phases. Import unfinished root todos when building and synchronize later status updates without rewriting the rest of the plan file.
9
+ - Preserve completion when a reviewed plan omits a todo's optional status. Insert the missing field without rewriting existing metadata, comments, line endings, or body text.
10
+ - Persist plan-imported todos through native Pi branch entries so they survive a restart. Worktree plan builders import their own lists before the first request and retain the plan association on resume. Readonly resumes cannot synchronize plan files.
11
+ - Serialize Task stale-lock recovery with token-directory leases. Treat unreaped Linux zombies as exited writers.
12
+ - Open PR review canvases with the system browser instead of assuming Cursor's in-app browser.
13
+ - Keep Unix sockets blocked in the readonly shell. Refuse a missing seccomp helper instead of allowing a host service to change state on the command's behalf. Linux hosts that refuse the helper's nested namespaces cannot run readonly shell commands.
14
+ - Correct Benny's credential-isolation gate. Readonly children still inherit environment variables and can read credential files. Setup fails closed without separate isolation, and operational runs keep analysis and code work in the coordinator when isolation is unavailable.
15
+
16
+ ## [0.15.36-pi.12] - 2026-11-04
17
+
18
+ Each item below was checked against Cursor CLI 2026.10.22 with pstack and cursor-team-kit loaded, through its bundle and live runs. `parity/pi-pstack-behavior-parity/` in the repository records the evidence and the decisions.
19
+
20
+ - A mode keeps its skill in context on every request until the user leaves it, as a Cursor Custom Mode does, and sends Cursor's notices: entered, the per-turn reminder, and an exit or switch notice once. The previous version sent the body on one request only, so models that replay the system prompt lost it.
21
+ - A background completion arrives as Cursor's system notification: its preamble, a title from the first line of the prompt (80 characters at most), and its follow-up request. The background launch text and the Agent ID line use Cursor's wording.
22
+ - Task, TodoWrite, and AskQuestion descriptions carry Cursor's usage rules, and AskQuestion needs two options per question. The model list adds Cursor's rules for user-requested models.
23
+ - Add Cursor's built-in `explore` subagent type, a file-search specialist with Pi's search tools and no Task tool. team-kit's thermo-nuclear agent text, which names it, is upstream's again.
24
+ - Every subagent hears Cursor's reminder that it runs under a parent and spawns no subagents unless asked.
25
+ - Add `GenerateImage`, Cursor's image tool, on Pi's image models. It is offered when an image model is available and saves each image to the session's artifacts folder. `teach` asks for the image tool again, as upstream does.
26
+ - Stop attaching `typescript-best-practices` when a `.ts` file is read. Cursor loads a skill that sets `paths` and `disable-model-invocation` only when invoked by name.
27
+ - Plan mode follows Cursor's: its instructions, `CreatePlan {plan, name, overview, todos}` writing Cursor's plan file, edits to markdown files only, `SwitchMode` with the user's consent, and a build-locally, build-in-a-worker, or propose-changes choice after a saved plan. `create_plan` is gone.
28
+ - A `/loop` wake that comes due during a run fires once when the run settles. A fixed tick was dropped before, and an agent-paced wake that landed during another run stopped the loop.
29
+ - `make-bot-ui` describes webhook routines as they behave: no default expiry, and `sessionStrategy: "new_session"` for webhooks.
30
+
3
31
  ## [0.15.36-pi.11] - 2026-11-04
4
32
 
5
33
  - Title a background completion notice with the Task `description`, as Cursor names a subagent, instead of a slice of its prompt.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pstack for Pi (pi-pstack)
2
2
 
3
- pi-pstack is pstack 0.15.36 for Pi 1.5.0: rigorous agent workflows (`/poteto-mode` and its playbooks), the principle skills, and the review, research, and verification skills, plus the full soft-dependency team-kit set (`deslop`, `control-cli`, `control-ui`, CI/PR helpers, thermo-nuclear review, and the rest) vendored in so you do not install a separate team-kit package. A small extension provides the host features the skills call by name: `/name` skill commands, `/mode`, `/plan`, the `Task` subagent tool with local worktree workers, forks, and `agent_status`, `TodoWrite`, `AskQuestion`, the model rule, `/loop`, subscriptions and webhook routines, and `visualize`.
3
+ pi-pstack is pstack 0.15.36 for Pi 1.5.0: rigorous agent workflows (`/poteto-mode` and its playbooks), the principle skills, and the review, research, and verification skills, plus the full soft-dependency team-kit set (`deslop`, `control-cli`, `control-ui`, CI/PR helpers, thermo-nuclear review, and the rest) vendored in so you do not install a separate team-kit package. A small extension provides the host features the skills call by name: `/name` skill commands, `/mode`, `/plan`, the `Task` subagent tool with local worktree workers, forks, and `agent_status`, `TodoWrite`, `AskQuestion`, `GenerateImage`, `SwitchMode`, the model rule, `/loop`, subscriptions and webhook routines, and `visualize`.
4
4
 
5
5
  ## Get set up
6
6
 
@@ -13,7 +13,7 @@ pi-pstack is pstack 0.15.36 for Pi 1.5.0: rigorous agent workflows (`/poteto-mod
13
13
  pi install ./extensions/pi-pstack
14
14
  ```
15
15
 
16
- Pi does not install dependencies for a local package, so `bun install` (or `npm install` in `extensions/pi-pstack`) fetches the one runtime dependency, `@anthropic-ai/sandbox-runtime`, which the read-only shell loads (readonly subagents and `/plan`). Without it everything else works, and a read-only shell command fails instead of running unsandboxed. On Linux the sandbox also needs `bubblewrap`, `socat`, and `ripgrep` (`sudo apt install bubblewrap socat ripgrep`), and Ubuntu 24.04 and later need the user-namespace change under Limits. macOS uses the built-in `sandbox-exec`. pi-pstack needs Node 22.19 or newer. To try it for one session without installing, run `pi -e ./extensions/pi-pstack`. To install the published package instead, run `pi install npm:@justjoshn/pi-pstack`.
16
+ Pi does not install dependencies for a local package, so `bun install` (or `npm install` in `extensions/pi-pstack`) fetches `@anthropic-ai/sandbox-runtime` for the read-only shell (readonly subagents and `/plan`) and `yaml` for plan metadata. If sandbox-runtime is missing, a read-only shell command fails instead of running unsandboxed. On Linux the sandbox also needs `bubblewrap`, `socat`, and `ripgrep` (`sudo apt install bubblewrap socat ripgrep`), and Ubuntu 24.04 and later need the user-namespace change under Limits. macOS uses the built-in `sandbox-exec`. pi-pstack needs Node 22.19 or newer. To try it for one session without installing, run `pi -e ./extensions/pi-pstack`. To install the published package instead, run `pi install npm:@justjoshn/pi-pstack`.
17
17
  Installing loads pi-pstack's tools and system-prompt sections at once, but no skill runs until you invoke it. 61 workflow skills stay out of the model's automatic skill list. Setup, create-skill, and the team-kit shipping and review skills (`deslop`, `control-cli`, `control-ui`, CI and PR helpers, and the rest of that set) can load from your words alone.
18
18
  2. Run `/setup-pstack`. It lists the models the `Task` tool can use, asks for a reasoning budget, maps a model to each role, and writes the model rule. A new rule applies from the next request.
19
19
  3. Start real work with `/poteto-mode`, a goal, and a check that can pass or fail.
@@ -27,9 +27,9 @@ Remove the package with `pi remove ./extensions/pi-pstack`. Its state lives in `
27
27
  | You type | What happens |
28
28
  |---|---|
29
29
  | `/poteto-mode <task>` | The skill attaches to that one message. Every skill Pi loaded works this way: pstack's (`/how`, `/why`, `/arena`, `/interrogate`, `/principle-prove-it-works`, `/deslop`) and your own, such as a `/<handle>-mode` skill from `/automate-me`. `/skill:<name>` works too. |
30
- | `/mode poteto-mode [task]` | Keeps the skill in context on every turn. The skill body rides the first request after entry, then each later request gets a reminder that names the skill file, so a long session does not re-send 21 KB every turn. The footer shows a badge with the skill's `icon` and `color` metadata, such as a yellow `♛ mode: poteto-mode` (other skills get `⚡`). `/mode off` exits and `/mode` reports. Any loaded skill can back a mode. |
31
- | `/plan [task]` | Plan mode: the agent gets read-only tools (`read`, `grep`, `find`, `ls`, the sandboxed `bash_readonly`, `create_plan`, `AskQuestion`, `TodoWrite`, `agent_status`, `Task`, whose launches run readonly: a fresh one runs here with no worktree, and a resume or fork stays where its agent ran, and `stop_agent`), investigates, and writes a plan with goal, verified steps, and risks. `create_plan` saves it under the agent dir's `plans/` as a `.plan.md` file, so the user can read it. Writes are blocked. A bare `/plan` enters plan mode. `/plan build` leaves plan mode and starts the work from the saved file, as the plan menu does; `/plan off` restores your tools. The footer shows `plan`. |
32
- | `/loop 30m <prompt>` | Runs the prompt now, then again every 30 minutes from each fire, so a long run does not push the next tick out. A tick that lands while a run is still going is skipped rather than queued, so one long run cannot leave a backlog of stale ticks; the next tick after it settles runs. The interval can come first or last, written as `30m`, `10 minutes`, or `every 10 minutes`. Without an interval the agent picks each wake with the `Loop` tool, and the loop ends when it picks none and no background subagent is still running. `/loop stop` or Escape during a run ends it. The prompt can be a skill command, such as `/loop 1h /poteto-mode run the audit tick`. When a playbook says to arm `/loop`, the agent starts it with the `Loop` tool. Intervals go up to 24 days. |
30
+ | `/mode poteto-mode [task]` | Keeps the skill in context on every turn until you leave the mode: the skill rides every request in its own system-prompt section, which Pi re-sends only when it changes. The first request after entry says the user entered the mode, later requests carry a reminder that names the skill file, and the request after `/mode off` or a switch to another mode says the user left it. The footer shows a badge with the skill's `icon` and `color` metadata, such as a yellow `♛ mode: poteto-mode` (other skills get `⚡`). `/mode off` exits and `/mode` reports. Any loaded skill can back a mode. |
31
+ | `/plan [task]` | Plan mode: the agent researches with read-only tools (`read`, `grep`, `find`, `ls`, the sandboxed `bash_readonly`, `AskQuestion`, `TodoWrite`, `agent_status`, `Task`, whose launches run readonly: a fresh one runs here with no worktree, and a resume or fork stays where its agent ran, and `stop_agent`), asks its clarifying questions early, and presents the plan with `CreatePlan` (`plan`, `name`, `overview`, `todos`, `is_project`, `phases`). `CreatePlan` writes the plan file under `<pstack dir>/plans/` (`<name>-<8 hex>.plan.md`: the chat id in a comment, the todos as front matter, then the plan), one file per plan name in a chat. Todo dependencies and project phases stay in the file. Building imports the file's unfinished root todos into the session, including edits made during review. Worktree builders import their own lists before the first model request and retain the associated plan on resume. Later writable `TodoWrite` status updates synchronize those root todos without rewriting other metadata or the plan body. An omitted status imports as pending and is inserted when the todo is updated. A readonly resume keeps its todo changes inside the session. `edit` and `write` work on markdown files only, so the agent refines the plan in its file. After a run that saved a plan, an interactive session asks `Yes, build locally`, `Yes, build in cloud` (in a git repository: a background isolated worker builds it on its own branch), or `No, propose changes`. `/plan build` builds the saved plan too, and `/plan off` restores your tools. A bare `/plan` enters plan mode. The footer shows `plan`. |
32
+ | `/loop 30m <prompt>` | Runs the prompt now, then again every 30 minutes from each fire, so a long run does not push the next tick out. A tick that comes due while a run is still going fires once when that run settles; several missed ticks still fire once. The interval can come first or last, written as `30m`, `10 minutes`, or `every 10 minutes`. Without an interval the agent picks each wake with the `Loop` tool, and the loop ends when it picks none and no background subagent is still running. Different prompts create independent loops. The same prompt replaces its schedule. `/loop` lists them. `/loop stop` ends the only loop, or `/loop stop <id>` selects one when several are running. Escape during a run ends the session's loops. `Loop` results include the loop ID in text and details; pass `loop_id` to wake, stop, or replace one of several loops. The prompt can be a skill command, such as `/loop 1h /poteto-mode run the audit tick`. When a playbook says to arm `/loop`, the agent starts it with the `Loop` tool. Intervals go up to 24 days. |
33
33
  | `/routines` | Lists webhook routines with their URL, credential file, and status. |
34
34
  | `/setup-pstack` | Configures the per-role models. |
35
35
  | `/poteto-help <question>` | Answers a question about pstack and hands you a prompt to send. |
@@ -40,18 +40,17 @@ Remove the package with `pi remove ./extensions/pi-pstack`. Its state lives in `
40
40
 
41
41
  | Feature | Behavior |
42
42
  |---|---|
43
- | `Task` (`description`, `prompt`, `subagent_type`, `model`, `run_in_background`, `resume`, `fork`, `fork_turns`, `readonly`, `file_attachments`, `environment`, `cloud_base_branch`) | Starts a separate `pi --mode rpc` process per subagent, so this Pi process can steer and abort it. Foreground calls return the response and an agent ID. Background calls return at once, and a `<task>` notification arrives after your turn ends, titled by the call's `description`; print and JSON runs wait for pending notifications before exiting, unless aborted. Several calls in one message run in parallel. A subagent's own subagents cannot spawn more. A run lock per agent ID keeps out a second writer, even from another Pi process (Limits notes the stale-lock race). Children inherit the parent's project-trust decision. Foreground usage counts toward the session totals. The Task card leads with the call's `description`, then the agent type and the model that ran, and while a foreground child works it shows its last few tool steps and latest line instead of a blank wait. |
43
+ | `Task` (`description`, `prompt`, `subagent_type`, `model`, `run_in_background`, `resume`, `fork`, `fork_turns`, `readonly`, `file_attachments`, `environment`, `cloud_base_branch`) | Starts a separate `pi --mode rpc` process per subagent, so this Pi process can steer and abort it. Foreground calls return the response and an agent ID. Background calls return at once, and a `<system_notification>` with a `<task>` block arrives after your turn ends, titled by the first line of the prompt (80 characters at most) and followed by a request to do any follow-up work; the notification card shows the call's `description`. Print and JSON runs wait for pending notifications before exiting, unless aborted. Several calls in one message run in parallel. A subagent's own subagents cannot spawn more, and every subagent is told to spawn none unless asked. A run lock per agent ID keeps out a second writer, even from another Pi process. A token-directory lease serializes stale-lock recovery while the PID file identifies the transcript writer. Children inherit the parent's project-trust decision. Foreground usage counts toward the session totals. The Task card leads with the call's `description`, then the agent type and the model that ran, and while a foreground child works it shows its last few tool steps and latest line instead of a blank wait. |
44
44
  | `resume` | Sends a follow-up to an idle agent with its context, model, type, and directory. The root chat can resume or fork a descendant that a worktree worker started inside that worktree, and the descendant still runs where it first ran. On an agent running in this Pi process, it delivers the prompt as a steer and returns at once. A readonly or plan-mode call cannot steer a writable agent. An agent running in another Pi process is refused. This is how a playbook "messages" a worker. Pi's own `/resume` command reopens a chat session instead. |
45
45
  | `fork` | Starts a new agent whose transcript begins as a copy of an idle agent's transcript, in that agent's directory (its worktree for an isolated worker), so it sees the built checkout and uncommitted changes. Type, model, and readonly default from the source; readonly can be added, never lifted. `fork_turns: N` (only with `fork`) copies just the first N user turns. `fork` excludes `resume`, `environment`, and `cloud_base_branch`. Pi's own `/fork` command branches the chat session instead. |
46
46
  | `stop_agent` | `agent_id`. Stops a running subagent. One this Pi process owns gets an RPC abort, then a kill after a grace period. One another of your Pi processes owns gets a signal to the live pid in its run lock. An idle or finished agent is left alone, and the result says so. |
47
47
  | `agent_status` | Reads a subagent's state (`running` while its run lock names a live pid, `idle`, or `missing`), type, model, directory, branch, times, and last reply, without waking it. It also shows whether the agent is readonly, the agent it was forked from, its pid while running, and its transcript. Without `agent_id` it lists the workspace's 20 newest agents. In the root chat that includes every descendant, isolated workers too. |
48
- | Subagent types | `generalPurpose` (default), `poteto-agent` (a background delegate that reads poteto-mode first), `ci-watcher` (a background PR check watcher), `comment-sicko`, and `thermo-nuclear-code-quality-review`, the last four read from `agents/*.md`. Unknown types fail with the list. |
48
+ | Subagent types | The built-in `generalPurpose` (default) and `explore` (a file-search specialist the caller tells how thorough to be, with `grep`, `find`, and `ls` on and no `Task`), then `poteto-agent` (a background delegate that reads poteto-mode first), `ci-watcher` (a background PR check watcher), `comment-sicko`, and `thermo-nuclear-code-quality-review`, the last four read from `agents/*.md`. Unknown types fail with the list. |
49
49
  | Models | A Pi model spec such as `claude-opus-5-5:xhigh` or `xai/grok-4.7:high`, model parameters such as `claude-opus-5-5[effort=high]` or `grok-4.7[fast=true]` (picks a listed `-fast` id of that model), `fast` for the parent model's listed `-fast` variant when it has one, else the parent model, or `inherit`, `inherit-parent`, `auto`, or nothing for the parent model. A model Pi does not list, or a thinking level the model does not support, fails with the allowed list. A bare model id that several providers offer resolves to the parent chat's provider when it offers that id, and otherwise fails with the choices. Older rules that wrote `claude-opus-5-5-xhigh` still resolve. The system prompt's `pstack_subagents` section lists the types, the parent model, and the models with their levels. |
50
50
  | Isolated workers (`environment: "cloud"`) | The subagent runs in a new git worktree at `<pstack dir>/workspaces/<workspace folder>/worktrees/<agent id>` on branch `pstack/<agent id>`, from `cloud_base_branch` (`origin/<branch>` when that remote-tracking ref exists, else a local branch or other ref) or your HEAD commit, so uncommitted changes do not reach it. The result and the card name the branch to merge, and `resume` and `fork` run in the same worktree. It fails clearly outside a git repository, in a repository with no commits, or when the base does not resolve. The worker shares the root chat's workspace state, so it sees the same projects, stores, and subagent transcripts. It also shares this machine's ports, processes, writable caches, simulators, and credentials. Assign separate ports, output directories, and writable caches to concurrent runtime lanes. `swarm` and `orchestrate` spawn worktree workers by default. |
51
- | `readonly: true` | The child gets `read`, `grep`, `find`, `ls`, `TodoWrite`, and a read-only `bash`, and no MCP. That shell runs each command in an OS sandbox ([`@anthropic-ai/sandbox-runtime`](https://github.com/anthropics/sandbox-runtime): `sandbox-exec` on macOS, bubblewrap on Linux) that blocks every file write and all network access, so `git log` works and `touch` or `curl` fail. Where no sandbox can start, the command fails rather than running unsandboxed. |
52
- | `TodoWrite` | `todos` with `id`, `content`, `status`, and `merge`. The list follows the session branch and shows above the editor. |
53
- | `AskQuestion` | `title`, and per question `id`, `prompt`, `options` (`id`, `label`, optional `description`), and `allow_multiple`, through Pi's select dialog. Every question ends with `Other: (type to answer)`; a typed answer comes back as `other` with its text. In print and JSON runs, including subagents, each question comes back skipped. |
54
- | Path-scoped skills | A skill whose frontmatter declares `paths` or `globs` (also under `metadata`) attaches once per session when the agent reads or edits a matching file, the way a path-scoped rule attaches. The shipped `typescript-best-practices` skill attaches on `.ts` and `.tsx` files this way. |
51
+ | `readonly: true` | The child gets `read`, `grep`, `find`, `ls`, `TodoWrite`, and a read-only `bash`, and no MCP. That shell runs each command in an OS sandbox ([`@anthropic-ai/sandbox-runtime`](https://github.com/anthropics/sandbox-runtime): `sandbox-exec` on macOS, bubblewrap on Linux) that blocks every file write and all network access, so `git log` works and `touch` or `curl` fail. Where no sandbox can start, the command fails rather than running unsandboxed. Readonly is not credential isolation. The child still inherits environment variables and can read credential files through its read tools. |
52
+ | `TodoWrite` | `todos` with `id`, `content`, `status`, and `merge`. Its description says when to keep a list, the four states, and one task in progress at a time. The list follows the session branch, shows above the editor, and rides every request's system prompt. Plan-imported lists persist as branch entries. Their dependencies survive status-only updates, and matching plan-file statuses are synchronized. |
53
+ | `AskQuestion` | `title`, and per question `id`, `prompt`, `options` (at least two, each `id`, `label`, optional `description`), and `allow_multiple`, through Pi's select dialog. It is for decisions only the user can make, and a recommended option goes first with `(Recommended)`. Every question ends with `Other: (type to answer)`; a typed answer comes back as `other` with its text. In print and JSON runs, including subagents, each question comes back skipped. |
55
54
  | Always-applied rules | The two team-kit rules are in `pstack_host` as their shipped text on every request, alongside the same rules as hidden skills. |
56
55
  | The model rule | `<pstack dir>/pstack-models.md`, plain Markdown with one line per role, added to every request's system prompt. A `pstack-models.mdc` from an earlier version is moved there once, without its frontmatter, and kept as `pstack-models.mdc.migrated`. |
57
56
  | Subscriptions | `subscribe_github_pr` (`scope` `pr` with `prUrl`, `repo` with `repo`, or `author` with `author` and `repo`) polls with `gh` every 60 seconds and wakes the chat when a PR's state, head, mergeability, review decision, reviews, or comments change, or when a check concludes or its conclusion changes; the first poll is a baseline. `subscribe_timer` takes a `name`, a `prompt`, and a 5-field `cron` or `delaySeconds`, either with `once`; `sessionStrategy` `wake_self` queues a wake for this owning session. With `new_session`, a live owner starts a background Task and receives its notification. An offline owner permits a detached run with a recorded outcome. Both reuse the model, thinking level, and project-trust decision the timer was created with. Re-subscribing an existing timer name returns `created: false`. `list_subscriptions` and `unsubscribe` manage them. The authoritative registry is `<pstack dir>/durable/<workspace>/subscriptions.json`. Any session in that workspace can list or cancel subscriptions. Session history does not recreate cancelled or completed subscriptions. Owner-directed events wait for the creating session rather than waking another workspace session. A detached run records its own final message, shown by `list_subscriptions`. A timer does not expire unless `expiresInHours` says so (at most 30 days); `0` means no expiry. A GitHub watch keeps a 7-day default because it is this port's own surface. |
@@ -60,7 +59,8 @@ Remove the package with `pi remove ./extensions/pi-pstack`. Its state lives in `
60
59
  | Stores and projects | The system prompt names "the current agent's store" (per session), "the root agent's store" (the main chat's, named to every subagent however deep), and the workspace's `projects/` folder, where a program's Project is `<slug>/notes.md` (its tracker) and `<slug>/store/`. |
61
60
  | `visualize` | `title`, `kind` (`bar` or `line`), `labels`, `series` (`name`, `values`), and `unit` render a Unicode chart in the result and write a standalone SVG to the session's artifacts folder. |
62
61
  | Transcripts | The system prompt names this workspace's Pi session directory, the current session file, and this workspace's subagent transcripts. |
63
- | Image generation | Pi's codemode `models.generateImages()`, when codemode is on and an image model is configured; otherwise skills fall back to a Mermaid diagram. |
62
+ | `GenerateImage` | Generates an image (`description` of at least six words, `filename`, `reference_image_paths`, `aspect_ratio`) on Pi's image models through `ctx.modelRegistry.generateImages()`. It is offered when an image model is available (for example an OpenRouter image model), not to readonly subagents or in plan mode, and saves each image to the session's artifacts folder. Without an image model, the host section tells skills to draw a Mermaid diagram instead. |
63
+ | `SwitchMode` | `target_mode_id` (`plan` or `agent`) and `explanation`. The agent proposes entering or leaving plan mode, and the switch happens only after you confirm it. Offered in interactive and RPC sessions. |
64
64
 
65
65
  Subagent transcripts are Pi sessions in `<pstack dir>/workspaces/<workspace folder>/subagents/`, with the agent ID in each file name, next to a small record that `resume`, `fork`, and `agent_status` read. Records belong to the main chat's shared workspace state, so the root chat can act on a descendant that ran in a worktree. Children inherit your installed extensions and MCP servers, and local ones run in your working directory. Give each local subagent that writes its own git worktree, or launch it with `environment: "cloud"`, because a child process does not isolate the filesystem. A child exits on its own if its parent Pi process dies.
66
66
 
@@ -78,10 +78,10 @@ Subagent transcripts are Pi sessions in `<pstack dir>/workspaces/<workspace fold
78
78
  - Depth limits apply to `Task`. A writable subagent can still start `pi` through `bash`, and that process is outside the depth limit and parent watchdog.
79
79
  - A child loads your installed extensions plus this package. If you run one checkout with `-e` while a different checkout of pi-pstack is installed, the child loads both and fails on duplicate tools; use one copy, or a separate `PI_CODING_AGENT_DIR`, as `live:e2e` does.
80
80
  - Subagents run headless in RPC mode, so an extension that asks for permission through a dialog cannot ask there.
81
- - The read-only shell sandboxes shell subprocesses only, and is verified on macOS and on the Ubuntu CI runner. On Linux it needs `bubblewrap`, `socat`, and `ripgrep`. Ubuntu 24.04 and later restrict unprivileged user namespaces: either add an AppArmor profile that grants `userns` to `bwrap`, or run `sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0`, which lifts the restriction for every program on the machine. The policy sets `allowAllUnixSockets: true` so Linux skips `apply-seccomp`, whose nested userns fails on GitHub-hosted runners; filesystem write denial and network denial still come from bubblewrap.
81
+ - The read-only shell sandboxes shell subprocesses only. Earlier macOS and Ubuntu CI runs do not verify the stricter Unix-socket policy. On Linux it needs `bubblewrap`, `socat`, and `ripgrep`. Ubuntu 24.04 and later restrict unprivileged user namespaces: either add an AppArmor profile that grants `userns` to `bwrap`, or run `sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0`, which lifts the restriction for every program on the machine. Unix sockets stay blocked because a host socket service can mutate files or access the network on a command's behalf. Linux also needs sandbox-runtime's bundled `apply-seccomp` helper and permission to create its nested user, PID, and mount namespaces. A missing helper or a namespace refusal blocks the shell command. The shell never falls back to permitting host sockets. Do not treat a readonly child as a credential boundary. Environment variables and readable credential files are still available to its read tools.
82
82
  - Whether a model follows a playbook is the model's call.
83
83
  - Workspace folders follow Pi's session-folder naming, so two paths that differ only by `/` versus `-` share a folder. Resume and fork refuse an agent whose record names the other directory, except that a record created inside this workspace's own worktrees belongs to this workspace. Subscription reads and mutations also reject a registry owned by the other workspace.
84
- - The run lock that keeps one writer per agent ID names the process writing the transcript. A lock file without a readable pid counts as held; the error names the file to delete. `agent_status` shows such an agent as `idle`. A lock whose pid is dead is taken over, and two processes that take over the same stale lock at the same moment can both succeed.
84
+ - The run lock that keeps one writer per agent ID names the process writing the transcript. A lock file without a readable pid counts as held; the error names the file to delete. `agent_status` shows such an agent as `idle`. A token-directory lease beside the PID file serializes stale-lock recovery. A dead process or an unreaped Linux zombie does not count as a live writer. Older installed versions without the lease do not participate in this protection.
85
85
  - `skills/poteto-mode/scripts/watch-pr` needs Bun and installs its one dependency on first run. `check-plan.mjs` needs only Node. `worktree-audit.sh` needs `rg` and `jq`, and works with BSD (macOS) or GNU `stat` and `date`.
86
86
  - `statechart` runs `skills/statechart/scripts/statechart` on Node 22.18 to 22.x, Node 23.6 or later, Bun 1.1.5 or later, or Deno 2.0 or later. The first run installs TLC and Java through [mise](https://mise.jdx.dev/) and needs the network. Without a SPEC it prints `Give one SPEC.tla.` and its usage, then exits 2.
87
87
 
@@ -20,4 +20,4 @@ You are a **Task subagent**. The parent agent already collected git output and c
20
20
 
21
21
  ## Parent orchestration
22
22
 
23
- Typical flow: collect `git diff <base>...HEAD` (default base `main`) and the full contents of changed files with this chat's own tools (`bash`, `read`, `grep`), or with one `Task` `generalPurpose` / `poteto-agent` helper when the tree is large. Then invoke this agent with `subagent_type: "thermo-nuclear-code-quality-review"` and a user prompt containing `### Git / diff output` and `### Changed file contents`. Do not invent Task types such as `shell` or `explore`; only the types in `<pstack_subagents>` exist.
23
+ Typical flow: in **one** message, run two `Task` calls in parallel — `subagent_type: "shell"` and `subagent_type: "explore"` — to collect `git diff <base>...HEAD` output and full contents of changed files (default base `main`). Then invoke this agent with `subagent_type: "thermo-nuclear-code-quality-review"` and a user prompt containing `### Git / diff output` and `### Changed file contents`.
@@ -27,7 +27,7 @@ i want two pi automations that work together in one slack issue channel. each on
27
27
 
28
28
  - i want the source channel and root thread coordinates to stay immutable for the whole run.
29
29
  - i treat utility and debug bots as evidence, not delegation or fix ownership.
30
- - i allow subagents to help, but they cannot post to slack or receive slack credentials. analysis subagents run as `Task` with `readonly: true`, which gives them no mcp servers and no network.
30
+ - i allow subagents to help, but they cannot post to slack or receive slack credentials. analysis subagents run as `Task` with `readonly: true`. readonly removes mcp tools and restricts shell operations, but does not isolate credentials. when separate credential isolation cannot be proven, keep the work in the coordinator.
31
31
  - i want this entire pack committed at `.pi/automations/benny/` in the target repository. its `SKILL.md` files are direct automation instructions, not skills pi discovers.
32
32
  - i want pi-pstack installed in pi for shared dependencies such as `how`, `why`, `tdd`, `unslop`, and the required principle skills.
33
33
  - i want each subscription prompt to read its operational file directly from the target repository. i do not want pi-pstack package paths, copied excerpts, or slash-skill discovery.
@@ -16,8 +16,8 @@ Load the external Benny configuration supplied by the automation. If the config,
16
16
  - Never post a root message in the source channel.
17
17
  - Preflight the source parent before every source-thread post.
18
18
  - The coordinator is the only Slack poster.
19
- - Delegated analysis workers are read-only and return findings or media notes. In Pi, start each one with `Task` and `readonly: true`, which gives it no MCP servers and a shell with no network.
20
- - A fix-phase code worker may edit only when its environment provably excludes Slack credentials and every Slack write action. Otherwise the coordinator edits. A writable Pi subagent inherits the session's MCP servers and environment, so it qualifies only when the Pi process that owns the subscriptions loads no Slack MCP server with write tools and has no Slack token in its environment.
19
+ - Delegated analysis workers are read-only and return findings or media notes. `Task` with `readonly: true` removes MCP tools and restricts shell operations, but still inherits environment credentials and can read credential files. Launch a child only after separate credential isolation is proven. Otherwise do the work in the coordinator.
20
+ - A fix-phase code worker may edit only when its environment and readable files provably exclude Slack credentials and every Slack write action. Otherwise the coordinator edits. A writable Pi subagent also inherits the session's MCP servers. Absence of a Slack MCP server or an environment token alone is not proof of credential isolation.
21
21
  - Every child prompt must explicitly forbid every Slack MCP write tool (`mcp__<slack-server>__*` tools that post, edit, react, or upload), `chat.postMessage`, and all other Slack writes.
22
22
  - Never give a child a Slack token, posting instructions, source coordinates for posting, or permission to report externally.
23
23
  - If a child needs Slack write access to run, do not launch it.
@@ -36,7 +36,7 @@ Load the external Benny configuration supplied by the automation. If the config,
36
36
  Before making a work list or delegating:
37
37
 
38
38
  1. Require the trigger channel to equal the configured source channel.
39
- 2. Set `SOURCE_THREAD_TS` to `trigger.thread_ts` when present. Otherwise use `trigger.ts`.
39
+ 2. Set `SOURCE_THREAD_TS` to `trigger.thread_ts` when present. Otherwise use `trigger.message_ts`, then `trigger.ts`.
40
40
  3. Require a nonempty `SOURCE_THREAD_TS`.
41
41
  4. Store `SOURCE_CHANNEL_ID` and `SOURCE_THREAD_TS` as immutable values.
42
42
  5. Read the source thread and verify its root has those exact coordinates.
@@ -38,7 +38,7 @@ If this file is already being read from the target destination, treat the copy a
38
38
 
39
39
  Confirm that pi-pstack is installed in Pi. A personal install (`pi install <path-to-pi-pstack>`) serves every repository on this machine. A project install (`pi install -l <path-to-pi-pstack>`) writes the target repository's `.pi/settings.json`; preserve every unrelated setting and package entry when that file exists, and validate it after editing.
40
40
 
41
- This setup session must run in the target repository, because a `Task` subagent starts in its parent's working directory. If it does not, stop and tell the user to start Pi in the target repository and point it at `FOR_AGENTS.md` again. Start a fresh `Task` subagent with `readonly: true`. Ask it to resolve `<SKILLS>` from its own system prompt and read each required `<SKILLS>/<name>/SKILL.md` file below. It must report each absolute path and confirm the file's frontmatter names the required skill. Hidden skills need not appear in Pi's automatic skill catalog.
41
+ This setup session must run in the target repository, because a `Task` subagent starts in its parent's working directory. If it does not, stop and tell the user to start Pi in the target repository and point it at `FOR_AGENTS.md` again. Before the dependency check, prove that its child cannot read Slack credentials from the inherited environment or files. `readonly: true` removes MCP tools and restricts shell operations, but does not remove credentials or restrict the `read` tool. If credential isolation is unavailable, stop setup before starting a child or enabling subscriptions. Otherwise start a fresh `Task` subagent with `readonly: true`. Ask it to resolve `<SKILLS>` from its own system prompt and read each required `<SKILLS>/<name>/SKILL.md` file below. It must report each absolute path and confirm the file's frontmatter names the required skill. Hidden skills need not appear in Pi's automatic skill catalog.
42
42
 
43
43
  - `how`
44
44
  - `why`
@@ -132,7 +132,7 @@ The repro automation needs:
132
132
  - `gh` authenticated for the repository, so `gh pr create --draft` can open a draft pull request
133
133
  - The configured control-adapter skill
134
134
 
135
- Prefer the configured Slack MCP tools for reads and posts. The optional `BENNY_SLACK_BOT_TOKEN` may fill a narrow gap such as editing one operations status message or downloading an attachment. Store the value in a secret manager or the owning session's environment, not in YAML. A writable subagent inherits that environment, which is one reason Benny's workers run readonly.
135
+ Prefer the configured Slack MCP tools for reads and posts. The optional `BENNY_SLACK_BOT_TOKEN` may fill a narrow gap such as editing one operations status message or downloading an attachment. Store the value in a secret manager or the owning session's environment, not in YAML. Every subagent inherits that environment, including readonly children. Removing a token from the prompt does not remove it from the process or make credential files unreadable. Unless separate credential isolation is established, keep analysis and code work in the coordinator.
136
136
 
137
137
  Do not use undocumented integration endpoints.
138
138
 
@@ -247,7 +247,7 @@ Verify:
247
247
  3. Repro accepts the marker only from the configured triage identity.
248
248
  4. Repro keeps the same immutable source coordinates.
249
249
  5. No source-channel root message appears.
250
- 6. A delegated worker cannot use any Slack write action: it runs as a `readonly` `Task`, so it has no MCP tools.
250
+ 6. Every delegated worker has verified credential isolation as well as no Slack write actions. `readonly: true` alone is insufficient. If that isolation is unavailable, the coordinator performs the work without an analysis or code child.
251
251
  7. Missing coordinates, a deleted parent, or a failed preflight produces no post and no tracker issue.
252
252
  8. A second fire, or a repeated webhook POST, for the same report does no work, because the ledger already lists it.
253
253
 
@@ -19,7 +19,7 @@ Load the external Benny configuration supplied by the automation. If the config
19
19
  - If the parent is missing, deleted, inaccessible, or uncertain, stop with no writes.
20
20
  - Post one substantive verdict. Do not narrate progress.
21
21
  - The coordinator is the only Slack poster.
22
- - Delegated workers return findings only. They must be read-only and receive no Slack credentials or write actions. In Pi, start each one with `Task` and `readonly: true`: a readonly subagent gets no MCP servers, and its shell can neither write files nor reach the network.
22
+ - Delegated workers return findings only. They must be read-only and receive no Slack credentials or write actions. In Pi, `Task` with `readonly: true` removes MCP tools and restricts shell operations, but still inherits environment credentials and can read credential files. Launch a child only after separate credential isolation is proven. Otherwise do the work in the coordinator.
23
23
  - Every child prompt must forbid every Slack MCP write tool (`mcp__<slack-server>__*` tools that post, edit, react, or upload), `chat.postMessage`, and every other Slack write.
24
24
  - If worker isolation cannot enforce those limits, do the work in the coordinator.
25
25
  - Never create an issue that cannot link back to the source thread.
@@ -33,7 +33,7 @@ Before making a work list or delegating:
33
33
 
34
34
  1. Read `source_channel_id` from the trigger.
35
35
  2. Require it to equal the configured source channel.
36
- 3. Set `SOURCE_THREAD_TS` to `trigger.thread_ts` when present. Otherwise use `trigger.ts`.
36
+ 3. Set `SOURCE_THREAD_TS` to `trigger.thread_ts` when present. Otherwise use `trigger.message_ts`, then `trigger.ts`.
37
37
  4. Require a nonempty `SOURCE_THREAD_TS`.
38
38
  5. Store `SOURCE_CHANNEL_ID` and `SOURCE_THREAD_TS` as immutable values.
39
39
  6. Read the thread and verify that its root has exactly those coordinates.
@@ -41,7 +41,7 @@ thin adapter over `RpcClient`.
41
41
 
42
42
  ## 2. The skill block `/mode` sends
43
43
 
44
- `modeSection` (`src/mode.ts:52-58`) strips frontmatter with Pi's exported `stripFrontmatter` (`dist/index.d.ts:50`) and
44
+ `modeSkill` (`src/mode.ts:102`) strips frontmatter with Pi's exported `stripFrontmatter` (`dist/index.d.ts:50`) and
45
45
  wraps the body in the `<skill name="..." location="...">` block Pi's own `/skill:name` expansion builds
46
46
  (`AgentSession._expandSkillCommand`, `dist/core/agent-session.js:1739`). Pi exports `parseSkillBlock` and
47
47
  `formatSkillsForPrompt` (`dist/index.d.ts:3,23`), which parse a block and format the skills catalog; neither formats
@@ -8,23 +8,24 @@ This page records what `pi-pstack` reproduces from Cursor `pstack` 0.15.36 and i
8
8
  - Installed Cursor CLI at the time of the reference capture: `2026.10.22-27dcf5f`.
9
9
  - Native implementation: this package, which pins its upstream provenance in `package.json.pstackSource`.
10
10
 
11
- A path and byte comparison of the tracked trees shows every pstack skill, both pstack agents, all 18 team-kit skills, both team-kit agents, and both team-kit rules in this package. Seventeen team-kit skill files are byte-identical; `workflow-from-chats` describes Pi paths instead of Cursor paths. The changed pstack files are host translations. One upstream paragraph has no counterpart: `poteto-help`'s Claude Code install path and its `docs/harness/claude-code.md` adapter, because this package targets Pi only. The two non-portable frontmatter keys Cursor ships (`icon`/`color` on `poteto-mode`, `paths` on `typescript-best-practices`) are kept under `metadata`, the Agent Skills extension point; the port reads both, and it attaches `typescript-best-practices` by path through `src/path-skills.ts`.
11
+ A path and byte comparison of the tracked trees shows every pstack skill, both pstack agents, all 18 team-kit skills, both team-kit agents, and both team-kit rules in this package. Sixteen team-kit skill files are byte-identical. `workflow-from-chats` describes Pi paths instead of Cursor paths, and `pr-review-canvas` opens a system browser instead of Cursor's in-app browser. The changed pstack files are host translations. One upstream paragraph has no counterpart: `poteto-help`'s Claude Code install path and its `docs/harness/claude-code.md` adapter, because this package targets Pi only. The two non-portable frontmatter keys Cursor ships (`icon`/`color` on `poteto-mode`, `paths` on `typescript-best-practices`) are kept under `metadata`, the Agent Skills extension point. The port reads `icon` and `color` for the mode badge. `paths` stays as metadata only, because Cursor loads a `paths` skill that sets `disable-model-invocation` only when it is invoked by name. team-kit's thermo-nuclear agent changes only where it names the plugin that ships its rubric.
12
12
 
13
13
  ## Native translations
14
14
 
15
15
  | Cursor dependency | Pi mechanism |
16
16
  | --- | --- |
17
17
  | Skill invocation and the slash menu | `pi.getCommands()` plus `/name` to `/skill:name` input rewriting, with TUI completions |
18
- | Custom Mode | `/mode <skill>`, a branch-persisted entry, the skill attached once on the entering request, and a path-naming reminder in a `pstack_mode` prompt section on every later request |
19
- | Plan mode | `/plan`, a reduced tool set, `bash_readonly` in an OS sandbox, a `create_plan` artifact under `plans/`, and `/plan build` |
18
+ | Custom Mode | `/mode <skill>`, a branch-persisted entry, the skill in a `pstack_mode_skill` prompt section on every request while the mode is on, and Cursor's entered, reminder, and exit or switch notices in `pstack_mode` |
19
+ | Plan mode | `/plan` and `SwitchMode`, Cursor's plan-mode instructions in `pstack_plan`, a reduced tool set with `bash_readonly` in an OS sandbox and markdown-only `edit` and `write`, `CreatePlan` writing Cursor's plan file under `plans/`, and a build prompt after a saved plan (`/plan build` too) |
20
20
  | Always-applied model rule | `pstack-models.md` read before every request and injected as `pstack_models` |
21
- | Task subagents | One `pi --mode rpc` process per agent, with resume, steer, fork, `fork_turns`, readonly, attachments, background notices, and local worktrees |
22
- | Agent types | The four bundled agent Markdown files, loaded into the child system prompt |
21
+ | Task subagents | One `pi --mode rpc` process per agent, with resume, steer, fork, `fork_turns`, readonly, attachments, Cursor's result and completion texts, Cursor's subagent reminder, and local worktrees |
22
+ | Agent types | Cursor's built-in `generalPurpose` and `explore`, then the four bundled agent Markdown files, loaded into the child system prompt |
23
23
  | Project and agent stores | Workspace state folders named in the host system prompt |
24
24
  | Todo list | `TodoWrite` with branch reconstruction and a TUI widget |
25
- | Structured questions | `AskQuestion` over Pi select and input dialogs |
26
- | `/loop` | `Loop` tool and `/loop` command. A fixed interval is wall-clock from each fire, like Cursor's sleep loop, and accepts the interval first or last (`5m`, `10 minutes`, `every 10 minutes`). An interval-less loop is agent-paced through `Loop` `wake_in`. |
27
- | Path-scoped skills | `src/path-skills.ts` attaches a loaded skill once per session when the session reads or edits a file matching its `paths`/`globs` (also under `metadata`), the way Cursor files a skill under `fileGlobbed` |
25
+ | Structured questions | `AskQuestion` over Pi select and input dialogs, with Cursor's schema minimums and usage rules |
26
+ | Image generation (`GenerateImage`) | `GenerateImage` on `ctx.modelRegistry.generateImages()`, offered when an image model is available |
27
+ | `/loop` | `Loop` tool and `/loop` command. A fixed interval is wall-clock from each fire, like Cursor's sleep loop, and accepts the interval first or last (`5m`, `10 minutes`, `every 10 minutes`). An interval-less loop is agent-paced through `Loop` `wake_in`. A wake that comes due mid-run fires once when the run settles, as Cursor's monitored shell output notifies after the turn. |
28
+ | Path-scoped skills | None needed. pstack's only `paths` skill also sets `disable-model-invocation`, and Cursor loads such a skill only by name, which Pi does natively |
28
29
  | Always-applied rules | The two shipped rule bodies are read into `pstack_host` verbatim on every request, not paraphrased |
29
30
  | Todo list state | `TodoWrite` writes branch entries, and the current list rides in the `pstack_todos` prompt section on every request, so a compacted context still sees it |
30
31
  | Automations | Durable timer, GitHub, and webhook subscriptions with a detached supervisor |
@@ -44,6 +45,37 @@ A live Cursor CLI session with both plugins loaded produced these contracts.
44
45
 
45
46
  Pi returns the child's final text with a transcript path and usage, and reports background completion as a `pstack/task` notification. The payload shape differs because the hosts are different; the observable workflow, a subagent result arriving after the parent turn, is preserved.
46
47
 
48
+ ## Reconstruction repairs in 0.15.36-pi.13
49
+
50
+ The repository's `parity/pstack-reconstruction-2026-11-04/` holds the reference inventory, baseline and treatment receipts, and decision log. These repairs do not establish that every workflow has been observed on both hosts.
51
+
52
+ The pre-bump PR-preparation run, `pr-make-verify.txt`, exits at pi-pstack's coverage suite with 680 passing tests and five failing positive readonly-shell checks. Lint, typecheck, mechanisms, toolchain, and test conventions pass before that stop. No later package result is inferred. `pr-preparation.md` records the focused checks, local review, and publication redactions.
53
+
54
+ The later [Linux CI run at `83cf4d9b`](https://github.com/just-joshn/pi-customizations/actions/runs/41885522222/job/126768816594) passes all 685 package tests and 367 statechart tests on Ubuntu 24.04. This includes successful restricted commands and the host Unix-socket regression. The workflow pins Ubuntu 24.04 after `ubuntu-latest` selected Ubuntu 26.04 and the helper refused nested namespace setup. The sandbox policy and assertions are unchanged. This result does not resolve startup on Ubuntu 26.04 or replace the failed local full-repository receipt.
55
+
56
+ - Leading word intervals such as `/loop every 10 minutes check CI` set the cadence instead of becoming part of the submitted prompt. Interval extraction preserves internal newlines.
57
+ - Different loop prompts run independently. Each `Loop` result includes an ID in text and details. With several loops running, `loop_id` selects a wake, stop, or replacement, and `/loop stop <id>` selects a command-line stop. Re-arming the same prompt replaces its schedule. Real Pi RPC regressions observe both prompts repeating and one continuing after the other stops.
58
+ - Leaving a planning branch restores the pre-plan tools when Pi has no recorded system-message tool loadout to replay. Both the recorded and unrecorded cases run through real Pi tree navigation.
59
+ - `CreatePlan` preserves todo dependencies, `is_project`, and project phases in the plan file. Building loads unfinished root todos from that file, including review edits. Imported lists survive a Pi restart. Worktree builders import their own lists before their first model request and restore the plan association on resume. Writable `TodoWrite` updates synchronize matching root statuses while preserving quotes, comments, custom metadata, and the plan body. Readonly resumes update only the session list. `plan-worker-baseline.txt` and `plan-worker-treatment.txt` record the actual Pi RPC regression.
60
+ - A reviewed todo without a status imports as pending and now records later completion in the saved file. The synchronizer inserts only the missing field. Unit regressions cover block and flow mappings, trailing commas, and CRLF. An actual Pi RPC regression covers the same edit. `plan-missing-status-baseline.txt` and `plan-missing-status-treatment.txt` retain the failing and passing cases.
61
+ - Task stale-lock recovery uses the same token-directory lease as subscription ownership. A two-process regression forces the former check-to-remove race and observes one owner after the repair. Task status also treats an unreaped Linux zombie as exited rather than blocking recovery indefinitely. Older versions without the lease do not participate in this protection.
62
+ - `pr-review-canvas` names the system browser and `control-ui` instead of assuming Cursor's in-app browser. This is an instruction translation, not evidence that a real model completed a canvas review.
63
+ - A readonly Pi child reached a disposable Unix socket and caused its unsandboxed server to modify a file. The shell now keeps Unix sockets blocked and refuses a missing seccomp helper. The Linux host used for this audit refuses the helper's nested namespace setup, so the treatment proves failure-closed behavior, not successful restricted command execution. `readonly-boundary-baseline.txt`, `readonly-boundary-treatment.txt`, and `package-suite-readonly-strict.txt` retain the evidence. The latter has 675 passing tests and five failing positive shell checks. The earlier full repository pass predates this safety change.
64
+ - A fake Slack token remained readable in a readonly child's inherited environment. Benny's instructions now require separate credential isolation rather than inferring it from readonly tools. Setup stops without that proof, and operational runs keep analysis and code work in the coordinator. This instruction repair is not a live Slack integration test.
65
+
66
+ ## Repairs in 0.15.36-pi.12
67
+
68
+ A fresh reverse engineering of Cursor CLI 2026.10.22 with pstack and cursor-team-kit loaded found these differences. The repository's `parity/pi-pstack-behavior-parity/` holds the findings, the decision trail, and `probe-cursor.sh`, which reruns every Cursor probe. Each change has a test that failed on the earlier code.
69
+
70
+ - A Custom Mode keeps its skill in context for the whole session in Cursor (its docs, and `durable_skill_blocks` in the CLI's conversation state). pi-pstack sent the body on one request, so a model that replays the system prompt lost it after a turn. The skill now rides every request, and Cursor's exit and switch notice is sent once after a mode ends.
71
+ - A background completion uses Cursor's `<system_notification>` text, a title from the prompt's first line (80 characters at most), and its follow-up request; the launch text and Agent ID line use Cursor's words. An earlier repair had titled it by `description`, which Cursor shows in its UI but not in the model-facing notice.
72
+ - Task, TodoWrite, and AskQuestion carry Cursor's usage rules; AskQuestion needs two options per question.
73
+ - `explore` exists, and every subagent hears Cursor's subagent reminder. team-kit's thermo-nuclear agent text is upstream's again.
74
+ - `GenerateImage` exists on Pi's image models. pstack's `teach` and `ketchup` reach for an image tool, which codemode, off by default, did not provide.
75
+ - The path-skills module is gone. A live probe showed Cursor never surfaces a `paths` skill that sets `disable-model-invocation`, which is `typescript-best-practices`.
76
+ - Plan mode follows Cursor's instructions and `CreatePlan` contract, allows markdown edits, offers `SwitchMode`, and asks whether to build a saved plan.
77
+ - A `/loop` wake that comes due mid-run fires once after the run instead of being dropped, which had also stalled agent-paced loops.
78
+
47
79
  ## Repairs in 0.15.36-pi.11
48
80
 
49
81
  Each code change has a regression in the package suite. Text restorations are recorded here and checked against the reference by the parity audit.
@@ -85,10 +117,11 @@ Each code change has a regression in the package suite. Text restorations are re
85
117
  These are not closed by extension code.
86
118
 
87
119
  - **Background workers stop when the chat exits.** A Pi subagent is a child process of the chat, so quitting or shutting the session stops the agents it started and reports how many. Whether a Cursor background subagent outlives its parent is unobserved; the CLI changelog says cancelling the prompt stops its subagents, and only the cloud-agent product promises work after the laptop closes. A `new_session` subscription fire is Pi's one detached path, and it starts a fresh run rather than continuing a subagent.
88
- - **A mode carries its body once, then a reminder.** Cursor attaches the skill body on the turn that enters the mode and sends a path-naming reminder every turn after, in a user-message field. Pi rebuilds its prompt per request, so the body rides the first request after entry as a `pstack_mode` section and later requests carry the reminder. A process restart re-sends the body once, since the new process cannot know the conversation already saw it.
120
+ - **A mode's skill rides the system prompt.** Cursor attaches the skill to the user message that enters the mode and keeps it durable in the conversation; its notices travel in user-message fields. Pi carries the skill and the notices in system-prompt sections, which reach the model on every request and survive compaction, so the model sees the same text in a different place.
89
121
  - **A fork needs an idle source.** Cursor exposes `fork` only on its internal and cloud-agent protos, never on the CLI Task schema, and no doc states whether a fork may start while the source runs. A Pi fork runs in the source's directory or worktree, so a running source is refused; the orchestrate playbook says to wait for its completion notification.
90
- - **Plan mode's restriction is stricter than the host's.** Cursor's inspected CLI carries no client-side plan-mode filter, and its docs recommend stating read-only intent in the prompt, so the restriction on that surface is prompt or backend side; no source shows a plan-mode network rule. Pi enforces a tool allowlist and a sandboxed shell that also denies network, so `gh`, `curl`, and package queries can fail while planning.
91
- - **No host-managed plan review UI.** The plan is a file the agent writes with `create_plan`, and `/plan build` starts the work from it. Cursor also renders a plan review menu with "build locally", "build in cloud", and "no, propose changes", and can hand the plan to a cloud agent. Pi has no equivalent UI, and its plan review is the file plus the reply.
122
+ - **Linux readonly shells require nested namespace support.** The stricter policy must block host Unix sockets as well as IP traffic and filesystem writes. On a host that refuses sandbox-runtime's seccomp helper, the command does not run. Earlier checks that permitted all Unix sockets are not evidence for this policy. Readonly also does not isolate environment credentials or files readable through the ordinary read tools.
123
+ - **Plan mode's restriction is stricter than the host's.** Cursor's plan mode keeps every tool and restricts by instruction: edit only markdown files, run only read-only commands. Pi enforces the same rules with a tool allowlist, markdown-only `edit` and `write`, and a sandboxed shell that also denies network, so `gh`, `curl`, and package queries can fail while planning. Allowing network in a read-only shell would also open a path for remote changes, so the sandbox keeps it closed.
124
+ - **The plan review is a dialog, not a card.** Cursor renders the plan with a build menu. Pi shows the same three choices in a select dialog after the run that saved the plan, and "build in cloud" starts a background isolated worktree worker, Pi's counterpart to a cloud agent, rather than a remote VM.
92
125
  - **benny's default cadence still needs its owning session open.** `wake_self` timers and webhook routines park while the owner is offline. A timer or webhook routine created with `sessionStrategy: "new_session"` runs detached with no chat open, but a detached run is one-shot: it must do the work in that run, because a background `Task` ends with it. Cursor automations run in the cloud and can hand work to anything. So benny keeps `wake_self` by default and setup names the tradeoff before switching.
93
126
  - **A routines listener is local, one port per workspace.** Cursor hosts each routine URL. Pi binds a loopback port per workspace, so two workspaces serve routines at once only because the default port falls back to an ephemeral one that the workspace then reuses and reports. A sender outside the machine still needs its own forwarding path.
94
127
  - **Cloud execution is local.** Cursor documents cloud VMs for its cloud product, but the inspected CLI schema omits `environment` and a requested cloud Task ran on the same machine and directory. Pi's `environment: "cloud"` goes further with a git worktree and a separate local process. Neither runs with the laptop off or provides a remote VM.
@@ -99,11 +132,22 @@ These are not closed by extension code.
99
132
  - **Hosted guidance and pages are outside the package.** MCP providers, ticket trackers, browsers, simulators, and Tailscale remain the user's own dependencies, as they are for Cursor.
100
133
  - **Background usage cannot enter parent totals.** Pi exposes no API that adds a later notification's usage to the parent session. It stays in the notification details and the child transcript.
101
134
 
135
+ ## Session probes on 2026-11-04 (continuation)
136
+
137
+ These observations update earlier open notes. They do not make the package VERIFIED.
138
+
139
+ - Cursor's live `TodoWrite` accepted a one-item write even though the published schema sets `minItems: 2` and requires `content` and `status` on every item. Pi keeps `minItems: 1` and status-only merges, which matches that runtime behavior. Evidence: this session's `CallDynamicTool` one-item call, plus `test/e2e/todo.e2e.test.ts` merge updates.
140
+ - On this Linux host, `kernel.apparmor_restrict_unprivileged_userns=1`. Socket-restricted sandbox commands fail in `apply-seccomp` while writing `/proc/self/setgroups`. The same sandbox with `allowAllUnixSockets: true` runs under bubblewrap and denies writes. Docker and passwordless sudo were unavailable here, so the positive restricted path remains a host blocker. CI on Ubuntu 24.04 still owns that green path.
141
+ - Benny operational skills now resolve `SOURCE_THREAD_TS` from `thread_ts`, then `message_ts`, then `ts`, so the documented webhook payload works when `thread_ts` is empty. Upstream Cursor skills still name only `trigger.ts`. Completeness audit: `parity/pstack-reconstruction-2026-11-04/session-2026-11-04T19-completeness.json`.
142
+ - The sibling `cursor-sdk` plugin remains out of scope. No pstack skill or agent references it.
143
+
102
144
  ## Open evidence
103
145
 
104
146
  The following were not observed end to end and are not claimed.
105
147
 
106
148
  - A real model following every ported skill on both hosts.
149
+ - Cursor's project-phase execution UI and per-phase build behavior. Pi preserves phase metadata but does not reproduce that UI.
150
+ - Hosted cloud plan execution's full todo lifecycle and simultaneous independent builders updating one plan. Native worktree startup, resume, dependency retention, writable status synchronization, and readonly non-synchronization have actual Pi RPC evidence.
107
151
  - Authenticated MCP exchanges and provider-specific tool behavior.
108
152
  - A successful live Cursor run for each workflow after the reference capture.
109
153
  - Reboot survival through a real launchd or systemd unit on both platforms.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justjoshn/pi-pstack",
3
- "version": "0.15.36-pi.11",
4
- "description": "pstack 0.15.36 for Pi with its soft-dependency team-kit skills vendored in: rigorous agent workflows and principles as Pi skills, with the host features they use: subagents, todos, modes, plan mode, the model rule, /loop, subscriptions and routines, AskQuestion, and visualize",
3
+ "version": "0.15.36-pi.13",
4
+ "description": "pstack 0.15.36 for Pi with its soft-dependency team-kit skills vendored in: rigorous agent workflows and principles as Pi skills, with the host features they use: subagents, todos, modes, plan mode, the model rule, /loop, subscriptions and routines, AskQuestion, SwitchMode, image generation, and visualize",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "pstackSource": {
@@ -64,7 +64,8 @@
64
64
  "live:e2e": "node scripts/live-e2e.mjs"
65
65
  },
66
66
  "dependencies": {
67
- "@anthropic-ai/sandbox-runtime": "0.0.79"
67
+ "@anthropic-ai/sandbox-runtime": "0.0.79",
68
+ "yaml": "2.9.0"
68
69
  },
69
70
  "peerDependencies": {
70
71
  "@earendil-works/pi-ai": "*",
@@ -20,7 +20,7 @@ Call `subscribe_webhook`. Set these fields:
20
20
  The routine slug is the kebab-case form of the name.
21
21
  The result gives the routine URL, `http://127.0.0.1:<port>/routines/<slug>`, and the credential file path. Use the path the result names, such as `~/.pi/agent/pstack/routines/<slug>/credentials.json` (`PI_CODING_AGENT_DIR` moves it).
22
22
  The result does not include the sender key.
23
- The routine targets the owning Pi session and expires at the `expiresAt` the result names. The durable supervisor keeps the listener available after the chat exits. Wakes received while the owner is offline park until that session is restored. Keep the owner running for immediate UI actions, and check the routine with `list_subscriptions`. A timer with `sessionStrategy: "new_session"` can start detached work while the owner is offline. A webhook does not use that strategy.
23
+ By default the routine wakes the owning Pi session, which keeps its context across presses the way a bot does. The durable supervisor keeps the listener available after the chat exits. Wakes received while the owner is offline park until that session is restored. Keep the owner running for immediate UI actions, and check the routine with `list_subscriptions`. To act on presses with no chat open, pass `sessionStrategy: "new_session"`: each accepted POST starts a fresh detached run without the owner's context, which must do the work itself. The routine does not expire unless `expiresInHours` sets a limit.
24
24
 
25
25
  ## Copy the URL and the sender key
26
26
 
@@ -157,7 +157,7 @@ Since renderer.js loads in `<head>`, you can also call `renderDiff(target, lines
157
157
  ```bash
158
158
  cd /tmp && python3 -m http.server 8432 --bind 127.0.0.1
159
159
  ```
160
- Run this backgrounded, then navigate the in-app browser to `http://127.0.0.1:8432/pr-review-{number}.html`.
160
+ Run this backgrounded. Open `http://127.0.0.1:8432/pr-review-{number}.html` in the system browser with `xdg-open` on Linux or `open` on macOS. Pi has no in-app browser. For automated inspection, use the `control-ui` skill and a local browser harness. If no graphical browser is available, report that limit and give the URL.
161
161
 
162
162
  **Why a fixed port and `cd /tmp`:** Background shells have no TTY, so Python buffers its startup message ("Serving HTTP on...") indefinitely — using port 0 means you can never read which port was chosen. And `--directory /tmp` works but `cd /tmp` is more robust across Python versions. If port 8432 is taken, try 8433, 8434, etc.
163
163
 
@@ -454,7 +454,16 @@ for (const signal of ["SIGINT", "SIGTERM"] satisfies NodeJS.Signals[]) {
454
454
  signalWhile(signal, () => ({
455
455
  dir: gridCase(150),
456
456
  reached: (parent) => {
457
- for (const f of fs.readdirSync(parent, { recursive: true, encoding: "utf8" }))
457
+ // The command creates and replaces draft trees while it writes. A recursive
458
+ // readdir can see a draft entry that is gone before Node descends into it.
459
+ let files: string[];
460
+ try {
461
+ files = fs.readdirSync(parent, { recursive: true, encoding: "utf8" });
462
+ } catch (error) {
463
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return false;
464
+ throw error;
465
+ }
466
+ for (const f of files)
458
467
  if (
459
468
  path.basename(f) === "chart.mmd" &&
460
469
  fs.statSync(path.join(parent, f), { throwIfNoEntry: false })?.size
@@ -14,7 +14,7 @@ Teach sits on top of `how` and `why`. Get your bearings on what the work is and
14
14
  2. Let `how` and `why` do the work, don't redo it. Read the code yourself to get oriented, then run `how` for how it works and `why` for why. Run them in parallel and combine the results. Match the size to the question. Run both for a subsystem, maybe one is enough for a small change. Keep `why` narrow by default since its full sweep is slow. Put the narrowing in the ask itself (a scoped question, git plus a source or two) so `why` records the skipped categories per its own contract, and widen it only when the reasons are the point.
15
15
  3. Start with a plain definition. Name the thing and say what it is in general terms, the way a senior engineer would say it out loud, with its common name if it has one. Then tie it to the case in front of you ("in X, we use this to ...") and build from there: how it works, the deeper reasons, the edge cases. For each part, explain the idea so it clicks: the problem it solves and how it actually works. Walk through what happens as the person does the thing (opens a long chat, scrolls up) when that is what makes it land. Listing functions and constants is reference, not teaching. Don't print framing labels ("the one idea to hold onto", "the thing to walk away with", "the key insight", "at its core", "TL;DR"). Give the smallest complete answer first, a sentence or two, not a dense paragraph, then stop. Add layers when they ask. Never a wall of text.
16
16
  4. Keep it a conversation, not a lecture or a performance. Offer to go deeper or move on, and follow their lead. No quizzes. No pacing theater. Don't print "Pause", don't ask them to say it back, don't announce "the sentence to nail", and don't flag a part as important or hard ("here is the part worth slowing down on", "this is the tricky part", "here is where it gets interesting"). Just say it. When you would pause, stop and let them respond. Running one-shot with no live human, deliver it cleanly and put any offer to go deeper at the end.
17
- 5. Show, don't only tell, and build the picture up diagram by diagram. Open the diff, the code, or the debugger when that is the fastest way to land it. Draw when a picture lands faster than words. For anything with three or more moving parts, do not draw one diagram with all of them at once. Draw a short series instead, where each diagram redraws the last and adds a single part, so the reader watches the system assemble. A single all-at-once diagram, especially one saved for the end, is a reference, not teaching. Concretely, to teach a flow from A to B to C, draw it three times. First A to B. Then redraw and add C. Then redraw and add the return edge or the next piece. Match the medium to the idea, and use both kinds when both help. A mermaid diagram fits a flow or structure where the labels carry the meaning. When the idea is spatial, like layout, overlap, scroll position, or a before and after, reach for image generation (Pi codemode's `models.generateImages()` when codemode is on and an image model is configured, otherwise a Mermaid diagram) and draw it marker-on-whiteboard style with a few short labels, since image models garble long text. Generate that picture, don't settle for describing it in words. The build-up rule holds for generated images too. A single simple point needs no figure.
17
+ 5. Show, don't only tell, and build the picture up diagram by diagram. Open the diff, the code, or the debugger when that is the fastest way to land it. Draw when a picture lands faster than words. For anything with three or more moving parts, do not draw one diagram with all of them at once. Draw a short series instead, where each diagram redraws the last and adds a single part, so the reader watches the system assemble. A single all-at-once diagram, especially one saved for the end, is a reference, not teaching. Concretely, to teach a flow from A to B to C, draw it three times. First A to B. Then redraw and add C. Then redraw and add the return edge or the next piece. Match the medium to the idea, and use both kinds when both help. A mermaid diagram fits a flow or structure where the labels carry the meaning. When the idea is spatial, like layout, overlap, scroll position, or a before and after, reach for the image-generation tool and draw it marker-on-whiteboard style with a few short labels, since image models garble long text. Generate that picture, don't settle for describing it in words. The build-up rule holds for generated images too. A single simple point needs no figure.
18
18
 
19
19
  Write every response through the **unslop** skill, in plain spoken English, the way you'd explain it to a colleague. Be tight, not terse. Cut filler and hedging, keep the part that makes it click. State the concrete mechanism, not a metaphor, a framing, or a preview of what is coming. This is the target density: "Virtualization runs in two parts, one for rendering and one for loading from disk. When an item scrolls out past the buffer, both its DOM node and its in-memory data are evicted." Normal sentence case, not all-lowercase. No em dashes. Prefer periods over commas. Keep each sentence to one or two commas. If clauses pile up, split them into separate sentences. Give each concept one name and keep it. Avoid mirror sentences ("A without B, or B without A") and tidy closers ("the rest follows", "it all falls out"). The words in these steps are directions to you, not labels to print. Don't echo the structure as headers or stock phrases.
20
20
 
package/src/ask.ts CHANGED
@@ -9,17 +9,22 @@ export const OTHER_ID = 'other';
9
9
  const SKIPPED = 'skipped (no one can answer questions in this session; decide yourself and say what you chose)';
10
10
 
11
11
  export const AskParams = Type.Object({
12
- title: Type.Optional(Type.String({ description: 'Short heading shown above the questions' })),
12
+ title: Type.Optional(Type.String({ description: 'Optional title for the questions form' })),
13
13
  questions: Type.Array(
14
14
  Type.Object({
15
- id: Type.String({ description: 'Stable identifier for the question' }),
16
- prompt: Type.String({ description: 'The question shown to the user' }),
17
- options: Type.Array(Type.Object({ id: Type.String(), label: Type.String(), description: Type.Optional(Type.String({ description: 'Detail shown after the label' })) }), {
18
- description: 'Choices the user picks from',
19
- }),
20
- allow_multiple: Type.Optional(Type.Boolean({ description: 'Let the user pick several options' })),
15
+ id: Type.String({ description: 'Unique identifier for this question' }),
16
+ prompt: Type.String({ description: 'The question text to display to the user, without the options.' }),
17
+ options: Type.Array(
18
+ Type.Object({
19
+ id: Type.String({ description: 'Unique identifier for this option' }),
20
+ label: Type.String({ description: 'Display text for this option' }),
21
+ description: Type.Optional(Type.String({ description: 'Detail shown after the label' })),
22
+ }),
23
+ { minItems: 2, description: 'Array of answer options (minimum 2 required)' },
24
+ ),
25
+ allow_multiple: Type.Optional(Type.Boolean({ description: 'If true, the user can select several options. Defaults to false.' })),
21
26
  }),
22
- { description: 'Questions asked one after another' },
27
+ { minItems: 1, description: 'Questions to present to the user, one after another (minimum 1 required)' },
23
28
  ),
24
29
  });
25
30
  export type Question = Static<typeof AskParams>['questions'][number];
@@ -102,8 +107,17 @@ export function registerAskQuestion(pi: ExtensionAPI): void {
102
107
  pi.registerTool({
103
108
  name: 'AskQuestion',
104
109
  label: 'Ask question',
105
- description:
106
- 'Ask the user one or more structured multiple-choice questions and wait for the answers. Each answer comes back as option IDs, or as other with the text the user typed. Use it for a genuine product or preference choice, not for a fact you can check yourself.',
110
+ description: [
111
+ "Collect structured multiple-choice answers from the user. Use this tool only when you are blocked on a decision that is genuinely the user's to make: one you cannot resolve from the request, the code, or sensible defaults.",
112
+ '',
113
+ 'Usage notes:',
114
+ '- Give each question at least 2 options.',
115
+ '- The user can always pick "Other" and type an answer, which comes back as other with the text.',
116
+ '- Set allow_multiple: true to let the user pick several options.',
117
+ '- If you recommend an option, put it first and end its label with "(Recommended)".',
118
+ '',
119
+ 'Prefer this tool over listing options in your reply text as letters, numbers, or bullets.',
120
+ ].join('\n'),
107
121
  promptSnippet: 'Structured multiple-choice questions for the user',
108
122
  parameters: AskParams,
109
123
  exposure: 'model-only',
package/src/child-env.ts CHANGED
@@ -7,6 +7,7 @@ export const READONLY_ENV = 'PI_PSTACK_READONLY';
7
7
  export const ROOT_STORE_ENV = 'PI_PSTACK_ROOT_STORE';
8
8
  export const WORKSPACE_ENV = 'PI_PSTACK_WORKSPACE_STATE';
9
9
  export const ROOT_WORKSPACE_ENV = 'PI_PSTACK_ROOT_WORKSPACE';
10
+ export const BUILD_PLAN_ENV = 'PI_PSTACK_BUILD_PLAN';
10
11
 
11
12
  export interface ChildIdentity {
12
13
  depth: number;
@@ -18,6 +19,7 @@ export interface ChildIdentity {
18
19
  workspaceState: string | undefined;
19
20
  /** The main chat's working directory, which authorizes every record stored in its shared workspace. */
20
21
  rootWorkspace: string | undefined;
22
+ buildPlan: string | undefined;
21
23
  }
22
24
 
23
25
  function read(): ChildIdentity {
@@ -31,6 +33,7 @@ function read(): ChildIdentity {
31
33
  rootStore: process.env[ROOT_STORE_ENV] || undefined,
32
34
  workspaceState: process.env[WORKSPACE_ENV] || undefined,
33
35
  rootWorkspace: process.env[ROOT_WORKSPACE_ENV] || undefined,
36
+ buildPlan: process.env[BUILD_PLAN_ENV] || undefined,
34
37
  };
35
38
  }
36
39
 
@@ -42,6 +45,7 @@ delete process.env[READONLY_ENV];
42
45
  delete process.env[ROOT_STORE_ENV];
43
46
  delete process.env[WORKSPACE_ENV];
44
47
  delete process.env[ROOT_WORKSPACE_ENV];
48
+ delete process.env[BUILD_PLAN_ENV];
45
49
 
46
50
  /** Variables for a child of this process at `depth` (an agent keeps the depth it was created at). */
47
51
  export function childVariables(agentType: string, depth: number, readonly: boolean, rootStore: string, workspaceState: string, rootWorkspace: string): Record<string, string> {