@cortexkit/opencode-magic-context 0.5.1 → 0.6.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 (95) hide show
  1. package/README.md +18 -2
  2. package/dist/cli/doctor.d.ts.map +1 -1
  3. package/dist/cli/setup.d.ts.map +1 -1
  4. package/dist/cli.js +23 -6
  5. package/dist/config/schema/magic-context.d.ts +21 -0
  6. package/dist/config/schema/magic-context.d.ts.map +1 -1
  7. package/dist/features/magic-context/compaction-marker.d.ts +72 -0
  8. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -0
  9. package/dist/features/magic-context/dreamer/runner.d.ts +8 -0
  10. package/dist/features/magic-context/dreamer/runner.d.ts.map +1 -1
  11. package/dist/features/magic-context/dreamer/scheduler.d.ts.map +1 -1
  12. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  13. package/dist/features/magic-context/migrations.d.ts +8 -0
  14. package/dist/features/magic-context/migrations.d.ts.map +1 -0
  15. package/dist/features/magic-context/plugin-messages.d.ts +75 -0
  16. package/dist/features/magic-context/plugin-messages.d.ts.map +1 -0
  17. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  18. package/dist/features/magic-context/storage-meta-persisted.d.ts +10 -0
  19. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  20. package/dist/features/magic-context/storage-notes.d.ts +51 -5
  21. package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
  22. package/dist/features/magic-context/storage.d.ts +1 -2
  23. package/dist/features/magic-context/storage.d.ts.map +1 -1
  24. package/dist/features/magic-context/user-memory/review-user-memories.d.ts +20 -0
  25. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -0
  26. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +33 -0
  27. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -0
  28. package/dist/hooks/magic-context/command-handler.d.ts +4 -0
  29. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +27 -0
  31. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -0
  32. package/dist/hooks/magic-context/compartment-parser.d.ts +1 -0
  33. package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/compartment-prompt.d.ts +4 -1
  35. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -0
  40. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/hook.d.ts +7 -0
  44. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/system-prompt-hash.d.ts +2 -0
  49. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +4 -0
  51. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  53. package/dist/hooks/magic-context/transform.d.ts +2 -0
  54. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +1231 -151
  57. package/dist/plugin/dream-timer.d.ts +4 -0
  58. package/dist/plugin/dream-timer.d.ts.map +1 -1
  59. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  60. package/dist/plugin/tui-action-consumer.d.ts +13 -0
  61. package/dist/plugin/tui-action-consumer.d.ts.map +1 -0
  62. package/dist/shared/tui-config.d.ts.map +1 -1
  63. package/dist/tools/ctx-note/constants.d.ts +1 -1
  64. package/dist/tools/ctx-note/constants.d.ts.map +1 -1
  65. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  66. package/dist/tools/ctx-note/types.d.ts +3 -1
  67. package/dist/tools/ctx-note/types.d.ts.map +1 -1
  68. package/dist/tui/data/context-db.d.ts +20 -0
  69. package/dist/tui/data/context-db.d.ts.map +1 -1
  70. package/package.json +2 -1
  71. package/src/shared/assistant-message-extractor.ts +74 -0
  72. package/src/shared/conflict-detector.ts +310 -0
  73. package/src/shared/conflict-fixer.ts +216 -0
  74. package/src/shared/data-path.ts +10 -0
  75. package/src/shared/error-message.ts +3 -0
  76. package/src/shared/format-bytes.ts +5 -0
  77. package/src/shared/index.ts +4 -0
  78. package/src/shared/internal-initiator-marker.ts +1 -0
  79. package/src/shared/jsonc-parser.ts +138 -0
  80. package/src/shared/logger.ts +63 -0
  81. package/src/shared/model-requirements.ts +84 -0
  82. package/src/shared/model-suggestion-retry.ts +160 -0
  83. package/src/shared/normalize-sdk-response.ts +40 -0
  84. package/src/shared/opencode-compaction-detector.test.ts +222 -0
  85. package/src/shared/opencode-compaction-detector.ts +81 -0
  86. package/src/shared/opencode-config-dir-types.ts +15 -0
  87. package/src/shared/opencode-config-dir.ts +38 -0
  88. package/src/shared/record-type-guard.ts +3 -0
  89. package/src/shared/system-directive.ts +9 -0
  90. package/src/shared/tui-config.ts +60 -0
  91. package/src/tui/data/context-db.ts +114 -6
  92. package/src/tui/index.tsx +77 -2
  93. package/src/tui/slots/sidebar-content.tsx +3 -2
  94. package/dist/features/magic-context/storage-smart-notes.d.ts +0 -24
  95. package/dist/features/magic-context/storage-smart-notes.d.ts.map +0 -1
package/README.md CHANGED
@@ -39,6 +39,12 @@ Your agent should never stop working to manage its own context. Magic Context is
39
39
 
40
40
  **5.** TUI sidebar with live context breakdown, token usage, historian status, and memory counts — right inside the terminal.
41
41
 
42
+ ### 🧪 Experimental
43
+
44
+ **Compaction Markers** — after historian compresses older messages, Magic Context injects a boundary into OpenCode's message table. OpenCode's built-in message loader stops at the boundary, so the transform processes only the live tail instead of the full session history. Dramatically reduces per-turn overhead on long sessions. Enable with `experimental.compaction_markers: true`.
45
+
46
+ **User Memories** — historian extracts behavioral observations about you alongside its normal compartment output (communication style, expertise level, review focus, working patterns). Recurring observations are promoted by the dreamer to stable user memories that appear in all sessions via `<user-profile>`. Enable with `experimental.user_memories.enabled: true` (requires dreamer).
47
+
42
48
  ---
43
49
 
44
50
  ## Get Started
@@ -253,11 +259,20 @@ An optional background agent that maintains memory quality overnight:
253
259
  - **Improve** — rewrite verbose memories into terse operational form
254
260
  - **Maintain docs** — update ARCHITECTURE.md and STRUCTURE.md from codebase changes
255
261
  - **Evaluate smart notes** — check pending smart note conditions and surface ready notes
262
+ - **Review user memories** (experimental) — promote recurring user behavior observations to stable memories
256
263
 
257
264
  The dreamer runs during a configurable schedule window and creates ephemeral OpenCode child sessions for each task. Since it runs during idle time (typically overnight), it works well with local models — even slower ones like `ollama/mlx-qwen3.5-27b-claude-4.6-opus-reasoning-distilled` are fine since there's no user waiting.
258
265
 
259
266
  When dreamer is enabled, ARCHITECTURE.md and STRUCTURE.md are automatically injected into the agent's system prompt (configurable via `inject_docs`). Content is cached per-session and refreshed on cache-busting passes.
260
267
 
268
+ ### User Memories (Experimental)
269
+
270
+ When `experimental.user_memories.enabled` is set, historian extracts behavioral observations about the user alongside its normal compartment output — things like communication style, expertise level, review focus, and working patterns. These go into a candidate pool.
271
+
272
+ During dreamer runs, a dedicated review pass checks candidates for recurring patterns across sessions. Observations that appear at least `promotion_threshold` times (default 3) are promoted to stable user memories and injected into all sessions via `<user-profile>` in the system prompt.
273
+
274
+ Stable user memories are visible and manageable in the dashboard's User Memories page. Requires dreamer to be enabled for the promotion step.
275
+
261
276
  ### TUI Sidebar
262
277
 
263
278
  When running in OpenCode's terminal UI, Magic Context shows a live sidebar panel with:
@@ -322,9 +337,8 @@ All durable states live in a local SQLite database. If the database can't be ope
322
337
  | `source_contents` | Raw content snapshots for persisted reductions |
323
338
  | `compartments` | Historian-produced structured history blocks |
324
339
  | `session_facts` | Categorized durable facts from historian runs |
325
- | `session_notes` | Session-scoped `ctx_note` content |
340
+ | `notes` | Unified session notes and project-scoped smart notes |
326
341
  | `session_meta` | Per-session state — usage, nudge flags, anchors |
327
- | `smart_notes` | Project-scoped smart notes with surface conditions |
328
342
  | `memories` | Cross-session persistent memories |
329
343
  | `memory_embeddings` | Embedding vectors for semantic search |
330
344
  | `dream_state` | Dreamer lease locking and task progress |
@@ -335,6 +349,8 @@ All durable states live in a local SQLite database. If the database can't be ope
335
349
  | `message_history_index` | Tracks last indexed ordinal per session for incremental FTS population |
336
350
  | `recomp_compartments` | Staging for `/ctx-recomp` partial progress |
337
351
  | `recomp_facts` | Staging for `/ctx-recomp` partial progress |
352
+ | `user_memory_candidates` | User behavior observations from historian (experimental) |
353
+ | `user_memories` | Promoted stable user memories injected into all sessions (experimental) |
338
354
 
339
355
  ---
340
356
 
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAWA,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAwHjD"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAYA,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CA8IjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AA4JA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAyPhD"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AA6JA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAyPhD"}
package/dist/cli.js CHANGED
@@ -8368,6 +8368,7 @@ if (!isTestEnv) {
8368
8368
 
8369
8369
  // src/shared/tui-config.ts
8370
8370
  var PLUGIN_NAME = "@cortexkit/opencode-magic-context";
8371
+ var PLUGIN_ENTRY = `${PLUGIN_NAME}@latest`;
8371
8372
  function resolveTuiConfigPath() {
8372
8373
  const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
8373
8374
  const jsoncPath = join5(configDir, "tui.jsonc");
@@ -8390,7 +8391,7 @@ function ensureTuiPluginEntry() {
8390
8391
  if (plugins.some((p) => p === PLUGIN_NAME || p.startsWith(`${PLUGIN_NAME}@`))) {
8391
8392
  return false;
8392
8393
  }
8393
- plugins.push(PLUGIN_NAME);
8394
+ plugins.push(PLUGIN_ENTRY);
8394
8395
  config.plugin = plugins;
8395
8396
  mkdirSync2(dirname2(configPath), { recursive: true });
8396
8397
  writeFileSync2(configPath, `${import_comment_json.stringify(config, null, 2)}
@@ -9595,6 +9596,7 @@ async function selectOne(message, options) {
9595
9596
 
9596
9597
  // src/cli/doctor.ts
9597
9598
  var PLUGIN_NAME2 = "@cortexkit/opencode-magic-context";
9599
+ var PLUGIN_ENTRY_WITH_VERSION = `${PLUGIN_NAME2}@latest`;
9598
9600
  async function runDoctor() {
9599
9601
  Wt2("Magic Context Doctor");
9600
9602
  let issues = 0;
@@ -9628,7 +9630,7 @@ async function runDoctor() {
9628
9630
  if (hasPlugin) {
9629
9631
  R2.success(`Plugin registered in ${configName}`);
9630
9632
  } else {
9631
- const updatedPlugins = [...plugins, PLUGIN_NAME2];
9633
+ const updatedPlugins = [...plugins, PLUGIN_ENTRY_WITH_VERSION];
9632
9634
  config.plugin = updatedPlugins;
9633
9635
  writeFileSync3(paths.opencodeConfig, `${import_comment_json2.stringify(config, null, 2)}
9634
9636
  `);
@@ -9669,6 +9671,20 @@ async function runDoctor() {
9669
9671
  R2.success("TUI sidebar plugin configured (tui.json created)");
9670
9672
  }
9671
9673
  }
9674
+ if (existsSync5(paths.magicContextConfig)) {
9675
+ try {
9676
+ const mcRaw = readFileSync3(paths.magicContextConfig, "utf-8");
9677
+ const mcConfig = import_comment_json2.parse(mcRaw);
9678
+ const userMemObj = mcConfig?.experimental?.user_memories;
9679
+ const userMemEnabled = userMemObj?.enabled === true;
9680
+ const dreamerObj = mcConfig?.dreamer;
9681
+ const dreamerEnabled = dreamerObj?.enabled === true;
9682
+ if (userMemEnabled && !dreamerEnabled) {
9683
+ R2.warn("experimental_user_memories is enabled but dreamer is disabled — user memory candidates will be collected but never promoted to stable memories");
9684
+ issues++;
9685
+ }
9686
+ } catch {}
9687
+ }
9672
9688
  if (paths.omoConfig) {
9673
9689
  R2.info(`OMO config found: ${paths.omoConfig}`);
9674
9690
  }
@@ -9691,6 +9707,7 @@ var import_comment_json3 = __toESM(require_src2(), 1);
9691
9707
  import { existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
9692
9708
  import { dirname as dirname3 } from "node:path";
9693
9709
  var PLUGIN_NAME3 = "@cortexkit/opencode-magic-context";
9710
+ var PLUGIN_ENTRY2 = "@cortexkit/opencode-magic-context@latest";
9694
9711
  function ensureDir(dir) {
9695
9712
  if (!existsSync6(dir)) {
9696
9713
  mkdirSync3(dir, { recursive: true });
@@ -9709,7 +9726,7 @@ function addPluginToOpenCodeConfig(configPath, format) {
9709
9726
  ensureDir(dirname3(configPath));
9710
9727
  if (format === "none") {
9711
9728
  const config = {
9712
- plugin: [PLUGIN_NAME3],
9729
+ plugin: [PLUGIN_ENTRY2],
9713
9730
  compaction: { auto: false, prune: false }
9714
9731
  };
9715
9732
  writeFileSync4(configPath, `${import_comment_json3.stringify(config, null, 2)}
@@ -9724,7 +9741,7 @@ function addPluginToOpenCodeConfig(configPath, format) {
9724
9741
  const plugins = existing.plugin ?? [];
9725
9742
  const hasPlugin = plugins.some((p) => p === PLUGIN_NAME3 || p.startsWith(`${PLUGIN_NAME3}@`));
9726
9743
  if (!hasPlugin) {
9727
- plugins.push(PLUGIN_NAME3);
9744
+ plugins.push(PLUGIN_ENTRY2);
9728
9745
  }
9729
9746
  existing.plugin = plugins;
9730
9747
  const compaction = existing.compaction ?? {};
@@ -9737,7 +9754,7 @@ function addPluginToOpenCodeConfig(configPath, format) {
9737
9754
  function addPluginToTuiConfig(configPath, format) {
9738
9755
  ensureDir(dirname3(configPath));
9739
9756
  if (format === "none") {
9740
- writeFileSync4(configPath, `${import_comment_json3.stringify({ plugin: [PLUGIN_NAME3] }, null, 2)}
9757
+ writeFileSync4(configPath, `${import_comment_json3.stringify({ plugin: [PLUGIN_ENTRY2] }, null, 2)}
9741
9758
  `);
9742
9759
  return;
9743
9760
  }
@@ -9749,7 +9766,7 @@ function addPluginToTuiConfig(configPath, format) {
9749
9766
  const plugins = existing.plugin ?? [];
9750
9767
  const hasPlugin = plugins.some((p) => p === PLUGIN_NAME3 || p.startsWith(`${PLUGIN_NAME3}@`));
9751
9768
  if (!hasPlugin) {
9752
- plugins.push(PLUGIN_NAME3);
9769
+ plugins.push(PLUGIN_ENTRY2);
9753
9770
  }
9754
9771
  existing.plugin = plugins;
9755
9772
  writeFileSync4(configPath, `${import_comment_json3.stringify(existing, null, 2)}
@@ -189,6 +189,13 @@ export interface MagicContextConfig {
189
189
  enabled: boolean;
190
190
  min_clusters: number;
191
191
  };
192
+ experimental: {
193
+ compaction_markers: boolean;
194
+ user_memories: {
195
+ enabled: boolean;
196
+ promotion_threshold: number;
197
+ };
198
+ };
192
199
  embedding: EmbeddingConfig;
193
200
  memory: {
194
201
  enabled: boolean;
@@ -357,6 +364,13 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
357
364
  endpoint?: string | undefined;
358
365
  api_key?: string | undefined;
359
366
  }>>>;
367
+ experimental: z.ZodDefault<z.ZodObject<{
368
+ compaction_markers: z.ZodDefault<z.ZodBoolean>;
369
+ user_memories: z.ZodDefault<z.ZodObject<{
370
+ enabled: z.ZodDefault<z.ZodBoolean>;
371
+ promotion_threshold: z.ZodDefault<z.ZodNumber>;
372
+ }, z.core.$strip>>;
373
+ }, z.core.$strip>>;
360
374
  memory: z.ZodDefault<z.ZodObject<{
361
375
  enabled: z.ZodDefault<z.ZodBoolean>;
362
376
  injection_budget_tokens: z.ZodDefault<z.ZodNumber>;
@@ -450,6 +464,13 @@ export declare const MagicContextConfigSchema: z.ZodPipe<z.ZodObject<{
450
464
  provider: "off";
451
465
  model?: undefined;
452
466
  };
467
+ experimental: {
468
+ compaction_markers: boolean;
469
+ user_memories: {
470
+ enabled: boolean;
471
+ promotion_threshold: number;
472
+ };
473
+ };
453
474
  memory: {
454
475
  enabled: boolean;
455
476
  injection_budget_tokens: number;
@@ -1 +1 @@
1
- {"version":3,"file":"magic-context.d.ts","sourceRoot":"","sources":["../../../src/config/schema/magic-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,eAAO,MAAM,6BAA6B,QAAS,CAAC;AACpD,eAAO,MAAM,oCAAoC,KAAK,CAAC;AACvD,eAAO,MAAM,gCAAgC,QAAS,CAAC;AACvD,eAAO,MAAM,4BAA4B,SAAU,CAAC;AACpD,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AAEvE,eAAO,MAAM,aAAa,iFAMhB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;EAAwB,CAAC;AACxD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,qBAAqB,EAAE,YAAY,EAK/C,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,mBAA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4
+ * Injects compaction boundaries into OpenCode's SQLite DB so that
5
+ * `filterCompacted` stops at the historian boundary. After injection,
6
+ * the transform hook receives only post-boundary messages instead
7
+ * of the full session history.
8
+ *
9
+ * Gated behind `experimental_compaction_markers` config flag.
10
+ *
11
+ * ## What gets injected (3 rows):
12
+ * 1. A `compaction` part on the boundary user message
13
+ * 2. A summary assistant message with `parentID` → boundary user message
14
+ * 3. A text part on that summary message containing a static placeholder
15
+ *
16
+ * The real `<session-history>` is injected by the transform pipeline via
17
+ * inject-compartments.ts. The marker exists solely to make filterCompacted
18
+ * stop at the boundary.
19
+ *
20
+ * ## How OpenCode's filterCompacted works:
21
+ * - Iterates newest→oldest
22
+ * - Stops when it finds a user message that:
23
+ * (a) has a part with type: "compaction"
24
+ * (b) has a completed summary assistant response (summary: true, finish: "stop")
25
+ * whose parentID matches that user message's id
26
+ */
27
+ export declare function generateMessageId(timestampMs: number, counter?: bigint): string;
28
+ export declare function generatePartId(timestampMs: number, counter?: bigint): string;
29
+ export declare function closeCompactionMarkerDb(): void;
30
+ interface BoundaryUserMessage {
31
+ id: string;
32
+ timeCreated: number;
33
+ }
34
+ /**
35
+ * Find the nearest user message at or before the given raw ordinal.
36
+ * The boundary must be a user message for filterCompacted to work.
37
+ *
38
+ * Filters out compaction summary messages (summary=true, finish="stop")
39
+ * so ordinals stay consistent with readRawSessionMessagesFromDb.
40
+ */
41
+ export declare function findBoundaryUserMessage(sessionId: string, endOrdinal: number): BoundaryUserMessage | null;
42
+ interface CompactionMarkerState {
43
+ /** The user message ID that has the compaction part */
44
+ boundaryMessageId: string;
45
+ /** The summary assistant message ID we injected */
46
+ summaryMessageId: string;
47
+ /** The compaction part ID on the user message */
48
+ compactionPartId: string;
49
+ /** The text part ID on the summary message */
50
+ summaryPartId: string;
51
+ }
52
+ export interface InjectCompactionMarkerArgs {
53
+ sessionId: string;
54
+ /** Raw ordinal of the last compartmentalized message */
55
+ endOrdinal: number;
56
+ /** Summary text for the compaction summary message (static placeholder) */
57
+ summaryText: string;
58
+ /** Working directory for the session */
59
+ directory: string;
60
+ }
61
+ /**
62
+ * Inject a compaction marker into OpenCode's DB.
63
+ * Returns the marker state if successful, null if boundary couldn't be found.
64
+ */
65
+ export declare function injectCompactionMarker(args: InjectCompactionMarkerArgs): CompactionMarkerState | null;
66
+ /**
67
+ * Remove an existing compaction marker (all 3 rows).
68
+ * Used when moving the boundary forward or on session cleanup.
69
+ */
70
+ export declare function removeCompactionMarker(state: CompactionMarkerState): boolean;
71
+ export {};
72
+ //# sourceMappingURL=compaction-marker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction-marker.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/compaction-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AA+BH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,SAAK,GAAG,MAAM,CAE3E;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,SAAK,GAAG,MAAM,CAExE;AA8BD,wBAAgB,uBAAuB,IAAI,IAAI,CAS9C;AAID,UAAU,mBAAmB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACnB,mBAAmB,GAAG,IAAI,CAkC5B;AAID,UAAU,qBAAqB;IAC3B,uDAAuD;IACvD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,gBAAgB,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;CACzB;AAID,MAAM,WAAW,0BAA0B;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,0BAA0B,GACjC,qBAAqB,GAAG,IAAI,CAiF9B;AAID;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAgB5E"}
@@ -25,6 +25,10 @@ export declare function runDream(args: {
25
25
  maxRuntimeMinutes: number;
26
26
  parentSessionId?: string;
27
27
  sessionDirectory?: string;
28
+ experimentalUserMemories?: {
29
+ enabled: boolean;
30
+ promotionThreshold: number;
31
+ };
28
32
  }): Promise<DreamRunResult>;
29
33
  export declare function processDreamQueue(args: {
30
34
  db: Database;
@@ -32,5 +36,9 @@ export declare function processDreamQueue(args: {
32
36
  tasks: DreamingTask[];
33
37
  taskTimeoutMinutes: number;
34
38
  maxRuntimeMinutes: number;
39
+ experimentalUserMemories?: {
40
+ enabled: boolean;
41
+ promotionThreshold: number;
42
+ };
35
43
  }): Promise<DreamRunResult | null>;
36
44
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA4B3D,wBAAgB,6BAA6B,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9F;AAMD,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CA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@@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,WAAW,mBAAmB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,MAAM,GACjB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkBrD;AAED,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,OAAO,CAYpF;AAED,6GAA6G;AAC7G,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,EAAE,CAyC/D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwB9E"}
1
+ {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,WAAW,mBAAmB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,MAAM,GACjB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkBrD;AAED,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,OAAO,CAYpF;AAED,6GAA6G;AAC7G,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,EAAE,CA0C/D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwB9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"embedding-local.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-local.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAgF9D,qBAAa,sBAAuB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,KAAK,SAAgC;IAK3C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAiC9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAsBjD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC;IA0B7D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B,QAAQ,IAAI,OAAO;CAGtB"}
1
+ {"version":3,"file":"embedding-local.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-local.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAqG9D,qBAAa,sBAAuB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,KAAK,SAAgC;IAK3C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAyC9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyBjD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC;IA6B7D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B,QAAQ,IAAI,OAAO;CAGtB"}
@@ -0,0 +1,8 @@
1
+ import type { Database } from "bun:sqlite";
2
+ /**
3
+ * Run all pending migrations sequentially.
4
+ * Each migration runs in its own transaction — if it fails, only that migration rolls back.
5
+ * Already-applied migrations are skipped.
6
+ */
7
+ export declare function runMigrations(db: Database): void;
8
+ //# sourceMappingURL=migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAsL3C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAkChD"}
@@ -0,0 +1,75 @@
1
+ import type { Database } from "bun:sqlite";
2
+ /**
3
+ * SQLite-backed message bus for TUI ↔ server plugin communication.
4
+ *
5
+ * Both the server plugin and TUI plugin share the same `context.db`.
6
+ * Messages are written by one side and consumed by the other via polling.
7
+ *
8
+ * Directions:
9
+ * - "server_to_tui": Server sends toasts, dialogs, state updates to TUI
10
+ * - "tui_to_server": TUI sends dialog confirmations, action triggers to server
11
+ *
12
+ * Message types:
13
+ * - "toast": Show a toast notification { message, variant?, duration? }
14
+ * - "dialog_confirm": Show a confirmation dialog { id, title, message }
15
+ * - "dialog_result": TUI response to a dialog { id, confirmed }
16
+ * - "state_update": State change hint { key, value }
17
+ *
18
+ * Messages are auto-cleaned after 5 minutes to prevent table bloat.
19
+ */
20
+ export type MessageDirection = "server_to_tui" | "tui_to_server";
21
+ export type MessageType = "toast" | "dialog_confirm" | "dialog_result" | "state_update";
22
+ export interface PluginMessage {
23
+ id: number;
24
+ direction: MessageDirection;
25
+ type: MessageType;
26
+ payload: Record<string, unknown>;
27
+ sessionId: string | null;
28
+ createdAt: number;
29
+ consumedAt: number | null;
30
+ }
31
+ /**
32
+ * Send a message from server to TUI.
33
+ */
34
+ export declare function sendToTui(db: Database, type: MessageType, payload: Record<string, unknown>, sessionId?: string): number;
35
+ /**
36
+ * Send a message from TUI to server.
37
+ */
38
+ export declare function sendToServer(db: Database, type: MessageType, payload: Record<string, unknown>, sessionId?: string): number;
39
+ /**
40
+ * Consume unconsumed messages for a given direction.
41
+ * Marks consumed messages and returns them.
42
+ * Also cleans up old messages (>5min) to prevent table bloat.
43
+ */
44
+ export declare function consumeMessages(db: Database, direction: MessageDirection, options?: {
45
+ type?: MessageType;
46
+ sessionId?: string;
47
+ }): PluginMessage[];
48
+ /**
49
+ * Peek at unconsumed messages without consuming them.
50
+ */
51
+ export declare function peekMessages(db: Database, direction: MessageDirection, options?: {
52
+ type?: MessageType;
53
+ sessionId?: string;
54
+ }): PluginMessage[];
55
+ /**
56
+ * Convenience: send a toast to TUI.
57
+ */
58
+ export declare function sendTuiToast(db: Database, message: string, options?: {
59
+ variant?: "info" | "warning" | "error" | "success";
60
+ duration?: number;
61
+ sessionId?: string;
62
+ }): number;
63
+ /**
64
+ * Convenience: send a confirmation dialog request to TUI.
65
+ * Returns the message ID which the TUI will reference in its dialog_result response.
66
+ */
67
+ export declare function sendTuiConfirmDialog(db: Database, id: string, title: string, message: string, sessionId?: string): number;
68
+ /**
69
+ * Convenience: check for a dialog result from TUI.
70
+ * Returns the confirmation result or null if not yet responded.
71
+ */
72
+ export declare function checkDialogResult(db: Database, dialogId: string): {
73
+ confirmed: boolean;
74
+ } | null;
75
+ //# sourceMappingURL=plugin-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-messages.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context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"version":3,"file":"storage-db.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAiRrD;AAiCD,wBAAgB,YAAY,IAAI,QAAQ,CAsCvC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAEzD;AAED,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAEvE;AAED,wBAAgB,aAAa,IAAI,IAAI,CAUpC;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -30,6 +30,16 @@ export declare function setPersistedNoteNudgeTrigger(db: Database, sessionId: st
30
30
  export declare function setPersistedNoteNudgeTriggerMessageId(db: Database, sessionId: string, triggerMessageId: string): void;
31
31
  export declare function setPersistedDeliveredNoteNudge(db: Database, sessionId: string, text: string, messageId?: string): void;
32
32
  export declare function clearPersistedNoteNudge(db: Database, sessionId: string): void;
33
+ export interface PersistedCompactionMarkerState {
34
+ boundaryMessageId: string;
35
+ summaryMessageId: string;
36
+ compactionPartId: string;
37
+ summaryPartId: string;
38
+ /** The raw ordinal at which the boundary was set */
39
+ boundaryOrdinal: number;
40
+ }
41
+ export declare function getPersistedCompactionMarkerState(db: Database, sessionId: string): PersistedCompactionMarkerState | null;
42
+ export declare function setPersistedCompactionMarkerState(db: Database, sessionId: string, state: PersistedCompactionMarkerState | null): void;
33
43
  export declare function getStrippedPlaceholderIds(db: Database, sessionId: string): Set<string>;
34
44
  export declare function setStrippedPlaceholderIds(db: Database, sessionId: string, ids: Set<string>): void;
35
45
  export declare function removeStrippedPlaceholderId(db: Database, sessionId: string, messageId: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"storage-meta-persisted.d.ts","sourceRoot":"","sources":["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,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,8BAA8B,GAAG,IAAI,GAC7C,IAAI,CAON;AAID,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CActF;AAED,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAOjG;AAED,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,OAAO,CAQT"}
@@ -1,12 +1,58 @@
1
1
  import type { Database } from "bun:sqlite";
2
- export interface SessionNote {
2
+ export type NoteType = "session" | "smart";
3
+ export type NoteStatus = "active" | "pending" | "ready" | "dismissed";
4
+ export interface Note {
3
5
  id: number;
4
- sessionId: string;
6
+ type: NoteType;
7
+ status: NoteStatus;
5
8
  content: string;
9
+ sessionId: string | null;
10
+ projectPath: string | null;
11
+ surfaceCondition: string | null;
6
12
  createdAt: number;
13
+ updatedAt: number;
14
+ lastCheckedAt: number | null;
15
+ readyAt: number | null;
16
+ readyReason: string | null;
17
+ }
18
+ export interface GetNotesOptions {
19
+ sessionId?: string;
20
+ projectPath?: string;
21
+ type?: NoteType;
22
+ status?: NoteStatus | NoteStatus[];
23
+ }
24
+ export interface UpdateNoteOptions {
25
+ content?: string;
26
+ sessionId?: string | null;
27
+ projectPath?: string | null;
28
+ surfaceCondition?: string | null;
29
+ status?: NoteStatus;
30
+ lastCheckedAt?: number | null;
31
+ readyAt?: number | null;
32
+ readyReason?: string | null;
33
+ }
34
+ interface SessionNoteInput {
35
+ sessionId: string;
36
+ content: string;
37
+ }
38
+ interface SmartNoteInput {
39
+ content: string;
40
+ sessionId?: string;
41
+ projectPath: string;
42
+ surfaceCondition: string;
7
43
  }
8
- export declare function getSessionNotes(db: Database, sessionId: string): SessionNote[];
9
- export declare function addSessionNote(db: Database, sessionId: string, content: string): void;
10
- export declare function clearSessionNotes(db: Database, sessionId: string): void;
44
+ export declare function getNotes(db: Database, options?: GetNotesOptions): Note[];
45
+ export declare function addNote(db: Database, type: "session", options: SessionNoteInput): Note;
46
+ export declare function addNote(db: Database, type: "smart", options: SmartNoteInput): Note;
47
+ export declare function getSessionNotes(db: Database, sessionId: string): Note[];
48
+ export declare function getSmartNotes(db: Database, projectPath: string, status?: NoteStatus): Note[];
49
+ export declare function getPendingSmartNotes(db: Database, projectPath: string): Note[];
50
+ export declare function getReadySmartNotes(db: Database, projectPath: string): Note[];
51
+ export declare function updateNote(db: Database, noteId: number, updates: UpdateNoteOptions): Note | null;
52
+ export declare function dismissNote(db: Database, noteId: number): boolean;
53
+ export declare function markNoteReady(db: Database, noteId: number, reason?: string): void;
54
+ export declare function markNoteChecked(db: Database, noteId: number): void;
55
+ export declare function deleteNote(db: Database, noteId: number): boolean;
11
56
  export declare function replaceAllSessionNotes(db: Database, sessionId: string, notes: string[]): void;
57
+ export {};
12
58
  //# sourceMappingURL=storage-notes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-notes.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-notes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AA6BD,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CAM9E;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMrF;AAED,wBAAgB,iBAAi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,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,CAE5E;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAuDhG;AAKD,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAOjE;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAKjF;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAKlE;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAW7F"}
@@ -3,9 +3,8 @@ export { clearCompressionDepth, getAverageCompressionDepth, getMaxCompressionDep
3
3
  export { clearIndexedMessages, deleteIndexedMessage, } from "./message-index";
4
4
  export { type ContextDatabase, closeDatabase, getDatabasePersistenceError, isDatabasePersisted, openDatabase, } from "./storage-db";
5
5
  export { clearPersistedNoteNudge, clearPersistedNudgePlacement, clearPersistedStickyTurnReminder, clearSession, getOrCreateSessionMeta, getPersistedNoteNudge, getPersistedNudgePlacement, getPersistedReasoningWatermark, getPersistedStickyTurnReminder, getStrippedPlaceholderIds, loadPersistedUsage, removeStrippedPlaceholderId, setPersistedNudgePlacement, setPersistedReasoningWatermark, setPersistedStickyTurnReminder, setStrippedPlaceholderIds, updateSessionMeta, } from "./storage-meta";
6
- export { addSessionNote, clearSessionNotes, getSessionNotes, replaceAllSessionNotes, type SessionNote, } from "./storage-notes";
6
+ export { addNote, deleteNote, dismissNote, getNotes, getPendingSmartNotes, getReadySmartNotes, getSessionNotes, getSmartNotes, markNoteChecked, markNoteReady, type Note, type NoteStatus, type NoteType, replaceAllSessionNotes, updateNote, } from "./storage-notes";
7
7
  export { clearPendingOps, getPendingOps, queuePendingOp, removePendingOp, } from "./storage-ops";
8
- export { addSmartNote, deleteSmartNote, dismissSmartNote, getPendingSmartNotes, getReadySmartNotes, getSmartNotes, markSmartNoteChecked, markSmartNoteReady, type SmartNote, type SmartNoteStatus, } from "./storage-smart-notes";
9
8
  export { getSourceContents, replaceSourceContent, saveSourceContent, } from "./storage-source";
10
9
  export { deleteTagsByMessageId, getMaxTagNumberBySession, getTagById, getTagsBySession, getTopNBySize, insertTag, updateTagMessageId, updateTagStatus, } from "./storage-tags";
11
10
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,KAAK,WAAW,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,GAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,oBAAoB,EACpB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,KAAK,eAAe,EACpB,aAAa,EACb,2BAA2B,EAC3B,mBAAmB,EACnB,YAAY,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,KAAK,WAAW,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACd,eAAe,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,eAAe,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,qBAAqB,EACrB,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,eAAe,GAClB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,KAAK,WAAW,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,GAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,oBAAoB,EACpB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,KAAK,eAAe,EACpB,aAAa,EACb,2BAA2B,EAC3B,mBAAmB,EACnB,YAAY,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,sBAAsB,EACtB,UAAU,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACd,eAAe,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,qBAAqB,EACrB,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,eAAe,GAClB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Database } from "bun:sqlite";
2
+ import type { PluginContext } from "../../../plugin/types";
3
+ interface ReviewUserMemoriesArgs {
4
+ db: Database;
5
+ client: PluginContext["client"];
6
+ parentSessionId: string | undefined;
7
+ sessionDirectory: string | undefined;
8
+ holderId: string;
9
+ deadline: number;
10
+ promotionThreshold: number;
11
+ }
12
+ interface ReviewResult {
13
+ promoted: number;
14
+ merged: number;
15
+ dismissed: number;
16
+ candidatesConsumed: number;
17
+ }
18
+ export declare function reviewUserMemories(args: ReviewUserMemoriesArgs): Promise<ReviewResult>;
19
+ export {};
20
+ //# sourceMappingURL=review-user-memories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-user-memories.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/user-memory/review-user-memories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAgB3D,UAAU,sBAAsB;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqN5F"}
@@ -0,0 +1,33 @@
1
+ import type { Database } from "bun:sqlite";
2
+ export interface UserMemoryCandidate {
3
+ id: number;
4
+ content: string;
5
+ sessionId: string;
6
+ sourceCompartmentStart: number | null;
7
+ sourceCompartmentEnd: number | null;
8
+ createdAt: number;
9
+ }
10
+ export interface UserMemory {
11
+ id: number;
12
+ content: string;
13
+ status: "active" | "dismissed";
14
+ promotedAt: number;
15
+ sourceCandidateIds: number[];
16
+ createdAt: number;
17
+ updatedAt: number;
18
+ }
19
+ export declare function insertUserMemoryCandidates(db: Database, candidates: Array<{
20
+ content: string;
21
+ sessionId: string;
22
+ sourceCompartmentStart?: number;
23
+ sourceCompartmentEnd?: number;
24
+ }>): void;
25
+ export declare function getUserMemoryCandidates(db: Database): UserMemoryCandidate[];
26
+ export declare function deleteUserMemoryCandidates(db: Database, ids: number[]): void;
27
+ export declare function insertUserMemory(db: Database, content: string, sourceCandidateIds: number[]): number;
28
+ export declare function getActiveUserMemories(db: Database): UserMemory[];
29
+ export declare function getAllUserMemories(db: Database): UserMemory[];
30
+ export declare function updateUserMemoryContent(db: Database, id: number, content: string): void;
31
+ export declare function dismissUserMemory(db: Database, id: number): void;
32
+ export declare function deleteUserMemory(db: Database, id: number): void;
33
+ //# sourceMappingURL=storage-user-memory.d.ts.map