@holmes-lab/holmes-kit 0.29.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.
- package/CHANGELOG.md +556 -0
- package/README.md +15 -5
- package/bin/holmes-hook-antigravity.js +4 -0
- package/bin/holmes-kit.js +4 -0
- package/bin/holmes-pre-push.js +3 -0
- package/bin/holmes-stop-antigravity.js +4 -0
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/agents-guidance-history.d.ts +1 -1
- package/dist/holmes/cli/agents-guidance-history.js +11 -2
- package/dist/holmes/cli/agents-guidance.d.ts +1 -0
- package/dist/holmes/cli/agents-guidance.js +11 -8
- package/dist/holmes/cli/agents.d.ts +41 -0
- package/dist/holmes/cli/agents.js +382 -2
- package/dist/holmes/cli/attest.d.ts +2 -0
- package/dist/holmes/cli/attest.js +66 -15
- package/dist/holmes/cli/ci-gate.js +16 -1
- package/dist/holmes/cli/claude-switches.d.ts +95 -0
- package/dist/holmes/cli/claude-switches.js +967 -0
- package/dist/holmes/cli/codex-hooks.d.ts +77 -0
- package/dist/holmes/cli/codex-hooks.js +802 -0
- package/dist/holmes/cli/codex-oracle.d.ts +194 -0
- package/dist/holmes/cli/codex-oracle.js +1245 -0
- package/dist/holmes/cli/codex-toml.d.ts +58 -1
- package/dist/holmes/cli/codex-toml.js +456 -40
- package/dist/holmes/cli/doctor.d.ts +108 -8
- package/dist/holmes/cli/doctor.js +1408 -98
- package/dist/holmes/cli/index.js +23 -11
- package/dist/holmes/cli/init.d.ts +13 -0
- package/dist/holmes/cli/init.js +749 -77
- package/dist/holmes/cli/interactive-prompt.js +2 -2
- package/dist/holmes/cli/mcp-launcher.d.ts +64 -6
- package/dist/holmes/cli/mcp-launcher.js +189 -6
- package/dist/holmes/cli/mcp-version.js +13 -2
- package/dist/holmes/cli/settings-merge.js +8 -2
- package/dist/holmes/cli/upgrade.d.ts +13 -0
- package/dist/holmes/cli/upgrade.js +116 -23
- package/dist/holmes/cli/workspace-scope.d.ts +22 -0
- package/dist/holmes/cli/workspace-scope.js +375 -0
- package/dist/holmes/cli/worktree-readiness.d.ts +1 -0
- package/dist/holmes/cli/worktree-readiness.js +17 -3
- package/dist/holmes/cpg/cpg-scanner.d.ts +29 -0
- package/dist/holmes/cpg/cpg-scanner.js +403 -3
- package/dist/holmes/cpg/cycle-detect.js +2 -1
- package/dist/holmes/cpg/forbidden-edges.js +9 -2
- package/dist/holmes/cpg/required-calls.js +8 -1
- package/dist/holmes/governance/autonomy.d.ts +9 -0
- package/dist/holmes/governance/autonomy.js +28 -1
- package/dist/holmes/governance/constitution-debt.js +3 -2
- package/dist/holmes/governance/constitution.js +15 -3
- package/dist/holmes/governance/provenance-chain.js +3 -2
- package/dist/holmes/governance/push-gate-runner.js +4 -3
- package/dist/holmes/guardrail/dependency-delta.js +4 -3
- package/dist/holmes/guardrail/linear-match.d.ts +57 -0
- package/dist/holmes/guardrail/linear-match.js +256 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +6 -7
- package/dist/holmes/guardrail/risk-classifier.js +931 -44
- package/dist/holmes/guardrail/risk-types.d.ts +6 -0
- package/dist/holmes/guardrail/scope-judgment.d.ts +4 -24
- package/dist/holmes/guardrail/scope-judgment.js +100 -23
- package/dist/holmes/guardrail/shell-words.d.ts +42 -0
- package/dist/holmes/guardrail/shell-words.js +1720 -0
- package/dist/holmes/guardrail/write-target.d.ts +168 -3
- package/dist/holmes/guardrail/write-target.js +2379 -87
- package/dist/holmes/hooks/adapters/antigravity.d.ts +3 -1
- package/dist/holmes/hooks/adapters/antigravity.js +115 -11
- package/dist/holmes/hooks/pre-tool-use.d.ts +32 -6
- package/dist/holmes/hooks/pre-tool-use.js +923 -87
- package/dist/holmes/hooks/rtm-refresh-child.d.ts +22 -1
- package/dist/holmes/hooks/rtm-refresh-child.js +102 -18
- package/dist/holmes/hooks/rtm-refresh.d.ts +20 -1
- package/dist/holmes/hooks/rtm-refresh.js +60 -15
- package/dist/holmes/hooks/session-start.d.ts +10 -0
- package/dist/holmes/hooks/session-start.js +31 -7
- package/dist/holmes/hooks/stop.d.ts +2 -1
- package/dist/holmes/hooks/stop.js +197 -91
- package/dist/holmes/mcp/approval-adapters.d.ts +22 -0
- package/dist/holmes/mcp/approval-adapters.js +21 -0
- package/dist/holmes/mcp/approval-commit.d.ts +20 -0
- package/dist/holmes/mcp/approval-commit.js +108 -0
- package/dist/holmes/mcp/approval-intent.d.ts +44 -0
- package/dist/holmes/mcp/approval-intent.js +67 -0
- package/dist/holmes/mcp/approval-policy.d.ts +14 -0
- package/dist/holmes/mcp/approval-policy.js +18 -0
- package/dist/holmes/mcp/elicit-approval.d.ts +2 -0
- package/dist/holmes/mcp/elicit-approval.js +8 -3
- package/dist/holmes/mcp/handlers/graph-operations.d.ts +17 -1
- package/dist/holmes/mcp/handlers/graph-operations.js +15 -6
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +11 -5
- package/dist/holmes/mcp/handlers/maintenance-evidence.js +3 -2
- package/dist/holmes/mcp/handlers/phase-queries.d.ts +22 -7
- package/dist/holmes/mcp/handlers/phase-queries.js +81 -2
- package/dist/holmes/mcp/handlers/requirement-triage.d.ts +26 -0
- package/dist/holmes/mcp/handlers/requirement-triage.js +48 -11
- package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -1
- package/dist/holmes/mcp/handlers/review-evidence.js +15 -5
- package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +18 -0
- package/dist/holmes/mcp/handlers/slice-orchestration.js +122 -16
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +35 -2
- package/dist/holmes/mcp/handlers/spec-approval.js +175 -57
- package/dist/holmes/mcp/handlers/spec-authoring.js +36 -3
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +39 -3
- package/dist/holmes/mcp/handlers/spec-queries.js +114 -7
- package/dist/holmes/mcp/handlers/test-execution.js +9 -3
- package/dist/holmes/mcp/handlers.d.ts +126 -8
- package/dist/holmes/mcp/handlers.js +109 -18
- package/dist/holmes/mcp/harness-attestation.d.ts +20 -0
- package/dist/holmes/mcp/harness-attestation.js +179 -0
- package/dist/holmes/mcp/maintenance-analyze.js +28 -4
- package/dist/holmes/mcp/maintenance-evidence.js +1 -1
- package/dist/holmes/mcp/requirement-triage-evidence.d.ts +72 -2
- package/dist/holmes/mcp/requirement-triage-evidence.js +227 -1
- package/dist/holmes/mcp/server.js +24 -3
- package/dist/holmes/mcp/supervisor.js +7 -3
- package/dist/holmes/mcp/tool-schemas.d.ts +8 -0
- package/dist/holmes/mcp/tool-schemas.js +54 -7
- package/dist/holmes/mcp/validate-args.js +12 -0
- package/dist/holmes/project/bounded-io.d.ts +102 -0
- package/dist/holmes/project/bounded-io.js +212 -0
- package/dist/holmes/project/change-source.js +3 -1
- package/dist/holmes/project/ci-runs.js +3 -2
- package/dist/holmes/project/ignore.d.ts +31 -2
- package/dist/holmes/project/ignore.js +409 -50
- package/dist/holmes/project/regular-file-guard.d.ts +13 -0
- package/dist/holmes/project/regular-file-guard.js +149 -0
- package/dist/holmes/project/root.js +12 -3
- package/dist/holmes/refresh/freshness-coordinator.d.ts +67 -0
- package/dist/holmes/refresh/freshness-coordinator.js +230 -0
- package/dist/holmes/reverse/anchor.js +4 -3
- package/dist/holmes/reverse/scan.js +6 -2
- package/dist/holmes/review/commit-text.js +3 -2
- package/dist/holmes/review/condition-hunk-replay.d.ts +12 -0
- package/dist/holmes/review/condition-hunk-replay.js +13 -2
- package/dist/holmes/review/condition-hunk-resolution.js +59 -8
- package/dist/holmes/review/failed-test-names.js +13 -10
- package/dist/holmes/review/findings.js +3 -1
- package/dist/holmes/review/kills-check.js +6 -1
- package/dist/holmes/review/point-in-time-replay.js +5 -4
- package/dist/holmes/review/replay-corpus.js +5 -4
- package/dist/holmes/review/requirement-triage-human-records.d.ts +59 -0
- package/dist/holmes/review/requirement-triage-human-records.js +119 -0
- package/dist/holmes/review/run-replay.js +3 -2
- package/dist/holmes/review/scope.js +6 -1
- package/dist/holmes/review/temporal-prior.js +3 -2
- package/dist/holmes/review/test-evidence.js +3 -2
- package/dist/holmes/review/test-outcomes.d.ts +28 -0
- package/dist/holmes/review/test-outcomes.js +92 -2
- package/dist/holmes/review/test-runner.d.ts +6 -0
- package/dist/holmes/review/test-runner.js +36 -15
- package/dist/holmes/rtm/advisory-outcomes.js +3 -2
- package/dist/holmes/rtm/anchor-ids.js +42 -2
- package/dist/holmes/rtm/file-anchors.js +4 -1
- package/dist/holmes/rtm/ftt-fulfilment.js +8 -3
- package/dist/holmes/rtm/git-changes.js +3 -1
- package/dist/holmes/rtm/graph-store.js +3 -2
- package/dist/holmes/rtm/test-scope.js +9 -4
- package/dist/holmes/spec/compat-impact.d.ts +25 -4
- package/dist/holmes/spec/compat-impact.js +682 -11
- package/dist/holmes/spec/entity-git-snapshot.js +3 -2
- package/dist/holmes/spec/entity-integration.js +3 -2
- package/dist/holmes/spec/entity-renumber-transaction.d.ts +19 -0
- package/dist/holmes/spec/entity-renumber-transaction.js +79 -6
- package/dist/holmes/spec/remote-spec-refs.js +3 -2
- package/dist/holmes/spec/renumber.js +25 -10
- package/dist/holmes/spec/spec-parser.js +9 -3
- package/dist/holmes/spec/yaml-scalar.js +2 -2
- package/dist/holmes/update/refresh.js +3 -1
- package/dist/holmes/update/update-notice.d.ts +6 -0
- package/dist/holmes/update/update-notice.js +18 -1
- package/package.json +11 -4
|
@@ -33,22 +33,31 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.MANAGED_END = exports.MANAGED_BEGIN = exports.AGENTS_MD = exports.CODEX_MARKETPLACE = exports.CODEX_PLUGIN_DIR = exports.HARNESS_ENFORCES = exports.AGENTS = void 0;
|
|
36
|
+
exports.AGY_HOOKS_MAX_BYTES = exports.MANAGED_END = exports.MANAGED_BEGIN = exports.AGENTS_MD = exports.AGY_LITERAL_PATH = exports.CODEX_MARKETPLACE = exports.CODEX_PLUGIN_DIR = exports.HARNESS_ENFORCES = exports.AGENTS = void 0;
|
|
37
37
|
exports.antigravityHookCommand = antigravityHookCommand;
|
|
38
38
|
exports.shortPathIfSpaced = shortPathIfSpaced;
|
|
39
39
|
exports.antigravityHookWarnings = antigravityHookWarnings;
|
|
40
40
|
exports.mergeAgentsMd = mergeAgentsMd;
|
|
41
41
|
exports.mergeMcpConfigJson = mergeMcpConfigJson;
|
|
42
|
+
exports.agyHooksFileProblem = agyHooksFileProblem;
|
|
43
|
+
exports.agyHome = agyHome;
|
|
44
|
+
exports.agyUserHooksPath = agyUserHooksPath;
|
|
45
|
+
exports.agyUserSwitch = agyUserSwitch;
|
|
42
46
|
exports.mergeHooksJson = mergeHooksJson;
|
|
43
47
|
exports.mergeMarketplaceJson = mergeMarketplaceJson;
|
|
44
48
|
exports.mergeWiringFile = mergeWiringFile;
|
|
45
49
|
exports.agentFiles = agentFiles;
|
|
46
50
|
exports.agentLinks = agentLinks;
|
|
51
|
+
exports.agyOtherHooksFiles = agyOtherHooksFiles;
|
|
52
|
+
exports.agySwitches = agySwitches;
|
|
53
|
+
exports.agyCanonicalFile = agyCanonicalFile;
|
|
47
54
|
// @implements A-SPEC-708, A-SPEC-707, A-SPEC-202, A-SPEC-250, A-SPEC-341
|
|
48
55
|
// @implements A-SPEC-442
|
|
49
56
|
// @implements A-SPEC-193
|
|
50
57
|
const agents_guidance_plan_1 = require("./agents-guidance-plan");
|
|
51
58
|
const agents_guidance_1 = require("./agents-guidance");
|
|
59
|
+
const fs = __importStar(require("node:fs"));
|
|
60
|
+
const os = __importStar(require("node:os"));
|
|
52
61
|
const path = __importStar(require("node:path"));
|
|
53
62
|
const node_child_process_1 = require("node:child_process");
|
|
54
63
|
const mcp_launcher_1 = require("./mcp-launcher");
|
|
@@ -160,10 +169,21 @@ function shortPathIfSpaced(p) {
|
|
|
160
169
|
* these INSTEAD of "the gate is enforced". Empty when every path is space-free (posix without a
|
|
161
170
|
* space, or win32 where 8.3 resolved it).
|
|
162
171
|
*/
|
|
172
|
+
/**
|
|
173
|
+
* @implements A-SPEC-251.2 (round 45) — a script path agy's launcher passes on literally: agy runs `command` through `sh -c` on
|
|
174
|
+
* Unix and `cmd /c` on Windows (its embedded hooks.json documentation), so a path holding a character either shell reads —
|
|
175
|
+
* `'`, `(`, `&`, `$`, `;`, quotes, `%`, a leading `~` — does not run as written (`inst'q` was an sh syntax error, `R&D` two
|
|
176
|
+
* commands — measured).
|
|
177
|
+
*/
|
|
178
|
+
exports.AGY_LITERAL_PATH = /^(?!~)[A-Za-z0-9_\-./:@+,=~\u0080-\uffff]+$/;
|
|
163
179
|
function antigravityHookWarnings(packageRoot) {
|
|
164
180
|
const out = [];
|
|
165
181
|
for (const script of ['holmes-hook-antigravity.js', 'holmes-stop-antigravity.js']) {
|
|
166
182
|
const final = shortPathIfSpaced(path.join(packageRoot, 'bin', script));
|
|
183
|
+
if (!/\s/.test(final) && !exports.AGY_LITERAL_PATH.test(final.replace(/\\/g, '/'))) {
|
|
184
|
+
out.push(`antigravity: the hook path holds a character agy's shell reads (${final.replace(/\\/g, '/')}) — agy runs the hook command through sh -c (cmd /c on Windows), so this hook does not run as written and the gate is NOT enforced. Install holmes-kit in a path of letters, digits and - _ . / : @ + , = only.`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
167
187
|
if (!/\s/.test(final))
|
|
168
188
|
continue;
|
|
169
189
|
out.push(`antigravity: the hook path still contains a space (${final.replace(/\\/g, '/')}) — agy's launcher splits the command on whitespace, so this hook never runs and the gate is NOT enforced. Install holmes-kit in a path without spaces${process.platform === 'win32' ? ' (or enable NTFS 8.3 names on this volume)' : ''}.`);
|
|
@@ -258,6 +278,213 @@ function mergeMcpConfigJson(before, ours) {
|
|
|
258
278
|
notes,
|
|
259
279
|
};
|
|
260
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* @implements A-SPEC-251.2 (round 46) — agy's hooks file as agy's parser reads it (the agy binary of 2026-09-25: `ParseHooks`
|
|
283
|
+
* validates every named hook and, on any error, loads nothing from the file — "Failed to parse hooks file"; field names match
|
|
284
|
+
* case-insensitively, the last one wins). A file outside the documented shape is reported, not guessed: a sibling's
|
|
285
|
+
* `"timeout": "10"` makes agy drop the whole file (Holmes's entry with it) while doctor read PASS and init said "enforced", and
|
|
286
|
+
* `"ENABLED": false` switched the entry off past round 45's rule (the wave-46 reviewer's emulation of agy's decoder).
|
|
287
|
+
*/
|
|
288
|
+
// Round 47: `SessionStart` too — agy's parser reads and validates it (its binary: "JSON session-start hook"), its documentation omits it.
|
|
289
|
+
const AGY_SPEC_FIELDS = ['enabled', 'PreToolUse', 'PostToolUse', 'PreInvocation', 'PostInvocation', 'Stop', 'SessionStart'];
|
|
290
|
+
const AGY_GROUP_FIELDS = ['matcher', 'hooks'];
|
|
291
|
+
const AGY_HANDLER_FIELDS = ['type', 'command', 'timeout', 'prompt', 'model'];
|
|
292
|
+
/** Go's case-insensitive name match, widened (dashes and underscores ignored too): a wider fold only reports more. */
|
|
293
|
+
const agyFold = (k) => k.toUpperCase().toLowerCase().replace(/[-_]/g, '');
|
|
294
|
+
const plainObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
295
|
+
const quoted = (s) => JSON.stringify(s.length > 40 ? `${s.slice(0, 40)}…` : s);
|
|
296
|
+
/** The fields agy reads from `o`, or the first key whose spelling differs from the field agy reads it as. */
|
|
297
|
+
function agyFieldsOf(o, fields, where) {
|
|
298
|
+
const byFold = new Map(fields.map((f) => [agyFold(f), f]));
|
|
299
|
+
const values = new Map();
|
|
300
|
+
for (const k of Object.keys(o)) {
|
|
301
|
+
const exact = byFold.get(agyFold(k));
|
|
302
|
+
if (exact === undefined)
|
|
303
|
+
continue;
|
|
304
|
+
if (k !== exact)
|
|
305
|
+
return { values, problem: `${where} has ${quoted(k)}, which agy reads as "${exact}" (it matches field names case-insensitively)` };
|
|
306
|
+
values.set(exact, o[k]);
|
|
307
|
+
}
|
|
308
|
+
return { values, problem: null };
|
|
309
|
+
}
|
|
310
|
+
function agyHandlerProblem(h, where) {
|
|
311
|
+
if (!plainObject(h))
|
|
312
|
+
return `${where} is not a handler object`;
|
|
313
|
+
const { values, problem } = agyFieldsOf(h, AGY_HANDLER_FIELDS, where);
|
|
314
|
+
if (problem !== null)
|
|
315
|
+
return problem;
|
|
316
|
+
const type = values.get('type');
|
|
317
|
+
if (type === 'prompt')
|
|
318
|
+
return `${where} is a prompt hook, which this reading does not confirm agy loads`;
|
|
319
|
+
if (!(type === undefined || type === null || type === '' || type === 'command'))
|
|
320
|
+
return `${where} has type ${JSON.stringify(type).slice(0, 60)}, which agy's parser rejects`;
|
|
321
|
+
const command = values.get('command');
|
|
322
|
+
if (typeof command !== 'string' || command === '')
|
|
323
|
+
return `${where} has no command, which agy's parser rejects`;
|
|
324
|
+
if (values.has('prompt') || values.has('model'))
|
|
325
|
+
return `${where} is a command hook with a prompt or model, which agy's parser rejects`;
|
|
326
|
+
const t = values.get('timeout');
|
|
327
|
+
if (t !== undefined && t !== null && !(typeof t === 'number' && Number.isInteger(t) && t >= -2147483648 && t <= 2147483647)) {
|
|
328
|
+
return `${where} has a timeout agy's parser does not read as whole seconds (${JSON.stringify(t).slice(0, 40)})`;
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
/** A number written with a fraction or an exponent after a key agy reads as `timeout` (`1e3`, `30.0`) — one pass over the text. */
|
|
333
|
+
function agyRawTimeoutProblem(raw) {
|
|
334
|
+
let key = null;
|
|
335
|
+
let afterColon = false;
|
|
336
|
+
for (let i = 0; i < raw.length;) {
|
|
337
|
+
const c = raw[i];
|
|
338
|
+
if (c === '"') {
|
|
339
|
+
let j = i + 1;
|
|
340
|
+
while (j < raw.length && raw[j] !== '"')
|
|
341
|
+
j += raw[j] === '\\' ? 2 : 1;
|
|
342
|
+
key = j - i < 80 ? raw.slice(i, j + 1) : null;
|
|
343
|
+
afterColon = false;
|
|
344
|
+
i = j + 1;
|
|
345
|
+
}
|
|
346
|
+
else if (c === ':') {
|
|
347
|
+
afterColon = true;
|
|
348
|
+
i++;
|
|
349
|
+
}
|
|
350
|
+
else if (c === '-' || (c >= '0' && c <= '9')) {
|
|
351
|
+
let j = i;
|
|
352
|
+
while (j < raw.length && /[-+0-9.eE]/.test(raw[j]))
|
|
353
|
+
j++;
|
|
354
|
+
const token = raw.slice(i, j);
|
|
355
|
+
if (afterColon && key !== null && /[.eE]/.test(token)) {
|
|
356
|
+
let name = null;
|
|
357
|
+
try {
|
|
358
|
+
name = JSON.parse(key);
|
|
359
|
+
}
|
|
360
|
+
catch { /* not a key */ }
|
|
361
|
+
if (typeof name === 'string' && agyFold(name) === 'timeout')
|
|
362
|
+
return `a timeout is written as ${token.slice(0, 40)}, which agy's parser does not read as whole seconds`;
|
|
363
|
+
}
|
|
364
|
+
afterColon = false;
|
|
365
|
+
i = j;
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
if (c !== ' ' && c !== '\t' && c !== '\n' && c !== '\r')
|
|
369
|
+
afterColon = false;
|
|
370
|
+
i++;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
function agyHooksFileProblem(raw, parsed) {
|
|
376
|
+
if (!plainObject(parsed))
|
|
377
|
+
return 'the file is not an object of named hooks';
|
|
378
|
+
const rawProblem = agyRawTimeoutProblem(raw);
|
|
379
|
+
if (rawProblem !== null)
|
|
380
|
+
return rawProblem;
|
|
381
|
+
for (const [name, spec] of Object.entries(parsed)) {
|
|
382
|
+
const where = `the named hook ${quoted(name)}`;
|
|
383
|
+
if (!plainObject(spec))
|
|
384
|
+
return `${where} is not an object`;
|
|
385
|
+
const { values, problem } = agyFieldsOf(spec, AGY_SPEC_FIELDS, where);
|
|
386
|
+
if (problem !== null)
|
|
387
|
+
return problem;
|
|
388
|
+
const enabled = values.get('enabled');
|
|
389
|
+
if (enabled !== undefined && enabled !== null && typeof enabled !== 'boolean')
|
|
390
|
+
return `${where} has "enabled" ${JSON.stringify(enabled).slice(0, 40)}, which agy's parser rejects`;
|
|
391
|
+
for (const event of AGY_SPEC_FIELDS.slice(1)) {
|
|
392
|
+
const list = values.get(event);
|
|
393
|
+
if (list === undefined || list === null)
|
|
394
|
+
continue;
|
|
395
|
+
if (!Array.isArray(list))
|
|
396
|
+
return `${where} ${event} is not a list`;
|
|
397
|
+
for (const [i, item] of list.entries()) {
|
|
398
|
+
const at = `${where} ${event}[${i}]`;
|
|
399
|
+
if (event !== 'PreToolUse' && event !== 'PostToolUse') {
|
|
400
|
+
const p = agyHandlerProblem(item, at);
|
|
401
|
+
if (p !== null)
|
|
402
|
+
return p;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
if (!plainObject(item))
|
|
406
|
+
return `${at} is not a matcher group`;
|
|
407
|
+
const g = agyFieldsOf(item, AGY_GROUP_FIELDS, at);
|
|
408
|
+
if (g.problem !== null)
|
|
409
|
+
return g.problem;
|
|
410
|
+
const matcher = g.values.get('matcher');
|
|
411
|
+
if (matcher !== undefined && matcher !== null && typeof matcher !== 'string')
|
|
412
|
+
return `${at} has a matcher that is not a string`;
|
|
413
|
+
const hooks = g.values.get('hooks');
|
|
414
|
+
if (hooks === undefined || hooks === null)
|
|
415
|
+
continue;
|
|
416
|
+
if (!Array.isArray(hooks))
|
|
417
|
+
return `${at} hooks is not a list`;
|
|
418
|
+
for (const [j, h] of hooks.entries()) {
|
|
419
|
+
const p = agyHandlerProblem(h, `${at}.hooks[${j}]`);
|
|
420
|
+
if (p !== null)
|
|
421
|
+
return p;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @implements A-SPEC-251.2 (round 46) — the user-level hooks file agy shares between its TUI and its backend
|
|
430
|
+
* (`~/.gemini/config/hooks.json`, agy's changelog; `/hooks` writes `"enabled": false` there). agy merges named hooks from
|
|
431
|
+
* every source by name, and the last source that sets `enabled` decides it: a `holmes-kit` entry switched off there switches
|
|
432
|
+
* the workspace gate off (read from the binary — not run).
|
|
433
|
+
*/
|
|
434
|
+
/** The largest hooks file read (round 47). */
|
|
435
|
+
exports.AGY_HOOKS_MAX_BYTES = 2 * 1024 * 1024;
|
|
436
|
+
/** The most read from the user-level file and the other workspace roots together (round 48). */
|
|
437
|
+
const AGY_SWITCH_BYTES_MAX = 8 * 1024 * 1024;
|
|
438
|
+
/**
|
|
439
|
+
* @implements A-SPEC-251.2 (round 50) — agy's home: `USERPROFILE` on Windows (Go's `os.UserHomeDir`; Git Bash can set `HOME` to
|
|
440
|
+
* another drive — code reading, not measured on Windows), `HOME` elsewhere.
|
|
441
|
+
*/
|
|
442
|
+
function agyHome(platform = process.platform, env = process.env) {
|
|
443
|
+
return (platform === 'win32' ? env.USERPROFILE : env.HOME) || os.homedir();
|
|
444
|
+
}
|
|
445
|
+
function agyUserHooksPath(home = agyHome()) {
|
|
446
|
+
return path.join(home, '.gemini', 'config', 'hooks.json');
|
|
447
|
+
}
|
|
448
|
+
function agyUserSwitch(file = agyUserHooksPath()) {
|
|
449
|
+
// @implements A-SPEC-251.2 (round 47) — a switch only in a file agy loads: one its parser drops (a handler it rejects, a
|
|
450
|
+
// byte-order mark, not JSON) switches nothing off (round 46 read FAIL where the gate runs); past 2 MiB it is not read and
|
|
451
|
+
// not confirmed.
|
|
452
|
+
let raw;
|
|
453
|
+
try {
|
|
454
|
+
const st = fs.statSync(file);
|
|
455
|
+
if (!st.isFile())
|
|
456
|
+
return { off: false, unconfirmed: null };
|
|
457
|
+
if (st.size > exports.AGY_HOOKS_MAX_BYTES)
|
|
458
|
+
return { off: false, unconfirmed: `${file} is larger than ${exports.AGY_HOOKS_MAX_BYTES / (1024 * 1024)} MiB and was not read` };
|
|
459
|
+
raw = fs.readFileSync(file, 'utf8');
|
|
460
|
+
}
|
|
461
|
+
catch {
|
|
462
|
+
return { off: false, unconfirmed: null };
|
|
463
|
+
}
|
|
464
|
+
let parsed;
|
|
465
|
+
try {
|
|
466
|
+
parsed = JSON.parse(raw);
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
return { off: false, unconfirmed: null };
|
|
470
|
+
}
|
|
471
|
+
if (!plainObject(parsed) || !Object.prototype.hasOwnProperty.call(parsed, HOLMES))
|
|
472
|
+
return { off: false, unconfirmed: null };
|
|
473
|
+
if (agyHooksFileProblem(raw, parsed) !== null)
|
|
474
|
+
return { off: false, unconfirmed: null };
|
|
475
|
+
const spec = parsed[HOLMES];
|
|
476
|
+
if (!plainObject(spec))
|
|
477
|
+
return { off: false, unconfirmed: `${file} has a holmes-kit entry that is not an object` };
|
|
478
|
+
const { values, problem } = agyFieldsOf(spec, ['enabled'], `the holmes-kit entry in ${file}`);
|
|
479
|
+
if (problem !== null)
|
|
480
|
+
return { off: false, unconfirmed: problem };
|
|
481
|
+
const enabled = values.get('enabled');
|
|
482
|
+
if (enabled === false)
|
|
483
|
+
return { off: true, unconfirmed: null };
|
|
484
|
+
if (enabled !== undefined && enabled !== null && typeof enabled !== 'boolean')
|
|
485
|
+
return { off: false, unconfirmed: `the holmes-kit entry in ${file} has "enabled" that is not true or false` };
|
|
486
|
+
return { off: false, unconfirmed: null };
|
|
487
|
+
}
|
|
261
488
|
/** `.agents/hooks.json`. Top-level keys are tool namespaces; only ours is replaced. */
|
|
262
489
|
function mergeHooksJson(before, ours) {
|
|
263
490
|
const parsed = parseOr(before, ours, 'hooks.json');
|
|
@@ -321,7 +548,7 @@ function agentFiles(agent, opts) {
|
|
|
321
548
|
case 'antigravity':
|
|
322
549
|
return [
|
|
323
550
|
{ path: path.join(target, '.agents', 'hooks.json'), content: hooksJson(packageRoot) },
|
|
324
|
-
{ path: path.join(target, '.agents', 'mcp_config.json'), content: mcpConfig(packageRoot, specsDir, opts.launcher) },
|
|
551
|
+
...(opts.mcp === false ? [] : [{ path: path.join(target, '.agents', 'mcp_config.json'), content: mcpConfig(packageRoot, specsDir, opts.launcher) }]),
|
|
325
552
|
{ path: path.join(target, 'AGENTS.md'), content: (0, exports.AGENTS_MD)(exports.HARNESS_ENFORCES.antigravity) },
|
|
326
553
|
];
|
|
327
554
|
case 'codex':
|
|
@@ -411,3 +638,156 @@ function agentLinks(agent, opts) {
|
|
|
411
638
|
why: '스킬 본문은 .claude/skills 한 곳에 둔다 — 두 벌이면 하나가 낡는다',
|
|
412
639
|
}];
|
|
413
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* @implements A-SPEC-251.2 (round 47) — the other hooks files agy merges into a workspace: `hooks.json` under `.agents`, `.agent`,
|
|
643
|
+
* `_agents` and `_agent` (agy's documentation), from the target up to its repository root (the first directory holding `.git`,
|
|
644
|
+
* at most 64 levels; the target alone without one) — all but the target's own `.agents/hooks.json`.
|
|
645
|
+
*/
|
|
646
|
+
const AGY_ROOT_NAMES = ['.agents', '.agent', '_agents', '_agent'];
|
|
647
|
+
function agyOtherHooksFiles(target, cut) {
|
|
648
|
+
const walk = (start) => {
|
|
649
|
+
const dirs = [start];
|
|
650
|
+
let top = -1;
|
|
651
|
+
let ended = false;
|
|
652
|
+
for (let d = start, i = 0; i < 64; i++) {
|
|
653
|
+
if (fs.existsSync(path.join(d, '.git'))) {
|
|
654
|
+
top = i;
|
|
655
|
+
ended = true;
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
const up = path.dirname(d);
|
|
659
|
+
if (up === d) {
|
|
660
|
+
ended = true;
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
d = up;
|
|
664
|
+
dirs.push(d);
|
|
665
|
+
}
|
|
666
|
+
// Round 49: 64 levels walked with neither a repository root nor the top reached — what lies above was not seen.
|
|
667
|
+
if (!ended && cut !== undefined)
|
|
668
|
+
cut.short = true;
|
|
669
|
+
const own = path.join(start, '.agents', 'hooks.json');
|
|
670
|
+
return dirs.slice(0, top < 0 ? 1 : top + 1).flatMap((d) => AGY_ROOT_NAMES.map((n) => path.join(d, n, 'hooks.json'))).filter((f) => f !== own);
|
|
671
|
+
};
|
|
672
|
+
// @implements A-SPEC-251.2 (round 48) — from the target as written AND from its real path: through a link into a repository the
|
|
673
|
+
// written path climbed the link's own parents and never saw the repository's switched-off entry (PASS — measured).
|
|
674
|
+
const written = path.resolve(target);
|
|
675
|
+
const real = (() => { try {
|
|
676
|
+
return fs.realpathSync.native(written);
|
|
677
|
+
}
|
|
678
|
+
catch {
|
|
679
|
+
return written;
|
|
680
|
+
} })();
|
|
681
|
+
return [...new Set([...walk(written), ...(real === written ? [] : walk(real))])];
|
|
682
|
+
}
|
|
683
|
+
/** The first switch among the user-level file and the other workspace roots: off, or not confirmed. */
|
|
684
|
+
function agySwitches(target, userFile = agyUserHooksPath()) {
|
|
685
|
+
let unconfirmed = null;
|
|
686
|
+
// @implements A-SPEC-251.2 (round 48) — read within 8 MiB in all: 240 files of 2 MiB along the parents held doctor for 25 s
|
|
687
|
+
// (measured); past the budget the rest is not read and the gate is not confirmed.
|
|
688
|
+
let left = AGY_SWITCH_BYTES_MAX;
|
|
689
|
+
const cut = { short: false };
|
|
690
|
+
const others = agyOtherHooksFiles(target, cut);
|
|
691
|
+
if (cut.short)
|
|
692
|
+
unconfirmed = `the repository root was not found within 64 levels above ${target}, so agy's hooks files above it were not read`;
|
|
693
|
+
for (const f of [userFile, ...others]) {
|
|
694
|
+
let size = 0;
|
|
695
|
+
try {
|
|
696
|
+
const st = fs.statSync(f);
|
|
697
|
+
if (!st.isFile())
|
|
698
|
+
continue;
|
|
699
|
+
size = st.size;
|
|
700
|
+
}
|
|
701
|
+
catch {
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
if (size <= exports.AGY_HOOKS_MAX_BYTES && size > left) {
|
|
705
|
+
unconfirmed ??= `more agy hooks files than were read (${AGY_SWITCH_BYTES_MAX / (1024 * 1024)} MiB in all) — ${f} was not read`;
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
if (size <= exports.AGY_HOOKS_MAX_BYTES)
|
|
709
|
+
left -= size;
|
|
710
|
+
const s = agyUserSwitch(f);
|
|
711
|
+
if (s.off)
|
|
712
|
+
return { offIn: f, unconfirmed: null };
|
|
713
|
+
unconfirmed ??= s.unconfirmed;
|
|
714
|
+
}
|
|
715
|
+
// @implements A-SPEC-251.2 (round 47, owner decision 2026-09-27) — only init's own file is confirmed: a hooks file in another
|
|
716
|
+
// workspace root (whatever it holds), or a `holmes-kit` entry in the user-level file, merges into the gate in ways this
|
|
717
|
+
// reading does not follow — not confirmed.
|
|
718
|
+
if (unconfirmed === null) {
|
|
719
|
+
const other = agyOtherHooksFiles(target).find((f) => { try {
|
|
720
|
+
return fs.lstatSync(f) !== undefined;
|
|
721
|
+
}
|
|
722
|
+
catch {
|
|
723
|
+
return false;
|
|
724
|
+
} });
|
|
725
|
+
if (other !== undefined)
|
|
726
|
+
unconfirmed = `another agy hooks file exists (${other}), which agy merges with this one`;
|
|
727
|
+
else if (agyHoldsHolmes(userFile))
|
|
728
|
+
unconfirmed = `${userFile} holds a holmes-kit entry, which agy merges with this one`;
|
|
729
|
+
}
|
|
730
|
+
return { offIn: null, unconfirmed };
|
|
731
|
+
}
|
|
732
|
+
/** Whether a hooks file agy loads holds a `holmes-kit` entry (a file it drops holds none for it). */
|
|
733
|
+
function agyHoldsHolmes(file) {
|
|
734
|
+
try {
|
|
735
|
+
const st = fs.statSync(file);
|
|
736
|
+
if (!st.isFile() || st.size > exports.AGY_HOOKS_MAX_BYTES)
|
|
737
|
+
return false;
|
|
738
|
+
const raw = fs.readFileSync(file, 'utf8');
|
|
739
|
+
const parsed = JSON.parse(raw);
|
|
740
|
+
return plainObject(parsed) && Object.prototype.hasOwnProperty.call(parsed, HOLMES) && agyHooksFileProblem(raw, parsed) === null;
|
|
741
|
+
}
|
|
742
|
+
catch {
|
|
743
|
+
return false;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* @implements A-SPEC-251.2 (round 47, owner decision 2026-09-27) — the file init writes, by shape: one named hook `holmes-kit`
|
|
748
|
+
* with `PreToolUse` (one `*` group of one handler) and `Stop` (one handler), each handler holding init's keys and values but
|
|
749
|
+
* for the script path. Anything else is not confirmed — agy's parser and merge rules are not transcribed.
|
|
750
|
+
*/
|
|
751
|
+
/** The text without the whitespace between its tokens (strings kept as written) — one pass. */
|
|
752
|
+
function jsonMinified(raw) {
|
|
753
|
+
let out = '';
|
|
754
|
+
for (let i = 0; i < raw.length; i++) {
|
|
755
|
+
const c = raw[i];
|
|
756
|
+
if (c === '"') {
|
|
757
|
+
let j = i + 1;
|
|
758
|
+
while (j < raw.length && raw[j] !== '"')
|
|
759
|
+
j += raw[j] === '\\' ? 2 : 1;
|
|
760
|
+
out += raw.slice(i, j + 1);
|
|
761
|
+
i = j;
|
|
762
|
+
}
|
|
763
|
+
else if (c !== ' ' && c !== '\t' && c !== '\n' && c !== '\r')
|
|
764
|
+
out += c;
|
|
765
|
+
}
|
|
766
|
+
return out;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* `raw` (round 48): the text itself must be the parsed object written out again — parsing keeps only the last of two equal keys,
|
|
770
|
+
* so `"timeout": "10", "timeout": 30` and a first `"holmes-kit": {"enabled": false}` read as init's file (measured).
|
|
771
|
+
*/
|
|
772
|
+
function agyCanonicalFile(parsed, raw) {
|
|
773
|
+
if (raw !== undefined && jsonMinified(raw.replace(/^\uFEFF/, '')) !== JSON.stringify(parsed))
|
|
774
|
+
return false;
|
|
775
|
+
const keysAre = (o, keys) => plainObject(o) && Object.keys(o).length === keys.length && keys.every((k) => Object.prototype.hasOwnProperty.call(o, k));
|
|
776
|
+
const template = antigravityHookEntry('/x', 'x.js');
|
|
777
|
+
const handler = (h) => keysAre(h, Object.keys(template))
|
|
778
|
+
&& Object.entries(template).every(([k, v]) => (k === 'command' ? typeof h[k] === 'string' && /^node \S+$/.test(h[k]) : h[k] === v));
|
|
779
|
+
if (!keysAre(parsed, [HOLMES]))
|
|
780
|
+
return false;
|
|
781
|
+
const spec = parsed[HOLMES];
|
|
782
|
+
if (!keysAre(spec, ['PreToolUse', 'Stop']))
|
|
783
|
+
return false;
|
|
784
|
+
const pre = spec.PreToolUse;
|
|
785
|
+
const stop = spec.Stop;
|
|
786
|
+
if (!Array.isArray(pre) || pre.length !== 1 || !Array.isArray(stop) || stop.length !== 1)
|
|
787
|
+
return false;
|
|
788
|
+
const group = pre[0];
|
|
789
|
+
if (!keysAre(group, ['matcher', 'hooks']) || group.matcher !== '*')
|
|
790
|
+
return false;
|
|
791
|
+
const hooks = group.hooks;
|
|
792
|
+
return Array.isArray(hooks) && hooks.length === 1 && handler(hooks[0]) && handler(stop[0]);
|
|
793
|
+
}
|
|
@@ -11,5 +11,7 @@ export interface AttestIo {
|
|
|
11
11
|
stderr(s: string): void;
|
|
12
12
|
}
|
|
13
13
|
export declare const BADGE_REL: string;
|
|
14
|
+
/** Round 15: the text of the qualifier when the working-tree status did not answer (it claimed a clean commit — measured). */
|
|
15
|
+
export declare const ATTEST_UNKNOWN = "+unknown";
|
|
14
16
|
export declare function buildAttestReport(root: string, exclude: string[]): Promise<AttestReport>;
|
|
15
17
|
export declare function runAttest(o: AttestOptions, io: AttestIo): Promise<number>;
|
|
@@ -33,10 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.BADGE_REL = void 0;
|
|
36
|
+
exports.ATTEST_UNKNOWN = exports.BADGE_REL = void 0;
|
|
37
37
|
exports.buildAttestReport = buildAttestReport;
|
|
38
38
|
exports.runAttest = runAttest;
|
|
39
|
-
// @implements A-SPEC-702
|
|
39
|
+
// @implements A-SPEC-702, A-SPEC-734
|
|
40
40
|
/**
|
|
41
41
|
* `holmes-kit attest` — the surface that calls `rtm/traced-files`.
|
|
42
42
|
*
|
|
@@ -54,37 +54,62 @@ const root_1 = require("../project/root");
|
|
|
54
54
|
const test_scope_1 = require("../rtm/test-scope");
|
|
55
55
|
const file_anchors_1 = require("../rtm/file-anchors");
|
|
56
56
|
const link_census_1 = require("../rtm/link-census");
|
|
57
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
57
58
|
const traced_files_1 = require("../rtm/traced-files");
|
|
58
59
|
exports.BADGE_REL = path.join('.ax', 'badges', 'traced.svg');
|
|
59
60
|
const SPECS_REL = path.join('.ax', 'specs');
|
|
60
61
|
const git = (root, args) => {
|
|
61
62
|
try {
|
|
62
|
-
return (0, node_child_process_1.execFileSync)('git', ['-C', root, ...args], { stdio: ['ignore', 'pipe', 'ignore'], env: (0, root_1.cleanSubprocessEnv)(process.env) }).toString('utf8');
|
|
63
|
+
return (0, node_child_process_1.execFileSync)('git', ['-C', root, ...args], { maxBuffer: bounded_io_1.GIT_MAX_BUFFER, timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'], env: (0, root_1.cleanSubprocessEnv)(process.env) }).toString('utf8');
|
|
63
64
|
}
|
|
64
65
|
catch {
|
|
65
66
|
return undefined;
|
|
66
67
|
}
|
|
67
68
|
};
|
|
69
|
+
/** Round 15: the text of the qualifier when the working-tree status did not answer (it claimed a clean commit — measured). */
|
|
70
|
+
exports.ATTEST_UNKNOWN = '+unknown';
|
|
68
71
|
/**
|
|
69
72
|
* `+dirty` only when something that DECIDES the number is uncommitted: a scanned source file or a
|
|
70
73
|
* spec. The badge and the README are outputs of this very command, and a session ledger is always
|
|
71
74
|
* moving — counting them would make a committed badge say `+dirty` forever.
|
|
72
75
|
*/
|
|
73
76
|
function decidingPathsDirty(root, scanned) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
// @implements A-SPEC-734 (round 17) — limited to the project and read from its own root: git prints porcelain paths
|
|
78
|
+
// from the REPOSITORY root, so a monorepo package's dirty tree was called clean (measured).
|
|
79
|
+
const prefix = git(root, ['rev-parse', '--show-prefix']);
|
|
80
|
+
const base0 = (prefix ?? '').trim();
|
|
81
|
+
const limit = base0 !== '' && /^[\x20-\x7e]+$/.test(base0) ? ['--', `:(top,icase,literal)${base0}`] : [];
|
|
82
|
+
const out = git(root, ['status', '--porcelain', '-z', '--untracked-files=all', '--ignore-submodules=all', ...limit]);
|
|
83
|
+
// @implements A-SPEC-734 (round 15) — a status that did not answer is not a clean tree.
|
|
84
|
+
if (out === undefined || prefix === undefined)
|
|
85
|
+
return 'unknown';
|
|
86
|
+
const base = prefix.trim();
|
|
77
87
|
const specs = SPECS_REL.split(path.sep).join('/') + '/';
|
|
78
|
-
|
|
88
|
+
const entries = out.split('\0');
|
|
89
|
+
for (let i = 0; i < entries.length; i++) {
|
|
90
|
+
const entry = entries[i];
|
|
79
91
|
if (entry.length < 4)
|
|
80
92
|
continue;
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
// `-z` renames and copies: the next entry is the source path, in either column (a working-tree rename's source
|
|
94
|
+
// swallowed the next real entry — measured).
|
|
95
|
+
const xy = entry.slice(0, 2);
|
|
96
|
+
const source = /[RC]/.test(xy) ? entries[++i] : undefined;
|
|
97
|
+
// A-SPEC-734 (round 20): a deleted source and a rename's source decide too (` D src/b.ts` and a spec renamed out of
|
|
98
|
+
// the store read clean — measured); a deleted file is not in the current scan, so it is judged by its extension.
|
|
99
|
+
const decides = (q, gone) => q !== null
|
|
100
|
+
&& (q.startsWith(specs) || scanned.has(q) || (gone && cpg_scanner_1.SCANNABLE_EXTENSIONS.some((e) => q.endsWith(e))));
|
|
101
|
+
if (source !== undefined && decides((0, bounded_io_1.underGitPrefix)(source, base), true))
|
|
102
|
+
return true;
|
|
103
|
+
const p = (0, bounded_io_1.underGitPrefix)(entry.slice(3), base);
|
|
104
|
+
if (p === null)
|
|
105
|
+
continue;
|
|
106
|
+
if (decides(p, xy.includes('D')))
|
|
83
107
|
return true;
|
|
84
108
|
}
|
|
85
109
|
return false;
|
|
86
110
|
}
|
|
87
111
|
async function buildAttestReport(root, exclude) {
|
|
112
|
+
(0, cpg_scanner_1.forgetUnverifiedUnder)(root);
|
|
88
113
|
const scanned = new cpg_scanner_1.CpgScanner().scan(root, root);
|
|
89
114
|
const specs = await new spec_store_1.LocalMarkdownRepository(path.join(root, SPECS_REL)).list();
|
|
90
115
|
const approved = specs.filter((s) => s.status === 'approved');
|
|
@@ -101,15 +126,26 @@ async function buildAttestReport(root, exclude) {
|
|
|
101
126
|
weakMentions: {},
|
|
102
127
|
});
|
|
103
128
|
const commit = git(root, ['rev-parse', 'HEAD'])?.trim();
|
|
129
|
+
const dirty = commit ? decidingPathsDirty(root, new Set(files.map((f) => f.path))) : false;
|
|
130
|
+
const provenance = (0, traced_files_1.attestProvenance)({
|
|
131
|
+
commit,
|
|
132
|
+
dirty: dirty === true,
|
|
133
|
+
approved: approved.map((s) => ({ id: s.id, digest: String(s.frontmatter.approved_digest ?? '') })),
|
|
134
|
+
exclude,
|
|
135
|
+
});
|
|
136
|
+
// @implements A-SPEC-734 (round 17) — a repository git refuses to read has an unknown commit, not none (a refused
|
|
137
|
+
// repository said `unversioned`); a repository with no commit yet still answers `--git-dir`.
|
|
138
|
+
if (commit === undefined && git(root, ['rev-parse', '--git-dir']) === undefined && (0, bounded_io_1.gitEntryAbove)(root))
|
|
139
|
+
provenance.at = 'unknown';
|
|
140
|
+
// Round 17: a directory the scan skipped because git could not answer for it leaves the tree's content unknown.
|
|
141
|
+
if (dirty === 'unknown' || (0, cpg_scanner_1.unverifiedUnder)(root).length > 0) {
|
|
142
|
+
if (!provenance.at.endsWith(exports.ATTEST_UNKNOWN) && provenance.at !== 'unknown')
|
|
143
|
+
provenance.at += exports.ATTEST_UNKNOWN;
|
|
144
|
+
}
|
|
104
145
|
return {
|
|
105
146
|
files: (0, traced_files_1.tracedFiles)({ files, approvedIds: approved.map((s) => s.id), exclude }),
|
|
106
147
|
specs: { total: census.total, linked: census.codeLinked },
|
|
107
|
-
provenance
|
|
108
|
-
commit,
|
|
109
|
-
dirty: commit ? decidingPathsDirty(root, new Set(files.map((f) => f.path))) : false,
|
|
110
|
-
approved: approved.map((s) => ({ id: s.id, digest: String(s.frontmatter.approved_digest ?? '') })),
|
|
111
|
-
exclude,
|
|
112
|
-
}),
|
|
148
|
+
provenance,
|
|
113
149
|
};
|
|
114
150
|
}
|
|
115
151
|
async function runAttest(o, io) {
|
|
@@ -118,6 +154,21 @@ async function runAttest(o, io) {
|
|
|
118
154
|
return 2;
|
|
119
155
|
}
|
|
120
156
|
const report = await buildAttestReport(o.root, o.exclude);
|
|
157
|
+
if (report.provenance.at.endsWith(exports.ATTEST_UNKNOWN))
|
|
158
|
+
io.stderr('attest: the working-tree status did not answer, so whether the tree matches the commit is unknown (+unknown)\n');
|
|
159
|
+
// @implements A-SPEC-734 (round 17) — directories whose nesting git could not answer were not counted; named.
|
|
160
|
+
const skipped = (0, cpg_scanner_1.unverifiedUnder)(o.root);
|
|
161
|
+
if (skipped.length > 0) {
|
|
162
|
+
let real = o.root;
|
|
163
|
+
try {
|
|
164
|
+
real = fs.realpathSync.native(o.root);
|
|
165
|
+
}
|
|
166
|
+
catch { /* as given */ }
|
|
167
|
+
const shown = skipped.slice(0, 5).map((d) => path.relative(real, d).split(path.sep).join('/'));
|
|
168
|
+
io.stderr(`attest: ${skipped.length} director${skipped.length === 1 ? 'y' : 'ies'} holding .git could not be verified with git and ${skipped.length === 1 ? 'was' : 'were'} not counted (${shown.join(', ')}${skipped.length > 5 ? ', …' : ''}) — the tree's content is unknown (+unknown)\n`);
|
|
169
|
+
}
|
|
170
|
+
if (report.provenance.at === 'unknown')
|
|
171
|
+
io.stderr('attest: git refused to read this repository, so the commit is unknown\n');
|
|
121
172
|
io.stdout(o.json ? (0, traced_files_1.renderAttestJson)(report) : (0, traced_files_1.renderAttestText)(report));
|
|
122
173
|
let code = 0;
|
|
123
174
|
const note = (s) => { if (!o.json)
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.runCiGate = runCiGate;
|
|
37
37
|
// @implements A-SPEC-213
|
|
38
|
+
// @implements A-SPEC-734
|
|
38
39
|
const fs = __importStar(require("node:fs"));
|
|
39
40
|
const path = __importStar(require("node:path"));
|
|
40
41
|
const cpg_scanner_1 = require("../cpg/cpg-scanner");
|
|
@@ -67,8 +68,22 @@ function runCiGate(targetDir, options) {
|
|
|
67
68
|
}
|
|
68
69
|
const ignore = (0, ignore_1.loadIgnore)(root);
|
|
69
70
|
const scanner = new cpg_scanner_1.CpgScanner();
|
|
71
|
+
(0, cpg_scanner_1.forgetUnverifiedUnder)(root);
|
|
70
72
|
const scannedFiles = scanner.scan(root, root);
|
|
73
|
+
// @implements A-SPEC-734 (round 17) — directories holding `.git` whose nesting git could not answer are skipped by
|
|
74
|
+
// the scan, so their code was not judged: the gate fails and names them (round 15 read 100% — measured; round 16
|
|
75
|
+
// walked them and judged a registered worktree's files as this project's — measured).
|
|
76
|
+
const skipped = (0, cpg_scanner_1.unverifiedUnder)(root);
|
|
77
|
+
let realRoot = root;
|
|
78
|
+
try {
|
|
79
|
+
realRoot = fs.realpathSync.native(root);
|
|
80
|
+
}
|
|
81
|
+
catch { /* as given */ }
|
|
82
|
+
const shown = skipped.slice(0, 5).map((d) => path.relative(realRoot, d).split(path.sep).join('/'));
|
|
83
|
+
const unverified = skipped.length === 0 ? '' : ` (${skipped.length} director${skipped.length === 1 ? 'y' : 'ies'} holding .git could not be verified with git and ${skipped.length === 1 ? 'was' : 'were'} not judged: ${shown.join(', ')}${skipped.length > 5 ? ', …' : ''})`;
|
|
71
84
|
const violations = [];
|
|
85
|
+
for (const d of shown)
|
|
86
|
+
violations.push({ file: d, reason: 'Not judged — a directory holding .git whose nesting git could not answer (fix git access to the repository and run again)' });
|
|
72
87
|
for (const sf of scannedFiles) {
|
|
73
88
|
const rel = path.relative(root, sf.path).split(path.sep).join('/');
|
|
74
89
|
if (ignore.isIgnored(rel))
|
|
@@ -94,7 +109,7 @@ function runCiGate(targetDir, options) {
|
|
|
94
109
|
return {
|
|
95
110
|
ok: false,
|
|
96
111
|
violations,
|
|
97
|
-
summary: `[Holmes-Kit CI Gate Refusal] Governance Violations Detected — ${violations.length} un-anchored file(s) or invalid spec anchors found in PR commit range
|
|
112
|
+
summary: `[Holmes-Kit CI Gate Refusal] Governance Violations Detected — ${violations.length - shown.length} un-anchored file(s) or invalid spec anchors found in PR commit range.${unverified}`,
|
|
98
113
|
};
|
|
99
114
|
}
|
|
100
115
|
return {
|