@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,94 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { describeError, getErrorMessage } from "./error-message";
|
|
3
|
+
|
|
4
|
+
describe("describeError", () => {
|
|
5
|
+
it("extracts name and message from standard Error", () => {
|
|
6
|
+
const err = new TypeError("boom");
|
|
7
|
+
const desc = describeError(err);
|
|
8
|
+
expect(desc.name).toBe("TypeError");
|
|
9
|
+
expect(desc.message).toBe("boom");
|
|
10
|
+
expect(desc.brief).toContain("TypeError");
|
|
11
|
+
expect(desc.brief).toContain('message="boom"');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("surfaces class name when message is empty (NotFoundError case)", () => {
|
|
15
|
+
class NotFoundError extends Error {
|
|
16
|
+
constructor() {
|
|
17
|
+
super("");
|
|
18
|
+
this.name = "NotFoundError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const err = new NotFoundError();
|
|
22
|
+
const desc = describeError(err);
|
|
23
|
+
expect(desc.name).toBe("NotFoundError");
|
|
24
|
+
expect(desc.message).toBe("");
|
|
25
|
+
// brief must still carry a useful signal even with empty message
|
|
26
|
+
expect(desc.brief).toContain("NotFoundError");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("falls back to constructor.name when .name is missing", () => {
|
|
30
|
+
// Simulate an SDK-shaped object where .name is an empty string
|
|
31
|
+
const err = Object.assign(new Error("x"), { name: "" });
|
|
32
|
+
const desc = describeError(err);
|
|
33
|
+
// Falls back to constructor.name ("Error")
|
|
34
|
+
expect(desc.name).toBe("Error");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("extracts status/code fields from HTTP-style errors", () => {
|
|
38
|
+
const err = Object.assign(new Error("not found"), {
|
|
39
|
+
status: 404,
|
|
40
|
+
code: "ENOTFOUND",
|
|
41
|
+
});
|
|
42
|
+
const desc = describeError(err);
|
|
43
|
+
expect(desc.status).toBe("404");
|
|
44
|
+
expect(desc.code).toBe("ENOTFOUND");
|
|
45
|
+
expect(desc.brief).toContain("status=404");
|
|
46
|
+
expect(desc.brief).toContain("code=ENOTFOUND");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("captures first stack frames in stackHead", () => {
|
|
50
|
+
const err = new Error("with stack");
|
|
51
|
+
const desc = describeError(err);
|
|
52
|
+
expect(desc.stackHead).toBeDefined();
|
|
53
|
+
expect(desc.stackHead?.length).toBeGreaterThan(0);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("handles non-Error thrown values", () => {
|
|
57
|
+
const desc = describeError("plain string");
|
|
58
|
+
expect(desc.brief).toContain("plain string");
|
|
59
|
+
expect(desc.stringForm).toContain("plain string");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("handles objects without .message", () => {
|
|
63
|
+
const desc = describeError({ name: "WeirdError" });
|
|
64
|
+
expect(desc.name).toBe("WeirdError");
|
|
65
|
+
expect(desc.message).toBe("");
|
|
66
|
+
expect(desc.brief).toContain("WeirdError");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("handles undefined/null", () => {
|
|
70
|
+
expect(describeError(undefined).brief).toBeTruthy();
|
|
71
|
+
expect(describeError(null).brief).toBeTruthy();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("surfaces cause name when present", () => {
|
|
75
|
+
const cause = new TypeError("inner");
|
|
76
|
+
const outer = new Error("outer");
|
|
77
|
+
(outer as unknown as { cause: unknown }).cause = cause;
|
|
78
|
+
const desc = describeError(outer);
|
|
79
|
+
expect(desc.causeName).toBe("TypeError");
|
|
80
|
+
expect(desc.brief).toContain("cause=TypeError");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("clips very long messages in brief", () => {
|
|
84
|
+
const long = "x".repeat(1000);
|
|
85
|
+
const err = new Error(long);
|
|
86
|
+
const desc = describeError(err);
|
|
87
|
+
expect(desc.brief.length).toBeLessThan(500);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("getErrorMessage still works as before", () => {
|
|
91
|
+
expect(getErrorMessage(new Error("foo"))).toBe("foo");
|
|
92
|
+
expect(getErrorMessage("bar")).toBe("bar");
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export function getErrorMessage(error: unknown): string {
|
|
2
|
+
return error instanceof Error ? error.message : String(error);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Produce a rich, safe-to-log description of any thrown value.
|
|
7
|
+
*
|
|
8
|
+
* Motivated by SDK errors whose `.message` is empty while `.name`/`toString()`
|
|
9
|
+
* carry the actual signal (e.g. `NotFoundError` with no message on OpenCode
|
|
10
|
+
* session-delete races). Using {@link getErrorMessage} alone erases that signal.
|
|
11
|
+
*
|
|
12
|
+
* Captures:
|
|
13
|
+
* - `name` from the Error (defaults to `constructor.name`)
|
|
14
|
+
* - `message` (may be empty)
|
|
15
|
+
* - first few stack frames
|
|
16
|
+
* - `String(error)` so objects and custom toString surfaces are visible
|
|
17
|
+
* - Common HTTP-shape fields (`status`, `statusCode`, `code`)
|
|
18
|
+
* - `cause` chain summary (first level only)
|
|
19
|
+
*
|
|
20
|
+
* Returns a compact, single-line-friendly string suitable for log lines,
|
|
21
|
+
* plus a structured object for callers that want individual fields.
|
|
22
|
+
*/
|
|
23
|
+
export interface ErrorDescription {
|
|
24
|
+
name: string;
|
|
25
|
+
message: string;
|
|
26
|
+
status?: string;
|
|
27
|
+
code?: string;
|
|
28
|
+
causeName?: string;
|
|
29
|
+
stackHead?: string;
|
|
30
|
+
stringForm: string;
|
|
31
|
+
/** Best short summary for human-readable logs. Never empty. */
|
|
32
|
+
brief: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function readString(value: unknown): string | undefined {
|
|
36
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
37
|
+
if (typeof value === "number") return String(value);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function clip(value: string, max: number): string {
|
|
42
|
+
if (value.length <= max) return value;
|
|
43
|
+
return `${value.slice(0, max)}…`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function describeError(error: unknown): ErrorDescription {
|
|
47
|
+
const stringForm = clip(safeString(error), 400);
|
|
48
|
+
|
|
49
|
+
if (!(error instanceof Error) && !(error && typeof error === "object")) {
|
|
50
|
+
return {
|
|
51
|
+
name: typeof error,
|
|
52
|
+
message: "",
|
|
53
|
+
stringForm,
|
|
54
|
+
brief: stringForm || "<empty>",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const obj = error as Record<string, unknown>;
|
|
59
|
+
const nameFromField = readString(obj.name);
|
|
60
|
+
const nameFromCtor = error?.constructor?.name;
|
|
61
|
+
const name = nameFromField ?? nameFromCtor ?? "Error";
|
|
62
|
+
|
|
63
|
+
const message = readString(obj.message) ?? "";
|
|
64
|
+
const status = readString(obj.status) ?? readString(obj.statusCode);
|
|
65
|
+
const code = readString(obj.code);
|
|
66
|
+
|
|
67
|
+
let causeName: string | undefined;
|
|
68
|
+
const cause = obj.cause;
|
|
69
|
+
if (cause && typeof cause === "object") {
|
|
70
|
+
const causeRecord = cause as Record<string, unknown>;
|
|
71
|
+
causeName =
|
|
72
|
+
readString(causeRecord.name) ??
|
|
73
|
+
(cause as { constructor?: { name?: string } }).constructor?.name;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const stack = readString(obj.stack);
|
|
77
|
+
const stackHead = stack
|
|
78
|
+
? stack
|
|
79
|
+
.split("\n")
|
|
80
|
+
.slice(0, 4)
|
|
81
|
+
.map((l) => l.trim())
|
|
82
|
+
.filter((l) => l.length > 0)
|
|
83
|
+
.join(" | ")
|
|
84
|
+
: undefined;
|
|
85
|
+
|
|
86
|
+
const briefParts: string[] = [];
|
|
87
|
+
if (name) briefParts.push(name);
|
|
88
|
+
if (message) briefParts.push(`message="${clip(message, 200)}"`);
|
|
89
|
+
if (status) briefParts.push(`status=${status}`);
|
|
90
|
+
if (code) briefParts.push(`code=${code}`);
|
|
91
|
+
if (causeName) briefParts.push(`cause=${causeName}`);
|
|
92
|
+
if (!message && stringForm && stringForm !== name) {
|
|
93
|
+
briefParts.push(`str="${clip(stringForm, 200)}"`);
|
|
94
|
+
}
|
|
95
|
+
const brief = briefParts.join(" ") || stringForm || name;
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
name,
|
|
99
|
+
message,
|
|
100
|
+
...(status ? { status } : {}),
|
|
101
|
+
...(code ? { code } : {}),
|
|
102
|
+
...(causeName ? { causeName } : {}),
|
|
103
|
+
...(stackHead ? { stackHead } : {}),
|
|
104
|
+
stringForm,
|
|
105
|
+
brief,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function safeString(value: unknown): string {
|
|
110
|
+
try {
|
|
111
|
+
return String(value);
|
|
112
|
+
} catch {
|
|
113
|
+
return "<unstringifiable>";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format an execute-threshold percentage for human-facing display.
|
|
3
|
+
*
|
|
4
|
+
* `executeThreshold` in the snapshot is always a percentage number, but it
|
|
5
|
+
* comes from two very different config paths:
|
|
6
|
+
* 1. `execute_threshold_percentage` (or its model-keyed variant) — user
|
|
7
|
+
* configures an integer like 65 directly. We must render exactly that.
|
|
8
|
+
* 2. `execute_threshold_tokens` — user configures absolute token cap (e.g.
|
|
9
|
+
* 128000). The resolver in `event-resolvers.ts` divides that by the
|
|
10
|
+
* model's context limit (`(128000 / 907788) * 100`) and the result is
|
|
11
|
+
* a long float like `14.099783080260304` that overflows the TUI cell
|
|
12
|
+
* (issue #90).
|
|
13
|
+
*
|
|
14
|
+
* Behaviour:
|
|
15
|
+
* - Integer input (≤0.05 fractional drift) renders without decimals.
|
|
16
|
+
* - Anything else is rendered with one decimal digit, which is precise
|
|
17
|
+
* enough to convey the configured token budget without smearing across
|
|
18
|
+
* two lines in a narrow sidebar.
|
|
19
|
+
*
|
|
20
|
+
* Returns the formatted percentage WITHOUT the trailing `%` so callers can
|
|
21
|
+
* compose richer strings like `47.5% / 65%` consistently.
|
|
22
|
+
*/
|
|
23
|
+
export function formatThresholdPercent(value: number | undefined | null): string {
|
|
24
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return "—";
|
|
25
|
+
const rounded = Math.round(value);
|
|
26
|
+
if (Math.abs(value - rounded) < 0.05) return String(rounded);
|
|
27
|
+
return value.toFixed(1);
|
|
28
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier for the host harness this plugin is running inside.
|
|
3
|
+
*
|
|
4
|
+
* Magic Context's SQLite database lives at a vendor-scoped path
|
|
5
|
+
* (`~/.local/share/cortexkit/magic-context/`) so OpenCode and Pi can share
|
|
6
|
+
* project memories, embedding cache, dreamer runs, and other project-scoped
|
|
7
|
+
* state. Session-scoped tables carry a `harness` column populated from this
|
|
8
|
+
* module so we can disambiguate which harness wrote each session row,
|
|
9
|
+
* filter by harness in the dashboard, and (eventually) migrate sessions
|
|
10
|
+
* between harnesses.
|
|
11
|
+
*
|
|
12
|
+
* Each plugin entry point sets this once at boot, before any DB write
|
|
13
|
+
* happens:
|
|
14
|
+
* - OpenCode plugin: relies on the default ("opencode") — no setHarness call
|
|
15
|
+
* needed
|
|
16
|
+
* - Pi plugin: calls `setHarness("pi")` before opening the database
|
|
17
|
+
*
|
|
18
|
+
* NEVER read this from configuration or session state — it is a
|
|
19
|
+
* boot-time constant per plugin instance. Cross-harness leakage is a
|
|
20
|
+
* correctness bug, not a feature.
|
|
21
|
+
*/
|
|
22
|
+
export type HarnessId = "opencode" | "pi";
|
|
23
|
+
|
|
24
|
+
let currentHarness: HarnessId = "opencode";
|
|
25
|
+
let harnessLocked = false;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Set the harness identifier for this plugin instance. Must be called once
|
|
29
|
+
* at boot before any DB write happens. Subsequent calls with a different
|
|
30
|
+
* value throw to prevent accidental mid-session swaps that would corrupt
|
|
31
|
+
* the harness column and break per-harness session scoping.
|
|
32
|
+
*
|
|
33
|
+
* Calling with the same value as the current is a no-op (safe to call
|
|
34
|
+
* defensively).
|
|
35
|
+
*/
|
|
36
|
+
export function setHarness(value: HarnessId): void {
|
|
37
|
+
if (harnessLocked && currentHarness !== value) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Magic Context: harness already locked to "${currentHarness}"; cannot change to "${value}"`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
currentHarness = value;
|
|
43
|
+
harnessLocked = true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get the current harness identifier. Used by storage modules when
|
|
48
|
+
* INSERTing session-scoped rows so each row is correctly attributed.
|
|
49
|
+
*/
|
|
50
|
+
export function getHarness(): HarnessId {
|
|
51
|
+
return currentHarness;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Test-only helper to reset harness state between test cases. Do NOT call
|
|
56
|
+
* from production code paths.
|
|
57
|
+
*/
|
|
58
|
+
export function _resetHarnessForTesting(): void {
|
|
59
|
+
currentHarness = "opencode";
|
|
60
|
+
harnessLocked = false;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const OMO_INTERNAL_INITIATOR_MARKER = "<!-- OMO_INTERNAL_INITIATOR -->";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
export function stripJsonComments(content: string): string {
|
|
4
|
+
let result = "";
|
|
5
|
+
let inString = false;
|
|
6
|
+
let escaped = false;
|
|
7
|
+
let inLineComment = false;
|
|
8
|
+
let inBlockComment = false;
|
|
9
|
+
|
|
10
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
11
|
+
const char = content[index];
|
|
12
|
+
const next = content[index + 1];
|
|
13
|
+
|
|
14
|
+
if (inLineComment) {
|
|
15
|
+
if (char === "\n") {
|
|
16
|
+
inLineComment = false;
|
|
17
|
+
result += char;
|
|
18
|
+
}
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (inBlockComment) {
|
|
23
|
+
if (char === "*" && next === "/") {
|
|
24
|
+
inBlockComment = false;
|
|
25
|
+
index += 1;
|
|
26
|
+
}
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (inString) {
|
|
31
|
+
result += char;
|
|
32
|
+
if (escaped) {
|
|
33
|
+
escaped = false;
|
|
34
|
+
} else if (char === "\\") {
|
|
35
|
+
escaped = true;
|
|
36
|
+
} else if (char === '"') {
|
|
37
|
+
inString = false;
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (char === '"') {
|
|
43
|
+
inString = true;
|
|
44
|
+
result += char;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (char === "/" && next === "/") {
|
|
49
|
+
inLineComment = true;
|
|
50
|
+
index += 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (char === "/" && next === "*") {
|
|
55
|
+
inBlockComment = true;
|
|
56
|
+
index += 1;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
result += char;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function stripTrailingCommas(content: string): string {
|
|
67
|
+
let result = "";
|
|
68
|
+
let inString = false;
|
|
69
|
+
let escaped = false;
|
|
70
|
+
|
|
71
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
72
|
+
const char = content[index];
|
|
73
|
+
|
|
74
|
+
if (inString) {
|
|
75
|
+
result += char;
|
|
76
|
+
if (escaped) {
|
|
77
|
+
escaped = false;
|
|
78
|
+
} else if (char === "\\") {
|
|
79
|
+
escaped = true;
|
|
80
|
+
} else if (char === '"') {
|
|
81
|
+
inString = false;
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (char === '"') {
|
|
87
|
+
inString = true;
|
|
88
|
+
result += char;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (char === ",") {
|
|
93
|
+
let lookahead = index + 1;
|
|
94
|
+
while (lookahead < content.length && /\s/.test(content[lookahead] ?? "")) {
|
|
95
|
+
lookahead += 1;
|
|
96
|
+
}
|
|
97
|
+
const next = content[lookahead];
|
|
98
|
+
if (next === "}" || next === "]") {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
result += char;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function parseJsonc<T = unknown>(content: string): T {
|
|
110
|
+
const normalized = stripTrailingCommas(stripJsonComments(content));
|
|
111
|
+
return JSON.parse(normalized) as T;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function readJsoncFile<T = unknown>(filePath: string): T | null {
|
|
115
|
+
try {
|
|
116
|
+
return parseJsonc<T>(readFileSync(filePath, "utf-8"));
|
|
117
|
+
} catch (_error) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function detectConfigFile(basePath: string): {
|
|
123
|
+
format: "json" | "jsonc" | "none";
|
|
124
|
+
path: string;
|
|
125
|
+
} {
|
|
126
|
+
const jsoncPath = `${basePath}.jsonc`;
|
|
127
|
+
const jsonPath = `${basePath}.json`;
|
|
128
|
+
|
|
129
|
+
if (existsSync(jsoncPath)) {
|
|
130
|
+
return { format: "jsonc", path: jsoncPath };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (existsSync(jsonPath)) {
|
|
134
|
+
return { format: "json", path: jsonPath };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return { format: "none", path: jsoncPath };
|
|
138
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { getMagicContextLogPath } from "./data-path";
|
|
4
|
+
|
|
5
|
+
const isTestEnv = process.env.NODE_ENV === "test";
|
|
6
|
+
|
|
7
|
+
let buffer: string[] = [];
|
|
8
|
+
let flushTimer: ReturnType<typeof setTimeout> | null = null;
|
|
9
|
+
const FLUSH_INTERVAL_MS = 500;
|
|
10
|
+
const BUFFER_SIZE_LIMIT = 50;
|
|
11
|
+
|
|
12
|
+
// Cache the last log directory we mkdir'd successfully so we only retry the
|
|
13
|
+
// filesystem call when the resolved path actually changes. The path is
|
|
14
|
+
// re-evaluated on every flush because `setHarness("pi")` runs after module
|
|
15
|
+
// load on Pi; we MUST NOT freeze it at import time, or Pi's first flush
|
|
16
|
+
// could land in the OpenCode subtree.
|
|
17
|
+
let lastEnsuredDir: string | null = null;
|
|
18
|
+
|
|
19
|
+
function ensureDir(filePath: string): void {
|
|
20
|
+
const dir = path.dirname(filePath);
|
|
21
|
+
if (dir === lastEnsuredDir) return;
|
|
22
|
+
try {
|
|
23
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
24
|
+
lastEnsuredDir = dir;
|
|
25
|
+
} catch {
|
|
26
|
+
// Intentional: logging must never throw. If mkdir fails we still
|
|
27
|
+
// try the append; failure there is also swallowed.
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function flush(): void {
|
|
32
|
+
if (flushTimer) {
|
|
33
|
+
clearTimeout(flushTimer);
|
|
34
|
+
flushTimer = null;
|
|
35
|
+
}
|
|
36
|
+
if (buffer.length === 0) return;
|
|
37
|
+
const data = buffer.join("");
|
|
38
|
+
buffer = [];
|
|
39
|
+
try {
|
|
40
|
+
const logFile = getMagicContextLogPath();
|
|
41
|
+
ensureDir(logFile);
|
|
42
|
+
fs.appendFileSync(logFile, data);
|
|
43
|
+
} catch {
|
|
44
|
+
// Intentional: logging must never throw
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function scheduleFlush(): void {
|
|
49
|
+
if (flushTimer) return;
|
|
50
|
+
flushTimer = setTimeout(() => {
|
|
51
|
+
flushTimer = null;
|
|
52
|
+
flush();
|
|
53
|
+
}, FLUSH_INTERVAL_MS);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function log(message: string, data?: unknown): void {
|
|
57
|
+
if (isTestEnv) return;
|
|
58
|
+
try {
|
|
59
|
+
const timestamp = new Date().toISOString();
|
|
60
|
+
const serialized =
|
|
61
|
+
data === undefined
|
|
62
|
+
? ""
|
|
63
|
+
: data instanceof Error
|
|
64
|
+
? ` ${data.message}${data.stack ? `\n${data.stack}` : ""}`
|
|
65
|
+
: ` ${JSON.stringify(data)}`;
|
|
66
|
+
buffer.push(`[${timestamp}] ${message}${serialized}\n`);
|
|
67
|
+
if (buffer.length >= BUFFER_SIZE_LIMIT) {
|
|
68
|
+
flush();
|
|
69
|
+
} else {
|
|
70
|
+
scheduleFlush();
|
|
71
|
+
}
|
|
72
|
+
} catch {
|
|
73
|
+
// Intentional: logging must never throw
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function sessionLog(sessionId: string, message: string, data?: unknown): void {
|
|
78
|
+
log(`[magic-context][${sessionId}] ${message}`, data);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the current log file path. The path is harness-aware (see
|
|
83
|
+
* {@link getMagicContextLogPath}) and re-evaluated on every call, so callers
|
|
84
|
+
* who format diagnostic output with this value always see the path the next
|
|
85
|
+
* flush will actually use.
|
|
86
|
+
*/
|
|
87
|
+
export function getLogFilePath(): string {
|
|
88
|
+
return getMagicContextLogPath();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Flush remaining buffer on process exit
|
|
92
|
+
if (!isTestEnv) {
|
|
93
|
+
process.on("exit", flush);
|
|
94
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { DREAMER_AGENT } from "../agents/dreamer";
|
|
2
|
+
import { HISTORIAN_AGENT, HISTORIAN_EDITOR_AGENT } from "../agents/historian";
|
|
3
|
+
import { SIDEKICK_AGENT } from "../agents/sidekick";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provider-agnostic fallback chain entry.
|
|
7
|
+
* Each entry specifies a model and the providers to try in priority order.
|
|
8
|
+
* Follows oh-my-opencode's FallbackEntry pattern — `opencode` acts as a
|
|
9
|
+
* catch-all proxy provider and is listed last in most entries.
|
|
10
|
+
*/
|
|
11
|
+
export type FallbackEntry = {
|
|
12
|
+
providers: string[];
|
|
13
|
+
model: string;
|
|
14
|
+
variant?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type AgentModelRequirement = {
|
|
18
|
+
fallbackChain: FallbackEntry[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Historian: quality matters, single long prompt.
|
|
22
|
+
// Copilot first (request-based pricing, ideal for single-prompt background work).
|
|
23
|
+
const HISTORIAN_FALLBACK_CHAIN: FallbackEntry[] = [
|
|
24
|
+
{ providers: ["github-copilot", "anthropic", "opencode"], model: "claude-sonnet-4-6" },
|
|
25
|
+
{ providers: ["opencode-go"], model: "minimax-m2.7" },
|
|
26
|
+
{
|
|
27
|
+
providers: ["zai-coding-plan", "bailian-coding-plan", "opencode-go", "opencode"],
|
|
28
|
+
model: "glm-5",
|
|
29
|
+
},
|
|
30
|
+
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.4" },
|
|
31
|
+
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3.1-pro" },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
// Dreamer: runs overnight during idle time, can be slow.
|
|
35
|
+
// Copilot first (request-based pricing). Local models also work well here.
|
|
36
|
+
const DREAMER_FALLBACK_CHAIN: FallbackEntry[] = [
|
|
37
|
+
{ providers: ["github-copilot", "anthropic", "opencode"], model: "claude-sonnet-4-6" },
|
|
38
|
+
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" },
|
|
39
|
+
{
|
|
40
|
+
providers: ["zai-coding-plan", "bailian-coding-plan", "opencode-go", "opencode"],
|
|
41
|
+
model: "glm-5",
|
|
42
|
+
},
|
|
43
|
+
{ providers: ["opencode-go"], model: "minimax-m2.7" },
|
|
44
|
+
{ providers: ["github-copilot", "openai", "opencode"], model: "gpt-5.4-mini" },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
// Sidekick: speed is critical — fast inference providers first.
|
|
48
|
+
// No Copilot preference (low token count, request-based pricing doesn't help).
|
|
49
|
+
const SIDEKICK_FALLBACK_CHAIN: FallbackEntry[] = [
|
|
50
|
+
{ providers: ["cerebras"], model: "qwen-3-235b-a22b-instruct-2507" },
|
|
51
|
+
{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" },
|
|
52
|
+
{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.4-mini" },
|
|
53
|
+
{ providers: ["opencode"], model: "gpt-5-nano" },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
export const AGENT_MODEL_REQUIREMENTS: Record<string, AgentModelRequirement> = {
|
|
57
|
+
[HISTORIAN_AGENT]: { fallbackChain: HISTORIAN_FALLBACK_CHAIN },
|
|
58
|
+
// Editor reuses historian's fallback chain — same input profile (long single prompt).
|
|
59
|
+
[HISTORIAN_EDITOR_AGENT]: { fallbackChain: HISTORIAN_FALLBACK_CHAIN },
|
|
60
|
+
[DREAMER_AGENT]: { fallbackChain: DREAMER_FALLBACK_CHAIN },
|
|
61
|
+
[SIDEKICK_AGENT]: { fallbackChain: SIDEKICK_FALLBACK_CHAIN },
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Expand a provider-agnostic fallback chain into a flat `provider/model` list
|
|
66
|
+
* that OpenCode's agent config accepts as `fallback_models`.
|
|
67
|
+
*/
|
|
68
|
+
export function expandFallbackChain(chain: FallbackEntry[]): string[] {
|
|
69
|
+
const models: string[] = [];
|
|
70
|
+
for (const entry of chain) {
|
|
71
|
+
for (const provider of entry.providers) {
|
|
72
|
+
models.push(`${provider}/${entry.model}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return models;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get the expanded fallback_models list for an agent.
|
|
80
|
+
* Returns undefined if no requirement is defined.
|
|
81
|
+
*/
|
|
82
|
+
export function getAgentFallbackModels(agent: string): string[] | undefined {
|
|
83
|
+
const requirement = AGENT_MODEL_REQUIREMENTS[agent];
|
|
84
|
+
if (!requirement) return undefined;
|
|
85
|
+
return expandFallbackChain(requirement.fallbackChain);
|
|
86
|
+
}
|