@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
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getMagicContextStorageDir
3
- } from "./index-0sahzkwr.js";
3
+ } from "./index-g2q4htwp.js";
4
4
  import {
5
5
  log2
6
- } from "./index-mvvephtj.js";
6
+ } from "./index-j75v2476.js";
7
7
  import {
8
8
  inRootAsyncContext2
9
9
  } from "./index-wafzvyhg.js";
@@ -17,9 +17,9 @@ import {
17
17
  // src/features/magic-context/memory/project-identity.ts
18
18
  import { execFileSync } from "node:child_process";
19
19
  import { createHash as createHash2 } from "node:crypto";
20
- import { existsSync, realpathSync, statSync } from "node:fs";
20
+ import { existsSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
21
21
  import { homedir } from "node:os";
22
- import path2 from "node:path";
22
+ import path3 from "node:path";
23
23
 
24
24
  // src/features/magic-context/memory/project-identity-cache.ts
25
25
  import { createHash } from "node:crypto";
@@ -44,6 +44,162 @@ function readRememberedGitIdentity(directory, storageDir) {
44
44
  return;
45
45
  }
46
46
 
47
+ // src/features/magic-context/memory/unborn-head.ts
48
+ import { readFileSync as readFileSync2, realpathSync, statSync } from "node:fs";
49
+ import path2 from "node:path";
50
+ var GIT_LOCATION_ENV_VARS = [
51
+ "GIT_DIR",
52
+ "GIT_COMMON_DIR",
53
+ "GIT_WORK_TREE",
54
+ "GIT_CEILING_DIRECTORIES"
55
+ ];
56
+ function errorCode(error) {
57
+ if (error === null || typeof error !== "object" || !("code" in error))
58
+ return;
59
+ const code = error.code;
60
+ return typeof code === "string" ? code : undefined;
61
+ }
62
+ function readText(file) {
63
+ try {
64
+ return { ok: true, text: readFileSync2(file, "utf8") };
65
+ } catch (error) {
66
+ return { ok: false, missing: errorCode(error) === "ENOENT" };
67
+ }
68
+ }
69
+ function entryKind(entry) {
70
+ try {
71
+ const stat = statSync(entry);
72
+ if (stat.isFile())
73
+ return "file";
74
+ if (stat.isDirectory())
75
+ return "directory";
76
+ return "other";
77
+ } catch (error) {
78
+ return errorCode(error) === "ENOENT" ? "missing" : "error";
79
+ }
80
+ }
81
+ function stripLineEnding(text) {
82
+ return text.replace(/\r?\n$/u, "");
83
+ }
84
+ function resolveMetadataPath(baseDirectory, value) {
85
+ return path2.resolve(baseDirectory, value);
86
+ }
87
+ function isPlainBranchName(name) {
88
+ if (name.length === 0 || name.endsWith("/") || name.endsWith("."))
89
+ return false;
90
+ if (name.includes("..") || name.includes("//") || name.includes("@{"))
91
+ return false;
92
+ for (const character of name) {
93
+ const code = character.charCodeAt(0);
94
+ if (code <= 32 || code === 127 || "~^:?*[\\".includes(character))
95
+ return false;
96
+ }
97
+ return name.split("/").every((component) => !component.startsWith(".") && !component.endsWith(".lock"));
98
+ }
99
+ function findGitDirectory(start) {
100
+ let current = start;
101
+ while (true) {
102
+ const dotGit = path2.join(current, ".git");
103
+ const kind = entryKind(dotGit);
104
+ if (kind === "directory")
105
+ return dotGit;
106
+ if (kind === "file") {
107
+ const read = readText(dotGit);
108
+ if (!read.ok)
109
+ return;
110
+ const match = /^gitdir: (.+)$/u.exec(stripLineEnding(read.text));
111
+ if (!match?.[1] || match[1].includes(`
112
+ `))
113
+ return;
114
+ return resolveMetadataPath(current, match[1]);
115
+ }
116
+ if (kind !== "missing")
117
+ return;
118
+ const parent = path2.dirname(current);
119
+ if (parent === current)
120
+ return;
121
+ current = parent;
122
+ }
123
+ }
124
+ function packedRefsList(text, ref) {
125
+ for (const rawLine of text.split(`
126
+ `)) {
127
+ const line = rawLine.replace(/\r$/u, "");
128
+ if (line === "" || line.startsWith("#") || line.startsWith("^"))
129
+ continue;
130
+ const match = /^[0-9a-f]{40,64} (\S+)$/u.exec(line);
131
+ if (!match)
132
+ return;
133
+ if (match[1] === ref)
134
+ return true;
135
+ }
136
+ return false;
137
+ }
138
+ function isUnbornHeadInLayout(directory) {
139
+ const gitDirectory = findGitDirectory(directory);
140
+ if (gitDirectory === undefined)
141
+ return false;
142
+ let commonDirectory = gitDirectory;
143
+ const commondir = readText(path2.join(gitDirectory, "commondir"));
144
+ if (commondir.ok) {
145
+ const value = stripLineEnding(commondir.text);
146
+ if (value === "" || value.includes(`
147
+ `))
148
+ return false;
149
+ commonDirectory = resolveMetadataPath(gitDirectory, value);
150
+ } else if (!commondir.missing) {
151
+ return false;
152
+ }
153
+ if (entryKind(path2.join(gitDirectory, "HEAD")) !== "file")
154
+ return false;
155
+ if (entryKind(path2.join(commonDirectory, "objects")) !== "directory")
156
+ return false;
157
+ if (entryKind(path2.join(commonDirectory, "refs")) !== "directory")
158
+ return false;
159
+ if (entryKind(path2.join(commonDirectory, "reftable")) !== "missing")
160
+ return false;
161
+ const config = readText(path2.join(commonDirectory, "config"));
162
+ if (config.ok) {
163
+ if (/refstorage/iu.test(config.text))
164
+ return false;
165
+ } else if (!config.missing) {
166
+ return false;
167
+ }
168
+ const head = readText(path2.join(gitDirectory, "HEAD"));
169
+ if (!head.ok)
170
+ return false;
171
+ const headMatch = /^ref: (refs\/heads\/(.+))$/u.exec(head.text.replace(/\s+$/u, ""));
172
+ const ref = headMatch?.[1];
173
+ const branch = headMatch?.[2];
174
+ if (!ref || branch === undefined || !isPlainBranchName(branch))
175
+ return false;
176
+ const refSegments = ref.split("/");
177
+ for (const base of new Set([commonDirectory, gitDirectory])) {
178
+ if (entryKind(path2.join(base, ...refSegments)) !== "missing")
179
+ return false;
180
+ }
181
+ const packed = readText(path2.join(commonDirectory, "packed-refs"));
182
+ if (packed.ok) {
183
+ if (packedRefsList(packed.text, ref) !== false)
184
+ return false;
185
+ } else if (!packed.missing) {
186
+ return false;
187
+ }
188
+ return true;
189
+ }
190
+ function isUnbornHeadOnDisk(directory, env = process.env) {
191
+ if (GIT_LOCATION_ENV_VARS.some((name) => env[name] !== undefined && env[name] !== "")) {
192
+ return false;
193
+ }
194
+ let realDirectory;
195
+ try {
196
+ realDirectory = realpathSync.native(path2.resolve(directory));
197
+ } catch {
198
+ return false;
199
+ }
200
+ return isUnbornHeadInLayout(realDirectory);
201
+ }
202
+
47
203
  // src/features/magic-context/memory/project-identity.ts
48
204
  var GIT_TIMEOUT_MS = 5000;
49
205
  var TRANSIENT_FAILURE_COOLDOWN_MS = 5 * 60 * 1000;
@@ -79,6 +235,7 @@ function shouldSkipHomeProjectMemory(directory) {
79
235
  }
80
236
  }
81
237
  var execFileSyncForIdentity = execFileSync;
238
+ var gitTimeoutMs = GIT_TIMEOUT_MS;
82
239
  var userHomeDirectoryForIdentity = () => homedir();
83
240
  var nowMs = () => Date.now();
84
241
  var filesystemProbeObserverForTests;
@@ -133,7 +290,7 @@ function getErrorStderr(error) {
133
290
  return "";
134
291
  }
135
292
  function directoryFallback(directory) {
136
- const canonical = path2.resolve(directory);
293
+ const canonical = path3.resolve(directory);
137
294
  const hash = createHash2("md5").update(canonical, "utf8").digest("hex").slice(0, 12);
138
295
  return `dir:${hash}`;
139
296
  }
@@ -142,7 +299,7 @@ function rememberedIdentityOrDirectoryFallback(canonical) {
142
299
  }
143
300
  function assertDirectoryUsable(canonicalDirectory, rawDirectory) {
144
301
  try {
145
- const stat = statSync(canonicalDirectory);
302
+ const stat = statSync2(canonicalDirectory);
146
303
  if (!stat.isDirectory()) {
147
304
  throw new ProjectIdentityError("unknown", rawDirectory, `Project path is not a directory: ${canonicalDirectory}`);
148
305
  }
@@ -168,7 +325,7 @@ function hasUnbornHead(directory) {
168
325
  encoding: "utf8",
169
326
  env: { ...process.env, LC_ALL: "C", LANG: "C" },
170
327
  stdio: ["ignore", "pipe", "pipe"],
171
- timeout: GIT_TIMEOUT_MS,
328
+ timeout: gitTimeoutMs,
172
329
  windowsHide: true
173
330
  };
174
331
  try {
@@ -185,7 +342,7 @@ function hasUnbornHead(directory) {
185
342
  }
186
343
  function classifyGitError(error, rawDirectory) {
187
344
  if (isGitTimeoutError(error)) {
188
- return new ProjectIdentityError("git_timeout", rawDirectory, `git rev-list timed out after ${GIT_TIMEOUT_MS}ms`, asError(error));
345
+ return new ProjectIdentityError("git_timeout", rawDirectory, `git rev-list timed out after ${gitTimeoutMs}ms`, asError(error));
189
346
  }
190
347
  const code = getErrorCode(error);
191
348
  if (code === "ENOENT") {
@@ -205,7 +362,7 @@ function classifyGitError(error, rawDirectory) {
205
362
  }
206
363
  function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectPermission, options = {}) {
207
364
  assertProjectAllowed(directory, allowHomeProject);
208
- const canonical = path2.resolve(directory);
365
+ const canonical = path3.resolve(directory);
209
366
  const cached = options.cache === false ? undefined : identityCache.get(canonical);
210
367
  if (cached !== undefined) {
211
368
  return cached;
@@ -214,6 +371,9 @@ function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectP
214
371
  if (!hasGitDir(canonical)) {
215
372
  throw new ProjectIdentityError("not_git_repo", directory, "Directory has no git metadata; caller may use directory fallback");
216
373
  }
374
+ if (isUnbornHeadOnDisk(canonical)) {
375
+ throw new ProjectIdentityError("no_commits", directory, "Git repository has no commits yet");
376
+ }
217
377
  let output;
218
378
  try {
219
379
  output = execFileSyncForIdentity("git", ["rev-list", "--max-parents=0", "HEAD"], {
@@ -221,7 +381,7 @@ function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectP
221
381
  encoding: "utf8",
222
382
  env: { ...process.env, LC_ALL: "C", LANG: "C" },
223
383
  stdio: ["ignore", "pipe", "pipe"],
224
- timeout: GIT_TIMEOUT_MS,
384
+ timeout: gitTimeoutMs,
225
385
  windowsHide: true
226
386
  });
227
387
  } catch (error) {
@@ -274,9 +434,9 @@ function nearestLastKnownGitIdentity(canonical) {
274
434
  const cached = lastKnownGitIdentity(current);
275
435
  if (cached !== undefined)
276
436
  return { identity: cached, source: current };
277
- if (existsSync(path2.join(current, ".git")))
437
+ if (existsSync(path3.join(current, ".git")))
278
438
  break;
279
- const parent = path2.dirname(current);
439
+ const parent = path3.dirname(current);
280
440
  if (parent === current)
281
441
  break;
282
442
  current = parent;
@@ -287,7 +447,7 @@ function nearestLastKnownGitIdentity(canonical) {
287
447
  if (exactOrAncestor)
288
448
  return exactOrAncestor;
289
449
  try {
290
- const realCanonical = realpathSync.native(canonical);
450
+ const realCanonical = realpathSync2.native(canonical);
291
451
  if (realCanonical !== canonical)
292
452
  return walk(realCanonical);
293
453
  } catch {}
@@ -315,7 +475,7 @@ function recordDubiousOwnershipFallback(canonical) {
315
475
  log2(`[magic-context] ${formatDubiousOwnershipWarning(canonical)}`);
316
476
  }
317
477
  function takeDubiousOwnershipProjectIdentityWarning(directory) {
318
- const canonical = path2.resolve(directory);
478
+ const canonical = path3.resolve(directory);
319
479
  if (!dubiousOwnershipFallbackDirectories.has(canonical))
320
480
  return null;
321
481
  if (dubiousOwnershipWarnedDirectories.has(canonical))
@@ -326,7 +486,7 @@ function takeDubiousOwnershipProjectIdentityWarning(directory) {
326
486
  function canonicalUserHomeDirectory() {
327
487
  const homeDirectory = userHomeDirectoryForIdentity();
328
488
  try {
329
- return realpathSync.native(homeDirectory);
489
+ return realpathSync2.native(homeDirectory);
330
490
  } catch {
331
491
  return homeDirectory;
332
492
  }
@@ -335,20 +495,20 @@ function isUserHomeDirectory(directory) {
335
495
  if (projectDirectoryKey(directory) === projectDirectoryKey(userHomeDirectoryForIdentity()))
336
496
  return true;
337
497
  try {
338
- return projectDirectoryKey(realpathSync.native(path2.resolve(directory))) === projectDirectoryKey(canonicalUserHomeDirectory());
498
+ return projectDirectoryKey(realpathSync2.native(path3.resolve(directory))) === projectDirectoryKey(canonicalUserHomeDirectory());
339
499
  } catch {
340
500
  return false;
341
501
  }
342
502
  }
343
503
  function assertProjectAllowed(directory, allowHomeProject) {
344
- const canonical = path2.resolve(directory);
504
+ const canonical = path3.resolve(directory);
345
505
  if (!allowHomeProject && (isUserHomeDirectory(directory) || isUserHomeDirectory(gitRootDirectory(canonical) ?? canonical))) {
346
506
  throw new ProjectIdentityError("home_project_disabled", directory, "Home project memory is disabled; set allow_home_project to opt in");
347
507
  }
348
508
  }
349
509
  function resolveProjectIdentity(directory, allowHomeProject = homeProjectPermission) {
350
510
  assertProjectAllowed(directory, allowHomeProject);
351
- const canonical = path2.resolve(directory);
511
+ const canonical = path3.resolve(directory);
352
512
  const cachedFallback = directoryFallbackCache.get(canonical);
353
513
  if (cachedFallback !== undefined) {
354
514
  if (!hasGitDir(canonical)) {
@@ -396,7 +556,7 @@ function resolveProjectIdentityOrFallback(directory, allowHomeProject = homeProj
396
556
  try {
397
557
  return resolveProjectIdentity(directory, allowHomeProject);
398
558
  } catch (error) {
399
- const canonical = path2.resolve(directory);
559
+ const canonical = path3.resolve(directory);
400
560
  if (hasGitDir(canonical) || error instanceof ProjectIdentityError && error.errorClass === "home_project_disabled")
401
561
  throw error;
402
562
  const fallback = rememberedIdentityOrDirectoryFallback(canonical);
@@ -410,7 +570,7 @@ function hasGitDir(canonical) {
410
570
  return true;
411
571
  }
412
572
  try {
413
- const realCanonical = realpathSync.native(canonical);
573
+ const realCanonical = realpathSync2.native(canonical);
414
574
  return realCanonical !== canonical && hasGitDirInAncestorChain(realCanonical);
415
575
  } catch {
416
576
  return false;
@@ -419,14 +579,14 @@ function hasGitDir(canonical) {
419
579
  function gitRootInAncestorChain(startDirectory) {
420
580
  let current = startDirectory;
421
581
  while (true) {
422
- if (existsSync(path2.join(current, ".git"))) {
582
+ if (existsSync(path3.join(current, ".git"))) {
423
583
  try {
424
- return realpathSync.native(current);
584
+ return realpathSync2.native(current);
425
585
  } catch {
426
- return path2.resolve(current);
586
+ return path3.resolve(current);
427
587
  }
428
588
  }
429
- const parent = path2.dirname(current);
589
+ const parent = path3.dirname(current);
430
590
  if (parent === current) {
431
591
  return null;
432
592
  }
@@ -441,21 +601,21 @@ function gitRootDirectory(canonical) {
441
601
  if (direct)
442
602
  return direct;
443
603
  try {
444
- const realCanonical = realpathSync.native(canonical);
604
+ const realCanonical = realpathSync2.native(canonical);
445
605
  return realCanonical === canonical ? null : gitRootInAncestorChain(realCanonical);
446
606
  } catch {
447
607
  return null;
448
608
  }
449
609
  }
450
610
  function directoryHasGitMetadata(directory) {
451
- return gitRootDirectory(path2.resolve(directory)) !== null;
611
+ return gitRootDirectory(path3.resolve(directory)) !== null;
452
612
  }
453
613
  function describeUnresolvedProjectIdentity(directory) {
454
- const resolvedDirectory = path2.resolve(directory);
614
+ const resolvedDirectory = path3.resolve(directory);
455
615
  const canonicalHome = canonicalUserHomeDirectory();
456
616
  const canonicalDirectory = (() => {
457
617
  try {
458
- return realpathSync.native(resolvedDirectory);
618
+ return realpathSync2.native(resolvedDirectory);
459
619
  } catch {
460
620
  return resolvedDirectory;
461
621
  }
@@ -471,7 +631,7 @@ function isUsableProjectIdentity(identity) {
471
631
  return typeof identity === "string" && identity.trim().length > 0;
472
632
  }
473
633
  function resolveProjectIdentityForSession(directory, allowHomeProject = homeProjectPermission) {
474
- const resolvedDirectory = path2.resolve(directory);
634
+ const resolvedDirectory = path3.resolve(directory);
475
635
  const cacheKey = `${allowHomeProject ? "1" : "0"}\x00${resolvedDirectory}`;
476
636
  const cached = sessionIdentityCache.get(cacheKey);
477
637
  if (cached && (cached.revalidateAt === null || nowMs() < cached.revalidateAt) && !(cached.identity?.startsWith("dir:") && hasGitDir(resolvedDirectory))) {
@@ -482,7 +642,7 @@ function resolveProjectIdentityForSession(directory, allowHomeProject = homeProj
482
642
  const canonicalDirectory = (() => {
483
643
  try {
484
644
  filesystemProbeObserverForTests?.();
485
- return realpathSync.native(resolvedDirectory);
645
+ return realpathSync2.native(resolvedDirectory);
486
646
  } catch {
487
647
  return resolvedDirectory;
488
648
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-pavzsdc6.js";
4
4
  import {
5
5
  sessionLog2
6
- } from "./index-mvvephtj.js";
6
+ } from "./index-j75v2476.js";
7
7
  import {
8
8
  UNKNOWN_FIT_RATIO,
9
9
  resolveDecisionCalibration,
@@ -23,7 +23,7 @@ import {
23
23
  TAG_SELECT_COLUMNS2,
24
24
  getCandidateToolOwners2,
25
25
  pickNearestPriorOwner2
26
- } from "./index-f8cn4xqa.js";
26
+ } from "./index-fwefky9w.js";
27
27
  import {
28
28
  OMO_INTERNAL_INITIATOR_MARKER,
29
29
  isSystemDirective,
@@ -40,18 +40,18 @@ import {
40
40
  formatBlock,
41
41
  compactTextForSummary,
42
42
  mergeCommitHashes
43
- } from "./index-gjvjh960.js";
43
+ } from "./index-hqkczed7.js";
44
44
  import {
45
45
  prepareCachedStatement2
46
46
  } from "./index-wafzvyhg.js";
47
47
  import {
48
48
  stableStringify
49
- } from "./index-g7jkrz0x.js";
49
+ } from "./index-bp5083x2.js";
50
50
  import {
51
51
  renderToolTemplate,
52
52
  resolveModelConfigValue,
53
53
  deriveDefaultProtectedTokens
54
- } from "./index-w28y7d0z.js";
54
+ } from "./index-1sarmj9z.js";
55
55
  import {
56
56
  readRawSessionMessagesFromDb2,
57
57
  readRawSessionMessagePageFromDb2,
@@ -68,25 +68,25 @@ import {
68
68
  readRawSeedTailFromDb2,
69
69
  readRawSessionBoundaryEndpointsFromDb2,
70
70
  prewarmRawSessionOrdinalsForDb
71
- } from "./index-angx1s0k.js";
71
+ } from "./index-mmfa86mt.js";
72
72
  import {
73
73
  openCodeDbExists,
74
74
  withReadOnlySessionDb,
75
75
  getRawSessionMessageCountFromDb,
76
76
  getMessageTimesFromOpenCodeDb
77
- } from "./index-bzp9s8z2.js";
77
+ } from "./index-1d289pq2.js";
78
78
  import {
79
79
  getToolDefinitionMeasurementSignature,
80
80
  getLargestMeasuredToolDefinitionTokens,
81
81
  getMeasuredToolDefinitionTokens
82
- } from "./index-9jvab89d.js";
82
+ } from "./index-n6m03s3n.js";
83
83
  import {
84
84
  canonicalModelIdentity,
85
85
  piModelRefToCanonical
86
86
  } from "./index-avwt563y.js";
87
87
  import {
88
88
  logSlowWriteTransaction
89
- } from "./index-150zz6fh.js";
89
+ } from "./index-k29z4aqh.js";
90
90
 
91
91
  // src/shared/hidden-zen-read.ts
92
92
  function isToolFreeHiddenAgent(agent) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./index-mvvephtj.js";
3
+ } from "./index-j75v2476.js";
4
4
  import {
5
5
  isKnownAutocommit
6
6
  } from "./index-8ajstryz.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-wafzvyhg.js";
5
5
  import {
6
6
  logSlowWriteTransaction
7
- } from "./index-150zz6fh.js";
7
+ } from "./index-k29z4aqh.js";
8
8
 
9
9
  // src/features/magic-context/message-fts-rowid-map.ts
10
10
  import { createHash } from "node:crypto";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-v0p37hm2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-mvvephtj.js";
6
+ } from "./index-j75v2476.js";
7
7
  import {
8
8
  inRootAsyncContext2,
9
9
  getSqliteDatabasePath2
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./index-gjvjh960.js";
3
+ } from "./index-hqkczed7.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./index-pavzsdc6.js";
7
7
  import {
8
8
  log2
9
- } from "./index-mvvephtj.js";
9
+ } from "./index-j75v2476.js";
10
10
  import {
11
11
  inRootAsyncContext2
12
12
  } from "./index-wafzvyhg.js";
@@ -4,13 +4,13 @@ import {
4
4
  } from "./index-1zx87sdm.js";
5
5
  import {
6
6
  estimateTokens
7
- } from "./index-gjvjh960.js";
7
+ } from "./index-hqkczed7.js";
8
8
  import {
9
9
  getHarness2
10
10
  } from "./index-pavzsdc6.js";
11
11
  import {
12
12
  sessionLog2
13
- } from "./index-mvvephtj.js";
13
+ } from "./index-j75v2476.js";
14
14
  import {
15
15
  getTagIdentityWriteGeneration2,
16
16
  getSqliteDatabasePath2
@@ -20,7 +20,7 @@ import {
20
20
  tagOrderConstraintIndex,
21
21
  stableStringify,
22
22
  stableStringifyHash
23
- } from "./index-g7jkrz0x.js";
23
+ } from "./index-bp5083x2.js";
24
24
  import {
25
25
  DEFAULT_PROTECTED_TOOLS,
26
26
  normalizeProtectedToolName,
@@ -2938,6 +2938,19 @@ function insertTag2(db, sessionId, messageId, type, byteSize, tagNumber, reasoni
2938
2938
  function updateTagStatus2(db, sessionId, tagId, status) {
2939
2939
  getUpdateTagStatusStatement(db).run(status, sessionId, tagId);
2940
2940
  }
2941
+ var droppedTagStatements = new WeakMap;
2942
+ function markTagDropped2(db, sessionId, tagId, mode) {
2943
+ if (!mode) {
2944
+ updateTagStatus2(db, sessionId, tagId, "dropped");
2945
+ return;
2946
+ }
2947
+ let statement = droppedTagStatements.get(db);
2948
+ if (!statement) {
2949
+ statement = db.prepare("UPDATE tags SET status = ?, drop_mode = ? WHERE session_id = ? AND tag_number = ?");
2950
+ droppedTagStatements.set(db, statement);
2951
+ }
2952
+ statement.run("dropped", mode, sessionId, tagId);
2953
+ }
2941
2954
  function markWhitespaceAssistantTagInert2(db, sessionId, tagNumber, contentId) {
2942
2955
  db.prepare(`UPDATE tags
2943
2956
  SET status = 'compacted',
@@ -3663,7 +3676,7 @@ function getNewestToolTagNumbers2(db, sessionId, limit) {
3663
3676
  let statement = newestToolTagNumberStatements.get(db);
3664
3677
  if (!statement) {
3665
3678
  statement = db.prepare(`SELECT tag_number FROM tags
3666
- WHERE session_id = ? AND type = 'tool'
3679
+ WHERE session_id = ? AND +type = 'tool'
3667
3680
  AND typeof(message_id) = 'text'
3668
3681
  AND typeof(status) = 'text'
3669
3682
  AND typeof(byte_size) IN ('integer', 'real')
@@ -3833,4 +3846,4 @@ function deleteToolTagsByOwner(db, sessionId, ownerMsgId) {
3833
3846
  return getDeleteToolTagsByOwnerStatement(db).all(sessionId, ownerMsgId).length;
3834
3847
  }
3835
3848
 
3836
- export { protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, currentReclaimableToolOutputCount, isRecord, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, hasPendingDropOps, getPendingOpsCount, clearPendingOps, removePendingOp, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, cachedTagOwnerRatios2, tagOwnerWarmupState2, scanTagOwnerDelta2, installTagOwnerDelta2, installTagOwnerSummary2, isTagOwnerSummaryReady2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markWhitespaceAssistantTagInert2, getInertWhitespaceAssistantTags2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTailHygieneTags2, getDroppedTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
3849
+ export { protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, currentReclaimableToolOutputCount, isRecord, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, hasPendingDropOps, getPendingOpsCount, clearPendingOps, removePendingOp, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, cachedTagOwnerRatios2, tagOwnerWarmupState2, scanTagOwnerDelta2, installTagOwnerDelta2, installTagOwnerSummary2, isTagOwnerSummaryReady2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markTagDropped2, markWhitespaceAssistantTagInert2, getInertWhitespaceAssistantTags2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTailHygieneTags2, getDroppedTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./index-w28y7d0z.js";
3
+ } from "./index-1sarmj9z.js";
4
4
  import {
5
5
  log2
6
- } from "./index-mvvephtj.js";
6
+ } from "./index-j75v2476.js";
7
7
  import {
8
8
  isSynapseEmbeddingTruncated,
9
9
  SynapseEmbeddingProvider
10
- } from "./index-kvw6xew3.js";
10
+ } from "./index-fkx2qnvw.js";
11
11
  import {
12
12
  LocalEmbeddingProvider
13
- } from "./index-bmwfzz28.js";
13
+ } from "./index-9vqb5p1s.js";
14
14
  import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./index-se1w3v2m.js";
18
+ } from "./index-7zd5asz9.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./index-qt1qqasc.js";
@@ -3,7 +3,15 @@ import {
3
3
  } from "./index-pavzsdc6.js";
4
4
 
5
5
  // src/shared/data-path.ts
6
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
+ import {
7
+ existsSync,
8
+ lstatSync,
9
+ mkdirSync,
10
+ readFileSync,
11
+ readlinkSync,
12
+ realpathSync,
13
+ writeFileSync
14
+ } from "node:fs";
7
15
  import * as os from "node:os";
8
16
  import * as path from "node:path";
9
17
 
@@ -95,8 +103,44 @@ function getMagicContextStorageResolution() {
95
103
  function getMagicContextStorageDir() {
96
104
  return getMagicContextStorageResolution().path;
97
105
  }
106
+ function canonicalizeStoragePath(value, seen = new Set) {
107
+ const absolute = path.resolve(value);
108
+ if (seen.has(absolute))
109
+ return absolute;
110
+ seen.add(absolute);
111
+ try {
112
+ return realpathSync.native(absolute);
113
+ } catch {
114
+ try {
115
+ if (lstatSync(absolute).isSymbolicLink()) {
116
+ const target = readlinkSync(absolute);
117
+ const resolvedTarget = path.isAbsolute(target) ? target : path.resolve(path.dirname(absolute), target);
118
+ return canonicalizeStoragePath(resolvedTarget, seen);
119
+ }
120
+ } catch {}
121
+ const parent = path.dirname(absolute);
122
+ if (parent === absolute)
123
+ return absolute;
124
+ const resolvedParent = canonicalizeStoragePath(parent, seen);
125
+ return path.resolve(resolvedParent, path.basename(absolute));
126
+ }
127
+ }
128
+ function isMagicContextStorageOutsideEngram(storageDir = getMagicContextStorageDir(), backupDir = path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context")) {
129
+ const resolvedStorageDir = canonicalizeStoragePath(storageDir);
130
+ const resolvedBackupDir = canonicalizeStoragePath(backupDir);
131
+ const relative2 = path.relative(resolvedBackupDir, resolvedStorageDir);
132
+ return path.isAbsolute(relative2) || relative2 === ".." || relative2.startsWith(`..${path.sep}`);
133
+ }
134
+ var STORAGE_BACKUP_WARNING_CHECKED = Symbol.for("magic-context.storage-backup-warning-checked");
135
+ function claimStorageBackupWarningCheck() {
136
+ const processState = globalThis;
137
+ if (processState[STORAGE_BACKUP_WARNING_CHECKED])
138
+ return false;
139
+ processState[STORAGE_BACKUP_WARNING_CHECKED] = true;
140
+ return true;
141
+ }
98
142
  function getLegacyOpenCodeMagicContextStorageDir() {
99
143
  return path.join(getOpenCodeStorageDir(), "plugin", "magic-context");
100
144
  }
101
145
 
102
- export { getDataDir, getMagicContextLogPath, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getOpenCodeStorageDir, getMagicContextStorageResolution, getMagicContextStorageDir, getLegacyOpenCodeMagicContextStorageDir };
146
+ export { getDataDir, getMagicContextLogPath, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getOpenCodeStorageDir, getMagicContextStorageResolution, getMagicContextStorageDir, isMagicContextStorageOutsideEngram, claimStorageBackupWarningCheck, getLegacyOpenCodeMagicContextStorageDir };