@cortexkit/pi-magic-context 0.49.11 → 0.49.13

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 (50) hide show
  1. package/dist/auto-search-worker.js +4 -4
  2. package/dist/chunk-embedding-write-worker.js +87 -0
  3. package/dist/{compaction-marker-candidates-n4dphyz4.js → compaction-marker-candidates-k4tqg4jb.js} +2 -2
  4. package/dist/compaction-marker-candidates-worker.js +1 -1
  5. package/dist/embedding-backfill-7kj16fh9.js +21 -0
  6. package/dist/embedding-worker-process.js +1 -1
  7. package/dist/embedding-worker.js +5 -5
  8. package/dist/historian-calibration-extension.js +2 -2
  9. package/dist/{index-ta0ed2nc.js → index-1k729e4f.js} +15 -15
  10. package/dist/index-1mrvw9en.js +225 -0
  11. package/dist/{index-g13fb2sj.js → index-3cnarwf8.js} +4 -4
  12. package/dist/{index-729kkhmf.js → index-46q4e104.js} +1 -1
  13. package/dist/{index-m8aaepft.js → index-53xdqb3d.js} +7 -7
  14. package/dist/{index-szh001qb.js → index-6dz2ed1v.js} +2 -2
  15. package/dist/{index-gqxsds3q.js → index-6ex901g3.js} +187 -27
  16. package/dist/{index-gycf3sp7.js → index-7bqrfyny.js} +46 -2
  17. package/dist/{index-drah07tf.js → index-7qc73yk5.js} +64 -7
  18. package/dist/{index-s9kwv5pp.js → index-7wagp5jp.js} +5 -5
  19. package/dist/{index-8yjhda46.js → index-9jvktm7k.js} +3 -3
  20. package/dist/{index-3veejgp8.js → index-apgwdby5.js} +1 -1
  21. package/dist/{index-0vq6ebae.js → index-aypx5h57.js} +58 -64
  22. package/dist/{index-43zqh10z.js → index-d4dt19md.js} +1 -1
  23. package/dist/{index-fdxzpnbj.js → index-djxc8w8c.js} +1 -1
  24. package/dist/{index-x7426vy4.js → index-ed9d2ded.js} +18 -5
  25. package/dist/{index-kh3jt7t9.js → index-f18ec69t.js} +1 -1
  26. package/dist/{index-4pxydwvg.js → index-g4jf772p.js} +1 -1
  27. package/dist/{index-4vj37yw9.js → index-he9s4qsj.js} +16 -6
  28. package/dist/{index-ttxsmaj5.js → index-jrap43gc.js} +1 -1
  29. package/dist/{index-78c864c8.js → index-nwbhe6qv.js} +324 -254
  30. package/dist/{index-9azmm7cg.js → index-t27xk4r7.js} +10 -10
  31. package/dist/{index-s3c9dskk.js → index-vv1j5cak.js} +8 -8
  32. package/dist/{index-2df03yc3.js → index-wp9q91kn.js} +8 -8
  33. package/dist/{index-xmdkde4v.js → index-y29y2j2w.js} +12 -1
  34. package/dist/index.js +854 -369
  35. package/dist/{logger-qg51hmp7.js → logger-dygt96rn.js} +1 -1
  36. package/dist/{message-index-5zjmsg57.js → message-index-7w179p64.js} +13 -13
  37. package/dist/{message-index-bounded-chgr6dn3.js → message-index-bounded-80n96ehp.js} +13 -13
  38. package/dist/{message-time-backfill-q9s88zdv.js → message-time-backfill-r2ar1qvk.js} +2 -2
  39. package/dist/migration-worker.js +9 -9
  40. package/dist/{project-embedding-registry-dk5axctd.js → project-embedding-registry-52zwmtbn.js} +11 -10
  41. package/dist/raw-ordinal-warmup-worker.js +12 -7
  42. package/dist/{read-session-chunk-3kb7r5pq.js → read-session-chunk-83864b37.js} +8 -8
  43. package/dist/{read-session-raw-hm7ptnrh.js → read-session-raw-azkqjgzg.js} +6 -2
  44. package/dist/{safe-notification-target-62ty6rvp.js → safe-notification-target-2rkvkmw8.js} +2 -2
  45. package/dist/{search-8pczyejh.js → search-hffb8xht.js} +20 -19
  46. package/dist/{storage-tags-zh23ynsh.js → storage-tags-zmf30zqp.js} +6 -4
  47. package/dist/subagent-entry.js +23 -22
  48. package/package.json +2 -2
  49. package/dist/embedding-backfill-1tknh2jn.js +0 -20
  50. /package/dist/{index-69vas84q.js → index-e6xnpach.js} +0 -0
@@ -18,15 +18,15 @@ var [
18
18
  { Database, registerSqliteDiagnosticSink },
19
19
  { log }
20
20
  ] = await Promise.all([
21
- import("./embedding-backfill-1tknh2jn.js"),
21
+ import("./embedding-backfill-7kj16fh9.js"),
22
22
  import("./embedding-cache-7rp4gqzr.js"),
23
23
  import("./storage-memory-axnsk5t1.js"),
24
- import("./project-embedding-registry-dk5axctd.js"),
25
- import("./search-8pczyejh.js"),
24
+ import("./project-embedding-registry-52zwmtbn.js"),
25
+ import("./search-hffb8xht.js"),
26
26
  import("./embedding-activity-ew6dshfd.js"),
27
27
  import("./harness-9872e0ym.js"),
28
28
  import("./sqlite-adjpy399.js"),
29
- import("./logger-qg51hmp7.js")
29
+ import("./logger-dygt96rn.js")
30
30
  ]);
31
31
  setHarness(input.harness);
32
32
  registerSqliteDiagnosticSink(log, getHarness);
@@ -0,0 +1,87 @@
1
+ import {
2
+ setHarness2
3
+ } from "./index-0h2mkab2.js";
4
+ import {
5
+ Database2
6
+ } from "./index-asrxgdt4.js";
7
+ import {
8
+ configureContextDatabasePragmas2
9
+ } from "./index-fapenpch.js";
10
+ import"./index-g4jf772p.js";
11
+ import"./index-7bqrfyny.js";
12
+ import"./index-6dz2ed1v.js";
13
+ import"./index-djxc8w8c.js";
14
+ import {
15
+ replaceCompartmentChunkEmbeddings,
16
+ recordChunkEmbedBackoff,
17
+ loadUnembeddedSessionChunkCandidates,
18
+ countUnembeddedSessionCompartments
19
+ } from "./index-7qc73yk5.js";
20
+ import {
21
+ recordSessionProjectIdentity,
22
+ acquireGitSweepLease,
23
+ renewGitSweepLease,
24
+ releaseGitSweepLease
25
+ } from "./index-1mrvw9en.js";
26
+ import"./index-6ex901g3.js";
27
+ import"./index-apgwdby5.js";
28
+ import {
29
+ LATEST_SUPPORTED_VERSION,
30
+ enforceSchemaFence
31
+ } from "./index-t27xk4r7.js";
32
+ import"./index-3cnarwf8.js";
33
+ import"./index-jrap43gc.js";
34
+ import"./index-135e8hvg.js";
35
+ import"./index-8976mezv.js";
36
+ import"./index-d4dt19md.js";
37
+
38
+ // ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts
39
+ import { parentPort, workerData } from "node:worker_threads";
40
+ var port = parentPort;
41
+ if (!port)
42
+ throw new Error("chunk embedding writer requires a parent port");
43
+ setHarness2(workerData.harness);
44
+ var db = new Database2(workerData.path);
45
+ if (!enforceSchemaFence(db, workerData.path, LATEST_SUPPORTED_VERSION)) {
46
+ db.close();
47
+ throw new Error("chunk embedding writer rejected an unsupported store schema");
48
+ }
49
+ var timeout = Math.max(0, Math.floor(workerData.timeout));
50
+ db.exec(`PRAGMA busy_timeout=${timeout}; PRAGMA foreign_keys=ON`);
51
+ configureContextDatabasePragmas2(db);
52
+ port.on("message", (input) => {
53
+ try {
54
+ let value;
55
+ switch (input.kind) {
56
+ case "replace":
57
+ replaceCompartmentChunkEmbeddings(db, input.rows, input.sourceKey);
58
+ break;
59
+ case "project":
60
+ recordSessionProjectIdentity(db, input.session, input.project);
61
+ break;
62
+ case "count":
63
+ value = countUnembeddedSessionCompartments(db, input.project, input.session, input.model, input.tokens);
64
+ break;
65
+ case "candidates":
66
+ value = loadUnembeddedSessionChunkCandidates(db, input.project, input.session, input.model, input.limit, input.excluded, input.tokens, true);
67
+ break;
68
+ case "backoff":
69
+ recordChunkEmbedBackoff(db, input.candidate, input.project, input.model);
70
+ break;
71
+ case "acquire":
72
+ value = acquireGitSweepLease(db, input.project, input.holder, {
73
+ ignoreCooldown: true
74
+ });
75
+ break;
76
+ case "renew":
77
+ value = renewGitSweepLease(db, input.project, input.holder);
78
+ break;
79
+ case "release":
80
+ releaseGitSweepLease(db, input.project, input.holder);
81
+ break;
82
+ }
83
+ port.postMessage({ value });
84
+ } catch (error) {
85
+ port.postMessage({ error: error instanceof Error ? error.message : String(error) });
86
+ }
87
+ });
@@ -4,10 +4,10 @@ import {
4
4
  readMarkerCandidateBasis2,
5
5
  prepareMarkerCandidateBasis2,
6
6
  scanMarkerCandidateSnapshot2
7
- } from "./index-729kkhmf.js";
7
+ } from "./index-46q4e104.js";
8
8
  import"./index-399p688g.js";
9
9
  import"./index-asrxgdt4.js";
10
- import"./index-gycf3sp7.js";
10
+ import"./index-7bqrfyny.js";
11
11
  import"./index-0h2mkab2.js";
12
12
  export {
13
13
  invalidateMarkerCandidateBasis2 as invalidateMarkerCandidateBasis,
@@ -6,7 +6,7 @@ if (!port)
6
6
  port.postMessage({ kind: "accepted" });
7
7
  var [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
8
8
  import("./sqlite-adjpy399.js"),
9
- import("./compaction-marker-candidates-n4dphyz4.js")
9
+ import("./compaction-marker-candidates-k4tqg4jb.js")
10
10
  ]);
11
11
  var input = workerData;
12
12
  var db;
@@ -0,0 +1,21 @@
1
+ import {
2
+ ensureMemoryEmbeddings2
3
+ } from "./index-7wagp5jp.js";
4
+ import"./index-nwbhe6qv.js";
5
+ import"./index-9p40dgkm.js";
6
+ import"./index-yhzhdp3m.js";
7
+ import"./index-1mrvw9en.js";
8
+ import"./index-7qc73yk5.js";
9
+ import"./index-9jvktm7k.js";
10
+ import"./index-6dz2ed1v.js";
11
+ import"./index-1k729e4f.js";
12
+ import"./index-6ex901g3.js";
13
+ import"./index-djxc8w8c.js";
14
+ import"./index-d4dt19md.js";
15
+ import"./index-g4jf772p.js";
16
+ import"./index-asrxgdt4.js";
17
+ import"./index-7bqrfyny.js";
18
+ import"./index-0h2mkab2.js";
19
+ export {
20
+ ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
21
+ };
@@ -1,7 +1,7 @@
1
1
  import"./index-0h2mkab2.js";
2
2
  import {
3
3
  log2
4
- } from "./index-gycf3sp7.js";
4
+ } from "./index-7bqrfyny.js";
5
5
  import {
6
6
  inRootAsyncContext2
7
7
  } from "./index-asrxgdt4.js";
@@ -3,16 +3,16 @@ import {
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-gycf3sp7.js";
7
- import"./index-ta0ed2nc.js";
8
- import"./index-szh001qb.js";
9
- import"./index-4pxydwvg.js";
6
+ } from "./index-7bqrfyny.js";
7
+ import"./index-1k729e4f.js";
8
+ import"./index-6dz2ed1v.js";
9
+ import"./index-g4jf772p.js";
10
10
  import"./index-asrxgdt4.js";
11
11
  import {
12
12
  resolveLocalEmbeddingWorkerRuntime,
13
13
  getLocalEmbeddingNativeMemoryStats,
14
14
  LocalEmbeddingProvider
15
- } from "./index-8yjhda46.js";
15
+ } from "./index-9jvktm7k.js";
16
16
  import {
17
17
  setStoragePrivatePermissionEnforcement
18
18
  } from "./index-81nthk8j.js";
@@ -2,10 +2,10 @@ import {
2
2
  subagentTemperature,
3
3
  promptFingerprint,
4
4
  readHostSystemPrompt
5
- } from "./index-xmdkde4v.js";
5
+ } from "./index-y29y2j2w.js";
6
6
  import"./index-6x556c2q.js";
7
7
  import"./index-0h2mkab2.js";
8
- import"./index-gycf3sp7.js";
8
+ import"./index-7bqrfyny.js";
9
9
 
10
10
  // src/historian-calibration-extension.ts
11
11
  import { readFileSync } from "node:fs";
@@ -5541,7 +5541,7 @@ var DreamTasksSchema = object({
5541
5541
  max_tokens: 12000
5542
5542
  })),
5543
5543
  "evaluate-smart-notes": DreamTaskBaseConfigSchema.default(() => DreamTaskBaseConfigSchema.parse(defaultTaskConfig("evaluate-smart-notes"))),
5544
- "review-user-memories": ReviewUserMemoriesTaskConfigSchema.default(() => ReviewUserMemoriesTaskConfigSchema.parse(defaultTaskConfig("review-user-memories"))),
5544
+ "review-user-memories": ReviewUserMemoriesTaskConfigSchema.default(() => ReviewUserMemoriesTaskConfigSchema.parse(defaultTaskConfig("review-user-memories"))).describe("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."),
5545
5545
  "promote-primers": PromotePrimersTaskConfigSchema.default(() => PromotePrimersTaskConfigSchema.parse(defaultTaskConfig("promote-primers"))),
5546
5546
  "refresh-primers": DreamTaskBaseConfigSchema.default(() => DreamTaskBaseConfigSchema.parse(defaultTaskConfig("refresh-primers")))
5547
5547
  }).describe("Harness-independent task metadata. schedule, promotion_threshold, and other task metadata remain here; execution settings live under dreamer.opencode.tasks, dreamer.pi.tasks, or dreamer.omp.tasks.");
@@ -5559,13 +5559,13 @@ var AgentMetadataSchema = AgentOverrideConfigSchema.pick({
5559
5559
  maxTokens: true
5560
5560
  });
5561
5561
  var DreamerConfigSchema = AgentMetadataSchema.extend({
5562
- disable: boolean2().optional().describe("Disable this agent"),
5562
+ disable: boolean2().optional().describe("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."),
5563
5563
  runner: _enum(["broca", "host"]).optional().describe(`Which side runs the dreamer completions the Rust module routes (classify-memories) in Rust transform mode: "host" runs them on this process's carrier, "broca" routes them to the Broca module. When unset, historian.runner applies, and when that is unset too the harness decides the same way it does for the historian. User-level config only.`),
5564
5564
  opencode: DreamerOpenCodeHarnessBlockSchema.optional(),
5565
5565
  pi: DreamerPiHarnessBlockSchema.optional(),
5566
5566
  omp: DreamerOmpHarnessBlockSchema.optional(),
5567
5567
  tasks: DreamTasksSchema.default(() => DreamTasksSchema.parse({})),
5568
- inject_docs: boolean2().default(true).describe("Inject ARCHITECTURE.md and STRUCTURE.md into the m[0] `<project-docs>` block (default true)")
5568
+ inject_docs: boolean2().default(true).describe("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.")
5569
5569
  });
5570
5570
  var HistorianConfigSchema = AgentMetadataSchema.extend({
5571
5571
  expand_tools: record(string2(), union([
@@ -5704,9 +5704,9 @@ var MagicContextConfigSchema = object({
5704
5704
  profile: string2().trim().min(1).optional().describe("Select a named user-owned model profile. A valid project name overrides this user default; an empty string, null, or other non-string project value is ignored with a warning so the user selection still applies. Unknown names warn and use the base configuration."),
5705
5705
  profiles: ConfigProfilesSchema.optional().describe("User-level named model profiles. A profile may contain only historian/dreamer model, fallback_models, OpenCode variant, and Pi/OMP thinking_level fields; task execution policy (including timeout_minutes) is excluded. Project configs may select a name but cannot define profiles."),
5706
5706
  historian: HistorianConfigSchema.describe("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."),
5707
- dreamer: DreamerConfigSchema.optional().describe("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."),
5707
+ dreamer: DreamerConfigSchema.optional().describe("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."),
5708
5708
  smart_notes: object({
5709
- enabled: boolean2().default(true).describe("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."),
5709
+ enabled: boolean2().default(true).describe("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."),
5710
5710
  retina_handoff: boolean2().default(false).describe("When true, dreamer skips smart notes whose surface conditions compiled to retina provider configs at authoring time. Default false keeps both paths active until the retina consumer is deployed.")
5711
5711
  }).default({ enabled: true, retina_handoff: false }).describe("Smart-note ownership transition controls."),
5712
5712
  cache_ttl: union([string2(), object({ default: string2() }).catchall(string2())]).default("5m").describe(`How long Magic Context assumes the provider's cached prefix stays valid. This is MC's own deferral gate — it does not change the provider's actual cache lifetime. String (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "provider/model": "1h", "provider/*": "never" }); keys resolve most-specific first (exact provider/model, bare model ID, shorter dash-prefixes, then the provider/* wildcard, then default). User and project settings, including an explicit "5m" or object default, apply on the next pass. Only built-in defaults are frozen per session, including across restarts: when unset, GPT-5.6 and later (including gpt-6*, through any provider prefix) use 30m, other models use 5m. /ctx-status shows the effective TTL and whether it comes from your config or a frozen built-in default. Editing the TTL does not itself rewrite prompt bytes; a lowered TTL rebuilds only after normal idle expiry. OpenAI documents at least 30 minutes since the latest write or reuse: https://developers.openai.com/api/docs/guides/prompt-caching (Cache lifetime and Summary of model differences). Set to "never" to mean MC never assumes expiry (for lanes kept warm externally by a cache-keep tool) — disables the idle-TTL heuristic so MC never initiates a rebuild based on elapsed time. Provider-side extended TTL is a separate request-level concern (cache_control: { ttl } in the request body).`),
@@ -5734,11 +5734,11 @@ var MagicContextConfigSchema = object({
5734
5734
  object({ default: number2().int().min(0).max(1e6).optional() }).catchall(number2().int().min(0).max(1e6))
5735
5735
  ]).optional().describe("Reasoning tokens to keep on rebuilding passes. Number or per-model object; exact, shorter model keys, provider/*, then default. Omitted: fixed 10,000. 0 removes all eligible historical reasoning; newest and exempt steps always stay."),
5736
5736
  history_budget_percentage: number2().min(0.05).max(0.5).default(DEFAULT_HISTORY_BUDGET_PERCENTAGE).describe("Fraction of usable context (context_limit × execute_threshold) reserved for the session history block (default: 0.15)"),
5737
- historian_timeout_ms: number2().min(60000).default(DEFAULT_HISTORIAN_TIMEOUT_MS).describe("Timeout for each historian prompt call in both TypeScript and Rust transform modes, in milliseconds (default: 600000)"),
5737
+ historian_timeout_ms: number2().min(60000).default(DEFAULT_HISTORIAN_TIMEOUT_MS).describe("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."),
5738
5738
  commit_cluster_trigger: object({
5739
5739
  enabled: boolean2().default(true).describe("Enable commit-cluster based historian triggering (default: true)"),
5740
5740
  min_clusters: number2().min(1).default(3).describe("Minimum commit clusters required to trigger historian (min: 1, default: 3)")
5741
- }).default({ enabled: true, min_clusters: 3 }).describe("Commit-cluster trigger: fire historian when enough commit clusters accumulate in the unsummarized tail"),
5741
+ }).default({ enabled: true, min_clusters: 3 }).describe("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."),
5742
5742
  system_prompt_injection: object({
5743
5743
  enabled: boolean2().default(true).describe("When false, NO injection happens for ANY agent — global escape hatch. (default: true)"),
5744
5744
  skip_signatures: array(string2()).default(["<!-- magic-context: skip -->"]).describe(`Substring opt-out list. If the agent's system prompt contains any of these strings, skip ALL Magic Context injection for that call. Default "<!-- magic-context: skip -->" is meant to be added inside a user's custom agent prompt to opt that agent out.`)
@@ -5783,20 +5783,20 @@ var MagicContextConfigSchema = object({
5783
5783
  min_chars: number2().min(100).max(1e4).default(500).describe("Text parts shorter than this (characters) stay untouched. Min 100, max 10000. Default: 500.")
5784
5784
  }).default({ enabled: false, min_chars: 500 }).describe("Age-tier caveman compression for long user/assistant text parts. Active for primary sessions when enabled; never for subagents. Oldest 20% of eligible tags (outside protected tail) go to ultra, next 20% to full, next 20% to lite, newest 40% untouched. Graduated from experimental.caveman_text_compression; opt-in, default off (lossy)."),
5785
5785
  memory: object({
5786
- enabled: boolean2().default(true).describe("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."),
5786
+ enabled: boolean2().default(true).describe("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."),
5787
5787
  injection_budget_tokens: number2().min(500).max(20000).default(4000).describe("Token budget for memory injection on session start (min: 500, max: 20000, default: 4000)"),
5788
- auto_promote: boolean2().default(true).describe("Automatically promote eligible session facts into memory (default: true)"),
5789
- retrieval_count_promotion_threshold: number2().min(1).default(3).describe("retrieval_count threshold for promoting memory to permanent status (min: 1, default: 3)"),
5788
+ auto_promote: boolean2().default(true).describe("Automatically promote eligible session facts into memory (default: true). No effect while memory.enabled is false."),
5789
+ retrieval_count_promotion_threshold: number2().min(1).default(3).describe("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)."),
5790
5790
  auto_search: object({
5791
- enabled: boolean2().default(true).describe("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."),
5791
+ enabled: boolean2().default(true).describe("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."),
5792
5792
  score_threshold: number2().min(0.3).max(0.95).default(0.6).describe("Top hit score must exceed this threshold for the hint to fire (min: 0.3, max: 0.95, default: 0.60)"),
5793
5793
  min_prompt_chars: number2().min(5).max(500).default(20).describe("Skip hint when user message is shorter than this (min: 5, max: 500, default: 20)")
5794
- }).default({ enabled: true, score_threshold: 0.6, min_prompt_chars: 20 }).describe("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."),
5794
+ }).default({ enabled: true, score_threshold: 0.6, min_prompt_chars: 20 }).describe("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."),
5795
5795
  git_commit_indexing: object({
5796
- enabled: boolean2().default(false).describe("Index HEAD git commits for ctx_search (git_commit source). Graduated from experimental.git_commit_indexing; opt-in, default off. Independent of memory.enabled."),
5796
+ enabled: boolean2().default(false).describe("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."),
5797
5797
  since_days: number2().min(7).max(3650).default(365).describe("Days of HEAD history to index (min: 7, max: 3650, default: 365)"),
5798
5798
  max_commits: number2().min(100).max(20000).default(2000).describe("Max commits kept per project; oldest evicted (min: 100, max: 20000, default: 2000)")
5799
- }).default({ enabled: false, since_days: 365, max_commits: 2000 }).describe("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.")
5799
+ }).default({ enabled: false, since_days: 365, max_commits: 2000 }).describe("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.")
5800
5800
  }).default({
5801
5801
  enabled: true,
5802
5802
  injection_budget_tokens: 4000,
@@ -5804,7 +5804,7 @@ var MagicContextConfigSchema = object({
5804
5804
  retrieval_count_promotion_threshold: 3,
5805
5805
  auto_search: { enabled: true, score_threshold: 0.6, min_prompt_chars: 20 },
5806
5806
  git_commit_indexing: { enabled: false, since_days: 365, max_commits: 2000 }
5807
- }).describe("Cross-session memory configuration")
5807
+ }).describe("Cross-session memory configuration. auto_search and git_commit_indexing sit here for history but work with memory.enabled false.")
5808
5808
  }).transform((data) => {
5809
5809
  return {
5810
5810
  ...data,
@@ -0,0 +1,225 @@
1
+ import {
2
+ getHarness2
3
+ } from "./index-0h2mkab2.js";
4
+ import {
5
+ isUserHomeDirectory
6
+ } from "./index-6ex901g3.js";
7
+ import {
8
+ logSlowWriteTransaction
9
+ } from "./index-d4dt19md.js";
10
+
11
+ // ../plugin/src/features/magic-context/session-project-storage.ts
12
+ var SESSION_CHUNK_REPAIR_BATCH_SIZE = 100;
13
+ var upsertSessionProjectStatements = new WeakMap;
14
+ var repairSessionChunkProjectStatements = new WeakMap;
15
+ var misScopedProjectChunkStatements = new WeakMap;
16
+ var MIS_SCOPED_PROJECT_CHUNK_IDS_SQL = `
17
+ SELECT e.id FROM compartment_chunk_embeddings e
18
+ JOIN session_projects sp ON sp.session_id = e.session_id AND sp.harness = e.harness
19
+ WHERE e.project_path = ? AND sp.project_path <> e.project_path
20
+ UNION ALL
21
+ SELECT e.id FROM session_projects sp
22
+ JOIN compartment_chunk_embeddings e ON e.session_id = sp.session_id
23
+ WHERE sp.project_path = ? AND e.harness = sp.harness AND e.project_path <> sp.project_path`;
24
+ function getUpsertSessionProjectStatement(db) {
25
+ let stmt = upsertSessionProjectStatements.get(db);
26
+ if (!stmt) {
27
+ stmt = db.prepare(`INSERT INTO session_projects (session_id, harness, project_path, updated_at)
28
+ VALUES (?, ?, ?, ?)
29
+ ON CONFLICT(session_id, harness) DO UPDATE SET
30
+ project_path = excluded.project_path,
31
+ updated_at = excluded.updated_at
32
+ WHERE session_projects.project_path <> excluded.project_path`);
33
+ upsertSessionProjectStatements.set(db, stmt);
34
+ }
35
+ return stmt;
36
+ }
37
+ function getRepairSessionChunkProjectStatement(db) {
38
+ let stmt = repairSessionChunkProjectStatements.get(db);
39
+ if (!stmt) {
40
+ stmt = db.prepare(`UPDATE compartment_chunk_embeddings
41
+ SET project_path = ?
42
+ WHERE id IN (
43
+ SELECT id
44
+ FROM compartment_chunk_embeddings
45
+ WHERE session_id = ?
46
+ AND harness = ?
47
+ AND project_path <> ?
48
+ LIMIT ?
49
+ )`);
50
+ repairSessionChunkProjectStatements.set(db, stmt);
51
+ }
52
+ return stmt;
53
+ }
54
+ function findMisScopedCompartmentChunkEmbeddingIdsForProject(db, projectPath) {
55
+ return db.prepare(`SELECT id FROM (${MIS_SCOPED_PROJECT_CHUNK_IDS_SQL}) LIMIT 25`).all(projectPath, projectPath).map(({ id }) => id);
56
+ }
57
+ function recordSessionProjectIdentity(db, sessionId, projectPath) {
58
+ if (!sessionId || !projectPath)
59
+ return;
60
+ if (!projectPath.startsWith("git:") && !projectPath.startsWith("dir:") && isUserHomeDirectory(projectPath))
61
+ return;
62
+ const harness = getHarness2();
63
+ const now = Date.now();
64
+ let previousProjectPath;
65
+ db.transaction(() => {
66
+ const existing = db.prepare("SELECT project_path FROM session_projects WHERE session_id = ? AND harness = ?").get(sessionId, harness);
67
+ previousProjectPath = existing?.project_path;
68
+ getUpsertSessionProjectStatement(db).run(sessionId, harness, projectPath, now);
69
+ getRepairSessionChunkProjectStatement(db).run(projectPath, sessionId, harness, projectPath, SESSION_CHUNK_REPAIR_BATCH_SIZE);
70
+ }).immediate();
71
+ return previousProjectPath === projectPath ? undefined : { previousProjectPath, projectPath };
72
+ }
73
+ function repairMisScopedCompartmentChunkEmbeddingsForProject(db, projectPath, ids = findMisScopedCompartmentChunkEmbeddingIdsForProject(db, projectPath)) {
74
+ if (!projectPath || ids.length === 0)
75
+ return 0;
76
+ return db.prepare(`UPDATE compartment_chunk_embeddings
77
+ SET project_path = (SELECT sp.project_path FROM session_projects sp
78
+ WHERE sp.session_id = compartment_chunk_embeddings.session_id
79
+ AND sp.harness = compartment_chunk_embeddings.harness)
80
+ WHERE id IN (${ids.map(() => "?").join(",")}) AND EXISTS (
81
+ SELECT 1 FROM session_projects sp
82
+ WHERE sp.session_id = compartment_chunk_embeddings.session_id
83
+ AND sp.harness = compartment_chunk_embeddings.harness
84
+ AND sp.project_path <> compartment_chunk_embeddings.project_path
85
+ AND (sp.project_path = ? OR compartment_chunk_embeddings.project_path = ?)
86
+ )`).run(...ids, projectPath, projectPath).changes;
87
+ }
88
+
89
+ // ../plugin/src/features/magic-context/git-commits/sweep-coordinator.ts
90
+ var GIT_SWEEP_COOLDOWN_MS = 10 * 60 * 1000;
91
+ var GIT_SWEEP_LEASE_TTL_MS = 5 * 60 * 1000;
92
+ var GIT_SWEEP_NON_INDEXABLE_REPROBE_MS = 24 * 60 * 60 * 1000;
93
+ var GIT_SWEEP_LEASE_RENEWAL_MS = 60 * 1000;
94
+ function runImmediate(db, body) {
95
+ db.exec("BEGIN IMMEDIATE");
96
+ const transactionStartedAt = performance.now();
97
+ let committed = false;
98
+ try {
99
+ const result = body();
100
+ db.exec("COMMIT");
101
+ committed = true;
102
+ logSlowWriteTransaction("git_sweep_lease", transactionStartedAt);
103
+ return result;
104
+ } finally {
105
+ if (!committed) {
106
+ try {
107
+ db.exec("ROLLBACK");
108
+ } catch {}
109
+ }
110
+ }
111
+ }
112
+ function rowToState(row) {
113
+ return {
114
+ projectPath: row.project_path,
115
+ leaseHolder: row.lease_holder,
116
+ leaseExpiresAt: row.lease_expires_at,
117
+ lastSweptAt: row.last_swept_at
118
+ };
119
+ }
120
+ function getGitSweepCoordinatorState(db, projectPath) {
121
+ const row = db.prepare(`SELECT project_path, lease_holder, lease_expires_at, last_swept_at
122
+ FROM git_sweep_coordinator
123
+ WHERE project_path = ?`).get(projectPath);
124
+ return row ? rowToState(row) : null;
125
+ }
126
+ function acquireGitSweepLease(db, projectPath, holderId, options = {}) {
127
+ const cooldownMs = options.cooldownMs ?? GIT_SWEEP_COOLDOWN_MS;
128
+ const leaseTtlMs = options.leaseTtlMs ?? GIT_SWEEP_LEASE_TTL_MS;
129
+ return runImmediate(db, () => {
130
+ const now = Date.now();
131
+ const row = getGitSweepCoordinatorState(db, projectPath);
132
+ if (row?.leaseHolder && row.leaseExpiresAt !== null && row.leaseExpiresAt > now) {
133
+ return {
134
+ acquired: false,
135
+ projectPath,
136
+ reason: "lease_active",
137
+ leaseHolder: row.leaseHolder,
138
+ leaseExpiresAt: row.leaseExpiresAt,
139
+ lastSweptAt: row.lastSweptAt,
140
+ nextAllowedAt: null
141
+ };
142
+ }
143
+ if (!options.ignoreCooldown && row?.lastSweptAt !== null && row?.lastSweptAt !== undefined) {
144
+ const nextAllowedAt = row.lastSweptAt + cooldownMs;
145
+ if (nextAllowedAt > now) {
146
+ return {
147
+ acquired: false,
148
+ projectPath,
149
+ reason: "cooldown_active",
150
+ leaseHolder: row.leaseHolder,
151
+ leaseExpiresAt: row.leaseExpiresAt,
152
+ lastSweptAt: row.lastSweptAt,
153
+ nextAllowedAt
154
+ };
155
+ }
156
+ }
157
+ const leaseExpiresAt = now + leaseTtlMs;
158
+ db.prepare(`INSERT INTO git_sweep_coordinator (
159
+ project_path,
160
+ lease_holder,
161
+ lease_expires_at,
162
+ last_swept_at
163
+ ) VALUES (?, ?, ?, NULL)
164
+ ON CONFLICT(project_path) DO UPDATE SET
165
+ lease_holder = excluded.lease_holder,
166
+ lease_expires_at = excluded.lease_expires_at`).run(projectPath, holderId, leaseExpiresAt);
167
+ return {
168
+ acquired: true,
169
+ projectPath,
170
+ holderId,
171
+ acquiredAt: now,
172
+ leaseExpiresAt
173
+ };
174
+ });
175
+ }
176
+ function renewGitSweepLease(db, projectPath, holderId, leaseTtlMs = GIT_SWEEP_LEASE_TTL_MS) {
177
+ return runImmediate(db, () => {
178
+ const now = Date.now();
179
+ const leaseExpiresAt = now + leaseTtlMs;
180
+ const result = db.prepare(`UPDATE git_sweep_coordinator
181
+ SET lease_expires_at = ?
182
+ WHERE project_path = ?
183
+ AND lease_holder = ?
184
+ AND lease_expires_at > ?`).run(leaseExpiresAt, projectPath, holderId, now);
185
+ return result.changes === 1;
186
+ });
187
+ }
188
+ function markGitSweepSuccessAndRelease(db, projectPath, holderId) {
189
+ return runImmediate(db, () => {
190
+ const now = Date.now();
191
+ const result = db.prepare(`UPDATE git_sweep_coordinator
192
+ SET lease_holder = NULL,
193
+ lease_expires_at = NULL,
194
+ last_swept_at = ?
195
+ WHERE project_path = ?
196
+ AND lease_holder = ?
197
+ AND lease_expires_at > ?`).run(now, projectPath, holderId, now);
198
+ return result.changes === 1;
199
+ });
200
+ }
201
+ function parkGitSweepNonIndexable(db, projectPath, holderId, reprobeMs = GIT_SWEEP_NON_INDEXABLE_REPROBE_MS) {
202
+ return runImmediate(db, () => {
203
+ const now = Date.now();
204
+ const sweptAt = now + reprobeMs - GIT_SWEEP_COOLDOWN_MS;
205
+ const result = db.prepare(`UPDATE git_sweep_coordinator
206
+ SET lease_holder = NULL,
207
+ lease_expires_at = NULL,
208
+ last_swept_at = ?
209
+ WHERE project_path = ?
210
+ AND lease_holder = ?
211
+ AND lease_expires_at > ?`).run(sweptAt, projectPath, holderId, now);
212
+ return result.changes === 1;
213
+ });
214
+ }
215
+ function releaseGitSweepLease(db, projectPath, holderId) {
216
+ runImmediate(db, () => {
217
+ db.prepare(`UPDATE git_sweep_coordinator
218
+ SET lease_holder = NULL,
219
+ lease_expires_at = NULL
220
+ WHERE project_path = ?
221
+ AND lease_holder = ?`).run(projectPath, holderId);
222
+ });
223
+ }
224
+
225
+ export { findMisScopedCompartmentChunkEmbeddingIdsForProject, recordSessionProjectIdentity, repairMisScopedCompartmentChunkEmbeddingsForProject, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease };
@@ -3,12 +3,12 @@ import {
3
3
  } from "./index-135e8hvg.js";
4
4
  import {
5
5
  log2
6
- } from "./index-gycf3sp7.js";
6
+ } from "./index-7bqrfyny.js";
7
7
  import {
8
8
  ensureColumn,
9
9
  healAllNullColumns,
10
10
  installV95PerfSchema
11
- } from "./index-ttxsmaj5.js";
11
+ } from "./index-jrap43gc.js";
12
12
  import {
13
13
  resolveOpenCodeDbPath,
14
14
  openCodeDbPathExists,
@@ -20,10 +20,10 @@ import {
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./index-gqxsds3q.js";
23
+ } from "./index-6ex901g3.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
- } from "./index-43zqh10z.js";
26
+ } from "./index-d4dt19md.js";
27
27
 
28
28
  // ../plugin/src/features/magic-context/migrations.ts
29
29
  import { isMainThread } from "node:worker_threads";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-399p688g.js";
4
4
  import {
5
5
  log2
6
- } from "./index-gycf3sp7.js";
6
+ } from "./index-7bqrfyny.js";
7
7
  import {
8
8
  inRootAsyncContext2,
9
9
  getSqliteDatabasePath2
@@ -4,7 +4,7 @@ import {
4
4
  renderToolTemplate,
5
5
  resolveModelConfigValue,
6
6
  deriveDefaultProtectedTokens
7
- } from "./index-ta0ed2nc.js";
7
+ } from "./index-1k729e4f.js";
8
8
  import {
9
9
  getHarness2,
10
10
  harnessOwnsOpenCodeStore2
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  log2,
14
14
  sessionLog2
15
- } from "./index-gycf3sp7.js";
15
+ } from "./index-7bqrfyny.js";
16
16
  import {
17
17
  resolveDecisionCalibration,
18
18
  calibrationForModelKey,
@@ -23,7 +23,7 @@ import {
23
23
  TAG_SELECT_COLUMNS2,
24
24
  getCandidateToolOwners2,
25
25
  pickNearestPriorOwner2
26
- } from "./index-x7426vy4.js";
26
+ } from "./index-ed9d2ded.js";
27
27
  import {
28
28
  OMO_INTERNAL_INITIATOR_MARKER,
29
29
  isSystemDirective,
@@ -38,7 +38,7 @@ import {
38
38
  formatBlock,
39
39
  compactTextForSummary,
40
40
  mergeCommitHashes
41
- } from "./index-4pxydwvg.js";
41
+ } from "./index-g4jf772p.js";
42
42
  import {
43
43
  Database2,
44
44
  prepareCachedStatement2
@@ -46,7 +46,7 @@ import {
46
46
  import {
47
47
  stableStringify,
48
48
  closeQuietly
49
- } from "./index-ttxsmaj5.js";
49
+ } from "./index-jrap43gc.js";
50
50
  import {
51
51
  resolveOpenCodeDbPath,
52
52
  assertOpenCodeStoreGeneration,
@@ -71,10 +71,10 @@ import {
71
71
  hasRawSessionMessageByIdFromDb2,
72
72
  readRawSeedTailFromDb2,
73
73
  readRawSessionBoundaryEndpointsFromDb2
74
- } from "./index-4vj37yw9.js";
74
+ } from "./index-he9s4qsj.js";
75
75
  import {
76
76
  logSlowWriteTransaction
77
- } from "./index-43zqh10z.js";
77
+ } from "./index-d4dt19md.js";
78
78
 
79
79
  // ../plugin/src/features/magic-context/overflow-detection.ts
80
80
  var OVERFLOW_PATTERNS = [
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./index-4pxydwvg.js";
3
+ } from "./index-g4jf772p.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./index-0h2mkab2.js";
7
7
  import {
8
8
  log2
9
- } from "./index-gycf3sp7.js";
9
+ } from "./index-7bqrfyny.js";
10
10
  import {
11
11
  inRootAsyncContext2
12
12
  } from "./index-asrxgdt4.js";