@holmes-lab/holmes-kit 0.39.0 → 0.40.1
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 +578 -6
- package/README.md +120 -41
- 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 +49 -13
- package/dist/holmes/cli/approve.js +249 -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 +34 -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 +226 -442
- package/dist/holmes/cli/init.js +33 -0
- package/dist/holmes/cli/interactive-prompt.d.ts +39 -2
- package/dist/holmes/cli/interactive-prompt.js +98 -16
- 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.js +1 -1
- 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 +3 -1
- package/dist/holmes/cli/run-provision.js +255 -44
- 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 +21 -0
- package/dist/holmes/cli/run.js +341 -92
- 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 +19 -0
- package/dist/holmes/config/config.js +18 -3
- 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 +26 -0
- package/dist/holmes/governance/approval-queue.js +109 -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 +12 -0
- package/dist/holmes/governance/autonomy.js +51 -15
- 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.d.ts +2 -0
- package/dist/holmes/governance/push-gate-runner.js +50 -9
- package/dist/holmes/governance/push-gate.d.ts +13 -2
- package/dist/holmes/governance/push-gate.js +106 -14
- 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/guardrail/advisory-line.d.ts +102 -0
- package/dist/holmes/guardrail/advisory-line.js +718 -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 +7 -0
- package/dist/holmes/guardrail/impact-gate.js +33 -6
- 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 +64 -10
- package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
- package/dist/holmes/guardrail/risk-classifier.js +228 -16
- 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.js +24 -8
- package/dist/holmes/guardrail/run-stages.d.ts +5 -0
- package/dist/holmes/guardrail/run-stages.js +25 -5
- 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 +116 -1
- package/dist/holmes/hooks/pre-tool-use.js +1176 -170
- 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.js +17 -1
- package/dist/holmes/hooks/stop.d.ts +23 -0
- package/dist/holmes/hooks/stop.js +86 -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 +3 -0
- package/dist/holmes/mcp/handlers/approval-ask.js +18 -7
- 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/maintenance-analysis.d.ts +13 -0
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +59 -2
- 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 +471 -4
- package/dist/holmes/mcp/handlers/test-execution.js +199 -21
- package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers.d.ts +557 -82
- package/dist/holmes/mcp/handlers.js +74 -23
- 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 +6 -1
- package/dist/holmes/mcp/maintenance-analyze.js +13 -11
- package/dist/holmes/mcp/maintenance-evidence.d.ts +9 -0
- package/dist/holmes/mcp/maintenance-evidence.js +35 -3
- package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
- package/dist/holmes/mcp/server-staleness.js +1 -1
- package/dist/holmes/mcp/server.js +9 -8
- 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 -9
- package/dist/holmes/project/act-root.d.ts +19 -0
- package/dist/holmes/project/act-root.js +100 -0
- package/dist/holmes/project/baseline.d.ts +15 -2
- package/dist/holmes/project/baseline.js +14 -8
- 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 +51 -2
- package/dist/holmes/project/bounded-io.js +140 -6
- package/dist/holmes/project/change-source.d.ts +4 -0
- package/dist/holmes/project/change-source.js +14 -6
- 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 +29 -8
- 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/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/evidence-mode.d.ts +21 -0
- package/dist/holmes/review/evidence-mode.js +33 -0
- package/dist/holmes/review/head-worktree.d.ts +55 -0
- package/dist/holmes/review/head-worktree.js +329 -0
- package/dist/holmes/review/hop-ablation.d.ts +4 -4
- package/dist/holmes/review/hop-ablation.js +5 -5
- package/dist/holmes/review/mrp.js +13 -3
- 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/run-provenance.d.ts +45 -0
- package/dist/holmes/review/run-provenance.js +314 -0
- package/dist/holmes/review/semantic-arm.d.ts +3 -3
- package/dist/holmes/review/semantic-arm.js +3 -3
- package/dist/holmes/review/test-evidence.d.ts +174 -0
- package/dist/holmes/review/test-evidence.js +330 -2
- package/dist/holmes/review/test-outcomes.js +3 -1
- package/dist/holmes/review/test-reports.d.ts +94 -0
- package/dist/holmes/review/test-reports.js +382 -0
- package/dist/holmes/review/test-runner.d.ts +180 -58
- package/dist/holmes/review/test-runner.js +560 -324
- package/dist/holmes/review/test-selection-breadth.js +2 -2
- package/dist/holmes/review/test-units.d.ts +159 -0
- package/dist/holmes/review/test-units.js +814 -0
- package/dist/holmes/review/verdicts.d.ts +105 -8
- package/dist/holmes/review/verdicts.js +640 -36
- 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 +47 -34
- package/dist/holmes/review/manual-baseline.d.ts +0 -209
- package/dist/holmes/review/manual-baseline.js +0 -2847
|
@@ -3,4 +3,6 @@ export type ProvisionResult = {
|
|
|
3
3
|
} | {
|
|
4
4
|
refused: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
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;
|
|
@@ -33,25 +33,42 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AGY_UNMEASURED = void 0;
|
|
36
37
|
exports.provisionWorktree = provisionWorktree;
|
|
37
|
-
// @implements A-SPEC-774.29
|
|
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
|
|
38
39
|
/**
|
|
39
40
|
* `run start --provision`: make an orchestrator's worktree governed.
|
|
40
41
|
*
|
|
41
|
-
* Measured 2026-10-23 (D11): a real 0.38.0 `run start --engine claude` on
|
|
42
|
-
* `versions` —
|
|
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
|
|
43
44
|
* fresh worktree carries neither. Provisioning writes those two files inside the worktree, and only when git ignores
|
|
44
45
|
* them there: built fresh from THIS CLI's package root (the build the run pins), nothing read from the main checkout
|
|
45
46
|
* (no secret copied), and nothing left once the worktree is removed. `init` would write tracked guidance files into
|
|
46
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.
|
|
47
58
|
*/
|
|
59
|
+
const crypto = __importStar(require("node:crypto"));
|
|
48
60
|
const fs = __importStar(require("node:fs"));
|
|
49
61
|
const path = __importStar(require("node:path"));
|
|
50
62
|
const node_child_process_1 = require("node:child_process");
|
|
51
63
|
const init_1 = require("./init");
|
|
52
64
|
const bounded_io_1 = require("../project/bounded-io");
|
|
53
|
-
const
|
|
54
|
-
const
|
|
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
|
+
} };
|
|
55
72
|
const readJson = (file) => {
|
|
56
73
|
try {
|
|
57
74
|
const v = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
@@ -61,54 +78,248 @@ const readJson = (file) => {
|
|
|
61
78
|
return null;
|
|
62
79
|
}
|
|
63
80
|
};
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
81
|
+
const objectAt = (doc, key) => {
|
|
82
|
+
const v = doc?.[key];
|
|
83
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v) ? v : {};
|
|
71
84
|
};
|
|
72
85
|
/** Whether git ignores `rel` in the worktree. `check-ignore` exits 0 for an ignored path. */
|
|
73
86
|
function ignored(worktree, rel) {
|
|
74
|
-
|
|
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 });
|
|
75
91
|
return r.status === 0;
|
|
76
92
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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`);
|
|
80
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');
|
|
81
175
|
const plan = [];
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
}
|
|
107
226
|
const exposed = plan.filter((p) => !ignored(worktree, p.rel)).map((p) => p.rel);
|
|
108
227
|
if (exposed.length > 0) {
|
|
109
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` };
|
|
110
229
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
+
}
|
|
114
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;
|