harnery 0.29.0 → 0.31.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/README.md +4 -4
- package/dist/commander.d.ts +8 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +14 -13
- package/dist/commands/adapter.d.ts +12 -0
- package/dist/commands/adapter.d.ts.map +1 -0
- package/dist/commands/{harness.js → adapter.js} +35 -35
- package/dist/commands/agents.d.ts +3 -2
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +61 -60
- package/dist/commands/artifacts.d.ts +4 -0
- package/dist/commands/artifacts.d.ts.map +1 -0
- package/dist/commands/artifacts.js +143 -0
- package/dist/commands/backup.d.ts +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +5 -2
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +310 -7
- package/dist/commands/checkpoint.d.ts +12 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +162 -0
- package/dist/commands/context.d.ts +2 -2
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +3 -151
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +31 -7
- package/dist/commands/deinit.d.ts +2 -2
- package/dist/commands/deinit.js +15 -15
- package/dist/commands/doctor.js +23 -23
- package/dist/commands/governor.d.ts +4 -0
- package/dist/commands/governor.d.ts.map +1 -0
- package/dist/commands/{supervisor.js → governor.js} +133 -108
- package/dist/commands/init.d.ts +12 -12
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +44 -30
- package/dist/commands/{session.d.ts → journal.d.ts} +2 -2
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/{scratch.js → journal.js} +47 -47
- package/dist/commands/policy.js +1 -1
- package/dist/commands/presence.js +2 -2
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +3 -3
- package/dist/commands/tunnel.d.ts +16 -0
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +193 -23
- package/dist/commands/web-fetch.js +1 -1
- package/dist/commands/web.d.ts +19 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +51 -0
- package/dist/commands/work.d.ts +2 -1
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +55 -25
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +35 -28
- package/dist/core/{harnesses → adapters}/attest-projection.d.ts +2 -2
- package/dist/core/adapters/attest-projection.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attest.d.ts +16 -16
- package/dist/core/adapters/attest.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attest.js +9 -9
- package/dist/core/{harnesses → adapters}/attestation.d.ts +16 -16
- package/dist/core/adapters/attestation.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attestation.js +20 -20
- package/dist/core/{harnesses → adapters}/bench.d.ts +12 -12
- package/dist/core/adapters/bench.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/bench.js +12 -12
- package/dist/core/adapters/index.d.ts +13 -0
- package/dist/core/adapters/index.d.ts.map +1 -0
- package/dist/core/adapters/index.js +6 -0
- package/dist/core/{harnesses → adapters}/profiles.d.ts +11 -11
- package/dist/core/adapters/profiles.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/profiles.js +11 -11
- package/dist/core/adapters/registry.d.ts +15 -0
- package/dist/core/adapters/registry.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/registry.js +11 -11
- package/dist/core/{harnesses → adapters}/types.d.ts +28 -23
- package/dist/core/adapters/types.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/types.js +1 -1
- package/dist/core/agents/canonical-emit.d.ts +4 -4
- package/dist/core/agents/canonical-emit.js +5 -5
- package/dist/core/agents/cli-emit.js +1 -1
- package/dist/core/agents/cli.js +30 -26
- package/dist/core/agents/codex-replay.d.ts +1 -1
- package/dist/core/agents/codex-replay.js +6 -6
- package/dist/core/agents/coord-client.d.ts +21 -2
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +122 -27
- package/dist/core/agents/events/consume.d.ts +1 -1
- package/dist/core/agents/events/emit.d.ts +5 -6
- package/dist/core/agents/events/emit.d.ts.map +1 -1
- package/dist/core/agents/events/emit.js +2 -2
- package/dist/core/agents/render/prompt-context.d.ts +21 -9
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +82 -30
- package/dist/core/agents/render/session-context.d.ts +1 -1
- package/dist/core/agents/render/session-context.js +5 -5
- package/dist/core/agents/rules/claim-conflict.d.ts +2 -6
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +1 -1
- package/dist/core/agents/rules/commit-conflict.js +98 -22
- package/dist/core/agents/rules/stop-hook.d.ts +9 -9
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +23 -5
- package/dist/core/agents/rules/verdict.d.ts +14 -0
- package/dist/core/agents/rules/verdict.d.ts.map +1 -0
- package/dist/core/agents/rules/verdict.js +1 -0
- package/dist/core/agents/session-events.js +3 -3
- package/dist/core/agents/state/council.d.ts +1 -1
- package/dist/core/agents/state/council.js +1 -1
- package/dist/core/agents/state/heartbeat-projector.d.ts +3 -2
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-projector.js +14 -10
- package/dist/core/agents/state/heartbeat-writer.d.ts +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +12 -12
- package/dist/core/agents/state/{scratch.d.ts → journal.d.ts} +7 -7
- package/dist/core/agents/state/{scratch.d.ts.map → journal.d.ts.map} +1 -1
- package/dist/core/agents/state/{scratch.js → journal.js} +12 -12
- package/dist/core/agents/state/pidmap.d.ts +28 -4
- package/dist/core/agents/state/pidmap.d.ts.map +1 -1
- package/dist/core/agents/state/pidmap.js +130 -15
- package/dist/core/agents/state/proc-start.d.ts +95 -0
- package/dist/core/agents/state/proc-start.d.ts.map +1 -0
- package/dist/core/agents/state/proc-start.js +199 -0
- package/dist/core/agents/state/shell-mutation.d.ts +1 -1
- package/dist/core/agents/state/shell-mutation.js +1 -1
- package/dist/core/agents/state/stale-sweep.js +7 -7
- package/dist/core/artifacts/index.d.ts +86 -0
- package/dist/core/artifacts/index.d.ts.map +1 -0
- package/dist/core/artifacts/index.js +421 -0
- package/dist/core/config.d.ts +9 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +26 -2
- package/dist/core/context/index.d.ts +12 -12
- package/dist/core/context/index.js +10 -10
- package/dist/core/governor/adapter-spread.d.ts +52 -0
- package/dist/core/governor/adapter-spread.d.ts.map +1 -0
- package/dist/core/governor/adapter-spread.js +52 -0
- package/dist/core/governor/index.d.ts +7 -0
- package/dist/core/governor/index.d.ts.map +1 -0
- package/dist/core/governor/index.js +6 -0
- package/dist/core/governor/plan-api.d.ts +38 -0
- package/dist/core/governor/plan-api.d.ts.map +1 -0
- package/dist/core/governor/plan-api.js +83 -0
- package/dist/core/governor/plan-read.d.ts +5 -0
- package/dist/core/governor/plan-read.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/plan-read.js +71 -51
- package/dist/core/governor/plan-types.d.ts +181 -0
- package/dist/core/governor/plan-types.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/plan-types.js +4 -4
- package/dist/core/governor/planning.d.ts +48 -0
- package/dist/core/governor/planning.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/planning.js +143 -94
- package/dist/core/governor/read.d.ts +6 -0
- package/dist/core/governor/read.d.ts.map +1 -0
- package/dist/core/governor/read.js +4 -0
- package/dist/core/governor/runner.d.ts +37 -0
- package/dist/core/governor/runner.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/runner.js +15 -15
- package/dist/core/governor/service-read.d.ts +6 -0
- package/dist/core/governor/service-read.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/service-read.js +12 -12
- package/dist/core/governor/service.d.ts +114 -0
- package/dist/core/governor/service.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/service.js +57 -57
- package/dist/core/governor/state.d.ts +116 -0
- package/dist/core/governor/state.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/state.js +290 -116
- package/dist/core/hooks/adapter/detect.d.ts +9 -0
- package/dist/core/hooks/{harness → adapter}/detect.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/detect.js +8 -8
- package/dist/core/hooks/{harness → adapter}/events.d.ts +15 -14
- package/dist/core/hooks/adapter/events.d.ts.map +1 -0
- package/dist/core/hooks/{harness → adapter}/events.js +5 -5
- package/dist/core/hooks/{harness → adapter}/output.d.ts +20 -14
- package/dist/core/hooks/adapter/output.d.ts.map +1 -0
- package/dist/core/hooks/{harness → adapter}/output.js +30 -22
- package/dist/core/hooks/{harness → adapter}/parse.d.ts +5 -5
- package/dist/core/hooks/{harness → adapter}/parse.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/parse.js +4 -4
- package/dist/core/hooks/{harness → adapter}/wiring.d.ts +15 -15
- package/dist/core/hooks/{harness → adapter}/wiring.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/wiring.js +13 -13
- package/dist/core/hooks/cli.d.ts +3 -3
- package/dist/core/hooks/cli.js +175 -151
- package/dist/core/hooks/effects/image-capture.d.ts +5 -5
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +3 -3
- package/dist/core/hooks/effects/index.d.ts +12 -12
- package/dist/core/hooks/effects/index.d.ts.map +1 -1
- package/dist/core/hooks/effects/index.js +17 -17
- package/dist/core/hooks/events/emit.d.ts +2 -2
- package/dist/core/hooks/events/emit.d.ts.map +1 -1
- package/dist/core/hooks/events/emit.js +1 -1
- package/dist/core/hooks/events/rotate.js +1 -1
- package/dist/core/hooks/events/schema.d.ts +13 -5
- package/dist/core/hooks/events/schema.d.ts.map +1 -1
- package/dist/core/hooks/guard-path.d.ts +2 -2
- package/dist/core/hooks/guard-path.js +2 -2
- package/dist/core/hooks/index.d.ts +1 -1
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/resolve/anchor.d.ts +14 -5
- package/dist/core/hooks/resolve/anchor.d.ts.map +1 -1
- package/dist/core/hooks/resolve/anchor.js +64 -7
- package/dist/core/hooks/resolve/coord-root.d.ts +3 -3
- package/dist/core/hooks/resolve/coord-root.js +4 -4
- package/dist/core/hooks/resolve/intent.js +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +1 -1
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +11 -5
- package/dist/core/{scratch → journal}/index.d.ts +25 -25
- package/dist/core/{scratch → journal}/index.d.ts.map +1 -1
- package/dist/core/{scratch → journal}/index.js +38 -38
- package/dist/core/policy/evaluate.d.ts +1 -1
- package/dist/core/policy/evaluate.d.ts.map +1 -1
- package/dist/core/policy/evaluate.js +7 -7
- package/dist/core/policy/types.d.ts +3 -3
- package/dist/core/policy/types.d.ts.map +1 -1
- package/dist/core/work/runner.d.ts.map +1 -1
- package/dist/core/work/runner.js +11 -2
- package/dist/core/work/state.d.ts +28 -3
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +148 -16
- package/dist/core/workflow/adapters.d.ts +17 -0
- package/dist/core/workflow/adapters.d.ts.map +1 -0
- package/dist/core/workflow/adapters.js +21 -0
- package/dist/core/workflow/approvals.js +6 -6
- package/dist/core/workflow/billing.d.ts +9 -9
- package/dist/core/workflow/billing.js +9 -9
- package/dist/core/workflow/child-env.d.ts +10 -2
- package/dist/core/workflow/child-env.d.ts.map +1 -1
- package/dist/core/workflow/child-env.js +12 -4
- package/dist/core/workflow/engine.d.ts +15 -5
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +151 -83
- package/dist/core/workflow/evidence-preflight.d.ts +24 -0
- package/dist/core/workflow/evidence-preflight.d.ts.map +1 -0
- package/dist/core/workflow/evidence-preflight.js +134 -0
- package/dist/core/workflow/index.d.ts +3 -2
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -1
- package/dist/core/workflow/proof.d.ts +28 -5
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +77 -34
- package/dist/core/workflow/run-state.d.ts +1 -1
- package/dist/core/workflow/run-state.js +7 -7
- package/dist/core/workflow/sandbox-projection.d.ts +6 -6
- package/dist/core/workflow/sandbox-projection.d.ts.map +1 -1
- package/dist/core/workflow/sandbox-projection.js +11 -11
- package/dist/core/workflow/spawn-claude.d.ts +3 -3
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +28 -8
- package/dist/core/workflow/spawn-codex.d.ts +4 -4
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +26 -8
- package/dist/core/workflow/spawn-cursor.d.ts +4 -4
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +27 -8
- package/dist/core/workflow/spawn-failure.d.ts +15 -1
- package/dist/core/workflow/spawn-failure.d.ts.map +1 -1
- package/dist/core/workflow/spawn-failure.js +35 -1
- package/dist/core/workflow/specialists.js +2 -2
- package/dist/core/workflow/{journal.d.ts → transcript.d.ts} +8 -8
- package/dist/core/workflow/transcript.d.ts.map +1 -0
- package/dist/core/workflow/{journal.js → transcript.js} +14 -14
- package/dist/core/workflow/types.d.ts +119 -46
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/types.js +11 -1
- package/dist/core/workflow/validate.d.ts +1 -1
- package/dist/core/workflow/validate.js +1 -1
- package/dist/core/workflow/workspaces/cancellation.js +2 -2
- package/dist/core/workflow/workspaces/cleanup.js +2 -2
- package/dist/core/workflow/workspaces/execution.js +6 -6
- package/dist/core/workflow/workspaces/inspect.js +9 -9
- package/dist/core/workflow/workspaces/integration.js +14 -14
- package/dist/core/workflow/workspaces/lifecycle.d.ts +1 -1
- package/dist/core/workflow/workspaces/lifecycle.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/lifecycle.js +9 -9
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +39 -5
- package/dist/core/workflow/workspaces/recovery.js +3 -3
- package/dist/core/workflow/workspaces/state.d.ts +1 -1
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +3 -3
- package/dist/core/workflow/workspaces/types.d.ts +1 -1
- package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
- package/dist/lib/browser/asserts.d.ts +28 -0
- package/dist/lib/browser/asserts.d.ts.map +1 -0
- package/dist/lib/browser/asserts.js +152 -0
- package/dist/lib/browser/client.d.ts +49 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +155 -14
- package/dist/lib/browser/content-checks.d.ts +108 -0
- package/dist/lib/browser/content-checks.d.ts.map +1 -0
- package/dist/lib/browser/content-checks.js +474 -0
- package/dist/lib/browser/critique.d.ts +91 -0
- package/dist/lib/browser/critique.d.ts.map +1 -0
- package/dist/lib/browser/critique.js +167 -0
- package/dist/lib/browser/geometry.d.ts +32 -0
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +244 -1
- package/dist/lib/browser/index.d.ts +4 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/claude-desktop.d.ts.map +1 -1
- package/dist/lib/claude-desktop.js +4 -1
- package/dist/lib/council/index.d.ts +6 -6
- package/dist/lib/council/index.d.ts.map +1 -1
- package/dist/lib/council/index.js +8 -8
- package/dist/lib/exec.d.ts +7 -0
- package/dist/lib/exec.d.ts.map +1 -1
- package/dist/lib/exec.js +6 -3
- package/dist/lib/identities/assume.d.ts +2 -2
- package/dist/lib/identities/assume.js +7 -7
- package/dist/lib/instructions/apply.d.ts +3 -3
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +75 -27
- package/dist/lib/instructions/host-addendum.d.ts +54 -0
- package/dist/lib/instructions/host-addendum.d.ts.map +1 -0
- package/dist/lib/instructions/host-addendum.js +107 -0
- package/dist/lib/instructions/templates.d.ts +10 -3
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +41 -12
- package/dist/lib/machine.d.ts +2 -2
- package/dist/lib/machine.js +2 -2
- package/package.json +26 -21
- package/schemas/config.schema.json +26 -1
- package/src/commander.ts +22 -13
- package/src/commands/{harness.ts → adapter.ts} +46 -46
- package/src/commands/agents.ts +71 -64
- package/src/commands/artifacts.ts +168 -0
- package/src/commands/backup.ts +47 -33
- package/src/commands/browse.ts +438 -2
- package/src/commands/checkpoint.ts +196 -0
- package/src/commands/context.ts +3 -176
- package/src/commands/decision.ts +41 -7
- package/src/commands/deinit.ts +16 -16
- package/src/commands/doctor.ts +28 -28
- package/src/commands/{supervisor.ts → governor.ts} +184 -154
- package/src/commands/init.ts +50 -34
- package/src/commands/{scratch.ts → journal.ts} +60 -60
- package/src/commands/policy.ts +1 -1
- package/src/commands/presence.ts +2 -2
- package/src/commands/sync.ts +3 -3
- package/src/commands/tunnel.ts +237 -34
- package/src/commands/web-fetch.ts +1 -1
- package/src/commands/web.ts +56 -1
- package/src/commands/work.ts +72 -38
- package/src/commands/workflow.ts +43 -34
- package/src/core/{harnesses → adapters}/attest-projection.ts +2 -2
- package/src/core/{harnesses → adapters}/attest.ts +27 -27
- package/src/core/{harnesses → adapters}/attestation.ts +41 -41
- package/src/core/{harnesses → adapters}/bench.ts +34 -43
- package/src/core/adapters/index.ts +56 -0
- package/src/core/{harnesses → adapters}/profiles.ts +16 -16
- package/src/core/{harnesses → adapters}/registry.ts +23 -23
- package/src/core/{harnesses → adapters}/types.ts +28 -23
- package/src/core/agents/canonical-emit.ts +6 -6
- package/src/core/agents/cli-emit.ts +1 -1
- package/src/core/agents/cli.ts +30 -28
- package/src/core/agents/codex-replay.ts +6 -6
- package/src/core/agents/coord-client.ts +119 -28
- package/src/core/agents/events/consume.ts +1 -1
- package/src/core/agents/events/emit.ts +7 -6
- package/src/core/agents/render/prompt-context.ts +107 -31
- package/src/core/agents/render/session-context.ts +6 -6
- package/src/core/agents/rules/claim-conflict.ts +4 -7
- package/src/core/agents/rules/commit-conflict.ts +103 -22
- package/src/core/agents/rules/stop-hook.ts +33 -17
- package/src/core/agents/rules/verdict.ts +13 -0
- package/src/core/agents/session-events.ts +4 -4
- package/src/core/agents/state/council.ts +1 -1
- package/src/core/agents/state/heartbeat-projector.ts +16 -12
- package/src/core/agents/state/heartbeat-writer.ts +12 -12
- package/src/core/agents/state/{scratch.ts → journal.ts} +12 -12
- package/src/core/agents/state/pidmap.ts +130 -15
- package/src/core/agents/state/proc-start.ts +208 -0
- package/src/core/agents/state/shell-mutation.ts +1 -1
- package/src/core/agents/state/stale-sweep.ts +7 -7
- package/src/core/artifacts/index.ts +557 -0
- package/src/core/config.ts +30 -2
- package/src/core/context/index.ts +15 -15
- package/src/core/governor/adapter-spread.ts +82 -0
- package/src/core/governor/index.ts +91 -0
- package/src/core/governor/plan-api.ts +115 -0
- package/src/core/{supervisor → governor}/plan-read.ts +120 -96
- package/src/core/{supervisor → governor}/plan-types.ts +64 -50
- package/src/core/{supervisor → governor}/planning.ts +240 -188
- package/src/core/governor/read.ts +59 -0
- package/src/core/{supervisor → governor}/runner.ts +39 -39
- package/src/core/{supervisor → governor}/service-read.ts +22 -22
- package/src/core/{supervisor → governor}/service.ts +117 -119
- package/src/core/{supervisor → governor}/state.ts +389 -174
- package/src/core/hooks/adapter/detect.ts +30 -0
- package/src/core/hooks/{harness → adapter}/events.ts +16 -14
- package/src/core/hooks/{harness → adapter}/output.ts +31 -23
- package/src/core/hooks/{harness → adapter}/parse.ts +5 -5
- package/src/core/hooks/{harness → adapter}/wiring.ts +21 -21
- package/src/core/hooks/cli.ts +185 -162
- package/src/core/hooks/effects/image-capture.ts +6 -6
- package/src/core/hooks/effects/index.ts +17 -17
- package/src/core/hooks/events/emit.ts +3 -3
- package/src/core/hooks/events/rotate.ts +1 -1
- package/src/core/hooks/events/schema.ts +15 -7
- package/src/core/hooks/guard-path.ts +2 -2
- package/src/core/hooks/index.ts +1 -1
- package/src/core/hooks/resolve/anchor.ts +63 -8
- package/src/core/hooks/resolve/coord-root.ts +4 -4
- package/src/core/hooks/resolve/intent.ts +1 -1
- package/src/core/hooks/resolve/owner.ts +11 -5
- package/src/core/{scratch → journal}/index.ts +53 -53
- package/src/core/policy/evaluate.ts +8 -8
- package/src/core/policy/types.ts +3 -3
- package/src/core/work/runner.ts +11 -2
- package/src/core/work/state.ts +185 -21
- package/src/core/workflow/adapters.ts +33 -0
- package/src/core/workflow/approvals.ts +7 -7
- package/src/core/workflow/billing.ts +12 -12
- package/src/core/workflow/child-env.ts +13 -4
- package/src/core/workflow/engine.ts +166 -90
- package/src/core/workflow/evidence-preflight.ts +165 -0
- package/src/core/workflow/index.ts +6 -3
- package/src/core/workflow/proof.ts +94 -48
- package/src/core/workflow/run-state.ts +7 -7
- package/src/core/workflow/sandbox-projection.ts +16 -16
- package/src/core/workflow/spawn-claude.ts +34 -12
- package/src/core/workflow/spawn-codex.ts +30 -12
- package/src/core/workflow/spawn-cursor.ts +31 -12
- package/src/core/workflow/spawn-failure.ts +41 -1
- package/src/core/workflow/specialists.ts +2 -2
- package/src/core/workflow/{journal.ts → transcript.ts} +16 -16
- package/src/core/workflow/types.ts +130 -46
- package/src/core/workflow/validate.ts +1 -1
- package/src/core/workflow/workspaces/cancellation.ts +2 -2
- package/src/core/workflow/workspaces/cleanup.ts +2 -2
- package/src/core/workflow/workspaces/execution.ts +6 -6
- package/src/core/workflow/workspaces/inspect.ts +14 -11
- package/src/core/workflow/workspaces/integration.ts +18 -14
- package/src/core/workflow/workspaces/lifecycle.ts +10 -10
- package/src/core/workflow/workspaces/local-git.ts +47 -5
- package/src/core/workflow/workspaces/recovery.ts +3 -3
- package/src/core/workflow/workspaces/state.ts +4 -3
- package/src/core/workflow/workspaces/types.ts +1 -1
- package/src/lib/browser/asserts.ts +177 -0
- package/src/lib/browser/client.ts +189 -14
- package/src/lib/browser/content-checks.ts +571 -0
- package/src/lib/browser/critique.ts +231 -0
- package/src/lib/browser/geometry.ts +297 -1
- package/src/lib/browser/index.ts +34 -0
- package/src/lib/claude-desktop.ts +4 -1
- package/src/lib/council/index.ts +9 -9
- package/src/lib/exec.ts +13 -3
- package/src/lib/identities/assume.ts +7 -7
- package/src/lib/instructions/apply.ts +87 -25
- package/src/lib/instructions/host-addendum.ts +126 -0
- package/src/lib/instructions/templates.ts +44 -15
- package/src/lib/machine.ts +2 -2
- package/dist/commands/harness.d.ts +0 -12
- package/dist/commands/harness.d.ts.map +0 -1
- package/dist/commands/scratch.d.ts +0 -4
- package/dist/commands/scratch.d.ts.map +0 -1
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js +0 -162
- package/dist/commands/supervisor.d.ts +0 -4
- package/dist/commands/supervisor.d.ts.map +0 -1
- package/dist/core/harnesses/attest-projection.d.ts.map +0 -1
- package/dist/core/harnesses/attest.d.ts.map +0 -1
- package/dist/core/harnesses/attestation.d.ts.map +0 -1
- package/dist/core/harnesses/bench.d.ts.map +0 -1
- package/dist/core/harnesses/index.d.ts +0 -13
- package/dist/core/harnesses/index.d.ts.map +0 -1
- package/dist/core/harnesses/index.js +0 -6
- package/dist/core/harnesses/profiles.d.ts.map +0 -1
- package/dist/core/harnesses/registry.d.ts +0 -15
- package/dist/core/harnesses/registry.d.ts.map +0 -1
- package/dist/core/harnesses/types.d.ts.map +0 -1
- package/dist/core/hooks/harness/detect.d.ts +0 -9
- package/dist/core/hooks/harness/events.d.ts.map +0 -1
- package/dist/core/hooks/harness/output.d.ts.map +0 -1
- package/dist/core/supervisor/index.d.ts +0 -7
- package/dist/core/supervisor/index.d.ts.map +0 -1
- package/dist/core/supervisor/index.js +0 -6
- package/dist/core/supervisor/plan-api.d.ts +0 -23
- package/dist/core/supervisor/plan-api.d.ts.map +0 -1
- package/dist/core/supervisor/plan-api.js +0 -50
- package/dist/core/supervisor/plan-read.d.ts +0 -5
- package/dist/core/supervisor/plan-read.d.ts.map +0 -1
- package/dist/core/supervisor/plan-types.d.ts +0 -170
- package/dist/core/supervisor/plan-types.d.ts.map +0 -1
- package/dist/core/supervisor/planning.d.ts +0 -33
- package/dist/core/supervisor/planning.d.ts.map +0 -1
- package/dist/core/supervisor/read.d.ts +0 -6
- package/dist/core/supervisor/read.d.ts.map +0 -1
- package/dist/core/supervisor/read.js +0 -4
- package/dist/core/supervisor/runner.d.ts +0 -37
- package/dist/core/supervisor/runner.d.ts.map +0 -1
- package/dist/core/supervisor/service-read.d.ts +0 -6
- package/dist/core/supervisor/service-read.d.ts.map +0 -1
- package/dist/core/supervisor/service.d.ts +0 -114
- package/dist/core/supervisor/service.d.ts.map +0 -1
- package/dist/core/supervisor/state.d.ts +0 -95
- package/dist/core/supervisor/state.d.ts.map +0 -1
- package/dist/core/workflow/harnesses.d.ts +0 -17
- package/dist/core/workflow/harnesses.d.ts.map +0 -1
- package/dist/core/workflow/harnesses.js +0 -21
- package/dist/core/workflow/journal.d.ts.map +0 -1
- package/src/commands/session.ts +0 -187
- package/src/core/harnesses/index.ts +0 -56
- package/src/core/hooks/harness/detect.ts +0 -30
- package/src/core/supervisor/index.ts +0 -89
- package/src/core/supervisor/plan-api.ts +0 -73
- package/src/core/supervisor/read.ts +0 -59
- package/src/core/workflow/harnesses.ts +0 -33
- /package/dist/core/{harnesses → adapters}/attest-projection.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { coordEnv } from "../../../lib/env.ts";
|
|
2
|
+
import type { Adapter } from "../events/schema.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the adapter firing the hook. The dispatcher binary is always
|
|
6
|
+
* invoked with `--adapter <name>` per the wiring in each adapter's settings
|
|
7
|
+
* file (Phase 1). Returns null when the flag is missing; caller falls
|
|
8
|
+
* through to the env-based fallback or skips emission.
|
|
9
|
+
*/
|
|
10
|
+
export function detectAdapter(argv: readonly string[]): Adapter | null {
|
|
11
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12
|
+
const a = argv[i]!;
|
|
13
|
+
if (a === "--adapter") {
|
|
14
|
+
return validate(argv[i + 1]);
|
|
15
|
+
}
|
|
16
|
+
if (a.startsWith("--adapter=")) {
|
|
17
|
+
return validate(a.slice("--adapter=".length));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return validate(coordEnv("AGENT_COORD_ADAPTER"));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function validate(v: string | undefined): Adapter | null {
|
|
24
|
+
if (v === "claude-code" || v === "cursor" || v === "codex") return v;
|
|
25
|
+
// Legacy: some adapters use `claude_code` (underscore). Map
|
|
26
|
+
// it through so the env-based fallback works for callers that haven't
|
|
27
|
+
// updated yet.
|
|
28
|
+
if (v === "claude_code") return "claude-code";
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
@@ -1,47 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical hook-wiring spec per
|
|
3
|
-
* event key maps to which `agent-hook <subcommand>`, and how each
|
|
2
|
+
* Canonical hook-wiring spec per adapter: which settings file to write, which
|
|
3
|
+
* event key maps to which `agent-hook <subcommand>`, and how each adapter encodes
|
|
4
4
|
* a command hook. Single source of truth for `harn init` (and any future docs /
|
|
5
5
|
* installers) so the wired set can't drift from what agent-hook actually handles.
|
|
6
6
|
*
|
|
7
7
|
* The event lists + entry shapes mirror exactly what a fully-wired project uses
|
|
8
|
-
* for each
|
|
8
|
+
* for each adapter (Claude Code `.claude/settings.json`, Cursor `.cursor/hooks.json`,
|
|
9
9
|
* Codex `.codex/hooks.json`).
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type { Adapter as AdapterId } from "../events/schema.ts";
|
|
13
|
+
|
|
14
|
+
import type { Adapter as AdapterId } from "../events/schema.ts";
|
|
13
15
|
|
|
14
16
|
export interface HookEvent {
|
|
15
|
-
/** Key under the
|
|
17
|
+
/** Key under the adapter settings file's `hooks` map (e.g. `SessionStart`, `preToolUse`). */
|
|
16
18
|
settingsKey: string;
|
|
17
19
|
/** agent-hook subcommand to invoke for this event. */
|
|
18
20
|
subcommand: string;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
|
-
* How a
|
|
24
|
+
* How a adapter encodes a single command hook under `hooks.<settingsKey>`:
|
|
23
25
|
* - `claude`: `[{ hooks: [{ type: "command", command }] }]` (Claude Code + Codex)
|
|
24
26
|
* - `cursor`: `[{ command }]` (Cursor: flat entry, no inner `hooks` array)
|
|
25
27
|
*/
|
|
26
28
|
export type HookEntryShape = "claude" | "cursor";
|
|
27
29
|
|
|
28
|
-
export interface
|
|
30
|
+
export interface AdapterSpec {
|
|
29
31
|
/** Settings file to wire, relative to the project root. */
|
|
30
32
|
settingsFile: string;
|
|
31
|
-
/** Events this
|
|
33
|
+
/** Events this adapter fires, mapped to agent-hook subcommands. */
|
|
32
34
|
events: HookEvent[];
|
|
33
35
|
/** Per-entry encoding under the root `hooks` object. */
|
|
34
36
|
entryShape: HookEntryShape;
|
|
35
37
|
/** When set, ensure this top-level `version` key in the file (Cursor requires `1`). */
|
|
36
38
|
rootVersion?: number;
|
|
37
|
-
/**
|
|
39
|
+
/** Adapter-owned entries from older specs that `init` should remove during migration. */
|
|
38
40
|
legacyEvents?: HookEvent[];
|
|
39
|
-
/** Strict top-level settings keys accepted by this
|
|
41
|
+
/** Strict top-level settings keys accepted by this adapter, when its parser is closed. */
|
|
40
42
|
allowedTopLevelKeys?: string[];
|
|
41
|
-
/** Strict hook event keys accepted by this
|
|
43
|
+
/** Strict hook event keys accepted by this adapter, including events harnery does not wire. */
|
|
42
44
|
allowedEventKeys?: string[];
|
|
43
45
|
/**
|
|
44
|
-
* Env var the
|
|
46
|
+
* Env var the adapter exports to hook processes carrying the project root
|
|
45
47
|
* (e.g. Claude Code's CLAUDE_PROJECT_DIR). When set, `init` anchors the
|
|
46
48
|
* agent-hook path on it so the hook still spawns when the process cwd has
|
|
47
49
|
* wandered (the session shell `cd`ing into a subdirectory or off-repo).
|
|
@@ -115,8 +117,8 @@ export const CODEX_ALLOWED_EVENT_KEYS = [
|
|
|
115
117
|
"Stop",
|
|
116
118
|
];
|
|
117
119
|
|
|
118
|
-
/** Every supported
|
|
119
|
-
export const
|
|
120
|
+
/** Every supported adapter, fully wireable by `harn init`. */
|
|
121
|
+
export const ADAPTER_SPECS: Record<AdapterId, AdapterSpec> = {
|
|
120
122
|
"claude-code": {
|
|
121
123
|
settingsFile: ".claude/settings.json",
|
|
122
124
|
events: CLAUDE_CODE_EVENTS,
|
|
@@ -1,50 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Adapter-aware hook output JSON. Each adapter target has its own protocol
|
|
3
3
|
* shape, so encode it once here so post-emit handlers don't have to branch on
|
|
4
|
-
* `
|
|
4
|
+
* `adapter` everywhere.
|
|
5
5
|
*
|
|
6
|
-
* Shapes (verified against live dispatchers + each
|
|
6
|
+
* Shapes (verified against live dispatchers + each adapter's upstream hooks docs):
|
|
7
7
|
*
|
|
8
8
|
* - **Claude Code**: `{hookSpecificOutput: {hookEventName, additionalContext}}`
|
|
9
9
|
* for SessionStart / UserPromptSubmit / SubagentStart; deny uses
|
|
10
10
|
* `{hookSpecificOutput: {hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason}}`.
|
|
11
11
|
* - **Cursor**: `{additional_context, env?}` flat for sessionStart /
|
|
12
12
|
* beforeSubmitPrompt; deny uses `{permission: "deny", agent_message, user_message}`.
|
|
13
|
-
* - **Codex**: structurally identical to Claude Code
|
|
14
|
-
*
|
|
13
|
+
* - **Codex**: structurally identical to Claude Code for context and tool
|
|
14
|
+
* denials. Stop blocks are deliberately suppressed because their automatic
|
|
15
|
+
* continuation can replace a completed user-facing answer.
|
|
15
16
|
*
|
|
16
17
|
* Every helper writes to process.stdout + newline-terminates so callers can
|
|
17
18
|
* fire-and-forget. Empty text → no-op (no JSON written).
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
|
-
import type {
|
|
21
|
+
import type { Adapter } from "../events/schema.ts";
|
|
21
22
|
|
|
22
23
|
export type SystemEvent = "SessionStart" | "UserPromptSubmit" | "SubagentStart";
|
|
23
24
|
|
|
24
25
|
/** Emit a context-injection (peer table, wiring check, council pending, …). */
|
|
25
|
-
export function emitContext(
|
|
26
|
+
export function emitContext(adapter: Adapter, event: SystemEvent, text: string): void {
|
|
26
27
|
if (!text || text.length === 0) return;
|
|
27
|
-
const json = buildContextJson(
|
|
28
|
+
const json = buildContextJson(adapter, event, text);
|
|
28
29
|
process.stdout.write(`${JSON.stringify(json)}\n`);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/** Emit a PreToolUse deny: blocks the tool call with `reason` shown to the model. */
|
|
32
|
-
export function emitDeny(
|
|
33
|
+
export function emitDeny(adapter: Adapter, reason: string): void {
|
|
33
34
|
if (!reason) return;
|
|
34
|
-
const json = buildDenyJson(
|
|
35
|
+
const json = buildDenyJson(adapter, reason);
|
|
35
36
|
process.stdout.write(`${JSON.stringify(json)}\n`);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
|
-
* Emit a Stop-hook block in the firing
|
|
40
|
+
* Emit a Stop-hook block in the firing adapter's enforcement channel and return
|
|
40
41
|
* the process exit code the caller should use.
|
|
41
42
|
*
|
|
42
|
-
* The verdict (allow/block + reason) is computed
|
|
43
|
+
* The verdict (allow/block + reason) is computed adapter-agnostically in
|
|
43
44
|
* agents/rules/stop-hook.ts; this function only shapes *how the block is
|
|
44
|
-
* communicated back*, because each
|
|
45
|
+
* communicated back*, because each adapter has a different mechanism:
|
|
45
46
|
*
|
|
46
|
-
* - **Claude Code
|
|
47
|
-
*
|
|
47
|
+
* - **Claude Code** honors `exit 2` + a stderr reason as a turn block, and the
|
|
48
|
+
* adapter re-prompts the model with the stderr text.
|
|
49
|
+
* - **Codex** also supports that channel, but Harnery must not use it for
|
|
50
|
+
* coordination reminders. A Stop continuation can replace the completed
|
|
51
|
+
* answer in clients that retain only the final continuation response. Return
|
|
52
|
+
* success without output as a defense in depth behind the observe-only
|
|
53
|
+
* verdict in `agents/rules/stop-hook.ts`.
|
|
48
54
|
* - **Cursor** ignores stop-hook exit codes (non-zero = fail-open, the turn
|
|
49
55
|
* proceeds) and re-prompts ONLY via a `followup_message` field in stdout
|
|
50
56
|
* JSON, which it auto-submits as the next user message: the sanctioned
|
|
@@ -52,11 +58,13 @@ export function emitDeny(harness: Harness, reason: string): void {
|
|
|
52
58
|
* We exit 0 so Cursor treats the run as a success and honors the output.
|
|
53
59
|
* (Confirmed against cursor.com/docs/agent/hooks.)
|
|
54
60
|
*/
|
|
55
|
-
export function emitStopBlock(
|
|
61
|
+
export function emitStopBlock(adapter: Adapter, verdict: { reason?: string; rule: string }): 0 | 2 {
|
|
62
|
+
if (adapter === "codex") return 0;
|
|
63
|
+
|
|
56
64
|
const message = `${
|
|
57
65
|
verdict.reason ?? "End-of-turn coordination ritual incomplete."
|
|
58
66
|
}\n[agent-hook stop]: rule=${verdict.rule}`;
|
|
59
|
-
if (
|
|
67
|
+
if (adapter === "cursor") {
|
|
60
68
|
process.stdout.write(`${JSON.stringify({ followup_message: message })}\n`);
|
|
61
69
|
return 0;
|
|
62
70
|
}
|
|
@@ -65,16 +73,16 @@ export function emitStopBlock(harness: Harness, verdict: { reason?: string; rule
|
|
|
65
73
|
}
|
|
66
74
|
|
|
67
75
|
function buildContextJson(
|
|
68
|
-
|
|
76
|
+
adapter: Adapter,
|
|
69
77
|
event: SystemEvent,
|
|
70
78
|
text: string,
|
|
71
79
|
): Record<string, unknown> {
|
|
72
|
-
if (
|
|
80
|
+
if (adapter === "cursor") {
|
|
73
81
|
// Cursor uses a flat top-level key + an env block that survives across the
|
|
74
82
|
// session. The dispatcher historically also wrote
|
|
75
|
-
// `env: {
|
|
83
|
+
// `env: {HARNERY_AGENT_COORD_ADAPTER, HARNERY_AGENT_COORD_PLATFORM}`. These are
|
|
76
84
|
// observer hints, not load-bearing; agent-hook + agent-coord recover the
|
|
77
|
-
//
|
|
85
|
+
// adapter from event metadata. Drop them.
|
|
78
86
|
return { additional_context: text };
|
|
79
87
|
}
|
|
80
88
|
// Claude Code + Codex share the `hookSpecificOutput` envelope.
|
|
@@ -86,8 +94,8 @@ function buildContextJson(
|
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
function buildDenyJson(
|
|
90
|
-
if (
|
|
97
|
+
function buildDenyJson(adapter: Adapter, reason: string): Record<string, unknown> {
|
|
98
|
+
if (adapter === "cursor") {
|
|
91
99
|
return { permission: "deny", agent_message: reason, user_message: reason };
|
|
92
100
|
}
|
|
93
101
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Adapter payload parser. One file because all three adapters (CC, Cursor,
|
|
3
3
|
* Codex) share most of their PreToolUse / PostToolUse field names (Codex's
|
|
4
4
|
* field names match CC's directly) and Cursor's deltas are small enough to
|
|
5
5
|
* branch inline.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* events without affecting behavior": fail-soft beats fail-hard.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type {
|
|
13
|
+
import type { Adapter } from "../events/schema.ts";
|
|
14
14
|
|
|
15
15
|
export interface ParsedPayload {
|
|
16
16
|
hook_event_name?: string;
|
|
@@ -40,10 +40,10 @@ export interface ParsedPayload {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Parse the raw stdin payload string for any
|
|
43
|
+
* Parse the raw stdin payload string for any adapter. Returns null when JSON
|
|
44
44
|
* parse fails (Cursor occasionally fires hooks with no payload).
|
|
45
45
|
*/
|
|
46
|
-
export function parsePayload(raw: string,
|
|
46
|
+
export function parsePayload(raw: string, _adapter: Adapter): ParsedPayload | null {
|
|
47
47
|
if (!raw || raw.trim().length === 0) return null;
|
|
48
48
|
let json: Record<string, unknown>;
|
|
49
49
|
try {
|
|
@@ -128,7 +128,7 @@ function pickBool(o: Record<string, unknown>, k: string): boolean | undefined {
|
|
|
128
128
|
// ── Event-name normalization ────────────────────────────────────────────────
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
* Each
|
|
131
|
+
* Each adapter uses a slightly different name for the "same" lifecycle event.
|
|
132
132
|
* Map the CLI-arg event-name (kebab-case, set by us in the wiring) to one of
|
|
133
133
|
* the canonical event_types. Phase 2's CLI passes the kebab event
|
|
134
134
|
* name; this returns the canonical event_type or null when the event has no
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Read-only
|
|
2
|
+
* Read-only adapter-hook wiring inspection — the inverse of `harn init`'s
|
|
3
3
|
* writer (commands/init.ts `wireHooks`). Compares what `init` would wire
|
|
4
|
-
* (
|
|
4
|
+
* (ADAPTER_SPECS) against what's actually present in a project's adapter
|
|
5
5
|
* settings file, so `harn doctor` and the SessionStart nudge can tell an agent
|
|
6
6
|
* when a harnery upgrade changed the hook set but the project hasn't been
|
|
7
7
|
* re-wired yet.
|
|
@@ -15,9 +15,9 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
15
15
|
import { dirname, join, resolve } from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
type
|
|
20
|
-
type
|
|
18
|
+
ADAPTER_SPECS,
|
|
19
|
+
type AdapterId,
|
|
20
|
+
type AdapterSpec,
|
|
21
21
|
type HookEntryShape,
|
|
22
22
|
type HookEvent,
|
|
23
23
|
} from "./events.ts";
|
|
@@ -42,7 +42,7 @@ export interface SettingsFile {
|
|
|
42
42
|
[k: string]: unknown;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/** Build a hook entry in the
|
|
45
|
+
/** Build a hook entry in the adapter's shape. */
|
|
46
46
|
export function makeEntry(shape: HookEntryShape, command: string): HookGroup {
|
|
47
47
|
return shape === "cursor" ? { command } : { hooks: [{ type: "command", command }] };
|
|
48
48
|
}
|
|
@@ -81,17 +81,17 @@ export interface WiringDiff {
|
|
|
81
81
|
* these — they need explicit removal — so they're surfaced separately.
|
|
82
82
|
*/
|
|
83
83
|
orphans: string[];
|
|
84
|
-
/** Settings fields rejected by a
|
|
84
|
+
/** Settings fields rejected by a adapter with a strict top-level schema. */
|
|
85
85
|
invalidTopLevelKeys: string[];
|
|
86
|
-
/** Hook event names rejected by a
|
|
86
|
+
/** Hook event names rejected by a adapter with a strict event schema. */
|
|
87
87
|
invalidEventKeys: string[];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* Pure diff of one settings object against one
|
|
91
|
+
* Pure diff of one settings object against one adapter spec. Read-only inverse
|
|
92
92
|
* of `wireHooks`; no fs, so it's unit-testable.
|
|
93
93
|
*/
|
|
94
|
-
export function diffWiring(settings: SettingsFile, spec:
|
|
94
|
+
export function diffWiring(settings: SettingsFile, spec: AdapterSpec): WiringDiff {
|
|
95
95
|
const missing: HookEvent[] = [];
|
|
96
96
|
const present: HookEvent[] = [];
|
|
97
97
|
const hooks = settings.hooks ?? {};
|
|
@@ -136,8 +136,8 @@ export function diffWiring(settings: SettingsFile, spec: HarnessSpec): WiringDif
|
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export interface
|
|
140
|
-
|
|
139
|
+
export interface AdapterWiringStatus {
|
|
140
|
+
adapter: AdapterId;
|
|
141
141
|
/** Settings file path, relative to the project root. */
|
|
142
142
|
settingsFile: string;
|
|
143
143
|
missing: HookEvent[];
|
|
@@ -148,19 +148,19 @@ export interface HarnessWiringStatus {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
|
-
* Inspect every
|
|
151
|
+
* Inspect every adapter whose settings file exists under `projectRoot` and
|
|
152
152
|
* return only those with *drift*. Read-only; never writes.
|
|
153
153
|
*
|
|
154
|
-
* Drift is reported only for a
|
|
154
|
+
* Drift is reported only for a adapter the project has **already opted into** —
|
|
155
155
|
* i.e. at least one harnery hook is already wired. A settings file with zero
|
|
156
|
-
* harnery hooks just means this
|
|
156
|
+
* harnery hooks just means this adapter isn't harnery-wired here (a bare
|
|
157
157
|
* `.claude/settings.json` is a generic Claude Code file); that's `harn init`'s
|
|
158
|
-
* job to surface on first run, not drift to nag about every session. A
|
|
158
|
+
* job to surface on first run, not drift to nag about every session. A adapter
|
|
159
159
|
* with no settings file at all, or an unparseable one, is skipped.
|
|
160
160
|
*/
|
|
161
|
-
export function
|
|
162
|
-
const out:
|
|
163
|
-
for (const [id, spec] of Object.entries(
|
|
161
|
+
export function loadAdapterWiring(projectRoot: string): AdapterWiringStatus[] {
|
|
162
|
+
const out: AdapterWiringStatus[] = [];
|
|
163
|
+
for (const [id, spec] of Object.entries(ADAPTER_SPECS) as [AdapterId, AdapterSpec][]) {
|
|
164
164
|
const settingsPath = resolve(projectRoot, spec.settingsFile);
|
|
165
165
|
if (!existsSync(settingsPath)) continue;
|
|
166
166
|
let settings: SettingsFile;
|
|
@@ -168,7 +168,7 @@ export function loadHarnessWiring(projectRoot: string): HarnessWiringStatus[] {
|
|
|
168
168
|
settings = JSON.parse(readFileSync(settingsPath, "utf8")) as SettingsFile;
|
|
169
169
|
} catch (error) {
|
|
170
170
|
out.push({
|
|
171
|
-
|
|
171
|
+
adapter: id,
|
|
172
172
|
settingsFile: spec.settingsFile,
|
|
173
173
|
missing: [],
|
|
174
174
|
orphans: [],
|
|
@@ -189,7 +189,7 @@ export function loadHarnessWiring(projectRoot: string): HarnessWiringStatus[] {
|
|
|
189
189
|
continue; // current
|
|
190
190
|
}
|
|
191
191
|
out.push({
|
|
192
|
-
|
|
192
|
+
adapter: id,
|
|
193
193
|
settingsFile: spec.settingsFile,
|
|
194
194
|
missing: diff.missing,
|
|
195
195
|
orphans: diff.orphans,
|