harnery 0.32.0 → 0.34.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 +2 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +7 -1
- package/dist/commands/adapter.js +2 -2
- package/dist/commands/agents.d.ts +144 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +1408 -565
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +7 -6
- package/dist/commands/backup.d.ts +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +29 -16
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +234 -12
- package/dist/commands/checkpoint.d.ts.map +1 -1
- package/dist/commands/checkpoint.js +3 -2
- package/dist/commands/claude-desktop.d.ts +2 -2
- package/dist/commands/claude-desktop.d.ts.map +1 -1
- package/dist/commands/claude-desktop.js +2 -2
- package/dist/commands/context.js +1 -6
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +22 -38
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +91 -28
- package/dist/commands/doctor.d.ts +4 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +55 -7
- package/dist/commands/events.d.ts +5 -0
- package/dist/commands/events.d.ts.map +1 -0
- package/dist/commands/events.js +189 -0
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +13 -4
- package/dist/commands/init.d.ts +10 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +233 -51
- package/dist/commands/instructions.d.ts +4 -0
- package/dist/commands/instructions.d.ts.map +1 -0
- package/dist/commands/instructions.js +100 -0
- package/dist/commands/journal.d.ts.map +1 -1
- package/dist/commands/journal.js +4 -13
- package/dist/commands/ledger-v3.d.ts +5 -0
- package/dist/commands/ledger-v3.d.ts.map +1 -0
- package/dist/commands/ledger-v3.js +91 -0
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +15 -6
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +1 -1
- package/dist/commands/web.d.ts +6 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +67 -7
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +22 -5
- package/dist/core/adapter.d.ts +5 -0
- package/dist/core/adapter.d.ts.map +1 -0
- package/dist/core/adapter.js +1 -0
- package/dist/core/adapters/attest.d.ts +5 -2
- package/dist/core/adapters/attest.d.ts.map +1 -1
- package/dist/core/adapters/attest.js +8 -3
- package/dist/core/adapters/profiles.d.ts +6 -6
- package/dist/core/adapters/profiles.d.ts.map +1 -1
- package/dist/core/adapters/profiles.js +4 -4
- package/dist/core/agents/canonical-emit.d.ts +17 -15
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +27 -25
- package/dist/core/agents/cli.js +212 -235
- package/dist/core/agents/codex-archive-v3.d.ts +14 -0
- package/dist/core/agents/codex-archive-v3.d.ts.map +1 -0
- package/dist/core/agents/codex-archive-v3.js +110 -0
- package/dist/core/agents/coord-client.d.ts +19 -70
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +65 -155
- package/dist/core/agents/finalization.d.ts +4 -1
- package/dist/core/agents/finalization.d.ts.map +1 -1
- package/dist/core/agents/finalization.js +89 -32
- package/dist/core/agents/index.d.ts +5 -5
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +5 -5
- package/dist/core/agents/live-authority-v3.d.ts +59 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -0
- package/dist/core/agents/live-authority-v3.js +233 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts +20 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -0
- package/dist/core/agents/live-lifecycle-v3.js +91 -0
- package/dist/core/agents/live-observation-v3.d.ts +25 -0
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -0
- package/dist/core/agents/live-observation-v3.js +157 -0
- package/dist/core/agents/render/prompt-context.d.ts +10 -4
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +61 -55
- package/dist/core/agents/render/session-context.d.ts +1 -1
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +15 -33
- package/dist/core/agents/rules/claim-conflict.d.ts +3 -3
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +79 -127
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +3 -18
- package/dist/core/agents/rules/stop-hook.d.ts +9 -50
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +193 -236
- package/dist/core/agents/session-events.d.ts +5 -7
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +127 -95
- package/dist/core/agents/session-finalization-state-v3.d.ts +30 -0
- package/dist/core/agents/session-finalization-state-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalization-state-v3.js +40 -0
- package/dist/core/agents/session-finalizer-v3.d.ts +107 -0
- package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalizer-v3.js +734 -0
- package/dist/core/agents/session-name-display.d.ts +40 -0
- package/dist/core/agents/session-name-display.d.ts.map +1 -0
- package/dist/core/agents/session-name-display.js +119 -0
- package/dist/core/agents/state/activity-log.d.ts +3 -3
- package/dist/core/agents/state/activity-log.d.ts.map +1 -1
- package/dist/core/agents/state/activity-log.js +7 -16
- package/dist/core/agents/state/heartbeat-writer.d.ts +29 -46
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +59 -199
- package/dist/core/agents/state/live-coordination-view.d.ts +31 -0
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -0
- package/dist/core/agents/state/live-coordination-view.js +209 -0
- package/dist/core/agents/state/session-state.d.ts +45 -0
- package/dist/core/agents/state/session-state.d.ts.map +1 -0
- package/dist/core/agents/state/session-state.js +90 -0
- package/dist/core/agents/state/stale-sweep.d.ts +1 -1
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +26 -15
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +5 -7
- package/dist/core/config.d.ts +33 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +98 -2
- package/dist/core/context/index.d.ts +1 -4
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +9 -9
- package/dist/core/events/span-parent.d.ts +15 -0
- package/dist/core/events/span-parent.d.ts.map +1 -0
- package/dist/core/events/span-parent.js +34 -0
- package/dist/core/events/v3/advance.d.ts +14 -0
- package/dist/core/events/v3/advance.d.ts.map +1 -0
- package/dist/core/events/v3/advance.js +134 -0
- package/dist/core/events/v3/authority-outbox.d.ts +78 -0
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -0
- package/dist/core/events/v3/authority-outbox.js +399 -0
- package/dist/core/events/v3/base-builder.d.ts +20 -0
- package/dist/core/events/v3/base-builder.d.ts.map +1 -0
- package/dist/core/events/v3/base-builder.js +29 -0
- package/dist/core/events/v3/base-contract.d.ts +7576 -0
- package/dist/core/events/v3/base-contract.d.ts.map +1 -0
- package/dist/core/events/v3/base-contract.js +647 -0
- package/dist/core/events/v3/bootstrap.d.ts +34 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -0
- package/dist/core/events/v3/bootstrap.js +175 -0
- package/dist/core/events/v3/builder.d.ts +20 -0
- package/dist/core/events/v3/builder.d.ts.map +1 -0
- package/dist/core/events/v3/builder.js +28 -0
- package/dist/core/events/v3/canonical.d.ts +31 -0
- package/dist/core/events/v3/canonical.d.ts.map +1 -0
- package/dist/core/events/v3/canonical.js +100 -0
- package/dist/core/events/v3/capabilities.d.ts +31 -0
- package/dist/core/events/v3/capabilities.d.ts.map +1 -0
- package/dist/core/events/v3/capabilities.js +107 -0
- package/dist/core/events/v3/capability-drift.d.ts +22 -0
- package/dist/core/events/v3/capability-drift.d.ts.map +1 -0
- package/dist/core/events/v3/capability-drift.js +134 -0
- package/dist/core/events/v3/catalog.d.ts +38 -0
- package/dist/core/events/v3/catalog.d.ts.map +1 -0
- package/dist/core/events/v3/catalog.js +135 -0
- package/dist/core/events/v3/clock-order.d.ts +34 -0
- package/dist/core/events/v3/clock-order.d.ts.map +1 -0
- package/dist/core/events/v3/clock-order.js +35 -0
- package/dist/core/events/v3/contract.d.ts +171 -0
- package/dist/core/events/v3/contract.d.ts.map +1 -0
- package/dist/core/events/v3/contract.js +180 -0
- package/dist/core/events/v3/control.d.ts +111 -0
- package/dist/core/events/v3/control.d.ts.map +1 -0
- package/dist/core/events/v3/control.js +419 -0
- package/dist/core/events/v3/coordination-view.d.ts +69 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -0
- package/dist/core/events/v3/coordination-view.js +119 -0
- package/dist/core/events/v3/economics.d.ts +77 -0
- package/dist/core/events/v3/economics.d.ts.map +1 -0
- package/dist/core/events/v3/economics.js +274 -0
- package/dist/core/events/v3/finalization-view.d.ts +26 -0
- package/dist/core/events/v3/finalization-view.d.ts.map +1 -0
- package/dist/core/events/v3/finalization-view.js +37 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts +25 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts.map +1 -0
- package/dist/core/events/v3/fingerprint-keys.js +217 -0
- package/dist/core/events/v3/generated.d.ts +4 -0
- package/dist/core/events/v3/generated.d.ts.map +1 -0
- package/dist/core/events/v3/generated.js +47 -0
- package/dist/core/events/v3/ids.d.ts +9 -0
- package/dist/core/events/v3/ids.d.ts.map +1 -0
- package/dist/core/events/v3/ids.js +25 -0
- package/dist/core/events/v3/index.d.ts +35 -0
- package/dist/core/events/v3/index.d.ts.map +1 -0
- package/dist/core/events/v3/index.js +33 -0
- package/dist/core/events/v3/latency.d.ts +63 -0
- package/dist/core/events/v3/latency.d.ts.map +1 -0
- package/dist/core/events/v3/latency.js +412 -0
- package/dist/core/events/v3/live-feed.d.ts +45 -0
- package/dist/core/events/v3/live-feed.d.ts.map +1 -0
- package/dist/core/events/v3/live-feed.js +246 -0
- package/dist/core/events/v3/live-observation.d.ts +35 -0
- package/dist/core/events/v3/live-observation.d.ts.map +1 -0
- package/dist/core/events/v3/live-observation.js +1 -0
- package/dist/core/events/v3/live-routing.d.ts +57 -0
- package/dist/core/events/v3/live-routing.d.ts.map +1 -0
- package/dist/core/events/v3/live-routing.js +107 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts +67 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command-recorder.js +477 -0
- package/dist/core/events/v3/producers/command.d.ts +50 -0
- package/dist/core/events/v3/producers/command.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command.js +135 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +53 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination-recorder.js +376 -0
- package/dist/core/events/v3/producers/coordination.d.ts +90 -0
- package/dist/core/events/v3/producers/coordination.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination.js +229 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +54 -0
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook-base.js +424 -0
- package/dist/core/events/v3/producers/hook.d.ts +29 -0
- package/dist/core/events/v3/producers/hook.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook.js +71 -0
- package/dist/core/events/v3/producers/intake.d.ts +65 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -0
- package/dist/core/events/v3/producers/intake.js +244 -0
- package/dist/core/events/v3/producers/recorder.d.ts +240 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/recorder.js +2176 -0
- package/dist/core/events/v3/projection.d.ts +101 -0
- package/dist/core/events/v3/projection.d.ts.map +1 -0
- package/dist/core/events/v3/projection.js +479 -0
- package/dist/core/events/v3/reader.d.ts +75 -0
- package/dist/core/events/v3/reader.d.ts.map +1 -0
- package/dist/core/events/v3/reader.js +778 -0
- package/dist/core/events/v3/recovery-record.d.ts +47 -0
- package/dist/core/events/v3/recovery-record.d.ts.map +1 -0
- package/dist/core/events/v3/recovery-record.js +167 -0
- package/dist/core/events/v3/recovery.d.ts +22 -0
- package/dist/core/events/v3/recovery.d.ts.map +1 -0
- package/dist/core/events/v3/recovery.js +227 -0
- package/dist/core/events/v3/span-state.d.ts +52 -0
- package/dist/core/events/v3/span-state.d.ts.map +1 -0
- package/dist/core/events/v3/span-state.js +142 -0
- package/dist/core/events/v3/targets.d.ts +23 -0
- package/dist/core/events/v3/targets.d.ts.map +1 -0
- package/dist/core/events/v3/targets.js +134 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +41 -0
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -0
- package/dist/core/events/v3/turn-telemetry.js +168 -0
- package/dist/core/events/v3/validate.d.ts +9 -0
- package/dist/core/events/v3/validate.d.ts.map +1 -0
- package/dist/core/events/v3/validate.js +281 -0
- package/dist/core/events/v3/writer.d.ts +56 -0
- package/dist/core/events/v3/writer.d.ts.map +1 -0
- package/dist/core/events/v3/writer.js +335 -0
- package/dist/core/governor/index.d.ts +1 -1
- package/dist/core/governor/index.d.ts.map +1 -1
- package/dist/core/governor/index.js +1 -1
- package/dist/core/governor/plan-api.d.ts +2 -1
- package/dist/core/governor/plan-api.d.ts.map +1 -1
- package/dist/core/governor/plan-api.js +6 -3
- package/dist/core/governor/read.d.ts +1 -1
- package/dist/core/governor/read.d.ts.map +1 -1
- package/dist/core/governor/read.js +1 -1
- package/dist/core/governor/state.d.ts +9 -0
- package/dist/core/governor/state.d.ts.map +1 -1
- package/dist/core/governor/state.js +40 -3
- package/dist/core/guard/config.d.ts +5 -0
- package/dist/core/guard/config.d.ts.map +1 -0
- package/dist/core/guard/config.js +157 -0
- package/dist/core/guard/coordinator.d.ts +14 -0
- package/dist/core/guard/coordinator.d.ts.map +1 -0
- package/dist/core/guard/coordinator.js +173 -0
- package/dist/core/guard/evaluator.d.ts +4 -0
- package/dist/core/guard/evaluator.d.ts.map +1 -0
- package/dist/core/guard/evaluator.js +242 -0
- package/dist/core/guard/evidence-v3.d.ts +15 -0
- package/dist/core/guard/evidence-v3.d.ts.map +1 -0
- package/dist/core/guard/evidence-v3.js +171 -0
- package/dist/core/guard/index.d.ts +10 -0
- package/dist/core/guard/index.d.ts.map +1 -0
- package/dist/core/guard/index.js +6 -0
- package/dist/core/guard/live-source-v3.d.ts +40 -0
- package/dist/core/guard/live-source-v3.d.ts.map +1 -0
- package/dist/core/guard/live-source-v3.js +128 -0
- package/dist/core/guard/storage.d.ts +27 -0
- package/dist/core/guard/storage.d.ts.map +1 -0
- package/dist/core/guard/storage.js +140 -0
- package/dist/core/guard/types.d.ts +119 -0
- package/dist/core/guard/types.d.ts.map +1 -0
- package/dist/core/guard/types.js +1 -0
- package/dist/core/hooks/adapter/detect.d.ts +18 -1
- package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
- package/dist/core/hooks/adapter/detect.js +29 -0
- package/dist/core/hooks/adapter/events.d.ts +7 -4
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +13 -4
- package/dist/core/hooks/adapter/output.d.ts +2 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.d.ts +7 -4
- package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.js +64 -24
- package/dist/core/hooks/adapter/wiring.d.ts +30 -4
- package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
- package/dist/core/hooks/adapter/wiring.js +89 -11
- package/dist/core/hooks/cli.d.ts +1 -1
- package/dist/core/hooks/cli.js +345 -400
- package/dist/core/hooks/codex-authorization.d.ts +30 -0
- package/dist/core/hooks/codex-authorization.d.ts.map +1 -0
- package/dist/core/hooks/codex-authorization.js +199 -0
- package/dist/core/hooks/effects/image-capture.d.ts +20 -34
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +212 -221
- package/dist/core/hooks/effects/index.d.ts +1 -9
- package/dist/core/hooks/effects/index.d.ts.map +1 -1
- package/dist/core/hooks/effects/index.js +1 -24
- package/dist/core/hooks/events/input-hash.d.ts +7 -0
- package/dist/core/hooks/events/input-hash.d.ts.map +1 -0
- package/dist/core/hooks/events/input-hash.js +43 -0
- package/dist/core/hooks/index.d.ts +4 -3
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js +2 -3
- package/dist/core/hooks/resolve/coord-root.d.ts +1 -1
- package/dist/core/hooks/resolve/coord-root.js +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +16 -15
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +51 -42
- package/dist/core/hooks/resolve/transcript.d.ts +33 -3
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +155 -14
- package/dist/core/hooks/session-name-presence.d.ts +9 -10
- package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
- package/dist/core/hooks/session-name-presence.js +15 -15
- package/dist/core/hooks/unsafe-cross-shell.d.ts +1 -1
- package/dist/core/hooks/unsafe-cross-shell.d.ts.map +1 -1
- package/dist/core/journal/index.d.ts +2 -2
- package/dist/core/journal/index.d.ts.map +1 -1
- package/dist/core/journal/index.js +9 -22
- package/dist/core/presence/blob.d.ts +8 -3
- package/dist/core/presence/blob.d.ts.map +1 -1
- package/dist/core/presence/blob.js +54 -41
- package/dist/core/presence/codec-digest.d.ts +29 -0
- package/dist/core/presence/codec-digest.d.ts.map +1 -0
- package/dist/core/presence/codec-digest.js +170 -0
- package/dist/core/presence/index.js +15 -1
- package/dist/core/presence/relay-client.d.ts +1 -1
- package/dist/core/presence/relay-client.d.ts.map +1 -1
- package/dist/core/presence/relay-client.js +5 -5
- package/dist/core/work/index.d.ts +1 -1
- package/dist/core/work/index.d.ts.map +1 -1
- package/dist/core/work/index.js +1 -1
- package/dist/core/work/read.d.ts +1 -1
- package/dist/core/work/read.d.ts.map +1 -1
- package/dist/core/work/read.js +1 -1
- package/dist/core/work/runner.d.ts.map +1 -1
- package/dist/core/work/runner.js +6 -0
- package/dist/core/work/state.d.ts +9 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +17 -3
- package/dist/core/workflow/engine.js +24 -25
- package/dist/core/workflow/live-session-v3.d.ts +19 -0
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -0
- package/dist/core/workflow/live-session-v3.js +86 -0
- package/dist/core/workflow/scope-id.d.ts +3 -0
- package/dist/core/workflow/scope-id.d.ts.map +1 -0
- package/dist/core/workflow/scope-id.js +5 -0
- package/dist/core/workflow/workspaces/leases.d.ts +4 -0
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +53 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/browser/client.d.ts +41 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +203 -0
- package/dist/lib/browser/critique.d.ts +28 -2
- package/dist/lib/browser/critique.d.ts.map +1 -1
- package/dist/lib/browser/critique.js +74 -18
- package/dist/lib/browser/geometry.d.ts +1 -1
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +130 -6
- package/dist/lib/browser/index.d.ts +3 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +3 -0
- package/dist/lib/browser/qa-plan.d.ts +174 -0
- package/dist/lib/browser/qa-plan.d.ts.map +1 -0
- package/dist/lib/browser/qa-plan.js +321 -0
- package/dist/lib/browser/qa-reuse.d.ts +99 -0
- package/dist/lib/browser/qa-reuse.d.ts.map +1 -0
- package/dist/lib/browser/qa-reuse.js +222 -0
- package/dist/lib/browser/qa-snapshot.d.ts +64 -0
- package/dist/lib/browser/qa-snapshot.d.ts.map +1 -0
- package/dist/lib/browser/qa-snapshot.js +171 -0
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +22 -1
- package/dist/lib/browser/tiling.d.ts +71 -0
- package/dist/lib/browser/tiling.d.ts.map +1 -0
- package/dist/lib/browser/tiling.js +118 -0
- package/dist/lib/context/index.d.ts +0 -3
- package/dist/lib/context/index.d.ts.map +1 -1
- package/dist/lib/context/index.js +20 -42
- package/dist/lib/council/index.d.ts +2 -2
- package/dist/lib/council/index.d.ts.map +1 -1
- package/dist/lib/council/index.js +9 -20
- package/dist/lib/docs-frontmatter.d.ts +1 -6
- package/dist/lib/docs-frontmatter.d.ts.map +1 -1
- package/dist/lib/docs-frontmatter.js +12 -78
- package/dist/lib/docs-index.d.ts +9 -0
- package/dist/lib/docs-index.d.ts.map +1 -1
- package/dist/lib/docs-index.js +32 -3
- package/dist/lib/docs-lint.d.ts.map +1 -1
- package/dist/lib/docs-lint.js +14 -30
- package/dist/lib/docs-metadata-audit.d.ts +19 -0
- package/dist/lib/docs-metadata-audit.d.ts.map +1 -0
- package/dist/lib/docs-metadata-audit.js +132 -0
- package/dist/lib/docs-metadata-managed.d.ts +23 -0
- package/dist/lib/docs-metadata-managed.d.ts.map +1 -0
- package/dist/lib/docs-metadata-managed.js +78 -0
- package/dist/lib/docs-metadata-sync.d.ts +20 -0
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -0
- package/dist/lib/docs-metadata-sync.js +222 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts +273 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2-schema.js +134 -0
- package/dist/lib/docs-metadata-v2.d.ts +21 -0
- package/dist/lib/docs-metadata-v2.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2.js +424 -0
- package/dist/lib/docs-new.d.ts +11 -0
- package/dist/lib/docs-new.d.ts.map +1 -0
- package/dist/lib/docs-new.js +52 -0
- package/dist/lib/docs-sweep.d.ts.map +1 -1
- package/dist/lib/docs-sweep.js +45 -29
- package/dist/lib/headless/index.d.ts +98 -0
- package/dist/lib/headless/index.d.ts.map +1 -0
- package/dist/lib/headless/index.js +211 -0
- package/dist/lib/identities/assume.d.ts +4 -4
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +52 -68
- package/dist/lib/instructions/apply.d.ts +5 -4
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +32 -20
- package/dist/lib/instructions/bundle.d.ts +33 -0
- package/dist/lib/instructions/bundle.d.ts.map +1 -0
- package/dist/lib/instructions/bundle.js +149 -0
- package/dist/lib/instructions/splice.d.ts +0 -1
- package/dist/lib/instructions/splice.d.ts.map +1 -1
- package/dist/lib/instructions/splice.js +22 -6
- package/dist/lib/instructions/templates.d.ts +7 -5
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +79 -9
- package/package.json +27 -6
- package/schemas/config.schema.json +120 -2
- package/schemas/docs-metadata-v2.schema.json +441 -0
- package/schemas/event-v3.schema.json +24472 -0
- package/src/commander.ts +7 -1
- package/src/commands/adapter.ts +2 -2
- package/src/commands/agents.ts +1737 -570
- package/src/commands/artifacts.ts +7 -6
- package/src/commands/backup.ts +29 -21
- package/src/commands/browse.ts +349 -8
- package/src/commands/checkpoint.ts +4 -3
- package/src/commands/claude-desktop.ts +7 -5
- package/src/commands/context.ts +1 -6
- package/src/commands/decision.ts +27 -44
- package/src/commands/docs.ts +100 -33
- package/src/commands/doctor.ts +73 -8
- package/src/commands/events.ts +256 -0
- package/src/commands/governor.ts +18 -4
- package/src/commands/init.ts +264 -57
- package/src/commands/instructions.ts +129 -0
- package/src/commands/journal.ts +4 -13
- package/src/commands/ledger-v3.ts +111 -0
- package/src/commands/presence.ts +18 -11
- package/src/commands/sync.ts +1 -1
- package/src/commands/web.ts +67 -8
- package/src/commands/work.ts +28 -5
- package/src/core/adapter.ts +5 -0
- package/src/core/adapters/attest.ts +8 -3
- package/src/core/adapters/profiles.ts +4 -6
- package/src/core/agents/canonical-emit.ts +39 -28
- package/src/core/agents/cli.ts +242 -263
- package/src/core/agents/codex-archive-v3.ts +138 -0
- package/src/core/agents/coord-client.ts +75 -177
- package/src/core/agents/finalization.ts +120 -38
- package/src/core/agents/index.ts +5 -5
- package/src/core/agents/live-authority-v3.ts +375 -0
- package/src/core/agents/live-lifecycle-v3.ts +140 -0
- package/src/core/agents/live-observation-v3.ts +216 -0
- package/src/core/agents/render/prompt-context.ts +89 -55
- package/src/core/agents/render/session-context.ts +23 -32
- package/src/core/agents/rules/claim-conflict.ts +85 -126
- package/src/core/agents/rules/commit-conflict.ts +3 -14
- package/src/core/agents/rules/stop-hook.ts +239 -293
- package/src/core/agents/session-events.ts +137 -104
- package/src/core/agents/session-finalization-state-v3.ts +90 -0
- package/src/core/agents/session-finalizer-v3.ts +953 -0
- package/src/core/agents/session-name-display.ts +149 -0
- package/src/core/agents/state/activity-log.ts +6 -14
- package/src/core/agents/state/heartbeat-writer.ts +98 -242
- package/src/core/agents/state/live-coordination-view.ts +290 -0
- package/src/core/agents/state/session-state.ts +143 -0
- package/src/core/agents/state/stale-sweep.ts +40 -17
- package/src/core/artifacts/index.ts +4 -5
- package/src/core/config.ts +148 -3
- package/src/core/context/index.ts +9 -17
- package/src/core/events/span-parent.ts +46 -0
- package/src/core/events/v3/advance.ts +168 -0
- package/src/core/events/v3/authority-outbox.ts +548 -0
- package/src/core/events/v3/base-builder.ts +60 -0
- package/src/core/events/v3/base-contract.ts +882 -0
- package/src/core/events/v3/bootstrap.ts +226 -0
- package/src/core/events/v3/builder.ts +59 -0
- package/src/core/events/v3/canonical.ts +153 -0
- package/src/core/events/v3/capabilities.ts +171 -0
- package/src/core/events/v3/capability-drift.ts +177 -0
- package/src/core/events/v3/catalog.ts +202 -0
- package/src/core/events/v3/clock-order.ts +41 -0
- package/src/core/events/v3/contract.ts +365 -0
- package/src/core/events/v3/control.ts +576 -0
- package/src/core/events/v3/coordination-view.ts +193 -0
- package/src/core/events/v3/economics.ts +384 -0
- package/src/core/events/v3/finalization-view.ts +67 -0
- package/src/core/events/v3/fingerprint-keys.ts +260 -0
- package/src/core/events/v3/generated.ts +48 -0
- package/src/core/events/v3/ids.ts +33 -0
- package/src/core/events/v3/index.ts +322 -0
- package/src/core/events/v3/latency.ts +551 -0
- package/src/core/events/v3/live-feed.ts +319 -0
- package/src/core/events/v3/live-observation.ts +39 -0
- package/src/core/events/v3/live-routing.ts +135 -0
- package/src/core/events/v3/producers/command-recorder.ts +631 -0
- package/src/core/events/v3/producers/command.ts +201 -0
- package/src/core/events/v3/producers/coordination-recorder.ts +538 -0
- package/src/core/events/v3/producers/coordination.ts +355 -0
- package/src/core/events/v3/producers/hook-base.ts +578 -0
- package/src/core/events/v3/producers/hook.ts +119 -0
- package/src/core/events/v3/producers/intake.ts +319 -0
- package/src/core/events/v3/producers/recorder.ts +2805 -0
- package/src/core/events/v3/projection.ts +653 -0
- package/src/core/events/v3/reader.ts +1127 -0
- package/src/core/events/v3/recovery-record.ts +244 -0
- package/src/core/events/v3/recovery.ts +271 -0
- package/src/core/events/v3/span-state.ts +187 -0
- package/src/core/events/v3/targets.ts +182 -0
- package/src/core/events/v3/turn-telemetry.ts +259 -0
- package/src/core/events/v3/validate.ts +361 -0
- package/src/core/events/v3/writer.ts +419 -0
- package/src/core/governor/index.ts +3 -0
- package/src/core/governor/plan-api.ts +10 -2
- package/src/core/governor/read.ts +3 -0
- package/src/core/governor/state.ts +52 -5
- package/src/core/guard/config.ts +206 -0
- package/src/core/guard/coordinator.ts +227 -0
- package/src/core/guard/evaluator.ts +343 -0
- package/src/core/guard/evidence-v3.ts +227 -0
- package/src/core/guard/index.ts +35 -0
- package/src/core/guard/live-source-v3.ts +204 -0
- package/src/core/guard/storage.ts +188 -0
- package/src/core/guard/types.ts +152 -0
- package/src/core/hooks/adapter/detect.ts +28 -1
- package/src/core/hooks/adapter/events.ts +15 -6
- package/src/core/hooks/adapter/output.ts +7 -2
- package/src/core/hooks/adapter/parse.ts +81 -36
- package/src/core/hooks/adapter/wiring.ts +119 -13
- package/src/core/hooks/cli.ts +398 -422
- package/src/core/hooks/codex-authorization.ts +253 -0
- package/src/core/hooks/effects/image-capture.ts +228 -238
- package/src/core/hooks/effects/index.ts +1 -36
- package/src/core/hooks/events/input-hash.ts +47 -0
- package/src/core/hooks/index.ts +4 -11
- package/src/core/hooks/resolve/coord-root.ts +1 -1
- package/src/core/hooks/resolve/owner.ts +52 -45
- package/src/core/hooks/resolve/transcript.ts +165 -14
- package/src/core/hooks/session-name-presence.ts +14 -15
- package/src/core/hooks/unsafe-cross-shell.ts +1 -1
- package/src/core/journal/index.ts +15 -22
- package/src/core/presence/blob.ts +63 -38
- package/src/core/presence/codec-digest.ts +215 -0
- package/src/core/presence/index.ts +18 -1
- package/src/core/presence/relay-client.ts +5 -5
- package/src/core/work/index.ts +3 -0
- package/src/core/work/read.ts +3 -0
- package/src/core/work/runner.ts +6 -0
- package/src/core/work/state.ts +27 -3
- package/src/core/workflow/engine.ts +24 -24
- package/src/core/workflow/live-session-v3.ts +126 -0
- package/src/core/workflow/scope-id.ts +6 -0
- package/src/core/workflow/workspaces/leases.ts +56 -19
- package/src/index.ts +1 -1
- package/src/lib/browser/client.ts +230 -0
- package/src/lib/browser/critique.ts +104 -27
- package/src/lib/browser/geometry.ts +143 -14
- package/src/lib/browser/index.ts +34 -0
- package/src/lib/browser/qa-plan.ts +501 -0
- package/src/lib/browser/qa-reuse.ts +306 -0
- package/src/lib/browser/qa-snapshot.ts +223 -0
- package/src/lib/browser/runts.ts +27 -2
- package/src/lib/browser/tiling.ts +164 -0
- package/src/lib/context/index.ts +22 -46
- package/src/lib/council/index.ts +9 -21
- package/src/lib/docs-frontmatter.ts +8 -79
- package/src/lib/docs-index.ts +33 -3
- package/src/lib/docs-lint.ts +15 -29
- package/src/lib/docs-metadata-audit.ts +166 -0
- package/src/lib/docs-metadata-managed.ts +83 -0
- package/src/lib/docs-metadata-sync.ts +262 -0
- package/src/lib/docs-metadata-v2-schema.ts +138 -0
- package/src/lib/docs-metadata-v2.ts +646 -0
- package/src/lib/docs-new.ts +63 -0
- package/src/lib/docs-sweep.ts +42 -28
- package/src/lib/headless/index.ts +287 -0
- package/src/lib/identities/assume.ts +67 -86
- package/src/lib/instructions/apply.ts +33 -20
- package/src/lib/instructions/bundle.ts +199 -0
- package/src/lib/instructions/splice.ts +21 -7
- package/src/lib/instructions/templates.ts +85 -13
- package/dist/core/agents/cli-emit.d.ts +0 -27
- package/dist/core/agents/cli-emit.d.ts.map +0 -1
- package/dist/core/agents/cli-emit.js +0 -57
- package/dist/core/agents/codex-replay.d.ts +0 -29
- package/dist/core/agents/codex-replay.d.ts.map +0 -1
- package/dist/core/agents/codex-replay.js +0 -138
- package/dist/core/agents/events/consume.d.ts +0 -82
- package/dist/core/agents/events/consume.d.ts.map +0 -1
- package/dist/core/agents/events/consume.js +0 -195
- package/dist/core/agents/events/emit.d.ts +0 -42
- package/dist/core/agents/events/emit.d.ts.map +0 -1
- package/dist/core/agents/events/emit.js +0 -75
- package/dist/core/agents/events/ulid.d.ts +0 -11
- package/dist/core/agents/events/ulid.d.ts.map +0 -1
- package/dist/core/agents/events/ulid.js +0 -47
- package/dist/core/agents/state/heartbeat-projector.d.ts +0 -65
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +0 -1
- package/dist/core/agents/state/heartbeat-projector.js +0 -527
- package/dist/core/hooks/events/emit.d.ts +0 -31
- package/dist/core/hooks/events/emit.d.ts.map +0 -1
- package/dist/core/hooks/events/emit.js +0 -93
- package/dist/core/hooks/events/rotate.d.ts +0 -43
- package/dist/core/hooks/events/rotate.d.ts.map +0 -1
- package/dist/core/hooks/events/rotate.js +0 -142
- package/dist/core/hooks/events/schema.d.ts +0 -312
- package/dist/core/hooks/events/schema.d.ts.map +0 -1
- package/dist/core/hooks/events/schema.js +0 -12
- package/dist/core/hooks/events/ulid.d.ts +0 -10
- package/dist/core/hooks/events/ulid.d.ts.map +0 -1
- package/dist/core/hooks/events/ulid.js +0 -47
- package/dist/lib/docs-frontmatter-migrate.d.ts +0 -33
- package/dist/lib/docs-frontmatter-migrate.d.ts.map +0 -1
- package/dist/lib/docs-frontmatter-migrate.js +0 -364
- package/src/core/agents/cli-emit.ts +0 -64
- package/src/core/agents/codex-replay.ts +0 -163
- package/src/core/agents/events/consume.ts +0 -254
- package/src/core/agents/events/emit.ts +0 -115
- package/src/core/agents/events/ulid.ts +0 -51
- package/src/core/agents/state/heartbeat-projector.ts +0 -582
- package/src/core/hooks/events/emit.ts +0 -125
- package/src/core/hooks/events/rotate.ts +0 -151
- package/src/core/hooks/events/schema.ts +0 -538
- package/src/core/hooks/events/ulid.ts +0 -51
- package/src/lib/docs-frontmatter-migrate.ts +0 -427
package/src/commands/init.ts
CHANGED
|
@@ -17,17 +17,32 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { spawnSync } from "node:child_process";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
20
21
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
21
22
|
import { dirname, relative, resolve } from "node:path";
|
|
22
23
|
import { fileURLToPath } from "node:url";
|
|
23
24
|
import type { Command } from "commander";
|
|
24
25
|
import type { EmitContext } from "../commander.ts";
|
|
25
26
|
import { DEFAULT_BIN_NAME, pinnedBinName, stripJsonComments } from "../core/config.ts";
|
|
27
|
+
import { canonicalJsonV3 } from "../core/events/v3/canonical.ts";
|
|
28
|
+
import { ADAPTER_CAPABILITY_PROFILES_V3 } from "../core/events/v3/capabilities.ts";
|
|
29
|
+
import type { EventV3ControlState } from "../core/events/v3/control.ts";
|
|
30
|
+
import { EVENT_V3_SCHEMA_DIGEST } from "../core/events/v3/generated.ts";
|
|
31
|
+
import {
|
|
32
|
+
initializeEventLedgerV3,
|
|
33
|
+
readEventV3ControlState,
|
|
34
|
+
sha256V3,
|
|
35
|
+
} from "../core/events/v3/index.ts";
|
|
36
|
+
import { liveEventV3BuildId } from "../core/events/v3/live-routing.ts";
|
|
26
37
|
import { ADAPTER_SPECS, type AdapterId, type AdapterSpec } from "../core/hooks/adapter/events.ts";
|
|
27
38
|
import {
|
|
39
|
+
agentHookPathForProject,
|
|
28
40
|
commandWiresSubcommand,
|
|
41
|
+
diffWiring,
|
|
29
42
|
groupCommands,
|
|
30
43
|
type HookGroup,
|
|
44
|
+
hookCommand,
|
|
45
|
+
isAgentHookCommand,
|
|
31
46
|
makeEntry,
|
|
32
47
|
type SettingsFile,
|
|
33
48
|
} from "../core/hooks/adapter/wiring.ts";
|
|
@@ -79,16 +94,86 @@ export function registerInitCommand(program: Command, emit: EmitContext, binName
|
|
|
79
94
|
// CLI re-stamps the host's name into committed agent-facing surfaces.
|
|
80
95
|
const bin = pinnedBinName(projectRoot) ?? (binName?.trim() ? binName : DEFAULT_BIN_NAME);
|
|
81
96
|
|
|
82
|
-
// ── --check: read-only drift report on
|
|
97
|
+
// ── --check: read-only drift report on every init-managed surface ─────
|
|
83
98
|
if (opts.check === true) {
|
|
84
99
|
const { status, issues } = checkInstructions(projectRoot, { binName: bin, adapter });
|
|
100
|
+
let hookCheckError = false;
|
|
101
|
+
let hookDrift = false;
|
|
102
|
+
const settingsPath = resolve(projectRoot, spec.settingsFile);
|
|
103
|
+
const agentHook = agentHookPathForProject(projectRoot, HARNERY_ROOT);
|
|
104
|
+
if (!existsSync(settingsPath)) {
|
|
105
|
+
hookDrift = true;
|
|
106
|
+
issues.push(`${spec.settingsFile}: missing (re-run init)`);
|
|
107
|
+
} else {
|
|
108
|
+
try {
|
|
109
|
+
const settings = JSON.parse(readFileSync(settingsPath, "utf8")) as SettingsFile;
|
|
110
|
+
const hookDiff = diffWiring(settings, spec, { agentHookPath: agentHook, adapter });
|
|
111
|
+
hookDrift =
|
|
112
|
+
hookDiff.missing.length > 0 ||
|
|
113
|
+
hookDiff.stale.length > 0 ||
|
|
114
|
+
hookDiff.duplicates.length > 0 ||
|
|
115
|
+
hookDiff.misplaced.length > 0 ||
|
|
116
|
+
hookDiff.orphans.length > 0 ||
|
|
117
|
+
hookDiff.invalidTopLevelKeys.length > 0 ||
|
|
118
|
+
hookDiff.invalidEventKeys.length > 0;
|
|
119
|
+
if (hookDiff.missing.length > 0) {
|
|
120
|
+
issues.push(
|
|
121
|
+
`${spec.settingsFile}: missing hooks (${hookDiff.missing.map((e) => e.settingsKey).join(", ")})`,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (hookDiff.stale.length > 0) {
|
|
125
|
+
issues.push(
|
|
126
|
+
`${spec.settingsFile}: stale hook commands (${hookDiff.stale.map((e) => e.settingsKey).join(", ")})`,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (hookDiff.duplicates.length > 0) {
|
|
130
|
+
issues.push(
|
|
131
|
+
`${spec.settingsFile}: duplicate hooks (${hookDiff.duplicates.map((e) => e.settingsKey).join(", ")})`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
if (hookDiff.misplaced.length > 0) {
|
|
135
|
+
issues.push(
|
|
136
|
+
`${spec.settingsFile}: hooks under the wrong event (${hookDiff.misplaced.map((e) => e.subcommand).join(", ")})`,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (hookDiff.orphans.length > 0) {
|
|
140
|
+
issues.push(`${spec.settingsFile}: obsolete hooks (${hookDiff.orphans.join(", ")})`);
|
|
141
|
+
}
|
|
142
|
+
if (hookDiff.invalidTopLevelKeys.length > 0) {
|
|
143
|
+
issues.push(
|
|
144
|
+
`${spec.settingsFile}: invalid fields (${hookDiff.invalidTopLevelKeys.join(", ")})`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (hookDiff.invalidEventKeys.length > 0) {
|
|
148
|
+
issues.push(
|
|
149
|
+
`${spec.settingsFile}: unsupported events (${hookDiff.invalidEventKeys.join(", ")})`,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
} catch (error) {
|
|
153
|
+
hookCheckError = true;
|
|
154
|
+
issues.push(`${spec.settingsFile}: invalid JSON (${(error as Error).message})`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
85
157
|
const gitHooks = checkGitHooks(projectRoot);
|
|
86
158
|
if (gitHooks.status !== "fresh") issues.push(...gitHooks.issues);
|
|
159
|
+
const ledger = readEventV3ControlState(projectRoot);
|
|
160
|
+
if (ledger.state !== "active") issues.push(`event ledger V3 is ${ledger.state}`);
|
|
161
|
+
const ledgerRuntimeIssues = eventLedgerV3RuntimeIssues(ledger, gitBuild(HARNERY_ROOT));
|
|
162
|
+
if (ledgerRuntimeIssues.length > 0) {
|
|
163
|
+
issues.push(`event ledger V3 is runtime-stale (${ledgerRuntimeIssues.join(", ")})`);
|
|
164
|
+
}
|
|
87
165
|
const merged =
|
|
88
|
-
status === "error"
|
|
166
|
+
status === "error" || hookCheckError
|
|
167
|
+
? "error"
|
|
168
|
+
: hookDrift ||
|
|
169
|
+
gitHooks.status !== "fresh" ||
|
|
170
|
+
ledger.state !== "active" ||
|
|
171
|
+
ledgerRuntimeIssues.length > 0
|
|
172
|
+
? "drift"
|
|
173
|
+
: status;
|
|
89
174
|
const head =
|
|
90
175
|
merged === "fresh"
|
|
91
|
-
? "harn init --check: instructions + skills +
|
|
176
|
+
? "harn init --check: hooks + instructions + skills + event ledger V3 are current"
|
|
92
177
|
: merged === "drift"
|
|
93
178
|
? "harn init --check: drift found (re-run `init` to refresh)"
|
|
94
179
|
: "harn init --check: error";
|
|
@@ -137,9 +222,41 @@ export function registerInitCommand(program: Command, emit: EmitContext, binName
|
|
|
137
222
|
if (stamp) actions.push(stamp);
|
|
138
223
|
}
|
|
139
224
|
|
|
225
|
+
// ── 1d. universal V3 event ledger ────────────────────────────────────
|
|
226
|
+
if (dryRun) {
|
|
227
|
+
const ledger = readEventV3ControlState(projectRoot);
|
|
228
|
+
const runtimeIssues = eventLedgerV3RuntimeIssues(ledger, gitBuild(HARNERY_ROOT));
|
|
229
|
+
actions.push(
|
|
230
|
+
ledger.state === "active" && runtimeIssues.length === 0
|
|
231
|
+
? "· event ledger V3 is active"
|
|
232
|
+
: ledger.state === "active"
|
|
233
|
+
? `+ would refresh event ledger V3 runtime profile (${runtimeIssues.join(", ")})`
|
|
234
|
+
: `+ would initialize event ledger V3 (current state: ${ledger.state})`,
|
|
235
|
+
);
|
|
236
|
+
} else {
|
|
237
|
+
const harneryBuild = gitBuild(HARNERY_ROOT);
|
|
238
|
+
const ledgerBefore = readEventV3ControlState(projectRoot);
|
|
239
|
+
const runtimeIssues = eventLedgerV3RuntimeIssues(ledgerBefore, harneryBuild);
|
|
240
|
+
const initialized = initializeEventLedgerV3({
|
|
241
|
+
coordRoot: projectRoot,
|
|
242
|
+
harneryBuild,
|
|
243
|
+
hostBuild: gitBuild(projectRoot),
|
|
244
|
+
configDigest: digestConfig(resolve(coordDir, "config.jsonc")),
|
|
245
|
+
approvalRecordId: "harnery-init-v3-universal",
|
|
246
|
+
forceNewEpoch: runtimeIssues.length > 0,
|
|
247
|
+
});
|
|
248
|
+
actions.push(
|
|
249
|
+
initialized.archived_epoch
|
|
250
|
+
? `+ refreshed event ledger V3 runtime profile (${runtimeIssues.join(", ")}); archived the prior epoch intact`
|
|
251
|
+
: initialized.initialized
|
|
252
|
+
? "+ initialized event ledger V3"
|
|
253
|
+
: "· event ledger V3 already active",
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
140
257
|
// ── 2. adapter hooks ───────────────────────────────────────────────────
|
|
141
258
|
const settingsPath = resolve(projectRoot, spec.settingsFile);
|
|
142
|
-
const agentHook =
|
|
259
|
+
const agentHook = agentHookPathForProject(projectRoot, HARNERY_ROOT);
|
|
143
260
|
|
|
144
261
|
let settings: SettingsFile;
|
|
145
262
|
if (existsSync(settingsPath)) {
|
|
@@ -165,16 +282,18 @@ export function registerInitCommand(program: Command, emit: EmitContext, binName
|
|
|
165
282
|
} else if (dryRun) {
|
|
166
283
|
actions.push(
|
|
167
284
|
`+ would wire ${wired} hook(s), upgrade ${upgraded} stale command(s), and remove ` +
|
|
168
|
-
`${removed}
|
|
285
|
+
`${removed} obsolete/duplicate command(s) in ${rel(projectRoot, settingsPath)} (${already} already present)`,
|
|
169
286
|
);
|
|
170
287
|
} else {
|
|
171
288
|
mkdirSync(dirname(settingsPath), { recursive: true });
|
|
172
289
|
writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}\n`);
|
|
173
290
|
actions.push(
|
|
174
291
|
`+ wired ${wired} hook(s), upgraded ${upgraded} stale command(s), and removed ` +
|
|
175
|
-
`${removed}
|
|
292
|
+
`${removed} obsolete/duplicate command(s) in ${rel(projectRoot, settingsPath)} (${already} already present)`,
|
|
176
293
|
);
|
|
177
294
|
}
|
|
295
|
+
const authorizationReview = codexHookReviewAction(adapter);
|
|
296
|
+
if (authorizationReview) actions.push(authorizationReview);
|
|
178
297
|
|
|
179
298
|
// ── 3. agent-facing instructions block + skills ────────────────────────
|
|
180
299
|
// A misconfigured host addendum aborts here rather than half-writing: the
|
|
@@ -202,6 +321,61 @@ export function registerInitCommand(program: Command, emit: EmitContext, binName
|
|
|
202
321
|
});
|
|
203
322
|
}
|
|
204
323
|
|
|
324
|
+
function gitBuild(root: string): string {
|
|
325
|
+
const result = spawnSync("git", ["-C", root, "rev-parse", "HEAD"], {
|
|
326
|
+
encoding: "utf8",
|
|
327
|
+
timeout: 5000,
|
|
328
|
+
});
|
|
329
|
+
const commit = result.status === 0 ? result.stdout.trim() : "";
|
|
330
|
+
return /^[0-9a-f]{40,64}$/.test(commit)
|
|
331
|
+
? commit
|
|
332
|
+
: createHash("sha256").update(resolve(root)).digest("hex");
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function digestConfig(path: string): `sha256:${string}` {
|
|
336
|
+
return sha256V3(existsSync(path) ? readFileSync(path) : Buffer.from("{}\n"));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Runtime gates bound into an immutable V3 epoch. `init` is the explicit
|
|
341
|
+
* upgrade boundary: when code or capability profiles change, it archives the
|
|
342
|
+
* old epoch intact and activates a compatible one instead of letting upgraded
|
|
343
|
+
* hooks fail closed against stale approvals.
|
|
344
|
+
*/
|
|
345
|
+
export function eventLedgerV3RuntimeIssues(
|
|
346
|
+
control: EventV3ControlState,
|
|
347
|
+
harneryBuild: string,
|
|
348
|
+
): string[] {
|
|
349
|
+
if (control.state !== "active") return [];
|
|
350
|
+
const issues: string[] = [];
|
|
351
|
+
const profile = control.genesis.profile;
|
|
352
|
+
if (profile.initial_schema_digest !== EVENT_V3_SCHEMA_DIGEST) issues.push("schema digest");
|
|
353
|
+
if (profile.contract_source_digest !== EVENT_V3_SCHEMA_DIGEST) issues.push("contract digest");
|
|
354
|
+
if (!profile.producer_build_ids.includes(liveEventV3BuildId(harneryBuild))) {
|
|
355
|
+
issues.push("producer build");
|
|
356
|
+
}
|
|
357
|
+
const expectedCapabilities = Object.values(ADAPTER_CAPABILITY_PROFILES_V3).map((value) =>
|
|
358
|
+
sha256V3(canonicalJsonV3(value)),
|
|
359
|
+
);
|
|
360
|
+
if (
|
|
361
|
+
expectedCapabilities.some(
|
|
362
|
+
(digest) => !profile.adapter_capability_profile_digests.includes(digest),
|
|
363
|
+
)
|
|
364
|
+
) {
|
|
365
|
+
issues.push("adapter capabilities");
|
|
366
|
+
}
|
|
367
|
+
return issues;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export function codexHookReviewAction(adapter: AdapterId): string | null {
|
|
371
|
+
if (adapter !== "codex") return null;
|
|
372
|
+
return (
|
|
373
|
+
"! Codex authorizes hook commands separately. Before starting work, review them in " +
|
|
374
|
+
"the terminal UI with `/hooks` or in Codex Desktop under Settings > Hooks. " +
|
|
375
|
+
"After approval, start a fresh task so SessionStart can run."
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
205
379
|
/**
|
|
206
380
|
* Merge agent-hook entries into a adapter settings object in place, idempotently.
|
|
207
381
|
* Preserves every existing hook; rewrites events already wired to
|
|
@@ -211,8 +385,7 @@ export function registerInitCommand(program: Command, emit: EmitContext, binName
|
|
|
211
385
|
* `{ command }`) and ensures the root `version` key when the adapter requires
|
|
212
386
|
* one. Pure (no fs/git) so it's unit-testable.
|
|
213
387
|
*
|
|
214
|
-
*
|
|
215
|
-
* it keeps `stop` from matching `stop-failure`.
|
|
388
|
+
* Token-aware matching keeps `stop` from matching `stop-failure`.
|
|
216
389
|
*/
|
|
217
390
|
export function wireHooks(
|
|
218
391
|
settings: SettingsFile,
|
|
@@ -228,31 +401,40 @@ export function wireHooks(
|
|
|
228
401
|
let already = 0;
|
|
229
402
|
let removed = 0;
|
|
230
403
|
let upgraded = 0;
|
|
231
|
-
for (const {
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
removed += groups.length - kept.length;
|
|
238
|
-
if (kept.length === 0) delete settings.hooks[settingsKey];
|
|
239
|
-
else settings.hooks[settingsKey] = kept;
|
|
404
|
+
for (const { subcommand } of spec.legacyEvents ?? []) {
|
|
405
|
+
for (const settingsKey of Object.keys(settings.hooks)) {
|
|
406
|
+
removed += removeCommandsFromKey(settings, settingsKey, (command) =>
|
|
407
|
+
commandWiresSubcommand(command, subcommand),
|
|
408
|
+
);
|
|
409
|
+
}
|
|
240
410
|
}
|
|
241
411
|
for (const { settingsKey, subcommand } of spec.events) {
|
|
242
412
|
const command = hookCommand(spec, agentHookPath, subcommand, adapter);
|
|
243
|
-
const groups = settings.hooks[settingsKey] ?? [];
|
|
244
413
|
let present = false;
|
|
414
|
+
for (const key of Object.keys(settings.hooks)) {
|
|
415
|
+
if (key === settingsKey) continue;
|
|
416
|
+
removed += removeCommandsFromKey(settings, key, (candidate) =>
|
|
417
|
+
commandWiresSubcommand(candidate, subcommand),
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
const groups = settings.hooks[settingsKey] ?? [];
|
|
421
|
+
const nextGroups: HookGroup[] = [];
|
|
245
422
|
for (const group of groups) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
423
|
+
const normalized = normalizeEventGroup(group, subcommand, command, present);
|
|
424
|
+
if (normalized.found && !present) present = true;
|
|
425
|
+
upgraded += normalized.upgraded;
|
|
426
|
+
removed += normalized.removed;
|
|
427
|
+
if (normalized.group) nextGroups.push(normalized.group);
|
|
249
428
|
}
|
|
429
|
+
if (nextGroups.length > 0) settings.hooks[settingsKey] = nextGroups;
|
|
430
|
+
else delete settings.hooks[settingsKey];
|
|
250
431
|
if (present) {
|
|
251
432
|
already++;
|
|
252
433
|
continue;
|
|
253
434
|
}
|
|
254
|
-
|
|
255
|
-
|
|
435
|
+
const current = settings.hooks[settingsKey] ?? [];
|
|
436
|
+
current.push(makeEntry(spec.entryShape, command));
|
|
437
|
+
settings.hooks[settingsKey] = current;
|
|
256
438
|
wired++;
|
|
257
439
|
}
|
|
258
440
|
return { wired, already, removed, upgraded };
|
|
@@ -268,49 +450,80 @@ export function wireHooks(
|
|
|
268
450
|
* that don't set the var. Only the env expansion is quoted so the
|
|
269
451
|
* `agent-hook <subcommand> ` wiring match stays byte-identical.
|
|
270
452
|
*/
|
|
271
|
-
function
|
|
272
|
-
spec: AdapterSpec,
|
|
273
|
-
agentHookPath: string,
|
|
274
|
-
subcommand: string,
|
|
275
|
-
adapter: AdapterId,
|
|
276
|
-
): string {
|
|
277
|
-
const anchor = spec.projectDirEnv ? `"\${${spec.projectDirEnv}:-.}"/` : "";
|
|
278
|
-
return `bash ${anchor}${agentHookPath} ${subcommand} --adapter ${adapter}`;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Rewrite any harnery-owned command for `subcommand` inside one hook group to
|
|
283
|
-
* the canonical form, in place. Returns the number of commands rewritten and
|
|
284
|
-
* calls `onPresent` when the subcommand is wired in this group at all.
|
|
285
|
-
*/
|
|
286
|
-
function rewriteStaleCommands(
|
|
453
|
+
function normalizeEventGroup(
|
|
287
454
|
group: HookGroup,
|
|
288
455
|
subcommand: string,
|
|
289
456
|
canonical: string,
|
|
290
|
-
|
|
291
|
-
): number {
|
|
292
|
-
let
|
|
457
|
+
alreadyFound: boolean,
|
|
458
|
+
): { group: HookGroup | null; found: boolean; upgraded: number; removed: number } {
|
|
459
|
+
let found = false;
|
|
460
|
+
let upgraded = 0;
|
|
461
|
+
let removed = 0;
|
|
293
462
|
if ("command" in group && typeof group.command === "string") {
|
|
294
463
|
if (commandWiresSubcommand(group.command, subcommand)) {
|
|
295
|
-
|
|
464
|
+
if (alreadyFound) return { group: null, found: true, upgraded: 0, removed: 1 };
|
|
465
|
+
found = true;
|
|
296
466
|
if (group.command !== canonical) {
|
|
297
467
|
group.command = canonical;
|
|
298
|
-
|
|
468
|
+
upgraded++;
|
|
299
469
|
}
|
|
300
470
|
}
|
|
301
471
|
}
|
|
302
472
|
if ("hooks" in group && Array.isArray(group.hooks)) {
|
|
473
|
+
const kept = [] as typeof group.hooks;
|
|
303
474
|
for (const hook of group.hooks) {
|
|
304
|
-
if (typeof hook.command !== "string")
|
|
305
|
-
|
|
306
|
-
|
|
475
|
+
if (typeof hook.command !== "string" || !commandWiresSubcommand(hook.command, subcommand)) {
|
|
476
|
+
kept.push(hook);
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if (alreadyFound || found) {
|
|
480
|
+
removed++;
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
found = true;
|
|
307
484
|
if (hook.command !== canonical) {
|
|
308
485
|
hook.command = canonical;
|
|
309
|
-
|
|
486
|
+
upgraded++;
|
|
310
487
|
}
|
|
488
|
+
kept.push(hook);
|
|
489
|
+
}
|
|
490
|
+
group.hooks = kept;
|
|
491
|
+
if (group.hooks.length === 0) return { group: null, found, upgraded, removed };
|
|
492
|
+
}
|
|
493
|
+
return { group, found, upgraded, removed };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** Remove matching command handlers while preserving unrelated handlers in a mixed group. */
|
|
497
|
+
function removeCommandsFromKey(
|
|
498
|
+
settings: SettingsFile,
|
|
499
|
+
settingsKey: string,
|
|
500
|
+
predicate: (command: string) => boolean,
|
|
501
|
+
): number {
|
|
502
|
+
const groups = settings.hooks?.[settingsKey];
|
|
503
|
+
if (!Array.isArray(groups)) return 0;
|
|
504
|
+
let removed = 0;
|
|
505
|
+
const kept: HookGroup[] = [];
|
|
506
|
+
for (const group of groups) {
|
|
507
|
+
if ("command" in group && typeof group.command === "string") {
|
|
508
|
+
if (predicate(group.command)) removed++;
|
|
509
|
+
else kept.push(group);
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
if ("hooks" in group && Array.isArray(group.hooks)) {
|
|
513
|
+
const handlers = group.hooks.filter((hook) => {
|
|
514
|
+
if (typeof hook.command !== "string" || !predicate(hook.command)) return true;
|
|
515
|
+
removed++;
|
|
516
|
+
return false;
|
|
517
|
+
});
|
|
518
|
+
group.hooks = handlers;
|
|
519
|
+
if (handlers.length > 0) kept.push(group);
|
|
520
|
+
continue;
|
|
311
521
|
}
|
|
522
|
+
kept.push(group);
|
|
312
523
|
}
|
|
313
|
-
|
|
524
|
+
if (kept.length === 0) delete settings.hooks?.[settingsKey];
|
|
525
|
+
else settings.hooks![settingsKey] = kept;
|
|
526
|
+
return removed;
|
|
314
527
|
}
|
|
315
528
|
|
|
316
529
|
/**
|
|
@@ -327,17 +540,11 @@ export function unwireHooks(settings: SettingsFile): { removed: number; remainin
|
|
|
327
540
|
if (!settings.hooks || typeof settings.hooks !== "object") return { removed: 0, remaining: 0 };
|
|
328
541
|
let removed = 0;
|
|
329
542
|
for (const key of Object.keys(settings.hooks)) {
|
|
330
|
-
|
|
331
|
-
if (!Array.isArray(groups)) continue;
|
|
332
|
-
const kept = groups.filter((g) => !groupCommands(g).some((c) => c.includes("agent-hook ")));
|
|
333
|
-
removed += groups.length - kept.length;
|
|
334
|
-
// removing the emptied hook key is the intent (tiny one-shot object)
|
|
335
|
-
if (kept.length === 0) delete settings.hooks[key];
|
|
336
|
-
else settings.hooks[key] = kept;
|
|
543
|
+
removed += removeCommandsFromKey(settings, key, isAgentHookCommand);
|
|
337
544
|
}
|
|
338
545
|
let remaining = 0;
|
|
339
546
|
for (const groups of Object.values(settings.hooks)) {
|
|
340
|
-
if (Array.isArray(groups)) remaining += groups.length;
|
|
547
|
+
if (Array.isArray(groups)) remaining += groups.flatMap(groupCommands).length;
|
|
341
548
|
}
|
|
342
549
|
// drop the now-empty hooks object so callers see a clean shape
|
|
343
550
|
if (Object.keys(settings.hooks).length === 0) delete settings.hooks;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import type { Command } from "commander";
|
|
5
|
+
import { countTokens } from "gpt-tokenizer/model/gpt-4o";
|
|
6
|
+
import type { EmitContext } from "../commander.ts";
|
|
7
|
+
import type { Adapter } from "../core/adapter.ts";
|
|
8
|
+
import { monorepoRoot } from "../core/agents/index.ts";
|
|
9
|
+
import {
|
|
10
|
+
buildInstructionBundle,
|
|
11
|
+
type InstructionBundleComponent,
|
|
12
|
+
} from "../lib/instructions/bundle.ts";
|
|
13
|
+
|
|
14
|
+
interface ManifestOptions {
|
|
15
|
+
adapter: string;
|
|
16
|
+
format: string;
|
|
17
|
+
output?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function registerInstructionsCommand(program: Command, emit: EmitContext): void {
|
|
21
|
+
const command = program
|
|
22
|
+
.command("instructions")
|
|
23
|
+
.description(
|
|
24
|
+
"Inspect and version the repo-authored instruction bundle loaded by each adapter.",
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
command
|
|
28
|
+
.command("manifest [paths...]")
|
|
29
|
+
.description("Emit a machine-readable bundle manifest for one or more working paths")
|
|
30
|
+
.option("--adapter <adapter>", "claude-code, cursor, codex, or all", "all")
|
|
31
|
+
.option("--format <type>", "Output format: json or table", "json")
|
|
32
|
+
.option("-o, --output <file>", "Write the complete JSON manifest to a file")
|
|
33
|
+
.action((paths: string[], options: ManifestOptions) => {
|
|
34
|
+
if (options.format === "json") emit.config({ format: "json" });
|
|
35
|
+
const coordRoot = monorepoRoot() ?? process.cwd();
|
|
36
|
+
const adapters = parseAdapters(options.adapter);
|
|
37
|
+
const profiles = (paths.length > 0 ? paths : [process.cwd()]).flatMap((path) =>
|
|
38
|
+
adapters.map((adapter) =>
|
|
39
|
+
enrichBundle(
|
|
40
|
+
buildInstructionBundle({ coordRoot, cwd: resolve(path), adapter }),
|
|
41
|
+
coordRoot,
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const manifest = {
|
|
47
|
+
ok: true,
|
|
48
|
+
schema_version: 1,
|
|
49
|
+
generated_at: new Date().toISOString(),
|
|
50
|
+
source_commit: gitHead(coordRoot),
|
|
51
|
+
tokenizer: "o200k_base",
|
|
52
|
+
coord_root: ".",
|
|
53
|
+
profile_count: profiles.length,
|
|
54
|
+
profiles,
|
|
55
|
+
};
|
|
56
|
+
if (options.output) {
|
|
57
|
+
const output = resolve(options.output);
|
|
58
|
+
writeFileSync(output, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
59
|
+
emit.data({
|
|
60
|
+
ok: true,
|
|
61
|
+
output,
|
|
62
|
+
schema_version: manifest.schema_version,
|
|
63
|
+
generated_at: manifest.generated_at,
|
|
64
|
+
source_commit: manifest.source_commit,
|
|
65
|
+
profile_count: manifest.profile_count,
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
emit.data(manifest);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function parseAdapters(value: string): Adapter[] {
|
|
74
|
+
if (value === "all") return ["claude-code", "cursor", "codex"];
|
|
75
|
+
if (value === "claude-code" || value === "cursor" || value === "codex") return [value];
|
|
76
|
+
throw new Error(`unsupported adapter '${value}' (expected claude-code, cursor, codex, or all)`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function enrichBundle(bundle: ReturnType<typeof buildInstructionBundle>, coordRoot: string) {
|
|
80
|
+
const components = bundle.components.map((component) => enrichComponent(component, coordRoot));
|
|
81
|
+
const canonicalSources = bundle.canonical_sources.map((component) =>
|
|
82
|
+
enrichComponent(component, coordRoot),
|
|
83
|
+
);
|
|
84
|
+
return {
|
|
85
|
+
...bundle,
|
|
86
|
+
coord_root: ".",
|
|
87
|
+
components,
|
|
88
|
+
canonical_sources: canonicalSources,
|
|
89
|
+
totals: totals(components),
|
|
90
|
+
canonical_source_totals: totals(canonicalSources),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function enrichComponent(component: InstructionBundleComponent, coordRoot: string) {
|
|
95
|
+
const bytes = readFileSync(resolve(coordRoot, component.path));
|
|
96
|
+
const text = bytes.includes(0) ? null : bytes.toString("utf8");
|
|
97
|
+
return {
|
|
98
|
+
...component,
|
|
99
|
+
chars: text?.length ?? null,
|
|
100
|
+
tokens: text === null ? null : countTokens(text),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function totals(components: ReturnType<typeof enrichComponent>[]) {
|
|
105
|
+
const roles = ["always_loaded", "just_in_time", "runtime_config"] as const;
|
|
106
|
+
return {
|
|
107
|
+
files: components.length,
|
|
108
|
+
bytes: components.reduce((sum, component) => sum + component.bytes, 0),
|
|
109
|
+
tokens: components.reduce((sum, component) => sum + (component.tokens ?? 0), 0),
|
|
110
|
+
by_role: Object.fromEntries(
|
|
111
|
+
roles.map((role) => {
|
|
112
|
+
const selected = components.filter((component) => component.role === role);
|
|
113
|
+
return [
|
|
114
|
+
role,
|
|
115
|
+
{
|
|
116
|
+
files: selected.length,
|
|
117
|
+
bytes: selected.reduce((sum, component) => sum + component.bytes, 0),
|
|
118
|
+
tokens: selected.reduce((sum, component) => sum + (component.tokens ?? 0), 0),
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
}),
|
|
122
|
+
),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function gitHead(root: string): string | null {
|
|
127
|
+
const result = spawnSync("git", ["rev-parse", "HEAD"], { cwd: root, encoding: "utf8" });
|
|
128
|
+
return result.status === 0 ? result.stdout.trim() : null;
|
|
129
|
+
}
|
package/src/commands/journal.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { existsSync, readdirSync, readFileSync, statSync, unlinkSync, watch } fr
|
|
|
2
2
|
import { resolve as resolvePath } from "node:path";
|
|
3
3
|
import type { Command } from "commander";
|
|
4
4
|
import type { EmitContext } from "../commander.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { monorepoRoot } from "../core/agents/index.ts";
|
|
6
|
+
import { readLiveCoordinationRow } from "../core/agents/state/live-coordination-view.ts";
|
|
6
7
|
import { resolveBinName } from "../core/config.ts";
|
|
7
8
|
import {
|
|
8
9
|
appendEntry,
|
|
@@ -53,17 +54,6 @@ export function registerJournalCommand(program: Command, emitParam: EmitContext)
|
|
|
53
54
|
try {
|
|
54
55
|
const owner = currentOwnerOrThrow();
|
|
55
56
|
const doc = appendEntry(owner, cat, body);
|
|
56
|
-
const hb = readHeartbeat(owner);
|
|
57
|
-
emitCanonical({
|
|
58
|
-
type: "state.journal_append",
|
|
59
|
-
owner,
|
|
60
|
-
session: hb?.session_id ?? owner,
|
|
61
|
-
adapter: normalizeAdapter(hb?.platform),
|
|
62
|
-
data: {
|
|
63
|
-
category: cat,
|
|
64
|
-
body_summary: body.length > 1000 ? `${body.slice(0, 997)}...` : body,
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
57
|
emit.data({
|
|
68
58
|
instance_id: owner,
|
|
69
59
|
name: doc.header.name,
|
|
@@ -341,7 +331,8 @@ function runRead(opts: { name?: string; owner?: string; archive?: string; limit:
|
|
|
341
331
|
process.exit(1);
|
|
342
332
|
}
|
|
343
333
|
|
|
344
|
-
const
|
|
334
|
+
const root = monorepoRoot();
|
|
335
|
+
const hb = root ? readLiveCoordinationRow(root, owner) : null;
|
|
345
336
|
const staleBanner = renderStaleBannerIfNeeded(hb?.last_heartbeat);
|
|
346
337
|
process.stdout.write(`${staleBanner + renderJournal(doc, limit)}\n`); // lint-ok-emission: pretty render, multi-line markdown for direct TTY/pipe consumption
|
|
347
338
|
}
|