@holmes-lab/holmes-kit 0.40.1 → 0.41.1

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 (88) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +12 -4
  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 +371 -250
  10. package/dist/holmes/cli/init.js +26 -6
  11. package/dist/holmes/cli/ledger-witness.d.ts +61 -0
  12. package/dist/holmes/cli/ledger-witness.js +252 -0
  13. package/dist/holmes/cli/playbook-skills.d.ts +3 -56
  14. package/dist/holmes/cli/playbook-skills.js +63 -354
  15. package/dist/holmes/cli/test-platform.d.ts +6 -0
  16. package/dist/holmes/cli/test-platform.js +12 -0
  17. package/dist/holmes/config/config.d.ts +9 -1
  18. package/dist/holmes/config/config.js +10 -3
  19. package/dist/holmes/governance/approval-grants.d.ts +2 -0
  20. package/dist/holmes/governance/approval-grants.js +6 -5
  21. package/dist/holmes/governance/approval-queue.d.ts +65 -1
  22. package/dist/holmes/governance/approval-queue.js +279 -9
  23. package/dist/holmes/governance/autonomous-shell.d.ts +13 -1
  24. package/dist/holmes/governance/autonomous-shell.js +157 -4
  25. package/dist/holmes/governance/autonomy.d.ts +209 -0
  26. package/dist/holmes/governance/autonomy.js +1129 -6
  27. package/dist/holmes/governance/install-manifest.d.ts +7 -4
  28. package/dist/holmes/governance/install-manifest.js +159 -15
  29. package/dist/holmes/governance/ledger-witness.d.ts +63 -0
  30. package/dist/holmes/governance/ledger-witness.js +296 -0
  31. package/dist/holmes/governance/provenance-chain.d.ts +8 -1
  32. package/dist/holmes/governance/provenance-chain.js +23 -4
  33. package/dist/holmes/governance/recorded-pairs.d.ts +4 -0
  34. package/dist/holmes/governance/recorded-pairs.js +25 -1
  35. package/dist/holmes/governance/session-context.d.ts +7 -0
  36. package/dist/holmes/governance/session-context.js +34 -6
  37. package/dist/holmes/guardrail/anchor-scope-text.d.ts +9 -0
  38. package/dist/holmes/guardrail/anchor-scope-text.js +7 -0
  39. package/dist/holmes/guardrail/command-traits.d.ts +102 -0
  40. package/dist/holmes/guardrail/command-traits.js +379 -0
  41. package/dist/holmes/guardrail/fixtures/manager-builtins.json +23 -0
  42. package/dist/holmes/guardrail/fixtures/npm-commands.json +7 -0
  43. package/dist/holmes/guardrail/outward-acts.d.ts +47 -0
  44. package/dist/holmes/guardrail/outward-acts.js +1102 -0
  45. package/dist/holmes/guardrail/refusal-codes.js +8 -1
  46. package/dist/holmes/guardrail/refusal-templates.d.ts +15 -0
  47. package/dist/holmes/guardrail/refusal-templates.js +71 -0
  48. package/dist/holmes/guardrail/risk-classifier.d.ts +22 -6
  49. package/dist/holmes/guardrail/risk-classifier.js +12 -118
  50. package/dist/holmes/guardrail/shell-lexer.d.ts +69 -0
  51. package/dist/holmes/guardrail/shell-lexer.js +567 -0
  52. package/dist/holmes/guardrail/write-target.js +7 -1
  53. package/dist/holmes/hooks/pre-tool-use.d.ts +60 -0
  54. package/dist/holmes/hooks/pre-tool-use.js +1423 -10
  55. package/dist/holmes/hooks/session-start.js +11 -1
  56. package/dist/holmes/hooks/stop.d.ts +7 -0
  57. package/dist/holmes/hooks/stop.js +39 -2
  58. package/dist/holmes/mcp/elicit-approval.d.ts +0 -21
  59. package/dist/holmes/mcp/elicit-approval.js +5 -2
  60. package/dist/holmes/mcp/handlers/approval-ask.js +3 -2
  61. package/dist/holmes/mcp/handlers/entity-integration.d.ts +1 -1
  62. package/dist/holmes/mcp/handlers/entity-integration.js +9 -6
  63. package/dist/holmes/mcp/handlers/entity-renumber.js +2 -1
  64. package/dist/holmes/mcp/handlers/entity-store.js +7 -2
  65. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -0
  66. package/dist/holmes/mcp/handlers/operator-inspection.js +25 -4
  67. package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -1
  68. package/dist/holmes/mcp/handlers/spec-approval.js +28 -10
  69. package/dist/holmes/mcp/handlers/spec-lifecycle.js +10 -7
  70. package/dist/holmes/mcp/handlers/test-execution.d.ts +6 -0
  71. package/dist/holmes/mcp/handlers/test-execution.js +37 -9
  72. package/dist/holmes/mcp/handlers.d.ts +5 -5
  73. package/dist/holmes/mcp/handlers.js +2 -1
  74. package/dist/holmes/mcp/tool-schemas.js +4 -4
  75. package/dist/holmes/project/playbook-reference.d.ts +50 -0
  76. package/dist/holmes/project/playbook-reference.js +259 -0
  77. package/dist/holmes/project/playbook-skill-states.d.ts +94 -0
  78. package/dist/holmes/project/playbook-skill-states.js +396 -0
  79. package/dist/holmes/project/root.d.ts +9 -1
  80. package/dist/holmes/project/root.js +23 -2
  81. package/dist/holmes/project/running-package.d.ts +15 -0
  82. package/dist/holmes/project/running-package.js +87 -0
  83. package/dist/holmes/review/head-worktree.js +9 -1
  84. package/dist/holmes/review/test-runner.d.ts +2 -0
  85. package/dist/holmes/review/test-runner.js +38 -11
  86. package/dist/holmes/spec/entity-integration-transaction.d.ts +19 -2
  87. package/dist/holmes/spec/entity-integration-transaction.js +68 -7
  88. package/package.json +5 -2
@@ -33,17 +33,12 @@ 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
- // @implements A-SPEC-190
41
+ // @implements A-SPEC-190, A-SPEC-794.126, A-SPEC-794.129
47
42
  // @implements A-SPEC-142
48
43
  const fs = __importStar(require("node:fs"));
49
44
  const path = __importStar(require("node:path"));
@@ -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
@@ -376,13 +200,45 @@ function installPlaybookSkills(packageRoot, target) {
376
200
  return false;
377
201
  }
378
202
  };
203
+ // @implements A-SPEC-794.126 — the backup is kept under the target's .ax/state (git-ignored by init's block, outside
204
+ // every root principle 7 watches, never in the install manifest), not beside the skill under .claude: a file there
205
+ // is one the gate counts, and leaving the gate an exception for it was a relaxation (0.41.1 review H1)
379
206
  const suffix = `.holmes-bak-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
380
- const bak = [
381
- `${dest}${suffix}`,
382
- path.join(path.dirname(path.dirname(dest)), `${invocableSkillName(name)}.SKILL.md${suffix}`),
383
- ].find(insideTarget);
207
+ const bakDir = path.join(target, '.ax', 'state', 'skill-backups', (0, playbook_skill_states_1.invocableSkillName)(name));
208
+ // nothing is created until the nearest existing ancestor of the directory resolves inside the target: a linked
209
+ // .ax/state must not receive even an empty directory
210
+ const nearest = (() => { let d = bakDir; while (!fs.existsSync(d) && path.dirname(d) !== d)
211
+ d = path.dirname(d); return d; })();
212
+ // @implements A-SPEC-794.129 (review C-L2) — no component of the path below the target may be a link, even one
213
+ // that resolves inside the target
214
+ const linkOnPath = (() => {
215
+ let d = target;
216
+ for (const part of path.relative(target, bakDir).split(path.sep)) {
217
+ d = path.join(d, part);
218
+ try {
219
+ if (fs.lstatSync(d).isSymbolicLink())
220
+ return d;
221
+ }
222
+ catch {
223
+ return null;
224
+ } // [no-substitution: absent from here on → created below as plain directories]
225
+ }
226
+ return null;
227
+ })();
228
+ if (linkOnPath !== null) {
229
+ out.failed.push({ name, reason: `${dest} 의 이전 내용을 보존할 수 없어 다시 쓰지 않았습니다 — ${linkOnPath} is a link — a backup is not written through a link. 링크를 풀고 다시 실행하십시오` });
230
+ continue;
231
+ }
232
+ const contained = insideTarget(path.join(nearest, 'x'));
233
+ if (contained) {
234
+ try {
235
+ fs.mkdirSync(bakDir, { recursive: true });
236
+ }
237
+ catch { /* [no-substitution: the containment check below refuses it] */ }
238
+ }
239
+ const bak = contained ? [path.join(bakDir, `SKILL.md${suffix}`)].find(insideTarget) : undefined;
384
240
  if (bak === undefined) {
385
- out.failed.push({ name, reason: `${dest} 의 이전 내용을 타깃(${target}) 안에 보존할 수 없어 다시 쓰지 않았습니다 — .claude/skills 가 타깃 밖을 가리키는 링크입니다. 링크를 풀거나 그 저장소에서 직접 갱신하십시오` });
241
+ out.failed.push({ name, reason: `${dest} 의 이전 내용을 타깃(${target}) 안에 보존할 수 없어 다시 쓰지 않았습니다 — ${path.join(target, '.ax', 'state')} 가 타깃 밖을 가리키는 링크이거나 만들 수 없습니다. 링크를 풀고 다시 실행하십시오` });
386
242
  continue;
387
243
  }
388
244
  try {
@@ -390,7 +246,7 @@ function installPlaybookSkills(packageRoot, target) {
390
246
  out.backedUp.push({ name, path: bak });
391
247
  }
392
248
  catch (bakErr) {
393
- out.failed.push({ name, reason: `${skillPathFor(target, name)} 의 이전 내용을 보존할 수 없어 다시 쓰지 않았습니다: ${bakErr instanceof Error ? bakErr.message : String(bakErr)}` });
249
+ out.failed.push({ name, reason: `${(0, playbook_skill_states_1.skillPathFor)(target, name)} 의 이전 내용을 보존할 수 없어 다시 쓰지 않았습니다: ${bakErr instanceof Error ? bakErr.message : String(bakErr)}` });
394
250
  continue;
395
251
  }
396
252
  }
@@ -426,7 +282,7 @@ function installPlaybookSkills(packageRoot, target) {
426
282
  // a file that never existed by the time the operator read it — the reason now names the
427
283
  // destination they can actually inspect.
428
284
  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, '')}` });
285
+ out.failed.push({ name, reason: `${(0, playbook_skill_states_1.skillPathFor)(target, name)}: ${raw.replace(/\.holmes-tmp-\d+-[a-z0-9]+/g, '')}` });
430
286
  }
431
287
  }
432
288
  return out;
@@ -439,7 +295,7 @@ function removePlaybookSkills(target) {
439
295
  // `init --remove`, with `failed` empty and the report naming in-target paths nothing touched.
440
296
  // The same one physical link cannot be refused below and traversed above. §12 moved that question
441
297
  // one level further up, where `.claude` itself was the link.
442
- const rootCheck = skillsRootInside(target);
298
+ const rootCheck = (0, playbook_skill_states_1.skillsRootInside)(target);
443
299
  if ('refusal' in rootCheck) {
444
300
  out.failed.push({ name: path.join('.claude', 'skills'), reason: rootCheck.refusal });
445
301
  return out;
@@ -467,7 +323,7 @@ function removePlaybookSkills(target) {
467
323
  out.failed.push({ name: entry, reason: `${path.join(skillsDir, entry)} 는 심볼릭 링크입니다 — 링크 너머의 파일을 지우지 않았습니다. 링크를 직접 정리하십시오` });
468
324
  continue;
469
325
  }
470
- if (!fs.existsSync(file) || !isOurs(file))
326
+ if (!fs.existsSync(file) || !(0, playbook_skill_states_1.isOurs)(file))
471
327
  continue;
472
328
  fs.rmSync(file);
473
329
  // round-9: our own backups kept the directory alive, and no state named the leftovers — the
@@ -506,161 +362,14 @@ function removePlaybookSkills(target) {
506
362
  * already looks like a path is a path.
507
363
  */
508
364
  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;
365
+ return name.includes('/') || name.includes('\\') ? name : (0, playbook_skill_states_1.invocableSkillName)(name);
657
366
  }
658
367
  /** How many recovery skills are installed — the fact `doctor` reports. */
659
368
  function installedPlaybookCount(target) {
660
369
  const skillsDir = path.join(target, '.claude', 'skills');
661
370
  try {
662
371
  return fs.readdirSync(skillsDir)
663
- .filter((e) => e.toLowerCase().startsWith('holmes-') && isOurs(path.join(skillsDir, e, 'SKILL.md')))
372
+ .filter((e) => e.toLowerCase().startsWith('holmes-') && (0, playbook_skill_states_1.isOurs)(path.join(skillsDir, e, 'SKILL.md')))
664
373
  .length;
665
374
  }
666
375
  catch {
@@ -76,3 +76,9 @@ export declare function removeWhenReleased(dir: string, ms?: number, remove?: (d
76
76
  * in the report is the honest form. `reason` is required for the same reason it is required there.
77
77
  */
78
78
  export declare function win32Only(reason: string, platform?: string): typeof it | typeof it.skip;
79
+ /**
80
+ * @implements A-SPEC-794.124 — as `win32Only`, for a fact of darwin's own tools: its /bin/sh execs a lone `-c` command,
81
+ * which another platform's /bin/sh may not. Elsewhere the case is a reported skip with its reason, never a body that
82
+ * returns early and counts as a pass (A-SPEC-220.3).
83
+ */
84
+ export declare function darwinOnly(reason: string, platform?: string): typeof it | typeof it.skip;
@@ -40,6 +40,7 @@ exports.posixOnlyWithCommand = posixOnlyWithCommand;
40
40
  exports.bashWord = bashWord;
41
41
  exports.removeWhenReleased = removeWhenReleased;
42
42
  exports.win32Only = win32Only;
43
+ exports.darwinOnly = darwinOnly;
43
44
  const fs = __importStar(require("node:fs"));
44
45
  const path = __importStar(require("node:path"));
45
46
  const node_crypto_1 = require("node:crypto");
@@ -191,3 +192,14 @@ function win32Only(reason, platform = process.platform) {
191
192
  }
192
193
  return platform === 'win32' ? it : it.skip;
193
194
  }
195
+ /**
196
+ * @implements A-SPEC-794.124 — as `win32Only`, for a fact of darwin's own tools: its /bin/sh execs a lone `-c` command,
197
+ * which another platform's /bin/sh may not. Elsewhere the case is a reported skip with its reason, never a body that
198
+ * returns early and counts as a pass (A-SPEC-220.3).
199
+ */
200
+ function darwinOnly(reason, platform = process.platform) {
201
+ if (typeof reason !== 'string' || reason.trim().length === 0) {
202
+ throw new Error('darwinOnly(reason): 사유 없는 스킵은 문법만 바뀐 침묵입니다 — 왜 이 단언이 darwin 밖에서 무의미한지 적으십시오.');
203
+ }
204
+ return platform === 'darwin' ? it : it.skip;
205
+ }
@@ -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
@@ -72,7 +76,11 @@ export interface AxConfig {
72
76
  * @implements A-SPEC-128.7 — an entry holding `/` is a root-relative path prefix (`test/fixtures/pyproj`); one without is
73
77
  * a directory name at any depth (`pyproj`). A leading `./` and a trailing `/` are ignored.
74
78
  * @implements A-SPEC-128.13 — `prepare`: the argv a full run runs in HEAD's worktree before its units (`["npm", "run",
75
- * "build"]`), no shell. Absent, or anything but a non-empty array of strings, declares none — no prepare is guessed.
79
+ * "build"]`), no shell. No prepare is guessed.
80
+ * @implements A-SPEC-794.128 — the contract, as A-SPEC-794.123 and 794.128 replace 128.13's clause: `prepare` absent,
81
+ * `[]` or `null` declares none; any other value that is not a non-empty array of non-empty strings makes a full run fail
82
+ * with the reason. Here the parsed config only drops a malformed value; the full run reads HEAD's file itself
83
+ * (test-execution.ts declaredPrepare), which is where the failure is decided.
76
84
  */
77
85
  testRun: {
78
86
  excludeDirs: string[];
@@ -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, A-SPEC-128.5, A-SPEC-128.7, A-SPEC-128.13
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,7 +156,7 @@ 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
162
  testRun: { excludeDirs: [] },
@@ -205,6 +205,13 @@ function loadConfig(root) {
205
205
  ceiling: CEILINGS.includes(declaredCeiling) ? declaredCeiling : 'off',
206
206
  // @implements A-SPEC-792.28 — absent is on; anything present but "on" is off (never fails toward wider)
207
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
+ })(),
208
215
  };
209
216
  // @implements A-SPEC-778 — only an integer from 1 to 1000 is a limit.
210
217
  const runCfg = merged.run;
@@ -240,6 +247,6 @@ function loadConfig(root) {
240
247
  catch {
241
248
  // @implements A-SPEC-476.3 — the defaults carry the widest ceiling, so a broken file raised it; it reads `off`, as a
242
249
  // malformed ceiling already does (A-SPEC-532.6: a ceiling never fails toward wider).
243
- 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
244
251
  }
245
252
  }
@@ -294,6 +294,8 @@ export declare class GrantSpendRefusal extends Error {
294
294
  * `spendGrants`, which removes them after the act.
295
295
  */
296
296
  export declare function spendGrantApprovals(root: string, approvals: readonly Approval[], what: string, rationale?: string): void;
297
+ /** @implements A-SPEC-794.127 — exported: the vouching form reads a session-form vouch's spend row by this one prefix. */
298
+ export declare const GRANT_SPEND_SUMMARY = "consumed approval grant for: ";
297
299
  /**
298
300
  * @implements A-SPEC-245.9 (1b-1) — the store's beforePublish (A-SPEC-245.14) for an act a grant authorized: undefined
299
301
  * when no grant authorized it (an env approval runs as before).