@north-light/crouter 0.3.352 → 0.3.354

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 (616) hide show
  1. package/dist/api/client.d.ts +35 -25
  2. package/dist/api/client.js +2 -2
  3. package/dist/api/dto/broker-ops.d.ts +2 -36
  4. package/dist/api/dto/canvas.d.ts +8 -13
  5. package/dist/api/dto/config.d.ts +4 -0
  6. package/dist/api/dto/delivery.d.ts +61 -0
  7. package/dist/api/dto/docs.d.ts +133 -0
  8. package/dist/api/dto/docs.js +1 -0
  9. package/dist/api/dto/health.d.ts +26 -79
  10. package/dist/api/dto/node-outcomes.d.ts +1 -3
  11. package/dist/api/dto/nodes.d.ts +5 -26
  12. package/dist/api/dto/objects.d.ts +167 -0
  13. package/dist/api/dto/objects.js +1 -0
  14. package/dist/api/dto/profiles.d.ts +14 -8
  15. package/dist/api/dto/reports.d.ts +9 -7
  16. package/dist/api/dto/reviews.d.ts +9 -3
  17. package/dist/api/dto/worktree.d.ts +1 -1
  18. package/dist/api/index.d.ts +0 -1
  19. package/dist/api/index.js +1 -1
  20. package/dist/api/routes.d.ts +14 -12
  21. package/dist/api/routes.js +1 -1
  22. package/dist/build-root.js +1 -1
  23. package/dist/builtin-memory/00-runtime-base/00-authoring.md +10 -5
  24. package/dist/builtin-memory/04-orchestration-kernel.md +7 -7
  25. package/dist/builtin-memory/05-kinds/advisor/01-orchestrator.md +1 -1
  26. package/dist/builtin-memory/05-kinds/explore/00-base.md +2 -2
  27. package/dist/builtin-memory/05-kinds/explore/01-orchestrator.md +2 -2
  28. package/dist/builtin-memory/crouter-concepts/INDEX.md +2 -2
  29. package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
  30. package/dist/builtin-memory/crouter-concepts/memory.md +15 -15
  31. package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +1 -1
  32. package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +5 -5
  33. package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
  34. package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
  35. package/dist/builtin-memory/crouter-sdk/INDEX.md +2 -2
  36. package/dist/builtin-memory/crouter-sdk/README.md +5 -6
  37. package/dist/builtin-memory/crouter-sdk/errors.md +0 -13
  38. package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -1
  39. package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +2 -2
  40. package/dist/builtin-memory/crouter-sdk/nodes.md +0 -2
  41. package/dist/builtin-memory/crouter-sdk/resources.md +0 -1
  42. package/dist/builtin-memory/explore/exploration-doc.md +4 -4
  43. package/dist/builtin-memory/insights/capture.md +6 -6
  44. package/dist/builtin-memory/insights/init.md +14 -14
  45. package/dist/builtin-memory/internal/INDEX.md +4 -4
  46. package/dist/builtin-memory/internal/agent-shaping.md +20 -20
  47. package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
  48. package/dist/builtin-memory/internal/marketplaces.md +2 -2
  49. package/dist/builtin-memory/internal/memory-loading.md +31 -30
  50. package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
  51. package/dist/builtin-memory/internal/plugins.md +16 -14
  52. package/dist/builtin-memory/internal/storage-tiers.md +4 -4
  53. package/dist/builtin-memory/memory-read-orientation.md +1 -1
  54. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +32 -40
  55. package/dist/clients/attach/input/controller.js +1 -1
  56. package/dist/clients/attach/input/ref-autocomplete.js +1 -1
  57. package/dist/clients/attach/input/titled-editor.js +1 -1
  58. package/dist/clients/attach/render/chat-view.js +1 -1
  59. package/dist/clients/attach/render/crtr-output.d.ts +1 -2
  60. package/dist/clients/attach/render/crtr-output.js +17 -17
  61. package/dist/clients/attach/render/group-activity.d.ts +8 -8
  62. package/dist/clients/attach/render/group-activity.js +2 -2
  63. package/dist/clients/attach/render/group-recap.js +1 -1
  64. package/dist/clients/attach/render/tool-calls.d.ts +1 -1
  65. package/dist/clients/attach/session/profile-files.js +1 -1
  66. package/dist/clients/attach/slash/dispatch.js +1 -1
  67. package/dist/clients/attach/viewer.js +806 -1553
  68. package/dist/commands/api-client.d.ts +2 -0
  69. package/dist/commands/api-client.js +3 -3
  70. package/dist/commands/canvas/edges.d.ts +2 -0
  71. package/dist/commands/canvas/edges.js +2 -0
  72. package/dist/commands/canvas/list.d.ts +4 -0
  73. package/dist/commands/canvas/list.js +3 -0
  74. package/dist/commands/canvas/read.d.ts +8 -0
  75. package/dist/commands/canvas/read.js +5 -0
  76. package/dist/commands/canvas/search.d.ts +2 -0
  77. package/dist/commands/canvas/search.js +3 -0
  78. package/dist/commands/canvas/unwatch.d.ts +2 -0
  79. package/dist/commands/canvas/unwatch.js +1 -0
  80. package/dist/commands/canvas/watch.d.ts +3 -0
  81. package/dist/commands/canvas/watch.js +1 -0
  82. package/dist/commands/canvas-analytics.js +1 -1
  83. package/dist/commands/canvas-history/grep.js +4 -4
  84. package/dist/commands/canvas-history/read.js +2 -2
  85. package/dist/commands/canvas-history/search.js +7 -7
  86. package/dist/commands/canvas-history/shared.d.ts +0 -1
  87. package/dist/commands/canvas-history/shared.js +1 -1
  88. package/dist/commands/canvas-history/stats.js +2 -2
  89. package/dist/commands/canvas-history.js +1 -1
  90. package/dist/commands/canvas.js +1 -1
  91. package/dist/commands/doc/delete.d.ts +2 -0
  92. package/dist/commands/doc/delete.js +1 -0
  93. package/dist/commands/doc/edit.d.ts +2 -0
  94. package/dist/commands/doc/edit.js +1 -0
  95. package/dist/commands/doc/history.d.ts +2 -0
  96. package/dist/commands/doc/history.js +2 -0
  97. package/dist/commands/doc/lint.d.ts +2 -0
  98. package/dist/commands/doc/lint.js +2 -0
  99. package/dist/commands/doc/list.d.ts +2 -0
  100. package/dist/commands/doc/list.js +1 -0
  101. package/dist/commands/doc/move.d.ts +2 -0
  102. package/dist/commands/doc/move.js +1 -0
  103. package/dist/commands/doc/read.d.ts +2 -0
  104. package/dist/commands/doc/read.js +1 -0
  105. package/dist/commands/doc/shared.d.ts +25 -0
  106. package/dist/commands/doc/shared.js +2 -0
  107. package/dist/commands/doc/write.d.ts +2 -0
  108. package/dist/commands/doc/write.js +1 -0
  109. package/dist/commands/{memory.d.ts → doc.d.ts} +1 -1
  110. package/dist/commands/doc.js +1 -0
  111. package/dist/commands/human/review.js +1 -1
  112. package/dist/commands/node/bash.js +2 -2
  113. package/dist/commands/node/create.js +1 -1
  114. package/dist/commands/node/inspect.js +10 -10
  115. package/dist/commands/node/lifecycle.js +2 -2
  116. package/dist/commands/node/outcome.js +1 -1
  117. package/dist/commands/node/subscription.js +1 -1
  118. package/dist/commands/node-context.js +2 -2
  119. package/dist/commands/pkg/browse/catalog.js +1 -1
  120. package/dist/commands/pkg/browse/doc-view.js +1 -1
  121. package/dist/commands/pkg/browse/model.d.ts +9 -17
  122. package/dist/commands/pkg/plugin-inspect.js +1 -1
  123. package/dist/commands/pkg/plugin-manage.d.ts +4 -8
  124. package/dist/commands/pkg/plugin-manage.js +15 -17
  125. package/dist/commands/profile/list.js +1 -1
  126. package/dist/commands/profile/new.js +1 -1
  127. package/dist/commands/profile/project.js +1 -1
  128. package/dist/commands/profile/show.js +1 -1
  129. package/dist/commands/push.js +3 -3
  130. package/dist/commands/sys/config.js +1 -1
  131. package/dist/commands/sys/context/admin/actions.d.ts +18 -43
  132. package/dist/commands/sys/context/admin/actions.js +1 -2
  133. package/dist/commands/sys/context/admin/detail-panel.d.ts +17 -25
  134. package/dist/commands/sys/context/admin/detail-panel.js +2 -1
  135. package/dist/commands/sys/context/admin/docs-panel.d.ts +7 -6
  136. package/dist/commands/sys/context/admin/docs-panel.js +1 -1
  137. package/dist/commands/sys/context/admin/list-view.d.ts +12 -12
  138. package/dist/commands/sys/context/admin/list-view.js +1 -1
  139. package/dist/commands/sys/context/admin/model.d.ts +96 -69
  140. package/dist/commands/sys/context/admin/model.js +1 -1
  141. package/dist/commands/sys/context/admin/rail-panel.d.ts +7 -5
  142. package/dist/commands/sys/context/admin/rail-panel.js +1 -1
  143. package/dist/commands/sys/context/admin/read-view.d.ts +10 -14
  144. package/dist/commands/sys/context/admin/read-view.js +1 -2
  145. package/dist/commands/sys/context/admin/shell.d.ts +26 -31
  146. package/dist/commands/sys/context/admin/shell.js +1 -1
  147. package/dist/commands/sys/context/admin.js +2 -2
  148. package/dist/commands/sys/context/doc.js +2 -3
  149. package/dist/commands/sys/context/expose.js +2 -2
  150. package/dist/commands/sys/context/prompt-review.js +4 -4
  151. package/dist/commands/sys/context/resolve.d.ts +92 -65
  152. package/dist/commands/sys/context/resolve.js +7 -9
  153. package/dist/commands/sys/context.js +1 -1
  154. package/dist/commands/sys/doctor.js +1 -1
  155. package/dist/commands/sys/migrate.js +1 -1
  156. package/dist/commands/sys/panels/profiles-panel.d.ts +3 -1
  157. package/dist/commands/sys/panels/profiles-panel.js +1 -1
  158. package/dist/commands/sys/sync-deps.d.ts +6 -11
  159. package/dist/commands/sys/sync-deps.js +7 -8
  160. package/dist/commands/sys/sync-project-guidance.js +5 -4
  161. package/dist/commands/sys/sync-shared.d.ts +41 -4
  162. package/dist/commands/sys/sync-shared.js +1 -1
  163. package/dist/commands/sys/sync-skills.js +2 -2
  164. package/dist/commands/sys/sync.js +1 -1
  165. package/dist/core/bash-job-supervisor.d.ts +2 -3
  166. package/dist/core/bash-job-supervisor.js +3 -3
  167. package/dist/core/bash-jobs.d.ts +0 -5
  168. package/dist/core/bash-jobs.js +7 -7
  169. package/dist/core/bootstrap.js +2 -2
  170. package/dist/core/canvas/canvas.d.ts +6 -50
  171. package/dist/core/canvas/canvas.js +16 -21
  172. package/dist/core/canvas/db.d.ts +4 -1
  173. package/dist/core/canvas/db.js +2 -2
  174. package/dist/core/canvas/history.d.ts +11 -39
  175. package/dist/core/canvas/history.js +9 -20
  176. package/dist/core/canvas/install-id.d.ts +2 -2
  177. package/dist/core/canvas/install-id.js +1 -1
  178. package/dist/core/canvas/memory-reads.d.ts +5 -0
  179. package/dist/core/canvas/memory-reads.js +1 -1
  180. package/dist/core/canvas/migrations.js +215 -41
  181. package/dist/core/canvas/node-agent-paths.js +1 -1
  182. package/dist/core/canvas/node-tokens.js +1 -1
  183. package/dist/core/canvas/paths.d.ts +0 -4
  184. package/dist/core/canvas/paths.js +1 -1
  185. package/dist/core/canvas/remote-canvas-source.d.ts +0 -1
  186. package/dist/core/canvas/remote-canvas-source.js +1 -1
  187. package/dist/core/canvas/render-source.d.ts +9 -6
  188. package/dist/core/canvas/render-source.js +6 -6
  189. package/dist/core/canvas/sessions.js +2 -2
  190. package/dist/core/canvas/source.d.ts +6 -0
  191. package/dist/core/canvas/tree.d.ts +29 -0
  192. package/dist/core/canvas/tree.js +12 -0
  193. package/dist/core/canvas/types.d.ts +0 -20
  194. package/dist/core/command-plugins/bundle.js +1 -1
  195. package/dist/core/config.d.ts +1 -1
  196. package/dist/core/conversation-store/listener.js +4 -2
  197. package/dist/core/feed/feed.d.ts +9 -7
  198. package/dist/core/feed/feed.js +3 -7
  199. package/dist/core/feed/inbox.d.ts +3 -5
  200. package/dist/core/feed/inbox.js +1 -10
  201. package/dist/core/feed/messages.d.ts +33 -6
  202. package/dist/core/feed/messages.js +10 -7
  203. package/dist/core/feed/reports.d.ts +10 -0
  204. package/dist/core/feed/reports.js +2 -0
  205. package/dist/core/grants/remove.js +1 -1
  206. package/dist/core/graph/access.d.ts +24 -0
  207. package/dist/core/graph/access.js +8 -0
  208. package/dist/core/graph/bodies.d.ts +6 -0
  209. package/dist/core/graph/bodies.js +1 -0
  210. package/dist/core/graph/deletion.d.ts +9 -0
  211. package/dist/core/graph/deletion.js +5 -0
  212. package/dist/core/graph/diff.d.ts +4 -0
  213. package/dist/core/graph/diff.js +4 -0
  214. package/dist/core/graph/documents.d.ts +160 -0
  215. package/dist/core/graph/documents.js +7 -0
  216. package/dist/core/graph/edges.d.ts +24 -0
  217. package/dist/core/graph/edges.js +1 -0
  218. package/dist/core/graph/events.d.ts +26 -0
  219. package/dist/core/graph/events.js +6 -0
  220. package/dist/core/graph/exposures.d.ts +53 -0
  221. package/dist/core/graph/exposures.js +4 -0
  222. package/dist/core/graph/jobs.d.ts +31 -0
  223. package/dist/core/graph/jobs.js +2 -0
  224. package/dist/core/graph/names.d.ts +28 -0
  225. package/dist/core/graph/names.js +3 -0
  226. package/dist/core/graph/objects.d.ts +55 -0
  227. package/dist/core/graph/objects.js +9 -0
  228. package/dist/core/graph/package-docs.d.ts +31 -0
  229. package/dist/core/graph/package-docs.js +5 -0
  230. package/dist/core/graph/package-files.d.ts +20 -0
  231. package/dist/core/graph/package-files.js +2 -0
  232. package/dist/core/graph/reader.d.ts +21 -0
  233. package/dist/core/graph/reader.js +3 -0
  234. package/dist/core/graph/repo-sync/exchange.d.ts +34 -0
  235. package/dist/core/graph/repo-sync/exchange.js +2 -0
  236. package/dist/core/graph/repo-sync/identity.d.ts +30 -0
  237. package/dist/core/graph/repo-sync/identity.js +1 -0
  238. package/dist/core/graph/repo-sync/index.d.ts +4 -0
  239. package/dist/core/graph/repo-sync/index.js +1 -0
  240. package/dist/core/graph/repo-sync/mirror.d.ts +30 -0
  241. package/dist/core/graph/repo-sync/mirror.js +6 -0
  242. package/dist/core/graph/repo-sync/ref-format.d.ts +76 -0
  243. package/dist/core/graph/repo-sync/ref-format.js +2 -0
  244. package/dist/core/graph/repo-sync/repos.d.ts +17 -0
  245. package/dist/core/graph/repo-sync/repos.js +3 -0
  246. package/dist/core/graph/repo-sync/sync.d.ts +42 -0
  247. package/dist/core/graph/repo-sync/sync.js +2 -0
  248. package/dist/core/graph/rules.d.ts +26 -0
  249. package/dist/core/graph/rules.js +3 -0
  250. package/dist/core/graph/spaces/app.d.ts +3 -0
  251. package/dist/core/graph/spaces/app.js +1 -0
  252. package/dist/core/graph/spaces/index.d.ts +19 -0
  253. package/dist/core/graph/spaces/index.js +1 -0
  254. package/dist/core/graph/spaces/person.d.ts +5 -0
  255. package/dist/core/graph/spaces/person.js +2 -0
  256. package/dist/core/graph/spaces/repo.d.ts +4 -0
  257. package/dist/core/graph/spaces/repo.js +1 -0
  258. package/dist/core/graph/types.d.ts +75 -0
  259. package/dist/core/graph/types.js +1 -0
  260. package/dist/core/graph/watches.d.ts +62 -0
  261. package/dist/core/graph/watches.js +18 -0
  262. package/dist/core/human/feedback-companion.js +1 -1
  263. package/dist/core/human/requests.d.ts +3 -1
  264. package/dist/core/human/requests.js +6 -6
  265. package/dist/core/inspector/model.js +2 -2
  266. package/dist/core/io.js +5 -5
  267. package/dist/core/layout-migrate/index.d.ts +24 -1
  268. package/dist/core/layout-migrate/index.js +4 -4
  269. package/dist/core/layout-migrate/paths.d.ts +4 -0
  270. package/dist/core/layout-migrate/paths.js +1 -1
  271. package/dist/core/layout-migrate/stored-paths.d.ts +7 -0
  272. package/dist/core/layout-migrate/stored-paths.js +11 -11
  273. package/dist/core/layout-migrate/stores.d.ts +19 -6
  274. package/dist/core/layout-migrate/stores.js +3 -4
  275. package/dist/core/manifest.d.ts +0 -2
  276. package/dist/core/manifest.js +1 -1
  277. package/dist/core/{memory/extensions.d.ts → plugin-extensions.d.ts} +9 -10
  278. package/dist/core/plugin-extensions.js +1 -0
  279. package/dist/core/preview-registry.d.ts +1 -1
  280. package/dist/core/preview-registry.js +3 -2
  281. package/dist/core/profiles/manifest.d.ts +7 -7
  282. package/dist/core/profiles/manifest.js +1 -1
  283. package/dist/core/profiles/select.js +3 -3
  284. package/dist/core/review/birth.js +1 -1
  285. package/dist/core/review/companion.js +1 -1
  286. package/dist/core/review/stage.d.ts +12 -1
  287. package/dist/core/review/stage.js +1 -1
  288. package/dist/core/review/store.d.ts +2 -0
  289. package/dist/core/review/store.js +1 -1
  290. package/dist/core/review/types.d.ts +7 -1
  291. package/dist/core/runs/events.js +1 -1
  292. package/dist/core/runs/operations.js +5 -5
  293. package/dist/core/runs/questions.js +2 -2
  294. package/dist/core/runtime/bearings-render.d.ts +13 -7
  295. package/dist/core/runtime/bearings-render.js +12 -12
  296. package/dist/core/runtime/bearings.d.ts +8 -18
  297. package/dist/core/runtime/bearings.js +7 -7
  298. package/dist/core/runtime/broker/daemon-ops.d.ts +7 -12
  299. package/dist/core/runtime/broker/daemon-ops.js +1 -1
  300. package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
  301. package/dist/core/runtime/broker/fault-retry.js +1 -1
  302. package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
  303. package/dist/core/runtime/broker/frame-memory-refs.d.ts +7 -2
  304. package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
  305. package/dist/core/runtime/broker/inbox.d.ts +1 -4
  306. package/dist/core/runtime/broker/inbox.js +1 -10
  307. package/dist/core/runtime/broker/rebind.js +1 -1
  308. package/dist/core/runtime/broker/retry-card-elision.d.ts +7 -0
  309. package/dist/core/runtime/broker/retry-card-elision.js +1 -0
  310. package/dist/core/runtime/broker-extension-render.d.ts +0 -13
  311. package/dist/core/runtime/broker-extension-render.js +2 -4
  312. package/dist/core/runtime/broker-persona-guidance.js +3 -3
  313. package/dist/core/runtime/broker-protocol.d.ts +1 -1
  314. package/dist/core/runtime/broker.js +1 -1
  315. package/dist/core/runtime/close.d.ts +9 -4
  316. package/dist/core/runtime/close.js +1 -1
  317. package/dist/core/runtime/deliver-live.js +1 -1
  318. package/dist/core/runtime/kickoff.js +17 -19
  319. package/dist/core/runtime/launch-target.d.ts +7 -0
  320. package/dist/core/runtime/launch-target.js +1 -1
  321. package/dist/core/runtime/ledger.d.ts +10 -0
  322. package/dist/core/runtime/ledger.js +3 -0
  323. package/dist/core/runtime/lifecycle.js +2 -2
  324. package/dist/core/runtime/nodes.d.ts +10 -2
  325. package/dist/core/runtime/nodes.js +1 -1
  326. package/dist/core/runtime/outcome-document.d.ts +2 -2
  327. package/dist/core/runtime/outcome-document.js +1 -1
  328. package/dist/core/runtime/persona.js +2 -2
  329. package/dist/core/runtime/placement.js +1 -1
  330. package/dist/core/runtime/promote.d.ts +2 -2
  331. package/dist/core/runtime/promote.js +1 -1
  332. package/dist/core/runtime/prospective-inventory-cli.js +2 -2
  333. package/dist/core/runtime/recycle.js +1 -1
  334. package/dist/core/runtime/reopen.js +1 -1
  335. package/dist/core/runtime/revive.js +2 -2
  336. package/dist/core/runtime/roadmap.d.ts +17 -9
  337. package/dist/core/runtime/roadmap.js +4 -4
  338. package/dist/core/runtime/spawn-env.js +1 -1
  339. package/dist/core/runtime/spawn.d.ts +5 -3
  340. package/dist/core/runtime/spawn.js +2 -2
  341. package/dist/core/runtime/structured-output.d.ts +3 -1
  342. package/dist/core/runtime/structured-output.js +4 -4
  343. package/dist/core/scope.d.ts +1 -32
  344. package/dist/core/scope.js +1 -1
  345. package/dist/core/scoped-state/db.js +2 -1
  346. package/dist/core/scoped-state/migrate.js +2 -2
  347. package/dist/core/scoped-state/profiles.d.ts +11 -0
  348. package/dist/core/scoped-state/profiles.js +1 -1
  349. package/dist/core/scoped-state/schema.d.ts +1 -1
  350. package/dist/core/scoped-state/schema.js +7 -5
  351. package/dist/core/spaces/permissions.d.ts +0 -14
  352. package/dist/core/spaces/permissions.js +1 -1
  353. package/dist/core/spaces/stop.d.ts +13 -0
  354. package/dist/core/spaces/stop.js +2 -2
  355. package/dist/core/storage/tables.d.ts +1 -1
  356. package/dist/core/substrate/delivery/corpus.d.ts +21 -0
  357. package/dist/core/substrate/delivery/corpus.js +3 -0
  358. package/dist/core/substrate/delivery/deliver.d.ts +76 -0
  359. package/dist/core/substrate/delivery/deliver.js +6 -0
  360. package/dist/core/substrate/delivery/listings.d.ts +27 -0
  361. package/dist/core/substrate/delivery/listings.js +4 -0
  362. package/dist/core/substrate/delivery/match.d.ts +28 -0
  363. package/dist/core/substrate/delivery/match.js +1 -0
  364. package/dist/core/substrate/delivery/plan.d.ts +67 -0
  365. package/dist/core/substrate/delivery/plan.js +3 -0
  366. package/dist/core/substrate/delivery/render-boot.d.ts +20 -0
  367. package/dist/core/substrate/delivery/render-boot.js +54 -0
  368. package/dist/core/substrate/delivery/render-event.d.ts +47 -0
  369. package/dist/core/substrate/delivery/render-event.js +6 -0
  370. package/dist/core/substrate/delivery/sub-persona-menu.d.ts +2 -0
  371. package/dist/core/substrate/delivery/sub-persona-menu.js +6 -0
  372. package/dist/core/substrate/delivery/types.d.ts +30 -0
  373. package/dist/core/substrate/delivery/types.js +0 -0
  374. package/dist/core/substrate/gate-explain.d.ts +0 -13
  375. package/dist/core/substrate/gate-explain.js +1 -1
  376. package/dist/core/substrate/schema.d.ts +11 -139
  377. package/dist/core/substrate/schema.js +1 -1
  378. package/dist/core/substrate/subject-fields.d.ts +3 -0
  379. package/dist/core/substrate/subject.d.ts +2 -1
  380. package/dist/core/substrate/subject.js +1 -1
  381. package/dist/daemon/api/app-listener.js +11 -11
  382. package/dist/daemon/api/handlers/app-profiles.js +1 -1
  383. package/dist/daemon/api/handlers/bash-jobs.js +1 -2
  384. package/dist/daemon/api/handlers/broker-ops.js +1 -1
  385. package/dist/daemon/api/handlers/canvas.js +5 -5
  386. package/dist/daemon/api/handlers/daemon.js +1 -1
  387. package/dist/daemon/api/handlers/delivery.d.ts +2 -0
  388. package/dist/daemon/api/handlers/delivery.js +1 -0
  389. package/dist/daemon/api/handlers/{memory.d.ts → docs.d.ts} +1 -1
  390. package/dist/daemon/api/handlers/docs.js +1 -0
  391. package/dist/daemon/api/handlers/hook-exec.js +1 -1
  392. package/dist/daemon/api/handlers/messages.js +2 -2
  393. package/dist/daemon/api/handlers/modelauth.d.ts +3 -0
  394. package/dist/daemon/api/handlers/modelauth.js +1 -1
  395. package/dist/daemon/api/handlers/node-records.js +2 -2
  396. package/dist/daemon/api/handlers/nodes.js +1 -1
  397. package/dist/daemon/api/handlers/objects.d.ts +2 -0
  398. package/dist/daemon/api/handlers/objects.js +5 -0
  399. package/dist/daemon/api/handlers/package-docs.d.ts +2 -0
  400. package/dist/daemon/api/handlers/package-docs.js +1 -0
  401. package/dist/daemon/api/handlers/profiles.js +1 -1
  402. package/dist/daemon/api/handlers/reports.d.ts +2 -2
  403. package/dist/daemon/api/handlers/reports.js +4 -4
  404. package/dist/daemon/api/handlers/reviews.js +1 -1
  405. package/dist/daemon/api/handlers/vendor-status.d.ts +8 -0
  406. package/dist/daemon/api/handlers/vendor-status.js +1 -0
  407. package/dist/daemon/api/map.d.ts +2 -2
  408. package/dist/daemon/api/map.js +2 -2
  409. package/dist/daemon/api/operations.d.ts +1 -1
  410. package/dist/daemon/api/operations.js +1 -1
  411. package/dist/daemon/api/principal.d.ts +5 -0
  412. package/dist/daemon/api/principal.js +1 -1
  413. package/dist/daemon/api/reader.d.ts +17 -0
  414. package/dist/daemon/api/reader.js +1 -0
  415. package/dist/daemon/api/server.js +1 -1
  416. package/dist/daemon/control.d.ts +2 -3
  417. package/dist/daemon/crtrd.js +8 -6
  418. package/dist/daemon/fleet.js +4 -4
  419. package/dist/daemon/reconcilers/bash-deadline.d.ts +11 -1
  420. package/dist/daemon/reconcilers/bash-deadline.js +2 -1
  421. package/dist/daemon/reconcilers/broker-supervision.js +4 -4
  422. package/dist/daemon/reconcilers/live-obligation.js +1 -1
  423. package/dist/daemon/reconcilers/node-deadline.js +1 -1
  424. package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
  425. package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -0
  426. package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
  427. package/dist/daemon/review/deliver.js +2 -2
  428. package/dist/daemon/review/finish.js +1 -1
  429. package/dist/hook-authoring.d.ts +0 -1
  430. package/dist/hook-authoring.js +3 -3
  431. package/dist/migrations/004-canvas-documents/apply.d.ts +10 -0
  432. package/dist/migrations/004-canvas-documents/apply.js +1 -0
  433. package/dist/migrations/004-canvas-documents/fields.d.ts +24 -0
  434. package/dist/migrations/004-canvas-documents/fields.js +2 -0
  435. package/dist/migrations/004-canvas-documents/index.d.ts +16 -0
  436. package/dist/migrations/004-canvas-documents/index.js +2 -0
  437. package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +16 -0
  438. package/dist/migrations/004-canvas-documents/legacy/discover.js +1 -0
  439. package/dist/migrations/004-canvas-documents/legacy/history.d.ts +5 -0
  440. package/dist/migrations/004-canvas-documents/legacy/history.js +2 -0
  441. package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +7 -0
  442. package/dist/migrations/004-canvas-documents/legacy/nested.js +1 -0
  443. package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +14 -0
  444. package/dist/migrations/004-canvas-documents/legacy/parse.js +1 -0
  445. package/dist/migrations/004-canvas-documents/legacy/types.d.ts +91 -0
  446. package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
  447. package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +6 -0
  448. package/dist/migrations/004-canvas-documents/legacy-edges.js +18 -0
  449. package/dist/migrations/004-canvas-documents/plan.d.ts +102 -0
  450. package/dist/migrations/004-canvas-documents/plan.js +3 -0
  451. package/dist/migrations/004-canvas-documents/pointers.d.ts +23 -0
  452. package/dist/migrations/004-canvas-documents/pointers.js +4 -0
  453. package/dist/migrations/activation.d.ts +9 -18
  454. package/dist/migrations/activation.js +2 -2
  455. package/dist/pi-extensions/broker-local.d.ts +2 -2
  456. package/dist/pi-extensions/broker-local.js +2 -2
  457. package/dist/pi-extensions/canvas-bash-valve.js +5 -4
  458. package/dist/pi-extensions/canvas-context-intro.js +2 -2
  459. package/dist/pi-extensions/canvas-doc-substrate.d.ts +0 -1
  460. package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
  461. package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
  462. package/dist/pi-extensions/canvas-passive-context.js +1 -1
  463. package/dist/pi-extensions/canvas-recap.js +2 -2
  464. package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
  465. package/dist/pi-extensions/canvas-stophook.js +1 -1
  466. package/dist/prompts/review.js +3 -3
  467. package/dist/shared/env.d.ts +5 -0
  468. package/dist/shared/env.js +1 -1
  469. package/dist/shared/generated-context.js +2 -10
  470. package/dist/shared/inbox-entry-body.d.ts +22 -0
  471. package/dist/shared/inbox-entry-body.js +10 -0
  472. package/dist/{core/memory → shared}/inline-ref-guidance.d.ts +2 -2
  473. package/dist/shared/inline-ref-guidance.js +2 -0
  474. package/dist/types.d.ts +3 -1
  475. package/docs/cli/memory-and-preferences.md +12 -14
  476. package/docs/concepts/README.md +1 -1
  477. package/docs/concepts/lifecycle-and-wakes.md +1 -1
  478. package/docs/concepts/memory.md +15 -15
  479. package/docs/concepts/nodes-and-the-canvas.md +1 -1
  480. package/docs/concepts/profiles-kinds-and-modes.md +5 -5
  481. package/docs/concepts/scopes-and-trust.md +1 -1
  482. package/docs/concepts/why-a-daemon.md +1 -1
  483. package/docs/sdk/README.md +5 -6
  484. package/docs/sdk/errors.md +0 -13
  485. package/docs/sdk/guides/README.md +0 -1
  486. package/docs/sdk/nodes.md +0 -2
  487. package/docs/sdk/resources.md +0 -1
  488. package/package.json +2 -2
  489. package/packages/crouter-identity/package.json +1 -1
  490. package/runtime.lock.json +11 -11
  491. package/dist/api/dto/memory.d.ts +0 -171
  492. package/dist/api/dto/memory.js +0 -1
  493. package/dist/builtin-memory/crouter-sdk/guides/app-memory.md +0 -73
  494. package/dist/builtin-memory/crouter-sdk/memory.md +0 -87
  495. package/dist/commands/broker-permissions.d.ts +0 -2
  496. package/dist/commands/broker-permissions.js +0 -1
  497. package/dist/commands/memory/client.d.ts +0 -11
  498. package/dist/commands/memory/client.js +0 -1
  499. package/dist/commands/memory/delete.d.ts +0 -1
  500. package/dist/commands/memory/delete.js +0 -1
  501. package/dist/commands/memory/edit.d.ts +0 -1
  502. package/dist/commands/memory/edit.js +0 -21
  503. package/dist/commands/memory/find.d.ts +0 -1
  504. package/dist/commands/memory/find.js +0 -1
  505. package/dist/commands/memory/history.d.ts +0 -1
  506. package/dist/commands/memory/history.js +0 -5
  507. package/dist/commands/memory/lint.d.ts +0 -1
  508. package/dist/commands/memory/lint.js +0 -1
  509. package/dist/commands/memory/list.d.ts +0 -1
  510. package/dist/commands/memory/list.js +0 -1
  511. package/dist/commands/memory/move.d.ts +0 -1
  512. package/dist/commands/memory/move.js +0 -1
  513. package/dist/commands/memory/origin.d.ts +0 -1
  514. package/dist/commands/memory/origin.js +0 -1
  515. package/dist/commands/memory/read.d.ts +0 -1
  516. package/dist/commands/memory/read.js +0 -6
  517. package/dist/commands/memory/shared.d.ts +0 -22
  518. package/dist/commands/memory/shared.js +0 -1
  519. package/dist/commands/memory/write.d.ts +0 -1
  520. package/dist/commands/memory/write.js +0 -13
  521. package/dist/commands/memory.js +0 -1
  522. package/dist/commands/node-inspect-artifacts.d.ts +0 -1
  523. package/dist/commands/node-inspect-artifacts.js +0 -8
  524. package/dist/core/help/memory-extensions.d.ts +0 -3
  525. package/dist/core/help/memory-extensions.js +0 -2
  526. package/dist/core/memory/cli-selector.d.ts +0 -13
  527. package/dist/core/memory/cli-selector.js +0 -1
  528. package/dist/core/memory/doc-link-grammar.d.ts +0 -20
  529. package/dist/core/memory/doc-link-grammar.js +0 -2
  530. package/dist/core/memory/extensions.js +0 -1
  531. package/dist/core/memory/history.d.ts +0 -87
  532. package/dist/core/memory/history.js +0 -6
  533. package/dist/core/memory/identity.d.ts +0 -65
  534. package/dist/core/memory/identity.js +0 -1
  535. package/dist/core/memory/inline-ref-guidance.js +0 -2
  536. package/dist/core/memory/inline-ref-inventory.d.ts +0 -9
  537. package/dist/core/memory/inline-ref-inventory.js +0 -1
  538. package/dist/core/memory/lint.d.ts +0 -163
  539. package/dist/core/memory/lint.js +0 -2
  540. package/dist/core/memory/mutation-domain.d.ts +0 -113
  541. package/dist/core/memory/mutation-domain.js +0 -12
  542. package/dist/core/memory/mutations.d.ts +0 -74
  543. package/dist/core/memory/mutations.js +0 -1
  544. package/dist/core/memory/project-namespace.d.ts +0 -31
  545. package/dist/core/memory/project-namespace.js +0 -2
  546. package/dist/core/memory/repository-association.d.ts +0 -31
  547. package/dist/core/memory/repository-association.js +0 -1
  548. package/dist/core/memory/service.d.ts +0 -145
  549. package/dist/core/memory/service.js +0 -2
  550. package/dist/core/memory/tree.d.ts +0 -39
  551. package/dist/core/memory/tree.js +0 -1
  552. package/dist/core/memory-resolver.d.ts +0 -280
  553. package/dist/core/memory-resolver.js +0 -2
  554. package/dist/core/nested-stores.d.ts +0 -18
  555. package/dist/core/nested-stores.js +0 -1
  556. package/dist/core/runtime/memory.d.ts +0 -3
  557. package/dist/core/runtime/memory.js +0 -1
  558. package/dist/core/substrate/frontmatter-validation.d.ts +0 -11
  559. package/dist/core/substrate/frontmatter-validation.js +0 -1
  560. package/dist/core/substrate/gate.d.ts +0 -16
  561. package/dist/core/substrate/gate.js +0 -1
  562. package/dist/core/substrate/index.d.ts +0 -18
  563. package/dist/core/substrate/index.js +0 -1
  564. package/dist/core/substrate/injected-store.d.ts +0 -75
  565. package/dist/core/substrate/injected-store.js +0 -2
  566. package/dist/core/substrate/listings.d.ts +0 -28
  567. package/dist/core/substrate/listings.js +0 -1
  568. package/dist/core/substrate/memory-events.d.ts +0 -6
  569. package/dist/core/substrate/memory-events.js +0 -1
  570. package/dist/core/substrate/on-read-node.d.ts +0 -6
  571. package/dist/core/substrate/on-read-node.js +0 -1
  572. package/dist/core/substrate/on-read.d.ts +0 -101
  573. package/dist/core/substrate/on-read.js +0 -9
  574. package/dist/core/substrate/plan.d.ts +0 -94
  575. package/dist/core/substrate/plan.js +0 -1
  576. package/dist/core/substrate/render-node.d.ts +0 -12
  577. package/dist/core/substrate/render-node.js +0 -1
  578. package/dist/core/substrate/render.d.ts +0 -41
  579. package/dist/core/substrate/render.js +0 -65
  580. package/dist/core/substrate/session-cache.d.ts +0 -27
  581. package/dist/core/substrate/session-cache.js +0 -1
  582. package/dist/core/substrate/surface-match.d.ts +0 -73
  583. package/dist/core/substrate/surface-match.js +0 -1
  584. package/dist/daemon/api/handlers/memory.js +0 -5
  585. package/dist/migrations/001-surfaces-frontmatter.d.ts +0 -2
  586. package/dist/migrations/001-surfaces-frontmatter.js +0 -1
  587. package/dist/migrations/002-profile-project-memory.d.ts +0 -2
  588. package/dist/migrations/002-profile-project-memory.js +0 -1
  589. package/dist/migrations/003-repository-root-memory-identity/front-door.d.ts +0 -26
  590. package/dist/migrations/003-repository-root-memory-identity/front-door.js +0 -11
  591. package/dist/migrations/003-repository-root-memory-identity/index.d.ts +0 -2
  592. package/dist/migrations/003-repository-root-memory-identity/index.js +0 -5
  593. package/dist/migrations/003-repository-root-memory-identity/references.d.ts +0 -95
  594. package/dist/migrations/003-repository-root-memory-identity/references.js +0 -5
  595. package/dist/migrations/003-repository-root-memory-identity/repository-facts.d.ts +0 -39
  596. package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +0 -3
  597. package/dist/migrations/convergent.d.ts +0 -43
  598. package/dist/migrations/convergent.js +0 -2
  599. package/dist/migrations/corpus.d.ts +0 -75
  600. package/dist/migrations/corpus.js +0 -3
  601. package/dist/migrations/frontmatter-splice.d.ts +0 -15
  602. package/dist/migrations/frontmatter-splice.js +0 -8
  603. package/dist/migrations/profile-manifests.d.ts +0 -30
  604. package/dist/migrations/profile-manifests.js +0 -2
  605. package/dist/migrations/registry.d.ts +0 -7
  606. package/dist/migrations/registry.js +0 -1
  607. package/dist/migrations/runner.d.ts +0 -43
  608. package/dist/migrations/runner.js +0 -1
  609. package/dist/migrations/types.d.ts +0 -211
  610. package/dist/shared/birth-announcement.d.ts +0 -12
  611. package/dist/shared/birth-announcement.js +0 -1
  612. package/docs/sdk/guides/app-memory.md +0 -22
  613. package/docs/sdk/memory.md +0 -85
  614. /package/dist/{migrations/types.js → api/dto/delivery.js} +0 -0
  615. /package/dist/{core/memory → shared}/inline-ref-grammar.d.ts +0 -0
  616. /package/dist/{core/memory → shared}/inline-ref-grammar.js +0 -0
@@ -1,2 +0,0 @@
1
- import type { ProfileManifestMigration } from './types.js';
2
- export declare const profileProjectMemoryMigration: ProfileManifestMigration;
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var a=(r,o)=>m(r,"name",{value:o,configurable:!0});import{PROFILE_PROJECT_MEMORY_VALUES as p}from"../api/dto/profiles.js";import{usage as l}from"../core/errors.js";const y="root-00000000";function t(r,o){return l(`profile manifest cannot be migrated: ${o}`,{received:r.path,field:"projects",next:`Fix ${r.path} by hand \u2014 every project entry is a string (pre-migration) or {"path": "/abs/dir", "memory": one of ${p.join(", ")}} \u2014 then re-run \`crtr sys migrate\`.`})}a(t,"malformed");function h(r){return typeof r=="string"&&p.includes(r)}a(h,"isMemory");const u={id:"002-profile-project-memory",lane:"profile-manifest",description:"profile projects carry an explicit memory value",apply(r){const o=r.raw.projects;if(!Array.isArray(o))throw t(r,`projects is ${o===void 0?"missing":typeof o}, not an array`);const f=r.profileId===y?"preview":"content";let n=!1;const c=o.map(e=>{if(typeof e=="string"){if(e.trim()==="")throw t(r,"a project entry is an empty path");return n=!0,{path:e,memory:f}}if(typeof e!="object"||e===null||Array.isArray(e))throw t(r,`a project entry is ${e===null?"null":typeof e}`);const{path:i,memory:s}=e;if(typeof i!="string"||i.trim()==="")throw t(r,`a project entry has no path: ${JSON.stringify(e)}`);if(!h(s))throw t(r,`project ${i} has an unknown memory value: ${JSON.stringify(s)}`);return e});return n?{...r.raw,projects:c}:null}};export{u as profileProjectMemoryMigration};
@@ -1,26 +0,0 @@
1
- import type { CorpusBlocker, CorpusSnapshot, FrontDoorAction } from '../types.js';
2
- import type { RepositoryDecision, StorePrefixFacts } from './repository-facts.js';
3
- export interface FrontDoorPlan {
4
- repositoryRoot: string;
5
- /** The repository-root store's key. */
6
- storeKey: string;
7
- rootDocPath: string;
8
- rootAction: 'kept' | 'created' | 'completed';
9
- /** The unique legacy front door whose workspace-open entries this run removes. It may live
10
- * in a nested store of the same repository, so it carries its own store key. */
11
- leafDocPath: string | null;
12
- leafStoreKey: string | null;
13
- /** The leaf's FINAL canonical name, for the created root body's `[[link]]`. */
14
- leafCanonicalName: string | null;
15
- action: FrontDoorAction;
16
- }
17
- export declare function planFrontDoors(repositories: readonly RepositoryDecision[], prefixes: ReadonlyMap<string, StorePrefixFacts>, corpus: CorpusSnapshot, finalNameOf: (realPath: string) => string | undefined): {
18
- plans: FrontDoorPlan[];
19
- blockers: CorpusBlocker[];
20
- };
21
- /** New repository-root INDEX.md source. `leafCanonicalName` null yields the generic minimal root body. */
22
- export declare function rootIndexSource(namespace: string, leafCanonicalName: string | null): string;
23
- /** Add the missing half or halves of the root front-door pair to a complete document source. */
24
- export declare function completeRootFrontDoor(source: string, docPath: string): string;
25
- /** Remove every workspace-open entry while preserving the body and every retained authored YAML byte. */
26
- export declare function demoteLeafSurfaces(source: string, docPath: string): string;
@@ -1,11 +0,0 @@
1
- var q=Object.defineProperty;var r=(o,e)=>q(o,"name",{value:e,configurable:!0});import{join as v,relative as B}from"node:path";import{parse as M,stringify as G}from"yaml";import{realpathOrSelf as O}from"../../core/fs-utils.js";import{parseFrontmatterGeneric as W}from"../../core/frontmatter.js";import{localNameFromPath as J}from"../../core/memory/identity.js";import{appendRenderedKey as X,dropSequenceItems as z,dropTopLevelKeys as H,proveFrontmatterRoundTrip as Q,rebuildDocSource as T,splitDocSource as Y}from"../frontmatter-splice.js";function R(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)?o:null}r(R,"record");function j(o){const e=o?.surfaces;return e===void 0?[]:Array.isArray(e)?e.map(R).filter(t=>t!==null):null}r(j,"surfaceEntries");function U(o){return o==="./**"||Array.isArray(o)&&o.includes("./**")}r(U,"matchIncludesOwnerTree");function I(o){return o.some(e=>e.on==="workspace-open"&&e.at==="content")}r(I,"hasWorkspaceOpen");function N(o){return o.some(e=>e.on==="read"&&e.at==="content"&&U(e.match))}r(N,"hasOwnerRead");function C(o){const e=j(o);return e!==null&&I(e)&&N(e)}r(C,"hasCompleteFrontDoor");function V(o){const e=j(o);return e===null?!0:e.some(t=>t.on!=="workspace-open"?!1:t.at!=="content"||Object.hasOwn(t,"match")||Object.hasOwn(t,"gate")||Object.hasOwn(t,"match-frontmatter"))}r(V,"conflictingRootWorkspaceOpen");function Z(o,e){for(const[t,a]of e)if(a.repositoryRoot===o&&a.ownerRelativePath==="")return t;return O(v(o,".crouter","memory"))}r(Z,"rootStoreKey");function _(o,e){return B(o,e).replace(/\\/g,"/")}r(_,"repositoryRelativePath");function $(o,e,t){return{kind:"front-door",message:o,storeRoot:v(t,".crouter","memory"),...e.length===1?{path:e[0]}:{},paths:[...e]}}r($,"frontDoorBlocker");function lo(o,e,t,a){const d=[],u=[];for(const n of o){const y=v(n.repositoryRoot,".crouter","memory","INDEX.md"),f=O(y),p=Z(n.repositoryRoot,e);let s=null;const D=new Map,b=new Map;for(const c of n.storeKeys){const i=e.get(c);if(i===void 0||i.repositoryRoot!==n.repositoryRoot)continue;const k=i.store??t.store(c);if(!(k===void 0||!k.writable)&&!(k.descriptor.scope!=="project"||k.descriptor.plugin!==void 0))for(const h of k.snapshot.docs){const g=O(h.path);if(g===f){s=h;continue}if(i.nestedDeclarationAction==="synthetic-index-removed"&&J(h.relPath)==="")continue;const x={doc:h,storeKey:c,realPath:g};j(h.frontmatter)?.some(E=>E.on==="workspace-open"&&E.at==="content")&&D.set(g,x),C(h.frontmatter)&&b.set(g,x)}}const w=[...b.values()],m=[];if(w.length>1){const c=w.map(i=>i.doc.path);m.push($(`repository ${n.repositoryRoot} has more than one non-root document carrying the complete workspace front door (${c.join(", ")}) \u2014 keep one source guide as the transfer source, remove the other workspace-open entries, and re-run`,c,n.repositoryRoot))}const A=[...D.values()].filter(c=>!b.has(c.realPath));if(A.length>0){const c=A.map(i=>i.doc.path);m.push($(`repository ${n.repositoryRoot} has non-root workspace-open documents without the complete owner-read pair (${c.join(", ")}) \u2014 complete exactly one legacy front door or remove these workspace-open entries, then re-run`,c,n.repositoryRoot))}if(s!==null&&V(s.frontmatter)){const c=[s.path,...w.map(i=>i.doc.path)];m.push($(`repository-root guide ${s.path} carries a workspace-open route that migration cannot make authoritative without changing its predicate \u2014 make every root workspace-open entry exactly {on: workspace-open, at: content} and re-run`,c,n.repositoryRoot))}const l=w.length===1?w[0]:null,K=l===null?null:a(l.realPath);if(l!==null&&K===void 0&&m.push($(`legacy workspace front door ${l.doc.path} has no provable final canonical name \u2014 repair its identity blocker and re-run`,[l.doc.path],n.repositoryRoot)),m.length>0){u.push(...m);continue}const S=s!==null&&C(s.frontmatter),L=s===null?"created":S?"kept":"completed",F=l===null?null:_(n.repositoryRoot,l.doc.path),P=F!==null?`transferred-from:${F}`:S?"kept-root":"created-root";d.push({repositoryRoot:n.repositoryRoot,storeKey:p,rootDocPath:y,rootAction:L,leafDocPath:l?.doc.path??null,leafStoreKey:l?.storeKey??null,leafCanonicalName:K??null,action:P})}return{plans:d,blockers:u}}r(lo,"planFrontDoors");function uo(o,e){const t=o.split("/").at(-1)??o,a=e===null?`# ${t}
2
-
3
- This project's memory store. Every document here answers at \`${o}/<local name>\`.
4
- `:`# ${t}
5
-
6
- This project's memory store. Every document here answers at \`${o}/<local name>\`. Read [[${e}]] for the detailed project guide.
7
- `;return["---",`namespace: ${JSON.stringify(o)}`,"kind: knowledge",`when-and-why-to-read: When working in \`${o}\`, this knowledge should be read because it names the namespace every document in this repository answers under.`,"surfaces:"," - on: workspace-open"," at: content"," - on: read",' match: "./**"'," at: content","---","",a].join(`
8
- `)}r(uo,"rootIndexSource");function oo(o){return W(o).data===null?`---
9
-
10
- ---
11
- ${o}`:o}r(oo,"sourceWithFrontmatter");function eo(o,e){let t;try{t=M(o===""?"{}":o)}catch(a){throw new Error(`front-door migration: unparseable frontmatter in ${e}`,{cause:a})}if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`front-door migration: frontmatter is not a mapping in ${e}`);return t}r(eo,"parsedYamlRecord");function fo(o,e){const t=oo(o),{rawYaml:a}=Y(t,e),d=eo(a,e),u=d.surfaces;if(u!==void 0&&!Array.isArray(u))throw new Error(`front-door migration: surfaces is not a sequence in ${e}`);const n=u===void 0?[]:u.map(s=>R(s)??s),y=n.filter(s=>R(s)!==null),f=[...n];if(I(y)||f.push({on:"workspace-open",at:"content"}),N(y)||f.push({on:"read",match:"./**",at:"content"}),f.length===n.length)return t;let p=a;return u!==void 0&&(p=H(p,["surfaces"],e)),p=p===""?G({surfaces:f},{lineWidth:0}).replace(/\r?\n$/,""):X(p,"surfaces",f,e),Q(p,{...d,surfaces:f},e),T(t,p,e)}r(fo,"completeRootFrontDoor");function mo(o,e){if(W(o).data===null)return o;const{rawYaml:t}=Y(o,e),a=z(t,"surfaces",d=>R(d)?.on==="workspace-open",e);return a===t?o:T(o,a,e)}r(mo,"demoteLeafSurfaces");export{fo as completeRootFrontDoor,mo as demoteLeafSurfaces,lo as planFrontDoors,uo as rootIndexSource};
@@ -1,2 +0,0 @@
1
- import type { CorpusMigration } from '../types.js';
2
- export declare const repositoryRootMemoryIdentityMigration: CorpusMigration;
@@ -1,5 +0,0 @@
1
- var K=Object.defineProperty;var f=(e,o)=>K(e,"name",{value:o,configurable:!0});import{existsSync as A,readFileSync as j}from"node:fs";import{dirname as N,matchesGlob as z}from"node:path";import{realpathOrSelf as g}from"../../core/fs-utils.js";import{parseFrontmatterGeneric as O}from"../../core/frontmatter.js";import{loadStoreMemoryDocs as T,openProjectMemoryStore as B}from"../../core/memory-resolver.js";import{canonicalSegments as G,composeCanonicalName as $,explicitLocalName as _,INDEX_SEGMENT as Y,localNameFromPath as J,normalizeDocName as U,normalizeNameSegment as X,resolveLocalName as q,stripNamespace as H,validateExplicitLocalName as Q,validateNamespace as V}from"../../core/memory/identity.js";import{lintMemoryStore as W,MEMORY_LINT_IDENTITY_RULES as Z,resolvableCanonicalNames as ee}from"../../core/memory/lint.js";import{completeRootFrontDoor as te,demoteLeafSurfaces as oe,planFrontDoors as ne,rootIndexSource as re}from"./front-door.js";import{planRepositories as ae}from"./repository-facts.js";import{applySplices as S,itemFor as D,keyLineSpan as E,linkRewrites as ie,OldCorpus as se,renderScalar as v,routeRewrites as ce,valueSpan as M,viewsForStore as le,yamlBlock as pe,yamlMap as de}from"./references.js";let h={links:[],routes:[],wrote:new Set,repositories:[]};function F(e=[]){return{blockers:e,consumers:[],identities:[],repositories:[],storePrefixes:[],renames:[],references:[]}}f(F,"emptyPlan");function fe(e){return G(e.replace(/\\/g,"/").replace(/\.md$/i,"")).map(X).join("/")}f(fe,"pathNameNoCollapse");function me(e){const o=e.frontmatter?.name;return typeof o=="string"&&o.trim()!==""?o.trim():null}f(me,"rawExplicitName");function C(e){return e.descriptor.ownerDir??N(N(e.descriptor.storeRoot))}f(C,"ownerDirOf");function x(e){return e.scope==="project"&&e.plugin===void 0}f(x,"isProjectStore");function ue(e){const o=e.descriptor.namespace,r=C(e),p=e.descriptor.plugin??"";return{store:e,storeKey:e.key,storeRoot:e.snapshot.root,ownerDir:r,repositoryKey:"",repositoryRoot:r,ownerRelativePath:"",oldPrefix:p,oldRule:"pre-003",effectivePrefix:o,nestedDeclarationAction:"none",legacyDeclaration:null}}f(ue,"fallbackPrefix");function he(e,o){return o.find(r=>r.repositoryRoot===e.repositoryRoot)}f(he,"repositoryForPrefix");function ye(e,o,r,p){const t=he(o,r),a=[];if(e.snapshot.docs.length===0)return a;if(e.descriptor.plugin!==void 0){const i=V(o.effectivePrefix);i.ok||p.push({kind:"namespace",message:`plugin \`${e.descriptor.plugin}\` mounts its memory under \`${o.effectivePrefix}\`, which is not a valid namespace (${i.reason}) \u2014 fix the plugin package and re-run`,storeRoot:e.key,name:o.effectivePrefix})}for(const i of e.snapshot.docs){const l=J(i.relPath);l===""&&!x(e.descriptor)&&e.descriptor.plugin===void 0&&p.push({kind:"namespace",message:`a root ${Y}.md in a ${e.descriptor.scope} store composes to the empty canonical name \u2014 only a project store's root document answers at its effective prefix; rename this file to a named document (\`<topic>.md\`) or fold its content into the docs it introduces, then re-run`,storeRoot:e.key,path:i.path});const c=me(i),k=c===null?fe(i.relPath):U(c),u=o.oldRule==="per-store-declaration"?$(o.oldPrefix,q(i.frontmatter,l)):$(o.oldPrefix,k);let n=l,d=null;if(l==="")c!==null&&(d="remove");else{const y=_(i.frontmatter);if(y!==null){const s=H(y,o.effectivePrefix)??y;if(s===""||s===l)d="remove";else{const w=Q(s,o.effectivePrefix);w.ok||p.push({kind:"namespace",message:`explicit \`name: ${c}\` cannot become a store-local name (${w.reason}) \u2014 correct it and re-run`,storeRoot:e.key,path:i.path,name:c??s}),n=s,s!==c&&(d={value:s})}}}let m=null;if(l===""&&x(e.descriptor))if(o.ownerRelativePath===""){const y=i.frontmatter?.namespace;t!==void 0&&y!==t.namespace&&(m={value:t.namespace})}else o.nestedDeclarationAction!=="none"&&(m="remove");a.push({doc:i,storeKey:e.key,realPath:g(i.path),oldName:u,finalName:$(o.effectivePrefix,n),finalLocal:n,nameEdit:d,namespaceEdit:m,oldPrefix:o.oldPrefix,deleted:o.nestedDeclarationAction==="synthetic-index-removed"&&l===""})}return a}f(ye,"buildDocFacts");function ge(e,o,r){const p=new Map;for(const t of o){const a=p.get(t.finalName);a===void 0?p.set(t.finalName,[t]):a.push(t)}for(const[t,a]of p)a.length<2||r.push({kind:"collision",message:`${a.length} documents in this store would own canonical name \`${t}\` (${a.map(i=>i.doc.relPath).join(", ")}) \u2014 merge them into one document or rename one, then re-run`,storeRoot:e.key,name:t,paths:a.map(i=>i.doc.path)})}f(ge,"addFinalCollisions");function we(e,o){const r=e.descriptor.plugin!==void 0?`plugin \`${e.descriptor.plugin}\``:"crouter's builtin corpus",p=e.descriptor.plugin!==void 0?`update the plugin package (\`crtr pkg plugin update ${e.descriptor.plugin}\`) once it ships the corrected corpus`:"update crouter (`crtr sys update`) to a release whose builtin corpus already uses repository-root identity";return`${o.doc.relPath} needs an identity rewrite (\`${o.oldName}\` \u2192 \`${o.finalName}\`) in ${r}, a package-owned store this migration never writes \u2014 ${p}`}f(we,"packageOwnedCorpusMessage");function Pe(e,o,r,p){if(r.nameEdit===null&&r.namespaceEdit===null)return[];const t=pe(e);if(t===null)return r.namespaceEdit===null||r.namespaceEdit==="remove"?[]:[{start:0,end:0,text:`---
2
- namespace: ${v(r.namespaceEdit.value)}
3
- ---
4
- `}];const a=de(t.raw);if(a===null)return p.blockers.push({kind:"parse-failure",message:`${r.doc.relPath}: frontmatter is not a YAML mapping, so its identity fields cannot be rewritten \u2014 fix the file and re-run`,storeRoot:o.key,path:r.doc.path}),[];const i=[];if(r.namespaceEdit!==null){const l=D(a,"namespace");if(r.namespaceEdit==="remove"){if(l!==null){const c=E(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:""})}}else if(l===null)i.push({start:t.base,end:t.base,text:`namespace: ${v(r.namespaceEdit.value)}
5
- `});else{const c=M(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:v(r.namespaceEdit.value)})}}if(r.nameEdit!==null){const l=D(a,"name");if(l!==null)if(r.nameEdit==="remove"){const c=E(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:""})}else{const c=M(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:v(r.nameEdit.value)})}}return i}f(Pe,"identityRewrites");function ve(e,o){const r=e.ownerRelativePath===""?o.find(p=>p.storeKey===e.storeKey)?.action??"none":"none";return{storeRoot:e.storeRoot,ownerDir:e.ownerDir,repositoryRoot:e.repositoryRoot,ownerRelativePath:e.ownerRelativePath,oldPrefix:e.oldPrefix,oldRule:e.oldRule,effectivePrefix:e.effectivePrefix,nestedDeclarationAction:e.nestedDeclarationAction,frontDoorAction:r}}f(ve,"storePrefixRow");function ke(e){return{repositoryRoot:e.repositoryRoot,repositoryKey:e.repositoryKey,declarationPath:e.declarationPath,namespace:e.namespace,source:e.source,action:e.action}}f(ke,"repositoryRow");function Re(e){h={links:[],routes:[],wrote:new Set,repositories:[]};const o=F(),r=ae(e);if(r.blockers.length>0)return F(r.blockers);const p=new Map,t=new Map;for(const n of e.stores){const d=r.prefixes.get(n.key)??ue(n);t.set(n.key,d);const m=ye(n,d,r.repositories,o.blockers);p.set(n.key,m),ge(n,m,o.blockers)}const a=new se(p),i=new Map;for(const n of p.values())for(const d of n)i.set(d.realPath,d.finalName);const l=ne(r.repositories,r.prefixes,e,n=>i.get(g(n)));o.blockers.push(...l.blockers),o.repositories.push(...r.repositories.map(ke)),o.storePrefixes.push(...[...r.prefixes.values()].map(n=>ve(n,l.plans)));const c=new Set(l.plans.filter(n=>n.rootAction==="completed").map(n=>g(n.rootDocPath))),k=new Set(l.plans.map(n=>n.leafDocPath).filter(n=>n!==null).map(g)),u=new Map;for(const n of e.stores){const d=t.get(n.key),m=p.get(n.key)??[],y=n.writable?le(e,n):[];for(const s of m){const w=n.writable?[...ie(a,y,n,s,o,h.links),...ce(a,y,n,s,d,o,h.routes)]:[],P=S(s.doc.source,w);if(s.deleted&&n.writable){u.set(s.realPath,{path:s.doc.path,after:null});continue}const R=c.has(s.realPath)?te(P,s.doc.path):k.has(s.realPath)?oe(P,s.doc.path):P,b=Pe(R,n,s,o),L=S(R,b);if(!n.writable){(s.oldPrefix!==d.effectivePrefix||b.length>0)&&s.oldName!==s.finalName&&o.blockers.push({kind:"package-owned-corpus",message:we(n,s),storeRoot:n.key,path:s.doc.path,name:s.finalName});continue}w.length>0&&o.consumers.push({path:s.doc.path,after:P}),(R!==P||b.length>0)&&u.set(s.realPath,{path:s.doc.path,after:L}),(s.oldPrefix!==d.effectivePrefix||s.nameEdit!==null||s.namespaceEdit!==null)&&s.oldName!==s.finalName&&o.renames.push({storeRoot:n.key,path:s.doc.path,from:s.oldName,to:s.finalName})}}for(const n of l.plans)if(n.rootAction==="created"){const d=r.repositories.find(m=>m.repositoryRoot===n.repositoryRoot);if(d===void 0)throw new Error(`migration 003: no repository decision for ${n.repositoryRoot}`);o.identities.push({path:n.rootDocPath,after:re(d.namespace,n.leafCanonicalName)})}else{const d=g(n.rootDocPath),m=u.get(d);m!==void 0&&(o.identities.push(m),u.delete(d))}for(const n of l.plans){if(n.leafDocPath===null)continue;const d=g(n.leafDocPath),m=u.get(d);m!==void 0&&(o.identities.push(m),u.delete(d))}o.identities.push(...u.values());for(const n of[...o.consumers,...o.identities])h.wrote.add(n.path);return h.repositories=o.repositories.map(n=>({...n})),o}f(Re,"plan");function I(e){return x(e.descriptor)?B(C(e)):e.descriptor}f(I,"freshDescriptor");function be(e,o){if(e.size!==o.size)return!1;for(const r of e)if(!o.has(r))return!1;return!0}f(be,"sameSet");function $e(e,o){try{return z(e,o)}catch{return!1}}f($e,"safeGlob");function xe(e){const o=[];for(const t of h.repositories){if(!A(t.declarationPath)){o.push({kind:"verification",message:`repository declaration ${t.declarationPath} was not written`,path:t.declarationPath,name:t.namespace});continue}try{const a=O(j(t.declarationPath,"utf8")).data?.namespace;if(a===t.namespace)continue;o.push({kind:"verification",message:`repository declaration ${t.declarationPath} declares ${JSON.stringify(a)}, not the planned namespace \`${t.namespace}\``,path:t.declarationPath,name:t.namespace})}catch(a){o.push({kind:"verification",message:`repository declaration ${t.declarationPath} cannot be parsed after the write (${a instanceof Error?a.message:String(a)})`,path:t.declarationPath,name:t.namespace})}}for(const t of e.stores)if(!(!t.writable||t.snapshot.docs.length===0))for(const a of W(I(t)).errors){const i=a.rule==="yaml"&&h.wrote.has(a.path);!Z.has(a.rule)&&!i||o.push({kind:"verification",message:`${a.rule}: ${a.message}`,storeRoot:t.key,path:a.path,...a.name===void 0?{}:{name:a.name}})}const r=new Map,p=f(t=>{const a=r.get(t);if(a!==void 0)return a;const i=e.storesForTarget(t).flatMap(c=>T(I(c),!0)),l={names:ee(i),docs:i.map(c=>({name:c.name,realPath:g(c.path)}))};return r.set(t,l),l},"viewFor");for(const t of h.links)p(t.targetId).names.has(t.name)||o.push({kind:"verification",message:`rewritten link [[${t.name}]] resolves to no document in target ${t.targetId} after the write phases`,path:t.carrier,targetId:t.targetId,name:t.name});for(const t of h.routes){const a=p(t.targetId),i=new Set;for(const l of a.docs)t.globs.some(c=>$e(l.name,c))&&i.add(l.realPath);be(i,new Set(t.expected))||o.push({kind:"verification",message:`rewritten memory-read route \`${t.globs.join(", ")}\` names ${i.size} document(s) in target ${t.targetId}, not the ${t.expected.length} it named before the cut`,path:t.carrier,targetId:t.targetId})}return o}f(xe,"verify");const Oe={id:"003-repository-root-memory-identity",lane:"corpus",description:"repository-root memory identity: one namespace per repository, nested stores derive their prefix from their path under it",plan:Re,verify:xe};export{Oe as repositoryRootMemoryIdentityMigration};
@@ -1,95 +0,0 @@
1
- import { type Pair, type YAMLMap } from 'yaml';
2
- import type { CorpusPlan, CorpusSnapshot, CorpusStore, StoreDoc } from '../types.js';
3
- import type { StorePrefixFacts } from './repository-facts.js';
4
- export interface DocFacts {
5
- doc: StoreDoc;
6
- storeKey: string;
7
- /** Realpath of the file: the identity a reference proof is keyed by. */
8
- realPath: string;
9
- /** The exact name this document answered at before this migration. */
10
- oldName: string;
11
- /** Its repository-root canonical name after this migration. */
12
- finalName: string;
13
- /** The store-local half of `finalName`; `''` for a store root document. */
14
- finalLocal: string;
15
- nameEdit: 'remove' | {
16
- value: string;
17
- } | null;
18
- namespaceEdit: 'remove' | {
19
- value: string;
20
- } | null;
21
- /** True when phase 2 deletes this exact synthetic nested INDEX document. */
22
- deleted: boolean;
23
- /** The prefix this document's store answered under before this migration. */
24
- oldPrefix: string;
25
- }
26
- export interface Splice {
27
- start: number;
28
- end: number;
29
- text: string;
30
- }
31
- /** Right-to-left, widest-first at a shared start. A whole-key removal beginning
32
- * at the YAML block base must run before a zero-width insertion there. */
33
- export declare function applySplices(source: string, splices: readonly Splice[]): string;
34
- /** Locate the raw YAML within a complete document source. */
35
- export declare function yamlBlock(source: string): {
36
- base: number;
37
- raw: string;
38
- } | null;
39
- export declare function yamlMap(raw: string): YAMLMap | null;
40
- export declare function itemFor(map: YAMLMap, key: string): Pair | null;
41
- /** Whole-line span of a mapping key, including its multiline value. */
42
- export declare function keyLineSpan(raw: string, item: Pair): [number, number] | null;
43
- /** Span of a mapping value with trailing whitespace excluded. */
44
- export declare function valueSpan(raw: string, item: Pair): [number, number] | null;
45
- export declare function renderScalar(value: string): string;
46
- /** Render one or several route globs without expanding a one-line value into a
47
- * block sequence. */
48
- export declare function renderGlobList(globs: readonly string[]): string;
49
- export interface View {
50
- signature: string;
51
- storeKeys: readonly string[];
52
- targetIds: readonly string[];
53
- }
54
- export declare function viewsForStore(corpus: CorpusSnapshot, store: CorpusStore): View[];
55
- export interface LinkProof {
56
- targetId: string;
57
- carrier: string;
58
- name: string;
59
- }
60
- export interface RouteProof {
61
- targetId: string;
62
- carrier: string;
63
- globs: readonly string[];
64
- /** Realpaths the rewritten globs must still name exactly. */
65
- expected: readonly string[];
66
- }
67
- /** Reference resolution under the frozen old corpus view. */
68
- export declare class OldCorpus {
69
- private readonly facts;
70
- private readonly matchCache;
71
- constructor(docsByStoreKey: ReadonlyMap<string, DocFacts[]>);
72
- /** The physical old-name winner in one view, including a synthetic document
73
- * phase 2 will delete. The retired directory-index fallback is part of this
74
- * frozen lookup. A virtual bare-directory prefix has no physical fact. */
75
- resolveOldFact(view: View, written: string): DocFacts | null;
76
- /** The final canonical name a written old name denoted in one view. Deleted
77
- * physical winners have no final projection; dangling references and
78
- * unprovable bare-directory mappings likewise return null. */
79
- resolveOld(view: View, written: string): string | null;
80
- /** Realpaths a glob names under old or final identity, plus the effective
81
- * prefixes of stores contributing a match. */
82
- matchSet(view: View, glob: string, phase: 'old' | 'final'): {
83
- paths: Set<string>;
84
- namespaces: Set<string>;
85
- };
86
- /** Candidate qualification for both accepted old models. A pre-003 store
87
- * gains its final prefix; a superseded per-store declaration has its old
88
- * prefix replaced by the repository-derived one. */
89
- finalGlobSpellings(views: readonly View[], glob: string): string[];
90
- }
91
- /** The minimal glob list naming exactly the old match set under final identity,
92
- * or null when no exact rewrite can be proved. */
93
- export declare function provenGlobs(corpus: OldCorpus, views: readonly View[], glob: string): string[] | null;
94
- export declare function linkRewrites(corpus: OldCorpus, views: readonly View[], store: CorpusStore, fact: DocFacts, result: CorpusPlan, proofs: LinkProof[]): Splice[];
95
- export declare function routeRewrites(corpus: OldCorpus, views: readonly View[], store: CorpusStore, fact: DocFacts, prefix: StorePrefixFacts, result: CorpusPlan, proofs: RouteProof[]): Splice[];
@@ -1,5 +0,0 @@
1
- var E=Object.defineProperty;var u=(t,n)=>E(t,"name",{value:n,configurable:!0});import{matchesGlob as j}from"node:path";import{isMap as M,isSeq as z,parseDocument as _}from"yaml";import{parseFrontmatterGeneric as q}from"../../core/frontmatter.js";import{findDocLinks as B}from"../../core/memory/doc-link-grammar.js";import{canonicalParent as D,composeCanonicalName as b,INDEX_SEGMENT as k,representationForPath as J,routingAnchorFor as T,stripNamespace as Z}from"../../core/memory/identity.js";function de(t,n){let o=t;for(const e of[...n].sort((s,r)=>r.start-s.start||r.end-s.end))o=o.slice(0,e.start)+e.text+o.slice(e.end);return o}u(de,"applySplices");function V(t){const n=q(t);if(n.raw==="")return null;const o=t.length-n.body.length,e=t.slice(0,o).indexOf(n.raw);return e<0?null:{base:e,raw:n.raw}}u(V,"yamlBlock");function X(t){const n=_(t);return n.errors.length===0&&M(n.contents)?n.contents:null}u(X,"yamlMap");function K(t,n){return t.items.find(o=>String(o.key)===n)??null}u(K,"itemFor");function fe(t,n){const o=n.key?.range;if(o===void 0)return null;const e=n.value?.range;let s=t.lastIndexOf(`
2
- `,o[0]-1)+1,r=e?.[2]??o[2];if(!(r>0&&t[r-1]===`
3
- `)){for(;r<t.length&&(t[r]===" "||t[r]===" "||t[r]==="\r");)r++;t[r]===`
4
- `&&r++}return r>=t.length&&s>0&&t[s-1]===`
5
- `&&(s-=1),[s,r]}u(fe,"keyLineSpan");function Y(t,n){const o=n.value?.range;if(o===void 0)return null;let e=o[1];for(;e>o[0]&&/\s/.test(t[e-1]);)e--;return[o[0],e]}u(Y,"valueSpan");const H=/^[A-Za-z][A-Za-z0-9._\-/]*$/;function ue(t){return H.test(t)?t:JSON.stringify(t)}u(ue,"renderScalar");function Q(t){return t.length===1?JSON.stringify(t[0]):`[${t.map(n=>JSON.stringify(n)).join(", ")}]`}u(Q,"renderGlobList");function he(t,n){if(n.targets.length===0)return[{signature:n.key,storeKeys:[n.key],targetIds:[]}];const o=new Map;for(const e of n.targets){const s=t.storesForTarget(e).map(i=>i.key),r=s.join("\0"),a=o.get(r);a===void 0?o.set(r,{signature:r,storeKeys:s,targetIds:[e]}):a.targetIds.push(e)}return[...o.values()]}u(he,"viewsForStore");function G(t,n){try{return j(t,n)}catch{return!1}}u(G,"safeGlob");function U(t,n){const o=t.doc.relPath.endsWith(`${k}.md`),e=n.doc.relPath.endsWith(`${k}.md`);return o!==e?o?t:n:t.doc.relPath.localeCompare(n.doc.relPath)<=0?t:n}u(U,"oldNameWinner");function ee(t){if(t.finalLocal==="")return t.finalName;if(t.finalName===t.finalLocal)return"";const n=`/${t.finalLocal}`;if(!t.finalName.endsWith(n))throw new Error(`migration 003 reference facts for ${t.doc.path} disagree: final name \`${t.finalName}\` does not compose from local name \`${t.finalLocal}\``);return t.finalName.slice(0,-n.length)}u(ee,"effectivePrefixOf");class me{static{u(this,"OldCorpus")}facts=new Map;matchCache=new Map;constructor(n){for(const[o,e]of n){const s=new Map;let r=null,a=null;for(const i of e){const l=s.get(i.oldName);if(s.set(i.oldName,l===void 0?i:U(l,i)),r===null)r=i.oldPrefix;else if(r!==i.oldPrefix)throw new Error(`migration 003 reference facts for store ${o} disagree on old prefix (\`${r}\` vs \`${i.oldPrefix}\`)`);const h=ee(i);if(a===null)a=h;else if(a!==h)throw new Error(`migration 003 reference facts for store ${o} disagree on effective prefix (\`${a}\` vs \`${h}\`)`)}this.facts.set(o,{docs:e,byOldName:s,oldPrefix:r??"",effectivePrefix:a??""})}}resolveOldFact(n,o){for(const e of n.storeKeys){const s=this.facts.get(e)?.byOldName.get(o);if(s!==void 0)return s}for(const e of n.storeKeys){const s=this.facts.get(e)?.byOldName.get(`${o}/${k}`);if(s!==void 0)return s}return null}resolveOld(n,o){const e=this.resolveOldFact(n,o);if(e!==null)return e.deleted?null:e.finalName;const s=`${o}/`;let r=null,a=!1;for(const i of n.storeKeys)for(const l of this.facts.get(i)?.docs??[]){if(!l.oldName.startsWith(s))continue;a=!0;const h=l.oldName.slice(s.length);if(!l.finalName.endsWith(`/${h}`))return null;const c=l.finalName.slice(0,l.finalName.length-h.length-1);if(r===null)r=c;else if(r!==c)return null}return a?r:null}matchSet(n,o,e){const s=`${n.signature}\0${e}\0${o}`,r=this.matchCache.get(s);if(r!==void 0)return r;const a=new Set,i=new Set;for(const h of n.storeKeys){const c=this.facts.get(h);if(c!==void 0)for(const d of c.docs){if(e==="final"&&d.deleted)continue;const y=e==="old"?d.oldName:d.finalName;y===""||!G(y,o)||(a.add(d.realPath),c.effectivePrefix!==""&&i.add(c.effectivePrefix))}}const l={paths:a,namespaces:i};return this.matchCache.set(s,l),l}finalGlobSpellings(n,o){const e=new Set;for(const s of n)for(const r of s.storeKeys){const a=this.facts.get(r);a===void 0||!a.docs.some(i=>i.oldName!==""&&G(i.oldName,o))||(e.add(b(a.effectivePrefix,o)),a.oldPrefix!==""&&(o===a.oldPrefix?e.add(a.effectivePrefix):o.startsWith(`${a.oldPrefix}/`)&&e.add(b(a.effectivePrefix,o.slice(a.oldPrefix.length+1)))))}return e.delete(""),[...e].sort()}}function C(t,n){for(const o of t)if(!n.has(o))return!1;return!0}u(C,"isSubset");function te(t,n){return t.size===n.size&&C(t,n)}u(te,"sameSet");function ne(t){const n=[],o=u(e=>{e!==""&&!n.includes(e)&&n.push(e)},"push");for(const e of t){o(e);const s=e.endsWith(`/${k}`)?e.slice(0,-(k.length+1)):e.endsWith("/**")?e.slice(0,-3):e.endsWith("/*")?e.slice(0,-2):null;s!==null&&o(s)}return n}u(ne,"candidateSpellings");function oe(t,n,o){const e=n.map(i=>({view:i,expected:t.matchSet(i,o,"old").paths}));if(e.every(({expected:i})=>i.size===0))return[o];let r=ne([o,...t.finalGlobSpellings(n,o)]).filter(i=>e.every(({view:l,expected:h})=>C(t.matchSet(l,i,"final").paths,h)));const a=u(i=>e.every(({view:l,expected:h})=>{const c=new Set;for(const d of i)for(const y of t.matchSet(l,d,"final").paths)c.add(y);return te(c,h)}),"covers");if(!a(r))return null;for(let i=r.length-1;i>=0;i--){const l=r.filter((h,c)=>c!==i);l.length>0&&a(l)&&(r=l)}return r}u(oe,"provenGlobs");function pe(t,n,o,e,s,r){const a=B(e.doc.body);if(a.length===0)return[];const i=e.doc.source.length-e.doc.body.length,l=new Map,h=[];for(const c of a){let d=l.get(c.name);if(d===void 0){const x=n.map(f=>({view:f,fact:t.resolveOldFact(f,c.name)})).filter(f=>f.fact?.deleted===!0);if(x.length>0){const f=[...new Set(x.map(p=>p.fact.doc.path))];s.blockers.push({kind:"divergent-reference",message:`[[${c.name}]] resolves to the synthetic document${f.length===1?"":"s"} ${f.map(p=>`\`${p}\``).join(", ")}, but this migration deletes ${f.length===1?"that exact document":"those exact documents"} and no surviving physical document has the same identity \u2014 rewrite the link to the intended surviving document and re-run`,storeRoot:o.key,path:e.doc.path,name:c.name,paths:f,...x[0]?.view.targetIds[0]===void 0?{}:{targetId:x[0].view.targetIds[0]}}),d=null,l.set(c.name,d);continue}const g=n.map(f=>({view:f,name:t.resolveOld(f,c.name)})).filter(f=>f.name!==null),$=[...new Set(g.map(f=>f.name))];if($.length>1)s.blockers.push({kind:"divergent-reference",message:`[[${c.name}]] resolves to different documents depending on the target view (${$.map(f=>`\`${f}\``).join(" vs ")}) \u2014 this migration never guesses which one the author meant; rewrite the link by hand and re-run`,storeRoot:o.key,path:e.doc.path,name:c.name,...g[0]===void 0||g[0].view.targetIds[0]===void 0?{}:{targetId:g[0].view.targetIds[0]}}),d=null;else if(d=$[0]??null,d!==null&&d!==c.name){for(const f of g){const p=f.view.targetIds[0];p!==void 0&&r.push({targetId:p,carrier:e.doc.path,name:d})}s.references.push({storeRoot:o.key,path:e.doc.path,kind:"link",from:c.name,to:d})}l.set(c.name,d)}d===null||d===c.name||h.push({start:i+c.start,end:i+c.end,text:`[[${d}]]`})}return h}u(pe,"linkRewrites");function ge(t,n,o,e,s,r,a){const i=e.doc.frontmatter?.surfaces;if(!Array.isArray(i))return[];const l=V(e.doc.source);if(l===null)return[];const h=X(l.raw),c=h===null?null:K(h,"surfaces")?.value,d=D(e.oldName),y=Z(d,e.oldPrefix)??d,x=b(s.effectivePrefix,y),g=T(e.finalName,J(e.doc.relPath)),$=g!==x,f=[];for(let p=0;p<i.length;p++){const w=i[p];if(w===null||typeof w!="object"||w.on!=="memory-read")continue;const N=w.match,I=(typeof N=="string"?[N]:Array.isArray(N)?N:[]).filter(m=>typeof m=="string");if(I.length===0)continue;const P=[];let A=!1;for(const m of I){if(m.startsWith("./")){$&&r.blockers.push({kind:"unsafe-route",message:`memory-read glob \`${m}\` is anchored at \`${d}\`, but this document's explicit \`name:\` re-anchors it at \`${g}\` after the identity cut \u2014 a different subtree, which no rewrite of the glob restores; spell the route out absolutely (or give the document the \`${x}/${k}.md\` path its name implies) and re-run`,storeRoot:o.key,path:e.doc.path,name:m}),P.push(m);continue}const v=oe(t,n,m);if(v===null){r.blockers.push({kind:"unsafe-route",message:`memory-read glob \`${m}\` cannot be proved to name the same documents under repository-root identity \u2014 rewrite the entry by hand (or anchor it with \`./\`) and re-run`,storeRoot:o.key,path:e.doc.path,name:m}),P.push(m);continue}if(v.length!==1||v[0]!==m){A=!0;for(const F of n){const L=F.targetIds[0],W=t.matchSet(F,m,"old").paths;L===void 0||W.size===0||a.push({targetId:L,carrier:e.doc.path,globs:v,expected:[...W]})}r.references.push({storeRoot:o.key,path:e.doc.path,kind:"memory-read",from:m,to:v.join(", ")})}P.push(...v)}if(!A)continue;if(!z(c)){r.blockers.push({kind:"unsafe-route",message:`memory-read routes in ${e.doc.relPath} need rewriting but its \`surfaces:\` block is not a YAML sequence \u2014 fix the file and re-run`,storeRoot:o.key,path:e.doc.path});continue}const O=c.items[p],R=M(O)?K(O,"match"):null,S=R===null?null:Y(l.raw,R);if(S===null){r.blockers.push({kind:"unsafe-route",message:`memory-read route in ${e.doc.relPath} needs rewriting but its \`match\` value cannot be located in the frontmatter text \u2014 fix the file and re-run`,storeRoot:o.key,path:e.doc.path});continue}f.push({start:l.base+S[0],end:l.base+S[1],text:Q([...new Set(P)])})}return f}u(ge,"routeRewrites");export{me as OldCorpus,de as applySplices,K as itemFor,fe as keyLineSpan,pe as linkRewrites,oe as provenGlobs,Q as renderGlobList,ue as renderScalar,ge as routeRewrites,Y as valueSpan,he as viewsForStore,V as yamlBlock,X as yamlMap};
@@ -1,39 +0,0 @@
1
- import { type ProjectNamespaceSource } from '../../core/memory/project-namespace.js';
2
- import type { CorpusBlocker, CorpusSnapshot, CorpusStore } from '../types.js';
3
- export interface RepositoryDecision {
4
- repositoryKey: string;
5
- repositoryRoot: string;
6
- declarationPath: string;
7
- namespace: string;
8
- source: 'declared' | ProjectNamespaceSource;
9
- action: 'kept' | 'created' | 'filled-linked-root';
10
- /** Store keys grouped under this repository, in corpus order. */
11
- storeKeys: readonly string[];
12
- }
13
- export type NestedDeclarationAction = 'none' | 'removed' | 'synthetic-index-removed';
14
- export interface StorePrefixFacts {
15
- store: CorpusStore;
16
- storeKey: string;
17
- storeRoot: string;
18
- ownerDir: string;
19
- repositoryKey: string;
20
- repositoryRoot: string;
21
- ownerRelativePath: string;
22
- /** The prefix this store's documents answered under BEFORE this run. */
23
- oldPrefix: string;
24
- /** How that prefix was proven: `'per-store-declaration'` when a declaration on
25
- * disk — this store's own legacy one, or the repository-root one a nested
26
- * store already answers under — names it, `'pre-003'` when nothing declares
27
- * it and the documents answered at bare local names. */
28
- oldRule: 'pre-003' | 'per-store-declaration';
29
- /** repositoryNamespace ⊕ ownerRelativePath. */
30
- effectivePrefix: string;
31
- nestedDeclarationAction: NestedDeclarationAction;
32
- /** The legacy nested `namespace:` value, when one was present. */
33
- legacyDeclaration: string | null;
34
- }
35
- export declare function planRepositories(corpus: CorpusSnapshot): {
36
- repositories: RepositoryDecision[];
37
- prefixes: Map<string, StorePrefixFacts>;
38
- blockers: CorpusBlocker[];
39
- };
@@ -1,3 +0,0 @@
1
- var A=Object.defineProperty;var p=(e,t)=>A(e,"name",{value:t,configurable:!0});import{dirname as v}from"node:path";import{realpathOrSelf as g,readTextIfExists as _}from"../../core/fs-utils.js";import{parseFrontmatterGeneric as C}from"../../core/frontmatter.js";import{composeCanonicalName as P,explicitLocalName as D,localNameFromPath as k,validateExplicitLocalName as T,validateNamespace as b}from"../../core/memory/identity.js";import{deriveProjectNamespace as I}from"../../core/memory/project-namespace.js";import{associateRepository as j}from"../../core/memory/repository-association.js";const R="__CROUTER_SYNTHETIC_NAMESPACE__",w="__CROUTER_SYNTHETIC_NAMESPACE_SCALAR__",K=["---","kind: knowledge",`namespace: ${w}`,`when-and-why-to-read: When working in \`${R}\`, this knowledge should be read because it names the namespace every document in this project answers under.`,"surfaces:"," - on: workspace-open"," at: content"," - on: read",' match: "./**"'," at: content","---",`# ${R}`,"",`This project's memory store. Every document here answers at \`${R}/<local name>\`.`,""].join(`
2
- `);function te(e){const t=[],r=[],n=new Map,a=[];for(const o of e.stores){if(!U(o))continue;const l=g(J(o)),d=j(l);if(!d.ok){t.push({kind:"association",message:`project memory store at ${o.key} owned by ${l} cannot be associated with a repository (${d.reason}) \u2014 repair the repository boundary and re-run`,storeRoot:o.key});continue}const m={store:o,ownerDir:l,association:d.association,rootDoc:o.snapshot.docs.find(N=>k(N.relPath)==="")??null};r.push(m);const h=d.association.kind==="git"?d.association.repositoryKey:`path:${d.association.repositoryRoot}`;let y=n.get(h);y===void 0&&(y={repositoryKey:d.association.repositoryKey,roots:new Map},n.set(h,y));let f=y.roots.get(d.association.repositoryRoot);f===void 0&&(f={association:d.association,stores:[],rootStore:null,index:$(),declaration:{state:"missing"}},y.roots.set(d.association.repositoryRoot,f),a.push(f)),f.stores.push(m),d.association.ownerRelativePath===""&&f.rootStore===null&&(f.rootStore=m)}const s=new Map;for(const o of r){if(o.association.ownerRelativePath===""){s.set(o.store.key,{declaration:{state:"missing"},action:"none"});continue}const l=H(o.rootDoc);let d="none";l.state==="invalid"?t.push(E(o.store.key,o.rootDoc?.path??o.store.key,l,"nested project memory store")):l.state==="valid"&&(d=o.rootDoc!==null&&z(o.rootDoc.source,l.value)?"synthetic-index-removed":"removed"),s.set(o.store.key,{declaration:l,action:d})}for(const o of a)o.index=F(o),o.declaration=o.index.error===null?Y(o.index.frontmatter?.namespace):{state:"invalid",reason:o.index.error,raw:void 0},o.declaration.state==="invalid"&&t.push(E(o.rootStore?.store.key??v(o.association.declarationPath),o.association.declarationPath,o.declaration,"repository root"));const i=new Map;for(const o of n.values())L(o,i,t);const u=[];for(const o of a){const l=i.get(o.association.repositoryRoot);l!==void 0&&u.push(l.decision)}const c=new Map;for(const o of r){const l=i.get(o.association.repositoryRoot),d=s.get(o.store.key);if(l===void 0||d.declaration.state==="invalid")continue;const m=o.association.ownerRelativePath==="",h=P(l.decision.namespace,o.association.ownerRelativePath),{oldPrefix:y,oldRule:f}=M(o.store,m,l.declaration,d.declaration,h);c.set(o.store.key,{store:o.store,storeKey:o.store.key,storeRoot:o.store.key,ownerDir:o.ownerDir,repositoryKey:o.association.repositoryKey,repositoryRoot:o.association.repositoryRoot,ownerRelativePath:o.association.ownerRelativePath,oldPrefix:y,oldRule:f,effectivePrefix:h,nestedDeclarationAction:d.action,legacyDeclaration:!m&&d.declaration.state==="valid"?d.declaration.value:null})}return B(r,i,t),{repositories:u,prefixes:c,blockers:t}}p(te,"planRepositories");function M(e,t,r,n,a){const s=t?r:n;return s.state==="valid"?{oldPrefix:s.value,oldRule:"per-store-declaration"}:!t&&r.state==="valid"&&!O(e,a)?{oldPrefix:a,oldRule:"per-store-declaration"}:{oldPrefix:"",oldRule:"pre-003"}}p(M,"oldAuthority");function O(e,t){return e.snapshot.docs.some(r=>{const n=D(r.frontmatter);return n===null?!1:k(r.relPath)===""||!T(n,t).ok})}p(O,"carriesLegacyExplicitIdentity");function L(e,t,r){const n=[...e.roots.values()];if(n.some(c=>c.declaration.state==="invalid"))return;const a=n.filter(c=>c.declaration.state==="valid"),s=[...new Set(a.map(c=>c.declaration.value))];if(s.length>1){const c=a.map(o=>o.association.declarationPath);r.push({kind:"namespace",message:`linked repository roots for ${e.repositoryKey} declare different namespaces (${s.map(o=>`\`${o}\``).join(", ")}) \u2014 make every root declaration agree and re-run`,paths:c});return}if(s.length===1){const c=s[0];for(const o of n){const l=o.declaration.state==="valid"?"kept":"filled-linked-root";t.set(o.association.repositoryRoot,{declaration:o.declaration,decision:x(e,o,c,"declared",l)})}return}const i=n[0],u=I({ownerDir:i.association.repositoryRoot,rootFrontmatter:i.index.frontmatter,...i.index.exists?{rootBody:i.index.body}:{}});if(!u.ok){r.push({kind:"namespace",message:`repository at ${i.association.repositoryRoot} cannot derive a namespace (${u.reason}) \u2014 declare a valid \`namespace:\` on ${i.association.declarationPath} and re-run`,storeRoot:i.rootStore?.store.key??v(i.association.declarationPath),...i.index.exists?{path:i.association.declarationPath}:{}});return}for(const c of n)t.set(c.association.repositoryRoot,{declaration:c.declaration,decision:x(e,c,u.namespace,u.source,c.index.exists?"kept":"created")})}p(L,"selectGroup");function x(e,t,r,n,a){return{repositoryKey:e.repositoryKey,repositoryRoot:t.association.repositoryRoot,declarationPath:t.association.declarationPath,namespace:r,source:n,action:a,storeKeys:t.stores.map(s=>s.store.key)}}p(x,"repositoryDecision");function F(e){const t=g(e.association.declarationPath),r=e.rootStore?.store.snapshot.docs.find(n=>g(n.path)===t);if(r!==void 0)return{exists:!0,frontmatter:r.frontmatter,body:r.body,error:null};try{const n=_(e.association.declarationPath);if(n===null)return $();const a=C(n);return{exists:!0,frontmatter:a.data,body:a.body,error:null}}catch(n){return{exists:!0,frontmatter:null,body:"",error:`cannot read or parse ${e.association.declarationPath} (${Z(n)})`}}}p(F,"readRootIndex");function $(){return{exists:!1,frontmatter:null,body:"",error:null}}p($,"missingRootIndex");function H(e){return e?.frontmatter===null||e?.frontmatter===void 0||!Object.prototype.hasOwnProperty.call(e.frontmatter,"namespace")?{state:"missing"}:S(e.frontmatter.namespace)}p(H,"legacyNestedDeclarationFacts");function Y(e){return e==null||e===""?{state:"missing"}:S(e)}p(Y,"declarationFacts");function S(e){if(typeof e!="string")return{state:"invalid",reason:`\`namespace:\` is non-string (${JSON.stringify(e)})`,raw:e};const t=b(e);return t.ok?{state:"valid",value:e}:{state:"invalid",reason:`\`namespace: ${e}\` is invalid (${t.reason})`,raw:e}}p(S,"authoredDeclarationFacts");function E(e,t,r,n){return{kind:"namespace",message:`${n} has an invalid namespace declaration at ${t} (${r.reason}) \u2014 correct it and re-run; migration never replaces an unprovable identity`,storeRoot:e,path:t,...typeof r.raw=="string"?{name:r.raw}:{}}}p(E,"invalidDeclarationBlocker");function B(e,t,r){const n=new Map;for(const a of e){const s=`${a.association.repositoryRoot}\0${a.association.ownerRelativePath}`,i=n.get(s);i===void 0?n.set(s,[a]):i.push(a)}for(const a of n.values()){if(a.length<2)continue;const s=a[0],i=t.get(s.association.repositoryRoot),u=i===void 0?s.association.ownerRelativePath:P(i.decision.namespace,s.association.ownerRelativePath),c=a.map(o=>o.ownerDir);r.push({kind:"collision",message:`directories ${c.join(", ")} in repository ${s.association.repositoryRoot} normalize to the same owner path \`${s.association.ownerRelativePath}\` and effective prefix \`${u}\` \u2014 rename one directory and re-run`,storeRoot:s.store.key,name:u,paths:c})}}p(B,"addOwnerPathCollisionBlockers");function z(e,t){return e===K.replaceAll(w,G(t)).replaceAll(R,t)}p(z,"isSupersededSyntheticIndex");function G(e){return/^[A-Za-z][A-Za-z0-9._\-/]*$/.test(e)?e:JSON.stringify(e)}p(G,"renderScalar");function J(e){return e.descriptor.ownerDir??v(v(e.descriptor.storeRoot))}p(J,"ownerDirOf");function U(e){return e.descriptor.scope==="project"&&e.descriptor.plugin===void 0}p(U,"isNativeProjectStore");function Z(e){return(e instanceof Error?e.message:String(e)).split(`
3
- `)[0]??String(e)}p(Z,"firstLine");export{te as planRepositories};
@@ -1,43 +0,0 @@
1
- import type { DocChange, StateMigration, StoreSnapshot } from './types.js';
2
- /** A doc excluded from the snapshot because its frontmatter is not valid YAML.
3
- * Per-doc throw isolation at the collection layer: the bad file is named and
4
- * the rest of the store still migrates. */
5
- export interface SkippedDoc {
6
- relPath: string;
7
- error: string;
8
- }
9
- export interface ConvergentRunResult {
10
- root: string;
11
- /** One row per migration that planned real changes, in registry order. */
12
- applied: {
13
- migration: string;
14
- files: string[];
15
- }[];
16
- skipped: SkippedDoc[];
17
- /** The store's docs with every planned change folded in — the bytes on disk
18
- * after a write run, and the bytes a write run WOULD have produced under
19
- * `--dry-run`. What the corpus lane plans against. */
20
- snapshot: StoreSnapshot;
21
- }
22
- /** Snapshot every parseable `.md` under `root` (hidden dirs — `.history`
23
- * sidecars and the like — skipped, mirroring substrate doc enumeration).
24
- * `SKILL.md` bundles are Agent Skills, not memory docs: they carry no
25
- * canonical identity and are never rewritten. */
26
- export declare function loadStoreSnapshot(root: string): {
27
- snapshot: StoreSnapshot;
28
- skipped: SkippedDoc[];
29
- };
30
- /** Fold one applied change back into the in-memory snapshot so the NEXT
31
- * migration plans against post-change state (dry runs included — that is what
32
- * makes a dry-run diff equal the real run's writes). A migration that emits
33
- * invalid YAML is a defect and throws here, before anything else compounds
34
- * on its output. */
35
- export declare function foldDocChange(snapshot: StoreSnapshot, change: DocChange): void;
36
- /** Run every registered convergent migration over the store at `root`, in
37
- * registry order. No-op changes (identical text) are filtered; each real
38
- * change is written atomically unless `dryRun`. Journaled migrations in the
39
- * list are the db chain's business and are skipped here. */
40
- export declare function runConvergentMigrations(root: string, opts?: {
41
- dryRun?: boolean;
42
- migrations?: readonly StateMigration[];
43
- }): ConvergentRunResult;
@@ -1,2 +0,0 @@
1
- var m=Object.defineProperty;var p=(o,t)=>m(o,"name",{value:t,configurable:!0});import{relative as l,sep as d}from"node:path";import{atomicWriteText as h,readText as S,removePath as g,walkFiles as x}from"../core/fs-utils.js";import{parseFrontmatterGeneric as u}from"../core/frontmatter.js";import{STATE_MIGRATIONS as y}from"./registry.js";function T(o,t){const s=l(o,t).split(d).join("/"),n=S(t);try{const{data:r,body:a}=u(n);return{doc:{path:t,relPath:s,source:n,frontmatter:r,body:a}}}catch(r){return{error:(r instanceof Error?r.message:String(r)).split(`
2
- `)[0]}}}p(T,"parseDoc");function v(o){const t=[],s=[];for(const n of x(o,r=>r.endsWith(".md")&&r!=="SKILL.md",r=>r.startsWith("."))){const r=T(o,n);"doc"in r?t.push(r.doc):s.push({relPath:l(o,n).split(d).join("/"),error:r.error})}return{snapshot:{root:o,docs:t},skipped:s}}p(v,"loadStoreSnapshot");function I(o,t){const s=o.docs.findIndex(c=>c.path===t.path);if(t.after===null){s>=0&&o.docs.splice(s,1);return}const n=l(o.root,t.path).split(d).join("/"),{data:r,body:a}=u(t.after),i={path:t.path,relPath:n,source:t.after,frontmatter:r,body:a};s>=0?o.docs[s]=i:o.docs.push(i)}p(I,"foldDocChange");function W(o,t={}){const s=(t.migrations??y).filter(i=>i.lane==="convergent"),{snapshot:n,skipped:r}=v(o),a=[];for(const i of s){const c=new Map(n.docs.map(e=>[e.path,e.source])),f=i.apply(n).filter(e=>e.after===null?c.has(e.path):c.get(e.path)!==e.after);if(f.length!==0){for(const e of f)t.dryRun!==!0&&(e.after===null?g(e.path):h(e.path,e.after)),I(n,e);a.push({migration:i.description,files:f.map(e=>e.path)})}}return{root:o,applied:a,skipped:r,snapshot:n}}p(W,"runConvergentMigrations");export{I as foldDocChange,v as loadStoreSnapshot,W as runConvergentMigrations};
@@ -1,75 +0,0 @@
1
- import type { NodeMemoryTarget } from '../core/canvas/types.js';
2
- import type { CorpusBlocker, CorpusDiscoveryRoot, CorpusIdentityRename, CorpusReferenceRewrite, CorpusRepositoryDecision, CorpusSnapshot, CorpusStore, CorpusStorePrefix, CorpusTarget, ProfileManifestSnapshot, StateMigration, StoreSnapshot } from './types.js';
3
- /** A store before its documents are read. */
4
- export type DiscoveredStore = Omit<CorpusStore, 'snapshot'>;
5
- export interface CorpusDiscovery {
6
- /** Every place discovery looked, in the order it looked. */
7
- roots: CorpusDiscoveryRoot[];
8
- /** Deduped by realpath, in discovery order. Stores whose directory does not
9
- * exist are absent: there is nothing to migrate and nothing to point at. */
10
- stores: DiscoveredStore[];
11
- targets: CorpusTarget[];
12
- /** Roots and targets discovery could not read. */
13
- blockers: CorpusBlocker[];
14
- }
15
- export interface CorpusSkippedDoc {
16
- storeRoot: string;
17
- relPath: string;
18
- error: string;
19
- }
20
- export interface CorpusRunResult {
21
- /** Corpus migrations in the registry. Zero means the lane is inert. */
22
- migrations: number;
23
- /** True when blockers exist and a corpus migration was registered to gate. */
24
- blocked: boolean;
25
- blockers: CorpusBlocker[];
26
- planned: {
27
- migration: string;
28
- consumers: string[];
29
- identities: string[];
30
- }[];
31
- repositories: CorpusRepositoryDecision[];
32
- storePrefixes: CorpusStorePrefix[];
33
- renames: CorpusIdentityRename[];
34
- references: CorpusReferenceRewrite[];
35
- /** Files written, or under `--dry-run` the files that would be written. */
36
- wrote: {
37
- consumers: string[];
38
- identities: string[];
39
- };
40
- /** True when the post-write rebuild ran every migration's `verify`. */
41
- verified: boolean;
42
- }
43
- /** Discover the whole reachable corpus: every store, the targets that mount
44
- * them, and the frontier searched to find them. `profiles` are the manifest
45
- * lane's post-migration snapshots — a pre-migration manifest reads as corrupt,
46
- * so discovery must run after that lane, not against `listProfiles()`. */
47
- export declare function discoverCorpus(opts: {
48
- cwd?: string;
49
- profiles: readonly ProfileManifestSnapshot[];
50
- explicitDirs?: readonly string[];
51
- nodes: readonly NodeMemoryTarget[];
52
- }): Promise<CorpusDiscovery>;
53
- /** Read every discovered store's documents. `preloaded` supplies the per-store
54
- * convergent lane's FOLDED snapshots so the corpus plans against the bytes a
55
- * write run leaves behind — identical under `--dry-run`, where the same fold
56
- * ran and nothing was written. */
57
- export declare function loadCorpusSnapshots(discovery: CorpusDiscovery, opts?: {
58
- preloaded?: ReadonlyMap<string, StoreSnapshot>;
59
- }): {
60
- snapshots: Map<string, StoreSnapshot>;
61
- skipped: CorpusSkippedDoc[];
62
- };
63
- export declare function parseFailureBlockers(skipped: readonly CorpusSkippedDoc[]): CorpusBlocker[];
64
- export declare function buildCorpusSnapshot(discovery: CorpusDiscovery, snapshots: ReadonlyMap<string, StoreSnapshot>): CorpusSnapshot;
65
- /** Plan every corpus migration over the whole corpus, then — only when the
66
- * global plan is blocker-free — write every migration's consumer rewrites
67
- * before any identity rewrite. `rebuild` re-reads the corpus from file truth
68
- * for the post-write `verify` pass. */
69
- export declare function runCorpusMigrations(corpus: CorpusSnapshot, opts?: {
70
- dryRun?: boolean;
71
- migrations?: readonly StateMigration[];
72
- /** Discovery and parse-failure blockers, gating identically to plan ones. */
73
- blockers?: readonly CorpusBlocker[];
74
- rebuild?: () => CorpusSnapshot;
75
- }): CorpusRunResult;
@@ -1,3 +0,0 @@
1
- var z=Object.defineProperty;var c=(t,n)=>z(t,"name",{value:n,configurable:!0});import{envProfileId as H}from"../shared/env.js";import{readdirSync as Q}from"node:fs";import{dirname as C,join as x}from"node:path";import{appsRoot as T,appSpace as V}from"../core/layout.js";import{atomicWriteText as L,listDirs as O,pathExists as v,realpathOrSelf as R,removePath as _,walkFiles as X}from"../core/fs-utils.js";import{memoryStoresInPrecedence as Z}from"../core/memory-resolver.js";import{descendantStoreRootsExhaustive as oo}from"../core/nested-stores.js";import{profileMemoryDir as eo}from"../core/profiles/manifest.js";import{memoryDir as to}from"../core/runtime/memory.js";import{listInstalledPlugins as so,listInstalledPluginsInRoot as no}from"../core/resolver.js";import{NEUTRAL_PROJECT_MEMORY as D,pluginMemoryDir as ro,projectScopeRoots as B,scopeRoot as io}from"../core/scope.js";import{CRTR_DIR_NAME as F}from"../types.js";import{foldDocChange as ao,loadStoreSnapshot as co}from"./convergent.js";import{STATE_MIGRATIONS as po}from"./registry.js";function fo(t){return(t instanceof Error?t.message:String(t)).split(`
2
- `)[0]??""}c(fo,"firstLine");function uo(t){return`${t.profileId??"-"}:${t.nodeId??"-"}:${R(t.cwd)}`}c(uo,"targetId");function lo(t){const n=ro(t);return{scope:t.scope,storeRoot:n,namespace:t.name,plugin:t.name,mountStatus:v(n)?"ready":"absent",projectMemory:D}}c(lo,"pluginStoreDescriptor");function mo(t){return{scope:"node",storeRoot:t,namespace:"",mountStatus:v(t)?"ready":"absent",projectMemory:D}}c(mo,"nodeStoreDescriptor");function ho(){const t=[];for(const n of O(T()))for(const r of O(x(T(),n,"memory","nodes"))){const i=x(T(),n,"memory","nodes",r);if(!v(i))continue;X(i,d=>d.endsWith(".md")&&d!=="SKILL.md",d=>d.startsWith(".")).length>0&&t.push({nodeId:r,storeRoot:i})}return t}c(ho,"nodeStoresWithDocs");async function Do(t){const n=R(t.cwd??process.cwd()),r=H()||null,i=t.explicitDirs??[],m=[],d=new Set,u=c(o=>{const e=`${o.reason}\0${R(o.root)}\0${o.detail??""}`;d.has(e)||(d.add(e),m.push(o))},"addRoot"),y=new Map,P=c((o,e,s)=>{const f=R(o);let p=y.get(f);p===void 0&&(p={root:o,reason:e,profileIds:[]},y.set(f,p)),p.profileIds.includes(s)||p.profileIds.push(s)},"addProjectRoot"),$=[{reason:"cwd-ancestor",profileId:r,roots:B(n,r)},...t.profiles.map(({profileId:o,manifest:e})=>({reason:"profile-project",profileId:o,detail:o,roots:[...new Set(e.projects.flatMap(s=>[x(s.path,F),...B(s.path,null)]))]})),...i.map(o=>({reason:"explicit-dir",profileId:r,detail:o,roots:[x(R(o),F)]}))],S=new Map,b=c(o=>{const e=o.map(f=>R(f)).sort().join(`
3
- `);let s=S.get(e);return s===void 0&&(s=oo([...o]),S.set(e,s)),s},"descendantsUnder"),j=c((o,e,s,f)=>{const p=f===void 0?{}:{detail:f};for(const h of o)u({reason:e,root:h,boundary:e==="explicit-dir"?"store":"ancestors",...p}),P(h,e,s);for(const h of b(o))u({reason:"descendant",root:h,boundary:"descendants",...p}),P(h,"descendant",s)},"expandRoots");for(const o of $)j(o.roots,o.reason,o.profileId,o.detail);const I=[],k=new Map,w=c((o,e,s)=>{const f=o.storeRoot;if(f===""||!v(f))return;const p=R(f);let h=k.get(p);if(h===void 0){h={key:p,descriptor:o,discovery:[],discoverySeen:new Set,targets:[],writable:o.scope!=="builtin"},k.set(p,h);try{Q(p)}catch(q){I.push({kind:"inaccessible-root",message:`memory store cannot be listed (${fo(q)}) \u2014 discovery cannot see its documents; fix the permissions and re-run`,storeRoot:p})}}const A=`${e.reason}\0${e.root}\0${e.targetId??""}`;h.discoverySeen.has(A)||(h.discoverySeen.add(A),h.discovery.push(e)),s!==void 0&&(h.targets.includes(s.id)||h.targets.push(s.id),s.storeKeys.includes(p)||s.storeKeys.push(p))},"register"),a=[],l=new Map,M=c((o,e,s)=>{const f=uo(s);if(l.has(f))return;const p={id:f,kind:o,origin:e,target:s,storeKeys:[]};l.set(f,p),a.push(p)},"addTarget");M("cwd",n,{cwd:n,profileId:r,nodeId:null});for(const{profileId:o,manifest:e}of t.profiles)M("profile",o,{cwd:e.projects[0]?.path??n,profileId:o,nodeId:null});const g=c(()=>{for(const{root:o,profileIds:e}of[...y.values()])for(const s of[...e])M("project",C(o),{cwd:C(o),profileId:s,nodeId:null})},"addProjectTargets"),Y=ho();v(T())&&u({reason:"node",root:T(),boundary:"nodes"});const G=new Map(t.nodes.map(o=>[o.nodeId,o]));for(const{nodeId:o,storeRoot:e}of Y){const s=G.get(o);if(s===void 0||s.cwd===""||to(o,s.grantee)!==e){const f=s===void 0?"no row":s.cwd===""?"empty cwd":"app assignment differs from folder";I.push({kind:"inaccessible-target",message:`node ${o} holds memory documents but canvas.db has no matching app assignment and usable row for it (${f}) \u2014 the corpus cannot resolve its project or profile`,storeRoot:R(e)}),w(mo(e),{reason:"node",root:e});continue}M("node",o,{cwd:s.cwd,profileId:s.profileId,nodeId:o,grantee:s.grantee})}const J=c(o=>{for(const e of Z(o.target)){if(e.plugin!==void 0){u({reason:"plugin",root:e.storeRoot,boundary:"store",detail:e.plugin}),w(e,{reason:"plugin",root:e.storeRoot,targetId:o.id},o);continue}if(e.scope==="project"){const f=C(e.storeRoot),p=y.get(R(f));p===void 0&&j([f],"cwd-ancestor",o.target.profileId,o.id),w(e,{reason:p?.reason??"cwd-ancestor",root:f,targetId:o.id},o);continue}const s=e.scope==="user"?"user":e.scope==="profile"?"profile":e.scope==="node"?"node":"builtin";u({reason:s,root:e.storeRoot,boundary:"store"}),w(e,{reason:s,root:e.storeRoot,targetId:o.id},o)}},"walkTarget"),E=new Set;for(;;){g();const o=a.filter(e=>!E.has(e.id));if(o.length===0)break;for(const e of o)E.add(e.id),J(e)}const K=io("user");K!==null&&u({reason:"plugin",root:K,boundary:"plugins"});const W=[...so("user")];for(const{root:o}of y.values())u({reason:"plugin",root:o,boundary:"plugins"}),W.push(...no("project",o));for(const o of W){const e=lo(o);u({reason:"plugin",root:e.storeRoot,boundary:"store",detail:o.name}),w(e,{reason:"plugin",root:e.storeRoot})}for(const{profileId:o,manifest:e}of t.profiles){const s=e.grantee?.startsWith("app:")?x(V(e.grantee).memory,"profiles",o):eo(o);u({reason:"profile",root:s,boundary:"store",detail:o}),w({scope:"profile",storeRoot:s,namespace:"",mountStatus:v(s)?"ready":"absent",projectMemory:D},{reason:"profile",root:s})}return{roots:m,stores:[...k.values()].map(o=>({key:o.key,descriptor:o.descriptor,discovery:o.discovery,targets:o.targets,writable:o.writable})),targets:a.map(o=>({id:o.id,kind:o.kind,origin:o.origin,target:o.target,storeKeys:o.storeKeys})),blockers:I}}c(Do,"discoverCorpus");function Eo(t,n={}){const r=new Map,i=[];for(const m of t.stores){const d=n.preloaded?.get(m.key);if(d!==void 0){r.set(m.key,d);continue}const u=co(m.descriptor.storeRoot);r.set(m.key,u.snapshot);for(const y of u.skipped)i.push({storeRoot:m.key,...y})}return{snapshots:r,skipped:i}}c(Eo,"loadCorpusSnapshots");function Ko(t){return t.map(n=>({kind:"parse-failure",message:`${n.relPath}: frontmatter is not valid YAML (${n.error}) \u2014 the document's identity cannot be read; fix the file and re-run`,storeRoot:n.storeRoot,path:x(n.storeRoot,n.relPath)}))}c(Ko,"parseFailureBlockers");function N(t,n,r){const i=new Map(t.map(d=>[d.key,d])),m=new Map(n.map(d=>[d.id,d]));return{stores:t,targets:n,roots:r,store:c(d=>i.get(d),"store"),storesForTarget:c(d=>(m.get(d)?.storeKeys??[]).map(u=>i.get(u)).filter(u=>u!==void 0),"storesForTarget")}}c(N,"makeCorpusSnapshot");function Wo(t,n){const r=t.stores.map(i=>({...i,snapshot:n.get(i.key)??{root:i.descriptor.storeRoot,docs:[]}}));return N(r,t.targets,t.roots)}c(Wo,"buildCorpusSnapshot");function go(t){const n=t.stores.map(r=>({...r,snapshot:{root:r.snapshot.root,docs:[...r.snapshot.docs]}}));return N(n,t.targets,t.roots)}c(go,"cloneCorpus");function U(t,n,r=new Set){let i;for(const m of t.stores)n.path.startsWith(`${m.snapshot.root}/`)&&(i===void 0||m.snapshot.root.length>i.snapshot.root.length)&&(i=m);if(i===void 0){if(r.has(n.path))return;throw new Error(`corpus migration: planned change outside every discovered store: ${n.path}`)}ao(i.snapshot,n)}c(U,"foldCorpusChange");function Ao(t,n={}){const r=(n.migrations??po).filter(a=>a.lane==="corpus"),i=[...n.blockers??[]],m=[],d=[],u=[],y=[],P=[],$=[],S=[],b=c((a,l)=>({migrations:r.length,blocked:i.length>0&&r.length>0,blockers:i,planned:m,repositories:d,storePrefixes:u,renames:y,references:P,wrote:l,verified:a}),"result"),j={consumers:[],identities:[]};if(r.length===0)return b(!1,j);const I=go(t);for(const a of r){const l=a.plan(I);i.push(...l.blockers),d.push(...l.repositories),u.push(...l.storePrefixes),y.push(...l.renames),P.push(...l.references);for(const g of l.consumers)U(I,g);const M=new Set(l.repositories.map(g=>g.declarationPath));for(const g of l.identities)U(I,g,M);$.push(...l.consumers),S.push(...l.identities),m.push({migration:a.description,consumers:l.consumers.map(g=>g.path),identities:l.identities.map(g=>g.path)})}const k={consumers:$.map(a=>a.path),identities:S.map(a=>a.path)};if(i.length>0)return b(!1,j);if(n.dryRun===!0)return b(!1,k);for(const a of $)a.after===null?_(a.path):L(a.path,a.after);for(const a of S)a.after===null?_(a.path):L(a.path,a.after);if(n.rebuild===void 0)return b(!1,k);const w=n.rebuild();for(const a of r)for(const l of a.verify?.(w)??[])i.push({...l,kind:"verification"});return b(!0,k)}c(Ao,"runCorpusMigrations");export{Wo as buildCorpusSnapshot,Do as discoverCorpus,Eo as loadCorpusSnapshots,Ko as parseFailureBlockers,Ao as runCorpusMigrations};
@@ -1,15 +0,0 @@
1
- /** Split a complete document into its raw frontmatter YAML and byte-preserved body. */
2
- export declare function splitDocSource(source: string, docPath: string): {
3
- rawYaml: string;
4
- body: string;
5
- };
6
- /** Remove complete top-level mapping-key lines, including multiline values. */
7
- export declare function dropTopLevelKeys(rawYaml: string, keys: readonly string[], docPath: string): string;
8
- /** Remove selected items from a top-level block sequence without re-rendering retained bytes. */
9
- export declare function dropSequenceItems(rawYaml: string, key: string, drop: (item: unknown) => boolean, docPath: string): string;
10
- /** Append a rendered top-level mapping pair while retaining existing YAML bytes. */
11
- export declare function appendRenderedKey(rawYaml: string, key: string, value: unknown, docPath: string): string;
12
- /** Prove that a transformed YAML block parses to exactly the expected mapping. */
13
- export declare function proveFrontmatterRoundTrip(after: string, expected: Record<string, unknown>, docPath: string): void;
14
- /** Replace only the YAML block in a complete document; the body remains byte-for-byte unchanged. */
15
- export declare function rebuildDocSource(source: string, newYaml: string, docPath: string): string;
@@ -1,8 +0,0 @@
1
- var A=Object.defineProperty;var p=(e,t)=>A(e,"name",{value:t,configurable:!0});import{isMap as q,isSeq as v,parse as x,parseDocument as k,stringify as O}from"yaml";import{parseFrontmatterGeneric as R}from"../core/frontmatter.js";function w(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((r,n)=>w(r,t[n]));if(e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"){const r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(c=>w(e[c],t[c]))}return!1}p(w,"deepEqual");function $(e,t){if(e.trim()==="")return[];const r=k(e);if(r.errors.length>0||!q(r.contents))throw new Error(`frontmatter splice: unparseable frontmatter in ${t}`);return r.contents.items}p($,"yamlMap");function j(e,t,r){const n=t.key?.range,c=t.value?.range;if(n===void 0)throw new Error(`frontmatter splice: rangeless key in ${r}`);const f=e.lastIndexOf(`
2
- `,n[0]-1)+1;let o=c?.[2]??n[2];if(!(o>0&&e[o-1]===`
3
- `)){for(;o<e.length&&(e[o]===" "||e[o]===" "||e[o]==="\r");)o++;e[o]===`
4
- `&&o++}return[f,o]}p(j,"keyLineSpan");function h(e,t){$(e,t);let r;try{r=x(e)}catch{throw new Error(`frontmatter splice: unparseable frontmatter in ${t}`)}if(r===null||typeof r!="object"||Array.isArray(r))throw new Error(`frontmatter splice: frontmatter is not a mapping in ${t}`);return r}p(h,"parseRecord");function D(e,t){let r;try{r=R(e)}catch(n){throw new Error(`frontmatter splice: unparseable frontmatter in ${t}`,{cause:n})}if(r.raw===""&&r.body===e)throw new Error(`frontmatter splice: cannot locate frontmatter block in ${t}`);return{rawYaml:r.raw,body:r.body}}p(D,"splitDocSource");function I(e,t,r){const n=$(e,r),c=new Set(t),f=n.filter(i=>c.has(String(i.key))).map(i=>j(e,i,r)).sort((i,u)=>u[0]-i[0]);let o=e;for(const[i,u]of f)o=o.slice(0,i)+o.slice(u);const l=h(e,r);for(const i of t)delete l[i];return g(o,l,r),o}p(I,"dropTopLevelKeys");function M(e,t,r,n){const f=$(e,n).find(s=>String(s.key)===t);if(f===void 0)return e;if(!v(f.value))throw new Error(`frontmatter splice: ${t} is not a sequence in ${n}`);const o=f.value.items,l=o.map(s=>r(s.toJSON?.()));if(!l.some(Boolean))return e;const i=h(e,n),u=i[t];if(!Array.isArray(u))throw new Error(`frontmatter splice: ${t} is not a sequence in ${n}`);const E=u.filter((s,a)=>!l[a]);if(E.length===0){delete i[t];const s=I(e,[t],n);return g(s,i,n),s}const b=f.value.range;if(b===void 0)throw new Error(`frontmatter splice: rangeless sequence in ${n}`);const y=o.map(s=>{const a=s.range;if(a===void 0)throw new Error(`frontmatter splice: rangeless sequence item in ${n}`);return e.lastIndexOf(`
5
- `,a[0]-1)+1});if(new Set(y).size!==y.length)throw new Error(`frontmatter splice: flow sequence cannot be spliced byte-precisely in ${n}`);const m=[];for(let s=0;s<o.length;s++){if(!l[s])continue;const a=y[s],S=y[s+1]??b[2];m.push([a,S])}m.sort((s,a)=>a[0]-s[0]);let d=e;for(const[s,a]of m)d=d.slice(0,s)+d.slice(a);return i[t]=E,g(d,i,n),d}p(M,"dropSequenceItems");function N(e,t,r,n){const c=h(e,n);c[t]=r;const f=O({[t]:r},{lineWidth:0});let o=e===""?f:(e.endsWith(`
6
- `)?e:e+`
7
- `)+f;return o=o.replace(/\r?\n$/,""),g(o,c,n),o}p(N,"appendRenderedKey");function g(e,t,r){let n;try{n=x(e===""?"{}":e)}catch(c){throw new Error(`frontmatter splice: transformed frontmatter does not parse in ${r}`,{cause:c})}if(!w(n??{},t))throw new Error(`frontmatter splice: spliced frontmatter does not round-trip in ${r}`)}p(g,"proveFrontmatterRoundTrip");function T(e,t,r){const{rawYaml:n,body:c}=D(e,r),f=e.length-c.length,o=e.indexOf(`
8
- `),l=o<0?-1:o+1,i=l<0?-1:l+n.length;if(n===""&&f===e.length)throw new Error(`frontmatter splice: cannot locate frontmatter block in ${r}`);if(l<0||i>f)throw new Error(`frontmatter splice: cannot locate frontmatter block in ${r}`);return e.slice(0,l)+t+e.slice(i)}p(T,"rebuildDocSource");export{N as appendRenderedKey,M as dropSequenceItems,I as dropTopLevelKeys,g as proveFrontmatterRoundTrip,T as rebuildDocSource,D as splitDocSource};
@@ -1,30 +0,0 @@
1
- import type { ProfileManifestSnapshot, StateMigration } from './types.js';
2
- export interface ProfileManifestRunResult {
3
- /** Profile manifests found under the profiles root. */
4
- profiles: number;
5
- /** One row per migration that rewrote a manifest, in registry order. */
6
- applied: {
7
- profileId: string;
8
- path: string;
9
- migration: string;
10
- }[];
11
- /** Post-migration manifest per readable profile, in scan order — coherent
12
- * under `dryRun`, where the same fold ran but nothing was written. */
13
- snapshots: ProfileManifestSnapshot[];
14
- /** Manifests left untouched because they are not valid JSON. Unreadable
15
- * bytes are not a structure this lane can convert, and failing the run over
16
- * one would block every other profile's convergence. */
17
- skipped: {
18
- profileId: string;
19
- path: string;
20
- error: string;
21
- }[];
22
- }
23
- export declare function runProfileManifestMigrations(profilesRoot: string, opts: {
24
- /** Held for the whole re-read/fold/write of one manifest — the same lock
25
- * add/remove take, so a concurrent mutation either lands before the
26
- * re-read or serializes after the write, never under it. */
27
- withLock: <T>(profileId: string, fn: () => T) => T;
28
- dryRun?: boolean;
29
- migrations?: readonly StateMigration[];
30
- }): ProfileManifestRunResult;
@@ -1,2 +0,0 @@
1
- var d=Object.defineProperty;var l=(n,o)=>d(n,"name",{value:o,configurable:!0});import{existsSync as u,readFileSync as h,readdirSync as y}from"node:fs";import{join as S}from"node:path";import{atomicWriteJson as g}from"../core/fs-utils.js";import{STATE_MIGRATIONS as w}from"./registry.js";const A=/^[a-z0-9]+(?:-[a-z0-9]+)*-[0-9a-f]{8}$/;function x(n,o){const m=(o.migrations??w).filter(s=>s.lane==="profile-manifest"),e={profiles:0,applied:[],snapshots:[],skipped:[]};if(!u(n))return e;for(const s of y(n,{withFileTypes:!0})){if(!s.isDirectory())continue;const t=s.name;if(!A.test(t))continue;const i=S(n,t,"profile.json");u(i)&&(e.profiles+=1,o.withLock(t,()=>{let f;try{const r=JSON.parse(h(i,"utf8"));if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("manifest is not a JSON object");f=r}catch(r){e.skipped.push({profileId:t,path:i,error:(r instanceof Error?r.message:String(r)).split(`
2
- `)[0]});return}let a=f,c=!1;for(const r of m){const p=r.apply({profileId:t,path:i,raw:a});p!==null&&(a=p,c=!0,e.applied.push({profileId:t,path:i,migration:r.description}))}c&&o.dryRun!==!0&&g(i,a),e.snapshots.push({profileId:t,path:i,manifest:a})}))}return e}l(x,"runProfileManifestMigrations");export{x as runProfileManifestMigrations};
@@ -1,7 +0,0 @@
1
- import type { OnDiskMigrationLane, StateMigration } from './types.js';
2
- export declare const STATE_MIGRATIONS: readonly StateMigration[];
3
- export interface OnDiskMigrationIdentity {
4
- readonly id: string;
5
- readonly lane: OnDiskMigrationLane;
6
- }
7
- export declare function onDiskMigrationIdentity(): readonly OnDiskMigrationIdentity[];
@@ -1 +0,0 @@
1
- var i=Object.defineProperty;var t=(o,r)=>i(o,"name",{value:r,configurable:!0});import{surfacesFrontmatterMigration as e}from"./001-surfaces-frontmatter.js";import{profileProjectMemoryMigration as n}from"./002-profile-project-memory.js";import{repositoryRootMemoryIdentityMigration as m}from"./003-repository-root-memory-identity/index.js";const a=[e,n,m];function y(){return a.filter(o=>o.lane!=="journaled").map(({id:o,lane:r})=>({id:o,lane:r}))}t(y,"onDiskMigrationIdentity");export{a as STATE_MIGRATIONS,y as onDiskMigrationIdentity};
@@ -1,43 +0,0 @@
1
- import type { NodeMemoryTarget } from '../core/canvas/types.js';
2
- import { type CorpusDiscovery } from './corpus.js';
3
- import type { CorpusBlocker, CorpusIdentityRename, CorpusRepositoryDecision, CorpusStorePrefix, CorpusReferenceRewrite, OnDiskMigrationLane, StoreSnapshot } from './types.js';
4
- export type OnDiskMigrationPhase = 'not-started' | 'planned' | 'written';
5
- export interface OnDiskMigrationApplied {
6
- store: string;
7
- lane: OnDiskMigrationLane;
8
- migration: string;
9
- files: string[];
10
- }
11
- export interface OnDiskMigrationSkipped {
12
- store: string;
13
- relPath: string;
14
- error: string;
15
- }
16
- export interface OnDiskMigrationRunResult {
17
- profiles: number;
18
- discovery: CorpusDiscovery;
19
- snapshots: ReadonlyMap<string, StoreSnapshot>;
20
- changed: number;
21
- applied: OnDiskMigrationApplied[];
22
- skipped: OnDiskMigrationSkipped[];
23
- blocked: boolean;
24
- blockers: CorpusBlocker[];
25
- corpusPhase: OnDiskMigrationPhase;
26
- wrote: {
27
- profileManifests: string[];
28
- documents: string[];
29
- corpusConsumers: string[];
30
- corpusIdentities: string[];
31
- };
32
- repositories: CorpusRepositoryDecision[];
33
- storePrefixes: CorpusStorePrefix[];
34
- renames: CorpusIdentityRename[];
35
- references: CorpusReferenceRewrite[];
36
- finalVerificationSucceeded: boolean;
37
- dryRun: boolean;
38
- }
39
- export declare function runOnDiskMigrations(opts: {
40
- dryRun?: boolean;
41
- explicitDirs?: readonly string[];
42
- nodes: readonly NodeMemoryTarget[];
43
- }): Promise<OnDiskMigrationRunResult>;
@@ -1 +0,0 @@
1
- var b=Object.defineProperty;var l=(n,t)=>b(n,"name",{value:t,configurable:!0});import{profileSpace as y}from"../core/layout.js";import{listStoredProfiles as C}from"../core/scoped-state/profiles.js";import{resetScopeCache as R,userScopeRoot as S}from"../core/scope.js";import{buildCorpusSnapshot as g,discoverCorpus as v,loadCorpusSnapshots as k,parseFailureBlockers as M,runCorpusMigrations as P}from"./corpus.js";import{runConvergentMigrations as x}from"./convergent.js";async function j(n){const t=n.dryRun===!0,i=[],u=[],f=C(S()).map(({profileId:e,manifest:r})=>({profileId:e,manifest:r,path:y(r.grantee??"app:terminal",e).memory}));R();const s=await v({profiles:f,explicitDirs:n.explicitDirs,nodes:n.nodes}),p=[],d=new Map;for(const e of s.stores){if(!e.writable)continue;const r=x(e.descriptor.storeRoot,{dryRun:t});d.set(e.key,r.snapshot);for(const c of r.applied)i.push({store:e.key,lane:"convergent",migration:c.migration,files:c.files});for(const c of r.skipped)p.push({storeRoot:e.key,...c})}const a=k(s,{preloaded:d});p.push(...a.skipped);for(const e of p)u.push({store:e.storeRoot,relPath:e.relPath,error:e.error});const o=P(g(s,a.snapshots),{dryRun:t,blockers:[...s.blockers,...M(p)],rebuild:l(()=>g(s,k(s).snapshots),"rebuild")}),m=o.wrote.consumers.length>0||o.wrote.identities.length>0;if(m)for(const e of o.planned){const r=[...e.consumers,...e.identities];r.length>0&&i.push({store:"corpus",lane:"corpus",migration:e.migration,files:r})}const w=t?"planned":m?"written":"not-started",h=o.blocked;return{profiles:f.length,discovery:s,snapshots:a.snapshots,changed:i.reduce((e,r)=>e+r.files.length,0),applied:i,skipped:u,blocked:h,blockers:o.blockers,corpusPhase:w,wrote:{profileManifests:[],documents:i.filter(e=>e.lane==="convergent").flatMap(e=>e.files),corpusConsumers:o.wrote.consumers,corpusIdentities:o.wrote.identities},repositories:o.repositories,storePrefixes:o.storePrefixes,renames:o.renames,references:o.references,finalVerificationSucceeded:o.verified&&!h,dryRun:t}}l(j,"runOnDiskMigrations");export{j as runOnDiskMigrations};