harnery 0.30.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.map +1 -1
- package/dist/commands/work.js +38 -22
- 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 +23 -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 +66 -52
- package/dist/core/{supervisor → governor}/plan-types.d.ts +57 -56
- 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 +125 -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 +228 -108
- 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/state.d.ts +12 -4
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +50 -17
- 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 +138 -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 +1 -1
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/proof.d.ts +11 -5
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +45 -36
- 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 +9 -6
- 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 +9 -6
- 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 +9 -6
- package/dist/core/workflow/spawn-failure.d.ts +1 -1
- package/dist/core/workflow/spawn-failure.js +1 -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 +98 -51
- 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/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 +50 -35
- 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 +23 -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 +112 -97
- package/src/core/{supervisor → governor}/plan-types.ts +59 -56
- package/src/core/{supervisor → governor}/planning.ts +223 -192
- 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 +325 -167
- 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/state.ts +65 -23
- 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 +155 -90
- package/src/core/workflow/evidence-preflight.ts +165 -0
- package/src/core/workflow/index.ts +3 -3
- package/src/core/workflow/proof.ts +60 -50
- 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 +13 -10
- package/src/core/workflow/spawn-codex.ts +13 -10
- package/src/core/workflow/spawn-cursor.ts +13 -10
- package/src/core/workflow/spawn-failure.ts +1 -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 +108 -51
- 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/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.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,196 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { EmitContext, HarneryProgramContext } from "../commander.ts";
|
|
3
|
+
import { monorepoRoot, readHeartbeat, resolveOwner } from "../core/agents/index.ts";
|
|
4
|
+
import {
|
|
5
|
+
type CheckpointReason,
|
|
6
|
+
checkpointContext,
|
|
7
|
+
readContextState,
|
|
8
|
+
readLatestCapsule,
|
|
9
|
+
} from "../core/context/index.ts";
|
|
10
|
+
import type { Adapter } from "../core/hooks/events/schema.ts";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `harn checkpoint`: durable context continuity across compaction.
|
|
14
|
+
*
|
|
15
|
+
* A checkpoint captures enough of the current work that a fresh generation of
|
|
16
|
+
* the same session can resume it after the adapter compacts or restarts.
|
|
17
|
+
* `create` writes a capsule, `show` prints the latest one, `status` reports the
|
|
18
|
+
* phase, generation, and whatever context telemetry the adapter supplied.
|
|
19
|
+
*/
|
|
20
|
+
export function registerCheckpointCommand(
|
|
21
|
+
program: Command,
|
|
22
|
+
emit: EmitContext,
|
|
23
|
+
context?: HarneryProgramContext,
|
|
24
|
+
): void {
|
|
25
|
+
const command = program
|
|
26
|
+
.command("checkpoint")
|
|
27
|
+
.description(
|
|
28
|
+
"Durable context-continuity capsules: create one, show the latest, or report continuity phase.",
|
|
29
|
+
)
|
|
30
|
+
.option("--json", "Structured JSON output");
|
|
31
|
+
|
|
32
|
+
command
|
|
33
|
+
.command("status")
|
|
34
|
+
.description("Show context-continuity phase, generation, and latest telemetry")
|
|
35
|
+
.option("--session <id>", "Session id (defaults to the current agent heartbeat)")
|
|
36
|
+
.option("--instance <id>", "Agent instance id (defaults to the current owner)")
|
|
37
|
+
.option("--json", "Structured JSON output")
|
|
38
|
+
.action((opts: { session?: string; instance?: string; json?: boolean }) => {
|
|
39
|
+
try {
|
|
40
|
+
const json = opts.json || Boolean(command.opts().json);
|
|
41
|
+
const identity = resolveContinuityIdentity(context, opts);
|
|
42
|
+
const state = readContextState(identity.coordRoot, identity.sessionId);
|
|
43
|
+
if (json) {
|
|
44
|
+
emit.config({ format: "json" });
|
|
45
|
+
emit.data({ state, identity });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!state) {
|
|
49
|
+
emit.text(`No context continuity state for session ${identity.sessionId}.\n`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const sample = state.latest_context;
|
|
53
|
+
const usage = sample
|
|
54
|
+
? `${sample.used_tokens ?? "?"}/${sample.window_tokens ?? "?"} tokens${sample.used_percent === undefined ? "" : ` (${sample.used_percent}%)`}`
|
|
55
|
+
: "not reported by adapter";
|
|
56
|
+
emit.text(
|
|
57
|
+
`${[
|
|
58
|
+
`Session: ${state.session_id}`,
|
|
59
|
+
`Phase: ${state.phase}`,
|
|
60
|
+
`Generation: ${state.generation}`,
|
|
61
|
+
`Telemetry: ${usage}`,
|
|
62
|
+
`Capsule: ${state.latest_capsule ?? "none"}`,
|
|
63
|
+
state.degraded_reason ? `Degraded: ${state.degraded_reason}` : "",
|
|
64
|
+
]
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.join("\n")}\n`,
|
|
67
|
+
);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
emitCommandError(emit, "checkpoint_status_failed", err);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
command
|
|
74
|
+
.command("create")
|
|
75
|
+
.description("Create a durable context-continuity capsule for the current work")
|
|
76
|
+
.option("--session <id>", "Session id (defaults to the current agent heartbeat)")
|
|
77
|
+
.option("--instance <id>", "Agent instance id (defaults to the current owner)")
|
|
78
|
+
.option("--adapter <id>", "claude-code, codex, or cursor (inferred from heartbeat)")
|
|
79
|
+
.option("--reason <reason>", "manual, pressure, pre_compact, or session_end", "manual")
|
|
80
|
+
.option("--note <text>", "Short continuation note for the recovered agent")
|
|
81
|
+
.option("--json", "Structured JSON output")
|
|
82
|
+
.action(
|
|
83
|
+
(opts: {
|
|
84
|
+
session?: string;
|
|
85
|
+
instance?: string;
|
|
86
|
+
adapter?: string;
|
|
87
|
+
reason: string;
|
|
88
|
+
note?: string;
|
|
89
|
+
json?: boolean;
|
|
90
|
+
}) => {
|
|
91
|
+
try {
|
|
92
|
+
const json = opts.json || Boolean(command.opts().json);
|
|
93
|
+
const reason = parseCheckpointReason(opts.reason);
|
|
94
|
+
const identity = resolveContinuityIdentity(context, opts);
|
|
95
|
+
if (!identity.adapter) {
|
|
96
|
+
throw new Error("could not infer the adapter; pass --adapter claude-code|codex|cursor");
|
|
97
|
+
}
|
|
98
|
+
const result = checkpointContext(identity.coordRoot, {
|
|
99
|
+
sessionId: identity.sessionId,
|
|
100
|
+
instanceId: identity.instanceId,
|
|
101
|
+
adapter: identity.adapter,
|
|
102
|
+
cwd: context?.repoRoot ?? process.cwd(),
|
|
103
|
+
reason,
|
|
104
|
+
continuationNote: opts.note,
|
|
105
|
+
});
|
|
106
|
+
const output = {
|
|
107
|
+
capsule_id: result.capsule.capsule_id,
|
|
108
|
+
generation: result.capsule.generation,
|
|
109
|
+
path: result.state.latest_capsule,
|
|
110
|
+
phase: result.state.phase,
|
|
111
|
+
reused: result.reused,
|
|
112
|
+
};
|
|
113
|
+
if (json) {
|
|
114
|
+
emit.config({ format: "json" });
|
|
115
|
+
emit.data(output);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
emit.text(
|
|
119
|
+
`Checkpointed context generation ${output.generation}: ${output.path ?? result.path}\n`,
|
|
120
|
+
);
|
|
121
|
+
} catch (err) {
|
|
122
|
+
emitCommandError(emit, "checkpoint_create_failed", err);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
command
|
|
128
|
+
.command("show")
|
|
129
|
+
.description("Show the latest durable context-continuity capsule")
|
|
130
|
+
.option("--session <id>", "Session id (defaults to the current agent heartbeat)")
|
|
131
|
+
.option("--instance <id>", "Agent instance id (defaults to the current owner)")
|
|
132
|
+
.option("--json", "Structured JSON output")
|
|
133
|
+
.action((opts: { session?: string; instance?: string; json?: boolean }) => {
|
|
134
|
+
try {
|
|
135
|
+
const json = opts.json || Boolean(command.opts().json);
|
|
136
|
+
const identity = resolveContinuityIdentity(context, opts);
|
|
137
|
+
const capsule = readLatestCapsule(identity.coordRoot, identity.sessionId);
|
|
138
|
+
if (!capsule) {
|
|
139
|
+
throw new Error(`no context capsule exists for session ${identity.sessionId}`);
|
|
140
|
+
}
|
|
141
|
+
if (json) emit.config({ format: "json" });
|
|
142
|
+
emit.data(capsule);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
emitCommandError(emit, "checkpoint_show_failed", err);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function resolveContinuityIdentity(
|
|
150
|
+
context: HarneryProgramContext | undefined,
|
|
151
|
+
opts: { session?: string; instance?: string; adapter?: string },
|
|
152
|
+
): { coordRoot: string; instanceId: string; sessionId: string; adapter: Adapter | null } {
|
|
153
|
+
const coordRoot = context?.resolveCoordRoot?.() ?? context?.repoRoot ?? monorepoRoot();
|
|
154
|
+
if (!coordRoot) throw new Error("could not resolve a project containing .harnery/");
|
|
155
|
+
const instanceId = opts.instance ?? resolveOwner();
|
|
156
|
+
if (!instanceId) {
|
|
157
|
+
throw new Error("could not resolve the current agent; pass --instance and --session");
|
|
158
|
+
}
|
|
159
|
+
const heartbeat = readHeartbeat(instanceId);
|
|
160
|
+
const sessionId = opts.session ?? heartbeat?.session_id ?? instanceId;
|
|
161
|
+
const adapter = opts.adapter
|
|
162
|
+
? parseAdapter(opts.adapter)
|
|
163
|
+
: adapterFromPlatform(heartbeat?.platform);
|
|
164
|
+
return { coordRoot, instanceId, sessionId, adapter };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function adapterFromPlatform(platform: string | undefined): Adapter | null {
|
|
168
|
+
if (platform === "claude_code" || platform === "claude-code") return "claude-code";
|
|
169
|
+
if (platform === "cursor") return "cursor";
|
|
170
|
+
if (platform === "codex") return "codex";
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function parseAdapter(value: string): Adapter {
|
|
175
|
+
if (value === "claude-code" || value === "codex" || value === "cursor") return value;
|
|
176
|
+
throw new Error(`invalid adapter "${value}"; expected claude-code, codex, or cursor`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function parseCheckpointReason(value: string): CheckpointReason {
|
|
180
|
+
if (
|
|
181
|
+
value === "manual" ||
|
|
182
|
+
value === "pressure" ||
|
|
183
|
+
value === "pre_compact" ||
|
|
184
|
+
value === "session_end"
|
|
185
|
+
) {
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
throw new Error(
|
|
189
|
+
`invalid reason "${value}"; expected manual, pressure, pre_compact, or session_end`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function emitCommandError(emit: EmitContext, code: string, err: unknown): void {
|
|
194
|
+
emit.error({ code, message: err instanceof Error ? err.message : String(err) });
|
|
195
|
+
emit.setExitCode(1);
|
|
196
|
+
}
|
package/src/commands/context.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { EmitContext, HarneryProgramContext } from "../commander.ts";
|
|
3
|
-
import { monorepoRoot, readHeartbeat, resolveOwner } from "../core/agents/index.ts";
|
|
4
|
-
import {
|
|
5
|
-
type CheckpointReason,
|
|
6
|
-
checkpointContext,
|
|
7
|
-
readContextState,
|
|
8
|
-
readLatestCapsule,
|
|
9
|
-
} from "../core/context/index.ts";
|
|
10
|
-
import type { Harness } from "../core/hooks/events/schema.ts";
|
|
11
3
|
import {
|
|
12
4
|
buildContext,
|
|
13
5
|
type ContextReport,
|
|
@@ -17,18 +9,18 @@ import {
|
|
|
17
9
|
} from "../lib/context/index.ts";
|
|
18
10
|
|
|
19
11
|
/**
|
|
20
|
-
* `harn context`: one-shot orientation snapshot.
|
|
12
|
+
* `harn agents context`: one-shot orientation snapshot.
|
|
21
13
|
*
|
|
22
14
|
* Aggregates self / time / repo / commits / submodules / peers (default) plus
|
|
23
15
|
* opt-in services. Useful at session start, post-compaction, or before
|
|
24
16
|
* dispatching subagents. Fail-open per section.
|
|
25
17
|
*/
|
|
26
18
|
export function registerContextCommand(
|
|
27
|
-
|
|
19
|
+
parent: Command,
|
|
28
20
|
emit: EmitContext,
|
|
29
21
|
context?: HarneryProgramContext,
|
|
30
22
|
): void {
|
|
31
|
-
|
|
23
|
+
parent
|
|
32
24
|
.command("context")
|
|
33
25
|
.description(
|
|
34
26
|
`One-shot orientation snapshot: self, repo, submodules, peers, recent commits. Default sections: ${DEFAULT_SECTIONS.join(" / ")}. Opt-in: ${OPT_IN_SECTIONS.join(" / ")}.`,
|
|
@@ -76,171 +68,6 @@ export function registerContextCommand(
|
|
|
76
68
|
}
|
|
77
69
|
},
|
|
78
70
|
);
|
|
79
|
-
|
|
80
|
-
command
|
|
81
|
-
.command("status")
|
|
82
|
-
.description("Show context-continuity phase, generation, and latest telemetry")
|
|
83
|
-
.option("--session <id>", "Session id (defaults to the current agent heartbeat)")
|
|
84
|
-
.option("--instance <id>", "Agent instance id (defaults to the current owner)")
|
|
85
|
-
.option("--json", "Structured JSON output")
|
|
86
|
-
.action((opts: { session?: string; instance?: string; json?: boolean }) => {
|
|
87
|
-
try {
|
|
88
|
-
const json = opts.json || Boolean(command.opts().json);
|
|
89
|
-
const identity = resolveContinuityIdentity(context, opts);
|
|
90
|
-
const state = readContextState(identity.coordRoot, identity.sessionId);
|
|
91
|
-
if (json) {
|
|
92
|
-
emit.config({ format: "json" });
|
|
93
|
-
emit.data({ state, identity });
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (!state) {
|
|
97
|
-
emit.text(`No context continuity state for session ${identity.sessionId}.\n`);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const sample = state.latest_context;
|
|
101
|
-
const usage = sample
|
|
102
|
-
? `${sample.used_tokens ?? "?"}/${sample.window_tokens ?? "?"} tokens${sample.used_percent === undefined ? "" : ` (${sample.used_percent}%)`}`
|
|
103
|
-
: "not reported by harness";
|
|
104
|
-
emit.text(
|
|
105
|
-
`${[
|
|
106
|
-
`Session: ${state.session_id}`,
|
|
107
|
-
`Phase: ${state.phase}`,
|
|
108
|
-
`Generation: ${state.generation}`,
|
|
109
|
-
`Telemetry: ${usage}`,
|
|
110
|
-
`Capsule: ${state.latest_capsule ?? "none"}`,
|
|
111
|
-
state.degraded_reason ? `Degraded: ${state.degraded_reason}` : "",
|
|
112
|
-
]
|
|
113
|
-
.filter(Boolean)
|
|
114
|
-
.join("\n")}\n`,
|
|
115
|
-
);
|
|
116
|
-
} catch (err) {
|
|
117
|
-
emitCommandError(emit, "context_status_failed", err);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
command
|
|
122
|
-
.command("checkpoint")
|
|
123
|
-
.description("Create a durable context-continuity capsule for the current work")
|
|
124
|
-
.option("--session <id>", "Session id (defaults to the current agent heartbeat)")
|
|
125
|
-
.option("--instance <id>", "Agent instance id (defaults to the current owner)")
|
|
126
|
-
.option("--harness <id>", "claude-code, codex, or cursor (inferred from heartbeat)")
|
|
127
|
-
.option("--reason <reason>", "manual, pressure, pre_compact, or session_end", "manual")
|
|
128
|
-
.option("--note <text>", "Short continuation note for the recovered agent")
|
|
129
|
-
.option("--json", "Structured JSON output")
|
|
130
|
-
.action(
|
|
131
|
-
(opts: {
|
|
132
|
-
session?: string;
|
|
133
|
-
instance?: string;
|
|
134
|
-
harness?: string;
|
|
135
|
-
reason: string;
|
|
136
|
-
note?: string;
|
|
137
|
-
json?: boolean;
|
|
138
|
-
}) => {
|
|
139
|
-
try {
|
|
140
|
-
const json = opts.json || Boolean(command.opts().json);
|
|
141
|
-
const reason = parseCheckpointReason(opts.reason);
|
|
142
|
-
const identity = resolveContinuityIdentity(context, opts);
|
|
143
|
-
if (!identity.harness) {
|
|
144
|
-
throw new Error("could not infer the harness; pass --harness claude-code|codex|cursor");
|
|
145
|
-
}
|
|
146
|
-
const result = checkpointContext(identity.coordRoot, {
|
|
147
|
-
sessionId: identity.sessionId,
|
|
148
|
-
instanceId: identity.instanceId,
|
|
149
|
-
harness: identity.harness,
|
|
150
|
-
cwd: context?.repoRoot ?? process.cwd(),
|
|
151
|
-
reason,
|
|
152
|
-
continuationNote: opts.note,
|
|
153
|
-
});
|
|
154
|
-
const output = {
|
|
155
|
-
capsule_id: result.capsule.capsule_id,
|
|
156
|
-
generation: result.capsule.generation,
|
|
157
|
-
path: result.state.latest_capsule,
|
|
158
|
-
phase: result.state.phase,
|
|
159
|
-
reused: result.reused,
|
|
160
|
-
};
|
|
161
|
-
if (json) {
|
|
162
|
-
emit.config({ format: "json" });
|
|
163
|
-
emit.data(output);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
emit.text(
|
|
167
|
-
`Checkpointed context generation ${output.generation}: ${output.path ?? result.path}\n`,
|
|
168
|
-
);
|
|
169
|
-
} catch (err) {
|
|
170
|
-
emitCommandError(emit, "context_checkpoint_failed", err);
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
command
|
|
176
|
-
.command("show")
|
|
177
|
-
.description("Show the latest durable context-continuity capsule")
|
|
178
|
-
.option("--session <id>", "Session id (defaults to the current agent heartbeat)")
|
|
179
|
-
.option("--instance <id>", "Agent instance id (defaults to the current owner)")
|
|
180
|
-
.option("--json", "Structured JSON output")
|
|
181
|
-
.action((opts: { session?: string; instance?: string; json?: boolean }) => {
|
|
182
|
-
try {
|
|
183
|
-
const json = opts.json || Boolean(command.opts().json);
|
|
184
|
-
const identity = resolveContinuityIdentity(context, opts);
|
|
185
|
-
const capsule = readLatestCapsule(identity.coordRoot, identity.sessionId);
|
|
186
|
-
if (!capsule) {
|
|
187
|
-
throw new Error(`no context capsule exists for session ${identity.sessionId}`);
|
|
188
|
-
}
|
|
189
|
-
if (json) emit.config({ format: "json" });
|
|
190
|
-
emit.data(capsule);
|
|
191
|
-
} catch (err) {
|
|
192
|
-
emitCommandError(emit, "context_show_failed", err);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function resolveContinuityIdentity(
|
|
198
|
-
context: HarneryProgramContext | undefined,
|
|
199
|
-
opts: { session?: string; instance?: string; harness?: string },
|
|
200
|
-
): { coordRoot: string; instanceId: string; sessionId: string; harness: Harness | null } {
|
|
201
|
-
const coordRoot = context?.resolveCoordRoot?.() ?? context?.repoRoot ?? monorepoRoot();
|
|
202
|
-
if (!coordRoot) throw new Error("could not resolve a project containing .harnery/");
|
|
203
|
-
const instanceId = opts.instance ?? resolveOwner();
|
|
204
|
-
if (!instanceId) {
|
|
205
|
-
throw new Error("could not resolve the current agent; pass --instance and --session");
|
|
206
|
-
}
|
|
207
|
-
const heartbeat = readHeartbeat(instanceId);
|
|
208
|
-
const sessionId = opts.session ?? heartbeat?.session_id ?? instanceId;
|
|
209
|
-
const harness = opts.harness
|
|
210
|
-
? parseHarness(opts.harness)
|
|
211
|
-
: harnessFromPlatform(heartbeat?.platform);
|
|
212
|
-
return { coordRoot, instanceId, sessionId, harness };
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function harnessFromPlatform(platform: string | undefined): Harness | null {
|
|
216
|
-
if (platform === "claude_code" || platform === "claude-code") return "claude-code";
|
|
217
|
-
if (platform === "cursor") return "cursor";
|
|
218
|
-
if (platform === "codex") return "codex";
|
|
219
|
-
return null;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function parseHarness(value: string): Harness {
|
|
223
|
-
if (value === "claude-code" || value === "codex" || value === "cursor") return value;
|
|
224
|
-
throw new Error(`invalid harness "${value}"; expected claude-code, codex, or cursor`);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function parseCheckpointReason(value: string): CheckpointReason {
|
|
228
|
-
if (
|
|
229
|
-
value === "manual" ||
|
|
230
|
-
value === "pressure" ||
|
|
231
|
-
value === "pre_compact" ||
|
|
232
|
-
value === "session_end"
|
|
233
|
-
) {
|
|
234
|
-
return value;
|
|
235
|
-
}
|
|
236
|
-
throw new Error(
|
|
237
|
-
`invalid reason "${value}"; expected manual, pressure, pre_compact, or session_end`,
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function emitCommandError(emit: EmitContext, code: string, err: unknown): void {
|
|
242
|
-
emit.error({ code, message: err instanceof Error ? err.message : String(err) });
|
|
243
|
-
emit.setExitCode(1);
|
|
244
71
|
}
|
|
245
72
|
|
|
246
73
|
function collectSections(value: string, prev: SectionName[]): SectionName[] {
|
package/src/commands/decision.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { EmitContext } from "../commander.ts";
|
|
|
4
4
|
import {
|
|
5
5
|
emitCanonical,
|
|
6
6
|
monorepoRoot,
|
|
7
|
-
|
|
7
|
+
normalizeAdapter,
|
|
8
8
|
readHeartbeat,
|
|
9
9
|
resolveOwner,
|
|
10
10
|
} from "../core/agents/index.ts";
|
|
@@ -108,23 +108,45 @@ export function registerDecisionCommand(program: Command, emitParam: EmitContext
|
|
|
108
108
|
.option("--stakes <small|medium|high>", "Filter by stakes")
|
|
109
109
|
.option("--open", "Only non-terminal decisions (the live queue)")
|
|
110
110
|
.option("--archived", "Include archived (graduated/terminal) decisions")
|
|
111
|
+
.option(
|
|
112
|
+
"--waiting",
|
|
113
|
+
"Only what a human still has to rule on: tier 2, unresolved. Oldest-first within stakes.",
|
|
114
|
+
)
|
|
111
115
|
.action((opts: ListOpts) => {
|
|
112
116
|
const coordRoot = coordRootOrExit();
|
|
113
117
|
const status = opts.status ? parseStatus(opts.status) : undefined;
|
|
114
118
|
const tier = opts.tier !== undefined ? parseTier(opts.tier) : undefined;
|
|
115
119
|
const stakes = opts.stakes ? parseStakes(opts.stakes) : undefined;
|
|
116
|
-
|
|
120
|
+
if (opts.waiting && tier !== undefined && tier !== 2) {
|
|
121
|
+
return fail(
|
|
122
|
+
"bad_request",
|
|
123
|
+
"--waiting is tier 2 by definition; drop --tier or pass --tier 2",
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
let rows = listDecisions(coordRoot, {
|
|
117
127
|
status,
|
|
118
|
-
tier,
|
|
128
|
+
tier: opts.waiting ? 2 : tier,
|
|
119
129
|
stakes,
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
// --waiting implies the live queue: an archived or resolved decision is
|
|
131
|
+
// not waiting on anyone.
|
|
132
|
+
openOnly: opts.open || opts.waiting,
|
|
133
|
+
includeArchived: opts.waiting ? false : opts.archived,
|
|
122
134
|
}).map(summarize);
|
|
135
|
+
if (opts.waiting) {
|
|
136
|
+
rows = rows.filter((r) => !r.resolved).sort(byStakesThenAge);
|
|
137
|
+
}
|
|
123
138
|
emit.data({
|
|
124
139
|
rows,
|
|
125
140
|
meta: {
|
|
126
141
|
total: rows.length,
|
|
127
|
-
filter: {
|
|
142
|
+
filter: {
|
|
143
|
+
status,
|
|
144
|
+
tier: opts.waiting ? 2 : tier,
|
|
145
|
+
stakes,
|
|
146
|
+
open: !!(opts.open || opts.waiting),
|
|
147
|
+
archived: opts.waiting ? false : !!opts.archived,
|
|
148
|
+
waiting: !!opts.waiting,
|
|
149
|
+
},
|
|
128
150
|
},
|
|
129
151
|
});
|
|
130
152
|
});
|
|
@@ -351,6 +373,7 @@ interface ListOpts {
|
|
|
351
373
|
stakes?: string;
|
|
352
374
|
open?: boolean;
|
|
353
375
|
archived?: boolean;
|
|
376
|
+
waiting?: boolean;
|
|
354
377
|
}
|
|
355
378
|
interface ResolveOpts {
|
|
356
379
|
recommendation: string;
|
|
@@ -403,6 +426,17 @@ function collect(value: string, previous: string[]): string[] {
|
|
|
403
426
|
}
|
|
404
427
|
|
|
405
428
|
/** Compact row for list/search output — the full manifest is available via `show`. */
|
|
429
|
+
const WAITING_STAKES_RANK: Record<string, number> = { high: 3, medium: 2, small: 1 };
|
|
430
|
+
|
|
431
|
+
/** Highest stakes first, longest-open breaking ties. Stakes leads because it is
|
|
432
|
+
* the filer's own triage signal; age breaks ties so a question nobody has
|
|
433
|
+
* answered in three weeks does not sit behind an equally-weighted fresh one. */
|
|
434
|
+
function byStakesThenAge(a: Record<string, unknown>, b: Record<string, unknown>): number {
|
|
435
|
+
const rank =
|
|
436
|
+
(WAITING_STAKES_RANK[String(b.stakes)] ?? 1) - (WAITING_STAKES_RANK[String(a.stakes)] ?? 1);
|
|
437
|
+
return rank !== 0 ? rank : String(a.filed_at ?? "").localeCompare(String(b.filed_at ?? ""));
|
|
438
|
+
}
|
|
439
|
+
|
|
406
440
|
function summarize(m: DecisionManifest): Record<string, unknown> {
|
|
407
441
|
return {
|
|
408
442
|
decision_id: m.decision_id,
|
|
@@ -432,7 +466,7 @@ function emitDecisionEvent(type: string, data: Record<string, unknown>): void {
|
|
|
432
466
|
type,
|
|
433
467
|
owner,
|
|
434
468
|
session: hb?.session_id ?? owner,
|
|
435
|
-
|
|
469
|
+
adapter: normalizeAdapter(hb?.platform),
|
|
436
470
|
data,
|
|
437
471
|
});
|
|
438
472
|
}
|
package/src/commands/deinit.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* `harn deinit`: reverse what `harn init` wired into a project.
|
|
3
3
|
*
|
|
4
4
|
* `init` makes two kinds of change outside the harnery package:
|
|
5
|
-
* 1. Merges `agent-hook` entries into the
|
|
5
|
+
* 1. Merges `agent-hook` entries into the adapter settings file
|
|
6
6
|
* (Claude Code `.claude/settings.json`, Cursor `.cursor/hooks.json`, or
|
|
7
7
|
* Codex `.codex/hooks.json`).
|
|
8
8
|
* 2. Creates the `.harnery/` coord root (runtime state: events, councils,
|
|
9
|
-
* identities,
|
|
9
|
+
* identities, journal) and stamps the host bin name into
|
|
10
10
|
* `.harnery/config.jsonc`.
|
|
11
11
|
*
|
|
12
12
|
* `deinit` undoes (1) by default: it removes only harnery's hook entries from
|
|
@@ -33,12 +33,12 @@ import { createInterface } from "node:readline";
|
|
|
33
33
|
import type { Command } from "commander";
|
|
34
34
|
import type { EmitContext } from "../commander.ts";
|
|
35
35
|
import { DEFAULT_BIN_NAME } from "../core/config.ts";
|
|
36
|
-
import {
|
|
36
|
+
import { ADAPTER_SPECS, type AdapterId } from "../core/hooks/adapter/events.ts";
|
|
37
37
|
import { removeInstructions } from "../lib/instructions/apply.ts";
|
|
38
38
|
import { type SettingsFile, unwireHooks } from "./init.ts";
|
|
39
39
|
|
|
40
40
|
interface DeinitOpts {
|
|
41
|
-
|
|
41
|
+
adapter: string;
|
|
42
42
|
dryRun?: boolean;
|
|
43
43
|
projectRoot?: string;
|
|
44
44
|
purgeState?: boolean;
|
|
@@ -54,20 +54,20 @@ export function registerDeinitCommand(program: Command, emit: EmitContext, binNa
|
|
|
54
54
|
program
|
|
55
55
|
.command("deinit")
|
|
56
56
|
.description(
|
|
57
|
-
"Reverse `harn init`: remove harnery's hook entries from the
|
|
57
|
+
"Reverse `harn init`: remove harnery's hook entries from the adapter " +
|
|
58
58
|
"settings file (keeps any others). Pass --purge-state to also delete the " +
|
|
59
59
|
".harnery/ coord root (on a terminal it asks first). Idempotent; use " +
|
|
60
60
|
"--dry-run to preview.",
|
|
61
61
|
)
|
|
62
|
-
.option("--
|
|
62
|
+
.option("--adapter <id>", "claude-code | cursor | codex", "claude-code")
|
|
63
63
|
.option("--dry-run", "Show what would change without writing")
|
|
64
64
|
.option("--project-root <path>", "Project root (default: git toplevel, else cwd)")
|
|
65
65
|
.option("--purge-state", "Also delete the .harnery/ coord root (runtime state, destructive)")
|
|
66
66
|
.action(async (opts: DeinitOpts) => {
|
|
67
|
-
const
|
|
68
|
-
const spec =
|
|
67
|
+
const adapter = opts.adapter as AdapterId;
|
|
68
|
+
const spec = ADAPTER_SPECS[adapter];
|
|
69
69
|
if (!spec) {
|
|
70
|
-
emit.text(`Unknown
|
|
70
|
+
emit.text(`Unknown adapter '${opts.adapter}'. Expected: claude-code | cursor | codex.`);
|
|
71
71
|
emit.setExitCode(1);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
@@ -92,7 +92,7 @@ export function registerDeinitCommand(program: Command, emit: EmitContext, binNa
|
|
|
92
92
|
purgeState = await confirmDeleteState(coordDir);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
// ── 1. unwire
|
|
95
|
+
// ── 1. unwire adapter hooks ────────────────────────────────────────────
|
|
96
96
|
const settingsPath = resolve(projectRoot, spec.settingsFile);
|
|
97
97
|
if (!existsSync(settingsPath)) {
|
|
98
98
|
actions.push(`· ${rel(projectRoot, settingsPath)} doesn't exist; no hooks to remove`);
|
|
@@ -111,7 +111,7 @@ export function registerDeinitCommand(program: Command, emit: EmitContext, binNa
|
|
|
111
111
|
const { removed, remaining } = unwireHooks(settings);
|
|
112
112
|
if (removed === 0) {
|
|
113
113
|
actions.push(`· no harnery hooks found in ${rel(projectRoot, settingsPath)}`);
|
|
114
|
-
} else if (
|
|
114
|
+
} else if (adapterOnly(settings)) {
|
|
115
115
|
// Nothing left but what init itself put there (no hooks, at most a
|
|
116
116
|
// version key), so remove the file rather than leave an empty shell.
|
|
117
117
|
if (dryRun) {
|
|
@@ -135,7 +135,7 @@ export function registerDeinitCommand(program: Command, emit: EmitContext, binNa
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// ── 1b. agent-facing instructions block + skills ───────────────────────
|
|
138
|
-
const removed = removeInstructions(projectRoot, {
|
|
138
|
+
const removed = removeInstructions(projectRoot, { adapter, dryRun });
|
|
139
139
|
actions.push(...removed.actions, ...removed.warnings.map((w) => `! ${w}`));
|
|
140
140
|
|
|
141
141
|
// ── 2. coord root (opt-in; destructive) ────────────────────────────────
|
|
@@ -143,7 +143,7 @@ export function registerDeinitCommand(program: Command, emit: EmitContext, binNa
|
|
|
143
143
|
if (!coordExists) {
|
|
144
144
|
actions.push("· .harnery/ doesn't exist; nothing to purge");
|
|
145
145
|
} else if (dryRun) {
|
|
146
|
-
actions.push("+ would delete .harnery/ and all coord state (events, councils,
|
|
146
|
+
actions.push("+ would delete .harnery/ and all coord state (events, councils, journal)");
|
|
147
147
|
} else {
|
|
148
148
|
rmSync(coordDir, { recursive: true, force: true });
|
|
149
149
|
actions.push("+ deleted .harnery/ and all coord state");
|
|
@@ -191,7 +191,7 @@ export function engineRemovalHint(): string {
|
|
|
191
191
|
function confirmDeleteState(coordDir: string): Promise<boolean> {
|
|
192
192
|
process.stdout.write(
|
|
193
193
|
"\nharnery saved this project's coordination history in .harnery/\n" +
|
|
194
|
-
"(its event log, councils, agent identities, and
|
|
194
|
+
"(its event log, councils, agent identities, and journals):\n" +
|
|
195
195
|
` ${coordDir}\n` +
|
|
196
196
|
"Unwiring leaves that in place. Deleting it can't be undone.\n",
|
|
197
197
|
);
|
|
@@ -210,7 +210,7 @@ function confirm(question: string): Promise<boolean> {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
/** True when an unwired settings object holds nothing but (optionally) `version`. */
|
|
213
|
-
function
|
|
213
|
+
function adapterOnly(settings: SettingsFile): boolean {
|
|
214
214
|
const keys = Object.keys(settings);
|
|
215
215
|
return keys.length === 0 || (keys.length === 1 && keys[0] === "version");
|
|
216
216
|
}
|
|
@@ -224,7 +224,7 @@ function render(
|
|
|
224
224
|
const head = dryRun ? "harn deinit (dry run): no changes written" : "harn deinit";
|
|
225
225
|
const tail = dryRun
|
|
226
226
|
? "\nRe-run without --dry-run to apply."
|
|
227
|
-
: "\nDone. harnery hooks are unwired; restart your
|
|
227
|
+
: "\nDone. harnery hooks are unwired; restart your adapter session to drop them.";
|
|
228
228
|
const hintBlock = hint ? `\n\n${hint}` : "";
|
|
229
229
|
return `${head}\n root: ${projectRoot}\n${actions.map((a) => ` ${a}`).join("\n")}${tail}${hintBlock}`;
|
|
230
230
|
}
|