@cortexkit/opencode-magic-context 0.49.11 → 0.49.12

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 (206) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +28 -0
  3. package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -0
  4. package/dist/{announcement-hdbkt8v5.js → announcement-g789dmt6.js} +2 -2
  5. package/dist/auto-search-worker.js +4 -4
  6. package/dist/{compaction-marker-candidates-xxz35vwp.js → compaction-marker-candidates-v5c6997n.js} +3 -3
  7. package/dist/compaction-marker-candidates-worker.js +1 -1
  8. package/dist/config/agent-disable.d.ts +14 -0
  9. package/dist/config/agent-disable.d.ts.map +1 -1
  10. package/dist/config/dependency-notes.d.ts +34 -0
  11. package/dist/config/dependency-notes.d.ts.map +1 -0
  12. package/dist/config/schema/magic-context.d.ts.map +1 -1
  13. package/dist/{conflict-warning-hook-xwkfncav.js → conflict-warning-hook-f4x5wed7.js} +8 -8
  14. package/dist/{context-twz3s0cg.js → context-dam8p201.js} +106 -96
  15. package/dist/{derive-budgets-3nbxsyss.js → derive-budgets-5306b1jt.js} +3 -3
  16. package/dist/embedding-backfill-qbfcbp87.js +21 -0
  17. package/dist/embedding-worker-process.js +2 -2
  18. package/dist/embedding-worker.js +6 -6
  19. package/dist/features/magic-context/dreamer/task-config.d.ts +22 -4
  20. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/task-registry.d.ts +22 -0
  22. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -1
  24. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  25. package/dist/features/magic-context/memory/embedding-openai.d.ts +32 -0
  26. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  27. package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
  28. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  29. package/dist/features/magic-context/memory/unborn-head.d.ts +34 -0
  30. package/dist/features/magic-context/memory/unborn-head.d.ts.map +1 -0
  31. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  32. package/dist/features/magic-context/storage-tags.d.ts +2 -0
  33. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  34. package/dist/{history-owner-ty29fz0f.js → history-owner-xp3pngv7.js} +3 -3
  35. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/compartment-prompt.d.ts +6 -0
  37. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -0
  40. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/compartment-trigger-error.d.ts +12 -0
  42. package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
  43. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -0
  44. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/pending-materialization.d.ts +2 -0
  47. package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +12 -0
  49. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts +58 -0
  51. package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts.map +1 -0
  52. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +7 -0
  53. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/read-session-raw.d.ts +19 -0
  55. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
  57. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
  59. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/transform.d.ts +4 -0
  62. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  64. package/dist/{index-g40wgxxt.js → index-05n6ykca.js} +4 -4
  65. package/dist/{index-bzp9s8z2.js → index-1d289pq2.js} +2 -2
  66. package/dist/{index-w28y7d0z.js → index-1sarmj9z.js} +15 -15
  67. package/dist/{index-hqnggmxn.js → index-1wwh38fk.js} +128 -66
  68. package/dist/{index-0abg88h2.js → index-2pgxcncf.js} +4 -4
  69. package/dist/{index-84j7jq8a.js → index-6sytd5w3.js} +10 -10
  70. package/dist/{index-yhrrx7qa.js → index-6sz25c3s.js} +3 -3
  71. package/dist/{index-4jkhhpn1.js → index-7h8a1xpc.js} +3 -3
  72. package/dist/{index-se1w3v2m.js → index-7zd5asz9.js} +140 -17
  73. package/dist/{index-jw4gbfkv.js → index-8ketfacn.js} +2 -2
  74. package/dist/{index-q3qck7j2.js → index-95s8xaj1.js} +6 -5
  75. package/dist/{index-bmwfzz28.js → index-9vqb5p1s.js} +4 -4
  76. package/dist/{index-0jz47061.js → index-a8bvhwqs.js} +190 -30
  77. package/dist/{index-qr1mkc2y.js → index-b16gpywn.js} +9 -9
  78. package/dist/{index-g7jkrz0x.js → index-bp5083x2.js} +1 -1
  79. package/dist/{index-mp2kghkv.js → index-dyvbsvga.js} +1 -1
  80. package/dist/{index-s178h9z8.js → index-f71thw8j.js} +1 -1
  81. package/dist/{index-kvw6xew3.js → index-fkx2qnvw.js} +2 -2
  82. package/dist/{index-f8cn4xqa.js → index-fwefky9w.js} +18 -5
  83. package/dist/{index-4ccdr7yw.js → index-fx90bvjd.js} +5 -5
  84. package/dist/{index-0sahzkwr.js → index-g2q4htwp.js} +46 -2
  85. package/dist/{index-9159kk15.js → index-gf0psee3.js} +5 -5
  86. package/dist/{index-mw7c950g.js → index-gp3kcpc4.js} +1 -1
  87. package/dist/{index-gjvjh960.js → index-hqkczed7.js} +1 -1
  88. package/dist/{index-mvvephtj.js → index-j75v2476.js} +1 -1
  89. package/dist/{index-150zz6fh.js → index-k29z4aqh.js} +1 -1
  90. package/dist/{index-b64n4d0h.js → index-kee4kn5j.js} +1 -1
  91. package/dist/index-ksdyrrav.js +52 -0
  92. package/dist/{index-angx1s0k.js → index-mmfa86mt.js} +16 -6
  93. package/dist/{index-9jvab89d.js → index-n6m03s3n.js} +2 -2
  94. package/dist/{index-q28hsbpg.js → index-nj7yykkx.js} +1 -1
  95. package/dist/{index-ghc9f0n7.js → index-p5y3k4g7.js} +29 -1
  96. package/dist/{index-kkvxnbt8.js → index-qtbdx42g.js} +54 -25
  97. package/dist/{index-a865mj02.js → index-tdn0zkw4.js} +4 -4
  98. package/dist/{index-0j6crjgh.js → index-wqs4q74r.js} +8 -8
  99. package/dist/{index-xztdf9t7.js → index-x2xjyq8f.js} +11 -11
  100. package/dist/{index-a4b0gbyg.js → index-y9f76s3f.js} +1 -1
  101. package/dist/{index-z7avx6rw.js → index-yx5kgp2x.js} +197 -98
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +95 -67
  104. package/dist/{logger-wn328tfg.js → logger-jm3sqqzr.js} +2 -2
  105. package/dist/{message-index-bounded-0rbbg9rd.js → message-index-bounded-nq6rp8xa.js} +16 -16
  106. package/dist/{message-index-ct5x2kwa.js → message-index-df7swgy1.js} +16 -16
  107. package/dist/{message-time-backfill-nb5hhnrt.js → message-time-backfill-qjge9044.js} +3 -3
  108. package/dist/migration-worker.js +11 -11
  109. package/dist/plugin/dream-timer.d.ts.map +1 -1
  110. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  111. package/dist/plugin/tool-registry.d.ts.map +1 -1
  112. package/dist/{project-embedding-registry-ft9gh2e2.js → project-embedding-registry-q0ysjyzc.js} +11 -11
  113. package/dist/raw-ordinal-warmup-worker.js +12 -7
  114. package/dist/{read-session-chunk-y3hhsbzw.js → read-session-chunk-ax05f7gr.js} +11 -11
  115. package/dist/{read-session-raw-gm6xj30v.js → read-session-raw-m56hc7v2.js} +7 -3
  116. package/dist/{recomp-orchestrator-67k45s0b.js → recomp-orchestrator-a0mvby4e.js} +29 -29
  117. package/dist/{safe-notification-target-jdynm677.js → safe-notification-target-1szv1k5k.js} +3 -3
  118. package/dist/{search-jd8xh721.js → search-fm002702.js} +23 -23
  119. package/dist/{send-session-notification-vzhj8bsg.js → send-session-notification-y2wg3fkh.js} +6 -6
  120. package/dist/shared/data-path.d.ts +4 -0
  121. package/dist/shared/data-path.d.ts.map +1 -1
  122. package/dist/{storage-tags-35m4gms2.js → storage-tags-yygfb9c8.js} +7 -5
  123. package/dist/{task-config-cgpg0nvh.js → task-config-x3qmayd2.js} +6 -2
  124. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  125. package/dist/{transform-postprocess-phase-pmqxfq4q.js → transform-postprocess-phase-s84rdf32.js} +29 -29
  126. package/dist/v2/auto-search-worker.js +4 -4
  127. package/dist/v2/{compaction-marker-candidates-a15w3mqh.js → compaction-marker-candidates-1vqwr3s5.js} +2 -2
  128. package/dist/v2/compaction-marker-candidates-worker.js +1 -1
  129. package/dist/v2/{context-p1zfcw41.js → context-x60fa16g.js} +181 -83
  130. package/dist/v2/{derive-budgets-0rmpmxjw.js → derive-budgets-z25jw3py.js} +3 -3
  131. package/dist/v2/embedding-backfill-mbjyza2a.js +20 -0
  132. package/dist/v2/embedding-worker-process.js +1 -1
  133. package/dist/v2/embedding-worker.js +5 -5
  134. package/dist/v2/{history-owner-2cr9py37.js → history-owner-42e16w0n.js} +2 -2
  135. package/dist/v2/hooks/context.d.ts.map +1 -1
  136. package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
  137. package/dist/v2/hooks/dream-trigger.d.ts +1 -1
  138. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  139. package/dist/v2/hooks/transform-features.d.ts +1 -0
  140. package/dist/v2/hooks/transform-features.d.ts.map +1 -1
  141. package/dist/v2/{logger-te6e1j72.js → logger-7qt02bnb.js} +1 -1
  142. package/dist/v2/{message-index-cjhv92m2.js → message-index-5nayhm1r.js} +15 -15
  143. package/dist/v2/{message-index-bounded-7wcbp975.js → message-index-bounded-pgv1ndpb.js} +15 -15
  144. package/dist/v2/{message-time-backfill-rz1pnpaj.js → message-time-backfill-bsteyc4d.js} +2 -2
  145. package/dist/v2/migration-worker.js +10 -10
  146. package/dist/v2/{project-embedding-registry-g34gcf74.js → project-embedding-registry-jbmjc0p4.js} +10 -10
  147. package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
  148. package/dist/v2/{read-session-chunk-8d3v87vr.js → read-session-chunk-hr3w5bjk.js} +10 -10
  149. package/dist/v2/{read-session-raw-h4azh85b.js → read-session-raw-b3tf6ra1.js} +6 -2
  150. package/dist/v2/recomp-orchestrator-8w3449eb.js +59 -0
  151. package/dist/v2/{safe-notification-target-936374xx.js → safe-notification-target-qg7n2s77.js} +2 -2
  152. package/dist/v2/{search-a1acjwf8.js → search-mhmxgq0e.js} +22 -22
  153. package/dist/v2/{send-session-notification-z5mcjdea.js → send-session-notification-jevgj9fe.js} +5 -5
  154. package/dist/v2/{server-npm52h2q.js → server-05xjtq6c.js} +1 -1
  155. package/dist/v2/{server-s6jqh8bj.js → server-0ppsweh6.js} +1 -1
  156. package/dist/v2/server-0s95v3en.js +49 -0
  157. package/dist/v2/{server-pbpp8r8h.js → server-25tg45b4.js} +9 -9
  158. package/dist/v2/{server-83d71zab.js → server-2x42esxd.js} +3 -3
  159. package/dist/v2/{server-5x7kmyz8.js → server-37ngj8qw.js} +10 -51
  160. package/dist/v2/{server-kn7skz9r.js → server-4c10404h.js} +3 -3
  161. package/dist/v2/{server-erfp0xb6.js → server-50mkkhy1.js} +10 -10
  162. package/dist/v2/{server-7fvmt15t.js → server-5gvkzzrf.js} +192 -49
  163. package/dist/v2/{server-7dv9wt9r.js → server-6pmqg9m4.js} +1 -1
  164. package/dist/v2/{server-h3wc20sv.js → server-83ygfha2.js} +4 -4
  165. package/dist/v2/{server-rxcq4t50.js → server-9ewkzqgd.js} +5 -5
  166. package/dist/v2/{server-kmapq3v0.js → server-bxpwy6fy.js} +18 -5
  167. package/dist/v2/{server-d6t16r89.js → server-d8tj10db.js} +1 -1
  168. package/dist/v2/{server-cxsr0ng6.js → server-da07v4xp.js} +1 -1
  169. package/dist/v2/{server-9e5r8y60.js → server-f2xf5gcb.js} +46 -2
  170. package/dist/v2/{server-hn9fb3v0.js → server-f7jfmrrz.js} +2 -2
  171. package/dist/v2/{server-f27he3j1.js → server-fa75w6gp.js} +4 -4
  172. package/dist/v2/{server-njnx39q2.js → server-gvkm8xaj.js} +189 -29
  173. package/dist/v2/{server-ckrb5rm8.js → server-h0410h0v.js} +1 -1
  174. package/dist/v2/{server-nveratm5.js → server-kn9n2qgd.js} +1 -1
  175. package/dist/v2/{server-wkhfyzpg.js → server-m97brnat.js} +9 -9
  176. package/dist/v2/{server-d3f4g62c.js → server-nmrm2rjy.js} +8 -8
  177. package/dist/v2/{server-bx59ezg6.js → server-prg55b7k.js} +16 -6
  178. package/dist/v2/{server-89fcbe37.js → server-pwv4ezb0.js} +1 -1
  179. package/dist/v2/{server-r5p3b1wy.js → server-qd11g795.js} +29 -1
  180. package/dist/v2/{server-988cqjme.js → server-rrqpvwqd.js} +2 -2
  181. package/dist/v2/{server-sg68np13.js → server-sz8jj92q.js} +140 -17
  182. package/dist/v2/{server-jc8v585p.js → server-th4y11y7.js} +15 -15
  183. package/dist/v2/{server-ewqshbs8.js → server-vknbt0gq.js} +5 -5
  184. package/dist/v2/{server-63ha7f0f.js → server-yrvqaswb.js} +1 -1
  185. package/dist/v2/{server-xqf2d2mg.js → server-zs8d0s3b.js} +2 -2
  186. package/dist/v2/server.d.ts.map +1 -1
  187. package/dist/v2/server.js +13 -6
  188. package/dist/v2/{storage-tags-c4zfcxv4.js → storage-tags-a2gq6dw7.js} +6 -4
  189. package/dist/v2/{task-config-x0hq3qfd.js → task-config-nvz8mapa.js} +6 -2
  190. package/dist/v2/{wrapup-orchestrator-87q9d5e2.js → wrapup-orchestrator-r82y780v.js} +30 -29
  191. package/dist/wrapup-orchestrator-vmt6z3q5.js +47 -0
  192. package/package.json +1 -1
  193. package/src/agents/smart-notes-dreamer-gate.fixture.ts +171 -0
  194. package/src/agents/smart-notes-dreamer-gate.golden.json +245 -0
  195. package/src/agents/smart-notes-dreamer-gate.test.ts +161 -0
  196. package/src/config/agent-disable.ts +13 -0
  197. package/src/config/dependency-notes.test.ts +114 -0
  198. package/src/config/dependency-notes.ts +80 -0
  199. package/src/config/schema/magic-context.ts +23 -14
  200. package/src/features/magic-context/dreamer/task-registry.ts +40 -0
  201. package/src/shared/data-path.test.ts +35 -1
  202. package/src/shared/data-path.ts +57 -1
  203. package/dist/embedding-backfill-fjbfh1dt.js +0 -21
  204. package/dist/v2/embedding-backfill-xcw3t6hp.js +0 -20
  205. package/dist/v2/recomp-orchestrator-n0pq36f0.js +0 -59
  206. package/dist/wrapup-orchestrator-jqapepw0.js +0 -47
@@ -0,0 +1,80 @@
1
+ import { PROJECT_MEMORY_DREAM_TASKS } from "../features/magic-context/dreamer/task-registry";
2
+ import { isDreamerRunnable } from "./agent-disable";
3
+
4
+ /**
5
+ * Settings whose effect depends on a different section of the config. These
6
+ * lines name a setting that is on but cannot act because another setting turns
7
+ * off what it relies on, so a user reading the log can tell why nothing happens.
8
+ *
9
+ * Only settings the user can see as "on" are reported: an explicit
10
+ * `memory.enabled: false` or `dreamer.disable: true` is the cause in every line,
11
+ * so a configuration that sets neither produces none.
12
+ */
13
+ export interface DependencyNoteConfig {
14
+ memory?: { enabled?: boolean } | null;
15
+ smart_notes?: { enabled?: boolean } | null;
16
+ dreamer?: {
17
+ disable?: boolean;
18
+ tasks?: Record<string, { schedule?: string } | undefined>;
19
+ } | null;
20
+ }
21
+
22
+ function scheduledTasks(config: DependencyNoteConfig): string[] {
23
+ const tasks = config.dreamer?.tasks ?? {};
24
+ return Object.entries(tasks)
25
+ .filter(([, task]) => typeof task?.schedule === "string" && task.schedule.trim() !== "")
26
+ .map(([name]) => name);
27
+ }
28
+
29
+ /** The dependency notes for one resolved config, in a stable order. */
30
+ export function configDependencyNotes(config: DependencyNoteConfig): string[] {
31
+ const notes: string[] = [];
32
+ const dreamerRunnable = isDreamerRunnable(config);
33
+ const dreamerDisabled = config.dreamer?.disable === true;
34
+ const memoryOff = config.memory?.enabled === false;
35
+
36
+ const memoryTasks = scheduledTasks(config).filter((task) =>
37
+ (PROJECT_MEMORY_DREAM_TASKS as readonly string[]).includes(task),
38
+ );
39
+ if (dreamerRunnable && memoryOff && memoryTasks.length > 0) {
40
+ notes.push(
41
+ `memory.enabled is false, so these scheduled dreamer tasks do not run for this project, on schedule or through /ctx-dream: ${memoryTasks.join(", ")}. maintain-docs, evaluate-smart-notes and review-user-memories still run.`,
42
+ );
43
+ }
44
+ if (dreamerDisabled && config.smart_notes?.enabled !== false) {
45
+ notes.push(
46
+ "dreamer.disable is true, so smart_notes.enabled has no effect: ctx_note does not offer surface_condition and pending smart notes are not evaluated.",
47
+ );
48
+ }
49
+ const reviewSchedule = config.dreamer?.tasks?.["review-user-memories"]?.schedule;
50
+ if (dreamerDisabled && typeof reviewSchedule === "string" && reviewSchedule.trim() !== "") {
51
+ notes.push(
52
+ "dreamer.disable is true, so dreamer.tasks.review-user-memories.schedule has no effect: the historian does not collect user observations and the <user-profile> block gets no new entries.",
53
+ );
54
+ }
55
+ return notes;
56
+ }
57
+
58
+ const loggedNotes = new Set<string>();
59
+
60
+ /**
61
+ * Log each dependency note once per process. OpenCode Desktop starts one
62
+ * plugin instance per open project in the same process, so a note already
63
+ * written by another instance is skipped rather than repeated.
64
+ */
65
+ export function logConfigDependencyNotesOnce(
66
+ config: DependencyNoteConfig,
67
+ log: (message: string) => void,
68
+ ): string[] {
69
+ const fresh = configDependencyNotes(config).filter((note) => !loggedNotes.has(note));
70
+ for (const note of fresh) {
71
+ loggedNotes.add(note);
72
+ log(`[magic-context] config note: ${note}`);
73
+ }
74
+ return fresh;
75
+ }
76
+
77
+ /** Test-only: forget which notes this process has logged. */
78
+ export function resetConfigDependencyNotesForTest(): void {
79
+ loggedNotes.clear();
80
+ }
@@ -613,6 +613,8 @@ export const DreamTasksSchema = z
613
613
  ),
614
614
  "review-user-memories": ReviewUserMemoriesTaskConfigSchema.default(() =>
615
615
  ReviewUserMemoriesTaskConfigSchema.parse(defaultTaskConfig("review-user-memories")),
616
+ ).describe(
617
+ "Promote recurring user observations into the <user-profile> block. A non-empty schedule also makes the historian collect user observations, but only while the dreamer is runnable (dreamer.disable not true); collection and review follow that one gate and do not depend on memory.enabled.",
616
618
  ),
617
619
  "promote-primers": PromotePrimersTaskConfigSchema.default(() =>
618
620
  PromotePrimersTaskConfigSchema.parse(defaultTaskConfig("promote-primers")),
@@ -644,7 +646,12 @@ export const DreamerConfigSchema = AgentMetadataSchema.extend({
644
646
  // Its own node rather than the one shared with the historian through
645
647
  // AgentMetadataSchema: `dreamer.disable` is a live-reload key and the
646
648
  // historian's is not, and the live marker is set on the schema node.
647
- disable: z.boolean().optional().describe("Disable this agent"),
649
+ disable: z
650
+ .boolean()
651
+ .optional()
652
+ .describe(
653
+ "Disable the dreamer: no scheduled or manual dream task runs. Also turns off smart notes (ctx_note drops surface_condition even with smart_notes.enabled true) and the historian's collection of user observations for review-user-memories. dreamer.inject_docs still applies.",
654
+ ),
648
655
  runner: z
649
656
  .enum(["broca", "host"])
650
657
  .optional()
@@ -659,7 +666,7 @@ export const DreamerConfigSchema = AgentMetadataSchema.extend({
659
666
  .boolean()
660
667
  .default(true)
661
668
  .describe(
662
- "Inject ARCHITECTURE.md and STRUCTURE.md into the m[0] `<project-docs>` block (default true)",
669
+ "Inject ARCHITECTURE.md and STRUCTURE.md into the m[0] `<project-docs>` block (default true). Not a dreamer setting despite its place under dreamer: it applies on every host, also with dreamer.disable true.",
663
670
  ),
664
671
  });
665
672
  export type DreamerConfig = z.infer<typeof DreamerConfigSchema>;
@@ -1181,7 +1188,7 @@ export const MagicContextConfigSchema = z
1181
1188
  "Historian metadata plus independent strict OpenCode, Pi, and OMP execution blocks. Retained metadata stays at historian; model, fallback_models, variant, and thinking_level belong only in historian.opencode, historian.pi, or historian.omp.",
1182
1189
  ),
1183
1190
  dreamer: DreamerConfigSchema.optional().describe(
1184
- "Dreamer metadata and scheduling plus independent strict OpenCode, Pi, and OMP execution blocks. schedule and promotion_threshold stay at dreamer.tasks; model, fallback_models, variant, thinking_level, and timeout_minutes belong only in the matching harness block.",
1191
+ "Dreamer metadata and scheduling plus independent strict OpenCode, Pi, and OMP execution blocks. schedule and promotion_threshold stay at dreamer.tasks; model, fallback_models, variant, thinking_level, and timeout_minutes belong only in the matching harness block. Each task follows the setting it serves: memory tasks need memory.enabled, evaluate-smart-notes needs smart_notes.enabled, review-user-memories needs its schedule, maintain-docs only a runnable dreamer.",
1185
1192
  ),
1186
1193
  smart_notes: z
1187
1194
  .object({
@@ -1189,7 +1196,7 @@ export const MagicContextConfigSchema = z
1189
1196
  .boolean()
1190
1197
  .default(true)
1191
1198
  .describe(
1192
- "Enable smart-note authoring and condition evaluation. User-level only: tool definitions are process-wide. Changes require a host restart and rebuild each session's cached prompt once. Pending notes remain stored and unchecked; already-ready notes still surface.",
1199
+ "Enable smart-note authoring and condition evaluation. Needs a runnable dreamer, which evaluates the conditions: with dreamer.disable true (or no dreamer block) ctx_note offers no surface_condition whatever this says. User-level only: tool definitions are process-wide. Changes require a host restart and rebuild each session's cached prompt once. Pending notes remain stored and unchecked; already-ready notes still surface.",
1193
1200
  ),
1194
1201
  retina_handoff: z
1195
1202
  .boolean()
@@ -1303,7 +1310,7 @@ export const MagicContextConfigSchema = z
1303
1310
  .min(60_000)
1304
1311
  .default(DEFAULT_HISTORIAN_TIMEOUT_MS)
1305
1312
  .describe(
1306
- "Timeout for each historian prompt call in both TypeScript and Rust transform modes, in milliseconds (default: 600000)",
1313
+ "Timeout for each historian prompt call in both TypeScript and Rust transform modes, in milliseconds (default: 600000). A historian setting kept at the top level for compatibility; no effect while historian.disable is true or compaction.enabled is false.",
1307
1314
  ),
1308
1315
  commit_cluster_trigger: z
1309
1316
  .object({
@@ -1321,7 +1328,7 @@ export const MagicContextConfigSchema = z
1321
1328
  })
1322
1329
  .default({ enabled: true, min_clusters: 3 })
1323
1330
  .describe(
1324
- "Commit-cluster trigger: fire historian when enough commit clusters accumulate in the unsummarized tail",
1331
+ "Commit-cluster trigger: fire historian when enough commit clusters accumulate in the unsummarized tail. A historian setting kept at the top level for compatibility; no effect while historian.disable is true or compaction.enabled is false.",
1325
1332
  ),
1326
1333
  system_prompt_injection: z
1327
1334
  .object({
@@ -1510,7 +1517,7 @@ export const MagicContextConfigSchema = z
1510
1517
  .boolean()
1511
1518
  .default(true)
1512
1519
  .describe(
1513
- "Enable cross-session memory (default: true). Does not affect history embedding or semantic ctx_search over session history; set embedding.provider to 'off' to stop all embedding.",
1520
+ "Enable cross-session project memory (default: true). Also gates the dreamer's project-memory tasks: while false, map-memories, verify, verify-broad, curate, compress-cues, classify-memories, retrospective, promote-primers and refresh-primers neither run on schedule nor through /ctx-dream; maintain-docs, evaluate-smart-notes and review-user-memories still run. memory.auto_search and memory.git_commit_indexing do not depend on it. Does not affect history embedding or semantic ctx_search over session history; set embedding.provider to 'off' to stop all embedding.",
1514
1521
  ),
1515
1522
  injection_budget_tokens: z
1516
1523
  .number()
@@ -1524,14 +1531,14 @@ export const MagicContextConfigSchema = z
1524
1531
  .boolean()
1525
1532
  .default(true)
1526
1533
  .describe(
1527
- "Automatically promote eligible session facts into memory (default: true)",
1534
+ "Automatically promote eligible session facts into memory (default: true). No effect while memory.enabled is false.",
1528
1535
  ),
1529
1536
  retrieval_count_promotion_threshold: z
1530
1537
  .number()
1531
1538
  .min(1)
1532
1539
  .default(3)
1533
1540
  .describe(
1534
- "retrieval_count threshold for promoting memory to permanent status (min: 1, default: 3)",
1541
+ "Currently has no effect: no code reads this value, and memories are not promoted to permanent by retrieval count. Kept so existing configs stay valid (min: 1, default: 3).",
1535
1542
  ),
1536
1543
  auto_search: z
1537
1544
  .object({
@@ -1539,7 +1546,7 @@ export const MagicContextConfigSchema = z
1539
1546
  .boolean()
1540
1547
  .default(true)
1541
1548
  .describe(
1542
- "Automatically append a compact <ctx-search-hint> to eligible user messages when relevant memories, conversation, or commits are found. Graduated from experimental.auto_search; on by default (set false to opt out). Independent of memory.enabled.",
1549
+ "Automatically append a compact <ctx-search-hint> to eligible user messages when relevant memories, conversation, or commits are found. Graduated from experimental.auto_search; on by default (set false to opt out). Independent of memory.enabled despite its place under memory: with memory off it still searches past conversation and commits, only the memory source is skipped.",
1543
1550
  ),
1544
1551
  score_threshold: z
1545
1552
  .number()
@@ -1560,7 +1567,7 @@ export const MagicContextConfigSchema = z
1560
1567
  })
1561
1568
  .default({ enabled: true, score_threshold: 0.6, min_prompt_chars: 20 })
1562
1569
  .describe(
1563
- "Auto-search hint: transform-time ctx_search on each new user message; when the top hit clears the threshold, append a compact <ctx-search-hint> block of vague fragments to that user message. Does NOT inject full content. Graduated from experimental.auto_search; enabled by default (set enabled: false to opt out). Independent of memory.enabled.",
1570
+ "Auto-search hint: transform-time ctx_search on each new user message; when the top hit clears the threshold, append a compact <ctx-search-hint> block of vague fragments to that user message. Does NOT inject full content. Graduated from experimental.auto_search; enabled by default (set enabled: false to opt out). Independent of memory.enabled despite its place under memory: with memory off it still searches past conversation and commits.",
1564
1571
  ),
1565
1572
  git_commit_indexing: z
1566
1573
  .object({
@@ -1568,7 +1575,7 @@ export const MagicContextConfigSchema = z
1568
1575
  .boolean()
1569
1576
  .default(false)
1570
1577
  .describe(
1571
- "Index HEAD git commits for ctx_search (git_commit source). Graduated from experimental.git_commit_indexing; opt-in, default off. Independent of memory.enabled.",
1578
+ "Index HEAD git commits for ctx_search (git_commit source). Graduated from experimental.git_commit_indexing; opt-in, default off. Independent of memory.enabled despite its place under memory.",
1572
1579
  ),
1573
1580
  since_days: z
1574
1581
  .number()
@@ -1589,7 +1596,7 @@ export const MagicContextConfigSchema = z
1589
1596
  })
1590
1597
  .default({ enabled: false, since_days: 365, max_commits: 2000 })
1591
1598
  .describe(
1592
- "Index git commit messages from HEAD into ctx_search. Commits become a 4th searchable source alongside memories and session history. Graduated from experimental.git_commit_indexing; opt-in, default off (per-project embedding cost). Independent of memory.enabled.",
1599
+ "Index git commit messages from HEAD into ctx_search. Commits become a 4th searchable source alongside memories and session history. Graduated from experimental.git_commit_indexing; opt-in, default off (per-project embedding cost). Independent of memory.enabled despite its place under memory.",
1593
1600
  ),
1594
1601
  })
1595
1602
  .default({
@@ -1600,7 +1607,9 @@ export const MagicContextConfigSchema = z
1600
1607
  auto_search: { enabled: true, score_threshold: 0.6, min_prompt_chars: 20 },
1601
1608
  git_commit_indexing: { enabled: false, since_days: 365, max_commits: 2000 },
1602
1609
  })
1603
- .describe("Cross-session memory configuration"),
1610
+ .describe(
1611
+ "Cross-session memory configuration. auto_search and git_commit_indexing sit here for history but work with memory.enabled false.",
1612
+ ),
1604
1613
  })
1605
1614
  .transform((data): MagicContextConfig => {
1606
1615
  return {
@@ -278,6 +278,46 @@ export const MEMORY_DOMAIN_TASKS: readonly DreamTaskName[] = [
278
278
 
279
279
  const MEMORY_DOMAIN_SET = new Set<DreamTaskName>(MEMORY_DOMAIN_TASKS);
280
280
 
281
+ /**
282
+ * The dreamer tasks that maintain project memory or knowledge derived from it
283
+ * (primers grow out of the same sessions and live beside the memories). They
284
+ * run only while `memory.enabled` is true. Every other task serves a different
285
+ * setting and runs with memory off:
286
+ * - evaluate-smart-notes follows `smart_notes.enabled`;
287
+ * - review-user-memories follows user-observation collection, which is on
288
+ * exactly when the review is scheduled and the dreamer is runnable, so
289
+ * observations are collected exactly when they will be reviewed;
290
+ * - maintain-docs needs only a runnable dreamer.
291
+ * A runnable dreamer is the precondition for any scheduler call at all.
292
+ */
293
+ export const PROJECT_MEMORY_DREAM_TASKS: readonly DreamTaskName[] = [
294
+ "map-memories",
295
+ "verify",
296
+ "verify-broad",
297
+ "curate",
298
+ "compress-cues",
299
+ "classify-memories",
300
+ "retrospective",
301
+ "promote-primers",
302
+ "refresh-primers",
303
+ ];
304
+
305
+ const PROJECT_MEMORY_DREAM_TASK_SET = new Set<DreamTaskName>(PROJECT_MEMORY_DREAM_TASKS);
306
+
307
+ /**
308
+ * Whether the per-project settings let this task run. `memory.enabled` gates
309
+ * only the project-memory tasks and `smart_notes.enabled` only
310
+ * evaluate-smart-notes; an omitted setting counts as on.
311
+ */
312
+ export function dreamTaskAllowedBySettings(
313
+ task: DreamTaskName,
314
+ settings: { projectMemoryEnabled?: boolean; smartNotesEnabled?: boolean },
315
+ ): boolean {
316
+ if (PROJECT_MEMORY_DREAM_TASK_SET.has(task)) return settings.projectMemoryEnabled !== false;
317
+ if (task === "evaluate-smart-notes") return settings.smartNotesEnabled !== false;
318
+ return true;
319
+ }
320
+
281
321
  /**
282
322
  * Lease KIND per task. `memory` + the three independent kinds are per-project;
283
323
  * `user-memories` is GLOBAL (mutates the cross-project user-profile pool, so two
@@ -1,5 +1,5 @@
1
1
  import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2
- import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ import { mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
3
3
  import * as os from "node:os";
4
4
  import * as path from "node:path";
5
5
  import {
@@ -14,6 +14,7 @@ import {
14
14
  getOpenCodeStorageDir,
15
15
  getProjectMagicContextDir,
16
16
  getProjectMagicContextHistorianDir,
17
+ isMagicContextStorageOutsideEngram,
17
18
  } from "./data-path";
18
19
  import { createTestTempDirFromPath } from "./test-temp-dir";
19
20
 
@@ -108,12 +109,45 @@ describe("data-path", () => {
108
109
  expect(getMagicContextStorageDir()).toBe(
109
110
  path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context"),
110
111
  );
112
+ expect(isMagicContextStorageOutsideEngram()).toBe(false);
111
113
  } finally {
112
114
  if (savedTestDir !== undefined) process.env.MAGIC_CONTEXT_TEST_DATA_DIR = savedTestDir;
113
115
  if (savedNodeEnv !== undefined) process.env.NODE_ENV = savedNodeEnv;
114
116
  }
115
117
  });
116
118
 
119
+ test("an external storage override is outside the Engram backup folder", () => {
120
+ const root = createTestTempDirFromPath(path.join(os.tmpdir(), "mc-storage-backup-"));
121
+ process.env.MAGIC_CONTEXT_STORAGE_DIR = path.join(root, "external-store");
122
+
123
+ expect(isMagicContextStorageOutsideEngram()).toBe(true);
124
+ });
125
+
126
+ test("storage below the Engram backup folder is considered inside it", () => {
127
+ const root = createTestTempDirFromPath(path.join(os.tmpdir(), "mc-storage-backup-"));
128
+ const backupDir = path.join(root, "default", "magic-context");
129
+
130
+ expect(isMagicContextStorageOutsideEngram(path.join(backupDir, "nested"), backupDir)).toBe(
131
+ false,
132
+ );
133
+ });
134
+
135
+ test("a storage symlink into the default folder is considered inside it", () => {
136
+ const root = createTestTempDirFromPath(path.join(os.tmpdir(), "mc-storage-backup-"));
137
+ const backupDir = path.join(root, "default", "magic-context");
138
+ const storageLink = path.join(root, "storage-link");
139
+ mkdirSync(backupDir, { recursive: true });
140
+ symlinkSync(backupDir, storageLink, "dir");
141
+
142
+ expect(isMagicContextStorageOutsideEngram(storageLink, backupDir)).toBe(false);
143
+ });
144
+
145
+ test("an unset storage override keeps the platform default inside the backup folder", () => {
146
+ expect(process.env.MAGIC_CONTEXT_STORAGE_DIR).toBeUndefined();
147
+ expect(process.env.XDG_DATA_HOME).toBeUndefined();
148
+ expect(isMagicContextStorageOutsideEngram()).toBe(false);
149
+ });
150
+
117
151
  test("getMagicContextStorageDir backstops to a temp dir under NODE_ENV=test with no guard set", () => {
118
152
  // CWD-independent backstop: a `bun test` from a dir whose bunfig has no
119
153
  // `[test] preload` runs every suite with neither guard env var set. The
@@ -1,4 +1,12 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
1
+ import {
2
+ existsSync,
3
+ lstatSync,
4
+ mkdirSync,
5
+ readFileSync,
6
+ readlinkSync,
7
+ realpathSync,
8
+ writeFileSync,
9
+ } from "node:fs";
2
10
  import * as os from "node:os";
3
11
  import * as path from "node:path";
4
12
  import { getHarness, type HarnessId } from "./harness";
@@ -253,6 +261,54 @@ export function getMagicContextStorageDir(): string {
253
261
  return getMagicContextStorageResolution().path;
254
262
  }
255
263
 
264
+ function canonicalizeStoragePath(value: string, seen = new Set<string>()): string {
265
+ const absolute = path.resolve(value);
266
+ if (seen.has(absolute)) return absolute;
267
+ seen.add(absolute);
268
+
269
+ try {
270
+ return realpathSync.native(absolute);
271
+ } catch {
272
+ try {
273
+ if (lstatSync(absolute).isSymbolicLink()) {
274
+ const target = readlinkSync(absolute);
275
+ const resolvedTarget = path.isAbsolute(target)
276
+ ? target
277
+ : path.resolve(path.dirname(absolute), target);
278
+ return canonicalizeStoragePath(resolvedTarget, seen);
279
+ }
280
+ } catch {
281
+ // The path may not exist yet; resolve the nearest existing parent below.
282
+ }
283
+
284
+ const parent = path.dirname(absolute);
285
+ if (parent === absolute) return absolute;
286
+ const resolvedParent = canonicalizeStoragePath(parent, seen);
287
+ return path.resolve(resolvedParent, path.basename(absolute));
288
+ }
289
+ }
290
+
291
+ /** Whether the resolved store is outside the default CortexKit backup directory. */
292
+ export function isMagicContextStorageOutsideEngram(
293
+ storageDir = getMagicContextStorageDir(),
294
+ backupDir = path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context"),
295
+ ): boolean {
296
+ const resolvedStorageDir = canonicalizeStoragePath(storageDir);
297
+ const resolvedBackupDir = canonicalizeStoragePath(backupDir);
298
+ const relative = path.relative(resolvedBackupDir, resolvedStorageDir);
299
+ return path.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path.sep}`);
300
+ }
301
+
302
+ const STORAGE_BACKUP_WARNING_CHECKED = Symbol.for("magic-context.storage-backup-warning-checked");
303
+
304
+ /** Claim the process-wide startup check so multiple host entries log at most once. */
305
+ export function claimStorageBackupWarningCheck(): boolean {
306
+ const processState = globalThis as unknown as { [key: symbol]: boolean | undefined };
307
+ if (processState[STORAGE_BACKUP_WARNING_CHECKED]) return false;
308
+ processState[STORAGE_BACKUP_WARNING_CHECKED] = true;
309
+ return true;
310
+ }
311
+
256
312
  let testBackstopStorageDir: string | null = null;
257
313
  let testBackstopWarned = false;
258
314
 
@@ -1,21 +0,0 @@
1
- import {
2
- ensureMemoryEmbeddings2
3
- } from "./index-4ccdr7yw.js";
4
- import"./index-se1w3v2m.js";
5
- import"./index-9159kk15.js";
6
- import"./index-4dhv7mqz.js";
7
- import"./index-qt1qqasc.js";
8
- import"./index-bmwfzz28.js";
9
- import"./index-kvw6xew3.js";
10
- import"./index-0jz47061.js";
11
- import"./index-mp2kghkv.js";
12
- import"./index-w28y7d0z.js";
13
- import"./index-150zz6fh.js";
14
- import"./index-gjvjh960.js";
15
- import"./index-wafzvyhg.js";
16
- import"./index-mvvephtj.js";
17
- import"./index-0sahzkwr.js";
18
- import"./index-pavzsdc6.js";
19
- export {
20
- ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
21
- };
@@ -1,20 +0,0 @@
1
- import {
2
- ensureMemoryEmbeddings2
3
- } from "./server-rxcq4t50.js";
4
- import"./server-sg68np13.js";
5
- import"./server-ewqshbs8.js";
6
- import"./server-4dhv7mqz.js";
7
- import"./server-qt1qqasc.js";
8
- import"./server-83d71zab.js";
9
- import"./server-988cqjme.js";
10
- import"./server-njnx39q2.js";
11
- import"./server-63ha7f0f.js";
12
- import"./server-jc8v585p.js";
13
- import"./server-7dv9wt9r.js";
14
- import"./server-s6jqh8bj.js";
15
- import"./server-wafzvyhg.js";
16
- import"./server-9e5r8y60.js";
17
- import"./server-pavzsdc6.js";
18
- export {
19
- ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
20
- };
@@ -1,59 +0,0 @@
1
- import {
2
- isRecompFailure2,
3
- isRecompSkip2,
4
- extractRecompReason2,
5
- setRecompStarting2,
6
- setRecompNote2,
7
- setRecompTerminal2,
8
- buildRecompDeps2,
9
- runManagedRecomp2
10
- } from "./server-7fvmt15t.js";
11
- import"./server-npm52h2q.js";
12
- import"./server-kn7skz9r.js";
13
- import"./server-d3f4g62c.js";
14
- import"./server-rxcq4t50.js";
15
- import"./server-n78avt2p.js";
16
- import"./server-sg68np13.js";
17
- import"./server-ewqshbs8.js";
18
- import"./server-4dhv7mqz.js";
19
- import"./server-hn9fb3v0.js";
20
- import"./server-h3wc20sv.js";
21
- import"./server-qt1qqasc.js";
22
- import"./server-ckrb5rm8.js";
23
- import"./server-5x7kmyz8.js";
24
- import"./server-nveratm5.js";
25
- import"./server-x8a7jmkh.js";
26
- import"./server-83d71zab.js";
27
- import"./server-988cqjme.js";
28
- import"./server-erfp0xb6.js";
29
- import"./server-fb3zxn06.js";
30
- import"./server-f27he3j1.js";
31
- import"./server-fr0wbhdn.js";
32
- import"./server-njnx39q2.js";
33
- import"./server-63ha7f0f.js";
34
- import"./server-cxsr0ng6.js";
35
- import"./server-wkhfyzpg.js";
36
- import"./server-kmapq3v0.js";
37
- import"./server-1zx87sdm.js";
38
- import"./server-d6t16r89.js";
39
- import"./server-bx59ezg6.js";
40
- import"./server-51779zs2.js";
41
- import"./server-jc8v585p.js";
42
- import"./server-xqf2d2mg.js";
43
- import"./server-89fcbe37.js";
44
- import"./server-2ra6pwf3.js";
45
- import"./server-7dv9wt9r.js";
46
- import"./server-s6jqh8bj.js";
47
- import"./server-wafzvyhg.js";
48
- import"./server-9e5r8y60.js";
49
- import"./server-pavzsdc6.js";
50
- export {
51
- buildRecompDeps2 as buildRecompDeps,
52
- extractRecompReason2 as extractRecompReason,
53
- isRecompFailure2 as isRecompFailure,
54
- isRecompSkip2 as isRecompSkip,
55
- runManagedRecomp2 as runManagedRecomp,
56
- setRecompNote2 as setRecompNote,
57
- setRecompStarting2 as setRecompStarting,
58
- setRecompTerminal2 as setRecompTerminal
59
- };
@@ -1,47 +0,0 @@
1
- import {
2
- runManagedWrapup2
3
- } from "./index-q3qck7j2.js";
4
- import"./index-g40wgxxt.js";
5
- import"./index-z7avx6rw.js";
6
- import"./index-s178h9z8.js";
7
- import"./index-yhrrx7qa.js";
8
- import"./index-0j6crjgh.js";
9
- import"./index-sd3egckz.js";
10
- import"./index-4ccdr7yw.js";
11
- import"./index-n78avt2p.js";
12
- import"./index-se1w3v2m.js";
13
- import"./index-9159kk15.js";
14
- import"./index-4dhv7mqz.js";
15
- import"./index-jw4gbfkv.js";
16
- import"./index-0abg88h2.js";
17
- import"./index-qt1qqasc.js";
18
- import"./index-x8a7jmkh.js";
19
- import"./index-a4b0gbyg.js";
20
- import"./index-bmwfzz28.js";
21
- import"./index-kvw6xew3.js";
22
- import"./index-xztdf9t7.js";
23
- import"./index-a865mj02.js";
24
- import"./index-fb3zxn06.js";
25
- import"./index-fr0wbhdn.js";
26
- import"./index-0jz47061.js";
27
- import"./index-mp2kghkv.js";
28
- import"./index-q28hsbpg.js";
29
- import"./index-qr1mkc2y.js";
30
- import"./index-f8cn4xqa.js";
31
- import"./index-1zx87sdm.js";
32
- import"./index-bzp9s8z2.js";
33
- import"./index-angx1s0k.js";
34
- import"./index-v0p37hm2.js";
35
- import"./index-w28y7d0z.js";
36
- import"./index-9jvab89d.js";
37
- import"./index-g7jkrz0x.js";
38
- import"./index-58e3y90n.js";
39
- import"./index-150zz6fh.js";
40
- import"./index-gjvjh960.js";
41
- import"./index-wafzvyhg.js";
42
- import"./index-mvvephtj.js";
43
- import"./index-0sahzkwr.js";
44
- import"./index-pavzsdc6.js";
45
- export {
46
- runManagedWrapup2 as runManagedWrapup
47
- };