@cleocode/core 2026.9.19 → 2026.9.21

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 (863) hide show
  1. package/dist/adapters/discovery.d.ts.map +1 -1
  2. package/dist/adapters/discovery.js +3 -10
  3. package/dist/adapters/discovery.js.map +1 -1
  4. package/dist/adrs/link-pipeline.js +2 -2
  5. package/dist/adrs/link-pipeline.js.map +1 -1
  6. package/dist/adrs/parse.js +3 -3
  7. package/dist/adrs/parse.js.map +1 -1
  8. package/dist/agents/invoke-meta-agent.d.ts.map +1 -1
  9. package/dist/agents/invoke-meta-agent.js +8 -4
  10. package/dist/agents/invoke-meta-agent.js.map +1 -1
  11. package/dist/bootstrap.d.ts +5 -1
  12. package/dist/bootstrap.d.ts.map +1 -1
  13. package/dist/bootstrap.js +41 -21
  14. package/dist/bootstrap.js.map +1 -1
  15. package/dist/cloud/crypto.d.ts +47 -0
  16. package/dist/cloud/crypto.d.ts.map +1 -0
  17. package/dist/cloud/crypto.js +223 -0
  18. package/dist/cloud/crypto.js.map +1 -0
  19. package/dist/cloud/http.d.ts +52 -0
  20. package/dist/cloud/http.d.ts.map +1 -0
  21. package/dist/cloud/http.js +98 -0
  22. package/dist/cloud/http.js.map +1 -0
  23. package/dist/cloud/index.d.ts +19 -0
  24. package/dist/cloud/index.d.ts.map +1 -0
  25. package/dist/cloud/index.js +19 -0
  26. package/dist/cloud/index.js.map +1 -0
  27. package/dist/cloud/journal.d.ts +169 -0
  28. package/dist/cloud/journal.d.ts.map +1 -0
  29. package/dist/cloud/journal.js +428 -0
  30. package/dist/cloud/journal.js.map +1 -0
  31. package/dist/cloud/keys.d.ts +213 -0
  32. package/dist/cloud/keys.d.ts.map +1 -0
  33. package/dist/cloud/keys.js +362 -0
  34. package/dist/cloud/keys.js.map +1 -0
  35. package/dist/cloud/manifest-check.d.ts +36 -0
  36. package/dist/cloud/manifest-check.d.ts.map +1 -0
  37. package/dist/cloud/manifest-check.js +70 -0
  38. package/dist/cloud/manifest-check.js.map +1 -0
  39. package/dist/cloud/projects.d.ts +13 -0
  40. package/dist/cloud/projects.d.ts.map +1 -0
  41. package/dist/cloud/projects.js +11 -0
  42. package/dist/cloud/projects.js.map +1 -0
  43. package/dist/cloud/signing.d.ts +105 -0
  44. package/dist/cloud/signing.d.ts.map +1 -0
  45. package/dist/cloud/signing.js +117 -0
  46. package/dist/cloud/signing.js.map +1 -0
  47. package/dist/cloud/streams.d.ts +6 -0
  48. package/dist/cloud/streams.d.ts.map +1 -0
  49. package/dist/cloud/streams.js +5 -0
  50. package/dist/cloud/streams.js.map +1 -0
  51. package/dist/decide/audit.d.ts +131 -0
  52. package/dist/decide/audit.d.ts.map +1 -0
  53. package/dist/decide/audit.js +98 -0
  54. package/dist/decide/audit.js.map +1 -0
  55. package/dist/decide/budget.d.ts +91 -0
  56. package/dist/decide/budget.d.ts.map +1 -0
  57. package/dist/decide/budget.js +194 -0
  58. package/dist/decide/budget.js.map +1 -0
  59. package/dist/decide/cache.d.ts +49 -0
  60. package/dist/decide/cache.d.ts.map +1 -0
  61. package/dist/decide/cache.js +87 -0
  62. package/dist/decide/cache.js.map +1 -0
  63. package/dist/decide/client.d.ts +103 -0
  64. package/dist/decide/client.d.ts.map +1 -0
  65. package/dist/decide/client.js +262 -0
  66. package/dist/decide/client.js.map +1 -0
  67. package/dist/decide/credentials.d.ts +159 -0
  68. package/dist/decide/credentials.d.ts.map +1 -0
  69. package/dist/decide/credentials.js +383 -0
  70. package/dist/decide/credentials.js.map +1 -0
  71. package/dist/decide/index.d.ts +18 -0
  72. package/dist/decide/index.d.ts.map +1 -0
  73. package/dist/decide/index.js +18 -0
  74. package/dist/decide/index.js.map +1 -0
  75. package/dist/decide/jev-wire.d.ts +155 -0
  76. package/dist/decide/jev-wire.d.ts.map +1 -0
  77. package/dist/decide/jev-wire.js +420 -0
  78. package/dist/decide/jev-wire.js.map +1 -0
  79. package/dist/decide/operations.d.ts +152 -0
  80. package/dist/decide/operations.d.ts.map +1 -0
  81. package/dist/decide/operations.js +199 -0
  82. package/dist/decide/operations.js.map +1 -0
  83. package/dist/decide/provider.d.ts +90 -0
  84. package/dist/decide/provider.d.ts.map +1 -0
  85. package/dist/decide/provider.js +43 -0
  86. package/dist/decide/provider.js.map +1 -0
  87. package/dist/decide/site.d.ts +148 -0
  88. package/dist/decide/site.d.ts.map +1 -0
  89. package/dist/decide/site.js +181 -0
  90. package/dist/decide/site.js.map +1 -0
  91. package/dist/decide/transport.d.ts +67 -0
  92. package/dist/decide/transport.d.ts.map +1 -0
  93. package/dist/decide/transport.js +350 -0
  94. package/dist/decide/transport.js.map +1 -0
  95. package/dist/docs/export-document.js +5908 -2436
  96. package/dist/docs/export-document.js.map +3 -3
  97. package/dist/docs/index.d.ts +2 -2
  98. package/dist/docs/index.d.ts.map +1 -1
  99. package/dist/docs/index.js +1 -1
  100. package/dist/docs/index.js.map +1 -1
  101. package/dist/docs/projection.d.ts.map +1 -1
  102. package/dist/docs/projection.js +2 -3
  103. package/dist/docs/projection.js.map +1 -1
  104. package/dist/docs/publish-pr.d.ts +69 -1
  105. package/dist/docs/publish-pr.d.ts.map +1 -1
  106. package/dist/docs/publish-pr.js +112 -10
  107. package/dist/docs/publish-pr.js.map +1 -1
  108. package/dist/doctor/db-substrate.d.ts +13 -8
  109. package/dist/doctor/db-substrate.d.ts.map +1 -1
  110. package/dist/doctor/db-substrate.js +39 -26
  111. package/dist/doctor/db-substrate.js.map +1 -1
  112. package/dist/doctor/index.d.ts +2 -0
  113. package/dist/doctor/index.d.ts.map +1 -1
  114. package/dist/doctor/index.js +1 -0
  115. package/dist/doctor/index.js.map +1 -1
  116. package/dist/doctor/knowledge.d.ts.map +1 -1
  117. package/dist/doctor/knowledge.js +5 -15
  118. package/dist/doctor/knowledge.js.map +1 -1
  119. package/dist/doctor/nexus-schema-residency.d.ts +1 -1
  120. package/dist/doctor/nexus-schema-residency.d.ts.map +1 -1
  121. package/dist/doctor/nexus-schema-residency.js +3 -0
  122. package/dist/doctor/nexus-schema-residency.js.map +1 -1
  123. package/dist/doctor/project-identity.d.ts +44 -1
  124. package/dist/doctor/project-identity.d.ts.map +1 -1
  125. package/dist/doctor/project-identity.js +237 -10
  126. package/dist/doctor/project-identity.js.map +1 -1
  127. package/dist/doctor/projects.d.ts +170 -0
  128. package/dist/doctor/projects.d.ts.map +1 -0
  129. package/dist/doctor/projects.js +1075 -0
  130. package/dist/doctor/projects.js.map +1 -0
  131. package/dist/doctor/twin-collapse.d.ts +97 -0
  132. package/dist/doctor/twin-collapse.d.ts.map +1 -0
  133. package/dist/doctor/twin-collapse.js +168 -0
  134. package/dist/doctor/twin-collapse.js.map +1 -0
  135. package/dist/doctor/worktree-orphans.d.ts.map +1 -1
  136. package/dist/doctor/worktree-orphans.js +13 -29
  137. package/dist/doctor/worktree-orphans.js.map +1 -1
  138. package/dist/doctor/worktree-stores.d.ts +128 -0
  139. package/dist/doctor/worktree-stores.d.ts.map +1 -0
  140. package/dist/doctor/worktree-stores.js +374 -0
  141. package/dist/doctor/worktree-stores.js.map +1 -0
  142. package/dist/engine/engine-ops.d.ts.map +1 -1
  143. package/dist/engine/engine-ops.js +59 -23
  144. package/dist/engine/engine-ops.js.map +1 -1
  145. package/dist/error-catalog.d.ts.map +1 -1
  146. package/dist/error-catalog.js +21 -0
  147. package/dist/error-catalog.js.map +1 -1
  148. package/dist/error-registry.d.ts.map +1 -1
  149. package/dist/error-registry.js +40 -0
  150. package/dist/error-registry.js.map +1 -1
  151. package/dist/gc/cleanup.d.ts.map +1 -1
  152. package/dist/gc/cleanup.js +32 -19
  153. package/dist/gc/cleanup.js.map +1 -1
  154. package/dist/git/bounded-git.d.ts +170 -0
  155. package/dist/git/bounded-git.d.ts.map +1 -0
  156. package/dist/git/bounded-git.js +371 -0
  157. package/dist/git/bounded-git.js.map +1 -0
  158. package/dist/git/work-tree.d.ts +20 -0
  159. package/dist/git/work-tree.d.ts.map +1 -1
  160. package/dist/git/work-tree.js +20 -2
  161. package/dist/git/work-tree.js.map +1 -1
  162. package/dist/hooks/handlers/session-hooks.d.ts +11 -26
  163. package/dist/hooks/handlers/session-hooks.d.ts.map +1 -1
  164. package/dist/hooks/handlers/session-hooks.js +18 -47
  165. package/dist/hooks/handlers/session-hooks.js.map +1 -1
  166. package/dist/hooks/payload-schemas.d.ts +2 -2
  167. package/dist/index.d.ts +6 -5
  168. package/dist/index.d.ts.map +1 -1
  169. package/dist/index.js +5 -3
  170. package/dist/index.js.map +1 -1
  171. package/dist/init/engine-ops.d.ts.map +1 -1
  172. package/dist/init/engine-ops.js +23 -1
  173. package/dist/init/engine-ops.js.map +1 -1
  174. package/dist/init.d.ts +158 -1
  175. package/dist/init.d.ts.map +1 -1
  176. package/dist/init.js +535 -44
  177. package/dist/init.js.map +1 -1
  178. package/dist/injection.d.ts +55 -0
  179. package/dist/injection.d.ts.map +1 -1
  180. package/dist/injection.js +102 -6
  181. package/dist/injection.js.map +1 -1
  182. package/dist/internal.d.ts +9 -5
  183. package/dist/internal.d.ts.map +1 -1
  184. package/dist/internal.js +8 -4
  185. package/dist/internal.js.map +1 -1
  186. package/dist/issue/diagnostics.d.ts.map +1 -1
  187. package/dist/issue/diagnostics.js +2 -1
  188. package/dist/issue/diagnostics.js.map +1 -1
  189. package/dist/lib/concurrency.d.ts +25 -0
  190. package/dist/lib/concurrency.d.ts.map +1 -0
  191. package/dist/lib/concurrency.js +43 -0
  192. package/dist/lib/concurrency.js.map +1 -0
  193. package/dist/lib/index.d.ts +1 -0
  194. package/dist/lib/index.d.ts.map +1 -1
  195. package/dist/lib/index.js +1 -0
  196. package/dist/lib/index.js.map +1 -1
  197. package/dist/lifecycle/engine-ops.d.ts.map +1 -1
  198. package/dist/lifecycle/engine-ops.js +4 -2
  199. package/dist/lifecycle/engine-ops.js.map +1 -1
  200. package/dist/lifecycle/stage-guidance.d.ts +5 -0
  201. package/dist/lifecycle/stage-guidance.d.ts.map +1 -1
  202. package/dist/lifecycle/stage-guidance.js +14 -4
  203. package/dist/lifecycle/stage-guidance.js.map +1 -1
  204. package/dist/llm/catalog-cache.d.ts +3 -2
  205. package/dist/llm/catalog-cache.d.ts.map +1 -1
  206. package/dist/llm/catalog-cache.js +5 -5
  207. package/dist/llm/catalog-cache.js.map +1 -1
  208. package/dist/llm/credentials.d.ts +4 -4
  209. package/dist/llm/credentials.js +6 -6
  210. package/dist/llm/credentials.js.map +1 -1
  211. package/dist/llm/plugin-facade.js +4312 -1798
  212. package/dist/llm/plugin-facade.js.map +3 -3
  213. package/dist/llm/stable-device-id.d.ts.map +1 -1
  214. package/dist/llm/stable-device-id.js +3 -5
  215. package/dist/llm/stable-device-id.js.map +1 -1
  216. package/dist/memory/attention.d.ts.map +1 -1
  217. package/dist/memory/attention.js +30 -30
  218. package/dist/memory/attention.js.map +1 -1
  219. package/dist/memory/decision-contradiction.d.ts +152 -0
  220. package/dist/memory/decision-contradiction.d.ts.map +1 -0
  221. package/dist/memory/decision-contradiction.js +273 -0
  222. package/dist/memory/decision-contradiction.js.map +1 -0
  223. package/dist/memory/decisions.d.ts +42 -11
  224. package/dist/memory/decisions.d.ts.map +1 -1
  225. package/dist/memory/decisions.js +153 -56
  226. package/dist/memory/decisions.js.map +1 -1
  227. package/dist/memory/dialectic-evaluator.d.ts +7 -0
  228. package/dist/memory/dialectic-evaluator.d.ts.map +1 -1
  229. package/dist/memory/dialectic-evaluator.js +23 -8
  230. package/dist/memory/dialectic-evaluator.js.map +1 -1
  231. package/dist/memory/dispatch-trace-format.d.ts +39 -0
  232. package/dist/memory/dispatch-trace-format.d.ts.map +1 -0
  233. package/dist/memory/dispatch-trace-format.js +54 -0
  234. package/dist/memory/dispatch-trace-format.js.map +1 -0
  235. package/dist/memory/dispatch-trace.d.ts.map +1 -1
  236. package/dist/memory/dispatch-trace.js +1 -27
  237. package/dist/memory/dispatch-trace.js.map +1 -1
  238. package/dist/memory/engine-compat.d.ts +2 -0
  239. package/dist/memory/engine-compat.d.ts.map +1 -1
  240. package/dist/memory/engine-compat.js +1 -0
  241. package/dist/memory/engine-compat.js.map +1 -1
  242. package/dist/memory/import-from-provider.js +3 -3
  243. package/dist/memory/import-from-provider.js.map +1 -1
  244. package/dist/memory/learnings.d.ts +2 -2
  245. package/dist/memory/observation-type-decision.d.ts +96 -0
  246. package/dist/memory/observation-type-decision.d.ts.map +1 -0
  247. package/dist/memory/observation-type-decision.js +218 -0
  248. package/dist/memory/observation-type-decision.js.map +1 -0
  249. package/dist/memory/redaction.js +2 -0
  250. package/dist/memory/redaction.js.map +1 -1
  251. package/dist/memory/retrieval/build-retrieval-bundle.d.ts +9 -2
  252. package/dist/memory/retrieval/build-retrieval-bundle.d.ts.map +1 -1
  253. package/dist/memory/retrieval/build-retrieval-bundle.js +42 -11
  254. package/dist/memory/retrieval/build-retrieval-bundle.js.map +1 -1
  255. package/dist/memory/retrieval/get-current-session-id.d.ts +5 -0
  256. package/dist/memory/retrieval/get-current-session-id.d.ts.map +1 -1
  257. package/dist/memory/retrieval/get-current-session-id.js +7 -2
  258. package/dist/memory/retrieval/get-current-session-id.js.map +1 -1
  259. package/dist/memory/retrieval/observe.d.ts.map +1 -1
  260. package/dist/memory/retrieval/observe.js +30 -29
  261. package/dist/memory/retrieval/observe.js.map +1 -1
  262. package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
  263. package/dist/nexus/analyze-orchestrator.js +42 -29
  264. package/dist/nexus/analyze-orchestrator.js.map +1 -1
  265. package/dist/nexus/assessment-projection.d.ts +76 -0
  266. package/dist/nexus/assessment-projection.d.ts.map +1 -0
  267. package/dist/nexus/assessment-projection.js +143 -0
  268. package/dist/nexus/assessment-projection.js.map +1 -0
  269. package/dist/nexus/assessment-store.d.ts +14 -2
  270. package/dist/nexus/assessment-store.d.ts.map +1 -1
  271. package/dist/nexus/assessment-store.js +21 -3
  272. package/dist/nexus/assessment-store.js.map +1 -1
  273. package/dist/nexus/checkout-nonce.d.ts +48 -0
  274. package/dist/nexus/checkout-nonce.d.ts.map +1 -0
  275. package/dist/nexus/checkout-nonce.js +84 -0
  276. package/dist/nexus/checkout-nonce.js.map +1 -0
  277. package/dist/nexus/devices.d.ts +93 -0
  278. package/dist/nexus/devices.d.ts.map +1 -0
  279. package/dist/nexus/devices.js +141 -0
  280. package/dist/nexus/devices.js.map +1 -0
  281. package/dist/nexus/freshness.d.ts.map +1 -1
  282. package/dist/nexus/freshness.js +25 -6
  283. package/dist/nexus/freshness.js.map +1 -1
  284. package/dist/nexus/git-state.d.ts +225 -0
  285. package/dist/nexus/git-state.d.ts.map +1 -0
  286. package/dist/nexus/git-state.js +677 -0
  287. package/dist/nexus/git-state.js.map +1 -0
  288. package/dist/nexus/graph-manifest.d.ts +20 -4
  289. package/dist/nexus/graph-manifest.d.ts.map +1 -1
  290. package/dist/nexus/graph-manifest.js +40 -5
  291. package/dist/nexus/graph-manifest.js.map +1 -1
  292. package/dist/nexus/identity.d.ts +68 -23
  293. package/dist/nexus/identity.d.ts.map +1 -1
  294. package/dist/nexus/identity.js +99 -22
  295. package/dist/nexus/identity.js.map +1 -1
  296. package/dist/nexus/index.d.ts +5 -2
  297. package/dist/nexus/index.d.ts.map +1 -1
  298. package/dist/nexus/index.js +10 -4
  299. package/dist/nexus/index.js.map +1 -1
  300. package/dist/nexus/knowledge.d.ts +5 -0
  301. package/dist/nexus/knowledge.d.ts.map +1 -1
  302. package/dist/nexus/knowledge.js +26 -2
  303. package/dist/nexus/knowledge.js.map +1 -1
  304. package/dist/nexus/legacy-alias.d.ts +60 -0
  305. package/dist/nexus/legacy-alias.d.ts.map +1 -0
  306. package/dist/nexus/legacy-alias.js +68 -0
  307. package/dist/nexus/legacy-alias.js.map +1 -0
  308. package/dist/nexus/migrate-json-to-sqlite.js +2 -2
  309. package/dist/nexus/migrate-json-to-sqlite.js.map +1 -1
  310. package/dist/nexus/ops.d.ts +1 -0
  311. package/dist/nexus/ops.d.ts.map +1 -1
  312. package/dist/nexus/path-map.d.ts +264 -20
  313. package/dist/nexus/path-map.d.ts.map +1 -1
  314. package/dist/nexus/path-map.js +580 -44
  315. package/dist/nexus/path-map.js.map +1 -1
  316. package/dist/nexus/projects-clean.d.ts +9 -1
  317. package/dist/nexus/projects-clean.d.ts.map +1 -1
  318. package/dist/nexus/projects-clean.js +126 -14
  319. package/dist/nexus/projects-clean.js.map +1 -1
  320. package/dist/nexus/projects-scan.d.ts +56 -1
  321. package/dist/nexus/projects-scan.d.ts.map +1 -1
  322. package/dist/nexus/projects-scan.js +144 -3
  323. package/dist/nexus/projects-scan.js.map +1 -1
  324. package/dist/nexus/registry-hygiene.d.ts +18 -2
  325. package/dist/nexus/registry-hygiene.d.ts.map +1 -1
  326. package/dist/nexus/registry-hygiene.js +37 -11
  327. package/dist/nexus/registry-hygiene.js.map +1 -1
  328. package/dist/nexus/registry-roots.d.ts +47 -0
  329. package/dist/nexus/registry-roots.d.ts.map +1 -0
  330. package/dist/nexus/registry-roots.js +79 -0
  331. package/dist/nexus/registry-roots.js.map +1 -0
  332. package/dist/nexus/registry.d.ts +50 -9
  333. package/dist/nexus/registry.d.ts.map +1 -1
  334. package/dist/nexus/registry.js +311 -156
  335. package/dist/nexus/registry.js.map +1 -1
  336. package/dist/nexus/stored-roots.d.ts +106 -0
  337. package/dist/nexus/stored-roots.d.ts.map +1 -0
  338. package/dist/nexus/stored-roots.js +180 -0
  339. package/dist/nexus/stored-roots.js.map +1 -0
  340. package/dist/nexus/transfer.d.ts.map +1 -1
  341. package/dist/nexus/transfer.js +3 -0
  342. package/dist/nexus/transfer.js.map +1 -1
  343. package/dist/nexus/user-profile-hygiene.d.ts +168 -0
  344. package/dist/nexus/user-profile-hygiene.d.ts.map +1 -0
  345. package/dist/nexus/user-profile-hygiene.js +305 -0
  346. package/dist/nexus/user-profile-hygiene.js.map +1 -0
  347. package/dist/nexus/user-profile.d.ts +53 -2
  348. package/dist/nexus/user-profile.d.ts.map +1 -1
  349. package/dist/nexus/user-profile.js +106 -4
  350. package/dist/nexus/user-profile.js.map +1 -1
  351. package/dist/orchestrate/pivot.d.ts.map +1 -1
  352. package/dist/orchestrate/pivot.js +5 -1
  353. package/dist/orchestrate/pivot.js.map +1 -1
  354. package/dist/orchestrate/spawn-ops.d.ts +12 -0
  355. package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
  356. package/dist/orchestrate/spawn-ops.js +152 -57
  357. package/dist/orchestrate/spawn-ops.js.map +1 -1
  358. package/dist/orchestration/classify-readiness.d.ts +37 -1
  359. package/dist/orchestration/classify-readiness.d.ts.map +1 -1
  360. package/dist/orchestration/classify-readiness.js +48 -19
  361. package/dist/orchestration/classify-readiness.js.map +1 -1
  362. package/dist/orchestration/index.d.ts +3 -2
  363. package/dist/orchestration/index.d.ts.map +1 -1
  364. package/dist/orchestration/index.js +2 -1
  365. package/dist/orchestration/index.js.map +1 -1
  366. package/dist/orchestration/owner-decision-readiness.d.ts +88 -0
  367. package/dist/orchestration/owner-decision-readiness.d.ts.map +1 -0
  368. package/dist/orchestration/owner-decision-readiness.js +152 -0
  369. package/dist/orchestration/owner-decision-readiness.js.map +1 -0
  370. package/dist/orchestration/psyche-memory-budget.d.ts +105 -0
  371. package/dist/orchestration/psyche-memory-budget.d.ts.map +1 -0
  372. package/dist/orchestration/psyche-memory-budget.js +383 -0
  373. package/dist/orchestration/psyche-memory-budget.js.map +1 -0
  374. package/dist/orchestration/spawn-prompt.d.ts +12 -1
  375. package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
  376. package/dist/orchestration/spawn-prompt.js +141 -179
  377. package/dist/orchestration/spawn-prompt.js.map +1 -1
  378. package/dist/orchestration/spawn.d.ts +7 -0
  379. package/dist/orchestration/spawn.d.ts.map +1 -1
  380. package/dist/orchestration/spawn.js +1 -0
  381. package/dist/orchestration/spawn.js.map +1 -1
  382. package/dist/paths.d.ts +24 -8
  383. package/dist/paths.d.ts.map +1 -1
  384. package/dist/paths.js +135 -71
  385. package/dist/paths.js.map +1 -1
  386. package/dist/platform.d.ts +6 -1
  387. package/dist/platform.d.ts.map +1 -1
  388. package/dist/platform.js +8 -19
  389. package/dist/platform.js.map +1 -1
  390. package/dist/project-info.d.ts +18 -0
  391. package/dist/project-info.d.ts.map +1 -1
  392. package/dist/project-info.js +29 -1
  393. package/dist/project-info.js.map +1 -1
  394. package/dist/project-lifecycle.d.ts +91 -32
  395. package/dist/project-lifecycle.d.ts.map +1 -1
  396. package/dist/project-lifecycle.js +639 -75
  397. package/dist/project-lifecycle.js.map +1 -1
  398. package/dist/project-scope.d.ts +86 -4
  399. package/dist/project-scope.d.ts.map +1 -1
  400. package/dist/project-scope.js +226 -13
  401. package/dist/project-scope.js.map +1 -1
  402. package/dist/project-tombstone.d.ts +111 -0
  403. package/dist/project-tombstone.d.ts.map +1 -0
  404. package/dist/project-tombstone.js +220 -0
  405. package/dist/project-tombstone.js.map +1 -0
  406. package/dist/release/artifacts.d.ts.map +1 -1
  407. package/dist/release/artifacts.js +14 -9
  408. package/dist/release/artifacts.js.map +1 -1
  409. package/dist/release/ci-evidence.d.ts +223 -0
  410. package/dist/release/ci-evidence.d.ts.map +1 -0
  411. package/dist/release/ci-evidence.js +652 -0
  412. package/dist/release/ci-evidence.js.map +1 -0
  413. package/dist/release/engine-ops.d.ts.map +1 -1
  414. package/dist/release/engine-ops.js +3 -3
  415. package/dist/release/engine-ops.js.map +1 -1
  416. package/dist/release/plan.d.ts.map +1 -1
  417. package/dist/release/plan.js +7 -6
  418. package/dist/release/plan.js.map +1 -1
  419. package/dist/release/pr-evidence.d.ts +38 -0
  420. package/dist/release/pr-evidence.d.ts.map +1 -1
  421. package/dist/release/pr-evidence.js +67 -11
  422. package/dist/release/pr-evidence.js.map +1 -1
  423. package/dist/release/reconcile.d.ts.map +1 -1
  424. package/dist/release/reconcile.js +3 -2
  425. package/dist/release/reconcile.js.map +1 -1
  426. package/dist/release/release-manifest.d.ts +2 -1
  427. package/dist/release/release-manifest.d.ts.map +1 -1
  428. package/dist/release/release-manifest.js +6 -5
  429. package/dist/release/release-manifest.js.map +1 -1
  430. package/dist/render/nexus/graph/index.d.ts +4 -0
  431. package/dist/render/nexus/graph/index.d.ts.map +1 -1
  432. package/dist/render/nexus/graph/index.js +57 -0
  433. package/dist/render/nexus/graph/index.js.map +1 -1
  434. package/dist/resources/spawn-wrapper.d.ts +8 -1
  435. package/dist/resources/spawn-wrapper.d.ts.map +1 -1
  436. package/dist/resources/spawn-wrapper.js +42 -5
  437. package/dist/resources/spawn-wrapper.js.map +1 -1
  438. package/dist/routing/build-command-groups.d.ts.map +1 -1
  439. package/dist/routing/build-command-groups.js +1 -0
  440. package/dist/routing/build-command-groups.js.map +1 -1
  441. package/dist/sagas/index.d.ts +1 -1
  442. package/dist/sagas/index.d.ts.map +1 -1
  443. package/dist/sagas/index.js +1 -1
  444. package/dist/sagas/index.js.map +1 -1
  445. package/dist/sagas/reconcile.d.ts +24 -4
  446. package/dist/sagas/reconcile.d.ts.map +1 -1
  447. package/dist/sagas/reconcile.js +226 -100
  448. package/dist/sagas/reconcile.js.map +1 -1
  449. package/dist/scaffold/ensure-config.d.ts.map +1 -1
  450. package/dist/scaffold/ensure-config.js +31 -1
  451. package/dist/scaffold/ensure-config.js.map +1 -1
  452. package/dist/scaffold/project-identity.d.ts +2 -8
  453. package/dist/scaffold/project-identity.d.ts.map +1 -1
  454. package/dist/scaffold/project-identity.js +5 -21
  455. package/dist/scaffold/project-identity.js.map +1 -1
  456. package/dist/security/input-sanitization.d.ts +9 -1
  457. package/dist/security/input-sanitization.d.ts.map +1 -1
  458. package/dist/security/input-sanitization.js +12 -2
  459. package/dist/security/input-sanitization.js.map +1 -1
  460. package/dist/selfimprove/fix-gen.js +4321 -1807
  461. package/dist/selfimprove/fix-gen.js.map +3 -3
  462. package/dist/sentient/propose-tick.d.ts.map +1 -1
  463. package/dist/sentient/propose-tick.js +4 -2
  464. package/dist/sentient/propose-tick.js.map +1 -1
  465. package/dist/sequence/index.d.ts.map +1 -1
  466. package/dist/sequence/index.js +6 -23
  467. package/dist/sequence/index.js.map +1 -1
  468. package/dist/session/engine-ops.d.ts +9 -0
  469. package/dist/session/engine-ops.d.ts.map +1 -1
  470. package/dist/session/engine-ops.js +110 -18
  471. package/dist/session/engine-ops.js.map +1 -1
  472. package/dist/sessions/assumptions.d.ts.map +1 -1
  473. package/dist/sessions/assumptions.js +7 -4
  474. package/dist/sessions/assumptions.js.map +1 -1
  475. package/dist/sessions/briefing.d.ts +6 -0
  476. package/dist/sessions/briefing.d.ts.map +1 -1
  477. package/dist/sessions/briefing.js +12 -1
  478. package/dist/sessions/briefing.js.map +1 -1
  479. package/dist/sessions/decisions.d.ts +38 -3
  480. package/dist/sessions/decisions.d.ts.map +1 -1
  481. package/dist/sessions/decisions.js +235 -21
  482. package/dist/sessions/decisions.js.map +1 -1
  483. package/dist/sessions/drift-watchdog.d.ts.map +1 -1
  484. package/dist/sessions/drift-watchdog.js +4 -2
  485. package/dist/sessions/drift-watchdog.js.map +1 -1
  486. package/dist/sessions/index.d.ts.map +1 -1
  487. package/dist/sessions/index.js +33 -4
  488. package/dist/sessions/index.js.map +1 -1
  489. package/dist/sessions/session-end-snapshot-entry.d.ts +26 -0
  490. package/dist/sessions/session-end-snapshot-entry.d.ts.map +1 -0
  491. package/dist/sessions/session-end-snapshot-entry.js +59 -0
  492. package/dist/sessions/session-end-snapshot-entry.js.map +1 -0
  493. package/dist/sessions/session-end-snapshot.d.ts +114 -0
  494. package/dist/sessions/session-end-snapshot.d.ts.map +1 -0
  495. package/dist/sessions/session-end-snapshot.js +446 -0
  496. package/dist/sessions/session-end-snapshot.js.map +1 -0
  497. package/dist/sessions/session-manifest-mirror.d.ts.map +1 -1
  498. package/dist/sessions/session-manifest-mirror.js +10 -17
  499. package/dist/sessions/session-manifest-mirror.js.map +1 -1
  500. package/dist/sessions/session-switch.d.ts.map +1 -1
  501. package/dist/sessions/session-switch.js +5 -3
  502. package/dist/sessions/session-switch.js.map +1 -1
  503. package/dist/sessions/snapshot.d.ts.map +1 -1
  504. package/dist/sessions/snapshot.js +5 -4
  505. package/dist/sessions/snapshot.js.map +1 -1
  506. package/dist/sessions/terminal-identity.d.ts +169 -0
  507. package/dist/sessions/terminal-identity.d.ts.map +1 -0
  508. package/dist/sessions/terminal-identity.js +273 -0
  509. package/dist/sessions/terminal-identity.js.map +1 -0
  510. package/dist/setup/sections/verification.d.ts +1 -1
  511. package/dist/setup/sections/verification.d.ts.map +1 -1
  512. package/dist/setup/sections/verification.js +11 -15
  513. package/dist/setup/sections/verification.js.map +1 -1
  514. package/dist/skills/discovery.d.ts +8 -2
  515. package/dist/skills/discovery.d.ts.map +1 -1
  516. package/dist/skills/discovery.js +15 -3
  517. package/dist/skills/discovery.js.map +1 -1
  518. package/dist/skills/dispatch.d.ts +5 -2
  519. package/dist/skills/dispatch.d.ts.map +1 -1
  520. package/dist/skills/dispatch.js +5 -2
  521. package/dist/skills/dispatch.js.map +1 -1
  522. package/dist/skills/doctor.d.ts.map +1 -1
  523. package/dist/skills/doctor.js +5 -1
  524. package/dist/skills/doctor.js.map +1 -1
  525. package/dist/skills/federated-search.js +2 -2
  526. package/dist/skills/federated-search.js.map +1 -1
  527. package/dist/skills/index.d.ts +3 -3
  528. package/dist/skills/index.d.ts.map +1 -1
  529. package/dist/skills/index.js +1 -1
  530. package/dist/skills/index.js.map +1 -1
  531. package/dist/skills/install.d.ts +15 -2
  532. package/dist/skills/install.d.ts.map +1 -1
  533. package/dist/skills/install.js +21 -5
  534. package/dist/skills/install.js.map +1 -1
  535. package/dist/skills/migration.d.ts +5 -5
  536. package/dist/skills/migration.d.ts.map +1 -1
  537. package/dist/skills/migration.js +7 -9
  538. package/dist/skills/migration.js.map +1 -1
  539. package/dist/skills/orchestrator/startup.d.ts.map +1 -1
  540. package/dist/skills/orchestrator/startup.js +4 -2
  541. package/dist/skills/orchestrator/startup.js.map +1 -1
  542. package/dist/skills/skill-paths.d.ts +30 -3
  543. package/dist/skills/skill-paths.d.ts.map +1 -1
  544. package/dist/skills/skill-paths.js +28 -9
  545. package/dist/skills/skill-paths.js.map +1 -1
  546. package/dist/skills/skill-root.d.ts +60 -11
  547. package/dist/skills/skill-root.d.ts.map +1 -1
  548. package/dist/skills/skill-root.js +100 -14
  549. package/dist/skills/skill-root.js.map +1 -1
  550. package/dist/skills/skills-guard.js +5 -5
  551. package/dist/skills/skills-guard.js.map +1 -1
  552. package/dist/skills/types.d.ts +23 -0
  553. package/dist/skills/types.d.ts.map +1 -1
  554. package/dist/skills/types.js.map +1 -1
  555. package/dist/spawn/agent-identity.d.ts +51 -2
  556. package/dist/spawn/agent-identity.d.ts.map +1 -1
  557. package/dist/spawn/agent-identity.js +89 -26
  558. package/dist/spawn/agent-identity.js.map +1 -1
  559. package/dist/spawn/branch-lock.d.ts.map +1 -1
  560. package/dist/spawn/branch-lock.js +56 -79
  561. package/dist/spawn/branch-lock.js.map +1 -1
  562. package/dist/spawn/index.d.ts +2 -2
  563. package/dist/spawn/index.d.ts.map +1 -1
  564. package/dist/spawn/index.js +1 -1
  565. package/dist/spawn/index.js.map +1 -1
  566. package/dist/spawn/worktree-lock-holder.d.ts +37 -0
  567. package/dist/spawn/worktree-lock-holder.d.ts.map +1 -0
  568. package/dist/spawn/worktree-lock-holder.js +41 -0
  569. package/dist/spawn/worktree-lock-holder.js.map +1 -0
  570. package/dist/sticky/convert.d.ts.map +1 -1
  571. package/dist/sticky/convert.js +16 -4
  572. package/dist/sticky/convert.js.map +1 -1
  573. package/dist/store/attachment-store.d.ts +14 -0
  574. package/dist/store/attachment-store.d.ts.map +1 -1
  575. package/dist/store/attachment-store.js +11 -1
  576. package/dist/store/attachment-store.js.map +1 -1
  577. package/dist/store/backup-inspect.d.ts +7 -3
  578. package/dist/store/backup-inspect.d.ts.map +1 -1
  579. package/dist/store/backup-inspect.js +18 -7
  580. package/dist/store/backup-inspect.js.map +1 -1
  581. package/dist/store/backup-sidecar.d.ts +60 -0
  582. package/dist/store/backup-sidecar.d.ts.map +1 -0
  583. package/dist/store/backup-sidecar.js +96 -0
  584. package/dist/store/backup-sidecar.js.map +1 -0
  585. package/dist/store/data-accessor.d.ts +1 -1
  586. package/dist/store/data-accessor.d.ts.map +1 -1
  587. package/dist/store/data-accessor.js +6 -6
  588. package/dist/store/data-accessor.js.map +1 -1
  589. package/dist/store/data-safety-central.d.ts +13 -4
  590. package/dist/store/data-safety-central.d.ts.map +1 -1
  591. package/dist/store/data-safety-central.js +31 -4
  592. package/dist/store/data-safety-central.js.map +1 -1
  593. package/dist/store/dual-scope-db.d.ts.map +1 -1
  594. package/dist/store/dual-scope-db.js +10 -0
  595. package/dist/store/dual-scope-db.js.map +1 -1
  596. package/dist/store/exodus/__fixtures__/representative-fixture.d.ts.map +1 -1
  597. package/dist/store/exodus/__fixtures__/representative-fixture.js +4 -0
  598. package/dist/store/exodus/__fixtures__/representative-fixture.js.map +1 -1
  599. package/dist/store/exodus/migrate.js +1 -1
  600. package/dist/store/exodus/migrate.js.map +1 -1
  601. package/dist/store/exodus/reconcile.js +1 -1
  602. package/dist/store/exodus/reconcile.js.map +1 -1
  603. package/dist/store/exodus/runtime-targets.d.ts +4 -3
  604. package/dist/store/exodus/runtime-targets.d.ts.map +1 -1
  605. package/dist/store/exodus/runtime-targets.js +4 -3
  606. package/dist/store/exodus/runtime-targets.js.map +1 -1
  607. package/dist/store/import-logging.d.ts.map +1 -1
  608. package/dist/store/import-logging.js +5 -4
  609. package/dist/store/import-logging.js.map +1 -1
  610. package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
  611. package/dist/store/legacy-tasks-lineage.js +2 -7
  612. package/dist/store/legacy-tasks-lineage.js.map +1 -1
  613. package/dist/store/lock.d.ts +1 -0
  614. package/dist/store/lock.d.ts.map +1 -1
  615. package/dist/store/lock.js +1 -0
  616. package/dist/store/lock.js.map +1 -1
  617. package/dist/store/memory-accessor.d.ts +8 -3
  618. package/dist/store/memory-accessor.d.ts.map +1 -1
  619. package/dist/store/memory-accessor.js +29 -13
  620. package/dist/store/memory-accessor.js.map +1 -1
  621. package/dist/store/memory-sqlite.d.ts.map +1 -1
  622. package/dist/store/memory-sqlite.js +5 -0
  623. package/dist/store/memory-sqlite.js.map +1 -1
  624. package/dist/store/open-cleo-db.d.ts.map +1 -1
  625. package/dist/store/open-cleo-db.js +11 -6
  626. package/dist/store/open-cleo-db.js.map +1 -1
  627. package/dist/store/portable-bundle-relocate.d.ts +13 -8
  628. package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
  629. package/dist/store/portable-bundle-relocate.js +75 -31
  630. package/dist/store/portable-bundle-relocate.js.map +1 -1
  631. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  632. package/dist/store/portable-bundle-scan.js +2 -1
  633. package/dist/store/portable-bundle-scan.js.map +1 -1
  634. package/dist/store/portable-bundle.d.ts.map +1 -1
  635. package/dist/store/portable-bundle.js +7 -3
  636. package/dist/store/portable-bundle.js.map +1 -1
  637. package/dist/store/pre-repair-snapshot.d.ts +77 -0
  638. package/dist/store/pre-repair-snapshot.d.ts.map +1 -0
  639. package/dist/store/pre-repair-snapshot.js +122 -0
  640. package/dist/store/pre-repair-snapshot.js.map +1 -0
  641. package/dist/store/regenerators.d.ts +2 -1
  642. package/dist/store/regenerators.d.ts.map +1 -1
  643. package/dist/store/regenerators.js +17 -3
  644. package/dist/store/regenerators.js.map +1 -1
  645. package/dist/store/relocated-store-guard.d.ts +71 -0
  646. package/dist/store/relocated-store-guard.d.ts.map +1 -0
  647. package/dist/store/relocated-store-guard.js +138 -0
  648. package/dist/store/relocated-store-guard.js.map +1 -0
  649. package/dist/store/safety-data-accessor.d.ts +2 -2
  650. package/dist/store/safety-data-accessor.d.ts.map +1 -1
  651. package/dist/store/safety-data-accessor.js +2 -2
  652. package/dist/store/safety-data-accessor.js.map +1 -1
  653. package/dist/store/schema/attachments.d.ts +2 -2
  654. package/dist/store/schema/audit.d.ts +5 -5
  655. package/dist/store/schema/background-jobs.d.ts +1 -1
  656. package/dist/store/schema/cleo-global/models-catalog.d.ts +1 -1
  657. package/dist/store/schema/cleo-global/nexus.d.ts +686 -0
  658. package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
  659. package/dist/store/schema/cleo-global/nexus.js +175 -7
  660. package/dist/store/schema/cleo-global/nexus.js.map +1 -1
  661. package/dist/store/schema/cleo-global/skills.d.ts +2 -2
  662. package/dist/store/schema/cleo-project/audit.d.ts +5 -5
  663. package/dist/store/schema/cleo-project/docs.d.ts +3 -3
  664. package/dist/store/schema/cleo-project/lifecycle.d.ts +3 -3
  665. package/dist/store/schema/cleo-project/provenance-commits.d.ts +2 -2
  666. package/dist/store/schema/cleo-project/provenance-rest.d.ts +3 -3
  667. package/dist/store/schema/cleo-project/tasks-core-batch2.d.ts +1 -1
  668. package/dist/store/schema/cleo-project/tasks-core.d.ts +6 -6
  669. package/dist/store/schema/cleo-shared/brain.d.ts +26 -26
  670. package/dist/store/schema/lifecycle.d.ts +3 -3
  671. package/dist/store/schema/manifest.d.ts +1 -1
  672. package/dist/store/schema/memory-schema.d.ts +26 -26
  673. package/dist/store/schema/nexus-schema.d.ts +696 -2
  674. package/dist/store/schema/nexus-schema.d.ts.map +1 -1
  675. package/dist/store/schema/nexus-schema.js +175 -19
  676. package/dist/store/schema/nexus-schema.js.map +1 -1
  677. package/dist/store/schema/provenance/releases.d.ts +1 -1
  678. package/dist/store/schema/skills-schema.d.ts +2 -2
  679. package/dist/store/schema/tasks.d.ts +5 -5
  680. package/dist/store/session-binding-schema.d.ts +132 -0
  681. package/dist/store/session-binding-schema.d.ts.map +1 -0
  682. package/dist/store/session-binding-schema.js +53 -0
  683. package/dist/store/session-binding-schema.js.map +1 -0
  684. package/dist/store/session-store.d.ts +262 -4
  685. package/dist/store/session-store.d.ts.map +1 -1
  686. package/dist/store/session-store.js +486 -26
  687. package/dist/store/session-store.js.map +1 -1
  688. package/dist/store/snapshot-gate.d.ts +239 -0
  689. package/dist/store/snapshot-gate.d.ts.map +1 -0
  690. package/dist/store/snapshot-gate.js +398 -0
  691. package/dist/store/snapshot-gate.js.map +1 -0
  692. package/dist/store/split-brain-import.js +2 -2
  693. package/dist/store/split-brain-import.js.map +1 -1
  694. package/dist/store/sqlite-backup.d.ts +55 -13
  695. package/dist/store/sqlite-backup.d.ts.map +1 -1
  696. package/dist/store/sqlite-backup.js +414 -106
  697. package/dist/store/sqlite-backup.js.map +1 -1
  698. package/dist/store/sqlite-data-accessor.d.ts +15 -0
  699. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  700. package/dist/store/sqlite-data-accessor.js +63 -4
  701. package/dist/store/sqlite-data-accessor.js.map +1 -1
  702. package/dist/store/sqlite.d.ts +1 -1
  703. package/dist/store/sqlite.d.ts.map +1 -1
  704. package/dist/store/sqlite.js +53 -5
  705. package/dist/store/sqlite.js.map +1 -1
  706. package/dist/store/store-write-guard.d.ts +28 -0
  707. package/dist/store/store-write-guard.d.ts.map +1 -0
  708. package/dist/store/store-write-guard.js +50 -0
  709. package/dist/store/store-write-guard.js.map +1 -0
  710. package/dist/store/table-classification.d.ts +143 -0
  711. package/dist/store/table-classification.d.ts.map +1 -0
  712. package/dist/store/table-classification.js +1866 -0
  713. package/dist/store/table-classification.js.map +1 -0
  714. package/dist/store/task-version.d.ts +72 -0
  715. package/dist/store/task-version.d.ts.map +1 -0
  716. package/dist/store/task-version.js +93 -0
  717. package/dist/store/task-version.js.map +1 -0
  718. package/dist/store/tasks-schema.d.ts +1 -0
  719. package/dist/store/tasks-schema.d.ts.map +1 -1
  720. package/dist/store/tasks-schema.js +13 -0
  721. package/dist/store/tasks-schema.js.map +1 -1
  722. package/dist/store/tasks-sqlite.d.ts +10 -3
  723. package/dist/store/tasks-sqlite.d.ts.map +1 -1
  724. package/dist/store/tasks-sqlite.js +12 -3
  725. package/dist/store/tasks-sqlite.js.map +1 -1
  726. package/dist/store/twin-collapse.d.ts +275 -0
  727. package/dist/store/twin-collapse.d.ts.map +1 -0
  728. package/dist/store/twin-collapse.js +805 -0
  729. package/dist/store/twin-collapse.js.map +1 -0
  730. package/dist/store/umbrella-data-accessor.d.ts +2 -2
  731. package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
  732. package/dist/store/umbrella-data-accessor.js +2 -2
  733. package/dist/store/umbrella-data-accessor.js.map +1 -1
  734. package/dist/store/validation-schemas.d.ts +63 -63
  735. package/dist/store/worktree-isolation-guard.d.ts +46 -24
  736. package/dist/store/worktree-isolation-guard.d.ts.map +1 -1
  737. package/dist/store/worktree-isolation-guard.js +69 -50
  738. package/dist/store/worktree-isolation-guard.js.map +1 -1
  739. package/dist/system/backup.d.ts.map +1 -1
  740. package/dist/system/backup.js +3 -67
  741. package/dist/system/backup.js.map +1 -1
  742. package/dist/system/cleo-link.d.ts +163 -0
  743. package/dist/system/cleo-link.d.ts.map +1 -0
  744. package/dist/system/cleo-link.js +246 -0
  745. package/dist/system/cleo-link.js.map +1 -0
  746. package/dist/system/dependencies.d.ts.map +1 -1
  747. package/dist/system/dependencies.js +26 -41
  748. package/dist/system/dependencies.js.map +1 -1
  749. package/dist/system/global-delivery.d.ts +205 -0
  750. package/dist/system/global-delivery.d.ts.map +1 -0
  751. package/dist/system/global-delivery.js +320 -0
  752. package/dist/system/global-delivery.js.map +1 -0
  753. package/dist/system/health.d.ts.map +1 -1
  754. package/dist/system/health.js +29 -6
  755. package/dist/system/health.js.map +1 -1
  756. package/dist/system/project-health.d.ts.map +1 -1
  757. package/dist/system/project-health.js +1 -20
  758. package/dist/system/project-health.js.map +1 -1
  759. package/dist/system/runtime.d.ts.map +1 -1
  760. package/dist/system/runtime.js +2 -12
  761. package/dist/system/runtime.js.map +1 -1
  762. package/dist/system/safestop.d.ts.map +1 -1
  763. package/dist/system/safestop.js +5 -2
  764. package/dist/system/safestop.js.map +1 -1
  765. package/dist/system/skill-fixtures.d.ts +200 -0
  766. package/dist/system/skill-fixtures.d.ts.map +1 -0
  767. package/dist/system/skill-fixtures.js +331 -0
  768. package/dist/system/skill-fixtures.js.map +1 -0
  769. package/dist/tasks/add.d.ts.map +1 -1
  770. package/dist/tasks/add.js +4 -2
  771. package/dist/tasks/add.js.map +1 -1
  772. package/dist/tasks/affected-packages.d.ts +173 -0
  773. package/dist/tasks/affected-packages.d.ts.map +1 -0
  774. package/dist/tasks/affected-packages.js +389 -0
  775. package/dist/tasks/affected-packages.js.map +1 -0
  776. package/dist/tasks/change-set.d.ts +151 -0
  777. package/dist/tasks/change-set.d.ts.map +1 -0
  778. package/dist/tasks/change-set.js +634 -0
  779. package/dist/tasks/change-set.js.map +1 -0
  780. package/dist/tasks/complete.d.ts.map +1 -1
  781. package/dist/tasks/complete.js +10 -5
  782. package/dist/tasks/complete.js.map +1 -1
  783. package/dist/tasks/done-plan.d.ts +103 -0
  784. package/dist/tasks/done-plan.d.ts.map +1 -0
  785. package/dist/tasks/done-plan.js +541 -0
  786. package/dist/tasks/done-plan.js.map +1 -0
  787. package/dist/tasks/done-record.d.ts +127 -0
  788. package/dist/tasks/done-record.d.ts.map +1 -0
  789. package/dist/tasks/done-record.js +373 -0
  790. package/dist/tasks/done-record.js.map +1 -0
  791. package/dist/tasks/duplicate-detector.d.ts +68 -11
  792. package/dist/tasks/duplicate-detector.d.ts.map +1 -1
  793. package/dist/tasks/duplicate-detector.js +314 -58
  794. package/dist/tasks/duplicate-detector.js.map +1 -1
  795. package/dist/tasks/evidence-paths.d.ts +78 -0
  796. package/dist/tasks/evidence-paths.d.ts.map +1 -0
  797. package/dist/tasks/evidence-paths.js +150 -0
  798. package/dist/tasks/evidence-paths.js.map +1 -0
  799. package/dist/tasks/evidence.d.ts +55 -0
  800. package/dist/tasks/evidence.d.ts.map +1 -1
  801. package/dist/tasks/evidence.js +223 -26
  802. package/dist/tasks/evidence.js.map +1 -1
  803. package/dist/tasks/gate-preview.d.ts +5 -0
  804. package/dist/tasks/gate-preview.d.ts.map +1 -1
  805. package/dist/tasks/gate-preview.js +25 -21
  806. package/dist/tasks/gate-preview.js.map +1 -1
  807. package/dist/tasks/gate-result-cache.d.ts +205 -0
  808. package/dist/tasks/gate-result-cache.d.ts.map +1 -0
  809. package/dist/tasks/gate-result-cache.js +285 -0
  810. package/dist/tasks/gate-result-cache.js.map +1 -0
  811. package/dist/tasks/gate-runner.d.ts +126 -3
  812. package/dist/tasks/gate-runner.d.ts.map +1 -1
  813. package/dist/tasks/gate-runner.js +483 -28
  814. package/dist/tasks/gate-runner.js.map +1 -1
  815. package/dist/tasks/session-scope.d.ts +3 -1
  816. package/dist/tasks/session-scope.d.ts.map +1 -1
  817. package/dist/tasks/session-scope.js +18 -3
  818. package/dist/tasks/session-scope.js.map +1 -1
  819. package/dist/tasks/tool-resolver.d.ts +23 -6
  820. package/dist/tasks/tool-resolver.d.ts.map +1 -1
  821. package/dist/tasks/tool-resolver.js +146 -8
  822. package/dist/tasks/tool-resolver.js.map +1 -1
  823. package/dist/tasks/tool-vacuity.d.ts +71 -0
  824. package/dist/tasks/tool-vacuity.d.ts.map +1 -0
  825. package/dist/tasks/tool-vacuity.js +334 -0
  826. package/dist/tasks/tool-vacuity.js.map +1 -0
  827. package/dist/tasks/update.d.ts +8 -0
  828. package/dist/tasks/update.d.ts.map +1 -1
  829. package/dist/tasks/update.js +159 -78
  830. package/dist/tasks/update.js.map +1 -1
  831. package/dist/upgrade.d.ts.map +1 -1
  832. package/dist/upgrade.js +18 -2
  833. package/dist/upgrade.js.map +1 -1
  834. package/dist/validation/doctor/checks.d.ts +20 -2
  835. package/dist/validation/doctor/checks.d.ts.map +1 -1
  836. package/dist/validation/doctor/checks.js +64 -4
  837. package/dist/validation/doctor/checks.js.map +1 -1
  838. package/dist/validation/doctor/index.d.ts +1 -1
  839. package/dist/validation/doctor/index.d.ts.map +1 -1
  840. package/dist/validation/doctor/index.js +1 -1
  841. package/dist/validation/doctor/index.js.map +1 -1
  842. package/dist/validation/doctor/utils.d.ts.map +1 -1
  843. package/dist/validation/doctor/utils.js +7 -2
  844. package/dist/validation/doctor/utils.js.map +1 -1
  845. package/dist/validation/engine-ops.d.ts +15 -0
  846. package/dist/validation/engine-ops.d.ts.map +1 -1
  847. package/dist/validation/engine-ops.js +249 -98
  848. package/dist/validation/engine-ops.js.map +1 -1
  849. package/migrations/drizzle-cleo-global/20260927000000_t12469-project-locations/migration.sql +121 -0
  850. package/migrations/drizzle-cleo-global/20260927010000_t12543-user-profile-project-scope/migration.sql +23 -0
  851. package/migrations/drizzle-cleo-global/20260928010000_t12470-location-candidates/migration.sql +72 -0
  852. package/migrations/drizzle-cleo-global/20260928020000_t12510-nexus-devices/migration.sql +34 -0
  853. package/migrations/drizzle-cleo-global/20260928030000_t12511-project-git-state/migration.sql +62 -0
  854. package/migrations/drizzle-cleo-project/20260927000000_t12499-session-terminal-bindings/migration.sql +34 -0
  855. package/migrations/drizzle-cleo-project/20260928000000_t12500-binding-provider-flag/migration.sql +15 -0
  856. package/package.json +23 -13
  857. package/schemas/config.schema.json +54 -0
  858. package/schemas/project-context.schema.json +51 -3
  859. package/schemas/project-info.schema.json +28 -1
  860. package/templates/CLEO-INJECTION.md +40 -332
  861. package/templates/CLEO-REFERENCE.md +303 -0
  862. package/templates/workflows/README.md +36 -14
  863. package/templates/workflows/release-prepare.yml.tmpl +7 -0
@@ -1,87 +1,623 @@
1
1
  /**
2
- * Device-local project path map (`nexus_project_paths`).
2
+ * Project locations (`nexus_project_locations`) — every place a project has
3
+ * been seen, on every device.
3
4
  *
4
- * The registry row is keyed by the immutable `project_id` (ADR-094), so its
5
- * `project_path` names one checkout — the one encountered most recently. The
6
- * path map records EVERY checkout of a project on this device, keyed by path,
7
- * so two checkouts of one project coexist instead of fighting over one row.
5
+ * The registry is keyed by the immutable `project_id` alone (ADR-094 ·
6
+ * T12469); its `project_path` names only the checkout encountered most
7
+ * recently. This table records every checkout as one row per
8
+ * `(project_id, device_id, path)`, so two checkouts of one project coexist and
9
+ * the same project on two devices keeps one registry row.
10
+ *
11
+ * Rows are never deleted because a directory vanished. When a project is
12
+ * recorded, this device's other `live` locations of it whose directory is gone
13
+ * move to `missing`; a location whose path now holds a different project moves
14
+ * to `superseded`. History therefore survives for consumers that need former
15
+ * paths (legacy path-derived credential candidates, T12475).
8
16
  *
9
17
  * Every writer that records a checkout in the registry records it here in the
10
18
  * same transaction: encounter registration, `nexusRegister`, `nexusReconcile`
11
- * and `nexusMoveProject`. Rows whose directory is gone are pruned when their
12
- * project is next recorded, so a move leaves one checkout, not two.
19
+ * and `nexusMoveProject`. Only an explicit unregister or clean removes rows.
20
+ *
21
+ * ## Compatibility with older binaries sharing the global store
22
+ *
23
+ * Older binaries still read the registry by path (`WHERE project_path = ?
24
+ * LIMIT 1`, and an owner filter of path OR hash OR id). Two registry rows at
25
+ * one path would make them pick a stale row and fail (`E_PROJECT_ID_DRIFT`,
26
+ * identity conflicts). So when a path changes hands, the previous holder's
27
+ * registry row is re-homed in the same transaction ({@link rehomeDisplacedRows}):
28
+ * to its most recent other live location on this device, or, if it has none,
29
+ * to the non-path sentinel {@link supersededRegistryPath} — which no path
30
+ * lookup can match. At most one registry row ever names a real path.
31
+ *
32
+ * The legacy `nexus_project_paths` map is dual-written (upsert only) for one
33
+ * release so older binaries keep reading a current map; drop it with a later
34
+ * migration once those binaries are gone.
13
35
  *
14
36
  * @task T12354
37
+ * @task T12469
38
+ */
39
+ import { existsSync, lstatSync, readdirSync } from 'node:fs';
40
+ import { lstat, readdir } from 'node:fs/promises';
41
+ import { isAbsolute, join, relative, sep } from 'node:path';
42
+ import { canonicalizePath, readDeclaredProjectIdentity } from '@cleocode/paths';
43
+ import { and, desc, eq, inArray, ne } from 'drizzle-orm';
44
+ import { getStableDeviceId } from '../llm/stable-device-id.js';
45
+ import { projectLocations, projectPaths, projectRegistry } from '../store/schema/nexus-schema.js';
46
+ import { generateProjectHash } from './hash.js';
47
+ import { withinBudget } from './projects-scan.js';
48
+ import { registryStorePath } from './registry-hygiene.js';
49
+ /**
50
+ * Device id carried by rows the T12469 migration backfilled. SQL cannot read
51
+ * the device id, and the global store is device-local, so every such row
52
+ * belongs to this device; {@link adoptLocalDeviceRows} re-keys them.
53
+ */
54
+ export const LOCAL_DEVICE_SENTINEL = 'local';
55
+ /**
56
+ * Key of a {@link ProjectCheckoutRecord.probed} entry.
57
+ *
58
+ * @param projectId - Project the holding was probed for.
59
+ * @param path - Probed path.
60
+ * @returns The map key.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * probed.set(holdingKey(id, path), await probeProjectHolding(path, id, 2000));
65
+ * ```
66
+ */
67
+ export function holdingKey(projectId, path) {
68
+ return `${projectId}\u0000${path}`;
69
+ }
70
+ /**
71
+ * Return this device's stable id — the persisted `<cleoHome>/device-id`
72
+ * (T9321). Reused rather than minting a second device identity.
73
+ *
74
+ * @returns Opaque stable device id.
75
+ */
76
+ export function currentDeviceId() {
77
+ return getStableDeviceId();
78
+ }
79
+ /** Prefix of the registry `project_path` sentinel for a row with no live location. */
80
+ export const SUPERSEDED_PATH_PREFIX = 'superseded:';
81
+ /**
82
+ * Registry `project_path` for a project whose last checkout now holds another
83
+ * project and which has no other live location. Not an absolute path, so no
84
+ * path lookup (current or older binary) can match it; unique per id.
85
+ *
86
+ * @param projectId - Immutable project id.
87
+ * @returns `superseded:<projectId>`.
88
+ */
89
+ export function supersededRegistryPath(projectId) {
90
+ return `${SUPERSEDED_PATH_PREFIX}${projectId}`;
91
+ }
92
+ /**
93
+ * Whether a registry `project_path` is the {@link supersededRegistryPath} sentinel.
94
+ *
95
+ * @param projectPath - Stored registry path.
96
+ * @returns `true` for the sentinel.
97
+ */
98
+ export function isSupersededRegistryPath(projectPath) {
99
+ return projectPath.startsWith(SUPERSEDED_PATH_PREFIX);
100
+ }
101
+ /**
102
+ * Whether `path` still holds `projectId`:
103
+ *
104
+ * - `no` — PROVABLY not: `.cleo/` is absent (ENOENT / ENOTDIR), or it
105
+ * declares a different id. A directory the project was moved or rerooted
106
+ * out of (or whose `.cleo/` was moved back out by hand).
107
+ * - `unknown` — cannot tell (EACCES, EPERM, EIO, …). A checkout made
108
+ * unreadable by `chmod 000` is NOT gone; treating it as vanished would let a
109
+ * same-nonce backup copy take its registry row (T12558 round 4).
110
+ * - `yes` — `.cleo/` is there and declares this id (or nothing).
111
+ */
112
+ export function projectHolding(path, projectId) {
113
+ const cleoDir = join(path, '.cleo');
114
+ try {
115
+ lstatSync(cleoDir);
116
+ readdirSync(cleoDir);
117
+ }
118
+ catch (error) {
119
+ const code = error.code;
120
+ return code === 'ENOENT' || code === 'ENOTDIR' ? 'no' : 'unknown';
121
+ }
122
+ const declared = readDeclaredProjectIdentity(path);
123
+ return declared === null || declared.projectId === projectId ? 'yes' : 'no';
124
+ }
125
+ /**
126
+ * {@link projectHolding} with a time budget, for machine-wide scans
127
+ * (T12471): a hung mount answers `unknown` after `timeoutMs` instead of
128
+ * stalling the caller. Same tri-state rules — only ENOENT/ENOTDIR prove the
129
+ * project gone.
130
+ *
131
+ * @param path - Checkout root to probe.
132
+ * @param projectId - Id the checkout should hold.
133
+ * @param timeoutMs - Budget for the directory probe.
134
+ * @returns `yes`, `no`, or `unknown` (unreadable or timed out).
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * if ((await probeProjectHolding(row.projectPath, row.projectId, 2000)) === 'no') markGone(row);
139
+ * ```
140
+ */
141
+ export async function probeProjectHolding(path, projectId, timeoutMs) {
142
+ const cleoDir = join(path, '.cleo');
143
+ const probe = async () => {
144
+ try {
145
+ await lstat(cleoDir);
146
+ await readdir(cleoDir);
147
+ return null;
148
+ }
149
+ catch (error) {
150
+ const code = error.code;
151
+ return code === 'ENOENT' || code === 'ENOTDIR' ? 'no' : 'unknown';
152
+ }
153
+ };
154
+ const settled = await withinBudget(probe(), timeoutMs);
155
+ if (settled === 'timeout')
156
+ return 'unknown';
157
+ if (settled !== null)
158
+ return settled;
159
+ const declared = readDeclaredProjectIdentity(path);
160
+ return declared === null || declared.projectId === projectId ? 'yes' : 'no';
161
+ }
162
+ /** `true` when `inner` is strictly inside `outer`, compared through symlinks. */
163
+ function isStrictlyInside(outer, inner) {
164
+ const rel = relative(canonicalizePath(outer), canonicalizePath(inner));
165
+ return rel.length > 0 && rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
166
+ }
167
+ /** Primary-key predicate for one location row. */
168
+ function locationKey(projectId, deviceId, path) {
169
+ return and(eq(projectLocations.projectId, projectId), eq(projectLocations.deviceId, deviceId), eq(projectLocations.path, path));
170
+ }
171
+ /**
172
+ * Re-key migration-backfilled rows (device id {@link LOCAL_DEVICE_SENTINEL})
173
+ * to `deviceId`, merging with any row already recorded under the real id.
174
+ *
175
+ * @param db - Registry handle or transaction.
176
+ * @param deviceId - This device's stable id.
177
+ * @returns Number of sentinel rows adopted.
15
178
  */
16
- import { existsSync } from 'node:fs';
17
- import { and, desc, eq, ne } from 'drizzle-orm';
18
- import { projectPaths } from '../store/schema/nexus-schema.js';
179
+ export function adoptLocalDeviceRows(db, deviceId) {
180
+ if (deviceId === LOCAL_DEVICE_SENTINEL)
181
+ return 0;
182
+ const sentinelRows = db
183
+ .select()
184
+ .from(projectLocations)
185
+ .where(eq(projectLocations.deviceId, LOCAL_DEVICE_SENTINEL))
186
+ .all();
187
+ for (const row of sentinelRows) {
188
+ const existing = db
189
+ .select()
190
+ .from(projectLocations)
191
+ .where(locationKey(row.projectId, deviceId, row.path))
192
+ .get();
193
+ if (existing) {
194
+ db.update(projectLocations)
195
+ .set({
196
+ firstSeen: existing.firstSeen < row.firstSeen ? existing.firstSeen : row.firstSeen,
197
+ lastSeen: existing.lastSeen > row.lastSeen ? existing.lastSeen : row.lastSeen,
198
+ })
199
+ .where(locationKey(row.projectId, deviceId, row.path))
200
+ .run();
201
+ }
202
+ else {
203
+ db.insert(projectLocations)
204
+ .values({ ...row, deviceId })
205
+ .run();
206
+ }
207
+ db.delete(projectLocations)
208
+ .where(locationKey(row.projectId, LOCAL_DEVICE_SENTINEL, row.path))
209
+ .run();
210
+ }
211
+ return sentinelRows.length;
212
+ }
19
213
  /**
20
- * Record a checkout in the path map and prune this project's vanished paths.
214
+ * Record a checkout as a `live` location, supersede other projects' claims on
215
+ * the same path, and mark this project's vanished paths on this device
216
+ * `missing`. Nothing is deleted.
21
217
  *
22
- * A path belongs to exactly one project, so recording it re-points a row that
23
- * previously named another project. Runs synchronously so it composes with the
24
- * registry writers' immediate transactions.
218
+ * Runs synchronously so it composes with the registry writers' immediate
219
+ * transactions.
25
220
  *
26
221
  * @param db - Registry handle or transaction.
27
222
  * @param record - The checkout encountered.
28
- * @returns Number of vanished checkouts pruned for this project.
223
+ * @returns Counts of rows moved to `missing` and `superseded`.
29
224
  */
30
225
  export function recordProjectCheckout(db, record) {
31
- db.insert(projectPaths)
226
+ const deviceId = record.deviceId ?? currentDeviceId();
227
+ adoptLocalDeviceRows(db, deviceId);
228
+ const evidence = confirmedColumns(record);
229
+ db.insert(projectLocations)
32
230
  .values({
33
- projectPath: record.projectPath,
34
231
  projectId: record.projectId,
35
- projectHash: record.projectHash,
232
+ deviceId,
233
+ path: record.projectPath,
36
234
  firstSeen: record.now,
37
235
  lastSeen: record.now,
236
+ state: 'live',
237
+ ...evidence,
38
238
  })
39
239
  .onConflictDoUpdate({
40
- target: projectPaths.projectPath,
41
- set: { projectId: record.projectId, projectHash: record.projectHash, lastSeen: record.now },
240
+ target: [projectLocations.projectId, projectLocations.deviceId, projectLocations.path],
241
+ set: { lastSeen: record.now, state: 'live', ...evidence },
42
242
  })
43
243
  .run();
244
+ // A path holds one project at a time: other projects' claims on it end.
245
+ const superseded = Number(db
246
+ .update(projectLocations)
247
+ .set({ state: 'superseded' })
248
+ .where(and(eq(projectLocations.deviceId, deviceId), eq(projectLocations.path, record.projectPath), ne(projectLocations.projectId, record.projectId), ne(projectLocations.state, 'superseded')))
249
+ .run().changes);
44
250
  const siblings = db
45
- .select({ projectPath: projectPaths.projectPath })
46
- .from(projectPaths)
47
- .where(and(eq(projectPaths.projectId, record.projectId), ne(projectPaths.projectPath, record.projectPath)))
251
+ .select({ path: projectLocations.path })
252
+ .from(projectLocations)
253
+ .where(and(eq(projectLocations.projectId, record.projectId), eq(projectLocations.deviceId, deviceId), eq(projectLocations.state, 'live'), ne(projectLocations.path, record.projectPath)))
48
254
  .all();
49
- let pruned = 0;
255
+ let markedMissing = 0;
50
256
  for (const sibling of siblings) {
51
- if (existsSync(sibling.projectPath))
257
+ // Only a PROVABLY vanished location is marked missing; an unreadable one
258
+ // (`unknown`) keeps its state.
259
+ const holding = record.probed?.get(holdingKey(record.projectId, sibling.path)) ??
260
+ projectHolding(sibling.path, record.projectId);
261
+ if (holding !== 'no')
52
262
  continue;
53
- db.delete(projectPaths).where(eq(projectPaths.projectPath, sibling.projectPath)).run();
54
- pruned++;
263
+ db.update(projectLocations)
264
+ .set({ state: 'missing' })
265
+ .where(locationKey(record.projectId, deviceId, sibling.path))
266
+ .run();
267
+ markedMissing++;
268
+ }
269
+ rehomeDisplacedRows(db, record.projectId, record.projectPath, deviceId, record.probed);
270
+ // Legacy path map, dual-written for older binaries (upsert only; see header).
271
+ db.insert(projectPaths)
272
+ .values({
273
+ projectPath: record.projectPath,
274
+ projectId: record.projectId,
275
+ projectHash: record.projectHash ?? generateProjectHash(record.projectPath),
276
+ firstSeen: record.now,
277
+ lastSeen: record.now,
278
+ })
279
+ .onConflictDoUpdate({
280
+ target: projectPaths.projectPath,
281
+ set: {
282
+ projectId: record.projectId,
283
+ projectHash: record.projectHash ?? generateProjectHash(record.projectPath),
284
+ lastSeen: record.now,
285
+ },
286
+ })
287
+ .run();
288
+ return { markedMissing, superseded };
289
+ }
290
+ /** The non-null displayed-evidence fields of a record, as location columns. */
291
+ function evidenceColumns(evidence) {
292
+ return {
293
+ ...(evidence?.gitRootCommit ? { gitRootCommit: evidence.gitRootCommit } : {}),
294
+ ...(evidence?.gitRemote ? { gitRemote: evidence.gitRemote } : {}),
295
+ };
296
+ }
297
+ /** A confirmed record's evidence plus its nonce, as location columns. */
298
+ function confirmedColumns(record) {
299
+ return {
300
+ ...evidenceColumns(record.evidence),
301
+ ...(record.checkoutNonce ? { checkoutNonce: record.checkoutNonce } : {}),
302
+ };
303
+ }
304
+ /**
305
+ * Decide how an encounter may bind a checkout (see {@link EncounterBinding}).
306
+ *
307
+ * @param db - Registry handle or transaction.
308
+ * @param record - The encountered checkout and its evidence.
309
+ * @returns The permitted binding.
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * const binding = decideEncounterBinding(tx, { projectId, projectPath, now, evidence });
314
+ * ```
315
+ */
316
+ export function decideEncounterBinding(db, record) {
317
+ const deviceId = record.deviceId ?? currentDeviceId();
318
+ const row = db
319
+ .select({ projectPath: projectRegistry.projectPath })
320
+ .from(projectRegistry)
321
+ .where(eq(projectRegistry.projectId, record.projectId))
322
+ .get();
323
+ if (!row || row.projectPath === record.projectPath)
324
+ return 'bind';
325
+ const here = db
326
+ .select({ state: projectLocations.state, checkoutNonce: projectLocations.checkoutNonce })
327
+ .from(projectLocations)
328
+ .where(and(eq(projectLocations.projectId, record.projectId), inArray(projectLocations.deviceId, [deviceId, LOCAL_DEVICE_SENTINEL]), eq(projectLocations.path, record.projectPath)))
329
+ .all();
330
+ if (here.some((location) => location.state === 'live'))
331
+ return 'refresh';
332
+ const oldPath = row.projectPath;
333
+ if (isSupersededRegistryPath(oldPath))
334
+ return 'candidate';
335
+ // Proof of a move is the checkout's NONCE alone (T12470): local, untracked
336
+ // state that a real `mv` or a restore of `.cleo/` carries and a clone
337
+ // cannot have. Root commit and remote are forgeable (a clone shares them, a
338
+ // bare `git init` can add any remote, `refs/replace` fakes a root commit),
339
+ // so they are displayed evidence only and never promote.
340
+ const nonce = record.checkoutNonce ?? null;
341
+ const previous = () => db
342
+ .select({ checkoutNonce: projectLocations.checkoutNonce })
343
+ .from(projectLocations)
344
+ .where(and(eq(projectLocations.projectId, record.projectId), inArray(projectLocations.deviceId, [deviceId, LOCAL_DEVICE_SENTINEL]), eq(projectLocations.path, oldPath)))
345
+ .all();
346
+ // The old path still holding the project (not merely existing — a reroot
347
+ // undone by hand leaves the child directory behind, empty of `.cleo/`), or
348
+ // being unreadable, means this is a second checkout, not a move.
349
+ if (projectHolding(oldPath, record.projectId) !== 'no') {
350
+ // T12558 round 4: the ORIGINAL checkout coming back. It was once
351
+ // confirmed here (only a confirmed location records a nonce — candidates
352
+ // never do), it still carries that nonce, and the current holder's nonce
353
+ // differs — so the holder is not a copy of it. Hand the row back rather
354
+ // than leave the original stuck behind a stranger.
355
+ if (nonce !== null &&
356
+ here.some((location) => location.checkoutNonce === nonce) &&
357
+ !previous().some((location) => location.checkoutNonce === nonce)) {
358
+ return 'promote';
359
+ }
360
+ return 'candidate';
361
+ }
362
+ if (nonce === null)
363
+ return 'candidate';
364
+ return previous().some((location) => location.checkoutNonce === nonce) ? 'promote' : 'candidate';
365
+ }
366
+ /**
367
+ * Record an UNCONFIRMED location of a project (T12470): the checkout declares
368
+ * the id, but nothing has confirmed it. The registry row, its path and its
369
+ * permissions are not touched, and no other project's claim on the path ends.
370
+ * A location that is already `live` stays `live`.
371
+ *
372
+ * @param db - Registry handle or transaction.
373
+ * @param record - The encountered checkout.
374
+ * @returns `true` when the candidate was recorded for the first time.
375
+ *
376
+ * @example
377
+ * ```ts
378
+ * recordCandidateLocation(tx, { projectId, projectPath, now, evidence });
379
+ * ```
380
+ */
381
+ export function recordCandidateLocation(db, record) {
382
+ const deviceId = record.deviceId ?? currentDeviceId();
383
+ adoptLocalDeviceRows(db, deviceId);
384
+ const key = locationKey(record.projectId, deviceId, record.projectPath);
385
+ const existing = db
386
+ .select({ state: projectLocations.state })
387
+ .from(projectLocations)
388
+ .where(key)
389
+ .get();
390
+ const evidence = evidenceColumns(record.evidence);
391
+ if (!existing) {
392
+ db.insert(projectLocations)
393
+ .values({
394
+ projectId: record.projectId,
395
+ deviceId,
396
+ path: record.projectPath,
397
+ firstSeen: record.now,
398
+ lastSeen: record.now,
399
+ state: 'candidate',
400
+ ...evidence,
401
+ })
402
+ .run();
403
+ return true;
404
+ }
405
+ // T12558: a `missing` location the project was explicitly moved AWAY from
406
+ // (reroot/move demoted it) stays `missing` while the project is live at
407
+ // another existing path on this device. A `git checkout -- .` at the old
408
+ // root restores the tracked id and makes every command an encounter here;
409
+ // flipping the row to `candidate` would disarm the store guard that refuses
410
+ // to create an empty store at a relocated root.
411
+ // Round 4: only in REROOT geometry (the live location is strictly inside
412
+ // this path) and only for a nonce-less encounter (restored tracked files —
413
+ // a real checkout carries its untracked nonce). Anywhere else a path that
414
+ // holds the project is a `candidate`, never stuck at `missing`.
415
+ const keepMissing = existing.state === 'missing' &&
416
+ (record.checkoutNonce ?? null) === null &&
417
+ hasOtherLiveLocation(db, record, deviceId);
418
+ db.update(projectLocations)
419
+ .set({
420
+ lastSeen: record.now,
421
+ ...(existing.state === 'live' || keepMissing ? {} : { state: 'candidate' }),
422
+ ...evidence,
423
+ })
424
+ .where(key)
425
+ .run();
426
+ return false;
427
+ }
428
+ /**
429
+ * Whether `record.projectId` has a `live` location on this device STRICTLY
430
+ * INSIDE this path (the project was rerooted into it) that still PROVES it
431
+ * holds the project — the directory declares the same id. Mere existence is not enough: after a reroot is undone by hand
432
+ * the child directory still exists but no longer holds `.cleo/`, and the old
433
+ * root must then be able to become a location again (T12558 round 3).
434
+ */
435
+ function hasOtherLiveLocation(db, record, deviceId) {
436
+ return db
437
+ .select({ path: projectLocations.path })
438
+ .from(projectLocations)
439
+ .where(and(eq(projectLocations.projectId, record.projectId), eq(projectLocations.deviceId, deviceId), eq(projectLocations.state, 'live'), ne(projectLocations.path, record.projectPath)))
440
+ .all()
441
+ .some((location) => isStrictlyInside(record.projectPath, location.path) &&
442
+ existsSync(location.path) &&
443
+ readDeclaredProjectIdentity(location.path)?.projectId === record.projectId);
444
+ }
445
+ /**
446
+ * Demote a location this device no longer treats as the project's home
447
+ * (T12556 · T12558). `cleo project move` leaves the source tree behind as a
448
+ * `candidate` (it still declares the id but is no longer confirmed);
449
+ * `cleo project reroot` leaves the old root with no `.cleo/` at all, so it is
450
+ * `missing`. A location that was never recorded is recorded in that state so
451
+ * the history is complete. The registry row is not touched.
452
+ *
453
+ * @param db - Registry handle or transaction.
454
+ * @param record - The location to demote.
455
+ * @param state - `candidate` (still declares the id) or `missing` (does not).
456
+ *
457
+ * @example
458
+ * ```ts
459
+ * demoteProjectLocation(tx, { projectId, projectPath: oldRoot, now }, 'missing');
460
+ * ```
461
+ */
462
+ export function demoteProjectLocation(db, record, state) {
463
+ const deviceId = record.deviceId ?? currentDeviceId();
464
+ adoptLocalDeviceRows(db, deviceId);
465
+ db.insert(projectLocations)
466
+ .values({
467
+ projectId: record.projectId,
468
+ deviceId,
469
+ path: record.projectPath,
470
+ firstSeen: record.now,
471
+ lastSeen: record.now,
472
+ state,
473
+ })
474
+ .onConflictDoUpdate({
475
+ target: [projectLocations.projectId, projectLocations.deviceId, projectLocations.path],
476
+ set: { state },
477
+ })
478
+ .run();
479
+ }
480
+ /**
481
+ * Refresh an already-confirmed location without repointing the registry row.
482
+ *
483
+ * @param db - Registry handle or transaction.
484
+ * @param record - The encountered checkout.
485
+ */
486
+ export function touchProjectLocation(db, record) {
487
+ const deviceId = record.deviceId ?? currentDeviceId();
488
+ adoptLocalDeviceRows(db, deviceId);
489
+ db.update(projectLocations)
490
+ .set({ lastSeen: record.now, ...confirmedColumns(record) })
491
+ .where(locationKey(record.projectId, deviceId, record.projectPath))
492
+ .run();
493
+ }
494
+ /**
495
+ * Explicitly confirm a checkout as a project's live location and point the
496
+ * registry row at it (T12470) — the promotion path for a `candidate` used by
497
+ * `cleo doctor project-identity --resolve`. Permissions stay on the row.
498
+ *
499
+ * @param db - Registry handle or transaction.
500
+ * @param record - The checkout to confirm.
501
+ * @returns `false` when the project has no registry row to point.
502
+ *
503
+ * @example
504
+ * ```ts
505
+ * confirmProjectLocation(tx, { projectId, projectPath, now, evidence });
506
+ * ```
507
+ */
508
+ export function confirmProjectLocation(db, record) {
509
+ const row = db
510
+ .select({ projectId: projectRegistry.projectId })
511
+ .from(projectRegistry)
512
+ .where(eq(projectRegistry.projectId, record.projectId))
513
+ .get();
514
+ if (!row)
515
+ return false;
516
+ db.update(projectRegistry)
517
+ .set({
518
+ projectPath: record.projectPath,
519
+ projectHash: generateProjectHash(record.projectPath),
520
+ lastSeen: record.now,
521
+ brainDbPath: registryStorePath(record.projectPath),
522
+ tasksDbPath: registryStorePath(record.projectPath),
523
+ })
524
+ .where(eq(projectRegistry.projectId, record.projectId))
525
+ .run();
526
+ recordProjectCheckout(db, record);
527
+ return true;
528
+ }
529
+ /**
530
+ * Keep at most one registry row per real path: move every OTHER project's
531
+ * registry row that still names `projectPath` to that project's most recent
532
+ * other live location on this device, or to its
533
+ * {@link supersededRegistryPath} sentinel when it has none.
534
+ *
535
+ * @param db - Registry handle or transaction.
536
+ * @param projectId - The project that now holds `projectPath`.
537
+ * @param projectPath - The path that changed hands.
538
+ * @param deviceId - This device's stable id.
539
+ * @param probed - Holdings probed before the transaction ({@link holdingKey}).
540
+ * @returns Number of registry rows re-homed.
541
+ */
542
+ export function rehomeDisplacedRows(db, projectId, projectPath, deviceId, probed) {
543
+ const displaced = db
544
+ .select({ projectId: projectRegistry.projectId })
545
+ .from(projectRegistry)
546
+ .where(and(eq(projectRegistry.projectPath, projectPath), ne(projectRegistry.projectId, projectId)))
547
+ .all();
548
+ for (const row of displaced) {
549
+ const candidates = db
550
+ .select({ path: projectLocations.path })
551
+ .from(projectLocations)
552
+ .where(and(eq(projectLocations.projectId, row.projectId), eq(projectLocations.deviceId, deviceId), eq(projectLocations.state, 'live'), ne(projectLocations.path, projectPath)))
553
+ .orderBy(desc(projectLocations.lastSeen))
554
+ .all();
555
+ // A candidate must exist on disk and not already name another registry row.
556
+ // A pre-probed holding answers without touching the filesystem (T12471):
557
+ // only a location that still holds the displaced project may take its row.
558
+ const present = (path) => {
559
+ const holding = probed?.get(holdingKey(row.projectId, path));
560
+ return holding === undefined ? existsSync(path) : holding === 'yes';
561
+ };
562
+ const home = candidates.find((c) => present(c.path) &&
563
+ db
564
+ .select({ projectId: projectRegistry.projectId })
565
+ .from(projectRegistry)
566
+ .where(eq(projectRegistry.projectPath, c.path))
567
+ .all().length === 0)?.path;
568
+ const nextPath = home ?? supersededRegistryPath(row.projectId);
569
+ db.update(projectRegistry)
570
+ .set({
571
+ projectPath: nextPath,
572
+ projectHash: generateProjectHash(nextPath),
573
+ brainDbPath: home ? registryStorePath(home) : null,
574
+ tasksDbPath: home ? registryStorePath(home) : null,
575
+ })
576
+ .where(eq(projectRegistry.projectId, row.projectId))
577
+ .run();
55
578
  }
56
- return pruned;
579
+ return displaced.length;
57
580
  }
58
581
  /**
59
- * List every recorded checkout of a project on this device, newest first.
582
+ * List every recorded location of a project, newest first.
60
583
  *
61
584
  * @param projectId - Immutable project id.
62
- * @returns Checkouts with an `exists` flag; a vanished one stays listed until
63
- * the project is next recorded.
585
+ * @param opts - `allDevices: true` includes other devices' locations; by
586
+ * default only this device's are listed.
587
+ * @returns Locations with their state and an `exists` flag (checked only for
588
+ * this device's rows; `false` for another device's).
64
589
  * @example
65
590
  * ```ts
66
591
  * const checkouts = await listProjectCheckouts(projectId);
592
+ * const live = checkouts.filter((c) => c.state === 'live');
67
593
  * ```
68
594
  */
69
- export async function listProjectCheckouts(projectId) {
595
+ export async function listProjectCheckouts(projectId, opts = {}) {
70
596
  const { getNexusRegistryDb } = await import('../store/nexus-sqlite.js');
71
597
  const { getCleoHome } = await import('../paths.js');
72
598
  const db = await getNexusRegistryDb(getCleoHome());
73
- return db
599
+ const deviceId = currentDeviceId();
600
+ const out = [];
601
+ for (const row of db
74
602
  .select()
75
- .from(projectPaths)
76
- .where(eq(projectPaths.projectId, projectId))
77
- .orderBy(desc(projectPaths.lastSeen))
78
- .all()
79
- .map((row) => ({
80
- projectPath: row.projectPath,
81
- projectHash: row.projectHash,
82
- firstSeen: row.firstSeen,
83
- lastSeen: row.lastSeen,
84
- exists: existsSync(row.projectPath),
85
- }));
603
+ .from(projectLocations)
604
+ .where(eq(projectLocations.projectId, projectId))
605
+ .orderBy(desc(projectLocations.lastSeen))
606
+ .all()) {
607
+ // Migration-backfilled rows are this device's until adopted.
608
+ const local = row.deviceId === deviceId || row.deviceId === LOCAL_DEVICE_SENTINEL;
609
+ if (!local && !opts.allDevices)
610
+ continue;
611
+ out.push({
612
+ projectPath: row.path,
613
+ projectHash: generateProjectHash(row.path),
614
+ firstSeen: row.firstSeen,
615
+ lastSeen: row.lastSeen,
616
+ exists: local && existsSync(row.path),
617
+ deviceId: local ? deviceId : row.deviceId,
618
+ state: row.state,
619
+ });
620
+ }
621
+ return out;
86
622
  }
87
623
  //# sourceMappingURL=path-map.js.map