@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,222 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, spyOn } from "bun:test";
|
|
2
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { isOpenCodeAutoCompactionEnabled } from "./opencode-compaction-detector";
|
|
5
|
+
import * as configDir from "./opencode-config-dir";
|
|
6
|
+
|
|
7
|
+
describe("opencode-compaction-detector", () => {
|
|
8
|
+
let tmpDir: string;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
tmpDir = join("/tmp", `compaction-detector-test-${Date.now()}`);
|
|
12
|
+
mkdirSync(join(tmpDir, ".opencode"), { recursive: true });
|
|
13
|
+
delete process.env.OPENCODE_DISABLE_AUTOCOMPACT;
|
|
14
|
+
spyOn(configDir, "getOpenCodeConfigPaths").mockReturnValue({
|
|
15
|
+
configJson: join(tmpDir, "user-config", "opencode.json"),
|
|
16
|
+
configJsonc: join(tmpDir, "user-config", "opencode.jsonc"),
|
|
17
|
+
} as ReturnType<typeof configDir.getOpenCodeConfigPaths>);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
22
|
+
delete process.env.OPENCODE_DISABLE_AUTOCOMPACT;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("#given no config exists", () => {
|
|
26
|
+
it("#then returns true (default: compaction enabled)", () => {
|
|
27
|
+
const emptyDir = join("/tmp", `compaction-empty-${Date.now()}`);
|
|
28
|
+
mkdirSync(emptyDir, { recursive: true });
|
|
29
|
+
|
|
30
|
+
const result = isOpenCodeAutoCompactionEnabled(emptyDir);
|
|
31
|
+
|
|
32
|
+
expect(result).toBe(true);
|
|
33
|
+
rmSync(emptyDir, { recursive: true, force: true });
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("#given OPENCODE_DISABLE_AUTOCOMPACT env flag is set", () => {
|
|
38
|
+
it("#then returns false", () => {
|
|
39
|
+
process.env.OPENCODE_DISABLE_AUTOCOMPACT = "1";
|
|
40
|
+
|
|
41
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
42
|
+
|
|
43
|
+
expect(result).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("#given project config has compaction.auto = false", () => {
|
|
48
|
+
it("#when opencode.json #then returns false", () => {
|
|
49
|
+
writeFileSync(
|
|
50
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
51
|
+
JSON.stringify({ compaction: { auto: false } }),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
55
|
+
|
|
56
|
+
expect(result).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("#when opencode.jsonc #then returns false", () => {
|
|
60
|
+
writeFileSync(
|
|
61
|
+
join(tmpDir, ".opencode", "opencode.jsonc"),
|
|
62
|
+
`{
|
|
63
|
+
// compaction disabled
|
|
64
|
+
"compaction": { "auto": false }
|
|
65
|
+
}`,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
69
|
+
|
|
70
|
+
expect(result).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("#given project config has compaction.auto = true", () => {
|
|
75
|
+
it("#then returns true", () => {
|
|
76
|
+
writeFileSync(
|
|
77
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
78
|
+
JSON.stringify({ compaction: { auto: true } }),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
82
|
+
|
|
83
|
+
expect(result).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe("#given project config has compaction.prune = true", () => {
|
|
88
|
+
it("#then returns true (conflict enabled)", () => {
|
|
89
|
+
writeFileSync(
|
|
90
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
91
|
+
JSON.stringify({ compaction: { auto: false, prune: true } }),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
95
|
+
|
|
96
|
+
expect(result).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("#given project config has auto/prune both false", () => {
|
|
101
|
+
it("#then returns false", () => {
|
|
102
|
+
writeFileSync(
|
|
103
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
104
|
+
JSON.stringify({ compaction: { auto: false, prune: false } }),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
108
|
+
|
|
109
|
+
expect(result).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("#given project config has only compaction.prune = false", () => {
|
|
114
|
+
it("#then returns false", () => {
|
|
115
|
+
writeFileSync(
|
|
116
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
117
|
+
JSON.stringify({ compaction: { prune: false } }),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
121
|
+
|
|
122
|
+
expect(result).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe("#given jsonc and json both exist", () => {
|
|
127
|
+
it("#then jsonc takes precedence", () => {
|
|
128
|
+
writeFileSync(
|
|
129
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
130
|
+
JSON.stringify({ compaction: { auto: true } }),
|
|
131
|
+
);
|
|
132
|
+
writeFileSync(
|
|
133
|
+
join(tmpDir, ".opencode", "opencode.jsonc"),
|
|
134
|
+
`{ "compaction": { "auto": false } }`,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
138
|
+
|
|
139
|
+
expect(result).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("#given config exists but no compaction field", () => {
|
|
144
|
+
it("#then returns true (default)", () => {
|
|
145
|
+
writeFileSync(
|
|
146
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
147
|
+
JSON.stringify({ model: "claude-opus-4-6" }),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
151
|
+
|
|
152
|
+
expect(result).toBe(true);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("#given env flag overrides config", () => {
|
|
157
|
+
it("#then env flag wins even when config has auto: true", () => {
|
|
158
|
+
process.env.OPENCODE_DISABLE_AUTOCOMPACT = "true";
|
|
159
|
+
writeFileSync(
|
|
160
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
161
|
+
JSON.stringify({ compaction: { auto: true } }),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
165
|
+
|
|
166
|
+
expect(result).toBe(false);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe("#given root-level project config", () => {
|
|
171
|
+
it("#when root opencode.json has compaction.auto = false #then returns false", () => {
|
|
172
|
+
writeFileSync(
|
|
173
|
+
join(tmpDir, "opencode.json"),
|
|
174
|
+
JSON.stringify({ compaction: { auto: false } }),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
178
|
+
|
|
179
|
+
expect(result).toBe(false);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("#when root opencode.jsonc has compaction.auto = false #then returns false", () => {
|
|
183
|
+
writeFileSync(join(tmpDir, "opencode.jsonc"), `{ "compaction": { "auto": false } }`);
|
|
184
|
+
|
|
185
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
186
|
+
|
|
187
|
+
expect(result).toBe(false);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
describe("#given .opencode/ overrides root-level config", () => {
|
|
192
|
+
it("#when root says false but .opencode says true #then .opencode wins", () => {
|
|
193
|
+
writeFileSync(
|
|
194
|
+
join(tmpDir, "opencode.json"),
|
|
195
|
+
JSON.stringify({ compaction: { auto: false } }),
|
|
196
|
+
);
|
|
197
|
+
writeFileSync(
|
|
198
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
199
|
+
JSON.stringify({ compaction: { auto: true } }),
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
203
|
+
|
|
204
|
+
expect(result).toBe(true);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("#when root says true but .opencode says false #then .opencode wins", () => {
|
|
208
|
+
writeFileSync(
|
|
209
|
+
join(tmpDir, "opencode.json"),
|
|
210
|
+
JSON.stringify({ compaction: { auto: true } }),
|
|
211
|
+
);
|
|
212
|
+
writeFileSync(
|
|
213
|
+
join(tmpDir, ".opencode", "opencode.json"),
|
|
214
|
+
JSON.stringify({ compaction: { auto: false } }),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
218
|
+
|
|
219
|
+
expect(result).toBe(false);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { readJsoncFile } from "./jsonc-parser";
|
|
3
|
+
import { log } from "./logger";
|
|
4
|
+
import { getOpenCodeConfigPaths } from "./opencode-config-dir";
|
|
5
|
+
|
|
6
|
+
interface OpenCodeConfig {
|
|
7
|
+
compaction?: {
|
|
8
|
+
auto?: boolean;
|
|
9
|
+
prune?: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function hasCompactionConflict(
|
|
14
|
+
compaction: OpenCodeConfig["compaction"] | undefined,
|
|
15
|
+
): boolean | undefined {
|
|
16
|
+
if (!compaction) return undefined;
|
|
17
|
+
const hasExplicitSetting = compaction.auto !== undefined || compaction.prune !== undefined;
|
|
18
|
+
if (!hasExplicitSetting) return undefined;
|
|
19
|
+
return compaction.auto === true || compaction.prune === true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function isOpenCodeAutoCompactionEnabled(directory: string): boolean {
|
|
23
|
+
if (process.env.OPENCODE_DISABLE_AUTOCOMPACT) {
|
|
24
|
+
log(
|
|
25
|
+
"[compaction-detector] OPENCODE_DISABLE_AUTOCOMPACT env flag set — auto compaction disabled",
|
|
26
|
+
);
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const projectCompaction = readProjectCompactionConfig(directory);
|
|
31
|
+
if (projectCompaction !== undefined) {
|
|
32
|
+
log("[compaction-detector] project config compaction conflict =", projectCompaction);
|
|
33
|
+
return projectCompaction;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const userCompaction = readUserCompactionConfig(directory);
|
|
37
|
+
if (userCompaction !== undefined) {
|
|
38
|
+
log("[compaction-detector] user config compaction conflict =", userCompaction);
|
|
39
|
+
return userCompaction;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
log("[compaction-detector] no compaction config found — default is enabled");
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function readProjectCompactionConfig(directory: string): boolean | undefined {
|
|
47
|
+
// .opencode/ dir config has higher precedence than root-level config in OpenCode's loading order.
|
|
48
|
+
// Check highest precedence first — if .opencode/ sets compaction.auto, that wins.
|
|
49
|
+
const dotOpenCodeJsonc = join(directory, ".opencode", "opencode.jsonc");
|
|
50
|
+
const dotOpenCodeJson = join(directory, ".opencode", "opencode.json");
|
|
51
|
+
const dotOpenCodeConfig =
|
|
52
|
+
readJsoncFile<OpenCodeConfig>(dotOpenCodeJsonc) ??
|
|
53
|
+
readJsoncFile<OpenCodeConfig>(dotOpenCodeJson);
|
|
54
|
+
|
|
55
|
+
const dotOpenCodeCompactionConflict = hasCompactionConflict(dotOpenCodeConfig?.compaction);
|
|
56
|
+
if (dotOpenCodeCompactionConflict !== undefined) {
|
|
57
|
+
return dotOpenCodeCompactionConflict;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Root-level project config (lower precedence than .opencode/)
|
|
61
|
+
const rootJsonc = join(directory, "opencode.jsonc");
|
|
62
|
+
const rootJson = join(directory, "opencode.json");
|
|
63
|
+
const rootConfig =
|
|
64
|
+
readJsoncFile<OpenCodeConfig>(rootJsonc) ?? readJsoncFile<OpenCodeConfig>(rootJson);
|
|
65
|
+
|
|
66
|
+
return hasCompactionConflict(rootConfig?.compaction);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function readUserCompactionConfig(_directory: string): boolean | undefined {
|
|
70
|
+
try {
|
|
71
|
+
const paths = getOpenCodeConfigPaths({ binary: "opencode" });
|
|
72
|
+
const config =
|
|
73
|
+
readJsoncFile<OpenCodeConfig>(paths.configJsonc) ??
|
|
74
|
+
readJsoncFile<OpenCodeConfig>(paths.configJson);
|
|
75
|
+
|
|
76
|
+
return hasCompactionConflict(config?.compaction);
|
|
77
|
+
} catch {
|
|
78
|
+
// Intentional: config read is best-effort; missing/unreadable config is not an error
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type OpenCodeBinaryType = "opencode" | "opencode-desktop";
|
|
2
|
+
|
|
3
|
+
export type OpenCodeConfigDirOptions = {
|
|
4
|
+
binary: OpenCodeBinaryType;
|
|
5
|
+
version?: string | null;
|
|
6
|
+
checkExisting?: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type OpenCodeConfigPaths = {
|
|
10
|
+
configDir: string;
|
|
11
|
+
configJson: string;
|
|
12
|
+
configJsonc: string;
|
|
13
|
+
packageJson: string;
|
|
14
|
+
omoConfig: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
import type { OpenCodeConfigDirOptions, OpenCodeConfigPaths } from "./opencode-config-dir-types";
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
OpenCodeBinaryType,
|
|
8
|
+
OpenCodeConfigDirOptions,
|
|
9
|
+
OpenCodeConfigPaths,
|
|
10
|
+
} from "./opencode-config-dir-types";
|
|
11
|
+
|
|
12
|
+
function getCliConfigDir(): string {
|
|
13
|
+
const envConfigDir = process.env.OPENCODE_CONFIG_DIR?.trim();
|
|
14
|
+
if (envConfigDir) {
|
|
15
|
+
return resolve(envConfigDir);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (process.platform === "win32") {
|
|
19
|
+
return join(homedir(), ".config", "opencode");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "opencode");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getOpenCodeConfigDir(_options: OpenCodeConfigDirOptions): string {
|
|
26
|
+
return getCliConfigDir();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getOpenCodeConfigPaths(options: OpenCodeConfigDirOptions): OpenCodeConfigPaths {
|
|
30
|
+
const configDir = getOpenCodeConfigDir(options);
|
|
31
|
+
return {
|
|
32
|
+
configDir,
|
|
33
|
+
configJson: join(configDir, "opencode.json"),
|
|
34
|
+
configJsonc: join(configDir, "opencode.jsonc"),
|
|
35
|
+
packageJson: join(configDir, "package.json"),
|
|
36
|
+
omoConfig: join(configDir, "magic-context.jsonc"),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { DREAMER_AGENT } from "../agents/dreamer";
|
|
4
|
+
import { HISTORIAN_AGENT } from "../agents/historian";
|
|
5
|
+
import { SIDEKICK_AGENT } from "../agents/sidekick";
|
|
6
|
+
import { parseProviderModel, resolveFallbackChain } from "./resolve-fallbacks";
|
|
7
|
+
|
|
8
|
+
describe("resolveFallbackChain", () => {
|
|
9
|
+
test("returns builtin chain when user provides nothing", () => {
|
|
10
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, undefined);
|
|
11
|
+
// Builtin DREAMER_FALLBACK_CHAIN expands to multiple provider/model entries.
|
|
12
|
+
expect(chain.length).toBeGreaterThan(2);
|
|
13
|
+
// Every entry must be in "provider/model" form.
|
|
14
|
+
for (const entry of chain) {
|
|
15
|
+
expect(entry.indexOf("/")).toBeGreaterThan(0);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("returns builtin chain for empty string", () => {
|
|
20
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, "");
|
|
21
|
+
expect(chain.length).toBeGreaterThan(0);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("returns builtin chain for empty array", () => {
|
|
25
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, []);
|
|
26
|
+
expect(chain.length).toBeGreaterThan(0);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("user-only when user provides valid fallback_models string", () => {
|
|
30
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, "anthropic/claude-sonnet-4-6");
|
|
31
|
+
expect(chain).toEqual(["anthropic/claude-sonnet-4-6"]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("user-only when user provides valid fallback_models array", () => {
|
|
35
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, [
|
|
36
|
+
"anthropic/claude-sonnet-4-6",
|
|
37
|
+
"google/gemini-3-flash",
|
|
38
|
+
]);
|
|
39
|
+
expect(chain).toEqual(["anthropic/claude-sonnet-4-6", "google/gemini-3-flash"]);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("dedupes user-provided list", () => {
|
|
43
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, [
|
|
44
|
+
"anthropic/claude-sonnet-4-6",
|
|
45
|
+
"anthropic/claude-sonnet-4-6",
|
|
46
|
+
"google/gemini-3-flash",
|
|
47
|
+
]);
|
|
48
|
+
expect(chain).toEqual(["anthropic/claude-sonnet-4-6", "google/gemini-3-flash"]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("strips invalid 'provider/model' entries", () => {
|
|
52
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, [
|
|
53
|
+
"anthropic/claude-sonnet-4-6",
|
|
54
|
+
"no-slash-here",
|
|
55
|
+
"/leading-slash",
|
|
56
|
+
"trailing-slash/",
|
|
57
|
+
"",
|
|
58
|
+
" ",
|
|
59
|
+
]);
|
|
60
|
+
expect(chain).toEqual(["anthropic/claude-sonnet-4-6"]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("trims whitespace in user entries", () => {
|
|
64
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, [
|
|
65
|
+
" anthropic/claude-sonnet-4-6 ",
|
|
66
|
+
"\tgoogle/gemini-3-flash\n",
|
|
67
|
+
]);
|
|
68
|
+
expect(chain).toEqual(["anthropic/claude-sonnet-4-6", "google/gemini-3-flash"]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("returns empty array for unknown agent with no user fallbacks", () => {
|
|
72
|
+
const chain = resolveFallbackChain("unknown-agent", undefined);
|
|
73
|
+
expect(chain).toEqual([]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("returns user fallbacks for unknown agent when provided", () => {
|
|
77
|
+
const chain = resolveFallbackChain("unknown-agent", ["foo/bar"]);
|
|
78
|
+
expect(chain).toEqual(["foo/bar"]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("HISTORIAN_AGENT has builtin chain", () => {
|
|
82
|
+
const chain = resolveFallbackChain(HISTORIAN_AGENT, undefined);
|
|
83
|
+
expect(chain.length).toBeGreaterThan(0);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("SIDEKICK_AGENT has builtin chain", () => {
|
|
87
|
+
const chain = resolveFallbackChain(SIDEKICK_AGENT, undefined);
|
|
88
|
+
expect(chain.length).toBeGreaterThan(0);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("user-only policy: builtin not appended even if user set short list", () => {
|
|
92
|
+
const chain = resolveFallbackChain(DREAMER_AGENT, ["anthropic/claude-sonnet-4-6"]);
|
|
93
|
+
expect(chain).toEqual(["anthropic/claude-sonnet-4-6"]);
|
|
94
|
+
// Confirm length is exactly 1, not user+builtin
|
|
95
|
+
expect(chain.length).toBe(1);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe("parseProviderModel", () => {
|
|
100
|
+
test("parses standard provider/model", () => {
|
|
101
|
+
expect(parseProviderModel("anthropic/claude-sonnet-4-6")).toEqual({
|
|
102
|
+
providerID: "anthropic",
|
|
103
|
+
modelID: "claude-sonnet-4-6",
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("handles model id with slashes (only splits on first slash)", () => {
|
|
108
|
+
expect(parseProviderModel("lemonade/GLM-4.7-Flash-GGUF/main")).toEqual({
|
|
109
|
+
providerID: "lemonade",
|
|
110
|
+
modelID: "GLM-4.7-Flash-GGUF/main",
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("trims whitespace", () => {
|
|
115
|
+
expect(parseProviderModel(" anthropic/claude-sonnet-4-6 ")).toEqual({
|
|
116
|
+
providerID: "anthropic",
|
|
117
|
+
modelID: "claude-sonnet-4-6",
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("returns null for no slash", () => {
|
|
122
|
+
expect(parseProviderModel("anthropic")).toBeNull();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("returns null for leading slash", () => {
|
|
126
|
+
expect(parseProviderModel("/claude-sonnet-4-6")).toBeNull();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("returns null for trailing slash", () => {
|
|
130
|
+
expect(parseProviderModel("anthropic/")).toBeNull();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("returns null for empty string", () => {
|
|
134
|
+
expect(parseProviderModel("")).toBeNull();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getAgentFallbackModels } from "./model-requirements";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the final fallback model list to attempt for an OpenCode subagent
|
|
5
|
+
* call.
|
|
6
|
+
*
|
|
7
|
+
* Policy (decided 2026-05-10):
|
|
8
|
+
* - If user configured explicit `fallback_models` in their magic-context.jsonc
|
|
9
|
+
* for this agent: use ONLY those. Respects user intent, no surprise
|
|
10
|
+
* providers.
|
|
11
|
+
* - If user did NOT configure any: fall back to the plugin's builtin
|
|
12
|
+
* provider-agnostic chain (`AGENT_MODEL_REQUIREMENTS`).
|
|
13
|
+
*
|
|
14
|
+
* The returned list does NOT include the primary model — it's the ordered
|
|
15
|
+
* list of *alternates* to try after the primary fails. Each entry is
|
|
16
|
+
* "provider/modelID" form.
|
|
17
|
+
*
|
|
18
|
+
* Duplicates and empty strings are filtered. Entries that don't match the
|
|
19
|
+
* "provider/modelID" shape (must contain a "/" with non-empty parts) are
|
|
20
|
+
* also dropped — defensive guard against malformed user config.
|
|
21
|
+
*/
|
|
22
|
+
export function resolveFallbackChain(
|
|
23
|
+
agentName: string,
|
|
24
|
+
userFallbacks: readonly string[] | string | undefined,
|
|
25
|
+
): string[] {
|
|
26
|
+
const userList = normalizeUserFallbacks(userFallbacks);
|
|
27
|
+
|
|
28
|
+
if (userList.length > 0) {
|
|
29
|
+
return dedupe(userList.filter(isValidModelSpec));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const builtin = getAgentFallbackModels(agentName);
|
|
33
|
+
if (!builtin || builtin.length === 0) return [];
|
|
34
|
+
return dedupe(builtin.filter(isValidModelSpec));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalizeUserFallbacks(userFallbacks: readonly string[] | string | undefined): string[] {
|
|
38
|
+
if (!userFallbacks) return [];
|
|
39
|
+
if (typeof userFallbacks === "string") {
|
|
40
|
+
const trimmed = userFallbacks.trim();
|
|
41
|
+
return trimmed ? [trimmed] : [];
|
|
42
|
+
}
|
|
43
|
+
return userFallbacks.map((s) => s.trim()).filter((s) => s.length > 0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isValidModelSpec(spec: string): boolean {
|
|
47
|
+
const slash = spec.indexOf("/");
|
|
48
|
+
return slash > 0 && slash < spec.length - 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function dedupe(list: string[]): string[] {
|
|
52
|
+
const seen = new Set<string>();
|
|
53
|
+
const out: string[] = [];
|
|
54
|
+
for (const item of list) {
|
|
55
|
+
if (seen.has(item)) continue;
|
|
56
|
+
seen.add(item);
|
|
57
|
+
out.push(item);
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Parse a "provider/modelID" string into the OpenCode `model` object shape.
|
|
64
|
+
* Returns null on invalid input.
|
|
65
|
+
*
|
|
66
|
+
* Note: only splits on the FIRST "/" — modelID can legitimately contain slashes
|
|
67
|
+
* (e.g. `lemonade/GLM-4.7-Flash-GGUF/main`).
|
|
68
|
+
*/
|
|
69
|
+
export function parseProviderModel(spec: string): { providerID: string; modelID: string } | null {
|
|
70
|
+
const slash = spec.indexOf("/");
|
|
71
|
+
if (slash < 1 || slash >= spec.length - 1) return null;
|
|
72
|
+
return {
|
|
73
|
+
providerID: spec.slice(0, slash).trim(),
|
|
74
|
+
modelID: spec.slice(slash + 1).trim(),
|
|
75
|
+
};
|
|
76
|
+
}
|