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.
@@ -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');
@@ -50,10 +50,6 @@ function setup(overrides = {}) {
50
50
  },
51
51
  }),
52
52
  warmUpDaemon: async () => true,
53
- createCodegraphCardResolver: (options) => {
54
- calls.card.push(options);
55
- return { registered: true };
56
- },
57
53
  ...(overrides.impl || {}),
58
54
  };
59
55
  const result = registerCodegraph(pi, {
@@ -86,34 +82,6 @@ test('without the CodeGraph CLI nothing is registered at all', () => {
86
82
  assert.equal(pi.handlers.size, 0);
87
83
  });
88
84
 
89
- test('the CodeGraph card is registered once through the host hook, with the extension\'s own text metrics', () => {
90
- const registered = [];
91
- const { calls, pi } = setup();
92
- assert.equal(calls.card.length, 1);
93
- assert.deepEqual(calls.card[0].metrics(), { metrics: true });
94
- assert.equal(typeof calls.card[0].registerToolRenderer, 'function');
95
- pi.registerToolRenderer = (resolver) => registered.push(resolver);
96
- calls.card[0].registerToolRenderer('resolver');
97
- assert.deepEqual(registered, ['resolver'], 'the hook is looked up when it is used');
98
- });
99
-
100
- test('S6: the CodeGraph card gets the session cwd through a live seam', async () => {
101
- const { calls, run } = setup();
102
- assert.equal(typeof calls.card[0].cwd, 'function', 'the card factory is handed a cwd seam');
103
- assert.equal(calls.card[0].cwd(), undefined, 'unknown until the session says');
104
- await run('session_start', { reason: 'startup' });
105
- assert.equal(calls.card[0].cwd(), '/work/repo', 'the seam answers with the session checkout');
106
- });
107
-
108
- test('a host without the renderer hook is given no registration to call', () => {
109
- const { calls } = setup();
110
- assert.equal(calls.card[0].registerToolRenderer('x'), undefined, 'a missing hook is a no-op, never a throw');
111
- });
112
-
113
- test('without the CLI the card is not registered either', () => {
114
- const { calls } = setup({ hasBinary: () => false });
115
- assert.equal(calls.card.length, 0);
116
- });
117
85
 
118
86
  test('a primary session start ensures the MCP entry once, prepares the index and reports the change', async () => {
119
87
  const { calls, run } = setup();
@@ -99,10 +99,9 @@ describe('the Card diff line (S2)', () => {
99
99
  assert.equal(typeof design.preview, 'function');
100
100
  });
101
101
 
102
- test('the preview is ONE row, titled after the value', () => {
102
+ test('the preview is ONE row, titled after the LINE so both options read as one line', () => {
103
103
  const preview = diffColorDesign(seamFor().seam).preview();
104
- assert.equal(preview.title, `Cards · ${DIFF_DESIGN_LABEL}`);
105
- assert.equal(preview.title, 'Cards · color');
104
+ assert.equal(preview.title, 'Cards · Card diff', 'the same title the `default` value shows');
106
105
  assert.equal(preview.sample.split('\n').length, 1, 'one row, like every Cards value');
107
106
  assert.deepEqual(preview, DIFF_DESIGN_PREVIEW);
108
107
  });
@@ -25,7 +25,7 @@ const {
25
25
  fileResultRows,
26
26
  } = require('../lib/file-card.js');
27
27
  const { createFileCardResolver, registerFileCard } = require('../lib/file-card-resolver.js');
28
- // The design this package registers on the bridge's `Card tags` line: the card's one
28
+ // The design this package registers on the bridge's `Card activity` line: the card's one
29
29
  // switch is that line's answer for the tool being drawn, so the card is only painted
30
30
  // for a tool the line actually covers.
31
31
  const { toolsActivityDesign } = require('../lib/bash-design.js');
@@ -564,7 +564,7 @@ test('a foreign, hostile or unreadable bridge never hides the card', () => {
564
564
  assert.match(draw(), /📑 odd/u, 'an unknown kind keeps the card');
565
565
  });
566
566
 
567
- test('S1: a write is covered by the Card tags line, so its file card paints and `default` restores the host row', () => {
567
+ test('S1: a write is covered by the Card activity line, so its file card paints and `default` restores the host row', () => {
568
568
  // A bridge answers from the design's own `tools` list, exactly as it resolves
569
569
  // coverage: a tool the line does not name is `not-covered`, which is the host's own
570
570
  // card. `write` is declared on that line so the file card can be asked about it.
@@ -573,7 +573,7 @@ test('S1: a write is covered by the Card tags line, so its file card paints and
573
573
  publishBridge((tool) => (design.tools.includes(tool) ? { kind: 'design', design } : { kind: 'not-covered' }), asked);
574
574
  const resolver = fileResolver();
575
575
  for (const tool of ['read', 'write']) {
576
- assert.equal(design.tools.includes(tool), true, `${tool} is covered by the Card tags line`);
576
+ assert.equal(design.tools.includes(tool), true, `${tool} is covered by the Card activity line`);
577
577
  const row = callRow(resolver, tool, { path: ODD, content: '# x\n' }, plainTheme);
578
578
  assert.match(unpaint(row), /📑 odd/u, `${tool}: the file card paints its heading`);
579
579
  assert.match(unpaint(row), new RegExp(`${tool} cards-skill-odd\\.md`, 'u'), `${tool}: and names the call`);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
  // The jobs card: `bash_background`, `monitor`, `job_stop` and `job_list` are registered by
3
3
  // Gentle Shell with no renderer of their own, so Pi draws its plain default box and the
4
- // conversation's card style never reaches them. While the bridge's `Card tags` line answers
4
+ // conversation's card style never reaches them. While the bridge's `Card activity` line answers
5
5
  // `activity` for the tool being drawn, this package draws them on its own card substrate
6
6
  // (`lib/shell-card.js`), in whichever style the shell has chosen. Any other answer — and the
7
7
  // absence of an answer — leaves Pi's own drawing exactly as it was.
@@ -117,7 +117,7 @@ function assertFramed(rows, width) {
117
117
 
118
118
  // ---- the one switch ----
119
119
 
120
- test('the card is drawn only while the Card tags line answers activity; every other answer leaves Pi\'s own drawing', () => {
120
+ test('the card is drawn only while the Card activity line answers activity; every other answer leaves Pi\'s own drawing', () => {
121
121
  const answers = [
122
122
  ['no bridge published', undefined],
123
123
  ['the bridge\'s native answer', { kind: 'native' }],
@@ -295,7 +295,7 @@ test('registerJobsCard hands one resolver to the host hook and reports a host th
295
295
  assert.deepEqual(registerJobsCard({}, { metrics }), { registered: false, resolver: undefined });
296
296
  });
297
297
 
298
- test('the Card tags line covers the four job tools, so the bridge can answer for them', () => {
298
+ test('the Card activity line covers the four job tools, so the bridge can answer for them', () => {
299
299
  for (const scopes of [true, false]) {
300
300
  const design = toolsActivityDesign({ scopes });
301
301
  for (const tool of JOB_TOOLS) assert.ok(design.tools.includes(tool), `${tool} (scopes: ${scopes})`);
@@ -5,7 +5,7 @@
5
5
  // paints them on its own card substrate (`lib/shell-card.js`) through gentle-shell-bridge's
6
6
  // message-design surface, in whichever style the host has chosen and always in full.
7
7
  //
8
- // Both designs FOLLOW the `Card tags` line this package's tool design is selected on, so the
8
+ // Both designs FOLLOW the `Card activity` line this package's tool design is selected on, so the
9
9
  // human picks `activity` once and these paint with it — live, per pass, with no switch of their
10
10
  // own. Every case below goes through the public surface: `registerMessageCards` (the wire), the
11
11
  // designs it registers, and the rows `apply` answers for a width. The text seam and the themes
@@ -85,7 +85,7 @@ const validFollow = (follow) => follow !== null
85
85
  * The published bridge object (gentle-shell-bridge@0.12.0's shape, and the older one it replaced).
86
86
  * `validatesFollows` is the 0.12.0 discipline — a registration whose `follows` is malformed is
87
87
  * refused whole; without it, the object is a pre-0.12.0 bridge that ignores the unknown field.
88
- * `toolLine` is the `Card tags` line's live value: `undefined` means the line does not exist.
88
+ * `toolLine` is the `Card activity` line's live value: `undefined` means the line does not exist.
89
89
  */
90
90
  function publishBridge(options = {}) {
91
91
  const settings = options !== null && typeof options === 'object' ? options : {};
@@ -227,7 +227,7 @@ test('each design FOLLOWS the line and the design id this package already regist
227
227
  assert.notEqual(outcome.bridge.designs[0].follows, outcome.bridge.designs[1].follows, 'one follow object per design');
228
228
  });
229
229
 
230
- test('while Card tags answers activity the message is the card', () => {
230
+ test('while Card activity answers activity the message is the card', () => {
231
231
  const wire = registered({ toolLine: ACTIVITY });
232
232
  const rows = renderMessage(wire.bridge, EXPLORATION, plainBody(EXPLORATION, STARTED));
233
233
  assert.equal(unpaint(rows[0]), headOf(EXPLORATION_HEADING, 70));