@sabaiway/agent-workflow-kit 20.2.0 → 21.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 (91) hide show
  1. package/CHANGELOG.md +39 -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/package.json +5 -2
  8. package/references/contracts.md +9 -9
  9. package/references/modes/bootstrap.md +3 -3
  10. package/references/modes/commit-guard.md +1 -1
  11. package/references/modes/recommendations.md +2 -2
  12. package/references/modes/upgrade.md +4 -4
  13. package/references/scripts/{archive-caps.mjs → archives/archive-caps.mjs} +1 -1
  14. package/references/scripts/{archive-changelog.mjs → archives/archive-changelog.mjs} +7 -9
  15. package/references/scripts/{archive-decisions.mjs → archives/archive-decisions.mjs} +13 -10
  16. package/references/scripts/{archive-issues.mjs → archives/archive-issues.mjs} +7 -8
  17. package/references/scripts/{check-docs-size.mjs → docs-size/check-docs-size.mjs} +3 -4
  18. package/references/scripts/docs-size/index.mjs +2 -0
  19. package/references/scripts/family.json +43 -0
  20. package/references/scripts/family.mjs +90 -0
  21. package/references/scripts/gates/kit-command-gates.mjs +117 -0
  22. package/references/scripts/{migrate-gates.mjs → gates/migrate-gates.mjs} +30 -13
  23. package/references/scripts/{install-git-hooks.mjs → git-hooks/install-git-hooks.mjs} +50 -38
  24. package/references/scripts/run.mjs +74 -0
  25. package/references/scripts/shared/index.mjs +3 -0
  26. package/references/scripts/shared/project-root.mjs +11 -0
  27. package/references/scripts/spec-schema/index.mjs +2 -0
  28. package/references/shared/composition-handoff.md +1 -1
  29. package/references/shared/deploy-tail.md +2 -2
  30. package/references/templates/SPEC_TEMPLATE.md +1 -1
  31. package/references/templates/adr-record.md +3 -3
  32. package/tools/apply-danger-check.mjs +9 -5
  33. package/tools/atomic-write.mjs +3 -1
  34. package/tools/direct-run.mjs +2 -0
  35. package/tools/distribution-files/retired.mjs +99 -0
  36. package/tools/distribution-files/scripts.mjs +67 -52
  37. package/tools/ensure-configs.mjs +21 -21
  38. package/tools/ensure-ops.mjs +60 -18
  39. package/tools/ensure-specs.mjs +82 -47
  40. package/tools/ensure-vocabulary.mjs +4 -4
  41. package/tools/epic-shape-cli.mjs +1 -1
  42. package/tools/epic-shape-ledger.mjs +1 -1
  43. package/tools/epic-shape.mjs +1 -1
  44. package/tools/family-registry.mjs +3 -1
  45. package/tools/feedback-record-cli.mjs +1 -1
  46. package/tools/fold-scope.mjs +2 -2
  47. package/tools/git-hooks.mjs +90 -65
  48. package/tools/jev-connect.mjs +1 -1
  49. package/tools/jev-guide.mjs +1 -1
  50. package/tools/jev-skill.mjs +1 -1
  51. package/tools/known-footprint.mjs +7 -29
  52. package/tools/node-evidence.mjs +29 -15
  53. package/tools/now-cli.mjs +1 -1
  54. package/tools/payload-prune.mjs +53 -58
  55. package/tools/plan-shape-cli.mjs +1 -1
  56. package/tools/plan-shape.mjs +1 -1
  57. package/tools/project-rules/rules-record.mjs +1 -1
  58. package/tools/queue-audit-cli.mjs +1 -1
  59. package/tools/queue-audit.mjs +2 -2
  60. package/tools/queue-purge-archive.mjs +1 -1
  61. package/tools/queue-purge-cli.mjs +1 -1
  62. package/tools/queue-purge.mjs +1 -1
  63. package/tools/recommendations.mjs +22 -19
  64. package/tools/script-priors.mjs +31 -3
  65. package/tools/source-size/piles.mjs +1 -1
  66. package/tools/spec-adoption.mjs +1 -1
  67. package/tools/spec-check-ops.mjs +2 -2
  68. package/tools/spec-check.mjs +2 -2
  69. package/tools/spec-coverage.mjs +1 -1
  70. package/tools/tier-guide.mjs +1 -1
  71. package/tools/transition/index.mjs +1 -1
  72. package/tools/upgrade-runlist.mjs +1 -1
  73. package/tools/write-lanes.mjs +2 -2
  74. package/references/scripts/_expect-shim.mjs +0 -41
  75. package/references/scripts/archive-caps.test.mjs +0 -321
  76. package/references/scripts/archive-changelog.test.mjs +0 -560
  77. package/references/scripts/archive-conservation.test.mjs +0 -466
  78. package/references/scripts/archive-decisions.test.mjs +0 -1503
  79. package/references/scripts/archive-issues.test.mjs +0 -825
  80. package/references/scripts/archiver-structure.test.mjs +0 -84
  81. package/references/scripts/check-docs-size-cli.test.mjs +0 -325
  82. package/references/scripts/check-docs-size-ensure.test.mjs +0 -360
  83. package/references/scripts/check-docs-size.test.mjs +0 -395
  84. package/references/scripts/install-git-hooks-repo-exec.test.mjs +0 -185
  85. package/references/scripts/install-git-hooks.test.mjs +0 -241
  86. package/references/scripts/markdown-blocks.test.mjs +0 -310
  87. package/references/scripts/migrate-gates-branches.test.mjs +0 -302
  88. package/references/scripts/migrate-gates.test.mjs +0 -517
  89. package/references/scripts/spec-schema.test.mjs +0 -352
  90. /package/references/scripts/{markdown-blocks.mjs → shared/markdown-blocks.mjs} +0 -0
  91. /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');
@@ -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',
@@ -980,8 +981,7 @@ const probeCommitGuard = ({ root, deps, add, skip }) => {
980
981
  if (gatesRaw === null) return; // undeclared — the gates-declaration item owns that story
981
982
  const gates = JSON.parse(gatesRaw).gates;
982
983
  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)) {
984
+ if (!(deps.exists ?? existsSync)(join(root, INSTALLER_REL))) {
985
985
  skip('commit-guard', new Error(enforcementAdmits(root, deps) ? COMMIT_GUARD_INSTALLER_VIA_ITEM : COMMIT_GUARD_INSTALLER_OWN_STEP));
986
986
  return;
987
987
  }
@@ -1006,16 +1006,19 @@ const probeHookChecks = ({ root, deps, add, skip, shared }) => {
1006
1006
  if (unsafe !== null) throw new Error(unsafe);
1007
1007
  const hook = readHookState(root, deps);
1008
1008
  if (hook.state === 'no-hooks-dir') return;
1009
+ const switchCommand = hook.state === 'managed' && !hook.command;
1009
1010
  const roles = plannedRoles(hookCheckAnswers(root, deps), hook).map(({ key }) => key);
1010
1011
  const waits = shared.layoutRecord === true && !hook.layoutArmed && !roles.includes('layout');
1011
- if (roles.length === 0 && !waits) return;
1012
+ if (roles.length === 0 && !waits && !switchCommand) return;
1012
1013
  if (hook.state === 'unmanaged') throw new Error(HOOK_CHECKS_UNMANAGED_HOOK);
1013
- if (!(deps.exists ?? existsSync)(join(root, 'scripts', 'install-git-hooks.mjs'))) {
1014
+ if (!(deps.exists ?? existsSync)(join(root, INSTALLER_REL))) {
1014
1015
  throw new Error(enforcementAdmits(root, deps) ? COMMIT_GUARD_INSTALLER_VIA_ITEM : COMMIT_GUARD_INSTALLER_OWN_STEP);
1015
1016
  }
1017
+ const missing = switchCommand ? missingHookCommandFile(root, deps) : undefined;
1018
+ if (missing) throw new Error(`${missing} is not a regular file — re-run /agent-workflow-kit upgrade, then apply this item again`);
1016
1019
  const keys = [...roles, ...(waits ? ['layout'] : [])];
1017
1020
  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);
1021
+ add('hook-checks', switchCommand ? HOOK_CHECKS_COMMAND : fillTemplate(WHATS['hook-checks'], { checks }), formsApply('hook-checks', root), 'hook-checks', waits ? HOOK_CHECKS_WAIT : null);
1019
1022
  } catch (err) {
1020
1023
  skip('hook-checks', err);
1021
1024
  }
@@ -1045,16 +1048,16 @@ const enforcementOffer = (root, deps) => {
1045
1048
  if (evidence.wrongKind.length > 0) throw new Error(join(root, evidence.wrongKind[0]));
1046
1049
  const readDir = deps.readdir ?? readdirSync;
1047
1050
  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
- }
1051
+ // The bundle is complete when every segment of each deployed path stands in its folder's listing.
1052
+ const listings = new Map();
1053
+ const inBundle = (path) => path.split('/').every((name, at, parts) => {
1054
+ const folder = join(bundleRoot, ...parts.slice(0, at));
1055
+ if (!listings.has(folder)) listings.set(folder, readDir(folder));
1056
+ return listings.get(folder).includes(name);
1057
+ });
1058
+ if (!DEPLOYED_SCRIPTS.every(({ path }) => inBundle(path))) throw new Error(`${bundleRoot}: a runnable enforcement script is missing`);
1059
+ // Evidence none with nothing of the wrong kind already proves the destination clean: every deployed path is a
1060
+ // probe, so each is absent and scripts/, the kit folder and each module folder are absent or plain directories.
1058
1061
  if (readHookState(root, deps).state === 'unmanaged') throw new Error(ENFORCEMENT_UNMANAGED_HOOK);
1059
1062
  return true;
1060
1063
  };
@@ -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';
@@ -52,7 +52,7 @@ export const UPGRADE_RUNLIST = Object.freeze([
52
52
  ),
53
53
  entry(
54
54
  'gates-migration',
55
- 'node ${CLAUDE_SKILL_DIR}/references/scripts/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project>',
55
+ 'node ${CLAUDE_SKILL_DIR}/references/scripts/gates/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project>',
56
56
  'preview first — apply only on an explicit yes, re-run with --apply',
57
57
  ['preview', 'INERT', 'CUSTOMIZED'],
58
58
  ),
@@ -2,7 +2,7 @@ import { join, resolve } from 'node:path';
2
2
  import { dirCovers } from './declared-paths.mjs';
3
3
  import { claudeDirOf, quoteArg, skillTargets } from './jev-facts.mjs';
4
4
  import { targetsFor } from './jev-connect.mjs';
5
- import { BUNDLED_SCRIPT_NAMES, INSTALLER_REL, SCRIPTS_DIR } from './node-evidence.mjs';
5
+ import { DEPLOYED_SCRIPTS, INSTALLER_REL } from './node-evidence.mjs';
6
6
  import { dqUnsafePath } from './checker-claim.mjs';
7
7
  import { isLineUnsafe } from './source-size-refusal.mjs';
8
8
  import { SOURCE_SIZE_GATE_ID } from './source-size-gate-cmd.mjs';
@@ -112,7 +112,7 @@ const getStartupPaths = ({ env, home, platform }) => targetsFor({
112
112
  }).filter(({ path }) => path !== null).map(({ path }) => path);
113
113
 
114
114
  const preCommitOf = (facts) => join(facts.hooksDir ?? join(facts.root, '.git', 'hooks'), 'pre-commit');
115
- const getEnforcementPaths = (facts) => [...BUNDLED_SCRIPT_NAMES.map((name) => join(facts.root, SCRIPTS_DIR, name)), preCommitOf(facts)];
115
+ const getEnforcementPaths = (facts) => [...DEPLOYED_SCRIPTS.map(({ deployed }) => join(facts.root, deployed)), preCommitOf(facts)];
116
116
  const getGuardPaths = (facts) => [preCommitOf(facts), join(facts.root, INSTALLER_REL)];
117
117
 
118
118
  const formatCommand = (argv) => argv.map(quoteArg).join(' ');
@@ -1,41 +0,0 @@
1
- // Minimal dependency-free `expect` shim mapping the Vitest matchers used by the
2
- // kernel's *.test.mjs onto node:assert, so the suite runs under `node --test` with
3
- // zero dependencies. Supports only the matchers these tests use.
4
- import assert from 'node:assert/strict';
5
-
6
- const has = (actual, expected) => {
7
- if (typeof actual === 'string') return actual.includes(expected);
8
- if (Array.isArray(actual)) return actual.includes(expected);
9
- return false;
10
- };
11
-
12
- const matchers = (actual, negate) => ({
13
- toBe: (expected) =>
14
- negate ? assert.notStrictEqual(actual, expected) : assert.strictEqual(actual, expected),
15
- toEqual: (expected) =>
16
- negate ? assert.notDeepStrictEqual(actual, expected) : assert.deepStrictEqual(actual, expected),
17
- toContain: (expected) =>
18
- assert.ok(
19
- negate ? !has(actual, expected) : has(actual, expected),
20
- `expected ${JSON.stringify(actual)} ${negate ? 'not ' : ''}to contain ${JSON.stringify(expected)}`,
21
- ),
22
- toMatch: (re) => (negate ? assert.doesNotMatch(actual, re) : assert.match(actual, re)),
23
- toHaveLength: (n) =>
24
- negate ? assert.notStrictEqual(actual.length, n) : assert.strictEqual(actual.length, n),
25
- toBeNull: () => (negate ? assert.notStrictEqual(actual, null) : assert.strictEqual(actual, null)),
26
- toBeInstanceOf: (Ctor) =>
27
- assert.ok(
28
- negate ? !(actual instanceof Ctor) : actual instanceof Ctor,
29
- `expected value ${negate ? 'not ' : ''}to be instance of ${Ctor.name}`,
30
- ),
31
- toBeGreaterThan: (n) =>
32
- assert.ok(negate ? !(actual > n) : actual > n, `expected ${actual} ${negate ? 'not ' : ''}> ${n}`),
33
- toBeLessThan: (n) =>
34
- assert.ok(negate ? !(actual < n) : actual < n, `expected ${actual} ${negate ? 'not ' : ''}< ${n}`),
35
- });
36
-
37
- export const expect = (actual) => {
38
- const api = matchers(actual, false);
39
- api.not = matchers(actual, true);
40
- return api;
41
- };