pi-odd-worktree 2.0.0 → 3.0.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 (160) hide show
  1. package/README.md +54 -311
  2. package/extensions/odd-worktree-tools.ts +4149 -2447
  3. package/lib/bash-activity.js +1164 -0
  4. package/lib/bash-design.js +684 -0
  5. package/lib/bash-destructive.js +559 -0
  6. package/lib/bash-frame.js +205 -0
  7. package/lib/card-content.js +23 -0
  8. package/lib/card-style.js +175 -0
  9. package/lib/checkout-facts.js +30 -70
  10. package/lib/codegraph-card-preview.js +628 -0
  11. package/lib/codegraph-card.js +515 -0
  12. package/lib/codegraph-compaction.js +76 -0
  13. package/lib/codegraph-daemon.js +246 -0
  14. package/lib/codegraph-edit-sync.js +182 -0
  15. package/lib/codegraph-guard-target.js +337 -0
  16. package/lib/codegraph-guard.js +211 -0
  17. package/lib/codegraph-index.js +1020 -0
  18. package/lib/codegraph-lock.js +607 -0
  19. package/lib/codegraph-mcp-config.js +134 -0
  20. package/lib/codegraph-mcp.js +123 -0
  21. package/lib/codegraph-paths.js +69 -0
  22. package/lib/codegraph-prompt/explore.md +11 -0
  23. package/lib/codegraph-prompt/fix.md +6 -0
  24. package/lib/codegraph-prompt/generic.md +8 -0
  25. package/lib/codegraph-prompt/judge.md +9 -0
  26. package/lib/codegraph-prompt/orchestrator.md +17 -0
  27. package/lib/codegraph-prompt/verify.md +10 -0
  28. package/lib/codegraph-prompt/worker.md +7 -0
  29. package/lib/codegraph-role.js +55 -0
  30. package/lib/codegraph-rules.js +146 -0
  31. package/lib/codegraph-session.js +303 -383
  32. package/lib/codegraph-warmup.js +139 -0
  33. package/lib/file-card-markdown.js +141 -0
  34. package/lib/file-card-resolver.js +245 -0
  35. package/lib/file-card.js +659 -0
  36. package/lib/files-index.js +387 -0
  37. package/lib/files-insert.js +81 -0
  38. package/lib/files-orders.js +326 -0
  39. package/lib/files-picker-view.js +1416 -0
  40. package/lib/files-preview.js +338 -0
  41. package/lib/files-scope-detail.js +171 -0
  42. package/lib/files-scope-view.js +507 -0
  43. package/lib/gh-issues.js +308 -14
  44. package/lib/issue-preview.js +26 -7
  45. package/lib/issues-bash-mutation.js +206 -0
  46. package/lib/issues-cache-store.js +261 -0
  47. package/lib/issues-section.js +710 -0
  48. package/lib/issues-view.js +649 -52
  49. package/lib/odd-prompt/odd-worktrees.md +21 -0
  50. package/lib/odd-worktrees-prompt.js +10 -28
  51. package/lib/related-issues-cache.js +210 -0
  52. package/lib/shell-card.js +825 -0
  53. package/lib/skill-odd-card.js +183 -0
  54. package/lib/tui-paint.js +4 -5
  55. package/lib/warp-create-panel.js +538 -250
  56. package/lib/warp-create-picker.js +56 -9
  57. package/lib/warp-delete-confirm.js +19 -28
  58. package/lib/warp-selector-view.js +160 -82
  59. package/lib/which-command.js +90 -0
  60. package/lib/worktree-card.js +267 -897
  61. package/lib/worktree-cards.js +383 -0
  62. package/lib/worktree-create.js +287 -0
  63. package/lib/worktree-git.js +3 -3
  64. package/lib/worktree-guard.js +548 -0
  65. package/lib/worktree-hooks.js +421 -711
  66. package/lib/worktree-list.js +120 -0
  67. package/lib/worktree-registry.js +162 -879
  68. package/lib/{worktree-close-herdr.js → worktree-remove.js} +9 -11
  69. package/lib/worktree-setup-runner.js +376 -0
  70. package/lib/worktree-setup.js +140 -0
  71. package/lib/worktree-warp-busy.js +462 -85
  72. package/lib/worktree-warp-sessions.js +1 -2
  73. package/package.json +2 -2
  74. package/tools/bash-activity.test.js +1419 -0
  75. package/tools/bash-design.test.js +1091 -0
  76. package/tools/bash-destructive.test.js +139 -0
  77. package/tools/card-content.test.js +44 -0
  78. package/tools/card-style.test.js +298 -0
  79. package/tools/codegraph-card-preview.test.js +254 -0
  80. package/tools/codegraph-card.test.js +1080 -0
  81. package/tools/codegraph-compaction.test.js +378 -0
  82. package/tools/codegraph-daemon.test.js +248 -0
  83. package/tools/codegraph-edit-sync.test.js +295 -0
  84. package/tools/codegraph-guard-target.test.js +174 -0
  85. package/tools/codegraph-guard.test.js +238 -0
  86. package/tools/codegraph-index.test.js +1948 -0
  87. package/tools/codegraph-lock.test.js +932 -0
  88. package/tools/codegraph-mcp-config.test.js +181 -0
  89. package/tools/codegraph-mcp.test.js +194 -0
  90. package/tools/codegraph-paths.test.js +44 -0
  91. package/tools/codegraph-role.test.js +30 -0
  92. package/tools/codegraph-rules.test.js +250 -0
  93. package/tools/codegraph-session.test.js +660 -391
  94. package/tools/codegraph-warmup.test.js +316 -0
  95. package/tools/commands.test.js +510 -31
  96. package/tools/file-card-markdown.test.js +188 -0
  97. package/tools/file-card.test.js +1289 -0
  98. package/tools/files-bridge.test.js +575 -0
  99. package/tools/files-command.test.js +610 -0
  100. package/tools/files-index.test.js +473 -0
  101. package/tools/files-insert.test.js +139 -0
  102. package/tools/files-orders.test.js +597 -0
  103. package/tools/files-picker-view.test.js +1871 -0
  104. package/tools/files-preview.test.js +452 -0
  105. package/tools/files-scope-detail.test.js +264 -0
  106. package/tools/files-scope-view.test.js +614 -0
  107. package/tools/fixtures/card-codegraph-outputs.js +110 -0
  108. package/tools/fixtures/codegraph-cli-stub.js +16 -0
  109. package/tools/fixtures/codegraph-init-process.js +28 -0
  110. package/tools/fixtures/codegraph-lock-worker.js +117 -0
  111. package/tools/fixtures/daemon-fake.js +98 -0
  112. package/tools/fixtures/daemon-mcp-server.js +39 -0
  113. package/tools/fixtures/daemon-warmup-worker.js +12 -0
  114. package/tools/fixtures/load-extension.js +136 -3
  115. package/tools/gh-issues-feedback.test.js +31 -7
  116. package/tools/gh-issues.test.js +391 -1
  117. package/tools/issue-preview.test.js +44 -7
  118. package/tools/issues-bash-mutation.test.js +101 -0
  119. package/tools/issues-cache-store.test.js +222 -0
  120. package/tools/issues-command.test.js +1512 -66
  121. package/tools/issues-open-guard.test.js +1096 -0
  122. package/tools/issues-section.test.js +4195 -0
  123. package/tools/issues-seed-query-regression.test.js +67 -0
  124. package/tools/issues-view.test.js +1489 -60
  125. package/tools/odd-worktrees-prompt.test.js +98 -65
  126. package/tools/package-surface.test.js +431 -36
  127. package/tools/related-issues-cache.test.js +324 -0
  128. package/tools/shell-card.test.js +834 -0
  129. package/tools/skill-odd-card.test.js +200 -0
  130. package/tools/t5-session-identity.test.js +44 -22
  131. package/tools/warp-busy-guard.test.js +2569 -308
  132. package/tools/warp-create-panel.test.js +499 -74
  133. package/tools/warp-create-picker.test.js +101 -5
  134. package/tools/warp-delete-confirm.test.js +49 -15
  135. package/tools/warp-empty-session.test.js +0 -1
  136. package/tools/warp-fallback-regression.test.js +533 -0
  137. package/tools/warp-selector-view.test.js +460 -196
  138. package/tools/which-command.test.js +126 -0
  139. package/tools/worktree-card.test.js +551 -0
  140. package/tools/worktree-cards.test.js +845 -0
  141. package/tools/worktree-changes.test.js +4 -5
  142. package/tools/worktree-create.test.js +489 -0
  143. package/tools/worktree-guard.test.js +823 -0
  144. package/tools/worktree-hooks.test.js +905 -0
  145. package/tools/worktree-list.test.js +170 -0
  146. package/tools/worktree-registry.test.js +89 -230
  147. package/tools/worktree-remove-async.test.js +318 -0
  148. package/tools/worktree-setup-runner.test.js +276 -0
  149. package/tools/worktree-setup.test.js +140 -0
  150. package/tools/worktree-tools.test.js +477 -93
  151. package/lib/codegraph-commands.js +0 -165
  152. package/lib/odd-prompt/odd-worktrees.with-codegraph.md +0 -19
  153. package/lib/odd-prompt/odd-worktrees.without-codegraph.md +0 -15
  154. package/lib/worktree-model-result.js +0 -291
  155. package/tools/codegraph-commands.test.js +0 -371
  156. package/tools/herdr-free-create.test.js +0 -161
  157. package/tools/worktree-close-herdr-async.test.js +0 -204
  158. package/tools/worktree-odd-migration.test.js +0 -224
  159. package/tools/worktree-registry-cache.test.js +0 -163
  160. package/tools/worktree-registry-odd.test.js +0 -231
package/README.md CHANGED
@@ -1,349 +1,92 @@
1
1
  # pi-odd-worktree
2
2
 
3
- A Pi extension package for agent worktrees, ODD documents and GitHub issues.
4
- Four agent tools, three panels, one extension entry point. It works in Pi
5
- alone; Herdr is optional.
3
+ A Pi extension that gives an agent session worktrees, ODD documents and GitHub issues, with `git` as its only external requirement.
6
4
 
7
5
  ## What It Does
8
6
 
9
- `package.json` declares one Pi extension,
10
- `./extensions/odd-worktree-tools.ts`, and that file registers everything below.
7
+ Two agent tools, four panels, one sidebar section and one tool design, loaded from one extension entry point. Each ODD feature gets its own checkout beside the clone, and you move between checkouts and read your ODD documents, files and issues without leaving Pi.
11
8
 
12
9
  | Surface | Kind | What it does |
13
10
  | --- | --- | --- |
14
- | `worktree_list` | tool | Lists the principal checkout, then this session's own checkout, then the rest, cross-checked against live git checkouts. Rows whose path is gone are excluded and pruned from the registry. |
15
- | `worktree_create` | tool | Creates a branch and its checkout from the **local** `main`, registers it, runs the creation hooks, and copies the pending changes you name. |
16
- | `worktree_warp` | tool | Queues the session move to another checkout as a `/warp` handoff; the command performs the move when the turn ends. |
17
- | `worktree_delete` | tool | Removes a registered checkout with `git worktree remove`, keeping the branch, and refuses while a live Pi session is working in it. |
18
- | `/warp` | panel | Moves this session to another checkout: no argument opens the selector (list, create, delete, extended list); `/warp <name>` jumps straight there. A session with no conversation yet changes checkout **silently** — no fork, no `Warp · moved` card, nothing to carry — and warping back from it is the same empty case. |
19
- | `/odd-list` | panel | Two-pane reader of this checkout's `odd/tasks/*.md`: list on the left, styled markdown on the right. |
20
- | `/issues` | panel | Full-screen reader of this checkout's repository issues — My issues / Assigned / Involved / All — with preview, comments, labels, assignees and close, gated on your repository role. |
21
- | `/codegraph-hook` | command | **Only when the CodeGraph CLI is installed.** Turns the edit/write sync on or off for the session. |
22
- | `/codegraph-init` | command | **Only when the CLI is installed.** Runs `codegraph init` at the session's current directory and says what happened: `initialized <path> — 1 file, 3 nodes, 3 edges`, or `already initialized at <path> — nothing to do`. |
23
- | `/codegraph-sync` | command | **Only when the CLI is installed.** Runs `codegraph sync` at the session's current directory and says what happened: `already up to date — nothing to sync`, `synced 3 changed files — 12 nodes`, or `no index in this checkout — run /codegraph-init first`. |
11
+ | `worktree_create` | tool | Creates `<repo-parent>/<repo-name>-worktrees/<odd>` on a branch, prepares it and starts its install in the background. |
12
+ | `worktree_list` | tool | Read-only list of the checkouts this package created, each by its ODD and branch. |
13
+ | `/warp` | panel | Moves this session to another checkout, creates one, and removes one. |
14
+ | `/odd` | panel | Reads this checkout's `odd/tasks/*.md`: list on the left, styled markdown on the right. |
15
+ | `/files` | panel | Browses one checkout's files with a live, language-coloured preview: `enter` pastes the chosen paths into your prompt, `ctrl+e` opens the file in `$EDITOR`. |
16
+ | `/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. |
17
+ | `GITHUB` rail section | sidebar section | Lists the open issues of this checkout's repository assigned to you, seven at a time plus a count of the rest; a click opens that issue in `/issues` on `Assigned` and the overflow row opens `/issues`. Needs `gh` and gentle-shell-bridge with its rail; without `gh` on `PATH` it is never added to the rail at all. |
18
+ | `activity` tools design | design on the bridge's `Card tools` line | Optional: `/gentle:customize` → `Cards` → `Card tools`, with `default` (the host's own card) and `activity`, which is selected for you on the first run. It covers `bash`, the read-only shell tools `grep`, `find`, `ls`, and `read` and `write`: a bash card's heading names what the command does, each family in its own theme colour (`⌕ exploring`, `✓ checking`, …; an unnamed command reads `$ bash`), those three are always `⌕ exploring`, and a `read` — which runs no shell command — is left exactly as the host drew it. `read` and `write` are covered so that the file card can ask about them too: the design draws nothing of its own for either, so a read or a write to a skill or an ODD artifact is the file card's row and everything else stays the host's. A finished call shows its duration on the closing rule and the frame turns `warning` while the call runs and `error` when it fails. Needs gentle-shell-bridge 0.6.0 or newer for the one `Card tools` row over the six tools; on 0.5.0 the row is `Card bash`, covers bash alone and keeps everything above for bash cards. Registered through gentle-shell-bridge's `registerToolDesign`; the bridge owns the choice, remembers it and repaints cards already on screen. |
24
19
 
25
- A checkout's **name** is the slug of its branch, and its path is
26
- `<repo-parent>/<repo-name>-worktrees/<slug>`: the slug lowercases the branch and
27
- turns every non-alphanumeric run into `-` (`feat/login` → `feat-login`). The
28
- principal checkout is `principal`. Names, paths and branches are accepted
29
- interchangeably by `worktree_delete`, and by `/warp`.
20
+ 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.
21
+
22
+ The tools card is a design, not a preference of this package: it adds the value `activity` to the bridge's own line, `Card tools` on a bridge that can put several tools on one (0.6.0 and later) and `Card bash` on anything older, which keeps `default` (the host's own card, stored as `native`) available. On the first run, and only when you have not chosen yet, the package selects `activity` once — before it registers the design, so a 0.6.0 bridge carries that choice over to the grouped line — and a later choice of `default` is never undone. The colours are theme roles, so a theme that gives two roles the same colour draws those two families alike. Load order does not matter. See [the cards the `activity` design paints](docs/reference.md#the-cards-the-activity-design-paints).
23
+
24
+ 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 tools`, 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).
30
25
 
31
26
  ## Quick Start
32
27
 
33
28
  | Requirement | Why it is needed |
34
29
  | --- | --- |
35
- | Pi (`@earendil-works/pi-coding-agent`, `@earendil-works/pi-tui`) | Peer dependencies at `*`, supplied by the host. The package installs no runtime dependencies. |
36
- | Node.js >= 18 and `git` | `engines` declares 18 as the floor, and every repository operation is a git child process. |
37
- | `gh`, authenticated (`gh auth login`) | `/issues` only. Without it the command stays registered, says once per session what is missing, and never opens. |
38
- | `codegraph` — optional | Keeps each checkout's index fresh: `codegraph init` when a checkout is created, and a background `codegraph sync` after edits and writes. Absent, both stay off for the whole session. |
39
- | Gentle Shell — recommended | Supplies the presence and transport records the deletion guard reads to see sessions other than this one. |
30
+ | Pi (`@earendil-works/pi-coding-agent`, `@earendil-works/pi-tui`) | Peer dependencies supplied by the host; the package installs no runtime dependencies. |
31
+ | Node.js >= 18 and `git` | Every repository operation is a `git` child process. |
32
+ | `gh`, authenticated (`gh auth login`) | `/issues` and the `GITHUB` rail section, and them alone. Without it neither is registered at all — `/issues` never loads 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. |
33
+ | Gentle Shell (recommended) | Supplies the session records the deletion guard reads to see other sessions. |
34
+ | Gentle Shell with `gentle-shell-bridge` (and its rail, for the section) | Every surface this package registers. The `activity` value of the `Card tools` line (or `Card bash`, on a bridge older than 0.6.0) in `/gentle:customize` → `Cards` — which the skill/ODD file cards obey too — and the `GITHUB` rail section, which needs the rail too. The file picker's `alt+p` and the issues panel's `alt+i` are not the bridge's: both are bound directly on the host, and `GENTLE_PI_FILES_KEY` / `GENTLE_PI_ISSUES_KEY` override the keys. Install it with `pi install npm:gentle-shell-bridge`, or `gentle-shell install npm:gentle-shell-bridge` inside a Gentle Shell session. 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. |
40
35
 
41
36
  ```bash
37
+ # plain Pi
42
38
  pi install npm:pi-odd-worktree
43
- ```
44
-
45
- Inside a Gentle Shell session, the same package is installed through the shell's
46
- launcher:
47
39
 
48
- ```bash
40
+ # inside a Gentle Shell session: its launcher, same place
41
+ # (the bridge above is the prerequisite for every Gentle Shell surface)
49
42
  gentle-shell install npm:pi-odd-worktree
50
43
  ```
51
44
 
52
- From a local clone, `pi install .` installs the working copy instead. Neither
53
- command takes a version, so the install tracks whatever npm publishes.
54
-
55
- Herdr is not required; Gentle Shell is recommended for the live-session deletion
56
- guard.
45
+ From a local clone, `pi install .` installs the working copy, and `gentle-shell install .` does the same from inside a Gentle Shell session.
57
46
 
58
- `pi.extensions` in `package.json` points at
59
- `./extensions/odd-worktree-tools.ts`, so Pi loads it without any extra
60
- registration. Expected result: `/warp`, `/odd-list` and `/issues` are available
61
- as commands, and the four `worktree_*` tools are offered to the agent.
47
+ Expected result: `/warp`, `/odd`, `/files` and `/issues` are available as commands — `/issues` only where `gh` is on `PATH` — the agent is offered `worktree_create` and `worktree_list`, a Gentle Shell whose `gentle-shell-bridge` is installed and whose rail is drawn shows a `GITHUB` section for this checkout, and its `/gentle:customize` → `Cards` page offers `activity` on its `Card tools` line — `Card bash` on a bridge older than 0.6.0.
62
48
 
63
49
  ## Core Workflow
64
50
 
65
- 1. **Create** — ask the agent for a worktree, or press `c` in `/warp`.
66
- `worktree_create` needs a `branch` and a mandatory `changes` selection:
67
- `"all"`, `"none"`, or a list of checkout-relative paths. It never guesses,
68
- and a repository with no local `main` is refused before anything is written.
69
- An existing branch is adopted as-is instead of being recreated.
70
- 2. **List** — `worktree_list`, or open `/warp`. Pass `all: true` to the tool (or
71
- `v` in the panel) to also see live checkouts the registry does not know.
72
- 3. **Move** — `/warp <name>`, the selector's `enter`, or `worktree_warp`. The
73
- selector never offers the checkout you are already in; the exclusion is by
74
- resolved real path, so a differently-spelled path to the same checkout is
75
- excluded too.
76
- 4. **Delete** — `worktree_delete` with exactly one of `name`, `path` or `branch`,
77
- plus `force: true` for a dirty checkout. Deleting asks for approval when the
78
- host offers dialog UI; creating never does, because it touches no existing
79
- data.
80
-
81
- ## Key Features You Should Know About
82
-
83
- ### Panel keys
84
-
85
- `/warp` selector — the footer legend is the key reference.
86
-
87
- | Key | Action |
88
- | --- | --- |
89
- | `↑`/`↓`, `j`/`k` | Move the selection |
90
- | `enter` | Warp to the focused checkout (`enter` on the `view all worktrees` row opens the extended list) |
91
- | `c` | Open the create flow |
92
- | `ctrl+d` | Ask to delete the focused checkout; the extension owns the confirmation, the evidence and the removal |
93
- | `v` | Open the extended list of every other checkout (`↑`/`↓`, `pgUp`/`pgDn`, `enter`, `T` or `/` to filter, `esc` back) |
94
- | `r` | Reload the listing |
95
- | `esc`, `ctrl+c` | Close the panel |
96
-
97
- `/odd-list` — `↑`/`↓` select, `t` search (`T` and `/` also open the box), `o`
98
- open the document in `$VISUAL`/`$EDITOR`, `s` toggles the order between `recent`
99
- and `name`, `r` reload, `esc` close. `←`/`→` and `[`/`]` scroll the list; the
100
- document pane pages with `ctrl+j`/`ctrl+k`.
101
-
102
- `/issues` — bucket tabs are `My issues`, `Assigned`, `Involved` and `All`.
103
-
104
- | Key | Action | Needs |
105
- | --- | --- | --- |
106
- | `↑`/`↓`, `j`/`k` | Move the selection | — |
107
- | `←`/`→` (also `tab`/`shift+tab`) | Switch bucket | — |
108
- | `]`/`[` | Scroll the list one page; the hint is deliberately absent from the footer | — |
109
- | `ctrl+j`/`ctrl+k` | Scroll the preview a page (`ctrl+shift+j/k`, `shift+J/K` and `pgUp`/`pgDn` also work; `ctrl+d`/`ctrl+u` scroll half a page) | — |
110
- | `t` | Open the search box (`T` and `/` also open it) | — |
111
- | `o` | Open the issue in the browser through `gh issue view <n> --web -R` | — |
112
- | `r` | Re-read the list and the preview freshly, and re-read your repository role | — |
113
- | `l` | Labels editor: apply or remove an existing label | triage |
114
- | `a` | Assignee editor | triage |
115
- | `c` | Comment | read access |
116
- | `x` (and `X`) | Close the issue, after the host's confirmation; only `x` rides the legend | triage |
117
- | `esc`, `q`, `ctrl+c` | Close the reader | — |
118
-
119
- Creating a **new** label is a separate capability inside the labels editor and
120
- needs `write`, so a triage-only viewer opens the editor normally and sees
121
- neither a create row nor its `n` keybinding. Commenting is deliberately ungated:
122
- GitHub lets anyone with read access comment, so requiring triage would hide an
123
- action the viewer is allowed to take. Anything but a confirmed capability fails
124
- closed — no hint, the key refuses on screen, no editor opens, no mutation is
125
- attempted.
126
-
127
- ### The deletion guard, and its honest limit
128
-
129
- Deleting a checkout is refused while a live Pi session is working in it, and
130
- the **same** check runs for `worktree_delete` and for the panel's `ctrl+d`, both
131
- before the pending-change question and again immediately before the removal.
132
- This session's own checkout is refused with "warp first"; another session's is
133
- refused naming its real session id, resolved by joining the published presence
134
- hash to Gentle Shell's transport activation record. When no record joins, the
135
- refusal shows the presence hash and says the id could not be resolved — it never
136
- invents one from a label. Nothing is auto-warped and nothing is closed on your
137
- behalf.
138
-
139
- That check is **best effort, not a guarantee**:
140
-
141
- - It reads Gentle Shell's presence records (heartbeat plus workspace) and its
142
- transport activation records when Gentle Shell is installed and running, and
143
- it always catches the checkout this session stands on.
144
- - A heartbeat older than 15 s cannot prove a session is gone, so it is reported
145
- in the close output as a stale record instead of blocking the removal forever.
146
- - Live records that published no workspace, and a scan that hit its bound, are
147
- disclosed too. An absent or unreadable presence store blocks nothing and is
148
- disclosed as unavailable.
149
- - Gentle Shell's scratch ledger is deliberately not consulted: it records what a
150
- session *created*, not where it is working.
151
-
152
- Removal is `git worktree remove <absolute path>`, with `--force` only when the
153
- caller asked for it. The branch is kept, and **no Herdr workspace is closed,
154
- opened or removed** on any path.
155
-
156
- ### A warp waits for this session's own agent tasks and background jobs
157
-
158
- A warp never lands while this session still has running or queued agent tasks or
159
- a running background job — and it is never thrown away: the request is
160
- **queued**.
161
-
162
- - The `worktree_warp` tool validates and queues the handoff exactly as it does
163
- when the session is idle, and its first line names both workloads: `worktree
164
- warp: handoff queued — waiting for 2 running agent task(s) and 1 running
165
- background job before the move`. It never claims a move. A second
166
- `worktree_warp` call in the same turn is refused, because the request is
167
- pending from the moment it is queued.
168
- - `/warp` — a typed name, the selector, a create's follow-up warp and the agent
169
- handoff all share one path — gives both sources a bounded chance to drain
170
- (`ODD_WORKTREE_WARP_BUSY_WAIT_MS`, 60 s by default) and then keeps the request
171
- **pending** instead of switching: the session stays where it is, and a bounded
172
- background poller re-dispatches the SAME validated handoff once this session
173
- reports no running or queued agent task and no running job. Nothing switches
174
- mid-work.
175
- - **One pending warp per session.** A second warp is refused while one is
176
- pending — on the tool and on the panel alike, with `a warp to <name> is
177
- already pending for this session — it runs when the pending agent tasks
178
- finish; wait for it or let it expire` — and the pending request is never
179
- replaced.
180
- - The pending warp expires after `ODD_WORKTREE_WARP_PENDING_MS` (30 minutes by
181
- default, clamped to a day) and notifies that it expired with nothing moved. It
182
- re-reads both sources every `ODD_WORKTREE_WARP_PENDING_POLL_MS` (2 s by
183
- default) and its timer never keeps the session alive. A warp that runs, is
184
- refused or expires clears the queue, so the next request is accepted again.
185
- - The re-dispatched handoff re-checks that the destination checkout and the
186
- session are still where the request left them: drift refuses the move instead
187
- of guessing.
188
-
189
- Both sources are read **best effort**, and neither is ever guessed:
190
-
191
- - **Agent tasks** come from Gentle Shell's presence header for this session,
192
- through the same bounded reader the deletion guard uses. A heartbeat older than
193
- 15 s is not evidence, and an absent or unreadable store blocks nothing.
194
- - **Background jobs** come from the host's `job_list` tool — the same `ctx.tools`
195
- + `ctx.executeTool` seam `worktree_create` uses to register a checkout. Each
196
- row is `id · status · label · elapsed · output`; only a status field that says
197
- `running` or `queued` (a monitor reports `monitor running`) keeps the warp
198
- waiting, while `exited 0`, `failed 1` and `stopped` are finished. "Not
199
- exited" is never read as activity.
200
- - A host that does not offer `job_list`, a call that fails, and an answer this
201
- parser does not know all count as **unknown**, never as "no jobs": the warp
202
- still runs, and a `queue:` line says the job state is unknown instead of
203
- pretending it was read.
51
+ 1. **Create** a checkout with `worktree_create` (an `odd` and a `branch`) or press `c` in `/warp`. It answers at once; the install continues in the background.
52
+ 2. **List** with `worktree_list` or by opening `/warp`.
53
+ 3. **Move** with `/warp <name>`, or pick a checkout in the selector.
54
+ 4. **Delete** with `ctrl+d` on a checkout in `/warp`, after its confirmation.
204
55
 
205
- ### `/issues` pins the repository
56
+ The full rules of each step, including every refusal, are in [Create, list, move and delete, in detail](docs/reference.md#create-list-move-and-delete-in-detail).
206
57
 
207
- The repository identity (`<host>/<owner>/<repo>`) is pinned when the list loads,
208
- and the host is part of it. Every page, detail, label, assignee and comment read
209
- binds that pin, and so do every action and the `o` browser opener. If
210
- the checkout's remote moves while the reader is open, mutations refuse with
211
- `the checkout's repository changed since this issue list loaded (now … instead of
212
- …); reopen /issues`, and the reads keep the displayed repository. An issue
213
- number on screen can never be sent to another repository.
214
-
215
- ### CodeGraph stays fresh, when the CLI is installed
216
-
217
- The probe for `codegraph` on `PATH` runs **once per session** and is cached for
218
- everything below. Install the CLI mid-session and nothing changes until the next
219
- start, unless you set `CODEGRAPH_FORCE=1`, which answers "present" without
220
- probing.
221
-
222
- - **On creation**, `worktree_create` runs `codegraph init` inside the new
223
- checkout, so it starts with its own index. A session where the gate answered
224
- false reports that step as `skipped` and names the gate as the reason; it never
225
- silently pretends to have indexed anything.
226
- - **On edits**, a successful `edit` or `write` schedules `codegraph sync` for the
227
- git toplevel of the file touched, so a worktree syncs that worktree. The sync is
228
- detached: the tool result never waits for it, and a failure never reaches you.
229
- - **Debounced and coalesced.** Rapid edits collapse into one sync after ~2s, and
230
- an edit that lands while a sync runs starts exactly one more when it ends —
231
- never a queue.
232
- - **One sync at a time across sessions**, guarded by
233
- `<root>/.codegraph/pi-sync.lock` holding `{pid, startedAt}`. A lock held by a
234
- live process means skip (the other session's sync already covers that tree),
235
- with one bounded retry so the edit that raced it still lands. A dead pid or an
236
- expired lock is taken over.
237
- - **Skipped when it would be wasted**: no `.codegraph/` in that checkout, or a
238
- live CodeGraph daemon (`<root>/.codegraph/daemon.pid`, either the JSON record
239
- 1.6 writes or the older bare pid), whose own watcher is already syncing that
240
- tree.
241
- - **Bounded**: a sync that never finishes is terminated after two minutes so a
242
- checkout can never be wedged for the rest of the session.
243
-
244
- Three commands exist **only when the CLI is present**, and they do not appear at
245
- all otherwise:
246
-
247
- | Command | What it does |
248
- | --- | --- |
249
- | `/codegraph-hook` | Turns the edit/write sync on or off for the whole process. No argument toggles; `on`, `off` and `status` say it explicitly. It starts enabled. |
250
- | `/codegraph-init` | Runs `codegraph init` at the session's current directory. |
251
- | `/codegraph-sync` | Runs `codegraph sync` at the session's current directory. |
252
-
253
- The toggle lasts for the session — this package writes nothing to user
254
- configuration — so `CODEGRAPH_HOOK=0` is how you start a session with it off.
255
-
256
- ### The `## ODD worktrees` block in the system prompt
257
-
258
- The primary session's system prompt gains a short section telling the agent where
259
- worktrees live, to resume an ODD in its assigned one, and — when `codegraph` is
260
- present — that creation indexes the checkout and edits sync it.
261
-
262
- It is **appended**, never substituted: the block rides
263
- `systemPromptOptions.appendSystemPrompt`, so whatever Gentle Shell (or any other
264
- extension) put there is preserved verbatim and our text lands after it. Two
265
- variants exist, with and without the CodeGraph sentences, chosen by the same
266
- session gate. Child and named-agent sessions get nothing, because their own
267
- instructions are already the bounded task they received. `ODD_WORKTREE_PROMPT=0`
268
- suppresses the block.
269
-
270
- One limit, stated plainly: a string has no "must be last" flag, so the block's
271
- position follows extension load order. It can sit before a later extension's
272
- short hint; it can never land inside or in place of another extension's text.
273
-
274
- ### Where state lives
275
-
276
- The worktree registry is per repository at `<git-common-dir>/pi-worktrees.json`,
277
- so every worktree of the same clone sees the same rows. Session names derived
278
- from an ODD write, and the warp's fork/resume bookkeeping, travel in the Pi
279
- session files the host already owns. The only other file this package writes is
280
- the short-lived `<root>/.codegraph/pi-sync.lock`. Nothing is written to user
281
- configuration.
282
-
283
- ### Deliberately absent
284
-
285
- This package is the worktree / ODD / issues surface only: no customize panel, no
286
- plugin-tools toggles, no Herdr plugin management, and no worktree↔issue
287
- association. There is nothing to configure, and `/warp`, `/odd-list` and
288
- `/issues` are always on (the three `/codegraph-*` commands follow the CLI).
289
- Paths, branches and arguments reach `git` and `gh` as fixed argv arrays,
290
- never as a shell string.
291
-
292
- ## Tests
293
-
294
- ```bash
295
- node --test tools/*.test.js # package.json `test`
296
- ```
297
-
298
- The suite uses Node builtins only — no install step, no lockfile, no network.
299
- Every temporary repository, stub binary and extension copy lives under the
300
- system temp directory and is removed on exit. `tools/fixtures/load-extension.js`
301
- copies the extension to a scratch `.mjs` with the two Pi imports stubbed and
302
- loads it against a fake host, which is how the registered commands, tools and
303
- manifest are asserted from the outside.
304
-
305
- ## CI and releases
306
-
307
- | Workflow | Trigger | What it runs |
308
- | --- | --- | --- |
309
- | `ci.yml` | push to `main`, every pull request | `node --test tools/*.test.js` on Node 18, 20, 22 and 24 — the range `engines` declares, 18 as its floor |
310
- | `pr-check.yml` | pull request opened, edited, reopened or synchronized | the PR title and every non-merge commit subject must follow [Conventional Commits](https://www.conventionalcommits.org/), plus one suite run on Node 22 |
311
- | `release.yml` | tag `v*` push, or a manual dispatch naming an existing tag | tag/`package.json` version parity, the suite, the GitHub Release, then `npm publish`, then verification |
312
-
313
- The npm package is `pi-odd-worktree`, published at 0.1.0. A release is the tag
314
- `v` plus the exact `package.json` version — the 1.0.0 release is `v1.0.0` — and
315
- preflight stops the run when the two disagree. Publication uses
316
- [Trusted Publishing](https://docs.npmjs.com/trusted-publishers): `id-token:
317
- write` is granted to the `release` job and nowhere else, and no npm credential
318
- exists in the workflow or in the protected environment. A version npm already
319
- serves is reported and left alone; a published version is immutable.
320
-
321
- The `release` environment is where a release pauses for approval when reviewers
322
- are attached to it, and the trusted publisher binds to this workflow file plus
323
- that environment name. Publication therefore needs the trusted publisher bound
324
- to this repository, this workflow file and the `release` environment, and the
325
- provenance attestation binds to the public `repository` `package.json` names,
326
- case-sensitively.
327
-
328
- Release notes are generated when the GitHub Release is created and curated
329
- afterwards by editing the published release (`gh release edit`); no notes file is
330
- committed.
58
+ ## Key Features You Should Know About
331
59
 
332
- Cutting a release, contributor rules and the repository invariants are in
333
- [`AGENTS.md`](AGENTS.md).
60
+ - **A create is instant and writes no state.** The directory is the whole record; there is no list file and no lock file.
61
+ - **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).
62
+ - **A warp is queued, never dropped.** While this session's tools, agent tasks or background jobs are still running, `/warp` keeps the request pending and moves when they finish. See [the queued warp](docs/reference.md#a-warp-waits-for-this-sessions-own-tools-agent-tasks-and-background-jobs).
63
+ - **`/files` lists one checkout's files and pastes them.** It always asks for a checkout first — `main` included, even with nothing else registered — offering `main`, the current checkout and the worktrees this session registered, with `a` widening the list to every worktree Git lists for the clone; `ctrl+o` cycles `files`, `tree` and `ext` (the trees open folded, `space` folds the focused group and `shift+space` collapses or expands every group), and the preview is read-only, bounded and coloured from your active theme. `enter` inserts `@`-prefixed paths — a file of another checkout travels as its absolute path instead, because `@` would resolve against the wrong directory — and `ctrl+e` opens the highlighted file in `$VISUAL`/`$EDITOR`. `alt+p` opens the picker from anywhere: the shortcut is bound directly on the host, and `GENTLE_PI_FILES_KEY` overrides the key. See [the file picker](docs/reference.md#files-the-picker-its-scopes-and-its-orders).
64
+ - **`/issues` opens on three tabs, not four.** The bar is `My issues`, `Assigned` and `Involved`; `All` is the `g` shortcut's own view, read the first time you enter it and reused after that, with the footer saying `g all issues` outside it and `g related issues` inside. A typed filter spans the three tabs and travels with you into `All`, which then reads a capped search and says so instead of claiming an exact total. `alt+i` opens the panel from anywhere: the shortcut is bound directly on the host, and `GENTLE_PI_ISSUES_KEY` overrides the key. See [the tabs, the shortcut and the filter](docs/reference.md#issues-three-tabs-one-shortcut-one-filter).
65
+ - **`/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.
66
+ - **`/issues` pins 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).
67
+ - **The issues rail is checkout-scoped and optional.** When a Gentle Shell has `gentle-shell-bridge` installed and draws its rail, a `GITHUB` rail section lists the open issues of this checkout's repository assigned to you — 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. A click opens that issue in the `/issues` panel on `Assigned`, not in a browser: the click first proves the number belongs to this checkout, so a row left over from another checkout — or a checkout whose repository cannot be proven — opens nothing instead of guessing, 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. 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, keeps no timer while hidden and 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` rather than emptying the list. Without `gh` on `PATH` neither the section nor `/issues` exists at all — the command is 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; the one thing you get is a single warning naming the install command, in a primary session only. See [the rail section](docs/reference.md#the-github-rail-section).
68
+ - **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).
69
+ - **Tool headings can name the activity.** With `activity` chosen on the `Card tools` 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).
70
+ - **File calls on a skill or an ODD are cards too.** While `Card tools` 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).
71
+ - **`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).
72
+ - **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).
73
+ - **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 adds it or fixes only the differing fields and keeps the rest). 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). Its tool rows are drawn as a card.
74
+ - **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`. Once per checkout, once per session, never a block. See [the reminders](docs/reference.md#the-two-codegraph-reminders).
75
+ - **Deliberately absent.** No customize panel, no plugin-tools toggles, no companion-app integration and no worktree-to-issue association. There is nothing to configure here: the tools design — and, with it, the skill/ODD file cards — is chosen on the bridge's own `Card tools` line (or `Card bash`, on an older bridge), so this package owns no preference of its own.
334
76
 
335
77
  ## Documentation
336
78
 
337
79
  | Your task | Start here |
338
80
  | --- | --- |
339
- | Change the package, run the suite, cut a release | [`AGENTS.md`](AGENTS.md) |
81
+ | Look up a panel key | [Panel keys](docs/reference.md#panel-keys) |
82
+ | Understand a create, a warp or a delete in detail | [Reference](docs/reference.md) |
83
+ | Run the suite or see what CI and releases do | [Tests](docs/reference.md#tests), [CI and releases](docs/reference.md#ci-and-releases) |
84
+ | Change the package, follow its invariants or cut a release | [`docs/codebase/mental-model.md`](docs/codebase/mental-model.md) |
340
85
  | Report a bug or request a feature | [`.github/ISSUE_TEMPLATE/`](.github/ISSUE_TEMPLATE/) |
341
86
  | Open a pull request | [`.github/PULL_REQUEST_TEMPLATE.md`](.github/PULL_REQUEST_TEMPLATE.md) |
342
87
 
343
88
  ## Next Steps
344
89
 
345
- - Run `/warp` in a repository with at least one other checkout to see the
346
- selector, then `worktree_list` from the agent to confirm both surfaces agree.
347
- - Install `gh` and authenticate if you want `/issues`; run `gh auth login` once.
348
- - Install Gentle Shell if the deletion guard should see sessions other than the
349
- one you are in.
90
+ - Run `/warp` in a repository with at least one other checkout to see the selector, then `worktree_list` from the agent to confirm both surfaces agree.
91
+ - Install `gh` and run `gh auth login` once if you want `/issues`.
92
+ - Install Gentle Shell if the deletion guard should see sessions other than the one you are in.