@holmes-lab/holmes-kit 0.26.2 → 0.28.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 +54 -0
- package/README.md +10 -0
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/agents-guidance-command.d.ts +9 -0
- package/dist/holmes/cli/agents-guidance-command.js +61 -0
- package/dist/holmes/cli/agents-guidance-file.d.ts +7 -0
- package/dist/holmes/cli/agents-guidance-file.js +86 -0
- package/dist/holmes/cli/agents-guidance-history.d.ts +10 -0
- package/dist/holmes/cli/agents-guidance-history.js +35 -0
- package/dist/holmes/cli/agents-guidance-plan.d.ts +11 -0
- package/dist/holmes/cli/agents-guidance-plan.js +81 -0
- package/dist/holmes/cli/agents-guidance.d.ts +1 -0
- package/dist/holmes/cli/agents-guidance.js +40 -0
- package/dist/holmes/cli/agents.d.ts +3 -19
- package/dist/holmes/cli/agents.js +12 -108
- package/dist/holmes/cli/attest.d.ts +15 -0
- package/dist/holmes/cli/attest.js +168 -0
- package/dist/holmes/cli/doctor-guidance.d.ts +2 -0
- package/dist/holmes/cli/doctor-guidance.js +61 -0
- package/dist/holmes/cli/doctor.d.ts +2 -0
- package/dist/holmes/cli/doctor.js +5 -1
- package/dist/holmes/cli/index.d.ts +1 -0
- package/dist/holmes/cli/index.js +51 -4
- package/dist/holmes/cli/init.js +32 -5
- package/dist/holmes/cli/upgrade.js +23 -26
- package/dist/holmes/cli/worktree-readiness.d.ts +6 -0
- package/dist/holmes/cli/worktree-readiness.js +81 -0
- package/dist/holmes/mcp/handlers/workspace-preflight.d.ts +9 -0
- package/dist/holmes/mcp/handlers/workspace-preflight.js +13 -0
- package/dist/holmes/mcp/handlers.d.ts +50 -46
- package/dist/holmes/mcp/handlers.js +6 -3
- package/dist/holmes/mcp/tool-schemas.js +6 -1
- package/dist/holmes/project/workspace-checkout.d.ts +8 -0
- package/dist/holmes/project/workspace-checkout.js +74 -0
- package/dist/holmes/project/workspace-preflight.d.ts +24 -0
- package/dist/holmes/project/workspace-preflight.js +99 -0
- package/dist/holmes/rtm/traced-files.d.ts +83 -0
- package/dist/holmes/rtm/traced-files.js +207 -0
- package/docs/install-guide.md +54 -0
- package/package.json +1 -1
- package/playbooks/superpowers-compat/PLAYBOOK.md +46 -0
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.runUpgrade = runUpgrade;
|
|
37
|
+
// @implements A-SPEC-709
|
|
37
38
|
// @implements A-SPEC-543.2
|
|
38
39
|
const fs = __importStar(require("node:fs"));
|
|
39
40
|
const os = __importStar(require("node:os"));
|
|
@@ -133,8 +134,18 @@ async function runUpgrade(io) {
|
|
|
133
134
|
}
|
|
134
135
|
catch { /* cache clear is best-effort */ }
|
|
135
136
|
// (3) re-pin every registered workspace that still exists.
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
// Load the newly installed package in a fresh process: the caller already cached old init.
|
|
138
|
+
let newCli;
|
|
139
|
+
try {
|
|
140
|
+
const modulesRoot = (0, node_child_process_1.execFileSync)(npmBin(), ['root', ...(plan.installMode === 'global-npx' ? ['-g'] : [])], { cwd: process.cwd(), encoding: 'utf8' }).trim();
|
|
141
|
+
newCli = path.join(modulesRoot, PKG, 'bin', 'holmes-kit.js');
|
|
142
|
+
if (!fs.statSync(newCli).isFile())
|
|
143
|
+
throw new Error('new CLI is not a file');
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
io.stderr(`Installed package CLI could not be resolved; no workspace re-pinned: ${String(e)}\n`);
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
138
149
|
let repinned = 0, skipped = 0, failed = 0;
|
|
139
150
|
io.stdout('\nRe-pinning workspaces:\n');
|
|
140
151
|
for (const w of registry.workspaces) {
|
|
@@ -144,34 +155,20 @@ async function runUpgrade(io) {
|
|
|
144
155
|
continue;
|
|
145
156
|
}
|
|
146
157
|
try {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
mcp: true,
|
|
154
|
-
dryRun: false,
|
|
155
|
-
force: true,
|
|
156
|
-
remove: false,
|
|
157
|
-
agents: w.agents,
|
|
158
|
-
allowAdditive: true,
|
|
159
|
-
});
|
|
160
|
-
if (res.ok) {
|
|
161
|
-
io.stdout(` re-pinned: ${w.target}\n`);
|
|
162
|
-
repinned++;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
io.stdout(` failed: ${w.target}\n`);
|
|
166
|
-
failed++;
|
|
167
|
-
}
|
|
158
|
+
const agents = w.agents.length ? w.agents.join(',') : 'claude';
|
|
159
|
+
const output = (0, node_child_process_1.execFileSync)(process.execPath, [newCli, 'init', '--target', w.target,
|
|
160
|
+
'--agent', agents, '--mode', 'guardrail', '--mcp-launcher', 'npx'], { cwd: process.cwd(), encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
161
|
+
io.stdout(output);
|
|
162
|
+
io.stdout(` re-pinned: ${w.target}\n`);
|
|
163
|
+
repinned++;
|
|
168
164
|
}
|
|
169
|
-
catch {
|
|
170
|
-
|
|
165
|
+
catch (e) {
|
|
166
|
+
const failure = e;
|
|
167
|
+
io.stdout(` failed: ${w.target}: ${String(failure.stderr ?? failure.message ?? e)}\n`);
|
|
171
168
|
failed++;
|
|
172
169
|
}
|
|
173
170
|
}
|
|
174
171
|
io.stdout(`\nUpgraded to ${plan.latest}. re-pinned ${repinned} · skipped ${skipped} · failed ${failed}. A new session's hooks/MCP will read the new wiring.\n`);
|
|
175
172
|
io.stdout(`(You can re-wire any individual workspace at any time with ${(0, npx_bin_1.npxBin)()} holmes-kit init --agent <…> --force.)\n`);
|
|
176
|
-
return 0;
|
|
173
|
+
return failed > 0 ? 1 : 0;
|
|
177
174
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Agent } from './agents';
|
|
2
|
+
import type { Check } from './doctor-check';
|
|
3
|
+
/** Disk preparation evidence for one selected harness. It never observes a client's loaded config. */
|
|
4
|
+
export declare function worktreeReadinessChecks(packageRoot: string, target: string, opts?: {
|
|
5
|
+
agent?: Agent;
|
|
6
|
+
}): Check[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.worktreeReadinessChecks = worktreeReadinessChecks;
|
|
37
|
+
// @implements A-SPEC-704
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const workspace_checkout_1 = require("../project/workspace-checkout");
|
|
41
|
+
const workspace_identity_1 = require("../project/workspace-identity");
|
|
42
|
+
const WIRING = {
|
|
43
|
+
claude: ['.mcp.json'],
|
|
44
|
+
codex: ['.codex/config.toml', '.claude-plugin/marketplace.json'],
|
|
45
|
+
antigravity: ['.agents/mcp_config.json', '.agents/hooks.json'],
|
|
46
|
+
};
|
|
47
|
+
/** Disk preparation evidence for one selected harness. It never observes a client's loaded config. */
|
|
48
|
+
function worktreeReadinessChecks(packageRoot, target, opts = {}) {
|
|
49
|
+
const agent = opts.agent;
|
|
50
|
+
if (!agent)
|
|
51
|
+
return [];
|
|
52
|
+
const checkout = (0, workspace_checkout_1.inspectWorkspaceCheckout)(target);
|
|
53
|
+
let identity = 'unavailable';
|
|
54
|
+
let identityWarning = false;
|
|
55
|
+
try {
|
|
56
|
+
const status = (0, workspace_identity_1.workspaceIdentity)(target, 'status');
|
|
57
|
+
identity = status.state;
|
|
58
|
+
identityWarning = status.state === 'initialized';
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
identityWarning = true;
|
|
62
|
+
identity = `unavailable (${e instanceof Error ? e.message : String(e)})`;
|
|
63
|
+
}
|
|
64
|
+
const files = WIRING[agent];
|
|
65
|
+
const missing = files.filter((file) => !fs.existsSync(path.join(target, file)));
|
|
66
|
+
const build = fs.existsSync(path.join(packageRoot, 'dist', 'holmes', 'mcp', 'server.js'));
|
|
67
|
+
const level = missing.length || identityWarning || checkout.kind === 'unknown' || !build ? 'WARN' : 'PASS';
|
|
68
|
+
const repair = `Run holmes-kit init --target ${target} --agent ${agent}, then restart that harness session.`;
|
|
69
|
+
const detail = [
|
|
70
|
+
`disk preparation only: ${agent}; checkout=${checkout.kind}${checkout.detached ? ' (detached)' : ''}; identity=${identity}.`,
|
|
71
|
+
missing.length ? `missing local wiring: ${missing.join(', ')}.` : `local wiring present: ${files.join(', ')}.`,
|
|
72
|
+
build ? 'package build is present.' : 'package build is absent.',
|
|
73
|
+
'This does not prove whether a current client loaded hooks or MCP configuration.',
|
|
74
|
+
].join(' ');
|
|
75
|
+
return [
|
|
76
|
+
{ name: `${agent} worktree readiness`, level, detail, fix: level === 'PASS' ? undefined : repair },
|
|
77
|
+
{ name: `${agent} live session enforcement`, level: 'WARN',
|
|
78
|
+
detail: 'unknown: disk preparation and a doctor-spawned MCP probe are separate-process evidence, not proof of this client session.',
|
|
79
|
+
fix: 'Restart the selected harness in this workspace and run workspace_preflight from that live session.' },
|
|
80
|
+
];
|
|
81
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Agent } from '../../cli/agents';
|
|
2
|
+
export declare function createWorkspacePreflightHandlers(context: {
|
|
3
|
+
storeRoot?: string;
|
|
4
|
+
}): {
|
|
5
|
+
workspace_preflight(a: {
|
|
6
|
+
root: string;
|
|
7
|
+
harness?: Agent;
|
|
8
|
+
}): Promise<import("../../project/workspace-preflight").WorkspacePreflight>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWorkspacePreflightHandlers = createWorkspacePreflightHandlers;
|
|
4
|
+
// @implements A-SPEC-703
|
|
5
|
+
const agents_1 = require("../../cli/agents");
|
|
6
|
+
const workspace_preflight_1 = require("../../project/workspace-preflight");
|
|
7
|
+
function createWorkspacePreflightHandlers(context) {
|
|
8
|
+
return { async workspace_preflight(a) {
|
|
9
|
+
if (a?.harness !== undefined && !agents_1.AGENTS.includes(a.harness))
|
|
10
|
+
throw new Error('Unsupported harness.');
|
|
11
|
+
return (0, workspace_preflight_1.inspectWorkspacePreflight)({ requestedRoot: a?.root, storeRoot: context.storeRoot });
|
|
12
|
+
} };
|
|
13
|
+
}
|
|
@@ -349,52 +349,6 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
349
349
|
code: string;
|
|
350
350
|
reason: string;
|
|
351
351
|
}>;
|
|
352
|
-
ledger_reconcile: (a: {
|
|
353
|
-
root?: string;
|
|
354
|
-
nonce: string;
|
|
355
|
-
rationale?: string;
|
|
356
|
-
}) => Promise<{
|
|
357
|
-
ok: boolean;
|
|
358
|
-
reason: string;
|
|
359
|
-
reconciled?: undefined;
|
|
360
|
-
nonce?: undefined;
|
|
361
|
-
pending?: undefined;
|
|
362
|
-
code?: undefined;
|
|
363
|
-
events?: undefined;
|
|
364
|
-
remaining?: undefined;
|
|
365
|
-
} | {
|
|
366
|
-
ok: boolean;
|
|
367
|
-
reconciled: boolean;
|
|
368
|
-
nonce: string;
|
|
369
|
-
pending: string[];
|
|
370
|
-
reason: string;
|
|
371
|
-
code?: undefined;
|
|
372
|
-
events?: undefined;
|
|
373
|
-
remaining?: undefined;
|
|
374
|
-
} | {
|
|
375
|
-
ok: boolean;
|
|
376
|
-
code: string;
|
|
377
|
-
reason: string;
|
|
378
|
-
reconciled?: undefined;
|
|
379
|
-
nonce?: undefined;
|
|
380
|
-
pending?: undefined;
|
|
381
|
-
events?: undefined;
|
|
382
|
-
remaining?: undefined;
|
|
383
|
-
} | {
|
|
384
|
-
ok: boolean;
|
|
385
|
-
reconciled: boolean;
|
|
386
|
-
nonce: string;
|
|
387
|
-
events: {
|
|
388
|
-
replicaId: string | null;
|
|
389
|
-
seq: number;
|
|
390
|
-
hash: string;
|
|
391
|
-
ts: string;
|
|
392
|
-
}[];
|
|
393
|
-
remaining: string[];
|
|
394
|
-
reason?: undefined;
|
|
395
|
-
pending?: undefined;
|
|
396
|
-
code?: undefined;
|
|
397
|
-
}>;
|
|
398
352
|
spec_reconcile: (a: {
|
|
399
353
|
root?: string;
|
|
400
354
|
operation?: string;
|
|
@@ -633,6 +587,56 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
633
587
|
reason: string;
|
|
634
588
|
}[];
|
|
635
589
|
}>;
|
|
590
|
+
workspace_preflight(a: {
|
|
591
|
+
root: string;
|
|
592
|
+
harness?: import("../cli/agents").Agent;
|
|
593
|
+
}): Promise<import("../project/workspace-preflight").WorkspacePreflight>;
|
|
594
|
+
ledger_reconcile: (a: {
|
|
595
|
+
root?: string;
|
|
596
|
+
nonce: string;
|
|
597
|
+
rationale?: string;
|
|
598
|
+
}) => Promise<{
|
|
599
|
+
ok: boolean;
|
|
600
|
+
reason: string;
|
|
601
|
+
reconciled?: undefined;
|
|
602
|
+
nonce?: undefined;
|
|
603
|
+
pending?: undefined;
|
|
604
|
+
code?: undefined;
|
|
605
|
+
events?: undefined;
|
|
606
|
+
remaining?: undefined;
|
|
607
|
+
} | {
|
|
608
|
+
ok: boolean;
|
|
609
|
+
reconciled: boolean;
|
|
610
|
+
nonce: string;
|
|
611
|
+
pending: string[];
|
|
612
|
+
reason: string;
|
|
613
|
+
code?: undefined;
|
|
614
|
+
events?: undefined;
|
|
615
|
+
remaining?: undefined;
|
|
616
|
+
} | {
|
|
617
|
+
ok: boolean;
|
|
618
|
+
code: string;
|
|
619
|
+
reason: string;
|
|
620
|
+
reconciled?: undefined;
|
|
621
|
+
nonce?: undefined;
|
|
622
|
+
pending?: undefined;
|
|
623
|
+
events?: undefined;
|
|
624
|
+
remaining?: undefined;
|
|
625
|
+
} | {
|
|
626
|
+
ok: boolean;
|
|
627
|
+
reconciled: boolean;
|
|
628
|
+
nonce: string;
|
|
629
|
+
events: {
|
|
630
|
+
replicaId: string | null;
|
|
631
|
+
seq: number;
|
|
632
|
+
hash: string;
|
|
633
|
+
ts: string;
|
|
634
|
+
}[];
|
|
635
|
+
remaining: string[];
|
|
636
|
+
reason?: undefined;
|
|
637
|
+
pending?: undefined;
|
|
638
|
+
code?: undefined;
|
|
639
|
+
}>;
|
|
636
640
|
maintenance_outcome(a: {
|
|
637
641
|
root: string;
|
|
638
642
|
digest: string;
|
|
@@ -38,7 +38,7 @@ exports.isHandlerRefusal = isHandlerRefusal;
|
|
|
38
38
|
exports.unreadableAmong = unreadableAmong;
|
|
39
39
|
exports.makeHandlers = makeHandlers;
|
|
40
40
|
exports.collectDecisions = collectDecisions;
|
|
41
|
-
// @implements A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627
|
|
41
|
+
// @implements A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627
|
|
42
42
|
// @implements A-SPEC-643
|
|
43
43
|
// @implements A-SPEC-642
|
|
44
44
|
// @implements A-SPEC-642
|
|
@@ -68,6 +68,7 @@ const spec_authoring_1 = require("./handlers/spec-authoring");
|
|
|
68
68
|
const spec_lifecycle_1 = require("./handlers/spec-lifecycle");
|
|
69
69
|
const spec_approval_1 = require("./handlers/spec-approval");
|
|
70
70
|
const workspace_identity_2 = require("./handlers/workspace-identity");
|
|
71
|
+
const workspace_preflight_1 = require("./handlers/workspace-preflight");
|
|
71
72
|
const operator_inspection_1 = require("./handlers/operator-inspection");
|
|
72
73
|
const phase_queries_1 = require("./handlers/phase-queries");
|
|
73
74
|
const risk_assessment_1 = require("./handlers/risk-assessment");
|
|
@@ -533,7 +534,8 @@ function makeHandlers(store, opts) {
|
|
|
533
534
|
const wrapped = {};
|
|
534
535
|
const run = (0, execution_context_1.createExecutionScope)(store instanceof spec_store_1.LocalMarkdownRepository ? store.specsRoot : undefined, opts?.observeInvocation);
|
|
535
536
|
for (const [name, fn] of Object.entries(raw)) {
|
|
536
|
-
const
|
|
537
|
+
const diagnostic = name === 'workspace_preflight';
|
|
538
|
+
const scoped = name === 'workspace_identity' || diagnostic ? fn : async (a) => {
|
|
537
539
|
try {
|
|
538
540
|
return await run(a?.root, () => fn(a));
|
|
539
541
|
}
|
|
@@ -545,7 +547,7 @@ function makeHandlers(store, opts) {
|
|
|
545
547
|
throw e;
|
|
546
548
|
}
|
|
547
549
|
};
|
|
548
|
-
wrapped[name] = (0, basis_1.withBasis)(scoped, (a) => basisFor(a?.root));
|
|
550
|
+
wrapped[name] = (0, basis_1.withBasis)(scoped, (a) => basisFor(diagnostic ? undefined : a?.root));
|
|
549
551
|
}
|
|
550
552
|
wrapped.basis_detail = async (a) => {
|
|
551
553
|
const b = basisFor(a?.root, true);
|
|
@@ -930,6 +932,7 @@ function makeRawHandlers(store, opts) {
|
|
|
930
932
|
// citation_pin+4, phase_check+3, cpg_scan+3, taint_scan..issue_localize, test_run+3, issue_localize+3,
|
|
931
933
|
// rtm_impact+4, rtm_reindex..review_record, review_prepare..risk_check, risk_check±, and the tail).
|
|
932
934
|
ledger_reconcile: operatorInspection.ledger_reconcile,
|
|
935
|
+
...(0, workspace_preflight_1.createWorkspacePreflightHandlers)({ storeRoot: store instanceof spec_store_1.LocalMarkdownRepository ? store.specsRoot : undefined }),
|
|
933
936
|
// @implements A-SPEC-700.2 — same unpinned slot: `spec_retire..spec_unseal` is a pinned run.
|
|
934
937
|
spec_reconcile: specLifecycle.spec_reconcile,
|
|
935
938
|
rtm_impact: graphOperations.rtm_impact,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TOOL_SCHEMAS = exports.HOOK_ENFORCED_TOOLS = void 0;
|
|
4
|
-
// @implements A-SPEC-629, A-SPEC-628, A-SPEC-623, A-SPEC-277, A-SPEC-624, A-SPEC-627
|
|
4
|
+
// @implements A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-623, A-SPEC-277, A-SPEC-624, A-SPEC-627
|
|
5
5
|
// @implements A-SPEC-495 — the maintenance_analyze description carries the semantic-evidence
|
|
6
6
|
// consumer contract (sem-verify / semCos / semanticAlternates) beside the anti-prediction warning.
|
|
7
7
|
// @implements A-SPEC-642
|
|
@@ -11,6 +11,7 @@ exports.TOOL_SCHEMAS = exports.HOOK_ENFORCED_TOOLS = void 0;
|
|
|
11
11
|
// @implements A-SPEC-269
|
|
12
12
|
// @implements A-SPEC-267
|
|
13
13
|
const spec_types_1 = require("../spec/spec-types");
|
|
14
|
+
const agents_1 = require("../cli/agents");
|
|
14
15
|
const phase_1 = require("../guardrail/phase");
|
|
15
16
|
const str = (description) => ({ type: 'string', description });
|
|
16
17
|
const num = (description) => ({ type: 'number', description });
|
|
@@ -51,6 +52,10 @@ exports.TOOL_SCHEMAS = {
|
|
|
51
52
|
description: 'Inspect or plan entity adoption without writes by default. Explicit adopt requires config-write approval for the exact returned plan and preserves sealed document bytes. Adopted stores retain entity identity through journaled document creation, edits and classification moves. recovery-plan reports interrupted targets without changing them. recover requires separate exact-plan approval to complete interrupted transactions or release locks for verified completed writes. Sealing, unsealing and retirement additionally require current spec-approve authority for the affected ID and the same transition policy as official spec tools. Live or unknown owners, external changes and noncanonical transitions refuse. Recovery audit completion across crashes remains under development.',
|
|
52
53
|
inputSchema: { type: 'object', properties: { root: ROOT_ANY, operation: { type: 'string', enum: ['status', 'plan-adoption', 'adopt', 'recovery-plan', 'recover'] }, plan: { type: 'object', description: 'The complete unmodified plan returned by plan-adoption or recovery-plan.' } } },
|
|
53
54
|
},
|
|
55
|
+
workspace_preflight: {
|
|
56
|
+
description: 'Read-only diagnosis of this live MCP server workspace binding. Mismatched roots are not scanned. Identity and checkout are inspected only for a matching root. Does not rebind, initialize, register or prove client hook enforcement.',
|
|
57
|
+
inputSchema: { type: 'object', properties: { root: ROOT_ANY, harness: { type: 'string', enum: [...agents_1.AGENTS] } }, required: ['root'] },
|
|
58
|
+
},
|
|
54
59
|
workspace_identity: {
|
|
55
60
|
description: 'Inspect canonical workspace and local replica identity without writes by default. Explicit initialize creates a Git-shareable .ax/workspace.json and registers this checkout; register requires an existing canonical identity. Preserve legacy specs and ledgers; these identifiers grant no approval authority. Share the manifest through Git and keep .ax/state local. Registered MCP writes include holmes-execution/1 provenance and require a reader supporting that schema; matching package versions alone do not establish this capability.',
|
|
56
61
|
inputSchema: {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CheckoutInfo = {
|
|
2
|
+
kind: 'main' | 'worktree' | 'submodule' | 'non-git' | 'unknown';
|
|
3
|
+
root: string;
|
|
4
|
+
gitTopLevel: string | null;
|
|
5
|
+
branch: string | null;
|
|
6
|
+
detached: boolean | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function inspectWorkspaceCheckout(root: string): CheckoutInfo;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.inspectWorkspaceCheckout = inspectWorkspaceCheckout;
|
|
37
|
+
// @implements A-SPEC-703
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const node_child_process_1 = require("node:child_process");
|
|
40
|
+
const root_1 = require("./root");
|
|
41
|
+
function inspectWorkspaceCheckout(root) {
|
|
42
|
+
const result = { kind: 'unknown', root, gitTopLevel: null, branch: null, detached: null };
|
|
43
|
+
const env = (0, root_1.cleanSubprocessEnv)();
|
|
44
|
+
// A caller's Git overrides must not redirect inspection to another checkout.
|
|
45
|
+
for (const key of Object.keys(env))
|
|
46
|
+
if (key.startsWith('GIT_'))
|
|
47
|
+
delete env[key];
|
|
48
|
+
const git = (...args) => (0, node_child_process_1.execFileSync)('git', ['-C', root, ...args], {
|
|
49
|
+
encoding: 'utf8', timeout: 5000, maxBuffer: 1024 * 1024, env,
|
|
50
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
51
|
+
}).trim();
|
|
52
|
+
try {
|
|
53
|
+
result.gitTopLevel = (0, root_1.canonicalPath)(git('rev-parse', '--show-toplevel'));
|
|
54
|
+
const gitDir = (0, root_1.canonicalPath)(git('rev-parse', '--absolute-git-dir'));
|
|
55
|
+
const common = (0, root_1.canonicalPath)(path.resolve(root, git('rev-parse', '--git-common-dir')));
|
|
56
|
+
const superproject = git('rev-parse', '--show-superproject-working-tree');
|
|
57
|
+
result.kind = superproject ? 'submodule' : gitDir !== common ? 'worktree' : 'main';
|
|
58
|
+
try {
|
|
59
|
+
result.branch = git('symbolic-ref', '--quiet', '--short', 'HEAD');
|
|
60
|
+
result.detached = false;
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
if (e.status === 1)
|
|
64
|
+
result.detached = true;
|
|
65
|
+
else
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
const err = e;
|
|
71
|
+
result.kind = err.status === 128 && String(err.stderr).includes('not a git repository') ? 'non-git' : 'unknown';
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WorkspaceIdentityStatus } from './workspace-identity';
|
|
2
|
+
import { CheckoutInfo } from './workspace-checkout';
|
|
3
|
+
export type { CheckoutInfo } from './workspace-checkout';
|
|
4
|
+
export type PreflightCheck = {
|
|
5
|
+
id: string;
|
|
6
|
+
status: 'pass' | 'blocked' | 'unknown';
|
|
7
|
+
detail: string;
|
|
8
|
+
actions: string[];
|
|
9
|
+
};
|
|
10
|
+
export type WorkspacePreflight = {
|
|
11
|
+
schema: 'holmes-workspace-preflight/1';
|
|
12
|
+
requestedRoot: string | null;
|
|
13
|
+
boundRoot: string | null;
|
|
14
|
+
boundSpecsRoot: string | null;
|
|
15
|
+
binding: 'matched' | 'mismatch' | 'unbound' | 'invalid';
|
|
16
|
+
identity: WorkspaceIdentityStatus | null;
|
|
17
|
+
checkout: CheckoutInfo | null;
|
|
18
|
+
checks: PreflightCheck[];
|
|
19
|
+
nextActions: string[];
|
|
20
|
+
};
|
|
21
|
+
export declare function inspectWorkspacePreflight(input: {
|
|
22
|
+
requestedRoot: string;
|
|
23
|
+
storeRoot?: string;
|
|
24
|
+
}): WorkspacePreflight;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.inspectWorkspacePreflight = inspectWorkspacePreflight;
|
|
37
|
+
// @implements A-SPEC-703
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const root_1 = require("./root");
|
|
41
|
+
const workspace_identity_1 = require("./workspace-identity");
|
|
42
|
+
const workspace_checkout_1 = require("./workspace-checkout");
|
|
43
|
+
function inspectWorkspacePreflight(input) {
|
|
44
|
+
const out = { schema: 'holmes-workspace-preflight/1', requestedRoot: null,
|
|
45
|
+
boundRoot: null, boundSpecsRoot: null, binding: 'invalid', identity: null, checkout: null, checks: [], nextActions: [] };
|
|
46
|
+
const check = (id, status, detail, actions = []) => {
|
|
47
|
+
out.checks.push({ id, status, detail, actions });
|
|
48
|
+
out.nextActions.push(...actions);
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
if (typeof input.requestedRoot !== 'string' || !path.isAbsolute(input.requestedRoot)) {
|
|
52
|
+
check('root', 'blocked', 'An absolute existing workspace directory is required.');
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
out.requestedRoot = (0, root_1.resolveProjectRoot)(input.requestedRoot, { includeGit: false }).root;
|
|
56
|
+
if (!input.storeRoot) {
|
|
57
|
+
out.binding = 'unbound';
|
|
58
|
+
check('binding', 'unknown', 'The server has no file-backed spec store.');
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
let existing = path.resolve(input.storeRoot);
|
|
62
|
+
while (!fs.existsSync(existing) && path.dirname(existing) !== existing)
|
|
63
|
+
existing = path.dirname(existing);
|
|
64
|
+
out.boundSpecsRoot = path.join((0, root_1.canonicalPath)(existing), path.relative(existing, path.resolve(input.storeRoot)));
|
|
65
|
+
out.boundRoot = (0, root_1.resolveProjectRoot)(existing, { includeGit: false }).root;
|
|
66
|
+
if (out.requestedRoot !== out.boundRoot) {
|
|
67
|
+
out.binding = 'mismatch';
|
|
68
|
+
check('binding', 'blocked', 'Requested workspace differs from the live server store.', ['Restart the MCP server with HOLMES_SPECS pointing to the intended workspace, then rerun workspace_preflight.']);
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
// Only after binding matches may we inspect checkout metadata or identity.
|
|
72
|
+
const requestedCheckout = (0, workspace_checkout_1.inspectWorkspaceCheckout)((0, root_1.canonicalPath)(input.requestedRoot));
|
|
73
|
+
if (requestedCheckout.gitTopLevel && requestedCheckout.gitTopLevel !== out.boundRoot) {
|
|
74
|
+
check('workspace-marker', 'blocked', 'The requested checkout inherits a different workspace marker.', ['Prepare the intended checkout explicitly; do not copy local replica state.']);
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
out.identity = (0, workspace_identity_1.workspaceIdentity)(out.boundRoot, 'status');
|
|
78
|
+
out.checkout = (0, workspace_checkout_1.inspectWorkspaceCheckout)(out.boundRoot);
|
|
79
|
+
out.binding = 'matched';
|
|
80
|
+
check('binding', 'pass', 'Requested workspace matches the live server store.');
|
|
81
|
+
if (out.identity.state === 'initialized')
|
|
82
|
+
check('identity', 'blocked', 'Canonical identity exists but this replica is unregistered.', ['Use workspace_identity operation register for this checkout before governed writes.']);
|
|
83
|
+
else
|
|
84
|
+
check('identity', 'pass', `Workspace identity is ${out.identity.state}.`);
|
|
85
|
+
check('checkout', out.checkout.kind === 'unknown' ? 'unknown' : 'pass', `Checkout kind: ${out.checkout.kind}.`);
|
|
86
|
+
check('runtime-enforcement', 'unknown', 'Binding and disk inspection do not prove current client hook enforcement.');
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
const error = e;
|
|
91
|
+
if (!(e instanceof workspace_identity_1.WorkspaceIdentityError) && !error.holmesRefusal && !['ENOENT', 'EACCES', 'EPERM', 'ENOTDIR'].includes(error.code ?? ''))
|
|
92
|
+
throw e;
|
|
93
|
+
out.binding = 'invalid';
|
|
94
|
+
out.identity = null;
|
|
95
|
+
out.checkout = null;
|
|
96
|
+
check('inspection', 'blocked', error.message, ['Preserve existing records and repair the reported path or identity explicitly.']);
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface TracedFilesInput {
|
|
2
|
+
/** What the scanner returned: repo-relative path and the spec ids the file anchors. */
|
|
3
|
+
files: readonly {
|
|
4
|
+
path: string;
|
|
5
|
+
anchors: readonly string[];
|
|
6
|
+
}[];
|
|
7
|
+
/** Ids whose status is `approved`. A draft anchor is not a trace. */
|
|
8
|
+
approvedIds: Iterable<string>;
|
|
9
|
+
/** Path prefixes that are not this project's source (vendored trees). Explicit, and echoed back. */
|
|
10
|
+
exclude?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface TracedFiles {
|
|
13
|
+
total: number;
|
|
14
|
+
traced: number;
|
|
15
|
+
excluded: number;
|
|
16
|
+
/** Sorted. */
|
|
17
|
+
untraced: string[];
|
|
18
|
+
measurable: boolean;
|
|
19
|
+
reason?: string;
|
|
20
|
+
/** One decimal, FLOORED; `null` when not measurable. */
|
|
21
|
+
tracedPct: number | null;
|
|
22
|
+
}
|
|
23
|
+
export interface AttestProvenance {
|
|
24
|
+
at: string;
|
|
25
|
+
specs: string;
|
|
26
|
+
exclude: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface AttestReport {
|
|
29
|
+
files: TracedFiles;
|
|
30
|
+
specs: {
|
|
31
|
+
total: number;
|
|
32
|
+
linked: number;
|
|
33
|
+
};
|
|
34
|
+
provenance: AttestProvenance;
|
|
35
|
+
}
|
|
36
|
+
export declare const ATTEST_BEGIN = "<!-- holmes-kit:attest:begin -->";
|
|
37
|
+
export declare const ATTEST_END = "<!-- holmes-kit:attest:end -->";
|
|
38
|
+
export declare const ATTEST_SCHEMA = "holmes-attest/1";
|
|
39
|
+
/** Above this many untraced files the text names none and points at `--json`. */
|
|
40
|
+
export declare const UNTRACED_LINE_CAP = 10;
|
|
41
|
+
/**
|
|
42
|
+
* Backslashes folded, one trailing slash. A prefix that means "everything" is DROPPED: excluding the
|
|
43
|
+
* whole tree would read as n/a at best and 100% at worst (the same rule A-SPEC-694 pinned for
|
|
44
|
+
* `cycleIgnore`). Sorted and de-duplicated so the provenance does not depend on how it was typed.
|
|
45
|
+
*/
|
|
46
|
+
export declare function normalizeExcludes(raw: readonly string[] | undefined): string[];
|
|
47
|
+
/** Floored to one decimal: 99.96 must not read as 100 — 100 means every file. */
|
|
48
|
+
export declare function flooredPct(num: number, den: number): number | null;
|
|
49
|
+
export declare function tracedFiles(input: TracedFilesInput): TracedFiles;
|
|
50
|
+
/**
|
|
51
|
+
* Where and when the number is true. `+dirty` because a commit alone would call an unreproducible
|
|
52
|
+
* number reproducible. The spec digest covers (id, seal) of every approved spec — that set is what
|
|
53
|
+
* decides the numerator. No clock anywhere.
|
|
54
|
+
*/
|
|
55
|
+
export declare function attestProvenance(input: {
|
|
56
|
+
commit?: string;
|
|
57
|
+
dirty: boolean;
|
|
58
|
+
approved: readonly {
|
|
59
|
+
id: string;
|
|
60
|
+
digest: string;
|
|
61
|
+
}[];
|
|
62
|
+
exclude: readonly string[];
|
|
63
|
+
}): AttestProvenance;
|
|
64
|
+
export declare function renderAttestText(r: AttestReport): string;
|
|
65
|
+
export declare function renderAttestJson(r: AttestReport): string;
|
|
66
|
+
/** Self-contained: no href, font, script or fetch. Only the ratio, the percentage and `at` go in. */
|
|
67
|
+
export declare function renderAttestSvg(r: AttestReport): string;
|
|
68
|
+
/** What goes between the markers. Carries the excludes, so the README says how to reproduce it. */
|
|
69
|
+
export declare function renderAttestMarker(r: AttestReport): string;
|
|
70
|
+
/**
|
|
71
|
+
* Replace what lies between the two markers — and ONLY when each appears exactly once, begin first.
|
|
72
|
+
* No marker is `no-marker`: the person never asked, so nothing is written. Anything else malformed is
|
|
73
|
+
* `unbalanced`: a lone begin marker followed by "replace to the end" is this feature's worst failure.
|
|
74
|
+
* The README's own line ending is kept, so a CRLF file does not become one whole-file diff.
|
|
75
|
+
*/
|
|
76
|
+
export declare function replaceMarkerRegion(readme: string, inner: string): {
|
|
77
|
+
ok: true;
|
|
78
|
+
text: string;
|
|
79
|
+
changed: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
ok: false;
|
|
82
|
+
reason: 'no-marker' | 'unbalanced';
|
|
83
|
+
};
|