@cleocode/cleo 2026.11.17 → 2026.11.18

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 (183) hide show
  1. package/dist/.source-stamp.json +1 -1
  2. package/dist/cli/{adapter-5MDCOYGC.js → adapter-5LAPPWDG.js} +3 -3
  3. package/dist/cli/{add-O74GFCW4.js → add-UW5YQRJF.js} +3 -3
  4. package/dist/cli/{add-batch-27TFCIOS.js → add-batch-VCNJVNUF.js} +3 -3
  5. package/dist/cli/{admin-H2YMRZ2U.js → admin-4CPCNOLE.js} +3 -3
  6. package/dist/cli/{admin-V2E56CI6.js → admin-MEJYZGFJ.js} +3 -3
  7. package/dist/cli/{adr-PRKE6GWP.js → adr-UE4H6ZFL.js} +3 -3
  8. package/dist/cli/{agent-TUUKQBZV.js → agent-RMPHLITH.js} +4 -3
  9. package/dist/cli/{analyze-TLF7PMOF.js → analyze-QZTXBKVH.js} +3 -3
  10. package/dist/cli/{archive-5W6MWOHW.js → archive-ZC2DBZIP.js} +3 -3
  11. package/dist/cli/{archive-stats-H53C4UTQ.js → archive-stats-WVSAILA7.js} +3 -3
  12. package/dist/cli/{attention-6QLUR2V5.js → attention-Q266HLPT.js} +3 -3
  13. package/dist/cli/{backup-4RLHQ7GY.js → backup-D76DEXWA.js} +3 -3
  14. package/dist/cli/{blockers-LWYKTZFY.js → blockers-CPYGYMB6.js} +3 -3
  15. package/dist/cli/{briefing-BDKQA7KW.js → briefing-ZXYIHVNM.js} +3 -3
  16. package/dist/cli/{cancel-KGN5HAMK.js → cancel-UE7FE44Q.js} +3 -3
  17. package/dist/cli/{cant-7453H4YN.js → cant-U4EGLXPJ.js} +16 -2
  18. package/dist/cli/cant-parses-5SIQ6U7T.js +22 -0
  19. package/dist/cli/{check-XL6T762F.js → check-PPARGLFQ.js} +2 -2
  20. package/dist/cli/{check-A55P2PPJ.js → check-ZPP4LIEG.js} +3 -3
  21. package/dist/cli/{chunk-7QKKXIZO.js → chunk-6ESGNFUU.js} +2 -2
  22. package/dist/cli/{chunk-NW4SOMJC.js → chunk-DGHNP57Z.js} +11 -11
  23. package/dist/cli/{chunk-EPTA6JOP.js → chunk-MUM7NTUD.js} +2 -2
  24. package/dist/cli/chunk-OSOQ5YXS.js +26 -0
  25. package/dist/cli/{claim-QPQVZFBD.js → claim-Y3MXS5UB.js} +3 -3
  26. package/dist/cli/{cli-AC55E53F.js → cli-RQDZRMOL.js} +3 -3
  27. package/dist/cli/{complete-FKOOFSXS.js → complete-2DBOR6IF.js} +4 -4
  28. package/dist/cli/{complexity-AWHB37LL.js → complexity-MISBHEYY.js} +3 -3
  29. package/dist/cli/{compliance-GPE7DQIN.js → compliance-SUXO6APO.js} +3 -3
  30. package/dist/cli/{config-NVSCHUVO.js → config-K45SIZXW.js} +3 -3
  31. package/dist/cli/{consensus-UJOGM2HY.js → consensus-5P6OMOCZ.js} +3 -3
  32. package/dist/cli/{context-5LTEY2FN.js → context-2PRS2NQH.js} +3 -3
  33. package/dist/cli/{contribution-LNETN2N2.js → contribution-7WVUFD6G.js} +3 -3
  34. package/dist/cli/{current-4AB4DCP5.js → current-LC4ICPLM.js} +3 -3
  35. package/dist/cli/{daemon-5DG4O6RM.js → daemon-FH6HPZJU.js} +3 -3
  36. package/dist/cli/{dash-DKIZBQQE.js → dash-WR2J7RE4.js} +3 -3
  37. package/dist/cli/{decompose-YIPLA2KW.js → decompose-QMIBRXT6.js} +3 -3
  38. package/dist/cli/{decomposition-NCLNGSYK.js → decomposition-IDCYNOYT.js} +3 -3
  39. package/dist/cli/{delete-HCWTH33S.js → delete-ELF5TYA7.js} +3 -3
  40. package/dist/cli/{deps-G4WH2JHF.js → deps-PSQ7PMW4.js} +3 -3
  41. package/dist/cli/{detect-U3FHF7SX.js → detect-QQL62ZNC.js} +3 -3
  42. package/dist/cli/{diagnostics-KSP3VSRL.js → diagnostics-EAVXKZKZ.js} +3 -3
  43. package/dist/cli/{docs-XCBYSR44.js → docs-2WLNHCKX.js} +16 -4
  44. package/dist/cli/{docs-D74A2C27.js → docs-N4UZ762Y.js} +15 -2
  45. package/dist/cli/{doctor-QAYWB4LS.js → doctor-JO3TOQDK.js} +26 -23
  46. package/dist/cli/doctor-gate-text-V7FT2IFK.js +60 -0
  47. package/dist/cli/{done-BY5AGPQK.js → done-P2X6HAAI.js} +4 -4
  48. package/dist/cli/{export-US54C7K4.js → export-K46IDT7J.js} +3 -3
  49. package/dist/cli/{export-tasks-S3HBJJLL.js → export-tasks-YWA2R6SV.js} +3 -3
  50. package/dist/cli/{find-GI2N4W4C.js → find-EAMOXG5D.js} +3 -3
  51. package/dist/cli/{focus-MBLPBCZP.js → focus-7VMY4OPJ.js} +3 -3
  52. package/dist/cli/{goal-B2LOBNAJ.js → goal-BJPJ6QIF.js} +2 -2
  53. package/dist/cli/{grade-N5FOIT77.js → grade-4NZ4PFR4.js} +3 -3
  54. package/dist/cli/{graph-OK6YOP42.js → graph-YHCDCIYY.js} +3 -3
  55. package/dist/cli/{history-LJFEFQSM.js → history-LRFQTQIM.js} +3 -3
  56. package/dist/cli/{import-UB3X43WG.js → import-TOPFUH6D.js} +3 -3
  57. package/dist/cli/{import-tasks-KK5JSORJ.js → import-tasks-43JE5CHL.js} +3 -3
  58. package/dist/cli/index.js +115 -107
  59. package/dist/cli/{inject-5ZW5MWK2.js → inject-TPWXIDUC.js} +3 -3
  60. package/dist/cli/{intelligence-MBHCYI37.js → intelligence-SNGSKZXV.js} +3 -3
  61. package/dist/cli/{issue-IFJ2L66E.js → issue-KDY2MBQZ.js} +3 -3
  62. package/dist/cli/{labels-AUKNPHK2.js → labels-LRGDKLF6.js} +3 -3
  63. package/dist/cli/{lifecycle-UDVHA3GI.js → lifecycle-QZ3EN2PW.js} +3 -3
  64. package/dist/cli/{list-ZRSNR4ZT.js → list-WRFWYGDJ.js} +3 -3
  65. package/dist/cli/{llm-C33IPUZ2.js → llm-AMXBN24Y.js} +3 -3
  66. package/dist/cli/{log-WN5Y7YUC.js → log-SWJWYYBR.js} +3 -3
  67. package/dist/cli/{manifest-WQR2MMB4.js → manifest-JES75O7E.js} +3 -3
  68. package/dist/cli/{map-6J7HTDDB.js → map-KXYE3ZCU.js} +3 -3
  69. package/dist/cli/{memory-TQDJULUR.js → memory-6GJVZXLU.js} +2 -2
  70. package/dist/cli/{memory-5UCRVX2D.js → memory-TBB7EPI4.js} +3 -3
  71. package/dist/cli/{migrate-claude-mem-5LS5ZC4B.js → migrate-claude-mem-5K6LARZL.js} +3 -3
  72. package/dist/cli/{next-4W2VCBLK.js → next-CASQPK7P.js} +3 -3
  73. package/dist/cli/{nexus-MJAM5QKA.js → nexus-KZ3KWNAF.js} +2 -2
  74. package/dist/cli/{nexus-NRSHSNSD.js → nexus-Q5OGKS2O.js} +3 -3
  75. package/dist/cli/{ops-NWEUYPMM.js → ops-BAGCCCGL.js} +3 -3
  76. package/dist/cli/{orchestrate-4JOC5JBH.js → orchestrate-56TWH7VX.js} +2 -2
  77. package/dist/cli/{orchestrate-PKP6NGDB.js → orchestrate-KH3UMO3A.js} +3 -3
  78. package/dist/cli/{phase-FFE3AYXK.js → phase-YFUIHHO3.js} +3 -3
  79. package/dist/cli/{pipeline-OMKEFYSV.js → pipeline-OWBRNTF4.js} +2 -2
  80. package/dist/cli/{pivot-MYXAZZOK.js → pivot-YUMSSFTZ.js} +3 -3
  81. package/dist/cli/{plan-PP7ZRDEL.js → plan-GXKPNFFR.js} +3 -3
  82. package/dist/cli/{playbook-3ZJ364AT.js → playbook-2ENSNMBX.js} +3 -3
  83. package/dist/cli/{promote-BMEJWJFS.js → promote-NNAEHQJE.js} +3 -3
  84. package/dist/cli/{provenance-E5YRQR6B.js → provenance-TVJDA63I.js} +3 -3
  85. package/dist/cli/{provider-CPXT43JJ.js → provider-UXQ6FRLT.js} +3 -3
  86. package/dist/cli/{reason-S3IX5MVW.js → reason-Q4O56AEQ.js} +3 -3
  87. package/dist/cli/{reconcile-QBQ2J5S7.js → reconcile-DNB26STV.js} +3 -3
  88. package/dist/cli/{relates-6HDKISVV.js → relates-C75YWMZJ.js} +3 -3
  89. package/dist/cli/{release-RCUUBO7N.js → release-REL4CB7S.js} +3 -3
  90. package/dist/cli/{reorder-QQM7Q6FL.js → reorder-J2IDDXE2.js} +3 -3
  91. package/dist/cli/{reparent-NWPI5GCQ.js → reparent-YPTCMIZ4.js} +3 -3
  92. package/dist/cli/{req-ZTCKOKAJ.js → req-BVFFKTXR.js} +3 -3
  93. package/dist/cli/{research-FDCTCUMM.js → research-IVYLZXES.js} +3 -3
  94. package/dist/cli/{restore-Q7YO647P.js → restore-SR2ODC2F.js} +3 -3
  95. package/dist/cli/{roadmap-BZHWWL5G.js → roadmap-ZVR4BFVV.js} +3 -3
  96. package/dist/cli/{safestop-LPZVMNXG.js → safestop-4NJAFUGS.js} +3 -3
  97. package/dist/cli/{saga-MW5T4GQQ.js → saga-4JJWDB5R.js} +3 -3
  98. package/dist/cli/{self-update-STWFASBR.js → self-update-U7W6QTLJ.js} +6 -3
  99. package/dist/cli/{selfimprove-4ZERPHXT.js → selfimprove-SS27Z7EN.js} +3 -3
  100. package/dist/cli/{selfimprove-C4HWDCM7.js → selfimprove-WQZKONL2.js} +2 -2
  101. package/dist/cli/{sequence-TINZEJ7V.js → sequence-XSYQKOVZ.js} +3 -3
  102. package/dist/cli/{service-WWCX2GBY.js → service-MBYXZ7BL.js} +3 -3
  103. package/dist/cli/{session-6NWSKFSG.js → session-7EX5W2NE.js} +3 -3
  104. package/dist/cli/{session-2XGQYSM4.js → session-F3ULVXCB.js} +2 -2
  105. package/dist/cli/{show-G3GPC23W.js → show-VGFTRMMQ.js} +3 -3
  106. package/dist/cli/{skills-FV6SVE7L.js → skills-56K36QBG.js} +3 -3
  107. package/dist/cli/{snapshot-QH3IRA6F.js → snapshot-3QATGRU5.js} +3 -3
  108. package/dist/cli/{start-S52HD5JV.js → start-2FQRPHWC.js} +3 -3
  109. package/dist/cli/{stats-6S4JMDOU.js → stats-WBNXMCF2.js} +3 -3
  110. package/dist/cli/{sticky-UB37G6EL.js → sticky-MND4WZLA.js} +3 -3
  111. package/dist/cli/{stop-DJMBHZR2.js → stop-CHVH7FQA.js} +3 -3
  112. package/dist/cli/{sync-BHUVE2CT.js → sync-4SJ6UWUU.js} +3 -3
  113. package/dist/cli/{tasks-MXKXRJC4.js → tasks-5YEGHPQW.js} +3 -3
  114. package/dist/cli/{tasks-HTOVUBA3.js → tasks-SHTN4VNH.js} +2 -2
  115. package/dist/cli/{testing-CSM77MCM.js → testing-2NACMGOB.js} +3 -3
  116. package/dist/cli/{token-SWBMAFNC.js → token-C7EUTCGG.js} +3 -3
  117. package/dist/cli/{update-MGQ3VOZA.js → update-ZD5HYSKB.js} +3 -3
  118. package/dist/cli/{upgrade-POVM5EDT.js → upgrade-363CG5IB.js} +6 -2
  119. package/dist/cli/{verify-E3HKTGZO.js → verify-LVM4TRD3.js} +3 -3
  120. package/dist/cli/{worktree-OHZ2HXVY.js → worktree-3TENVCFN.js} +3 -3
  121. package/package.json +14 -14
  122. package/studio-dist/client/_app/immutable/chunks/{COvBLBir.js → BPn6xjpy.js} +1 -1
  123. package/studio-dist/client/_app/immutable/chunks/C113yBd0.js +1 -0
  124. package/studio-dist/client/_app/immutable/chunks/{CzOru2IQ.js → DbccpEZ2.js} +1 -1
  125. package/studio-dist/client/_app/immutable/chunks/{Bx_Ybdwg.js → DibDuJs3.js} +1 -1
  126. package/studio-dist/client/_app/immutable/entry/{app.DnI5mM73.js → app.D4YI_RAP.js} +2 -2
  127. package/studio-dist/client/_app/immutable/entry/start._LyaK-iD.js +1 -0
  128. package/studio-dist/client/_app/immutable/nodes/{0.DQ30q-mz.js → 0.D_UzQ8Yl.js} +1 -1
  129. package/studio-dist/client/_app/immutable/nodes/{1.JV0f2m6G.js → 1.CAVDaxks.js} +1 -1
  130. package/studio-dist/client/_app/immutable/nodes/{15.CLlik7BX.js → 15.BLW07CRr.js} +1 -1
  131. package/studio-dist/client/_app/immutable/nodes/{16.3tCwb6mJ.js → 16.OwFHKxFl.js} +1 -1
  132. package/studio-dist/client/_app/immutable/nodes/{17.CnYe2cL4.js → 17.ByNcDwwk.js} +1 -1
  133. package/studio-dist/client/_app/immutable/nodes/{18.CmRvKXU6.js → 18.DQ2z0cVj.js} +1 -1
  134. package/studio-dist/client/_app/immutable/nodes/{20.Dd8Jncv-.js → 20.DcklgcYr.js} +1 -1
  135. package/studio-dist/client/_app/immutable/nodes/{24.BKeV5sCP.js → 24.CFNCQUQa.js} +1 -1
  136. package/studio-dist/client/_app/immutable/nodes/{25.42FV04bG.js → 25.DOpU5M2h.js} +2 -2
  137. package/studio-dist/client/_app/immutable/nodes/{26.kdWFFy6h.js → 26.BZvubV3F.js} +1 -1
  138. package/studio-dist/client/_app/immutable/nodes/{3.C7gybX_c.js → 3.DfqLHFYv.js} +1 -1
  139. package/studio-dist/client/_app/version.json +1 -1
  140. package/studio-dist/server/chunks/{0-D5IK1A6a.js → 0-CbgboTx6.js} +3 -3
  141. package/studio-dist/server/chunks/1-Cyw2DSw5.js +9 -0
  142. package/studio-dist/server/chunks/{15-1FEj7YLh.js → 15-HB3bkWMP.js} +3 -3
  143. package/studio-dist/server/chunks/{16-BPExaCbz.js → 16-DGVo0Czi.js} +3 -3
  144. package/studio-dist/server/chunks/{17-BJDZbxOa.js → 17-CNX9-knu.js} +3 -3
  145. package/studio-dist/server/chunks/{18-Ctw9hVSr.js → 18-1spEvEI8.js} +3 -3
  146. package/studio-dist/server/chunks/{20-DHYBZQXc.js → 20-DJJyDqmv.js} +3 -3
  147. package/studio-dist/server/chunks/{24-DAI0Lyyc.js → 24-CCnxieNz.js} +3 -3
  148. package/studio-dist/server/chunks/{25-I2HNzAo9.js → 25-DiDtvOeY.js} +10 -338
  149. package/studio-dist/server/chunks/{26-DyIOS9XM.js → 26-BIzvIYSx.js} +3 -3
  150. package/studio-dist/server/chunks/{3-B2xvXVT0.js → 3-WAClmfHo.js} +6 -5
  151. package/studio-dist/server/chunks/{_layout.svelte-DWyTOQxs.js → _layout.svelte-D6Ldlo8e.js} +4 -4
  152. package/studio-dist/server/chunks/{_page.svelte-rvUlNZoL.js → _page.svelte--c8tMFPx.js} +4 -4
  153. package/studio-dist/server/chunks/{_page.svelte-B9H6-g06.js → _page.svelte-BAQybygW.js} +3 -3
  154. package/studio-dist/server/chunks/{_page.svelte-RhWTQFHO.js → _page.svelte-Bm6AVnMf.js} +3 -3
  155. package/studio-dist/server/chunks/{_page.svelte-BnFe-NMP.js → _page.svelte-COWnE68H.js} +3 -3
  156. package/studio-dist/server/chunks/{_page.svelte-C-87PKFP.js → _page.svelte-Cz61TPsq.js} +3 -3
  157. package/studio-dist/server/chunks/{_page.svelte-BbyRiKdN.js → _page.svelte-D4YDVEYh.js} +3 -3
  158. package/studio-dist/server/chunks/{_page.svelte-DXjPWuIN.js → _page.svelte-Dpr2yepq.js} +3 -3
  159. package/studio-dist/server/chunks/{_page.svelte-CEwUAieV.js → _page.svelte-KD8A9NNL.js} +3 -3
  160. package/studio-dist/server/chunks/{_page.svelte-B45EpBnX.js → _page.svelte-imuh1_oL.js} +7 -6
  161. package/studio-dist/server/chunks/{_server.ts-BcEKZJJA.js → _server.ts-B-ezGzXl.js} +3 -3
  162. package/studio-dist/server/chunks/{_server.ts-CjV8PszM.js → _server.ts-B9qiqq4z.js} +3 -3
  163. package/studio-dist/server/chunks/{_server.ts-BoJ3fPMJ.js → _server.ts-BiyZRJLN.js} +3 -2
  164. package/studio-dist/server/chunks/{_server.ts-BbEV1obK.js → _server.ts-BkEnOqaQ.js} +3 -3
  165. package/studio-dist/server/chunks/{_server.ts-CUFugtSt.js → _server.ts-C4rPjGI1.js} +3 -3
  166. package/studio-dist/server/chunks/{_server.ts-DqCpzs5A.js → _server.ts-CSH4fzXf.js} +4 -3
  167. package/studio-dist/server/chunks/{_server.ts-DSM1bzLc.js → _server.ts-Dz-499Yg.js} +3 -2
  168. package/studio-dist/server/chunks/{_server.ts-CwDGVJ2P.js → _server.ts-MJtlS_2Z.js} +2 -2
  169. package/studio-dist/server/chunks/{_server.ts-C_AxPpt-.js → _server.ts-pZ4SU8_H.js} +4 -3
  170. package/studio-dist/server/chunks/{brain-BAwmMnA6.js → brain-BTM0v0Cd.js} +2 -2
  171. package/studio-dist/server/chunks/{client-Br0ikrJg.js → client-BcCBvM6e.js} +2 -2
  172. package/studio-dist/server/chunks/{error.svelte-BmmeOJVZ.js → error.svelte-BI9UKC3a.js} +3 -3
  173. package/studio-dist/server/chunks/errors-CbKNtzWS.js +360 -0
  174. package/studio-dist/server/chunks/{http-CQioSYsK.js → http-DcRPuXuV.js} +2 -2
  175. package/studio-dist/server/chunks/{internal-qWV_lqaN.js → internal-CWvXHt7s.js} +2 -2
  176. package/studio-dist/server/chunks/{operations-registry-C_x34kYM.js → operations-registry-DPL0JZAc.js} +39 -12
  177. package/studio-dist/server/chunks/{src-DMQE8esV.js → src-DHIA6U44.js} +378 -341
  178. package/studio-dist/server/chunks/{stores-ClTAlUAW.js → stores-mFH1rHF6.js} +2 -2
  179. package/studio-dist/server/index.js +1 -1
  180. package/studio-dist/server/manifest.js +21 -21
  181. package/studio-dist/client/_app/immutable/chunks/CK74r9qk.js +0 -1
  182. package/studio-dist/client/_app/immutable/entry/start.CocuF8MJ.js +0 -1
  183. package/studio-dist/server/chunks/1-BQTnuTNB.js +0 -9
@@ -1,3 +1,4 @@
1
+ import { g as getErrorMessage } from './errors-CbKNtzWS.js';
1
2
  import { createRequire } from 'node:module';
2
3
  import { existsSync, statSync, realpathSync, readFileSync } from 'node:fs';
3
4
  import { openCleoDbSnapshot } from '@cleocode/core/store/open-cleo-db.js';
@@ -831,20 +832,27 @@ function allTyped(stmt, ...params) {
831
832
  *
832
833
  * @param path - Absolute path to a consolidated `cleo.db`.
833
834
  * @param read - Synchronous read; the handle is closed when it returns.
834
- * @returns The read's result, or null when the store is missing or cannot be
835
- * opened (a restore in progress, a malformed file), so the substrate degrades
836
- * to no nodes.
835
+ * @param onError - Receives the failure when the store exists but cannot be
836
+ * opened (a restore in progress, a malformed file) or `read` throws. Without
837
+ * it a failed open returns null and a throwing `read` propagates.
838
+ * @returns The read's result, or null when the store is missing, cannot be
839
+ * opened, or `read` failed and `onError` received the failure.
837
840
  */
838
- function readStore(path, read) {
841
+ function readStore(path, read, onError) {
839
842
  if (!existsSync(path)) return null;
840
843
  let snapshot;
841
844
  try {
842
845
  snapshot = openCleoDbSnapshot(path, { readOnly: true });
843
- } catch {
846
+ } catch (err) {
847
+ onError?.(`store cannot be opened: ${getErrorMessage(err)}`);
844
848
  return null;
845
849
  }
846
850
  try {
847
851
  return read(snapshot.db);
852
+ } catch (err) {
853
+ if (!onError) throw err;
854
+ onError(getErrorMessage(err));
855
+ return null;
848
856
  } finally {
849
857
  snapshot.close();
850
858
  }
@@ -854,19 +862,56 @@ function readStore(path, read) {
854
862
  *
855
863
  * @param ctx - The active project context; `tasksDbPath` names its `cleo.db`.
856
864
  * @param read - Synchronous read against the project store.
865
+ * @param onError - Receives an open or read failure (see {@link StoreErrorSink}).
857
866
  * @returns The read's result, or null when the store is missing or unreadable.
858
867
  */
859
- function readProjectStore(ctx, read) {
860
- return readStore(ctx.tasksDbPath, read);
868
+ function readProjectStore(ctx, read, onError) {
869
+ return readStore(ctx.tasksDbPath, read, onError);
861
870
  }
862
871
  /**
863
872
  * Runs `read` against the global-scope `cleo.db` under CLEO home.
864
873
  *
865
874
  * @param read - Synchronous read against the global store.
875
+ * @param onError - Receives an open or read failure (see {@link StoreErrorSink}).
866
876
  * @returns The read's result, or null when the store is missing or unreadable.
867
877
  */
868
- function readGlobalStore(read) {
869
- return readStore(getGlobalStorePath(), read);
878
+ function readGlobalStore(read, onError) {
879
+ return readStore(getGlobalStorePath(), read, onError);
880
+ }
881
+ /**
882
+ * Runs one substrate query, recording its failure instead of throwing, so one
883
+ * failing query never skips the substrate's other queries (T14656).
884
+ *
885
+ * @param errors - Collects `<name>: <message>` for each failed query.
886
+ * @param name - The query's name in the recorded message (usually its table).
887
+ * @param query - The query to run.
888
+ * @returns The query's rows, or an empty array when it failed.
889
+ */
890
+ function tryQuery(errors, name, query) {
891
+ try {
892
+ return query();
893
+ } catch (err) {
894
+ errors.push(`${name}: ${getErrorMessage(err)}`);
895
+ return [];
896
+ }
897
+ }
898
+ /**
899
+ * Builds an adapter result, joining the recorded failures into `error`.
900
+ *
901
+ * @param nodes - Nodes read from the substrate.
902
+ * @param edges - Edges read from the substrate.
903
+ * @param errors - Failures recorded while reading; empty when every read succeeded.
904
+ * @returns The result, with `error` set only when a read failed.
905
+ */
906
+ function substrateResult(nodes, edges, errors) {
907
+ return errors.length === 0 ? {
908
+ nodes,
909
+ edges
910
+ } : {
911
+ nodes,
912
+ edges,
913
+ error: errors.join("; ")
914
+ };
870
915
  }
871
916
  //#endregion
872
917
  //#region ../brain/dist/src/adapters/agent-registry.js
@@ -906,9 +951,9 @@ function getAgentRegistrySubstrate(options = {}) {
906
951
  const perSubstrateLimit = Math.ceil((options.limit ?? 500) / 5);
907
952
  const nodes = [];
908
953
  const edges = [];
954
+ const errors = [];
909
955
  readGlobalStore((db) => {
910
- try {
911
- const agentRows = allTyped(db.prepare(`SELECT agent_id, name, status,
956
+ const agentRows = tryQuery(errors, "agent_registry_agents", () => allTyped(db.prepare(`SELECT agent_id, name, status,
912
957
  CASE WHEN typeof(created_at) = 'integer'
913
958
  THEN strftime('%Y-%m-%dT%H:%M:%S', created_at, 'unixepoch')
914
959
  ELSE strftime('%Y-%m-%dT%H:%M:%S', created_at)
@@ -916,25 +961,21 @@ function getAgentRegistrySubstrate(options = {}) {
916
961
  FROM main.agent_registry_agents
917
962
  WHERE is_active = 1
918
963
  ORDER BY created_at DESC
919
- LIMIT ?`), perSubstrateLimit);
920
- for (const row of agentRows) nodes.push({
921
- id: `agent-registry:${row.agent_id}`,
922
- kind: "agent",
923
- substrate: "agent-registry",
924
- label: row.name,
925
- weight: row.status === "online" ? 1 : .5,
926
- createdAt: row.created_at,
927
- meta: {
928
- status: row.status,
929
- created_at: row.created_at
930
- }
931
- });
932
- } catch {}
933
- });
934
- return {
935
- nodes,
936
- edges
937
- };
964
+ LIMIT ?`), perSubstrateLimit));
965
+ for (const row of agentRows) nodes.push({
966
+ id: `agent-registry:${row.agent_id}`,
967
+ kind: "agent",
968
+ substrate: "agent-registry",
969
+ label: row.name,
970
+ weight: row.status === "online" ? 1 : .5,
971
+ createdAt: row.created_at,
972
+ meta: {
973
+ status: row.status,
974
+ created_at: row.created_at
975
+ }
976
+ });
977
+ }, (message) => errors.push(message));
978
+ return substrateResult(nodes, edges, errors);
938
979
  }
939
980
  //#endregion
940
981
  //#region ../brain/dist/src/project-context.js
@@ -1068,166 +1109,162 @@ function getBrainSubstrate(options = {}) {
1068
1109
  const perSubstrateLimit = Math.ceil((options.limit ?? 500) / 5);
1069
1110
  const nodes = [];
1070
1111
  const edges = [];
1112
+ const errors = [];
1071
1113
  readProjectStore(ctx, (db) => {
1072
- try {
1073
- const obsRows = allTyped(db.prepare(`SELECT id, title, quality_score, memory_tier,
1114
+ const obsRows = tryQuery(errors, "brain_observations", () => allTyped(db.prepare(`SELECT id, title, quality_score, memory_tier,
1074
1115
  strftime('%Y-%m-%dT%H:%M:%S', created_at) AS created_at,
1075
1116
  source_session_id, files_modified_json
1076
1117
  FROM main.brain_observations
1077
1118
  WHERE (quality_score IS NULL OR quality_score >= ?)
1078
1119
  ORDER BY quality_score DESC, created_at DESC
1079
- LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .4));
1080
- for (const row of obsRows) nodes.push({
1081
- id: `brain:${row.id}`,
1082
- kind: "observation",
1083
- substrate: "brain",
1084
- label: row.title,
1085
- weight: row.quality_score ?? void 0,
1086
- createdAt: row.created_at,
1087
- meta: {
1088
- memory_tier: row.memory_tier,
1089
- created_at: row.created_at,
1090
- source_session_id: row.source_session_id
1091
- }
1092
- });
1093
- const decRows = allTyped(db.prepare(`SELECT id, decision, quality_score, context_task_id,
1120
+ LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .4)));
1121
+ for (const row of obsRows) nodes.push({
1122
+ id: `brain:${row.id}`,
1123
+ kind: "observation",
1124
+ substrate: "brain",
1125
+ label: row.title,
1126
+ weight: row.quality_score ?? void 0,
1127
+ createdAt: row.created_at,
1128
+ meta: {
1129
+ memory_tier: row.memory_tier,
1130
+ created_at: row.created_at,
1131
+ source_session_id: row.source_session_id
1132
+ }
1133
+ });
1134
+ const decRows = tryQuery(errors, "brain_decisions", () => allTyped(db.prepare(`SELECT id, decision, quality_score, context_task_id,
1094
1135
  strftime('%Y-%m-%dT%H:%M:%S', created_at) AS created_at
1095
1136
  FROM main.brain_decisions
1096
1137
  WHERE (quality_score IS NULL OR quality_score >= ?)
1097
1138
  ORDER BY quality_score DESC, created_at DESC
1098
- LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .25));
1099
- for (const row of decRows) nodes.push({
1100
- id: `brain:${row.id}`,
1101
- kind: "decision",
1102
- substrate: "brain",
1103
- label: row.decision.slice(0, 100),
1104
- weight: row.quality_score ?? void 0,
1105
- createdAt: row.created_at,
1106
- meta: {
1107
- context_task_id: row.context_task_id,
1108
- created_at: row.created_at
1109
- }
1110
- });
1111
- const patRows = allTyped(db.prepare(`SELECT id, pattern, type, quality_score,
1139
+ LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .25)));
1140
+ for (const row of decRows) nodes.push({
1141
+ id: `brain:${row.id}`,
1142
+ kind: "decision",
1143
+ substrate: "brain",
1144
+ label: row.decision.slice(0, 100),
1145
+ weight: row.quality_score ?? void 0,
1146
+ createdAt: row.created_at,
1147
+ meta: {
1148
+ context_task_id: row.context_task_id,
1149
+ created_at: row.created_at
1150
+ }
1151
+ });
1152
+ const patRows = tryQuery(errors, "brain_patterns", () => allTyped(db.prepare(`SELECT id, pattern, type, quality_score,
1112
1153
  strftime('%Y-%m-%dT%H:%M:%S', extracted_at) AS extracted_at
1113
1154
  FROM main.brain_patterns
1114
1155
  WHERE (quality_score IS NULL OR quality_score >= ?)
1115
1156
  ORDER BY quality_score DESC, extracted_at DESC
1116
- LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .2));
1117
- for (const row of patRows) nodes.push({
1118
- id: `brain:${row.id}`,
1119
- kind: "pattern",
1120
- substrate: "brain",
1121
- label: row.pattern.slice(0, 100),
1122
- weight: row.quality_score ?? void 0,
1123
- createdAt: row.extracted_at,
1124
- meta: {
1125
- pattern_type: row.type,
1126
- created_at: row.extracted_at
1127
- }
1128
- });
1129
- const learnRows = allTyped(db.prepare(`SELECT id, insight, quality_score,
1157
+ LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .2)));
1158
+ for (const row of patRows) nodes.push({
1159
+ id: `brain:${row.id}`,
1160
+ kind: "pattern",
1161
+ substrate: "brain",
1162
+ label: row.pattern.slice(0, 100),
1163
+ weight: row.quality_score ?? void 0,
1164
+ createdAt: row.extracted_at,
1165
+ meta: {
1166
+ pattern_type: row.type,
1167
+ created_at: row.extracted_at
1168
+ }
1169
+ });
1170
+ const learnRows = tryQuery(errors, "brain_learnings", () => allTyped(db.prepare(`SELECT id, insight, quality_score,
1130
1171
  strftime('%Y-%m-%dT%H:%M:%S', created_at) AS created_at
1131
1172
  FROM main.brain_learnings
1132
1173
  WHERE (quality_score IS NULL OR quality_score >= ?)
1133
1174
  ORDER BY quality_score DESC, created_at DESC
1134
- LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .15));
1135
- for (const row of learnRows) nodes.push({
1136
- id: `brain:${row.id}`,
1137
- kind: "learning",
1138
- substrate: "brain",
1139
- label: row.insight.slice(0, 100),
1140
- weight: row.quality_score ?? void 0,
1141
- createdAt: row.created_at,
1142
- meta: { created_at: row.created_at }
1175
+ LIMIT ?`), minWeight, Math.ceil(perSubstrateLimit * .15)));
1176
+ for (const row of learnRows) nodes.push({
1177
+ id: `brain:${row.id}`,
1178
+ kind: "learning",
1179
+ substrate: "brain",
1180
+ label: row.insight.slice(0, 100),
1181
+ weight: row.quality_score ?? void 0,
1182
+ createdAt: row.created_at,
1183
+ meta: { created_at: row.created_at }
1184
+ });
1185
+ const typeIdToBrainNodeId = /* @__PURE__ */ new Map();
1186
+ for (const n of nodes) {
1187
+ const rawId = n.id.slice(6);
1188
+ let typePrefix;
1189
+ if (n.kind === "observation") typePrefix = "observation";
1190
+ else if (n.kind === "decision") typePrefix = "decision";
1191
+ else if (n.kind === "pattern") typePrefix = "pattern";
1192
+ else typePrefix = "learning";
1193
+ typeIdToBrainNodeId.set(`${typePrefix}:${rawId}`, n.id);
1194
+ }
1195
+ const pageEdgeRows = tryQuery(errors, "brain_page_edges", () => allTyped(db.prepare(`SELECT from_id, to_id, edge_type, weight FROM main.brain_page_edges`)));
1196
+ for (const row of pageEdgeRows) {
1197
+ const sourceBrainNodeId = typeIdToBrainNodeId.get(row.from_id) ?? brainTypeIdToBrainNodeId(row.from_id);
1198
+ if (!sourceBrainNodeId) continue;
1199
+ if (isTaskId(row.to_id)) edges.push({
1200
+ source: sourceBrainNodeId,
1201
+ target: taskRefToBrainNodeId(row.to_id),
1202
+ type: row.edge_type,
1203
+ weight: row.weight ?? .5,
1204
+ substrate: "cross"
1143
1205
  });
1144
- const typeIdToBrainNodeId = /* @__PURE__ */ new Map();
1145
- for (const n of nodes) {
1146
- const rawId = n.id.slice(6);
1147
- let typePrefix;
1148
- if (n.kind === "observation") typePrefix = "observation";
1149
- else if (n.kind === "decision") typePrefix = "decision";
1150
- else if (n.kind === "pattern") typePrefix = "pattern";
1151
- else typePrefix = "learning";
1152
- typeIdToBrainNodeId.set(`${typePrefix}:${rawId}`, n.id);
1153
- }
1154
- const pageEdgeRows = allTyped(db.prepare(`SELECT from_id, to_id, edge_type, weight FROM main.brain_page_edges`));
1155
- for (const row of pageEdgeRows) {
1156
- const sourceBrainNodeId = typeIdToBrainNodeId.get(row.from_id) ?? brainTypeIdToBrainNodeId(row.from_id);
1157
- if (!sourceBrainNodeId) continue;
1158
- if (isTaskId(row.to_id)) edges.push({
1159
- source: sourceBrainNodeId,
1160
- target: taskRefToBrainNodeId(row.to_id),
1161
- type: row.edge_type,
1162
- weight: row.weight ?? .5,
1163
- substrate: "cross"
1164
- });
1165
- else if (isNexusStyleId(row.to_id)) edges.push({
1206
+ else if (isNexusStyleId(row.to_id)) edges.push({
1207
+ source: sourceBrainNodeId,
1208
+ target: `nexus:${row.to_id}`,
1209
+ type: row.edge_type,
1210
+ weight: row.weight ?? .5,
1211
+ substrate: "cross"
1212
+ });
1213
+ else {
1214
+ const targetBrainNodeId = typeIdToBrainNodeId.get(row.to_id) ?? brainTypeIdToBrainNodeId(row.to_id);
1215
+ if (targetBrainNodeId) edges.push({
1166
1216
  source: sourceBrainNodeId,
1167
- target: `nexus:${row.to_id}`,
1217
+ target: targetBrainNodeId,
1168
1218
  type: row.edge_type,
1169
1219
  weight: row.weight ?? .5,
1170
- substrate: "cross"
1220
+ substrate: "brain"
1171
1221
  });
1172
- else {
1173
- const targetBrainNodeId = typeIdToBrainNodeId.get(row.to_id) ?? brainTypeIdToBrainNodeId(row.to_id);
1174
- if (targetBrainNodeId) edges.push({
1175
- source: sourceBrainNodeId,
1176
- target: targetBrainNodeId,
1177
- type: row.edge_type,
1178
- weight: row.weight ?? .5,
1179
- substrate: "brain"
1180
- });
1181
- }
1182
1222
  }
1183
- const memLinkRows = allTyped(db.prepare(`SELECT memory_type, memory_id, task_id, link_type
1184
- FROM main.brain_memory_links`));
1185
- for (const row of memLinkRows) {
1186
- const sourceTypeId = `${row.memory_type}:${row.memory_id}`;
1187
- const sourceBrainNodeId = typeIdToBrainNodeId.get(sourceTypeId) ?? brainTypeIdToBrainNodeId(sourceTypeId);
1188
- if (!sourceBrainNodeId) continue;
1223
+ }
1224
+ const memLinkRows = tryQuery(errors, "brain_memory_links", () => allTyped(db.prepare(`SELECT memory_type, memory_id, task_id, link_type
1225
+ FROM main.brain_memory_links`)));
1226
+ for (const row of memLinkRows) {
1227
+ const sourceTypeId = `${row.memory_type}:${row.memory_id}`;
1228
+ const sourceBrainNodeId = typeIdToBrainNodeId.get(sourceTypeId) ?? brainTypeIdToBrainNodeId(sourceTypeId);
1229
+ if (!sourceBrainNodeId) continue;
1230
+ edges.push({
1231
+ source: sourceBrainNodeId,
1232
+ target: `tasks:${row.task_id}`,
1233
+ type: row.link_type,
1234
+ weight: .7,
1235
+ substrate: "cross"
1236
+ });
1237
+ }
1238
+ for (const row of obsRows) {
1239
+ if (!row.files_modified_json) continue;
1240
+ let filePaths;
1241
+ try {
1242
+ filePaths = JSON.parse(row.files_modified_json);
1243
+ } catch {
1244
+ continue;
1245
+ }
1246
+ if (!Array.isArray(filePaths)) continue;
1247
+ const sourceBrainNodeId = `brain:${row.id}`;
1248
+ for (const rawPath of filePaths) {
1249
+ if (typeof rawPath !== "string" || rawPath.length === 0) continue;
1189
1250
  edges.push({
1190
1251
  source: sourceBrainNodeId,
1191
- target: `tasks:${row.task_id}`,
1192
- type: row.link_type,
1193
- weight: .7,
1252
+ target: `nexus:${rawPath}`,
1253
+ type: "modified_by",
1254
+ weight: .6,
1194
1255
  substrate: "cross"
1195
1256
  });
1196
1257
  }
1197
- for (const row of obsRows) {
1198
- if (!row.files_modified_json) continue;
1199
- let filePaths;
1200
- try {
1201
- filePaths = JSON.parse(row.files_modified_json);
1202
- } catch {
1203
- continue;
1204
- }
1205
- if (!Array.isArray(filePaths)) continue;
1206
- const sourceBrainNodeId = `brain:${row.id}`;
1207
- for (const rawPath of filePaths) {
1208
- if (typeof rawPath !== "string" || rawPath.length === 0) continue;
1209
- edges.push({
1210
- source: sourceBrainNodeId,
1211
- target: `nexus:${rawPath}`,
1212
- type: "modified_by",
1213
- weight: .6,
1214
- substrate: "cross"
1215
- });
1216
- }
1217
- }
1218
- for (const dec of decRows) if (dec.context_task_id) edges.push({
1219
- source: `brain:${dec.id}`,
1220
- target: `tasks:${dec.context_task_id}`,
1221
- type: "applies_to",
1222
- weight: .8,
1223
- substrate: "cross"
1224
- });
1225
- } catch {}
1226
- });
1227
- return {
1228
- nodes,
1229
- edges
1230
- };
1258
+ }
1259
+ for (const dec of decRows) if (dec.context_task_id) edges.push({
1260
+ source: `brain:${dec.id}`,
1261
+ target: `tasks:${dec.context_task_id}`,
1262
+ type: "applies_to",
1263
+ weight: .8,
1264
+ substrate: "cross"
1265
+ });
1266
+ }, (message) => errors.push(message));
1267
+ return substrateResult(nodes, edges, errors);
1231
1268
  }
1232
1269
  //#endregion
1233
1270
  //#region ../brain/dist/src/adapters/conduit.js
@@ -1256,56 +1293,52 @@ function getConduitSubstrate(options = {}) {
1256
1293
  const perSubstrateLimit = Math.ceil((options.limit ?? 500) / 5);
1257
1294
  const nodes = [];
1258
1295
  const edges = [];
1296
+ const errors = [];
1259
1297
  readProjectStore(ctx, (db) => {
1260
- try {
1261
- const msgRows = allTyped(db.prepare(`SELECT id, content, from_agent_id, to_agent_id,
1298
+ const msgRows = tryQuery(errors, "conduit_messages", () => allTyped(db.prepare(`SELECT id, content, from_agent_id, to_agent_id,
1262
1299
  strftime('%Y-%m-%dT%H:%M:%S', created_at) AS created_at, conversation_id
1263
1300
  FROM main.conduit_messages
1264
1301
  ORDER BY created_at DESC
1265
- LIMIT ?`), perSubstrateLimit);
1266
- const agentPairs = /* @__PURE__ */ new Map();
1267
- for (const row of msgRows) {
1268
- const label = row.content.length > 80 ? `${row.content.slice(0, 80)}…` : row.content;
1269
- nodes.push({
1270
- id: `conduit:${row.id}`,
1271
- kind: "message",
1272
- substrate: "conduit",
1273
- label,
1274
- createdAt: row.created_at,
1275
- meta: {
1276
- from_agent_id: row.from_agent_id,
1277
- to_agent_id: row.to_agent_id,
1278
- conversation_id: row.conversation_id,
1279
- created_at: row.created_at
1280
- }
1281
- });
1282
- if (row.from_agent_id && row.to_agent_id) {
1283
- const key = `${row.from_agent_id}→${row.to_agent_id}`;
1284
- const existing = agentPairs.get(key);
1285
- if (existing) existing.count++;
1286
- else agentPairs.set(key, {
1287
- count: 1,
1288
- from: row.from_agent_id,
1289
- to: row.to_agent_id
1290
- });
1302
+ LIMIT ?`), perSubstrateLimit));
1303
+ const agentPairs = /* @__PURE__ */ new Map();
1304
+ for (const row of msgRows) {
1305
+ const label = row.content.length > 80 ? `${row.content.slice(0, 80)}…` : row.content;
1306
+ nodes.push({
1307
+ id: `conduit:${row.id}`,
1308
+ kind: "message",
1309
+ substrate: "conduit",
1310
+ label,
1311
+ createdAt: row.created_at,
1312
+ meta: {
1313
+ from_agent_id: row.from_agent_id,
1314
+ to_agent_id: row.to_agent_id,
1315
+ conversation_id: row.conversation_id,
1316
+ created_at: row.created_at
1291
1317
  }
1292
- }
1293
- for (const [, pair] of agentPairs) {
1294
- const weight = Math.min(1, pair.count / 10);
1295
- edges.push({
1296
- source: `agent-registry:${pair.from}`,
1297
- target: `agent-registry:${pair.to}`,
1298
- type: "messages",
1299
- weight,
1300
- substrate: "cross"
1318
+ });
1319
+ if (row.from_agent_id && row.to_agent_id) {
1320
+ const key = `${row.from_agent_id}→${row.to_agent_id}`;
1321
+ const existing = agentPairs.get(key);
1322
+ if (existing) existing.count++;
1323
+ else agentPairs.set(key, {
1324
+ count: 1,
1325
+ from: row.from_agent_id,
1326
+ to: row.to_agent_id
1301
1327
  });
1302
1328
  }
1303
- } catch {}
1304
- });
1305
- return {
1306
- nodes,
1307
- edges
1308
- };
1329
+ }
1330
+ for (const [, pair] of agentPairs) {
1331
+ const weight = Math.min(1, pair.count / 10);
1332
+ edges.push({
1333
+ source: `agent-registry:${pair.from}`,
1334
+ target: `agent-registry:${pair.to}`,
1335
+ type: "messages",
1336
+ weight,
1337
+ substrate: "cross"
1338
+ });
1339
+ }
1340
+ }, (message) => errors.push(message));
1341
+ return substrateResult(nodes, edges, errors);
1309
1342
  }
1310
1343
  //#endregion
1311
1344
  //#region ../brain/dist/src/adapters/nexus.js
@@ -1339,9 +1372,9 @@ function getNexusSubstrate(options = {}) {
1339
1372
  const perSubstrateLimit = Math.ceil((options.limit ?? 500) / 5);
1340
1373
  const nodes = [];
1341
1374
  const edges = [];
1375
+ const errors = [];
1342
1376
  readProjectStore(ctx, (db) => {
1343
- try {
1344
- const nodeRows = allTyped(db.prepare(`SELECT n.id, n.kind, COALESCE(n.name, n.label) AS name, n.indexed_at,
1377
+ const nodeRows = tryQuery(errors, "nexus_nodes", () => allTyped(db.prepare(`SELECT n.id, n.kind, COALESCE(n.name, n.label) AS name, n.indexed_at,
1345
1378
  COUNT(r.target_id) AS in_degree
1346
1379
  FROM main.nexus_nodes n
1347
1380
  LEFT JOIN main.nexus_relations r ON r.target_id = n.id
@@ -1351,40 +1384,36 @@ function getNexusSubstrate(options = {}) {
1351
1384
  )
1352
1385
  GROUP BY n.id
1353
1386
  ORDER BY in_degree DESC
1354
- LIMIT ?`), perSubstrateLimit);
1355
- for (const row of nodeRows) nodes.push({
1356
- id: `nexus:${row.id}`,
1357
- kind: mapKind(row.kind),
1358
- substrate: "nexus",
1359
- label: row.name,
1360
- weight: row.in_degree > 0 ? Math.min(1, row.in_degree / 50) : void 0,
1361
- createdAt: row.indexed_at ?? null,
1362
- meta: {
1363
- nexus_kind: row.kind,
1364
- in_degree: row.in_degree
1365
- }
1366
- });
1367
- const nodeIds = new Set(nodes.map((n) => n.id));
1368
- const rawIds = new Set([...nodeIds].map((id) => id.replace(/^nexus:/, "")));
1369
- const placeholders = [...rawIds].map(() => "?").join(",");
1370
- if (rawIds.size === 0) return;
1371
- const relRows = allTyped(db.prepare(`SELECT source_id, target_id, type, confidence
1387
+ LIMIT ?`), perSubstrateLimit));
1388
+ for (const row of nodeRows) nodes.push({
1389
+ id: `nexus:${row.id}`,
1390
+ kind: mapKind(row.kind),
1391
+ substrate: "nexus",
1392
+ label: row.name,
1393
+ weight: row.in_degree > 0 ? Math.min(1, row.in_degree / 50) : void 0,
1394
+ createdAt: row.indexed_at ?? null,
1395
+ meta: {
1396
+ nexus_kind: row.kind,
1397
+ in_degree: row.in_degree
1398
+ }
1399
+ });
1400
+ const nodeIds = new Set(nodes.map((n) => n.id));
1401
+ const rawIds = new Set([...nodeIds].map((id) => id.replace(/^nexus:/, "")));
1402
+ const placeholders = [...rawIds].map(() => "?").join(",");
1403
+ if (rawIds.size === 0) return;
1404
+ const relRows = tryQuery(errors, "nexus_relations", () => allTyped(db.prepare(`SELECT source_id, target_id, type, confidence
1372
1405
  FROM main.nexus_relations
1373
1406
  WHERE source_id IN (${placeholders})
1374
- AND target_id IN (${placeholders})`), ...rawIds, ...rawIds);
1375
- for (const row of relRows) edges.push({
1376
- source: `nexus:${row.source_id}`,
1377
- target: `nexus:${row.target_id}`,
1378
- type: row.type,
1379
- weight: row.confidence ?? .5,
1380
- substrate: "nexus"
1381
- });
1382
- } catch {}
1383
- });
1384
- return {
1385
- nodes,
1386
- edges
1387
- };
1407
+ AND target_id IN (${placeholders})`), ...rawIds, ...rawIds));
1408
+ for (const row of relRows) edges.push({
1409
+ source: `nexus:${row.source_id}`,
1410
+ target: `nexus:${row.target_id}`,
1411
+ type: row.type,
1412
+ weight: row.confidence ?? .5,
1413
+ substrate: "nexus"
1414
+ });
1415
+ }, (message) => errors.push(message));
1416
+ return substrateResult(nodes, edges, errors);
1388
1417
  }
1389
1418
  //#endregion
1390
1419
  //#region ../brain/dist/src/adapters/tasks.js
@@ -1422,9 +1451,9 @@ function getTasksSubstrate(options = {}) {
1422
1451
  const minWeight = options.minWeight ?? 0;
1423
1452
  const nodes = [];
1424
1453
  const edges = [];
1454
+ const errors = [];
1425
1455
  readProjectStore(ctx, (db) => {
1426
- try {
1427
- const taskRows = allTyped(db.prepare(`SELECT id, title, status, priority, type, parent_id, created_at
1456
+ const taskRows = tryQuery(errors, "tasks_tasks", () => allTyped(db.prepare(`SELECT id, title, status, priority, type, parent_id, created_at
1428
1457
  FROM main.tasks_tasks
1429
1458
  WHERE status NOT IN ('archived', 'cancelled')
1430
1459
  ORDER BY
@@ -1432,87 +1461,83 @@ function getTasksSubstrate(options = {}) {
1432
1461
  WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 ELSE 3
1433
1462
  END,
1434
1463
  created_at DESC
1435
- LIMIT ?`), Math.ceil(perSubstrateLimit * .8));
1436
- const taskIds = /* @__PURE__ */ new Set();
1437
- for (const row of taskRows) {
1438
- const weight = priorityWeight(row.priority);
1439
- if (weight < minWeight) continue;
1440
- taskIds.add(row.id);
1441
- nodes.push({
1442
- id: `tasks:${row.id}`,
1443
- kind: "task",
1444
- substrate: "tasks",
1445
- label: row.title,
1446
- weight,
1447
- createdAt: row.created_at,
1448
- meta: {
1449
- status: row.status,
1450
- priority: row.priority,
1451
- type: row.type,
1452
- parent_id: row.parent_id,
1453
- created_at: row.created_at
1454
- }
1455
- });
1456
- }
1457
- const sessionRows = allTyped(db.prepare(`SELECT id, status, started_at, ended_at
1464
+ LIMIT ?`), Math.ceil(perSubstrateLimit * .8)));
1465
+ const taskIds = /* @__PURE__ */ new Set();
1466
+ for (const row of taskRows) {
1467
+ const weight = priorityWeight(row.priority);
1468
+ if (weight < minWeight) continue;
1469
+ taskIds.add(row.id);
1470
+ nodes.push({
1471
+ id: `tasks:${row.id}`,
1472
+ kind: "task",
1473
+ substrate: "tasks",
1474
+ label: row.title,
1475
+ weight,
1476
+ createdAt: row.created_at,
1477
+ meta: {
1478
+ status: row.status,
1479
+ priority: row.priority,
1480
+ type: row.type,
1481
+ parent_id: row.parent_id,
1482
+ created_at: row.created_at
1483
+ }
1484
+ });
1485
+ }
1486
+ const sessionRows = tryQuery(errors, "tasks_sessions", () => allTyped(db.prepare(`SELECT id, status, started_at, ended_at
1458
1487
  FROM main.tasks_sessions
1459
1488
  ORDER BY started_at DESC
1460
- LIMIT ?`), Math.ceil(perSubstrateLimit * .2));
1461
- const sessionIds = /* @__PURE__ */ new Set();
1462
- for (const row of sessionRows) {
1463
- sessionIds.add(row.id);
1464
- nodes.push({
1465
- id: `tasks:${row.id}`,
1466
- kind: "session",
1467
- substrate: "tasks",
1468
- label: `Session ${row.id.slice(-8)}`,
1469
- weight: row.status === "active" ? .9 : .4,
1470
- createdAt: row.started_at,
1471
- meta: {
1472
- status: row.status,
1473
- started_at: row.started_at,
1474
- ended_at: row.ended_at
1475
- }
1476
- });
1477
- }
1478
- for (const row of taskRows) if (row.parent_id && taskIds.has(row.parent_id)) edges.push({
1479
- source: `tasks:${row.parent_id}`,
1480
- target: `tasks:${row.id}`,
1481
- type: "parent_of",
1482
- weight: .9,
1483
- substrate: "tasks"
1489
+ LIMIT ?`), Math.ceil(perSubstrateLimit * .2)));
1490
+ const sessionIds = /* @__PURE__ */ new Set();
1491
+ for (const row of sessionRows) {
1492
+ sessionIds.add(row.id);
1493
+ nodes.push({
1494
+ id: `tasks:${row.id}`,
1495
+ kind: "session",
1496
+ substrate: "tasks",
1497
+ label: `Session ${row.id.slice(-8)}`,
1498
+ weight: row.status === "active" ? .9 : .4,
1499
+ createdAt: row.started_at,
1500
+ meta: {
1501
+ status: row.status,
1502
+ started_at: row.started_at,
1503
+ ended_at: row.ended_at
1504
+ }
1484
1505
  });
1485
- if (taskIds.size > 0) {
1486
- const placeholders = [...taskIds].map(() => "?").join(",");
1487
- const relRows = allTyped(db.prepare(`SELECT task_id, related_to, relation_type
1506
+ }
1507
+ for (const row of taskRows) if (row.parent_id && taskIds.has(row.parent_id)) edges.push({
1508
+ source: `tasks:${row.parent_id}`,
1509
+ target: `tasks:${row.id}`,
1510
+ type: "parent_of",
1511
+ weight: .9,
1512
+ substrate: "tasks"
1513
+ });
1514
+ if (taskIds.size > 0) {
1515
+ const placeholders = [...taskIds].map(() => "?").join(",");
1516
+ const relRows = tryQuery(errors, "tasks_task_relations", () => allTyped(db.prepare(`SELECT task_id, related_to, relation_type
1488
1517
  FROM main.tasks_task_relations
1489
1518
  WHERE task_id IN (${placeholders})
1490
- AND related_to IN (${placeholders})`), ...taskIds, ...taskIds);
1491
- for (const row of relRows) edges.push({
1492
- source: `tasks:${row.task_id}`,
1493
- target: `tasks:${row.related_to}`,
1494
- type: row.relation_type,
1495
- weight: .7,
1496
- substrate: "tasks"
1497
- });
1498
- const depRows = allTyped(db.prepare(`SELECT task_id, depends_on
1519
+ AND related_to IN (${placeholders})`), ...taskIds, ...taskIds));
1520
+ for (const row of relRows) edges.push({
1521
+ source: `tasks:${row.task_id}`,
1522
+ target: `tasks:${row.related_to}`,
1523
+ type: row.relation_type,
1524
+ weight: .7,
1525
+ substrate: "tasks"
1526
+ });
1527
+ const depRows = tryQuery(errors, "tasks_task_dependencies", () => allTyped(db.prepare(`SELECT task_id, depends_on
1499
1528
  FROM main.tasks_task_dependencies
1500
1529
  WHERE task_id IN (${placeholders})
1501
- AND depends_on IN (${placeholders})`), ...taskIds, ...taskIds);
1502
- for (const row of depRows) edges.push({
1503
- source: `tasks:${row.task_id}`,
1504
- target: `tasks:${row.depends_on}`,
1505
- type: "depends_on",
1506
- weight: .85,
1507
- substrate: "tasks"
1508
- });
1509
- }
1510
- } catch {}
1511
- });
1512
- return {
1513
- nodes,
1514
- edges
1515
- };
1530
+ AND depends_on IN (${placeholders})`), ...taskIds, ...taskIds));
1531
+ for (const row of depRows) edges.push({
1532
+ source: `tasks:${row.task_id}`,
1533
+ target: `tasks:${row.depends_on}`,
1534
+ type: "depends_on",
1535
+ weight: .85,
1536
+ substrate: "tasks"
1537
+ });
1538
+ }
1539
+ }, (message) => errors.push(message));
1540
+ return substrateResult(nodes, edges, errors);
1516
1541
  }
1517
1542
  //#endregion
1518
1543
  //#region ../brain/dist/src/adapters/index.js
@@ -1544,9 +1569,11 @@ var ADAPTER_MAP = {
1544
1569
  * @param loadedNodeIds - Set of already-loaded node IDs (substrate-prefixed).
1545
1570
  * @param edges - All edges collected from substrates (may reference unloaded targets).
1546
1571
  * @param ctx - Project whose `cleo.db` code graph resolves nexus stubs.
1572
+ * @param errors - Collects a failed nexus stub read, so the stubs it would
1573
+ * have recovered are never dropped silently (T14656).
1547
1574
  * @returns Array of stub BrainNode objects for missing targets.
1548
1575
  */
1549
- function loadStubNodesForEdgeTargets(loadedNodeIds, edges, ctx) {
1576
+ function loadStubNodesForEdgeTargets(loadedNodeIds, edges, ctx, errors) {
1550
1577
  const missingTargetIds = /* @__PURE__ */ new Set();
1551
1578
  for (const edge of edges) if (!loadedNodeIds.has(edge.target)) missingTargetIds.add(edge.target);
1552
1579
  if (missingTargetIds.size === 0) return [];
@@ -1568,29 +1595,27 @@ function loadStubNodesForEdgeTargets(loadedNodeIds, edges, ctx) {
1568
1595
  const stubs = [];
1569
1596
  const nexusStubs = stubsBySubstrate.get("nexus");
1570
1597
  if (nexusStubs && nexusStubs.length > 0) readProjectStore(ctx, (db) => {
1571
- try {
1572
- const rawNexusIds = nexusStubs.map((id) => id.replace(/^nexus:/, ""));
1573
- const placeholders = rawNexusIds.map(() => "?").join(",");
1574
- const stubRows = allTyped(db.prepare(`SELECT id, kind, COALESCE(name, label) AS name
1598
+ const rawNexusIds = nexusStubs.map((id) => id.replace(/^nexus:/, ""));
1599
+ const placeholders = rawNexusIds.map(() => "?").join(",");
1600
+ const stubRows = tryQuery(errors, "nexus_nodes (stubs)", () => allTyped(db.prepare(`SELECT id, kind, COALESCE(name, label) AS name
1575
1601
  FROM main.nexus_nodes
1576
- WHERE id IN (${placeholders})`), ...rawNexusIds);
1577
- for (const row of stubRows) {
1578
- const kind = row.kind === "file" || row.kind === "folder" || row.kind === "module" ? "file" : "symbol";
1579
- stubs.push({
1580
- id: `nexus:${row.id}`,
1581
- kind,
1582
- substrate: "nexus",
1583
- label: row.name,
1584
- weight: void 0,
1585
- createdAt: null,
1586
- meta: {
1587
- nexus_kind: row.kind,
1588
- isStub: true
1589
- }
1590
- });
1591
- }
1592
- } catch {}
1593
- });
1602
+ WHERE id IN (${placeholders})`), ...rawNexusIds));
1603
+ for (const row of stubRows) {
1604
+ const kind = row.kind === "file" || row.kind === "folder" || row.kind === "module" ? "file" : "symbol";
1605
+ stubs.push({
1606
+ id: `nexus:${row.id}`,
1607
+ kind,
1608
+ substrate: "nexus",
1609
+ label: row.name,
1610
+ weight: void 0,
1611
+ createdAt: null,
1612
+ meta: {
1613
+ nexus_kind: row.kind,
1614
+ isStub: true
1615
+ }
1616
+ });
1617
+ }
1618
+ }, (message) => errors.push(message));
1594
1619
  for (const [substrate, nodeIds] of stubsBySubstrate) {
1595
1620
  if (substrate === "nexus") continue;
1596
1621
  for (const nodeId of nodeIds) {
@@ -1621,6 +1646,10 @@ function loadStubNodesForEdgeTargets(loadedNodeIds, edges, ctx) {
1621
1646
  * that would otherwise be silently dropped.
1622
1647
  *
1623
1648
  * Stub nodes carry `meta.isStub: true` for optional UI differentiation.
1649
+ * A substrate whose read failed is named in `errors` with the SQL error, so a
1650
+ * broken query never passes for an empty substrate (T14647). Each query is
1651
+ * caught on its own, so one failure never skips a substrate's other queries;
1652
+ * an unopenable store and a failed nexus stub read are reported too (T14656).
1624
1653
  *
1625
1654
  * @param options - Query options forwarded to each substrate adapter.
1626
1655
  * @returns Merged BrainGraph across all requested substrates, with stub nodes for unresolved edge targets.
@@ -1632,13 +1661,15 @@ function getAllSubstrates(options = {}) {
1632
1661
  const allEdges = [];
1633
1662
  const nodeCounts = Object.fromEntries(ALL_SUBSTRATES.map((s) => [s, 0]));
1634
1663
  const edgeCounts = Object.fromEntries([...ALL_SUBSTRATES, "cross"].map((s) => [s, 0]));
1664
+ const errors = {};
1635
1665
  for (const substrate of substrates) {
1636
1666
  const adapter = ADAPTER_MAP[substrate];
1637
1667
  if (!adapter) continue;
1638
- const { nodes, edges } = adapter({
1668
+ const { nodes, edges, error } = adapter({
1639
1669
  ...options,
1640
1670
  limit
1641
1671
  });
1672
+ if (error !== void 0) errors[substrate] = error;
1642
1673
  allNodes.push(...nodes);
1643
1674
  allEdges.push(...edges);
1644
1675
  nodeCounts[substrate] = nodes.length;
@@ -1651,7 +1682,12 @@ function getAllSubstrates(options = {}) {
1651
1682
  uniqueNodes.push(node);
1652
1683
  }
1653
1684
  const requestedSubstrateSet = options.substrates ? new Set(options.substrates) : null;
1654
- const stubNodes = loadStubNodesForEdgeTargets(seenIds, allEdges, options.projectCtx ?? resolveDefaultProjectContext());
1685
+ const stubErrors = [];
1686
+ const stubNodes = loadStubNodesForEdgeTargets(seenIds, allEdges, options.projectCtx ?? resolveDefaultProjectContext(), stubErrors);
1687
+ for (const message of stubErrors) {
1688
+ if (errors.nexus?.includes(message)) continue;
1689
+ errors.nexus = errors.nexus === void 0 ? message : `${errors.nexus}; ${message}`;
1690
+ }
1655
1691
  for (const stubNode of stubNodes) if (!seenIds.has(stubNode.id)) {
1656
1692
  if (requestedSubstrateSet && !requestedSubstrateSet.has(stubNode.substrate)) continue;
1657
1693
  seenIds.add(stubNode.id);
@@ -1665,9 +1701,10 @@ function getAllSubstrates(options = {}) {
1665
1701
  nodes: nodeCounts,
1666
1702
  edges: edgeCounts
1667
1703
  },
1668
- truncated
1704
+ truncated,
1705
+ ...Object.keys(errors).length > 0 ? { errors } : {}
1669
1706
  };
1670
1707
  }
1671
1708
 
1672
1709
  export { getAllSubstrates as g, readProjectStore as r };
1673
- //# sourceMappingURL=src-DMQE8esV.js.map
1710
+ //# sourceMappingURL=src-DHIA6U44.js.map