@cortexkit/opencode-magic-context 0.24.1 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +4 -2
  2. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  3. package/dist/agents/permissions.d.ts +6 -0
  4. package/dist/agents/permissions.d.ts.map +1 -1
  5. package/dist/config/schema/magic-context.d.ts +22 -0
  6. package/dist/config/schema/magic-context.d.ts.map +1 -1
  7. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +25 -0
  8. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  9. package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
  10. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  11. package/dist/features/magic-context/memory/embedding-local.d.ts +7 -3
  12. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  13. package/dist/features/magic-context/memory/embedding-openai.d.ts +8 -4
  14. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  15. package/dist/features/magic-context/memory/embedding-provider.d.ts +8 -4
  16. package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -1
  17. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  18. package/dist/features/magic-context/memory/relocate-memory.d.ts +58 -0
  19. package/dist/features/magic-context/memory/relocate-memory.d.ts.map +1 -0
  20. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +6 -0
  21. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
  22. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  23. package/dist/features/magic-context/project-embedding-registry.d.ts +41 -3
  24. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  25. package/dist/features/magic-context/storage-db.d.ts +2 -1
  26. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  27. package/dist/features/magic-context/storage-meta-persisted.d.ts +37 -0
  28. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  29. package/dist/features/magic-context/storage-meta-session.d.ts +1 -0
  30. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  31. package/dist/features/magic-context/storage-meta-shared.d.ts +4 -1
  32. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  33. package/dist/features/magic-context/storage-meta.d.ts +2 -2
  34. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  35. package/dist/features/magic-context/storage-tags.d.ts +58 -2
  36. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  37. package/dist/features/magic-context/storage.d.ts +3 -3
  38. package/dist/features/magic-context/storage.d.ts.map +1 -1
  39. package/dist/features/magic-context/tagger.d.ts +1 -1
  40. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  41. package/dist/features/magic-context/transform-decision-log.d.ts +49 -0
  42. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -0
  43. package/dist/features/magic-context/types.d.ts +1 -0
  44. package/dist/features/magic-context/types.d.ts.map +1 -1
  45. package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/apply-operations.d.ts +3 -25
  47. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/caveman-cleanup.d.ts +1 -0
  50. package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
  51. package/dist/hooks/magic-context/channel2-delivery.d.ts +2 -0
  52. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  53. package/dist/hooks/magic-context/command-handler.d.ts +7 -5
  54. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
  57. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +7 -2
  59. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/derive-budgets.d.ts +5 -9
  61. package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
  62. package/dist/hooks/magic-context/embed-session-state.d.ts +14 -0
  63. package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -0
  64. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/event-payloads.d.ts +1 -0
  66. package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
  67. package/dist/hooks/magic-context/format-embed-status.d.ts +9 -0
  68. package/dist/hooks/magic-context/format-embed-status.d.ts.map +1 -0
  69. package/dist/hooks/magic-context/heuristic-cleanup.d.ts +2 -0
  70. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  72. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +10 -0
  74. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  75. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  76. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +1 -1
  77. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/strip-content.d.ts +0 -1
  79. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/tag-content-primitives.d.ts +2 -0
  81. package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
  82. package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -1
  83. package/dist/hooks/magic-context/tag-messages.d.ts +10 -0
  84. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/tool-drop-target.d.ts +1 -1
  86. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/tool-reclaim.d.ts +12 -0
  88. package/dist/hooks/magic-context/tool-reclaim.d.ts.map +1 -0
  89. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +32 -1
  90. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/transform-operations.d.ts +1 -1
  92. package/dist/hooks/magic-context/transform-operations.d.ts.map +1 -1
  93. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +6 -0
  94. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/transform.d.ts +2 -0
  96. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +1767 -613
  99. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
  100. package/dist/plugin/dream-timer.d.ts.map +1 -1
  101. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  102. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  103. package/dist/shared/announcement.d.ts +1 -1
  104. package/dist/shared/index.d.ts +0 -1
  105. package/dist/shared/index.d.ts.map +1 -1
  106. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  107. package/dist/shared/resolve-fallbacks.d.ts +16 -16
  108. package/dist/shared/resolve-fallbacks.d.ts.map +1 -1
  109. package/dist/shared/rpc-types.d.ts +20 -0
  110. package/dist/shared/rpc-types.d.ts.map +1 -1
  111. package/dist/shared/sqlite.d.ts +5 -1
  112. package/dist/shared/sqlite.d.ts.map +1 -1
  113. package/dist/tools/ctx-expand/constants.d.ts +1 -1
  114. package/dist/tools/ctx-expand/constants.d.ts.map +1 -1
  115. package/dist/tools/ctx-expand/render.d.ts +43 -0
  116. package/dist/tools/ctx-expand/render.d.ts.map +1 -0
  117. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  118. package/dist/tools/ctx-expand/types.d.ts +6 -2
  119. package/dist/tools/ctx-expand/types.d.ts.map +1 -1
  120. package/dist/tools/ctx-reduce/constants.d.ts +1 -1
  121. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  122. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  123. package/dist/tui/data/context-db.d.ts +4 -2
  124. package/dist/tui/data/context-db.d.ts.map +1 -1
  125. package/package.json +1 -1
  126. package/src/shared/announcement.ts +6 -6
  127. package/src/shared/index.ts +0 -1
  128. package/src/shared/model-suggestion-retry.test.ts +61 -1
  129. package/src/shared/model-suggestion-retry.ts +22 -0
  130. package/src/shared/resolve-fallbacks.test.ts +37 -71
  131. package/src/shared/resolve-fallbacks.ts +16 -26
  132. package/src/shared/rpc-types.ts +11 -0
  133. package/src/shared/sqlite-bind-style.test.ts +82 -0
  134. package/src/shared/sqlite.ts +30 -1
  135. package/src/shared/tag-transcript.test.ts +3 -1
  136. package/src/shared/tag-transcript.ts +19 -17
  137. package/src/tui/data/context-db.ts +34 -2
  138. package/src/tui/index.tsx +58 -4
  139. package/src/tui/slots/sidebar-content.tsx +18 -9
  140. package/dist/shared/model-requirements.d.ts +0 -26
  141. package/dist/shared/model-requirements.d.ts.map +0 -1
  142. package/src/shared/model-requirements.ts +0 -86
@@ -1,26 +0,0 @@
1
- /**
2
- * Provider-agnostic fallback chain entry.
3
- * Each entry specifies a model and the providers to try in priority order.
4
- * Follows oh-my-opencode's FallbackEntry pattern — `opencode` acts as a
5
- * catch-all proxy provider and is listed last in most entries.
6
- */
7
- export type FallbackEntry = {
8
- providers: string[];
9
- model: string;
10
- variant?: string;
11
- };
12
- export type AgentModelRequirement = {
13
- fallbackChain: FallbackEntry[];
14
- };
15
- export declare const AGENT_MODEL_REQUIREMENTS: Record<string, AgentModelRequirement>;
16
- /**
17
- * Expand a provider-agnostic fallback chain into a flat `provider/model` list
18
- * that OpenCode's agent config accepts as `fallback_models`.
19
- */
20
- export declare function expandFallbackChain(chain: FallbackEntry[]): string[];
21
- /**
22
- * Get the expanded fallback_models list for an agent.
23
- * Returns undefined if no requirement is defined.
24
- */
25
- export declare function getAgentFallbackModels(agent: string): string[] | undefined;
26
- //# sourceMappingURL=model-requirements.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-requirements.d.ts","sourceRoot":"","sources":["../../src/shared/model-requirements.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,aAAa,EAAE,aAAa,EAAE,CAAC;CAClC,CAAC;AAqCF,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAM1E,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAQpE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAI1E"}
@@ -1,86 +0,0 @@
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
- }