pi-odd-worktree 3.12.2 → 3.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,7 +16,7 @@ Two agent tools, five panels, one background-explorer command, two sidebar secti
16
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. `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`. |
17
17
  | `/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`. |
18
18
  | `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`. |
19
- | `ODD` rail section | sidebar section | Lists the ODDs this session is working on, 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). A click opens `/odd` on that document; the ODDs this session wrote or edited come first. Does not need `Worktrees+`: registration is what scopes it. Needs gentle-shell-bridge with its rail. |
19
+ | `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. |
20
20
  | `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. |
21
21
  | `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. |
22
22
 
@@ -95,7 +95,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
95
95
  - **`/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.
96
96
  - **`/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).
97
97
  - **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).
98
- - **The ODD rail lists what this session is working on.** A second section, titled `ODD` and placed right after the host's own `AGENTS` part, lists the ODDs under `odd/tasks/` — 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 scope is the worktrees this session registered — the same session entries `/odd`, `/files` and this section all read — so main's ODDs are always there, a registered worktree whose `odd/tasks` has nothing new or different from main contributes nothing, and the section keeps working with `Worktrees+` off. The ODDs this session wrote or edited come first and force an immediate re-read; the attribution only ORDERS, it never decides what exists or where. 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).
98
+ - **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).
99
99
  - **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).
100
100
  - **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).
101
101
  - **File calls on a skill or an ODD are cards too.** While that line answers with `activity` for the tool being painted, a `read`, `edit` or `write` whose path names a skill or an ODD heads as that file — its own mark and label, the tool, the path and a read's line range — and its Markdown body is drawn by Pi's own renderer in the theme's Markdown roles. Any other file call is the host's own row. See [the file cards](docs/reference.md#the-file-cards).
@@ -108,7 +108,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
108
108
  - **`bash` cannot leave the principal checkout's default branch.** A `git worktree add` is refused in any cwd and pointed at `worktree_create`; 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).
109
109
  - **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 block](docs/reference.md#the--odd-worktrees-block-in-the-system-prompt).
110
110
  - **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).
111
- - **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. See [the reminders](docs/reference.md#the-two-codegraph-reminders).
111
+ - **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).
112
112
  - **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).
113
113
 
114
114
  ## Documentation
@@ -3017,6 +3017,13 @@ function handleWorktreeOddEvent(event, ctx, pi, allowPhaseTrigger) {
3017
3017
  // a session that cannot register a worktree still works on ODDs. Only the observation
3018
3018
  // lives here, so leaving it on costs one comparison per tool result and no surface.
3019
3019
  let oddSession = null;
3020
+ // T4 (odd-rail-session-scope S2-S4): the ODD NAMES this session is ASSOCIATED with —
3021
+ // what the rail draws, and the one scope its rows have. It is rebuilt from the
3022
+ // ACTIVE branch (`getBranch()`) at `session_start` and after a subagent result is
3023
+ // persisted, and it is grown by the live touch record, so a document the session just
3024
+ // wrote shows before any history read sees it. Name-keyed, exactly like the model:
3025
+ // `railRows` draws only these names (lib/odd-rail-model.js).
3026
+ let oddAssociated = new Set();
3020
3027
  // The section's immediate-refresh request. Unset until the rail binds it (T4), and
3021
3028
  // calling an unset request is a no-op, so a touch never depends on a section existing.
3022
3029
  let oddSessionRefresh = null;
@@ -3075,6 +3082,8 @@ function noteOddSessionTouch(event, ctx, pi) {
3075
3082
  // path and `at` instead of a second reading of the clock.
3076
3083
  const touch = oddSession.touched()[0];
3077
3084
  if (!touch) return;
3085
+ // T4 (S2): the live record is association evidence too, so the row can show now.
3086
+ for (const recorded of oddSession.touched()) oddAssociated.add(recorded.name);
3078
3087
  appendOddTouchEntry(pi, oddSession.entryOf(touch));
3079
3088
  if (oddSessionRefresh !== null) {
3080
3089
  try {
@@ -3089,18 +3098,80 @@ function noteOddSessionTouch(event, ctx, pi) {
3089
3098
  return undefined;
3090
3099
  }
3091
3100
 
3101
+ // S3 (odd-rail-session-scope): the entries of the ACTIVE branch, `getBranch()` and
3102
+ // not `getEntries()`. `getEntries()` is append-only, so an abandoned branch still sits
3103
+ // in it and its writes would claim work this session did not do. A manager that cannot
3104
+ // answer the branch falls back to its append-only list rather than restoring nothing.
3105
+ function sessionBranchEntries(ctx) {
3106
+ const sm = ctx && ctx.sessionManager ? ctx.sessionManager : null;
3107
+ if (!sm) return undefined;
3108
+ if (typeof sm.getBranch === "function") {
3109
+ try {
3110
+ const branch = sm.getBranch();
3111
+ if (Array.isArray(branch)) return branch;
3112
+ } catch {
3113
+ // A branch it cannot read still has its append-only answer below.
3114
+ }
3115
+ }
3116
+ if (typeof sm.getEntries === "function") {
3117
+ try {
3118
+ const entries = sm.getEntries();
3119
+ if (Array.isArray(entries)) return entries;
3120
+ } catch {
3121
+ // No answer at all: the caller restores nothing.
3122
+ }
3123
+ }
3124
+ return undefined;
3125
+ }
3126
+
3127
+ // T4 (S2-S4): replace the association with what these branch entries name, UNIONED
3128
+ // with the live touch record — a touch not yet persisted is still this session's
3129
+ // work. Answers whether the association could be applied at all: the module may be
3130
+ // unavailable, and a caller that gets `false` keeps whatever it already had.
3131
+ function applyOddAssociation(entries) {
3132
+ try {
3133
+ const lib = libRequire("odd-session.js");
3134
+ if (!lib || typeof lib.associatedFromHistory !== "function") return false;
3135
+ const next = lib.associatedFromHistory(entries);
3136
+ if (oddSession !== null) {
3137
+ for (const touch of oddSession.touched()) next.add(touch.name);
3138
+ }
3139
+ oddAssociated = next;
3140
+ return true;
3141
+ } catch {
3142
+ // A module that cannot answer costs the association, never the boundary.
3143
+ return false;
3144
+ }
3145
+ }
3146
+
3147
+ // T4: re-read the ACTIVE branch and apply it. The subagent-result hook is the one
3148
+ // trigger besides `session_start`.
3149
+ function syncOddAssociation(ctx) {
3150
+ try {
3151
+ const entries = sessionBranchEntries(ctx);
3152
+ if (!Array.isArray(entries)) return false;
3153
+ return applyOddAssociation(entries);
3154
+ } catch {
3155
+ return false;
3156
+ }
3157
+ }
3158
+
3092
3159
  // S8 (T8): the resume boundary. `session_start` fires for a new, resumed, forked and
3093
3160
  // reloaded session alike, and the persisted entries are what a resumed session
3094
3161
  // remembers — so the record is rebuilt from them there and nowhere else. A manager that
3095
3162
  // cannot answer restores nothing (lib/odd-session.js skips every garbage entry).
3163
+ //
3164
+ // T4 (S2, S3): the SAME boundary rebuilds the association, from the active branch.
3165
+ // It is a replace, not a merge: a session boundary is a fresh session.
3096
3166
  function restoreOddSession(ctx) {
3097
3167
  try {
3098
- if (oddSession === null) return;
3099
- const sm = ctx && ctx.sessionManager;
3100
- const entries = sm && typeof sm.getEntries === "function" ? sm.getEntries() : undefined;
3101
- oddSession.restore(entries);
3168
+ const entries = sessionBranchEntries(ctx);
3169
+ if (oddSession !== null) oddSession.restore(entries);
3170
+ oddAssociated = new Set();
3171
+ if (Array.isArray(entries)) applyOddAssociation(entries);
3102
3172
  } catch {
3103
- // An unreadable session manager leaves the record empty, never the boundary broken.
3173
+ // An unreadable session manager leaves the record and the association empty,
3174
+ // never the boundary broken.
3104
3175
  }
3105
3176
  }
3106
3177
 
@@ -3230,12 +3301,20 @@ function guardSkillReadBashCall(event) {
3230
3301
  // the identity and the default branch memoized per checkout, the current branch read
3231
3302
  // on demand, so the hot path costs one `Map` hit per call plus one git read for a
3232
3303
  // switch.
3304
+ // Worktree creation and the principal checkout's branch are the ORCHESTRATOR's actions: a subagent child is
3305
+ // handed the worktree it works in and never creates one or leaves the default branch, so neither worktree
3306
+ // guard judges a child (`GENTLE_PI_AGENTS_CHILD`, the signal the prompt blocks use).
3307
+ function oddChildSession() {
3308
+ return process.env.GENTLE_PI_AGENTS_CHILD === "1";
3309
+ }
3310
+
3233
3311
  function guardWorktreeBashCall(event, ctx) {
3234
3312
  try {
3235
3313
  // `ODD_WORKTREE_GUARD=0` turns the guards off for this process, the way
3236
3314
  // `ODD_WORKTREE_PROMPT=0` turns off the prompt blocks. Read per call: a guard is
3237
3315
  // cheap, and an escape hatch that needs a restart is not one.
3238
3316
  if (process.env.ODD_WORKTREE_GUARD === "0") return undefined;
3317
+ if (oddChildSession()) return undefined;
3239
3318
  if (!event || event.toolName !== "bash") return undefined;
3240
3319
  const guard = libRequire("worktree-guard.js");
3241
3320
  if (!guard || typeof guard.decideBashGuard !== "function") return undefined;
@@ -3277,6 +3356,7 @@ const WRITE_GUARD_TOOLS = new Set(["edit", "write"]);
3277
3356
  function guardWorktreeWriteCall(event, ctx) {
3278
3357
  try {
3279
3358
  if (process.env.ODD_WORKTREE_GUARD === "0") return undefined;
3359
+ if (oddChildSession()) return undefined;
3280
3360
  const toolName = oddToolNameOf(event);
3281
3361
  if (!WRITE_GUARD_TOOLS.has(toolName)) return undefined;
3282
3362
  const paths = oddTouchedPaths(oddArgsOf(event));
@@ -7929,7 +8009,13 @@ function filesSessionWorktreeRoots(ctx) {
7929
8009
  };
7930
8010
  const sessionId = typeof sm.getSessionId === 'function' ? safe(() => sm.getSessionId()) : undefined;
7931
8011
  if (typeof sessionId !== 'string' || sessionId.length === 0) return [];
7932
- const entries = typeof sm.getEntries === 'function' ? safe(() => sm.getEntries()) : undefined;
8012
+ // S5 (odd-rail-session-scope): the ACTIVE branch, not the append-only list. A
8013
+ // registration that lives only on an abandoned branch is alternative history, and
8014
+ // a worktree nobody registered on this path must not keep its documents in scope.
8015
+ // A manager without the branch accessor keeps the append-only answer.
8016
+ const entries = typeof sm.getBranch === 'function'
8017
+ ? (safe(() => sm.getBranch()) ?? (typeof sm.getEntries === 'function' ? safe(() => sm.getEntries()) : undefined))
8018
+ : (typeof sm.getEntries === 'function' ? safe(() => sm.getEntries()) : undefined);
7933
8019
  if (!Array.isArray(entries)) return [];
7934
8020
  const warpSessions = libRequire('worktree-warp-sessions.js');
7935
8021
  const roots = [];
@@ -11343,6 +11429,10 @@ async function loadOddRailRows() {
11343
11429
  return model.railRows({
11344
11430
  groups,
11345
11431
  touched: oddSession === null ? [] : oddSession.touched(),
11432
+ // S2 (odd-rail-session-scope): the rail draws ONLY the ODDs this session is
11433
+ // associated with — never everything on disk. A new session's association is
11434
+ // empty, so it draws the section's own `no ODD associated` line.
11435
+ associated: oddAssociated,
11346
11436
  });
11347
11437
  }
11348
11438
 
@@ -12136,6 +12226,9 @@ function registerOddWorktreeSurfaceEntries(pi) {
12136
12226
  // the open guard goes with it too, so a click left over never blocks the next
12137
12227
  // session.
12138
12228
  teardownOddRail();
12229
+ // T4 (odd-rail-session-scope S2): the association is this session's alone, so the
12230
+ // ended session leaves none behind for a frame drawn before the next start.
12231
+ oddAssociated = new Set();
12139
12232
  // S7: the prompt card's teardown belongs to the lifecycle pair registered before the
12140
12233
  // bridge gate — the same owner as its install, so a session whose bridge was never
12141
12234
  // present still closes (and its ready announcement can no longer arm an install).
@@ -12179,6 +12272,23 @@ function registerOddWorktreeSurfaceEntries(pi) {
12179
12272
  // list belongs to that module, so the attribution must already be recording when the
12180
12273
  // module is off. Every worktree observation above and below keeps its own gate.
12181
12274
  pi.on("tool_result", (event, ctx) => noteOddSessionTouch(event, ctx, pi));
12275
+ // T4 (S4 of odd-rail-session-scope): a subagent's work reaches the PARENT as ONE
12276
+ // persisted `custom_message` under `gentle-agents.result` — the child runs in its
12277
+ // own session, so the parent reads its OWN history. That moment is when the parent
12278
+ // rebuilds the association from its active branch and refreshes the rail, so the
12279
+ // subagent's ODD appears without waiting out the section's TTL. Like the touch
12280
+ // record it is NOT gated by `Worktrees+`: the association is session state.
12281
+ pi.on("message_end", (event, ctx) => {
12282
+ try {
12283
+ const message = event && typeof event === "object" ? event.message : null;
12284
+ if (!message || typeof message !== "object" || message.role !== "custom") return;
12285
+ if (message.customType !== "gentle-agents.result") return;
12286
+ if (syncOddAssociation(ctx) !== true) return;
12287
+ refreshOddRailNow();
12288
+ } catch {
12289
+ // A subagent report never breaks the host.
12290
+ }
12291
+ });
12182
12292
  // S10 (T9): ONE `tool_result` observation for the rail's forced refresh. It
12183
12293
  // answers the `bash` tool only — every other tool returns before the classifier
12184
12294
  // is even loaded — and it is separate from the naming handler because the two
@@ -12359,4 +12469,4 @@ function registerOddWorktreeSurfaceEntries(pi) {
12359
12469
  });
12360
12470
  }
12361
12471
 
12362
- export { executeWorktreeCreate, executePortedWorktreeCreate, executePortedWorktreeList, executeWorktreeClose, resolveThread, executeWorktreeWarp, emitOsc7, awaitPendingStartupTasks, scanLiveCheckouts, runStartupDiscovery, setWarpTuiLoader, setOddTuiLoader, setIssuesTuiLoader, setFilesTuiLoader, setFilesAgentLoader, setUserPromptCardHostLoader, setWorktreeCardHelpers, setWorktreeToolCardMetrics, setWarpDirtyAsker, setWarpFactsFactory, warpCreatePreflight, warpForkSourceUsable, dispatchIssuesPanel, issuesSidebarGeneration, issuesOpenInBrowser, libModule, oddSession, setOddSessionRefresh };
12472
+ export { executeWorktreeCreate, executePortedWorktreeCreate, executePortedWorktreeList, executeWorktreeClose, resolveThread, executeWorktreeWarp, emitOsc7, awaitPendingStartupTasks, scanLiveCheckouts, runStartupDiscovery, setWarpTuiLoader, setOddTuiLoader, setIssuesTuiLoader, setFilesTuiLoader, setFilesAgentLoader, setUserPromptCardHostLoader, setWorktreeCardHelpers, setWorktreeToolCardMetrics, setWarpDirtyAsker, setWarpFactsFactory, warpCreatePreflight, warpForkSourceUsable, dispatchIssuesPanel, issuesSidebarGeneration, issuesOpenInBrowser, libModule, oddSession, oddAssociated, setOddSessionRefresh };
@@ -4,9 +4,9 @@
4
4
  // Guard 1 says a call went to ANOTHER checkout and points the session at
5
5
  // `mcp__codegraph__codegraph_explore` with that checkout as `projectPath`; it belongs to the primary
6
6
  // session and fires once per checkout per session. Guard 2 says to reach CodeGraph first inside the
7
- // session's OWN checkout; it belongs to the primary session and to every child except the `review-*`
8
- // agents, and it reminds once on the first search of a checkout, while the graph is unused in that
9
- // request, and then never again for that checkout in that request (S3, S7).
7
+ // session's OWN checkout; it belongs to the primary session too (a child is short-lived and its own rule
8
+ // text already says it), and it reminds once on the first search of a checkout, while the graph is unused
9
+ // in that request, and then never again for that checkout in that request (S3, S7).
10
10
  //
11
11
  // Both are precise: a checkout the session already explored with the MCP tool silences guard 1, and a
12
12
  // reminder that does not fire uses up no slot. A call that failed is no subject at all: the model got no
@@ -186,6 +186,9 @@ function createCodegraphGuard(deps = {}) {
186
186
  if (event.isError === true) return undefined;
187
187
  const cwd = sessionCwd(event, ctx);
188
188
  if (recordCodegraphUse(state, event, cwd)) return undefined;
189
+ // Both reminders are the primary session's: a child lives a message or two and its own section already
190
+ // states the rule, so a reminder there would only repeat it.
191
+ if (child()) return undefined;
189
192
  // The same gate as the prompt section: the session must hold a CodeGraph tool to be advised.
190
193
  const held = tools();
191
194
  if (!holdsCodegraph(held)) return undefined;
@@ -1,8 +1,7 @@
1
1
  ## CodeGraph
2
2
 
3
- Run one call to the CodeGraph tool you hold before you search or read code — `fd`, `find`, `rg`, `grep`,
4
- `read` or `cat` — when the task needs structure rather than a lookup: where something lives, who calls it,
5
- what a change reaches. Skip it only for an exact string or a file path you were given. The other tools stay
6
- available after the first call.
3
+ Before you search or read code — `fd`, `find`, `rg`, `grep`, `read` or `cat` — your first call is one call to
4
+ the CodeGraph tool you hold: where something lives, who calls it, what a change reaches. The one exemption is
5
+ an exact string or a file path you were given.
7
6
 
8
- The answer is a map, not proof: confirm it in the source, and read a file before editing it.
7
+ Then read the files it points at, and read a file before editing it.
@@ -1,12 +1,11 @@
1
1
  ## CodeGraph
2
2
 
3
3
  Before you `grep`, `rg`, `fd`, `find`, `read` or `cat` to answer where code lives, who calls it, how it
4
- works, or what a change reaches, call CodeGraph first: `codegraph` with `operation: "explore"` and
4
+ works, or what a change reaches, your first call is CodeGraph: `codegraph` with `operation: "explore"` and
5
5
  `query: "<symbols or the question>"` returns the source and the call paths in one call, and it is
6
6
  also what scope, size and any handoff depend on. Use `operation: "query"` only to find where one
7
- symbol is defined. Skip it only for an exact string or a file path the user gave you. The other tools stay for
8
- what the graph does not index. Its answer is a map: confirm it in the source, and a verdict comes
9
- from the source and from tests.
7
+ symbol is defined. The one exemption is an exact string or a file path the user gave you. Then read the
8
+ files it points at: a verdict comes from the source and from tests.
10
9
 
11
10
  `codegraph` answers only for the checkout the session runs in, and each worktree is its own workspace with
12
11
  its own index. An ODD works in its own worktree: when the session runs elsewhere, look at that worktree, at
@@ -12,8 +12,16 @@
12
12
  // Order (S9): the names the session touched come first, by the touch's own `at`,
13
13
  // most recent first; everything else follows by `mtimeMs` descending and then by
14
14
  // name in CODE UNITS (never `localeCompare`, so every host and every run agree).
15
- // Attribution only ORDERS: a touch adds no row, removes none and never duplicates
16
- // one — a touched name no group lists produces nothing at all.
15
+ //
16
+ // Scope (odd-rail-session-scope S2): the rail draws the ODDs the SESSION is
17
+ // associated with, never every document on disk. The association is a set of ODD
18
+ // NAMES (`associated`) the caller rebuilt from the session's active branch and from
19
+ // the live touch record; the live touches are unioned in here, so a document the
20
+ // session just wrote shows even before history names it. A name outside that union
21
+ // is never drawn, however new its copy is, and an empty association draws nothing at
22
+ // all: the rail's empty body is the section's own dim row, not a row this module may
23
+ // invent. Within the association the election and the order are exactly as before.
24
+ // A touched name no group lists produces nothing at all.
17
25
  //
18
26
  // Scope (S13): the caller hands the groups of the SESSION's registered worktrees,
19
27
  // main always whole. A worktree group with `docs: []` contributes nothing here as
@@ -107,26 +115,44 @@ function touchedOrderOf(touched) {
107
115
  return order;
108
116
  }
109
117
 
118
+ // The associated NAMES, accepting the Set the wiring hands over and a plain array
119
+ // (a test or a sibling caller). Anything else is no association at all: the rail
120
+ // never guesses that "not told" means "everything on disk" (S2).
121
+ function associatedNamesOf(associated) {
122
+ const out = new Set();
123
+ const source = associated instanceof Set ? associated : (Array.isArray(associated) ? associated : []);
124
+ for (const name of source) {
125
+ if (typeof name === 'string' && name.length > 0) out.add(name);
126
+ }
127
+ return out;
128
+ }
129
+
110
130
  /**
111
- * The rail's rows: one per ODD name, ordered attribution-first, then by recency,
112
- * then by name.
131
+ * The rail's rows: one per associated ODD name, ordered attribution-first, then by
132
+ * recency, then by name.
113
133
  *
114
- * @param {{ groups?: Array<object>, touched?: Array<object> }} input
134
+ * @param {{ groups?: Array<object>, touched?: Array<object>, associated?: Set<string>|string[] }} input
115
135
  * @returns {Array<{ name: string, docPath: string, checkoutRoot: string, checkoutName: string, mtimeMs: number }>}
116
136
  */
117
137
  function railRows(input) {
118
138
  const opts = input && typeof input === 'object' ? input : {};
119
139
  const groups = Array.isArray(opts.groups) ? opts.groups : [];
140
+ // S2: the union of what history associates and what this session touched live. A
141
+ // touch is evidence of association, never a row of its own (it must still be a
142
+ // document a group lists).
143
+ const associated = associatedNamesOf(opts.associated);
144
+ const touched = touchedOrderOf(opts.touched);
120
145
  const elected = new Map();
121
146
  // Groups are visited in the order the caller gave them, which is what decides an
122
147
  // exact tie between two worktrees.
123
148
  for (const group of groups) {
124
149
  for (const candidate of candidatesOf(group)) {
125
- elected.set(candidate.row.name, elect(elected.get(candidate.row.name), candidate));
150
+ const name = candidate.row.name;
151
+ if (!associated.has(name) && !touched.has(name)) continue;
152
+ elected.set(name, elect(elected.get(name), candidate));
126
153
  }
127
154
  }
128
155
  if (elected.size === 0) return [];
129
- const touched = touchedOrderOf(opts.touched);
130
156
  const rows = [];
131
157
  for (const [name, candidate] of elected) {
132
158
  rows.push({ name, candidate, touch: touched.get(name) });
@@ -59,6 +59,10 @@ const DEFAULT_DRAWN_WINDOW_MS = 120000;
59
59
  // S2: the body holds four ODDs; anything beyond them is the ONE elision row.
60
60
  const MAX_ROWS = 4;
61
61
  const LOADING_ROW = { label: 'loading…', tone: 'dim' };
62
+ // S1 (odd-rail-session-scope): a ready body with nothing in it SAYS so, exactly as
63
+ // the issues section does (`EMPTY_ROW`, lib/issues-section.js): one dim line, no
64
+ // click, no invented row. It is a state, not a failure: the next read replaces it.
65
+ const EMPTY_ROW = { label: 'no ODD associated', tone: 'dim' };
62
66
  const READ_FAILED = 'cannot read the ODDs';
63
67
  const OPEN_FAILED = 'cannot open the ODD';
64
68
 
@@ -387,8 +391,10 @@ function createOddRailSection(options = {}) {
387
391
  ensureFresh();
388
392
  if (snapshot === null) return [{ ...LOADING_ROW }];
389
393
  if (snapshot.status === 'error') return [{ label: snapshot.error, tone: 'error' }];
390
- // A ready list with nothing in it draws no rows at all: there is no copy
391
- // this module may invent for an empty scan.
394
+ // S1 (odd-rail-session-scope): a ready list with nothing in it is the ONE dim
395
+ // line that says so — never a bare empty box, and never a row this module
396
+ // invents: the association decided there is nothing to draw.
397
+ if (snapshot.rows.length === 0) return [{ ...EMPTY_ROW }];
392
398
  // A copy per frame: the host may keep the array it was handed, and the
393
399
  // snapshot stays the one source the TTL and the clicks read.
394
400
  return snapshot.rows.map((row) => (row.meta === undefined