@cortexkit/opencode-magic-context 0.42.6 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/agents/dreamer.d.ts +7 -9
- package/dist/agents/dreamer.d.ts.map +1 -1
- package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/{announcement-8mgn61fw.js → announcement-1a8bvswd.js} +2 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/live-run-config.d.ts +12 -0
- package/dist/config/live-run-config.d.ts.map +1 -0
- package/dist/config/live-snapshot.d.ts +32 -0
- package/dist/config/live-snapshot.d.ts.map +1 -0
- package/dist/config/schema/magic-context.d.ts +12 -2
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-aktepwpz.js → conflict-warning-hook-956fkedc.js} +6 -4
- package/dist/{derive-budgets-v1fkhjjr.js → derive-budgets-b8ybssh9.js} +7 -3
- package/dist/features/builtin-commands/commands.d.ts +0 -4
- package/dist/features/builtin-commands/commands.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +6 -0
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +4 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-lease.d.ts +8 -0
- package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts +21 -0
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/context-authority.d.ts +9 -2
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +23 -0
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts +5 -1
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +51 -0
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/manual-summary.d.ts +7 -0
- package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/map-memories.d.ts +3 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/promote-primers.d.ts +8 -1
- package/dist/features/magic-context/dreamer/promote-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts +3 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts +5 -2
- package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +22 -13
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +9 -0
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +3 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -4
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +53 -2
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -0
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/tick-failure.d.ts +38 -0
- package/dist/features/magic-context/dreamer/tick-failure.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify.d.ts +4 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts +2 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-identity.d.ts +1 -0
- package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/memory-diagnostics.d.ts +6 -0
- package/dist/features/magic-context/memory/memory-diagnostics.d.ts.map +1 -0
- package/dist/features/magic-context/memory/memory-selection.d.ts +12 -0
- package/dist/features/magic-context/memory/memory-selection.d.ts.map +1 -0
- package/dist/features/magic-context/memory/memory-visibility.d.ts +46 -0
- package/dist/features/magic-context/memory/memory-visibility.d.ts.map +1 -0
- package/dist/features/magic-context/memory/mirror-reembed.d.ts +22 -0
- package/dist/features/magic-context/memory/mirror-reembed.d.ts.map +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts +9 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts +6 -2
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
- package/dist/features/magic-context/memory/transformers-remote-host.d.ts +6 -0
- package/dist/features/magic-context/memory/transformers-remote-host.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-web-entry.d.ts.map +1 -1
- package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +3 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +8 -3
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +7 -1
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/message-time-backfill.d.ts +19 -0
- package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -0
- package/dist/features/magic-context/migrations.d.ts +10 -6
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/mural/storage-mural.d.ts +5 -0
- package/dist/features/magic-context/mural/storage-mural.d.ts.map +1 -1
- package/dist/features/magic-context/opencode2-relabel.d.ts +132 -0
- package/dist/features/magic-context/opencode2-relabel.d.ts.map +1 -0
- package/dist/features/magic-context/overflow-detection.d.ts +3 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/protection-window.d.ts +1 -1
- package/dist/features/magic-context/protection-window.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +6 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-decision-calibration.d.ts +31 -0
- package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -0
- package/dist/features/magic-context/shadow-backfill-state.d.ts +1 -1
- package/dist/features/magic-context/shadow-backfill-state.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts +5 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-historian-runs.d.ts +4 -2
- package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +16 -2
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-notes.d.ts +1 -0
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage-replay-document.d.ts +2 -0
- package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
- package/dist/features/magic-context/storage-subagent-invocations.d.ts +1 -1
- package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +42 -4
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +2 -2
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts +95 -0
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -0
- package/dist/features/magic-context/subagent-token-capture.d.ts +1 -0
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
- package/dist/features/magic-context/tagger.d.ts +2 -0
- package/dist/features/magic-context/tagger.d.ts.map +1 -1
- package/dist/features/magic-context/tool-definition-tokens.d.ts +1 -0
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts +5 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
- package/dist/hooks/auto-update-checker/checker.d.ts +1 -0
- package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +10 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +19 -3
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +5 -4
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-off-transition.d.ts +1 -0
- package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts +3 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +8 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +19 -11
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +4 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/decay-render.d.ts +1 -0
- package/dist/hooks/magic-context/decay-render.d.ts.map +1 -1
- package/dist/hooks/magic-context/decision-calibration.d.ts +24 -0
- package/dist/hooks/magic-context/decision-calibration.d.ts.map +1 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts +2 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
- package/dist/hooks/magic-context/dropped-input-guard.d.ts +50 -4
- package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/embed-history-runner.d.ts +30 -0
- package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -0
- package/dist/hooks/magic-context/emergency-drop.d.ts +13 -8
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-payloads.d.ts +2 -1
- package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +2 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-no-fire-cause.d.ts +5 -0
- package/dist/hooks/magic-context/historian-no-fire-cause.d.ts.map +1 -0
- package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts +3 -0
- package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts +0 -3
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +4 -4
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +58 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts +38 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/legacy-compartments.d.ts +20 -0
- package/dist/hooks/magic-context/legacy-compartments.d.ts.map +1 -0
- package/dist/hooks/magic-context/live-session-state.d.ts +7 -7
- package/dist/hooks/magic-context/lkg-slot.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/m0-token-breakdown.d.ts +6 -0
- package/dist/hooks/magic-context/m0-token-breakdown.d.ts.map +1 -1
- package/dist/hooks/magic-context/maintenance-authority.d.ts +0 -1
- package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts +42 -0
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/postprocess-read-cache.d.ts +8 -0
- package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -0
- package/dist/hooks/magic-context/producer-window-guard.d.ts +16 -0
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-test-support.d.ts +14 -0
- package/dist/hooks/magic-context/producer-window-test-support.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +45 -10
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +4 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +6 -0
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +17 -39
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +26 -3
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts +1 -0
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +6 -7
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +21 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +63 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts +19 -12
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +52 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-sweep-policy.d.ts +50 -0
- package/dist/hooks/magic-context/tool-sweep-policy.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +20 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +9 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -3
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +37 -4
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-f9gem5cr.js → index-0ccmyzbj.js} +90 -10
- package/dist/index-1gtwrdc4.js +393 -0
- package/dist/{index-ntbmt6rq.js → index-4b30nf6z.js} +1 -1
- package/dist/index-6w9p73jz.js +170 -0
- package/dist/{index-4ftb5hcq.js → index-6z9g64js.js} +7 -1
- package/dist/{index-djp6rwz6.js → index-7wpwr2e2.js} +28002 -30125
- package/dist/index-9r1cbh9e.js +16 -0
- package/dist/{safe-notification-target-fepvcbsj.js → index-febg06dy.js} +6 -7
- package/dist/index-j7cnyvq1.js +5409 -0
- package/dist/{index-s61hh7gv.js → index-kpmmr8s0.js} +95 -73
- package/dist/{index-a9ssj59b.js → index-v8qr6tt2.js} +56 -16
- package/dist/{index-qp20p2py.js → index-wgzyeyf5.js} +1 -1
- package/dist/index-y5145x8k.js +619 -0
- package/dist/{index-ngjmj6xx.js → index-yc81txp4.js} +38 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6274 -3180
- package/dist/message-time-backfill-0ccvyk9n.js +109 -0
- package/dist/plugin/dream-timer.d.ts +13 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +5 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/memory-id-translation.d.ts +86 -0
- package/dist/plugin/memory-id-translation.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +10 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/rust-note-backend.d.ts +84 -0
- package/dist/plugin/rust-note-backend.d.ts.map +1 -0
- package/dist/plugin/tool-registry.d.ts +1 -0
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/read-session-chunk-z7fv0qjv.js +62 -0
- package/dist/recomp-orchestrator-r00aa5t3.js +21 -0
- package/dist/safe-notification-target-vrkjrbgb.js +10 -0
- package/dist/{send-session-notification-jbxknvar.js → send-session-notification-3warjyjp.js} +7 -3
- package/dist/shared/assistant-message-extractor.d.ts +6 -0
- package/dist/shared/assistant-message-extractor.d.ts.map +1 -1
- package/dist/shared/conflict-detector.d.ts +9 -4
- package/dist/shared/conflict-detector.d.ts.map +1 -1
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/hidden-variant-warnings.d.ts +5 -0
- package/dist/shared/hidden-variant-warnings.d.ts.map +1 -0
- package/dist/shared/host-limitations.d.ts +14 -0
- package/dist/shared/host-limitations.d.ts.map +1 -0
- package/dist/shared/keep-subagents.d.ts +1 -1
- package/dist/shared/keep-subagents.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts +1 -0
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/opencode-config-dir.d.ts +52 -0
- package/dist/shared/opencode-config-dir.d.ts.map +1 -1
- package/dist/shared/opencode-db-path.d.ts +15 -0
- package/dist/shared/opencode-db-path.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +5 -5
- package/dist/shared/rpc-server.d.ts +10 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +64 -5
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/status-detail-text.d.ts +1 -3
- package/dist/shared/status-detail-text.d.ts.map +1 -1
- package/dist/shared/status-summary.d.ts +7 -0
- package/dist/shared/status-summary.d.ts.map +1 -1
- package/dist/shared/status-view.d.ts +229 -0
- package/dist/shared/status-view.d.ts.map +1 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/tail-hygiene-status.d.ts +8 -0
- package/dist/shared/tail-hygiene-status.d.ts.map +1 -1
- package/dist/shared/test-temp-dir.d.ts +1 -1
- package/dist/shared/test-temp-dir.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +32 -7
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/shared/window-geometry.d.ts +3 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/{task-config-cv8k9y8r.js → task-config-mgf5nsh3.js} +1 -1
- package/dist/tools/ctx-expand/constants.d.ts +1 -1
- package/dist/tools/ctx-expand/constants.d.ts.map +1 -1
- package/dist/tools/ctx-expand/render.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/constants.d.ts +3 -1
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +2 -2
- package/dist/tools/ctx-note/constants.d.ts +1 -1
- package/dist/tools/ctx-note/constants.d.ts.map +1 -1
- package/dist/tools/ctx-note/render.d.ts +88 -0
- package/dist/tools/ctx-note/render.d.ts.map +1 -0
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/tools/ctx-search/constants.d.ts +1 -1
- package/dist/tools/ctx-search/constants.d.ts.map +1 -1
- package/dist/tools/ctx-search/date-range.d.ts +9 -0
- package/dist/tools/ctx-search/date-range.d.ts.map +1 -0
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/types.d.ts +2 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -1
- package/dist/tools/light-descriptions.d.ts +5 -5
- package/dist/tools/light-descriptions.d.ts.map +1 -1
- package/dist/tools/parameter-descriptions.d.ts +75 -0
- package/dist/tools/parameter-descriptions.d.ts.map +1 -0
- package/dist/transformers-node-wasm.js +1918 -826
- package/dist/transformers-web.js +1736 -636
- package/dist/{transformers.node-dpmf3wpx.js → transformers.node-3zqr6k1w.js} +4087 -2898
- package/dist/tui/data/context-db.d.ts +19 -7
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/dist/tui-compiled/data/context-db.d.ts +19 -7
- package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
- package/dist/v2/fold/host-media.d.ts +36 -0
- package/dist/v2/fold/host-media.d.ts.map +1 -0
- package/dist/v2/fold/restore.d.ts +21 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts +45 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/commands.d.ts +29 -0
- package/dist/v2/hooks/commands.d.ts.map +1 -0
- package/dist/v2/hooks/context.d.ts +46 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/deleted-session-tombstones.d.ts +10 -0
- package/dist/v2/hooks/deleted-session-tombstones.d.ts.map +1 -0
- package/dist/v2/hooks/dream-manual.d.ts +43 -0
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -0
- package/dist/v2/hooks/dream-trigger.d.ts +7 -0
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +7 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/model-limit-cache.d.ts +19 -0
- package/dist/v2/hooks/model-limit-cache.d.ts.map +1 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/provider-admission.d.ts +22 -0
- package/dist/v2/hooks/provider-admission.d.ts.map +1 -0
- package/dist/v2/hooks/rpc-live-state.d.ts +9 -0
- package/dist/v2/hooks/rpc-live-state.d.ts.map +1 -0
- package/dist/v2/hooks/store.d.ts +38 -2
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +8 -0
- package/dist/v2/hooks/tools.d.ts.map +1 -0
- package/dist/v2/hooks/types.d.ts +59 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/hooks/usage-reading.d.ts +42 -0
- package/dist/v2/hooks/usage-reading.d.ts.map +1 -0
- package/dist/v2/host-service.d.ts +65 -0
- package/dist/v2/host-service.d.ts.map +1 -0
- package/dist/v2/server.js +142236 -112052
- package/dist/v2/store-reader.d.ts +67 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/tui/events.d.ts +7 -0
- package/dist/v2/tui/events.d.ts.map +1 -0
- package/dist/v2/tui/index.d.ts +23 -0
- package/dist/v2/tui/index.d.ts.map +1 -1
- package/dist/v2/tui/sidebar-mount.d.ts +40 -0
- package/dist/v2/tui/sidebar-mount.d.ts.map +1 -0
- package/dist/v2/tui/status-dialog-mount.d.ts +29 -0
- package/dist/v2/tui/status-dialog-mount.d.ts.map +1 -0
- package/dist/v2/tui/types.d.ts +74 -6
- package/dist/v2/tui/types.d.ts.map +1 -1
- package/dist/wrapup-orchestrator-y0bs7t5a.js +18 -0
- package/package.json +9 -7
- package/src/agents/dreamer.ts +7 -16
- package/src/agents/hidden-agent-registrations.ts +10 -22
- package/src/agents/magic-context-prompt.test.ts +29 -39
- package/src/agents/magic-context-prompt.ts +99 -122
- package/src/agents/permissions.test.ts +17 -21
- package/src/config/index.ts +8 -3
- package/src/config/live-run-config.test.ts +237 -0
- package/src/config/live-run-config.ts +80 -0
- package/src/config/live-schema-drift.test.ts +67 -0
- package/src/config/live-snapshot.test.ts +85 -0
- package/src/config/live-snapshot.ts +191 -0
- package/src/config/raw-loader.test.ts +1 -0
- package/src/config/schema/magic-context.test.ts +13 -5
- package/src/config/schema/magic-context.ts +101 -10
- package/src/features/magic-context/dreamer/task-registry.ts +137 -13
- package/src/shared/assistant-message-extractor.test.ts +21 -0
- package/src/shared/assistant-message-extractor.ts +43 -8
- package/src/shared/child-session-teardown.test.ts +38 -3
- package/src/shared/child-session-teardown.ts +3 -3
- package/src/shared/conflict-detector.test.ts +224 -7
- package/src/shared/conflict-detector.ts +161 -89
- package/src/shared/data-path.ts +6 -6
- package/src/shared/hidden-variant-warnings.ts +21 -0
- package/src/shared/host-limitations.ts +43 -0
- package/src/shared/keep-subagents.ts +6 -6
- package/src/shared/model-suggestion-retry.test.ts +86 -0
- package/src/shared/model-suggestion-retry.ts +29 -0
- package/src/shared/models-dev-cache.ts +5 -0
- package/src/shared/opencode-config-dir.ts +80 -7
- package/src/shared/opencode-db-path.test.ts +78 -0
- package/src/shared/opencode-db-path.ts +49 -2
- package/src/shared/opencode-host-generation.test.ts +29 -0
- package/src/shared/prompt-surface-a1-golden.md +142 -211
- package/src/shared/rpc-server.ts +18 -0
- package/src/shared/rpc-types.ts +63 -4
- package/src/shared/status-detail-text.test.ts +52 -18
- package/src/shared/status-detail-text.ts +1 -90
- package/src/shared/status-summary.ts +37 -2
- package/src/shared/status-view.test.ts +441 -0
- package/src/shared/status-view.ts +707 -0
- package/src/shared/tag-transcript.ts +115 -16
- package/src/shared/tail-hygiene-status.ts +9 -1
- package/src/shared/test-temp-dir.ts +3 -0
- package/src/shared/user-facing-codes.test.ts +3 -4
- package/src/shared/user-facing-codes.ts +33 -8
- package/src/shared/window-geometry.test.ts +23 -5
- package/src/shared/window-geometry.ts +13 -3
- package/src/tui/data/context-db.ts +50 -15
- package/src/tui/dialogs/status-dialog-colors.test.ts +58 -0
- package/src/tui/dialogs/status-dialog.tsx +288 -0
- package/src/tui/index.tsx +7 -464
- package/src/tui/slots/sidebar-content.tsx +21 -5
- package/src/tui-compiled/data/context-db.ts +50 -15
- package/src/tui-compiled/dialogs/status-dialog.tsx +552 -0
- package/src/tui-compiled/index.tsx +43 -1025
- package/src/tui-compiled/slots/sidebar-content.tsx +173 -152
- package/src/v2/tui/__fixtures__/ga-host-theme.json +160 -0
- package/src/v2/tui/events.ts +23 -0
- package/src/v2/tui/host-contract.test.ts +57 -8
- package/src/v2/tui/index.ts +315 -59
- package/src/v2/tui/load-compiled-sidebar.d.mts +59 -0
- package/src/v2/tui/load-compiled-sidebar.mjs +24 -0
- package/src/v2/tui/load-compiled-status-dialog.d.mts +17 -0
- package/src/v2/tui/load-compiled-status-dialog.mjs +16 -0
- package/src/v2/tui/sidebar-fallback.test.ts +100 -0
- package/src/v2/tui/sidebar-mount.ts +164 -0
- package/src/v2/tui/sidebar-text.test.ts +70 -0
- package/src/v2/tui/status-dialog-fallback.test.ts +97 -0
- package/src/v2/tui/status-dialog-mount.ts +76 -0
- package/src/v2/tui/theme-mapping.test.ts +57 -0
- package/src/v2/tui/types.ts +69 -4
- package/tui.js +1 -0
- package/dist/features/magic-context/memory/memory-migration.d.ts +0 -129
- package/dist/features/magic-context/memory/memory-migration.d.ts.map +0 -1
- package/dist/hooks/magic-context/upgrade-reminder.d.ts +0 -76
- package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +0 -1
- package/dist/index-4wwr6cz0.js +0 -112
- package/dist/index-avwt563y.js +0 -62
- package/dist/index-znraa0kv.js +0 -637
- package/dist/recomp-orchestrator-0xx1364v.js +0 -19
- package/dist/storage-meta-session-z818pn1e.js +0 -20
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
buildDreamTaskRuntimeConfigs,
|
|
8
|
+
userMemoryCollectionEnabled,
|
|
9
|
+
} from "../features/magic-context/dreamer/task-config";
|
|
10
|
+
import { resolveHistorianModel } from "../shared/model-resolution";
|
|
11
|
+
import { loadPluginConfigDetailed } from "./index";
|
|
12
|
+
import { dreamerRunConfig, historianRunConfig } from "./live-run-config";
|
|
13
|
+
import { LiveConfigReader } from "./live-snapshot";
|
|
14
|
+
|
|
15
|
+
for (const host of ["OC1", "OC2", "Pi"] as const) {
|
|
16
|
+
test(`${host} historian samples the next generation while an existing run keeps its model and fallback`, () => {
|
|
17
|
+
const root = mkdtempSync(join(tmpdir(), "mc-live-historian-"));
|
|
18
|
+
const previous = { home: process.env.HOME, config: process.env.XDG_CONFIG_HOME };
|
|
19
|
+
process.env.HOME = root;
|
|
20
|
+
process.env.XDG_CONFIG_HOME = join(root, "config");
|
|
21
|
+
const directory = join(root, "project");
|
|
22
|
+
const file = join(root, "config", "cortexkit", "magic-context.jsonc");
|
|
23
|
+
mkdirSync(join(root, "config", "cortexkit"), { recursive: true });
|
|
24
|
+
mkdirSync(join(directory, ".cortexkit"), { recursive: true });
|
|
25
|
+
try {
|
|
26
|
+
const block = host === "Pi" ? "pi" : "opencode";
|
|
27
|
+
const write = (
|
|
28
|
+
model: string,
|
|
29
|
+
fallback: string,
|
|
30
|
+
autoPromote: boolean,
|
|
31
|
+
minClusters: number,
|
|
32
|
+
) =>
|
|
33
|
+
writeFileSync(
|
|
34
|
+
file,
|
|
35
|
+
JSON.stringify({
|
|
36
|
+
historian: { [block]: { model, fallback_models: [fallback] } },
|
|
37
|
+
memory: { auto_promote: autoPromote },
|
|
38
|
+
commit_cluster_trigger: { enabled: true, min_clusters: minClusters },
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
write("anthropic/old-model", "anthropic/old-fallback", true, 3);
|
|
42
|
+
const load = () => loadPluginConfigDetailed(directory, false).config;
|
|
43
|
+
const boot = load();
|
|
44
|
+
const reader = new LiveConfigReader(directory, boot, load, () => {});
|
|
45
|
+
reader.poll();
|
|
46
|
+
const runOne = historianRunConfig(boot, reader.current().effective);
|
|
47
|
+
write(
|
|
48
|
+
"anthropic/new-model-with-longer-name",
|
|
49
|
+
"anthropic/new-fallback-with-longer-name",
|
|
50
|
+
false,
|
|
51
|
+
5,
|
|
52
|
+
);
|
|
53
|
+
const runTwo = historianRunConfig(boot, reader.poll().effective);
|
|
54
|
+
const harness = host === "Pi" ? "pi" : "opencode";
|
|
55
|
+
expect(resolveHistorianModel(runOne, harness).primary?.model).toBe(
|
|
56
|
+
"anthropic/old-model",
|
|
57
|
+
);
|
|
58
|
+
expect(resolveHistorianModel(runOne, harness).fallbacks[0]?.model).toBe(
|
|
59
|
+
"anthropic/old-fallback",
|
|
60
|
+
);
|
|
61
|
+
expect(resolveHistorianModel(runTwo, harness).primary?.model).toBe(
|
|
62
|
+
"anthropic/new-model-with-longer-name",
|
|
63
|
+
);
|
|
64
|
+
expect(resolveHistorianModel(runTwo, harness).fallbacks[0]?.model).toBe(
|
|
65
|
+
"anthropic/new-fallback-with-longer-name",
|
|
66
|
+
);
|
|
67
|
+
expect(runOne.memory.auto_promote).toBe(true);
|
|
68
|
+
expect(runTwo.memory.auto_promote).toBe(false);
|
|
69
|
+
expect(runOne.commit_cluster_trigger.min_clusters).toBe(3);
|
|
70
|
+
expect(runTwo.commit_cluster_trigger.min_clusters).toBe(5);
|
|
71
|
+
expect(reader.current().generation).toBe(2);
|
|
72
|
+
} finally {
|
|
73
|
+
if (previous.home === undefined) delete process.env.HOME;
|
|
74
|
+
else process.env.HOME = previous.home;
|
|
75
|
+
if (previous.config === undefined) delete process.env.XDG_CONFIG_HOME;
|
|
76
|
+
else process.env.XDG_CONFIG_HOME = previous.config;
|
|
77
|
+
rmSync(root, { recursive: true, force: true });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for (const host of ["OC1", "OC2", "Pi"] as const) {
|
|
83
|
+
test(`${host} dreamer samples the new schedule and model chain without changing a running task`, () => {
|
|
84
|
+
const root = mkdtempSync(join(tmpdir(), "mc-live-dreamer-"));
|
|
85
|
+
const previous = { home: process.env.HOME, config: process.env.XDG_CONFIG_HOME };
|
|
86
|
+
process.env.HOME = root;
|
|
87
|
+
process.env.XDG_CONFIG_HOME = join(root, "config");
|
|
88
|
+
const directory = join(root, "project");
|
|
89
|
+
const userFile = join(root, "config", "cortexkit", "magic-context.jsonc");
|
|
90
|
+
const projectFile = join(directory, ".cortexkit", "magic-context.jsonc");
|
|
91
|
+
mkdirSync(join(root, "config", "cortexkit"), { recursive: true });
|
|
92
|
+
mkdirSync(join(directory, ".cortexkit"), { recursive: true });
|
|
93
|
+
try {
|
|
94
|
+
const block = host === "Pi" ? "pi" : "opencode";
|
|
95
|
+
writeFileSync(
|
|
96
|
+
userFile,
|
|
97
|
+
JSON.stringify({
|
|
98
|
+
dreamer: { [block]: { model: "old/model", fallback_models: ["old/fallback"] } },
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
101
|
+
const writeSchedule = (schedule: string) =>
|
|
102
|
+
writeFileSync(
|
|
103
|
+
projectFile,
|
|
104
|
+
JSON.stringify({
|
|
105
|
+
dreamer: {
|
|
106
|
+
tasks: {
|
|
107
|
+
verify: { schedule },
|
|
108
|
+
"review-user-memories": {
|
|
109
|
+
schedule: schedule === "0 3 * * *" ? "" : "0 0 * * *",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
writeSchedule("0 3 * * *");
|
|
116
|
+
const load = () => loadPluginConfigDetailed(directory, false).config;
|
|
117
|
+
const boot = load();
|
|
118
|
+
const reader = new LiveConfigReader(directory, boot, load, () => {});
|
|
119
|
+
reader.poll();
|
|
120
|
+
const runOne = dreamerRunConfig(boot, reader.current().effective);
|
|
121
|
+
writeFileSync(
|
|
122
|
+
userFile,
|
|
123
|
+
JSON.stringify({
|
|
124
|
+
dreamer: {
|
|
125
|
+
[block]: {
|
|
126
|
+
model: "new/model-long",
|
|
127
|
+
fallback_models: ["new/fallback-long"],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
writeSchedule("15 4 * * *");
|
|
133
|
+
const runTwo = dreamerRunConfig(boot, reader.poll().effective);
|
|
134
|
+
const task = (cfg: typeof runOne) =>
|
|
135
|
+
buildDreamTaskRuntimeConfigs(cfg.dreamer, host === "Pi" ? "pi" : "opencode").find(
|
|
136
|
+
(entry) => entry.task === "verify",
|
|
137
|
+
)!;
|
|
138
|
+
expect(task(runOne).schedule).toBe("0 3 * * *");
|
|
139
|
+
expect(userMemoryCollectionEnabled(runOne.dreamer)).toBe(false);
|
|
140
|
+
expect(task(runOne).model?.model).toBe("old/model");
|
|
141
|
+
expect(task(runOne).fallbackModels[0]?.model).toBe("old/fallback");
|
|
142
|
+
expect(task(runTwo).schedule).toBe("15 4 * * *");
|
|
143
|
+
expect(
|
|
144
|
+
userMemoryCollectionEnabled(
|
|
145
|
+
historianRunConfig(boot, reader.current().effective).dreamer,
|
|
146
|
+
),
|
|
147
|
+
).toBe(true);
|
|
148
|
+
expect(task(runTwo).model?.model).toBe("new/model-long");
|
|
149
|
+
expect(task(runTwo).fallbackModels[0]?.model).toBe("new/fallback-long");
|
|
150
|
+
} finally {
|
|
151
|
+
if (previous.home === undefined) delete process.env.HOME;
|
|
152
|
+
else process.env.HOME = previous.home;
|
|
153
|
+
if (previous.config === undefined) delete process.env.XDG_CONFIG_HOME;
|
|
154
|
+
else process.env.XDG_CONFIG_HOME = previous.config;
|
|
155
|
+
rmSync(root, { recursive: true, force: true });
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
test("malformed project config retains last good values and deduplicates the warning; project overrides remain tier-safe", () => {
|
|
161
|
+
const root = mkdtempSync(join(tmpdir(), "mc-live-tiers-"));
|
|
162
|
+
const previous = { home: process.env.HOME, config: process.env.XDG_CONFIG_HOME };
|
|
163
|
+
process.env.HOME = root;
|
|
164
|
+
process.env.XDG_CONFIG_HOME = join(root, "config");
|
|
165
|
+
const directory = join(root, "project");
|
|
166
|
+
const userFile = join(root, "config", "cortexkit", "magic-context.jsonc");
|
|
167
|
+
const projectFile = join(directory, ".cortexkit", "magic-context.jsonc");
|
|
168
|
+
mkdirSync(join(root, "config", "cortexkit"), { recursive: true });
|
|
169
|
+
mkdirSync(join(directory, ".cortexkit"), { recursive: true });
|
|
170
|
+
const warnings: string[] = [];
|
|
171
|
+
try {
|
|
172
|
+
writeFileSync(
|
|
173
|
+
userFile,
|
|
174
|
+
JSON.stringify({
|
|
175
|
+
dreamer: {
|
|
176
|
+
opencode: { model: "user/model" },
|
|
177
|
+
tasks: { verify: { schedule: "0 3 * * *" } },
|
|
178
|
+
prompt: "trusted",
|
|
179
|
+
},
|
|
180
|
+
historian: { opencode: { model: "user/historian" } },
|
|
181
|
+
}),
|
|
182
|
+
);
|
|
183
|
+
writeFileSync(
|
|
184
|
+
projectFile,
|
|
185
|
+
JSON.stringify({
|
|
186
|
+
dreamer: {
|
|
187
|
+
opencode: { model: "project/model" },
|
|
188
|
+
tasks: { verify: { schedule: "1 3 * * *" } },
|
|
189
|
+
prompt: "untrusted",
|
|
190
|
+
},
|
|
191
|
+
historian: { opencode: { model: "project/historian" } },
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
const load = () => loadPluginConfigDetailed(directory, false).config;
|
|
195
|
+
const reader = new LiveConfigReader(directory, load(), load, (message) =>
|
|
196
|
+
warnings.push(message),
|
|
197
|
+
);
|
|
198
|
+
const first = reader.poll();
|
|
199
|
+
expect(first.effective.dreamer?.opencode?.model).toBe("project/model");
|
|
200
|
+
expect(first.effective.dreamer?.prompt).toBe("trusted");
|
|
201
|
+
expect(resolveHistorianModel(first.effective, "opencode").primary?.model).toBe(
|
|
202
|
+
"user/historian",
|
|
203
|
+
);
|
|
204
|
+
writeFileSync(projectFile, "{ broken:");
|
|
205
|
+
expect(reader.poll()).toBe(first);
|
|
206
|
+
expect(reader.poll()).toBe(first);
|
|
207
|
+
expect(warnings.filter((message) => message.includes("config reload failed"))).toHaveLength(
|
|
208
|
+
1,
|
|
209
|
+
);
|
|
210
|
+
writeFileSync(
|
|
211
|
+
projectFile,
|
|
212
|
+
JSON.stringify({
|
|
213
|
+
dreamer: {
|
|
214
|
+
opencode: { model: "project/new-model" },
|
|
215
|
+
tasks: { verify: { schedule: "2 3 * * *" } },
|
|
216
|
+
prompt: "still-untrusted",
|
|
217
|
+
},
|
|
218
|
+
historian: { opencode: { model: "project/new-historian" } },
|
|
219
|
+
}),
|
|
220
|
+
);
|
|
221
|
+
const second = reader.poll();
|
|
222
|
+
expect(second.generation).toBe(2);
|
|
223
|
+
expect(second.effective.dreamer?.opencode?.model).toBe("project/new-model");
|
|
224
|
+
expect(second.effective.dreamer?.tasks?.verify.schedule).toBe("2 3 * * *");
|
|
225
|
+
expect(second.effective.dreamer?.prompt).toBe("trusted");
|
|
226
|
+
expect(resolveHistorianModel(second.effective, "opencode").primary?.model).toBe(
|
|
227
|
+
"user/historian",
|
|
228
|
+
);
|
|
229
|
+
expect(first.effective.dreamer?.opencode?.model).toBe("project/model");
|
|
230
|
+
} finally {
|
|
231
|
+
if (previous.home === undefined) delete process.env.HOME;
|
|
232
|
+
else process.env.HOME = previous.home;
|
|
233
|
+
if (previous.config === undefined) delete process.env.XDG_CONFIG_HOME;
|
|
234
|
+
else process.env.XDG_CONFIG_HOME = previous.config;
|
|
235
|
+
rmSync(root, { recursive: true, force: true });
|
|
236
|
+
}
|
|
237
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { log } from "../shared/logger";
|
|
2
|
+
import { loadPluginConfigDetailed, type MagicContextPluginConfig } from "./index";
|
|
3
|
+
import { LiveConfigReader } from "./live-snapshot";
|
|
4
|
+
import { LIVE_RELOAD_CONFIG_PATHS, type MagicContextConfig } from "./schema/magic-context";
|
|
5
|
+
|
|
6
|
+
/** Copy only schema-marked live paths from fresh config; other settings retain boot values. */
|
|
7
|
+
export function sampleLiveConfig<T extends MagicContextConfig>(boot: T, fresh: T): T {
|
|
8
|
+
const result = { ...boot } as Record<string, unknown>;
|
|
9
|
+
for (const path of LIVE_RELOAD_CONFIG_PATHS) {
|
|
10
|
+
const parts = path.split(".");
|
|
11
|
+
let value: unknown = fresh;
|
|
12
|
+
for (const part of parts) value = (value as Record<string, unknown> | undefined)?.[part];
|
|
13
|
+
let target = result;
|
|
14
|
+
for (const part of parts.slice(0, -1)) {
|
|
15
|
+
const child = target[part];
|
|
16
|
+
const copy =
|
|
17
|
+
child && typeof child === "object" && !Array.isArray(child)
|
|
18
|
+
? { ...(child as Record<string, unknown>) }
|
|
19
|
+
: {};
|
|
20
|
+
target[part] = copy;
|
|
21
|
+
target = copy;
|
|
22
|
+
}
|
|
23
|
+
const leaf = parts.at(-1);
|
|
24
|
+
if (leaf !== undefined) target[leaf] = value;
|
|
25
|
+
}
|
|
26
|
+
return result as T;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function changedLiveKeys(previous: MagicContextConfig, next: MagicContextConfig): string[] {
|
|
30
|
+
const at = (config: MagicContextConfig, path: string): unknown =>
|
|
31
|
+
path
|
|
32
|
+
.split(".")
|
|
33
|
+
.reduce<unknown>(
|
|
34
|
+
(node, part) => (node as Record<string, unknown> | undefined)?.[part],
|
|
35
|
+
config,
|
|
36
|
+
);
|
|
37
|
+
return LIVE_RELOAD_CONFIG_PATHS.filter(
|
|
38
|
+
(path) => JSON.stringify(at(previous, path)) !== JSON.stringify(at(next, path)),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const historianRunConfig = sampleLiveConfig;
|
|
43
|
+
export const dreamerRunConfig = sampleLiveConfig;
|
|
44
|
+
|
|
45
|
+
const pluginReaders = new Map<string, LiveConfigReader<MagicContextPluginConfig>>();
|
|
46
|
+
|
|
47
|
+
/** Shared by all OpenCode entry points for one project in this process. */
|
|
48
|
+
export function pluginConfigReader(directory: string, boot: MagicContextPluginConfig) {
|
|
49
|
+
let reader = pluginReaders.get(directory);
|
|
50
|
+
if (!reader) {
|
|
51
|
+
reader = new LiveConfigReader(
|
|
52
|
+
directory,
|
|
53
|
+
boot,
|
|
54
|
+
() => {
|
|
55
|
+
const loaded = loadPluginConfigDetailed(directory, false);
|
|
56
|
+
if (
|
|
57
|
+
loaded.loadOutcome === "project-file-parse-error" ||
|
|
58
|
+
loaded.loadOutcome === "project-file-io-error" ||
|
|
59
|
+
loaded.loadOutcome === "schema-recovery"
|
|
60
|
+
) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`invalid configuration: ${loaded.config.configWarnings?.join("; ") ?? loaded.loadOutcome}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return loaded.config;
|
|
66
|
+
},
|
|
67
|
+
// Into our own log file: console output lands in the host's stdout/stderr
|
|
68
|
+
// (for `opencode serve`, the terminal or service log the user reads).
|
|
69
|
+
(message) => log(`[config] ${message}`),
|
|
70
|
+
changedLiveKeys,
|
|
71
|
+
);
|
|
72
|
+
reader.poll();
|
|
73
|
+
pluginReaders.set(directory, reader);
|
|
74
|
+
}
|
|
75
|
+
return reader;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function currentPluginConfigReader(directory: string) {
|
|
79
|
+
return pluginReaders.get(directory);
|
|
80
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { buildSchema } from "../../scripts/build-schema";
|
|
4
|
+
import { sampleLiveConfig } from "./live-run-config";
|
|
5
|
+
import { LIVE_RELOAD_CONFIG_PATHS, type MagicContextConfig } from "./schema/magic-context";
|
|
6
|
+
|
|
7
|
+
type SchemaNode = { properties?: Record<string, SchemaNode>; "x-mc-live-reload"?: boolean };
|
|
8
|
+
|
|
9
|
+
function leaves(node: SchemaNode, prefix = ""): Array<{ path: string; marked: boolean }> {
|
|
10
|
+
return Object.entries(node.properties ?? {}).flatMap(([key, child]) => {
|
|
11
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
12
|
+
return child.properties
|
|
13
|
+
? leaves(child, path)
|
|
14
|
+
: [{ path, marked: child["x-mc-live-reload"] === true }];
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function assign(target: Record<string, unknown>, path: string, value: unknown): void {
|
|
19
|
+
const keys = path.split(".");
|
|
20
|
+
let node = target;
|
|
21
|
+
for (const key of keys.slice(0, -1)) {
|
|
22
|
+
node[key] ??= {};
|
|
23
|
+
node = node[key] as Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
node[keys.at(-1)!] = value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function lookup(target: Record<string, unknown>, path: string): unknown {
|
|
29
|
+
return path
|
|
30
|
+
.split(".")
|
|
31
|
+
.reduce<unknown>(
|
|
32
|
+
(node, key) => (node as Record<string, unknown> | undefined)?.[key],
|
|
33
|
+
target,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
test("schema live marks equal the keys sampled by producer consumers and published JSON schema", async () => {
|
|
38
|
+
const generated = buildSchema() as SchemaNode;
|
|
39
|
+
const published = (await Bun.file(
|
|
40
|
+
new URL("../../../../assets/magic-context.schema.json", import.meta.url),
|
|
41
|
+
).json()) as SchemaNode;
|
|
42
|
+
const generatedLive = leaves(generated)
|
|
43
|
+
.filter((row) => row.marked)
|
|
44
|
+
.map((row) => row.path)
|
|
45
|
+
.sort();
|
|
46
|
+
const publishedLive = leaves(published)
|
|
47
|
+
.filter((row) => row.marked)
|
|
48
|
+
.map((row) => row.path)
|
|
49
|
+
.sort();
|
|
50
|
+
const boot = {} as Record<string, unknown>;
|
|
51
|
+
const fresh = {} as Record<string, unknown>;
|
|
52
|
+
for (const row of leaves(generated)) assign(fresh, row.path, `changed:${row.path}`);
|
|
53
|
+
const sampled = sampleLiveConfig(
|
|
54
|
+
boot as MagicContextConfig,
|
|
55
|
+
fresh as MagicContextConfig,
|
|
56
|
+
) as Record<string, unknown>;
|
|
57
|
+
const consumed = leaves(generated)
|
|
58
|
+
.filter((row) => lookup(sampled, row.path) === `changed:${row.path}`)
|
|
59
|
+
.map((row) => row.path)
|
|
60
|
+
.sort();
|
|
61
|
+
expect(generatedLive).toEqual([...LIVE_RELOAD_CONFIG_PATHS].sort());
|
|
62
|
+
expect(publishedLive).toEqual(generatedLive);
|
|
63
|
+
expect(consumed).toEqual(generatedLive);
|
|
64
|
+
expect(generatedLive).not.toContain("language");
|
|
65
|
+
expect(generatedLive).not.toContain("historian.top_p");
|
|
66
|
+
expect(generatedLive).not.toContain("protected_tokens");
|
|
67
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
import { parseJsonc } from "../shared/jsonc-parser";
|
|
7
|
+
import { LiveConfigReader } from "./live-snapshot";
|
|
8
|
+
|
|
9
|
+
test("one snapshot per run survives a malformed tier and adopts both tiers atomically", () => {
|
|
10
|
+
const oldConfigHome = process.env.XDG_CONFIG_HOME;
|
|
11
|
+
const root = mkdtempSync(join(tmpdir(), "mc-live-config-"));
|
|
12
|
+
const project = join(root, "project");
|
|
13
|
+
const projectFile = join(project, ".cortexkit", "magic-context.jsonc");
|
|
14
|
+
const userFile = join(root, "config", "cortexkit", "magic-context.jsonc");
|
|
15
|
+
mkdirSync(join(project, ".cortexkit"), { recursive: true });
|
|
16
|
+
mkdirSync(join(root, "config", "cortexkit"), { recursive: true });
|
|
17
|
+
process.env.XDG_CONFIG_HOME = join(root, "config");
|
|
18
|
+
try {
|
|
19
|
+
const logs: string[] = [];
|
|
20
|
+
writeFileSync(userFile, '{"historian":{"model":"user"}}');
|
|
21
|
+
writeFileSync(projectFile, '{"historian":{"model":"project"}}');
|
|
22
|
+
const load = () => {
|
|
23
|
+
const user = parseJsonc<{ historian: { model: string } }>(
|
|
24
|
+
readFileSync(userFile, "utf8"),
|
|
25
|
+
);
|
|
26
|
+
const projectConfig = parseJsonc<{ historian: { model: string } }>(
|
|
27
|
+
readFileSync(projectFile, "utf8"),
|
|
28
|
+
);
|
|
29
|
+
return { model: projectConfig.historian.model ?? user.historian.model };
|
|
30
|
+
};
|
|
31
|
+
const reader = new LiveConfigReader(project, load(), load, (line) => logs.push(line));
|
|
32
|
+
const first = reader.poll();
|
|
33
|
+
expect(first.generation).toBe(1);
|
|
34
|
+
writeFileSync(projectFile, '{"historian":');
|
|
35
|
+
expect(reader.poll()).toBe(first);
|
|
36
|
+
expect(reader.lastFailure()?.path).toBe(projectFile);
|
|
37
|
+
reader.poll();
|
|
38
|
+
expect(logs.filter((line) => line.includes("reload failed"))).toHaveLength(1);
|
|
39
|
+
writeFileSync(projectFile, '{"historian":{"model":"second-model"}}');
|
|
40
|
+
const second = reader.poll();
|
|
41
|
+
expect(second.generation).toBe(2);
|
|
42
|
+
expect(second.effective.model).toBe("second-model");
|
|
43
|
+
expect(first.effective.model).toBe("project");
|
|
44
|
+
expect(reader.lastFailure()).toBeUndefined();
|
|
45
|
+
expect(logs.filter((line) => line.includes("config reloaded"))).toEqual([
|
|
46
|
+
"config reloaded gen=2 keys=[model]",
|
|
47
|
+
]);
|
|
48
|
+
} finally {
|
|
49
|
+
if (oldConfigHome === undefined) delete process.env.XDG_CONFIG_HOME;
|
|
50
|
+
else process.env.XDG_CONFIG_HOME = oldConfigHome;
|
|
51
|
+
rmSync(root, { recursive: true, force: true });
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("a write crossing the tier load boundary is not published as a mixed snapshot", () => {
|
|
56
|
+
const root = mkdtempSync(join(tmpdir(), "mc-live-crossing-"));
|
|
57
|
+
const previous = process.env.XDG_CONFIG_HOME;
|
|
58
|
+
process.env.XDG_CONFIG_HOME = join(root, "config");
|
|
59
|
+
const project = join(root, "project");
|
|
60
|
+
const file = join(project, ".cortexkit", "magic-context.jsonc");
|
|
61
|
+
mkdirSync(join(project, ".cortexkit"), { recursive: true });
|
|
62
|
+
try {
|
|
63
|
+
writeFileSync(file, '{"model":"old"}');
|
|
64
|
+
let crossWrite = false;
|
|
65
|
+
const load = () => {
|
|
66
|
+
if (crossWrite) {
|
|
67
|
+
crossWrite = false;
|
|
68
|
+
writeFileSync(file, '{"model":"newest-longer"}');
|
|
69
|
+
}
|
|
70
|
+
return { model: JSON.parse(readFileSync(file, "utf8")).model as string };
|
|
71
|
+
};
|
|
72
|
+
const reader = new LiveConfigReader(project, load(), load, () => {});
|
|
73
|
+
reader.poll();
|
|
74
|
+
writeFileSync(file, '{"model":"intermediate"}');
|
|
75
|
+
crossWrite = true;
|
|
76
|
+
expect(reader.poll().effective.model).toBe("old");
|
|
77
|
+
expect(reader.current().generation).toBe(1);
|
|
78
|
+
expect(reader.poll().effective.model).toBe("newest-longer");
|
|
79
|
+
expect(reader.current().generation).toBe(2);
|
|
80
|
+
} finally {
|
|
81
|
+
if (previous === undefined) delete process.env.XDG_CONFIG_HOME;
|
|
82
|
+
else process.env.XDG_CONFIG_HOME = previous;
|
|
83
|
+
rmSync(root, { recursive: true, force: true });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFileSync, statSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
import { detectConfigFile, parseJsoncRecovering } from "../shared/jsonc-parser";
|
|
5
|
+
import {
|
|
6
|
+
cortexKitProjectConfigBasePath,
|
|
7
|
+
cortexKitUserConfigBasePath,
|
|
8
|
+
} from "./migrate-config-location";
|
|
9
|
+
|
|
10
|
+
export interface ConfigSnapshot<T> {
|
|
11
|
+
readonly generation: number;
|
|
12
|
+
readonly digest: string;
|
|
13
|
+
readonly adoptedAt: number;
|
|
14
|
+
readonly effective: T;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ConfigReloadFailure {
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly digest: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface FileState {
|
|
24
|
+
metadata: string;
|
|
25
|
+
digest: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Publishes a project configuration only after the user and project files parse
|
|
30
|
+
* and the loader assembles the final effective configuration successfully.
|
|
31
|
+
*/
|
|
32
|
+
export class LiveConfigReader<T> {
|
|
33
|
+
private snapshot: ConfigSnapshot<T>;
|
|
34
|
+
private files = new Map<string, FileState>();
|
|
35
|
+
private initialized = false;
|
|
36
|
+
private warned = new Set<string>();
|
|
37
|
+
private failure: ConfigReloadFailure | undefined;
|
|
38
|
+
|
|
39
|
+
constructor(
|
|
40
|
+
private readonly directory: string,
|
|
41
|
+
initial: T,
|
|
42
|
+
private readonly load: () => T,
|
|
43
|
+
// Callers pass the host's log sink; the default is silent so a caller that
|
|
44
|
+
// forgets never writes into the host process's stderr.
|
|
45
|
+
private readonly onLog: (message: string) => void = () => {},
|
|
46
|
+
private readonly changedKeys: (previous: T, next: T) => readonly string[] = (
|
|
47
|
+
previous,
|
|
48
|
+
next,
|
|
49
|
+
) =>
|
|
50
|
+
Object.keys(next as object).filter(
|
|
51
|
+
(key) =>
|
|
52
|
+
JSON.stringify((previous as Record<string, unknown>)[key]) !==
|
|
53
|
+
JSON.stringify((next as Record<string, unknown>)[key]),
|
|
54
|
+
),
|
|
55
|
+
) {
|
|
56
|
+
this.snapshot = {
|
|
57
|
+
generation: 1,
|
|
58
|
+
digest: "initial",
|
|
59
|
+
adoptedAt: Date.now(),
|
|
60
|
+
effective: initial,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
current(): ConfigSnapshot<T> {
|
|
65
|
+
return this.snapshot;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
lastFailure(): ConfigReloadFailure | undefined {
|
|
69
|
+
return this.failure;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
poll(): ConfigSnapshot<T> {
|
|
73
|
+
const paths = [
|
|
74
|
+
cortexKitUserConfigBasePath(),
|
|
75
|
+
cortexKitProjectConfigBasePath(this.directory),
|
|
76
|
+
].map((base) => detectConfigFile(base).path);
|
|
77
|
+
const next = new Map<string, FileState>();
|
|
78
|
+
let changed = paths.some((path) => !this.files.has(path));
|
|
79
|
+
for (const path of paths) {
|
|
80
|
+
let metadata: string;
|
|
81
|
+
try {
|
|
82
|
+
const stat = statSync(path);
|
|
83
|
+
metadata = `${stat.mtimeMs}:${stat.size}:${stat.ino}`;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
86
|
+
this.reportFailure(path, String(error), error);
|
|
87
|
+
return this.snapshot;
|
|
88
|
+
}
|
|
89
|
+
metadata = "absent";
|
|
90
|
+
}
|
|
91
|
+
const previous = this.files.get(path);
|
|
92
|
+
if (previous?.metadata === metadata) {
|
|
93
|
+
next.set(path, previous);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
let content: string;
|
|
97
|
+
try {
|
|
98
|
+
content = metadata === "absent" ? "" : readFileSync(path, "utf8");
|
|
99
|
+
} catch (error) {
|
|
100
|
+
this.reportFailure(path, String(error), error);
|
|
101
|
+
return this.snapshot;
|
|
102
|
+
}
|
|
103
|
+
const digest = createHash("sha256").update(content).digest("hex");
|
|
104
|
+
if (metadata !== "absent") {
|
|
105
|
+
const parsed = parseJsoncRecovering(content);
|
|
106
|
+
if (
|
|
107
|
+
parsed.issues.length ||
|
|
108
|
+
!parsed.value ||
|
|
109
|
+
typeof parsed.value !== "object" ||
|
|
110
|
+
Array.isArray(parsed.value)
|
|
111
|
+
) {
|
|
112
|
+
const issue = parsed.issues[0];
|
|
113
|
+
this.reportFailure(
|
|
114
|
+
path,
|
|
115
|
+
digest,
|
|
116
|
+
issue
|
|
117
|
+
? `${issue.line}:${issue.column}: ${issue.message}`
|
|
118
|
+
: "expected an object",
|
|
119
|
+
);
|
|
120
|
+
return this.snapshot;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
next.set(path, { metadata, digest });
|
|
124
|
+
changed ||= previous?.digest !== digest;
|
|
125
|
+
}
|
|
126
|
+
if (!changed) {
|
|
127
|
+
this.files = next;
|
|
128
|
+
return this.snapshot;
|
|
129
|
+
}
|
|
130
|
+
let effective: T;
|
|
131
|
+
try {
|
|
132
|
+
effective = this.load();
|
|
133
|
+
} catch (error) {
|
|
134
|
+
this.reportFailure(paths[0] ?? this.directory, "load", error);
|
|
135
|
+
return this.snapshot;
|
|
136
|
+
}
|
|
137
|
+
// The loader reads both tiers again. A concurrent writer must not let it
|
|
138
|
+
// publish a mixed user/project pair under the metadata staged above.
|
|
139
|
+
for (const path of paths) {
|
|
140
|
+
let metadata = "absent";
|
|
141
|
+
try {
|
|
142
|
+
const stat = statSync(path);
|
|
143
|
+
metadata = `${stat.mtimeMs}:${stat.size}:${stat.ino}`;
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
146
|
+
this.reportFailure(path, String(error), error);
|
|
147
|
+
return this.snapshot;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (metadata !== next.get(path)?.metadata) return this.snapshot;
|
|
151
|
+
}
|
|
152
|
+
const digest = createHash("sha256")
|
|
153
|
+
.update(paths.map((path) => `${path}:${next.get(path)?.digest}`).join("\n"))
|
|
154
|
+
.digest("hex");
|
|
155
|
+
this.files = next;
|
|
156
|
+
this.failure = undefined;
|
|
157
|
+
if (!this.initialized) {
|
|
158
|
+
this.initialized = true;
|
|
159
|
+
this.snapshot = {
|
|
160
|
+
generation: 1,
|
|
161
|
+
digest,
|
|
162
|
+
adoptedAt: this.snapshot.adoptedAt,
|
|
163
|
+
effective,
|
|
164
|
+
};
|
|
165
|
+
} else if (this.snapshot.digest !== digest) {
|
|
166
|
+
const keys = this.changedKeys(this.snapshot.effective, effective);
|
|
167
|
+
this.snapshot = {
|
|
168
|
+
generation: this.snapshot.generation + 1,
|
|
169
|
+
digest,
|
|
170
|
+
adoptedAt: Date.now(),
|
|
171
|
+
effective,
|
|
172
|
+
};
|
|
173
|
+
// A file can change (a save, a comment edit) without any setting changing;
|
|
174
|
+
// only a real change is worth a line.
|
|
175
|
+
if (keys.length > 0) {
|
|
176
|
+
this.onLog(
|
|
177
|
+
`config reloaded gen=${this.snapshot.generation} keys=[${keys.join(",")}]`,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return this.snapshot;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private reportFailure(path: string, digest: string, error: unknown): void {
|
|
185
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
186
|
+
this.failure = { path, message, digest };
|
|
187
|
+
if (this.warned.has(`${path}:${digest}`)) return;
|
|
188
|
+
this.warned.add(`${path}:${digest}`);
|
|
189
|
+
this.onLog(`config reload failed ${path}: ${message}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -168,6 +168,7 @@ describe("per-harness raw config migration", () => {
|
|
|
168
168
|
const taskRetained = {
|
|
169
169
|
schedule: "0 3 * * *",
|
|
170
170
|
promotion_threshold: 4,
|
|
171
|
+
recency_days: 30,
|
|
171
172
|
};
|
|
172
173
|
expect(Object.keys(historianRetained)).toEqual(
|
|
173
174
|
PER_HARNESS_MIGRATION_INVENTORY.historian.retained,
|