pi-odd-worktree 3.7.1 → 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.
@@ -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.1",
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
 
@@ -15,6 +15,9 @@ const {
15
15
  // The second line this package registers. Its own suite owns its drawing; the release rule below is
16
16
  // here because one `VERSION` decides both lines at once.
17
17
  const { registerDiffDesign } = require('../lib/diff-design.js');
18
+ // modular-tools S11: the two CodeGraph tools are declared on the `Card activity` line too, because the
19
+ // CodeGraph card is a DESIGN of that line and `not-covered` would be a card nobody could switch on.
20
+ const CODEGRAPH_TOOLS = ['codegraph', 'codegraph_explore', 'mcp__codegraph__codegraph_explore'];
18
21
 
19
22
  const CALL = { tool: 'bash', part: 'call', width: 90 };
20
23
  const strip = (row) => row.replace(/\u001b\[[0-9;]*m/g, '');
@@ -522,7 +525,7 @@ describe('the registration', () => {
522
525
  assert.equal(design.label, BASH_DESIGN_LABEL);
523
526
  assert.equal(BASH_DESIGN_LABEL, 'activity');
524
527
  const preview = design.preview();
525
- assert.equal(preview.title, 'Cards · activity');
528
+ assert.equal(preview.title, 'Cards · Card bash', 'the single-tool registration names its own implicit line');
526
529
  // One line like every other Cards row, and one that fits a narrow panel.
527
530
  assert.equal(preview.sample.split('\n').length, 1);
528
531
  assert.ok(textWidth(preview.sample) <= 72, preview.sample);
@@ -530,7 +533,7 @@ describe('the registration', () => {
530
533
  assert.ok(preview.sample.includes(word), word);
531
534
  }
532
535
  preview.title = 'changed';
533
- assert.equal(design.preview().title, 'Cards · activity');
536
+ assert.equal(design.preview().title, 'Cards · Card bash');
534
537
  });
535
538
 
536
539
  test('registers once per process, returns an idempotent disposer, and tolerates a bridge without the API', () => {
@@ -838,7 +841,7 @@ const designFor = (version) => {
838
841
  return seen.find((design) => design.id !== 'odd-worktree.capability-probe');
839
842
  };
840
843
 
841
- describe('the Card tags line', () => {
844
+ describe('the Card activity line', () => {
842
845
  test('the line declares `read` and `write` so the file card can be asked about them, and the design paints nothing for either', () => {
843
846
  // S1: the file card is painted only while this line resolves to the activity design
844
847
  // for the tool being drawn, and a bridge resolves coverage from the line's own
@@ -846,7 +849,7 @@ describe('the Card tags line', () => {
846
849
  // answers `undefined` for both (`computeActivity` knows only bash and the three read-only
847
850
  // shell marks), so their rows come back byte for byte and the host's own card is never lost.
848
851
  const design = designFor('0.6.0');
849
- assert.deepEqual(design.tools, ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list']);
852
+ assert.deepEqual(design.tools, ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS]);
850
853
  const answer = (tool) => (design.tools.includes(tool) ? { kind: 'design', design } : { kind: 'not-covered' });
851
854
  assert.equal(answer('write').kind, 'design', 'a write is covered by the line');
852
855
  assert.equal(answer('write').design.id, BASH_DESIGN_ID);
@@ -865,8 +868,8 @@ describe('the Card tags line', () => {
865
868
 
866
869
  test('a 0.6.0 bridge gets ONE grouped registration over bash and the read-only tools', () => {
867
870
  const design = designFor('0.6.0');
868
- assert.equal(design.line, 'tags', 'the row the bridge derives is `Card tags` (S10)');
869
- assert.deepEqual(design.tools, ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list']);
871
+ assert.equal(design.line, 'activity', 'the row the bridge derives is `Card activity` (S3 of modular-tools)');
872
+ assert.deepEqual(design.tools, ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS]);
870
873
  assert.equal(Object.hasOwn(design, 'tool'), false, 'never both shapes');
871
874
  assert.equal(design.id, BASH_DESIGN_ID);
872
875
  assert.equal(design.label, BASH_DESIGN_LABEL);
@@ -874,14 +877,14 @@ describe('the Card tags line', () => {
874
877
  assert.match(design.description, /read-only/);
875
878
  assert.match(design.description, /exploring/);
876
879
  const preview = design.preview();
877
- assert.equal(preview.title, 'Cards · activity');
880
+ assert.equal(preview.title, 'Cards · Card activity');
878
881
  assert.equal(preview.sample.split('\n').length, 1, 'one row, like every Cards value');
879
882
  assert.equal(typeof design.apply, 'function');
880
883
  });
881
884
 
882
885
  test('every release from 0.6.0 up gets the line', () => {
883
886
  for (const version of ['0.6.0', '0.6.1', '0.10.0', '0.7.0-rc.1', '1.0.0', '0.6']) {
884
- assert.equal(designFor(version).line, 'tags', version);
887
+ assert.equal(designFor(version).line, 'activity', version);
885
888
  }
886
889
  });
887
890
 
@@ -911,7 +914,7 @@ describe('the Card tags line', () => {
911
914
  try {
912
915
  assert.equal(registerBashDesign(api), dispose);
913
916
  assert.equal(seen.length, 1);
914
- assert.equal(seen[0].line, 'tags');
917
+ assert.equal(seen[0].line, 'activity');
915
918
  } finally {
916
919
  dispose();
917
920
  }
@@ -1055,8 +1058,8 @@ describe('the seed runs before the registration', () => {
1055
1058
  api.registerToolDesign = () => {
1056
1059
  const selections = store['bridge-tool-designs']?.selections ?? {};
1057
1060
  inherited.push(JSON.parse(JSON.stringify(selections)));
1058
- if (typeof selections.bash === 'string' && selections.bash !== 'native' && selections.$lines?.tags === undefined) {
1059
- store['bridge-tool-designs'] = { ...store['bridge-tool-designs'], selections: { ...selections, $lines: { tags: selections.bash } } };
1061
+ if (typeof selections.bash === 'string' && selections.bash !== 'native' && selections.$lines?.activity === undefined) {
1062
+ store['bridge-tool-designs'] = { ...store['bridge-tool-designs'], selections: { ...selections, $lines: { activity: selections.bash } } };
1060
1063
  }
1061
1064
  return () => {};
1062
1065
  };
@@ -1069,7 +1072,7 @@ describe('the seed runs before the registration', () => {
1069
1072
  assert.equal(typeof dispose, 'function');
1070
1073
  dispose();
1071
1074
  assert.deepEqual(inherited[0], { bash: BASH_DESIGN_ID }, 'the seed was already stored when the bridge registered');
1072
- assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { tags: BASH_DESIGN_ID } });
1075
+ assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { activity: BASH_DESIGN_ID } });
1073
1076
  });
1074
1077
 
1075
1078
  test('a stored legacy choice is kept: the seed writes no selection and the line inherits that choice', () => {
@@ -1077,7 +1080,7 @@ describe('the seed runs before the registration', () => {
1077
1080
  const dispose = registerBashDesign(api);
1078
1081
  dispose();
1079
1082
  assert.deepEqual(writes.filter(([store]) => store === SELECTIONS[0]), [], 'no selection was written');
1080
- assert.deepEqual(files['bridge-tool-designs'].selections, { bash: 'someone.else', $lines: { tags: 'someone.else' } });
1083
+ assert.deepEqual(files['bridge-tool-designs'].selections, { bash: 'someone.else', $lines: { activity: 'someone.else' } });
1081
1084
  });
1082
1085
 
1083
1086
  test('the seed never writes the reserved line key itself', () => {
@@ -1096,8 +1099,8 @@ describe('the seed runs before the registration', () => {
1096
1099
  const { api, files, inherited } = migratingBridge(stored);
1097
1100
  const dispose = registerBashDesign(api);
1098
1101
  dispose();
1099
- assert.deepEqual(inherited[0].$lines, { tags: 'native' }, 'the bridge registered with the new key already taken');
1100
- assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { tags: 'native' } }, 'the user keeps `default`');
1102
+ assert.deepEqual(inherited[0].$lines, { activity: 'native' }, 'the bridge registered with the new key already taken');
1103
+ assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { activity: 'native' } }, 'the user keeps `default`');
1101
1104
  });
1102
1105
 
1103
1106
  test('an old bridge keeps today\'s per-tool choice, with no line value', () => {
@@ -1111,30 +1114,42 @@ describe('the seed runs before the registration', () => {
1111
1114
 
1112
1115
  // S10: the row name is the bridge's, derived from the LINE KEY itself — `Card ` + the line, a line has
1113
1116
  // no label of its own — so
1114
- // `Card tools` becoming `Card tags` is a rename of this package's line. The bridge has no rename or
1117
+ // `Card tools` becoming `Card activity` is a rename of this package's line. The bridge has no rename or
1115
1118
  // alias path, and its own registration-time migration treats an ABSENT line key as "inherit the
1116
1119
  // joining tool's legacy per-tool value", which is exactly the `bash` = `activity` this package seeds
1117
1120
  // on a first run: a bare rename would hand `activity` back to a user who had chosen `default`. So the
1118
1121
  // package carries the stored value over itself, BEFORE it registers, and the bridge then finds the
1119
1122
  // line's key taken.
1120
- describe('the `Card tools` -> `Card tags` carry-over', () => {
1123
+ describe('the `Card tools` -> `Card activity` carry-over', () => {
1121
1124
  const stored = (selections) => ({ 'bridge-tool-designs': { selections } });
1122
1125
 
1123
- test('a stored tools value becomes the tags value and the old key is gone', () => {
1124
- for (const chosen of ['native', 'someone.else']) {
1125
- const { api, files } = fakeBridge(stored({ bash: BASH_DESIGN_ID, $lines: { tools: chosen } }));
1126
- assert.equal(carryOverLineSelection(api), true, chosen);
1127
- assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { tags: chosen } }, chosen);
1128
- assert.equal(Object.hasOwn(files['bridge-tool-designs'].selections.$lines, 'tools'), false, `${chosen}: no tools key is left`);
1126
+ test('a value stored under either previous key becomes the activity value and the old key is gone', () => {
1127
+ for (const previous of ['tags', 'tools']) {
1128
+ for (const chosen of ['native', 'someone.else']) {
1129
+ const { api, files } = fakeBridge(stored({ bash: BASH_DESIGN_ID, $lines: { [previous]: chosen } }));
1130
+ assert.equal(carryOverLineSelection(api), true, `${previous} ${chosen}`);
1131
+ assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { activity: chosen } }, `${previous} ${chosen}`);
1132
+ assert.equal(Object.hasOwn(files['bridge-tool-designs'].selections.$lines, previous), false, `${previous} ${chosen}: the old key is gone`);
1133
+ }
1129
1134
  }
1130
1135
  });
1131
1136
 
1137
+ test('the newest previous key wins, and an invalid one migrates nothing at all', () => {
1138
+ const both = fakeBridge(stored({ $lines: { tags: 'native', tools: 'someone.else' } }));
1139
+ assert.equal(carryOverLineSelection(both.api), true);
1140
+ assert.deepEqual(both.files['bridge-tool-designs'].selections, { $lines: { activity: 'native', tools: 'someone.else' } }, 'the newest key is carried and no other key is dropped');
1141
+ const invalid = fakeBridge(stored({ $lines: { tags: [], tools: 'native' } }));
1142
+ assert.equal(carryOverLineSelection(invalid.api), false);
1143
+ assert.deepEqual(invalid.writes, []);
1144
+ });
1145
+
1132
1146
  test('a store with no tools value writes nothing', () => {
1133
1147
  const untouched = [
1134
1148
  {},
1135
1149
  { bash: 'native' },
1136
1150
  { bash: 'native', $lines: {} },
1137
1151
  { bash: 'native', $lines: { diff: 'odd-worktree.diff-color' } },
1152
+ { bash: 'native', $lines: { colour: 'odd-worktree.diff-color' } },
1138
1153
  ];
1139
1154
  for (const selections of untouched) {
1140
1155
  const { api, files, writes } = fakeBridge(stored(selections));
@@ -1153,7 +1168,7 @@ describe('the `Card tools` -> `Card tags` carry-over', () => {
1153
1168
  // non-blank id string (`native` included). Copying anything else would write garbage under the
1154
1169
  // new key and delete the old one, so an invalid value is NO migration at all.
1155
1170
  for (const chosen of [42, null, {}, ' ', '', ['native'], false]) {
1156
- const selections = { bash: BASH_DESIGN_ID, $lines: { tools: chosen } };
1171
+ const selections = { bash: BASH_DESIGN_ID, $lines: { tags: chosen } };
1157
1172
  const before = JSON.stringify(selections);
1158
1173
  const { api, files, writes } = fakeBridge(stored(selections));
1159
1174
  assert.equal(carryOverLineSelection(api), false, JSON.stringify(chosen));
@@ -1162,8 +1177,8 @@ describe('the `Card tools` -> `Card tags` carry-over', () => {
1162
1177
  }
1163
1178
  });
1164
1179
 
1165
- test('a value already stored at tags is never overwritten', () => {
1166
- const selections = { bash: BASH_DESIGN_ID, $lines: { tags: 'someone.else', tools: 'native' } };
1180
+ test('a value already stored at activity is never overwritten', () => {
1181
+ const selections = { bash: BASH_DESIGN_ID, $lines: { activity: 'someone.else', tags: 'native' } };
1167
1182
  const { api, files, writes } = fakeBridge(stored(selections));
1168
1183
  assert.equal(carryOverLineSelection(api), false);
1169
1184
  assert.deepEqual(writes, [], 'nothing was written');
@@ -1239,7 +1254,7 @@ describe('the scoped claim', () => {
1239
1254
 
1240
1255
  test('the line gains edit, and every other tool keeps its whole claim', () => {
1241
1256
  const design = toolsActivityDesign();
1242
- assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', 'edit']);
1257
+ assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS, 'edit']);
1243
1258
  for (const tool of ['bash', 'grep', 'find', 'ls', 'read']) {
1244
1259
  assert.equal(Object.hasOwn(design.scopes, tool), false, `${tool} is claimed for every call`);
1245
1260
  }
@@ -1273,7 +1288,7 @@ describe('the scoped claim', () => {
1273
1288
  assert.equal(design.scopes.write, design.scopes.edit, version);
1274
1289
  continue;
1275
1290
  }
1276
- assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list'], `${version}: today's tools`);
1291
+ assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS], `${version}: today's tools`);
1277
1292
  assert.deepEqual(
1278
1293
  Object.keys(design).sort(),
1279
1294
  ['apply', 'description', 'id', 'label', 'line', 'name', 'preview', 'tools'],
@@ -1285,15 +1300,15 @@ describe('the scoped claim', () => {
1285
1300
  test('a prerelease or a build suffix of the cutoff never meets it: 0.9.0-rc.1 keeps the unscoped line', () => {
1286
1301
  // Semver puts a prerelease BELOW its own release, so `0.9.0-rc.1` carries no per-(`line`, `tool`)
1287
1302
  // scope even though its digits read 0.9.0; a build suffix is read the same conservative way. Its
1288
- // numbers still clear the 0.6.0 line, so the grouped `Card tags` row is kept, unscoped.
1303
+ // numbers still clear the 0.6.0 line, so the grouped `Card activity` row is kept, unscoped.
1289
1304
  for (const version of ['0.9.0-rc.1', '0.9.0+build.7', '0.9.0-rc.1+sha.abc']) {
1290
1305
  const { api, calls } = registering(version);
1291
1306
  registerBashDesign(api)();
1292
1307
  assert.equal(calls.length, 1, `${version}: a readable release is never probed`);
1293
1308
  const design = calls.at(-1);
1294
- assert.equal(design.line, 'tags', version);
1309
+ assert.equal(design.line, 'activity', version);
1295
1310
  assert.equal(design.scopes, undefined, `${version}: a prerelease of 0.9.0 does not meet the 0.9.0 cutoff`);
1296
- assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list'], version);
1311
+ assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS], version);
1297
1312
  }
1298
1313
  });
1299
1314
 
@@ -1303,14 +1318,14 @@ describe('the scoped claim', () => {
1303
1318
  assert.equal(calls[0].id, 'odd-worktree.capability-probe', 'the grouped shape is still probed');
1304
1319
  const design = calls.at(-1);
1305
1320
  assert.equal(design.scopes, undefined, 'an unreadable release never takes a scoped registration');
1306
- assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list']);
1321
+ assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS]);
1307
1322
  });
1308
1323
  });
1309
1324
 
1310
1325
  // S6: ONE rule for every cutoff this package reads — an advertised release meets a cutoff by semver
1311
1326
  // order, numbers first, and a prerelease or build suffix loses ONLY when the numbers are equal. Both
1312
1327
  // of this package's lines sit at the same `0.9.0` cutoff, so each version is read through both
1313
- // registrations at once: a release that is below it keeps the unscoped `Card tags` line and gets no
1328
+ // registrations at once: a release that is below it keeps the unscoped `Card activity` line and gets no
1314
1329
  // `Card diff` row, and a newer one gets both the scope and the diff line.
1315
1330
  describe('the release rule is semver order, on both lines at once (S6)', () => {
1316
1331
  const registerBoth = (version) => {
@@ -1322,16 +1337,16 @@ describe('the release rule is semver order, on both lines at once (S6)', () => {
1322
1337
  if (typeof disposeTags === 'function') disposeTags();
1323
1338
  if (typeof disposeDiff === 'function') disposeDiff();
1324
1339
  };
1325
- return { seen, dispose, tags: seen.find((design) => design.line === 'tags'), diff: seen.find((design) => design.line === 'diff') };
1340
+ return { seen, dispose, tags: seen.find((design) => design.line === 'activity'), diff: seen.find((design) => design.line === 'diff') };
1326
1341
  };
1327
1342
 
1328
- test('a prerelease or a build suffix of 0.9.0 is BELOW it: unscoped `Card tags`, no `Card diff`', () => {
1343
+ test('a prerelease or a build suffix of 0.9.0 is BELOW it: unscoped `Card activity`, no `Card diff`', () => {
1329
1344
  for (const version of ['0.9.0-rc.1', '0.9.0-beta.1+build', '0.9.0+workstation']) {
1330
1345
  const registration = registerBoth(version);
1331
1346
  try {
1332
- assert.deepEqual(registration.seen.map((design) => design.line), ['tags'], `${version}: the grouped line, and no diff line`);
1347
+ assert.deepEqual(registration.seen.map((design) => design.line), ['activity'], `${version}: the grouped line, and no diff line`);
1333
1348
  assert.equal(registration.tags.scopes, undefined, `${version}: below 0.9.0, so no scope`);
1334
- assert.deepEqual([...registration.tags.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list'], `${version}: ten tools, no edit`);
1349
+ assert.deepEqual([...registration.tags.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS], `${version}: ten tools, no edit`);
1335
1350
  assert.equal(registration.diff, undefined, `${version}: nothing is offered for a row the bridge would refuse`);
1336
1351
  } finally {
1337
1352
  registration.dispose();
@@ -1339,13 +1354,13 @@ describe('the release rule is semver order, on both lines at once (S6)', () => {
1339
1354
  }
1340
1355
  });
1341
1356
 
1342
- test('a NEWER release carrying a suffix is ABOVE 0.9.0: the scoped `Card tags` line AND `Card diff`', () => {
1357
+ test('a NEWER release carrying a suffix is ABOVE 0.9.0: the scoped `Card activity` line AND `Card diff`', () => {
1343
1358
  for (const version of ['0.9.1-rc.1', '0.10.0+local.2']) {
1344
1359
  const registration = registerBoth(version);
1345
1360
  try {
1346
- assert.deepEqual(registration.seen.map((design) => design.line), ['tags', 'diff'], `${version}: both lines`);
1361
+ assert.deepEqual(registration.seen.map((design) => design.line), ['activity', 'diff'], `${version}: both lines`);
1347
1362
  assert.equal(registration.tags.scopes.write, registration.tags.scopes.edit, `${version}: the scope is on the line`);
1348
- assert.deepEqual([...registration.tags.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', 'edit'], `${version}: eleven tools`);
1363
+ assert.deepEqual([...registration.tags.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'bash_background', 'monitor', 'job_stop', 'job_list', ...CODEGRAPH_TOOLS, 'edit'], `${version}: eleven tools`);
1349
1364
  assert.equal(registration.diff.id, 'odd-worktree.diff', version);
1350
1365
  assert.equal(registration.diff.label, 'color', version);
1351
1366
  assert.deepEqual([...registration.diff.tools], ['write', 'edit'], version);
@@ -1377,7 +1392,7 @@ describe('the release rule is semver order, on both lines at once (S6)', () => {
1377
1392
 
1378
1393
  test('the ordinary releases still read as they always did', () => {
1379
1394
  // 0.6.0 itself, and anything above it, is the grouped line; 0.5.0 is the single one.
1380
- for (const [version, shape] of [['0.5.0', 'bash'], ['0.6.0', 'tags'], ['0.9.0', 'tags']]) {
1395
+ for (const [version, shape] of [['0.5.0', 'bash'], ['0.6.0', 'activity'], ['0.9.0', 'activity']]) {
1381
1396
  const registration = registerBoth(version);
1382
1397
  try {
1383
1398
  assert.equal(registration.tags === undefined, shape === 'bash', version);
@@ -18,7 +18,7 @@ const { join } = require('node:path');
18
18
  const { after, before, test } = require('node:test');
19
19
  const { pathToFileURL } = require('node:url');
20
20
 
21
- const { LIB_DIR, stubbedSource, installDefaultBridge } = require('./fixtures/load-extension.js');
21
+ const { LIB_DIR, defaultBridge, stubbedSource } = require('./fixtures/load-extension.js');
22
22
 
23
23
  const {
24
24
  CARD_CONTENT,
@@ -181,6 +181,35 @@ function withContent(content, run) {
181
181
  }
182
182
  }
183
183
 
184
+ // ---- the switch: the bridge's `Card activity` line (S11) ----
185
+
186
+ // S11 (modular-tools): the card is a DESIGN, so it paints only while the bridge's `Card activity` line
187
+ // answers with this package's activity design. The slot is published here exactly as the host
188
+ // publishes it; `selection` is an answer or a function of the tool being drawn, and `asked`
189
+ // collects every question.
190
+ const BRIDGE_API_SLOT = Symbol.for('gentle-shell-bridge/api/v1');
191
+ const ACTIVITY_DESIGN_ID = 'odd-worktree.bash-activity';
192
+
193
+ function publishBridge(selection, asked = []) {
194
+ globalThis[BRIDGE_API_SLOT] = {
195
+ schema: 'gentle-shell-bridge/api',
196
+ version: 1,
197
+ VERSION: '0.12.1',
198
+ resolveToolDesignSelection(tool) {
199
+ asked.push(tool);
200
+ return typeof selection === 'function' ? selection(tool) : selection;
201
+ },
202
+ };
203
+ return asked;
204
+ }
205
+
206
+ /** Every tool the card paints wears the activity design: the switch is ON. */
207
+ const ACTIVITY_ON = (tool) => (isCodeGraphCardTool(tool) || tool === 'bash' ? { kind: 'design', design: { id: ACTIVITY_DESIGN_ID } } : { kind: 'not-covered', id: ACTIVITY_DESIGN_ID });
208
+ publishBridge(ACTIVITY_ON);
209
+ after(() => {
210
+ delete globalThis[BRIDGE_API_SLOT];
211
+ });
212
+
184
213
  // ---- the resolver under test ----
185
214
 
186
215
  /** No hook at all would be the host's own: every case here registers through the probe. */
@@ -927,6 +956,59 @@ test('an unreadable call or output draws nothing instead of throwing', () => {
927
956
  assert.deepEqual(codegraphShape('read', { command: 'codegraph init' }), undefined);
928
957
  });
929
958
 
959
+ // ---- S11: the switch is the bridge's `Card activity` line ----
960
+ //
961
+ // The card paints a CALL; it does not run CodeGraph. So no module switch decides it: the line
962
+ // the activity design owns does, asked on every paint. `activity` selected claims it, and every
963
+ // other answer — `native`, `not-covered`, `missing`, another plugin's design, a reader that
964
+ // throws, or no reader at all — hands the chain's own rows back without asking one slot.
965
+
966
+ test('S11: `activity` selected claims the CodeGraph tools and a bash call that runs the program', () => {
967
+ publishBridge(ACTIVITY_ON);
968
+ const resolver = cardFor();
969
+ for (const tool of [CODEGRAPH_TOOL, CODEGRAPH_MCP_TOOL]) {
970
+ const slot = resolver(tool, () => HOST_BASH);
971
+ assert.equal(slot?.renderShell, 'self', `${tool} is drawn as a self-framed card`);
972
+ assert.equal(typeof slot.renderCall, 'function', `${tool}: the card draws the call`);
973
+ assert.equal(typeof slot.renderResult, 'function', `${tool}: the card draws the result`);
974
+ }
975
+ const bash = resolver('bash', () => HOST_BASH);
976
+ assert.equal(bash?.renderShell, 'self', 'a bash call on a self-framed chain is the card’s');
977
+ });
978
+
979
+ test('S11: `native`, `not-covered`, `missing`, another design and a throwing reader hand every row back', () => {
980
+ const answers = [
981
+ { kind: 'native' },
982
+ { kind: 'not-covered', id: ACTIVITY_DESIGN_ID },
983
+ { kind: 'missing', id: 'gone.design' },
984
+ { kind: 'design', design: { id: 'someone.else' } },
985
+ { kind: 'design' },
986
+ { kind: 'design', design: null },
987
+ undefined,
988
+ null,
989
+ ];
990
+ for (const answer of answers) {
991
+ publishBridge(() => answer);
992
+ const resolver = cardFor();
993
+ for (const tool of [CODEGRAPH_TOOL, CODEGRAPH_MCP_TOOL, 'bash']) {
994
+ assert.equal(resolver(tool, () => HOST_BASH), HOST_BASH, `${tool} under ${JSON.stringify(answer)}`);
995
+ }
996
+ }
997
+ publishBridge(() => { throw new Error('bridge exploded'); });
998
+ assert.equal(cardFor()(CODEGRAPH_TOOL, () => HOST_BASH), HOST_BASH, 'a throwing reader is a no');
999
+ publishBridge(ACTIVITY_ON);
1000
+ });
1001
+
1002
+ test('S11: with no reader at all the card claims nothing, and a host without the hook registers nothing', () => {
1003
+ globalThis[BRIDGE_API_SLOT] = { schema: 'gentle-shell-bridge/api', version: 1 };
1004
+ assert.equal(cardFor()(CODEGRAPH_TOOL, () => HOST_BASH), HOST_BASH, 'an older bridge has no switch to follow');
1005
+ delete globalThis[BRIDGE_API_SLOT];
1006
+ assert.equal(cardFor()(CODEGRAPH_TOOL, () => HOST_BASH), HOST_BASH, 'no bridge, no switch, no card');
1007
+ publishBridge(ACTIVITY_ON);
1008
+ const { registerCodegraphCard } = require('../lib/codegraph-card.js');
1009
+ assert.deepEqual(registerCodegraphCard({}, {}), { registered: false, resolver: undefined }, 'no host hook, no registration');
1010
+ });
1011
+
930
1012
  // ---- purity ----
931
1013
 
932
1014
  test('the modules carry no colour, no escape and no host package', () => {
@@ -936,8 +1018,9 @@ test('the modules carry no colour, no escape and no host package', () => {
936
1018
  assert.doesNotMatch(source, /\\u001b|\\x1b|String\.fromCharCode\(27\)/, `${file} writes no escape sequence down`);
937
1019
  assert.doesNotMatch(source, /#[0-9a-fA-F]{6}\b/, `${file} writes no hexadecimal colour`);
938
1020
  assert.doesNotMatch(source, /require\(['"](?!\.\/|node:)/, `${file} imports only its own modules and Node builtins`);
939
- // S1: no model-facing tool is registered, executed or shadowed — the card only draws.
940
- assert.doesNotMatch(source, /registerTool\(|\.execute\b|registerCommand\(|registerToolRenderer\(/, `${file} registers and runs nothing`);
1021
+ // S1: no model-facing tool is registered, executed or shadowed — the card only draws. The
1022
+ // one host seam it touches is the renderer hook, through `registerCodegraphCard`.
1023
+ assert.doesNotMatch(source, /registerTool\(|\.execute\b|registerCommand\(/, `${file} registers and runs nothing`);
941
1024
  }
942
1025
  });
943
1026
 
@@ -994,9 +1077,16 @@ async function loadComposedExtension() {
994
1077
  await withCodegraphCli(() => {
995
1078
  // S18 (T14): the extension registers nothing without gentle-shell-bridge, so
996
1079
  // this file's own host publishes the shared fixture's bridge before the factory
997
- // runs.
998
- installDefaultBridge();
999
- mod.default(host);
1080
+ // runs. This load's bridge also answers the `Card activity` reader with the activity
1081
+ // design (S11), which is the switch the CodeGraph card follows.
1082
+ const previous = globalThis[BRIDGE_API_SLOT];
1083
+ globalThis[BRIDGE_API_SLOT] = { ...defaultBridge().api, resolveToolDesignSelection: ACTIVITY_ON };
1084
+ try {
1085
+ mod.default(host);
1086
+ } finally {
1087
+ if (previous === undefined) delete globalThis[BRIDGE_API_SLOT];
1088
+ else globalThis[BRIDGE_API_SLOT] = previous;
1089
+ }
1000
1090
  });
1001
1091
  // The cards measure text through the extension's own injected seam, so the test
1002
1092
  // supplies it after the load — the way the other card suites inject theirs.
@@ -1015,20 +1105,6 @@ function hostChain(resolvers, toolName, base = HOST_BASH) {
1015
1105
  return resolve(0);
1016
1106
  }
1017
1107
 
1018
- /** A resolver wrapped so a case can state whether its slots were ever asked for a row. */
1019
- function countedResolver(resolver, asked = []) {
1020
- const wrapped = (toolName, next) => {
1021
- const renderers = resolver(toolName, next);
1022
- if (renderers === undefined || renderers === null) return renderers;
1023
- const observe = (name) => (...args) => {
1024
- asked.push(name);
1025
- return renderers[name](...args);
1026
- };
1027
- return { ...renderers, renderCall: observe('renderCall'), renderResult: observe('renderResult') };
1028
- };
1029
- return { asked, resolver: wrapped };
1030
- }
1031
-
1032
1108
  /** One bash row down a chain, as the host drives it: its call and its result, as drawn lines. */
1033
1109
  function drawThrough(resolvers, command, output) {
1034
1110
  const slot = hostChain(resolvers, 'bash');