pi-odd-worktree 3.2.0 → 3.4.0

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/README.md CHANGED
@@ -26,6 +26,8 @@ The diff card is a design of the same kind, on a line of its own: `Card diff`, w
26
26
 
27
27
  The file cards are not a preference of this package either: they belong to that same `activity` value. While the bridge answers that `activity` draws the tool being painted, a `read`, `edit` or `write` call on a skill or an ODD artifact heads as that file — its own mark and label, the tool, the path and a read's line range, each in the theme role the reference design gives it — instead of a bare tool row, and its Markdown body is drawn by Pi's own renderer with the theme's Markdown roles. Choosing `default` on `Card tags`, or any other design on that line, gives every one of those calls back to the host. The question is asked of the bridge on every paint, so a mid-session switch repaints cards already on screen, and a bridge older than 0.7.0 — which cannot answer it — keeps the card it always had. See [the file cards](docs/reference.md#the-file-cards).
28
28
 
29
+ The jobs card follows the same value. Gentle Shell registers `bash_background`, `monitor`, `job_stop` and `job_list` with no renderer of their own, so Pi draws them in a plain box and neither `neon` nor `float` ever reaches them. While the bridge answers that `activity` draws the tool being painted, they are drawn on the same card substrate in the style the shell has chosen: the job's mark and name (its label, else the first line of its command), the whole command when expanded, and the job's own answer below. Under the `minimal` card content level the call is drawn alone, and a failure still says why. Any other answer on `Card tags`, no bridge, or a bridge older than 0.7.0 leaves Pi's own box exactly as it was. Unlike the file cards, the answer is read when a job card is built, because there is no host drawing to hand back on a later paint: a switch made mid-session reaches the next job card. See [the jobs card](docs/reference.md#the-jobs-card).
30
+
29
31
  ## Quick Start
30
32
 
31
33
  | Requirement | Why it is needed |
@@ -71,6 +73,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
71
73
  - **Cards follow your shell.** Tool and warp cards use the card style Gentle Shell publishes, and a click expands that card only. See [card style](docs/reference.md#card-style-follows-your-shell).
72
74
  - **Tool headings can name the activity.** With `activity` chosen on the `Card tags` line, a bash card whose heading shows the whole command is headed with the family its command names (mark and word) instead of `$`, and a `grep`, `find` or `ls` card is headed `⌕ exploring` instead of its own glyph and name, while a `read` — which runs no shell command — keeps the host's own card, colour and width; a bash command the classifier cannot name, or a heading that hides part of it, keeps the host's `$`. See [the cards the `activity` design paints](docs/reference.md#the-cards-the-activity-design-paints).
73
75
  - **File calls on a skill or an ODD are cards too.** While `Card tags` answers with `activity` for the tool being painted, a `read`, `edit` or `write` call whose path names a skill (anything below a `skills` folder) or an ODD (anything below an `odd` folder) heads as that file, with the tool, the path and a read's line range; its Markdown body — the whole document when expanded, the first rows when collapsed — is drawn by Pi's own renderer in the theme's Markdown roles, and an edit always keeps its diff. Any other file call, and every call while that line answers anything else, is the host's own row. See [the file cards](docs/reference.md#the-file-cards).
76
+ - **Background-job tools are cards too.** While `Card tags` answers with `activity` for the tool being painted, `bash_background`, `monitor`, `job_stop` and `job_list` are drawn in the shell's own card style instead of Pi's plain box. Any other answer leaves Pi's box untouched. See [the jobs card](docs/reference.md#the-jobs-card).
74
77
  - **`edit` and `write` cannot land in the principal checkout's default branch.** A write whose path is inside the principal checkout of the session's repository, while that checkout is on the default branch, is refused with one line pointing at `worktree_list` and `worktree_create`. Paths outside the repository, anything under the OS temp directories, other repositories and linked worktrees are never blocked. See [the guard](docs/reference.md#the-edit-and-write-guard).
75
78
  - **`bash` cannot leave the principal checkout's default branch.** A `git worktree add` or `git worktree list` is refused in any cwd and pointed at `worktree_create` and `worktree_list`; in the principal checkout, a switch that would leave the branch it is on is refused while that branch is the repository's default, and creating a branch is not blocked. See [the guards](docs/reference.md#the-bash-guards).
76
79
  - **Two blocks in the system prompt.** `## ODD worktrees` tells the agent how worktrees and ODDs work. `## CodeGraph` tells a session that already holds a CodeGraph tool how to use it, with one text per role. Both are appended after the host's own text, and `ODD_WORKTREE_PROMPT=0` suppresses them. See [the prompt blocks](docs/reference.md#the--odd-worktrees-block-in-the-system-prompt).
@@ -3064,6 +3064,30 @@ function readCurrentBranch(git, root) {
3064
3064
  return readGitTextSync(git, root, ["symbolic-ref", "--quiet", "--short", "HEAD"]);
3065
3065
  }
3066
3066
 
3067
+ // invariant 22: the skill-read guard, the second `tool_call` observation that REFUSES a
3068
+ // `bash` call — a reader (`cat`, `sed -n`, `head`, …) pointed at a skill file, which the
3069
+ // `read` tool is for. The decision is `lib/skill-read-guard.js`'s: text-only, over the
3070
+ // command string, and only for the `bash` tool. Nothing is registered here either — no
3071
+ // command, no tool, no option and no setting — and `ODD_WORKTREE_GUARD=0`, the worktree
3072
+ // guard's own switch, turns this guard off the same way, read per call.
3073
+ function guardSkillReadBashCall(event) {
3074
+ try {
3075
+ if (process.env.ODD_WORKTREE_GUARD === "0") return undefined;
3076
+ if (!event || event.toolName !== "bash") return undefined;
3077
+ const guard = libRequire("skill-read-guard.js");
3078
+ if (!guard || typeof guard.decideSkillReadGuard !== "function") return undefined;
3079
+ const input = event.input || {};
3080
+ const decision = guard.decideSkillReadGuard(input.command);
3081
+ if (decision && decision.block === true && typeof decision.reason === "string") {
3082
+ return { block: true, reason: decision.reason };
3083
+ }
3084
+ return undefined;
3085
+ } catch {
3086
+ // invariant 22: the guard never throws into the host, and a command it cannot judge passes.
3087
+ return undefined;
3088
+ }
3089
+ }
3090
+
3067
3091
  // The registered `tool_call` handler: the guard's one host surface. A non-`bash` call
3068
3092
  // returns before any module is read, and the git answers ride in as the guard's seams:
3069
3093
  // the identity and the default branch memoized per checkout, the current branch read
@@ -9821,16 +9845,22 @@ function registerOddWorktreeSurfaceEntries(pi) {
9821
9845
  startupEpoch += 1;
9822
9846
  });
9823
9847
  pi.on("tool_call", (event, ctx) => handleWorktreeOddEvent(event, ctx, pi));
9824
- // S1/S3/S4/S9: the worktree guard, the ONE `tool_call` observation that refuses a
9848
+ // S1/S3/S4/S9: the worktree guard, the first `tool_call` observation that refuses a
9825
9849
  // `bash` command instead of observing it. It sits beside the naming handler and is
9826
- // the only handler that returns a `block` answer; every other tool call is left
9827
- // exactly as the host proposed it. Nothing about it is callable by the agent (S7).
9850
+ // one of the two handlers that return a `block` answer — the skill-read guard, below,
9851
+ // is the other; every other tool call is left exactly as the host proposed it. Nothing
9852
+ // about it is callable by the agent (S7).
9828
9853
  pi.on("tool_call", (event, ctx) => guardWorktreeBashCall(event, ctx));
9829
9854
  // S4 (T3): the write guard, a second `tool_call` observation that refuses an `edit`
9830
9855
  // or `write` into the primary checkout while it sits on the default branch. It is a
9831
9856
  // sibling of the bash guard, not a part of it: the two read different inputs, and a
9832
9857
  // `bash` call and a file write are refused for different reasons.
9833
9858
  pi.on("tool_call", (event, ctx) => guardWorktreeWriteCall(event, ctx));
9859
+ // invariant 22: the skill-read guard, the second refusal and the guard registered LAST
9860
+ // of the two, so a call that would break both shows the worktree refusal. It reads the
9861
+ // command text only, shares the same `ODD_WORKTREE_GUARD=0` switch, and adds no
9862
+ // command, tool, option or setting of its own.
9863
+ pi.on("tool_call", (event) => guardSkillReadBashCall(event));
9834
9864
  pi.on("tool_result", (event, ctx) => handleWorktreeOddEvent(event, ctx, pi, true));
9835
9865
  // S10 (T9): ONE `tool_result` observation for the rail's forced refresh. It
9836
9866
  // answers the `bash` tool only — every other tool returns before the classifier
@@ -9949,6 +9979,16 @@ function registerOddWorktreeSurfaceEntries(pi) {
9949
9979
  } catch {
9950
9980
  // The card is cosmetic.
9951
9981
  }
9982
+ // The jobs card, through the same host hook: `bash_background`, `monitor`, `job_stop` and
9983
+ // `job_list` have no renderer of their own, so Pi draws a plain box and the conversation's
9984
+ // card style never reaches them. While the bridge's `Card tags` line answers with this
9985
+ // package's activity design for the tool, they are drawn on the card substrate in the
9986
+ // shell's own style; any other answer leaves Pi's drawing exactly as it was.
9987
+ try {
9988
+ libRequire("jobs-card-resolver.js").registerJobsCard(pi, { metrics: () => resolveWorktreeToolCardMetrics() });
9989
+ } catch {
9990
+ // The card is cosmetic.
9991
+ }
9952
9992
  // The live-checkout scan is DISPATCHED and never awaited. Its only product is
9953
9993
  // `warpDiscoveryCache`, which nothing reads — every warp lists fresh before
9954
9994
  // acting — so the old "startup barrier" awaited three git reads for a result the