@north-light/crouter 0.3.353 → 0.3.355

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 (626) 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 +135 -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 +168 -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 +11 -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/02-turn-lifecycle/02-resident.md +1 -0
  25. package/dist/builtin-memory/04-orchestration-kernel.md +10 -31
  26. package/dist/builtin-memory/05-kinds/advisor/01-orchestrator.md +1 -1
  27. package/dist/builtin-memory/05-kinds/explore/00-base.md +2 -2
  28. package/dist/builtin-memory/05-kinds/explore/01-orchestrator.md +2 -2
  29. package/dist/builtin-memory/crouter-concepts/INDEX.md +2 -2
  30. package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
  31. package/dist/builtin-memory/crouter-concepts/memory.md +15 -15
  32. package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +1 -1
  33. package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +5 -5
  34. package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
  35. package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
  36. package/dist/builtin-memory/crouter-sdk/INDEX.md +2 -2
  37. package/dist/builtin-memory/crouter-sdk/README.md +5 -6
  38. package/dist/builtin-memory/crouter-sdk/errors.md +0 -13
  39. package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -1
  40. package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +2 -2
  41. package/dist/builtin-memory/crouter-sdk/nodes.md +0 -2
  42. package/dist/builtin-memory/crouter-sdk/resources.md +0 -1
  43. package/dist/builtin-memory/explore/exploration-doc.md +4 -4
  44. package/dist/builtin-memory/insights/capture.md +6 -6
  45. package/dist/builtin-memory/insights/init.md +14 -14
  46. package/dist/builtin-memory/internal/INDEX.md +4 -4
  47. package/dist/builtin-memory/internal/agent-shaping.md +20 -20
  48. package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
  49. package/dist/builtin-memory/internal/marketplaces.md +2 -2
  50. package/dist/builtin-memory/internal/memory-loading.md +31 -30
  51. package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
  52. package/dist/builtin-memory/internal/plugins.md +16 -14
  53. package/dist/builtin-memory/internal/storage-tiers.md +4 -4
  54. package/dist/builtin-memory/memory-read-orientation.md +1 -1
  55. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +32 -40
  56. package/dist/clients/attach/input/controller.js +1 -1
  57. package/dist/clients/attach/input/ref-autocomplete.js +1 -1
  58. package/dist/clients/attach/input/titled-editor.js +1 -1
  59. package/dist/clients/attach/overlays/file-review.d.ts +1 -0
  60. package/dist/clients/attach/overlays/file-review.js +2 -2
  61. package/dist/clients/attach/render/chat-view.d.ts +6 -0
  62. package/dist/clients/attach/render/chat-view.js +2 -2
  63. package/dist/clients/attach/render/crtr-output.d.ts +1 -2
  64. package/dist/clients/attach/render/crtr-output.js +17 -17
  65. package/dist/clients/attach/render/doc-links.d.ts +34 -0
  66. package/dist/clients/attach/render/doc-links.js +1 -0
  67. package/dist/clients/attach/render/group-activity.d.ts +8 -8
  68. package/dist/clients/attach/render/group-activity.js +2 -2
  69. package/dist/clients/attach/render/group-recap.js +1 -1
  70. package/dist/clients/attach/render/markdown-source.js +5 -5
  71. package/dist/clients/attach/render/tool-calls.d.ts +1 -1
  72. package/dist/clients/attach/session/doc-materialize.d.ts +53 -0
  73. package/dist/clients/attach/session/doc-materialize.js +3 -0
  74. package/dist/clients/attach/session/document-links.d.ts +21 -0
  75. package/dist/clients/attach/session/document-links.js +1 -0
  76. package/dist/clients/attach/session/file-links.d.ts +2 -0
  77. package/dist/clients/attach/session/file-links.js +1 -1
  78. package/dist/clients/attach/session/profile-files.js +1 -1
  79. package/dist/clients/attach/slash/dispatch.js +1 -1
  80. package/dist/clients/attach/viewer.js +816 -1561
  81. package/dist/clients/inbox/review/review-client.d.ts +5 -1
  82. package/dist/clients/inbox/review/review-client.js +1 -1
  83. package/dist/commands/api-client.d.ts +2 -0
  84. package/dist/commands/api-client.js +3 -3
  85. package/dist/commands/canvas/edges.d.ts +2 -0
  86. package/dist/commands/canvas/edges.js +2 -0
  87. package/dist/commands/canvas/list.d.ts +4 -0
  88. package/dist/commands/canvas/list.js +3 -0
  89. package/dist/commands/canvas/read.d.ts +8 -0
  90. package/dist/commands/canvas/read.js +5 -0
  91. package/dist/commands/canvas/search.d.ts +2 -0
  92. package/dist/commands/canvas/search.js +3 -0
  93. package/dist/commands/canvas/unwatch.d.ts +2 -0
  94. package/dist/commands/canvas/unwatch.js +1 -0
  95. package/dist/commands/canvas/watch.d.ts +3 -0
  96. package/dist/commands/canvas/watch.js +1 -0
  97. package/dist/commands/canvas-analytics.js +1 -1
  98. package/dist/commands/canvas-history/grep.js +4 -4
  99. package/dist/commands/canvas-history/read.js +2 -2
  100. package/dist/commands/canvas-history/search.js +7 -7
  101. package/dist/commands/canvas-history/shared.d.ts +0 -1
  102. package/dist/commands/canvas-history/shared.js +1 -1
  103. package/dist/commands/canvas-history/stats.js +2 -2
  104. package/dist/commands/canvas-history.js +1 -1
  105. package/dist/commands/canvas.js +1 -1
  106. package/dist/commands/doc/delete.d.ts +2 -0
  107. package/dist/commands/doc/delete.js +1 -0
  108. package/dist/commands/doc/edit.d.ts +2 -0
  109. package/dist/commands/doc/edit.js +1 -0
  110. package/dist/commands/doc/history.d.ts +2 -0
  111. package/dist/commands/doc/history.js +2 -0
  112. package/dist/commands/doc/lint.d.ts +2 -0
  113. package/dist/commands/doc/lint.js +2 -0
  114. package/dist/commands/doc/list.d.ts +2 -0
  115. package/dist/commands/doc/list.js +1 -0
  116. package/dist/commands/doc/move.d.ts +2 -0
  117. package/dist/commands/doc/move.js +1 -0
  118. package/dist/commands/doc/read.d.ts +2 -0
  119. package/dist/commands/doc/read.js +1 -0
  120. package/dist/commands/doc/shared.d.ts +25 -0
  121. package/dist/commands/doc/shared.js +2 -0
  122. package/dist/commands/doc/write.d.ts +2 -0
  123. package/dist/commands/doc/write.js +1 -0
  124. package/dist/commands/{memory.d.ts → doc.d.ts} +1 -1
  125. package/dist/commands/doc.js +1 -0
  126. package/dist/commands/human/review.js +1 -1
  127. package/dist/commands/node/bash.js +2 -2
  128. package/dist/commands/node/create.js +1 -1
  129. package/dist/commands/node/inspect.js +10 -10
  130. package/dist/commands/node/lifecycle.js +2 -2
  131. package/dist/commands/node/outcome.js +1 -1
  132. package/dist/commands/node/subscription.js +1 -1
  133. package/dist/commands/node-context.js +2 -2
  134. package/dist/commands/pkg/browse/catalog.js +1 -1
  135. package/dist/commands/pkg/browse/doc-view.js +1 -1
  136. package/dist/commands/pkg/browse/model.d.ts +9 -17
  137. package/dist/commands/pkg/plugin-inspect.js +1 -1
  138. package/dist/commands/pkg/plugin-manage.d.ts +4 -8
  139. package/dist/commands/pkg/plugin-manage.js +15 -17
  140. package/dist/commands/profile/list.js +1 -1
  141. package/dist/commands/profile/new.js +1 -1
  142. package/dist/commands/profile/project.js +1 -1
  143. package/dist/commands/profile/show.js +1 -1
  144. package/dist/commands/push.js +3 -3
  145. package/dist/commands/sys/config.js +1 -1
  146. package/dist/commands/sys/context/admin/actions.d.ts +18 -43
  147. package/dist/commands/sys/context/admin/actions.js +1 -2
  148. package/dist/commands/sys/context/admin/detail-panel.d.ts +17 -25
  149. package/dist/commands/sys/context/admin/detail-panel.js +2 -1
  150. package/dist/commands/sys/context/admin/docs-panel.d.ts +7 -6
  151. package/dist/commands/sys/context/admin/docs-panel.js +1 -1
  152. package/dist/commands/sys/context/admin/list-view.d.ts +12 -12
  153. package/dist/commands/sys/context/admin/list-view.js +1 -1
  154. package/dist/commands/sys/context/admin/model.d.ts +96 -69
  155. package/dist/commands/sys/context/admin/model.js +1 -1
  156. package/dist/commands/sys/context/admin/rail-panel.d.ts +7 -5
  157. package/dist/commands/sys/context/admin/rail-panel.js +1 -1
  158. package/dist/commands/sys/context/admin/read-view.d.ts +10 -14
  159. package/dist/commands/sys/context/admin/read-view.js +1 -2
  160. package/dist/commands/sys/context/admin/shell.d.ts +26 -31
  161. package/dist/commands/sys/context/admin/shell.js +1 -1
  162. package/dist/commands/sys/context/admin.js +2 -2
  163. package/dist/commands/sys/context/doc.js +2 -3
  164. package/dist/commands/sys/context/expose.js +2 -2
  165. package/dist/commands/sys/context/prompt-review.js +4 -4
  166. package/dist/commands/sys/context/resolve.d.ts +92 -65
  167. package/dist/commands/sys/context/resolve.js +7 -9
  168. package/dist/commands/sys/context.js +1 -1
  169. package/dist/commands/sys/doctor.js +1 -1
  170. package/dist/commands/sys/migrate.js +1 -1
  171. package/dist/commands/sys/panels/profiles-panel.d.ts +3 -1
  172. package/dist/commands/sys/panels/profiles-panel.js +1 -1
  173. package/dist/commands/sys/sync-deps.d.ts +6 -11
  174. package/dist/commands/sys/sync-deps.js +7 -8
  175. package/dist/commands/sys/sync-project-guidance.js +5 -4
  176. package/dist/commands/sys/sync-shared.d.ts +41 -4
  177. package/dist/commands/sys/sync-shared.js +1 -1
  178. package/dist/commands/sys/sync-skills.js +2 -2
  179. package/dist/commands/sys/sync.js +1 -1
  180. package/dist/core/bash-job-supervisor.d.ts +2 -3
  181. package/dist/core/bash-job-supervisor.js +3 -3
  182. package/dist/core/bash-jobs.d.ts +0 -5
  183. package/dist/core/bash-jobs.js +7 -7
  184. package/dist/core/bootstrap.js +2 -2
  185. package/dist/core/canvas/canvas.d.ts +6 -50
  186. package/dist/core/canvas/canvas.js +16 -21
  187. package/dist/core/canvas/db.d.ts +4 -1
  188. package/dist/core/canvas/db.js +2 -2
  189. package/dist/core/canvas/history.d.ts +11 -39
  190. package/dist/core/canvas/history.js +9 -20
  191. package/dist/core/canvas/install-id.d.ts +2 -2
  192. package/dist/core/canvas/install-id.js +1 -1
  193. package/dist/core/canvas/memory-reads.d.ts +5 -0
  194. package/dist/core/canvas/memory-reads.js +1 -1
  195. package/dist/core/canvas/migrations.js +215 -41
  196. package/dist/core/canvas/node-agent-paths.js +1 -1
  197. package/dist/core/canvas/node-tokens.js +1 -1
  198. package/dist/core/canvas/paths.d.ts +0 -4
  199. package/dist/core/canvas/paths.js +1 -1
  200. package/dist/core/canvas/remote-canvas-source.d.ts +0 -1
  201. package/dist/core/canvas/remote-canvas-source.js +1 -1
  202. package/dist/core/canvas/render-source.d.ts +9 -6
  203. package/dist/core/canvas/render-source.js +6 -6
  204. package/dist/core/canvas/sessions.js +2 -2
  205. package/dist/core/canvas/source.d.ts +6 -0
  206. package/dist/core/canvas/tree.d.ts +29 -0
  207. package/dist/core/canvas/tree.js +12 -0
  208. package/dist/core/canvas/types.d.ts +0 -20
  209. package/dist/core/command-plugins/bundle.js +1 -1
  210. package/dist/core/config.d.ts +1 -1
  211. package/dist/core/conversation-store/listener.js +4 -2
  212. package/dist/core/feed/feed.d.ts +9 -7
  213. package/dist/core/feed/feed.js +3 -7
  214. package/dist/core/feed/inbox.d.ts +3 -5
  215. package/dist/core/feed/inbox.js +1 -10
  216. package/dist/core/feed/messages.d.ts +33 -6
  217. package/dist/core/feed/messages.js +10 -7
  218. package/dist/core/feed/reports.d.ts +10 -0
  219. package/dist/core/feed/reports.js +2 -0
  220. package/dist/core/grants/remove.js +1 -1
  221. package/dist/core/graph/access.d.ts +24 -0
  222. package/dist/core/graph/access.js +8 -0
  223. package/dist/core/graph/bodies.d.ts +6 -0
  224. package/dist/core/graph/bodies.js +1 -0
  225. package/dist/core/graph/deletion.d.ts +10 -0
  226. package/dist/core/graph/deletion.js +5 -0
  227. package/dist/core/graph/diff.d.ts +4 -0
  228. package/dist/core/graph/diff.js +4 -0
  229. package/dist/core/graph/documents.d.ts +167 -0
  230. package/dist/core/graph/documents.js +10 -0
  231. package/dist/core/graph/edges.d.ts +25 -0
  232. package/dist/core/graph/edges.js +1 -0
  233. package/dist/core/graph/events.d.ts +26 -0
  234. package/dist/core/graph/events.js +7 -0
  235. package/dist/core/graph/exposures.d.ts +53 -0
  236. package/dist/core/graph/exposures.js +4 -0
  237. package/dist/core/graph/jobs.d.ts +31 -0
  238. package/dist/core/graph/jobs.js +2 -0
  239. package/dist/core/graph/names.d.ts +30 -0
  240. package/dist/core/graph/names.js +3 -0
  241. package/dist/core/graph/objects.d.ts +55 -0
  242. package/dist/core/graph/objects.js +9 -0
  243. package/dist/core/graph/package-docs.d.ts +31 -0
  244. package/dist/core/graph/package-docs.js +5 -0
  245. package/dist/core/graph/package-files.d.ts +20 -0
  246. package/dist/core/graph/package-files.js +2 -0
  247. package/dist/core/graph/reader.d.ts +21 -0
  248. package/dist/core/graph/reader.js +3 -0
  249. package/dist/core/graph/repo-sync/exchange.d.ts +34 -0
  250. package/dist/core/graph/repo-sync/exchange.js +2 -0
  251. package/dist/core/graph/repo-sync/identity.d.ts +30 -0
  252. package/dist/core/graph/repo-sync/identity.js +1 -0
  253. package/dist/core/graph/repo-sync/index.d.ts +4 -0
  254. package/dist/core/graph/repo-sync/index.js +1 -0
  255. package/dist/core/graph/repo-sync/mirror.d.ts +30 -0
  256. package/dist/core/graph/repo-sync/mirror.js +6 -0
  257. package/dist/core/graph/repo-sync/ref-format.d.ts +76 -0
  258. package/dist/core/graph/repo-sync/ref-format.js +2 -0
  259. package/dist/core/graph/repo-sync/repos.d.ts +17 -0
  260. package/dist/core/graph/repo-sync/repos.js +3 -0
  261. package/dist/core/graph/repo-sync/sync.d.ts +42 -0
  262. package/dist/core/graph/repo-sync/sync.js +2 -0
  263. package/dist/core/graph/rules.d.ts +26 -0
  264. package/dist/core/graph/rules.js +3 -0
  265. package/dist/core/graph/spaces/app.d.ts +3 -0
  266. package/dist/core/graph/spaces/app.js +1 -0
  267. package/dist/core/graph/spaces/index.d.ts +19 -0
  268. package/dist/core/graph/spaces/index.js +1 -0
  269. package/dist/core/graph/spaces/person.d.ts +5 -0
  270. package/dist/core/graph/spaces/person.js +2 -0
  271. package/dist/core/graph/spaces/repo.d.ts +4 -0
  272. package/dist/core/graph/spaces/repo.js +1 -0
  273. package/dist/core/graph/types.d.ts +75 -0
  274. package/dist/core/graph/types.js +1 -0
  275. package/dist/core/graph/watches.d.ts +62 -0
  276. package/dist/core/graph/watches.js +18 -0
  277. package/dist/core/human/feedback-companion.js +1 -1
  278. package/dist/core/human/requests.d.ts +3 -1
  279. package/dist/core/human/requests.js +6 -6
  280. package/dist/core/inspector/model.js +2 -2
  281. package/dist/core/io.js +5 -5
  282. package/dist/core/layout-migrate/index.d.ts +24 -1
  283. package/dist/core/layout-migrate/index.js +4 -4
  284. package/dist/core/layout-migrate/paths.d.ts +4 -0
  285. package/dist/core/layout-migrate/paths.js +1 -1
  286. package/dist/core/layout-migrate/stored-paths.d.ts +7 -0
  287. package/dist/core/layout-migrate/stored-paths.js +11 -11
  288. package/dist/core/layout-migrate/stores.d.ts +19 -6
  289. package/dist/core/layout-migrate/stores.js +3 -4
  290. package/dist/core/manifest.d.ts +0 -2
  291. package/dist/core/manifest.js +1 -1
  292. package/dist/core/{memory/extensions.d.ts → plugin-extensions.d.ts} +9 -10
  293. package/dist/core/plugin-extensions.js +1 -0
  294. package/dist/core/preview-registry.d.ts +1 -1
  295. package/dist/core/preview-registry.js +3 -2
  296. package/dist/core/profiles/manifest.d.ts +7 -7
  297. package/dist/core/profiles/manifest.js +1 -1
  298. package/dist/core/profiles/select.js +3 -3
  299. package/dist/core/review/birth.js +1 -1
  300. package/dist/core/review/companion.js +1 -1
  301. package/dist/core/review/stage.d.ts +12 -1
  302. package/dist/core/review/stage.js +1 -1
  303. package/dist/core/review/store.d.ts +2 -0
  304. package/dist/core/review/store.js +1 -1
  305. package/dist/core/review/types.d.ts +7 -1
  306. package/dist/core/runs/events.js +1 -1
  307. package/dist/core/runs/operations.js +5 -5
  308. package/dist/core/runs/questions.js +2 -2
  309. package/dist/core/runtime/bearings-render.d.ts +13 -7
  310. package/dist/core/runtime/bearings-render.js +12 -12
  311. package/dist/core/runtime/bearings.d.ts +8 -18
  312. package/dist/core/runtime/bearings.js +7 -7
  313. package/dist/core/runtime/broker/daemon-ops.d.ts +7 -12
  314. package/dist/core/runtime/broker/daemon-ops.js +1 -1
  315. package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
  316. package/dist/core/runtime/broker/fault-retry.js +1 -1
  317. package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
  318. package/dist/core/runtime/broker/frame-memory-refs.d.ts +7 -2
  319. package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
  320. package/dist/core/runtime/broker/inbox.d.ts +1 -4
  321. package/dist/core/runtime/broker/inbox.js +1 -10
  322. package/dist/core/runtime/broker/rebind.js +1 -1
  323. package/dist/core/runtime/broker/retry-card-elision.d.ts +7 -0
  324. package/dist/core/runtime/broker/retry-card-elision.js +1 -0
  325. package/dist/core/runtime/broker-extension-render.d.ts +0 -13
  326. package/dist/core/runtime/broker-extension-render.js +2 -4
  327. package/dist/core/runtime/broker-persona-guidance.js +3 -3
  328. package/dist/core/runtime/broker-protocol.d.ts +1 -1
  329. package/dist/core/runtime/broker.js +1 -1
  330. package/dist/core/runtime/close.d.ts +9 -4
  331. package/dist/core/runtime/close.js +1 -1
  332. package/dist/core/runtime/deliver-live.js +1 -1
  333. package/dist/core/runtime/kickoff.js +17 -19
  334. package/dist/core/runtime/launch-target.d.ts +7 -0
  335. package/dist/core/runtime/launch-target.js +1 -1
  336. package/dist/core/runtime/ledger.d.ts +10 -0
  337. package/dist/core/runtime/ledger.js +3 -0
  338. package/dist/core/runtime/lifecycle.js +2 -2
  339. package/dist/core/runtime/nodes.d.ts +10 -2
  340. package/dist/core/runtime/nodes.js +1 -1
  341. package/dist/core/runtime/outcome-document.d.ts +2 -2
  342. package/dist/core/runtime/outcome-document.js +1 -1
  343. package/dist/core/runtime/persona.js +2 -2
  344. package/dist/core/runtime/placement.js +1 -1
  345. package/dist/core/runtime/promote.d.ts +2 -2
  346. package/dist/core/runtime/promote.js +1 -1
  347. package/dist/core/runtime/prospective-inventory-cli.js +2 -2
  348. package/dist/core/runtime/recycle.js +1 -1
  349. package/dist/core/runtime/reopen.js +1 -1
  350. package/dist/core/runtime/revive.js +2 -2
  351. package/dist/core/runtime/roadmap.d.ts +20 -9
  352. package/dist/core/runtime/roadmap.js +10 -6
  353. package/dist/core/runtime/spawn-env.js +1 -1
  354. package/dist/core/runtime/spawn.d.ts +5 -3
  355. package/dist/core/runtime/spawn.js +2 -2
  356. package/dist/core/runtime/structured-output.d.ts +3 -1
  357. package/dist/core/runtime/structured-output.js +4 -4
  358. package/dist/core/scope.d.ts +1 -32
  359. package/dist/core/scope.js +1 -1
  360. package/dist/core/scoped-state/db.js +2 -1
  361. package/dist/core/scoped-state/migrate.js +2 -2
  362. package/dist/core/scoped-state/profiles.d.ts +11 -0
  363. package/dist/core/scoped-state/profiles.js +1 -1
  364. package/dist/core/scoped-state/schema.d.ts +1 -1
  365. package/dist/core/scoped-state/schema.js +7 -5
  366. package/dist/core/spaces/permissions.d.ts +0 -14
  367. package/dist/core/spaces/permissions.js +1 -1
  368. package/dist/core/spaces/stop.d.ts +13 -0
  369. package/dist/core/spaces/stop.js +2 -2
  370. package/dist/core/storage/tables.d.ts +1 -1
  371. package/dist/core/substrate/delivery/corpus.d.ts +21 -0
  372. package/dist/core/substrate/delivery/corpus.js +3 -0
  373. package/dist/core/substrate/delivery/deliver.d.ts +76 -0
  374. package/dist/core/substrate/delivery/deliver.js +6 -0
  375. package/dist/core/substrate/delivery/listings.d.ts +30 -0
  376. package/dist/core/substrate/delivery/listings.js +7 -0
  377. package/dist/core/substrate/delivery/match.d.ts +28 -0
  378. package/dist/core/substrate/delivery/match.js +1 -0
  379. package/dist/core/substrate/delivery/plan.d.ts +67 -0
  380. package/dist/core/substrate/delivery/plan.js +3 -0
  381. package/dist/core/substrate/delivery/render-boot.d.ts +20 -0
  382. package/dist/core/substrate/delivery/render-boot.js +54 -0
  383. package/dist/core/substrate/delivery/render-event.d.ts +54 -0
  384. package/dist/core/substrate/delivery/render-event.js +8 -0
  385. package/dist/core/substrate/delivery/sub-persona-menu.d.ts +2 -0
  386. package/dist/core/substrate/delivery/sub-persona-menu.js +6 -0
  387. package/dist/core/substrate/delivery/types.d.ts +30 -0
  388. package/dist/core/substrate/delivery/types.js +0 -0
  389. package/dist/core/substrate/gate-explain.d.ts +0 -13
  390. package/dist/core/substrate/gate-explain.js +1 -1
  391. package/dist/core/substrate/schema.d.ts +11 -139
  392. package/dist/core/substrate/schema.js +1 -1
  393. package/dist/core/substrate/subject-fields.d.ts +3 -0
  394. package/dist/core/substrate/subject.d.ts +2 -1
  395. package/dist/core/substrate/subject.js +1 -1
  396. package/dist/daemon/api/handlers/app-profiles.js +1 -1
  397. package/dist/daemon/api/handlers/bash-jobs.js +1 -2
  398. package/dist/daemon/api/handlers/broker-ops.js +1 -1
  399. package/dist/daemon/api/handlers/canvas.js +5 -5
  400. package/dist/daemon/api/handlers/daemon.js +1 -1
  401. package/dist/daemon/api/handlers/delivery.d.ts +2 -0
  402. package/dist/daemon/api/handlers/delivery.js +1 -0
  403. package/dist/daemon/api/handlers/{memory.d.ts → docs.d.ts} +1 -1
  404. package/dist/daemon/api/handlers/docs.js +1 -0
  405. package/dist/daemon/api/handlers/hook-exec.js +1 -1
  406. package/dist/daemon/api/handlers/messages.js +2 -2
  407. package/dist/daemon/api/handlers/node-records.js +2 -2
  408. package/dist/daemon/api/handlers/nodes.js +1 -1
  409. package/dist/daemon/api/handlers/objects.d.ts +2 -0
  410. package/dist/daemon/api/handlers/objects.js +5 -0
  411. package/dist/daemon/api/handlers/package-docs.d.ts +2 -0
  412. package/dist/daemon/api/handlers/package-docs.js +1 -0
  413. package/dist/daemon/api/handlers/profiles.js +1 -1
  414. package/dist/daemon/api/handlers/reports.d.ts +2 -2
  415. package/dist/daemon/api/handlers/reports.js +4 -4
  416. package/dist/daemon/api/handlers/reviews.d.ts +4 -1
  417. package/dist/daemon/api/handlers/reviews.js +1 -1
  418. package/dist/daemon/api/map.d.ts +2 -2
  419. package/dist/daemon/api/map.js +2 -2
  420. package/dist/daemon/api/operations.d.ts +1 -1
  421. package/dist/daemon/api/operations.js +1 -1
  422. package/dist/daemon/api/reader.d.ts +17 -0
  423. package/dist/daemon/api/reader.js +1 -0
  424. package/dist/daemon/api/server.js +1 -1
  425. package/dist/daemon/control.d.ts +2 -3
  426. package/dist/daemon/crtrd.js +8 -6
  427. package/dist/daemon/fleet.js +4 -4
  428. package/dist/daemon/reconcilers/bash-deadline.d.ts +11 -1
  429. package/dist/daemon/reconcilers/bash-deadline.js +2 -1
  430. package/dist/daemon/reconcilers/broker-supervision.js +4 -4
  431. package/dist/daemon/reconcilers/live-obligation.js +1 -1
  432. package/dist/daemon/reconcilers/node-deadline.js +1 -1
  433. package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
  434. package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -0
  435. package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
  436. package/dist/daemon/review/deliver.js +2 -2
  437. package/dist/daemon/review/finish.js +1 -1
  438. package/dist/hook-authoring.d.ts +0 -1
  439. package/dist/hook-authoring.js +3 -3
  440. package/dist/migrations/004-canvas-documents/apply.d.ts +10 -0
  441. package/dist/migrations/004-canvas-documents/apply.js +1 -0
  442. package/dist/migrations/004-canvas-documents/fields.d.ts +24 -0
  443. package/dist/migrations/004-canvas-documents/fields.js +2 -0
  444. package/dist/migrations/004-canvas-documents/index.d.ts +16 -0
  445. package/dist/migrations/004-canvas-documents/index.js +2 -0
  446. package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +16 -0
  447. package/dist/migrations/004-canvas-documents/legacy/discover.js +1 -0
  448. package/dist/migrations/004-canvas-documents/legacy/history.d.ts +5 -0
  449. package/dist/migrations/004-canvas-documents/legacy/history.js +2 -0
  450. package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +7 -0
  451. package/dist/migrations/004-canvas-documents/legacy/nested.js +1 -0
  452. package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +14 -0
  453. package/dist/migrations/004-canvas-documents/legacy/parse.js +1 -0
  454. package/dist/migrations/004-canvas-documents/legacy/types.d.ts +91 -0
  455. package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
  456. package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +6 -0
  457. package/dist/migrations/004-canvas-documents/legacy-edges.js +18 -0
  458. package/dist/migrations/004-canvas-documents/plan.d.ts +102 -0
  459. package/dist/migrations/004-canvas-documents/plan.js +3 -0
  460. package/dist/migrations/004-canvas-documents/pointers.d.ts +23 -0
  461. package/dist/migrations/004-canvas-documents/pointers.js +4 -0
  462. package/dist/migrations/activation.d.ts +9 -18
  463. package/dist/migrations/activation.js +2 -2
  464. package/dist/pi-extensions/broker-local.d.ts +2 -2
  465. package/dist/pi-extensions/broker-local.js +2 -2
  466. package/dist/pi-extensions/canvas-bash-valve.js +5 -4
  467. package/dist/pi-extensions/canvas-context-intro.js +2 -2
  468. package/dist/pi-extensions/canvas-doc-substrate.d.ts +0 -1
  469. package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
  470. package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
  471. package/dist/pi-extensions/canvas-passive-context.js +1 -1
  472. package/dist/pi-extensions/canvas-recap.js +2 -2
  473. package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
  474. package/dist/pi-extensions/canvas-stophook.js +1 -1
  475. package/dist/prompts/review.js +3 -3
  476. package/dist/shared/env.d.ts +5 -0
  477. package/dist/shared/env.js +1 -1
  478. package/dist/shared/generated-context.js +2 -10
  479. package/dist/shared/inbox-entry-body.d.ts +22 -0
  480. package/dist/shared/inbox-entry-body.js +10 -0
  481. package/dist/{core/memory → shared}/inline-ref-guidance.d.ts +2 -2
  482. package/dist/shared/inline-ref-guidance.js +2 -0
  483. package/dist/types.d.ts +3 -1
  484. package/docs/cli/memory-and-preferences.md +12 -14
  485. package/docs/concepts/README.md +1 -1
  486. package/docs/concepts/lifecycle-and-wakes.md +1 -1
  487. package/docs/concepts/memory.md +15 -15
  488. package/docs/concepts/nodes-and-the-canvas.md +1 -1
  489. package/docs/concepts/profiles-kinds-and-modes.md +5 -5
  490. package/docs/concepts/scopes-and-trust.md +1 -1
  491. package/docs/concepts/why-a-daemon.md +1 -1
  492. package/docs/sdk/README.md +5 -6
  493. package/docs/sdk/errors.md +0 -13
  494. package/docs/sdk/guides/README.md +0 -1
  495. package/docs/sdk/nodes.md +0 -2
  496. package/docs/sdk/resources.md +0 -1
  497. package/package.json +2 -2
  498. package/packages/crouter-identity/package.json +1 -1
  499. package/runtime.lock.json +11 -11
  500. package/scripts/lib/isolation-env.mjs +8 -2
  501. package/dist/api/dto/memory.d.ts +0 -171
  502. package/dist/api/dto/memory.js +0 -1
  503. package/dist/builtin-memory/crouter-sdk/guides/app-memory.md +0 -73
  504. package/dist/builtin-memory/crouter-sdk/memory.md +0 -87
  505. package/dist/commands/broker-permissions.d.ts +0 -2
  506. package/dist/commands/broker-permissions.js +0 -1
  507. package/dist/commands/memory/client.d.ts +0 -11
  508. package/dist/commands/memory/client.js +0 -1
  509. package/dist/commands/memory/delete.d.ts +0 -1
  510. package/dist/commands/memory/delete.js +0 -1
  511. package/dist/commands/memory/edit.d.ts +0 -1
  512. package/dist/commands/memory/edit.js +0 -21
  513. package/dist/commands/memory/find.d.ts +0 -1
  514. package/dist/commands/memory/find.js +0 -1
  515. package/dist/commands/memory/history.d.ts +0 -1
  516. package/dist/commands/memory/history.js +0 -5
  517. package/dist/commands/memory/lint.d.ts +0 -1
  518. package/dist/commands/memory/lint.js +0 -1
  519. package/dist/commands/memory/list.d.ts +0 -1
  520. package/dist/commands/memory/list.js +0 -1
  521. package/dist/commands/memory/move.d.ts +0 -1
  522. package/dist/commands/memory/move.js +0 -1
  523. package/dist/commands/memory/origin.d.ts +0 -1
  524. package/dist/commands/memory/origin.js +0 -1
  525. package/dist/commands/memory/read.d.ts +0 -1
  526. package/dist/commands/memory/read.js +0 -6
  527. package/dist/commands/memory/shared.d.ts +0 -22
  528. package/dist/commands/memory/shared.js +0 -1
  529. package/dist/commands/memory/write.d.ts +0 -1
  530. package/dist/commands/memory/write.js +0 -13
  531. package/dist/commands/memory.js +0 -1
  532. package/dist/commands/node-inspect-artifacts.d.ts +0 -1
  533. package/dist/commands/node-inspect-artifacts.js +0 -8
  534. package/dist/core/help/memory-extensions.d.ts +0 -3
  535. package/dist/core/help/memory-extensions.js +0 -2
  536. package/dist/core/memory/cli-selector.d.ts +0 -13
  537. package/dist/core/memory/cli-selector.js +0 -1
  538. package/dist/core/memory/doc-link-grammar.d.ts +0 -20
  539. package/dist/core/memory/doc-link-grammar.js +0 -2
  540. package/dist/core/memory/extensions.js +0 -1
  541. package/dist/core/memory/history.d.ts +0 -87
  542. package/dist/core/memory/history.js +0 -6
  543. package/dist/core/memory/identity.d.ts +0 -65
  544. package/dist/core/memory/identity.js +0 -1
  545. package/dist/core/memory/inline-ref-guidance.js +0 -2
  546. package/dist/core/memory/inline-ref-inventory.d.ts +0 -9
  547. package/dist/core/memory/inline-ref-inventory.js +0 -1
  548. package/dist/core/memory/lint.d.ts +0 -163
  549. package/dist/core/memory/lint.js +0 -2
  550. package/dist/core/memory/mutation-domain.d.ts +0 -113
  551. package/dist/core/memory/mutation-domain.js +0 -12
  552. package/dist/core/memory/mutations.d.ts +0 -74
  553. package/dist/core/memory/mutations.js +0 -1
  554. package/dist/core/memory/project-namespace.d.ts +0 -31
  555. package/dist/core/memory/project-namespace.js +0 -2
  556. package/dist/core/memory/repository-association.d.ts +0 -31
  557. package/dist/core/memory/repository-association.js +0 -1
  558. package/dist/core/memory/service.d.ts +0 -145
  559. package/dist/core/memory/service.js +0 -2
  560. package/dist/core/memory/tree.d.ts +0 -39
  561. package/dist/core/memory/tree.js +0 -1
  562. package/dist/core/memory-resolver.d.ts +0 -280
  563. package/dist/core/memory-resolver.js +0 -2
  564. package/dist/core/nested-stores.d.ts +0 -18
  565. package/dist/core/nested-stores.js +0 -1
  566. package/dist/core/runtime/memory.d.ts +0 -3
  567. package/dist/core/runtime/memory.js +0 -1
  568. package/dist/core/substrate/frontmatter-validation.d.ts +0 -11
  569. package/dist/core/substrate/frontmatter-validation.js +0 -1
  570. package/dist/core/substrate/gate.d.ts +0 -16
  571. package/dist/core/substrate/gate.js +0 -1
  572. package/dist/core/substrate/index.d.ts +0 -18
  573. package/dist/core/substrate/index.js +0 -1
  574. package/dist/core/substrate/injected-store.d.ts +0 -75
  575. package/dist/core/substrate/injected-store.js +0 -2
  576. package/dist/core/substrate/listings.d.ts +0 -28
  577. package/dist/core/substrate/listings.js +0 -1
  578. package/dist/core/substrate/memory-events.d.ts +0 -6
  579. package/dist/core/substrate/memory-events.js +0 -1
  580. package/dist/core/substrate/on-read-node.d.ts +0 -6
  581. package/dist/core/substrate/on-read-node.js +0 -1
  582. package/dist/core/substrate/on-read.d.ts +0 -101
  583. package/dist/core/substrate/on-read.js +0 -9
  584. package/dist/core/substrate/plan.d.ts +0 -94
  585. package/dist/core/substrate/plan.js +0 -1
  586. package/dist/core/substrate/render-node.d.ts +0 -12
  587. package/dist/core/substrate/render-node.js +0 -1
  588. package/dist/core/substrate/render.d.ts +0 -41
  589. package/dist/core/substrate/render.js +0 -65
  590. package/dist/core/substrate/session-cache.d.ts +0 -27
  591. package/dist/core/substrate/session-cache.js +0 -1
  592. package/dist/core/substrate/surface-match.d.ts +0 -73
  593. package/dist/core/substrate/surface-match.js +0 -1
  594. package/dist/daemon/api/handlers/memory.js +0 -5
  595. package/dist/migrations/001-surfaces-frontmatter.d.ts +0 -2
  596. package/dist/migrations/001-surfaces-frontmatter.js +0 -1
  597. package/dist/migrations/002-profile-project-memory.d.ts +0 -2
  598. package/dist/migrations/002-profile-project-memory.js +0 -1
  599. package/dist/migrations/003-repository-root-memory-identity/front-door.d.ts +0 -26
  600. package/dist/migrations/003-repository-root-memory-identity/front-door.js +0 -11
  601. package/dist/migrations/003-repository-root-memory-identity/index.d.ts +0 -2
  602. package/dist/migrations/003-repository-root-memory-identity/index.js +0 -5
  603. package/dist/migrations/003-repository-root-memory-identity/references.d.ts +0 -95
  604. package/dist/migrations/003-repository-root-memory-identity/references.js +0 -5
  605. package/dist/migrations/003-repository-root-memory-identity/repository-facts.d.ts +0 -39
  606. package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +0 -3
  607. package/dist/migrations/convergent.d.ts +0 -43
  608. package/dist/migrations/convergent.js +0 -2
  609. package/dist/migrations/corpus.d.ts +0 -75
  610. package/dist/migrations/corpus.js +0 -3
  611. package/dist/migrations/frontmatter-splice.d.ts +0 -15
  612. package/dist/migrations/frontmatter-splice.js +0 -8
  613. package/dist/migrations/profile-manifests.d.ts +0 -30
  614. package/dist/migrations/profile-manifests.js +0 -2
  615. package/dist/migrations/registry.d.ts +0 -7
  616. package/dist/migrations/registry.js +0 -1
  617. package/dist/migrations/runner.d.ts +0 -43
  618. package/dist/migrations/runner.js +0 -1
  619. package/dist/migrations/types.d.ts +0 -211
  620. package/dist/shared/birth-announcement.d.ts +0 -12
  621. package/dist/shared/birth-announcement.js +0 -1
  622. package/docs/sdk/guides/app-memory.md +0 -22
  623. package/docs/sdk/memory.md +0 -85
  624. /package/dist/{migrations/types.js → api/dto/delivery.js} +0 -0
  625. /package/dist/{core/memory → shared}/inline-ref-grammar.d.ts +0 -0
  626. /package/dist/{core/memory → shared}/inline-ref-grammar.js +0 -0
@@ -1,65 +0,0 @@
1
- /** The filename (and path segment) whose document fronts its directory. */
2
- export declare const INDEX_SEGMENT = "INDEX";
3
- /** Strip an optional `NN-` ordering prefix from ONE segment. */
4
- export declare function normalizeNameSegment(segment: string): string;
5
- /** Slugify one authored or filesystem label into a canonical segment. */
6
- export declare function slugCanonicalSegment(raw: string): string;
7
- /** Slugify a derived label into canonical path segments. Empty segments are
8
- * intentionally dropped; owner paths use slugCanonicalSegment directly. */
9
- export declare function slugCanonicalPath(raw: string): string;
10
- /** Strip the ordering prefix from EVERY segment of a slash-separated name:
11
- * `01-spine/00-has-manager` -> `spine/has-manager`. */
12
- export declare function normalizeDocName(name: string): string;
13
- /** Split a name into segments, dropping empties from `//`, a leading `/`, or an
14
- * empty name. */
15
- export declare function canonicalSegments(name: string): string[];
16
- /** The canonical directory containing `name`, or `''` at the top. */
17
- export declare function canonicalParent(name: string): string;
18
- /** Remove EXACTLY ONE trailing `INDEX` segment. `a/INDEX` -> `a`; `INDEX` ->
19
- * `''` (a store root); `a/INDEX/INDEX` -> `a/INDEX` (the inner segment is an
20
- * ordinary directory name). */
21
- export declare function collapseTrailingIndex(name: string): string;
22
- export type DocRepresentation = 'leaf-file' | 'directory-index';
23
- /** Which form a store-relative markdown path takes. */
24
- export declare function representationForPath(physicalRelativePath: string): DocRepresentation;
25
- /** Store-local name derived from a store-relative markdown path: ordering
26
- * prefixes stripped from every segment and one trailing `INDEX` collapsed.
27
- * Empty only for a store root `INDEX.md`. */
28
- export declare function localNameFromPath(physicalRelativePath: string): string;
29
- /** The store-relative markdown path a local name occupies in a given form.
30
- * Both forms are checked before any create or move, so occupancy never depends
31
- * on which one a store happens to use. */
32
- export declare function physicalRelativePathFor(localName: string, representation: DocRepresentation): string;
33
- /** A document's explicit frontmatter `name` as a local name — normalized with
34
- * one trailing `INDEX` collapsed — or `null` when it carries none. */
35
- export declare function explicitLocalName(fm: Record<string, unknown> | null | undefined): string | null;
36
- /** A document's store-local name: its explicit frontmatter `name` when present,
37
- * else the path-derived local name. Explicit names are local to their store —
38
- * they never carry the store's namespace. */
39
- export declare function resolveLocalName(fm: Record<string, unknown> | null | undefined, pathDerivedLocalName: string): string;
40
- /** namespace ⊕ local — the only address. Composition is unconditional: a local
41
- * name that already looks namespace-prefixed is composed anyway, so identity
42
- * never depends on string coincidence. An empty result means a namespace-less
43
- * store root, which has no valid canonical identity. */
44
- export declare function composeCanonicalName(namespace: string, localName: string): string;
45
- /** The canonical directory a document's `./` memory-read entries match against:
46
- * a directory document anchors at its own name, an ordinary leaf at its
47
- * canonical parent. */
48
- export declare function routingAnchorFor(canonicalName: string, representation: DocRepresentation): string;
49
- /** The local name a canonical name has inside `namespace`, or `null` when it
50
- * falls outside it. Exact on segment boundaries: `a/bc` is not inside `a/b`.
51
- * The namespace itself yields `''` — the store root document. */
52
- export declare function stripNamespace(canonicalName: string, namespace: string): string | null;
53
- export type IdentityValidation = {
54
- ok: true;
55
- } | {
56
- ok: false;
57
- reason: string;
58
- };
59
- /** A project store's declared namespace, or an installed plugin's mount prefix:
60
- * one or more normalized segments, never ending in `INDEX`. */
61
- export declare function validateNamespace(namespace: string): IdentityValidation;
62
- /** An explicit non-root `name:`: a non-empty local name, never ending in
63
- * `INDEX` (its directory name is the identity) and never carrying its own
64
- * store's namespace. */
65
- export declare function validateExplicitLocalName(localName: string, namespace?: string): IdentityValidation;
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var t=(e,n)=>m(e,"name",{value:n,configurable:!0});const c=/^\d{2}-/,g=/^[A-Za-z0-9._-]+$/,s="INDEX";function u(e){return e.replace(c,"")}t(u,"normalizeNameSegment");function d(e){return u(e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""))}t(d,"slugCanonicalSegment");function k(e){return e.replace(/\\/g,"/").replace(/\.md$/i,"").split("/").map(d).filter(Boolean).join("/")}t(k,"slugCanonicalPath");function x(e){return e.split("/").map(u).join("/")}t(x,"normalizeDocName");function o(e){return e.split("/").filter(n=>n!=="")}t(o,"canonicalSegments");function h(e){return o(e).slice(0,-1).join("/")}t(h,"canonicalParent");function l(e){const n=o(e);return n[n.length-1]===s&&n.pop(),n.join("/")}t(l,"collapseTrailingIndex");function f(e){return o(e.replace(/\\/g,"/").replace(/\.md$/i,"")).map(u)}t(f,"pathIdentitySegments");function j(e){const n=f(e);return n[n.length-1]===s?"directory-index":"leaf-file"}t(j,"representationForPath");function N(e){return l(f(e).join("/"))}t(N,"localNameFromPath");function S(e,n){const r=o(e).join("/");if(r===""){if(n==="leaf-file")throw new Error("a store root document has no leaf-file representation");return`${s}.md`}return n==="directory-index"?`${r}/${s}.md`:`${r}.md`}t(S,"physicalRelativePathFor");function $(e){const n=e?.name;return typeof n!="string"||n.trim()===""?null:l(x(n.trim()))}t($,"explicitLocalName");function w(e,n){return $(e)??n}t(w,"resolveLocalName");function _(e,n){const r=o(e).join("/"),i=o(n).join("/");return r===""?i:i===""?r:`${r}/${i}`}t(_,"composeCanonicalName");function v(e,n){return n==="directory-index"?o(e).join("/"):h(e)}t(v,"routingAnchorFor");function y(e,n){const r=o(e),i=o(n);for(let a=0;a<i.length;a++)if(r[a]!==i[a])return null;return r.slice(i.length).join("/")}t(y,"stripNamespace");function p(e){for(const n of e.split("/")){if(n==="")return`empty segment in \`${e}\``;if(n==="."||n==="..")return`relative segment \`${n}\` in \`${e}\``;if(!g.test(n))return`segment \`${n}\` is not [A-Za-z0-9._-]`;if(c.test(n))return`segment \`${n}\` carries an \`NN-\` ordering prefix, which is physical-path-only \u2014 use \`${u(n)}\``}return null}t(p,"invalidSegmentReason");function I(e){if(e.trim()!==e)return{ok:!1,reason:"namespace has surrounding whitespace"};if(e==="")return{ok:!1,reason:"namespace is empty"};const n=p(e);return n!==null?{ok:!1,reason:n}:o(e).pop()===s?{ok:!1,reason:`namespace ends in \`${s}\``}:{ok:!0}}t(I,"validateNamespace");function P(e,n=""){if(e.trim()!==e)return{ok:!1,reason:"name has surrounding whitespace"};if(e==="")return{ok:!1,reason:"name is empty"};const r=p(e);if(r!==null)return{ok:!1,reason:r};if(o(e).pop()===s){const i=l(e);return{ok:!1,reason:`name ends in \`${s}\` \u2014 a directory document answers at its directory name${i===""?"":`, so use \`${i}\``}`}}return n!==""&&y(e,n)!==null?{ok:!1,reason:`name repeats its store's namespace \`${n}\` \u2014 explicit names are store-local`}:{ok:!0}}t(P,"validateExplicitLocalName");export{s as INDEX_SEGMENT,h as canonicalParent,o as canonicalSegments,l as collapseTrailingIndex,_ as composeCanonicalName,$ as explicitLocalName,N as localNameFromPath,x as normalizeDocName,u as normalizeNameSegment,S as physicalRelativePathFor,j as representationForPath,w as resolveLocalName,v as routingAnchorFor,k as slugCanonicalPath,d as slugCanonicalSegment,y as stripNamespace,P as validateExplicitLocalName,I as validateNamespace};
@@ -1,2 +0,0 @@
1
- var a=Object.defineProperty;var c=(n,t)=>a(n,"name",{value:t,configurable:!0});import{findRefTokens as r}from"./inline-ref-grammar.js";const s="The user explicitly called out specific memories. Read the relevant mentioned memory files:";function u(n,t){const o=new Set,i=[];for(const e of r(n))o.has(e.candidate)||t.has(e.candidate)&&(o.add(e.candidate),i.push(e.candidate));if(i.length===0)return null;const d=i.map(e=>`- crtr memory read ${e}`);return[s,...d].join(`
2
- `)}c(u,"buildGuidance");export{u as buildGuidance};
@@ -1,9 +0,0 @@
1
- import { type MemoryTarget } from '../memory-resolver.js';
2
- import type { RefMeta } from '../runtime/broker-protocol.js';
3
- /** Build the inline inventory from exact target-view winners. `refs` carries
4
- * metadata rows; `names` adds only canonical directory nodes with members for
5
- * browse links. Gates, rungs, and `slash` do not affect referenceability. */
6
- export declare function buildRefInventory(target?: MemoryTarget): {
7
- refs: RefMeta[];
8
- names: Set<string>;
9
- };
@@ -1 +0,0 @@
1
- var d=Object.defineProperty;var c=(n,i)=>d(n,"name",{value:i,configurable:!0});import{ambientMemoryTarget as u,loadMemoryTargetView as h}from"../memory-resolver.js";import{buildMemoryTree as y}from"./tree.js";import{memoryExtensionEffectiveCatalog as D,projectEffectiveMemoryExtensions as b}from"./extensions.js";import{parseSubstrateDoc as g}from"../substrate/schema.js";const f={node:0,project:1,profile:2,user:3,builtin:4};function x(n=u()){const i=h(n,{quiet:!0}),s=new Map;for(const e of i.candidateSets()){const o=e.winner,t=g(o);t!==null&&s.set(e.name,{doc:t,memoryDoc:o})}const r=[];for(const[e,{doc:o,memoryDoc:t}]of s){const p=o.scope!=="builtin"&&b(t.frontmatter?.extensions,D(t)).northlight?.visibility!==!1;r.push({name:e,kind:o.kind,scope:o.scope,shortForm:o.shortForm,gatewayVisible:p})}r.sort((e,o)=>{const t=f[e.scope]-f[o.scope];return t!==0?t:e.name.localeCompare(o.name)});const m=new Set(r.map(e=>e.name)),l=y([...s.values()].map(({memoryDoc:e})=>e)),a=c(e=>{e.name!==""&&(e.childDirectories.length>0||e.childDocuments.length>0)&&m.add(e.name);for(const o of e.childDirectories)a(o)},"addDirectoryNames");return a(l.root),{refs:r,names:m}}c(x,"buildRefInventory");export{x as buildRefInventory};
@@ -1,163 +0,0 @@
1
- import { type MemoryDoc, type MemoryScope, type MemoryStoreDescriptor, type MemoryTarget } from '../memory-resolver.js';
2
- export type MemoryLintSeverity = 'error' | 'warning' | 'notice';
3
- export type MemoryLintRule =
4
- /** Frontmatter does not parse as YAML. */
5
- 'yaml'
6
- /** Substrate frontmatter contract violation. */
7
- | 'schema'
8
- /** A plugin-declared `extensions` value is invalid. */
9
- | 'extension'
10
- /** Body longer than its delivery entries earn. */
11
- | 'length'
12
- /** A body short enough to inline still pays a routing line. */
13
- | 'short-preview'
14
- /** A `memory-read` glob that fires on every memory read. */
15
- | 'broad-memory-read'
16
- /** A project store the runtime refuses to mount: no/invalid repository-root `namespace:`. */
17
- | 'store-namespace'
18
- /** `namespace:` declared anywhere but the repository-root store's root INDEX.md. */
19
- | 'namespace-placement'
20
- /** Two owner directories in one repository normalize to one effective prefix. */
21
- | 'owner-path-collision'
22
- /** `name:` on a store's root INDEX.md, whose identity is the namespace. */
23
- | 'root-name'
24
- /** A root INDEX.md in a store that declares no namespace — no address. */
25
- | 'root-index-unaddressable'
26
- /** An explicit non-root `name:` that is not a valid store-local name. */
27
- | 'local-name'
28
- /** Two files in ONE store owning the same canonical identity. */
29
- | 'canonical-collision'
30
- /** One canonical identity held by several stores (inspection data). */
31
- | 'cross-store-candidates'
32
- /** A `[[link]]` that resolves to no document or directory. */
33
- | 'dangling-link'
34
- /** A `memory-read` route that matches no canonical name. */
35
- | 'memory-read-route'
36
- /** A document no reachability path routes an agent to — no surface delivers
37
- * it, no reached document links it, and no reached directory lists it. */
38
- | 'orphan'
39
- /** A project store's workspace front door is missing or not its root doc. */
40
- | 'front-door'
41
- /** Boot entries in a nested store, which never rides the boot catalog. */
42
- | 'nested-store-boot'
43
- /** Reference checks skipped because the store's identities are undetermined. */
44
- | 'reference-check-deferred';
45
- /** The rules that decide whether a corpus is COMPATIBLE with exact canonical
46
- * identity — what a plugin candidate gate, the builtin build gate, and
47
- * migration verification refuse a corpus on, independent of authoring-quality
48
- * rules such as length or routing lines. */
49
- export declare const MEMORY_LINT_IDENTITY_RULES: ReadonlySet<MemoryLintRule>;
50
- export interface MemoryLintFinding {
51
- severity: MemoryLintSeverity;
52
- rule: MemoryLintRule;
53
- /** The markdown file, store root, or project directory at fault. */
54
- path: string;
55
- message: string;
56
- scope?: MemoryScope;
57
- storeRoot?: string;
58
- /** The canonical identity the finding is about, when it has one. */
59
- name?: string;
60
- /** Every physical path sharing a collided identity, read winner first. */
61
- paths?: readonly string[];
62
- }
63
- export interface MemoryLintResult {
64
- /** No `error` findings. */
65
- ok: boolean;
66
- /** Markdown files examined, including non-document files (`SKILL.md`,
67
- * `MEMORY.md`) that are YAML-checked but never loaded as documents. */
68
- checked: number;
69
- /** Of `checked`, the files the substrate actually loads as memory
70
- * documents — `checked` minus `SKILL.md`/`MEMORY.md`. */
71
- documents: number;
72
- storesLinted: number;
73
- /** Every finding, in emission order. */
74
- findings: readonly MemoryLintFinding[];
75
- errors: readonly MemoryLintFinding[];
76
- warnings: readonly MemoryLintFinding[];
77
- notices: readonly MemoryLintFinding[];
78
- }
79
- export interface MemoryLintTargetResult extends MemoryLintResult {
80
- /** Every store the target saw, mounted or not, in precedence order. */
81
- stores: readonly MemoryStoreDescriptor[];
82
- /** Projects the selected profile manages that were checked for a workspace
83
- * front door — zero under a scope filter that excludes project stores. */
84
- profileProjects: number;
85
- }
86
- /** The length rule. Caps come from the parsed entries — an invalid entry already
87
- * fails the schema check, so it simply matches no cap here. `docName` is the
88
- * doc's canonical identity; persona layers under `kinds/` are never capped. */
89
- export declare function lintBodyLength(fm: Record<string, unknown>, body: string, docName: string): string | null;
90
- /** Warn when a body short enough to inline still pays a routing line. */
91
- export declare function lintShortPreviewBody(fm: Record<string, unknown>, body: string): string | null;
92
- /** Every canonical name a reference may target in a corpus: each document's
93
- * exact identity plus every canonical directory, because reading a directory
94
- * answers with its own document and its listing. Derived from the canonical
95
- * tree, never from string prefixes of a name. */
96
- export declare function resolvableCanonicalNames(docs: readonly MemoryDoc[]): Set<string>;
97
- /** The orphan rule. A document is reachable when an agent is routed to it
98
- * without knowing its name: a surface delivers it (a `memory-read` surface is
99
- * deliberate companion wiring and counts), it is invocable as a slash command,
100
- * a reached document's real `[[link]]` names it, or a reached CURATED INDEX
101
- * document's listing includes it. The listing edge routes only through a
102
- * directory that carries its own non-root index document — a bare directory
103
- * has no curator, and a store's root front door is delivered with the whole
104
- * boot tree, so treating either listing as a route would reach every doc and
105
- * defeat the rule (the same reason the corpus root is never seeded). Curated
106
- * BODY LINKS on those docs still route. Reachability is computed over the
107
- * WHOLE target view — a doc linked only from another store is still reachable.
108
- * `flagStoreRoot` restricts which store's unreachable docs are flagged while
109
- * every store still participates in the graph as a potential linker. */
110
- export declare function lintOrphans(viewDocs: readonly MemoryDoc[], options?: {
111
- flagStoreRoot?: string;
112
- }): MemoryLintFinding[];
113
- export interface MemoryLintStoreOptions {
114
- /** Canonical names a `[[link]]` or route may target — the target view the
115
- * store's documents are read in. Omit to skip reference checks entirely
116
- * (a store linted in isolation, such as the builtin corpus at build time,
117
- * passes only its own names). */
118
- resolvable?: ReadonlySet<string>;
119
- /** Whether a project store must carry a workspace front door: `required` for
120
- * a profile-managed project, `advisory` (warning) for an unmanaged one that
121
- * was asked about directly, `ignore` otherwise. A front door on any doc but
122
- * the store root is an error under every mode. */
123
- frontDoor?: 'required' | 'advisory' | 'ignore';
124
- /** A store discovered BELOW the mounted project roots: the boot catalog never
125
- * includes one, so its boot entries are inert. */
126
- nestedStore?: boolean;
127
- }
128
- /** Lint ONE physical store, whether or not the runtime mounts it. An undeclared
129
- * or invalid project store still has its files checked — every store-local rule
130
- * holds before a namespace exists — but its references are deferred, because
131
- * the identities its links resolve against are undetermined until migration
132
- * declares the namespace. */
133
- export declare function lintMemoryStore(store: MemoryStoreDescriptor, options?: MemoryLintStoreOptions): MemoryLintResult;
134
- export interface MemoryLintDocumentOptions {
135
- /** Canonical names a `[[link]]` or route may target. Omit to skip reference
136
- * checks — the caller pays for the corpus index only when the document
137
- * actually carries a reference to resolve. */
138
- resolvable?: ReadonlySet<string>;
139
- /** The store sits below the mounted project roots, so its boot entries are
140
- * inert. Omit when the document carries no boot entry: the rule cannot fire. */
141
- nestedStore?: boolean;
142
- }
143
- /** Lint ONE document, by absolute path, in the store that holds it. Runs every
144
- * file-level rule the store sweep runs, and the store-level front-door rule
145
- * this one file can violate on its own. It does NOT run the rules that need
146
- * the whole store (canonical collisions, missing front-door coverage), so it
147
- * never replaces `crtr memory lint` — it catches what an author just typed. */
148
- export declare function lintMemoryDocument(store: MemoryStoreDescriptor, filePath: string, options?: MemoryLintDocumentOptions): MemoryLintResult;
149
- export interface MemoryLintTargetOptions {
150
- /** Whose view to lint. Default: the ambient process (cwd + CRTR_PROFILE_ID +
151
- * CRTR_NODE_ID). */
152
- target?: MemoryTarget;
153
- /** Restrict to one source class. Front-door coverage applies only to an
154
- * unfiltered or project-scoped view. */
155
- scope?: MemoryScope;
156
- /** Also lint `.crouter/memory` stores discovered below the mounted project
157
- * roots. Default true: they are addressable, so they are lintable. */
158
- includeDescendants?: boolean;
159
- }
160
- /** Lint every store a target sees, then the diagnostics only the merged view
161
- * produces: references resolved against the view's canonical names, and equal
162
- * canonical identities held by several stores. */
163
- export declare function lintMemoryTarget(options?: MemoryLintTargetOptions): MemoryLintTargetResult;
@@ -1,2 +0,0 @@
1
- var J=Object.defineProperty;var w=(e,t)=>J(e,"name",{value:t,configurable:!0});import{envNodeId as Q,envProfileId as Z}from"../../shared/env.js";import{basename as ee,join as L,matchesGlob as te,relative as W,sep as A}from"node:path";import{pathExists as oe,realpathOrSelf as D}from"../fs-utils.js";import{readFileBeneath as ne,walkFilesBeneath as re}from"../spaces/open-beneath.js";import{parseFrontmatterGeneric as se}from"../frontmatter.js";import{descendantStoreRoots as ie}from"../nested-stores.js";import{projectScopeRoots as ae}from"../scope.js";import{associateRepository as x}from"./repository-association.js";import{loadProfileManifest as ce}from"../profiles/manifest.js";import{loadMemoryTargetView as de,loadStoreMemoryDocs as F,openProjectMemoryStore as B}from"../memory-resolver.js";import{buildMemoryTree as N}from"./tree.js";import{canonicalSegments as E,collapseTrailingIndex as q,INDEX_SEGMENT as $,localNameFromPath as C,normalizeDocName as G,validateExplicitLocalName as le}from"./identity.js";import{lintSubstrateFrontmatter as me,parsedSubstrateSurfaces as j}from"../substrate/frontmatter-validation.js";import{memoryExtensionValidationCatalog as fe,validateMemoryExtensionValues as ue}from"./extensions.js";import{docLinkNames as z}from"./doc-link-grammar.js";const Ce=new Set(["store-namespace","namespace-placement","owner-path-collision","root-name","root-index-unaddressable","local-name","canonical-collision","dangling-link","memory-read-route"]);function M(e,t,r,s){const i=e.filter(a=>a.severity==="error");return{ok:i.length===0,checked:t,documents:r,storesLinted:s,findings:e,errors:i,warnings:e.filter(a=>a.severity==="warning"),notices:e.filter(a=>a.severity==="notice")}}w(M,"makeResult");const P=1e3,V=1e3,O=3e3,he=30,T="Keep the load-bearing core here and split the depth into [[linked]] reference docs carrying no surfaces at all (the listing and the link are how they are found, so they cost nothing until followed). Split by subject: each leaf covers a different subject a task might need on its own; never split off \u201Cfurther evidence\u201D, examples, or references \u2014 a references leaf is never followed, so supporting material stays next to the point it supports or gets cut. Keep it whole \u2014 `lint-ignore: length` in the frontmatter \u2014 only when every reader who surfaces this doc genuinely benefits from reading 100% of it, or it is one indivisible body of knowledge; then splitting just adds hops.";function _(e,t){const r=e["lint-ignore"];return r===t||Array.isArray(r)&&r.includes(t)}w(_,"ignoresRule");function X(e){const t=e.trim();return t===""?0:t.split(/\s+/).length}w(X,"countBodyWords");function pe(e,t,r){if(_(e,"length")||r==="kinds"||r.startsWith("kinds/"))return null;const s=j(e),i=X(t);if(s.some(c=>c.on==="boot"&&c.at==="content")&&i>P)return`body is ${i} words but a boot entry at \`content\` inlines every word into every agent's system prompt \u2014 capped at ${P} words (boot preview gets ${O}; name entries are never capped). ${T}`;const a=[...new Set(s.filter(c=>c.on!=="boot"&&c.at==="content").map(c=>c.on))];return a.length>0&&i>V?`body is ${i} words, over the ${V}-word cap for a \`content\` entry on ${a.join("/")} (the whole body delivers every time the entry fires; name entries are never capped). ${T}`:s.some(c=>c.on==="boot"&&c.at==="preview")&&i>O?`body is ${i} words, over the ${O}-word cap for boot preview (the routing line invites every reader into the whole body, so the cap is the longest doc worth reading end-to-end; boot content is capped at ${P} words; name entries are never capped). ${T}`:null}w(pe,"lintBodyLength");function ye(e,t){const r=X(t);if(r>=he)return null;const s=[...new Set(j(e).filter(a=>a.at==="preview").map(a=>a.on))];if(s.length===0)return null;const i=s.length===1?"entry delivers":"entries deliver";return`body is ${r} words but the ${s.join("/")} ${i} \`preview\`; use \`at: content\` so agents receive the whole rule without a separate memory read`}w(ye,"lintShortPreviewBody");function we(e){const t=new Set,r=w(s=>{s.name!==""&&t.add(s.name);for(const i of s.childDirectories)r(i);for(const i of s.childDocuments)t.add(i.name)},"walk");return r(N(e).root),t}w(we,"resolvableCanonicalNames");function ge(e,t={}){const r=N(e),s=new Map,i=w(o=>{o.name!==""&&s.set(o.name,o);for(const d of o.childDirectories)i(d);for(const d of o.childDocuments)s.set(d.name,d)},"indexWalk");i(r.root);const a=new Set,c=[],u=w(o=>{o===""||a.has(o)||!s.has(o)||(a.add(o),c.push(o))},"enqueue");for(const o of e){const d=o.frontmatter??{};(j(d).length>0||d.slash===!0)&&u(o.name)}for(;c.length>0;){const o=s.get(c.shift()),d=o.document;if(d!==null)for(const p of z(d.body))s.has(p)&&u(p);if(!(d===null||d.localName==="")){for(const p of o.childDirectories)p.document?.frontmatter?.unlisted!==!0&&u(p.name);for(const p of o.childDocuments)p.document.frontmatter?.unlisted!==!0&&u(p.name)}}const h=[];for(const o of e)t.flagStoreRoot!==void 0&&o.store.storeRoot!==t.flagStoreRoot||a.has(o.name)||o.scope==="builtin"||o.plugin!==void 0||o.localName!==""&&(o.name==="kinds"||o.name.startsWith("kinds/")||_(o.frontmatter??{},"orphan")||h.push({severity:"warning",rule:"orphan",path:o.path,name:o.name,scope:o.scope,...o.store.storeRoot===""?{}:{storeRoot:o.store.storeRoot},message:`\`${o.name}\` is unreachable: no surface delivers it, no reached document links it, and no reached directory lists it \u2014 it is findable only by deliberate search. Give it a surface, link it from a reached doc (a cluster index, or its directory's own ${$}.md), or accept it with \`lint-ignore: orphan\`.`}));return h}w(ge,"lintOrphans");const Y='the store\'s root INDEX.md is the workspace front door: give it `surfaces: [{on: workspace-open, at: content}, {on: read, match: "./**", at: content}]` (run `crtr memory write -h` first)',ve=/[*?[\]{}]/;function K(e,t){try{return te(e,t)}catch{return!1}}w(K,"safeGlob");function Re(e,t){const r=e.startsWith("./")?e.slice(2):e,s=e.startsWith("./")?`${t}/${r}`:r;return E(G(s)).join("/")}w(Re,"literalRouteTarget");function be(e,t,r){if(!e.startsWith("./")){for(const a of r)if(K(a,e))return!0;return!1}const s=e.slice(2),i=t===""?"":`${t}/`;for(const a of r)if(a.startsWith(i)&&K(a.slice(i.length),s))return!0;return!1}w(be,"routeMatchesAny");function U(e){const t=E(e),r=t[t.length-1]===$,s=q(e),i=E(s).pop()??e;return`${r?` A directory's own document answers at the directory name, so name \`${s}\` instead.`:""} Run \`crtr memory find ${i}\` for the canonical name, or drop the reference.`}w(U,"missingNameDiagnostic");const $e=new Set(["SKILL.md","MEMORY.md"]);function I(e,t={}){const r=[],s={scope:e.scope,...e.storeRoot===""?{}:{storeRoot:e.storeRoot}},i=w((l,y,n,m,f={})=>{r.push({severity:l,rule:y,path:n,message:m,...s,...f})},"add"),a=e.mountStatus==="ready";e.mountFailure==="collision"?i("error","owner-path-collision",e.namespacePath??e.storeRoot,e.diagnostic??`project memory stores have owner directories that normalize to the same effective prefix \`${e.namespace}\` \u2014 rename one owner directory`):(e.mountStatus==="undeclared"||e.mountStatus==="invalid")&&i("error","store-namespace",e.namespacePath??e.storeRoot,e.diagnostic??"project memory store does not mount"),(e.mountStatus==="undeclared"||e.mountStatus==="invalid")&&t.resolvable!==void 0&&i("notice","reference-check-deferred",e.storeRoot,"links and `memory-read` routes are not checked here: the canonical identities they resolve against are undetermined until this store declares its namespace");const c=e.scope==="project"&&e.plugin===void 0,u=t.frontDoor??"ignore",h=[],o=F(e,!0).filter(l=>!l.physicalRelativePath.split("/").some(y=>y.startsWith("."))),d=new Map(o.map(l=>[l.path,l]));let p=0,v=0;const R=e.mountFailure==="symlink"?[]:re(e.storeRoot,e.storeRoot,l=>l.endsWith(".md"),l=>l.startsWith("."));for(const l of R){const y=W(e.storeRoot,l).split(A).join("/");y!==""&&(p+=1,H({store:e,file:l,relPath:y,doc:d.get(l),isProjectStore:c,mounted:a,...t.resolvable===void 0?{}:{resolvable:t.resolvable},nestedStore:t.nestedStore===!0,add:i,frontDoors:h})==="document"&&(v+=1))}const g=new Map;for(const l of o){const y=g.get(l.name);y?y.push(l):g.set(l.name,[l])}for(const[l,y]of g){if(y.length<2)continue;const n=y.map(m=>m.path);i("error","canonical-collision",n[0],`${y.length} files in this store own canonical name \`${l}\` (${n.join(", ")}); \`${y[0].physicalRelativePath}\` is the deterministic read winner. Recover the collision with \`crtr memory move ${l} --to <new-free-name>\`; move selects the first physical path in stable lexical order, and no filesystem surgery is needed.`,{name:l,paths:n})}if(c){for(const n of h)n.root||i("error","front-door",n.path,`a project store's workspace front door is its root ${$}.md, not this doc \u2014 a {on: workspace-open, at: content} entry here delivers a second whole document at every workspace open; fold it into the root document or lower this entry`);const l=(e.ownerRelativePath??"")==="",y=h.some(n=>n.root&&n.complete);if(l&&!y&&u!=="ignore"){const n=e.ownerDir??e.storeRoot,m=u==="required"?`the selected profile manages this project but its store has no workspace front door \u2014 ${Y}`:`this project store has no workspace front door, so agents open the workspace blind \u2014 ${Y}`;i(u==="required"?"error":"warning","front-door",n,m)}}return M(r,p,v,1)}w(I,"lintMemoryStore");function H(e){const{store:t,file:r,relPath:s,doc:i,isProjectStore:a,mounted:c,resolvable:u,add:h}=e;let o,d;try{({data:o,body:d}=se(ne(t.storeRoot,r).toString("utf8")))}catch(g){return h("error","yaml",r,`invalid YAML frontmatter: ${(g instanceof Error?g.message:String(g)).split(`
2
- `)[0]}`),"yaml-error"}if($e.has(ee(r)))return"non-document";const p=C(s)==="",v=i===void 0?{}:{name:i.name},R=me(o);if(R!==null&&h("error","schema",r,R,v),o!==null){const g=a&&t.ownerRelativePath==="";if(o.namespace!==void 0&&!(p&&g)){const l=p&&a&&t.ownerRelativePath!==void 0&&t.ownerRelativePath!==""?`\`namespace:\` belongs only on the repository-root store's ${$}.md (${t.namespacePath??t.storeRoot}) \u2014 a nested store's prefix is derived from its path under ${t.repositoryRoot??t.ownerDir??t.storeRoot}`:`\`namespace:\` belongs only on a project store's root ${$}.md, where it declares the whole store's prefix \u2014 drop it here (an explicit \`name:\` is store-LOCAL and never carries a namespace)`;h("error","namespace-placement",r,l,v)}p&&o.name!==void 0&&h("error","root-name",r,`a store's root ${$}.md carries no \`name:\` \u2014 its identity answers at \`${t.namespace}\`; drop the field`,v)}if(i===void 0)return p&&!a&&h("error","root-index-unaddressable",r,`a root ${$}.md has no canonical name in a ${t.scope} store, which declares no namespace \u2014 only a project store's root document answers at its namespace, so rename this file to a named document (\`<topic>.md\`) or fold its content into the docs it introduces`),"document";if(o!==null){if(!p&&o.name!==void 0){const n=o.name;if(typeof n!="string"||n.trim()==="")h("error","local-name",r,`invalid name: ${JSON.stringify(n)} (expected a non-empty store-local name)`,v);else{const m=le(n.trim(),t.namespace);if(!m.ok){const f=Se(G(n.trim()),t.namespace,s);h("error","local-name",r,`invalid name \`${n}\`: ${m.reason} \u2014 ${f}`,v)}}}for(const n of ue(o.extensions,fe(i)))h("error","extension",r,`${n.path}: ${n.message}`,v);const g=pe(o,d,i.name);g!==null&&h("error","length",r,g,v);const l=ye(o,d);l!==null&&h("warning","short-preview",r,l,v);const y=j(o);if(e.nestedStore&&y.some(n=>n.on==="boot")&&h("warning","nested-store-boot",r,"nested-store docs never ride the boot catalog, so its boot surfaces entries are inert \u2014 drop them",v),a&&y.some(n=>n.on==="workspace-open"&&n.at==="content")){const n=y.some(m=>m.on!=="read"||m.at!=="content"?!1:m.match?.includes("./**")===!0);e.frontDoors.push({path:r,root:p,complete:n})}for(const n of y)n.on==="memory-read"&&ke(n,i,o,u,c,h)}if(u!==void 0&&c)for(const g of z(d))u.has(g)||h("error","dangling-link",r,`dangling doc link [[${g}]]: no memory document or directory in this target view has that exact canonical name.${U(g)}`,v);return"document"}w(H,"lintDocumentFile");function Ge(e,t,r={}){const s=[],i={scope:e.scope,...e.storeRoot===""?{}:{storeRoot:e.storeRoot}},a=w((d,p,v,R,g={})=>{s.push({severity:d,rule:p,path:v,message:R,...i,...g})},"add"),c=W(e.storeRoot,t).split(A).join("/"),u=F(e,!0).find(d=>d.path===t),h=[],o=H({store:e,file:t,relPath:c,doc:u,isProjectStore:e.scope==="project"&&e.plugin===void 0,mounted:e.mountStatus==="ready",...r.resolvable===void 0?{}:{resolvable:r.resolvable},nestedStore:r.nestedStore===!0,add:a,frontDoors:h});for(const d of h)d.root||a("error","front-door",d.path,`a project store's workspace front door is its root ${$}.md, not this doc \u2014 a {on: workspace-open, at: content} entry here delivers a second whole document at every workspace open; fold it into the root document or lower this entry`);return M(s,1,o==="document"?1:0,1)}w(Ge,"lintMemoryDocument");function Se(e,t,r){let s=q(e);if(t!==""){const i=E(t),a=E(s);i.every((c,u)=>a[u]===c)&&(s=a.slice(i.length).join("/"))}return s===""?`remove the field: this document's identity would be the store root's, which only the root ${$}.md owns`:s===C(r)?`drop the field \u2014 its physical path already derives \`${s}\``:`use \`name: ${s}\``}w(Se,"suggestedLocalName");function ke(e,t,r,s,i,a){for(const c of e.match??[]){if((c==="**"||c==="*")&&!_(r,"broad-memory-read")){a("warning","broad-memory-read",t.path,`memory-read glob \`${c}\` fires on every memory read \u2014 scope it to a name subtree`,{name:t.name});continue}if(!(s===void 0||!i)){if(!ve.test(c)){const u=Re(c,t.routingAnchor);s.has(u)||a("error","memory-read-route",t.path,`memory-read route \`${c}\` names \`${u}\`, which is no document or directory in this target view, so the entry can never fire.${U(u)}`,{name:t.name});continue}be(c,t.routingAnchor,s)||a("warning","memory-read-route",t.path,`memory-read glob \`${c}\`${c.startsWith("./")?` (anchored at \`${t.routingAnchor}\`)`:""} matches no canonical name in this target view \u2014 a project document's name carries its store's namespace, so an unqualified subtree glob no longer matches`,{name:t.name})}}}w(ke,"lintMemoryReadEntry");function De(){return{cwd:process.cwd(),profileId:Z()||null,nodeId:Q()||null}}w(De,"ambientTarget");function ze(e={}){const t=e.target??De(),r=e.includeDescendants??!0,s=de(t,{...e.scope===void 0?{}:{scope:e.scope},includeDescendants:r,quiet:!0}),i=we(s.docs),a=new Set(r?ie(ae(t.cwd,t.profileId)).map(n=>D(L(n,"memory"))):[]),c=e.scope===void 0||e.scope==="project",u=new Set,h=new Set;if(c&&t.profileId!==null&&t.profileId!=="")try{const{manifest:n}=ce(t.profileId);for(const m of n.projects){const f=D(m.path);u.add(f);const S=x(f);h.add(S.ok?S.association.repositoryRoot:f)}}catch{}const o=D(t.cwd),d=[];let p=0,v=0,R=0;const g=new Set;for(const n of s.stores){const m=n.ownerDir===void 0?null:D(n.ownerDir),f=n.repositoryRoot??m;f!=null&&g.add(f);const k=n.ownerRelativePath!==void 0&&n.ownerRelativePath!==""||!c||m===null?"ignore":h.has(f??m)?"required":u.size===0&&m===o?"advisory":"ignore",b=I(n,{resolvable:i,frontDoor:k,nestedStore:a.has(D(n.storeRoot))});d.push(...b.findings),p+=b.checked,v+=b.documents,R+=b.storesLinted}if(c){for(const f of u){const S=x(f),k=S.ok?S.association.repositoryRoot:f;if(g.has(k))continue;const b=I(B(k),{resolvable:i,frontDoor:"required"});d.push(...b.findings),p+=b.checked,v+=b.documents,R+=b.storesLinted,g.add(k)}const n=x(o),m=n.ok?n.association.repositoryRoot:o;if(u.size===0&&!g.has(m)&&oe(L(t.cwd,".crouter"))){const f=I(B(t.cwd),{resolvable:i,frontDoor:"advisory"});d.push(...f.findings),p+=f.checked,v+=f.documents,R+=f.storesLinted}}const l=N(s.docs),y=w(n=>{const m=n.documentCandidates;m.length>1&&new Set(m.map(f=>f.root)).size>1&&d.push({severity:"notice",rule:"cross-store-candidates",path:m[0].path,name:n.name,paths:m.map(f=>f.path),message:`canonical name \`${n.name}\` is held by ${m.length} stores; this target view reads ${m[0].path} (${m[0].scope}) and the later candidates stay reachable with \`crtr memory read ${n.name} --dir <project>\``});for(const f of n.childDirectories)y(f);for(const f of n.childDocuments)y(f)},"walk");return y(l.root),e.scope===void 0&&d.push(...ge(s.docs)),{...M(d,p,v,R),stores:s.stores,profileProjects:u.size}}w(ze,"lintMemoryTarget");export{Ce as MEMORY_LINT_IDENTITY_RULES,pe as lintBodyLength,Ge as lintMemoryDocument,I as lintMemoryStore,ze as lintMemoryTarget,ge as lintOrphans,ye as lintShortPreviewBody,we as resolvableCanonicalNames};
@@ -1,113 +0,0 @@
1
- import { type MemoryCandidateSet, type MemoryDoc, type MemoryStoreDescriptor } from '../memory-resolver.js';
2
- import { type DocRepresentation } from './identity.js';
3
- import { type MemoryExtensionCatalog } from './extensions.js';
4
- import type { MemoryExtensionScalar } from '../../types.js';
5
- export declare function requireMountedStore(store: MemoryStoreDescriptor): MemoryStoreDescriptor;
6
- /** Normalize and validate a full canonical name: ordering prefixes are
7
- * physical-path-only, a trailing `INDEX` is never an address, and the segment
8
- * charset is fixed. */
9
- export declare function requireCanonicalName(rawName: string): string;
10
- /** The store-local name a full canonical name has inside one exact store, or a
11
- * usage error when it falls outside that store's namespace. `''` names the
12
- * store's own root document — a project store answers at its namespace. */
13
- export declare function requireLocalNameInStore(store: MemoryStoreDescriptor, rawName: string): string;
14
- export interface MemoryPlacement {
15
- store: MemoryStoreDescriptor;
16
- /** Full canonical name — the address the document answers at. */
17
- canonicalName: string;
18
- /** Store-local name, `''` for the store's own root document. */
19
- localName: string;
20
- representation: DocRepresentation;
21
- /** Store-relative markdown path. */
22
- physicalRelativePath: string;
23
- /** Absolute path of the `.md` file. */
24
- path: string;
25
- }
26
- /** Where a NEW document (a `write`, a `move` destination) physically lands in
27
- * one exact store, after proving the canonical identity is free.
28
- *
29
- * Both physical forms carry the same identity, so occupancy is checked against
30
- * the loaded identities AND both `<local>.md` and `<local>/INDEX.md` — a file
31
- * whose explicit `name:` points elsewhere still owns its path. The chosen form
32
- * is `<local>/INDEX.md` when the canonical directory already has descendants
33
- * in this store (the document fronts a directory that exists), else
34
- * `<local>.md`; descendants created later never relocate it, because either
35
- * form validly owns the identity. Pass `storeDocs` when the caller already
36
- * loaded the store, and `source` when planning a move, whose own identity and
37
- * file are being vacated. */
38
- export declare function planNewDocumentPlacement(store: MemoryStoreDescriptor, rawName: string, storeDocs?: readonly MemoryDoc[], source?: MemoryDoc): MemoryPlacement;
39
- /** The document a mutation acts on, refusing an identity two files in ONE
40
- * store both own. Reads stay answerable (`<name>/INDEX.md` deterministically
41
- * wins), but a mutation would silently pick one of two files, so it stops with
42
- * both paths. Candidates in OTHER stores are ordinary alternates — precedence
43
- * picked the winner and `--dir` reaches the rest. */
44
- export declare function requireUnambiguousDoc(set: MemoryCandidateSet): MemoryDoc;
45
- /** Move and delete are the only mutation recovery path for a same-store
46
- * collision. The exact-store winner remains the ordinary target; only the
47
- * selected store's candidates are ordered by their physical path. */
48
- export interface MutationDocSelection {
49
- doc: MemoryDoc;
50
- collisionPaths: readonly string[];
51
- }
52
- export declare function selectMutationDoc(set: MemoryCandidateSet): MutationDocSelection;
53
- /** Remove a just-removed file's now-empty parent directories up to (never
54
- * including) its store root, so removing the last entry under an `area/`
55
- * prefix does not orphan an empty directory. `pathSegments` counts the
56
- * PHYSICAL store-relative path (`doc.physicalRelativePath.split('/').length`),
57
- * never the canonical name, which carries the store's namespace on top of it —
58
- * the same count addresses a `.history/<path>.jsonl` sidecar. Stops at the
59
- * first non-empty ancestor. Every directory resolves beneath `root`, the store root. */
60
- export declare function pruneEmptyParents(root: string, filePath: string, pathSegments: number): void;
61
- /** Map a STORE-LOCAL name (`topic`, `area/topic`, `INDEX`) to its file path
62
- * under a memory dir, guarding against traversal/absolute escapes. Physical
63
- * mapping only: it composes no namespace and collapses no `INDEX`, so a
64
- * canonical name reaches it through `planNewDocumentPlacement`. */
65
- export declare function memoryFilePath(memoryDir: string, name: string): string;
66
- export declare function coerceGate(raw: string): Record<string, unknown>;
67
- /** Coerce one `--surface` value into a validated surfaces entry. Strict where
68
- * the runtime parser is tolerant: a flag that would be silently dropped or
69
- * trimmed at render time is an authoring mistake and fails HERE. The entry is
70
- * returned in canonical key order with a single glob kept as a bare string,
71
- * so the stored YAML stays as compact as the flag that authored it. */
72
- export declare function coerceSurface(raw: string): Record<string, unknown>;
73
- /** Serialize a substrate frontmatter record + body into a complete `.md`
74
- * document. Frontmatter is emitted as a `---` fenced YAML block (the `yaml`
75
- * package — the same one the parser uses — so nested gate maps and surfaces
76
- * entry lists round-trip), in canonical field order with preserved extras last. */
77
- export declare function serializeMemoryDoc(frontmatter: Record<string, unknown>, body: string): string;
78
- /** Everything after the closing frontmatter fence, byte for byte — leading blank
79
- * lines and indentation intact. Source without a fence is all body. */
80
- export declare function literalBodySegment(source: string): string;
81
- /** Serialize a document WITHOUT touching the body. `bodySegment` is everything
82
- * after the closing frontmatter fence (leading blank line included), emitted
83
- * byte for byte. This is the revision path: `edit` saves what it was given, so
84
- * an unchanged doc round-trips identically and a supplied body reaches disk
85
- * untransformed. Creation uses `serializeMemoryDoc`, which normalizes a first
86
- * body into the canonical shape. */
87
- export declare function serializeMemoryDocLiteral(frontmatter: Record<string, unknown>, bodySegment: string): string;
88
- export declare function coerceLintIgnore(raw: unknown): string | string[] | undefined;
89
- export interface RequestedExtensionSet {
90
- path: string;
91
- namespace: string;
92
- field: string;
93
- value: MemoryExtensionScalar;
94
- }
95
- interface RequestedExtensionPath {
96
- path: string;
97
- namespace: string;
98
- field: string;
99
- }
100
- /** Resolve declarations at the same scope and path a document will use. The
101
- * catalog intentionally includes disabled plugins: they still authorize typed
102
- * edits to values that stay inert until their plugin is enabled again. */
103
- export declare function memoryExtensionCatalogForDoc(doc: Pick<MemoryDoc, 'scope' | 'path'>): MemoryExtensionCatalog;
104
- /** Parse every requested extension mutation before the caller constructs any
105
- * frontmatter. Set values are deliberately declaration-typed rather than YAML. */
106
- export declare function parseRequestedExtensionChanges(setRaw: readonly string[] | undefined, unsetRaw: readonly string[] | undefined, catalog: MemoryExtensionCatalog): {
107
- sets: RequestedExtensionSet[];
108
- unsets: RequestedExtensionPath[];
109
- };
110
- /** Apply only requested extension paths. Existing unknown namespaces remain
111
- * untouched; an unset prunes the empty namespace and empty root mapping. */
112
- export declare function applyExtensionChanges(frontmatter: Record<string, unknown>, sets: readonly RequestedExtensionSet[], unsets: readonly RequestedExtensionPath[]): void;
113
- export {};
@@ -1,12 +0,0 @@
1
- var O=Object.defineProperty;var f=(e,t)=>O(e,"name",{value:t,configurable:!0});import{dirname as y,join as g}from"node:path";import{stringify as $,parse as b}from"yaml";import{usage as s}from"../errors.js";import{existsBeneath as A,readdirBeneath as k,rmdirBeneath as J}from"../spaces/open-beneath.js";import{pathExists as P,realpathOrSelf as x}from"../fs-utils.js";import{loadStoreMemoryDocs as q}from"../memory-resolver.js";import{canonicalSegments as D,physicalRelativePathFor as v,stripNamespace as C,validateExplicitLocalName as L}from"./identity.js";import{memoryExtensionValidationCatalog as F}from"./extensions.js";import{SURFACE_EVENTS as S,SURFACE_RUNGS as w}from"../substrate/schema.js";import{SUPPRESSIBLE_RULES as R}from"../substrate/frontmatter-validation.js";function T(e){if(e.scope!=="project"||e.mountStatus==="ready")return e;const t=e.ownerDir??e.storeRoot;if(e.mountStatus==="absent")throw s(`no memory store at ${e.storeRoot}`,{next:`Initialize it with \`crtr memory write <namespace> --dir ${t}\`, which declares the repository namespace.`});const n=e.repositoryRoot??t;throw s(e.diagnostic??`project memory store at ${e.storeRoot} does not declare a namespace`,{next:`Run \`crtr sys migrate --dir ${n}\`.`})}f(T,"requireMountedStore");function j(e){const t=D(e.trim()).join("/");if(t==="")throw s("memory document name required");const n=L(t);if(!n.ok)throw s(`invalid memory document name \`${e}\`: ${n.reason}`,{received:e,next:"Pass the full canonical name (a project document is <namespace>/<local name>); run `crtr memory find <leaf>` to look one up."});return t}f(j,"requireCanonicalName");function M(e,t){T(e);const n=j(t);if(e.namespace==="")return n;const o=C(n,e.namespace);if(o===null)throw s(`\`${n}\` is not in the namespace of the store at ${e.storeRoot} (\`${e.namespace}\`)`,{memory:n,next:`Every document there answers at \`${e.namespace}/<local name>\`; the store's own document answers at \`${e.namespace}\`.`});return o}f(M,"requireLocalNameInStore");function te(e,t,n,o){const i=M(e,t),r=j(t),a=n??q(e,!0),l=o===void 0?null:x(o.path),c=a.find(h=>h.name===r&&x(h.path)!==l);if(c!==void 0)throw s(`${r} already exists in ${e.storeRoot}`,{memory:r,path:c.path,next:`Revise it with \`crtr memory edit ${r}\`, which records the change, or move it with \`crtr memory move\`.`});const p=(i===""?["directory-index"]:["directory-index","leaf-file"]).map(h=>g(e.storeRoot,v(i,h))).filter(h=>P(h)&&x(h)!==l);if(p.length>0)throw s(`${r} cannot be created: ${p.join(" and ")} already exists`,{memory:r,path:p.join(", "),next:"Both `<name>.md` and `<name>/INDEX.md` carry that identity. Read the existing file, then edit, move, or delete it."});const u=i===""||a.some(h=>h.localName.startsWith(`${i}/`))?"directory-index":"leaf-file",d=v(i,u);return{store:e,canonicalName:r,localName:i,representation:u,physicalRelativePath:d,path:g(e.storeRoot,d)}}f(te,"planNewDocumentPlacement");function ne(e){const t=e.winner,n=e.candidates.filter(o=>o.store.storeRoot===t.store.storeRoot);if(n.length>1)throw s(`${e.name} is owned by ${n.length} files in one store: ${n.map(o=>o.path).join(" and ")}`,{memory:e.name,path:n.map(o=>o.path).join(", "),next:`Recover the collision with \`crtr memory move ${e.name} --to <new-free-name>\`; it selects the first physical path in stable lexical order. Do not remove files by hand; \`crtr memory lint\` reports every such collision.`});return t}f(ne,"requireUnambiguousDoc");function oe(e){const n=[...e.candidates.filter(o=>o.store.storeRoot===e.winner.store.storeRoot)].sort((o,i)=>{const r=o.physicalRelativePath.localeCompare(i.physicalRelativePath);return r!==0?r:o.path.localeCompare(i.path)});return{doc:n[0]??e.winner,collisionPaths:n.length>1?n.map(o=>o.path):[]}}f(oe,"selectMutationDoc");function re(e,t,n){let o=t;for(let r=0;r<n;r+=1)o=y(o);let i=y(t);for(;i!==o&&i.startsWith(o)&&A(e,i)&&k(e,i).length===0;)J(e,i),i=y(i)}f(re,"pruneEmptyParents");function ie(e,t){const n=t.split("/").filter(o=>o.length>0);if(n.length===0)throw s("memory document name required");if(n.some(o=>o==="."||o===".."))throw s(`invalid memory document name: ${t}`);return g(e,...n)+".md"}f(ie,"memoryFilePath");function U(e){const t=b(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:`expected an object, got ${JSON.stringify(t)}`}f(U,"parseYamlObject");function ae(e){const t=U(e);if(typeof t=="string")throw s(`--gate must be a YAML/JSON object (field\u2192matcher map): ${t}. Example: --gate '{kind: design}' or --gate '{orchestration.depth: {gte: 2}}'`);return t}f(ae,"coerceGate");const _=new Set(["on","match","match-frontmatter","gate","at"]);function se(e){const t=b(e);if(t===null||typeof t!="object"||Array.isArray(t))throw s(`--surface must be a YAML/JSON object entry {on, at, match?, match-frontmatter?, gate?}, got ${JSON.stringify(t)}. Example: --surface '{on: read, match: "src/**", at: content}'`);const n=t;for(const c of Object.keys(n))if(!_.has(c))throw s(`--surface: unknown key \`${c}\` (an entry carries only on, match, match-frontmatter, gate, at)`);const o=n.on;if(typeof o!="string"||!S.includes(o))throw s(`--surface: invalid \`on\`: ${JSON.stringify(o)} (expected ${S.join("|")})`);const i=n.at;if(typeof i!="string"||!w.includes(i))throw s(`--surface: invalid \`at\`: ${JSON.stringify(i)} (expected ${w.join("|")})`);let r;if(n.match!==void 0){if(o==="boot"||o==="workspace-open")throw s(`--surface: \`match\` is meaningless on \`${o}\` \u2014 the entry's presence is the match; drop it`);if(typeof n.match=="string"){const c=n.match.trim();if(c==="")throw s("--surface: `match` must be a non-empty glob or a non-empty glob list");r=c}else if(Array.isArray(n.match)){const c=n.match.map(m=>typeof m=="string"?m.trim():"");if(c.length===0||c.some(m=>m===""))throw s("--surface: `match` must be a non-empty glob or a non-empty glob list");r=c.length===1?c[0]:c}else throw s(`--surface: invalid \`match\`: ${JSON.stringify(n.match)} (expected a glob string or list)`)}const a=n["match-frontmatter"];if(a!==void 0){if(o!=="read")throw s("--surface: `match-frontmatter` is a `read`-event predicate only");if(a===null||typeof a!="object"||Array.isArray(a))throw s(`--surface: invalid \`match-frontmatter\`: ${JSON.stringify(a)} (expected a field\u2192matcher object)`)}if((o==="read"||o==="memory-read"||o==="command"||o==="pre-command")&&r===void 0&&a===void 0)throw s(`--surface: a \`${o}\` entry requires \`match\`${o==="read"?" or `match-frontmatter`":""}`);const l=n.gate;if(l!==void 0&&(l===null||typeof l!="object"||Array.isArray(l)))throw s(`--surface: invalid \`gate\`: ${JSON.stringify(l)} (expected a field\u2192matcher object)`);return{on:o,...r!==void 0?{match:r}:{},...a!==void 0?{"match-frontmatter":a}:{},...l!==void 0?{gate:l}:{},at:i}}f(se,"coerceSurface");const N=["kind","privacy","when-and-why-to-read","short-form","unlisted","surfaces","gate","slash","rationale","lint-ignore","last-updated","origin"];function ce(e,t){const n={};for(const r of N)e[r]!==void 0&&(n[r]=e[r]);for(const r of Object.keys(e))!(r in n)&&e[r]!==void 0&&(n[r]=e[r]);const o=$(n).replace(/\n+$/,""),i=t.replace(/^\n+/,"").replace(/\s+$/,"");return`---
2
- ${o}
3
- ---
4
-
5
- ${i}
6
- `}f(ce,"serializeMemoryDoc");const B=/^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;function fe(e){const t=e.match(B);return t?e.slice(t[0].length):e}f(fe,"literalBodySegment");function me(e,t){const n={};for(const i of N)e[i]!==void 0&&(n[i]=e[i]);for(const i of Object.keys(e))!(i in n)&&e[i]!==void 0&&(n[i]=e[i]);return`---
7
- ${$(n).replace(/\n+$/,"")}
8
- ---
9
- ${/^\r?\n/.test(t)?"":`
10
- `}${t}`}f(me,"serializeMemoryDocLiteral");function le(e){if(e===void 0)return;const t=Array.isArray(e)?e:[e];if(t.length===0||t.some(n=>typeof n!="string"||!R.includes(n)))throw s(`invalid lint-ignore: ${JSON.stringify(e)} (suppressible rules: ${R.map(n=>`\`${n}\``).join(", ")})`);return t.length===1?t[0]:t}f(le,"coerceLintIgnore");function pe(e){return F(e)}f(pe,"memoryExtensionCatalogForDoc");function ue(e){return e.type!=="enum"?e.type:`enum (${e.values.join("|")})`}f(ue,"declarationValueDescription");function de(e){return typeof e=="string"?JSON.stringify(e):String(e)}f(de,"extensionHelpValue");function E(e,t){const n=/^extensions\.([^.]+)\.([^.]+)$/.exec(e);return n===null?`${t} requires the full path extensions.<plugin>.<field>: ${e}`:{path:e,namespace:n[1],field:n[2]}}f(E,"parseExtensionPath");function I(e,t,n){if(n.type==="boolean")return t==="true"?!0:t==="false"?!1:`${e} expects boolean true or false, received ${JSON.stringify(t)}`;if(n.type==="number"){if(!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(t))return`${e} expects finite numeric syntax, received ${JSON.stringify(t)}`;const o=Number(t);return Number.isFinite(o)?o:`${e} expects a finite number, received ${JSON.stringify(t)}`}return n.type==="enum"&&!n.values.includes(t)?`${e} expects one of ${n.values.join("|")}, received ${JSON.stringify(t)}`:t}f(I,"parseExtensionValue");function he(e,t,n){const o=[],i=[],r=[],a=new Set,l=new Set;for(const c of e??[]){const m=c.indexOf("=");if(m<0){o.push(`--extension requires extensions.<plugin>.<field>=VALUE: ${c}`);continue}const p=E(c.slice(0,m),"--extension");if(typeof p=="string"){o.push(p);continue}if(a.has(p.path)){o.push(`duplicate --extension path: ${p.path}`);continue}a.add(p.path);const u=n[p.namespace]?.[p.field];if(u===void 0){o.push(`${p.path} is not declared by an installed plugin`);continue}const d=I(p.path,c.slice(m+1),u);if(typeof d=="string"&&u.type!=="string"&&u.type!=="enum"){o.push(d);continue}if(typeof d=="string"&&u.type==="enum"&&!u.values.includes(d)){o.push(`${p.path} expects one of ${u.values.join("|")}, received ${JSON.stringify(d)}`);continue}i.push({...p,value:d})}for(const c of t??[]){const m=E(c,"--unset-extension");if(typeof m=="string"){o.push(m);continue}if(l.has(m.path)){o.push(`duplicate --unset-extension path: ${m.path}`);continue}if(l.add(m.path),n[m.namespace]?.[m.field]===void 0){o.push(`${m.path} is not declared by an installed plugin`);continue}r.push(m)}for(const c of a)l.has(c)&&o.push(`${c} was requested in both --extension and --unset-extension`);if(o.length>0)throw s(`invalid plugin memory extension request:
11
- - ${o.join(`
12
- - `)}`,{received:[...e??[],...t??[]].join(", "),next:"Run `crtr memory write -h` or `crtr memory edit -h` for the installed field catalog and value syntax."});return{sets:i,unsets:r}}f(he,"parseRequestedExtensionChanges");function ye(e,t,n){if(t.length===0&&n.length===0)return;const o=e.extensions;if(o!==void 0&&(o===null||typeof o!="object"||Array.isArray(o)))throw s("existing extensions frontmatter must be a mapping before extension fields can be changed",{received:JSON.stringify(o),next:"Repair the extensions mapping, or make a core-field-only edit that preserves it unchanged."});const i={...o??{}};for(const r of t){const a=i[r.namespace];if(a!==void 0&&(a===null||typeof a!="object"||Array.isArray(a)))throw s(`existing ${`extensions.${r.namespace}`} frontmatter must be a mapping before ${r.path} can change`,{received:JSON.stringify(a),next:"Repair the namespace mapping, or make a core-field-only edit that preserves it unchanged."});i[r.namespace]={...a??{},[r.field]:r.value}}for(const r of n){const a=i[r.namespace];if(a===void 0)continue;if(a===null||typeof a!="object"||Array.isArray(a))throw s(`existing ${`extensions.${r.namespace}`} frontmatter must be a mapping before ${r.path} can change`,{received:JSON.stringify(a),next:"Repair the namespace mapping, or make a core-field-only edit that preserves it unchanged."});const l={...a};delete l[r.field],Object.keys(l).length===0?delete i[r.namespace]:i[r.namespace]=l}Object.keys(i).length===0?delete e.extensions:e.extensions=i}f(ye,"applyExtensionChanges");export{ye as applyExtensionChanges,ae as coerceGate,le as coerceLintIgnore,se as coerceSurface,fe as literalBodySegment,pe as memoryExtensionCatalogForDoc,ie as memoryFilePath,he as parseRequestedExtensionChanges,te as planNewDocumentPlacement,re as pruneEmptyParents,j as requireCanonicalName,M as requireLocalNameInStore,T as requireMountedStore,ne as requireUnambiguousDoc,oe as selectMutationDoc,ce as serializeMemoryDoc,me as serializeMemoryDocLiteral};
@@ -1,74 +0,0 @@
1
- import { type MemoryScope, type MemoryStoreDescriptor, type MemoryTarget } from '../memory-resolver.js';
2
- import { type HistoryActor } from './history.js';
3
- export interface MemoryMutationSelection {
4
- target: MemoryTarget;
5
- scope?: MemoryScope;
6
- store?: MemoryStoreDescriptor | null;
7
- }
8
- interface MemoryMutationInput {
9
- target: MemoryTarget;
10
- /** CLI callers preserve their history actor; API callers default to the addressed target. */
11
- history?: HistoryActor;
12
- }
13
- export interface CreateDocInput extends MemoryMutationInput {
14
- scope: MemoryScope;
15
- memoryDir: string;
16
- store: MemoryStoreDescriptor;
17
- /** The caller performed an explicit --dir-like project selection. */
18
- isExplicitProjectStore: boolean;
19
- /** Provenance is supplied by the caller; core mutation code has no ambient identity. */
20
- origin: Record<string, unknown>;
21
- fields: Record<string, unknown>;
22
- }
23
- export declare function createDoc(input: CreateDocInput): {
24
- name: string;
25
- scope: MemoryScope;
26
- path: string;
27
- findings?: {
28
- severity: string;
29
- rule: string;
30
- message: string;
31
- }[];
32
- };
33
- export interface UpdateDocInput extends MemoryMutationInput {
34
- selection: MemoryMutationSelection;
35
- fields: Record<string, unknown>;
36
- }
37
- export interface DeleteDocInput extends MemoryMutationInput {
38
- selection: MemoryMutationSelection;
39
- fields: Record<string, unknown>;
40
- }
41
- export interface MoveDocInput extends MemoryMutationInput {
42
- selection: MemoryMutationSelection;
43
- fields: Record<string, unknown>;
44
- }
45
- export declare function updateDoc(input: UpdateDocInput): {
46
- name: string;
47
- kind: string;
48
- scope: "user" | "profile" | "project" | "node";
49
- path: string;
50
- revision: number;
51
- changed: string[];
52
- };
53
- export declare function deleteDoc(input: DeleteDocInput): {
54
- follow_up?: string | undefined;
55
- name: string;
56
- scope: "user" | "profile" | "project" | "node";
57
- path: string;
58
- log_path: string;
59
- };
60
- export declare function moveDoc(input: MoveDocInput): {
61
- name: string;
62
- previous_name: string;
63
- scope: "user" | "profile" | "project" | "node";
64
- path: string;
65
- log_path: string;
66
- refs_rewritten: {
67
- name: string;
68
- scope: MemoryScope;
69
- path: string;
70
- refs: number;
71
- }[];
72
- follow_up: string;
73
- };
74
- export {};
@@ -1 +0,0 @@
1
- var be=Object.defineProperty;var $=(a,s)=>be(a,"name",{value:s,configurable:!0});import{dirname as E,join as te,resolve as G}from"node:path";import{CrtrError as oe,notFound as z,usage as p}from"../errors.js";import{parseFrontmatterGeneric as ve}from"../frontmatter.js";import{realpathOrSelf as I,walkFiles as $e}from"../fs-utils.js";import{appendFileBeneath as xe,existsBeneath as re,readFileBeneath as Re,renameBeneath as ke,unlinkBeneath as J,writeFileBeneath as V}from"../spaces/open-beneath.js";import{docLinkNames as De,findDocLinks as ne}from"./doc-link-grammar.js";import{lintMemoryDocument as je,resolvableCanonicalNames as Se}from"./lint.js";import{descendantStoreRoots as Pe}from"../nested-stores.js";import{projectScopeRoots as Ie}from"../scope.js";import{associateRepository as Ne}from"./repository-association.js";import{parsedSubstrateSurfaces as Ee}from"../substrate/frontmatter-validation.js";import{explicitLocalName as Fe}from"./identity.js";import{buildMemoryTree as Le}from"./tree.js";import{loadMemoryStoreView as K,loadMemoryTargetView as U,openProjectMemoryStore as Oe,resolveMemoryCandidatesForTarget as ae}from"../memory-resolver.js";import{appendHistoryRecord as C,buildHistoryRecord as M,historyLogPathFor as F,readHistoryRecords as Ae}from"./history.js";import{applyExtensionChanges as ie,coerceGate as se,coerceLintIgnore as ce,coerceSurface as me,literalBodySegment as W,memoryExtensionCatalogForDoc as de,parseRequestedExtensionChanges as le,planNewDocumentPlacement as pe,pruneEmptyParents as Q,requireCanonicalName as ue,requireLocalNameInStore as he,requireMountedStore as Y,requireUnambiguousDoc as Ce,selectMutationDoc as fe,serializeMemoryDoc as Me,serializeMemoryDocLiteral as H}from"./mutation-domain.js";function q(a,s){return Re(a,s).toString("utf8")}$(q,"readBeneath");function B(a){return a.history??{cwd:a.target.cwd,...a.target.nodeId===null?{}:{node:a.target.nodeId}}}$(B,"historyActorFor");function qe(a){return $e(a,s=>s.endsWith(".md")&&s!=="SKILL.md",s=>s===".crouter").length===0}$(qe,"emptyMemoryStore");function Be(a){const s=a.some(o=>o.on==="workspace-open"&&o.at==="content"),m=a.some(o=>{if(o.on!=="read"||o.at!=="content")return!1;const r=o.match;return r==="./**"||Array.isArray(r)&&r.includes("./**")});return s&&m}$(Be,"hasWorkspaceFrontDoor");function nt(a){const{target:s,scope:m,memoryDir:o,store:r,origin:b,fields:c}=a,h=c.name,e=c.kind,t=c.body??"";let d=!1;if(m==="project"&&r.mountStatus!=="ready"&&a.isExplicitProjectStore&&qe(o)){const n=Ne(I(r.ownerDir??E(E(o))));if(n.ok){if(n.association.ownerRelativePath!=="")throw p(`${r.ownerDir??E(E(o))} is a nested store in the repository rooted at ${n.association.repositoryRoot}; only the repository root declares a namespace`,{next:"crtr memory write <namespace> --dir <repositoryRoot>, or crtr sys migrate --dir <repositoryRoot>"});d=!0}else n.code==="no-project-root"&&(d=!0)}m==="project"&&r.mountStatus!=="ready"&&!d&&Y(r);let y,g;if(d)y=ue(h),g=te(o,"INDEX.md");else{const n=pe(r,h);y=n.canonicalName,g=n.path}const v=ce(c.lintIgnore),u=le(c.extension,void 0,de({scope:m,path:g})),l={};l.kind=e,l.privacy=c.privacy??"public",d&&(l.namespace=y),l.origin=b;const x=$((n,D)=>{D!==void 0&&(l[n]=D)},"setIf");x("when-and-why-to-read",c.whenAndWhyToRead),x("short-form",c.shortForm),c.unlisted===!0&&(l.unlisted=!0),c.surface!==void 0&&(l.surfaces=c.surface.map(me)),c.gate!==void 0&&(l.gate=se(c.gate)),x("lint-ignore",v),c.slash===!0&&(l.slash=!0),x("rationale",c.rationale),ie(l,u.sets,u.unsets),l["last-updated"]=b.created;const R=l.surfaces;if(m!=="project"&&Array.isArray(R)&&R.some(n=>n!==null&&typeof n=="object"&&n.on==="workspace-open"))throw p("a workspace-open surfaces entry is a project-store mount route; user, profile, and node memory cannot carry one \u2014 drop the entry or write to a project store");if(d){const n=Array.isArray(R)?R.filter(D=>D!==null&&typeof D=="object"):[];if(!Be(n))throw p(`empty project initialization requires the ordinary workspace front door: --surface '{on: workspace-open, at: content}' and --surface '{on: read, match: "./**", at: content}'`,{memory:y,next:`Pass both front-door surfaces when initializing ${y} with --dir.`})}const j=Me(l,t);V(o,g,j);const N=F(o,g);C(o,N,M({op:"create",actor:B(a),before:"",after:j}));const k=Ee(l),S=De(t).length>0||k.some(n=>n.on==="memory-read"),L=k.some(n=>n.on==="boot"),P=d?Oe(r.ownerDir??E(E(o))):r,i=je(P,g,{...S?{resolvable:Se(U({cwd:r.ownerDir??s.cwd,profileId:s.profileId,nodeId:s.nodeId},{quiet:!0,includeDescendants:!0}).docs)}:{},...L?{nestedStore:Pe(Ie(s.cwd,s.profileId)).map(n=>I(te(n,"memory"))).includes(I(o))}:{}});return{name:y,scope:m,path:g,...i.findings.length===0?{}:{findings:i.findings.map(n=>({severity:n.severity,rule:n.rule,message:n.message}))}}}$(nt,"createDoc");const Te=["short-form","gate","surfaces","unlisted","slash","rationale","lint-ignore"],Z=["kind","privacy","when-and-why-to-read","origin","last-updated"];function ye(a,s,m,o){if(o!==null)return o.candidates(a);try{return ae(a,s,{includeDescendants:!0,...m!==void 0?{scope:m}:{}})}catch(r){if(r instanceof oe&&r.code==="not_found")return null;throw r}}$(ye,"mutationCandidates");function we(a,s,m){const o=W(a),r=a.length-o.length,b=ne(o).filter(h=>h.name===s);let c=a;for(let h=b.length-1;h>=0;h-=1){const e=b[h];c=c.slice(0,r+e.start)+`[[${m}]]`+c.slice(r+e.end)}return{text:c,count:b.length}}$(we,"rewriteRefs");function at(a){const{target:s,selection:m,fields:o}=a,r=o.name,b=o.rationale,c=o.verbatim===!0,h=o.body??"";let e;try{const i=m.store===null||m.store===void 0?ae(r,s,{includeDescendants:!0,...m.scope===void 0?{}:{scope:m.scope}}):(he(m.store,r),K(m.store,!0,s).candidates(r));if(i===null)throw z(`memory document not found: ${r}`,{memory:r,next:`\`edit\` revises a document that already exists. Create it with \`crtr memory write ${r} ...\`, or run \`crtr memory find <query>\` if it exists under another name.`});e=Ce(i)}catch(i){throw i instanceof oe&&i.code==="not_found"?z(`memory document not found: ${r}`,{memory:r,next:`\`edit\` revises a document that already exists. Create it with \`crtr memory write ${r} ...\`, or run \`crtr memory find <query>\` if it exists under another name.`}):i}if(e.plugin!==void 0)throw p(`${e.name} belongs to the installed plugin "${e.plugin}" \u2014 a read-only corpus managed by \`crtr pkg\`, not editable here. To override just this doc, write a same-named doc at a writable scope (\`crtr memory write ${e.name} ...\`).`,{memory:e.name,plugin:e.plugin});if(e.scope==="builtin")throw p(`${e.name} is a builtin document shipped with the package (read-only) \u2014 it cannot be edited. Override it with a same-named doc at a writable scope instead (\`crtr memory write ${e.name} ...\`).`,{memory:e.name,scope:"builtin"});const t=ce(o.lintIgnore),d=le(o.extension,o.unsetExtension,de(e)),y=q(e.root,e.path),v={...ve(y).data??{}},u={...v};if(u.privacy===void 0&&(u.privacy="private"),e.scope==="project"&&e.localName===""){if(e.store.ownerRelativePath!==""&&Object.prototype.hasOwnProperty.call(v,"namespace"))throw p(`a nested store's INDEX.md carries no namespace: \u2014 the repository at ${e.store.repositoryRoot??e.root} declares it`,{memory:e.name,path:e.path,next:`Run \`crtr memory lint --dir ${e.store.ownerDir??e.root}\` or \`crtr sys migrate --dir ${e.store.repositoryRoot??e.root}\`.`});if(e.store.ownerRelativePath===""&&v.namespace!==e.store.repositoryNamespace)throw p(`the repository namespace on ${e.path} is immutable; it must remain \`${e.store.repositoryNamespace}\``,{memory:e.name,path:e.path});if(v.name!==void 0)throw p(`the project root INDEX at ${e.path} cannot carry a \`name:\` field`,{memory:e.name,path:e.path,next:`Run \`crtr sys migrate --dir ${e.store.repositoryRoot??e.store.ownerDir??e.root}\`.`})}const l=$((i,n)=>{n!==void 0&&(u[i]=n)},"setIf");l("kind",o.kind),l("privacy",o.privacy),l("when-and-why-to-read",o.whenAndWhyToRead),l("short-form",o.shortForm),o.unlisted===!0&&(u.unlisted=!0),o.surface!==void 0&&(u.surfaces=o.surface.map(me)),o.gate!==void 0&&(u.gate=se(o.gate)),l("lint-ignore",t),o.slash===!0&&(u.slash=!0),l("rationale",o.docRationale),ie(u,d.sets,d.unsets);for(const i of o.unset??[]){if(Z.includes(i))throw p(`--unset ${i}: ${i} is never clearable`,{memory:e.name,next:`Protected fields are ${Z.join(", ")}.`});if(!Te.includes(i)&&!Object.prototype.hasOwnProperty.call(v,i)){const n=Object.keys(v).filter(D=>!Z.includes(D));throw p(`--unset ${i}: ${e.name} has no \`${i}\` field to unset`,{memory:e.name,next:n.length>0?`Fields ${e.name} has: ${n.join(", ")}.`:`${e.name} carries no field eligible for --unset.`})}delete u[i]}const x=u.surfaces;if(e.scope!=="project"&&Array.isArray(x)&&x.some(i=>i!==null&&typeof i=="object"&&i.on==="workspace-open"))throw p("a workspace-open surfaces entry is a project-store mount route; user, profile, and node memory cannot carry one \u2014 drop the entry");const R=W(y),j=h===""?R:h;if(H(u,j)===y)throw p(`edit changed nothing \u2014 ${e.name} already says exactly this, so there is nothing to record`,{memory:e.name,next:"Pipe a different body or pass a frontmatter flag that changes a value. To remove the doc entirely, use `crtr memory delete`."});u["last-updated"]=new Date().toISOString();const k=H(u,j);V(e.root,e.path,k);const S=F(e.root,e.path);C(e.root,S,M({op:"edit",actor:B(a),rationale:b,...c?{verbatim:!0}:{},before:y,after:k}));const L=[...new Set([...Object.keys(v),...Object.keys(u)])].filter(i=>i!=="last-updated").filter(i=>JSON.stringify(v[i])!==JSON.stringify(u[i])).sort((i,n)=>i.localeCompare(n)),P=[...j!==R?["body"]:[],...L];return{name:e.name,kind:String(u.kind??""),scope:e.scope,path:e.path,revision:Ae(e.root,S).length,changed:P}}$(at,"updateDoc");function it(a){const{target:s,selection:m,fields:o}=a,r=o.name,b=m.store===null||m.store===void 0?null:K(Y(m.store),!0,s),c=ye(r,s,m.scope,b);if(c===null)throw z(`memory document not found: ${r}`,{memory:r,next:"A delete takes the full canonical name (a project document is <namespace>/<local name>), and a directory\u2019s own document answers at the directory name. Run `crtr memory find <leaf>` to look it up, or pass --dir to reach one exact project store."});const h=fe(c),e=h.doc;if(e.plugin!==void 0)throw p(`${e.name} belongs to the installed plugin "${e.plugin}" \u2014 it is not a scope doc and cannot be deleted here. Manage plugin docs with \`crtr pkg\`. To override just this doc, write a same-named doc at a writable scope (\`crtr memory write ${e.name} ...\`).`,{memory:e.name,plugin:e.plugin});if(e.scope==="builtin")throw p(`${e.name} is a builtin document shipped with the package (read-only) \u2014 it cannot be deleted. Override it with a same-named doc at a writable scope instead (\`crtr memory write ${e.name} ...\`).`,{memory:e.name,scope:"builtin"});if(e.localName===""&&e.store.ownerRelativePath==="")throw p(`${e.name} is the repository-root document at ${e.path}, which declares the namespace every document in this repository composes under \u2014 deleting it would unmount the whole repository, so it cannot be deleted.`,{memory:e.name,path:e.path,next:`Delete the documents under \`${e.name}/\` individually, or revise the repository-root document with \`crtr memory edit ${e.name} --rationale "<why>"\`.`});const t=q(e.root,e.path),d=F(e.root,e.path);return J(e.root,e.path),Q(e.root,G(e.path),e.physicalRelativePath.split("/").length),C(e.root,d,M({op:"delete",actor:B(a),before:t,after:""})),{name:e.name,scope:e.scope,path:e.path,log_path:d,...h.collisionPaths.length>0?{follow_up:`Removed the first physical path in stable lexical order (${e.path}) to recover a same-store collision.`}:{}}}$(it,"deleteDoc");function st(a){const{target:s,selection:m,fields:o}=a,r=o.name,b=(o.to??"").trim(),c=m.store===null||m.store===void 0?null:K(Y(m.store),!0,s),h=ye(r,s,m.scope,c);if(h===null)throw Le(c?.docs??U(s,{quiet:!0,includeDescendants:!0}).docs).isDirectory(r)?p(`${r} is a canonical directory with no document of its own, and a directory never moves as a unit \u2014 move its members individually.`,{memory:r,next:`Run \`crtr memory read ${r}\` to list the members, then \`crtr memory move <member> --to <new-name>\` per document.`}):z(`memory document not found: ${r}`,{memory:r,next:"A move takes the full canonical name (a project document is <namespace>/<local name>), and a directory\u2019s own document answers at the directory name. Run `crtr memory find <leaf>` to look it up, or pass --dir to reach one exact project store."});const e=fe(h),t=e.doc;if(t.plugin!==void 0)throw p(`${t.name} belongs to the installed plugin "${t.plugin}" \u2014 it is not a scope doc and cannot be moved here. Manage plugin docs with \`crtr pkg\`.`,{memory:t.name,plugin:t.plugin});if(t.scope==="builtin")throw p(`${t.name} is a builtin document shipped with the package (read-only) \u2014 it cannot be moved. Override it with a same-named doc at a writable scope instead (\`crtr memory write ${t.name} ...\`).`,{memory:t.name,scope:"builtin"});if(t.localName===""&&t.store.ownerRelativePath==="")throw p(`${t.name} is the repository-root document at ${t.path}, which declares the namespace every document in this repository composes under \u2014 it answers at the namespace itself and cannot be moved.`,{memory:t.name,path:t.path});if(b==="")throw p("--to requires the new canonical name");const d=ue(b);if(d===t.name)throw p(`${t.name} already answers to that name \u2014 nothing to move`);if(t.store.ownerRelativePath===""&&he(t.store,d)==="")throw p(`${d} is the repository namespace of the store at ${t.root} \u2014 its repository-root document declares that namespace and is not a destination a move can create.`,{memory:d});const y=I(t.path),g=pe(t.store,d,c?.docs,t),v=I(g.path)===y,u=U(s,{quiet:!0,includeDescendants:!0}).docs,l=c?.docs??u,x=u.find(f=>f.name===t.name),R=x!==void 0&&I(x.path)===y,j=[],N=[];if(R){const f=new Set([y]);for(const w of l){const T=I(w.path);f.has(T)||(f.add(T),ne(w.body).some(_=>_.name===t.name)&&(w.plugin!==void 0||w.scope==="builtin"?N.push(w):j.push(w)))}if(N.length>0)throw p(`cannot move ${t.name}: read-only docs link to it with [[${t.name}]] and their refs cannot be rewritten \u2014 `+N.map(w=>`${w.plugin!==void 0?`plugin ${w.plugin}`:w.scope}: ${w.name} (${w.path})`).join("; ")+". Nothing was changed.",{memory:t.name})}const k=[];for(const f of j){const w=q(f.root,f.path),{text:T,count:_}=we(w,t.name,d);if(_===0)continue;const X={...f.frontmatter??{}};X.privacy===void 0&&(X.privacy="private");const ee=H(X,W(T));V(f.root,f.path,ee),C(f.root,F(f.root,f.path),M({op:"edit",actor:B(a),rationale:`\`crtr memory move\`: [[${t.name}]] \u2192 [[${d}]]`,before:w,after:ee})),k.push({name:f.name,scope:f.scope,path:f.path,refs:_})}const S=q(t.root,t.path),L=R?we(S,t.name,d).text:S,P={...t.frontmatter??{}};P.privacy===void 0&&(P.privacy="private"),Fe(t.frontmatter)!==null&&delete P.name;const i=H(P,W(L)),n=g.store.storeRoot;V(n,g.path,i);const D=t.physicalRelativePath.split("/").length;v||(J(t.root,t.path),Q(t.root,G(t.path),D));const O=F(t.root,t.path),A=F(n,g.path);!v&&re(t.root,O)&&(re(n,A)?(xe(n,A,q(t.root,O)),J(t.root,O)):ke(t.root,O,A),Q(t.root,G(O),D)),C(n,A,M({op:"move",actor:B(a),from:t.name,before:S,after:i}));const ge=R?k.length>0?` Rewrote [[${t.name}]] in ${k.length} doc${k.length===1?"":"s"}.`:" No inbound refs needed rewriting.":x===void 0?` Inbound [[${t.name}]] refs were left alone: no document answers to that name in this target view, so no link here pointed at the moved file.`:` Inbound [[${t.name}]] refs were left alone: ${x.path} answers to that name in this target view, so they still resolve to it.`;return{name:d,previous_name:t.name,scope:t.scope,path:g.path,log_path:A,refs_rewritten:k,follow_up:`Moved${e.collisionPaths.length>0?` the first physical path in stable lexical order (${t.path}) to recover a same-store collision.`:"."}${ge}`}}$(st,"moveDoc");export{nt as createDoc,it as deleteDoc,st as moveDoc,at as updateDoc};
@@ -1,31 +0,0 @@
1
- export type ProjectNamespaceSource =
2
- /** The store root's existing explicit `name`. */
3
- 'root-name'
4
- /** Git common-repository label plus the owner's worktree-relative path. */
5
- | 'git-worktree'
6
- /** H1 title of the store root's guide body. */
7
- | 'root-guide-h1'
8
- /** The owner directory's own basename. */
9
- | 'owner-basename';
10
- export type ProjectNamespaceDerivation = {
11
- ok: true;
12
- namespace: string;
13
- source: ProjectNamespaceSource;
14
- } | {
15
- ok: false;
16
- reason: string;
17
- };
18
- export interface ProjectNamespaceInput {
19
- /** The project directory containing `.crouter/` — not the memory dir. */
20
- ownerDir: string;
21
- /** Frontmatter of the store's root `INDEX.md`, when it has one. */
22
- rootFrontmatter?: Record<string, unknown> | null;
23
- /** Body of the store's root `INDEX.md`, when it has one. */
24
- rootBody?: string;
25
- }
26
- /** Derive one project store's namespace: its existing root `name` first, else
27
- * the git repository label plus the owner's path within its worktree, else the
28
- * root guide's H1, else the owner basename. An existing root `name` that
29
- * cannot be a namespace fails rather than falling through — a declared
30
- * identity is never silently replaced. */
31
- export declare function deriveProjectNamespace(input: ProjectNamespaceInput): ProjectNamespaceDerivation;
@@ -1,2 +0,0 @@
1
- var g=Object.defineProperty;var n=(t,e)=>g(t,"name",{value:e,configurable:!0});import{basename as c,dirname as h,relative as k,resolve as m,sep as v}from"node:path";import{realpathOrSelf as f}from"../fs-utils.js";import{gitSync as d}from"../git.js";import{collapseTrailingIndex as b,normalizeDocName as $,slugCanonicalPath as i,validateNamespace as p}from"./identity.js";function R(t){const e=m(t.ownerDir),r=t.rootFrontmatter?.name;if(typeof r=="string"&&r.trim()!==""){const l=b($(r.trim())),u=p(l);return u.ok?{ok:!0,namespace:l,source:"root-name"}:{ok:!1,reason:`root \`name: ${r.trim()}\` cannot become a namespace: ${u.reason}`}}const o=N(e);if(o!==null)return a(o,"git-worktree");const s=t.rootBody===void 0?void 0:j(t.rootBody);return s!==void 0?a(i(s),"root-guide-h1"):a(i(c(e)||e),"owner-basename")}n(R,"deriveProjectNamespace");function a(t,e){const r=p(t);return r.ok?{ok:!0,namespace:t,source:e}:{ok:!1,reason:`derived namespace \`${t}\` is invalid: ${r.reason}`}}n(a,"validated");function N(t){const e=w(t);if(e===null)return null;const r=y(t);if(r===null)return null;const o=k(f(r),f(t)).split(v).join("/");return o.startsWith("..")?null:o===""||o==="."?i(e):i(`${e}/${o}`)}n(N,"gitNamespace");function w(t){const e=d(["rev-parse","--path-format=absolute","--git-common-dir"],t);if(e.status!==0)return null;const r=e.stdout.trim();return r===""?null:c(h(r))||null}n(w,"gitRepoLabel");function y(t){const e=d(["rev-parse","--path-format=absolute","--show-toplevel"],t);if(e.status!==0)return null;const r=e.stdout.trim();return r===""?null:m(r)}n(y,"gitWorktreeRoot");function j(t){for(const e of t.split(`
2
- `)){const r=e.match(/^#\s+(.+)$/);if(r){const o=r[1].replace(/\s+/g," ").trim();if(o!=="")return o}}}n(j,"h1Title");export{R as deriveProjectNamespace};