pi-odd-worktree 3.0.1 → 3.1.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.
@@ -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 tools` line are read on every paint, so a row whose path names
16
+ // the bridge's `Card tags` 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 tools` line answers that this package's activity design draws the tool being
41
+ // `Card tags` 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).
@@ -74,12 +74,20 @@ function bridgeApi() {
74
74
  * card. The bridge's reader never throws (an absent or unreadable store answers
75
75
  * `native`), and this one does not either: an answer it cannot read keeps the card
76
76
  * visible rather than hiding a row behind a version it does not know.
77
+ *
78
+ * S4: the call's own `args` travel with the question, because the line's claim on `write`
79
+ * and `edit` is a SCOPE (gentle-shell-bridge@0.9.0) — a predicate over `{ tool, args }`,
80
+ * answered per CALL. Without them the bridge cannot tell a skill's path from any other
81
+ * write, and this card would paint a call another line owns. The object is the host's
82
+ * own, by reference and never copied: the scope reads only its stable `path`. A bridge
83
+ * whose reader takes no second argument ignores it and answers exactly as before, and
84
+ * an older bridge reads the call as unknown, which is what it has always done.
77
85
  */
78
- function activitySelected(tool) {
86
+ function activitySelected(tool, args) {
79
87
  const api = bridgeApi();
80
88
  if (api === undefined || typeof api.resolveToolDesignSelection !== 'function') return true;
81
89
  try {
82
- const selection = api.resolveToolDesignSelection(tool);
90
+ const selection = api.resolveToolDesignSelection(tool, args);
83
91
  const answer = selection !== null && typeof selection === 'object' ? selection : {};
84
92
  if (answer.kind === 'native' || answer.kind === 'missing' || answer.kind === 'not-covered') return false;
85
93
  if (answer.kind !== 'design') return true;
@@ -153,13 +161,15 @@ function createFileCardResolver(options) {
153
161
  }
154
162
  },
155
163
  /**
156
- * The one switch, read now (S1/S7): the bridge's `Card tools` line answers with the
157
- * activity design for `tool`. A bridge with no reader — older than 0.7.0, or none at
158
- * all — paints the card, which is the behaviour it had before.
164
+ * The one switch, read now (S1/S7): the bridge's `Card tags` line answers with the
165
+ * activity design for `tool` — and, since a claim can be scoped, for THIS call: the
166
+ * call's `args` are handed over with the question (S4). A bridge with no reader —
167
+ * older than 0.7.0, or none at all — paints the card, which is the behaviour it had
168
+ * before; a reader that takes one argument ignores the second and answers as it did.
159
169
  */
160
- enabled(tool) {
170
+ enabled(tool, args) {
161
171
  try {
162
- return activitySelected(tool) === true;
172
+ return activitySelected(tool, args) === true;
163
173
  } catch {
164
174
  return true;
165
175
  }
package/lib/file-card.js CHANGED
@@ -521,7 +521,7 @@ function fileResultRows(input) {
521
521
  /**
522
522
  * The call slot. The identity and the ONE switch are both decided INSIDE the
523
523
  * component's build, so the host's `render(width)` re-reads them on every frame: a card
524
- * already on screen repaints when the bridge's `Card tools` line changes (L6), and the
524
+ * already on screen repaints when the bridge's `Card tags` line changes (L6), and the
525
525
  * measurement seam is asked for at paint time rather than at construction.
526
526
  *
527
527
  * A path that names neither identity returns the chain's own component straight away,
@@ -544,7 +544,10 @@ function fileCallSlot(tool, inherited, seams, shell) {
544
544
  return hostShellComponent(forwardedComponent(inherited, 'renderCall', [args, theme, context]), ctx, paint, seams, layout);
545
545
  }
546
546
  return component((width) => {
547
- if (!seams.enabled(tool)) {
547
+ // S4: the call's own arguments travel with the question, so a SCOPE on the
548
+ // bridge's line (`write` and `edit`, paths under `skills/` or `odd/`) can answer
549
+ // for THIS call and no other.
550
+ if (!seams.enabled(tool, callArgs)) {
548
551
  return hostShellRows(forwardedComponent(inherited, 'renderCall', [args, theme, context]), width, ctx, paint, seams, layout);
549
552
  }
550
553
  const metrics = seams.metrics();
@@ -583,7 +586,10 @@ function fileResultSlot(tool, inherited, seams, shell) {
583
586
  return hostShellComponent(forwardedComponent(inherited, 'renderResult', slotArgs), boxContext, paint, seams, layout);
584
587
  }
585
588
  return component((width) => {
586
- if (!seams.enabled(tool)) {
589
+ // S4: the result half asks the same question of the same call, with the arguments
590
+ // it holds (`ctx.args`), so both halves of one card are resolved against the same
591
+ // call and no half is asked a different question.
592
+ if (!seams.enabled(tool, args)) {
587
593
  return hostShellRows(forwardedComponent(inherited, 'renderResult', slotArgs), width, boxContext, paint, seams, layout);
588
594
  }
589
595
  const metrics = seams.metrics();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-odd-worktree",
3
- "version": "3.0.1",
3
+ "version": "3.1.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",
@@ -7,9 +7,14 @@ const {
7
7
  BASH_DESIGN_LABEL,
8
8
  applyBashActivityHeading,
9
9
  bashActivityDesign,
10
+ carryOverLineSelection,
10
11
  registerBashDesign,
11
12
  seedBashDesignSelection,
13
+ toolsActivityDesign,
12
14
  } = require('../lib/bash-design.js');
15
+ // The second line this package registers. Its own suite owns its drawing; the release rule below is
16
+ // here because one `VERSION` decides both lines at once.
17
+ const { registerDiffDesign } = require('../lib/diff-design.js');
13
18
 
14
19
  const CALL = { tool: 'bash', part: 'call', width: 90 };
15
20
  const strip = (row) => row.replace(/\u001b\[[0-9;]*m/g, '');
@@ -833,7 +838,7 @@ const designFor = (version) => {
833
838
  return seen.find((design) => design.id !== 'odd-worktree.capability-probe');
834
839
  };
835
840
 
836
- describe('the Card tools line', () => {
841
+ describe('the Card tags line', () => {
837
842
  test('the line declares `read` and `write` so the file card can be asked about them, and the design paints nothing for either', () => {
838
843
  // S1: the file card is painted only while this line resolves to the activity design
839
844
  // for the tool being drawn, and a bridge resolves coverage from the line's own
@@ -860,7 +865,7 @@ describe('the Card tools line', () => {
860
865
 
861
866
  test('a 0.6.0 bridge gets ONE grouped registration over bash and the read-only tools', () => {
862
867
  const design = designFor('0.6.0');
863
- assert.equal(design.line, 'tools');
868
+ assert.equal(design.line, 'tags', 'the row the bridge derives is `Card tags` (S10)');
864
869
  assert.deepEqual(design.tools, ['bash', 'grep', 'find', 'ls', 'read', 'write']);
865
870
  assert.equal(Object.hasOwn(design, 'tool'), false, 'never both shapes');
866
871
  assert.equal(design.id, BASH_DESIGN_ID);
@@ -876,7 +881,7 @@ describe('the Card tools line', () => {
876
881
 
877
882
  test('every release from 0.6.0 up gets the line', () => {
878
883
  for (const version of ['0.6.0', '0.6.1', '0.10.0', '0.7.0-rc.1', '1.0.0', '0.6']) {
879
- assert.equal(designFor(version).line, 'tools', version);
884
+ assert.equal(designFor(version).line, 'tags', version);
880
885
  }
881
886
  });
882
887
 
@@ -906,7 +911,7 @@ describe('the Card tools line', () => {
906
911
  try {
907
912
  assert.equal(registerBashDesign(api), dispose);
908
913
  assert.equal(seen.length, 1);
909
- assert.equal(seen[0].line, 'tools');
914
+ assert.equal(seen[0].line, 'tags');
910
915
  } finally {
911
916
  dispose();
912
917
  }
@@ -1050,8 +1055,8 @@ describe('the seed runs before the registration', () => {
1050
1055
  api.registerToolDesign = () => {
1051
1056
  const selections = store['bridge-tool-designs']?.selections ?? {};
1052
1057
  inherited.push(JSON.parse(JSON.stringify(selections)));
1053
- if (typeof selections.bash === 'string' && selections.bash !== 'native' && selections.$lines?.tools === undefined) {
1054
- store['bridge-tool-designs'] = { ...store['bridge-tool-designs'], selections: { ...selections, $lines: { tools: selections.bash } } };
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 } } };
1055
1060
  }
1056
1061
  return () => {};
1057
1062
  };
@@ -1064,7 +1069,7 @@ describe('the seed runs before the registration', () => {
1064
1069
  assert.equal(typeof dispose, 'function');
1065
1070
  dispose();
1066
1071
  assert.deepEqual(inherited[0], { bash: BASH_DESIGN_ID }, 'the seed was already stored when the bridge registered');
1067
- assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { tools: BASH_DESIGN_ID } });
1072
+ assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID, $lines: { tags: BASH_DESIGN_ID } });
1068
1073
  });
1069
1074
 
1070
1075
  test('a stored legacy choice is kept: the seed writes no selection and the line inherits that choice', () => {
@@ -1072,7 +1077,7 @@ describe('the seed runs before the registration', () => {
1072
1077
  const dispose = registerBashDesign(api);
1073
1078
  dispose();
1074
1079
  assert.deepEqual(writes.filter(([store]) => store === SELECTIONS[0]), [], 'no selection was written');
1075
- assert.deepEqual(files['bridge-tool-designs'].selections, { bash: 'someone.else', $lines: { tools: 'someone.else' } });
1080
+ assert.deepEqual(files['bridge-tool-designs'].selections, { bash: 'someone.else', $lines: { tags: 'someone.else' } });
1076
1081
  });
1077
1082
 
1078
1083
  test('the seed never writes the reserved line key itself', () => {
@@ -1083,6 +1088,18 @@ describe('the seed runs before the registration', () => {
1083
1088
  assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID }, 'no $lines from this package');
1084
1089
  });
1085
1090
 
1091
+ test('a stored line choice survives the rename: the carry-over takes the key first', () => {
1092
+ // S10: a user who chose `default` on `Card tools` has `$lines.tools` = `native`, while the
1093
+ // first-run seed left `bash` = `activity`. A bare rename would leave `$lines.tags` absent and the
1094
+ // bridge's own migration would resurrect that stale `activity`; the carry-over makes it a no-op.
1095
+ const stored = { 'bridge-tool-designs': { selections: { bash: BASH_DESIGN_ID, $lines: { tools: 'native' } } } };
1096
+ const { api, files, inherited } = migratingBridge(stored);
1097
+ const dispose = registerBashDesign(api);
1098
+ 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`');
1101
+ });
1102
+
1086
1103
  test('an old bridge keeps today\'s per-tool choice, with no line value', () => {
1087
1104
  const { api, files } = fakeBridge();
1088
1105
  api.VERSION = '0.5.0';
@@ -1091,3 +1108,283 @@ describe('the seed runs before the registration', () => {
1091
1108
  assert.deepEqual(files['bridge-tool-designs'].selections, { bash: BASH_DESIGN_ID });
1092
1109
  });
1093
1110
  });
1111
+
1112
+ // S10: the row name is the bridge's, derived from the LINE KEY itself — `Card ` + the line, a line has
1113
+ // 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
1115
+ // alias path, and its own registration-time migration treats an ABSENT line key as "inherit the
1116
+ // joining tool's legacy per-tool value", which is exactly the `bash` = `activity` this package seeds
1117
+ // on a first run: a bare rename would hand `activity` back to a user who had chosen `default`. So the
1118
+ // package carries the stored value over itself, BEFORE it registers, and the bridge then finds the
1119
+ // line's key taken.
1120
+ describe('the `Card tools` -> `Card tags` carry-over', () => {
1121
+ const stored = (selections) => ({ 'bridge-tool-designs': { selections } });
1122
+
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`);
1129
+ }
1130
+ });
1131
+
1132
+ test('a store with no tools value writes nothing', () => {
1133
+ const untouched = [
1134
+ {},
1135
+ { bash: 'native' },
1136
+ { bash: 'native', $lines: {} },
1137
+ { bash: 'native', $lines: { diff: 'odd-worktree.diff-color' } },
1138
+ ];
1139
+ for (const selections of untouched) {
1140
+ const { api, files, writes } = fakeBridge(stored(selections));
1141
+ assert.equal(carryOverLineSelection(api), false, JSON.stringify(selections));
1142
+ assert.deepEqual(writes, [], JSON.stringify(selections));
1143
+ assert.deepEqual(files['bridge-tool-designs'].selections, selections);
1144
+ }
1145
+ // No store file at all is the first run, not a rename.
1146
+ const fresh = fakeBridge();
1147
+ assert.equal(carryOverLineSelection(fresh.api), false);
1148
+ assert.deepEqual(fresh.writes, []);
1149
+ });
1150
+
1151
+ test('an invalid stored value is never migrated: the document stays byte-identical and nothing is written', () => {
1152
+ // The bridge's own `storedId` reads a line value as a choice only when it is a non-empty,
1153
+ // non-blank id string (`native` included). Copying anything else would write garbage under the
1154
+ // new key and delete the old one, so an invalid value is NO migration at all.
1155
+ for (const chosen of [42, null, {}, ' ', '', ['native'], false]) {
1156
+ const selections = { bash: BASH_DESIGN_ID, $lines: { tools: chosen } };
1157
+ const before = JSON.stringify(selections);
1158
+ const { api, files, writes } = fakeBridge(stored(selections));
1159
+ assert.equal(carryOverLineSelection(api), false, JSON.stringify(chosen));
1160
+ assert.deepEqual(writes, [], `${JSON.stringify(chosen)}: nothing was written`);
1161
+ assert.equal(JSON.stringify(files['bridge-tool-designs'].selections), before, `${JSON.stringify(chosen)}: byte-identical`);
1162
+ }
1163
+ });
1164
+
1165
+ test('a value already stored at tags is never overwritten', () => {
1166
+ const selections = { bash: BASH_DESIGN_ID, $lines: { tags: 'someone.else', tools: 'native' } };
1167
+ const { api, files, writes } = fakeBridge(stored(selections));
1168
+ assert.equal(carryOverLineSelection(api), false);
1169
+ assert.deepEqual(writes, [], 'nothing was written');
1170
+ assert.deepEqual(files['bridge-tool-designs'].selections, selections, 'neither key is touched');
1171
+ });
1172
+
1173
+ test('a malformed, foreign or refusing store writes nothing and never throws', () => {
1174
+ const foreign = [
1175
+ stored('oops'),
1176
+ stored({ $lines: 'oops' }),
1177
+ stored({ $lines: ['tools'] }),
1178
+ stored({ $lines: 42 }),
1179
+ { 'someone-else': { selections: { $lines: { tools: 'native' } } } },
1180
+ {},
1181
+ ];
1182
+ for (const files of foreign) {
1183
+ const { api, writes } = fakeBridge(files);
1184
+ assert.doesNotThrow(() => carryOverLineSelection(api), JSON.stringify(files));
1185
+ assert.equal(carryOverLineSelection(api), false, JSON.stringify(files));
1186
+ assert.deepEqual(writes, [], JSON.stringify(files));
1187
+ }
1188
+ const refusing = { createStore: () => { throw new Error('disk full'); } };
1189
+ assert.doesNotThrow(() => carryOverLineSelection(refusing));
1190
+ assert.equal(carryOverLineSelection(refusing), false);
1191
+ assert.equal(carryOverLineSelection({}), false);
1192
+ assert.equal(carryOverLineSelection(null), false);
1193
+ });
1194
+
1195
+ test('it writes the bridge\'s own store and nothing else', () => {
1196
+ const { api, writes } = fakeBridge(stored({ $lines: { tools: 'native' } }));
1197
+ assert.equal(carryOverLineSelection(api), true);
1198
+ assert.deepEqual(writes, [SELECTIONS], 'one document, the bridge\'s, never a marker of ours');
1199
+ });
1200
+ });
1201
+
1202
+ // S3/S6: the grouped `tags` line claims `write` and `edit` only for the paths the file card itself
1203
+ // claims — `lib/skill-odd-card.js`'s own rule, reused and never copied — so a skill or an ODD
1204
+ // artifact keeps the file card it has today while every other write is another line's call. The
1205
+ // scope is a 0.9.0 member, so the shape is decided before anything is registered: an older bridge
1206
+ // takes today's unscoped list, which is exactly the registration it has always accepted.
1207
+ describe('the scoped claim', () => {
1208
+ test('one shared scope owns exactly the paths under a skills/ or an odd/ folder', () => {
1209
+ const design = toolsActivityDesign();
1210
+ const scope = design.scopes.write;
1211
+ assert.equal(scope, design.scopes.edit, 'ONE shared scope object, so the two tools can never disagree');
1212
+ assert.equal(scope.description, 'paths under skills/ or odd/');
1213
+ assert.doesNotMatch(scope.description, /[\r\n]/u, 'the description is one line');
1214
+ const owned = [
1215
+ 'skills/one/SKILL.md',
1216
+ 'lib/skills/one/references/deep/x.md',
1217
+ 'odd/tasks/a.md',
1218
+ 'odd/work/a.md',
1219
+ 'a\\skills\\b\\c.md',
1220
+ 'ODD/tasks/a.md',
1221
+ ];
1222
+ for (const path of owned) assert.equal(scope.matches({ tool: 'write', args: { path } }), true, path);
1223
+ const foreign = [
1224
+ 'src/app.ts',
1225
+ 'lib/bash-design.js',
1226
+ 'lib/skillset/notes.md',
1227
+ 'docs/oddity.md',
1228
+ 'odd-work/a.md',
1229
+ 'notes/SKILL.md',
1230
+ 'skills',
1231
+ '',
1232
+ ];
1233
+ for (const path of foreign) assert.equal(scope.matches({ tool: 'write', args: { path } }), false, JSON.stringify(path));
1234
+ // A call with no arguments, or with arguments that are not an object, names no file at all.
1235
+ for (const call of [undefined, null, {}, { tool: 'write' }, { tool: 'write', args: null }, { tool: 'write', args: 'src' }, { tool: 'write', args: 42 }]) {
1236
+ assert.equal(scope.matches(call), false, JSON.stringify(call));
1237
+ }
1238
+ });
1239
+
1240
+ test('the line gains edit, and every other tool keeps its whole claim', () => {
1241
+ const design = toolsActivityDesign();
1242
+ assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write', 'edit']);
1243
+ for (const tool of ['bash', 'grep', 'find', 'ls', 'read']) {
1244
+ assert.equal(Object.hasOwn(design.scopes, tool), false, `${tool} is claimed for every call`);
1245
+ }
1246
+ for (const tool of ['write', 'edit']) assert.equal(Object.hasOwn(design.scopes, tool), true, tool);
1247
+ });
1248
+
1249
+ const registering = (version) => {
1250
+ const calls = [];
1251
+ return {
1252
+ calls,
1253
+ api: {
1254
+ VERSION: version,
1255
+ registerToolDesign: (design) => {
1256
+ calls.push(design);
1257
+ return () => {};
1258
+ },
1259
+ },
1260
+ };
1261
+ };
1262
+
1263
+ test('a bridge older than 0.9.0 registers today\'s unscoped line, without edit', () => {
1264
+ const cases = [['0.6.0', false], ['0.8.9', false], ['0.9.0', true], ['0.10.0', true], ['1.0.0', true]];
1265
+ for (const [version, scoped] of cases) {
1266
+ const { api, calls } = registering(version);
1267
+ registerBashDesign(api)();
1268
+ const design = calls.at(-1);
1269
+ assert.equal(Array.isArray(design.tools), true, `${version}: still the one line`);
1270
+ assert.equal(design.scopes !== undefined, scoped, version);
1271
+ assert.equal(design.tools.includes('edit'), scoped, version);
1272
+ if (scoped) {
1273
+ assert.equal(design.scopes.write, design.scopes.edit, version);
1274
+ continue;
1275
+ }
1276
+ assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write'], `${version}: today's tools`);
1277
+ assert.deepEqual(
1278
+ Object.keys(design).sort(),
1279
+ ['apply', 'description', 'id', 'label', 'line', 'name', 'preview', 'tools'],
1280
+ `${version}: today's registration byte for byte`,
1281
+ );
1282
+ }
1283
+ });
1284
+
1285
+ test('a prerelease or a build suffix of the cutoff never meets it: 0.9.0-rc.1 keeps the unscoped line', () => {
1286
+ // Semver puts a prerelease BELOW its own release, so `0.9.0-rc.1` carries no per-(`line`, `tool`)
1287
+ // 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.
1289
+ for (const version of ['0.9.0-rc.1', '0.9.0+build.7', '0.9.0-rc.1+sha.abc']) {
1290
+ const { api, calls } = registering(version);
1291
+ registerBashDesign(api)();
1292
+ assert.equal(calls.length, 1, `${version}: a readable release is never probed`);
1293
+ const design = calls.at(-1);
1294
+ assert.equal(design.line, 'tags', version);
1295
+ 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'], version);
1297
+ }
1298
+ });
1299
+
1300
+ test('a release that cannot be read keeps the unscoped line', () => {
1301
+ const { api, calls } = registering('nightly');
1302
+ registerBashDesign(api)();
1303
+ assert.equal(calls[0].id, 'odd-worktree.capability-probe', 'the grouped shape is still probed');
1304
+ const design = calls.at(-1);
1305
+ assert.equal(design.scopes, undefined, 'an unreadable release never takes a scoped registration');
1306
+ assert.deepEqual([...design.tools], ['bash', 'grep', 'find', 'ls', 'read', 'write']);
1307
+ });
1308
+ });
1309
+
1310
+ // S6: ONE rule for every cutoff this package reads — an advertised release meets a cutoff by semver
1311
+ // order, numbers first, and a prerelease or build suffix loses ONLY when the numbers are equal. Both
1312
+ // 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
1314
+ // `Card diff` row, and a newer one gets both the scope and the diff line.
1315
+ describe('the release rule is semver order, on both lines at once (S6)', () => {
1316
+ const registerBoth = (version) => {
1317
+ const seen = [];
1318
+ const api = { VERSION: version, registerToolDesign: (design) => { seen.push(design); return () => {}; } };
1319
+ const disposeTags = registerBashDesign(api);
1320
+ const disposeDiff = registerDiffDesign(api);
1321
+ const dispose = () => {
1322
+ if (typeof disposeTags === 'function') disposeTags();
1323
+ if (typeof disposeDiff === 'function') disposeDiff();
1324
+ };
1325
+ return { seen, dispose, tags: seen.find((design) => design.line === 'tags'), diff: seen.find((design) => design.line === 'diff') };
1326
+ };
1327
+
1328
+ test('a prerelease or a build suffix of 0.9.0 is BELOW it: unscoped `Card tags`, no `Card diff`', () => {
1329
+ for (const version of ['0.9.0-rc.1', '0.9.0-beta.1+build', '0.9.0+workstation']) {
1330
+ const registration = registerBoth(version);
1331
+ try {
1332
+ assert.deepEqual(registration.seen.map((design) => design.line), ['tags'], `${version}: the grouped line, and no diff line`);
1333
+ 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'], `${version}: six tools, no edit`);
1335
+ assert.equal(registration.diff, undefined, `${version}: nothing is offered for a row the bridge would refuse`);
1336
+ } finally {
1337
+ registration.dispose();
1338
+ }
1339
+ }
1340
+ });
1341
+
1342
+ test('a NEWER release carrying a suffix is ABOVE 0.9.0: the scoped `Card tags` line AND `Card diff`', () => {
1343
+ for (const version of ['0.9.1-rc.1', '0.10.0+local.2']) {
1344
+ const registration = registerBoth(version);
1345
+ try {
1346
+ assert.deepEqual(registration.seen.map((design) => design.line), ['tags', 'diff'], `${version}: both lines`);
1347
+ 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', 'edit'], `${version}: seven tools`);
1349
+ assert.equal(registration.diff.id, 'odd-worktree.diff', version);
1350
+ assert.equal(registration.diff.label, 'color', version);
1351
+ assert.deepEqual([...registration.diff.tools], ['write', 'edit'], version);
1352
+ } finally {
1353
+ registration.dispose();
1354
+ }
1355
+ }
1356
+ });
1357
+
1358
+ test('0.6.0-rc.1 is BELOW 0.6.0, so it falls back to the single `tool: "bash"` design', () => {
1359
+ // Deliberate and more conservative than the base commit, which accepted the grouped shape here:
1360
+ // semver puts `0.6.0-rc.1` below `0.6.0`, and this package reads one rule at every cutoff. That
1361
+ // is the `Card bash` row over bash alone — never a grouped registration a 0.6.0 bridge would
1362
+ // accept but its own release ordering says came first.
1363
+ const registration = registerBoth('0.6.0-rc.1');
1364
+ try {
1365
+ assert.equal(registration.seen.length, 1, 'a readable release is never probed');
1366
+ const [design] = registration.seen;
1367
+ assert.equal(design.tool, 'bash', 'the single-tool shape');
1368
+ assert.equal(Object.hasOwn(design, 'tools'), false, 'never both shapes');
1369
+ assert.equal(Object.hasOwn(design, 'line'), false, 'the older bridge names the row itself, `Card bash`');
1370
+ assert.equal(design.id, 'odd-worktree.bash-activity');
1371
+ assert.equal(design.label, 'activity');
1372
+ assert.equal(registration.diff, undefined, 'and the diff line is not offered either');
1373
+ } finally {
1374
+ registration.dispose();
1375
+ }
1376
+ });
1377
+
1378
+ test('the ordinary releases still read as they always did', () => {
1379
+ // 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']]) {
1381
+ const registration = registerBoth(version);
1382
+ try {
1383
+ assert.equal(registration.tags === undefined, shape === 'bash', version);
1384
+ assert.equal(registration.diff === undefined, version !== '0.9.0', version);
1385
+ } finally {
1386
+ registration.dispose();
1387
+ }
1388
+ }
1389
+ });
1390
+ });