@sabaiway/agent-workflow-kit 20.2.0 → 22.0.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +7 -5
  3. package/SKILL.md +1 -1
  4. package/bin/install.mjs +10 -11
  5. package/capability.json +1 -1
  6. package/launchers/windsurf-workflow.md +3 -1
  7. package/migrations/3.0.0-hardened-core-loop.md +7 -6
  8. package/package.json +5 -2
  9. package/references/advisor-writers.md +1 -1
  10. package/references/contracts.md +11 -10
  11. package/references/modes/bootstrap.md +3 -3
  12. package/references/modes/commit-guard.md +1 -1
  13. package/references/modes/gates.md +2 -2
  14. package/references/modes/recommendations.md +3 -3
  15. package/references/modes/upgrade.md +6 -6
  16. package/references/scripts/{archive-caps.mjs → archives/archive-caps.mjs} +1 -1
  17. package/references/scripts/{archive-changelog.mjs → archives/archive-changelog.mjs} +7 -9
  18. package/references/scripts/{archive-decisions.mjs → archives/archive-decisions.mjs} +13 -10
  19. package/references/scripts/{archive-issues.mjs → archives/archive-issues.mjs} +7 -8
  20. package/references/scripts/{check-docs-size.mjs → docs-size/check-docs-size.mjs} +3 -4
  21. package/references/scripts/docs-size/index.mjs +2 -0
  22. package/references/scripts/family.json +45 -0
  23. package/references/scripts/family.mjs +90 -0
  24. package/references/scripts/gates/kit-command-gates.mjs +117 -0
  25. package/references/scripts/{migrate-gates.mjs → gates/migrate-gates.mjs} +263 -182
  26. package/references/scripts/{install-git-hooks.mjs → git-hooks/install-git-hooks.mjs} +50 -38
  27. package/references/scripts/run.mjs +90 -0
  28. package/references/scripts/shared/index.mjs +3 -0
  29. package/references/scripts/shared/project-root.mjs +11 -0
  30. package/references/scripts/spec-schema/index.mjs +2 -0
  31. package/references/scripts/test-reporter/reporter.mjs +130 -0
  32. package/references/shared/composition-handoff.md +1 -1
  33. package/references/shared/deploy-tail.md +2 -2
  34. package/references/templates/SPEC_TEMPLATE.md +1 -1
  35. package/references/templates/adr-record.md +3 -3
  36. package/tools/apply-danger-check.mjs +9 -5
  37. package/tools/atomic-write.mjs +3 -1
  38. package/tools/coverage-producer.mjs +76 -41
  39. package/tools/direct-run.mjs +2 -0
  40. package/tools/distribution-files/retired.mjs +99 -0
  41. package/tools/distribution-files/scripts.mjs +68 -52
  42. package/tools/ensure-configs.mjs +21 -21
  43. package/tools/ensure-ops.mjs +60 -18
  44. package/tools/ensure-specs.mjs +85 -47
  45. package/tools/ensure-vocabulary.mjs +4 -4
  46. package/tools/epic-shape-cli.mjs +1 -1
  47. package/tools/epic-shape-ledger.mjs +1 -1
  48. package/tools/epic-shape.mjs +1 -1
  49. package/tools/family-registry.mjs +3 -1
  50. package/tools/feedback-record-cli.mjs +1 -1
  51. package/tools/fold-scope.mjs +2 -2
  52. package/tools/gates-declaration.mjs +22 -14
  53. package/tools/gates-init.mjs +33 -17
  54. package/tools/git-hooks.mjs +90 -65
  55. package/tools/jev-connect.mjs +1 -1
  56. package/tools/jev-guide.mjs +1 -1
  57. package/tools/jev-skill.mjs +1 -1
  58. package/tools/known-footprint.mjs +7 -29
  59. package/tools/node-evidence.mjs +29 -15
  60. package/tools/now-cli.mjs +1 -1
  61. package/tools/payload-prune.mjs +53 -58
  62. package/tools/plan-shape-cli.mjs +1 -1
  63. package/tools/plan-shape.mjs +1 -1
  64. package/tools/project-rules/rules-record.mjs +1 -1
  65. package/tools/queue-audit-cli.mjs +1 -1
  66. package/tools/queue-audit.mjs +2 -2
  67. package/tools/queue-purge-archive.mjs +1 -1
  68. package/tools/queue-purge-cli.mjs +1 -1
  69. package/tools/queue-purge.mjs +1 -1
  70. package/tools/recommendations.mjs +37 -25
  71. package/tools/script-priors.mjs +31 -3
  72. package/tools/source-size/piles.mjs +1 -1
  73. package/tools/spec-adoption.mjs +1 -1
  74. package/tools/spec-check-ops.mjs +2 -2
  75. package/tools/spec-check.mjs +2 -2
  76. package/tools/spec-coverage.mjs +1 -1
  77. package/tools/tier-guide.mjs +1 -1
  78. package/tools/transition/index.mjs +1 -1
  79. package/tools/upgrade-runlist.mjs +3 -3
  80. package/tools/write-lanes.mjs +2 -2
  81. package/references/scripts/_expect-shim.mjs +0 -41
  82. package/references/scripts/archive-caps.test.mjs +0 -321
  83. package/references/scripts/archive-changelog.test.mjs +0 -560
  84. package/references/scripts/archive-conservation.test.mjs +0 -466
  85. package/references/scripts/archive-decisions.test.mjs +0 -1503
  86. package/references/scripts/archive-issues.test.mjs +0 -825
  87. package/references/scripts/archiver-structure.test.mjs +0 -84
  88. package/references/scripts/check-docs-size-cli.test.mjs +0 -325
  89. package/references/scripts/check-docs-size-ensure.test.mjs +0 -360
  90. package/references/scripts/check-docs-size.test.mjs +0 -395
  91. package/references/scripts/install-git-hooks-repo-exec.test.mjs +0 -185
  92. package/references/scripts/install-git-hooks.test.mjs +0 -241
  93. package/references/scripts/markdown-blocks.test.mjs +0 -310
  94. package/references/scripts/migrate-gates-branches.test.mjs +0 -302
  95. package/references/scripts/migrate-gates.test.mjs +0 -517
  96. package/references/scripts/spec-schema.test.mjs +0 -352
  97. /package/references/scripts/{markdown-blocks.mjs → shared/markdown-blocks.mjs} +0 -0
  98. /package/references/scripts/{spec-schema.mjs → spec-schema/spec-schema.mjs} +0 -0
@@ -1,13 +1,16 @@
1
+ // The payload prune both installers take. This file is the canon: the second package ships a
2
+ // byte-identical copy that scripts/sync-mirrors.mjs writes, so an edit lands here and the sync carries
3
+ // it. What differs between the installers arrives as parameters — the owner record
4
+ // { name, prefix, noun, rerun } and the guards { assertContainedRealPath, lstatNoFollow }.
1
5
  import { lstatSync, readdirSync, readFileSync, rmdirSync, unlinkSync } from 'node:fs';
2
6
  import { resolve, sep } from 'node:path';
3
- import { assertContainedRealPath } from './fs-safe.mjs';
4
- import { lstatNoFollowRead } from './fs-read-nofollow.mjs';
5
7
 
6
- const PREFIX = '[agent-workflow-kit]';
7
- const NON_CONVERGENCE = `${PREFIX} the kit home did not converge to the package (see the lines above) `
8
- + '— fix them, then re-run npx @sabaiway/agent-workflow-kit@latest init';
8
+ // The re-run command of the non-convergence line: the bare command over the installer's default home,
9
+ // else the command with the home as a POSIX single-quoted --dir.
10
+ export const rerunCommand = (command, home, fromDefault) =>
11
+ (fromDefault ? command : `${command} --dir '${home.replaceAll("'", "'\\''")}'`);
9
12
 
10
- export const readHomeOwner = (home) => {
13
+ export const readHomeOwner = (home, owner) => {
11
14
  try {
12
15
  const stat = lstatSync(home, { throwIfNoEntry: false });
13
16
  if (stat === undefined) {
@@ -31,21 +34,21 @@ export const readHomeOwner = (home) => {
31
34
  if (end < 0) {
32
35
  return 'other';
33
36
  }
34
- return lines.slice(1, end).some((line) => line.trimEnd() === 'name: agent-workflow-kit') ? 'kit' : 'other';
37
+ return lines.slice(1, end).some((line) => line.trimEnd() === `name: ${owner.name}`) ? 'owned' : 'other';
35
38
  } catch {
36
39
  return 'other';
37
40
  }
38
41
  };
39
42
 
40
- export const assertInstallableHome = (home) => {
41
- const owner = readHomeOwner(home);
42
- if (owner === 'other') {
43
+ export const assertInstallableHome = (home, owner) => {
44
+ const answer = readHomeOwner(home, owner);
45
+ if (answer === 'other') {
43
46
  throw new Error(
44
- `${PREFIX} refusing to install into ${home}: it is not empty and holds no agent-workflow-kit SKILL.md; `
45
- + 'choose a new or empty folder, or an existing kit home',
47
+ `${owner.prefix} refusing to install into ${home}: it is not empty and holds no ${owner.name} SKILL.md; `
48
+ + `choose a new or empty folder, or an existing ${owner.noun}`,
46
49
  );
47
50
  }
48
- return owner;
51
+ return answer;
49
52
  };
50
53
 
51
54
  const describeKind = (stat) => {
@@ -58,21 +61,19 @@ const describeKind = (stat) => {
58
61
  return stat.isFile() ? 'file' : 'non-regular object';
59
62
  };
60
63
 
61
- const reportFailure = (path, error) => ({
62
- ok: false,
63
- line: `${PREFIX} failed ${path}: ${error.message}`,
64
- });
64
+ const reportFailure = (say, path, error) => ({ ok: false, line: say(`failed ${path}: ${error.message}`) });
65
65
 
66
- const finishReport = (reports) => {
66
+ const finishReport = (owner, reports) => {
67
67
  const ok = reports.every((report) => report.ok);
68
68
  return {
69
69
  ok,
70
70
  lines: reports.map((report) => report.line),
71
- nonConvergence: ok ? null : NON_CONVERGENCE,
71
+ nonConvergence: ok ? null : `${owner.prefix} the ${owner.noun} did not converge to the package `
72
+ + `(see the lines above) — fix them, then re-run ${owner.rerun}`,
72
73
  };
73
74
  };
74
75
 
75
- const readTree = (root, entry, reports, directoryOnly = false) => {
76
+ const readTree = (say, root, entry, reports, directoryOnly = false) => {
76
77
  const entries = new Map();
77
78
  const visitEntry = (path, first = false) => {
78
79
  try {
@@ -89,7 +90,7 @@ const readTree = (root, entry, reports, directoryOnly = false) => {
89
90
  }
90
91
  }
91
92
  } catch (error) {
92
- reports.push(reportFailure(path, error));
93
+ reports.push(reportFailure(say, path, error));
93
94
  }
94
95
  };
95
96
  try {
@@ -102,39 +103,39 @@ const readTree = (root, entry, reports, directoryOnly = false) => {
102
103
  }
103
104
  visitEntry(entry, true);
104
105
  } catch (error) {
105
- reports.push(reportFailure(entry, error));
106
+ reports.push(reportFailure(say, entry, error));
106
107
  }
107
108
  return entries;
108
109
  };
109
110
 
110
- const planSubtree = (carried, installed, orphans, directories, reports) => {
111
+ const planSubtree = (say, carried, installed, plan) => {
111
112
  for (const [path, kind] of installed) {
112
113
  if (carried.has(path)) {
113
114
  const packageKind = carried.get(path);
114
115
  if (kind !== packageKind) {
115
- reports.push({
116
+ plan.reports.push({
116
117
  ok: false,
117
- line: `${PREFIX} kind-mismatch ${path}: the home holds a ${kind}, the package a ${packageKind}`,
118
+ line: say(`kind-mismatch ${path}: the home holds a ${kind}, the package a ${packageKind}`),
118
119
  });
119
120
  }
120
121
  } else if (kind === 'file') {
121
- orphans.push(path);
122
+ plan.orphans.push(path);
122
123
  } else if (kind === 'directory') {
123
- directories.push(path);
124
+ plan.directories.push(path);
124
125
  } else {
125
- reports.push({
126
+ plan.reports.push({
126
127
  ok: true,
127
- line: `${PREFIX} kept ${path} (a ${kind} the package does not carry — yours to remove by hand)`,
128
+ line: say(`kept ${path} (a ${kind} the package does not carry — yours to remove by hand)`),
128
129
  });
129
130
  }
130
131
  }
131
132
  };
132
133
 
133
- const removeOrphan = (home, path, remove) => {
134
+ const removeOrphan = (say, home, path, remove) => {
134
135
  const absolute = resolve(home, path);
135
136
  try {
136
137
  remove.assertContainedRealPath(home, absolute);
137
- const stat = remove.lstatNoFollowRead(absolute);
138
+ const stat = remove.lstatNoFollow(absolute);
138
139
  if (stat === null) {
139
140
  return [];
140
141
  }
@@ -142,17 +143,17 @@ const removeOrphan = (home, path, remove) => {
142
143
  throw new Error('the leaf is no longer a regular file');
143
144
  }
144
145
  remove.unlinkSync(absolute);
145
- return [{ ok: true, line: `${PREFIX} removed ${path} (not in the package)` }];
146
+ return [{ ok: true, line: say(`removed ${path} (not in the package)`) }];
146
147
  } catch (error) {
147
- return [reportFailure(path, error)];
148
+ return [reportFailure(say, path, error)];
148
149
  }
149
150
  };
150
151
 
151
- const removeEmptyDirectory = (home, path, remove) => {
152
+ const removeEmptyDirectory = (say, home, path, remove) => {
152
153
  const absolute = resolve(home, path);
153
154
  try {
154
155
  remove.assertContainedRealPath(home, absolute);
155
- const stat = remove.lstatNoFollowRead(absolute);
156
+ const stat = remove.lstatNoFollow(absolute);
156
157
  if (stat === null) {
157
158
  return { state: 'absent' };
158
159
  }
@@ -163,13 +164,13 @@ const removeEmptyDirectory = (home, path, remove) => {
163
164
  return { state: 'removed' };
164
165
  } catch (error) {
165
166
  const settled = { ENOTEMPTY: 'kept', EEXIST: 'kept', ENOENT: 'absent' }[error.code];
166
- return settled ? { state: settled } : { state: 'failed', report: reportFailure(path, error) };
167
+ return settled ? { state: settled } : { state: 'failed', report: reportFailure(say, path, error) };
167
168
  }
168
169
  };
169
170
 
170
171
  // The walk lists a directory before its children: reversed, a child is removed before its parent.
171
- const removeEmptyDirectories = (home, directories, remove) => {
172
- const outcomes = new Map([...directories].reverse().map((path) => [path, removeEmptyDirectory(home, path, remove)]));
172
+ const removeEmptyDirectories = (say, home, directories, remove) => {
173
+ const outcomes = new Map([...directories].reverse().map((path) => [path, removeEmptyDirectory(say, home, path, remove)]));
173
174
  const isTop = (path) => !directories.some((other) => path.startsWith(`${other}/`));
174
175
  return directories.flatMap((path) => {
175
176
  const { state, report } = outcomes.get(path);
@@ -182,37 +183,31 @@ const removeEmptyDirectories = (home, directories, remove) => {
182
183
  return [{
183
184
  ok: true,
184
185
  line: state === 'removed'
185
- ? `${PREFIX} removed ${path} (not in the package)`
186
- : `${PREFIX} kept ${path} (a directory the package does not carry that still holds an entry)`,
186
+ ? say(`removed ${path} (not in the package)`)
187
+ : say(`kept ${path} (a directory the package does not carry that still holds an entry)`),
187
188
  }];
188
189
  });
189
190
  };
190
191
 
191
- export const prunePayload = ({ packageRoot, home, payload }, deps = {}) => {
192
- const reports = [];
193
- const orphans = [];
194
- const directories = [];
192
+ export const prunePayload = ({ packageRoot, home, payload, owner }, guards) => {
193
+ const say = (text) => `${owner.prefix} ${text}`;
194
+ const plan = { reports: [], orphans: [], directories: [] };
195
195
  for (const entry of new Set(payload)) {
196
196
  const path = entry.split(sep).join('/');
197
- const carried = readTree(packageRoot, path, reports, true);
197
+ const carried = readTree(say, packageRoot, path, plan.reports, true);
198
198
  if (![...carried.values()].includes('file')) {
199
199
  continue;
200
200
  }
201
- const installed = readTree(home, path, reports);
202
- planSubtree(carried, installed, orphans, directories, reports);
201
+ planSubtree(say, carried, readTree(say, home, path, plan.reports), plan);
203
202
  }
203
+ const { reports } = plan;
204
204
  if (reports.some((report) => !report.ok)) {
205
- return finishReport(reports);
205
+ return finishReport(owner, reports);
206
206
  }
207
- const remove = {
208
- assertContainedRealPath: deps.assertContainedRealPath ?? assertContainedRealPath,
209
- lstatNoFollowRead: deps.lstatNoFollowRead ?? lstatNoFollowRead,
210
- unlinkSync: deps.unlinkSync ?? unlinkSync,
211
- rmdirSync: deps.rmdirSync ?? rmdirSync,
212
- };
213
- for (const path of orphans) {
214
- reports.push(...removeOrphan(home, path, remove));
207
+ const remove = { ...guards, unlinkSync: guards.unlinkSync ?? unlinkSync, rmdirSync: guards.rmdirSync ?? rmdirSync };
208
+ for (const path of plan.orphans) {
209
+ reports.push(...removeOrphan(say, home, path, remove));
215
210
  }
216
- reports.push(...removeEmptyDirectories(home, directories, remove));
217
- return finishReport(reports);
211
+ reports.push(...removeEmptyDirectories(say, home, plan.directories, remove));
212
+ return finishReport(owner, reports);
218
213
  };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { resolve } from 'node:path';
4
- import { tokenizeMarkdown } from '../references/scripts/markdown-blocks.mjs';
4
+ import { tokenizeMarkdown } from '../references/scripts/shared/index.mjs';
5
5
  import { isDirectRun } from './direct-run.mjs';
6
6
  import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
7
7
  import { plansInFlight, PLANS_REL, readPlanEntries } from './plan-files.mjs';
@@ -1,5 +1,5 @@
1
1
  import { posix } from 'node:path';
2
- import { tokenizeMarkdown } from '../references/scripts/markdown-blocks.mjs';
2
+ import { tokenizeMarkdown } from '../references/scripts/shared/index.mjs';
3
3
  import { parseRobustTag } from './robustness-literals.mjs';
4
4
  import { unique } from './claim-relation.mjs';
5
5
  import { checkStoryOwnership, PIN_FILE, PIN_VERBS } from './plan-shape-ownership.mjs';
@@ -5,7 +5,7 @@
5
5
  import { lstatSync } from 'node:fs';
6
6
  import { join } from 'node:path';
7
7
  import { writeDocsAiFileAtomic } from '../atomic-write.mjs';
8
- import { parseFrontmatter } from '../../references/scripts/check-docs-size.mjs';
8
+ import { parseFrontmatter } from '../../references/scripts/docs-size/index.mjs';
9
9
  import { digestOf, readRecord, readUnder } from './rules-check.mjs';
10
10
  import { RECORD_PATH, THEMES, themePaths } from './themes.mjs';
11
11
 
@@ -10,7 +10,7 @@
10
10
  // missing/unknown flag, a flag with no value, an unreadable path, or a section that is not there.
11
11
 
12
12
  import { readFileSync } from 'node:fs';
13
- import { fail } from '../references/scripts/markdown-blocks.mjs';
13
+ import { fail } from '../references/scripts/shared/index.mjs';
14
14
  import { isDirectRun } from './direct-run.mjs';
15
15
  import { CLASSES, DEFAULTS, auditQueue, checkQueue, formatReport } from './queue-audit.mjs';
16
16
 
@@ -25,7 +25,7 @@
25
25
  // explain why something was CUT, and reading that as the row's own state would delete live work. Only
26
26
  // the title and a bold status line are status positions.
27
27
  //
28
- // Markdown is read through the family's ONE block model (references/scripts/markdown-blocks.mjs) and
28
+ // Markdown is read through the family's ONE block model (references/scripts/shared/index.mjs) and
29
29
  // the ONE bullet scan the other queue reader uses (fold-scope.mjs) — fences, CRLF, indented headings
30
30
  // and the backtick-info-string rule are THEIR problem, never a second hand-rolled grammar here. A
31
31
  // document either of them refuses is a loud refusal, never a silent empty read.
@@ -34,7 +34,7 @@
34
34
  // nothing. Dependency-free, Node >= 22. No side effects on import.
35
35
 
36
36
 
37
- import { tokenizeMarkdown, fail } from '../references/scripts/markdown-blocks.mjs';
37
+ import { tokenizeMarkdown, fail } from '../references/scripts/shared/index.mjs';
38
38
  import { bulletBlocks } from './fold-scope.mjs';
39
39
  import { CARRY_WORK, CLASSES, DEFAULTS, UNREAD_ITEM, authorisesRemoval, classifyRow, titleOf } from './queue-audit-rows.mjs';
40
40
  import { nameFindings } from './queue-row-name.mjs';
@@ -2,7 +2,7 @@ import { createHash, randomUUID } from 'node:crypto';
2
2
  import { constants, openSync, closeSync, fstatSync, fsyncSync, readFileSync, writeFileSync, writeSync, unlinkSync } from 'node:fs';
3
3
  import { basename, dirname, join } from 'node:path';
4
4
  import { canonicalHeading } from './queue-audit.mjs';
5
- import { fail } from '../references/scripts/markdown-blocks.mjs';
5
+ import { fail } from '../references/scripts/shared/index.mjs';
6
6
 
7
7
  export const EXIT = Object.freeze({ accept: 0, refuse: 1, usage: 2 });
8
8
  const MAGIC = 'queue-purge: 1';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { constants, openSync, closeSync, fstatSync, readFileSync, realpathSync, statSync } from 'node:fs';
3
3
  import { dirname, resolve } from 'node:path';
4
- import { fail } from '../references/scripts/markdown-blocks.mjs';
4
+ import { fail } from '../references/scripts/shared/index.mjs';
5
5
  import { isDirectRun } from './direct-run.mjs';
6
6
  import { EXIT, appendBlock, readArchive } from './queue-purge-archive.mjs';
7
7
  import { snapshotQueue, checkPurge } from './queue-purge.mjs';
@@ -1,6 +1,6 @@
1
1
  import { auditQueue, authorisesRemoval, canonicalHeading } from './queue-audit.mjs';
2
2
  import { EXIT, frameBlock, hashBytes, judgeIntact, readArchive, renderTitle, sliceSection } from './queue-purge-archive.mjs';
3
- import { fail } from '../references/scripts/markdown-blocks.mjs';
3
+ import { fail } from '../references/scripts/shared/index.mjs';
4
4
 
5
5
  const readInputs = ({ queueBytes, section, archiveBytes = Buffer.alloc(0) }) => {
6
6
  if (!canonicalHeading(section)) throw fail(EXIT.usage, '--section is required');
@@ -56,14 +56,14 @@ import { surveyFamily, surveyGateHook } from './family-registry.mjs';
56
56
  import { probeSandboxMasks, needsMasksApply, patternToRel } from './sandbox-masks.mjs';
57
57
  import { shellQuoteArg } from './review-state.mjs';
58
58
  import { isFinalCapableDeclaration } from './run-gates.mjs';
59
- import { loadDeclaration, canonicalCheckerGates, coverageProducerPrecedes, isKitOwnedCheckerGate } from './gates-declaration.mjs';
59
+ import { loadDeclaration, canonicalCheckerGates, coverageProducerPrecedes, isKitOwnedCheckerGate, movableEarlierForm } from './gates-declaration.mjs';
60
60
  // The typed channel's READ-ONLY leaf only — never tools/mcp.mjs, which reaches the write core.
61
61
  import {
62
62
  SERVER_NAME as MCP_SERVER_NAME,
63
63
  STATE as MCP_STATE,
64
64
  readRegistration,
65
65
  } from './mcp-registration.mjs';
66
- import { matchesCoverageProducer, isCoverageProducerGate } from './coverage-producer.mjs';
66
+ import { matchesCoverageProducer } from './coverage-producer.mjs';
67
67
  // How much of the TRACKED tree the changed-line coverage domain can assess at all — the fact that
68
68
  // turns "the checker certifies" into "the checker certifies the assessable minority".
69
69
  import { takeCensus, censusFact, CENSUS_VERDICT } from './tracked-tree-census.mjs';
@@ -75,7 +75,7 @@ import { CHECKER_CLAIM, INITIAL_ADOPTION_REASON, SOURCE_SIZE_GATE_ID, classifySo
75
75
  // The declared-path resolution + segment containment this item's convergence lane shares with the
76
76
  // autonomy render's allowWrite degrade — ONE leaf, so the two answers cannot drift.
77
77
  import { resolveDeclaredDir, dirCovers, isResolvableDeclaredEntry } from './declared-paths.mjs';
78
- import { hookCheckAnswers, plannedRoles, readPreCommitState, unsafeToolsPath } from './git-hooks.mjs';
78
+ import { hookCheckAnswers, missingHookCommandFile, plannedRoles, readPreCommitState, unsafeToolsPath } from './git-hooks.mjs';
79
79
  export { resolveGitHooksPath, readPreCommitState, canonicalGuardLineRe, INSTALLER_MARKER_RE } from './git-hooks.mjs';
80
80
  import { loadConfig } from './orchestration-config.mjs';
81
81
  import { homeRelative } from './bridge-state-dirs.mjs';
@@ -85,7 +85,7 @@ import { nearestExistingDir, worktreesGrantDir, worktreesGrantHoldsHome } from '
85
85
  import { readBundledAgents, writeCheapAgents, EXECUTOR_VEHICLE } from './cheap-agents.mjs';
86
86
  import { ATTRIBUTION_KEY, LEGACY_ATTRIBUTION_KEY, attributionHidesText, effectiveAttribution, readAttributionChoice, wrongTypedKey } from './attribution.mjs';
87
87
  import { planGlobalRemoval } from './hide-footprint.mjs';
88
- import { NODE_EVIDENCE, NODE_EVIDENCE_SCRIPTS, probeNodeEvidence } from './node-evidence.mjs';
88
+ import { DEPLOYED_SCRIPTS, INSTALLER_REL, NODE_EVIDENCE, probeNodeEvidence } from './node-evidence.mjs';
89
89
  // The vehicle READINESS comes from the read-only half — the same survey `recipes` and `status` read.
90
90
  import { surveyExecutorVehicle, readExecutorPosture, agentsAccepted, readStamp, readFsDeps, AGENTS_DIR, WORKFLOW_STAMP, EXPECTED_WORKFLOW_VERSION } from './cheap-agents-read.mjs';
91
91
  // The ack store's path, keys, lane registry, fingerprint and guarded reader live in their own leaf
@@ -126,11 +126,12 @@ const ENFORCEMENT_KIT_ROOT = resolve(HERE, '..');
126
126
  const ENFORCEMENT_BUNDLE_ROOT = join(ENFORCEMENT_KIT_ROOT, 'references', 'scripts');
127
127
  const ENFORCEMENT_WHAT = 'the enforcement scripts are not deployed beside docs/ai (no Node evidence) \u2014 the offer copies them and installs the pre-commit hook';
128
128
  const ENFORCEMENT_UNMANAGED_HOOK = 'an UNMANAGED pre-commit hook exists \u2014 the installer never overwrites it, so the kit places no script here; with that hook moved aside (your own step) the enforcement item is offered';
129
- const COMMIT_GUARD_INSTALLER_VIA_ITEM = 'the hook installer (scripts/install-git-hooks.mjs) is not deployed \u2014 apply the enforcement item first, then re-run';
130
- const COMMIT_GUARD_INSTALLER_OWN_STEP = 'the hook installer (scripts/install-git-hooks.mjs) is not deployed here \u2014 deploying the enforcement scripts into this project is your own step, then re-run';
129
+ const COMMIT_GUARD_INSTALLER_VIA_ITEM = `the hook installer (${INSTALLER_REL}) is not deployed \u2014 apply the enforcement item first, then re-run`;
130
+ const COMMIT_GUARD_INSTALLER_OWN_STEP = `the hook installer (${INSTALLER_REL}) is not deployed here \u2014 deploying the enforcement scripts into this project is your own step, then re-run`;
131
131
  const COMMIT_GUARD_UNMANAGED_HOOK = 'an UNMANAGED pre-commit hook exists \u2014 the installer never overwrites it; adding the guard line to it is your own step';
132
132
  const HOOK_CHECKS_UNMANAGED_HOOK = 'an UNMANAGED pre-commit hook exists \u2014 the installer never overwrites it; adding the lines this item would arm to it is your own step';
133
133
  const HOOK_CHECKS_WAIT = 'the layout line follows the source-size.layout record \u2014 apply that item first; this item\'s check line then arms the layout line too';
134
+ const HOOK_CHECKS_COMMAND = "the hook runs the kit's checks by flat paths this upgrade removes — once they are gone every commit stops until this item is applied";
134
135
  const LAYOUT_RECORD_RECIPE = 'the hook is per clone and the config per branch: a branch or linked worktree with no size config is judged under the kit\'s values and stops on its piles until it takes the record (a hidden deployment\'s linked worktree carries none); one with an older config without layout is not judged on layout; one whose config is schema 1 or unminted stops every commit on that config\'s own stop until it takes the current config';
135
136
  const LAYOUT_HELD = {
136
137
  stops: () => 'the source-size check stops on this tree, so a layout record or layout line not yet in place waits \u2014 record that growth first with the reasoned --write-baseline its stop names, then re-run',
@@ -265,7 +266,7 @@ export const composeVerdict = ({ attention, optional, skipped, kit = 0 }) => {
265
266
  // banned tokens), never a fixture-coverage gamble. A pure-placeholder template marks a WHAT whose
266
267
  // content is fully dynamic (capped at composition by truncation-with-count) — except `profile-gap`, whose
267
268
  // WHAT is never truncated: the leaf's suite pins every composed WHAT under the cap.
268
- const GATES_INERT_WHAT = 'the declared coverage checker ({id}) has no producer before it — it certifies nothing this run, or reads a stale lcov';
269
+ const GATES_INERT_WHAT = 'the declared coverage checker ({id}): no gate before it is a producer this kit reads';
269
270
  export const WHATS = Object.freeze({
270
271
  'velocity-core': 'routine read-only commands still prompt — {n} audited read-only allowlist entr(ies) not seeded',
271
272
  'velocity-core.rule': 'auto mode refuses a harness apply, so work cannot stay in auto mode — the apply ask rule is not seeded',
@@ -692,7 +693,7 @@ export const probeGatesInert = ({ root, deps, add, skip }) => {
692
693
  // ORDER decides, through the declaration's own shared predicate: a producer declared AFTER the
693
694
  // checker leaves it just as inert as no producer at all (it reads nothing, or stale bytes), and
694
695
  // only --final refuses that shape — a plain run reports every gate PASS.
695
- if (coverageProducerPrecedes(gates, gates.indexOf(checkers[0]))) {
696
+ if (coverageProducerPrecedes(gates, gates.indexOf(checkers[0]), root)) {
696
697
  // The pair is LIVE, and that is exactly where the DOMAIN question becomes the honest one: the
697
698
  // checker's changed-line domain is `.mjs/.cjs/.js` by design, so on a tree dominated by what
698
699
  // that domain excludes, "certified" means "certified over the assessable minority". An
@@ -727,7 +728,16 @@ export const probeGatesInert = ({ root, deps, add, skip }) => {
727
728
  // arm's sentence would be false over it. An offer computation that throws reaches the probe's
728
729
  // stated-skip lane, which is the honest answer to "can the fill help here" when nobody knows.
729
730
  const declaredIds = new Set(gates.map((gate) => gate.id));
730
- const offered = buildOffer(root, deps).entries.filter((entry) => matchesCoverageProducer(entry.cmd));
731
+ const offer = buildOffer(root, deps);
732
+ // A gate an earlier kit wrote that the upgrade moves, anywhere in the declaration, or a `node --test`
733
+ // script the offer withheld on its unit-tests guard: the upgrade is the remedy, in place of the fill
734
+ // preview and of both user arms below — it moves the gate with no question, or a line of its report
735
+ // names what stops it; the advisor predicts nothing about the run (spec coverage-producer, the remedy route).
736
+ if (movableEarlierForm(gates) || offer.guardWithheld.length > 0) {
737
+ add('gates-inert', fillTemplate(WHATS['gates-inert'], { id: truncatedTo(oneLineOf(checkers[0].id), templateBudget(WHATS['gates-inert'])) }), '/agent-workflow-kit upgrade');
738
+ return;
739
+ }
740
+ const offered = offer.entries.filter((entry) => matchesCoverageProducer(entry.cmd));
731
741
  const producer = offered.find((entry) => !declaredIds.has(entry.id));
732
742
  // The dead pair on a tree the recognized producer set cannot speak for. It is deliberately NOT
733
743
  // the ordering arm: a producer that EXISTS but sits after the checker is one MOVE away from
@@ -753,7 +763,7 @@ export const probeGatesInert = ({ root, deps, add, skip }) => {
753
763
  // a recognizable producer the offer never carries. The arm therefore says only what it knows —
754
764
  // nothing declares one and nothing offers one — and its apply names that gap, because the
755
765
  // remedy there is a hand-declared gate rather than the marker.
756
- if (offered.length === 0 && !gates.some((gate) => !checkers.includes(gate) && isCoverageProducerGate(gate))) {
766
+ if (offered.length === 0 && !coverageProducerPrecedes(gates, gates.length, root)) {
757
767
  // An UNAVAILABLE census is NOT a skip here. The dead pair is a defect on any tree, and the
758
768
  // arm below states it truthfully — falling through keeps a non-git deployment byte-identical
759
769
  // to what it saw before this outcome existed, and still renders an item, so the flow-optimal
@@ -980,8 +990,7 @@ const probeCommitGuard = ({ root, deps, add, skip }) => {
980
990
  if (gatesRaw === null) return; // undeclared — the gates-declaration item owns that story
981
991
  const gates = JSON.parse(gatesRaw).gates;
982
992
  if (!isFinalCapableDeclaration(gates, root)) return; // no receipt to guard yet — no offer
983
- const installer = join(root, 'scripts', 'install-git-hooks.mjs');
984
- if (!(deps.exists ?? existsSync)(installer)) {
993
+ if (!(deps.exists ?? existsSync)(join(root, INSTALLER_REL))) {
985
994
  skip('commit-guard', new Error(enforcementAdmits(root, deps) ? COMMIT_GUARD_INSTALLER_VIA_ITEM : COMMIT_GUARD_INSTALLER_OWN_STEP));
986
995
  return;
987
996
  }
@@ -1006,16 +1015,19 @@ const probeHookChecks = ({ root, deps, add, skip, shared }) => {
1006
1015
  if (unsafe !== null) throw new Error(unsafe);
1007
1016
  const hook = readHookState(root, deps);
1008
1017
  if (hook.state === 'no-hooks-dir') return;
1018
+ const switchCommand = hook.state === 'managed' && !hook.command;
1009
1019
  const roles = plannedRoles(hookCheckAnswers(root, deps), hook).map(({ key }) => key);
1010
1020
  const waits = shared.layoutRecord === true && !hook.layoutArmed && !roles.includes('layout');
1011
- if (roles.length === 0 && !waits) return;
1021
+ if (roles.length === 0 && !waits && !switchCommand) return;
1012
1022
  if (hook.state === 'unmanaged') throw new Error(HOOK_CHECKS_UNMANAGED_HOOK);
1013
- if (!(deps.exists ?? existsSync)(join(root, 'scripts', 'install-git-hooks.mjs'))) {
1023
+ if (!(deps.exists ?? existsSync)(join(root, INSTALLER_REL))) {
1014
1024
  throw new Error(enforcementAdmits(root, deps) ? COMMIT_GUARD_INSTALLER_VIA_ITEM : COMMIT_GUARD_INSTALLER_OWN_STEP);
1015
1025
  }
1026
+ const missing = switchCommand ? missingHookCommandFile(root, deps) : undefined;
1027
+ if (missing) throw new Error(`${missing} is not a regular file — re-run /agent-workflow-kit upgrade, then apply this item again`);
1016
1028
  const keys = [...roles, ...(waits ? ['layout'] : [])];
1017
1029
  const checks = HOOK_CHECK_NAMES[keys.length === 2 ? 'both' : keys[0]];
1018
- add('hook-checks', fillTemplate(WHATS['hook-checks'], { checks }), formsApply('hook-checks', root), 'hook-checks', waits ? HOOK_CHECKS_WAIT : null);
1030
+ add('hook-checks', switchCommand ? HOOK_CHECKS_COMMAND : fillTemplate(WHATS['hook-checks'], { checks }), formsApply('hook-checks', root), 'hook-checks', waits ? HOOK_CHECKS_WAIT : null);
1019
1031
  } catch (err) {
1020
1032
  skip('hook-checks', err);
1021
1033
  }
@@ -1045,16 +1057,16 @@ const enforcementOffer = (root, deps) => {
1045
1057
  if (evidence.wrongKind.length > 0) throw new Error(join(root, evidence.wrongKind[0]));
1046
1058
  const readDir = deps.readdir ?? readdirSync;
1047
1059
  const bundleRoot = deps.scriptsBundleRoot ?? ENFORCEMENT_BUNDLE_ROOT;
1048
- const bundleBasenames = readDir(bundleRoot).filter((name) => name.endsWith('.mjs')).sort();
1049
- if (NODE_EVIDENCE_SCRIPTS.some((name) => !bundleBasenames.includes(name))) throw new Error(`${bundleRoot}: a runnable enforcement script is missing`);
1050
- const scripts = join(root, 'scripts');
1051
- const scriptsNode = readEnforcementNode(scripts, lstat);
1052
- if (scriptsNode !== null && !scriptsNode.isDirectory()) throw new Error(`${scripts} is not a plain directory`);
1053
- for (const basename of scriptsNode === null ? [] : bundleBasenames) {
1054
- const destination = join(scripts, basename);
1055
- if (readEnforcementNode(destination, lstat) === null) continue;
1056
- throw new Error(`${destination} already exists; the enforcement copy would clobber it`);
1057
- }
1060
+ // The bundle is complete when every segment of each deployed path stands in its folder's listing.
1061
+ const listings = new Map();
1062
+ const inBundle = (path) => path.split('/').every((name, at, parts) => {
1063
+ const folder = join(bundleRoot, ...parts.slice(0, at));
1064
+ if (!listings.has(folder)) listings.set(folder, readDir(folder));
1065
+ return listings.get(folder).includes(name);
1066
+ });
1067
+ if (!DEPLOYED_SCRIPTS.every(({ path }) => inBundle(path))) throw new Error(`${bundleRoot}: a runnable enforcement script is missing`);
1068
+ // Evidence none with nothing of the wrong kind already proves the destination clean: every deployed path is a
1069
+ // probe, so each is absent and scripts/, the kit folder and each module folder are absent or plain directories.
1058
1070
  if (readHookState(root, deps).state === 'unmanaged') throw new Error(ENFORCEMENT_UNMANAGED_HOOK);
1059
1071
  return true;
1060
1072
  };
@@ -11,12 +11,13 @@
11
11
  // script-priors.test.mjs holds the two sides equal both ways and pins the row count. Rows are never
12
12
  // edited or removed: a deployment on any shipped body must keep classifying `prior`.
13
13
  //
14
- // Pure leaf: node:crypto only. No side effects on import.
14
+ // A leaf: node:crypto and the direct-run guard only (upgrade.md names it, so a direct run refuses). No side effects on import.
15
15
 
16
16
  import { createHash } from 'node:crypto';
17
+ import { refuseDirectRun } from './direct-run.mjs';
17
18
 
18
- // The deployed scripts a refresh may REPLACE: every bundled name (the suite pins it equal to the
19
- // bundle). A name with no row here classifies `custom` on any body but the bundled one.
19
+ // The 25 flat names of the last flat release, frozen: the files the move from the flat layout judges in scripts/.
20
+ // None is a bundled name; a name with no row here classifies `custom` on any body but the bundled one.
20
21
  export const PRIOR_FILES = Object.freeze([
21
22
  '_expect-shim.mjs', 'archive-caps.mjs', 'archive-caps.test.mjs', 'archive-changelog.mjs', 'archive-changelog.test.mjs',
22
23
  'archive-conservation.test.mjs', 'archive-decisions.mjs', 'archive-decisions.test.mjs', 'archive-issues.mjs',
@@ -62,6 +63,31 @@ export const SCRIPT_PRIORS = Object.freeze([
62
63
  prior('archive-decisions.mjs', '8.1.3', '8.4.0', '2e1c378fe8a395440dc17a712643a549487e87f958f9d6ec5922dced876421ad'),
63
64
  prior('spec-schema.mjs', '8.0.0', '8.6.3', '238e9a0ab3839f56b9f488b8c3232e8289c90d9808c772864dd5a95405b8488c'),
64
65
  prior('spec-schema.test.mjs', '8.0.0', '8.6.3', '192661dd459c130004b2639d506676ee023fb24e862aad09656adc8c1418af04'),
66
+ // The last flat release (memory 9.0.0): each flat body that is not the bundled one of its deployed entry,
67
+ // so the move's body check knows every flat file the kit left in scripts/.
68
+ prior('_expect-shim.mjs', '1.0.0', '9.0.0', 'f6aa541f4fae226e8fd56420400649e9f0a308a2a9c69de1b9040e7745209b30'),
69
+ prior('archive-caps.mjs', '6.0.0', '9.0.0', '0792ad611b566ad15f2230c3bd68b534e51f184b45619bf8925dc441bed71665'),
70
+ prior('archive-caps.test.mjs', '6.0.0', '9.0.0', '38652af64cab83c754a00c957dda8b3032e32004f7f419182a9f35edbf3cea0d'),
71
+ prior('archive-changelog.mjs', '6.0.0', '9.0.0', 'ab1e1124edd5c2da37056dee5278a442008045a3d1b08acf7a5a6d617e47c41a'),
72
+ prior('archive-changelog.test.mjs', '6.0.0', '9.0.0', '58785635406a1ad2006ab2c18d00644a1db3efd060395d72516473a5c812d9c3'),
73
+ prior('archive-conservation.test.mjs', '4.0.0', '9.0.0', '9da44e089caf6b55942ae77c6a5ae4644ead8cdb013b44a1bd9d0e2c5f7a9077'),
74
+ prior('archive-decisions.mjs', '8.5.0', '9.0.0', '4425aa899b32ada19e5859b8b438de37edbff2d9d925571beb866ca460e9a868'),
75
+ prior('archive-decisions.test.mjs', '8.1.3', '9.0.0', '52a5170077acd1e7b3568a6387ff0f320efdd452396d4df6c4dd1f95ab2efdcb'),
76
+ prior('archive-issues.mjs', '4.5.1', '9.0.0', 'd1d1a82c158aac9a0ab4b6b89c837f0ee7aa9598ddb55fa70374aec6fcf16588'),
77
+ prior('archive-issues.test.mjs', '4.0.0', '9.0.0', '96eef36bd83259dfc7df6fd1858b60c4afe0fe5b324aa76cb760f0591237f045'),
78
+ prior('archiver-structure.test.mjs', '7.2.0', '9.0.0', '0f0e096579916ec917d393092e3ea8b66904cf78017fab550b4e839c4e578531'),
79
+ prior('check-docs-size-cli.test.mjs', '8.2.0', '9.0.0', '6e43e1e8141697ecbe310fa9328cd2107ad71e140f317d25cc627cd14661ad92'),
80
+ prior('check-docs-size-ensure.test.mjs', '8.2.0', '9.0.0', '3ba3c565a32b9371c59ea7f1ccffd9cbe40b5a3d214ee7d09ab1eafb7502add8'),
81
+ prior('check-docs-size.mjs', '8.2.0', '9.0.0', '22d902c277cd123327c65b2753a319532a934308ebc6188d882490e1dc43272c'),
82
+ prior('check-docs-size.test.mjs', '4.6.0', '9.0.0', '547290e3cbb8da1da7ded60f1ca060eaaeaf444f0e4f196103b892a1b6b93ad5'),
83
+ prior('install-git-hooks-repo-exec.test.mjs', '8.4.0', '9.0.0', 'a1e00887d9ebd4f5ee3c8066ba04a557cdfad1c462b1805f54da61fe51bfed9e'),
84
+ prior('install-git-hooks.mjs', '8.4.0', '9.0.0', '0c4d1eb6bdd6dec492c7be8f3d92751f330b53786bf0e07936b0fe7cf6118395'),
85
+ prior('install-git-hooks.test.mjs', '8.4.0', '9.0.0', '9d9475be5bcef99ba5b233d9d676d78203cff3be834a8525adc8b14d4210247e'),
86
+ prior('markdown-blocks.test.mjs', '4.0.0', '9.0.0', 'd2289da8783ce6df8260e83eb52d62f8dfc1233555b074087997e94117047ffd'),
87
+ prior('migrate-gates-branches.test.mjs', '4.3.0', '9.0.0', '59734b15ddf98762c6db0c048edf374f949f7b92c53ea4fd986d72b7f44e283f'),
88
+ prior('migrate-gates.mjs', '8.1.5', '9.0.0', 'd9c3f9da27397dd94ad866c3cbac72e529ad2e6311ffa15de7478a960800cdfa'),
89
+ prior('migrate-gates.test.mjs', '8.1.5', '9.0.0', '8f99a2f65f1f3db0eb3464a0382c208ca5076388b6df0596cf099d53ab2a1f86'),
90
+ prior('spec-schema.test.mjs', '8.7.0', '9.0.0', '6a602a93e9f9f21f0bc10c50e356de693936d3e204987efbab1a1d7674030498'),
65
91
  ]);
66
92
 
67
93
  export const digestOf = (bytes) => createHash('sha256').update(bytes).digest('hex');
@@ -75,3 +101,5 @@ export const classifyDeployedScript = (deployedBytes, file, bundleBytes, priors
75
101
  if (digest === digestOf(bundleBytes)) return 'current';
76
102
  return priors.some((row) => row.file === file && row.digest === digest) ? 'prior' : 'custom';
77
103
  };
104
+
105
+ refuseDirectRun(import.meta.url);
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { createHash } from 'node:crypto';
9
9
  import { join, resolve } from 'node:path';
10
- import { tokenizeMarkdown } from '../../references/scripts/markdown-blocks.mjs';
10
+ import { tokenizeMarkdown } from '../../references/scripts/shared/index.mjs';
11
11
  import { auditQueue, canonicalHeading, checkQueue } from '../queue-audit.mjs';
12
12
  import { parseArgv } from '../queue-audit-cli.mjs';
13
13
  import { bandOf } from './layout.mjs';
@@ -3,7 +3,7 @@
3
3
  // spec-check's own exported seam; this module walks nothing of its own. Read-only, Node >= 22.
4
4
 
5
5
  import { join } from 'node:path';
6
- import { SPEC_SCHEMA } from '../references/scripts/spec-schema.mjs';
6
+ import { SPEC_SCHEMA } from '../references/scripts/spec-schema/index.mjs';
7
7
  import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
8
8
  import { probe as probePath, realpath as realpathOf, list as listDir } from './spec-check-cli.mjs';
9
9
  import { walkStore, readClosure } from './spec-check.mjs';
@@ -14,11 +14,11 @@
14
14
  // some other path, so one document has exactly ONE accepted spelling and a dedup can be an equality.
15
15
  // The store root is never an op target — it is the navigator, not a contract.
16
16
  //
17
- // The D-schema values come from the ONE reader (references/scripts/spec-schema.mjs): no second
17
+ // The D-schema values come from the ONE reader (references/scripts/spec-schema/index.mjs): no second
18
18
  // source of the prefix, the navigator filename or the slug pattern. Pure strings in, ops out — the
19
19
  // filesystem belongs to spec-check.mjs. Dependency-free, Node >= 22.
20
20
 
21
- import { SPEC_SCHEMA } from '../references/scripts/spec-schema.mjs';
21
+ import { SPEC_SCHEMA } from '../references/scripts/spec-schema/index.mjs';
22
22
 
23
23
  const STORE = SPEC_SCHEMA.storePrefix;
24
24
  const NAV = SPEC_SCHEMA.navigatorFile;
@@ -3,7 +3,7 @@
3
3
  // It answers ONE question per document: given what the session says it changed, does the store on
4
4
  // disk say the same thing? The change source is EXPLICIT (parsed ops, never git), and "well-formed"
5
5
  // has no second definition here — every per-document verdict is RELAYED from the ONE reader
6
- // (references/scripts/spec-schema.mjs) and its 2a `structure` extraction. This module adds only what
6
+ // (references/scripts/spec-schema/index.mjs) and its 2a `structure` extraction. This module adds only what
7
7
  // text alone cannot decide: does the post-state on disk match the declared op, is the document
8
8
  // listed by its parent, does its scenario marker really occur once in the file it names, and — under
9
9
  // --all — the five invariants that span documents.
@@ -22,7 +22,7 @@
22
22
  // No IO of its own: { read, probe, realpath, list } are injected. Dependency-free, Node >= 22.
23
23
 
24
24
  import { dirname as pathDirname, isAbsolute, relative, sep } from 'node:path';
25
- import { SPEC_SCHEMA, readSpecDocument, classifyPath } from '../references/scripts/spec-schema.mjs';
25
+ import { SPEC_SCHEMA, readSpecDocument, classifyPath } from '../references/scripts/spec-schema/index.mjs';
26
26
  import { SPEC_OPS_GRAMMAR, buildClosure, listingParentOf, slugOf } from './spec-check-ops.mjs';
27
27
 
28
28
  const STORE = SPEC_OPS_GRAMMAR.storePrefix;
@@ -14,7 +14,7 @@
14
14
  // Pure functions. No filesystem, no argv, no side effects on import — the CLI half owns all of that.
15
15
  // Dependency-free, Node >= 22.
16
16
 
17
- import { readSpecDocument } from '../references/scripts/spec-schema.mjs';
17
+ import { readSpecDocument } from '../references/scripts/spec-schema/index.mjs';
18
18
 
19
19
  // One `## Module` bullet, carried with the document that made the claim so a refusal can name the
20
20
  // owner. The two forms are the ones the spec schema already validates and there is no third here:
@@ -2,7 +2,7 @@
2
2
  // spec:tier-guide — docs/ai/specs/kit/tier/tier-guide/index.md
3
3
  import { dirname, resolve } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
- import { fail } from '../references/scripts/markdown-blocks.mjs';
5
+ import { fail } from '../references/scripts/shared/index.mjs';
6
6
  import { isDirectRun } from './direct-run.mjs';
7
7
  import { shellQuoteArg } from './repo-lex.mjs';
8
8
  import { readTierFacts } from './tier-guide-facts.mjs';
@@ -6,7 +6,7 @@
6
6
  // Contract: docs/ai/specs/kit/transition/.
7
7
 
8
8
  import { join, resolve } from 'node:path';
9
- import { tokenizeMarkdown } from '../../references/scripts/markdown-blocks.mjs';
9
+ import { tokenizeMarkdown } from '../../references/scripts/shared/index.mjs';
10
10
  import { writeContainedFileAtomic } from '../atomic-write.mjs';
11
11
  import { isDirectRun } from '../direct-run.mjs';
12
12
  import { probeRegularFileNoFollow, readRegularFileNoFollow } from '../fs-read-nofollow.mjs';