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
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
export const DOCS_METADATA_SCHEMA_V2 = "harnery-doc/v2";
|
|
2
|
+
export const DOCS_METADATA_TYPES = [
|
|
3
|
+
"plan",
|
|
4
|
+
"issue",
|
|
5
|
+
"handoff",
|
|
6
|
+
"runbook",
|
|
7
|
+
"topic",
|
|
8
|
+
"audit",
|
|
9
|
+
"book",
|
|
10
|
+
"entity",
|
|
11
|
+
"concept",
|
|
12
|
+
"query",
|
|
13
|
+
"page",
|
|
14
|
+
"inquiry",
|
|
15
|
+
"quote-sheet",
|
|
16
|
+
"weekly-post",
|
|
17
|
+
"synced-page",
|
|
18
|
+
];
|
|
19
|
+
const RFC3339_UTC_SECONDS = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
|
|
20
|
+
const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
21
|
+
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
22
|
+
const PLAN_STATUSES = new Set(["proposed", "in-progress", "shipped", "abandoned"]);
|
|
23
|
+
const ISSUE_STATUSES = new Set(["open", "resolved", "wontfix"]);
|
|
24
|
+
const HANDOFF_STATUSES = new Set(["open", "resolved", "abandoned"]);
|
|
25
|
+
const ISSUE_SEVERITIES = new Set(["low", "medium", "high", "critical"]);
|
|
26
|
+
const LIFECYCLE_TYPES = new Set(["plan", "issue", "handoff"]);
|
|
27
|
+
const WIKI_TYPES = new Set(["book", "entity", "concept", "query", "page"]);
|
|
28
|
+
const SUPPORTED_TYPES = new Set(DOCS_METADATA_TYPES);
|
|
29
|
+
const BASE_FIELDS = new Set([
|
|
30
|
+
"schema",
|
|
31
|
+
"type",
|
|
32
|
+
"created_at",
|
|
33
|
+
"updated_at",
|
|
34
|
+
"owner",
|
|
35
|
+
"summary",
|
|
36
|
+
"tags",
|
|
37
|
+
"relations",
|
|
38
|
+
"access",
|
|
39
|
+
]);
|
|
40
|
+
const PROFILE_FIELDS = {
|
|
41
|
+
lifecycle: new Set([
|
|
42
|
+
...BASE_FIELDS,
|
|
43
|
+
"status",
|
|
44
|
+
"status_changed_at",
|
|
45
|
+
"status_note",
|
|
46
|
+
"severity",
|
|
47
|
+
"resolved_at",
|
|
48
|
+
"affected",
|
|
49
|
+
"resolution",
|
|
50
|
+
]),
|
|
51
|
+
runbook: new Set([...BASE_FIELDS, "title", "audience", "source", "reviewed_at", "review_due_at"]),
|
|
52
|
+
wiki: new Set([
|
|
53
|
+
...BASE_FIELDS,
|
|
54
|
+
"title",
|
|
55
|
+
"category",
|
|
56
|
+
"aliases",
|
|
57
|
+
"source_count",
|
|
58
|
+
"provenance",
|
|
59
|
+
"primary_entity",
|
|
60
|
+
"source_pages",
|
|
61
|
+
"source_tokens",
|
|
62
|
+
"top_entities",
|
|
63
|
+
]),
|
|
64
|
+
synced: new Set([
|
|
65
|
+
...BASE_FIELDS,
|
|
66
|
+
"title",
|
|
67
|
+
"handle",
|
|
68
|
+
"published",
|
|
69
|
+
"source",
|
|
70
|
+
"source_updated_at",
|
|
71
|
+
"source_id",
|
|
72
|
+
"source_template",
|
|
73
|
+
]),
|
|
74
|
+
"quote-sheet": new Set([
|
|
75
|
+
...BASE_FIELDS,
|
|
76
|
+
"title",
|
|
77
|
+
"status",
|
|
78
|
+
"product",
|
|
79
|
+
"variant",
|
|
80
|
+
"sku",
|
|
81
|
+
"manufacturer",
|
|
82
|
+
"customer",
|
|
83
|
+
"bid_id",
|
|
84
|
+
"drive_file_id",
|
|
85
|
+
"drive_title",
|
|
86
|
+
"quote_date",
|
|
87
|
+
"revision",
|
|
88
|
+
"batch_size",
|
|
89
|
+
"order_size",
|
|
90
|
+
"price",
|
|
91
|
+
"source_pdf",
|
|
92
|
+
"claims",
|
|
93
|
+
]),
|
|
94
|
+
"weekly-post": new Set([...BASE_FIELDS, "title", "status", "week", "coverage"]),
|
|
95
|
+
inquiry: new Set([
|
|
96
|
+
...BASE_FIELDS,
|
|
97
|
+
"title",
|
|
98
|
+
"status",
|
|
99
|
+
"status_changed_at",
|
|
100
|
+
"resolved_at",
|
|
101
|
+
"severity",
|
|
102
|
+
"affected",
|
|
103
|
+
]),
|
|
104
|
+
general: BASE_FIELDS,
|
|
105
|
+
};
|
|
106
|
+
const LIFECYCLE_FIELDS = {
|
|
107
|
+
plan: new Set([...BASE_FIELDS, "status", "status_changed_at", "status_note"]),
|
|
108
|
+
issue: new Set([
|
|
109
|
+
...BASE_FIELDS,
|
|
110
|
+
"status",
|
|
111
|
+
"status_changed_at",
|
|
112
|
+
"status_note",
|
|
113
|
+
"severity",
|
|
114
|
+
"resolved_at",
|
|
115
|
+
"affected",
|
|
116
|
+
]),
|
|
117
|
+
handoff: new Set([...BASE_FIELDS, "status", "status_changed_at", "status_note", "resolution"]),
|
|
118
|
+
};
|
|
119
|
+
function isRecord(value) {
|
|
120
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
121
|
+
}
|
|
122
|
+
function add(issues, severity, code, field, message) {
|
|
123
|
+
issues.push({ severity, code, field, message });
|
|
124
|
+
}
|
|
125
|
+
export function docsMetadataProfileForType(type) {
|
|
126
|
+
if (LIFECYCLE_TYPES.has(type))
|
|
127
|
+
return "lifecycle";
|
|
128
|
+
if (type === "runbook")
|
|
129
|
+
return "runbook";
|
|
130
|
+
if (WIKI_TYPES.has(type))
|
|
131
|
+
return "wiki";
|
|
132
|
+
if (type === "synced-page")
|
|
133
|
+
return "synced";
|
|
134
|
+
if (type === "quote-sheet")
|
|
135
|
+
return "quote-sheet";
|
|
136
|
+
if (type === "weekly-post")
|
|
137
|
+
return "weekly-post";
|
|
138
|
+
if (type === "inquiry")
|
|
139
|
+
return "inquiry";
|
|
140
|
+
return "general";
|
|
141
|
+
}
|
|
142
|
+
export function isDocsMetadataType(value) {
|
|
143
|
+
return typeof value === "string" && SUPPORTED_TYPES.has(value);
|
|
144
|
+
}
|
|
145
|
+
function requireString(data, field, issues) {
|
|
146
|
+
const value = data[field];
|
|
147
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
148
|
+
add(issues, "error", "required_string", field, `${field} must be a non-empty string`);
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
function validateTimestamp(data, field, issues, required = true) {
|
|
154
|
+
const value = data[field];
|
|
155
|
+
if (value === undefined && !required)
|
|
156
|
+
return null;
|
|
157
|
+
if (typeof value !== "string" || !RFC3339_UTC_SECONDS.test(value)) {
|
|
158
|
+
add(issues, "error", "invalid_timestamp", field, `${field} must use RFC 3339 UTC seconds, for example 2026-08-19T19:47:53Z`);
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
const parsed = Date.parse(value);
|
|
162
|
+
if (Number.isNaN(parsed) || new Date(parsed).toISOString().replace(".000Z", "Z") !== value) {
|
|
163
|
+
add(issues, "error", "invalid_timestamp", field, `${field} is not a real timestamp`);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return parsed;
|
|
167
|
+
}
|
|
168
|
+
function validateOwner(data, issues, required = false) {
|
|
169
|
+
if (data.owner === undefined && !required)
|
|
170
|
+
return;
|
|
171
|
+
const owner = requireString(data, "owner", issues);
|
|
172
|
+
if (owner && !SLUG.test(owner)) {
|
|
173
|
+
add(issues, "error", "invalid_owner", "owner", "owner must be a lowercase kebab-case id");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function validateSummary(data, issues, required = false) {
|
|
177
|
+
if (data.summary === undefined && !required)
|
|
178
|
+
return;
|
|
179
|
+
requireString(data, "summary", issues);
|
|
180
|
+
}
|
|
181
|
+
function validateOptionalString(data, field, issues) {
|
|
182
|
+
if (data[field] !== undefined)
|
|
183
|
+
requireString(data, field, issues);
|
|
184
|
+
}
|
|
185
|
+
function validateStringList(value, field, issues, itemPattern) {
|
|
186
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !item.trim())) {
|
|
187
|
+
add(issues, "error", "invalid_list", field, `${field} must be a YAML list of strings`);
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const items = value;
|
|
191
|
+
if (new Set(items).size !== items.length) {
|
|
192
|
+
add(issues, "error", "duplicate_list_item", field, `${field} contains duplicate values`);
|
|
193
|
+
}
|
|
194
|
+
if (itemPattern) {
|
|
195
|
+
for (const item of items) {
|
|
196
|
+
if (!itemPattern.test(item)) {
|
|
197
|
+
add(issues, "error", "invalid_list_item", field, `${field} contains invalid value '${item}'`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return items;
|
|
202
|
+
}
|
|
203
|
+
function validateRelations(data, issues) {
|
|
204
|
+
if (data.relations === undefined)
|
|
205
|
+
return;
|
|
206
|
+
if (!isRecord(data.relations)) {
|
|
207
|
+
add(issues, "error", "invalid_relations", "relations", "relations must be a YAML mapping");
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const allowed = new Set(["depends_on", "supersedes", "superseded_by", "continues", "related"]);
|
|
211
|
+
for (const [key, value] of Object.entries(data.relations)) {
|
|
212
|
+
if (!allowed.has(key)) {
|
|
213
|
+
add(issues, "error", "unknown_relation", `relations.${key}`, `unknown relation '${key}'`);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
validateStringList(value, `relations.${key}`, issues);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function validateAccess(data, issues) {
|
|
220
|
+
if (data.access === undefined)
|
|
221
|
+
return;
|
|
222
|
+
if (!isRecord(data.access)) {
|
|
223
|
+
add(issues, "error", "invalid_access", "access", "access must be a YAML mapping");
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const allowed = new Set(["roles", "viewers"]);
|
|
227
|
+
for (const key of Object.keys(data.access)) {
|
|
228
|
+
if (!allowed.has(key)) {
|
|
229
|
+
add(issues, "error", "unknown_access_field", `access.${key}`, `unknown access field '${key}'`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (data.access.roles !== undefined) {
|
|
233
|
+
validateStringList(data.access.roles, "access.roles", issues, SLUG);
|
|
234
|
+
}
|
|
235
|
+
if (data.access.viewers !== undefined) {
|
|
236
|
+
validateStringList(data.access.viewers, "access.viewers", issues, EMAIL);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function validateLifecycle(data, type, createdAt, updatedAt, issues) {
|
|
240
|
+
const status = requireString(data, "status", issues);
|
|
241
|
+
const allowed = type === "plan" ? PLAN_STATUSES : type === "issue" ? ISSUE_STATUSES : HANDOFF_STATUSES;
|
|
242
|
+
if (status && !allowed.has(status)) {
|
|
243
|
+
add(issues, "error", "invalid_status", "status", `status '${status}' is invalid for ${type}`);
|
|
244
|
+
}
|
|
245
|
+
const changedAt = validateTimestamp(data, "status_changed_at", issues);
|
|
246
|
+
if (createdAt !== null && changedAt !== null && changedAt < createdAt) {
|
|
247
|
+
add(issues, "error", "timestamp_order", "status_changed_at", "status_changed_at cannot precede created_at");
|
|
248
|
+
}
|
|
249
|
+
if (updatedAt !== null && changedAt !== null && changedAt > updatedAt) {
|
|
250
|
+
add(issues, "error", "timestamp_order", "status_changed_at", "status_changed_at cannot be later than updated_at");
|
|
251
|
+
}
|
|
252
|
+
validateOptionalString(data, "status_note", issues);
|
|
253
|
+
if (type === "issue") {
|
|
254
|
+
const severity = requireString(data, "severity", issues);
|
|
255
|
+
if (severity && !ISSUE_SEVERITIES.has(severity)) {
|
|
256
|
+
add(issues, "error", "invalid_severity", "severity", `severity '${severity}' must be low, medium, high, or critical`);
|
|
257
|
+
}
|
|
258
|
+
if (data.affected !== undefined)
|
|
259
|
+
validateStringList(data.affected, "affected", issues);
|
|
260
|
+
const resolvedAt = validateTimestamp(data, "resolved_at", issues, status === "resolved");
|
|
261
|
+
if (status !== "resolved" && resolvedAt !== null) {
|
|
262
|
+
add(issues, "error", "unexpected_resolved_at", "resolved_at", "resolved_at is only valid when status is resolved");
|
|
263
|
+
}
|
|
264
|
+
if (createdAt !== null && resolvedAt !== null && resolvedAt < createdAt) {
|
|
265
|
+
add(issues, "error", "timestamp_order", "resolved_at", "resolved_at cannot precede created_at");
|
|
266
|
+
}
|
|
267
|
+
if (updatedAt !== null && resolvedAt !== null && resolvedAt > updatedAt) {
|
|
268
|
+
add(issues, "error", "timestamp_order", "resolved_at", "resolved_at cannot be later than updated_at");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (type === "handoff") {
|
|
272
|
+
const terminal = status === "resolved" || status === "abandoned";
|
|
273
|
+
if (terminal && !isRecord(data.resolution)) {
|
|
274
|
+
add(issues, "error", "missing_resolution", "resolution", "terminal handoffs require a resolution mapping");
|
|
275
|
+
}
|
|
276
|
+
if (!terminal && data.resolution !== undefined) {
|
|
277
|
+
add(issues, "error", "unexpected_resolution", "resolution", "open handoffs cannot carry resolution metadata");
|
|
278
|
+
}
|
|
279
|
+
if (isRecord(data.resolution)) {
|
|
280
|
+
if (typeof data.resolution.outcome !== "string" || !data.resolution.outcome.trim()) {
|
|
281
|
+
add(issues, "error", "invalid_resolution", "resolution.outcome", "resolution.outcome must be a non-empty string");
|
|
282
|
+
}
|
|
283
|
+
if (data.resolution.commits !== undefined) {
|
|
284
|
+
validateStringList(data.resolution.commits, "resolution.commits", issues);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function validateRunbook(data, updatedAt, issues) {
|
|
290
|
+
validateOptionalString(data, "title", issues);
|
|
291
|
+
validateOptionalString(data, "audience", issues);
|
|
292
|
+
validateOptionalString(data, "source", issues);
|
|
293
|
+
const reviewedAt = validateTimestamp(data, "reviewed_at", issues);
|
|
294
|
+
const reviewDueAt = validateTimestamp(data, "review_due_at", issues);
|
|
295
|
+
if (reviewedAt !== null && reviewDueAt !== null && reviewDueAt <= reviewedAt) {
|
|
296
|
+
add(issues, "error", "timestamp_order", "review_due_at", "review_due_at must be later than reviewed_at");
|
|
297
|
+
}
|
|
298
|
+
if (updatedAt !== null && reviewedAt !== null && reviewedAt > updatedAt) {
|
|
299
|
+
add(issues, "error", "timestamp_order", "reviewed_at", "reviewed_at cannot be later than updated_at");
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function validateWiki(data, issues) {
|
|
303
|
+
requireString(data, "title", issues);
|
|
304
|
+
requireString(data, "category", issues);
|
|
305
|
+
if (data.aliases !== undefined)
|
|
306
|
+
validateStringList(data.aliases, "aliases", issues);
|
|
307
|
+
if (typeof data.source_count !== "number" ||
|
|
308
|
+
!Number.isInteger(data.source_count) ||
|
|
309
|
+
data.source_count < 0) {
|
|
310
|
+
add(issues, "error", "invalid_source_count", "source_count", "source_count must be a non-negative integer");
|
|
311
|
+
}
|
|
312
|
+
if (!isRecord(data.provenance)) {
|
|
313
|
+
add(issues, "error", "invalid_provenance", "provenance", "provenance must be a mapping");
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
validateStringList(data.provenance.sources, "provenance.sources", issues);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function validateSynced(data, issues) {
|
|
320
|
+
requireString(data, "title", issues);
|
|
321
|
+
requireString(data, "handle", issues);
|
|
322
|
+
requireString(data, "source", issues);
|
|
323
|
+
validateTimestamp(data, "source_updated_at", issues);
|
|
324
|
+
if (typeof data.published !== "boolean") {
|
|
325
|
+
add(issues, "error", "invalid_boolean", "published", "published must be a boolean");
|
|
326
|
+
}
|
|
327
|
+
validateOptionalString(data, "source_id", issues);
|
|
328
|
+
validateOptionalString(data, "source_template", issues);
|
|
329
|
+
}
|
|
330
|
+
function validateQuoteSheet(data, issues) {
|
|
331
|
+
for (const field of ["title", "status", "product", "manufacturer", "quote_date", "source_pdf"]) {
|
|
332
|
+
requireString(data, field, issues);
|
|
333
|
+
}
|
|
334
|
+
if (typeof data.status === "string" &&
|
|
335
|
+
!new Set(["not-final", "unsigned", "signed", "final"]).has(data.status)) {
|
|
336
|
+
add(issues, "error", "invalid_status", "status", "quote-sheet status must be not-final, unsigned, signed, or final");
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function validateWeeklyPost(data, issues) {
|
|
340
|
+
for (const field of ["title", "status", "week", "coverage"])
|
|
341
|
+
requireString(data, field, issues);
|
|
342
|
+
}
|
|
343
|
+
function validateInquiry(data, createdAt, updatedAt, issues) {
|
|
344
|
+
requireString(data, "title", issues);
|
|
345
|
+
const status = requireString(data, "status", issues);
|
|
346
|
+
if (status && !new Set(["open", "resolved", "abandoned"]).has(status)) {
|
|
347
|
+
add(issues, "error", "invalid_status", "status", `inquiry status '${status}' is invalid`);
|
|
348
|
+
}
|
|
349
|
+
const changedAt = validateTimestamp(data, "status_changed_at", issues);
|
|
350
|
+
if (createdAt !== null && changedAt !== null && changedAt < createdAt) {
|
|
351
|
+
add(issues, "error", "timestamp_order", "status_changed_at", "status_changed_at cannot precede created_at");
|
|
352
|
+
}
|
|
353
|
+
if (updatedAt !== null && changedAt !== null && changedAt > updatedAt) {
|
|
354
|
+
add(issues, "error", "timestamp_order", "status_changed_at", "status_changed_at cannot be later than updated_at");
|
|
355
|
+
}
|
|
356
|
+
const resolvedAt = validateTimestamp(data, "resolved_at", issues, status === "resolved");
|
|
357
|
+
if (status !== "resolved" && resolvedAt !== null) {
|
|
358
|
+
add(issues, "error", "unexpected_resolved_at", "resolved_at", "resolved_at is only valid when status is resolved");
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/** Validate one parsed YAML frontmatter mapping against the harnery-doc/v2 contract. */
|
|
362
|
+
export function validateDocsMetadataV2(data) {
|
|
363
|
+
const issues = [];
|
|
364
|
+
if (data.schema !== DOCS_METADATA_SCHEMA_V2) {
|
|
365
|
+
add(issues, "error", "invalid_schema", "schema", `schema must be '${DOCS_METADATA_SCHEMA_V2}'`);
|
|
366
|
+
}
|
|
367
|
+
const rawType = requireString(data, "type", issues);
|
|
368
|
+
const type = rawType && isDocsMetadataType(rawType) ? rawType : null;
|
|
369
|
+
if (rawType && !type) {
|
|
370
|
+
add(issues, "error", "invalid_type", "type", `unsupported document type '${rawType}'`);
|
|
371
|
+
}
|
|
372
|
+
const profile = type ? docsMetadataProfileForType(type) : null;
|
|
373
|
+
const createdAt = validateTimestamp(data, "created_at", issues);
|
|
374
|
+
const updatedAt = validateTimestamp(data, "updated_at", issues);
|
|
375
|
+
if (createdAt !== null && updatedAt !== null && updatedAt < createdAt) {
|
|
376
|
+
add(issues, "error", "timestamp_order", "updated_at", "updated_at cannot precede created_at");
|
|
377
|
+
}
|
|
378
|
+
if (data.tags !== undefined)
|
|
379
|
+
validateStringList(data.tags, "tags", issues, SLUG);
|
|
380
|
+
const lifecycleType = type !== null && LIFECYCLE_TYPES.has(type);
|
|
381
|
+
validateOwner(data, issues, lifecycleType || type === "runbook" || type === "inquiry");
|
|
382
|
+
validateSummary(data, issues, type !== null);
|
|
383
|
+
validateRelations(data, issues);
|
|
384
|
+
validateAccess(data, issues);
|
|
385
|
+
if (profile) {
|
|
386
|
+
const allowed = type && LIFECYCLE_TYPES.has(type)
|
|
387
|
+
? LIFECYCLE_FIELDS[type]
|
|
388
|
+
: PROFILE_FIELDS[profile];
|
|
389
|
+
for (const key of Object.keys(data)) {
|
|
390
|
+
if (!allowed.has(key) && !key.startsWith("x_")) {
|
|
391
|
+
add(issues, "error", "unknown_field", key, `unknown ${profile} metadata field '${key}'`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (type && LIFECYCLE_TYPES.has(type)) {
|
|
396
|
+
validateLifecycle(data, type, createdAt, updatedAt, issues);
|
|
397
|
+
}
|
|
398
|
+
else if (type === "runbook") {
|
|
399
|
+
validateRunbook(data, updatedAt, issues);
|
|
400
|
+
}
|
|
401
|
+
else if (type && WIKI_TYPES.has(type)) {
|
|
402
|
+
validateWiki(data, issues);
|
|
403
|
+
}
|
|
404
|
+
else if (type === "synced-page") {
|
|
405
|
+
validateSynced(data, issues);
|
|
406
|
+
}
|
|
407
|
+
else if (type === "quote-sheet") {
|
|
408
|
+
validateQuoteSheet(data, issues);
|
|
409
|
+
}
|
|
410
|
+
else if (type === "weekly-post") {
|
|
411
|
+
validateWeeklyPost(data, issues);
|
|
412
|
+
}
|
|
413
|
+
else if (type === "inquiry") {
|
|
414
|
+
validateInquiry(data, createdAt, updatedAt, issues);
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
valid: issues.every((issue) => issue.severity !== "error"),
|
|
418
|
+
profile,
|
|
419
|
+
issues,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
export function isDocsMetadataV2(data) {
|
|
423
|
+
return data.schema === DOCS_METADATA_SCHEMA_V2;
|
|
424
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DocsNewOpts {
|
|
2
|
+
type: "plan" | "issue" | "handoff" | "runbook" | "topic";
|
|
3
|
+
path: string;
|
|
4
|
+
summary: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
status?: string;
|
|
7
|
+
severity?: string;
|
|
8
|
+
now?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createDocsFile(repoRoot: string, opts: DocsNewOpts): string;
|
|
11
|
+
//# sourceMappingURL=docs-new.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-new.d.ts","sourceRoot":"","sources":["../../src/lib/docs-new.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CA8C1E"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
3
|
+
import { dump as dumpYaml, JSON_SCHEMA } from "js-yaml";
|
|
4
|
+
import { validateDocsMetadataV2 } from "./docs-metadata-v2.js";
|
|
5
|
+
export function createDocsFile(repoRoot, opts) {
|
|
6
|
+
const file = resolve(repoRoot, opts.path);
|
|
7
|
+
const relativePath = relative(resolve(repoRoot), file);
|
|
8
|
+
if (!relativePath || relativePath.startsWith("..") || isAbsolute(relativePath)) {
|
|
9
|
+
throw new Error("document path must stay inside the repository");
|
|
10
|
+
}
|
|
11
|
+
if (!file.endsWith(".md"))
|
|
12
|
+
throw new Error("document path must end in .md");
|
|
13
|
+
if (existsSync(file))
|
|
14
|
+
throw new Error(`document already exists: ${opts.path}`);
|
|
15
|
+
const now = opts.now ?? new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
16
|
+
const type = opts.type;
|
|
17
|
+
const data = {
|
|
18
|
+
schema: "harnery-doc/v2",
|
|
19
|
+
type,
|
|
20
|
+
created_at: now,
|
|
21
|
+
updated_at: now,
|
|
22
|
+
owner: opts.owner,
|
|
23
|
+
summary: opts.summary,
|
|
24
|
+
};
|
|
25
|
+
if (type === "plan" || type === "issue" || type === "handoff") {
|
|
26
|
+
data.status = opts.status ?? (type === "plan" ? "proposed" : "open");
|
|
27
|
+
data.status_changed_at = now;
|
|
28
|
+
}
|
|
29
|
+
if (type === "issue")
|
|
30
|
+
data.severity = opts.severity ?? "medium";
|
|
31
|
+
if (type === "runbook") {
|
|
32
|
+
data.reviewed_at = now;
|
|
33
|
+
const due = new Date(now);
|
|
34
|
+
due.setUTCDate(due.getUTCDate() + 180);
|
|
35
|
+
data.review_due_at = due.toISOString().replace(".000Z", "Z");
|
|
36
|
+
}
|
|
37
|
+
const validation = validateDocsMetadataV2(data);
|
|
38
|
+
if (!validation.valid) {
|
|
39
|
+
throw new Error(validation.issues.map((issue) => `${issue.field}: ${issue.message}`).join("; "));
|
|
40
|
+
}
|
|
41
|
+
const yaml = dumpYaml(data, { schema: JSON_SCHEMA, noRefs: true, lineWidth: -1 }).trimEnd();
|
|
42
|
+
const title = opts.path
|
|
43
|
+
.split("/")
|
|
44
|
+
.at(-1)
|
|
45
|
+
.replace(/\.md$/, "")
|
|
46
|
+
.replace(/^\d{4}-\d{2}-\d{2}_/, "")
|
|
47
|
+
.replace(/[-_]/g, " ")
|
|
48
|
+
.replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
49
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
50
|
+
writeFileSync(file, `---\n${yaml}\n---\n\n# ${title}\n\n${opts.summary}\n`, "utf8");
|
|
51
|
+
return file;
|
|
52
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-sweep.d.ts","sourceRoot":"","sources":["../../src/lib/docs-sweep.ts"],"names":[],"mappings":"AAWA,wBAAgB,eAAe,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAG/F;AAaD;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,SAAS,GACjB,cAAc,GACd,oBAAoB,GACpB,iBAAiB,GACjB,cAAc,GACd,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,CAAC;AAUxB,KAAK,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAmB,GAAG,MAAM,CAgBlF;
|
|
1
|
+
{"version":3,"file":"docs-sweep.d.ts","sourceRoot":"","sources":["../../src/lib/docs-sweep.ts"],"names":[],"mappings":"AAWA,wBAAgB,eAAe,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAG/F;AAaD;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,SAAS,GACjB,cAAc,GACd,oBAAoB,GACpB,iBAAiB,GACjB,cAAc,GACd,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,CAAC;AAUxB,KAAK,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAmB,GAAG,MAAM,CAgBlF;AAqOD,wBAAsB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CA4BpE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAIzD"}
|
package/dist/lib/docs-sweep.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync as __existsSyncForDocs } from "node:fs";
|
|
2
2
|
import { resolve as __resolveForDocs } from "node:path";
|
|
3
|
-
import { readDocStatus } from "./docs-frontmatter.js";
|
|
3
|
+
import { parseFrontmatter, readDocStatus } from "./docs-frontmatter.js";
|
|
4
4
|
import { sh } from "./exec.js";
|
|
5
5
|
// Module-level docs context, initialized by initDocsContext() before any
|
|
6
6
|
// other function in this file is called. The repo root + submodule list
|
|
@@ -17,7 +17,7 @@ function submodulePath(name) {
|
|
|
17
17
|
function isSubmoduleInitialized(name) {
|
|
18
18
|
return __existsSyncForDocs(__resolveForDocs(REPO_ROOT, name, ".git"));
|
|
19
19
|
}
|
|
20
|
-
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
20
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
21
21
|
import { join, relative } from "node:path";
|
|
22
22
|
const STALLED_PLAN_DAYS = 90;
|
|
23
23
|
const UNARCHIVED_SHIPPED_DAYS = 180;
|
|
@@ -97,7 +97,19 @@ function walkMdFiles(dir, skipReadme = false) {
|
|
|
97
97
|
}
|
|
98
98
|
return out;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function metadataAgeDays(file, field, nowMs = Date.now()) {
|
|
101
|
+
try {
|
|
102
|
+
const value = parseFrontmatter(readFileSync(file, "utf8")).data[field];
|
|
103
|
+
if (typeof value !== "string")
|
|
104
|
+
return null;
|
|
105
|
+
const parsed = Date.parse(value);
|
|
106
|
+
return Number.isNaN(parsed) ? null : Math.floor((nowMs - parsed) / (1000 * 60 * 60 * 24));
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function sweepPlans(repoName, repoPath, items) {
|
|
101
113
|
const plansDir = join(repoPath, "docs", "plans");
|
|
102
114
|
if (!existsSync(plansDir))
|
|
103
115
|
return;
|
|
@@ -106,7 +118,7 @@ function sweepPlans(repoName, repoPath, ages, items) {
|
|
|
106
118
|
const displayPath = join(repoName === "(root)" ? "" : repoName, rel);
|
|
107
119
|
const isArchived = rel.includes("/archive/");
|
|
108
120
|
const status = readDocStatus(full, "plan");
|
|
109
|
-
const age =
|
|
121
|
+
const age = metadataAgeDays(full, "status_changed_at");
|
|
110
122
|
if (age == null)
|
|
111
123
|
continue;
|
|
112
124
|
if (!isArchived && status === "in-progress" && age > STALLED_PLAN_DAYS) {
|
|
@@ -115,7 +127,7 @@ function sweepPlans(repoName, repoPath, ages, items) {
|
|
|
115
127
|
repo: repoName,
|
|
116
128
|
path: displayPath,
|
|
117
129
|
ageDays: age,
|
|
118
|
-
message: `plan
|
|
130
|
+
message: `plan has remained in-progress for ${age}d; confirm it is still active or change status`,
|
|
119
131
|
});
|
|
120
132
|
}
|
|
121
133
|
if (!isArchived && status === "shipped" && age > UNARCHIVED_SHIPPED_DAYS) {
|
|
@@ -129,7 +141,7 @@ function sweepPlans(repoName, repoPath, ages, items) {
|
|
|
129
141
|
}
|
|
130
142
|
}
|
|
131
143
|
}
|
|
132
|
-
function sweepIssues(repoName, repoPath,
|
|
144
|
+
function sweepIssues(repoName, repoPath, items) {
|
|
133
145
|
const issuesDir = join(repoPath, "docs", "issues");
|
|
134
146
|
if (!existsSync(issuesDir))
|
|
135
147
|
return;
|
|
@@ -142,7 +154,7 @@ function sweepIssues(repoName, repoPath, ages, items) {
|
|
|
142
154
|
const status = readDocStatus(full, "issue");
|
|
143
155
|
if (status !== "open")
|
|
144
156
|
continue;
|
|
145
|
-
const age =
|
|
157
|
+
const age = metadataAgeDays(full, "status_changed_at");
|
|
146
158
|
if (age == null || age <= OPEN_ISSUE_DAYS)
|
|
147
159
|
continue;
|
|
148
160
|
items.push({
|
|
@@ -154,7 +166,7 @@ function sweepIssues(repoName, repoPath, ages, items) {
|
|
|
154
166
|
});
|
|
155
167
|
}
|
|
156
168
|
}
|
|
157
|
-
function sweepHandoffs(repoName, repoPath,
|
|
169
|
+
function sweepHandoffs(repoName, repoPath, items) {
|
|
158
170
|
const handoffsDir = join(repoPath, "docs", "handoffs");
|
|
159
171
|
if (!existsSync(handoffsDir))
|
|
160
172
|
return;
|
|
@@ -163,7 +175,7 @@ function sweepHandoffs(repoName, repoPath, ages, items) {
|
|
|
163
175
|
const status = readDocStatus(full, "handoff");
|
|
164
176
|
if (status !== "open")
|
|
165
177
|
continue;
|
|
166
|
-
const age =
|
|
178
|
+
const age = metadataAgeDays(full, "status_changed_at");
|
|
167
179
|
if (age == null || age <= COLD_HANDOFF_DAYS)
|
|
168
180
|
continue;
|
|
169
181
|
const displayPath = join(repoName === "(root)" ? "" : repoName, rel);
|
|
@@ -176,21 +188,26 @@ function sweepHandoffs(repoName, repoPath, ages, items) {
|
|
|
176
188
|
});
|
|
177
189
|
}
|
|
178
190
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
if (!existsSync(
|
|
182
|
-
return;
|
|
183
|
-
const age = ageDays(ages, "docs/runbook.md");
|
|
184
|
-
if (age == null || age <= RUNBOOK_DAYS)
|
|
191
|
+
function sweepRunbooks(repoName, repoPath, items) {
|
|
192
|
+
const docs = join(repoPath, "docs");
|
|
193
|
+
if (!existsSync(docs))
|
|
185
194
|
return;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
for (const runbook of walkMdFiles(docs)) {
|
|
196
|
+
const metadata = parseFrontmatter(readFileSync(runbook, "utf8")).data;
|
|
197
|
+
if (metadata.schema !== "harnery-doc/v2" || metadata.type !== "runbook")
|
|
198
|
+
continue;
|
|
199
|
+
const age = metadataAgeDays(runbook, "reviewed_at");
|
|
200
|
+
if (age == null || age <= RUNBOOK_DAYS)
|
|
201
|
+
continue;
|
|
202
|
+
const rel = relative(repoPath, runbook);
|
|
203
|
+
items.push({
|
|
204
|
+
kind: "runbook-unverified",
|
|
205
|
+
repo: repoName,
|
|
206
|
+
path: join(repoName === "(root)" ? "" : repoName, rel),
|
|
207
|
+
ageDays: age,
|
|
208
|
+
message: `runbook has not been reviewed for ${age}d; verify it with docs metadata sync --reviewed`,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
194
211
|
}
|
|
195
212
|
function sweepTopicDocs(repoName, repoPath, ages, items) {
|
|
196
213
|
const docsDir = join(repoPath, "docs");
|
|
@@ -275,10 +292,10 @@ export async function runSweep(opts) {
|
|
|
275
292
|
for (let i = 0; i < filtered.length; i++) {
|
|
276
293
|
const { name, path } = filtered[i];
|
|
277
294
|
const ages = ageMaps[i];
|
|
278
|
-
sweepPlans(name, path,
|
|
279
|
-
sweepIssues(name, path,
|
|
280
|
-
sweepHandoffs(name, path,
|
|
281
|
-
|
|
295
|
+
sweepPlans(name, path, items);
|
|
296
|
+
sweepIssues(name, path, items);
|
|
297
|
+
sweepHandoffs(name, path, items);
|
|
298
|
+
sweepRunbooks(name, path, items);
|
|
282
299
|
sweepTopicDocs(name, path, ages, items);
|
|
283
300
|
await sweepDecisions(name, path, ages, items);
|
|
284
301
|
}
|
|
@@ -293,7 +310,6 @@ export async function runSweep(opts) {
|
|
|
293
310
|
*/
|
|
294
311
|
export async function countColdHandoffs() {
|
|
295
312
|
const items = [];
|
|
296
|
-
|
|
297
|
-
sweepHandoffs("(root)", REPO_ROOT, ages, items);
|
|
313
|
+
sweepHandoffs("(root)", REPO_ROOT, items);
|
|
298
314
|
return items.length;
|
|
299
315
|
}
|