pi-odd-worktree 3.7.2 → 3.8.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.
@@ -22,10 +22,9 @@ const nodeOs = require('node:os');
22
22
  const nodePath = require('node:path');
23
23
 
24
24
  const index = require('./codegraph-index.js');
25
- const { createCodegraphCardResolver } = require('./codegraph-card.js');
25
+ const { createCodegraphGuard } = require('./codegraph-guard.js');
26
26
  const { compactionSync } = require('./codegraph-compaction.js');
27
27
  const { createEditSync } = require('./codegraph-edit-sync.js');
28
- const { createCodegraphGuard } = require('./codegraph-guard.js');
29
28
  const { liveDaemon } = require('./codegraph-daemon.js');
30
29
  const { ensureCodegraphServer } = require('./codegraph-mcp-config.js');
31
30
  const { sessionIndexRole } = require('./codegraph-role.js');
@@ -119,7 +118,6 @@ function registerCodegraph(pi, deps = {}) {
119
118
  createEditSync,
120
119
  createCodegraphGuard,
121
120
  warmUpDaemon,
122
- createCodegraphCardResolver,
123
121
  ...(deps.impl || {}),
124
122
  };
125
123
  if (typeof pi?.on !== 'function') return { registered: false };
@@ -128,9 +126,6 @@ function registerCodegraph(pi, deps = {}) {
128
126
  const child = env.GENTLE_PI_AGENTS_CHILD === '1';
129
127
  const role = sessionIndexRole(env);
130
128
  const registryDir = deps.registryDir;
131
- // S6: the card's cwd seam reads the session this wiring belongs to; unknown until
132
- // the host names it at session_start, and then the segment is shown, not guessed.
133
- let sessionDir;
134
129
  let mcpChecked = false;
135
130
  // S2: the index writes this process already asked for, per checkout. Registering one here is what lets a
136
131
  // search join it; nothing in this map starts work of its own.
@@ -140,17 +135,9 @@ function registerCodegraph(pi, deps = {}) {
140
135
  if (timer && typeof timer.unref === 'function') timer.unref();
141
136
  });
142
137
 
143
- // The CodeGraph card goes through the host's renderer hook, looked up when it is used: an older host without it draws
144
- // nothing of ours and loses nothing. No tool, command or execution is registered by it.
145
- try {
146
- impl.createCodegraphCardResolver({
147
- metrics: deps.metrics || (() => null),
148
- cwd: () => sessionDir,
149
- registerToolRenderer: (resolver) => (typeof pi.registerToolRenderer === 'function' ? pi.registerToolRenderer(resolver) : undefined),
150
- });
151
- } catch {
152
- // The card is cosmetic.
153
- }
138
+ // The CodeGraph CARD is not registered here (modular-tools S11): it is a design, so its switch is
139
+ // the bridge's `Card activity` line and the extension registers it beside the file and jobs cards,
140
+ // outside this module. What CodeGraph does is never decided by what is drawn.
154
141
 
155
142
  // The two reminders own their own state: a compaction, a `/warp` and a new session are its facts to keep.
156
143
  const guards = impl.createCodegraphGuard({ env, argv: deps.argv, toplevel: deps.toplevel, isDirectory: deps.isDirectory });
@@ -254,12 +241,6 @@ function registerCodegraph(pi, deps = {}) {
254
241
  }
255
242
 
256
243
  pi.on('session_start', (event, ctx) => {
257
- try {
258
- // The card names the explored checkout against the session's own directory.
259
- sessionDir = sessionCwd(event, ctx);
260
- } catch {
261
- // An unknown cwd only means the explicit projectPath is shown.
262
- }
263
244
  try {
264
245
  // A new, resumed or forked session is a new session; a `/reload` keeps this one and what it was told.
265
246
  if (!event || event.reason !== 'reload') guards.onNewSession();
@@ -10,7 +10,7 @@
10
10
  //
11
11
  // ONE line, `diff`, covers the two tools that change a file. `/gentle:customize` -> `Cards` draws
12
12
  // it as `Card diff`, keeps the host's own card first as `default` (stored `native`) and shows this
13
- // design's value as `color`. The line is UNSCOPED: the path scope belongs to the `Card tags`
13
+ // design's value as `color`. The line is UNSCOPED: the path scope belongs to the `Card activity`
14
14
  // line's own claim on the same two tools (gentle-shell-bridge 0.9.0 maps a scope to ONE
15
15
  // (`line`, `tool`) claim, so one unscoped claim and any number of scoped ones coexist), and a call
16
16
  // that line owns is painted by it before this one is asked.
@@ -831,8 +831,11 @@ function applyDiffDesign(lines, ctx, seam) {
831
831
 
832
832
  // The read-only picture `/gentle:customize` draws while `color` is highlighted. ONE row, like every
833
833
  // other Cards value: the gutter, a diff's two kinds and a hunk header on a single line.
834
+ // S4 (modular-tools): the preview's TITLE is the line's own name — what the bridge shows for the
835
+ // `default` value — so both options of `Card diff` read as one line and only the SAMPLE tells them
836
+ // apart. The bridge derives the row from the line key (`Card <line>`), and so does this title.
834
837
  const DIFF_DESIGN_PREVIEW = {
835
- title: `Cards · ${DIFF_DESIGN_LABEL}`,
838
+ title: `Cards · Card ${LINE_NAME}`,
836
839
  sample: ' 12 │ const total = items.length + 3 added − 1 removed @@ -1,4 +1,4 @@',
837
840
  };
838
841
 
@@ -13,7 +13,7 @@
13
13
  // * WHICH ROWS IT CLAIMS. `read`, `edit` and `write` only, and only when the host
14
14
  // offers a usable measurement seam. Whether one particular CALL is this card's is
15
15
  // decided per call, inside the slots (`lib/file-card.js`): the path's identity and
16
- // the bridge's `Card tags` line are read on every paint, so a row whose path names
16
+ // the bridge's `Card activity` line are read on every paint, so a row whose path names
17
17
  // neither is the chain's own drawing and a switch flipped while the transcript is
18
18
  // on screen repaints the row already there.
19
19
  // * THE SEAMS. Text measurement and Pi's Markdown renderer are injected, so a host
@@ -38,7 +38,7 @@ const { loadMarkdownClass } = require('./file-card-markdown.js');
38
38
  // ---- the one switch (S1/S7) ----
39
39
  //
40
40
  // The file card no longer owns a preference: it is painted while the bridge's
41
- // `Card tags` line answers that this package's activity design draws the tool being
41
+ // `Card activity` line answers that this package's activity design draws the tool being
42
42
  // drawn, and the host's own card is painted for every other value (the bridge's
43
43
  // `native`, a design that has left the line, and a design that does not cover this
44
44
  // tool alike).
@@ -161,7 +161,7 @@ function createFileCardResolver(options) {
161
161
  }
162
162
  },
163
163
  /**
164
- * The one switch, read now (S1/S7): the bridge's `Card tags` line answers with the
164
+ * The one switch, read now (S1/S7): the bridge's `Card activity` line answers with the
165
165
  * activity design for `tool` — and, since a claim can be scoped, for THIS call: the
166
166
  * call's `args` are handed over with the question (S4). A bridge with no reader —
167
167
  * older than 0.7.0, or none at all — paints the card, which is the behaviour it had
package/lib/file-card.js CHANGED
@@ -536,7 +536,7 @@ function fileResultRows(input) {
536
536
  /**
537
537
  * The call slot. The identity and the ONE switch are both decided INSIDE the
538
538
  * component's build, so the host's `render(width)` re-reads them on every frame: a card
539
- * already on screen repaints when the bridge's `Card tags` line changes (L6), and the
539
+ * already on screen repaints when the bridge's `Card activity` line changes (L6), and the
540
540
  * measurement seam is asked for at paint time rather than at construction.
541
541
  *
542
542
  * A path that names neither identity returns the chain's own component straight away,
@@ -15,7 +15,7 @@
15
15
  // activity design hands back exactly what the chain resolved, and Pi draws what it always drew.
16
16
  // A switch flipped while a card is already on screen reaches the next job card, not that one.
17
17
  //
18
- // THE SWITCH is the bridge's `Card tags` line, read through its published reader, never a
18
+ // THE SWITCH is the bridge's `Card activity` line, read through its published reader, never a
19
19
  // store path. It is strict: only the answer `design` carrying this package's activity design
20
20
  // paints. No bridge, a bridge older than the reader, a reader that throws, `native`,
21
21
  // `not-covered`, `missing`, another plugin's design and an answer nothing can read all leave
package/lib/jobs-card.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // Gentle Shell registers those four tools with no renderer of their own, so Pi draws its
6
6
  // plain default box and the conversation's card style (neon or float) never reaches them.
7
7
  // This module is the drawing half; `lib/jobs-card-resolver.js` decides WHEN it is used — only
8
- // while the bridge's `Card tags` line answers `activity` for the tool being drawn.
8
+ // while the bridge's `Card activity` line answers `activity` for the tool being drawn.
9
9
  //
10
10
  // It is shaped exactly like `lib/file-card.js` and shares its helpers (tone, expand hint,
11
11
  // theme fallback, result text, the bounded body preview), so the two cards read as one family.
@@ -40,7 +40,7 @@ const { PREVIEW_ROWS, cardTone, component, expandHint, fileResultRows, optionFla
40
40
  // The one reader of text as a card draws it: no terminal sequences, however the model wrote it.
41
41
  const { cardText } = require('./codegraph-card-preview.js');
42
42
 
43
- /** The four tools this card owns, in the order the bridge's `Card tags` line declares them. */
43
+ /** The four tools this card owns, in the order the bridge's `Card activity` line declares them. */
44
44
  const JOB_TOOLS = Object.freeze(['bash_background', 'monitor', 'job_stop', 'job_list']);
45
45
 
46
46
  // Each tool's mark, its label, the theme role the heading wears and the role the call's own text
@@ -33,7 +33,7 @@
33
33
  //
34
34
  // THE SWITCH (S1). Both alerts are selected by the SAME value that already draws this package's
35
35
  // tool cards, and this module owns no switch of its own: each design FOLLOWS the tool design line
36
- // this package registers — `follows: { line: TOOLS_LINE, id: BASH_DESIGN_ID }` — so `Card tags`
36
+ // this package registers — `follows: { line: TOOLS_LINE, id: BASH_DESIGN_ID }` — so `Card activity`
37
37
  // answering `activity` is what paints them. The bridge resolves that LIVE on every pass, reading
38
38
  // the tool document and never writing it: a flip on the line repaints a message already on screen
39
39
  // and turns it off again, with no re-registration, no seed and no second store. A following design
@@ -300,7 +300,7 @@ function bridgeTakesFollows(api) {
300
300
 
301
301
  /**
302
302
  * `registerMessageCards({ metrics, theme })` — the extension's one wiring point, shaped like
303
- * `registerJobsCard`. Both designs follow `Card tags` → `activity`, so the human's existing choice
303
+ * `registerJobsCard`. Both designs follow `Card activity` → `activity`, so the human's existing choice
304
304
  * is the switch and the bridge decides per pass; this module registers whenever the bridge can
305
305
  * express that follow, and NOTHING at all on an older one (a bridge that ignores `follows` would
306
306
  * silently create a `Message <type>` switch of its own).
package/lib/modules.js ADDED
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+ // The module switches (modular-tools): which of this package's two optional halves a
3
+ // user wants. `Codegraph+` is everything CodeGraph (the prompt text, the two reminders
4
+ // and the session wiring); `Worktrees+` is everything worktree (the prompt text, the
5
+ // two tools, `/warp` and the guards). Everything else — issues, cards, `/odd`,
6
+ // `/files`, the skill-read guard — is transversal and has no switch here.
7
+ //
8
+ // One persisted document, through the bridge's own store: `odd-worktree` →
9
+ // `modules` → `{ codegraph?: boolean, worktrees?: boolean }`. A module is ON unless its
10
+ // stored value is exactly `false`, so a missing, malformed or unreadable document keeps
11
+ // the package whole. The extension reads it ONCE, when it registers: a change made on
12
+ // the `Tools` page lands on the next load, which is why a change says so.
13
+ //
14
+ // The rows are a plain bridge provider (`registerRows`): two consecutive rows sharing
15
+ // one `choice.setting` make one `Off On` line. Pure over the injected bridge and
16
+ // notifier; nothing here touches the host.
17
+
18
+ const OWN_STORE = 'odd-worktree';
19
+ const MODULES_KEY = 'modules';
20
+ const CATEGORY = 'Tools';
21
+ const PROVIDER_ID = 'odd-worktree.tools';
22
+
23
+ // The two switches, in the order the page lists them. `setting` is the row name the bridge
24
+ // validates (one to three plain words, no structural mark: `+` is allowed).
25
+ const MODULES = Object.freeze([
26
+ Object.freeze({ key: 'codegraph', setting: 'Codegraph+' }),
27
+ Object.freeze({ key: 'worktrees', setting: 'Worktrees+' }),
28
+ ]);
29
+ const VALUES = Object.freeze([
30
+ Object.freeze({ value: 'Off', on: false }),
31
+ Object.freeze({ value: 'On', on: true }),
32
+ ]);
33
+
34
+ function storeOf(api) {
35
+ if (api === null || typeof api !== 'object' || typeof api.createStore !== 'function') return null;
36
+ return api.createStore(OWN_STORE);
37
+ }
38
+
39
+ function storedDocument(store) {
40
+ const stored = store.get(MODULES_KEY, undefined);
41
+ return stored !== null && typeof stored === 'object' && !Array.isArray(stored) ? stored : {};
42
+ }
43
+
44
+ /** `{ codegraph, worktrees }`: ON unless the stored value is exactly `false`. Never throws. */
45
+ function readModules(api) {
46
+ const state = {};
47
+ let stored = {};
48
+ try {
49
+ const store = storeOf(api);
50
+ if (store !== null) stored = storedDocument(store);
51
+ } catch {
52
+ stored = {};
53
+ }
54
+ for (const { key } of MODULES) state[key] = stored[key] !== false;
55
+ return state;
56
+ }
57
+
58
+ /** Persist one switch, keeping the other module and every other key. True when it wrote. Never throws. */
59
+ function writeModule(api, key, on) {
60
+ try {
61
+ if (!MODULES.some((module) => module.key === key)) return false;
62
+ const store = storeOf(api);
63
+ if (store === null) return false;
64
+ store.set(MODULES_KEY, { ...storedDocument(store), [key]: on === true });
65
+ return true;
66
+ } catch {
67
+ return false;
68
+ }
69
+ }
70
+
71
+ /** The one short line a change says: it lands on the next load, in a NEW session. */
72
+ function restartNotice(setting, value) {
73
+ return `${setting} ${value} · run /reload and start a new session to apply`;
74
+ }
75
+
76
+ /**
77
+ * The bridge provider for the `Tools` page. `notify(text)` carries the restart notice to
78
+ * the session's UI; a change to the value a module already has writes nothing and says
79
+ * nothing, and a store that cannot write says nothing either, so the notice is never
80
+ * promised for a change that was not kept.
81
+ */
82
+ function moduleRowsProvider({ api, notify }) {
83
+ const say = (text) => {
84
+ try {
85
+ if (typeof notify === 'function') notify(text);
86
+ } catch {
87
+ // A dead UI never fails the row.
88
+ }
89
+ };
90
+ return {
91
+ id: PROVIDER_ID,
92
+ category: CATEGORY,
93
+ rows() {
94
+ const rows = [];
95
+ for (const { key, setting } of MODULES) {
96
+ for (const { value, on } of VALUES) {
97
+ rows.push({
98
+ category: CATEGORY,
99
+ label: () => setting,
100
+ choice: {
101
+ setting,
102
+ value,
103
+ current: () => readModules(api)[key] === on,
104
+ },
105
+ action: () => {
106
+ if (readModules(api)[key] === on) return;
107
+ if (writeModule(api, key, on)) say(restartNotice(setting, value));
108
+ },
109
+ });
110
+ }
111
+ }
112
+ return rows;
113
+ },
114
+ };
115
+ }
116
+
117
+ module.exports = {
118
+ MODULES,
119
+ CATEGORY,
120
+ PROVIDER_ID,
121
+ readModules,
122
+ writeModule,
123
+ restartNotice,
124
+ moduleRowsProvider,
125
+ };
@@ -1,43 +1,31 @@
1
1
  'use strict';
2
- // The `## ODD worktrees` section of the primary session's system prompt (S7), and
3
- // (T3, S5) the one short block a CHILD that writes gets.
2
+ // The `## ODD worktrees` section of the primary session's system prompt (S7).
4
3
  //
5
4
  // It is appended to `systemPromptOptions.appendSystemPrompt` and nowhere else:
6
5
  // a handler-returned `systemPrompt` is dropped by pi-claude-bridge, and
7
6
  // replacing the option would erase the harness's own text. The block is only
8
7
  // ever added after the existing text, is skipped when it is already there, and
9
8
  // reaches a primary session only — a named agent gets the primary text of its
10
- // own session, never this one.
9
+ // own session, never this one, and a `GENTLE_PI_AGENTS_CHILD` session gets none
10
+ // of it: a child works where the primary session's handoff put it (its
11
+ // `workspace_root`), so the rule is the primary session's to apply.
11
12
  //
12
- // S5: a `GENTLE_PI_AGENTS_CHILD` session is not skipped any more. A child that
13
- // WRITES — `gentle-ai-worker`, `jd-fix-agent`, and any child whose agent name the
14
- // argv cannot name, which is the generic child — gets one short line telling it to
15
- // work in its workspace root's worktree and to stop and report on the primary. The
16
- // children that only look or judge (explore, verify, the two judges, every
17
- // `review-*`) get nothing, exactly as before. The agent name comes from
18
- // `lib/codegraph-rules.js` (`agentNameFromArgv`), which already reads it from the
19
- // child's own argv; the argv parsing is never duplicated here.
20
- //
21
- // `ODD_WORKTREE_PROMPT=0` turns both blocks off.
13
+ // `ODD_WORKTREE_PROMPT=0` turns the block off.
22
14
 
23
15
  const fs = require('node:fs');
24
16
  const path = require('node:path');
25
- const { agentNameFromArgv, variantFor } = require('./codegraph-rules.js');
26
17
 
27
18
  // The heading is the identity of the block, so an already-injected section is
28
19
  // never added twice.
29
20
  const SECTION_MARKER = '## ODD worktrees';
30
21
 
31
22
  // The section text lives in its own Markdown file so it can be read, reviewed
32
- // and edited as prose: `lib/odd-prompt/odd-worktrees.md`, and — one short line for a
33
- // child that writes — `lib/odd-prompt/odd-worktrees-child.md`. A missing or empty
23
+ // and edited as prose: `lib/odd-prompt/odd-worktrees.md`. A missing or empty
34
24
  // file falls back to the heading alone: the block still injects, never crashes the
35
25
  // session, and the idempotency marker still works.
36
26
  const PROMPT_DIR = path.join(__dirname, 'odd-prompt');
37
27
  const PROMPT_FILE = path.join(PROMPT_DIR, 'odd-worktrees.md');
38
- const CHILD_PROMPT_FILE = path.join(PROMPT_DIR, 'odd-worktrees-child.md');
39
28
  const FALLBACK = `${SECTION_MARKER}\n\nEach ODD feature has its own worktree.`;
40
- const CHILD_FALLBACK = `${SECTION_MARKER}\n`;
41
29
 
42
30
  function readPromptFile(file) {
43
31
  try {
@@ -54,25 +42,6 @@ function sectionFromFile(file, fallback) {
54
42
  }
55
43
 
56
44
  const SECTION = sectionFromFile(PROMPT_FILE, FALLBACK);
57
- const CHILD_SECTION = sectionFromFile(CHILD_PROMPT_FILE, CHILD_FALLBACK);
58
-
59
- // S5: the children that WRITE, by the name `agentNameFromArgv` reports for them.
60
- const CHILD_WRITER_AGENTS = new Set(['gentle-ai-worker', 'jd-fix-agent']);
61
- const REVIEWER_PREFIX = 'review-';
62
-
63
- /**
64
- * S5: whether this child gets the block. A worker or the fix agent does; a child whose
65
- * name cannot be read is the generic one and does too; a child that only looks or
66
- * judges — explore, verify, the judges, every `review-*` — never does. An unknown but
67
- * READ name is generic exactly as `lib/codegraph-rules.js` decides it, so the two
68
- * blocks can never call the same child two different things.
69
- */
70
- function childGetsSection(agent) {
71
- if (typeof agent !== 'string' || agent.length === 0) return true;
72
- if (CHILD_WRITER_AGENTS.has(agent)) return true;
73
- if (agent.startsWith(REVIEWER_PREFIX)) return false;
74
- return variantFor({ child: true, agent }) === 'generic';
75
- }
76
45
 
77
46
  // The names a named-agent event may carry. `agent` itself is listed because a
78
47
  // plain string there is a named agent too; an object is read through `.name`.
@@ -100,32 +69,26 @@ function separatorFor(existing) {
100
69
  // Append the section for this session to
101
70
  // `event.systemPromptOptions.appendSystemPrompt`. Returns nothing: the mutation
102
71
  // is the whole contract, so a host that awaits the handler receives no
103
- // replacement prompt. `deps.env` and `deps.argv` are the seams: the environment the
104
- // session runs with, and the argv a child's agent name is read from.
72
+ // replacement prompt. `deps.env` is the seam: the environment the session runs with.
105
73
  function appendOddWorktreesSection(event, deps = {}) {
106
74
  try {
107
75
  const effectiveDeps = deps || {};
108
76
  const env = effectiveDeps.env || process.env;
109
77
  if (env.ODD_WORKTREE_PROMPT === '0') return;
110
78
 
111
- // S5: a child is judged by the agent name its own argv carries, and gets the child
112
- // block only when it writes. A primary session keeps the one section it always had,
113
- // and a named-agent event still gets none of it.
114
- const child = env.GENTLE_PI_AGENTS_CHILD === '1';
115
- if (child) {
116
- if (!childGetsSection(agentNameFromArgv(effectiveDeps.argv || process.argv))) return;
117
- } else if (namedAgentOf(event) !== null) return;
79
+ // A child and a named-agent event get none of it.
80
+ if (env.GENTLE_PI_AGENTS_CHILD === '1') return;
81
+ if (namedAgentOf(event) !== null) return;
118
82
 
119
83
  const options = event && event.systemPromptOptions;
120
84
  if (!options || typeof options !== 'object') return;
121
85
 
122
- const section = child ? CHILD_SECTION : SECTION;
123
86
  const existing = typeof options.appendSystemPrompt === 'string' ? options.appendSystemPrompt : '';
124
87
  if (existing.includes(SECTION_MARKER)) return;
125
88
  // Append-only: every existing byte stays the prefix of the new value.
126
89
  options.appendSystemPrompt = existing.length === 0
127
- ? section
128
- : `${existing}${separatorFor(existing)}${section}`;
90
+ ? SECTION
91
+ : `${existing}${separatorFor(existing)}${SECTION}`;
129
92
  } catch {
130
93
  // The prompt block must never break session start.
131
94
  }
@@ -133,10 +96,7 @@ function appendOddWorktreesSection(event, deps = {}) {
133
96
 
134
97
  module.exports = {
135
98
  appendOddWorktreesSection,
136
- childGetsSection,
137
99
  readPromptFile,
138
100
  sectionFromFile,
139
101
  SECTION,
140
- CHILD_SECTION,
141
- CHILD_FALLBACK,
142
102
  };
@@ -2,15 +2,13 @@
2
2
  // T1, T5 (S1–S6, S8–S11): the worktree guard, decided from one `bash` command string,
3
3
  // plus (T3, S4) the `edit`/`write` guard, decided from the paths a call touches.
4
4
  //
5
- // A worktree is the checkout one ODD owns, and it is created, listed and removed
6
- // through this package's surfaces — never through Git typed into `bash`. The guard
7
- // is the net behind that rule: it refuses, before the command runs, the three things
8
- // a session must not do with Git.
5
+ // A worktree is the checkout one ODD owns, and it is created and removed through this
6
+ // package's surfaces — never through Git typed into `bash`. The guard is the net behind
7
+ // that rule: it refuses, before the command runs, the two things a session must not do
8
+ // with Git.
9
9
  //
10
10
  // S1 a command containing the `git` … `worktree` … `add` sequence, in ANY cwd:
11
11
  // the create is `worktree_create`'s.
12
- // S9 a command containing the `git` … `worktree` … `list` sequence, in ANY cwd:
13
- // the listing is `worktree_list`'s.
14
12
  // S4 in the PRINCIPAL checkout whose CURRENT branch is the default branch, a
15
13
  // command that leaves that branch: another ref, `-`, or a detached checkout,
16
14
  // also behind `checkout -b|-B|--orphan` and `switch -c|-C|--create|
@@ -40,7 +38,7 @@
40
38
  // parent of the absolute git common dir. A linked worktree's common dir lives in the
41
39
  // principal's `.git`, so its own root never matches, and nothing is refused there. A
42
40
  // cwd outside version control, or an identity the seam cannot read, leaves S4 inert
43
- // (S8); S1 and S9 apply in every cwd, whatever the `cd`s do.
41
+ // (S8); S1 applies in every cwd, whatever the `cd`s do.
44
42
  //
45
43
  // S11 — which checkout is judged is the one the command runs in: the segments are
46
44
  // walked in order and a `cd <literal path>` moves the effective cwd for the segments
@@ -107,9 +105,6 @@ const nodePath = require('node:path');
107
105
  /** S1 (S10): creating a worktree with Git, refused in every cwd. */
108
106
  const WORKTREE_ADD_REFUSAL = '`git worktree add` did not run: create the ODD\'s checkout with `worktree_create`.';
109
107
 
110
- /** S9 (S10): listing worktrees with Git, refused in every cwd. */
111
- const WORKTREE_LIST_REFUSAL = '`git worktree list` did not run: use `worktree_list` (`all: true` also shows checkouts outside `<repo-name>-worktrees`).';
112
-
113
108
  /** S4 (S10): leaving the default branch of the principal checkout. */
114
109
  const BRANCH_SWITCH_REFUSAL = 'The branch switch did not run: the principal checkout stays on its default branch. Create the ODD\'s checkout with `worktree_create`.';
115
110
 
@@ -144,7 +139,7 @@ const MAX_SUBSTITUTION_DEPTH = 8;
144
139
  const SHELL_NAMES = /(?:^|\/)(?:bash|sh|zsh|dash|ksh)$/;
145
140
 
146
141
  // ---------------------------------------------------------------------
147
- // The scanner: one command string -> segment -> token list (S1, S9, L2).
142
+ // The scanner: one command string -> segment -> token list (S1, L2).
148
143
  // ---------------------------------------------------------------------
149
144
 
150
145
  /** The index of the `)` closing the `(` at `open`, or -1 when it never closes. */
@@ -279,7 +274,7 @@ function scanCommand(command) {
279
274
  }
280
275
 
281
276
  // ---------------------------------------------------------------------
282
- // The detectors: what one segment's tokens name (S1, S3, S4, S9).
277
+ // The detectors: what one segment's tokens name (S1, S3, S4).
283
278
  // ---------------------------------------------------------------------
284
279
 
285
280
  /**
@@ -323,14 +318,13 @@ function gitIndices(tokens) {
323
318
  return found;
324
319
  }
325
320
 
326
- /** S1/S9: the worktree verb this segment names, or undefined. */
321
+ /** S1: the worktree verb this segment names, or undefined. */
327
322
  function worktreeIntent(tokens) {
328
323
  for (const gitIndex of gitIndices(tokens)) {
329
324
  const subcommand = gitSubcommandIndex(tokens, gitIndex);
330
325
  if (subcommand < 0 || tokens[subcommand] !== 'worktree') continue;
331
326
  const verb = tokens[subcommand + 1];
332
327
  if (verb === 'add') return 'add';
333
- if (verb === 'list') return 'list';
334
328
  }
335
329
  return undefined;
336
330
  }
@@ -460,7 +454,7 @@ function isLiteralCdTarget(value) {
460
454
  * really runs moves it for the segments after it, resolved against the cwd in force
461
455
  * before it; anything else — quoted argument text, a missing or non-literal argument,
462
456
  * or a cwd already unknown — leaves it unknown, and an unknown cwd refuses nothing of
463
- * S4 (S8). S1 and S9 were answered before this walk, so they stay any-cwd.
457
+ * S4 (S8). S1 was answered before this walk, so it stays any-cwd.
464
458
  */
465
459
  function segmentsWithCwd(segments, cwd) {
466
460
  let effective = typeof cwd === 'string' && cwd.length > 0 ? cwd : undefined;
@@ -679,12 +673,11 @@ function decideBashGuard(input) {
679
673
  const segments = scanCommand(command);
680
674
  if (segments.length === 0) return { block: false };
681
675
 
682
- // S1 and S9 are text-only and apply in every cwd, so they are answered first,
676
+ // S1 is text-only and applies in every cwd, so it is answered first,
683
677
  // before anything reads the repository at all.
684
678
  for (const { tokens } of segments) {
685
679
  const verb = worktreeIntent(tokens);
686
680
  if (verb === 'add') return { block: true, reason: WORKTREE_ADD_REFUSAL };
687
- if (verb === 'list') return { block: true, reason: WORKTREE_LIST_REFUSAL };
688
681
  }
689
682
 
690
683
  // S4 is the only rule left, and it needs a switch to judge: without one nothing
@@ -7,7 +7,7 @@
7
7
  // sees: the main checkout first and unnumbered, then this package's own checkouts in
8
8
  // name order, then — with `all` — the worktrees Git knows outside the directory.
9
9
  //
10
- // A row is its directory's basename, which IS the ODD, and the branch Git reports.
10
+ // A row is the checkout's absolute path, whose last segment IS the ODD, and the branch Git reports.
11
11
  // There is no `odd:` field, no date, no setup line, no hooks line and no stored
12
12
  // state: a directory that exists is a worktree and one that does not is simply not
13
13
  // listed (S2, S3). Nothing here reads the filesystem or spawns Git, and this module
@@ -90,10 +90,10 @@ function mainLine(row) {
90
90
  return `base: ${row.branch}${head}`;
91
91
  }
92
92
 
93
- // The ODD and its branch are two facts, so a middle dot keeps them visibly apart:
94
- // `1 <name> · <branch>`.
93
+ // The checkout and its branch are two facts, so a middle dot keeps them visibly apart:
94
+ // `1 <absolute path> · <branch>`.
95
95
  function rowLine(row) {
96
- return `${row.index} ${row.name} · ${row.branch}`;
96
+ return `${row.index} ${row.path} · ${row.branch}`;
97
97
  }
98
98
 
99
99
  /** The agent-facing text: fixed field order, single spaces, no decoration. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-odd-worktree",
3
- "version": "3.7.2",
3
+ "version": "3.8.0",
4
4
  "description": "Pi package for odd-worktree: the Git worktree tools a Pi session uses (create and list the checkouts the agent works in), the /warp worktree panel, the /odd ODD viewer, and the /issues GitHub issue reader. Needs only Pi and git: no companion app, no extra service.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -1574,7 +1574,7 @@ test('a removed checkout wears the destructive family, a created one prepares',
1574
1574
  // backtick or an `->` in a commit message is that message, not a hidden command and not
1575
1575
  // a redirect. Only an expanding body (unquoted delimiter) can still run something.
1576
1576
  test('a quoted heredoc body is data, whatever characters it carries', () => {
1577
- assert.equal(inferBashActivity("git commit -q -F - <<'MSG'\nfix(cards): repaint `Card tags` a -> b\n\nbody > more\nMSG"), 'versioning');
1577
+ assert.equal(inferBashActivity("git commit -q -F - <<'MSG'\nfix(cards): repaint `Card activity` a -> b\n\nbody > more\nMSG"), 'versioning');
1578
1578
  assert.equal(
1579
1579
  inferBashActivity("cd /repo && set -e\ngit add a b\ngit commit -q -F - <<'MSG'\nfix: x `y`\nMSG\ngit log --oneline -5; git status --short | wc -l"),
1580
1580
  'versioning',
@@ -1608,12 +1608,12 @@ test('the audit\'s real PR command names the publishing activity', () => {
1608
1608
  const command = `cd /home/jona/dev/projects/odd-worktree-worktrees/jobs-activity-card && git push -q origin feat/jobs-activity-card 2>&1 | tail -3; gh pr create --base main --head feat/jobs-activity-card --title "feat(cards): draw background-job tools in the active card style" --body "$(cat <<'EOF'
1609
1609
  ## What
1610
1610
 
1611
- \`bash_background\`, \`monitor\`, \`job_stop\` and \`job_list\` are registered with no renderer of their own, so Pi draws them in a plain box and neither \`neon\` nor \`float\` ever reaches them. While the bridge's \`Card tags\` line answers with this package's \`activity\` design for the tool, they are now drawn on the card substrate in the shell's chosen style.
1611
+ \`bash_background\`, \`monitor\`, \`job_stop\` and \`job_list\` are registered with no renderer of their own, so Pi draws them in a plain box and neither \`neon\` nor \`float\` ever reaches them. While the bridge's \`Card activity\` line answers with this package's \`activity\` design for the tool, they are now drawn on the card substrate in the shell's chosen style.
1612
1612
 
1613
1613
  - Call: the tool's mark and word (\`⧗ background\`, \`◉ monitor\`, \`■ stop\`, \`≡ jobs\`) plus the job's label, else the first line of its command; the whole command when expanded.
1614
1614
  - Result: the job's own answer, first rows collapsed and everything expanded, closing the frame with the call's duration.
1615
1615
  - \`minimal\`: the call alone while collapsed; a failure still says why.
1616
- - Any other answer on \`Card tags\` — \`native\`, \`not-covered\`, \`missing\`, another plugin's design, no bridge, a bridge older than the reader — leaves Pi's own drawing untouched.
1616
+ - Any other answer on \`Card activity\` — \`native\`, \`not-covered\`, \`missing\`, another plugin's design, no bridge, a bridge older than the reader — leaves Pi's own drawing untouched.
1617
1617
 
1618
1618
  The four tools are declared on the \`tags\` line so the bridge can answer for them; the activity design itself returns their rows exactly as drawn.
1619
1619
 
@@ -1910,7 +1910,7 @@ test('a shell or ssh handed a command line is named by that command line', () =>
1910
1910
 
1911
1911
  // Single quotes expand nothing, so a backtick inside them hides no command.
1912
1912
  test('a backtick inside single quotes is text', () => {
1913
- assert.equal(inferBashActivity("git commit -m 'fix `Card tags` row'"), 'versioning');
1913
+ assert.equal(inferBashActivity("git commit -m 'fix `Card activity` row'"), 'versioning');
1914
1914
  assert.equal(inferBashActivity('git commit -m "fix `date`"'), undefined);
1915
1915
  });
1916
1916