@holmes-lab/holmes-kit 0.37.2 → 0.39.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 +44 -0
- package/README.md +17 -2
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve-status.js +2 -1
- package/dist/holmes/cli/approve.d.ts +1 -0
- package/dist/holmes/cli/approve.js +36 -4
- package/dist/holmes/cli/autonomy.d.ts +28 -0
- package/dist/holmes/cli/autonomy.js +62 -8
- package/dist/holmes/cli/doctor.js +12 -1
- package/dist/holmes/cli/index.js +64 -5
- package/dist/holmes/cli/mcp-processes.d.ts +32 -0
- package/dist/holmes/cli/mcp-processes.js +132 -0
- package/dist/holmes/cli/run-provision.d.ts +6 -0
- package/dist/holmes/cli/run-provision.js +114 -0
- package/dist/holmes/cli/run.d.ts +5 -0
- package/dist/holmes/cli/run.js +38 -6
- package/dist/holmes/cli/runtime-binding-approval.js +2 -3
- package/dist/holmes/governance/approval-queue.d.ts +12 -1
- package/dist/holmes/governance/approval-queue.js +23 -28
- package/dist/holmes/governance/autonomy.d.ts +3 -1
- package/dist/holmes/governance/autonomy.js +28 -2
- package/dist/holmes/governance/full-autonomy.d.ts +72 -0
- package/dist/holmes/governance/full-autonomy.js +308 -0
- package/dist/holmes/governance/tool-actions.js +2 -0
- package/dist/holmes/guardrail/operator-person.js +3 -2
- package/dist/holmes/guardrail/refusal-codes.js +19 -4
- package/dist/holmes/guardrail/risk-classifier.js +21 -3
- package/dist/holmes/guardrail/run-refusals.d.ts +6 -1
- package/dist/holmes/guardrail/run-refusals.js +19 -12
- package/dist/holmes/guardrail/run-stages.d.ts +5 -0
- package/dist/holmes/guardrail/run-stages.js +23 -3
- package/dist/holmes/guardrail/write-target.js +4 -1
- package/dist/holmes/hooks/pre-tool-use.d.ts +2 -0
- package/dist/holmes/hooks/pre-tool-use.js +88 -11
- package/dist/holmes/hooks/session-start.d.ts +5 -0
- package/dist/holmes/hooks/session-start.js +29 -1
- package/dist/holmes/hooks/stop.js +6 -4
- package/dist/holmes/mcp/elicit-approval.js +5 -6
- package/dist/holmes/mcp/handlers/approval-ask.d.ts +11 -0
- package/dist/holmes/mcp/handlers/approval-ask.js +18 -3
- package/dist/holmes/mcp/handlers/review-verdict.js +3 -2
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +2 -0
- package/dist/holmes/mcp/handlers/spec-approval.js +23 -5
- package/dist/holmes/mcp/handlers/workspace-preflight.d.ts +5 -0
- package/dist/holmes/mcp/handlers/workspace-preflight.js +10 -2
- package/dist/holmes/mcp/handlers.d.ts +12 -0
- package/dist/holmes/mcp/handlers.js +25 -3
- package/dist/holmes/mcp/operator-recovery.d.ts +7 -2
- package/dist/holmes/mcp/operator-recovery.js +15 -58
- package/dist/holmes/mcp/server-staleness.d.ts +43 -0
- package/dist/holmes/mcp/server-staleness.js +158 -0
- package/dist/holmes/mcp/server.js +26 -2
- package/dist/holmes/mcp/tool-schemas.js +14 -1
- package/dist/holmes/project/workspace-preflight.d.ts +5 -0
- package/dist/holmes/project/workspace-preflight.js +24 -1
- package/dist/holmes/review/verdicts.d.ts +5 -0
- package/dist/holmes/review/verdicts.js +16 -1
- package/package.json +1 -1
- package/playbooks/promote-slice/PLAYBOOK.md +2 -1
|
@@ -0,0 +1,132 @@
|
|
|
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.parsePsRows = parsePsRows;
|
|
37
|
+
exports.readPackageInstall = readPackageInstall;
|
|
38
|
+
exports.staleMcpServers = staleMcpServers;
|
|
39
|
+
exports.listProcessRows = listProcessRows;
|
|
40
|
+
exports.mcpProcessesRow = mcpProcessesRow;
|
|
41
|
+
exports.mcpProcessBannerLine = mcpProcessBannerLine;
|
|
42
|
+
// @implements A-SPEC-251.5
|
|
43
|
+
/**
|
|
44
|
+
* Running holmes-kit MCP servers that started before their install was upgraded.
|
|
45
|
+
*
|
|
46
|
+
* Measured 2026-10-23 (D1): the jarvis session's server served v0.36.0 under a 0.38.0 global install — two such
|
|
47
|
+
* processes had been alive a day and a half. A server older than A-SPEC-251.4 cannot say so itself; from outside, its
|
|
48
|
+
* process started before its package.json was written. Read-only: nothing here signals a process.
|
|
49
|
+
*/
|
|
50
|
+
const fs = __importStar(require("node:fs"));
|
|
51
|
+
const path = __importStar(require("node:path"));
|
|
52
|
+
const node_child_process_1 = require("node:child_process");
|
|
53
|
+
const TOLERANCE_MS = 2000;
|
|
54
|
+
const MAX_ROWS = 2000;
|
|
55
|
+
const SERVER_RE = /(?:^|\s)(\S*?)[\\/]bin[\\/]holmes-mcp\.js(?:\s|$)/;
|
|
56
|
+
/** Rows of `ps -Ao pid=,lstart=,command=` under LC_ALL=C: `<pid> <Dow Mon DD HH:MM:SS YYYY> <command>`. */
|
|
57
|
+
function parsePsRows(text) {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const line of text.split('\n').slice(0, MAX_ROWS)) {
|
|
60
|
+
const m = /^\s*(\d+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.*)$/.exec(line);
|
|
61
|
+
if (!m)
|
|
62
|
+
continue;
|
|
63
|
+
const startedMs = new Date(m[2]).getTime();
|
|
64
|
+
if (!Number.isFinite(startedMs))
|
|
65
|
+
continue;
|
|
66
|
+
out.push({ pid: Number(m[1]), startedMs, command: m[3].trim() });
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/** The holmes-kit package at `root`: its version and the mtime of its package.json (the install time). */
|
|
71
|
+
function readPackageInstall(root) {
|
|
72
|
+
try {
|
|
73
|
+
const file = path.join(root, 'package.json');
|
|
74
|
+
const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
75
|
+
if (pkg.name !== '@holmes-lab/holmes-kit' || typeof pkg.version !== 'string')
|
|
76
|
+
return null;
|
|
77
|
+
return { version: pkg.version.slice(0, 40), installedMs: fs.statSync(file).mtimeMs };
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function staleMcpServers(rows, readPkg) {
|
|
84
|
+
const out = [];
|
|
85
|
+
const cache = new Map();
|
|
86
|
+
for (const r of rows) {
|
|
87
|
+
const m = SERVER_RE.exec(r.command);
|
|
88
|
+
if (!m || m[1] === '')
|
|
89
|
+
continue;
|
|
90
|
+
const root = m[1];
|
|
91
|
+
if (!cache.has(root))
|
|
92
|
+
cache.set(root, readPkg(root));
|
|
93
|
+
const pkg = cache.get(root);
|
|
94
|
+
if (!pkg || r.startedMs >= pkg.installedMs - TOLERANCE_MS)
|
|
95
|
+
continue;
|
|
96
|
+
out.push({ pid: r.pid, startedAt: new Date(r.startedMs).toISOString(), packageRoot: root,
|
|
97
|
+
installedVersion: pkg.version, installedAt: new Date(pkg.installedMs).toISOString() });
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
/** The process table, or null where it cannot be read (win32, or ps failing). Bounded by a 3 s timeout. */
|
|
102
|
+
function listProcessRows() {
|
|
103
|
+
if (process.platform === 'win32')
|
|
104
|
+
return null;
|
|
105
|
+
try {
|
|
106
|
+
const p = (0, node_child_process_1.spawnSync)('ps', ['-Ao', 'pid=,lstart=,command='], { encoding: 'utf8', timeout: 3000, env: { ...process.env, LC_ALL: 'C', LANG: 'C' }, maxBuffer: 8 * 1024 * 1024 });
|
|
107
|
+
if (p.status !== 0 || typeof p.stdout !== 'string')
|
|
108
|
+
return null;
|
|
109
|
+
return parsePsRows(p.stdout);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const STEP = 'restart those sessions (their MCP servers) to load the installed build; nothing here stops a process';
|
|
116
|
+
function mcpProcessesRow(stale) {
|
|
117
|
+
const name = 'mcp server processes';
|
|
118
|
+
if (stale === null)
|
|
119
|
+
return { name, level: 'INFO', detail: 'process scan unavailable on this platform' };
|
|
120
|
+
if (stale.length === 0)
|
|
121
|
+
return { name, level: 'PASS', detail: 'no running holmes-kit MCP server predates its install' };
|
|
122
|
+
const list = stale.slice(0, 20).map((s) => `pid ${s.pid} (started ${s.startedAt}, ${s.packageRoot}, now v${s.installedVersion} since ${s.installedAt})`).join('; ');
|
|
123
|
+
return { name, level: 'WARN', detail: `${stale.length} holmes-kit MCP server(s) started before their install was upgraded: ${list} — ${STEP}` };
|
|
124
|
+
}
|
|
125
|
+
/** One banner line for the servers running from the workspace's wired package root, or ''. */
|
|
126
|
+
function mcpProcessBannerLine(stale, wiredRoot) {
|
|
127
|
+
const mine = stale.filter((s) => path.resolve(s.packageRoot) === path.resolve(wiredRoot));
|
|
128
|
+
if (mine.length === 0)
|
|
129
|
+
return '';
|
|
130
|
+
return `[Holmes-Kit] ${mine.length} holmes-kit MCP server process(es) from ${wiredRoot} started before it was upgraded to v${mine[0].installedVersion} `
|
|
131
|
+
+ `(${mine.slice(0, 10).map((s) => `pid ${s.pid}`).join(', ')}): sessions started then still serve the older tools — ${STEP}`;
|
|
132
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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.provisionWorktree = provisionWorktree;
|
|
37
|
+
// @implements A-SPEC-774.29
|
|
38
|
+
/**
|
|
39
|
+
* `run start --provision`: make an orchestrator's worktree governed.
|
|
40
|
+
*
|
|
41
|
+
* Measured 2026-10-23 (D11): a real 0.38.0 `run start --engine claude` on a jarvis copy's worktree failed `mcp` and
|
|
42
|
+
* `versions` — jarvis keeps `.mcp.json` (it held an approval token) and `.claude/settings.local.json` out of git, so a
|
|
43
|
+
* fresh worktree carries neither. Provisioning writes those two files inside the worktree, and only when git ignores
|
|
44
|
+
* them there: built fresh from THIS CLI's package root (the build the run pins), nothing read from the main checkout
|
|
45
|
+
* (no secret copied), and nothing left once the worktree is removed. `init` would write tracked guidance files into
|
|
46
|
+
* the worktree; runtime-binding is machine-level state that outlives it.
|
|
47
|
+
*/
|
|
48
|
+
const fs = __importStar(require("node:fs"));
|
|
49
|
+
const path = __importStar(require("node:path"));
|
|
50
|
+
const node_child_process_1 = require("node:child_process");
|
|
51
|
+
const init_1 = require("./init");
|
|
52
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
53
|
+
const MCP_FILE = '.mcp.json';
|
|
54
|
+
const LOCAL_SETTINGS = path.join('.claude', 'settings.local.json');
|
|
55
|
+
const readJson = (file) => {
|
|
56
|
+
try {
|
|
57
|
+
const v = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
58
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v) ? v : null;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const namesHolmes = (file) => {
|
|
65
|
+
try {
|
|
66
|
+
return /holmes/i.test(fs.readFileSync(file, 'utf8'));
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/** Whether git ignores `rel` in the worktree. `check-ignore` exits 0 for an ignored path. */
|
|
73
|
+
function ignored(worktree, rel) {
|
|
74
|
+
const r = (0, node_child_process_1.spawnSync)('git', ['-C', worktree, 'check-ignore', '-q', '--', rel], { stdio: 'ignore', timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER });
|
|
75
|
+
return r.status === 0;
|
|
76
|
+
}
|
|
77
|
+
function provisionWorktree(worktree, engine, packageRoot) {
|
|
78
|
+
if (engine !== 'claude') {
|
|
79
|
+
return { refused: `provisioning is not available for ${engine}: its gate is wired at user level (${engine === 'codex' ? '$CODEX_HOME/hooks.json' : 'the agy settings'}), which a worktree cannot carry without leaving a trace — wire it with holmes-kit init or runtime-binding` };
|
|
80
|
+
}
|
|
81
|
+
const plan = [];
|
|
82
|
+
const mcpPath = path.join(worktree, MCP_FILE);
|
|
83
|
+
if (!namesHolmes(mcpPath)) {
|
|
84
|
+
plan.push({ rel: MCP_FILE, write: () => {
|
|
85
|
+
const doc = readJson(mcpPath) ?? {};
|
|
86
|
+
const servers = (doc.mcpServers !== null && typeof doc.mcpServers === 'object' && !Array.isArray(doc.mcpServers) ? doc.mcpServers : {});
|
|
87
|
+
servers['holmes-kit'] = { command: 'node', args: [path.join(packageRoot, 'bin', 'holmes-mcp.js')], env: { HOLMES_SPECS: '.ax/specs' } };
|
|
88
|
+
fs.writeFileSync(mcpPath, JSON.stringify({ ...doc, mcpServers: servers }, null, 2) + '\n');
|
|
89
|
+
} });
|
|
90
|
+
}
|
|
91
|
+
const settingsPath = path.join(worktree, LOCAL_SETTINGS);
|
|
92
|
+
if (!namesHolmes(path.join(worktree, '.claude', 'settings.json')) && !namesHolmes(settingsPath)) {
|
|
93
|
+
plan.push({ rel: LOCAL_SETTINGS, write: () => {
|
|
94
|
+
const hp = (0, init_1.buildHookPlan)(packageRoot, '.*');
|
|
95
|
+
const doc = readJson(settingsPath) ?? {};
|
|
96
|
+
const hooks = (doc.hooks !== null && typeof doc.hooks === 'object' && !Array.isArray(doc.hooks) ? doc.hooks : {});
|
|
97
|
+
const add = (event, entry) => { hooks[event] = [...(Array.isArray(hooks[event]) ? hooks[event] : []), entry]; };
|
|
98
|
+
add('PreToolUse', { matcher: hp.preToolUseMatcher, hooks: [{ type: 'command', command: hp.preToolUseCommand }] });
|
|
99
|
+
add('Stop', { hooks: [{ type: 'command', command: hp.stopCommand, timeout: 75 }] });
|
|
100
|
+
add('SessionStart', { hooks: [{ type: 'command', command: hp.sessionStartCommand }] });
|
|
101
|
+
const enabled = Array.isArray(doc.enabledMcpjsonServers) ? doc.enabledMcpjsonServers : [];
|
|
102
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
103
|
+
fs.writeFileSync(settingsPath, JSON.stringify({ ...doc, hooks, enabledMcpjsonServers: [...new Set([...enabled, 'holmes-kit'])] }, null, 2) + '\n');
|
|
104
|
+
} });
|
|
105
|
+
}
|
|
106
|
+
// Every file is checked before any is written: a refusal leaves the worktree as it was.
|
|
107
|
+
const exposed = plan.filter((p) => !ignored(worktree, p.rel)).map((p) => p.rel);
|
|
108
|
+
if (exposed.length > 0) {
|
|
109
|
+
return { refused: `${exposed.join(', ')} is not ignored by git in ${worktree}; provisioning would leave wiring that could be committed — ignore it in the repository, or wire the worktree another way` };
|
|
110
|
+
}
|
|
111
|
+
for (const p of plan)
|
|
112
|
+
p.write();
|
|
113
|
+
return { written: plan.map((p) => p.rel) };
|
|
114
|
+
}
|
package/dist/holmes/cli/run.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export interface RunOptions {
|
|
|
18
18
|
why?: string;
|
|
19
19
|
/** @implements A-SPEC-774.20, A-SPEC-774.24 — the unreadable version fields to start despite, by name; recorded. */
|
|
20
20
|
acceptUnknownVersions?: string[];
|
|
21
|
+
/** @implements A-SPEC-774.29 — write git-ignored worktree-local wiring pinned to this CLI's build before the checks. */
|
|
22
|
+
provision?: boolean;
|
|
23
|
+
/** @implements A-SPEC-102.10 — the review policy: a cap on failing review rounds (1–20), and strict review. */
|
|
24
|
+
reviewRounds?: string;
|
|
25
|
+
strictReview?: boolean;
|
|
21
26
|
}
|
|
22
27
|
export interface RunDeps {
|
|
23
28
|
home?: string;
|
package/dist/holmes/cli/run.js
CHANGED
|
@@ -39,7 +39,7 @@ exports.unreadableVersions = unreadableVersions;
|
|
|
39
39
|
exports.parseAcceptedVersions = parseAcceptedVersions;
|
|
40
40
|
exports.versionsCheck = versionsCheck;
|
|
41
41
|
exports.runRun = runRun;
|
|
42
|
-
// @implements A-SPEC-774.17, A-SPEC-779, A-SPEC-780, A-SPEC-102.3, A-SPEC-102.5, A-SPEC-781, A-SPEC-774.20, A-SPEC-781.2
|
|
42
|
+
// @implements A-SPEC-774.17, A-SPEC-779, A-SPEC-780, A-SPEC-102.3, A-SPEC-102.5, A-SPEC-781, A-SPEC-774.20, A-SPEC-781.2, A-SPEC-774.29, A-SPEC-102.10
|
|
43
43
|
const node_child_process_1 = require("node:child_process");
|
|
44
44
|
const crypto = __importStar(require("node:crypto"));
|
|
45
45
|
const config_1 = require("../config/config");
|
|
@@ -120,7 +120,7 @@ function runVersions(worktree, engine, deps) {
|
|
|
120
120
|
mcp = null;
|
|
121
121
|
}
|
|
122
122
|
const hookFiles = engine === 'claude'
|
|
123
|
-
? [path.join(worktree, '.claude', 'settings.json'), path.join(home, '.claude', 'settings.json')]
|
|
123
|
+
? [path.join(worktree, '.claude', 'settings.json'), path.join(worktree, '.claude', 'settings.local.json'), path.join(home, '.claude', 'settings.json')]
|
|
124
124
|
: engine === 'codex' ? [path.join(deps.codexHome ?? process.env.CODEX_HOME ?? path.join(home, '.codex'), 'hooks.json')] : [];
|
|
125
125
|
const hookPkg = hookFiles.flatMap((f) => hookCommandsIn(readText(f))).map(hookCommandPackage).find((v) => v !== null) ?? null;
|
|
126
126
|
return {
|
|
@@ -178,7 +178,7 @@ function versionsCheck(v, engine, accepted) {
|
|
|
178
178
|
return { name: 'versions', status: 'pass', detail: `the MCP and hook versions equal this CLI ${v.cli}, and every ${s.exempt.length > 0 ? 'other ' : ''}build id was read${exemptNote}` };
|
|
179
179
|
}
|
|
180
180
|
const HEADLESS = { claude: ['claude', '-p'], codex: ['codex', 'exec'], agy: ['agy', '-p'] };
|
|
181
|
-
const USAGE = 'usage: holmes-kit run start --worktree <dir> --engine claude|codex|agy [--engine-arg <a>]... [--accept-unknown-versions <field,...>] [--target <dir>]\n'
|
|
181
|
+
const USAGE = 'usage: holmes-kit run start --worktree <dir> --engine claude|codex|agy [--engine-arg <a>]... [--accept-unknown-versions <field,...>] [--provision] [--review-rounds <1-20>] [--strict-review] [--target <dir>]\n'
|
|
182
182
|
+ ' holmes-kit run status [--target <dir>]\n'
|
|
183
183
|
+ ' holmes-kit run transition --id <run_id> --to <stage> --key <stop_key> [--why <text>] [--target <dir>]\n'
|
|
184
184
|
+ ' holmes-kit run stop --id <run_id> --key <stop_key> [--target <dir>]\n';
|
|
@@ -212,9 +212,11 @@ function checks(main, worktree, engine, args, deps) {
|
|
|
212
212
|
out.push(mcp ? { name: 'mcp', status: 'pass', detail: `the ${engine} MCP wiring in the worktree names holmes-kit` }
|
|
213
213
|
: { name: 'mcp', status: 'fail', detail: `the worktree carries no ${engine} MCP wiring that names holmes-kit` });
|
|
214
214
|
if (engine === 'claude') {
|
|
215
|
-
|
|
215
|
+
// @implements A-SPEC-774.29 — settings.local.json too: Claude loads it, and init writes the hooks there.
|
|
216
|
+
const hooked = namesHolmes(readText(path.join(worktree, '.claude', 'settings.json'))) || namesHolmes(readText(path.join(worktree, '.claude', 'settings.local.json')))
|
|
217
|
+
|| namesHolmes(readText(path.join(home, '.claude', 'settings.json')));
|
|
216
218
|
out.push(hooked ? { name: 'gate', status: 'pass', detail: 'a Holmes hook is wired in the project or user Claude settings' }
|
|
217
|
-
: { name: 'gate', status: 'fail', detail: 'no Holmes hook in <worktree>/.claude/settings.json or ~/.claude/settings.json — the Claude gate would not load' });
|
|
219
|
+
: { name: 'gate', status: 'fail', detail: 'no Holmes hook in <worktree>/.claude/settings.json, <worktree>/.claude/settings.local.json or ~/.claude/settings.json — the Claude gate would not load' });
|
|
218
220
|
}
|
|
219
221
|
else if (engine === 'codex') {
|
|
220
222
|
const codexHome = deps.codexHome ?? process.env.CODEX_HOME ?? path.join(home, '.codex');
|
|
@@ -269,12 +271,39 @@ function runRun(sub, opts, io, deps = {}) {
|
|
|
269
271
|
const engine = opts.engine;
|
|
270
272
|
const worktree = path.resolve(opts.worktree);
|
|
271
273
|
const args = opts.engineArgs ?? [];
|
|
274
|
+
// @implements A-SPEC-102.10 — the review policy is the orchestrator's, set once here and recorded.
|
|
275
|
+
let reviewRounds;
|
|
276
|
+
if (opts.reviewRounds !== undefined) {
|
|
277
|
+
const n = Number(opts.reviewRounds);
|
|
278
|
+
if (!/^\d+$/.test(opts.reviewRounds.trim()) || !Number.isInteger(n) || n < 1 || n > 20) {
|
|
279
|
+
io.stderr(`--review-rounds must be an integer from 1 to 20 (got ${JSON.stringify(opts.reviewRounds).slice(0, 40)})\n${USAGE}`);
|
|
280
|
+
return 2;
|
|
281
|
+
}
|
|
282
|
+
reviewRounds = n;
|
|
283
|
+
}
|
|
284
|
+
const review = reviewRounds !== undefined || opts.strictReview
|
|
285
|
+
? { ...(reviewRounds !== undefined ? { rounds: reviewRounds } : {}), ...(opts.strictReview ? { strict: true } : {}) } : undefined;
|
|
286
|
+
// @implements A-SPEC-774.29 — provisioning runs before the checks, so they judge the worktree as provisioned.
|
|
287
|
+
let provisioned = [];
|
|
288
|
+
let provisionRefusal = null;
|
|
289
|
+
if (opts.provision) {
|
|
290
|
+
const { provisionWorktree } = require('./run-provision');
|
|
291
|
+
const p = provisionWorktree(worktree, engine, path.resolve(__dirname, '..', '..', '..'));
|
|
292
|
+
if ('refused' in p)
|
|
293
|
+
provisionRefusal = p.refused;
|
|
294
|
+
else
|
|
295
|
+
provisioned = p.written;
|
|
296
|
+
}
|
|
272
297
|
const found = checks(main, worktree, engine, args, deps);
|
|
298
|
+
if (opts.provision) {
|
|
299
|
+
found.unshift(provisionRefusal !== null ? { name: 'provision', status: 'fail', detail: provisionRefusal }
|
|
300
|
+
: { name: 'provision', status: 'pass', detail: provisioned.length > 0 ? `wrote ${provisioned.join(', ')} (git-ignored, pinned to this CLI)` : 'the worktree already carries Holmes wiring' });
|
|
301
|
+
}
|
|
273
302
|
// @implements A-SPEC-774.18 — the builds that would govern the run, pinned before anything is written.
|
|
274
303
|
const versions = runVersions(worktree, engine, deps);
|
|
275
304
|
found.push(versionsCheck(versions, engine, opts.acceptUnknownVersions ?? []));
|
|
276
305
|
if (found.some((c) => c.status === 'fail')) {
|
|
277
|
-
io.stdout(`${JSON.stringify({ ok: false, refused: 'a check failed — the run would not be governed', checks: found, versions }, null, 2)}\n`);
|
|
306
|
+
io.stdout(`${JSON.stringify({ ok: false, refused: 'a check failed — the run would not be governed', checks: found, versions, ...(provisioned.length > 0 ? { provisioned } : {}) }, null, 2)}\n`);
|
|
278
307
|
return 3;
|
|
279
308
|
}
|
|
280
309
|
const now = (deps.now ?? (() => new Date()))();
|
|
@@ -288,6 +317,8 @@ function runRun(sub, opts, io, deps = {}) {
|
|
|
288
317
|
const rec = {
|
|
289
318
|
run_id: runId, worktree: fs.realpathSync(worktree), sessions: [], engine, started: now.toISOString(), stop_key_sha256: (0, run_records_1.keyHash)(stopKey),
|
|
290
319
|
versions, ...(base ? { base } : {}),
|
|
320
|
+
...(provisioned.length > 0 ? { provisioned } : {}), // @implements A-SPEC-774.29
|
|
321
|
+
...(review ? { review } : {}), // @implements A-SPEC-102.10
|
|
291
322
|
...(opts.scope && opts.scope.length > 0 ? { scope: [...opts.scope] } : {}),
|
|
292
323
|
...(accepted.length > 0 ? { accepted_unknown_versions: accepted } : {}),
|
|
293
324
|
...(exempt.length > 0 ? { exempt_unknown_versions: exempt } : {}),
|
|
@@ -302,6 +333,7 @@ function runRun(sub, opts, io, deps = {}) {
|
|
|
302
333
|
(0, run_refusals_1.appendRunEvent)(main, runId, { ts: now.toISOString(), event: 'stages_interpreted', notes: stageNotes });
|
|
303
334
|
io.stdout(`${JSON.stringify({
|
|
304
335
|
ok: true, run_id: runId, worktree, record, env: { HOLMES_RUN_ID: runId }, command: [...HEADLESS[engine], ...args],
|
|
336
|
+
...(provisioned.length > 0 ? { provisioned } : {}),
|
|
305
337
|
stop_key: stopKey, versions, checks: found, ...(stageNotes.length > 0 ? { stage_notes: stageNotes } : {}),
|
|
306
338
|
}, null, 2)}\n`);
|
|
307
339
|
return 0;
|
|
@@ -35,9 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.runtimePlanDigest = runtimePlanDigest;
|
|
37
37
|
exports.applyApprovedRuntimePlan = applyApprovedRuntimePlan;
|
|
38
|
-
// @implements A-SPEC-752, A-SPEC-752.14, A-SPEC-770.3, A-SPEC-770.6
|
|
38
|
+
// @implements A-SPEC-752, A-SPEC-752.14, A-SPEC-770.3, A-SPEC-770.6, A-SPEC-792.1
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
|
-
const npx_bin_1 = require("../project/npx-bin");
|
|
41
40
|
const node_crypto_1 = require("node:crypto");
|
|
42
41
|
const risk_gate_1 = require("../guardrail/risk-gate");
|
|
43
42
|
const approval_grants_1 = require("../governance/approval-grants");
|
|
@@ -83,7 +82,7 @@ function applyApprovedRuntimePlan(root, subject, envApproval, check, apply, appr
|
|
|
83
82
|
const id = (0, approval_queue_1.approvalRequestId)(action.kind, target);
|
|
84
83
|
if (result.reason !== 'written' && result.reason !== 'duplicate')
|
|
85
84
|
throw new Error(`Cannot queue governance-wiring approval: ${result.reason}; nothing installed`);
|
|
86
|
-
throw new Error(`governance-wiring approval required for plan ${subject}; request ${id}. In ${approvalRoot === root ? 'this workspace' : `the workspace ${approvalRoot}`}
|
|
85
|
+
throw new Error(`governance-wiring approval required for plan ${subject}; request ${id}. In ${approvalRoot === root ? 'this workspace' : `the workspace ${approvalRoot}`} the person approves request ${id} in a session's approval form (approval_ask with id "${id}"), then retry the same runtime-binding command. If an old decision remains, revoke it and retry to request the current plan.`);
|
|
87
86
|
};
|
|
88
87
|
check();
|
|
89
88
|
if (!resolve())
|
|
@@ -29,7 +29,13 @@ export declare const DECISION_KINDS: ReadonlySet<string>;
|
|
|
29
29
|
* without a title (A-SPEC-770.1's bytes). Every field is flattened and bounded and loses `]`, so the bracket closes once.
|
|
30
30
|
*/
|
|
31
31
|
export declare function requestLabel(kind: string | undefined, target: string | undefined, title: string | undefined): string;
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @implements A-SPEC-792.1 — the header and the in-session route only. The `운영자: … approve --grant <id> --target …`
|
|
34
|
+
* clause (A-SPEC-770, 770.1, 770.2) is gone: an agent relayed it verbatim and the person typed it in a terminal
|
|
35
|
+
* (field report 2026-10-22), the UX REQ-792 removes. The request id still names the workspace's queue entry, and the
|
|
36
|
+
* approve CLI still finds it by id; nothing tells a person to type it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function pendingRequestLine(id: string, kind?: string, _root?: string, title?: string, target?: string): string;
|
|
33
39
|
/**
|
|
34
40
|
* @implements A-SPEC-718.5 — the in-session route, addressed to the agent: since A-SPEC-779.4 neither the agent's shell
|
|
35
41
|
* nor the session's `!` can type the operator line above, so without this line an agent has no way to ask.
|
|
@@ -48,6 +54,8 @@ export interface RefusalRecord {
|
|
|
48
54
|
reasonBytes?: number;
|
|
49
55
|
/** @implements A-SPEC-779.2 — the run that filed it; absent outside a run. */
|
|
50
56
|
requester_run?: string;
|
|
57
|
+
/** @implements A-SPEC-779.7 — the MCP server instance that filed it; absent for hooks and the CLI. */
|
|
58
|
+
requester_server?: string;
|
|
51
59
|
}
|
|
52
60
|
export declare function refusalsFilename(replica: string): string;
|
|
53
61
|
/** Born split: there is no legacy single `refusals.jsonl` — the file did not exist before replicas did. */
|
|
@@ -86,7 +94,10 @@ export interface PendingRequest {
|
|
|
86
94
|
title?: string;
|
|
87
95
|
/** @implements A-SPEC-779.2 — the run that filed it, the only one that may withdraw it; absent outside a run. */
|
|
88
96
|
requesterRun?: string;
|
|
97
|
+
/** @implements A-SPEC-779.7 — the MCP server instance that filed it (`<pid>:<startedAt>`), which may withdraw it. */
|
|
98
|
+
requesterServer?: string;
|
|
89
99
|
}
|
|
100
|
+
export declare function setRequesterServer(instance: string | undefined): void;
|
|
90
101
|
export interface QueueState {
|
|
91
102
|
pending: PendingRequest[];
|
|
92
103
|
/**
|
|
@@ -40,6 +40,7 @@ exports.approvalAskLine = approvalAskLine;
|
|
|
40
40
|
exports.refusalsFilename = refusalsFilename;
|
|
41
41
|
exports.isRefusalsFilename = isRefusalsFilename;
|
|
42
42
|
exports.readRefusals = readRefusals;
|
|
43
|
+
exports.setRequesterServer = setRequesterServer;
|
|
43
44
|
exports.approvalRequestId = approvalRequestId;
|
|
44
45
|
exports.foldQueue = foldQueue;
|
|
45
46
|
exports.enqueueApprovalRequest = enqueueApprovalRequest;
|
|
@@ -56,7 +57,6 @@ const execution_context_1 = require("../project/execution-context");
|
|
|
56
57
|
const run_mode_1 = require("./run-mode");
|
|
57
58
|
const root_1 = require("../project/root");
|
|
58
59
|
const node_crypto_1 = require("node:crypto");
|
|
59
|
-
const npx_bin_1 = require("../project/npx-bin");
|
|
60
60
|
const fs = __importStar(require("node:fs"));
|
|
61
61
|
const path = __importStar(require("node:path"));
|
|
62
62
|
const screen_safe_1 = require("../cli/screen-safe");
|
|
@@ -110,26 +110,15 @@ function requestLabel(kind, target, title) {
|
|
|
110
110
|
const f = (s, max) => (0, screen_safe_1.flattenField)(s, max).replace(/[\]「」]/g, ' ').trim();
|
|
111
111
|
return ` · ${f(kind ?? '', 40)} ${f(target ?? '', 60)} 「${f(title, 80)}」`;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
/**
|
|
114
|
+
* @implements A-SPEC-792.1 — the header and the in-session route only. The `운영자: … approve --grant <id> --target …`
|
|
115
|
+
* clause (A-SPEC-770, 770.1, 770.2) is gone: an agent relayed it verbatim and the person typed it in a terminal
|
|
116
|
+
* (field report 2026-10-22), the UX REQ-792 removes. The request id still names the workspace's queue entry, and the
|
|
117
|
+
* approve CLI still finds it by id; nothing tells a person to type it.
|
|
118
|
+
*/
|
|
119
|
+
function pendingRequestLine(id, kind, _root, title, target) {
|
|
114
120
|
const label = requestLabel(kind, target, title); // @implements A-SPEC-770.12
|
|
115
|
-
|
|
116
|
-
const command = `${(0, npx_bin_1.holmesKitCommand)(root)} approve`; // A-SPEC-770.6 — the root the request is stored in
|
|
117
|
-
// @implements A-SPEC-770.2 — the request lives in the refusal log / queue of the workspace whose hook refused, not in
|
|
118
|
-
// the shell's cwd (measured 2026-10-12: a command run under a worktree filed its request in the development root;
|
|
119
|
-
// 2026-10-13, Codex X1: the hint carried no `--target` at all). With a root, every command names it; a root with
|
|
120
|
-
// white space is double-quoted once; a root is never folded or relativised. Without a root the A-SPEC-770.1 lines
|
|
121
|
-
// are produced byte for byte.
|
|
122
|
-
const targetFlag = root === undefined ? '' : ` --target ${/\s/.test(root) ? `"${root}"` : root}`;
|
|
123
|
-
// @implements A-SPEC-770 — a request outside the decision inbox (A-SPEC-563.1 routes gate refusals to the local
|
|
124
|
-
// refusal log) names the id-bearing command, because the bare command opens a screen that by design does not list
|
|
125
|
-
// it. Field report (jarvis, 2026-10-11): the operator ran the bare command, saw six old inbox requests, and the
|
|
126
|
-
// agent's shell command was refused again with the same id. A decision kind keeps the short line: it IS listed.
|
|
127
|
-
// @implements A-SPEC-770.1 — the id rides the `--grant` flag: the CLI refuses a positional id (`unexpected
|
|
128
|
-
// argument: req-…`, measured by the operator on 0.35.17 with the command this line used to name).
|
|
129
|
-
if (kind !== undefined && !exports.DECISION_KINDS.has(kind)) {
|
|
130
|
-
return `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${id}${targetFlag} — 인박스 화면에는 뜨지 않는 거부입니다(${command} --refusals${targetFlag} 로 조회)${approvalAskLine(id)}`;
|
|
131
|
-
}
|
|
132
|
-
return root === undefined ? `\n[승인 대기 ${id}${label}] 운영자: ${command}${approvalAskLine(id)}` : `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${id}${targetFlag}${approvalAskLine(id)}`;
|
|
121
|
+
return `\n[승인 대기 ${id}${label}]${approvalAskLine(id)}`;
|
|
133
122
|
}
|
|
134
123
|
/**
|
|
135
124
|
* @implements A-SPEC-718.5 — the in-session route, addressed to the agent: since A-SPEC-779.4 neither the agent's shell
|
|
@@ -183,6 +172,15 @@ function readRefusals(root) {
|
|
|
183
172
|
}
|
|
184
173
|
return out.sort((a, b) => (a.r.ts < b.r.ts ? -1 : a.r.ts > b.r.ts ? 1 : a.i - b.i)).map((e) => e.r);
|
|
185
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* @implements A-SPEC-779.7 — the requester key of a filing made inside the MCP server: its instance id, set once at
|
|
177
|
+
* server start. Process-global on purpose: a request is filed deep inside handlers that never see the server. Hooks and
|
|
178
|
+
* the CLI never set it, so their filings carry no `requester_server`.
|
|
179
|
+
*/
|
|
180
|
+
let requesterServer;
|
|
181
|
+
function setRequesterServer(instance) {
|
|
182
|
+
requesterServer = typeof instance === 'string' && instance !== '' ? instance.slice(0, 120) : undefined;
|
|
183
|
+
}
|
|
186
184
|
/**
|
|
187
185
|
* Deterministic request id from the action's identity.
|
|
188
186
|
*
|
|
@@ -280,6 +278,7 @@ function foldQueue(lines, opts) {
|
|
|
280
278
|
...(typeof e.risk === 'string' && e.risk !== '' ? { risk: e.risk } : {}),
|
|
281
279
|
...(typeof e.title === 'string' && e.title !== '' ? { title: e.title } : {}), // @implements A-SPEC-770.12
|
|
282
280
|
...(typeof e.requester_run === 'string' && e.requester_run !== '' ? { requesterRun: e.requester_run } : {}), // @implements A-SPEC-779.2
|
|
281
|
+
...(typeof e.requester_server === 'string' && e.requester_server !== '' ? { requesterServer: e.requester_server } : {}), // @implements A-SPEC-779.7
|
|
283
282
|
});
|
|
284
283
|
}
|
|
285
284
|
break;
|
|
@@ -438,6 +437,7 @@ function enqueueApprovalRequestDetailed(root, req) {
|
|
|
438
437
|
...(typeof req.risk === 'string' && req.risk !== '' ? { risk: req.risk } : {}),
|
|
439
438
|
...(typeof req.title === 'string' && req.title.trim() !== '' ? { title: (0, screen_safe_1.flattenField)(req.title, 200) } : {}), // @implements A-SPEC-770.12
|
|
440
439
|
...(requesterRun ? { requester_run: requesterRun } : {}),
|
|
440
|
+
...(requesterServer ? { requester_server: requesterServer } : {}), // @implements A-SPEC-779.7
|
|
441
441
|
// @implements A-SPEC-564.2 — only the refusal log carries the feedback cost; inbox kinds have
|
|
442
442
|
// no deny text to measure.
|
|
443
443
|
...(!exports.DECISION_KINDS.has(req.kind) && typeof req.reasonBytes === 'number' && Number.isFinite(req.reasonBytes)
|
|
@@ -571,14 +571,8 @@ function queueHint(root, req, opts) {
|
|
|
571
571
|
// template-owned margin; this producer, read by the operator AND relayed by the agent, never got
|
|
572
572
|
// one. The first row keeps the template's own opening; the rest sit under the margin.
|
|
573
573
|
const question = `\n[보류 — 운영자 질문: ${(0, screen_safe_1.flattenField)(held.question ?? '(질문 없음)', 300)}] 게이트는 닫혀 있습니다.`;
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
// would change the command the operator is being asked to execute.
|
|
577
|
-
return (0, screen_safe_1.wrapColumns)(question + ' 이 질문에 대한 답을 사용자에게 보고하십시오. 결정은 운영자 승인 UI에서 내립니다.', 76, ' \u2502 ')
|
|
578
|
-
+ `\n운영자 검토: ${opts.reviewCommand}`;
|
|
579
|
-
}
|
|
580
|
-
return (0, screen_safe_1.wrapColumns)(question
|
|
581
|
-
+ ` 이 질문에 대한 답을 사용자에게 보고하십시오. 결정은 운영자가 ${(0, npx_bin_1.holmesKitCommand)(root)} approve 에서 내립니다.`, 76, ' \u2502 ');
|
|
574
|
+
// @implements A-SPEC-792.1 — the decision is the person's in the session form, never a command to type.
|
|
575
|
+
return (0, screen_safe_1.wrapColumns)(question + ' 이 질문에 대한 답을 사용자에게 보고하십시오. 결정은 세션 승인 창에서 내립니다 — 답을 받은 뒤 approval_ask 로 ' + id + ' 를 다시 물으십시오.', 76, ' \u2502 ');
|
|
582
576
|
}
|
|
583
577
|
const decided = state.decisions[id];
|
|
584
578
|
const denialLine = decided?.event === 'denied'
|
|
@@ -687,5 +681,6 @@ function asPendingRequest(id, occurrences) {
|
|
|
687
681
|
lastTs: latest.ts,
|
|
688
682
|
...(latest.replica ? { replica: latest.replica } : {}),
|
|
689
683
|
...(latest.requester_run ? { requesterRun: latest.requester_run } : {}), // @implements A-SPEC-779.2
|
|
684
|
+
...(latest.requester_server ? { requesterServer: latest.requester_server } : {}), // @implements A-SPEC-779.7
|
|
690
685
|
};
|
|
691
686
|
}
|
|
@@ -61,7 +61,9 @@ export declare function sessionAutonomyActive(root: string, now: string): boolea
|
|
|
61
61
|
* (A-SPEC-553.1). `root`/`now` are optional so env-only callers are byte-identical. */
|
|
62
62
|
export declare function projectDefaultAutonomy(root: string): boolean;
|
|
63
63
|
export declare function autonomousApprovalEnabled(env: NodeJS.ProcessEnv, root?: string, now?: string): boolean;
|
|
64
|
-
|
|
64
|
+
/** @implements A-SPEC-792.7 — the full profile covering `root`, as one line (without the banner prefix), or ''. */
|
|
65
|
+
export declare function fullAutonomyLine(root: string, home?: string): string;
|
|
66
|
+
export declare function autonomyBanner(env: NodeJS.ProcessEnv, root: string, now: string, home?: string): string;
|
|
65
67
|
export declare function autonomyMarkerShouldPrune(root: string, now: string): boolean;
|
|
66
68
|
export declare function versionBumpKind(from: string, to: string): 'major' | 'minor' | 'patch' | 'none';
|
|
67
69
|
export declare function releaseAutonomy(specs: Spec[], versionBump: 'major' | 'minor' | 'patch' | 'none', env: NodeJS.ProcessEnv, root?: string, now?: string): ApprovalAutonomy;
|
|
@@ -46,11 +46,12 @@ exports.requiresAutonomousApprovalPrompt = requiresAutonomousApprovalPrompt;
|
|
|
46
46
|
exports.sessionAutonomyActive = sessionAutonomyActive;
|
|
47
47
|
exports.projectDefaultAutonomy = projectDefaultAutonomy;
|
|
48
48
|
exports.autonomousApprovalEnabled = autonomousApprovalEnabled;
|
|
49
|
+
exports.fullAutonomyLine = fullAutonomyLine;
|
|
49
50
|
exports.autonomyBanner = autonomyBanner;
|
|
50
51
|
exports.autonomyMarkerShouldPrune = autonomyMarkerShouldPrune;
|
|
51
52
|
exports.versionBumpKind = versionBumpKind;
|
|
52
53
|
exports.releaseAutonomy = releaseAutonomy;
|
|
53
|
-
// @implements A-SPEC-532.1, A-SPEC-718, A-SPEC-532.3, A-SPEC-532.4, A-SPEC-532.7
|
|
54
|
+
// @implements A-SPEC-532.1, A-SPEC-718, A-SPEC-532.3, A-SPEC-532.4, A-SPEC-532.7, A-SPEC-792.7
|
|
54
55
|
// Whether a spec approval may be sealed AUTONOMOUSLY by the agent, or must still ask a human through
|
|
55
56
|
// the MCP elicitation TUI. The governance chain (REQ→H→A→T→CPG + RTM + taint + phase gate) already
|
|
56
57
|
// forces quality structurally, so a low/mid-risk spec self-approving under an explicitly-enabled
|
|
@@ -67,6 +68,8 @@ const scope_judgment_1 = require("../guardrail/scope-judgment");
|
|
|
67
68
|
/** The out-of-band switch. An agent cannot read or set it — the pre-tool-use gate blocks that
|
|
68
69
|
* (A-SPEC-532.2), the same self-disarm protection HOLMES_APPROVAL and HOLMES_GATE_BYPASS have. */
|
|
69
70
|
const delegation_1 = require("./delegation"); // @implements A-SPEC-771 — the run delegation, the third envelope
|
|
71
|
+
const full_autonomy_1 = require("./full-autonomy"); // @implements A-SPEC-792.7
|
|
72
|
+
const os = __importStar(require("node:os"));
|
|
70
73
|
exports.AUTONOMY_ENV = 'HOLMES_AUTONOMOUS_APPROVAL';
|
|
71
74
|
/**
|
|
72
75
|
* Path prefixes whose files govern the gate, the ledger, taint boundaries, or this session's own
|
|
@@ -377,7 +380,30 @@ function autonomousApprovalEnabled(env, root, now) {
|
|
|
377
380
|
}
|
|
378
381
|
// @implements A-SPEC-554.1 — the session-start REMINDER (the headless hook surfaces, it never decides).
|
|
379
382
|
// Only ON postures get a line; OFF is silent (a permanent line is one nobody reads). Wired below.
|
|
380
|
-
|
|
383
|
+
/** @implements A-SPEC-792.7 — the full profile covering `root`, as one line (without the banner prefix), or ''. */
|
|
384
|
+
function fullAutonomyLine(root, home = os.homedir()) {
|
|
385
|
+
let s;
|
|
386
|
+
try {
|
|
387
|
+
s = (0, full_autonomy_1.readFullProfile)(home, root);
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
return '';
|
|
391
|
+
}
|
|
392
|
+
if (!s.active)
|
|
393
|
+
return '';
|
|
394
|
+
const f = s.entry.flags;
|
|
395
|
+
const onOff = (b) => (b ? 'on' : 'off');
|
|
396
|
+
return `full autonomy: ON (scope ${s.entry.scope}; push ${onOff(f.push)}, publish ${onOff(f.publish)}, architecture ${onOff(f.architecture)}) — no judgment here waits for a person`;
|
|
397
|
+
}
|
|
398
|
+
function autonomyBanner(env, root, now, home) {
|
|
399
|
+
// @implements A-SPEC-792.7 — an active full profile is named first; without one the banner is what it was.
|
|
400
|
+
const full = fullAutonomyLine(root, home);
|
|
401
|
+
const posture = postureBanner(env, root, now);
|
|
402
|
+
if (full === '')
|
|
403
|
+
return posture;
|
|
404
|
+
return `[Holmes-Kit] ${full}; a refusal names its route${posture === '' ? '' : `\n${posture}`}`;
|
|
405
|
+
}
|
|
406
|
+
function postureBanner(env, root, now) {
|
|
381
407
|
const v = env[exports.AUTONOMY_ENV];
|
|
382
408
|
// @implements A-SPEC-771 — one added line names an active run delegation, beside whichever posture line applies.
|
|
383
409
|
const delegation = (0, delegation_1.readDelegation)(root, now);
|