@holmes-lab/holmes-kit 0.40.0 → 0.41.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 (119) hide show
  1. package/CHANGELOG.md +312 -0
  2. package/README.md +79 -5
  3. package/dist/.build-id +1 -1
  4. package/dist/holmes/cli/approve-context.js +4 -3
  5. package/dist/holmes/cli/approve.js +22 -12
  6. package/dist/holmes/cli/autonomy.d.ts +21 -0
  7. package/dist/holmes/cli/autonomy.js +35 -5
  8. package/dist/holmes/cli/doctor.js +58 -6
  9. package/dist/holmes/cli/index.js +394 -267
  10. package/dist/holmes/cli/init.js +17 -6
  11. package/dist/holmes/cli/interactive-prompt.d.ts +39 -2
  12. package/dist/holmes/cli/interactive-prompt.js +98 -16
  13. package/dist/holmes/cli/ledger-witness.d.ts +61 -0
  14. package/dist/holmes/cli/ledger-witness.js +212 -0
  15. package/dist/holmes/cli/playbook-skills.d.ts +3 -56
  16. package/dist/holmes/cli/playbook-skills.js +26 -349
  17. package/dist/holmes/config/config.d.ts +21 -0
  18. package/dist/holmes/config/config.js +22 -3
  19. package/dist/holmes/governance/approval-queue.d.ts +65 -1
  20. package/dist/holmes/governance/approval-queue.js +279 -9
  21. package/dist/holmes/governance/autonomous-shell.d.ts +13 -1
  22. package/dist/holmes/governance/autonomous-shell.js +157 -4
  23. package/dist/holmes/governance/autonomy.d.ts +216 -0
  24. package/dist/holmes/governance/autonomy.js +1162 -10
  25. package/dist/holmes/governance/install-manifest.d.ts +7 -4
  26. package/dist/holmes/governance/install-manifest.js +144 -14
  27. package/dist/holmes/governance/ledger-witness.d.ts +63 -0
  28. package/dist/holmes/governance/ledger-witness.js +296 -0
  29. package/dist/holmes/governance/provenance-chain.d.ts +8 -1
  30. package/dist/holmes/governance/provenance-chain.js +23 -4
  31. package/dist/holmes/governance/push-gate-runner.d.ts +2 -0
  32. package/dist/holmes/governance/push-gate-runner.js +40 -3
  33. package/dist/holmes/governance/push-gate.d.ts +13 -2
  34. package/dist/holmes/governance/push-gate.js +106 -14
  35. package/dist/holmes/governance/recorded-pairs.d.ts +4 -0
  36. package/dist/holmes/governance/recorded-pairs.js +25 -1
  37. package/dist/holmes/governance/session-context.d.ts +7 -0
  38. package/dist/holmes/governance/session-context.js +34 -6
  39. package/dist/holmes/guardrail/advisory-line.d.ts +102 -0
  40. package/dist/holmes/guardrail/advisory-line.js +718 -0
  41. package/dist/holmes/guardrail/anchor-scope-text.d.ts +9 -0
  42. package/dist/holmes/guardrail/anchor-scope-text.js +7 -0
  43. package/dist/holmes/guardrail/command-traits.d.ts +102 -0
  44. package/dist/holmes/guardrail/command-traits.js +379 -0
  45. package/dist/holmes/guardrail/fixtures/manager-builtins.json +23 -0
  46. package/dist/holmes/guardrail/fixtures/npm-commands.json +7 -0
  47. package/dist/holmes/guardrail/impact-gate.d.ts +6 -0
  48. package/dist/holmes/guardrail/impact-gate.js +32 -5
  49. package/dist/holmes/guardrail/outward-acts.d.ts +47 -0
  50. package/dist/holmes/guardrail/outward-acts.js +1102 -0
  51. package/dist/holmes/guardrail/refusal-codes.js +8 -1
  52. package/dist/holmes/guardrail/refusal-templates.d.ts +15 -0
  53. package/dist/holmes/guardrail/refusal-templates.js +71 -0
  54. package/dist/holmes/guardrail/risk-classifier.d.ts +22 -6
  55. package/dist/holmes/guardrail/risk-classifier.js +12 -118
  56. package/dist/holmes/guardrail/shell-lexer.d.ts +69 -0
  57. package/dist/holmes/guardrail/shell-lexer.js +567 -0
  58. package/dist/holmes/guardrail/write-target.js +7 -1
  59. package/dist/holmes/hooks/pre-tool-use.d.ts +71 -0
  60. package/dist/holmes/hooks/pre-tool-use.js +1466 -14
  61. package/dist/holmes/hooks/session-start.js +27 -1
  62. package/dist/holmes/hooks/stop.d.ts +7 -0
  63. package/dist/holmes/hooks/stop.js +39 -2
  64. package/dist/holmes/mcp/elicit-approval.d.ts +0 -21
  65. package/dist/holmes/mcp/elicit-approval.js +5 -2
  66. package/dist/holmes/mcp/handlers/approval-ask.js +3 -2
  67. package/dist/holmes/mcp/handlers/entity-integration.d.ts +1 -1
  68. package/dist/holmes/mcp/handlers/entity-integration.js +9 -6
  69. package/dist/holmes/mcp/handlers/entity-renumber.js +2 -1
  70. package/dist/holmes/mcp/handlers/entity-store.js +7 -2
  71. package/dist/holmes/mcp/handlers/maintenance-analysis.d.ts +13 -0
  72. package/dist/holmes/mcp/handlers/maintenance-analysis.js +59 -2
  73. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -0
  74. package/dist/holmes/mcp/handlers/operator-inspection.js +25 -4
  75. package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -1
  76. package/dist/holmes/mcp/handlers/spec-approval.js +28 -10
  77. package/dist/holmes/mcp/handlers/spec-lifecycle.js +10 -7
  78. package/dist/holmes/mcp/handlers/test-execution.d.ts +470 -3
  79. package/dist/holmes/mcp/handlers/test-execution.js +201 -21
  80. package/dist/holmes/mcp/handlers.d.ts +473 -8
  81. package/dist/holmes/mcp/handlers.js +6 -1
  82. package/dist/holmes/mcp/maintenance-analyze.d.ts +5 -0
  83. package/dist/holmes/mcp/maintenance-analyze.js +4 -2
  84. package/dist/holmes/mcp/maintenance-evidence.d.ts +9 -0
  85. package/dist/holmes/mcp/maintenance-evidence.js +4 -1
  86. package/dist/holmes/mcp/tool-schemas.js +16 -10
  87. package/dist/holmes/project/baseline.d.ts +15 -2
  88. package/dist/holmes/project/baseline.js +11 -6
  89. package/dist/holmes/project/bounded-io.d.ts +1 -0
  90. package/dist/holmes/project/bounded-io.js +4 -2
  91. package/dist/holmes/project/change-source.d.ts +4 -0
  92. package/dist/holmes/project/change-source.js +13 -5
  93. package/dist/holmes/project/playbook-reference.d.ts +50 -0
  94. package/dist/holmes/project/playbook-reference.js +259 -0
  95. package/dist/holmes/project/playbook-skill-states.d.ts +94 -0
  96. package/dist/holmes/project/playbook-skill-states.js +396 -0
  97. package/dist/holmes/project/root.d.ts +9 -1
  98. package/dist/holmes/project/root.js +26 -3
  99. package/dist/holmes/project/running-package.d.ts +15 -0
  100. package/dist/holmes/project/running-package.js +87 -0
  101. package/dist/holmes/review/evidence-mode.d.ts +21 -0
  102. package/dist/holmes/review/evidence-mode.js +33 -0
  103. package/dist/holmes/review/head-worktree.d.ts +55 -0
  104. package/dist/holmes/review/head-worktree.js +329 -0
  105. package/dist/holmes/review/mrp.js +13 -3
  106. package/dist/holmes/review/run-provenance.d.ts +45 -0
  107. package/dist/holmes/review/run-provenance.js +314 -0
  108. package/dist/holmes/review/test-evidence.d.ts +174 -0
  109. package/dist/holmes/review/test-evidence.js +330 -2
  110. package/dist/holmes/review/test-reports.d.ts +94 -0
  111. package/dist/holmes/review/test-reports.js +382 -0
  112. package/dist/holmes/review/test-runner.d.ts +178 -65
  113. package/dist/holmes/review/test-runner.js +551 -319
  114. package/dist/holmes/review/test-units.d.ts +159 -0
  115. package/dist/holmes/review/test-units.js +814 -0
  116. package/dist/holmes/spec/entity-integration-transaction.d.ts +19 -2
  117. package/dist/holmes/spec/entity-integration-transaction.js +68 -7
  118. package/package.json +5 -2
  119. package/playbooks/publish/PLAYBOOK.md +2 -1
@@ -33,15 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.frontmatterEnd = exports.carriesMarker = exports.PLAYBOOK_SKILL_MARKER = void 0;
37
- exports.installedSkillBytes = installedSkillBytes;
38
- exports.invocableSkillName = invocableSkillName;
39
- exports.skillPathFor = skillPathFor;
36
+ exports.judgedSkillStates = exports.classifyExtraEntries = exports.playbookSkillStates = exports.skillPathFor = exports.invocableSkillName = exports.installedSkillBytes = exports.frontmatterEnd = exports.carriesMarker = exports.PLAYBOOK_SKILL_MARKER = void 0;
40
37
  exports.installPlaybookSkills = installPlaybookSkills;
41
38
  exports.removePlaybookSkills = removePlaybookSkills;
42
39
  exports.skillLabel = skillLabel;
43
- exports.playbookSkillStates = playbookSkillStates;
44
- exports.classifyExtraEntries = classifyExtraEntries;
45
40
  exports.installedPlaybookCount = installedPlaybookCount;
46
41
  // @implements A-SPEC-190
47
42
  // @implements A-SPEC-142
@@ -64,190 +59,19 @@ const installer_markers_1 = require("../project/installer-markers");
64
59
  Object.defineProperty(exports, "PLAYBOOK_SKILL_MARKER", { enumerable: true, get: function () { return installer_markers_1.PLAYBOOK_SKILL_MARKER; } });
65
60
  Object.defineProperty(exports, "carriesMarker", { enumerable: true, get: function () { return installer_markers_1.carriesMarker; } });
66
61
  Object.defineProperty(exports, "frontmatterEnd", { enumerable: true, get: function () { return installer_markers_1.frontmatterEnd; } });
67
- /**
68
- * @implements A-SPEC-190 (round 7)
69
- * The bytes an install writes. The marker used to go FIRST, which put it ahead of the playbook's
70
- * YAML frontmatter — and frontmatter is only frontmatter when it starts at byte 0. Measured on this
71
- * repository's own installed skills: the agent's skill list rendered
72
- * `holmes-adopt: <!-- installed by holmes-kit; edits will be replaced on upgrade -->` for all three,
73
- * i.e. the `description` that quotes the deny text — the entire reason this layer exists, since a
74
- * refusal is supposed to summon the playbook by that sentence — was destroyed at install time,
75
- * while doctor certified the layout as `current`. The marker now follows the frontmatter block.
76
- */
77
- function installedSkillBytes(body) {
78
- const end = (0, installer_markers_1.frontmatterEnd)(body);
79
- if (end === null)
80
- return `${installer_markers_1.PLAYBOOK_SKILL_MARKER}\n${body}`;
81
- // The offset is computed on normalised text; a body with CRLF or a BOM is rewritten normalised so
82
- // the marker cannot land inside the frontmatter it must follow.
83
- const text = body.replace(/^\uFEFF/, '').replace(/\r\n/g, '\n');
84
- const head = text.slice(0, end);
85
- return `${head}${head.endsWith('\n') ? '' : '\n'}${installer_markers_1.PLAYBOOK_SKILL_MARKER}\n${text.slice(end)}`;
86
- }
87
- /**
88
- * @implements A-SPEC-172
89
- * What the user types to reach a playbook.
90
- *
91
- * The install directory is namespaced (`holmes-adopt`), but the internal playbook name is bare
92
- * (`adopt`), and every message echoed the bare one. Measured 2026-08-12 on an installed tarball: init
93
- * printed `Installed 3 recovery skill(s): adopt, author-slice, promote-slice` while nothing by those
94
- * names existed. Anything shown to a user goes through here.
95
- */
96
- function invocableSkillName(playbookName) {
97
- return `holmes-${playbookName}`;
98
- }
99
- /** `<target>/.claude/skills/holmes-<name>/SKILL.md` */
100
- function skillPathFor(target, playbookName) {
101
- return path.join(target, '.claude', 'skills', invocableSkillName(playbookName), 'SKILL.md');
102
- }
103
- function playbookNames(packageRoot) {
104
- const dir = path.join(packageRoot, 'playbooks');
105
- try {
106
- return fs.readdirSync(dir)
107
- // Presence by lstat, not existsSync (round-8): existsSync follows links and needs read
108
- // permission, so a DANGLING PLAYBOOK.md link or an unreadable playbook directory dropped the
109
- // name from the shipped list — and a currently-installed skill of that name then read as
110
- // `orphaned`, i.e. doctor told the operator to DELETE a skill the package still ships.
111
- // A damaged source is reported as damage (`source-unreadable`), never as an orphan.
112
- .filter((n) => { try {
113
- fs.lstatSync(path.join(dir, n, 'PLAYBOOK.md'));
114
- return true;
115
- }
116
- catch {
117
- return false;
118
- } })
119
- .sort();
120
- }
121
- catch {
122
- return []; // no playbooks directory: nothing to install, not an error
123
- }
124
- }
125
- const isOurs = (file) => {
126
- try {
127
- return (0, installer_markers_1.carriesMarker)(fs.readFileSync(file, 'utf8'));
128
- }
129
- catch {
130
- return false;
131
- }
132
- };
133
- /**
134
- * @implements A-SPEC-190 (round 8)
135
- * Which shipped names resolve to the SAME file as another (a link between skill directories, at file
136
- * or directory level). Shared by install and by the state report so both say the same thing.
137
- */
138
- function aliasGroupsOf(packageRoot, target) {
139
- const names = playbookNames(packageRoot);
140
- const realOf = (name) => {
141
- const dest = skillPathFor(target, name);
142
- try {
143
- return fs.realpathSync(dest);
144
- }
145
- catch { /* not yet materialised */ }
146
- try {
147
- return path.join(fs.realpathSync(path.dirname(dest)), path.basename(dest));
148
- }
149
- catch {
150
- return dest;
151
- }
152
- };
153
- // @implements A-SPEC-190 §10 (round 9) — identity is (dev, ino), not a path STRING. On a
154
- // case-insensitive filesystem (macOS default) `…/holmes-Adopt/SKILL.md` and `…/holmes-adopt/SKILL.md`
155
- // are one file with two spellings, so the string-keyed grouping saw two destinations and let one
156
- // playbook's body overwrite the other's — the exact harm the round-8 pre-scan was added to stop.
157
- const identity = (name) => {
158
- const real = realOf(name);
159
- // NTFS file IDs can exceed Number precision; rounded IDs alias unrelated files.
160
- try {
161
- const st = fs.statSync(real, { bigint: true });
162
- return `${st.dev}:${st.ino}`;
163
- }
164
- catch { /* not yet there */ }
165
- try {
166
- const st = fs.statSync(path.dirname(real), { bigint: true });
167
- return `${st.dev}:${st.ino}:${path.basename(real).toLowerCase()}`;
168
- }
169
- catch { /* dangling */ }
170
- // round-9: a DANGLING directory link resolves to nothing, so the old fallback compared path
171
- // STRINGS — two skills whose links point at one missing directory read as two destinations and
172
- // one playbook's body overwrote the other's, exit 0. Follow the link TEXTUALLY: where it points
173
- // is identity enough, even when nothing is there yet.
174
- const dest = skillPathFor(target, name);
175
- let dir = path.dirname(dest);
176
- for (let hop = 0; hop < 10; hop++) {
177
- try {
178
- if (!fs.lstatSync(dir).isSymbolicLink())
179
- break;
180
- dir = path.resolve(path.dirname(dir), fs.readlinkSync(dir));
181
- }
182
- catch {
183
- break;
184
- }
185
- }
186
- return path.join(dir, path.basename(dest)).toLowerCase();
187
- };
188
- const groups = new Map();
189
- for (const name of names) {
190
- const key = identity(name);
191
- const g = groups.get(key);
192
- if (g)
193
- g.push(name);
194
- else
195
- groups.set(key, [name]);
196
- }
197
- const out = new Map();
198
- for (const [, group] of groups) {
199
- if (group.length < 2)
200
- continue;
201
- for (const n of group)
202
- out.set(n, group.filter((o) => o !== n));
203
- }
204
- return out;
205
- }
206
- function aliasedNames(packageRoot, target) {
207
- return new Set(aliasGroupsOf(packageRoot, target).keys());
208
- }
209
- /**
210
- * The skills root, but only if it is genuinely INSIDE the target.
211
- *
212
- * @implements A-SPEC-190 §12 (round 11) — the link was refused at `.claude/skills` and at each skill
213
- * directory, and traversed one level ABOVE both: with `<target>/.claude` itself a link to a central
214
- * store, install wrote five shipped skills into someone else's tree and reported success, and
215
- * `--remove` then deleted marker-owned files there with `failed` empty. One containment question,
216
- * asked once, cannot be walked around by moving the link up a level. It also names the component
217
- * that is actually a link — the old wording blamed `.claude/skills` for `.claude`.
218
- */
219
- function skillsRootInside(target) {
220
- const dir = path.join(target, '.claude', 'skills');
221
- let base;
222
- try {
223
- base = fs.realpathSync(target);
224
- }
225
- catch {
226
- return { dir };
227
- } // 타깃이 없으면 상류가 답한다
228
- // @implements A-SPEC-193 §7 — 묻는 것은 "링크인가"가 아니라 "**타깃 밖으로 나가는가**"다.
229
- // 첫 판(§12)은 해소된 경로가 제자리와 다르기만 하면 거부했는데, 그것은 다중 에이전트의 표준
230
- // 배치를 통째로 막는다: 원본을 `.agents/skills` 에 두고 `.claude/skills` 를 그리로 링크하는
231
- // SSOT 는 타깃 **안**에 머문다(실측: 그 배치에서 written 0, 전 스킬 unresolvable). §12 가
232
- // 막으려던 해악은 타깃 밖 중앙 저장소의 파괴였고, 그 해악은 아래 검사로 그대로 막힌다.
233
- for (const rel of [path.join('.claude'), path.join('.claude', 'skills')]) {
234
- const at = path.join(target, rel);
235
- let real;
236
- try {
237
- real = fs.realpathSync(at);
238
- }
239
- catch {
240
- continue;
241
- } // 아직 없는 것은 여기서 만든다
242
- if (real !== base && !real.startsWith(base + path.sep)) {
243
- return { refusal: `${at} 가 타깃(${target}) 밖(${real})을 가리킵니다 — 링크 너머의 파일을 쓰거나 지우지 않았습니다. 링크를 풀거나 그 저장소에서 직접 다루십시오` };
244
- }
245
- }
246
- return { dir };
247
- }
62
+ // @implements A-SPEC-794.101 — the recovery-skill verdict lives below the cli layer so governance can call it too
63
+ const playbook_skill_states_1 = require("../project/playbook-skill-states");
64
+ Object.defineProperty(exports, "installedSkillBytes", { enumerable: true, get: function () { return playbook_skill_states_1.installedSkillBytes; } });
65
+ Object.defineProperty(exports, "invocableSkillName", { enumerable: true, get: function () { return playbook_skill_states_1.invocableSkillName; } });
66
+ Object.defineProperty(exports, "skillPathFor", { enumerable: true, get: function () { return playbook_skill_states_1.skillPathFor; } });
67
+ Object.defineProperty(exports, "playbookSkillStates", { enumerable: true, get: function () { return playbook_skill_states_1.playbookSkillStates; } });
68
+ Object.defineProperty(exports, "classifyExtraEntries", { enumerable: true, get: function () { return playbook_skill_states_1.classifyExtraEntries; } });
69
+ // @implements A-SPEC-794.110 — what a skill is judged against is decided in one place; the cli reaches it here
70
+ var playbook_reference_1 = require("../project/playbook-reference");
71
+ Object.defineProperty(exports, "judgedSkillStates", { enumerable: true, get: function () { return playbook_reference_1.judgedSkillStates; } });
248
72
  function installPlaybookSkills(packageRoot, target) {
249
73
  const out = { written: [], backedUp: [], skipped: [], failed: [] };
250
- const rootCheck = skillsRootInside(target);
74
+ const rootCheck = (0, playbook_skill_states_1.skillsRootInside)(target);
251
75
  if ('refusal' in rootCheck) {
252
76
  out.failed.push({ name: path.join('.claude', 'skills'), reason: rootCheck.refusal });
253
77
  return out;
@@ -257,10 +81,10 @@ function installPlaybookSkills(packageRoot, target) {
257
81
  // when the SECOND write arrived, by which time the first had already destroyed the other skill's
258
82
  // body — success reported, never converging. The aliases are computed BEFORE anything is written,
259
83
  // and every member of a colliding set is refused with the alias named.
260
- const names = playbookNames(packageRoot);
261
- const collidingWith0 = aliasGroupsOf(packageRoot, target);
84
+ const names = (0, playbook_skill_states_1.playbookNames)(packageRoot);
85
+ const collidingWith0 = (0, playbook_skill_states_1.aliasGroupsOf)(packageRoot, target);
262
86
  const realOf = (name) => {
263
- const dest = skillPathFor(target, name);
87
+ const dest = (0, playbook_skill_states_1.skillPathFor)(target, name);
264
88
  try {
265
89
  return fs.realpathSync(dest);
266
90
  }
@@ -277,13 +101,13 @@ function installPlaybookSkills(packageRoot, target) {
277
101
  for (const name of names) {
278
102
  const others = collidingWith.get(name);
279
103
  if (others) {
280
- out.failed.push({ name, reason: `${skillPathFor(target, name)} 와 ${others.map((o) => skillPathFor(target, o)).join(', ')} 가 같은 파일(${realOf(name)})로 해석됩니다 — 한쪽 본문이 다른 쪽을 덮어쓰지 않도록 아무것도 쓰지 않았습니다. 링크를 풀고 다시 실행하십시오` });
104
+ out.failed.push({ name, reason: `${(0, playbook_skill_states_1.skillPathFor)(target, name)} 와 ${others.map((o) => (0, playbook_skill_states_1.skillPathFor)(target, o)).join(', ')} 가 같은 파일(${realOf(name)})로 해석됩니다 — 한쪽 본문이 다른 쪽을 덮어쓰지 않도록 아무것도 쓰지 않았습니다. 링크를 풀고 다시 실행하십시오` });
281
105
  }
282
106
  }
283
107
  for (const name of names) {
284
108
  if (collidingWith.has(name))
285
109
  continue;
286
- const dest = skillPathFor(target, name);
110
+ const dest = (0, playbook_skill_states_1.skillPathFor)(target, name);
287
111
  try {
288
112
  // Presence by lstat, not existsSync: existsSync FOLLOWS symlinks, so a user's broken or
289
113
  // self-referential symlink read as "absent" and the shipped file was written over it —
@@ -302,7 +126,7 @@ function installPlaybookSkills(packageRoot, target) {
302
126
  return false;
303
127
  }
304
128
  })();
305
- if (present && !isOurs(dest)) {
129
+ if (present && !(0, playbook_skill_states_1.isOurs)(dest)) {
306
130
  out.skipped.push(name);
307
131
  continue;
308
132
  }
@@ -349,7 +173,7 @@ function installPlaybookSkills(packageRoot, target) {
349
173
  catch {
350
174
  return undefined;
351
175
  } })();
352
- const wanted = installedSkillBytes(body);
176
+ const wanted = (0, playbook_skill_states_1.installedSkillBytes)(body);
353
177
  if (prevBytes !== undefined && prevBytes.toString('utf8') !== wanted) {
354
178
  // round-9: beside the DESTINATION, never beside the link's far end. The rewrite follows a
355
179
  // user's symlink by design (§5g), but a file the kit CREATES belongs inside the target the
@@ -379,7 +203,7 @@ function installPlaybookSkills(packageRoot, target) {
379
203
  const suffix = `.holmes-bak-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
380
204
  const bak = [
381
205
  `${dest}${suffix}`,
382
- path.join(path.dirname(path.dirname(dest)), `${invocableSkillName(name)}.SKILL.md${suffix}`),
206
+ path.join(path.dirname(path.dirname(dest)), `${(0, playbook_skill_states_1.invocableSkillName)(name)}.SKILL.md${suffix}`),
383
207
  ].find(insideTarget);
384
208
  if (bak === undefined) {
385
209
  out.failed.push({ name, reason: `${dest} 의 이전 내용을 타깃(${target}) 안에 보존할 수 없어 다시 쓰지 않았습니다 — .claude/skills 가 타깃 밖을 가리키는 링크입니다. 링크를 풀거나 그 저장소에서 직접 갱신하십시오` });
@@ -390,7 +214,7 @@ function installPlaybookSkills(packageRoot, target) {
390
214
  out.backedUp.push({ name, path: bak });
391
215
  }
392
216
  catch (bakErr) {
393
- out.failed.push({ name, reason: `${skillPathFor(target, name)} 의 이전 내용을 보존할 수 없어 다시 쓰지 않았습니다: ${bakErr instanceof Error ? bakErr.message : String(bakErr)}` });
217
+ out.failed.push({ name, reason: `${(0, playbook_skill_states_1.skillPathFor)(target, name)} 의 이전 내용을 보존할 수 없어 다시 쓰지 않았습니다: ${bakErr instanceof Error ? bakErr.message : String(bakErr)}` });
394
218
  continue;
395
219
  }
396
220
  }
@@ -426,7 +250,7 @@ function installPlaybookSkills(packageRoot, target) {
426
250
  // a file that never existed by the time the operator read it — the reason now names the
427
251
  // destination they can actually inspect.
428
252
  const raw = err instanceof Error ? err.message : String(err);
429
- out.failed.push({ name, reason: `${skillPathFor(target, name)}: ${raw.replace(/\.holmes-tmp-\d+-[a-z0-9]+/g, '')}` });
253
+ out.failed.push({ name, reason: `${(0, playbook_skill_states_1.skillPathFor)(target, name)}: ${raw.replace(/\.holmes-tmp-\d+-[a-z0-9]+/g, '')}` });
430
254
  }
431
255
  }
432
256
  return out;
@@ -439,7 +263,7 @@ function removePlaybookSkills(target) {
439
263
  // `init --remove`, with `failed` empty and the report naming in-target paths nothing touched.
440
264
  // The same one physical link cannot be refused below and traversed above. §12 moved that question
441
265
  // one level further up, where `.claude` itself was the link.
442
- const rootCheck = skillsRootInside(target);
266
+ const rootCheck = (0, playbook_skill_states_1.skillsRootInside)(target);
443
267
  if ('refusal' in rootCheck) {
444
268
  out.failed.push({ name: path.join('.claude', 'skills'), reason: rootCheck.refusal });
445
269
  return out;
@@ -467,7 +291,7 @@ function removePlaybookSkills(target) {
467
291
  out.failed.push({ name: entry, reason: `${path.join(skillsDir, entry)} 는 심볼릭 링크입니다 — 링크 너머의 파일을 지우지 않았습니다. 링크를 직접 정리하십시오` });
468
292
  continue;
469
293
  }
470
- if (!fs.existsSync(file) || !isOurs(file))
294
+ if (!fs.existsSync(file) || !(0, playbook_skill_states_1.isOurs)(file))
471
295
  continue;
472
296
  fs.rmSync(file);
473
297
  // round-9: our own backups kept the directory alive, and no state named the leftovers — the
@@ -506,161 +330,14 @@ function removePlaybookSkills(target) {
506
330
  * already looks like a path is a path.
507
331
  */
508
332
  function skillLabel(name) {
509
- return name.includes('/') || name.includes('\\') ? name : invocableSkillName(name);
510
- }
511
- /**
512
- * @implements A-SPEC-190
513
- * Per-playbook state of the installed copy, judged against the bytes install would write NOW
514
- * (`marker + '\n' + shipped body`). An installed skill is a COPY: the kit's conventions move on
515
- * while the copy stays frozen at install time. Measured 2026-08-15 in this very repository: all
516
- * three installed skills had drifted (diff 50/38/64 lines) and the author-slice copy still taught
517
- * the abolished `A-SPEC-125.5 → T-SPEC-1255` id convention — while the count-only doctor check
518
- * reported "3 of 3 … PASS". Equality with the reconstruction is the single source of truth; a
519
- * version stamp or hash file would be a second truth that itself goes stale.
520
- *
521
- * A shipped body that cannot be read (a race — playbookNames just confirmed it) yields no entry
522
- * for that name: silence beats a wrong repair hint.
523
- */
524
- function playbookSkillStates(packageRoot, target) {
525
- const out = [];
526
- // @implements A-SPEC-190 §20 (round 13) — §12's fence went on install and remove, not on the
527
- // function DOCTOR judges from. So with `<target>/.claude` linked outside the target, doctor read
528
- // the files beyond the link, declared them drifted/missing, and prescribed `skills refresh` —
529
- // which §12 refuses every time. A diagnosis whose remedy can never run is worse than no
530
- // diagnosis: it teaches the operator to ignore the tool. Say the one thing that IS actionable.
531
- const fenced = skillsRootInside(target);
532
- if ('refusal' in fenced) {
533
- return playbookNames(packageRoot).map((name) => ({ name, state: 'unresolvable' }));
534
- }
535
- const shipped = playbookNames(packageRoot);
536
- for (const name of shipped) {
537
- let body;
538
- // @implements A-SPEC-190 (round 7) — an unreadable SHIPPED playbook used to `continue`, so the
539
- // name vanished from the report: doctor said PASS (or the nonsense '3 of 0') while the refresh
540
- // it never advised exited 1 on the same target. The package's own damage gets its own state.
541
- try {
542
- body = fs.readFileSync(path.join(packageRoot, 'playbooks', name, 'PLAYBOOK.md'), 'utf8');
543
- }
544
- catch {
545
- out.push({ name, state: 'source-unreadable' });
546
- continue;
547
- }
548
- const dest = skillPathFor(target, name);
549
- // @implements A-SPEC-190 (round 8) — two skills resolving to ONE file is a state, not just an
550
- // install-time failure: doctor used to call one of them `drifted` and advise a refresh that
551
- // could only ever exit 1. The operator has to unlink; say so.
552
- if (aliasedNames(packageRoot, target).has(name)) {
553
- out.push({ name, state: 'aliased' });
554
- continue;
555
- }
556
- let installed;
557
- try {
558
- installed = fs.readFileSync(dest, 'utf8');
559
- }
560
- catch (err) {
561
- // ENOENT alone is absence — but only when nothing occupies the path: readFileSync FOLLOWS
562
- // symlinks, so a BROKEN link also reads ENOENT while install's lstat sees it present and
563
- // skips it as foreign (round-3: doctor said 'missing', the advised refresh said 'yours' —
564
- // an unresolvable loop). Presence is judged the way install judges it: by lstat. Any other
565
- // read failure (EACCES, EISDIR, ELOOP…) means the marker cannot be read, and ownership is
566
- // decided by the marker — a file we cannot prove ours is not ours to repair.
567
- const lstatPresent = (() => {
568
- try {
569
- fs.lstatSync(dest);
570
- return true;
571
- }
572
- catch { /* fall through */ }
573
- // round-8: the SKILLS directory itself may be a dangling link. Reading through it is ENOENT
574
- // while install's mkdir/write is ENOENT too — the old 'missing' verdict advised a refresh
575
- // that could only ever fail, the exact non-convergent loop rounds 3 and 5 closed one level
576
- // deeper. Something occupies the path; it is not ours to repair.
577
- try {
578
- const skillsRoot = path.dirname(path.dirname(dest));
579
- if (fs.lstatSync(skillsRoot).isSymbolicLink() && !fs.existsSync(skillsRoot))
580
- return true;
581
- }
582
- catch { /* fall through */ }
583
- // The skill DIRECTORY itself may be a (possibly dangling) symlink the user manages —
584
- // read fails ENOENT through it while something clearly occupies the path (round-5:
585
- // 'missing' here + install's skip = another unresolvable remedy loop).
586
- try {
587
- return fs.lstatSync(path.dirname(dest)).isSymbolicLink();
588
- }
589
- catch {
590
- return false;
591
- }
592
- })();
593
- out.push({ name, state: err.code === 'ENOENT' && !lstatPresent ? 'missing' : 'foreign' });
594
- continue;
595
- }
596
- const state = !(0, installer_markers_1.carriesMarker)(installed) ? 'foreign'
597
- : installed === installedSkillBytes(body) ? 'current' : 'drifted';
598
- out.push({ name, state });
599
- }
600
- // Marker-owned installs of names we no longer ship are STALE GUIDANCE — exactly REQ-190's problem
601
- // class — yet the shipped loop above cannot see them. Markerless non-shipped entries are the
602
- // user's own skills and stay off our list entirely.
603
- const skillsDir = path.join(target, '.claude', 'skills');
604
- let entries;
605
- try {
606
- entries = fs.readdirSync(skillsDir);
607
- }
608
- catch {
609
- entries = [];
610
- }
611
- for (const entry of classifyExtraEntries(entries, shipped, (entry2, canonical) => {
612
- try {
613
- const a = fs.statSync(path.join(skillsDir, entry2), { bigint: true });
614
- const b = fs.statSync(path.join(skillsDir, canonical), { bigint: true });
615
- return a.ino === b.ino && a.dev === b.dev;
616
- }
617
- catch {
618
- return undefined;
619
- }
620
- }, (entry2) => isOurs(path.join(skillsDir, entry2, 'SKILL.md')))) {
621
- // The RAW directory name, case intact (round-6 HIGH): slicing the prefix folded
622
- // `Holmes-adopt` to `adopt`, doctor re-prefixed it to `holmes-adopt`, and the orphan remedy
623
- // told the operator to DELETE THE CURRENT SKILL on a case-sensitive FS.
624
- out.push({ name: entry, state: 'orphaned' });
625
- }
626
- return out;
627
- }
628
- /**
629
- * @implements A-SPEC-190 (§6)
630
- * Which extra `.claude/skills` entries are ORPHANED marker-owned installs? Pure — the fs facts
631
- * (inode identity, marker ownership) come in as functions, so the case-SENSITIVE world is testable
632
- * on any machine (round-5 HIGH lived exactly in the branch this box's case-folding FS cannot
633
- * exercise: `Holmes-adopt` sliced to `adopt`, matched shipped, and was swallowed BEFORE the
634
- * variant/inode logic — doctor printed PASS over stale marker-owned guidance).
635
- *
636
- * - exact canonical entries are the shipped loop's business (skip);
637
- * - a case-variant with the SAME inode is the same physical dir (case-insensitive FS — skip;
638
- * round-2: double-counting made the orphan remedy delete the current skill);
639
- * - everything else marker-owned is orphaned; unreadable/markerless stays silent (ownership is
640
- * the marker's job — user territory).
641
- */
642
- function classifyExtraEntries(entries, shipped, sameInode, owned) {
643
- const orphans = [];
644
- for (const entry of [...entries].sort()) {
645
- if (!entry.toLowerCase().startsWith('holmes-'))
646
- continue; // 'Holmes-adopt' is still ours to judge
647
- const name = entry.slice('holmes-'.length);
648
- if (entry.startsWith('holmes-') && shipped.includes(name))
649
- continue; // exact canonical only
650
- const variantOf = shipped.find((s) => `holmes-${s}`.toLowerCase() === entry.toLowerCase());
651
- if (variantOf && sameInode(entry, invocableSkillName(variantOf)) === true)
652
- continue;
653
- if (owned(entry))
654
- orphans.push(entry); // RAW entry — the name the operator must act on
655
- }
656
- return orphans;
333
+ return name.includes('/') || name.includes('\\') ? name : (0, playbook_skill_states_1.invocableSkillName)(name);
657
334
  }
658
335
  /** How many recovery skills are installed — the fact `doctor` reports. */
659
336
  function installedPlaybookCount(target) {
660
337
  const skillsDir = path.join(target, '.claude', 'skills');
661
338
  try {
662
339
  return fs.readdirSync(skillsDir)
663
- .filter((e) => e.toLowerCase().startsWith('holmes-') && isOurs(path.join(skillsDir, e, 'SKILL.md')))
340
+ .filter((e) => e.toLowerCase().startsWith('holmes-') && (0, playbook_skill_states_1.isOurs)(path.join(skillsDir, e, 'SKILL.md')))
664
341
  .length;
665
342
  }
666
343
  catch {
@@ -52,9 +52,13 @@ export interface AxConfig {
52
52
  * when absent, `off` when malformed — a ceiling must never fail toward wider.
53
53
  */
54
54
  /** @implements A-SPEC-792.28 — `shellStaging`: autonomous approval of governance staging; `on` when absent, `off` when malformed. */
55
+ /** @implements A-SPEC-794.86 — `specStaging`: the R1 row (sealed-spec staging without a person); `on` when absent, `off` otherwise. */
56
+ /** @implements A-SPEC-794.95 — `sealWindowHours`: how long a person's seal opens the gate files it names; 12 when absent or malformed, clamped to 1..24. */
55
57
  autonomy: {
56
58
  ceiling: AutonomyCeiling;
57
59
  shellStaging: 'on' | 'off';
60
+ specStaging: 'on' | 'off';
61
+ sealWindowHours?: number;
58
62
  };
59
63
  /**
60
64
  * @implements A-SPEC-778
@@ -66,6 +70,23 @@ export interface AxConfig {
66
70
  };
67
71
  /** @implements A-SPEC-781 — a run's stage machine: the stages, the allowed edges, and the stages that need review. */
68
72
  stages: StageMachine;
73
+ /**
74
+ * @implements A-SPEC-128.5 — directories test ecosystem detection never walks (vendored or reference trees). Empty when
75
+ * absent; anything that is not an array of strings declares nothing.
76
+ * @implements A-SPEC-128.7 — an entry holding `/` is a root-relative path prefix (`test/fixtures/pyproj`); one without is
77
+ * a directory name at any depth (`pyproj`). A leading `./` and a trailing `/` are ignored.
78
+ * @implements A-SPEC-128.13 — `prepare`: the argv a full run runs in HEAD's worktree before its units (`["npm", "run",
79
+ * "build"]`), no shell. Absent, or anything but a non-empty array of strings, declares none — no prepare is guessed.
80
+ */
81
+ testRun: {
82
+ excludeDirs: string[];
83
+ prepare?: string[];
84
+ linkWalk?: {
85
+ entries: number;
86
+ seconds: number;
87
+ };
88
+ pythonNames?: number;
89
+ };
69
90
  }
70
91
  /** @implements A-SPEC-781 */
71
92
  /** @implements A-SPEC-781.1 — `deny`: per stage, the classifier actions the gate refuses in a run at that stage. */
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DEFAULT_CONFIG = exports.RUN_APPROVAL_WAIT_DEFAULT = exports.RUN_REFUSAL_LIMIT_DEFAULT = exports.DEFAULT_STAGES = void 0;
37
37
  exports.loadConfig = loadConfig;
38
- // @implements A-SPEC-278, A-SPEC-781.2, A-SPEC-476.3
38
+ // @implements A-SPEC-794.95, A-SPEC-794.86, A-SPEC-278, A-SPEC-781.2, A-SPEC-476.3, A-SPEC-128.5, A-SPEC-128.7, A-SPEC-128.13
39
39
  // @implements A-SPEC-125.5
40
40
  // src/holmes/config/config.ts
41
41
  const fs = __importStar(require("node:fs"));
@@ -156,9 +156,10 @@ exports.DEFAULT_CONFIG = {
156
156
  storage: { specStore: 'local-markdown' },
157
157
  architecture: { cycleIgnore: [] },
158
158
  classification: { strict: false, testDirs: [] },
159
- autonomy: { ceiling: 'default', shellStaging: 'on' },
159
+ autonomy: { ceiling: 'default', shellStaging: 'on', specStaging: 'on', sealWindowHours: 12 },
160
160
  run: { refusalRepeatLimit: exports.RUN_REFUSAL_LIMIT_DEFAULT, approvalWaitMinutes: exports.RUN_APPROVAL_WAIT_DEFAULT },
161
161
  stages: structuredClone(exports.DEFAULT_STAGES),
162
+ testRun: { excludeDirs: [] },
162
163
  };
163
164
  function deepMerge(base, ov) {
164
165
  if (ov == null || typeof ov !== 'object')
@@ -204,6 +205,13 @@ function loadConfig(root) {
204
205
  ceiling: CEILINGS.includes(declaredCeiling) ? declaredCeiling : 'off',
205
206
  // @implements A-SPEC-792.28 — absent is on; anything present but "on" is off (never fails toward wider)
206
207
  shellStaging: declaredStaging === undefined || declaredStaging === 'on' ? 'on' : 'off',
208
+ // @implements A-SPEC-794.86 — the R1 row: absent is on (owner decision Q4(a), 11/10); anything else is off
209
+ specStaging: (() => { const d = auto !== null && typeof auto === 'object' ? auto.specStaging : undefined; return d === undefined || d === 'on' ? 'on' : 'off'; })(),
210
+ // @implements A-SPEC-794.95 — the seal window: a finite number clamped to 1..24, anything else 12
211
+ sealWindowHours: (() => {
212
+ const d = auto !== null && typeof auto === 'object' ? auto.sealWindowHours : undefined;
213
+ return typeof d === 'number' && Number.isFinite(d) ? Math.min(24, Math.max(1, d)) : 12;
214
+ })(),
207
215
  };
208
216
  // @implements A-SPEC-778 — only an integer from 1 to 1000 is a limit.
209
217
  const runCfg = merged.run;
@@ -223,11 +231,22 @@ function loadConfig(root) {
223
231
  declaredStages = undefined;
224
232
  }
225
233
  merged.stages = stageMachineOf(declaredStages);
234
+ // @implements A-SPEC-128.5 — an exclusion list never fails toward wider: only an array of strings excludes anything
235
+ const tr = merged.testRun;
236
+ const ex = tr !== null && typeof tr === 'object' ? tr.excludeDirs : undefined;
237
+ const prep = tr !== null && typeof tr === 'object' ? tr.prepare : undefined;
238
+ const prepare = Array.isArray(prep) && prep.length > 0 && prep.every((x) => typeof x === 'string' && x !== '') ? prep : undefined;
239
+ // @implements A-SPEC-128.16 — W1: linkWalk survives the rebuild when both are positive finite numbers (review A M1)
240
+ const lw = tr !== null && typeof tr === 'object' ? tr.linkWalk : undefined;
241
+ const ok = (n) => typeof n === 'number' && Number.isFinite(n) && n > 0;
242
+ const linkWalk = lw && typeof lw === 'object' && ok(lw.entries) && ok(lw.seconds) ? { entries: lw.entries, seconds: lw.seconds } : undefined;
243
+ merged.testRun = { excludeDirs: Array.isArray(ex) ? ex.filter((x) => typeof x === 'string' && x !== '') : [], ...(prepare ? { prepare } : {}), ...(linkWalk ? { linkWalk } : {}),
244
+ ...(Number.isInteger(tr?.pythonNames) && (tr.pythonNames) > 0 ? { pythonNames: tr.pythonNames } : {}) };
226
245
  return merged;
227
246
  }
228
247
  catch {
229
248
  // @implements A-SPEC-476.3 — the defaults carry the widest ceiling, so a broken file raised it; it reads `off`, as a
230
249
  // malformed ceiling already does (A-SPEC-532.6: a ceiling never fails toward wider).
231
- return { ...structuredClone(exports.DEFAULT_CONFIG), autonomy: { ceiling: 'off', shellStaging: 'off' } };
250
+ return { ...structuredClone(exports.DEFAULT_CONFIG), autonomy: { ceiling: 'off', shellStaging: 'off', specStaging: 'off' } }; // A-SPEC-794.86: closed too
232
251
  }
233
252
  }