@orkestrel/scaffold 0.0.134 → 0.0.136

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.
Files changed (53) hide show
  1. package/dist/agents/skills/orkestrel-parallel/scripts/lane.js +777 -83
  2. package/dist/agents/skills/orkestrel-publish/scripts/wave.js +327 -21
  3. package/dist/bin/main.js +254 -36
  4. package/dist/bin/main.js.map +1 -1
  5. package/dist/host/AGENTS.md +2 -2
  6. package/dist/host/agents/orchestration.md +2 -2
  7. package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +1 -1
  8. package/dist/host/agents/skills/orkestrel-parallel/scripts/lane.ts +983 -123
  9. package/dist/host/agents/skills/orkestrel-publish/references/release.md +1 -0
  10. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +22 -5
  11. package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +403 -32
  12. package/dist/host/claude/agents/orkestrel.md +17 -17
  13. package/dist/host/claude/agents/reviewer.md +1 -1
  14. package/dist/host/claude/rules/architecture.md +1 -1
  15. package/dist/host/claude/rules/documentation.md +1 -1
  16. package/dist/host/claude/rules/patterns.md +4 -2
  17. package/dist/host/claude/rules/workspace.md +73 -67
  18. package/dist/host/configs/helpers.ts +109 -73
  19. package/dist/host/dotfiles/oxlintrc.json +1 -57
  20. package/dist/host/guides/agent.md +989 -395
  21. package/dist/host/guides/contract.md +198 -163
  22. package/dist/host/guides/database.md +978 -503
  23. package/dist/host/guides/indexeddb.md +80 -66
  24. package/dist/host/guides/middleware.md +5 -5
  25. package/dist/host/guides/ollama.md +41 -42
  26. package/dist/host/guides/relation.md +56 -32
  27. package/dist/host/guides/scaffold.md +185 -107
  28. package/dist/host/guides/sqlite.md +44 -23
  29. package/dist/host/guides/study.md +12 -12
  30. package/dist/host/guides/test.md +163 -47
  31. package/dist/host/guides/toolbox.md +127 -81
  32. package/dist/host/guides/workspace.md +21 -14
  33. package/dist/host/manifest.json +30 -30
  34. package/dist/host/scripts/browsers.sh +0 -0
  35. package/dist/host/scripts/codex.sh +0 -0
  36. package/dist/host/scripts/cursor.sh +0 -0
  37. package/dist/host/scripts/deps.sh +0 -0
  38. package/dist/host/scripts/npm.sh +0 -0
  39. package/dist/host/scripts/ollama.sh +0 -0
  40. package/dist/host/tests/config.test.ts +237 -115
  41. package/dist/src/core/index.cjs +591 -218
  42. package/dist/src/core/index.cjs.map +1 -1
  43. package/dist/src/core/index.d.cts +248 -29
  44. package/dist/src/core/index.d.ts +248 -29
  45. package/dist/src/core/index.js +581 -216
  46. package/dist/src/core/index.js.map +1 -1
  47. package/dist/src/server/index.cjs +18 -8
  48. package/dist/src/server/index.cjs.map +1 -1
  49. package/dist/src/server/index.d.cts +4 -3
  50. package/dist/src/server/index.d.ts +4 -3
  51. package/dist/src/server/index.js +19 -9
  52. package/dist/src/server/index.js.map +1 -1
  53. package/package.json +3 -3
@@ -678,7 +678,8 @@ export function refuseLocalSpecs(runner, step) {
678
678
  *
679
679
  * @param runner - The visit's state.
680
680
  * @returns The first refusal, or undefined when the lock is tracked and clean, the manifest holds no
681
- * local spec or workspace, `tmp/` is ignored, and the target is its work tree's root.
681
+ * local spec or workspace, `tmp/units/wave` crosses no link inside the target, `tmp/` is ignored,
682
+ * and the target is its work tree's root.
682
683
  */
683
684
  export function readRegenerationRefusal(runner) {
684
685
  if (runStep(runner, 'regenerate', 'git', ['ls-files', '--error-unmatch', 'package-lock.json'], runner.target)?.status !== 0)
@@ -692,6 +693,13 @@ export function readRegenerationRefusal(runner) {
692
693
  return `local dependency specs: ${specs.map(([path, spec]) => `${path}: ${spec}`).join(', ')}`;
693
694
  if (manifest !== undefined && 'workspaces' in manifest)
694
695
  return 'the manifest declares workspaces';
696
+ // Git refuses a pathspec beyond a link with exit 128, which reads as an unignored `tmp/`.
697
+ try {
698
+ validateWavePath(runner.target, join(runner.target, 'tmp', 'units', 'wave'));
699
+ }
700
+ catch (error) {
701
+ return error instanceof Error ? error.message : String(error);
702
+ }
695
703
  if (runStep(runner, 'regenerate', 'git', ['check-ignore', '-q', 'tmp/units/wave/probe'], runner.target)?.status !== 0)
696
704
  return 'tmp/ is not git-ignored';
697
705
  const root = runStep(runner, 'regenerate', 'git', ['rev-parse', '--show-toplevel'], runner.target);
@@ -1108,6 +1116,234 @@ export function runFormat(runner) {
1108
1116
  version,
1109
1117
  };
1110
1118
  }
1119
+ /**
1120
+ * Parses a whole text as one JSON object or a list of JSON objects.
1121
+ *
1122
+ * @param text - A JSON document, such as `npm view NAME@RANGE FIELD --json` output, which prints one
1123
+ * record for one match and a list for several.
1124
+ * @returns Each object the document carries, or none when the text is not JSON.
1125
+ */
1126
+ export function parseJsonRecords(text) {
1127
+ try {
1128
+ const parsed = JSON.parse(text);
1129
+ return (Array.isArray(parsed) ? parsed : [parsed])
1130
+ .filter(isRecord)
1131
+ .map((entry) => Object.fromEntries(Object.entries(entry)));
1132
+ }
1133
+ catch {
1134
+ return [];
1135
+ }
1136
+ }
1137
+ /**
1138
+ * Parses the major, minor, and patch numbers of a plain `major.minor.patch` version.
1139
+ *
1140
+ * @param text - The version text.
1141
+ * @returns The three numbers, or undefined when the text carries a prefix, a prerelease, or any
1142
+ * other form.
1143
+ * @example
1144
+ * ```ts
1145
+ * parseVersion('8.3.8') // [8, 3, 8]
1146
+ * parseVersion('8.3.8-beta.1') // undefined
1147
+ * ```
1148
+ */
1149
+ export function parseVersion(text) {
1150
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u.exec(text);
1151
+ if (match === null)
1152
+ return undefined;
1153
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
1154
+ }
1155
+ /**
1156
+ * Compares two plain versions by their major, minor, and patch numbers.
1157
+ *
1158
+ * @param left - The version ordered first when it compares lower.
1159
+ * @param right - The version it is compared with.
1160
+ * @returns A negative number when `left` is lower, zero when equal, and a positive number when higher.
1161
+ * @example
1162
+ * ```ts
1163
+ * compareVersions([0, 0, 23], [0, 0, 24]) // -1
1164
+ * ```
1165
+ */
1166
+ export function compareVersions(left, right) {
1167
+ return left[0] - right[0] || left[1] - right[1] || left[2] - right[2];
1168
+ }
1169
+ /**
1170
+ * Parses a declared range as the half-open version intervals its `||` arms admit.
1171
+ *
1172
+ * @remarks
1173
+ * An arm is an exact `major.minor.patch` version, a caret, or a tilde over one. A caret admits up to
1174
+ * the next major, the next minor under major 0, and the next patch under `0.0`; a tilde admits up to
1175
+ * the next minor. Any other form, an empty arm included, makes the whole range unreadable.
1176
+ *
1177
+ * @param range - The declared range.
1178
+ * @returns One interval per arm, with an inclusive `floor` and an exclusive `ceiling`, or undefined
1179
+ * when an arm is outside those forms.
1180
+ * @example
1181
+ * ```ts
1182
+ * parseRange('^0.0.23') // [{ floor: [0, 0, 23], ceiling: [0, 0, 24] }]
1183
+ * parseRange('>=8') // undefined
1184
+ * ```
1185
+ */
1186
+ export function parseRange(range) {
1187
+ const arms = range.trim().split(/\s*\|\|\s*/u);
1188
+ const parsed = arms.flatMap((arm) => {
1189
+ const match = /^([\^~]?)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u.exec(arm);
1190
+ if (match === null)
1191
+ return [];
1192
+ const major = Number(match[2]);
1193
+ const minor = Number(match[3]);
1194
+ const patch = Number(match[4]);
1195
+ const ceiling = match[1] === '~'
1196
+ ? [major, minor + 1, 0]
1197
+ : match[1] === ''
1198
+ ? [major, minor, patch + 1]
1199
+ : major > 0
1200
+ ? [major + 1, 0, 0]
1201
+ : minor > 0
1202
+ ? [0, minor + 1, 0]
1203
+ : [0, 0, patch + 1];
1204
+ return [{ floor: [major, minor, patch], ceiling }];
1205
+ });
1206
+ return parsed.length === arms.length ? parsed : undefined;
1207
+ }
1208
+ /**
1209
+ * Computes whether a declared range admits a plain version.
1210
+ *
1211
+ * @param range - The declared range, in a form {@link parseRange} reads.
1212
+ * @param version - The plain version.
1213
+ * @returns True if an arm admits the version, false if none does, and undefined when the range or
1214
+ * the version is unreadable.
1215
+ * @example
1216
+ * ```ts
1217
+ * computeSatisfaction('^8.3.7', '8.3.8') // true
1218
+ * computeSatisfaction('^0.0.23', '0.0.24') // false
1219
+ * computeSatisfaction('*', '1.0.0') // undefined
1220
+ * ```
1221
+ */
1222
+ export function computeSatisfaction(range, version) {
1223
+ const arms = parseRange(range);
1224
+ const parsed = parseVersion(version);
1225
+ if (arms === undefined || parsed === undefined)
1226
+ return undefined;
1227
+ return arms.some((arm) => compareVersions(arm.floor, parsed) <= 0 && compareVersions(parsed, arm.ceiling) < 0);
1228
+ }
1229
+ /**
1230
+ * Raises one declared peer range whose floor fails the served release, and words the decision.
1231
+ *
1232
+ * @remarks
1233
+ * A range the served version satisfies stays as declared. A failing range moves per
1234
+ * {@link moveRange}: the one arm in the release's major becomes the caret of the release. A range
1235
+ * that is unreadable, carries no arm or several arms in that major, or whose arm in that major opens
1236
+ * above the release stays as declared, and the message names why. A reading that names the peer and
1237
+ * carries no release keeps it as `no eligible release`; no reading keeps it as `no release reading`.
1238
+ *
1239
+ * @param name - The peer's package name.
1240
+ * @param range - The declared peer range.
1241
+ * @param reading - The release reading that names the peer, or undefined when none does.
1242
+ * @returns The range after the decision and the rewrite row message: `peer NAME OLD -> NEW` when it
1243
+ * rose, `peer NAME OLD kept, REASON` otherwise.
1244
+ * @example
1245
+ * ```ts
1246
+ * raisePeer('@orkestrel/database', '^0.0.23', { name: '@orkestrel/database', range: '*', latest: '0.0.24' })
1247
+ * // { range: '^0.0.24', message: 'peer @orkestrel/database ^0.0.23 -> ^0.0.24', raised: true }
1248
+ * ```
1249
+ */
1250
+ export function raisePeer(name, range, reading) {
1251
+ const arms = parseRange(range);
1252
+ const latest = reading?.latest;
1253
+ const version = latest === undefined ? undefined : parseVersion(latest);
1254
+ const matched = version === undefined ? [] : (arms ?? []).filter((entry) => entry.floor[0] === version[0]);
1255
+ const reason = arms === undefined
1256
+ ? 'unreadable range'
1257
+ : reading === undefined
1258
+ ? 'no release reading'
1259
+ : latest === undefined
1260
+ ? 'no eligible release'
1261
+ : version === undefined
1262
+ ? `unreadable release ${latest}`
1263
+ : computeSatisfaction(range, latest) === true
1264
+ ? `admits ${latest}`
1265
+ : matched.length === 0
1266
+ ? `no arm in the major of ${latest}`
1267
+ : matched.length > 1
1268
+ ? `several arms in the major of ${latest}`
1269
+ : matched.some((arm) => compareVersions(arm.floor, version) > 0)
1270
+ ? `its floor is above ${latest}`
1271
+ : undefined;
1272
+ if (reason !== undefined || latest === undefined)
1273
+ return { range, message: `peer ${name} ${range} kept, ${String(reason)}`, raised: false };
1274
+ const next = String(moveRange(range, latest));
1275
+ return { range: next, message: `peer ${name} ${range} -> ${next}`, raised: true };
1276
+ }
1277
+ /**
1278
+ * Collects the registry lookup each peer-only dependency needs for its release reading.
1279
+ *
1280
+ * @remarks
1281
+ * A peer a release reading already names, such as one also declared under `devDependencies`, takes
1282
+ * that reading. A peer whose range {@link parseRange} cannot read needs no reading. A fleet package
1283
+ * is looked up with `*`, and a foreign tool with a caret over its declared major, or with the
1284
+ * declared range when its arms span several majors, as the audit bounds a dependency. A range bound
1285
+ * by itself admits every release its lookup serves, so such a peer never rises.
1286
+ *
1287
+ * @param manifest - The manifest record.
1288
+ * @param releases - The audit's release readings.
1289
+ * @returns One lookup per peer-only dependency, in declaration order.
1290
+ * @example
1291
+ * ```ts
1292
+ * collectPeerLookups({ peerDependencies: { vite: '^8.3.7' } }, [])
1293
+ * // [{ name: 'vite', bound: '^8' }]
1294
+ * ```
1295
+ */
1296
+ export function collectPeerLookups(manifest, releases) {
1297
+ const named = new Set(releases.map((release) => release.name));
1298
+ const block = manifest.peerDependencies;
1299
+ if (typeof block !== 'object' || block === null)
1300
+ return [];
1301
+ return Object.entries(block).flatMap(([name, range]) => {
1302
+ if (typeof range !== 'string' || named.has(name))
1303
+ return [];
1304
+ const majors = [...new Set(parseRange(range)?.map((arm) => arm.floor[0]))];
1305
+ if (majors.length === 0)
1306
+ return [];
1307
+ const bound = name.startsWith('@orkestrel/')
1308
+ ? '*'
1309
+ : majors.length === 1
1310
+ ? `^${String(majors[0])}`
1311
+ : range;
1312
+ return [{ name, bound }];
1313
+ });
1314
+ }
1315
+ /**
1316
+ * Reads the release a registry lookup serves out of the output of
1317
+ * `npm view NAME@BOUND version deprecated dist-tags.latest --json`.
1318
+ *
1319
+ * @remarks
1320
+ * The reading skips a deprecated version, a version outside the plain `major.minor.patch` form, and
1321
+ * a version above `latest` when the bound is `*` or the caret of `latest`'s major, then takes the
1322
+ * highest, as the audit's lookup does.
1323
+ *
1324
+ * @param text - The command's standard output.
1325
+ * @param bound - The lookup bound.
1326
+ * @returns The served version, or undefined when no version is eligible or the output is unreadable.
1327
+ * @example
1328
+ * ```ts
1329
+ * readServedVersion('{"version":"0.0.24","dist-tags.latest":"0.0.24"}', '*') // '0.0.24'
1330
+ * ```
1331
+ */
1332
+ export function readServedVersion(text, bound) {
1333
+ const eligible = parseJsonRecords(text).flatMap((entry) => {
1334
+ const version = readString(entry, 'version') ?? '';
1335
+ const plain = parseVersion(version);
1336
+ const deprecated = readString(entry, 'deprecated') ?? '';
1337
+ const latest = parseVersion(readString(entry, 'dist-tags.latest') ?? '');
1338
+ if (plain === undefined || deprecated.length > 0)
1339
+ return [];
1340
+ const capped = latest !== undefined && (bound === '*' || bound === `^${String(latest[0])}`)
1341
+ ? compareVersions(plain, latest) <= 0
1342
+ : true;
1343
+ return capped ? [{ version, plain }] : [];
1344
+ });
1345
+ return eligible.toSorted((left, right) => compareVersions(right.plain, left.plain))[0]?.version;
1346
+ }
1111
1347
  /**
1112
1348
  * Moves one declared range to the registry caret of a release, keeping every other major a
1113
1349
  * disjunctive range admits.
@@ -1164,24 +1400,28 @@ export function computeRanges(ranges, releases) {
1164
1400
  }, { ranges, moved: [] });
1165
1401
  }
1166
1402
  /**
1167
- * Writes the re-pinned ranges into the target's manifest, keeping every peer range at its floor.
1403
+ * Writes the re-pinned ranges into the target's manifest, raising each peer range whose floor fails
1404
+ * its release.
1168
1405
  *
1169
1406
  * @remarks
1170
- * A `peerDependencies` range moves only when its floor fails the release, and no reading the visit
1171
- * takes names a floor the release needs, so every peer the registry moved past stays as declared and
1172
- * is reported as kept.
1407
+ * A `dependencies` or `devDependencies` range moves per {@link computeRanges} over the audit's
1408
+ * readings alone. A `peerDependencies` range takes the last audit reading that names it with a
1409
+ * release, else its peer-only reading, and moves per {@link raisePeer}: it rises to the caret of the
1410
+ * served version only when the declared range excludes that version, and otherwise stays as
1411
+ * declared. Every raised peer joins the moved list and every other peer is reported as kept.
1173
1412
  *
1174
1413
  * @param target - The target directory.
1175
1414
  * @param releases - The audit's release readings.
1415
+ * @param peers - The peer-only readings, which move `peerDependencies` ranges alone. Default: none.
1176
1416
  * @returns One message per range moved and one per peer range kept; the manifest is rewritten only
1177
1417
  * when a range moved.
1178
1418
  * @example
1179
1419
  * ```ts
1180
1420
  * writeRanges('.', [{ name: 'vite', range: '^8', latest: '8.3.8' }])
1181
- * // { moved: ['vite ^8.3.7 -> ^8.3.8'], kept: ['peer vite ^8.3.7 left alone, not ^8.3.8'] }
1421
+ * // { moved: ['vite ^8.3.7 -> ^8.3.8'], kept: ['peer vite ^8.3.7 kept, admits 8.3.8'] }
1182
1422
  * ```
1183
1423
  */
1184
- export function writeRanges(target, releases) {
1424
+ export function writeRanges(target, releases, peers = []) {
1185
1425
  const manifest = readManifest(target);
1186
1426
  if (manifest === undefined)
1187
1427
  return { moved: [], kept: [] };
@@ -1190,26 +1430,66 @@ export function writeRanges(target, releases) {
1190
1430
  if (typeof block !== 'object' || block === null)
1191
1431
  return [];
1192
1432
  const ranges = Object.fromEntries(Object.entries(block));
1193
- return [{ field, ranges, moves: computeRanges(ranges, releases) }];
1433
+ if (field !== 'peerDependencies')
1434
+ return [{ field, moves: computeRanges(ranges, releases), kept: [] }];
1435
+ const decisions = Object.entries(ranges).flatMap(([name, range]) => typeof range === 'string'
1436
+ ? [
1437
+ [
1438
+ name,
1439
+ raisePeer(name, range, releases.findLast((release) => release.name === name && release.latest !== undefined) ?? peers.findLast((release) => release.name === name)),
1440
+ ],
1441
+ ]
1442
+ : []);
1443
+ return [
1444
+ {
1445
+ field,
1446
+ moves: {
1447
+ ranges: {
1448
+ ...ranges,
1449
+ ...Object.fromEntries(decisions.map(([name, peer]) => [name, peer.range])),
1450
+ },
1451
+ moved: decisions.flatMap(([, peer]) => (peer.raised ? [peer.message] : [])),
1452
+ },
1453
+ kept: decisions.flatMap(([, peer]) => (peer.raised ? [] : [peer.message])),
1454
+ },
1455
+ ];
1194
1456
  });
1195
- const peers = fields.filter((entry) => entry.field === 'peerDependencies');
1196
- const kept = peers.flatMap((entry) => Object.entries(entry.ranges)
1197
- .filter(([name, range]) => entry.moves.ranges[name] !== range)
1198
- .map(([name, range]) => `peer ${name} ${String(range)} left alone, not ${String(entry.moves.ranges[name])}`));
1199
- const pinned = fields.filter((entry) => entry.field !== 'peerDependencies');
1200
- const moved = pinned.flatMap((entry) => entry.moves.moved);
1457
+ const moved = fields.flatMap((entry) => entry.moves.moved);
1201
1458
  if (moved.length > 0) {
1202
1459
  const written = {
1203
1460
  ...manifest,
1204
- ...Object.fromEntries(pinned.map((entry) => [entry.field, entry.moves.ranges])),
1461
+ ...Object.fromEntries(fields.map((entry) => [entry.field, entry.moves.ranges])),
1205
1462
  };
1206
1463
  writeFileSync(join(target, 'package.json'), `${JSON.stringify(written, null, '\t')}\n`);
1207
1464
  }
1208
- return { moved, kept };
1465
+ return { moved, kept: fields.flatMap((entry) => entry.kept) };
1466
+ }
1467
+ /**
1468
+ * Judges one peer-only release lookup.
1469
+ *
1470
+ * @param result - The `npm view NAME@BOUND version deprecated dist-tags.latest --json` command.
1471
+ * @param bound - The lookup bound.
1472
+ * @returns Exit 0 naming the served version, or naming that no release within the bound is
1473
+ * eligible, when the lookup exited 0; else the lookup's failing exit and its reason.
1474
+ */
1475
+ export function judgeLookup(result, bound) {
1476
+ if (result.status !== 0)
1477
+ return readVerdict(result);
1478
+ const served = readServedVersion(result.stdout, bound);
1479
+ return {
1480
+ exit: 0,
1481
+ note: served === undefined ? `no eligible release within ${bound}` : `serves ${served}`,
1482
+ };
1209
1483
  }
1210
1484
  /**
1211
1485
  * Runs the pin step.
1212
1486
  *
1487
+ * @remarks
1488
+ * A peer-only dependency produces no audit release reading, so the step looks each one up with
1489
+ * `npm view`, per {@link collectPeerLookups}, before the rewrite, and stops before the rewrite and
1490
+ * the install when a lookup exits non-zero. A lookup that exits 0 with no eligible release keeps
1491
+ * its peer. Offline, it looks up none and the rewrite keeps those peers as declared.
1492
+ *
1213
1493
  * @param runner - The visit's state.
1214
1494
  * @param scaffoldFile - The scaffold executable.
1215
1495
  * @param scaffoldPrefix - The arguments that precede scaffold's own.
@@ -1222,7 +1502,26 @@ export function runPin(runner, scaffoldFile, scaffoldPrefix, offline) {
1222
1502
  const releases = readReleases(audit.stdout);
1223
1503
  if (releases === undefined || (audit.status !== 0 && audit.status !== 1))
1224
1504
  return;
1225
- const { moved, kept } = writeRanges(runner.target, releases);
1505
+ const lookups = collectPeerLookups(readManifest(runner.target) ?? {}, releases);
1506
+ if (runner.offline && lookups.length > 0)
1507
+ appendStep(runner, 'pin', 'npm view', `offline: no peer-only lookup for ${lookups.map((lookup) => lookup.name).join(', ')}`);
1508
+ const readings = (runner.offline ? [] : lookups).map((lookup) => {
1509
+ const view = runNpmStep(runner, 'pin', [
1510
+ 'view',
1511
+ `${lookup.name}@${lookup.bound}`,
1512
+ 'version',
1513
+ 'deprecated',
1514
+ 'dist-tags.latest',
1515
+ '--json',
1516
+ ], (result) => judgeLookup(result, lookup.bound));
1517
+ if (view?.status !== 0)
1518
+ return undefined;
1519
+ const latest = readServedVersion(view.stdout, lookup.bound);
1520
+ return { name: lookup.name, range: lookup.bound, latest };
1521
+ });
1522
+ if (readings.includes(undefined))
1523
+ return;
1524
+ const { moved, kept } = writeRanges(runner.target, releases, readings.filter((reading) => reading !== undefined));
1226
1525
  appendStep(runner, 'pin', 'rewrite audit release ranges to the registry caret', [moved.length === 0 ? 'no range moved' : moved.join(', '), ...kept].join('; '));
1227
1526
  }
1228
1527
  else {
@@ -1548,7 +1847,8 @@ export function runVisit(values) {
1548
1847
  *
1549
1848
  * @param target - The target directory.
1550
1849
  * @returns A new stamped directory under the target's `tmp/units/wave/` when the target is inside a
1551
- * work tree that ignores `tmp/`, else undefined.
1850
+ * work tree that ignores `tmp/`, or when that path crosses a link, which the caller's link check
1851
+ * refuses; else undefined.
1552
1852
  */
1553
1853
  export function readJournalDirectory(target) {
1554
1854
  const inside = spawnSync('git', ['rev-parse', '--is-inside-work-tree'], {
@@ -1558,14 +1858,20 @@ export function readJournalDirectory(target) {
1558
1858
  });
1559
1859
  if (inside.status !== 0 || inside.stdout.trim() !== 'true')
1560
1860
  return undefined;
1861
+ const directory = join(target, 'tmp', 'units', 'wave', new Date().toISOString().replace(/[:.]/gu, '-'));
1862
+ // Git refuses a pathspec beyond a link with exit 128, which reads as an unignored `tmp/`.
1863
+ try {
1864
+ validateWavePath(target, join(target, 'tmp', 'units', 'wave'));
1865
+ }
1866
+ catch {
1867
+ return directory;
1868
+ }
1561
1869
  const ignored = spawnSync('git', ['check-ignore', '-q', 'tmp/units/wave/probe'], {
1562
1870
  cwd: target,
1563
1871
  encoding: 'utf8',
1564
1872
  windowsHide: true,
1565
1873
  });
1566
- return ignored.status === 0
1567
- ? join(target, 'tmp', 'units', 'wave', new Date().toISOString().replace(/[:.]/gu, '-'))
1568
- : undefined;
1874
+ return ignored.status === 0 ? directory : undefined;
1569
1875
  }
1570
1876
  /**
1571
1877
  * Reads the packages by layer out of the catalog table.