pi-odd-worktree 3.15.1 → 3.16.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.
Files changed (126) hide show
  1. package/README.md +48 -25
  2. package/extensions/odd-worktree-tools.ts +64 -211
  3. package/lib/shell-api/api.ts +523 -0
  4. package/lib/shell-api/arm.ts +83 -0
  5. package/lib/shell-api/bus.ts +1389 -0
  6. package/lib/shell-api/capture.ts +1340 -0
  7. package/lib/shell-api/card-style-line.ts +112 -0
  8. package/lib/shell-api/card-style-rows.ts +390 -0
  9. package/lib/shell-api/card-style-transform.ts +862 -0
  10. package/lib/shell-api/card-style-wiring.ts +477 -0
  11. package/lib/shell-api/card-styles.ts +153 -0
  12. package/lib/shell-api/config.ts +71 -0
  13. package/lib/shell-api/extension.ts +247 -0
  14. package/lib/shell-api/hook.ts +322 -0
  15. package/lib/shell-api/index.ts +88 -0
  16. package/lib/shell-api/message-design-adoption.ts +549 -0
  17. package/lib/shell-api/message-design-rows.ts +313 -0
  18. package/lib/shell-api/message-design-wiring.ts +369 -0
  19. package/lib/shell-api/message-designs.ts +746 -0
  20. package/lib/shell-api/notices.ts +137 -0
  21. package/lib/shell-api/plugin-lines.ts +877 -0
  22. package/lib/shell-api/presence.ts +258 -0
  23. package/lib/shell-api/repaint.ts +351 -0
  24. package/lib/shell-api/row-labels.ts +146 -0
  25. package/lib/shell-api/row-names.ts +273 -0
  26. package/lib/shell-api/row-origin.ts +144 -0
  27. package/lib/shell-api/rows.ts +591 -0
  28. package/lib/shell-api/section-panel.ts +378 -0
  29. package/lib/shell-api/section-pointer.ts +164 -0
  30. package/lib/shell-api/sections-preview.ts +275 -0
  31. package/lib/shell-api/sections-rows.ts +133 -0
  32. package/lib/shell-api/sidebar-render.ts +705 -0
  33. package/lib/shell-api/sidebar.ts +1126 -0
  34. package/lib/shell-api/store.ts +279 -0
  35. package/lib/shell-api/tool-design-adoption.ts +263 -0
  36. package/lib/shell-api/tool-design-rows.ts +307 -0
  37. package/lib/shell-api/tool-design-wiring.ts +481 -0
  38. package/lib/shell-api/tool-designs.ts +1411 -0
  39. package/lib/shell-api/transform-pipeline.ts +351 -0
  40. package/lib/shell-api/types.ts +803 -0
  41. package/lib/shell-api/visibility.ts +154 -0
  42. package/package.json +3 -2
  43. package/tools/files-bridge.test.js +81 -66
  44. package/tools/fixtures/load-extension.js +40 -18
  45. package/tools/issues-command.test.js +4 -7
  46. package/tools/issues-section.test.js +71 -81
  47. package/tools/odd-rail-wiring.test.js +16 -10
  48. package/tools/package-surface.test.js +42 -13
  49. package/tools/prs-command.test.js +11 -6
  50. package/tools/shell-api/api.test.ts +484 -0
  51. package/tools/shell-api/apply-on-move.test.ts +529 -0
  52. package/tools/shell-api/arm.test.ts +220 -0
  53. package/tools/shell-api/bridge-ready.test.ts +309 -0
  54. package/tools/shell-api/bus.test.ts +194 -0
  55. package/tools/shell-api/button-rows.test.ts +435 -0
  56. package/tools/shell-api/capture.test.ts +583 -0
  57. package/tools/shell-api/card-style-rows.test.ts +493 -0
  58. package/tools/shell-api/card-style-transform.test.ts +379 -0
  59. package/tools/shell-api/card-style-wiring.test.ts +258 -0
  60. package/tools/shell-api/card-styles-e2e.test.ts +502 -0
  61. package/tools/shell-api/card-styles.test.ts +324 -0
  62. package/tools/shell-api/card-transcript-path.test.ts +178 -0
  63. package/tools/shell-api/compatibility-regression.test.mjs +64 -0
  64. package/tools/shell-api/config.test.ts +93 -0
  65. package/tools/shell-api/docs-coverage.test.ts +82 -0
  66. package/tools/shell-api/e2e.test.ts +562 -0
  67. package/tools/shell-api/example-bash-identity.test.ts +372 -0
  68. package/tools/shell-api/example-bash-matrix.test.ts +856 -0
  69. package/tools/shell-api/example-designs.test.ts +737 -0
  70. package/tools/shell-api/example-neon-transform.test.ts +283 -0
  71. package/tools/shell-api/example-plain-style.test.ts +1225 -0
  72. package/tools/shell-api/extension.test.ts +157 -0
  73. package/tools/shell-api/fake-events.ts +58 -0
  74. package/tools/shell-api/fake-host.ts +211 -0
  75. package/tools/shell-api/fake-sidebar.ts +516 -0
  76. package/tools/shell-api/fake-transcript.ts +486 -0
  77. package/tools/shell-api/frame-telemetry.test.ts +317 -0
  78. package/tools/shell-api/hook.test.ts +196 -0
  79. package/tools/shell-api/manifest.test.ts +47 -0
  80. package/tools/shell-api/message-design-adoption.test.ts +611 -0
  81. package/tools/shell-api/message-design-follows.test.ts +361 -0
  82. package/tools/shell-api/message-design-pi-release.test.mjs +157 -0
  83. package/tools/shell-api/message-design-regressions.test.mjs +162 -0
  84. package/tools/shell-api/message-design-rows.test.ts +266 -0
  85. package/tools/shell-api/message-design-wiring.test.ts +362 -0
  86. package/tools/shell-api/message-designs.test.ts +339 -0
  87. package/tools/shell-api/new-category.test.ts +1101 -0
  88. package/tools/shell-api/notices.test.ts +292 -0
  89. package/tools/shell-api/plugin-integration-lines.test.ts +827 -0
  90. package/tools/shell-api/presence.test.ts +396 -0
  91. package/tools/shell-api/rail-part-hits.test.ts +281 -0
  92. package/tools/shell-api/rail-surfaces.test.ts +402 -0
  93. package/tools/shell-api/rail-width.test.ts +406 -0
  94. package/tools/shell-api/regression.test.ts +434 -0
  95. package/tools/shell-api/repaint-api.test.ts +200 -0
  96. package/tools/shell-api/reserved-categories.test.ts +250 -0
  97. package/tools/shell-api/row-labels.test.ts +261 -0
  98. package/tools/shell-api/row-names.test.ts +407 -0
  99. package/tools/shell-api/row-origin.test.ts +395 -0
  100. package/tools/shell-api/row-placement-regression.test.ts +797 -0
  101. package/tools/shell-api/row-placement.test.ts +410 -0
  102. package/tools/shell-api/section-interaction.test.ts +364 -0
  103. package/tools/shell-api/section-panel.test.ts +430 -0
  104. package/tools/shell-api/section-placement-rail.test.ts +390 -0
  105. package/tools/shell-api/section-placement.test.ts +386 -0
  106. package/tools/shell-api/sections-preview.test.ts +312 -0
  107. package/tools/shell-api/sections-rows.test.ts +293 -0
  108. package/tools/shell-api/sidebar-backend.test.ts +477 -0
  109. package/tools/shell-api/sidebar-e2e.test.ts +317 -0
  110. package/tools/shell-api/sidebar-hover.test.ts +276 -0
  111. package/tools/shell-api/sidebar-independent.test.ts +291 -0
  112. package/tools/shell-api/sidebar-render.test.ts +281 -0
  113. package/tools/shell-api/sidebar-sections.test.ts +247 -0
  114. package/tools/shell-api/store.test.ts +192 -0
  115. package/tools/shell-api/surface-repaint-cost.test.ts +520 -0
  116. package/tools/shell-api/tool-design-card-style.test.ts +308 -0
  117. package/tools/shell-api/tool-design-chain.test.ts +471 -0
  118. package/tools/shell-api/tool-design-cost.test.ts +591 -0
  119. package/tools/shell-api/tool-design-rows.test.ts +627 -0
  120. package/tools/shell-api/tool-design-scopes-audit.test.ts +212 -0
  121. package/tools/shell-api/tool-designs.test.ts +2412 -0
  122. package/tools/shell-api/transform-pipeline.test.ts +376 -0
  123. package/tools/shell-api/transforms-bus.test.ts +233 -0
  124. package/tools/shell-api/verifier-width-regressions.test.ts +147 -0
  125. package/tools/shell-api-rpc.test.js +189 -0
  126. package/tools/user-prompt-card.test.js +8 -9
package/README.md CHANGED
@@ -17,9 +17,9 @@ Two agent tools, five panels, the `/identity` command, two sidebar sections and
17
17
  | `/issues` | panel | Reads this checkout's GitHub issues — the three scoped tabs on open, every open issue behind `g` — and, when your role allows it, edits them. `enter` inserts the focused issue into the chat input as `ISSUE #63`, and each linked pull request in the pane is its own click that opens that pull request in `/prs`. |
18
18
  | `/prs` | panel | The same reader for pull requests: `My Pull Request`, `Needs My Review` and `Involved` on open, every open pull request of the repository behind `g`, the pane's `Changes` and `Checks` summaries, and — when your role allows it — comment, labels, assignees, the linked issues, merge (after a confirmation naming the method and the commit message) and close. `enter` inserts the focused pull request as `PR #87`, and each linked issue in the pane is its own click that opens that issue in `/issues`. |
19
19
  | `GITHUB` rail section | sidebar section | Lists the open issues of this checkout's repository you authored or are assigned, seven at a time plus a count of the rest, and its header counts the pull requests beside them (`7 issues · 3 pr`: your own plus the ones awaiting your review). A click opens that issue in `/issues` on `Assigned` — or, when the issue carries a linked pull request, that pull request in `/prs` on the bucket it belongs to; the overflow row opens `/issues`. Needs `gh`. |
20
- | `ODD` rail section | sidebar section | Lists the ODDs this session is ASSOCIATED with — the ones it (or a subagent it ran) wrote or edited, rebuilt from its own active branch, so old and resumed sessions show theirs too — four at a time plus a count of the rest, right after the host's `AGENTS` part. One row per ODD name across main and the worktrees the session registered, with `main` or the worktree's own name at the far right saying which copy the click opens (the most recently modified one; `main` breaks an exact tie), and with nothing associated it draws one dim `no ODD associated` line instead of listing the disk. A click opens `/odd` on that document; the associated ODDs this session wrote or edited come first. Does not need `Worktrees+`: registration is what scopes it. Needs gentle-shell-bridge with its rail. |
21
- | `activity` card design | design on the bridge's `Card activity` line | Optional, and selected for you on the first run: a bash card's heading names the activity its command does, each family in its own theme colour, and — while that line answers for the tool being painted — the skill/ODD file cards, the background-job cards and the two advisory messages follow it. |
22
- | `color` diff design | design on the bridge's `Card diff` line | Optional, and selected for you on the first run: redraws `write` and `edit` as an IDE pane — a write's content behind a line-number gutter, an edit's diff — in the active theme's own syntax roles. |
20
+ | `ODD` rail section | sidebar section | Lists the ODDs this session is ASSOCIATED with — the ones it (or a subagent it ran) wrote or edited, rebuilt from its own active branch, so old and resumed sessions show theirs too — four at a time plus a count of the rest, right after the host's `AGENTS` part. One row per ODD name across main and the worktrees the session registered, with `main` or the worktree's own name at the far right saying which copy the click opens (the most recently modified one; `main` breaks an exact tie), and with nothing associated it draws one dim `no ODD associated` line instead of listing the disk. A click opens `/odd` on that document; the associated ODDs this session wrote or edited come first. Does not need `Worktrees+`: registration is what scopes it. Needs the rail a Gentle Shell draws. |
21
+ | `activity` card design | design on the shell API's `Card activity` line | Optional, and selected for you on the first run: a bash card's heading names the activity its command does, each family in its own theme colour, and — while that line answers for the tool being painted — the skill/ODD file cards, the background-job cards and the two advisory messages follow it. |
22
+ | `color` diff design | design on the shell API's `Card diff` line | Optional, and selected for you on the first run: redraws `write` and `edit` as an IDE pane — a write's content behind a line-number gutter, an edit's diff — in the active theme's own syntax roles. |
23
23
 
24
24
  Moving the session and removing a checkout are human actions: only `/warp` does either, and no agent tool can. A checkout has one identity, its ODD: the directory name is the ODD it serves, and `branch` is only the git branch.
25
25
 
@@ -29,49 +29,71 @@ Moving the session and removing a checkout are human actions: only `/warp` does
29
29
 
30
30
  | Requirement | Why it is needed |
31
31
  | --- | --- |
32
- | [`gentle-shell-bridge`](https://github.com/jonasotoaguilar/gentle-shell-bridge), installed **first** | Every surface this package registers. Without it the package loads nothing at all — no command, no tool, no card, no rail — and only names that install line, in a primary session. |
33
32
  | Pi (`@earendil-works/pi-coding-agent`, `@earendil-works/pi-tui`) | Peer dependencies supplied by the host; the package installs no runtime dependencies. |
34
33
  | Node.js >= 18 and `git` | Every repository operation is a `git` child process. |
35
- | Gentle Shell (recommended) | Supplies the session records the deletion guard reads to see other sessions, and the rail the `GITHUB` and `ODD` sections are drawn in. |
34
+ | Gentle Shell (`gentle-pi`) | Supplies the session records the deletion guard reads to see other sessions, the rail the `GITHUB` and `ODD` sections are drawn in, the `/gentle:customize` command the shell API checks before it arms any row, section or design, and the host theme those draw with. Without it the six commands, the two tools and this package's own cards still load; the customize rows, both rails and the `Card activity`/`Card diff` designs stay off, and the package says so once, naming `gentle-pi`. |
36
35
  | `gh`, authenticated (`gh auth login`) | `/issues`, `/prs` and the `GITHUB` rail section, and them alone. Without `gh` on `PATH` none of the three is registered at all — `/issues` and `/prs` never load and the section is never added to the rail, so there is nothing to refuse and no line to draw — and every other surface keeps working. |
37
36
 
38
37
  ### Install
39
38
 
40
- `gentle-shell-bridge` goes first: it is the API every surface of this package is registered through.
39
+ `pi-odd-worktree` is the only install. It carries its own extension point for gentle-shell —
40
+ the shell API in `lib/shell-api/` — so nothing else goes first and no second plugin is needed.
41
41
 
42
42
  ```bash
43
- # 1. the bridge, a prerequisite for every surface here
44
- pi install npm:gentle-shell-bridge
45
-
46
- # 2. this package
47
43
  pi install npm:pi-odd-worktree
48
44
  ```
49
45
 
50
- Inside a Gentle Shell session use its launcher, in the same order:
46
+ Inside a Gentle Shell session use its launcher:
51
47
 
52
48
  ```bash
53
- gentle-shell install npm:gentle-shell-bridge
54
49
  gentle-shell install npm:pi-odd-worktree
55
50
  ```
56
51
 
57
52
  From a local clone, `pi install .` installs the working copy, and `gentle-shell install .` does the same from inside a Gentle Shell session.
58
53
 
54
+ The standalone `gentle-shell-bridge` is no longer needed: this package publishes the same global
55
+ API state, and an older copy left installed shares it ("first wins") instead of conflicting with it.
56
+
59
57
  ### Expected result
60
58
 
61
- `/warp`, `/odd`, `/files`, `/identity`, `/issues` and `/prs` are available as commands — `/issues` and `/prs` only where `gh` is on `PATH` — the agent is offered `worktree_create` and `worktree_list`, a Gentle Shell whose rail is drawn shows a `GITHUB` section for this checkout and an `ODD` section listing the ODDs the session is working on, and its `/gentle:customize` → `Cards` page offers `activity` on its `Card activity` line.
59
+ `/warp`, `/odd`, `/files`, `/identity`, `/issues` and `/prs` are available as commands — `/issues`
60
+ and `/prs` only where `gh` is on `PATH` — the agent is offered `worktree_create` and
61
+ `worktree_list`, a Gentle Shell whose rail is drawn shows a `GITHUB` section for this checkout and an
62
+ `ODD` section listing the ODDs the session is working on, and its `/gentle:customize` → `Cards` page
63
+ offers `activity` on its `Card activity` line.
62
64
 
63
- ### Bridge versions
65
+ ### Shell API version
64
66
 
65
- Older bridges register less, never something different:
67
+ The shell API this package publishes reports `VERSION` `0.16.2`, so every floor the
68
+ [reference](docs/reference.md) names below it is already satisfied. The per-version notes there
69
+ describe gates that exist in the code, not a choice you make at install time.
66
70
 
67
- | Bridge | What it can hold |
68
- | --- | --- |
69
- | `0.5.0` | One `Card bash` row, bash alone; `activity` still heads a bash card with the family its command names. |
70
- | `0.6.0` | One `Card activity` row over `bash`, `grep`, `find`, `ls` and `read`; the file card's question arrives in `0.7.0`. |
71
- | `0.9.0` | The scoped claim that puts `write` and `edit` on the `activity` line, and the `Card diff` line itself. |
72
- | `0.12.1` | The two advisory message cards, which follow the `Card activity` line with no row of their own. |
71
+ ## Extend gentle-shell through odd-worktree
72
+
73
+ A plugin reaches gentle-shell through this package alone. Read the slot:
74
+
75
+ ```ts
76
+ const api = globalThis[Symbol.for("gentle-shell-bridge/api/v1")];
77
+ ```
73
78
 
74
- Below a row's floor the surface registers nothing and Pi's own card stays byte-identical. The `Card activity` line and, with it, every card that follows it are documented in [the reference](docs/reference.md#the-cards-the-activity-design-paints).
79
+ Its identity is `schema: "gentle-shell-bridge/api"`, `version: 1` and `VERSION` `0.16.2`, and it
80
+ offers settings rows and pages, sidebar sections, card styles, transcript transforms, per-tool and
81
+ per-message card designs, a repaint request and a small namespaced store. The contract is
82
+ [`docs/shell-api/contract.md`](https://github.com/jonasotoaguilar/odd-worktree/blob/main/docs/shell-api/contract.md),
83
+ with
84
+ [`architecture.md`](https://github.com/jonasotoaguilar/odd-worktree/blob/main/docs/shell-api/architecture.md),
85
+ [`state.md`](https://github.com/jonasotoaguilar/odd-worktree/blob/main/docs/shell-api/state.md) and a
86
+ worked example in
87
+ [`examples/bash-card.ts`](https://github.com/jonasotoaguilar/odd-worktree/blob/main/docs/shell-api/examples/bash-card.ts);
88
+ start at [`docs/shell-api/README.md`](https://github.com/jonasotoaguilar/odd-worktree/blob/main/docs/shell-api/README.md).
89
+ Those pages live in the repository, not in the published tarball.
90
+
91
+ The surfaces are still DRAWN by `gentle-pi`, the package registering `/gentle:customize`: without it
92
+ the API arms nothing, and this package says so once, naming `gentle-pi` and the rows, sections and
93
+ designs that are off. If another plugin published an incompatible object on the slot first, the
94
+ package registers no surface at all — its commands and tools included — and it says that once too,
95
+ naming the slot and the schema and version it actually holds. Neither message is silent, and in the
96
+ first case everything but the shell surfaces keeps working.
75
97
 
76
98
  ## Core Workflow
77
99
 
@@ -84,7 +106,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
84
106
 
85
107
  ## Key Capabilities
86
108
 
87
- - **Two halves are optional.** With `gentle-shell-bridge`, `/gentle:customize` has a `Tools` page with an Off/On line for `Codegraph+` (the CodeGraph prompt text, reminders and wiring; its card follows the `Card activity` line like every other card) and one for `Worktrees+` (the worktree tools, `/warp`, the worktree guards and prompt text). Both are On by default; a change needs `/reload` and a new session. See [the module switches](docs/reference.md#the-module-switches).
109
+ - **Two halves are optional.** On the shell API's `Tools` page in `/gentle:customize` there is an Off/On line for `Codegraph+` (the CodeGraph prompt text, reminders and wiring; its card follows the `Card activity` line like every other card) and one for `Worktrees+` (the worktree tools, `/warp`, the worktree guards and prompt text). Both are On by default; a change needs `/reload` and a new session. See [the module switches](docs/reference.md#the-module-switches).
88
110
  - **OpenCode Go usage comes built in, and every peak window has its own switch.** The `opencode-go` provider is registered on Gentle Shell's own usage event, so `/gentle:usage`, the status-bar segment and the panel's `r` refresh work exactly as they do for the providers the shell ships. Above the editor, one row per provider whose peak window is running, in the registry's order: `peak · 2× deepseek · until 04:00` (OpenCode Go bills DeepSeek at double rate in weekdays 01:00–04:00 and 06:00–10:00 UTC) and `peak · claude · until 10:00` (weekdays 05:00–11:00 Pacific; Anthropic publishes no price multiplier there — the subscription window drains faster instead). A row never depends on the model the session uses or on a usage key: only that provider's switch and its window matter. `/gentle:customize` → `Alert`, between `Notifications` and `Layout`, holds one Off/On line per provider — `Deepseek peak`, `Claude peak` — **all Off on a first run**, applied without `/reload`. A third provider costs no change outside the registry. See [the usage source and the peak rows](docs/reference.md#the-opencode-go-usage-source-and-the-peak-rows-above-the-editor).
89
111
  - **A create is instant and writes no state.** The directory is the whole record; there is no list file and no lock file.
90
112
  - **Deleting refuses on a live session.** The guard reads Gentle Shell's presence records, discloses what it could not resolve, and never auto-warps. Removal is `git worktree remove` and the branch is kept. See [the deletion guard](docs/reference.md#the-deletion-guard-and-its-honest-limit).
@@ -96,7 +118,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
96
118
  - **`/issues` and `/prs` link to each other.** In the issues pane every linked pull request number is its own click that opens `/prs` on it; in the pull request pane every linked issue number is its own click that opens `/issues` on it. The panel you clicked in closes first, so two panels never stack, and a line's label, its separators and a `#N` in a title or a body are not click targets. A linked reference is identified by repository AND number, so one that belongs to another repository is painted as `owner/repo#N` and is not a click at all: a same-numbered lookalike here is never opened by mistake. See [the cross-links](docs/reference.md#the-cross-links-between-the-two-panels).
97
119
  - **`/issues` can open on one issue.** `/issues 42` (or `/issues #42`) opens the panel on `Assigned` with that issue selected, and a number that tab cannot find says so instead of guessing a row. `prs`'s sibling form is `/prs 42` (or `/prs #42`), which opens on `My Pull Request` with that pull request selected — on `Needs My Review` when a rail click named that bucket, saying `#42 is not in My Pull Request` when neither holds it.
98
120
  - **`/issues` and `/prs` pin the repository.** Every read, mutation and browser open is bound to the repository that was loaded, and capabilities fail closed. See [the repository pin](docs/reference.md#issues-pins-the-repository).
99
- - **The GitHub rail is checkout-scoped and optional.** When a Gentle Shell draws its rail, a `GITHUB` rail section lists the open issues of this checkout's repository you authored or are assigned — that one repository, not every issue across every repository you touch — seven at a time, with `and N more issues` for the rest and a pull-request mark on the issues that already have one, and its header counts the pull requests beside them (`7 issues · 3 pr`, the distinct rows of your own and the ones awaiting your review; the segment appears once that read lands, and a stalled list still reads `· stale`). A click on an issue that carries a linked pull request opens `/prs` on that pull request — `Needs My Review` winning when it belongs to both buckets, `My Pull Request` next, and the `all` view when the rail's read places it in neither — instead of the issue; every other row opens that issue in `/issues` on `Assigned`, in no case a browser. The click does not prove the repository itself — the panel it opens pins and proves the checkout, so a row left over from another checkout still dispatches its number and the panel decides — and `/issues`' own `o` key is still the browser. The overflow row opens `/issues` with no number. While the rail's cache holds this repository, `/issues` paints its first frame from it and reads one tab at mount instead of three, the other two reading the first time you open them; the cache outlives both the session and the process — one document under `$XDG_CACHE_HOME/odd-worktree/` — so a warm checkout's first read is already a delta, and the rail's pull requests are persisted the same way (`prs-rail.json`) so a cold start paints `N issues · M pr` at once. A frame never waits on `gh`, and neither does a session start: the `gh` gate is dispatched, never awaited, so no child process and no network call sits on opening or switching a session. While the section is drawn it re-reads on its own 20 s timer — the issues and the pull requests behind the same floor — keeps no timer while hidden, stops the moment it is no longer drawn, and a `bash` command that mutates an issue or a pull request forces one read behind a 5 s cap; a failed refresh keeps the rows and marks them `stale`, and a failed pull-request read keeps the count already painted. Without `gh` on `PATH` neither the section nor `/issues`/`/prs` exists at all — the commands are never registered and the section is never added to the rail — and every other surface keeps working. With no bridge the section simply never appears. See [the rail section](docs/reference.md#the-github-rail-section).
121
+ - **The GitHub rail is checkout-scoped and optional.** When a Gentle Shell draws its rail, a `GITHUB` rail section lists the open issues of this checkout's repository you authored or are assigned — that one repository, not every issue across every repository you touch — seven at a time, with `and N more issues` for the rest and a pull-request mark on the issues that already have one, and its header counts the pull requests beside them (`7 issues · 3 pr`, the distinct rows of your own and the ones awaiting your review; the segment appears once that read lands, and a stalled list still reads `· stale`). A click on an issue that carries a linked pull request opens `/prs` on that pull request — `Needs My Review` winning when it belongs to both buckets, `My Pull Request` next, and the `all` view when the rail's read places it in neither — instead of the issue; every other row opens that issue in `/issues` on `Assigned`, in no case a browser. The click does not prove the repository itself — the panel it opens pins and proves the checkout, so a row left over from another checkout still dispatches its number and the panel decides — and `/issues`' own `o` key is still the browser. The overflow row opens `/issues` with no number. While the rail's cache holds this repository, `/issues` paints its first frame from it and reads one tab at mount instead of three, the other two reading the first time you open them; the cache outlives both the session and the process — one document under `$XDG_CACHE_HOME/odd-worktree/` — so a warm checkout's first read is already a delta, and the rail's pull requests are persisted the same way (`prs-rail.json`) so a cold start paints `N issues · M pr` at once. A frame never waits on `gh`, and neither does a session start: the `gh` gate is dispatched, never awaited, so no child process and no network call sits on opening or switching a session. While the section is drawn it re-reads on its own 20 s timer — the issues and the pull requests behind the same floor — keeps no timer while hidden, stops the moment it is no longer drawn, and a `bash` command that mutates an issue or a pull request forces one read behind a 5 s cap; a failed refresh keeps the rows and marks them `stale`, and a failed pull-request read keeps the count already painted. Without `gh` on `PATH` neither the section nor `/issues`/`/prs` exists at all — the commands are never registered and the section is never added to the rail — and every other surface keeps working. A host whose rail is not drawn registers the section and never paints it. See [the rail section](docs/reference.md#the-github-rail-section).
100
122
  - **The ODD rail lists what this session is working on — and nothing else.** A second section, titled `ODD` and placed right after the host's own `AGENTS` part, lists ONLY the ODDs this session is associated with, four at a time, with `<N> more` for the rest, as ONE row per ODD name, never one per checkout: when the same ODD exists in main and in a worktree the row's right-hand gray cell says which copy the click opens, `main` or the worktree's own name, and the copy on offer is the most recently modified document (`main` breaks an exact tie). The association is by ODD name and is rebuilt from the session's own ACTIVE branch, so an old session written before the touch entry existed and a resumed one both show their ODDs: a successful `write`/`edit` on `odd/tasks/<name>.md`, the session's persisted touch entries, a subagent's `files_changed:` report and the `Spec:` line of the subagent task that started it (a subagent's write counts for the parent), while a failed write and an abandoned branch's work do not count. A document this session just wrote shows at once. A new session is associated with nothing on disk, so the body is ONE dim `no ODD associated` line instead of a bare box. The checkouts are the worktrees this session registered — the same session entries `/odd`, `/files` and this section all read — so a registered worktree whose `odd/tasks` has nothing new or different from main contributes nothing, a worktree registered only on an abandoned branch is out of scope, and the section keeps working with `Worktrees+` off. The associated ODDs this session wrote or edited come first and force an immediate re-read; attribution is the filter AND the order, and the grouped model still decides what exists and where. The `/odd` panel is unchanged: it keeps listing main whole plus each worktree's delta. A click sends `/odd <document>` to the host, so the panel opens on exactly that ODD, and a second click while an open is in flight does nothing. See [the ODD rail section](docs/reference.md#the-odd-rail-section).
101
123
  - **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).
102
124
  - **Tool headings can name the activity.** With `activity` chosen on the `Card activity` line, a bash card whose heading shows the whole command is headed with the family its command names instead of `$`, and a `grep`, `find` or `ls` card is headed `⌕ exploring`; a 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).
@@ -111,7 +133,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
111
133
  - **Three 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. `## User identity` states your name in one line, and it is there only while a name is stored. All three are appended after the host's own text; `ODD_WORKTREE_PROMPT=0` suppresses the first two, and the third is the stored name's business alone. See [the prompt block](docs/reference.md#the--odd-worktrees-block-in-the-system-prompt) and [the user identity block](docs/reference.md#the--user-identity-block-in-the-system-prompt).
112
134
  - **CodeGraph stays fresh, only when its CLI is installed.** At session start the package creates or syncs the checkout's index and warms its daemon, and makes sure your global `mcp.json` has the `codegraph` entry. It also syncs after a compaction, after a native `codegraph init` and after an `edit` or `write`, in the background and without ever blocking you. See [CodeGraph](docs/reference.md#codegraph-index-daemon-and-mcp-entry).
113
135
  - **Two reminders keep a session on the CodeGraph rule.** The first `grep`, `find`, `ls`, `read` or `bash` search in a checkout gets one sentence appended to its result: use `codegraph` first, or — for another checkout — call `mcp__codegraph__codegraph_explore` with that path as `projectPath`. Neither is ever a block, and a subagent child hears neither. See [the reminders](docs/reference.md#the-two-codegraph-reminders).
114
- - **Deliberately absent.** No customize panel of its own, no plugin-tools toggles, no companion-app integration and no worktree-to-issue association. There is nothing to configure here: the card designs are chosen on the bridge's own lines, so this package owns no preference of its own. See [deliberately absent](docs/reference.md#deliberately-absent).
136
+ - **Deliberately absent.** No customize panel of its own, no plugin-tools toggles, no companion-app integration and no worktree-to-issue association. There is nothing to configure here: the card designs are chosen on the shell API's own lines, so this package owns no preference of its own. See [deliberately absent](docs/reference.md#deliberately-absent).
115
137
 
116
138
  ## Documentation
117
139
 
@@ -122,6 +144,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
122
144
  | Understand a create, a warp or a delete in detail | [Reference](docs/reference.md) |
123
145
  | Run the suite or see what CI and releases do | [Tests](docs/reference.md#tests), [CI and releases](docs/reference.md#ci-and-releases) |
124
146
  | Change the package, follow its invariants or cut a release | [`docs/codebase/mental-model.md`](docs/codebase/mental-model.md) |
147
+ | Extend gentle-shell from your own plugin | [`docs/shell-api/README.md`](https://github.com/jonasotoaguilar/odd-worktree/blob/main/docs/shell-api/README.md), then [`contract.md`](https://github.com/jonasotoaguilar/odd-worktree/blob/main/docs/shell-api/contract.md) |
125
148
  | Report a bug or request a feature | [`.github/ISSUE_TEMPLATE/`](.github/ISSUE_TEMPLATE/) |
126
149
  | Open a pull request | [`.github/PULL_REQUEST_TEMPLATE.md`](.github/PULL_REQUEST_TEMPLATE.md) |
127
150
 
@@ -34,6 +34,14 @@
34
34
 
35
35
  import { Type } from "@earendil-works/pi-ai";
36
36
  import { defineTool } from "@earendil-works/pi-coding-agent";
37
+ // S2/S4 (native-bridge T5): the shell API is THIS PACKAGE'S OWN CODE (`lib/shell-api/`), not a
38
+ // second plugin. Importing it publishes the frozen API object at
39
+ // `Symbol.for("gentle-shell-bridge/api/v1")` at MODULE LOAD — before any `session_start`,
40
+ // and with no external plugin required — which is why the slot is already published when
41
+ // the factory below runs. A plain-JS host stubs this one import
42
+ // (`tools/fixtures/load-extension.js`), which is what keeps `tools/*.test.js` free of
43
+ // TypeScript.
44
+ import bridgeExtension from "../lib/shell-api/extension.ts";
37
45
  import { createRequire } from "node:module";
38
46
  import { spawn } from "node:child_process";
39
47
  import * as fs from "node:fs";
@@ -8523,25 +8531,13 @@ let issuesGateOpen = null;
8523
8531
  let issuesGateProbe = null;
8524
8532
  let issuesGateGeneration = 0;
8525
8533
 
8526
- // S3 (issues-sidebar): the rail section beside the `/issues` reader. The
8527
- // bridge is read from its published slot, never imported; the section reads ONE
8528
- // in-process snapshot per frame and refreshes on its frame TTL and on the
8529
- // session's own activity behind the floor below — never at `session_start`, and
8530
- // never while it is hidden (T13).
8534
+ // S3 (issues-sidebar): the rail section beside the `/issues` reader. The shell API's
8535
+ // RUNTIME is this package's own code (`lib/shell-api/`), and the API OBJECT is read from its
8536
+ // published slot, exactly as a third-party plugin reads it; the section reads ONE in-process
8537
+ // snapshot per frame and refreshes on its frame TTL and on the session's own activity behind
8538
+ // the floor below — never at `session_start`, and never while it is hidden (T13).
8531
8539
  const ISSUES_SIDEBAR_BRIDGE_SLOT = Symbol.for("gentle-shell-bridge/api/v1");
8532
8540
  const ISSUES_SIDEBAR_READY_EVENT = "gentle-shell-bridge:ready";
8533
- // S2 amended (T11): the ONE hint a host without the bridge gets. It names the
8534
- // install command verbatim, because the user's own words were "pone el comando
8535
- // de instalacion".
8536
- const ISSUES_SIDEBAR_INSTALL_HINT = "the issues rail needs the gentle-shell-bridge plugin: install it with pi install npm:gentle-shell-bridge";
8537
- // The announcement window. An empty slot at `session_start` is "not yet" — the
8538
- // bridge publishes from its own extension load — so the check waits this long
8539
- // before it is honest to call the plugin missing.
8540
- const ISSUES_SIDEBAR_INSTALL_WINDOW_MS = 2000;
8541
- // "One warning per process" includes a `/reload`, which builds a NEW instance of
8542
- // this module: the fact that the human was already told lives on a process-wide
8543
- // slot, exactly like the bridge's own published object does.
8544
- const ISSUES_SIDEBAR_WARN_SLOT = Symbol.for("odd-worktree/issues-sidebar/install-warned");
8545
8541
  // S3 (activity floor): a frame only exists when the host has a reason to produce
8546
8542
  // one, so the TTL never fires on a session that is merely in use. The session's
8547
8543
  // own events ask for a read at most once per this floor.
@@ -8614,12 +8610,6 @@ let issuesSidebarCacheGeneration = 0;
8614
8610
  // the cache can ignore an answer that is older than the last one applied for the
8615
8611
  // same identity — a full read that finishes late never overwrites a newer one.
8616
8612
  let issuesSidebarReadSequence = 0;
8617
- // T11: one hint per process. `Armed` keeps two session starts from arming two
8618
- // checks; `Announced` is what a late publication sets, so the deferred check
8619
- // never speaks over a bridge that arrived; the "already told the human" fact
8620
- // itself lives on the process-wide slot above, so `/reload` is silent too.
8621
- let issuesSidebarInstallArmed = false;
8622
- let issuesSidebarInstallAnnounced = false;
8623
8613
  // S1 (issues-sidebar-click T1): ONE rail open at a time. A click on a row (or on
8624
8614
  // the overflow row) takes this token SYNCHRONOUSLY before `sendUserMessage`, so
8625
8615
  // two clicks in the same tick cannot both pass, and a click while it is held does
@@ -10099,8 +10089,9 @@ function issuesGateMessage(error) {
10099
10089
  //
10100
10090
  // Every other surface keeps working without `gh` — `/warp`, `/odd`, `/files`,
10101
10091
  // the tools, the cards, the bash design, the prompt append and CodeGraph — because
10102
- // "no desactiva todo el plugin, eso dije". The only plugin-wide switch in this
10103
- // package is the missing `gentle-shell-bridge` (S18).
10092
+ // "no desactiva todo el plugin, eso dije". The bridge is this package's own now
10093
+ // (native-bridge S2), so the only plugin-wide switch left is the published
10094
+ // object's own schema and version gate (S18): an INCOMPATIBLE slot registers nothing.
10104
10095
  //
10105
10096
  // The guards below stay as DEFENCE IN DEPTH, not as the policy: a `gh` that
10106
10097
  // disappears after the extension loaded still fails the gate and the rail's read
@@ -11136,9 +11127,8 @@ let userPromptCardEpoch = 0;
11136
11127
  let userPromptCardPendingEpoch;
11137
11128
  // Whether the session that owns this shim is the live one. It starts CLOSED — Pi loads the
11138
11129
  // factory before any session exists — and `session_start` opens it. Every path into the host
11139
- // package (the design registration, a `gentle-shell-bridge:ready` announcement, a gate observer
11140
- // woken by a silent publication, a load that resolved late) checks it before arming and again
11141
- // before patching.
11130
+ // package (the design registration, a `gentle-shell-bridge:ready` announcement, a load that
11131
+ // resolved late) checks it before arming and again before patching.
11142
11132
  let userPromptCardSessionLive = false;
11143
11133
  // Whether this load already owns the session boundary (the pair below). A load may arm an
11144
11134
  // install only once it owns the shutdown that unwraps it, whichever path got there first.
@@ -11235,15 +11225,14 @@ function requestPromptCardRepaintNow() {
11235
11225
  }
11236
11226
 
11237
11227
  /**
11238
- * The prompt card's session boundary — registered ONCE per load, by whichever path can first arm
11239
- * an install: the factory when a bridge is already published, the ready subscription, or the gate
11240
- * observer when a silent publication wakes it.
11228
+ * The prompt card's session boundary — registered ONCE per load, by the factory, which owns it
11229
+ * beside the surface registration it gates.
11241
11230
  *
11242
- * S7: the boundary may not live behind the surface's own registration (a gate-closed load with no
11243
- * bus registered no surface and therefore no shutdown hook at all, so a session that woke the
11231
+ * S7: the boundary may not live behind the surface's own registration (a load whose slot check
11232
+ * failed registered no surface and therefore no shutdown hook at all, so a session that woke the
11244
11233
  * surface left the class wrapped), and a bridge announced during a shutdown must find a session
11245
11234
  * that is already closed. Registering the pair is not a SURFACE registration — it contributes no
11246
- * command, tool, section, design or card — so a gate-closed load still ships nothing.
11235
+ * command, tool, section, design or card — so a load that ships nothing still ships no surface.
11247
11236
  *
11248
11237
  * OWNING THE TEARDOWN IS A PRECONDITION OF INSTALLING, so the SHUTDOWN hook is registered FIRST
11249
11238
  * and a host that refuses it (or has no `pi.on`) owns nothing: the start hook is never registered
@@ -11273,9 +11262,8 @@ function registerUserPromptCardLifecycle(pi) {
11273
11262
  installUserPromptCard();
11274
11263
  });
11275
11264
  } catch {
11276
- // An accepted shutdown is still ownership: the teardown exists, so a session opened by the
11277
- // gate observer (a `session_start` it accepted) is still unwrapped. Nothing installs without
11278
- // one of those paths opening the session.
11265
+ // An accepted shutdown is still ownership: the teardown exists, so a session this load
11266
+ // opened is still unwrapped. Nothing installs without one of those paths opening the session.
11279
11267
  }
11280
11268
  userPromptCardLifecycleRegistered = true;
11281
11269
  return true;
@@ -11570,9 +11558,6 @@ function registerIssuesSidebar(pi) {
11570
11558
  }
11571
11559
  if (issuesSidebarSubscribed) return;
11572
11560
  const subscribed = subscribeBridgeReady(pi, () => {
11573
- // T11: a publication that arrives late makes the missing-plugin hint
11574
- // untrue, so it is recorded before anything else is attempted.
11575
- issuesSidebarInstallAnnounced = true;
11576
11561
  try {
11577
11562
  registerIssuesSidebar(pi);
11578
11563
  } catch {
@@ -11985,82 +11970,6 @@ function bindIssuesShortcut(pi) {
11985
11970
  }
11986
11971
  }
11987
11972
 
11988
- // T11 (S2 amended, L10): discoverability is the ONE thing a host without the
11989
- // bridge gets. Nothing throws today — every bridge call is guarded — so this is a
11990
- // hint, not error handling: ONE warning per process, from a primary session only
11991
- // (the same `GENTLE_PI_AGENTS_CHILD` signal the prompt block uses, so a subagent
11992
- // never speaks for the human), naming the install command verbatim.
11993
- function warnIssuesSidebarMissing(ctx) {
11994
- if (issuesSidebarInstallWarnedAlready()) return;
11995
- if (process.env.GENTLE_PI_AGENTS_CHILD === "1") return;
11996
- const notify = ctx && ctx.ui ? ctx.ui.notify : undefined;
11997
- // A host with no notice seam cannot be told anything; the flag stays clear so
11998
- // a later session that does have one still gets the single warning.
11999
- if (typeof notify !== "function") return;
12000
- markIssuesSidebarInstallWarned();
12001
- try {
12002
- notify(ISSUES_SIDEBAR_INSTALL_HINT, "warning");
12003
- } catch {
12004
- // A notice is best effort; it never breaks startup.
12005
- }
12006
- }
12007
-
12008
- function issuesSidebarInstallWarnedAlready() {
12009
- try {
12010
- return globalThis[ISSUES_SIDEBAR_WARN_SLOT] === true;
12011
- } catch {
12012
- return false;
12013
- }
12014
- }
12015
-
12016
- function markIssuesSidebarInstallWarned() {
12017
- try {
12018
- globalThis[ISSUES_SIDEBAR_WARN_SLOT] = true;
12019
- } catch {
12020
- // A frozen global still gets the warning; only the dedupe is lost.
12021
- }
12022
- }
12023
-
12024
- // T11: the check itself, and the part that must be timed honestly. An empty slot
12025
- // at `session_start` means "not yet": the bridge publishes from its own load, so
12026
- // with a bus the check waits the announcement window and warns only if the slot
12027
- // is STILL empty and no announcement arrived in between. A host with no bus can
12028
- // never announce, so there it warns at once. The timer is unref'd: a hint never
12029
- // holds the process open.
12030
- function checkIssuesSidebarInstall(pi, ctx) {
12031
- try {
12032
- if (issuesSidebarInstallWarnedAlready()) return;
12033
- if (issuesSidebarBridge() !== null) return;
12034
- if (process.env.GENTLE_PI_AGENTS_CHILD === "1") return;
12035
- const events = pi && pi.events ? pi.events : null;
12036
- if (!events || typeof events.on !== "function") {
12037
- warnIssuesSidebarMissing(ctx);
12038
- return;
12039
- }
12040
- if (issuesSidebarInstallArmed) return;
12041
- issuesSidebarInstallArmed = true;
12042
- let timer;
12043
- try {
12044
- timer = setTimeout(() => {
12045
- issuesSidebarInstallArmed = false;
12046
- try {
12047
- if (issuesSidebarInstallAnnounced) return;
12048
- if (issuesSidebarBridge() !== null) return;
12049
- warnIssuesSidebarMissing(ctx);
12050
- } catch {
12051
- // A failed hint never breaks the session.
12052
- }
12053
- }, ISSUES_SIDEBAR_INSTALL_WINDOW_MS);
12054
- } catch {
12055
- issuesSidebarInstallArmed = false;
12056
- return;
12057
- }
12058
- if (timer && typeof timer.unref === "function") timer.unref();
12059
- } catch {
12060
- // The rail is optional: a failed hint never breaks startup.
12061
- }
12062
- }
12063
-
12064
11973
  function rememberIssuesSidebarSession(ctx) {
12065
11974
  if (!ctx || typeof ctx !== "object") return;
12066
11975
  issuesSidebarCtx = ctx;
@@ -12212,47 +12121,32 @@ function oddSessionStillCurrent(ctx) {
12212
12121
  return event === undefined || event === current;
12213
12122
  }
12214
12123
  // ---------------------------------------------------------------------------
12215
- // S18 (T14, L13): the bridge gate. This package is a guest of
12216
- // gentle-shell-bridge — the rail, the bash design and the `Cards` rows all live
12217
- // on its published object (the picker's `alt+p` shortcut is bound on the host
12218
- // itself, but only once this gate has registered the command it opens) — and the human's
12219
- // answer for what to do without it was exactly "Desactivar todo el plugin":
12220
- // register NOTHING. No command, no tool, no message or entry renderer, no card,
12221
- // no rail, no hook, no prompt append.
12124
+ // S18 (T14, L13; native-bridge T5): the shell API is this package's OWN code.
12125
+ // `lib/shell-api/` holds it as ordinary modules, never a nested package, and importing it —
12126
+ // the static import at the top of this file — publishes the compatible API object at the
12127
+ // process-global slot BEFORE any `session_start`, so the rail, the bash design, the `Cards`
12128
+ // rows and the card designs all exist with no external plugin installed. There is no gate to
12129
+ // wait on, no ready-event hold and no install hint: the API is not something a host could be
12130
+ // missing any more.
12222
12131
  //
12223
- // The bridge publishes ASYNCHRONOUSLY, and Pi may load this package before or after
12224
- // it, so the registration is DEFERRED rather than eager: everything registers the
12225
- // moment the bridge is known present (already on its slot at load, or announced on
12226
- // its ready event later), and if the announcement never comes the package registers
12227
- // nothing and only says how to install it. Nothing may register twice, whichever
12228
- // path arrives first.
12132
+ // What SURVIVES is the slot check, because the slot is process-global and another
12133
+ // plugin may have published an INCOMPATIBLE object first ("first wins"). A slot holding such
12134
+ // an object leaves every surface of this package silently UNREGISTERED: no command, no tool,
12135
+ // no message or entry renderer, no card, no rail, no prompt append — the shell API records
12136
+ // the foreign object as a notice instead. Nothing retries it either: the slot is read once
12137
+ // per factory call and the observer that used to wait for a later publication is gone.
12229
12138
  //
12230
- // The one thing that is NOT deferred is the notice's observer: `ctx.ui.notify`
12231
- // lives on a session, so the only way to name the missing plugin in a primary
12232
- // session is to observe `session_start` until the gate opens — one hook, kept sole
12233
- // while the gate is closed and released the moment the surface registers.
12139
+ // `subscribeBridgeReady` stays (the rail and the bash design rebind on a
12140
+ // republished object, which is generic and harmless), and nothing may register
12141
+ // twice, whichever moment arrives first.
12234
12142
  let oddSurfaceRegistered = false;
12235
- let bridgeGateDisposer = null;
12236
-
12237
- function releaseBridgeGateObserver() {
12238
- const dispose = bridgeGateDisposer;
12239
- bridgeGateDisposer = null;
12240
- if (typeof dispose !== "function") return;
12241
- try {
12242
- dispose();
12243
- } catch {
12244
- // A host that will not release the observer still has a harmless one.
12245
- }
12246
- }
12247
12143
 
12248
- // ONE registration per gate episode. The flag is set FIRST, so a path that fails
12249
- // half way can never re-register the parts that did land, and the two gate paths
12250
- // (already published at load, announced later) share it: whichever arrives first
12251
- // registers, the other is a no-op.
12144
+ // ONE registration per factory call. The flag is set FIRST, so a path that fails
12145
+ // half way can never re-register the parts that did land.
12252
12146
  function registerOddWorktreeSurface(pi) {
12253
12147
  if (oddSurfaceRegistered) return false;
12254
- // The bridge is the precondition, whichever path arrives: an announcement with
12255
- // no published object is not a bridge this package may load on.
12148
+ // The slot is the precondition: an absent or incompatible published object is
12149
+ // not a bridge this package may load on.
12256
12150
  if (issuesSidebarBridge() === null) return false;
12257
12151
  oddSurfaceRegistered = true;
12258
12152
  try {
@@ -12260,70 +12154,34 @@ function registerOddWorktreeSurface(pi) {
12260
12154
  } catch {
12261
12155
  // A host that refuses a registration keeps the rest of the surface.
12262
12156
  }
12263
- releaseBridgeGateObserver();
12264
12157
  return true;
12265
12158
  }
12266
12159
 
12267
- // While the bridge is absent: ONE ready-announcement subscription (the bridge may
12268
- // publish after us) and ONE session_start observer (the missing-plugin notice).
12269
- // Nothing else is registered.
12270
- function holdSurfaceForBridge(pi) {
12271
- let announced = false;
12272
- try {
12273
- announced = subscribeBridgeReady(pi, () => {
12274
- try {
12275
- registerOddWorktreeSurface(pi);
12276
- } catch {
12277
- // The gate stays closed; the announcement is not retried.
12278
- }
12279
- });
12280
- } catch {
12281
- announced = false;
12282
- }
12283
- // S7: with a bus, the bridge's announcement can wake the surface at ANY moment — a shutdown
12284
- // included — so the prompt card's session boundary has to exist from here on, even though no
12285
- // surface registered yet.
12286
- if (announced === true) registerUserPromptCardLifecycle(pi);
12287
- if (typeof pi?.on !== "function") return;
12288
- try {
12289
- const dispose = pi.on("session_start", (event, ctx) => {
12290
- // S7: the observer is a WAKE-UP path, not a session. The moment it wakes the surface it
12291
- // owns the session too — the boundary is acquired here and the session opened — so a
12292
- // silent publication on a host with no bus cannot leave the class wrapped after shutdown.
12293
- // Registering this pair is session bookkeeping, not a surface: a gate-closed load still
12294
- // registers no command, tool, section, design or card. A host that refuses the teardown
12295
- // owns nothing, so the session is NOT opened for it: no install, no patch.
12296
- if (registerUserPromptCardLifecycle(pi) === true) userPromptCardSessionLive = true;
12297
- // A bridge that was there all along, or arrived without an announcement,
12298
- // makes the notice untrue: register instead of warning.
12299
- if (issuesSidebarBridge() !== null) {
12300
- registerOddWorktreeSurface(pi);
12301
- return;
12302
- }
12303
- checkIssuesSidebarInstall(pi, ctx);
12304
- });
12305
- bridgeGateDisposer = typeof dispose === "function" ? dispose : null;
12306
- } catch {
12307
- // A host that refuses the observer still gets the install line nowhere else.
12308
- }
12309
- }
12310
-
12311
12160
  export default function (pi) {
12312
12161
  // A factory call is one registration episode. Pi builds a fresh registry for a
12313
12162
  // `/reload` and expects the same surfaces again, which is why the episode starts
12314
- // HERE; the gate's own two paths share the episode, so neither of them can
12315
- // register the surface twice.
12163
+ // HERE, so nothing can register the surface twice.
12316
12164
  oddSurfaceRegistered = false;
12317
- // S18 (T14): no bridge, no package. The published object is read from its slot
12318
- // after its own schema and version gate — never imported, never a dependency.
12165
+ // S2/S3 (native-bridge T5): this package's own shell API factory FIRST. It republishes the
12166
+ // slot object and announces it on `pi.events`, and on `session_start` it arms the rows, the
12167
+ // rail and the card designs, so those surfaces exist before any part of this package looks for
12168
+ // the object. A shell API that throws on the way out is never fatal: every other surface of
12169
+ // this package still loads.
12170
+ try {
12171
+ bridgeExtension(pi);
12172
+ } catch {
12173
+ // The shell API is this package's own code, but its failure still leaves the rest alone.
12174
+ }
12175
+ // S18 (T14): the slot check. The object is read after its own schema and version
12176
+ // gate; an absent or INCOMPATIBLE slot (another plugin published first) leaves this
12177
+ // package's surface unregistered. Nothing is said here: the shell API records the foreign
12178
+ // object itself as a notice.
12319
12179
  if (issuesSidebarBridge() !== null) {
12320
12180
  // S7: the prompt card's session boundary is owned here, before the surface registers, so
12321
12181
  // this load always has the shutdown hook that closes the session it belongs to.
12322
12182
  registerUserPromptCardLifecycle(pi);
12323
12183
  registerOddWorktreeSurface(pi);
12324
- return;
12325
12184
  }
12326
- holdSurfaceForBridge(pi);
12327
12185
  }
12328
12186
 
12329
12187
  function registerOddWorktreeSurfaceEntries(pi) {
@@ -12451,12 +12309,8 @@ function registerOddWorktreeSurfaceEntries(pi) {
12451
12309
  // S5 (T4/S5): dispatched, never awaited, and only while the rail is active.
12452
12310
  preloadIssuesSidebar(railHandleBefore, railWasDrawn);
12453
12311
  // S7: the prompt card's install belongs to the lifecycle pair the factory registers
12454
- // BEFORE the bridge gate (it must exist on a load that registered no surface), so this
12455
- // boundary leaves it alone: one owner for one session state.
12456
- // T11 (S2 amended): the missing-plugin hint. It is armed in the same
12457
- // boundary as the section's own state, and it says nothing yet when the
12458
- // host could still announce.
12459
- checkIssuesSidebarInstall(pi, ctx);
12312
+ // BEFORE the surface (it exists on its own, one owner for one session state), so this
12313
+ // boundary leaves it alone.
12460
12314
  // S5 (T8): the `gh` gate is DISPATCHED here, never awaited. The host awaits
12461
12315
  // every handler it is handed, one at a time, so awaiting it put the first
12462
12316
  // prompt behind `gh api user` + `gh repo view` and the checkout's own git
@@ -12524,9 +12378,8 @@ function registerOddWorktreeSurfaceEntries(pi) {
12524
12378
  // opencode-usage-alert: the schedule timer and the rows belong to the session that armed
12525
12379
  // them, so the ended session leaves neither behind.
12526
12380
  teardownOpenCodePeakAlert();
12527
- // S7: the prompt card's teardown belongs to the lifecycle pair registered before the
12528
- // bridge gate — the same owner as its install, so a session whose bridge was never
12529
- // present still closes (and its ready announcement can no longer arm an install).
12381
+ // S7: the prompt card's teardown belongs to the lifecycle pair the factory registers —
12382
+ // the same owner as its install, so a session whose install never landed still closes.
12530
12383
  });
12531
12384
  // Nothing deferred survives its session: shutdown advances the startup epoch,
12532
12385
  // so startup work still in flight drops instead of writing into the session