@tekmidian/pai 1.0.0 → 1.0.3

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 (219) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +67 -5
  3. package/dist/aibroker-client-BxzeEHPF.mjs +3 -0
  4. package/dist/{aibroker-client-CXEYBzbf.mjs → aibroker-client-CQPGqLxL.mjs} +1 -1
  5. package/dist/atomic-file-BorMa4T3.mjs +21 -0
  6. package/dist/{auto-route-D5SXrMpB.mjs → auto-route-B7Yu6Uam.mjs} +3 -3
  7. package/dist/auto-route-CjjQqU1o.mjs +11 -0
  8. package/dist/budget-Dod6rnA9.mjs +15 -0
  9. package/dist/{caller-identity-CVTuiLSs.mjs → caller-identity-yLFb7CKq.mjs} +6 -5
  10. package/dist/{capacity-DaXrVj3J.mjs → capacity-DEveQdFV.mjs} +3 -3
  11. package/dist/{chain-BcQlIlEd.mjs → chain-7n9Gx56r.mjs} +5 -5
  12. package/dist/cli/index.mjs +1628 -370
  13. package/dist/{cockpit-actions-ODmt8yF9.mjs → cockpit-actions-BBHeyEZI.mjs} +84 -42
  14. package/dist/cockpit-actions-DR9X514g.mjs +20 -0
  15. package/dist/cockpit-memory--dnShXBA.mjs +20 -0
  16. package/dist/{config-BSXKyeJ1.mjs → config-Bu1_vbY8.mjs} +42 -3
  17. package/dist/{config-B955yYmo.mjs → config-Cxi-aBf4.mjs} +2 -2
  18. package/dist/{config-TaWmdTLx.mjs → config-DtENJ6cL.mjs} +1 -1
  19. package/dist/{config-D5chi2LO.mjs → config-XpZWOYOG.mjs} +2 -2
  20. package/dist/{controls-BGkK_Bdi.mjs → controls-CPoeudou.mjs} +37 -22
  21. package/dist/daemon/index.mjs +43 -42
  22. package/dist/daemon-DKdBNKfa.mjs +45 -0
  23. package/dist/{daemon-CorGh6Ub.mjs → daemon-DPAo6WTa.mjs} +103 -55
  24. package/dist/daemon-mcp/index.mjs +40 -39
  25. package/dist/{define-DGFu-sCf.mjs → define-CjJsmq-6.mjs} +1 -1
  26. package/dist/{detect-C1d5cUkT.mjs → detect-9CZNO0yf.mjs} +2 -2
  27. package/dist/detect-D1ziFFfA.mjs +10 -0
  28. package/dist/{embed-pass-CeQD8kRE.mjs → embed-pass-DIWjA68P.mjs} +5 -5
  29. package/dist/{embedding-gate-BHuBsgHD.mjs → embedding-gate-6rZrWRXa.mjs} +5 -5
  30. package/dist/{embedding-gate-Z7CJSOJk.mjs → embedding-gate-Cnk4YCyX.mjs} +3 -3
  31. package/dist/{embeddings-D4t6L-EH.mjs → embeddings-BVq3esBF.mjs} +1 -1
  32. package/dist/{embeddings-OF9Pt4by.mjs → embeddings-CIkJBKd-.mjs} +1 -1
  33. package/dist/{endreason-x1KOSrcO.mjs → endreason-C577xIQz.mjs} +7 -6
  34. package/dist/{env-DArqGq-Z.mjs → env-BE8mrsxr.mjs} +1 -1
  35. package/dist/factory-Bsib-qDG.mjs +9 -0
  36. package/dist/{factory-BtjbQ0np.mjs → factory-DjAAsqr_.mjs} +15 -13
  37. package/dist/{fallback-BIyEpPsQ.mjs → fallback-DFlItw1Z.mjs} +5 -5
  38. package/dist/{fmt-age-BiSHrTKN.mjs → fmt-age-ByDkvkoU.mjs} +1 -1
  39. package/dist/{health-C6jZWvRG.mjs → health-Dnym-qcT.mjs} +4 -4
  40. package/dist/{helpers-DFmYRCOa.mjs → helpers-BD6V-p9w.mjs} +2 -2
  41. package/dist/helpers-CMGjy_0N.mjs +10 -0
  42. package/dist/{helpers-CJpb_MNB.mjs → helpers-CRuBUas3.mjs} +87 -38
  43. package/dist/hooks/capture-all-events.mjs +52 -11
  44. package/dist/hooks/capture-session-summary.mjs +64 -47
  45. package/dist/hooks/capture-tool-output.mjs +49 -8
  46. package/dist/hooks/context-compression-hook.mjs +30 -10
  47. package/dist/hooks/initialize-session.mjs +1 -0
  48. package/dist/hooks/load-core-context.mjs +1 -1
  49. package/dist/hooks/load-project-context.mjs +32 -29
  50. package/dist/hooks/security-validator.mjs +45 -13
  51. package/dist/hooks/stop-hook.mjs +54 -16
  52. package/dist/hooks/supervision-banner.mjs +9 -0
  53. package/dist/hooks/sync-todo-to-md.mjs +147 -113
  54. package/dist/hooks/worker-edit-repair.mjs +2 -1
  55. package/dist/hooks/worker-guard.mjs +40 -16
  56. package/dist/hooks/worker-note.mjs +12 -5
  57. package/dist/hooks/worker-path-repair.mjs +1 -1
  58. package/dist/hooks/worker-pool-host.mjs +329 -231
  59. package/dist/hooks/worker-status-line.mjs +195 -114
  60. package/dist/index.d.mts +18 -0
  61. package/dist/index.mjs +12 -12
  62. package/dist/{indexer-backend-BM2CUSu8.mjs → indexer-backend-Cll7le4P.mjs} +149 -96
  63. package/dist/{ipc-client-BMqWw_gv.mjs → ipc-client-CaiGJnSM.mjs} +1 -1
  64. package/dist/{ipc-client-YYDD6zzU.mjs → ipc-client-ZRmDKd5Z.mjs} +1 -1
  65. package/dist/kill-tree-BG7dRVtp.mjs +10 -0
  66. package/dist/{kill-tree-BjYz5BxK.mjs → kill-tree-EWYaEk5v.mjs} +8 -8
  67. package/dist/{launch-CLp0OJxV.mjs → launch-CXVlZjHt.mjs} +8 -8
  68. package/dist/{launch-DgqQdAjI.mjs → launch-Jh5NVeNe.mjs} +3 -3
  69. package/dist/local-candidate-DLdwQt0s.mjs +112 -0
  70. package/dist/local-instances-DOxSgT_L.mjs +210 -0
  71. package/dist/local-instances-ZeRkkuS5.mjs +6 -0
  72. package/dist/{local-tiers-DPZYqv9m.mjs → local-tiers-BE4jGaMa.mjs} +2 -2
  73. package/dist/{local-tiers-DnBIAkbK.mjs → local-tiers-DNMI5W86.mjs} +3 -3
  74. package/dist/{main-config-ops-C0SflOWk.mjs → main-config-ops-BEMpuhDz.mjs} +3 -3
  75. package/dist/{main-resolver-DVPpSWVy.mjs → main-resolver-3Ns1HPmS.mjs} +18 -17
  76. package/dist/{migrate-BUJHadA8.mjs → migrate-DrA_OwlZ.mjs} +45 -14
  77. package/dist/min-max-DrSRUaWQ.mjs +16 -0
  78. package/dist/{model-inventory-Dasber3S.mjs → model-inventory-BFVSNFT3.mjs} +13 -12
  79. package/dist/{models-add-Bt7aUHDs.mjs → models-add-C1QIc1DA.mjs} +39 -38
  80. package/dist/operator-BTqvTIc8.mjs +7 -0
  81. package/dist/{operator-DZxcP-g8.mjs → operator-CyuB3aVw.mjs} +3 -3
  82. package/dist/{pai-marker-kIYuNt3c.mjs → pai-marker-BcZyJguM.mjs} +7 -6
  83. package/dist/{pane-audit-OGYrOAik.mjs → pane-audit-DKQt71s4.mjs} +7 -7
  84. package/dist/{paths-DoRuFc60.mjs → paths-CFHTloSe.mjs} +3 -3
  85. package/dist/{paths-DoIyRnhx.mjs → paths-CHifubDh.mjs} +3 -3
  86. package/dist/{planner-DLGOYlVb.mjs → planner-BmFACdLa.mjs} +31 -30
  87. package/dist/{pool-CZ5MZaXg.mjs → pool-Dh-q3iJi.mjs} +45 -6
  88. package/dist/{pool-cli-BxNSPzzY.mjs → pool-cli-BggU8GRp.mjs} +5 -5
  89. package/dist/{pool-cli-CbJfl37y.mjs → pool-cli-DQ6OzRy2.mjs} +6 -6
  90. package/dist/postgres-BdBNkL_l.mjs +7 -0
  91. package/dist/{postgres-CDnd_k5f.mjs → postgres-C6ti4haA.mjs} +55 -34
  92. package/dist/{project-setup-DM4npnL3.mjs → project-setup-jvfONJTQ.mjs} +131 -74
  93. package/dist/providers-BeDiVEb-.mjs +16 -0
  94. package/dist/{providers-UsKtLcUR.mjs → providers-CblTFrhz.mjs} +6 -6
  95. package/dist/{query-feedback-I-txSnld.mjs → query-feedback-BRfPtqki.mjs} +2 -2
  96. package/dist/registrable-BzH4TObg.mjs +9 -0
  97. package/dist/{registrable-LrRIVYQc.mjs → registrable-DpyTtajg.mjs} +4 -4
  98. package/dist/{render-BDbb4CF-.mjs → render-BYmQkuLd.mjs} +8 -8
  99. package/dist/render-CoMvwMPs.mjs +13 -0
  100. package/dist/{reranker-B4r4vykM.mjs → reranker-8g6xMwP7.mjs} +1 -1
  101. package/dist/{reranker-DxxMCtA0.mjs → reranker-CqCbpGnX.mjs} +1 -1
  102. package/dist/root-FtJsxYnm.mjs +36 -0
  103. package/dist/{root-BMeJuHOb.mjs → root-Xglu0OPD.mjs} +11 -11
  104. package/dist/route-table-B7zpoypi.mjs +15 -0
  105. package/dist/{router-L8Nu-OHF.mjs → router-CQSc3lk3.mjs} +17 -7
  106. package/dist/{router-D6Ec6Fid.mjs → router-DwHJRgG9.mjs} +1 -1
  107. package/dist/{routing-CUyiglfu.mjs → routing-BAAST9vT.mjs} +27 -308
  108. package/dist/{routing-ZuGlc0ge.mjs → routing-CENt4HH1.mjs} +13 -12
  109. package/dist/{run-ulAi5dFD.mjs → run-CSC7mgPf.mjs} +35 -33
  110. package/dist/{scan-B7I0gPe-.mjs → scan-C_Y5W9py.mjs} +6 -6
  111. package/dist/{local-candidate-jOjTNlOL.mjs → scheduler-CtUyWJ3O.mjs} +7 -109
  112. package/dist/scheduler-dmHXoRvm.mjs +3 -0
  113. package/dist/{scope-D5VSQxe4.mjs → scope-D-h6F6DN.mjs} +4 -4
  114. package/dist/{search-CPoE0830.mjs → search-RSyeQqj1.mjs} +18 -18
  115. package/dist/{session-CNXF6DLP.mjs → session-8iqQDkqb.mjs} +55 -31
  116. package/dist/session-BeqAbNPd.mjs +35 -0
  117. package/dist/session-scan-BJI_ZO8M.mjs +9 -0
  118. package/dist/{session-scan-BDLEc4w1.mjs → session-scan-W-gbwJHM.mjs} +6 -6
  119. package/dist/{sources-CjhUKKtO.mjs → sources-ESUkZaWv.mjs} +1 -1
  120. package/dist/{status-DYydKQUI.mjs → status-Dm4dYciN.mjs} +4 -4
  121. package/dist/{status-CvVi9cDf.mjs → status-ggJ7lgVg.mjs} +17 -9
  122. package/dist/{stop-words-SdSL1WKH.mjs → stop-words-DSEYQdNe.mjs} +1 -1
  123. package/dist/{test-isolation-CoDeOVXb.mjs → test-isolation-lqSmYxr0.mjs} +1 -1
  124. package/dist/{timeouts-OwEONmc8.mjs → timeouts-1MLooEBB.mjs} +1 -1
  125. package/dist/{tool-errors-AeRQuG3Y.mjs → tool-errors-7E13StWd.mjs} +4 -3
  126. package/dist/{tool-errors-R5E0fCgf.mjs → tool-errors-CJWODvlo.mjs} +6 -6
  127. package/dist/viewer-CqozWW39.mjs +22 -0
  128. package/dist/{viewer-DtWj5Vti.mjs → viewer-mDXUNHNy.mjs} +15 -15
  129. package/dist/{wait-BMUR-U-U.mjs → wait-ByV0OyMZ.mjs} +3 -3
  130. package/dist/{worker-config-BLqa1yiD.mjs → worker-config-CJhEMk19.mjs} +294 -92
  131. package/dist/worker-config-DESkIjMF.mjs +41 -0
  132. package/dist/{workers-config-DEI9lrV4.mjs → workers-config-f8KrkY4L.mjs} +2 -2
  133. package/dist/{worktree-zmRf556h.mjs → worktree-CRs2gyg0.mjs} +37 -7
  134. package/dist/{zettelkasten-nigq7fqs.mjs → zettelkasten-B_rRRRvD.mjs} +5 -5
  135. package/dist/{zettelkasten-Cr_Xj0mG.mjs → zettelkasten-BzMm8REH.mjs} +29 -19
  136. package/docs/README.md +2 -0
  137. package/docs/cockpit.md +10 -4
  138. package/docs/commands/README.md +4 -4
  139. package/docs/commands/backup.md +2 -0
  140. package/docs/commands/install.md +29 -4
  141. package/docs/commands/providers.md +1 -1
  142. package/docs/commands/restore.md +4 -0
  143. package/docs/commands/setup.md +29 -4
  144. package/docs/commands/worker.md +1 -1
  145. package/docs/config.md +2 -0
  146. package/docs/features.md +299 -0
  147. package/docs/images/architecture.drawio +51 -0
  148. package/docs/images/architecture.png +0 -0
  149. package/docs/images/architecture.svg +3 -0
  150. package/docs/images/cockpit-01-system-tokens.jpg +0 -0
  151. package/docs/images/cockpit-02-totals-cache.jpg +0 -0
  152. package/docs/images/cockpit-03-local-servers-models-pool.jpg +0 -0
  153. package/docs/images/cockpit-04-workers-memory.jpg +0 -0
  154. package/docs/images/cockpit-05-performance.jpg +0 -0
  155. package/docs/images/cockpit-06-runs-speed-routing.jpg +0 -0
  156. package/docs/images/cockpit-07-settings-registry.jpg +0 -0
  157. package/docs/install/index.md +29 -0
  158. package/docs/three-tier-coding.md +1 -1
  159. package/gemini-extension.json +1 -1
  160. package/package.json +1 -5
  161. package/pai-plugin.json +1 -1
  162. package/plugins/context-preservation/plugin.json +1 -1
  163. package/plugins/core/plugin.json +1 -1
  164. package/plugins/core/skills/setup/SKILL.md +41 -9
  165. package/plugins/creative/plugin.json +1 -1
  166. package/plugins/observability/plugin.json +1 -1
  167. package/plugins/productivity/plugin.json +1 -1
  168. package/plugins/semantic-search/plugin.json +1 -1
  169. package/plugins/ui/plugin.json +1 -1
  170. package/plugins/zettelkasten/plugin.json +1 -1
  171. package/src/hooks/session-autosave.sh +8 -1
  172. package/src/hooks/session-stop.sh +8 -1
  173. package/src/hooks/ts/capture-all-events.ts +7 -12
  174. package/src/hooks/ts/lib/context-fill.ts +2 -1
  175. package/src/hooks/ts/lib/path-repair.ts +1 -1
  176. package/src/hooks/ts/lib/project-utils/notify.ts +1 -0
  177. package/src/hooks/ts/lib/project-utils/session-notes.ts +23 -6
  178. package/src/hooks/ts/lib/raw-capture.ts +36 -0
  179. package/src/hooks/ts/lib/session-summary.ts +129 -0
  180. package/src/hooks/ts/lib/todo-sync.ts +120 -0
  181. package/src/hooks/ts/lib/worker-git-guard.ts +1 -1
  182. package/src/hooks/ts/post-tool-use/capture-tool-output.ts +6 -10
  183. package/src/hooks/ts/post-tool-use/sync-todo-to-md.ts +5 -105
  184. package/src/hooks/ts/pre-compact/context-compression-hook.ts +1 -1
  185. package/src/hooks/ts/pre-tool-use/security-validator.ts +35 -14
  186. package/src/hooks/ts/session-end/capture-session-summary.ts +20 -128
  187. package/src/hooks/ts/session-start/load-core-context.ts +3 -3
  188. package/src/hooks/ts/session-start/load-project-context.ts +18 -22
  189. package/src/hooks/ts/stop/stop-hook.ts +13 -5
  190. package/src/hooks/ztk-auto.sh +7 -2
  191. package/dist/aibroker-client-JjE74jo0.mjs +0 -3
  192. package/dist/auto-route-BRk8NEFv.mjs +0 -11
  193. package/dist/budget-DuhQ2zzG.mjs +0 -14
  194. package/dist/cockpit-actions-DcQ-ucU8.mjs +0 -19
  195. package/dist/cockpit-memory-KV45PPO2.mjs +0 -19
  196. package/dist/daemon-C7yt_ptC.mjs +0 -44
  197. package/dist/detect-DRUkmHnb.mjs +0 -10
  198. package/dist/factory-DAGG9_n8.mjs +0 -9
  199. package/dist/helpers-DPJEHPq6.mjs +0 -10
  200. package/dist/kill-tree-LV0Q7Mte.mjs +0 -10
  201. package/dist/operator-CfL0HiBK.mjs +0 -7
  202. package/dist/postgres-DgqWyqhN.mjs +0 -7
  203. package/dist/providers-CTu2s1z2.mjs +0 -15
  204. package/dist/registrable-D9aNZOTh.mjs +0 -9
  205. package/dist/render-BSfVlYHj.mjs +0 -13
  206. package/dist/root-xI9DqVIe.mjs +0 -35
  207. package/dist/route-table-HjvnLVEU.mjs +0 -14
  208. package/dist/session-BJHzmUg2.mjs +0 -34
  209. package/dist/session-scan-YORKE1NO.mjs +0 -9
  210. package/dist/viewer-B8709jDN.mjs +0 -22
  211. package/dist/worker-config-D8tRuvo7.mjs +0 -40
  212. package/docs/images/cockpit-limits-routing.jpg +0 -0
  213. package/docs/images/cockpit-models.jpg +0 -0
  214. package/docs/images/cockpit-usage.jpg +0 -0
  215. package/docs/images/cockpit-workers-system.jpg +0 -0
  216. package/scripts/build-docs.mjs +0 -41
  217. package/scripts/build-hooks.mjs +0 -311
  218. package/scripts/build-skill-stubs.mjs +0 -216
  219. package/scripts/copy-defaults.mjs +0 -46
@@ -0,0 +1,7 @@
1
+ import "./config-XpZWOYOG.mjs";
2
+ import "./config-Bu1_vbY8.mjs";
3
+ import "./paths-CHifubDh.mjs";
4
+ import "./status-ggJ7lgVg.mjs";
5
+ import { n as operatorSocketPath, r as sayToWorker, t as createOperatorServer } from "./operator-CyuB3aVw.mjs";
6
+
7
+ export { sayToWorker };
@@ -1,7 +1,7 @@
1
- import { g as isLive, v as loadStatus } from "./status-CvVi9cDf.mjs";
1
+ import { g as isLive, v as loadStatus } from "./status-ggJ7lgVg.mjs";
2
2
  import { existsSync, unlinkSync } from "node:fs";
3
- import { join } from "node:path";
4
3
  import { createHash } from "node:crypto";
4
+ import { join } from "node:path";
5
5
  import { connect, createServer } from "node:net";
6
6
 
7
7
  //#region src/workers/operator.ts
@@ -95,4 +95,4 @@ function sayToWorker(logDir, id, text, timeoutMs = 4e3) {
95
95
 
96
96
  //#endregion
97
97
  export { operatorSocketPath as n, sayToWorker as r, createOperatorServer as t };
98
- //# sourceMappingURL=operator-DZxcP-g8.mjs.map
98
+ //# sourceMappingURL=operator-CyuB3aVw.mjs.map
@@ -1,5 +1,6 @@
1
- import { s as worktreeReason } from "./registrable-LrRIVYQc.mjs";
2
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
1
+ import { t as writeFileAtomic } from "./atomic-file-BorMa4T3.mjs";
2
+ import { s as worktreeReason } from "./registrable-DpyTtajg.mjs";
3
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync } from "node:fs";
3
4
  import { join, resolve } from "node:path";
4
5
  import { homedir } from "node:os";
5
6
 
@@ -153,20 +154,20 @@ function ensurePaiMarker(projectRoot, slug, displayName) {
153
154
  if (!existsSync(markerPath)) {
154
155
  if (isContainerDirectory(projectRoot)) return;
155
156
  mkdirSync(notesDir, { recursive: true });
156
- writeFileSync(markerPath, renderTemplate(slug, name), "utf8");
157
+ writeFileAtomic(markerPath, renderTemplate(slug, name));
157
158
  return;
158
159
  }
159
160
  const raw = readFileSync(markerPath, "utf8");
160
161
  const parsed = parseFrontmatter(raw);
161
162
  if (!parsed) {
162
- writeFileSync(markerPath, `---\n${buildPaiBlock(slug, isoDate(), null, "active")}---\n\n${raw}`, "utf8");
163
+ writeFileAtomic(markerPath, `---\n${buildPaiBlock(slug, isoDate(), null, "active")}---\n\n${raw}`);
163
164
  return;
164
165
  }
165
166
  const { frontmatter, body } = parsed;
166
167
  const existingRegistered = extractYamlValue(frontmatter, "registered") ?? isoDate();
167
168
  const rawLastIndexed = extractYamlValue(frontmatter, "last_indexed");
168
169
  const newFrontmatter = replacePaiBlock(frontmatter, buildPaiBlock(slug, existingRegistered, rawLastIndexed === null || rawLastIndexed === "null" ? null : rawLastIndexed, extractYamlValue(frontmatter, "status") ?? "active"));
169
- writeFileSync(markerPath, `---\n${newFrontmatter.endsWith("\n") ? newFrontmatter : newFrontmatter + "\n"}---\n${body}`, "utf8");
170
+ writeFileAtomic(markerPath, `---\n${newFrontmatter.endsWith("\n") ? newFrontmatter : newFrontmatter + "\n"}---\n${body}`);
170
171
  }
171
172
  /**
172
173
  * Read PAI marker data from `<projectRoot>/Notes/PAI.md`.
@@ -227,4 +228,4 @@ function discoverPaiMarkers(searchDirs) {
227
228
 
228
229
  //#endregion
229
230
  export { ensurePaiMarker as n, readPaiMarker as r, discoverPaiMarkers as t };
230
- //# sourceMappingURL=pai-marker-kIYuNt3c.mjs.map
231
+ //# sourceMappingURL=pai-marker-BcZyJguM.mjs.map
@@ -1,10 +1,10 @@
1
1
  import { g as paiHomePath } from "./runtime-paths-WsO9sJFc.mjs";
2
- import { wt as appendLedger } from "./config-D5chi2LO.mjs";
3
- import { i as ledgerPath } from "./paths-DoIyRnhx.mjs";
4
- import { C as nowStamp, M as spawnTimeOf, T as ownsPidCached, b as loadStatusesCached, g as isLive, h as isChatPane, v as loadStatus, w as ownsPid } from "./status-CvVi9cDf.mjs";
5
- import { i as itermUuid } from "./scope-D5VSQxe4.mjs";
6
- import { At as recordPath, Ct as PANE_EXEC_PID_ENV, Dt as pidAlive, L as fmtElapsed, Mt as panePolicy, Ot as readExit, St as PANE_EXEC_ENV, Tt as listRecords, V as loadPlanStatuses, _t as paneTitle, dt as osascript, kt as readRecord, mt as realPaneOps, nt as closePaneForWorker, st as loadRegistry, tt as closeOwnPane, vt as writePaneTitle, wt as exitFilePath } from "./controls-BGkK_Bdi.mjs";
7
- import { i as killTree } from "./kill-tree-BjYz5BxK.mjs";
2
+ import { wt as appendLedger } from "./config-XpZWOYOG.mjs";
3
+ import { i as ledgerPath } from "./paths-CHifubDh.mjs";
4
+ import { C as nowStamp, M as spawnTimeOf, T as ownsPidCached, b as loadStatusesCached, g as isLive, h as isChatPane, v as loadStatus, w as ownsPid } from "./status-ggJ7lgVg.mjs";
5
+ import { i as itermUuid } from "./scope-D-h6F6DN.mjs";
6
+ import { At as recordPath, Ct as PANE_EXEC_PID_ENV, Dt as pidAlive, L as fmtElapsed, Mt as panePolicy, Ot as readExit, St as PANE_EXEC_ENV, Tt as listRecords, V as loadPlanStatuses, _t as paneTitle, dt as osascript, kt as readRecord, mt as realPaneOps, nt as closePaneForWorker, st as loadRegistry, tt as closeOwnPane, vt as writePaneTitle, wt as exitFilePath } from "./controls-CPoeudou.mjs";
7
+ import { i as killTree } from "./kill-tree-EWYaEk5v.mjs";
8
8
  import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
9
9
  import { join } from "node:path";
10
10
  import { execFileSync, spawn } from "node:child_process";
@@ -743,4 +743,4 @@ function renderPaneAudit(verdicts) {
743
743
 
744
744
  //#endregion
745
745
  export { readAudit as a, followPaneRun as c, loadPaneRunStatuses as d, paneRunRows as f, listItermTabs as i, isPaneRunId as l, runInPane as m, auditTick as n, renderPaneAudit as o, renderPaneRunLines as p, closeFinishedPanes as r, runningProcs as s, auditPanes as t, loadPaneRunStatus as u };
746
- //# sourceMappingURL=pane-audit-OGYrOAik.mjs.map
746
+ //# sourceMappingURL=pane-audit-DKQt71s4.mjs.map
@@ -1,5 +1,5 @@
1
- import "./config-D5chi2LO.mjs";
2
- import "./config-BSXKyeJ1.mjs";
3
- import { a as noMcpConfigPath, c as slotCurrentPath, i as ledgerPath, l as statusPath, n as ensureNoMcpConfig, o as panesDir, r as eventsPath, s as routingStatePath, t as WORKER_ID_RE, u as workersLogDir } from "./paths-DoIyRnhx.mjs";
1
+ import "./config-XpZWOYOG.mjs";
2
+ import "./config-Bu1_vbY8.mjs";
3
+ import { a as noMcpConfigPath, c as slotCurrentPath, i as ledgerPath, l as statusPath, n as ensureNoMcpConfig, o as panesDir, r as eventsPath, s as routingStatePath, t as WORKER_ID_RE, u as workersLogDir } from "./paths-CHifubDh.mjs";
4
4
 
5
5
  export { WORKER_ID_RE, ensureNoMcpConfig, eventsPath, ledgerPath, noMcpConfigPath, panesDir, routingStatePath, slotCurrentPath, statusPath, workersLogDir };
@@ -1,6 +1,6 @@
1
1
  import { _ as resolvePaiFile, g as paiHomePath } from "./runtime-paths-WsO9sJFc.mjs";
2
- import { d as defaultWorkersConfig } from "./config-D5chi2LO.mjs";
3
- import { o as expandHome } from "./config-BSXKyeJ1.mjs";
2
+ import { d as defaultWorkersConfig } from "./config-XpZWOYOG.mjs";
3
+ import { o as expandHome } from "./config-Bu1_vbY8.mjs";
4
4
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
 
@@ -65,4 +65,4 @@ function slotCurrentPath(logDir, slot) {
65
65
 
66
66
  //#endregion
67
67
  export { noMcpConfigPath as a, slotCurrentPath as c, ledgerPath as i, statusPath as l, ensureNoMcpConfig as n, panesDir as o, eventsPath as r, routingStatePath as s, WORKER_ID_RE as t, workersLogDir as u };
68
- //# sourceMappingURL=paths-DoIyRnhx.mjs.map
68
+ //# sourceMappingURL=paths-CHifubDh.mjs.map
@@ -1,32 +1,33 @@
1
- import { j as readWorkersSection, wt as appendLedger } from "./config-D5chi2LO.mjs";
2
- import "./config-BSXKyeJ1.mjs";
3
- import { i as ledgerPath, u as workersLogDir } from "./paths-DoIyRnhx.mjs";
4
- import { g as mergeWorker, n as MergeConflictError } from "./worktree-zmRf556h.mjs";
5
- import { S as newWorkerId, nt as shortText, tt as parseRunnerArgs, v as loadStatus } from "./status-CvVi9cDf.mjs";
6
- import "./pool-CZ5MZaXg.mjs";
7
- import "./helpers-CJpb_MNB.mjs";
8
- import "./scope-D5VSQxe4.mjs";
9
- import "./routing-CUyiglfu.mjs";
10
- import "./tool-errors-AeRQuG3Y.mjs";
11
- import "./wait-BMUR-U-U.mjs";
12
- import "./local-tiers-DPZYqv9m.mjs";
13
- import "./caller-identity-CVTuiLSs.mjs";
14
- import "./local-candidate-jOjTNlOL.mjs";
15
- import "./capacity-DaXrVj3J.mjs";
16
- import "./factory-BtjbQ0np.mjs";
17
- import "./postgres-CDnd_k5f.mjs";
18
- import "./embedding-gate-BHuBsgHD.mjs";
19
- import "./embeddings-D4t6L-EH.mjs";
20
- import "./router-L8Nu-OHF.mjs";
21
- import "./launch-DgqQdAjI.mjs";
22
- import { V as printResult, t as runWorker } from "./run-ulAi5dFD.mjs";
23
- import "./controls-BGkK_Bdi.mjs";
24
- import "./endreason-x1KOSrcO.mjs";
25
- import "./render-BDbb4CF-.mjs";
26
- import "./operator-DZxcP-g8.mjs";
27
- import "./kill-tree-BjYz5BxK.mjs";
28
- import "./pool-cli-BxNSPzzY.mjs";
29
- import { n as swapPromptArg } from "./chain-BcQlIlEd.mjs";
1
+ import { j as readWorkersSection, wt as appendLedger } from "./config-XpZWOYOG.mjs";
2
+ import "./config-Bu1_vbY8.mjs";
3
+ import { i as ledgerPath, u as workersLogDir } from "./paths-CHifubDh.mjs";
4
+ import { g as mergeWorker, n as MergeConflictError } from "./worktree-CRs2gyg0.mjs";
5
+ import { S as newWorkerId, nt as shortText, tt as parseRunnerArgs, v as loadStatus } from "./status-ggJ7lgVg.mjs";
6
+ import "./pool-Dh-q3iJi.mjs";
7
+ import "./helpers-CRuBUas3.mjs";
8
+ import "./scope-D-h6F6DN.mjs";
9
+ import "./routing-BAAST9vT.mjs";
10
+ import "./tool-errors-7E13StWd.mjs";
11
+ import "./wait-ByV0OyMZ.mjs";
12
+ import "./local-tiers-BE4jGaMa.mjs";
13
+ import "./caller-identity-yLFb7CKq.mjs";
14
+ import "./capacity-DEveQdFV.mjs";
15
+ import "./local-instances-DOxSgT_L.mjs";
16
+ import "./local-candidate-DLdwQt0s.mjs";
17
+ import "./factory-DjAAsqr_.mjs";
18
+ import "./postgres-C6ti4haA.mjs";
19
+ import "./embedding-gate-6rZrWRXa.mjs";
20
+ import "./embeddings-BVq3esBF.mjs";
21
+ import "./router-CQSc3lk3.mjs";
22
+ import "./launch-Jh5NVeNe.mjs";
23
+ import { V as printResult, t as runWorker } from "./run-CSC7mgPf.mjs";
24
+ import "./controls-CPoeudou.mjs";
25
+ import "./endreason-C577xIQz.mjs";
26
+ import "./render-BYmQkuLd.mjs";
27
+ import "./operator-CyuB3aVw.mjs";
28
+ import "./kill-tree-EWYaEk5v.mjs";
29
+ import "./pool-cli-BggU8GRp.mjs";
30
+ import { n as swapPromptArg } from "./chain-7n9Gx56r.mjs";
30
31
  import { existsSync, mkdirSync, readFileSync } from "node:fs";
31
32
  import { join } from "node:path";
32
33
 
@@ -306,4 +307,4 @@ function printPlannerSummary(logDir, plannerId, results, merged, conflicted, fmt
306
307
 
307
308
  //#endregion
308
309
  export { runPlanner };
309
- //# sourceMappingURL=planner-DLGOYlVb.mjs.map
310
+ //# sourceMappingURL=planner-BmFACdLa.mjs.map
@@ -1,7 +1,7 @@
1
- import { Et as parseLedger, I as LOOPBACK_HOST, c as WorkersConfigError, d as defaultWorkersConfig, i as DEFAULT_POOL_PORT, t as ANTHROPIC_NATIVE } from "./config-D5chi2LO.mjs";
2
- import { t as assertTestWriteAllowed } from "./test-isolation-CoDeOVXb.mjs";
3
- import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
4
- import { dirname, join } from "node:path";
1
+ import { Et as parseLedger, I as LOOPBACK_HOST, c as WorkersConfigError, d as defaultWorkersConfig, i as DEFAULT_POOL_PORT, t as ANTHROPIC_NATIVE } from "./config-XpZWOYOG.mjs";
2
+ import { t as assertTestWriteAllowed } from "./test-isolation-lqSmYxr0.mjs";
3
+ import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
4
+ import { dirname, join, resolve } from "node:path";
5
5
  import { homedir } from "node:os";
6
6
  import { request } from "node:http";
7
7
 
@@ -105,6 +105,45 @@ function trustProjectPath(absPath) {
105
105
  });
106
106
  return true;
107
107
  }
108
+ /** Canonical form of a script path: realpath when it exists, else the resolved text. */
109
+ function canonicalScript(p) {
110
+ try {
111
+ return realpathSync(p);
112
+ } catch {
113
+ return resolve(p);
114
+ }
115
+ }
116
+ /** True when an mcpServers entry runs `script`, comparing by realpath (symlinked repo paths match). */
117
+ function mcpEntryRunsScript(entry, script) {
118
+ const args = entry?.args;
119
+ if (!Array.isArray(args)) return false;
120
+ const want = canonicalScript(script);
121
+ return args.some((a) => typeof a === "string" && canonicalScript(a) === want);
122
+ }
123
+ /**
124
+ * Point `servers[name]` at `script`. An existing entry running the same file
125
+ * (by realpath) is updated in place; a genuinely different one is kept as
126
+ * `<name>-legacy`.
127
+ */
128
+ function registerMcpScript(servers, name, script) {
129
+ const existing = servers[name];
130
+ const entry = {
131
+ command: "node",
132
+ args: [script]
133
+ };
134
+ if (!existing) {
135
+ servers[name] = entry;
136
+ return "added";
137
+ }
138
+ if (mcpEntryRunsScript(existing, script)) {
139
+ const same = JSON.stringify(existing) === JSON.stringify(entry);
140
+ servers[name] = entry;
141
+ return same ? "unchanged" : "updated";
142
+ }
143
+ servers[`${name}-legacy`] = existing;
144
+ servers[name] = entry;
145
+ return "legacy-kept";
146
+ }
108
147
 
109
148
  //#endregion
110
149
  //#region src/workers/mcp.ts
@@ -589,5 +628,5 @@ function spareStats(ledgerText) {
589
628
  }
590
629
 
591
630
  //#endregion
592
- export { trustProjectPath as A, describeMcp as C, readMcpServers as D, mcpServersFromToolGrants as E, writeMcpConfig as O, inputSideTokens as S, grantsChrome as T, readPoolMetrics as _, formatCarryByProvider as a, spareStats as b, poolHostAlive as c, poolIneligibleReason as d, poolMetricsPath as f, postTaskToPool as g, poolSettings as h, bundleBuildStamp as i, writeClaudeJson as j, readClaudeJson as k, poolHostProbe as l, poolPort as m, SLOT_TOOLS as n, poolCarry as o, poolPidPath as p, UNIT_MARKER as r, poolDir as s, SHARED_MARKER as t, poolHostStale as u, readPoolState as v, expandMcpNames as w, warmOrCold as x, reloadInProgress as y };
593
- //# sourceMappingURL=pool-CZ5MZaXg.mjs.map
631
+ export { readClaudeJson as A, describeMcp as C, readMcpServers as D, mcpServersFromToolGrants as E, trustProjectPath as M, writeClaudeJson as N, writeMcpConfig as O, inputSideTokens as S, grantsChrome as T, readPoolMetrics as _, formatCarryByProvider as a, spareStats as b, poolHostAlive as c, poolIneligibleReason as d, poolMetricsPath as f, postTaskToPool as g, poolSettings as h, bundleBuildStamp as i, registerMcpScript as j, mcpEntryRunsScript as k, poolHostProbe as l, poolPort as m, SLOT_TOOLS as n, poolCarry as o, poolPidPath as p, UNIT_MARKER as r, poolDir as s, SHARED_MARKER as t, poolHostStale as u, readPoolState as v, expandMcpNames as w, warmOrCold as x, reloadInProgress as y };
632
+ //# sourceMappingURL=pool-Dh-q3iJi.mjs.map
@@ -1,7 +1,7 @@
1
- import { Et as parseLedger, F as writeWorkersSection, I as LOOPBACK_HOST, j as readWorkersSection, wt as appendLedger } from "./config-D5chi2LO.mjs";
2
- import { i as ledgerPath } from "./paths-DoIyRnhx.mjs";
3
- import { m as fmtTokens } from "./status-CvVi9cDf.mjs";
4
- import { _ as readPoolMetrics, a as formatCarryByProvider, b as spareStats, c as poolHostAlive, f as poolMetricsPath, h as poolSettings, i as bundleBuildStamp, l as poolHostProbe, m as poolPort, o as poolCarry, p as poolPidPath, s as poolDir, u as poolHostStale, v as readPoolState, y as reloadInProgress } from "./pool-CZ5MZaXg.mjs";
1
+ import { Et as parseLedger, F as writeWorkersSection, I as LOOPBACK_HOST, j as readWorkersSection, wt as appendLedger } from "./config-XpZWOYOG.mjs";
2
+ import { i as ledgerPath } from "./paths-CHifubDh.mjs";
3
+ import { m as fmtTokens } from "./status-ggJ7lgVg.mjs";
4
+ import { _ as readPoolMetrics, a as formatCarryByProvider, b as spareStats, c as poolHostAlive, f as poolMetricsPath, h as poolSettings, i as bundleBuildStamp, l as poolHostProbe, m as poolPort, o as poolCarry, p as poolPidPath, s as poolDir, u as poolHostStale, v as readPoolState, y as reloadInProgress } from "./pool-Dh-q3iJi.mjs";
5
5
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join } from "node:path";
7
7
  import { spawn } from "node:child_process";
@@ -313,4 +313,4 @@ function spareStatusLines(state, logDir) {
313
313
 
314
314
  //#endregion
315
315
  export { poolOff as a, poolStatusText as c, spareStatusLines as d, standalonePoolHostPath as f, hostBuildText as i, reloadPoolHost as l, diskBundleMtime as n, poolOn as o, ensurePoolHost as r, poolReloadLive as s, POOL_HEAL_GAP_MS as t, skipReasonLine as u };
316
- //# sourceMappingURL=pool-cli-BxNSPzzY.mjs.map
316
+ //# sourceMappingURL=pool-cli-BggU8GRp.mjs.map
@@ -1,8 +1,8 @@
1
- import "./config-D5chi2LO.mjs";
2
- import "./config-BSXKyeJ1.mjs";
3
- import "./paths-DoIyRnhx.mjs";
4
- import "./status-CvVi9cDf.mjs";
5
- import "./pool-CZ5MZaXg.mjs";
6
- import { a as poolOff, c as poolStatusText, d as spareStatusLines, f as standalonePoolHostPath, i as hostBuildText, l as reloadPoolHost, n as diskBundleMtime, o as poolOn, r as ensurePoolHost, s as poolReloadLive, t as POOL_HEAL_GAP_MS, u as skipReasonLine } from "./pool-cli-BxNSPzzY.mjs";
1
+ import "./config-XpZWOYOG.mjs";
2
+ import "./config-Bu1_vbY8.mjs";
3
+ import "./paths-CHifubDh.mjs";
4
+ import "./status-ggJ7lgVg.mjs";
5
+ import "./pool-Dh-q3iJi.mjs";
6
+ import { a as poolOff, c as poolStatusText, d as spareStatusLines, f as standalonePoolHostPath, i as hostBuildText, l as reloadPoolHost, n as diskBundleMtime, o as poolOn, r as ensurePoolHost, s as poolReloadLive, t as POOL_HEAL_GAP_MS, u as skipReasonLine } from "./pool-cli-BggU8GRp.mjs";
7
7
 
8
8
  export { poolOff, poolOn, poolStatusText };
@@ -0,0 +1,7 @@
1
+ import "./config-Bu1_vbY8.mjs";
2
+ import "./helpers-CRuBUas3.mjs";
3
+ import { o as buildPgTsQuery, t as PostgresBackend } from "./postgres-C6ti4haA.mjs";
4
+ import "./embedding-gate-6rZrWRXa.mjs";
5
+ import "./embeddings-BVq3esBF.mjs";
6
+
7
+ export { PostgresBackend };
@@ -1,12 +1,12 @@
1
- import { A as postgresConnectionString, k as DEFAULT_PG_CONNECTION_TIMEOUT_MS } from "./config-BSXKyeJ1.mjs";
2
- import { a as parseSessionTitleChunk, c as yieldToEventLoop, f as fileContentHash, h as sha256File, i as isPathTooBroadForContentScan, m as sha256, n as chunkId, o as walkContentFiles, r as detectTier, s as walkMdFiles, t as INDEX_YIELD_EVERY, u as chunkMarkdown } from "./helpers-CJpb_MNB.mjs";
3
- import { t as STOP_WORDS } from "./stop-words-SdSL1WKH.mjs";
4
- import { p as LEGACY_EMBEDDING_BINDING, r as gateBackend } from "./embedding-gate-BHuBsgHD.mjs";
5
- import { s as serializeEmbedding } from "./embeddings-D4t6L-EH.mjs";
1
+ import { M as postgresConnectionString, k as DEFAULT_PG_CONNECTION_TIMEOUT_MS } from "./config-Bu1_vbY8.mjs";
2
+ import { a as parseSessionTitleChunk, c as yieldToEventLoop, f as fileContentHash, h as sha256File, i as isPathTooBroadForContentScan, m as sha256, n as chunkId, o as walkContentFiles, r as detectTier, s as walkMdFiles, t as INDEX_YIELD_EVERY, u as chunkMarkdown } from "./helpers-CRuBUas3.mjs";
3
+ import { t as STOP_WORDS } from "./stop-words-DSEYQdNe.mjs";
4
+ import { p as LEGACY_EMBEDDING_BINDING, r as gateBackend } from "./embedding-gate-6rZrWRXa.mjs";
5
+ import { s as serializeEmbedding } from "./embeddings-BVq3esBF.mjs";
6
6
  import { existsSync, readFileSync, statSync } from "node:fs";
7
+ import { createHash } from "node:crypto";
7
8
  import { basename, dirname, join, relative } from "node:path";
8
9
  import { fileURLToPath } from "node:url";
9
- import { createHash } from "node:crypto";
10
10
  import pg from "pg";
11
11
 
12
12
  //#region src/module-paths.ts
@@ -67,13 +67,17 @@ function bufferToVector(buf) {
67
67
  * semantics are too strict for multi-word queries because all terms rarely
68
68
  * co-occur in a single chunk.
69
69
  *
70
- * Example: "Synchrotech interview follow-up Gilles"
71
- * → "synchrotech | interview | follow | gilles"
70
+ * The query is reduced to plain words (letters, digits, underscore, any script)
71
+ * and each word is single-quoted, so no user text can form a tsquery operator
72
+ * (& | ! < > - * ~ : parentheses, backslash).
73
+ *
74
+ * Example: "Acme interview follow-up Alice"
75
+ * → "'acme' | 'interview' | 'follow' | 'alice'"
72
76
  */
73
77
  function buildPgTsQuery(query) {
74
- const tokens = query.toLowerCase().split(/[\s\p{P}]+/u).filter(Boolean).filter((t) => t.length >= 2).filter((t) => !STOP_WORDS.has(t)).map((t) => t.replace(/'/g, "''").replace(/[&|!():]/g, "")).filter(Boolean);
75
- if (tokens.length === 0) return query.replace(/[^a-z0-9]/gi, " ").trim().split(/\s+/).filter(Boolean).join(" | ") || "";
76
- return tokens.join(" | ");
78
+ const long = (query.toLowerCase().match(/[\p{L}\p{N}_]+/gu) ?? []).filter((t) => t.length >= 2);
79
+ const tokens = long.filter((t) => !STOP_WORDS.has(t));
80
+ return (tokens.length > 0 ? tokens : long).map((t) => `'${t}'`).join(" | ");
77
81
  }
78
82
 
79
83
  //#endregion
@@ -86,11 +90,8 @@ function buildPgTsQuery(query) {
86
90
  * and a genuine miss were BYTE-IDENTICAL at the call site — `memory_search`
87
91
  * reported "No results found for query: …" either way.
88
92
  *
89
- * That cost a real wrong answer on 2026-08-04. `pai-pgvector` exited at 13:39Z and
90
- * the index lived inside it; for the next two hours every memory_search returned
91
- * cleanly empty. A sibling session searched for an open DMARC point, got nothing,
92
- * and told the owner nothing was recorded. The search had run against a dead
93
- * backend and was worthless — and nothing in the reply could have revealed that.
93
+ * A stopped backend therefore made every search look like a genuine miss, and
94
+ * a caller could conclude "nothing recorded" from a search that never ran.
94
95
  *
95
96
  * So: throw. The MCP shim already turns a thrown error into a visible message, and
96
97
  * an error the user can act on beats an empty result they cannot distinguish from
@@ -130,6 +131,7 @@ async function searchKeyword(pool, query, opts) {
130
131
  const limitParam = `$${paramIdx}`;
131
132
  const sql = `
132
133
  SELECT
134
+ id,
133
135
  project_id,
134
136
  path,
135
137
  start_line,
@@ -137,6 +139,8 @@ async function searchKeyword(pool, query, opts) {
137
139
  text AS snippet,
138
140
  tier,
139
141
  source,
142
+ updated_at,
143
+ last_accessed_at,
140
144
  ts_rank(fts_vector, to_tsquery('simple', $1)) AS rank_score
141
145
  FROM pai_chunks
142
146
  WHERE ${conditions.join(" AND ")}
@@ -144,7 +148,10 @@ async function searchKeyword(pool, query, opts) {
144
148
  LIMIT ${limitParam}
145
149
  `;
146
150
  try {
147
- return (await pool.query(sql, params)).rows.map((row) => ({
151
+ const result = await pool.query(sql, params);
152
+ const minScore = opts?.minScore ?? 0;
153
+ return result.rows.map((row) => ({
154
+ chunkId: row.id,
148
155
  projectId: row.project_id,
149
156
  path: row.path,
150
157
  startLine: row.start_line,
@@ -152,8 +159,10 @@ async function searchKeyword(pool, query, opts) {
152
159
  snippet: row.snippet,
153
160
  score: row.rank_score,
154
161
  tier: row.tier,
155
- source: row.source
156
- }));
162
+ source: row.source,
163
+ updatedAt: Number(row.updated_at),
164
+ lastAccessedAt: row.last_accessed_at != null ? Number(row.last_accessed_at) : void 0
165
+ })).filter((r) => r.score >= minScore);
157
166
  } catch (e) {
158
167
  process.stderr.write(`[pai-postgres] searchKeyword error: ${e}\n`);
159
168
  throw searchFailure("keyword", e);
@@ -633,12 +642,15 @@ function defaultLogger(attempt, delayMs, error) {
633
642
  * The SQLite path still uses sync.ts directly (which is faster for SQLite
634
643
  * due to synchronous transactions).
635
644
  */
645
+ /** Path namespace for memory files from the claude project dir (avoids clashing with the project root's memory/). */
646
+ const CLAUDE_MEMORY_PREFIX = ".claude-memory/";
636
647
  /**
637
648
  * Index a single file through the StorageBackend interface.
638
649
  * Returns true if the file was re-indexed (changed or new), false if skipped.
639
650
  */
640
- async function indexFileWithBackend(backend, projectId, rootPath, relativePath, source, tier) {
651
+ async function indexFileWithBackend(backend, projectId, rootPath, relativePath, source, tier, pathPrefix = "") {
641
652
  const absPath = join(rootPath, relativePath);
653
+ const dbPath = pathPrefix + relativePath;
642
654
  let content;
643
655
  let stat;
644
656
  try {
@@ -650,16 +662,16 @@ async function indexFileWithBackend(backend, projectId, rootPath, relativePath,
650
662
  const hash = fileContentHash(content);
651
663
  const mtime = Math.floor(stat.mtimeMs);
652
664
  const size = stat.size;
653
- if (await backend.getFileHash(projectId, relativePath) === hash) return false;
654
- await backend.deleteChunksForFile(projectId, relativePath);
665
+ if (await backend.getFileHash(projectId, dbPath) === hash) return false;
666
+ await backend.deleteChunksForFile(projectId, dbPath);
655
667
  const rawChunks = chunkMarkdown(content);
656
668
  const updatedAt = Date.now();
657
669
  const chunks = rawChunks.map((c, i) => ({
658
- id: chunkId(projectId, relativePath, i, c.startLine, c.endLine),
670
+ id: chunkId(projectId, dbPath, i, c.startLine, c.endLine),
659
671
  projectId,
660
672
  source,
661
673
  tier,
662
- path: relativePath,
674
+ path: dbPath,
663
675
  startLine: c.startLine,
664
676
  endLine: c.endLine,
665
677
  hash: c.hash,
@@ -670,7 +682,7 @@ async function indexFileWithBackend(backend, projectId, rootPath, relativePath,
670
682
  await backend.insertChunks(chunks);
671
683
  await backend.upsertFile({
672
684
  projectId,
673
- path: relativePath,
685
+ path: dbPath,
674
686
  source,
675
687
  tier,
676
688
  hash,
@@ -730,6 +742,7 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
730
742
  embedding: null
731
743
  };
732
744
  try {
745
+ if ((await backend.getChunkIds(projectId, syntheticPath)).length > 0) continue;
733
746
  await backend.insertChunks([titleChunk]);
734
747
  } catch {}
735
748
  }
@@ -767,6 +780,7 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
767
780
  embedding: null
768
781
  };
769
782
  try {
783
+ if ((await backend.getChunkIds(projectId, syntheticPath)).length > 0) continue;
770
784
  await backend.insertChunks([titleChunk]);
771
785
  } catch {}
772
786
  }
@@ -778,7 +792,8 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
778
792
  absPath: claudeMemoryMd,
779
793
  rootBase: claudeProjectDir,
780
794
  source: "memory",
781
- tier: "evergreen"
795
+ tier: "evergreen",
796
+ pathPrefix: CLAUDE_MEMORY_PREFIX
782
797
  });
783
798
  const claudeMemoryDir = join(claudeProjectDir, "memory");
784
799
  for (const absPath of walkMdFiles(claudeMemoryDir)) {
@@ -787,14 +802,15 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
787
802
  absPath,
788
803
  rootBase: claudeProjectDir,
789
804
  source: "memory",
790
- tier
805
+ tier,
806
+ pathPrefix: CLAUDE_MEMORY_PREFIX
791
807
  });
792
808
  }
793
809
  }
794
810
  }
795
811
  await yieldToEventLoop();
796
812
  let filesSinceYield = 0;
797
- for (const { absPath, rootBase, source, tier } of filesToIndex) {
813
+ for (const { absPath, rootBase, source, tier, pathPrefix = "" } of filesToIndex) {
798
814
  if (filesSinceYield >= INDEX_YIELD_EVERY) {
799
815
  await yieldToEventLoop();
800
816
  filesSinceYield = 0;
@@ -802,8 +818,8 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
802
818
  filesSinceYield++;
803
819
  const relPath = relative(rootBase, absPath);
804
820
  try {
805
- if (await indexFileWithBackend(backend, projectId, rootBase, relPath, source, tier)) {
806
- const ids = await backend.getChunkIds(projectId, relPath);
821
+ if (await indexFileWithBackend(backend, projectId, rootBase, relPath, source, tier, pathPrefix)) {
822
+ const ids = await backend.getChunkIds(projectId, pathPrefix + relPath);
807
823
  result.filesProcessed++;
808
824
  result.chunksCreated += ids.length;
809
825
  } else result.filesSkipped++;
@@ -812,7 +828,7 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
812
828
  }
813
829
  }
814
830
  const livePaths = /* @__PURE__ */ new Set();
815
- for (const { absPath, rootBase } of filesToIndex) livePaths.add(relative(rootBase, absPath));
831
+ for (const { absPath, rootBase, pathPrefix = "" } of filesToIndex) livePaths.add(pathPrefix + relative(rootBase, absPath));
816
832
  const dbChunkPaths = await backend.getDistinctChunkPaths(projectId);
817
833
  const stalePaths = [];
818
834
  for (const p of dbChunkPaths) {
@@ -1860,6 +1876,7 @@ var PostgresBackend = class PostgresBackend {
1860
1876
  async insertChunks(chunks) {
1861
1877
  if (chunks.length === 0) return;
1862
1878
  const client = await this.pool.connect();
1879
+ let releaseErr;
1863
1880
  try {
1864
1881
  await client.query("BEGIN");
1865
1882
  for (const c of chunks) {
@@ -1894,10 +1911,14 @@ var PostgresBackend = class PostgresBackend {
1894
1911
  }
1895
1912
  await client.query("COMMIT");
1896
1913
  } catch (e) {
1897
- await client.query("ROLLBACK");
1914
+ try {
1915
+ await client.query("ROLLBACK");
1916
+ } catch (rollbackErr) {
1917
+ releaseErr = rollbackErr instanceof Error ? rollbackErr : new Error(String(rollbackErr));
1918
+ }
1898
1919
  throw e;
1899
1920
  } finally {
1900
- client.release();
1921
+ client.release(releaseErr);
1901
1922
  }
1902
1923
  }
1903
1924
  async getDistinctChunkPaths(projectId) {
@@ -2288,4 +2309,4 @@ function rowToKgEntity(row) {
2288
2309
 
2289
2310
  //#endregion
2290
2311
  export { entityContentId as a, resolveFromModule as c, retryTransient as i, embedChunksWithBackend as n, buildPgTsQuery as o, indexProjectWithBackend as r, packageRoot as s, PostgresBackend as t };
2291
- //# sourceMappingURL=postgres-CDnd_k5f.mjs.map
2312
+ //# sourceMappingURL=postgres-C6ti4haA.mjs.map