@wolfx/opencode-magic-context 0.21.8-patch.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/dist/agents/dreamer.d.ts +2 -0
- package/dist/agents/dreamer.d.ts.map +1 -0
- package/dist/agents/historian.d.ts +3 -0
- package/dist/agents/historian.d.ts.map +1 -0
- package/dist/agents/magic-context-prompt.d.ts +3 -0
- package/dist/agents/magic-context-prompt.d.ts.map +1 -0
- package/dist/agents/permissions.d.ts +142 -0
- package/dist/agents/permissions.d.ts.map +1 -0
- package/dist/agents/sidekick.d.ts +2 -0
- package/dist/agents/sidekick.d.ts.map +1 -0
- package/dist/config/agent-disable.d.ts +26 -0
- package/dist/config/agent-disable.d.ts.map +1 -0
- package/dist/config/index.d.ts +33 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/schema/agent-overrides.d.ts +55 -0
- package/dist/config/schema/agent-overrides.d.ts.map +1 -0
- package/dist/config/schema/magic-context.d.ts +841 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -0
- package/dist/config/schema.d.ts +3 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/variable.d.ts +48 -0
- package/dist/config/variable.d.ts.map +1 -0
- package/dist/features/builtin-commands/commands.d.ts +3 -0
- package/dist/features/builtin-commands/commands.d.ts.map +1 -0
- package/dist/features/builtin-commands/types.d.ts +5 -0
- package/dist/features/builtin-commands/types.d.ts.map +1 -0
- package/dist/features/magic-context/compaction-marker.d.ts +91 -0
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -0
- package/dist/features/magic-context/compaction.d.ts +7 -0
- package/dist/features/magic-context/compaction.d.ts.map +1 -0
- package/dist/features/magic-context/compartment-lease.d.ts +14 -0
- package/dist/features/magic-context/compartment-lease.d.ts.map +1 -0
- package/dist/features/magic-context/compartment-storage.d.ts +130 -0
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -0
- package/dist/features/magic-context/compression-depth-storage.d.ts +14 -0
- package/dist/features/magic-context/compression-depth-storage.d.ts.map +1 -0
- package/dist/features/magic-context/defaults.d.ts +2 -0
- package/dist/features/magic-context/defaults.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/index.d.ts +8 -0
- package/dist/features/magic-context/dreamer/index.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/lease.d.ts +8 -0
- package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/queue.d.ts +44 -0
- package/dist/features/magic-context/dreamer/queue.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/runner.d.ts +81 -0
- package/dist/features/magic-context/dreamer/runner.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/scheduler.d.ts +33 -0
- package/dist/features/magic-context/dreamer/scheduler.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +41 -0
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/storage-dream-state.d.ts +5 -0
- package/dist/features/magic-context/dreamer/storage-dream-state.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +26 -0
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts +57 -0
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/index.d.ts +7 -0
- package/dist/features/magic-context/git-commits/index.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/indexer.d.ts +43 -0
- package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts +32 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +19 -0
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts +47 -0
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -0
- package/dist/features/magic-context/index.d.ts +12 -0
- package/dist/features/magic-context/index.d.ts.map +1 -0
- package/dist/features/magic-context/key-files/aft-availability.d.ts +11 -0
- package/dist/features/magic-context/key-files/aft-availability.d.ts.map +1 -0
- package/dist/features/magic-context/key-files/identify-key-files.d.ts +84 -0
- package/dist/features/magic-context/key-files/identify-key-files.d.ts.map +1 -0
- package/dist/features/magic-context/key-files/project-key-files.d.ts +42 -0
- package/dist/features/magic-context/key-files/project-key-files.d.ts.map +1 -0
- package/dist/features/magic-context/key-files/read-history.d.ts +26 -0
- package/dist/features/magic-context/key-files/read-history.d.ts.map +1 -0
- package/dist/features/magic-context/key-files/read-stats.d.ts +20 -0
- package/dist/features/magic-context/key-files/read-stats.d.ts.map +1 -0
- package/dist/features/magic-context/key-files/storage-key-files.d.ts +25 -0
- package/dist/features/magic-context/key-files/storage-key-files.d.ts.map +1 -0
- package/dist/features/magic-context/memory/constants.d.ts +5 -0
- package/dist/features/magic-context/memory/constants.d.ts.map +1 -0
- package/dist/features/magic-context/memory/cosine-similarity.d.ts +2 -0
- package/dist/features/magic-context/memory/cosine-similarity.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-backfill.d.ts +9 -0
- package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-cache.d.ts +8 -0
- package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-identity.d.ts +11 -0
- package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts +20 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts +44 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-probe.d.ts +69 -0
- package/dist/features/magic-context/memory/embedding-probe.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-provider.d.ts +15 -0
- package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding.d.ts +39 -0
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -0
- package/dist/features/magic-context/memory/index.d.ts +12 -0
- package/dist/features/magic-context/memory/index.d.ts.map +1 -0
- package/dist/features/magic-context/memory/normalize-hash.d.ts +3 -0
- package/dist/features/magic-context/memory/normalize-hash.d.ts.map +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts +23 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -0
- package/dist/features/magic-context/memory/promotion.d.ts +13 -0
- package/dist/features/magic-context/memory/promotion.d.ts.map +1 -0
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +8 -0
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -0
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts +12 -0
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -0
- package/dist/features/magic-context/memory/storage-memory.d.ts +31 -0
- package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -0
- package/dist/features/magic-context/memory/types.d.ts +37 -0
- package/dist/features/magic-context/memory/types.d.ts.map +1 -0
- package/dist/features/magic-context/message-index-async.d.ts +12 -0
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -0
- package/dist/features/magic-context/message-index.d.ts +10 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -0
- package/dist/features/magic-context/migrations.d.ts +33 -0
- package/dist/features/magic-context/migrations.d.ts.map +1 -0
- package/dist/features/magic-context/mock-database.d.ts +3 -0
- package/dist/features/magic-context/mock-database.d.ts.map +1 -0
- package/dist/features/magic-context/overflow-detection.d.ts +51 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -0
- package/dist/features/magic-context/plugin-messages.d.ts +75 -0
- package/dist/features/magic-context/plugin-messages.d.ts.map +1 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts +44 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -0
- package/dist/features/magic-context/range-parser.d.ts +13 -0
- package/dist/features/magic-context/range-parser.d.ts.map +1 -0
- package/dist/features/magic-context/resolve-subagent-fallback.d.ts +40 -0
- package/dist/features/magic-context/resolve-subagent-fallback.d.ts.map +1 -0
- package/dist/features/magic-context/scheduler.d.ts +18 -0
- package/dist/features/magic-context/scheduler.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts +69 -0
- package/dist/features/magic-context/search.d.ts.map +1 -0
- package/dist/features/magic-context/sidekick/agent.d.ts +13 -0
- package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -0
- package/dist/features/magic-context/sidekick/core.d.ts +38 -0
- package/dist/features/magic-context/sidekick/core.d.ts.map +1 -0
- package/dist/features/magic-context/sidekick/index.d.ts +3 -0
- package/dist/features/magic-context/sidekick/index.d.ts.map +1 -0
- package/dist/features/magic-context/storage-db.d.ts +48 -0
- package/dist/features/magic-context/storage-db.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts +246 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-session.d.ts +6 -0
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-shared.d.ts +31 -0
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta.d.ts +3 -0
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -0
- package/dist/features/magic-context/storage-notes.d.ts +62 -0
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -0
- package/dist/features/magic-context/storage-ops.d.ts +7 -0
- package/dist/features/magic-context/storage-ops.d.ts.map +1 -0
- package/dist/features/magic-context/storage-source.d.ts +5 -0
- package/dist/features/magic-context/storage-source.d.ts.map +1 -0
- package/dist/features/magic-context/storage-subagent-invocations.d.ts +52 -0
- package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -0
- package/dist/features/magic-context/storage-tags.d.ts +206 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -0
- package/dist/features/magic-context/storage.d.ts +11 -0
- package/dist/features/magic-context/storage.d.ts.map +1 -0
- package/dist/features/magic-context/subagent-token-capture.d.ts +33 -0
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -0
- package/dist/features/magic-context/tagger.d.ts +64 -0
- package/dist/features/magic-context/tagger.d.ts.map +1 -0
- package/dist/features/magic-context/tool-definition-tokens.d.ts +79 -0
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -0
- package/dist/features/magic-context/tool-owner-backfill.d.ts +90 -0
- package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -0
- package/dist/features/magic-context/types.d.ts +72 -0
- package/dist/features/magic-context/types.d.ts.map +1 -0
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts +22 -0
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -0
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +33 -0
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -0
- package/dist/features/magic-context/work-metrics.d.ts +13 -0
- package/dist/features/magic-context/work-metrics.d.ts.map +1 -0
- package/dist/hooks/auto-update-checker/cache.d.ts +23 -0
- package/dist/hooks/auto-update-checker/cache.d.ts.map +1 -0
- package/dist/hooks/auto-update-checker/checker.d.ts +13 -0
- package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -0
- package/dist/hooks/auto-update-checker/constants.d.ts +10 -0
- package/dist/hooks/auto-update-checker/constants.d.ts.map +1 -0
- package/dist/hooks/auto-update-checker/index.d.ts +40 -0
- package/dist/hooks/auto-update-checker/index.d.ts.map +1 -0
- package/dist/hooks/auto-update-checker/types.d.ts +50 -0
- package/dist/hooks/auto-update-checker/types.d.ts.map +1 -0
- package/dist/hooks/is-anthropic-provider.d.ts +2 -0
- package/dist/hooks/is-anthropic-provider.d.ts.map +1 -0
- package/dist/hooks/magic-context/apply-context-nudge.d.ts +5 -0
- package/dist/hooks/magic-context/apply-context-nudge.d.ts.map +1 -0
- package/dist/hooks/magic-context/apply-operations.d.ts +7 -0
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts +34 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts +53 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -0
- package/dist/hooks/magic-context/boundary-execution.d.ts +24 -0
- package/dist/hooks/magic-context/boundary-execution.d.ts.map +1 -0
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +10 -0
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts +86 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -0
- package/dist/hooks/magic-context/caveman.d.ts +35 -0
- package/dist/hooks/magic-context/caveman.d.ts.map +1 -0
- package/dist/hooks/magic-context/command-handler.d.ts +89 -0
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +106 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-parser.d.ts +18 -0
- package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-prompt.d.ts +19 -0
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-compressor.d.ts +87 -0
- package/dist/hooks/magic-context/compartment-runner-compressor.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +26 -0
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +42 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +6 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-mapping.d.ts +33 -0
- package/dist/hooks/magic-context/compartment-runner-mapping.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts +29 -0
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +3 -0
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts +21 -0
- package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +102 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +28 -0
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner.d.ts +54 -0
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-trigger.d.ts +17 -0
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts +57 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -0
- package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts +4 -0
- package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts.map +1 -0
- package/dist/hooks/magic-context/event-handler.d.ts +49 -0
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -0
- package/dist/hooks/magic-context/event-payloads.d.ts +62 -0
- package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -0
- package/dist/hooks/magic-context/event-resolvers.d.ts +72 -0
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -0
- package/dist/hooks/magic-context/execute-flush.d.ts +3 -0
- package/dist/hooks/magic-context/execute-flush.d.ts.map +1 -0
- package/dist/hooks/magic-context/execute-status.d.ts +12 -0
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -0
- package/dist/hooks/magic-context/format-bytes.d.ts +2 -0
- package/dist/hooks/magic-context/format-bytes.d.ts.map +1 -0
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +22 -0
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -0
- package/dist/hooks/magic-context/historian-state-file.d.ts +43 -0
- package/dist/hooks/magic-context/historian-state-file.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts +165 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts +118 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -0
- package/dist/hooks/magic-context/image-token-estimate.d.ts +6 -0
- package/dist/hooks/magic-context/image-token-estimate.d.ts.map +1 -0
- package/dist/hooks/magic-context/index.d.ts +3 -0
- package/dist/hooks/magic-context/index.d.ts.map +1 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts +52 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -0
- package/dist/hooks/magic-context/key-files-block.d.ts +27 -0
- package/dist/hooks/magic-context/key-files-block.d.ts.map +1 -0
- package/dist/hooks/magic-context/live-session-state.d.ts +42 -0
- package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -0
- package/dist/hooks/magic-context/note-nudger.d.ts +71 -0
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -0
- package/dist/hooks/magic-context/note-visibility.d.ts +43 -0
- package/dist/hooks/magic-context/note-visibility.d.ts.map +1 -0
- package/dist/hooks/magic-context/nudge-bands.d.ts +6 -0
- package/dist/hooks/magic-context/nudge-bands.d.ts.map +1 -0
- package/dist/hooks/magic-context/nudge-injection.d.ts +7 -0
- package/dist/hooks/magic-context/nudge-injection.d.ts.map +1 -0
- package/dist/hooks/magic-context/nudge-placement-store.d.ts +15 -0
- package/dist/hooks/magic-context/nudge-placement-store.d.ts.map +1 -0
- package/dist/hooks/magic-context/nudger.d.ts +21 -0
- package/dist/hooks/magic-context/nudger.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts +99 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-db.d.ts +21 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts +35 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts +10 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -0
- package/dist/hooks/magic-context/send-session-notification.d.ts +13 -0
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -0
- package/dist/hooks/magic-context/sentinel.d.ts +102 -0
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +140 -0
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-structural-noise.d.ts +17 -0
- package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-injection-stripper.d.ts +2 -0
- package/dist/hooks/magic-context/system-injection-stripper.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +85 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-content-primitives.d.ts +6 -0
- package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-id-fallback.d.ts +9 -0
- package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-messages.d.ts +48 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-part-guards.d.ts +23 -0
- package/dist/hooks/magic-context/tag-part-guards.d.ts.map +1 -0
- package/dist/hooks/magic-context/temporal-awareness.d.ts +73 -0
- package/dist/hooks/magic-context/temporal-awareness.d.ts.map +1 -0
- package/dist/hooks/magic-context/text-complete.d.ts +8 -0
- package/dist/hooks/magic-context/text-complete.d.ts.map +1 -0
- package/dist/hooks/magic-context/todo-view.d.ts +102 -0
- package/dist/hooks/magic-context/todo-view.d.ts.map +1 -0
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts +85 -0
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts +48 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +66 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts +12 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-message-helpers.d.ts +29 -0
- package/dist/hooks/magic-context/transform-message-helpers.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-operations.d.ts +5 -0
- package/dist/hooks/magic-context/transform-operations.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +100 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +2 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform.d.ts +145 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +179800 -0
- package/dist/plugin/conflict-warning-hook.d.ts +34 -0
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -0
- package/dist/plugin/dream-timer.d.ts +44 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -0
- package/dist/plugin/embedding-bootstrap-helpers.d.ts +35 -0
- package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -0
- package/dist/plugin/embedding-bootstrap.d.ts +3 -0
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -0
- package/dist/plugin/event.d.ts +13 -0
- package/dist/plugin/event.d.ts.map +1 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts +44 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -0
- package/dist/plugin/messages-transform.d.ts +46 -0
- package/dist/plugin/messages-transform.d.ts.map +1 -0
- package/dist/plugin/normalize-tool-arg-schemas.d.ts +7 -0
- package/dist/plugin/normalize-tool-arg-schemas.d.ts.map +1 -0
- package/dist/plugin/rpc-handlers.d.ts +21 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -0
- package/dist/plugin/sidebar-snapshot-cache.d.ts +19 -0
- package/dist/plugin/sidebar-snapshot-cache.d.ts.map +1 -0
- package/dist/plugin/tool-registry.d.ts +8 -0
- package/dist/plugin/tool-registry.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +3 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/shared/announcement.d.ts +55 -0
- package/dist/shared/announcement.d.ts.map +1 -0
- package/dist/shared/assistant-message-extractor.d.ts +2 -0
- package/dist/shared/assistant-message-extractor.d.ts.map +1 -0
- package/dist/shared/bounded-session-map.d.ts +45 -0
- package/dist/shared/bounded-session-map.d.ts.map +1 -0
- package/dist/shared/conflict-detector.d.ts +74 -0
- package/dist/shared/conflict-detector.d.ts.map +1 -0
- package/dist/shared/conflict-fixer.d.ts +3 -0
- package/dist/shared/conflict-fixer.d.ts.map +1 -0
- package/dist/shared/data-path.d.ts +121 -0
- package/dist/shared/data-path.d.ts.map +1 -0
- package/dist/shared/error-message.d.ts +32 -0
- package/dist/shared/error-message.d.ts.map +1 -0
- package/dist/shared/format-bytes.d.ts +2 -0
- package/dist/shared/format-bytes.d.ts.map +1 -0
- package/dist/shared/format-threshold.d.ts +24 -0
- package/dist/shared/format-threshold.d.ts.map +1 -0
- package/dist/shared/harness.d.ts +43 -0
- package/dist/shared/harness.d.ts.map +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/internal-initiator-marker.d.ts +2 -0
- package/dist/shared/internal-initiator-marker.d.ts.map +1 -0
- package/dist/shared/jsonc-parser.d.ts +8 -0
- package/dist/shared/jsonc-parser.d.ts.map +1 -0
- package/dist/shared/logger.d.ts +10 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/model-requirements.d.ts +26 -0
- package/dist/shared/model-requirements.d.ts.map +1 -0
- package/dist/shared/model-suggestion-retry.d.ts +68 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -0
- package/dist/shared/models-dev-cache.d.ts +65 -0
- package/dist/shared/models-dev-cache.d.ts.map +1 -0
- package/dist/shared/native-binding.d.ts +87 -0
- package/dist/shared/native-binding.d.ts.map +1 -0
- package/dist/shared/normalize-sdk-response.d.ts +5 -0
- package/dist/shared/normalize-sdk-response.d.ts.map +1 -0
- package/dist/shared/opencode-compaction-detector.d.ts +2 -0
- package/dist/shared/opencode-compaction-detector.d.ts.map +1 -0
- package/dist/shared/opencode-config-dir-types.d.ts +14 -0
- package/dist/shared/opencode-config-dir-types.d.ts.map +1 -0
- package/dist/shared/opencode-config-dir.d.ts +5 -0
- package/dist/shared/opencode-config-dir.d.ts.map +1 -0
- package/dist/shared/record-type-guard.d.ts +2 -0
- package/dist/shared/record-type-guard.d.ts.map +1 -0
- package/dist/shared/resolve-fallbacks.d.ts +32 -0
- package/dist/shared/resolve-fallbacks.d.ts.map +1 -0
- package/dist/shared/rpc-client.d.ts +17 -0
- package/dist/shared/rpc-client.d.ts.map +1 -0
- package/dist/shared/rpc-notifications.d.ts +24 -0
- package/dist/shared/rpc-notifications.d.ts.map +1 -0
- package/dist/shared/rpc-server.d.ts +20 -0
- package/dist/shared/rpc-server.d.ts.map +1 -0
- package/dist/shared/rpc-types.d.ts +105 -0
- package/dist/shared/rpc-types.d.ts.map +1 -0
- package/dist/shared/rpc-utils.d.ts +19 -0
- package/dist/shared/rpc-utils.d.ts.map +1 -0
- package/dist/shared/sqlite-helpers.d.ts +16 -0
- package/dist/shared/sqlite-helpers.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +43 -0
- package/dist/shared/sqlite.d.ts.map +1 -0
- package/dist/shared/stable-json.d.ts +21 -0
- package/dist/shared/stable-json.d.ts.map +1 -0
- package/dist/shared/subagent-runner.d.ts +208 -0
- package/dist/shared/subagent-runner.d.ts.map +1 -0
- package/dist/shared/system-directive.d.ts +3 -0
- package/dist/shared/system-directive.d.ts.map +1 -0
- package/dist/shared/tag-transcript.d.ts +66 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -0
- package/dist/shared/transcript-opencode.d.ts +71 -0
- package/dist/shared/transcript-opencode.d.ts.map +1 -0
- package/dist/shared/transcript.d.ts +212 -0
- package/dist/shared/transcript.d.ts.map +1 -0
- package/dist/shared/tui-config.d.ts +10 -0
- package/dist/shared/tui-config.d.ts.map +1 -0
- package/dist/tools/ctx-expand/constants.d.ts +3 -0
- package/dist/tools/ctx-expand/constants.d.ts.map +1 -0
- package/dist/tools/ctx-expand/index.d.ts +2 -0
- package/dist/tools/ctx-expand/index.d.ts.map +1 -0
- package/dist/tools/ctx-expand/tools.d.ts +3 -0
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -0
- package/dist/tools/ctx-expand/types.d.ts +5 -0
- package/dist/tools/ctx-expand/types.d.ts.map +1 -0
- package/dist/tools/ctx-memory/constants.d.ts +4 -0
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -0
- package/dist/tools/ctx-memory/index.d.ts +4 -0
- package/dist/tools/ctx-memory/index.d.ts.map +1 -0
- package/dist/tools/ctx-memory/tools.d.ts +4 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -0
- package/dist/tools/ctx-memory/types.d.ts +35 -0
- package/dist/tools/ctx-memory/types.d.ts.map +1 -0
- package/dist/tools/ctx-note/constants.d.ts +2 -0
- package/dist/tools/ctx-note/constants.d.ts.map +1 -0
- package/dist/tools/ctx-note/index.d.ts +4 -0
- package/dist/tools/ctx-note/index.d.ts.map +1 -0
- package/dist/tools/ctx-note/tools.d.ts +15 -0
- package/dist/tools/ctx-note/tools.d.ts.map +1 -0
- package/dist/tools/ctx-note/types.d.ts +9 -0
- package/dist/tools/ctx-note/types.d.ts.map +1 -0
- package/dist/tools/ctx-reduce/constants.d.ts +2 -0
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -0
- package/dist/tools/ctx-reduce/index.d.ts +4 -0
- package/dist/tools/ctx-reduce/index.d.ts.map +1 -0
- package/dist/tools/ctx-reduce/tools.d.ts +9 -0
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -0
- package/dist/tools/ctx-reduce/types.d.ts +4 -0
- package/dist/tools/ctx-reduce/types.d.ts.map +1 -0
- package/dist/tools/ctx-search/constants.d.ts +4 -0
- package/dist/tools/ctx-search/constants.d.ts.map +1 -0
- package/dist/tools/ctx-search/index.d.ts +4 -0
- package/dist/tools/ctx-search/index.d.ts.map +1 -0
- package/dist/tools/ctx-search/tools.d.ts +4 -0
- package/dist/tools/ctx-search/tools.d.ts.map +1 -0
- package/dist/tools/ctx-search/types.d.ts +34 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tui/data/context-db.d.ts +36 -0
- package/dist/tui/data/context-db.d.ts.map +1 -0
- package/package.json +80 -0
- package/src/shared/announcement.test.ts +143 -0
- package/src/shared/announcement.ts +97 -0
- package/src/shared/assistant-message-extractor.ts +74 -0
- package/src/shared/bounded-session-map.test.ts +97 -0
- package/src/shared/bounded-session-map.ts +84 -0
- package/src/shared/conflict-detector.test.ts +232 -0
- package/src/shared/conflict-detector.ts +371 -0
- package/src/shared/conflict-fixer.test.ts +124 -0
- package/src/shared/conflict-fixer.ts +222 -0
- package/src/shared/data-path.test.ts +159 -0
- package/src/shared/data-path.ts +155 -0
- package/src/shared/error-message.test.ts +94 -0
- package/src/shared/error-message.ts +115 -0
- package/src/shared/format-bytes.ts +5 -0
- package/src/shared/format-threshold.ts +28 -0
- package/src/shared/harness.ts +61 -0
- package/src/shared/index.ts +5 -0
- package/src/shared/internal-initiator-marker.ts +1 -0
- package/src/shared/jsonc-parser.ts +138 -0
- package/src/shared/logger.ts +94 -0
- package/src/shared/model-requirements.ts +86 -0
- package/src/shared/model-suggestion-retry.test.ts +251 -0
- package/src/shared/model-suggestion-retry.ts +348 -0
- package/src/shared/models-dev-cache.test.ts +394 -0
- package/src/shared/models-dev-cache.ts +337 -0
- package/src/shared/native-binding.ts +311 -0
- package/src/shared/normalize-sdk-response.ts +40 -0
- package/src/shared/opencode-compaction-detector.test.ts +222 -0
- package/src/shared/opencode-compaction-detector.ts +81 -0
- package/src/shared/opencode-config-dir-types.ts +15 -0
- package/src/shared/opencode-config-dir.ts +38 -0
- package/src/shared/record-type-guard.ts +3 -0
- package/src/shared/resolve-fallbacks.test.ts +136 -0
- package/src/shared/resolve-fallbacks.ts +76 -0
- package/src/shared/rpc-client.test.ts +161 -0
- package/src/shared/rpc-client.ts +183 -0
- package/src/shared/rpc-notifications.test.ts +20 -0
- package/src/shared/rpc-notifications.ts +53 -0
- package/src/shared/rpc-server.ts +174 -0
- package/src/shared/rpc-types.ts +104 -0
- package/src/shared/rpc-utils.ts +72 -0
- package/src/shared/session-messages-bounded.test.ts +112 -0
- package/src/shared/sqlite-helpers.ts +27 -0
- package/src/shared/sqlite.ts +134 -0
- package/src/shared/stable-json.test.ts +87 -0
- package/src/shared/stable-json.ts +37 -0
- package/src/shared/subagent-runner.ts +222 -0
- package/src/shared/system-directive.ts +9 -0
- package/src/shared/tag-transcript.ts +553 -0
- package/src/shared/transcript-opencode.ts +259 -0
- package/src/shared/transcript.ts +226 -0
- package/src/shared/tui-config.ts +99 -0
- package/src/tui/data/context-db.ts +303 -0
- package/src/tui/index.tsx +692 -0
- package/src/tui/slots/sidebar-content.tsx +482 -0
- package/src/tui/types/opencode-plugin-tui.d.ts +232 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/// <reference types="bun-types" />
|
|
2
|
+
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
4
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { parse as parseJsonc } from "comment-json";
|
|
8
|
+
import { fixConflicts } from "./conflict-fixer";
|
|
9
|
+
|
|
10
|
+
const noOmoConflicts = {
|
|
11
|
+
omoPreemptiveCompaction: false,
|
|
12
|
+
omoContextWindowMonitor: false,
|
|
13
|
+
omoAnthropicRecovery: false,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe("fixConflicts", () => {
|
|
17
|
+
let root: string;
|
|
18
|
+
let projectDir: string;
|
|
19
|
+
let userConfigDir: string;
|
|
20
|
+
let originalEnv: Record<string, string | undefined>;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
root = mkdtempSync(join(tmpdir(), "mc-conflict-fixer-"));
|
|
24
|
+
projectDir = join(root, "project");
|
|
25
|
+
userConfigDir = join(root, "user-config", "opencode");
|
|
26
|
+
mkdirSync(projectDir, { recursive: true });
|
|
27
|
+
mkdirSync(userConfigDir, { recursive: true });
|
|
28
|
+
originalEnv = {
|
|
29
|
+
OPENCODE_CONFIG_DIR: process.env.OPENCODE_CONFIG_DIR,
|
|
30
|
+
XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME,
|
|
31
|
+
};
|
|
32
|
+
process.env.OPENCODE_CONFIG_DIR = userConfigDir;
|
|
33
|
+
delete process.env.XDG_CONFIG_HOME;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
for (const [key, value] of Object.entries(originalEnv)) {
|
|
38
|
+
if (value === undefined) delete process.env[key];
|
|
39
|
+
else process.env[key] = value;
|
|
40
|
+
}
|
|
41
|
+
rmSync(root, { recursive: true, force: true });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("preserves JSONC comments and tuple plugin entries while removing canonical DCP", () => {
|
|
45
|
+
const configPath = join(projectDir, "opencode.jsonc");
|
|
46
|
+
writeFileSync(
|
|
47
|
+
configPath,
|
|
48
|
+
`{
|
|
49
|
+
// keep this file-level comment
|
|
50
|
+
"plugin": [
|
|
51
|
+
["@plannotator/opencode@latest", { "workflow": "plan-agent" }],
|
|
52
|
+
["@tarquinen/opencode-dcp@latest", { "enabled": true }],
|
|
53
|
+
"@wolfx/opencode-magic-context@latest"
|
|
54
|
+
],
|
|
55
|
+
"compaction": {
|
|
56
|
+
// keep this compaction comment
|
|
57
|
+
"auto": true,
|
|
58
|
+
"prune": true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const actions = fixConflicts(projectDir, {
|
|
65
|
+
compactionAuto: true,
|
|
66
|
+
compactionPrune: true,
|
|
67
|
+
dcpPlugin: true,
|
|
68
|
+
...noOmoConflicts,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const updatedText = readFileSync(configPath, "utf-8");
|
|
72
|
+
const updated = parseJsonc(updatedText) as Record<string, unknown>;
|
|
73
|
+
expect(actions).toEqual(["Disabled auto-compaction", "Removed opencode-dcp plugin"]);
|
|
74
|
+
expect(updatedText).toContain("keep this file-level comment");
|
|
75
|
+
expect(updatedText).toContain("keep this compaction comment");
|
|
76
|
+
expect(updated.compaction).toEqual({ auto: false, prune: false });
|
|
77
|
+
expect(updated.plugin).toEqual([
|
|
78
|
+
["@plannotator/opencode@latest", { workflow: "plan-agent" }],
|
|
79
|
+
"@wolfx/opencode-magic-context@latest",
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("skips non-existent target files instead of creating user config", () => {
|
|
84
|
+
const actions = fixConflicts(projectDir, {
|
|
85
|
+
compactionAuto: true,
|
|
86
|
+
compactionPrune: true,
|
|
87
|
+
dcpPlugin: true,
|
|
88
|
+
...noOmoConflicts,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(actions).toEqual([]);
|
|
92
|
+
expect(existsSync(join(userConfigDir, "opencode.json"))).toBe(false);
|
|
93
|
+
expect(existsSync(join(userConfigDir, "opencode.jsonc"))).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("keeps DCP forks and substring-only names because matching is canonical", () => {
|
|
97
|
+
const configPath = join(projectDir, "opencode.json");
|
|
98
|
+
writeFileSync(
|
|
99
|
+
configPath,
|
|
100
|
+
JSON.stringify({
|
|
101
|
+
plugin: [
|
|
102
|
+
"@some-fork/opencode-dcp-fork",
|
|
103
|
+
"file:///tmp/opencode-dcp-dev",
|
|
104
|
+
["@other/opencode-dcp-slim@latest", { enabled: true }],
|
|
105
|
+
],
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const actions = fixConflicts(projectDir, {
|
|
110
|
+
compactionAuto: false,
|
|
111
|
+
compactionPrune: false,
|
|
112
|
+
dcpPlugin: true,
|
|
113
|
+
...noOmoConflicts,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const updated = parseJsonc(readFileSync(configPath, "utf-8")) as Record<string, unknown>;
|
|
117
|
+
expect(actions).toEqual([]);
|
|
118
|
+
expect(updated.plugin).toEqual([
|
|
119
|
+
"@some-fork/opencode-dcp-fork",
|
|
120
|
+
"file:///tmp/opencode-dcp-dev",
|
|
121
|
+
["@other/opencode-dcp-slim@latest", { enabled: true }],
|
|
122
|
+
]);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse, stringify } from "comment-json";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type ConflictResult,
|
|
7
|
+
DCP_PACKAGE_NAMES,
|
|
8
|
+
extractPluginName,
|
|
9
|
+
matchesPackageName,
|
|
10
|
+
} from "./conflict-detector";
|
|
11
|
+
import { getOpenCodeConfigPaths } from "./opencode-config-dir";
|
|
12
|
+
|
|
13
|
+
type JsonObject = Record<string, unknown>;
|
|
14
|
+
|
|
15
|
+
const CONFLICTING_OMO_HOOKS = [
|
|
16
|
+
"context-window-monitor",
|
|
17
|
+
"preemptive-compaction",
|
|
18
|
+
"anthropic-context-window-limit-recovery",
|
|
19
|
+
] as const;
|
|
20
|
+
|
|
21
|
+
const OMO_CONFIG_NAMES = [
|
|
22
|
+
"oh-my-openagent.jsonc",
|
|
23
|
+
"oh-my-openagent.json",
|
|
24
|
+
"oh-my-opencode.jsonc",
|
|
25
|
+
"oh-my-opencode.json",
|
|
26
|
+
] as const;
|
|
27
|
+
|
|
28
|
+
function isRecord(value: unknown): value is JsonObject {
|
|
29
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function asStringArray(value: unknown): string[] {
|
|
33
|
+
return Array.isArray(value)
|
|
34
|
+
? value.filter((item): item is string => typeof item === "string")
|
|
35
|
+
: [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function readConfig(filePath: string): JsonObject | null {
|
|
39
|
+
if (!existsSync(filePath)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const parsed = parse(readFileSync(filePath, "utf-8"));
|
|
45
|
+
return isRecord(parsed) ? parsed : null;
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function writeConfig(filePath: string, config: JsonObject): void {
|
|
52
|
+
writeFileSync(filePath, `${stringify(config, null, 2)}\n`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function resolveUserOpenCodeConfigPath(): string {
|
|
56
|
+
const paths = getOpenCodeConfigPaths({ binary: "opencode" });
|
|
57
|
+
if (existsSync(paths.configJsonc)) return paths.configJsonc;
|
|
58
|
+
return paths.configJson;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function collectOpenCodeConfigPaths(directory: string): string[] {
|
|
62
|
+
const paths = new Set<string>();
|
|
63
|
+
const userConfig = resolveUserOpenCodeConfigPath();
|
|
64
|
+
|
|
65
|
+
if (existsSync(userConfig)) {
|
|
66
|
+
paths.add(userConfig);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const filePath of [
|
|
70
|
+
join(directory, ".opencode", "opencode.jsonc"),
|
|
71
|
+
join(directory, ".opencode", "opencode.json"),
|
|
72
|
+
join(directory, "opencode.jsonc"),
|
|
73
|
+
join(directory, "opencode.json"),
|
|
74
|
+
]) {
|
|
75
|
+
if (existsSync(filePath)) {
|
|
76
|
+
paths.add(filePath);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return [...paths];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function collectOmoConfigPaths(directory: string): string[] {
|
|
84
|
+
const paths = new Set<string>();
|
|
85
|
+
const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
|
|
86
|
+
|
|
87
|
+
for (const fileName of OMO_CONFIG_NAMES) {
|
|
88
|
+
const userPath = join(configDir, fileName);
|
|
89
|
+
const projectPath = join(directory, fileName);
|
|
90
|
+
|
|
91
|
+
if (existsSync(userPath)) {
|
|
92
|
+
paths.add(userPath);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (existsSync(projectPath)) {
|
|
96
|
+
paths.add(projectPath);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return [...paths];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function filterDcpPluginEntries(entries: unknown[]): { plugins: unknown[]; removed: boolean } {
|
|
104
|
+
const plugins = entries.filter((entry) => {
|
|
105
|
+
const name = extractPluginName(entry);
|
|
106
|
+
return name ? !matchesPackageName(name, DCP_PACKAGE_NAMES) : true;
|
|
107
|
+
});
|
|
108
|
+
return { plugins, removed: plugins.length !== entries.length };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function fixConflicts(directory: string, conflicts: ConflictResult["conflicts"]): string[] {
|
|
112
|
+
const actions: string[] = [];
|
|
113
|
+
let updatedCompaction = false;
|
|
114
|
+
let removedDcpPlugin = false;
|
|
115
|
+
let disabledOmoHooks = false;
|
|
116
|
+
|
|
117
|
+
if (conflicts.compactionAuto || conflicts.compactionPrune || conflicts.dcpPlugin) {
|
|
118
|
+
for (const configPath of collectOpenCodeConfigPaths(directory)) {
|
|
119
|
+
const config = readConfig(configPath);
|
|
120
|
+
if (!config) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let changed = false;
|
|
125
|
+
|
|
126
|
+
if (conflicts.compactionAuto || conflicts.compactionPrune) {
|
|
127
|
+
const compaction = isRecord(config.compaction) ? config.compaction : {};
|
|
128
|
+
|
|
129
|
+
if (compaction.auto !== false) {
|
|
130
|
+
compaction.auto = false;
|
|
131
|
+
changed = true;
|
|
132
|
+
updatedCompaction = true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (compaction.prune !== false) {
|
|
136
|
+
compaction.prune = false;
|
|
137
|
+
changed = true;
|
|
138
|
+
updatedCompaction = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
config.compaction = compaction;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (conflicts.dcpPlugin) {
|
|
145
|
+
const plugins = Array.isArray(config.plugin) ? config.plugin : [];
|
|
146
|
+
const filtered = filterDcpPluginEntries(plugins);
|
|
147
|
+
|
|
148
|
+
if (filtered.removed) {
|
|
149
|
+
config.plugin = filtered.plugins;
|
|
150
|
+
changed = true;
|
|
151
|
+
removedDcpPlugin = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (changed) {
|
|
156
|
+
writeConfig(configPath, config);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (
|
|
162
|
+
conflicts.omoContextWindowMonitor ||
|
|
163
|
+
conflicts.omoPreemptiveCompaction ||
|
|
164
|
+
conflicts.omoAnthropicRecovery
|
|
165
|
+
) {
|
|
166
|
+
const hooksToDisable = new Set<string>();
|
|
167
|
+
if (conflicts.omoContextWindowMonitor) {
|
|
168
|
+
hooksToDisable.add("context-window-monitor");
|
|
169
|
+
}
|
|
170
|
+
if (conflicts.omoPreemptiveCompaction) {
|
|
171
|
+
hooksToDisable.add("preemptive-compaction");
|
|
172
|
+
}
|
|
173
|
+
if (conflicts.omoAnthropicRecovery) {
|
|
174
|
+
hooksToDisable.add("anthropic-context-window-limit-recovery");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
for (const configPath of collectOmoConfigPaths(directory)) {
|
|
178
|
+
const config = readConfig(configPath);
|
|
179
|
+
if (!config) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const disabledHooks = new Set(asStringArray(config.disabled_hooks));
|
|
184
|
+
let changed = false;
|
|
185
|
+
|
|
186
|
+
for (const hook of hooksToDisable) {
|
|
187
|
+
if (!disabledHooks.has(hook)) {
|
|
188
|
+
disabledHooks.add(hook);
|
|
189
|
+
changed = true;
|
|
190
|
+
disabledOmoHooks = true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (changed) {
|
|
195
|
+
config.disabled_hooks = [
|
|
196
|
+
...CONFLICTING_OMO_HOOKS.filter((hook) => disabledHooks.has(hook)),
|
|
197
|
+
...[...disabledHooks].filter(
|
|
198
|
+
(hook) =>
|
|
199
|
+
!CONFLICTING_OMO_HOOKS.includes(
|
|
200
|
+
hook as (typeof CONFLICTING_OMO_HOOKS)[number],
|
|
201
|
+
),
|
|
202
|
+
),
|
|
203
|
+
];
|
|
204
|
+
writeConfig(configPath, config);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (updatedCompaction) {
|
|
210
|
+
actions.push("Disabled auto-compaction");
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (removedDcpPlugin) {
|
|
214
|
+
actions.push("Removed opencode-dcp plugin");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (disabledOmoHooks) {
|
|
218
|
+
actions.push("Disabled conflicting oh-my-opencode hooks");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return actions;
|
|
222
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import {
|
|
5
|
+
getCacheDir,
|
|
6
|
+
getDataDir,
|
|
7
|
+
getLegacyOpenCodeMagicContextStorageDir,
|
|
8
|
+
getMagicContextStorageDir,
|
|
9
|
+
getOpenCodeCacheDir,
|
|
10
|
+
getOpenCodeStorageDir,
|
|
11
|
+
getProjectMagicContextDir,
|
|
12
|
+
getProjectMagicContextHistorianDir,
|
|
13
|
+
} from "./data-path";
|
|
14
|
+
|
|
15
|
+
const savedEnv = {
|
|
16
|
+
XDG_CACHE_HOME: process.env.XDG_CACHE_HOME,
|
|
17
|
+
XDG_DATA_HOME: process.env.XDG_DATA_HOME,
|
|
18
|
+
LOCALAPPDATA: process.env.LOCALAPPDATA,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
describe("data-path", () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
process.env.XDG_CACHE_HOME = undefined;
|
|
24
|
+
process.env.XDG_DATA_HOME = undefined;
|
|
25
|
+
process.env.LOCALAPPDATA = undefined;
|
|
26
|
+
// Bun's env handling: explicit delete for unset
|
|
27
|
+
delete process.env.XDG_CACHE_HOME;
|
|
28
|
+
delete process.env.XDG_DATA_HOME;
|
|
29
|
+
delete process.env.LOCALAPPDATA;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
if (savedEnv.XDG_CACHE_HOME !== undefined)
|
|
34
|
+
process.env.XDG_CACHE_HOME = savedEnv.XDG_CACHE_HOME;
|
|
35
|
+
if (savedEnv.XDG_DATA_HOME !== undefined)
|
|
36
|
+
process.env.XDG_DATA_HOME = savedEnv.XDG_DATA_HOME;
|
|
37
|
+
if (savedEnv.LOCALAPPDATA !== undefined) process.env.LOCALAPPDATA = savedEnv.LOCALAPPDATA;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("getCacheDir falls back to <homedir>/.cache when XDG_CACHE_HOME is unset (all platforms)", () => {
|
|
41
|
+
// Matches OpenCode's xdg-basedir behavior on every platform, including
|
|
42
|
+
// Windows. A previous bug mapped Windows to %LOCALAPPDATA% and caused
|
|
43
|
+
// doctor --force to target a non-existent cache directory.
|
|
44
|
+
expect(getCacheDir()).toBe(path.join(os.homedir(), ".cache"));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("getCacheDir honors XDG_CACHE_HOME when set", () => {
|
|
48
|
+
process.env.XDG_CACHE_HOME = "/tmp/custom-cache";
|
|
49
|
+
expect(getCacheDir()).toBe("/tmp/custom-cache");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("getCacheDir ignores LOCALAPPDATA on Windows (must match OpenCode's xdg-basedir)", () => {
|
|
53
|
+
// Even with LOCALAPPDATA set, cache must go to ~/.cache to match
|
|
54
|
+
// OpenCode's own resolution. Otherwise doctor --force clears the
|
|
55
|
+
// wrong directory on Windows.
|
|
56
|
+
process.env.LOCALAPPDATA = "C:\\Users\\Test\\AppData\\Local";
|
|
57
|
+
expect(getCacheDir()).toBe(path.join(os.homedir(), ".cache"));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("getOpenCodeCacheDir appends 'opencode' to the cache base", () => {
|
|
61
|
+
expect(getOpenCodeCacheDir()).toBe(path.join(os.homedir(), ".cache", "opencode"));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("getOpenCodeCacheDir with XDG_CACHE_HOME set", () => {
|
|
65
|
+
process.env.XDG_CACHE_HOME = "/tmp/custom-cache";
|
|
66
|
+
expect(getOpenCodeCacheDir()).toBe(path.join("/tmp/custom-cache", "opencode"));
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("getDataDir falls back to <homedir>/.local/share when XDG_DATA_HOME is unset", () => {
|
|
70
|
+
expect(getDataDir()).toBe(path.join(os.homedir(), ".local", "share"));
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("getOpenCodeStorageDir composes correctly", () => {
|
|
74
|
+
expect(getOpenCodeStorageDir()).toBe(
|
|
75
|
+
path.join(os.homedir(), ".local", "share", "opencode", "storage"),
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("getMagicContextStorageDir uses cortexkit/magic-context layout", () => {
|
|
80
|
+
// Cross-harness shared path: both OpenCode and Pi plugins read/write here,
|
|
81
|
+
// unlike the legacy opencode/storage/plugin/magic-context location which
|
|
82
|
+
// was OpenCode-specific. See ARCHITECTURE_DECISIONS memory for rationale.
|
|
83
|
+
expect(getMagicContextStorageDir()).toBe(
|
|
84
|
+
path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context"),
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("getMagicContextStorageDir honors XDG_DATA_HOME", () => {
|
|
89
|
+
process.env.XDG_DATA_HOME = "/tmp/custom-data";
|
|
90
|
+
expect(getMagicContextStorageDir()).toBe(
|
|
91
|
+
path.join("/tmp/custom-data", "cortexkit", "magic-context"),
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("getLegacyOpenCodeMagicContextStorageDir points at the pre-cortexkit OpenCode path", () => {
|
|
96
|
+
// Used only for one-time migration of pre-shared-storage data into the new
|
|
97
|
+
// location. Must remain stable so users with legacy installs can still
|
|
98
|
+
// have their data migrated forward across multiple plugin upgrades.
|
|
99
|
+
expect(getLegacyOpenCodeMagicContextStorageDir()).toBe(
|
|
100
|
+
path.join(
|
|
101
|
+
os.homedir(),
|
|
102
|
+
".local",
|
|
103
|
+
"share",
|
|
104
|
+
"opencode",
|
|
105
|
+
"storage",
|
|
106
|
+
"plugin",
|
|
107
|
+
"magic-context",
|
|
108
|
+
),
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("legacy storage dir distinct from new shared dir even with same XDG override", () => {
|
|
113
|
+
// Sanity check: even when XDG_DATA_HOME points the same place, the two
|
|
114
|
+
// resolvers must return different paths so the migration copy doesn't
|
|
115
|
+
// self-overwrite.
|
|
116
|
+
process.env.XDG_DATA_HOME = "/tmp/test-xdg";
|
|
117
|
+
const legacy = getLegacyOpenCodeMagicContextStorageDir();
|
|
118
|
+
const shared = getMagicContextStorageDir();
|
|
119
|
+
expect(legacy).not.toBe(shared);
|
|
120
|
+
expect(legacy).toContain("opencode");
|
|
121
|
+
expect(shared).toContain("cortexkit");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("getProjectMagicContextDir composes <project>/.opencode/magic-context", () => {
|
|
125
|
+
// Project-local artifacts (historian state file, failure dumps) live
|
|
126
|
+
// inside the project so OpenCode's external_directory permission system
|
|
127
|
+
// treats them as project-internal. Without this, historian's Read tool
|
|
128
|
+
// would trigger a permission prompt on every run when artifacts lived
|
|
129
|
+
// under os.tmpdir().
|
|
130
|
+
expect(getProjectMagicContextDir("/Users/me/Work/proj")).toBe(
|
|
131
|
+
path.join("/Users/me/Work/proj", ".opencode", "magic-context"),
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("getProjectMagicContextHistorianDir appends historian/", () => {
|
|
136
|
+
expect(getProjectMagicContextHistorianDir("/Users/me/Work/proj")).toBe(
|
|
137
|
+
path.join("/Users/me/Work/proj", ".opencode", "magic-context", "historian"),
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("getProjectMagicContextDir is unaffected by XDG_DATA_HOME", () => {
|
|
142
|
+
// Project-local paths anchor to the project directory the caller
|
|
143
|
+
// passes in, NOT to any user-config env var. Setting XDG_DATA_HOME
|
|
144
|
+
// (which changes the shared storage dir) must not change the
|
|
145
|
+
// project-local historian dir.
|
|
146
|
+
process.env.XDG_DATA_HOME = "/tmp/custom-data";
|
|
147
|
+
expect(getProjectMagicContextDir("/some/project")).toBe(
|
|
148
|
+
path.join("/some/project", ".opencode", "magic-context"),
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("getProjectMagicContextDir handles trailing slashes via path.join", () => {
|
|
153
|
+
// path.join normalizes redundant separators so callers don't need to
|
|
154
|
+
// worry about how the project directory was constructed.
|
|
155
|
+
expect(getProjectMagicContextDir("/some/project/")).toBe(
|
|
156
|
+
path.join("/some/project/", ".opencode", "magic-context"),
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as os from "node:os";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { getHarness, type HarnessId } from "./harness";
|
|
4
|
+
|
|
5
|
+
export function getDataDir(): string {
|
|
6
|
+
return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Per-harness scratch directory under the OS temp dir.
|
|
11
|
+
*
|
|
12
|
+
* Layout:
|
|
13
|
+
* - OpenCode: `${os.tmpdir()}/opencode/magic-context/`
|
|
14
|
+
* - Pi: `${os.tmpdir()}/pi/magic-context/`
|
|
15
|
+
*
|
|
16
|
+
* Why a per-harness subtree of `os.tmpdir()`:
|
|
17
|
+
* 1. OpenCode Desktop runs as an Electron app with a permission sandbox.
|
|
18
|
+
* Writing to arbitrary tmp paths can trigger user-visible permission
|
|
19
|
+
* prompts; the `${tmpdir}/opencode/` subtree is allow-listed by
|
|
20
|
+
* OpenCode, so anything we put under it never asks for permission.
|
|
21
|
+
* 2. Splitting OpenCode from Pi keeps their logs and historian dump
|
|
22
|
+
* directories cleanly separated. `doctor --issue` for each harness
|
|
23
|
+
* reports diagnostics from the matching subtree, so an OpenCode
|
|
24
|
+
* issue report never includes Pi log noise (and vice versa).
|
|
25
|
+
* 3. Pi has no permission sandbox, so the path choice is purely
|
|
26
|
+
* cosmetic for Pi — it just keeps the layout symmetric.
|
|
27
|
+
*
|
|
28
|
+
* Pass an explicit `harness` only when the caller already knows the
|
|
29
|
+
* harness without relying on the global `setHarness()` state (e.g. the
|
|
30
|
+
* CLI's doctor commands, which target a specific harness regardless of
|
|
31
|
+
* which plugin is loaded). Production runtime callers should omit it so
|
|
32
|
+
* the helper picks up the boot-time harness automatically.
|
|
33
|
+
*/
|
|
34
|
+
export function getMagicContextTempDir(harness: HarnessId = getHarness()): string {
|
|
35
|
+
return path.join(os.tmpdir(), harness, "magic-context");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Standard log file path the plugin writes to. Pi and OpenCode write to
|
|
40
|
+
* SEPARATE logs under their respective harness subtrees so a single
|
|
41
|
+
* machine running both harnesses doesn't interleave session traces.
|
|
42
|
+
*
|
|
43
|
+
* The plugin's buffered logger calls this on every flush rather than
|
|
44
|
+
* caching, so `setHarness("pi")` taking effect after module load is
|
|
45
|
+
* reflected in the next flush.
|
|
46
|
+
*/
|
|
47
|
+
export function getMagicContextLogPath(harness: HarnessId = getHarness()): string {
|
|
48
|
+
return path.join(getMagicContextTempDir(harness), "magic-context.log");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Directory used for both historian validation-failure dumps and the
|
|
53
|
+
* existing-state offload XMLs that large historian/recomp passes write
|
|
54
|
+
* before invoking the model. Per-harness so dumps from different
|
|
55
|
+
* harnesses don't collide on filename and so `doctor --issue` for each
|
|
56
|
+
* harness reports only its own historian artifacts.
|
|
57
|
+
*/
|
|
58
|
+
export function getMagicContextHistorianDir(harness: HarnessId = getHarness()): string {
|
|
59
|
+
return path.join(getMagicContextTempDir(harness), "historian");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Project-local magic-context artifact directory.
|
|
64
|
+
*
|
|
65
|
+
* Layout: `<project-directory>/.opencode/magic-context/`
|
|
66
|
+
*
|
|
67
|
+
* Used for artifacts that the historian/recomp pipeline writes during a run
|
|
68
|
+
* and that the model is asked to read via its native Read tool. OpenCode's
|
|
69
|
+
* `external_directory` permission system asks the user before reading any
|
|
70
|
+
* file outside the project directory or its worktree, which interrupts every
|
|
71
|
+
* historian run when artifacts live under `os.tmpdir()`. Writing under the
|
|
72
|
+
* project's own `.opencode/` subtree falls inside the project boundary and
|
|
73
|
+
* never triggers a permission prompt.
|
|
74
|
+
*
|
|
75
|
+
* The `.opencode/` parent dir is OpenCode's own per-project convention (used
|
|
76
|
+
* for project-local config, plans, dumps, plugin installs). Anchoring
|
|
77
|
+
* magic-context artifacts under `.opencode/magic-context/` keeps them
|
|
78
|
+
* co-located with related OpenCode metadata and makes them easy for users to
|
|
79
|
+
* locate when debugging.
|
|
80
|
+
*
|
|
81
|
+
* Logger does NOT use this — log files stay in the per-harness tmp subtree
|
|
82
|
+
* because they are written by the plugin process itself (no model-side Read
|
|
83
|
+
* tool call, no permission prompt) and span sessions/projects.
|
|
84
|
+
*/
|
|
85
|
+
export function getProjectMagicContextDir(directory: string): string {
|
|
86
|
+
return path.join(directory, ".opencode", "magic-context");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Project-local historian artifact directory.
|
|
91
|
+
*
|
|
92
|
+
* Layout: `<project-directory>/.opencode/magic-context/historian/`
|
|
93
|
+
*
|
|
94
|
+
* Used for:
|
|
95
|
+
* - existing-state offload XMLs that long historian/recomp passes write
|
|
96
|
+
* before invoking the model (the model reads the file via Read tool)
|
|
97
|
+
* - validation-failure dump XMLs preserved for debugging
|
|
98
|
+
*
|
|
99
|
+
* Callers must `mkdirSync(dir, { recursive: true })` before writing — the
|
|
100
|
+
* `.opencode/` parent may not exist on a fresh project, and write failures
|
|
101
|
+
* here must degrade gracefully (e.g. historian falls back to inline state).
|
|
102
|
+
*/
|
|
103
|
+
export function getProjectMagicContextHistorianDir(directory: string): string {
|
|
104
|
+
return path.join(getProjectMagicContextDir(directory), "historian");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function getOpenCodeStorageDir(): string {
|
|
108
|
+
return path.join(getDataDir(), "opencode", "storage");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Resolve the shared magic-context storage directory.
|
|
113
|
+
*
|
|
114
|
+
* Magic-context's own data (compartments, facts, memories, embeddings, dream
|
|
115
|
+
* runs, notes, etc.) lives at this path regardless of which harness loaded the
|
|
116
|
+
* plugin (OpenCode or Pi). This enables:
|
|
117
|
+
* - Shared project memories across harnesses
|
|
118
|
+
* - Shared embedding cache
|
|
119
|
+
* - Shared Dreamer runs (one per project per machine)
|
|
120
|
+
* - Future cross-harness session migration
|
|
121
|
+
*
|
|
122
|
+
* Layout: <XDG_DATA_HOME>/cortexkit/magic-context/
|
|
123
|
+
*/
|
|
124
|
+
export function getMagicContextStorageDir(): string {
|
|
125
|
+
return path.join(getDataDir(), "cortexkit", "magic-context");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Legacy magic-context storage directory used by the OpenCode plugin before the
|
|
130
|
+
* shared cortexkit path. Used only for one-time migration of existing data into
|
|
131
|
+
* the new shared location. The legacy directory is left in place after copy so
|
|
132
|
+
* users can roll back if needed; manual cleanup is safe after one stable
|
|
133
|
+
* release.
|
|
134
|
+
*/
|
|
135
|
+
export function getLegacyOpenCodeMagicContextStorageDir(): string {
|
|
136
|
+
return path.join(getOpenCodeStorageDir(), "plugin", "magic-context");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Resolve OpenCode's cache base directory.
|
|
141
|
+
*
|
|
142
|
+
* OpenCode uses the `xdg-basedir` package, which — on every platform, including
|
|
143
|
+
* Windows — falls back to `<homedir>/.cache` when `XDG_CACHE_HOME` is unset.
|
|
144
|
+
* A previous Windows-specific branch that resolved to `%LOCALAPPDATA%` did not
|
|
145
|
+
* match OpenCode's own resolution and caused `doctor --force` to target a
|
|
146
|
+
* non-existent directory, leaving the real cache at `C:\Users\<user>\.cache`
|
|
147
|
+
* untouched.
|
|
148
|
+
*/
|
|
149
|
+
export function getCacheDir(): string {
|
|
150
|
+
return process.env.XDG_CACHE_HOME ?? path.join(os.homedir(), ".cache");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function getOpenCodeCacheDir(): string {
|
|
154
|
+
return path.join(getCacheDir(), "opencode");
|
|
155
|
+
}
|