@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,8 @@
|
|
|
1
|
+
export type ProvisionResult = {
|
|
2
|
+
written: string[];
|
|
3
|
+
} | {
|
|
4
|
+
refused: string;
|
|
5
|
+
};
|
|
6
|
+
/** @implements A-SPEC-774.31 — agy fails closed until its loading of a linked worktree's `.agents` is measured. */
|
|
7
|
+
export declare const AGY_UNMEASURED = "agy until its loading of a linked worktree's .agents is measured";
|
|
8
|
+
export declare function provisionWorktree(worktree: string, engine: string, packageRoot: string, expectCommon?: string): ProvisionResult;
|
|
@@ -0,0 +1,325 @@
|
|
|
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.AGY_UNMEASURED = void 0;
|
|
37
|
+
exports.provisionWorktree = provisionWorktree;
|
|
38
|
+
// @implements A-SPEC-774.29, A-SPEC-774.30, A-SPEC-774.31, A-SPEC-774.32, A-SPEC-774.33, A-SPEC-102.14, A-SPEC-774.37
|
|
39
|
+
/**
|
|
40
|
+
* `run start --provision`: make an orchestrator's worktree governed.
|
|
41
|
+
*
|
|
42
|
+
* Measured 2026-10-23 (D11): a real 0.38.0 `run start --engine claude` on an orchestrator's worktree failed `mcp` and
|
|
43
|
+
* `versions` — that repository keeps `.mcp.json` (it held an approval token) and `.claude/settings.local.json` out of git, so a
|
|
44
|
+
* fresh worktree carries neither. Provisioning writes those two files inside the worktree, and only when git ignores
|
|
45
|
+
* them there: built fresh from THIS CLI's package root (the build the run pins), nothing read from the main checkout
|
|
46
|
+
* (no secret copied), and nothing left once the worktree is removed. `init` would write tracked guidance files into
|
|
47
|
+
* the worktree; runtime-binding is machine-level state that outlives it.
|
|
48
|
+
*
|
|
49
|
+
* @implements A-SPEC-774.30 — codex and agy too, judged by content, through no link:
|
|
50
|
+
* - codex: only the worktree's `.codex/config.toml` MCP table. Measured (codex-cli 0.163): Codex loads a linked
|
|
51
|
+
* worktree's project table when the main checkout is trusted, and not when nothing is. The gate stays the user-level
|
|
52
|
+
* `$CODEX_HOME/hooks.json`: a new project hooks file starts untrusted and would run the gate twice.
|
|
53
|
+
* - agy: `.agents/hooks.json` and `.agents/mcp_config.json`, as `init --agent antigravity` builds them.
|
|
54
|
+
* - A file is skipped only when it already launches Holmes, never because it names holmes. `.claude/settings.json` is
|
|
55
|
+
* never written (an orchestrator may refuse a modified one).
|
|
56
|
+
* - Review H1 (2026-10-23 08:53): every path component below the worktree is lstat-ed and a link refuses the whole provision; each
|
|
57
|
+
* file is written beside its target and renamed into place, so a link swapped in later is replaced, not followed.
|
|
58
|
+
*/
|
|
59
|
+
const crypto = __importStar(require("node:crypto"));
|
|
60
|
+
const fs = __importStar(require("node:fs"));
|
|
61
|
+
const path = __importStar(require("node:path"));
|
|
62
|
+
const node_child_process_1 = require("node:child_process");
|
|
63
|
+
const init_1 = require("./init");
|
|
64
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
65
|
+
const run_wiring_1 = require("./run-wiring");
|
|
66
|
+
const readText = (file) => { try {
|
|
67
|
+
return fs.readFileSync(file, 'utf8');
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
} };
|
|
72
|
+
const readJson = (file) => {
|
|
73
|
+
try {
|
|
74
|
+
const v = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
75
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v) ? v : null;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const objectAt = (doc, key) => {
|
|
82
|
+
const v = doc?.[key];
|
|
83
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v) ? v : {};
|
|
84
|
+
};
|
|
85
|
+
/** Whether git ignores `rel` in the worktree. `check-ignore` exits 0 for an ignored path. */
|
|
86
|
+
function ignored(worktree, rel) {
|
|
87
|
+
// @implements A-SPEC-102.14 — no inherited GIT_* variable points the question at another repository (review L3).
|
|
88
|
+
// @implements A-SPEC-774.79 — the judgments' git environment from its own module, not through run.ts (no cycle)
|
|
89
|
+
const { judgmentGitEnv } = require('../review/verdicts');
|
|
90
|
+
const r = (0, node_child_process_1.spawnSync)('git', ['-C', worktree, 'check-ignore', '-q', '--', rel], { stdio: 'ignore', env: judgmentGitEnv(process.env), timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER });
|
|
91
|
+
return r.status === 0;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @implements A-SPEC-774.33 — the race fix (review H3: 15 of 300 provisions wrote outside while another process swapped
|
|
95
|
+
* `.claude` for a link, because every path call resolved the path again). Node has no openat, so the walk uses the
|
|
96
|
+
* working directory as the directory handle: each component is lstat-ed, created non-recursively, entered, and the
|
|
97
|
+
* entered directory's real path checked. Every later call is relative to that directory, so a component swapped for
|
|
98
|
+
* a link afterwards changes nothing this process touches.
|
|
99
|
+
*/
|
|
100
|
+
class Refusal extends Error {
|
|
101
|
+
}
|
|
102
|
+
const O_NOFOLLOW = fs.constants.O_NOFOLLOW ?? 0;
|
|
103
|
+
const realCwd = () => fs.realpathSync(process.cwd());
|
|
104
|
+
function enterVerified(rootReal, rel) {
|
|
105
|
+
process.chdir(rootReal);
|
|
106
|
+
if (realCwd() !== rootReal)
|
|
107
|
+
throw new Refusal(`the worktree ${rootReal} moved while provisioning`);
|
|
108
|
+
let expected = rootReal;
|
|
109
|
+
let walked = '';
|
|
110
|
+
for (const part of path.dirname(rel).split(/[\\/]+/).filter((p) => p !== '' && p !== '.')) {
|
|
111
|
+
walked = walked === '' ? part : path.join(walked, part);
|
|
112
|
+
let st;
|
|
113
|
+
try {
|
|
114
|
+
st = fs.lstatSync(part);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
try {
|
|
118
|
+
fs.mkdirSync(part);
|
|
119
|
+
}
|
|
120
|
+
catch { /* a racing create: judged below */ }
|
|
121
|
+
st = fs.lstatSync(part);
|
|
122
|
+
}
|
|
123
|
+
if (st.isSymbolicLink())
|
|
124
|
+
throw new Refusal(`${walked} is a symbolic link`);
|
|
125
|
+
if (!st.isDirectory())
|
|
126
|
+
throw new Refusal(`${walked} is not a directory`);
|
|
127
|
+
process.chdir(part);
|
|
128
|
+
expected = path.join(expected, part);
|
|
129
|
+
if (realCwd() !== expected)
|
|
130
|
+
throw new Refusal(`${walked} moved while provisioning`);
|
|
131
|
+
}
|
|
132
|
+
return expected;
|
|
133
|
+
}
|
|
134
|
+
/** Removes what this call wrote: staged temporaries and renamed files it can still reach through verified directories. */
|
|
135
|
+
function rollback(rootReal, staged) {
|
|
136
|
+
for (const s of staged) {
|
|
137
|
+
try {
|
|
138
|
+
if (enterVerified(rootReal, s.rel) !== s.dir)
|
|
139
|
+
continue;
|
|
140
|
+
const name = s.renamed ? s.base : s.tmp;
|
|
141
|
+
const st = fs.lstatSync(name);
|
|
142
|
+
if (!s.renamed || st.ino === s.ino)
|
|
143
|
+
fs.rmSync(name, { force: true });
|
|
144
|
+
}
|
|
145
|
+
catch { /* unreachable now: it stays inside the worktree, where it was written */ }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @implements A-SPEC-774.32 — each file is written whole, from this CLI's package alone. Skipping a file that "already
|
|
150
|
+
* launches Holmes" let forged wiring through, and merging kept `disableAllHooks` and `disabledMcpjsonServers` (review
|
|
151
|
+
* H1, H2, L2 — measured); nothing is read from what was there.
|
|
152
|
+
*/
|
|
153
|
+
function claudePlan(_worktree, packageRoot) {
|
|
154
|
+
const want = (0, run_wiring_1.expectedWiring)(packageRoot);
|
|
155
|
+
const hp = (0, init_1.buildHookPlan)(packageRoot, '.*');
|
|
156
|
+
return [
|
|
157
|
+
{ rel: '.mcp.json', content: () => JSON.stringify({ mcpServers: { 'holmes-kit': want.claudeMcp } }, null, 2) + '\n' },
|
|
158
|
+
{ rel: path.join('.claude', 'settings.local.json'), content: () => JSON.stringify({
|
|
159
|
+
hooks: {
|
|
160
|
+
PreToolUse: [{ matcher: hp.preToolUseMatcher, hooks: [{ type: 'command', command: hp.preToolUseCommand }] }],
|
|
161
|
+
Stop: [{ hooks: [{ type: 'command', command: hp.stopCommand, timeout: 75 }] }],
|
|
162
|
+
SessionStart: [{ hooks: [{ type: 'command', command: hp.sessionStartCommand }] }],
|
|
163
|
+
},
|
|
164
|
+
enabledMcpjsonServers: ['holmes-kit'],
|
|
165
|
+
}, null, 2) + '\n' },
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
function codexPlan(_worktree, packageRoot) {
|
|
169
|
+
const { codexMcpBlock } = require('./codex-toml');
|
|
170
|
+
const want = (0, run_wiring_1.expectedWiring)(packageRoot);
|
|
171
|
+
return [{ rel: path.join('.codex', 'config.toml'), content: () => codexMcpBlock(want.codexMcp) }];
|
|
172
|
+
}
|
|
173
|
+
function agyPlan(worktree, packageRoot) {
|
|
174
|
+
const { agentFiles, mergeWiringFile } = require('./agents');
|
|
175
|
+
const plan = [];
|
|
176
|
+
const hooksRel = path.join('.agents', 'hooks.json');
|
|
177
|
+
const hooksBefore = readText(path.join(worktree, hooksRel));
|
|
178
|
+
if (!(0, run_wiring_1.holmesGate)([{ file: hooksRel, text: hooksBefore }]).ok) {
|
|
179
|
+
const ours = agentFiles('antigravity', { target: worktree, packageRoot, specsDir: '.ax/specs', mcp: false })
|
|
180
|
+
.find((f) => path.basename(f.path) === 'hooks.json').content;
|
|
181
|
+
plan.push({ rel: hooksRel, content: () => (hooksBefore === null ? ours : mergeWiringFile('hooks.json', hooksBefore, ours)?.content ?? ours) });
|
|
182
|
+
}
|
|
183
|
+
const mcpRel = path.join('.agents', 'mcp_config.json');
|
|
184
|
+
const mcpBefore = readText(path.join(worktree, mcpRel));
|
|
185
|
+
let mcpDoc = null;
|
|
186
|
+
try {
|
|
187
|
+
mcpDoc = mcpBefore === null ? null : JSON.parse(mcpBefore);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
mcpDoc = null;
|
|
191
|
+
}
|
|
192
|
+
if (!(0, run_wiring_1.holmesMcpEntry)(objectAt(mcpDoc, 'mcpServers')['holmes-kit']).ok) {
|
|
193
|
+
const ours = `${JSON.stringify({ mcpServers: { 'holmes-kit': { command: 'node', args: [path.join(packageRoot, 'bin', 'holmes-mcp.js')], env: { HOLMES_SPECS: '.ax/specs' } } } }, null, 2)}\n`;
|
|
194
|
+
plan.push({ rel: mcpRel, content: () => (mcpBefore === null ? ours : mergeWiringFile('mcp_config.json', mcpBefore, ours)?.content ?? ours) });
|
|
195
|
+
}
|
|
196
|
+
return plan;
|
|
197
|
+
}
|
|
198
|
+
/** @implements A-SPEC-774.31 — agy fails closed until its loading of a linked worktree's `.agents` is measured. */
|
|
199
|
+
// `agyPlan` above is kept for the day that loading is measured (its own spec); nothing calls it until then.
|
|
200
|
+
exports.AGY_UNMEASURED = "agy until its loading of a linked worktree's .agents is measured";
|
|
201
|
+
function provisionWorktree(worktree, engine, packageRoot, expectCommon) {
|
|
202
|
+
const cwdAtStart = process.cwd();
|
|
203
|
+
if (engine === 'agy')
|
|
204
|
+
return { refused: `provisioning is not available for ${exports.AGY_UNMEASURED} — nothing was written` };
|
|
205
|
+
const plan = engine === 'claude' ? claudePlan(worktree, packageRoot)
|
|
206
|
+
: engine === 'codex' ? codexPlan(worktree, packageRoot)
|
|
207
|
+
: null;
|
|
208
|
+
if (plan === null)
|
|
209
|
+
return { refused: `provisioning is not available for ${engine}` };
|
|
210
|
+
// A link names itself before git is asked (git cannot judge a path beyond a link); the walk below re-checks it race-free.
|
|
211
|
+
for (const p of plan) {
|
|
212
|
+
let cur = worktree;
|
|
213
|
+
for (const part of p.rel.split(/[\\/]+/).filter(Boolean)) {
|
|
214
|
+
cur = path.join(cur, part);
|
|
215
|
+
let st;
|
|
216
|
+
try {
|
|
217
|
+
st = fs.lstatSync(cur);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
if (st.isSymbolicLink())
|
|
223
|
+
return { refused: `${path.relative(worktree, cur)} in ${worktree} is a symbolic link; provisioning writes through no link — remove it, or wire the worktree another way` };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const exposed = plan.filter((p) => !ignored(worktree, p.rel)).map((p) => p.rel);
|
|
227
|
+
if (exposed.length > 0) {
|
|
228
|
+
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` };
|
|
229
|
+
}
|
|
230
|
+
// @implements A-SPEC-774.33 — stage every file, then rename them; any failure removes what this call wrote (M3), and
|
|
231
|
+
// a link or a non-file at a target refuses (M1). The working directory is restored whatever happens.
|
|
232
|
+
const cwd = process.cwd();
|
|
233
|
+
const staged = [];
|
|
234
|
+
// @implements A-SPEC-774.37 — the path the worktree check judged must still be its own real path, and the directory
|
|
235
|
+
// entered must still be a linked worktree (of the expected main), judged from inside it (review N3: 12 of 300).
|
|
236
|
+
let rootReal;
|
|
237
|
+
try {
|
|
238
|
+
rootReal = fs.realpathSync(worktree);
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return { refused: `${worktree} cannot be resolved` };
|
|
242
|
+
}
|
|
243
|
+
if (rootReal !== worktree)
|
|
244
|
+
return { refused: `${worktree} moved since the worktree check (its real path is now ${rootReal}) — nothing was written` };
|
|
245
|
+
try {
|
|
246
|
+
enterVerified(rootReal, 'probe');
|
|
247
|
+
const { judgmentGitEnv } = require('../review/verdicts'); // A-SPEC-774.79
|
|
248
|
+
let dirs = [];
|
|
249
|
+
try {
|
|
250
|
+
dirs = (0, node_child_process_1.spawnSync)('git', ['rev-parse', '--path-format=absolute', '--git-dir', '--git-common-dir'], { encoding: 'utf8', env: judgmentGitEnv(process.env), timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER }).stdout.trim().split('\n');
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
dirs = [];
|
|
254
|
+
}
|
|
255
|
+
const realOf = (p) => { try {
|
|
256
|
+
return fs.realpathSync(p);
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
return p;
|
|
260
|
+
} };
|
|
261
|
+
if (dirs.length !== 2 || dirs[0] === '' || realOf(dirs[0]) === realOf(dirs[1]))
|
|
262
|
+
throw new Refusal(`${rootReal} is not a linked worktree`);
|
|
263
|
+
if (expectCommon !== undefined && realOf(dirs[1]) !== realOf(expectCommon))
|
|
264
|
+
throw new Refusal(`${rootReal} is not a linked worktree of the expected repository`);
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
try {
|
|
268
|
+
process.chdir(cwdAtStart);
|
|
269
|
+
}
|
|
270
|
+
catch { /* gone */ }
|
|
271
|
+
return { refused: `provisioning ${worktree} refused, nothing written: ${e instanceof Error ? e.message : String(e)}` };
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
process.chdir(cwdAtStart);
|
|
275
|
+
}
|
|
276
|
+
catch { /* gone */ }
|
|
277
|
+
try {
|
|
278
|
+
for (const p of plan) {
|
|
279
|
+
const dir = enterVerified(rootReal, p.rel);
|
|
280
|
+
const base = path.basename(p.rel);
|
|
281
|
+
let st = null;
|
|
282
|
+
try {
|
|
283
|
+
st = fs.lstatSync(base);
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
st = null;
|
|
287
|
+
}
|
|
288
|
+
if (st?.isSymbolicLink())
|
|
289
|
+
throw new Refusal(`${p.rel} is a symbolic link; provisioning writes through no link`);
|
|
290
|
+
if (st && !st.isFile())
|
|
291
|
+
throw new Refusal(`${p.rel} is not a regular file`);
|
|
292
|
+
const tmp = `.${base}.holmes-${process.pid}-${crypto.randomBytes(4).toString('hex')}`;
|
|
293
|
+
const fd = fs.openSync(tmp, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY | O_NOFOLLOW, 0o644);
|
|
294
|
+
const entry = { rel: p.rel, tmp, base, dir, renamed: false };
|
|
295
|
+
staged.push(entry);
|
|
296
|
+
try {
|
|
297
|
+
fs.writeSync(fd, p.content());
|
|
298
|
+
entry.ino = fs.fstatSync(fd).ino;
|
|
299
|
+
}
|
|
300
|
+
finally {
|
|
301
|
+
fs.closeSync(fd);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
for (const s of staged) {
|
|
305
|
+
if (enterVerified(rootReal, s.rel) !== s.dir)
|
|
306
|
+
throw new Refusal(`${path.dirname(s.rel)} moved while provisioning`);
|
|
307
|
+
fs.renameSync(s.tmp, s.base);
|
|
308
|
+
s.renamed = true;
|
|
309
|
+
if (realCwd() !== s.dir)
|
|
310
|
+
throw new Refusal(`${path.dirname(s.rel)} moved while provisioning`);
|
|
311
|
+
}
|
|
312
|
+
return { written: plan.map((p) => p.rel) };
|
|
313
|
+
}
|
|
314
|
+
catch (e) {
|
|
315
|
+
rollback(rootReal, staged);
|
|
316
|
+
const why = e instanceof Error ? e.message : String(e);
|
|
317
|
+
return { refused: `provisioning ${worktree} refused, nothing left written: ${why}` };
|
|
318
|
+
}
|
|
319
|
+
finally {
|
|
320
|
+
try {
|
|
321
|
+
process.chdir(cwd);
|
|
322
|
+
}
|
|
323
|
+
catch { /* the original directory is gone */ }
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** `version` null: a Holmes launch whose version cannot be read here (the `holmes-mcp` bin on PATH). */
|
|
2
|
+
export type Pkg = {
|
|
3
|
+
root: string | null;
|
|
4
|
+
version: string | null;
|
|
5
|
+
};
|
|
6
|
+
export type WiringVerdict = {
|
|
7
|
+
ok: true;
|
|
8
|
+
pkg: Pkg;
|
|
9
|
+
detail: string;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
detail: string;
|
|
13
|
+
};
|
|
14
|
+
/** The holmes-kit package an MCP server entry launches, or why it launches none. */
|
|
15
|
+
export declare function holmesMcpEntry(entry: unknown): WiringVerdict;
|
|
16
|
+
/** The holmes-kit package a hook command's script belongs to: its absolute, existing `.js` word. */
|
|
17
|
+
export declare function holmesHookScript(command: string): {
|
|
18
|
+
root: string;
|
|
19
|
+
version: string;
|
|
20
|
+
} | null;
|
|
21
|
+
/** Whether the hooks documents carry a Holmes PreToolUse hook and a Holmes Stop hook; `files` name them in the detail. */
|
|
22
|
+
export declare function holmesGate(docs: {
|
|
23
|
+
file: string;
|
|
24
|
+
text: string | null;
|
|
25
|
+
}[]): WiringVerdict;
|
|
26
|
+
/**
|
|
27
|
+
* @implements A-SPEC-774.32 — the wiring this CLI's package `pkg` builds. The checks pass only for exactly this: a
|
|
28
|
+
* content judgement that accepts "a script inside some holmes-kit package" was forged with echo wrappers, decoy keys,
|
|
29
|
+
* no-match matchers, unrelated scripts and a self-made package.json (review H1, measured).
|
|
30
|
+
*/
|
|
31
|
+
export declare function expectedWiring(pkg: string): {
|
|
32
|
+
claudeMcp: {
|
|
33
|
+
command: string;
|
|
34
|
+
args: string[];
|
|
35
|
+
env: {
|
|
36
|
+
HOLMES_SPECS: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
codexMcp: {
|
|
40
|
+
command: string;
|
|
41
|
+
args: string[];
|
|
42
|
+
};
|
|
43
|
+
claudeHooks: {
|
|
44
|
+
pre: string;
|
|
45
|
+
stop: string;
|
|
46
|
+
sessionStart: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
codexHooks: {
|
|
49
|
+
pre: string;
|
|
50
|
+
stop: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/** @implements A-SPEC-774.32 — an MCP entry equal to `want`, key for key. */
|
|
54
|
+
export declare function exactMcp(entry: unknown, want: unknown, pkgVersion: string | null): WiringVerdict;
|
|
55
|
+
/**
|
|
56
|
+
* @implements A-SPEC-774.32 — a PreToolUse hook (matcher `.*` or none) and a Stop hook whose commands equal this CLI's,
|
|
57
|
+
* read only under `hooks.<Event>[*].hooks[*]`, the shape Claude and Codex load.
|
|
58
|
+
*/
|
|
59
|
+
export declare function exactGate(docs: {
|
|
60
|
+
file: string;
|
|
61
|
+
text: string | null;
|
|
62
|
+
}[], want: {
|
|
63
|
+
pre: string;
|
|
64
|
+
stop: string;
|
|
65
|
+
}): WiringVerdict;
|
|
66
|
+
/** @implements A-SPEC-774.32 — whether `pkg` lies inside `worktree`, where the engine could rewrite it. */
|
|
67
|
+
export declare function packageInside(pkg: string, worktree: string): boolean;
|
|
68
|
+
/** Whether a Codex user config marks one of `dirs` trusted. */
|
|
69
|
+
export declare function codexTrusts(configText: string | null, dirs: string[]): boolean;
|
|
@@ -0,0 +1,270 @@
|
|
|
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.holmesMcpEntry = holmesMcpEntry;
|
|
37
|
+
exports.holmesHookScript = holmesHookScript;
|
|
38
|
+
exports.holmesGate = holmesGate;
|
|
39
|
+
exports.expectedWiring = expectedWiring;
|
|
40
|
+
exports.exactMcp = exactMcp;
|
|
41
|
+
exports.exactGate = exactGate;
|
|
42
|
+
exports.packageInside = packageInside;
|
|
43
|
+
exports.codexTrusts = codexTrusts;
|
|
44
|
+
// @implements A-SPEC-774.30, A-SPEC-774.32
|
|
45
|
+
/**
|
|
46
|
+
* What a worktree's wiring launches, judged by content. A "holmes" substring is not wiring: a settings.json holding
|
|
47
|
+
* only that word skipped provisioning and passed the gate check (measured by an orchestrator's review). An MCP entry is Holmes's when it runs
|
|
48
|
+
* an existing holmes-mcp.js inside a `@holmes-lab/holmes-kit` package (or an npx pinned to that package); a gate is
|
|
49
|
+
* Holmes's when a PreToolUse hook and a Stop hook each run an existing script inside such a package.
|
|
50
|
+
*/
|
|
51
|
+
const fs = __importStar(require("node:fs"));
|
|
52
|
+
const path = __importStar(require("node:path"));
|
|
53
|
+
const run_refusals_1 = require("../guardrail/run-refusals");
|
|
54
|
+
const MCP_SCRIPTS = new Set(['bin/holmes-mcp.js', 'dist/holmes/mcp/server.js']);
|
|
55
|
+
const isFile = (p) => { try {
|
|
56
|
+
return fs.statSync(p).isFile();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
} };
|
|
61
|
+
const NPX_PIN = /^@holmes-lab\/holmes-kit@(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)$/;
|
|
62
|
+
/** The holmes-kit package an MCP server entry launches, or why it launches none. */
|
|
63
|
+
function holmesMcpEntry(entry) {
|
|
64
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry))
|
|
65
|
+
return { ok: false, detail: 'no holmes-kit server entry' };
|
|
66
|
+
const e = entry;
|
|
67
|
+
const args = Array.isArray(e.args) ? e.args.filter((a) => typeof a === 'string') : [];
|
|
68
|
+
if (e.command === 'node') {
|
|
69
|
+
const script = args[0];
|
|
70
|
+
if (script === undefined || !path.isAbsolute(script)) {
|
|
71
|
+
return { ok: false, detail: `the holmes-kit entry runs node ${script ?? '(no script)'}, not an absolute holmes-kit MCP script` };
|
|
72
|
+
}
|
|
73
|
+
if (!isFile(script))
|
|
74
|
+
return { ok: false, detail: `the holmes-kit entry runs ${script}, which does not exist` };
|
|
75
|
+
const pkg = (0, run_refusals_1.holmesPackageAbove)(script);
|
|
76
|
+
if (pkg === null)
|
|
77
|
+
return { ok: false, detail: `${script} is not inside a @holmes-lab/holmes-kit package` };
|
|
78
|
+
const rel = path.relative(pkg.root, script).replace(/\\/g, '/');
|
|
79
|
+
if (!MCP_SCRIPTS.has(rel))
|
|
80
|
+
return { ok: false, detail: `${script} is not holmes-kit's MCP entry (${[...MCP_SCRIPTS].join(' or ')})` };
|
|
81
|
+
return { ok: true, pkg, detail: `runs ${script} (holmes-kit ${pkg.version})` };
|
|
82
|
+
}
|
|
83
|
+
// The package's own `holmes-mcp` bin on PATH: Holmes's server, at a version run start cannot read.
|
|
84
|
+
if (typeof e.command === 'string' && /^holmes-mcp(?:\.cmd)?$/i.test(path.basename(e.command))) {
|
|
85
|
+
return { ok: true, pkg: { root: null, version: null }, detail: `runs the holmes-mcp bin on PATH (version unreadable)` };
|
|
86
|
+
}
|
|
87
|
+
if (e.command === 'npx') {
|
|
88
|
+
const pin = args.map((a) => NPX_PIN.exec(a)).find((m) => m !== null);
|
|
89
|
+
if (pin)
|
|
90
|
+
return { ok: true, pkg: { root: null, version: pin[1] }, detail: `runs npx @holmes-lab/holmes-kit@${pin[1]}` };
|
|
91
|
+
return { ok: false, detail: 'the holmes-kit entry runs npx without a pinned @holmes-lab/holmes-kit version' };
|
|
92
|
+
}
|
|
93
|
+
return { ok: false, detail: `the holmes-kit entry runs ${typeof e.command === 'string' ? e.command : '(no command)'}, which is no launch holmes-kit can identify` };
|
|
94
|
+
}
|
|
95
|
+
/** The holmes-kit package a hook command's script belongs to: its absolute, existing `.js` word. */
|
|
96
|
+
function holmesHookScript(command) {
|
|
97
|
+
const words = command.match(/"[^"]*"|'[^']*'|\S+/g) ?? [];
|
|
98
|
+
for (const w of words) {
|
|
99
|
+
const word = w.replace(/^["']|["']$/g, '');
|
|
100
|
+
if (!/\.js$/.test(word) || !path.isAbsolute(word) || !isFile(word))
|
|
101
|
+
continue;
|
|
102
|
+
const pkg = (0, run_refusals_1.holmesPackageAbove)(word);
|
|
103
|
+
if (pkg !== null)
|
|
104
|
+
return pkg;
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
/** Every hook `command` string under the key `event`, anywhere in a hooks document (Claude, Codex and agy shapes). */
|
|
109
|
+
function commandsUnder(doc, event) {
|
|
110
|
+
const out = [];
|
|
111
|
+
const collect = (v) => {
|
|
112
|
+
if (Array.isArray(v)) {
|
|
113
|
+
v.forEach(collect);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (v && typeof v === 'object') {
|
|
117
|
+
const o = v;
|
|
118
|
+
if (typeof o.command === 'string')
|
|
119
|
+
out.push(o.command);
|
|
120
|
+
Object.values(o).forEach(collect);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const find = (v) => {
|
|
124
|
+
if (Array.isArray(v)) {
|
|
125
|
+
v.forEach(find);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (v && typeof v === 'object') {
|
|
129
|
+
for (const [k, child] of Object.entries(v)) {
|
|
130
|
+
if (k === event)
|
|
131
|
+
collect(child);
|
|
132
|
+
else
|
|
133
|
+
find(child);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
find(doc);
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
const parseJson = (text) => { if (text === null)
|
|
141
|
+
return null; try {
|
|
142
|
+
return JSON.parse(text);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return null;
|
|
146
|
+
} };
|
|
147
|
+
/** Whether the hooks documents carry a Holmes PreToolUse hook and a Holmes Stop hook; `files` name them in the detail. */
|
|
148
|
+
function holmesGate(docs) {
|
|
149
|
+
const found = { PreToolUse: null, Stop: null };
|
|
150
|
+
for (const d of docs) {
|
|
151
|
+
const doc = parseJson(d.text);
|
|
152
|
+
for (const event of ['PreToolUse', 'Stop']) {
|
|
153
|
+
if (found[event])
|
|
154
|
+
continue;
|
|
155
|
+
for (const c of commandsUnder(doc, event)) {
|
|
156
|
+
const pkg = holmesHookScript(c);
|
|
157
|
+
if (pkg) {
|
|
158
|
+
found[event] = { ...pkg, file: d.file };
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const missing = ['PreToolUse', 'Stop'].filter((e) => found[e] === null);
|
|
165
|
+
if (missing.length > 0) {
|
|
166
|
+
return { ok: false, detail: `no ${missing.join(' or ')} hook in ${docs.map((d) => d.file).join(', ')} runs a script inside a holmes-kit package` };
|
|
167
|
+
}
|
|
168
|
+
const pre = found.PreToolUse;
|
|
169
|
+
return { ok: true, pkg: { root: pre.root, version: pre.version }, detail: `PreToolUse and Stop run holmes-kit ${pre.version} (${pre.file})` };
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @implements A-SPEC-774.32 — the wiring this CLI's package `pkg` builds. The checks pass only for exactly this: a
|
|
173
|
+
* content judgement that accepts "a script inside some holmes-kit package" was forged with echo wrappers, decoy keys,
|
|
174
|
+
* no-match matchers, unrelated scripts and a self-made package.json (review H1, measured).
|
|
175
|
+
*/
|
|
176
|
+
function expectedWiring(pkg) {
|
|
177
|
+
const { buildHookPlan } = require('./init');
|
|
178
|
+
const hp = buildHookPlan(pkg, '.*');
|
|
179
|
+
const mcpScript = path.join(pkg, 'bin', 'holmes-mcp.js');
|
|
180
|
+
const kernel = (s) => `node "${path.join(pkg, 'dist', 'holmes', 'hooks', s)}"`;
|
|
181
|
+
return {
|
|
182
|
+
claudeMcp: { command: 'node', args: [mcpScript], env: { HOLMES_SPECS: '.ax/specs' } },
|
|
183
|
+
codexMcp: { command: 'node', args: [mcpScript] },
|
|
184
|
+
claudeHooks: { pre: hp.preToolUseCommand, stop: hp.stopCommand, sessionStart: hp.sessionStartCommand },
|
|
185
|
+
codexHooks: { pre: kernel('pre-tool-use.js'), stop: kernel('stop.js') },
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const canon = (v) => JSON.stringify(v, (_k, x) => (x && typeof x === 'object' && !Array.isArray(x)
|
|
189
|
+
? Object.fromEntries(Object.keys(x).sort().map((k) => [k, x[k]])) : x));
|
|
190
|
+
/** @implements A-SPEC-774.32 — an MCP entry equal to `want`, key for key. */
|
|
191
|
+
function exactMcp(entry, want, pkgVersion) {
|
|
192
|
+
if (entry === undefined || entry === null)
|
|
193
|
+
return { ok: false, detail: 'no holmes-kit server entry' };
|
|
194
|
+
if (canon(entry) !== canon(want))
|
|
195
|
+
return { ok: false, detail: `the holmes-kit entry is not the one this CLI writes (${canon(want).slice(0, 200)})` };
|
|
196
|
+
return { ok: true, pkg: { root: null, version: pkgVersion }, detail: 'the holmes-kit entry is the one this CLI writes' };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* @implements A-SPEC-774.32 — a PreToolUse hook (matcher `.*` or none) and a Stop hook whose commands equal this CLI's,
|
|
200
|
+
* read only under `hooks.<Event>[*].hooks[*]`, the shape Claude and Codex load.
|
|
201
|
+
*/
|
|
202
|
+
function exactGate(docs, want) {
|
|
203
|
+
const has = (doc, event, command) => {
|
|
204
|
+
const groups = doc?.hooks?.[event];
|
|
205
|
+
if (!Array.isArray(groups))
|
|
206
|
+
return false;
|
|
207
|
+
return groups.some((g) => {
|
|
208
|
+
if (!g || typeof g !== 'object')
|
|
209
|
+
return false;
|
|
210
|
+
const matcher = g.matcher;
|
|
211
|
+
if (event === 'PreToolUse' && matcher !== undefined && matcher !== '.*')
|
|
212
|
+
return false;
|
|
213
|
+
const hooks = g.hooks;
|
|
214
|
+
return Array.isArray(hooks) && hooks.some((h) => h && typeof h === 'object'
|
|
215
|
+
&& h.type === 'command' && h.command === command);
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
const parsed = docs.map((d) => ({ file: d.file, doc: parseJson(d.text) }));
|
|
219
|
+
const pre = parsed.find((d) => has(d.doc, 'PreToolUse', want.pre));
|
|
220
|
+
const stop = parsed.find((d) => has(d.doc, 'Stop', want.stop));
|
|
221
|
+
const missing = [...(pre ? [] : ['PreToolUse']), ...(stop ? [] : ['Stop'])];
|
|
222
|
+
if (missing.length > 0) {
|
|
223
|
+
return { ok: false, detail: `no ${missing.join(' or ')} hook in ${docs.map((d) => d.file).join(', ')} is the one this CLI writes (${missing.includes('PreToolUse') ? want.pre : want.stop})` };
|
|
224
|
+
}
|
|
225
|
+
return { ok: true, pkg: { root: null, version: null }, detail: `PreToolUse and Stop are the hooks this CLI writes (${pre.file})` };
|
|
226
|
+
}
|
|
227
|
+
/** @implements A-SPEC-774.32 — whether `pkg` lies inside `worktree`, where the engine could rewrite it. */
|
|
228
|
+
function packageInside(pkg, worktree) {
|
|
229
|
+
const real = (p) => { try {
|
|
230
|
+
return fs.realpathSync(p);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return path.resolve(p);
|
|
234
|
+
} };
|
|
235
|
+
const rel = path.relative(real(worktree), real(pkg));
|
|
236
|
+
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
237
|
+
}
|
|
238
|
+
/** Whether a Codex user config marks one of `dirs` trusted. */
|
|
239
|
+
function codexTrusts(configText, dirs) {
|
|
240
|
+
if (configText === null)
|
|
241
|
+
return false;
|
|
242
|
+
const { parseCodexConfig } = require('./codex-toml');
|
|
243
|
+
const parsed = parseCodexConfig(configText);
|
|
244
|
+
if (!parsed.ok)
|
|
245
|
+
return false;
|
|
246
|
+
const projects = parsed.doc.projects;
|
|
247
|
+
if (!projects || typeof projects !== 'object')
|
|
248
|
+
return false;
|
|
249
|
+
const wanted = new Set();
|
|
250
|
+
for (const d of dirs) {
|
|
251
|
+
wanted.add(path.resolve(d));
|
|
252
|
+
try {
|
|
253
|
+
wanted.add(fs.realpathSync(d));
|
|
254
|
+
}
|
|
255
|
+
catch { /* the path itself */ }
|
|
256
|
+
}
|
|
257
|
+
for (const [key, value] of Object.entries(projects)) {
|
|
258
|
+
const level = value?.trust_level;
|
|
259
|
+
if (level !== 'trusted')
|
|
260
|
+
continue;
|
|
261
|
+
if (wanted.has(path.resolve(key)))
|
|
262
|
+
return true;
|
|
263
|
+
try {
|
|
264
|
+
if (wanted.has(fs.realpathSync(key)))
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
catch { /* a stale key */ }
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|