@holmes-lab/holmes-kit 0.30.0 → 0.31.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 (136) hide show
  1. package/CHANGELOG.md +494 -0
  2. package/README.md +10 -1
  3. package/bin/holmes-hook-antigravity.js +4 -0
  4. package/bin/holmes-kit.js +4 -0
  5. package/bin/holmes-pre-push.js +3 -0
  6. package/bin/holmes-stop-antigravity.js +4 -0
  7. package/dist/.build-id +1 -1
  8. package/dist/holmes/cli/agents.d.ts +41 -0
  9. package/dist/holmes/cli/agents.js +382 -2
  10. package/dist/holmes/cli/attest.d.ts +2 -0
  11. package/dist/holmes/cli/attest.js +66 -15
  12. package/dist/holmes/cli/ci-gate.js +16 -1
  13. package/dist/holmes/cli/claude-switches.d.ts +95 -0
  14. package/dist/holmes/cli/claude-switches.js +967 -0
  15. package/dist/holmes/cli/codex-hooks.d.ts +77 -0
  16. package/dist/holmes/cli/codex-hooks.js +802 -0
  17. package/dist/holmes/cli/codex-oracle.d.ts +194 -0
  18. package/dist/holmes/cli/codex-oracle.js +1245 -0
  19. package/dist/holmes/cli/codex-toml.d.ts +35 -0
  20. package/dist/holmes/cli/codex-toml.js +321 -52
  21. package/dist/holmes/cli/doctor.d.ts +98 -8
  22. package/dist/holmes/cli/doctor.js +1328 -94
  23. package/dist/holmes/cli/index.js +23 -11
  24. package/dist/holmes/cli/init.d.ts +11 -0
  25. package/dist/holmes/cli/init.js +736 -44
  26. package/dist/holmes/cli/mcp-launcher.d.ts +64 -6
  27. package/dist/holmes/cli/mcp-launcher.js +189 -6
  28. package/dist/holmes/cli/mcp-version.js +13 -2
  29. package/dist/holmes/cli/settings-merge.js +8 -2
  30. package/dist/holmes/cli/upgrade.d.ts +13 -0
  31. package/dist/holmes/cli/upgrade.js +116 -23
  32. package/dist/holmes/cli/workspace-scope.d.ts +22 -0
  33. package/dist/holmes/cli/workspace-scope.js +375 -0
  34. package/dist/holmes/cpg/cpg-scanner.d.ts +29 -0
  35. package/dist/holmes/cpg/cpg-scanner.js +403 -3
  36. package/dist/holmes/cpg/cycle-detect.js +2 -1
  37. package/dist/holmes/cpg/forbidden-edges.js +9 -2
  38. package/dist/holmes/cpg/required-calls.js +8 -1
  39. package/dist/holmes/governance/constitution-debt.js +3 -2
  40. package/dist/holmes/governance/constitution.js +15 -3
  41. package/dist/holmes/governance/provenance-chain.js +3 -2
  42. package/dist/holmes/governance/push-gate-runner.js +4 -3
  43. package/dist/holmes/guardrail/dependency-delta.js +4 -3
  44. package/dist/holmes/guardrail/linear-match.d.ts +57 -0
  45. package/dist/holmes/guardrail/linear-match.js +256 -0
  46. package/dist/holmes/guardrail/risk-classifier.d.ts +6 -7
  47. package/dist/holmes/guardrail/risk-classifier.js +931 -44
  48. package/dist/holmes/guardrail/risk-types.d.ts +6 -0
  49. package/dist/holmes/guardrail/scope-judgment.d.ts +4 -24
  50. package/dist/holmes/guardrail/scope-judgment.js +100 -23
  51. package/dist/holmes/guardrail/shell-words.d.ts +42 -0
  52. package/dist/holmes/guardrail/shell-words.js +1720 -0
  53. package/dist/holmes/guardrail/write-target.d.ts +168 -3
  54. package/dist/holmes/guardrail/write-target.js +2379 -87
  55. package/dist/holmes/hooks/adapters/antigravity.d.ts +3 -1
  56. package/dist/holmes/hooks/adapters/antigravity.js +115 -11
  57. package/dist/holmes/hooks/pre-tool-use.d.ts +32 -6
  58. package/dist/holmes/hooks/pre-tool-use.js +923 -87
  59. package/dist/holmes/hooks/rtm-refresh-child.js +3 -1
  60. package/dist/holmes/hooks/rtm-refresh.js +8 -4
  61. package/dist/holmes/hooks/session-start.d.ts +10 -0
  62. package/dist/holmes/hooks/session-start.js +31 -7
  63. package/dist/holmes/hooks/stop.d.ts +2 -1
  64. package/dist/holmes/hooks/stop.js +197 -91
  65. package/dist/holmes/mcp/approval-commit.d.ts +5 -6
  66. package/dist/holmes/mcp/approval-commit.js +18 -2
  67. package/dist/holmes/mcp/elicit-approval.js +4 -2
  68. package/dist/holmes/mcp/handlers/graph-operations.js +3 -2
  69. package/dist/holmes/mcp/handlers/maintenance-analysis.js +11 -5
  70. package/dist/holmes/mcp/handlers/maintenance-evidence.js +3 -2
  71. package/dist/holmes/mcp/handlers/phase-queries.d.ts +22 -7
  72. package/dist/holmes/mcp/handlers/phase-queries.js +81 -2
  73. package/dist/holmes/mcp/handlers/requirement-triage.js +5 -3
  74. package/dist/holmes/mcp/handlers/review-evidence.js +8 -2
  75. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +11 -0
  76. package/dist/holmes/mcp/handlers/slice-orchestration.js +115 -16
  77. package/dist/holmes/mcp/handlers/spec-approval.d.ts +9 -0
  78. package/dist/holmes/mcp/handlers/spec-approval.js +110 -17
  79. package/dist/holmes/mcp/handlers/spec-authoring.js +17 -2
  80. package/dist/holmes/mcp/handlers/spec-queries.d.ts +39 -3
  81. package/dist/holmes/mcp/handlers/spec-queries.js +114 -7
  82. package/dist/holmes/mcp/handlers/test-execution.js +9 -3
  83. package/dist/holmes/mcp/handlers.d.ts +81 -9
  84. package/dist/holmes/mcp/handlers.js +70 -23
  85. package/dist/holmes/mcp/harness-attestation.d.ts +20 -0
  86. package/dist/holmes/mcp/harness-attestation.js +179 -0
  87. package/dist/holmes/mcp/requirement-triage-evidence.d.ts +36 -0
  88. package/dist/holmes/mcp/requirement-triage-evidence.js +160 -4
  89. package/dist/holmes/mcp/server.js +20 -1
  90. package/dist/holmes/mcp/tool-schemas.js +26 -9
  91. package/dist/holmes/mcp/validate-args.js +12 -0
  92. package/dist/holmes/project/bounded-io.d.ts +102 -0
  93. package/dist/holmes/project/bounded-io.js +212 -0
  94. package/dist/holmes/project/change-source.js +3 -1
  95. package/dist/holmes/project/ci-runs.js +3 -2
  96. package/dist/holmes/project/ignore.d.ts +31 -2
  97. package/dist/holmes/project/ignore.js +409 -50
  98. package/dist/holmes/project/regular-file-guard.d.ts +13 -0
  99. package/dist/holmes/project/regular-file-guard.js +149 -0
  100. package/dist/holmes/project/root.js +12 -3
  101. package/dist/holmes/reverse/anchor.js +4 -3
  102. package/dist/holmes/reverse/scan.js +6 -2
  103. package/dist/holmes/review/commit-text.js +3 -2
  104. package/dist/holmes/review/condition-hunk-replay.js +3 -2
  105. package/dist/holmes/review/failed-test-names.js +13 -10
  106. package/dist/holmes/review/findings.js +3 -1
  107. package/dist/holmes/review/kills-check.js +6 -1
  108. package/dist/holmes/review/point-in-time-replay.js +5 -4
  109. package/dist/holmes/review/replay-corpus.js +5 -4
  110. package/dist/holmes/review/run-replay.js +3 -2
  111. package/dist/holmes/review/temporal-prior.js +3 -2
  112. package/dist/holmes/review/test-evidence.js +3 -2
  113. package/dist/holmes/review/test-outcomes.js +3 -2
  114. package/dist/holmes/review/test-runner.d.ts +6 -0
  115. package/dist/holmes/review/test-runner.js +36 -15
  116. package/dist/holmes/rtm/advisory-outcomes.js +3 -2
  117. package/dist/holmes/rtm/anchor-ids.js +42 -2
  118. package/dist/holmes/rtm/file-anchors.js +4 -1
  119. package/dist/holmes/rtm/ftt-fulfilment.js +8 -3
  120. package/dist/holmes/rtm/git-changes.js +3 -1
  121. package/dist/holmes/rtm/graph-store.js +3 -2
  122. package/dist/holmes/rtm/test-scope.js +9 -4
  123. package/dist/holmes/spec/compat-impact.d.ts +25 -4
  124. package/dist/holmes/spec/compat-impact.js +682 -11
  125. package/dist/holmes/spec/entity-git-snapshot.js +3 -2
  126. package/dist/holmes/spec/entity-integration.js +3 -2
  127. package/dist/holmes/spec/entity-renumber-transaction.d.ts +19 -0
  128. package/dist/holmes/spec/entity-renumber-transaction.js +79 -6
  129. package/dist/holmes/spec/remote-spec-refs.js +3 -2
  130. package/dist/holmes/spec/renumber.js +25 -10
  131. package/dist/holmes/spec/spec-parser.js +9 -3
  132. package/dist/holmes/spec/yaml-scalar.js +2 -2
  133. package/dist/holmes/update/refresh.js +3 -1
  134. package/dist/holmes/update/update-notice.d.ts +6 -0
  135. package/dist/holmes/update/update-notice.js +18 -1
  136. package/package.json +11 -4
@@ -37,7 +37,7 @@ exports.isBrokenPipe = void 0;
37
37
  exports.packageRoot = packageRoot;
38
38
  exports.main = main;
39
39
  exports.installPipeGuard = installPipeGuard;
40
- // @implements A-SPEC-704, A-SPEC-709
40
+ // @implements A-SPEC-704, A-SPEC-709, A-SPEC-734
41
41
  // @implements A-SPEC-549.2
42
42
  // @implements A-SPEC-591, A-SPEC-626
43
43
  const cli_execution_1 = require("./cli-execution");
@@ -50,6 +50,7 @@ const path = __importStar(require("node:path"));
50
50
  const init_1 = require("./init");
51
51
  const doctor_1 = require("./doctor");
52
52
  const colophon_1 = require("./colophon");
53
+ const bounded_io_1 = require("../project/bounded-io");
53
54
  /**
54
55
  * `holmes-kit` CLI entry — argv dispatch, hand-rolled (no new dependency).
55
56
  *
@@ -124,7 +125,9 @@ class UnknownFlagError extends Error {
124
125
  * what you'd do" spelling performed a REAL write (round-3 HIGH; same class inverted --remove and
125
126
  * --force). A boolean flag must never consume a token.
126
127
  */
127
- const BOOLEAN_FLAGS = new Set(['badge', 'readme', 'help', 'dry-run', 'no-mcp', 'remove', 'force', 'json', 'list', 'status', 'watch', 'autonomy', 'no-autonomy']); // A-SPEC-650: --status
128
+ // A-SPEC-251.1 (round 26): `yes` — `upgrade --yes` was refused as "--yes requires a value", so the non-interactive
129
+ // upgrade its own guidance names could not run (measured).
130
+ const BOOLEAN_FLAGS = new Set(['badge', 'readme', 'help', 'dry-run', 'no-mcp', 'remove', 'force', 'json', 'list', 'status', 'watch', 'autonomy', 'no-autonomy', 'yes']); // A-SPEC-650: --status
128
131
  function parseFlags(argv, known) {
129
132
  const flags = {};
130
133
  const positionals = [];
@@ -434,7 +437,7 @@ async function main(argv) {
434
437
  return 2;
435
438
  }
436
439
  const checks = await (0, doctor_1.runDoctor)(packageRoot(), typeof flags.target === 'string' ? path.resolve(flags.target) : undefined, { agent: flags.agent });
437
- process.stdout.write(flags.json ? JSON.stringify(checks, null, 2) + '\n' : (0, doctor_1.formatChecks)(checks) + '\n');
440
+ process.stdout.write(flags.json ? (0, doctor_1.checksJson)(checks) + '\n' : (0, doctor_1.formatChecks)(checks) + '\n');
438
441
  return checks.some((c) => c.level === 'FAIL') ? 1 : 0;
439
442
  }
440
443
  if (cmd === 'skills') {
@@ -545,7 +548,7 @@ async function main(argv) {
545
548
  return 2;
546
549
  }
547
550
  try {
548
- execFileSync('git', ['-C', root, 'rev-parse', '--git-dir'], { stdio: 'pipe', env: gitEnv });
551
+ execFileSync('git', ['-C', root, 'rev-parse', '--git-dir'], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, stdio: 'pipe', env: gitEnv });
549
552
  }
550
553
  catch {
551
554
  process.stderr.write('not a git repository — without a canonical ref there is no rechaining: a rechain is a wholesale re-signing, and only the committed history can say what is canonical.\n');
@@ -556,7 +559,7 @@ async function main(argv) {
556
559
  // call site uses.
557
560
  try {
558
561
  assertSafeRev(ref);
559
- execFileSync('git', ['-C', root, 'rev-parse', '--verify', '--quiet', `${ref}^{commit}`], { stdio: 'pipe', env: gitEnv });
562
+ execFileSync('git', ['-C', root, 'rev-parse', '--verify', '--quiet', `${ref}^{commit}`], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, stdio: 'pipe', env: gitEnv });
560
563
  }
561
564
  catch {
562
565
  process.stderr.write(`--ref ${ref} cannot be resolved to a commit — without a canonical ref there is no rechaining.\n`);
@@ -583,7 +586,7 @@ async function main(argv) {
583
586
  const WALK_LIMIT = 64;
584
587
  let walkCommits = [];
585
588
  try {
586
- walkCommits = execFileSync('git', ['-C', root, 'rev-list', '--first-parent', '-n', String(WALK_LIMIT), ref], { encoding: 'utf8', env: gitEnv, stdio: ['ignore', 'pipe', 'pipe'] })
589
+ walkCommits = execFileSync('git', ['-C', root, 'rev-list', '--first-parent', '-n', String(WALK_LIMIT), ref], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', env: gitEnv, stdio: ['ignore', 'pipe', 'pipe'] })
587
590
  .split('\n').map((l) => l.trim()).filter(Boolean);
588
591
  }
589
592
  catch (e) {
@@ -597,7 +600,7 @@ async function main(argv) {
597
600
  // branch name too, making the trail self-describing later. Falls back to the raw ref.
598
601
  let refLabel = ref;
599
602
  try {
600
- refLabel = execFileSync('git', ['-C', root, 'rev-parse', '--abbrev-ref', ref], { encoding: 'utf8', env: gitEnv, stdio: ['ignore', 'pipe', 'pipe'] }).trim() || ref;
603
+ refLabel = execFileSync('git', ['-C', root, 'rev-parse', '--abbrev-ref', ref], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', env: gitEnv, stdio: ['ignore', 'pipe', 'pipe'] }).trim() || ref;
601
604
  }
602
605
  catch { /* keep raw ref */ }
603
606
  const planRechain = (mainline, input, mainlineAt) => {
@@ -662,7 +665,7 @@ async function main(argv) {
662
665
  // committed candidate that is CORRUPT (strict-parse throws) is skipped like an absent one.
663
666
  let raw;
664
667
  try {
665
- raw = execFileSync('git', ['-C', root, 'show', `${at}:./${rel}`], { encoding: 'utf8', maxBuffer: 1 << 28, env: gitEnv, stdio: ['ignore', 'pipe', 'pipe'] });
668
+ raw = execFileSync('git', ['-C', root, 'show', `${at}:./${rel}`], { timeout: bounded_io_1.GIT_TIMEOUT_MS, encoding: 'utf8', maxBuffer: 1 << 28, env: gitEnv, stdio: ['ignore', 'pipe', 'pipe'] });
666
669
  }
667
670
  catch {
668
671
  continue;
@@ -1238,17 +1241,24 @@ async function main(argv) {
1238
1241
  mcpLauncher,
1239
1242
  };
1240
1243
  const res = (0, init_1.runInit)(opts);
1244
+ // @implements A-SPEC-251.2 (round 44) — a message quoting a workspace file is escaped (an entry named with ESC and BEL
1245
+ // retitled the terminal through init — measured).
1241
1246
  for (const m of res.messages)
1242
- process[res.ok ? 'stdout' : 'stderr'].write(`${m}\n`);
1247
+ process[res.ok ? 'stdout' : 'stderr'].write(`${(0, doctor_1.terminalSafe)(m)}\n`);
1243
1248
  if (res.ok) {
1244
1249
  // round-8: a planned DELETION printed under 'would write' contradicted the line above it.
1245
1250
  for (const p of res.removals ?? [])
1246
1251
  process.stdout.write(` would remove ${p}\n`);
1247
1252
  for (const c of res.changes) {
1253
+ // A-SPEC-251.1 (round 26): a change with nothing to write is not written (`--remove` said "wrote" for a settings
1254
+ // file that did not exist — measured).
1255
+ if (c.after === null)
1256
+ continue;
1248
1257
  const verb = opts.dryRun ? 'would write' : 'wrote';
1249
- process.stdout.write(` ${verb} ${c.path}\n`);
1258
+ process.stdout.write(` ${verb} ${(0, doctor_1.terminalSafe)(c.path)}\n`);
1250
1259
  if (opts.dryRun && c.after) {
1251
- process.stdout.write(c.after.split('\n').map((l) => ` | ${l}`).join('\n') + '\n');
1260
+ // A-SPEC-251.2 (round 45): a preview line quoting a workspace file is escaped too (AGENTS.md's ESC and BEL reached it).
1261
+ process.stdout.write(c.after.split('\n').map((l) => ` | ${(0, doctor_1.terminalSafe)(l)}`).join('\n') + '\n');
1252
1262
  }
1253
1263
  }
1254
1264
  // @implements A-SPEC-543.1 — zero-config upgrade PREPARATION: a successful real wiring records
@@ -1354,6 +1364,8 @@ function installPipeGuard() {
1354
1364
  });
1355
1365
  }
1356
1366
  if (require.main === module) {
1367
+ // @implements A-SPEC-734 (round 13) — this process never blocks on a file that is not a regular file.
1368
+ require('../project/regular-file-guard').installProcessGuards();
1357
1369
  main(process.argv.slice(2))
1358
1370
  .then((code) => process.exit(code))
1359
1371
  .catch((err) => {
@@ -1,6 +1,7 @@
1
1
  import { HookPlan } from './settings-merge';
2
2
  import { Agent } from './agents';
3
3
  import { LauncherMode } from './mcp-launcher';
4
+ import { type CodexVerdict } from './codex-oracle';
4
5
  import { Approval } from '../guardrail/risk-gate';
5
6
  /**
6
7
  * `holmes-kit init` — wire holmes-kit into a TARGET project (the I/O half; all merge logic is pure
@@ -33,6 +34,16 @@ export interface InitOptions {
33
34
  mcpLauncher?: LauncherMode;
34
35
  /** Test/integration override for Codex's default user configuration path. */
35
36
  codexConfigPath?: string;
37
+ /** @implements A-SPEC-727 — test/integration override for Codex's user-level hooks file. */
38
+ codexHooksPath?: string;
39
+ /** A-SPEC-738: how to ask Codex whether its files load (tests inject; default: the installed codex). */
40
+ codexOracle?: (input: {
41
+ configBytes: Buffer | null;
42
+ hooksBytes: Buffer | null;
43
+ cwd: string;
44
+ realConfigPath?: string;
45
+ realHooksPath?: string;
46
+ }) => CodexVerdict;
36
47
  autonomy?: boolean;
37
48
  autonomyInteractive?: boolean;
38
49
  }