@holmes-lab/holmes-kit 0.38.0 → 0.40.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 +370 -6
- package/README.md +58 -40
- package/dist/.build-id +1 -1
- package/dist/holmes/admission/core/admission-policy.d.ts +37 -0
- package/dist/holmes/admission/core/admission-policy.js +147 -0
- package/dist/holmes/admission/core/bounded-reader.d.ts +56 -0
- package/dist/holmes/admission/core/bounded-reader.js +135 -0
- package/dist/holmes/admission/core/change-classifier.d.ts +34 -0
- package/dist/holmes/admission/core/change-classifier.js +278 -0
- package/dist/holmes/admission/core/config-loader.d.ts +30 -0
- package/dist/holmes/admission/core/config-loader.js +145 -0
- package/dist/holmes/admission/core/event-judgement.d.ts +37 -0
- package/dist/holmes/admission/core/event-judgement.js +251 -0
- package/dist/holmes/admission/core/path-rules.d.ts +35 -0
- package/dist/holmes/admission/core/path-rules.js +88 -0
- package/dist/holmes/admission/core/pin.d.ts +7 -0
- package/dist/holmes/admission/core/pin.js +29 -0
- package/dist/holmes/admission/core/ports.d.ts +48 -0
- package/dist/holmes/admission/core/ports.js +11 -0
- package/dist/holmes/admission/core/range-resolver.d.ts +32 -0
- package/dist/holmes/admission/core/range-resolver.js +51 -0
- package/dist/holmes/admission/core/self-containment.d.ts +1 -0
- package/dist/holmes/admission/core/self-containment.js +125 -0
- package/dist/holmes/admission/core/signature-source.d.ts +9 -0
- package/dist/holmes/admission/core/signature-source.js +4 -0
- package/dist/holmes/admission/core/transition-planner.d.ts +15 -0
- package/dist/holmes/admission/core/transition-planner.js +14 -0
- package/dist/holmes/admission/core/verdict.d.ts +38 -0
- package/dist/holmes/admission/core/verdict.js +17 -0
- package/dist/holmes/admission/core/wiring.d.ts +44 -0
- package/dist/holmes/admission/core/wiring.js +618 -0
- package/dist/holmes/admission/forge/git-object-port.d.ts +4 -0
- package/dist/holmes/admission/forge/git-object-port.js +132 -0
- package/dist/holmes/assoc/assoc-arm.d.ts +1 -1
- package/dist/holmes/assoc/assoc-arm.js +1 -1
- package/dist/holmes/cli/agents.d.ts +8 -0
- package/dist/holmes/cli/agents.js +9 -5
- package/dist/holmes/cli/approve-cli.d.ts +2 -0
- package/dist/holmes/cli/approve-cli.js +392 -0
- package/dist/holmes/cli/approve-ref.d.ts +13 -7
- package/dist/holmes/cli/approve-ref.js +30 -10
- package/dist/holmes/cli/approve-status.d.ts +26 -2
- package/dist/holmes/cli/approve-status.js +98 -18
- package/dist/holmes/cli/approve-watch.d.ts +5 -0
- package/dist/holmes/cli/approve-watch.js +10 -5
- package/dist/holmes/cli/approve.d.ts +50 -13
- package/dist/holmes/cli/approve.js +260 -67
- package/dist/holmes/cli/attest.js +2 -1
- package/dist/holmes/cli/autonomy.d.ts +4 -1
- package/dist/holmes/cli/autonomy.js +17 -10
- package/dist/holmes/cli/codex-oracle.d.ts +11 -0
- package/dist/holmes/cli/codex-oracle.js +5 -1
- package/dist/holmes/cli/codex-toml.d.ts +10 -0
- package/dist/holmes/cli/codex-toml.js +36 -2
- package/dist/holmes/cli/doctor-boundary.d.ts +76 -0
- package/dist/holmes/cli/doctor-boundary.js +308 -0
- package/dist/holmes/cli/doctor-locks.d.ts +15 -0
- package/dist/holmes/cli/doctor-locks.js +119 -0
- package/dist/holmes/cli/doctor.d.ts +2 -0
- package/dist/holmes/cli/doctor.js +45 -5
- package/dist/holmes/cli/flags.d.ts +23 -0
- package/dist/holmes/cli/flags.js +89 -0
- package/dist/holmes/cli/index.d.ts +5 -1
- package/dist/holmes/cli/index.js +206 -424
- package/dist/holmes/cli/init.js +33 -0
- package/dist/holmes/cli/lock-recover.d.ts +5 -0
- package/dist/holmes/cli/lock-recover.js +126 -0
- package/dist/holmes/cli/mcp-processes.d.ts +32 -0
- package/dist/holmes/cli/mcp-processes.js +132 -0
- package/dist/holmes/cli/release-docs.js +1 -1
- package/dist/holmes/cli/run-exec.d.ts +141 -0
- package/dist/holmes/cli/run-exec.js +1435 -0
- package/dist/holmes/cli/run-provision.d.ts +8 -0
- package/dist/holmes/cli/run-provision.js +325 -0
- package/dist/holmes/cli/run-wiring.d.ts +69 -0
- package/dist/holmes/cli/run-wiring.js +270 -0
- package/dist/holmes/cli/run.d.ts +26 -0
- package/dist/holmes/cli/run.js +364 -83
- package/dist/holmes/cli/runtime-binding-approval.js +32 -19
- package/dist/holmes/cli/screen-safe.d.ts +3 -92
- package/dist/holmes/cli/screen-safe.js +18 -756
- package/dist/holmes/config/config.d.ts +2 -0
- package/dist/holmes/config/config.js +5 -2
- package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
- package/dist/holmes/cpg/import-resolver.js +1 -1
- package/dist/holmes/governance/approval-decisions.d.ts +47 -0
- package/dist/holmes/governance/approval-decisions.js +29 -0
- package/dist/holmes/governance/approval-grants.d.ts +220 -1
- package/dist/holmes/governance/approval-grants.js +612 -33
- package/dist/holmes/governance/approval-queue.d.ts +31 -0
- package/dist/holmes/governance/approval-queue.js +122 -11
- package/dist/holmes/governance/approval-spend.d.ts +95 -0
- package/dist/holmes/governance/approval-spend.js +191 -0
- package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
- package/dist/holmes/governance/autonomous-shell.js +332 -0
- package/dist/holmes/governance/autonomy.d.ts +5 -0
- package/dist/holmes/governance/autonomy.js +16 -11
- package/dist/holmes/governance/constitution.d.ts +5 -0
- package/dist/holmes/governance/constitution.js +32 -12
- package/dist/holmes/governance/full-autonomy.d.ts +10 -0
- package/dist/holmes/governance/full-autonomy.js +103 -7
- package/dist/holmes/governance/harness-catalog.d.ts +103 -0
- package/dist/holmes/governance/harness-catalog.js +348 -0
- package/dist/holmes/governance/human-channel.d.ts +38 -0
- package/dist/holmes/governance/human-channel.js +49 -0
- package/dist/holmes/governance/install-manifest.d.ts +22 -0
- package/dist/holmes/governance/install-manifest.js +160 -0
- package/dist/holmes/governance/ledger-rechain.js +2 -0
- package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
- package/dist/holmes/governance/ledger-store.conformance.js +66 -0
- package/dist/holmes/governance/ledger-store.d.ts +88 -11
- package/dist/holmes/governance/ledger-store.js +186 -8
- package/dist/holmes/governance/provenance-chain.d.ts +16 -4
- package/dist/holmes/governance/provenance-chain.js +19 -4
- package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
- package/dist/holmes/governance/provenance-ledger.js +53 -18
- package/dist/holmes/governance/push-gate-runner.js +11 -7
- package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
- package/dist/holmes/governance/recorded-pairs.js +522 -0
- package/dist/holmes/governance/replica-id.d.ts +1 -1
- package/dist/holmes/governance/replica-id.js +1 -1
- package/dist/holmes/governance/spec-seam.d.ts +59 -0
- package/dist/holmes/governance/spec-seam.js +587 -0
- package/dist/holmes/governance/spend-kinds.d.ts +16 -0
- package/dist/holmes/governance/spend-kinds.js +18 -0
- package/dist/holmes/governance/tool-actions.js +2 -0
- package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
- package/dist/holmes/guardrail/decision-ledger.js +2 -1
- package/dist/holmes/guardrail/impact-gate.d.ts +1 -0
- package/dist/holmes/guardrail/impact-gate.js +1 -1
- package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
- package/dist/holmes/guardrail/line-continuation.js +39 -0
- package/dist/holmes/guardrail/operator-person.d.ts +28 -4
- package/dist/holmes/guardrail/operator-person.js +57 -11
- package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
- package/dist/holmes/guardrail/refusal-codes.js +70 -10
- package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
- package/dist/holmes/guardrail/risk-classifier.js +245 -15
- package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
- package/dist/holmes/guardrail/risk-gate.js +7 -34
- package/dist/holmes/guardrail/risk-types.d.ts +10 -0
- package/dist/holmes/guardrail/run-plan-scope.js +3 -1
- package/dist/holmes/guardrail/run-refusals.d.ts +6 -1
- package/dist/holmes/guardrail/run-refusals.js +36 -14
- package/dist/holmes/guardrail/run-stages.d.ts +10 -0
- package/dist/holmes/guardrail/run-stages.js +46 -6
- package/dist/holmes/guardrail/scope-judgment.js +1 -1
- package/dist/holmes/guardrail/shell-words.js +24 -3
- package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
- package/dist/holmes/guardrail/unresolved-write.js +556 -0
- package/dist/holmes/guardrail/write-target.d.ts +3 -0
- package/dist/holmes/guardrail/write-target.js +26 -5
- package/dist/holmes/hooks/pre-tool-use.d.ts +105 -1
- package/dist/holmes/hooks/pre-tool-use.js +1167 -168
- package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
- package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
- package/dist/holmes/hooks/session-start.d.ts +5 -0
- package/dist/holmes/hooks/session-start.js +29 -1
- package/dist/holmes/hooks/stop.d.ts +23 -0
- package/dist/holmes/hooks/stop.js +88 -33
- package/dist/holmes/mcp/approval-adapters.js +3 -1
- package/dist/holmes/mcp/approval-commit.js +3 -2
- package/dist/holmes/mcp/approval-policy.d.ts +2 -1
- package/dist/holmes/mcp/approval-policy.js +3 -1
- package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
- package/dist/holmes/mcp/handlers/approval-ask.d.ts +14 -0
- package/dist/holmes/mcp/handlers/approval-ask.js +31 -6
- package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
- package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
- package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
- package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
- package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
- package/dist/holmes/mcp/handlers/entity-store.js +133 -59
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
- package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
- package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
- package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
- package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
- package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
- package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
- package/dist/holmes/mcp/handlers/review-queries.js +8 -1
- package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
- package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
- package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
- package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
- package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
- package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
- package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
- package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
- package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
- package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
- package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
- package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
- package/dist/holmes/mcp/handlers/test-execution.d.ts +1 -1
- 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/workspace-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers.d.ts +99 -79
- package/dist/holmes/mcp/handlers.js +93 -25
- package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
- package/dist/holmes/mcp/harness-attestation.js +325 -53
- package/dist/holmes/mcp/maintenance-analyze.d.ts +1 -1
- package/dist/holmes/mcp/maintenance-analyze.js +9 -9
- package/dist/holmes/mcp/maintenance-evidence.js +31 -2
- package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
- 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 +34 -9
- package/dist/holmes/mcp/spec-id-guard.js +1 -1
- package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
- package/dist/holmes/mcp/tool-schemas.js +42 -2
- package/dist/holmes/project/act-root.d.ts +19 -0
- package/dist/holmes/project/act-root.js +100 -0
- package/dist/holmes/project/baseline.js +4 -3
- package/dist/holmes/project/bounded-group.d.ts +47 -0
- package/dist/holmes/project/bounded-group.js +140 -0
- package/dist/holmes/project/bounded-io.d.ts +50 -2
- package/dist/holmes/project/bounded-io.js +138 -6
- package/dist/holmes/project/change-source.js +2 -2
- package/dist/holmes/project/instance-id.d.ts +10 -0
- package/dist/holmes/project/instance-id.js +233 -0
- package/dist/holmes/project/machine-identity.d.ts +25 -0
- package/dist/holmes/project/machine-identity.js +133 -0
- package/dist/holmes/project/owned-lock.d.ts +84 -0
- package/dist/holmes/project/owned-lock.js +263 -0
- package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
- package/dist/holmes/project/plain-lock-fs.js +126 -0
- package/dist/holmes/project/request-lock.d.ts +85 -0
- package/dist/holmes/project/request-lock.js +459 -0
- package/dist/holmes/project/root.d.ts +12 -4
- package/dist/holmes/project/root.js +26 -7
- package/dist/holmes/project/run-records.d.ts +19 -0
- package/dist/holmes/project/run-records.js +94 -12
- package/dist/holmes/project/screen-text.d.ts +94 -0
- package/dist/holmes/project/screen-text.js +763 -0
- package/dist/holmes/project/spend-lock.d.ts +82 -0
- package/dist/holmes/project/spend-lock.js +413 -0
- package/dist/holmes/project/workspace-preflight.d.ts +5 -0
- package/dist/holmes/project/workspace-preflight.js +24 -1
- package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
- package/dist/holmes/refresh/freshness-coordinator.js +1 -1
- package/dist/holmes/review/condition-hunk-replay.js +4 -2
- package/dist/holmes/review/confidence-calibration.d.ts +1 -1
- package/dist/holmes/review/confidence-calibration.js +1 -1
- package/dist/holmes/review/content-verify.js +1 -1
- package/dist/holmes/review/hop-ablation.d.ts +4 -4
- package/dist/holmes/review/hop-ablation.js +5 -5
- package/dist/holmes/review/point-in-time-replay.js +12 -3
- package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
- package/dist/holmes/review/rank-diagnosis.js +1 -1
- package/dist/holmes/review/replay-corpus.d.ts +10 -4
- package/dist/holmes/review/replay-corpus.js +25 -9
- package/dist/holmes/review/requirement-triage.js +2 -2
- package/dist/holmes/review/semantic-arm.d.ts +3 -3
- package/dist/holmes/review/semantic-arm.js +3 -3
- package/dist/holmes/review/test-outcomes.js +3 -1
- package/dist/holmes/review/test-runner.d.ts +11 -0
- package/dist/holmes/review/test-runner.js +31 -10
- package/dist/holmes/review/test-selection-breadth.js +2 -2
- package/dist/holmes/review/verdicts.d.ts +109 -7
- package/dist/holmes/review/verdicts.js +653 -34
- package/dist/holmes/rtm/anchor-census.d.ts +9 -0
- package/dist/holmes/rtm/anchor-census.js +151 -0
- package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
- package/dist/holmes/rtm/anchor-ids.js +45 -2
- package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
- package/dist/holmes/rtm/comment-ranges.js +104 -0
- package/dist/holmes/rtm/counted-tests.d.ts +1 -0
- package/dist/holmes/rtm/counted-tests.js +63 -0
- package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
- package/dist/holmes/rtm/known-defects.js +1 -1
- package/dist/holmes/rtm/localize.js +1 -1
- package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
- package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
- package/dist/holmes/rtm/test-scope.d.ts +31 -0
- package/dist/holmes/rtm/test-scope.js +166 -5
- package/dist/holmes/rtm/trace-gaps.js +1 -1
- package/dist/holmes/runtime/dispatch.d.ts +10 -0
- package/dist/holmes/runtime/dispatch.js +12 -1
- package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
- package/dist/holmes/semantic/cloud-usage.js +1 -1
- package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
- package/dist/holmes/semantic/unreadable-paths.js +1 -1
- package/dist/holmes/spec/approval-blockers.js +1 -1
- package/dist/holmes/spec/entity-store.d.ts +6 -1
- package/dist/holmes/spec/entity-store.js +16 -2
- package/dist/holmes/spec/entity-transaction.d.ts +7 -2
- package/dist/holmes/spec/entity-transaction.js +87 -170
- package/dist/holmes/spec/spec-store.d.ts +12 -6
- package/dist/holmes/spec/spec-store.js +4 -2
- package/dist/holmes/spec/spec-types.js +1 -1
- package/dist/holmes/spec/succession-guard.d.ts +56 -0
- package/dist/holmes/spec/succession-guard.js +187 -0
- package/dist/holmes/spec/succession.d.ts +70 -0
- package/dist/holmes/spec/succession.js +171 -0
- package/dist/holmes/spec/transition-policy.d.ts +2 -2
- package/docs/install-guide.md +9 -3
- package/docs/language-support.md +78 -0
- package/package.json +4 -3
- package/playbooks/author-slice/PLAYBOOK.md +1 -1
- package/playbooks/promote-slice/PLAYBOOK.md +5 -1
- package/playbooks/publish/PLAYBOOK.md +45 -33
- package/dist/holmes/review/manual-baseline.d.ts +0 -209
- package/dist/holmes/review/manual-baseline.js +0 -2847
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STREAM_MAX_BUFFER = void 0;
|
|
4
|
+
exports.gitObjectPort = gitObjectPort;
|
|
5
|
+
// @implements A-SPEC-792.50
|
|
6
|
+
/**
|
|
7
|
+
* The git object port of the admission detector (A-SPEC-792.50): the one I/O module of slice 1a. Replace objects are
|
|
8
|
+
* off (`GIT_NO_REPLACE_OBJECTS=1`, `--no-replace-objects`) and inherited `GIT_*` variables are dropped, so the objects
|
|
9
|
+
* read are the commit's own. A blob's prefix hash, last byte and line hashes are computed in a child process that
|
|
10
|
+
* streams `git cat-file blob`; only the small answer reaches this process (STREAM_MAX_BUFFER), never the blob.
|
|
11
|
+
*/
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
/** The largest answer a streamed operation may return to this process (prefix hash, last byte). */
|
|
14
|
+
exports.STREAM_MAX_BUFFER = 64 * 1024;
|
|
15
|
+
/** A git child, or the streaming child, is killed after the event's own time budget. */
|
|
16
|
+
const GIT_TIMEOUT_MS = 120_000;
|
|
17
|
+
/** Line hashes are 17 bytes per line under the 1,000,000-line cap. */
|
|
18
|
+
const LINES_MAX_BUFFER = 32 * 1024 * 1024;
|
|
19
|
+
const STREAMER = `
|
|
20
|
+
const { spawn } = require('child_process');
|
|
21
|
+
const crypto = require('crypto');
|
|
22
|
+
const [op, oid, arg] = process.argv.slice(1);
|
|
23
|
+
const p = spawn('git', ['--no-replace-objects', 'cat-file', 'blob', oid], { stdio: ['ignore', 'pipe', 'ignore'], timeout: 120000, killSignal: 'SIGKILL' });
|
|
24
|
+
// the parent's timeout sends SIGTERM: take the git grandchild down with this process, so none is left running
|
|
25
|
+
const stop = () => { try { p.kill('SIGKILL'); } catch { /* gone */ } process.exit(1); };
|
|
26
|
+
process.on('SIGTERM', stop);
|
|
27
|
+
process.on('SIGINT', stop);
|
|
28
|
+
if (op === 'prefix') {
|
|
29
|
+
let left = Number(arg); const h = crypto.createHash('sha256');
|
|
30
|
+
p.stdout.on('data', (c) => { if (left > 0) { const s = c.subarray(0, Math.min(left, c.length)); h.update(s); left -= s.length; } });
|
|
31
|
+
p.on('close', (code) => { process.stdout.write(code === 0 ? h.digest('hex') : 'error'); });
|
|
32
|
+
} else if (op === 'last') {
|
|
33
|
+
let last = -1;
|
|
34
|
+
p.stdout.on('data', (c) => { if (c.length) last = c[c.length - 1]; });
|
|
35
|
+
p.on('close', (code) => { process.stdout.write(code === 0 ? String(last) : 'error'); });
|
|
36
|
+
} else if (op === 'lines') {
|
|
37
|
+
const max = Number(arg); const out = []; let h = crypto.createHash('sha256'); let open = false; let over = false;
|
|
38
|
+
p.stdout.on('data', (c) => {
|
|
39
|
+
if (over) return;
|
|
40
|
+
let start = 0;
|
|
41
|
+
for (let i = 0; i < c.length; i++) {
|
|
42
|
+
if (c[i] !== 10) continue;
|
|
43
|
+
h.update(c.subarray(start, i + 1)); out.push(h.digest('hex').slice(0, 16)); h = crypto.createHash('sha256'); open = false; start = i + 1;
|
|
44
|
+
if (out.length > max) { over = true; return; }
|
|
45
|
+
}
|
|
46
|
+
if (start < c.length) { h.update(c.subarray(start)); open = true; }
|
|
47
|
+
});
|
|
48
|
+
p.on('close', (code) => {
|
|
49
|
+
if (code !== 0) { process.stdout.write('error'); return; }
|
|
50
|
+
if (!over && open) out.push(h.digest('hex').slice(0, 16));
|
|
51
|
+
process.stdout.write(over || out.length > max ? 'null' : out.join('\\n'));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
/** The environment git runs under: no inherited GIT_* variable, replace objects off. */
|
|
56
|
+
function gitEnv() {
|
|
57
|
+
const env = {};
|
|
58
|
+
for (const [k, v] of Object.entries(process.env))
|
|
59
|
+
if (!k.startsWith('GIT_'))
|
|
60
|
+
env[k] = v;
|
|
61
|
+
env.GIT_NO_REPLACE_OBJECTS = '1';
|
|
62
|
+
return env;
|
|
63
|
+
}
|
|
64
|
+
function gitObjectPort(root) {
|
|
65
|
+
const env = gitEnv();
|
|
66
|
+
// every git child is bounded (A-SPEC-734's census): the event's own 120 s, and a buffer above any tree listing
|
|
67
|
+
const run = (args, maxBuffer = 1 << 28) => (0, child_process_1.spawnSync)('git', ['--no-replace-objects', ...args], { cwd: root, env, maxBuffer, timeout: GIT_TIMEOUT_MS, killSignal: 'SIGKILL' });
|
|
68
|
+
const ok = (args) => {
|
|
69
|
+
const r = run(args);
|
|
70
|
+
if (r.status !== 0)
|
|
71
|
+
throw new Error(`git ${args[0]} failed: ${String(r.stderr ?? '').slice(0, 200)}`);
|
|
72
|
+
return r.stdout;
|
|
73
|
+
};
|
|
74
|
+
const stream = (op, oid, arg, maxBuffer) => {
|
|
75
|
+
const r = (0, child_process_1.spawnSync)(process.execPath, ['-e', STREAMER, op, oid, arg], { cwd: root, env, maxBuffer, timeout: GIT_TIMEOUT_MS, killSignal: 'SIGTERM' });
|
|
76
|
+
const out = String(r.stdout ?? '');
|
|
77
|
+
if (r.status !== 0 || out === 'error')
|
|
78
|
+
throw new Error(`streaming ${op} of ${oid} failed`);
|
|
79
|
+
return out;
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
entries(commit) {
|
|
83
|
+
return ok(['ls-tree', '-r', '-t', '-z', '--full-tree', commit]).toString('utf8').split('\0').filter(Boolean).map((line) => {
|
|
84
|
+
const tab = line.indexOf('\t');
|
|
85
|
+
const [mode, type, oid] = line.slice(0, tab).split(' ');
|
|
86
|
+
return { path: line.slice(tab + 1), mode, type: type, oid };
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
size: (oid) => Number(ok(['cat-file', '-s', oid]).toString('utf8').trim()),
|
|
90
|
+
bytes(oid, max) {
|
|
91
|
+
if (this.size(oid) > max)
|
|
92
|
+
return null;
|
|
93
|
+
return ok(['cat-file', 'blob', oid]);
|
|
94
|
+
},
|
|
95
|
+
bytesMany(oids, max) {
|
|
96
|
+
const out = new Map();
|
|
97
|
+
const wanted = [...new Set(oids)];
|
|
98
|
+
if (wanted.length === 0)
|
|
99
|
+
return out;
|
|
100
|
+
const r = (0, child_process_1.spawnSync)('git', ['--no-replace-objects', 'cat-file', '--batch'], { cwd: root, env, input: wanted.join('\n') + '\n', maxBuffer: 1 << 30, timeout: GIT_TIMEOUT_MS, killSignal: 'SIGKILL' });
|
|
101
|
+
if (r.status !== 0)
|
|
102
|
+
throw new Error(`git cat-file --batch failed: ${String(r.stderr ?? '').slice(0, 200)}`);
|
|
103
|
+
const buf = r.stdout;
|
|
104
|
+
let at = 0;
|
|
105
|
+
for (const oid of wanted) {
|
|
106
|
+
const nl = buf.indexOf(0x0a, at);
|
|
107
|
+
if (nl < 0)
|
|
108
|
+
throw new Error('git cat-file --batch ended early');
|
|
109
|
+
const header = buf.subarray(at, nl).toString('utf8').split(' ');
|
|
110
|
+
if (header[1] === 'missing')
|
|
111
|
+
throw new Error(`object ${oid} is missing`);
|
|
112
|
+
const size = Number(header[2]);
|
|
113
|
+
out.set(oid, size > max ? null : Buffer.from(buf.subarray(nl + 1, nl + 1 + size)));
|
|
114
|
+
at = nl + 1 + size + 1;
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
},
|
|
118
|
+
prefixSha256: (oid, length) => stream('prefix', oid, String(length), exports.STREAM_MAX_BUFFER),
|
|
119
|
+
lastByte(oid) { const v = Number(stream('last', oid, '0', exports.STREAM_MAX_BUFFER)); return v < 0 ? null : v; },
|
|
120
|
+
lineHashes(oid, maxLines) {
|
|
121
|
+
const out = stream('lines', oid, String(maxLines), LINES_MAX_BUFFER);
|
|
122
|
+
return out === 'null' ? null : out === '' ? [] : out.split('\n');
|
|
123
|
+
},
|
|
124
|
+
isAncestor: (a, b) => run(['merge-base', '--is-ancestor', a, b]).status === 0,
|
|
125
|
+
mergeBases(a, b) {
|
|
126
|
+
const r = run(['merge-base', '--all', a, b]);
|
|
127
|
+
return r.status === 0 ? String(r.stdout).split('\n').filter(Boolean) : [];
|
|
128
|
+
},
|
|
129
|
+
exists: (commit) => run(['cat-file', '-e', `${commit}^{commit}`]).status === 0,
|
|
130
|
+
shallow: () => String(ok(['rev-parse', '--is-shallow-repository']).toString('utf8')).trim() === 'true',
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -74,7 +74,7 @@ export declare function pprImpactRanked(view: GraphView, seeds: ReadonlyMap<stri
|
|
|
74
74
|
/**
|
|
75
75
|
* @implements A-SPEC-469 — the adopted configuration, frozen to the S-484 three-corpus winner:
|
|
76
76
|
* uni-d0.3-h0 at k=10 beat the ungraded closure on BOTH recall and precision on every corpus
|
|
77
|
-
* (HOLMES 0.0347/0.0413 → 0.5713/0.1611;
|
|
77
|
+
* (HOLMES 0.0347/0.0413 → 0.5713/0.1611; CONSUMER 0.0980/0.0125 → 0.3333/0.0588; GEMINI
|
|
78
78
|
* 0.3143/0.0203 → 0.3611/0.0533). Change these numbers only with a new sweep beside them.
|
|
79
79
|
*/
|
|
80
80
|
export declare const RANKED_IMPACT_CONFIG: PprArmConfig;
|
|
@@ -140,7 +140,7 @@ function pprImpactRanked(view, seeds, excludeFiles, k, config) {
|
|
|
140
140
|
/**
|
|
141
141
|
* @implements A-SPEC-469 — the adopted configuration, frozen to the S-484 three-corpus winner:
|
|
142
142
|
* uni-d0.3-h0 at k=10 beat the ungraded closure on BOTH recall and precision on every corpus
|
|
143
|
-
* (HOLMES 0.0347/0.0413 → 0.5713/0.1611;
|
|
143
|
+
* (HOLMES 0.0347/0.0413 → 0.5713/0.1611; CONSUMER 0.0980/0.0125 → 0.3333/0.0588; GEMINI
|
|
144
144
|
* 0.3143/0.0203 → 0.3611/0.0533). Change these numbers only with a new sweep beside them.
|
|
145
145
|
*/
|
|
146
146
|
exports.RANKED_IMPACT_CONFIG = {
|
|
@@ -38,6 +38,8 @@ export declare const HARNESS_ENFORCES: Record<Agent, boolean>;
|
|
|
38
38
|
* 중첩이 허용된다는 것은 실측으로 확인했다.
|
|
39
39
|
*/
|
|
40
40
|
export declare const CODEX_PLUGIN_DIR: string;
|
|
41
|
+
/** @implements A-SPEC-792.50 — the codex marketplace manifests init writes (0.152.x first, then 0.151.x), relative to the target. */
|
|
42
|
+
export declare const CODEX_MARKETPLACE_PATHS: readonly string[];
|
|
41
43
|
export declare const CODEX_MARKETPLACE = "holmes-kit-local";
|
|
42
44
|
export interface AgentWiringOptions {
|
|
43
45
|
target: string;
|
|
@@ -164,6 +166,12 @@ export interface AgentLink {
|
|
|
164
166
|
* 지나간다(A-SPEC-193 §7 이 그 담장을 '타깃 밖만'으로 좁힌 이유이기도 하다).
|
|
165
167
|
*/
|
|
166
168
|
export declare function agentLinks(agent: Agent, opts: AgentWiringOptions): AgentLink[];
|
|
169
|
+
/**
|
|
170
|
+
* @implements A-SPEC-251.2 (round 47) — the other hooks files agy merges into a workspace: `hooks.json` under `.agents`, `.agent`,
|
|
171
|
+
* `_agents` and `_agent` (agy's documentation), from the target up to its repository root (the first directory holding `.git`,
|
|
172
|
+
* at most 64 levels; the target alone without one) — all but the target's own `.agents/hooks.json`.
|
|
173
|
+
*/
|
|
174
|
+
export declare const AGY_ROOT_NAMES: readonly string[];
|
|
167
175
|
export declare function agyOtherHooksFiles(target: string, cut?: {
|
|
168
176
|
short: boolean;
|
|
169
177
|
}): string[];
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
36
|
+
exports.AGY_ROOT_NAMES = exports.AGY_HOOKS_MAX_BYTES = exports.MANAGED_END = exports.MANAGED_BEGIN = exports.AGENTS_MD = exports.AGY_LITERAL_PATH = exports.CODEX_MARKETPLACE = exports.CODEX_MARKETPLACE_PATHS = 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;
|
|
@@ -107,6 +107,8 @@ exports.HARNESS_ENFORCES = {
|
|
|
107
107
|
* 중첩이 허용된다는 것은 실측으로 확인했다.
|
|
108
108
|
*/
|
|
109
109
|
exports.CODEX_PLUGIN_DIR = path.join('.holmes', 'codex-plugin', 'holmes-kit');
|
|
110
|
+
/** @implements A-SPEC-792.50 — the codex marketplace manifests init writes (0.152.x first, then 0.151.x), relative to the target. */
|
|
111
|
+
exports.CODEX_MARKETPLACE_PATHS = [path.join('.claude-plugin', 'marketplace.json'), path.join('.agents', 'plugins', 'marketplace.json')];
|
|
110
112
|
exports.CODEX_MARKETPLACE = 'holmes-kit-local';
|
|
111
113
|
const q = (p) => p;
|
|
112
114
|
// @implements A-SPEC-251.1 — same launch contract as the Claude wiring: npx-pin for installed
|
|
@@ -769,12 +771,13 @@ function agentFiles(agent, opts) {
|
|
|
769
771
|
}],
|
|
770
772
|
}, null, 2)}\n`;
|
|
771
773
|
return [
|
|
774
|
+
// @implements A-SPEC-792.50 — the two paths are CODEX_MARKETPLACE_PATHS, which the admission census reads
|
|
772
775
|
{
|
|
773
|
-
path: path.join(target,
|
|
776
|
+
path: path.join(target, exports.CODEX_MARKETPLACE_PATHS[0]), // codex 0.152.x reads here
|
|
774
777
|
content: marketplaceJson,
|
|
775
778
|
},
|
|
776
779
|
{
|
|
777
|
-
path: path.join(target,
|
|
780
|
+
path: path.join(target, exports.CODEX_MARKETPLACE_PATHS[1]), // 0.151.x (backward compat)
|
|
778
781
|
content: marketplaceJson,
|
|
779
782
|
},
|
|
780
783
|
{
|
|
@@ -838,7 +841,8 @@ function agentLinks(agent, opts) {
|
|
|
838
841
|
* `_agents` and `_agent` (agy's documentation), from the target up to its repository root (the first directory holding `.git`,
|
|
839
842
|
* at most 64 levels; the target alone without one) — all but the target's own `.agents/hooks.json`.
|
|
840
843
|
*/
|
|
841
|
-
|
|
844
|
+
// @implements A-SPEC-792.50 — exported for the admission census; value and use unchanged
|
|
845
|
+
exports.AGY_ROOT_NAMES = ['.agents', '.agent', '_agents', '_agent'];
|
|
842
846
|
function agyOtherHooksFiles(target, cut) {
|
|
843
847
|
const walk = (start) => {
|
|
844
848
|
const dirs = [start];
|
|
@@ -862,7 +866,7 @@ function agyOtherHooksFiles(target, cut) {
|
|
|
862
866
|
if (!ended && cut !== undefined)
|
|
863
867
|
cut.short = true;
|
|
864
868
|
const own = path.join(start, '.agents', 'hooks.json');
|
|
865
|
-
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);
|
|
869
|
+
return dirs.slice(0, top < 0 ? 1 : top + 1).flatMap((d) => exports.AGY_ROOT_NAMES.map((n) => path.join(d, n, 'hooks.json'))).filter((f) => f !== own);
|
|
866
870
|
};
|
|
867
871
|
// @implements A-SPEC-251.2 (round 48) — from the target as written AND from its real path: through a link into a repository the
|
|
868
872
|
// written path climbed the link's own parents and never saw the repository's switched-off entry (PASS — measured).
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const APPROVE_USAGE = "holmes-kit approve \u2014 decide pending approval requests (HITL)\n\n interactive (TTY): per item [a] approve [e] approve with reason/duration [v] details [d] deny [q] ask [s] skip [A] approve all remaining\n --watch resident mode \u2014 decide as requests arrive, wait when the queue is empty (Ctrl-C to exit, --poll-ms <ms>)\n --list print the pending list, and name grant files beyond a request's own\n --status the whole picture: workspace, delegation, who asked and how risky, live grants, recent outcomes\n --grant <id> issue a narrow grant for that request (--ttl <minutes>, --rationale <text>)\n <id> = the id under the request, or a unique prefix of 8+ characters;\n a list number is refused \u2014 it names whatever row holds it when the command runs\n --deny <id> --reason <text> deny \u2014 the reason rides the agent's next refusal\n --ask <id> --question <text> leave a question and hold \u2014 the agent relays it to the user\n --revoke <id> --reason <text> withdraw a live grant (see --status) \u2014 the request must be decided again\n --withdraw <id> --reason <text> the run that filed a request closes it (recorded as withdrawn, not denied); a session's MCP server uses approval_withdraw\n --all show requests idle past the fold too (every screen folds alike; the refusal log does not fold: its count keeps old refusals, which cannot be withdrawn; --deny <id> closes one and lowers the --list footer's count)\n --stale-hours <h> the fold's window in hours (default 24; 0 turns it off)\n --target <dir> project root (default: the current directory's .ax project)\n";
|
|
2
|
+
export declare function runApprove(flags: Record<string, string | boolean>): Promise<number>;
|
|
@@ -0,0 +1,392 @@
|
|
|
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.APPROVE_USAGE = void 0;
|
|
37
|
+
exports.runApprove = runApprove;
|
|
38
|
+
// @implements A-SPEC-794.55, A-SPEC-794.30, A-SPEC-794.31, A-SPEC-794.32, A-SPEC-794.33, A-SPEC-794.34, A-SPEC-794.35, A-SPEC-794.37, A-SPEC-794.40, A-SPEC-794.41, A-SPEC-794.42, A-SPEC-794.43, A-SPEC-215, A-SPEC-246, A-SPEC-260, A-SPEC-262.1, A-SPEC-262.2, A-SPEC-497.2, A-SPEC-507.1, A-SPEC-563.2, A-SPEC-649, A-SPEC-650, A-SPEC-770, A-SPEC-770.2, A-SPEC-779, A-SPEC-779.1, A-SPEC-779.2, A-SPEC-779.4, A-SPEC-792.20, A-SPEC-792.28, A-SPEC-102.29, A-SPEC-102.30
|
|
39
|
+
/**
|
|
40
|
+
* The `holmes-kit approve` dispatch. It lives here, not in index.ts, so that file stays under its 1,500-line ceiling;
|
|
41
|
+
* A-SPEC-794.30 returned its behaviour to the one before the S1 generation cycles (the owner's decision of 2026-11-01:
|
|
42
|
+
* 0.40.0 ships the 0.39 queue, the redesign is 0.41). The comments below name the specifications each branch carries
|
|
43
|
+
* out (A-SPEC-576.1 and 690 included); their anchors stay on the code those specifications list.
|
|
44
|
+
*
|
|
45
|
+
* A-SPEC-246 — the surface where a human decides. Interactive on a TTY with no decision flags; every interactive
|
|
46
|
+
* decision has a flag equivalent so a CI or remote operator is never locked out.
|
|
47
|
+
*/
|
|
48
|
+
const os = __importStar(require("node:os"));
|
|
49
|
+
const path = __importStar(require("node:path"));
|
|
50
|
+
const cli_execution_1 = require("./cli-execution");
|
|
51
|
+
exports.APPROVE_USAGE = `holmes-kit approve — decide pending approval requests (HITL)
|
|
52
|
+
|
|
53
|
+
interactive (TTY): per item [a] approve [e] approve with reason/duration [v] details [d] deny [q] ask [s] skip [A] approve all remaining
|
|
54
|
+
--watch resident mode — decide as requests arrive, wait when the queue is empty (Ctrl-C to exit, --poll-ms <ms>)
|
|
55
|
+
--list print the pending list, and name grant files beyond a request's own
|
|
56
|
+
--status the whole picture: workspace, delegation, who asked and how risky, live grants, recent outcomes
|
|
57
|
+
--grant <id> issue a narrow grant for that request (--ttl <minutes>, --rationale <text>)
|
|
58
|
+
<id> = the id under the request, or a unique prefix of 8+ characters;
|
|
59
|
+
a list number is refused — it names whatever row holds it when the command runs
|
|
60
|
+
--deny <id> --reason <text> deny — the reason rides the agent's next refusal
|
|
61
|
+
--ask <id> --question <text> leave a question and hold — the agent relays it to the user
|
|
62
|
+
--revoke <id> --reason <text> withdraw a live grant (see --status) — the request must be decided again
|
|
63
|
+
--withdraw <id> --reason <text> the run that filed a request closes it (recorded as withdrawn, not denied); a session's MCP server uses approval_withdraw
|
|
64
|
+
--all show requests idle past the fold too (every screen folds alike; the refusal log does not fold: its count keeps old refusals, which cannot be withdrawn; --deny <id> closes one and lowers the --list footer's count)
|
|
65
|
+
--stale-hours <h> the fold's window in hours (default 24; 0 turns it off)
|
|
66
|
+
--target <dir> project root (default: the current directory's .ax project)
|
|
67
|
+
`;
|
|
68
|
+
async function runApprove(flags) {
|
|
69
|
+
// A-SPEC-792.20 — the flag path names a grant's validity as the interactive screen does.
|
|
70
|
+
const { grantRequest, denyRequest, holdRequest, renderPending, renderNonTtyHint, runInteractive, decisionSubject, decisionDetail, grantValidityText } = require('./approve');
|
|
71
|
+
const { readQueue } = require('../governance/approval-queue');
|
|
72
|
+
// A-SPEC-262.1 — the flag path speaks the SAME grammar as the screen: an index, an exact id, or a unique prefix. A
|
|
73
|
+
// remote operator decides here, so an ambiguous reference must refuse by name here too — never resolve to "probably
|
|
74
|
+
// this one".
|
|
75
|
+
const { resolveRequestRef } = require('./approve-ref');
|
|
76
|
+
const root = require('../project/act-root').actRoot(flags); // A-SPEC-102.30 — the queue's root is the guard's
|
|
77
|
+
// A-SPEC-507.1 — stale folding is a LIST-VIEW judgment: the clock enters only here, never on gate-path folds.
|
|
78
|
+
// `--stale-hours 0` disables it; `--all` unfolds.
|
|
79
|
+
const { staleView, listedRequests } = require('./approve');
|
|
80
|
+
const viewed = staleView(flags);
|
|
81
|
+
// A-SPEC-794.33 — a bad --stale-hours is refused below; every screen reads this one window (A-H2)
|
|
82
|
+
const stale = viewed !== null && 'refusal' in viewed ? null : viewed;
|
|
83
|
+
const queueOpts = stale ? { now: Date.now(), ttlMs: stale.ttlMs } : undefined;
|
|
84
|
+
const listView = stale ? { staleHours: stale.ttlMs / 3_600_000, showAll: stale.showAll } : undefined;
|
|
85
|
+
// The SUBJECT travels with the id: every decision line names what it acted on, so an index that resolved against a
|
|
86
|
+
// queue that shifted since `--list` is visible on the screen (round-1). The detail row travels with it: round-5
|
|
87
|
+
// measured the one-line form at 81 columns, so the flag path prints the same two rows the screen does — subject read,
|
|
88
|
+
// id acted on.
|
|
89
|
+
const resolveRef = (ref, closesDev = false) => {
|
|
90
|
+
// A-SPEC-576.1 — an id or prefix is the operator naming a specific request — including a `shell` refusal they
|
|
91
|
+
// approved out of band (A-SPEC-563.2), which the inbox filter hides from the list but must never make ungrantable.
|
|
92
|
+
// A-SPEC-690 — `grantableRequests` reaches the refusal log too.
|
|
93
|
+
// A-SPEC-794.33 — a list number is refused (A-H1); the refusal names the row the list now shows at that number. A
|
|
94
|
+
// prefix must be unique among every id the queue has seen. --deny and --withdraw may close a development record (L3).
|
|
95
|
+
const { grantableRequests, devFiledRefusal, readRefusals } = require('../governance/approval-queue');
|
|
96
|
+
const all = readQueue(root, { includeAllKinds: true });
|
|
97
|
+
const grantable = grantableRequests(root);
|
|
98
|
+
const dev = closesDev ? Object.entries(all.devFiled ?? {}).filter(([id]) => !grantable.some((p) => p.id === id))
|
|
99
|
+
.map(([id, d]) => ({ id, kind: d.kind, target: d.target, why: '', count: 1, firstTs: '', lastTs: '' })) : [];
|
|
100
|
+
let logged = [];
|
|
101
|
+
try {
|
|
102
|
+
logged = readRefusals(root).map((x) => x.id);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
logged = [];
|
|
106
|
+
}
|
|
107
|
+
const known = [...Object.keys(all.decisions), ...Object.keys(all.subjects ?? {}), ...Object.keys(all.devFiled ?? {}), ...logged];
|
|
108
|
+
const r = resolveRequestRef([...grantable, ...dev], ref, { listed: listedRequests(readQueue(root, queueOpts), listView), known });
|
|
109
|
+
if (r.ok)
|
|
110
|
+
return { id: r.entry.id, subject: (prefix) => decisionSubject(r.entry, prefix), detail: (tail) => decisionDetail(r.entry, tail) };
|
|
111
|
+
// A-SPEC-794.31, A-SPEC-794.32 — the answer of a resolution that found nothing: a reference naming a development-build
|
|
112
|
+
// request is told why in words. A-SPEC-794.33 — only when nothing matched: an ambiguity is the resolver's to report (B-1)
|
|
113
|
+
// A-SPEC-794.34 — the resolver says why it found nothing; its words are not parsed here
|
|
114
|
+
return { refusal: (r.kind === 'none' ? devFiledRefusal(all, ref) : null) ?? r.reason };
|
|
115
|
+
};
|
|
116
|
+
const actor = (() => { try {
|
|
117
|
+
return os.userInfo().username || 'operator';
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return 'operator';
|
|
121
|
+
} })();
|
|
122
|
+
// A-SPEC-779.4 — the granting acts (a grant, the two screens that grant) are a person's, never an agent's own shell;
|
|
123
|
+
// a denial, a revocation, a question and the read-only views grant nothing and stay open.
|
|
124
|
+
const operatorRefusal = (act) => require('../guardrail/operator-person').operatorActGuard(act, root); // A-SPEC-102.29, A-SPEC-102.30 — the root the act works on, --target or not
|
|
125
|
+
const refuseOperatorAct = (act) => {
|
|
126
|
+
const why = operatorRefusal(act);
|
|
127
|
+
if (why === null)
|
|
128
|
+
return false;
|
|
129
|
+
const { withRefusalLine } = require('../guardrail/refusal-codes');
|
|
130
|
+
process.stdout.write(`${withRefusalLine(`✗ ${why}`, 'grant.operator-only')}\n`); // A-SPEC-245.25
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
if (flags.help) {
|
|
134
|
+
process.stdout.write(exports.APPROVE_USAGE);
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
// @implements A-SPEC-794.33 — the screen flags belong to the screens: beside a decision they were accepted and ignored
|
|
138
|
+
const decision = ['grant', 'deny', 'ask', 'withdraw', 'revoke', 'refusals'].find((f) => flags[f] !== undefined);
|
|
139
|
+
if (decision && (flags.all !== undefined || flags['stale-hours'] !== undefined)) {
|
|
140
|
+
process.stderr.write(`✗ --all and --stale-hours apply to the screens (--list, --status, --watch, the interactive screen), not to --${decision}\n`);
|
|
141
|
+
return 1;
|
|
142
|
+
}
|
|
143
|
+
if (viewed !== null && 'refusal' in viewed) {
|
|
144
|
+
process.stderr.write(`✗ ${viewed.refusal}\n`);
|
|
145
|
+
return 1;
|
|
146
|
+
}
|
|
147
|
+
return (0, cli_execution_1.runOperatorExecution)(root, async () => {
|
|
148
|
+
if (typeof flags.grant === 'string') {
|
|
149
|
+
const opts = { actor };
|
|
150
|
+
if (typeof flags.ttl === 'string')
|
|
151
|
+
opts.ttlMinutes = Number(flags.ttl);
|
|
152
|
+
if (typeof flags.rationale === 'string')
|
|
153
|
+
opts.rationale = flags.rationale;
|
|
154
|
+
const ref = resolveRef(flags.grant);
|
|
155
|
+
if ('refusal' in ref) {
|
|
156
|
+
process.stdout.write(`✗ ${ref.refusal}\n`);
|
|
157
|
+
return 1;
|
|
158
|
+
}
|
|
159
|
+
// A-SPEC-779 — never from inside a run; a run's awaited request only from a terminal.
|
|
160
|
+
const { grantGuard } = require('../guardrail/run-refusals');
|
|
161
|
+
// A-SPEC-779.4 — and never from a process an agent harness started.
|
|
162
|
+
const guarded = operatorRefusal(`a grant of ${ref.id}`)
|
|
163
|
+
?? grantGuard(root, ref.id, { env: process.env, interactive: process.stdin.isTTY === true && process.stdout.isTTY === true });
|
|
164
|
+
if (guarded !== null) {
|
|
165
|
+
// A-SPEC-779.1 — the refusal carries its envelope, so an orchestrator reads its class.
|
|
166
|
+
const { withRefusalLine } = require('../guardrail/refusal-codes');
|
|
167
|
+
process.stdout.write(`${withRefusalLine(`✗ ${guarded}`, 'grant.operator-only')}\n`); // A-SPEC-245.25
|
|
168
|
+
return 1;
|
|
169
|
+
}
|
|
170
|
+
const r = grantRequest(root, ref.id, opts);
|
|
171
|
+
process.stdout.write(r.ok ? `✓ approved — ${ref.subject('✓ approved — ')}\n${ref.detail(grantValidityText(r.expires))}\n` : `✗ ${r.reason}\n`);
|
|
172
|
+
return r.ok ? 0 : 1;
|
|
173
|
+
}
|
|
174
|
+
if (typeof flags.deny === 'string') {
|
|
175
|
+
const reason = typeof flags.reason === 'string' ? flags.reason.trim() : '';
|
|
176
|
+
if (reason === '') {
|
|
177
|
+
process.stderr.write('✗ --deny requires --reason — a denial with no reason is invisible to the agent\n');
|
|
178
|
+
return 1;
|
|
179
|
+
}
|
|
180
|
+
const ref = resolveRef(flags.deny, true); // A-SPEC-794.33 — a person's denial closes a development record (L3)
|
|
181
|
+
if ('refusal' in ref) {
|
|
182
|
+
process.stdout.write(`✗ ${ref.refusal}\n`);
|
|
183
|
+
return 1;
|
|
184
|
+
}
|
|
185
|
+
const r = denyRequest(root, ref.id, reason, actor);
|
|
186
|
+
process.stdout.write(r.ok ? `✓ denied — ${ref.subject('✓ denied — ')}\n${ref.detail('the denial was recorded')}\n` : `✗ ${r.reason}\n`);
|
|
187
|
+
return r.ok ? 0 : 1;
|
|
188
|
+
}
|
|
189
|
+
// A-SPEC-779.2 — the requester's own close: only the run that filed it, recorded as `withdrawn`.
|
|
190
|
+
if (typeof flags.withdraw === 'string') {
|
|
191
|
+
const reason = typeof flags.reason === 'string' ? flags.reason.trim() : '';
|
|
192
|
+
if (reason === '') {
|
|
193
|
+
process.stderr.write('✗ --withdraw requires --reason — it is what the operator reads in place of a decision\n');
|
|
194
|
+
return 1;
|
|
195
|
+
}
|
|
196
|
+
const { withdrawRequest } = require('./approve');
|
|
197
|
+
const ref = resolveRef(flags.withdraw, true); // A-SPEC-794.33 — and the filing run's withdrawal does (L3)
|
|
198
|
+
if ('refusal' in ref) {
|
|
199
|
+
process.stdout.write(`✗ ${ref.refusal}\n`);
|
|
200
|
+
return 1;
|
|
201
|
+
}
|
|
202
|
+
const r = withdrawRequest(root, ref.id, reason, { env: process.env, cwd: process.cwd() });
|
|
203
|
+
process.stdout.write(r.ok ? `↩ withdrawn — ${ref.subject('↩ withdrawn — ')}\n${ref.detail('withdrawn by its run')}\n` : `✗ ${r.reason}\n`);
|
|
204
|
+
return r.ok ? 0 : 1;
|
|
205
|
+
}
|
|
206
|
+
// A-SPEC-649 — the operator withdraws a live grant. A granted id is no longer pending, so it resolves against the
|
|
207
|
+
// DECIDED ids (full id or a unique prefix), never a list index.
|
|
208
|
+
if (typeof flags.revoke === 'string') {
|
|
209
|
+
const reason = typeof flags.reason === 'string' ? flags.reason.trim() : '';
|
|
210
|
+
if (reason === '') {
|
|
211
|
+
process.stderr.write('✗ --revoke requires --reason — a revocation with no reason is invisible to the agent\n');
|
|
212
|
+
return 1;
|
|
213
|
+
}
|
|
214
|
+
const { revokeGrant, revokeCandidates } = require('./approve');
|
|
215
|
+
const { rowField } = require('./screen-safe');
|
|
216
|
+
const raw = String(flags.revoke);
|
|
217
|
+
const ref = raw.trim();
|
|
218
|
+
// A-SPEC-794.32 — a grant file counts as granted: a torn `granted` row authorizes all the same (Q3). A-SPEC-794.33 —
|
|
219
|
+
// by prefix too, a claimed copy included, request ids only (A-1, A-2, A-4); every id printed is screen-safe (A-4)
|
|
220
|
+
const granted = revokeCandidates(root);
|
|
221
|
+
// @implements A-SPEC-794.35 — an exact candidate always resolves; a prefix needs eight characters, as a decision does
|
|
222
|
+
const MIN_PREFIX = 8; // the decision flags' prefix rule (approve-ref)
|
|
223
|
+
// @implements A-SPEC-794.37 — a name as written comes first: a grant's name may hold blanks, or be `.json` alone
|
|
224
|
+
const exact = [raw, raw.endsWith('.json') ? raw.slice(0, -'.json'.length) : null, ref].find((r) => r !== null && (r !== '' || raw === '.json') && granted.includes(r));
|
|
225
|
+
if (exact === undefined && ref.length < MIN_PREFIX && ref !== '') {
|
|
226
|
+
process.stdout.write(`✗ reference '${rowField(ref, 20)}' is too short — give eight or more characters of the id, or the whole grant name\n`);
|
|
227
|
+
return 1;
|
|
228
|
+
}
|
|
229
|
+
const matches = exact !== undefined ? [exact] : ref === '' ? [] : granted.filter((id) => id.startsWith(ref));
|
|
230
|
+
if (matches.length !== 1) {
|
|
231
|
+
process.stdout.write(`✗ ${matches.length === 0 ? `no granted request matches ${rowField(ref, 40)}` : `${rowField(ref, 40)} matches ${matches.length} granted requests — use the full id`}\n`);
|
|
232
|
+
return 1;
|
|
233
|
+
}
|
|
234
|
+
const r = revokeGrant(root, matches[0], reason, actor);
|
|
235
|
+
const about = readQueue(root, { includeAllKinds: true }).subjects?.[matches[0]];
|
|
236
|
+
const what = about ? ` (${rowField(about.kind, 16)} ${rowField(about.target, 40)})` : '';
|
|
237
|
+
process.stdout.write(r.ok ? `✓ revoked — ${rowField(matches[0], 40)}${what}\n the grant is withdrawn; the agent's next attempt is refused and re-filed\n${r.note ? ` ${r.note}\n` : ''}` : `✗ ${r.reason}\n`);
|
|
238
|
+
return r.ok ? 0 : 1;
|
|
239
|
+
}
|
|
240
|
+
if (typeof flags.ask === 'string') {
|
|
241
|
+
const question = typeof flags.question === 'string' ? flags.question.trim() : '';
|
|
242
|
+
if (question === '') {
|
|
243
|
+
process.stderr.write('✗ --ask requires --question\n');
|
|
244
|
+
return 1;
|
|
245
|
+
}
|
|
246
|
+
const ref = resolveRef(flags.ask);
|
|
247
|
+
if ('refusal' in ref) {
|
|
248
|
+
process.stdout.write(`✗ ${ref.refusal}\n`);
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
251
|
+
const r = holdRequest(root, ref.id, question, actor);
|
|
252
|
+
process.stdout.write(r.ok ? `✓ held — ${ref.subject('✓ held — ')}\n${ref.detail('the question rides the next refusal')}\n` : `✗ ${r.reason}\n`);
|
|
253
|
+
return r.ok ? 0 : 1;
|
|
254
|
+
}
|
|
255
|
+
if (flags.list) {
|
|
256
|
+
// A-SPEC-770 — the list ends with the count of refusals outside it; A-SPEC-770.2 — and names the workspace
|
|
257
|
+
const { refusalsOutsideInbox } = require('../governance/approval-queue');
|
|
258
|
+
process.stdout.write(renderPending(readQueue(root, queueOpts), listView, refusalsOutsideInbox(root), root) + '\n');
|
|
259
|
+
// @implements A-SPEC-794.35 — every grant file the store reads is named, a hand-written one included (A-M1)
|
|
260
|
+
const others = require('./approve-status').statusContext(root).otherGrantFiles ?? [];
|
|
261
|
+
if (others.length > 0) {
|
|
262
|
+
const { rowField } = require('./screen-safe');
|
|
263
|
+
process.stdout.write(`${others.length} grant file(s) beyond a request's own exact grant: ${others.map((f) => rowField(f.name, 40)).join(', ')} — see approve --status\n`);
|
|
264
|
+
}
|
|
265
|
+
// A-SPEC-792.28 — and what was approved without a person, by its conditions
|
|
266
|
+
try {
|
|
267
|
+
const { renderAutonomousApprovals } = require('../governance/autonomous-shell');
|
|
268
|
+
const { FileLedgerStore } = require('../governance/ledger-store');
|
|
269
|
+
const auto = renderAutonomousApprovals(new FileLedgerStore(path.join(root, '.ax', 'ledger')).loadAll());
|
|
270
|
+
if (auto)
|
|
271
|
+
process.stdout.write(`${auto}\n`);
|
|
272
|
+
}
|
|
273
|
+
catch { /* an unreadable ledger shows no autonomous rows; the list above stands */ }
|
|
274
|
+
return 0;
|
|
275
|
+
}
|
|
276
|
+
// A-SPEC-650 — the whole picture, read-only; the list above stays script-clean.
|
|
277
|
+
if (flags.status) {
|
|
278
|
+
const { renderStatus, statusContext } = require('./approve-status');
|
|
279
|
+
process.stdout.write(renderStatus(readQueue(root, queueOpts), statusContext(root), { ...(listView ? { view: listView } : {}) }) + '\n'); // A-SPEC-794.33 — folded as --list
|
|
280
|
+
// A-SPEC-794.40 — "the whole picture" includes what is outside the inbox, as --list and --watch say (D3)
|
|
281
|
+
const { outsideInboxFooter } = require('./approve');
|
|
282
|
+
const { refusalsOutsideInbox } = require('../governance/approval-queue');
|
|
283
|
+
const footer = outsideInboxFooter(refusalsOutsideInbox(root), root);
|
|
284
|
+
if (footer !== null)
|
|
285
|
+
process.stdout.write(`${footer}\n`);
|
|
286
|
+
return 0;
|
|
287
|
+
}
|
|
288
|
+
// A-SPEC-563.2 — the read-only refusal view (local log; raw targets stay on-screen).
|
|
289
|
+
if (flags.refusals !== undefined) {
|
|
290
|
+
const { renderRefusals } = require('./approve');
|
|
291
|
+
const { readRefusals, refusalsOutsideInbox } = require('../governance/approval-queue');
|
|
292
|
+
const limit = typeof flags.refusals === 'string' ? Number(flags.refusals) : 20;
|
|
293
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
294
|
+
process.stderr.write(`✗ --refusals expects a positive integer count — received: ${flags.refusals}\n`);
|
|
295
|
+
return 1;
|
|
296
|
+
}
|
|
297
|
+
// A-SPEC-770.2; A-SPEC-794.55 — the header names the open count the --list footer shows
|
|
298
|
+
process.stdout.write(renderRefusals(readRefusals(root), limit, root, refusalsOutsideInbox(root)) + '\n');
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
// A-SPEC-262.2 — the RESIDENT surface. Validate --poll-ms first (so a bad value is named even on a non-TTY), then
|
|
302
|
+
// refuse a non-TTY (a resident interactive loop needs a terminal), then run the loop. SIGINT and readline close both
|
|
303
|
+
// abort it — the operator leaving, either way, ends the watch at once and exit 0; pending items stay in the queue.
|
|
304
|
+
if (flags.watch === true) {
|
|
305
|
+
let pollMs;
|
|
306
|
+
if (typeof flags['poll-ms'] === 'string') {
|
|
307
|
+
pollMs = Number(flags['poll-ms']);
|
|
308
|
+
if (!Number.isInteger(pollMs) || pollMs <= 0) {
|
|
309
|
+
process.stderr.write(`✗ --poll-ms must be a positive integer (milliseconds) — received: ${flags['poll-ms']}\n`);
|
|
310
|
+
return 1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (!process.stdin.isTTY) {
|
|
314
|
+
process.stderr.write('✗ interactive resident mode (--watch) requires a TTY — use --list in scripts\n');
|
|
315
|
+
return 1;
|
|
316
|
+
}
|
|
317
|
+
if (refuseOperatorAct('the approval screen (--watch)'))
|
|
318
|
+
return 1; // A-SPEC-779.4
|
|
319
|
+
// A-SPEC-497.2 — the resident surface decides on ONE raw keypress (a/d/q/s, no Enter, no deadline) and pings the
|
|
320
|
+
// OS on each new arrival. Raw mode is restored on the way out whatever happens; Ctrl-C arrives as \x03 through
|
|
321
|
+
// decideByKey and ends the loop.
|
|
322
|
+
const { runWatch } = require('./approve-watch');
|
|
323
|
+
const { notifyQueueArrival } = require('./os-notify');
|
|
324
|
+
const ac = new AbortController();
|
|
325
|
+
const onSig = () => ac.abort();
|
|
326
|
+
process.once('SIGINT', onSig);
|
|
327
|
+
const stdin = process.stdin;
|
|
328
|
+
try {
|
|
329
|
+
stdin.setRawMode?.(true);
|
|
330
|
+
stdin.resume();
|
|
331
|
+
await runWatch(root, {
|
|
332
|
+
print: (t) => process.stdout.write(t + '\n'),
|
|
333
|
+
ask: async () => '', // unused on the key surface; kept for the ApproveIO shape
|
|
334
|
+
}, actor, {
|
|
335
|
+
signal: ac.signal,
|
|
336
|
+
keyStream: stdin,
|
|
337
|
+
notify: (p) => notifyQueueArrival(p),
|
|
338
|
+
// A-SPEC-650 — the status header before each new-item pass.
|
|
339
|
+
status: () => { const { renderStatus, statusContext } = require('./approve-status'); return renderStatus(readQueue(root, stale ? { now: Date.now(), ttlMs: stale.ttlMs } : undefined), statusContext(root), { ...(listView ? { view: listView } : {}) }); },
|
|
340
|
+
...(pollMs !== undefined ? { pollMs } : {}),
|
|
341
|
+
stale, // A-SPEC-794.33 — the watch folds as --list does
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
catch (e) {
|
|
345
|
+
if (e?.name !== 'AbortError')
|
|
346
|
+
throw e;
|
|
347
|
+
}
|
|
348
|
+
finally {
|
|
349
|
+
process.removeListener('SIGINT', onSig);
|
|
350
|
+
stdin.setRawMode?.(false);
|
|
351
|
+
stdin.pause();
|
|
352
|
+
}
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
// A-SPEC-260 — the implicit non-TTY fallback tells the operator the next command, with the real pending id filled
|
|
356
|
+
// in; the explicit --list above stays script-clean.
|
|
357
|
+
if (!process.stdin.isTTY) {
|
|
358
|
+
const state = readQueue(root, queueOpts);
|
|
359
|
+
const hint = renderNonTtyHint(state, root); // A-SPEC-794.32 — every command names this workspace
|
|
360
|
+
process.stdout.write(renderPending(state, listView) + (hint ? '\n\n' + hint : '') + '\n');
|
|
361
|
+
return 0;
|
|
362
|
+
}
|
|
363
|
+
if (refuseOperatorAct('the approval screen'))
|
|
364
|
+
return 1; // A-SPEC-779.4
|
|
365
|
+
// A-SPEC-262.1 — AWAITED, not fire-and-forget. Measured 2026-08-25 against the shipped bin with a real pty: the
|
|
366
|
+
// prompt printed and the session ended with zero grants, because `void runInteractive(...)` returned 0 immediately
|
|
367
|
+
// and bin/holmes-kit.js turns that into `process.exit(0)` — killing the loop before the first keypress. The decision
|
|
368
|
+
// surface REQ-246 shipped had never run for a real operator; every test called `runInteractive` directly and so
|
|
369
|
+
// never crossed this seam.
|
|
370
|
+
const rl = require('node:readline/promises').createInterface({ input: process.stdin, output: process.stdout });
|
|
371
|
+
// EOF is the operator LEAVING (Ctrl-D, a closed pipe). Node leaves a pending `question` unsettled when the interface
|
|
372
|
+
// closes, so without this the awaited loop would hang the command forever — measured 2026-08-25, a pty probe hung
|
|
373
|
+
// for five minutes. The abort ends the session the way the operator asked: quietly, exit 0, nothing decided that
|
|
374
|
+
// was not decided.
|
|
375
|
+
const ac = new AbortController();
|
|
376
|
+
rl.once('close', () => ac.abort());
|
|
377
|
+
try {
|
|
378
|
+
await runInteractive(root, {
|
|
379
|
+
print: (t) => process.stdout.write(t + '\n'),
|
|
380
|
+
ask: (q) => rl.question(q, { signal: ac.signal }),
|
|
381
|
+
}, actor, stale); // A-SPEC-794.33 — the interactive screen folds as --list does
|
|
382
|
+
}
|
|
383
|
+
catch (e) {
|
|
384
|
+
if (e?.name !== 'AbortError')
|
|
385
|
+
throw e;
|
|
386
|
+
}
|
|
387
|
+
finally {
|
|
388
|
+
rl.close();
|
|
389
|
+
}
|
|
390
|
+
return 0;
|
|
391
|
+
});
|
|
392
|
+
}
|