@north-light/crouter 0.3.352 → 0.3.354

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (616) hide show
  1. package/dist/api/client.d.ts +35 -25
  2. package/dist/api/client.js +2 -2
  3. package/dist/api/dto/broker-ops.d.ts +2 -36
  4. package/dist/api/dto/canvas.d.ts +8 -13
  5. package/dist/api/dto/config.d.ts +4 -0
  6. package/dist/api/dto/delivery.d.ts +61 -0
  7. package/dist/api/dto/docs.d.ts +133 -0
  8. package/dist/api/dto/docs.js +1 -0
  9. package/dist/api/dto/health.d.ts +26 -79
  10. package/dist/api/dto/node-outcomes.d.ts +1 -3
  11. package/dist/api/dto/nodes.d.ts +5 -26
  12. package/dist/api/dto/objects.d.ts +167 -0
  13. package/dist/api/dto/objects.js +1 -0
  14. package/dist/api/dto/profiles.d.ts +14 -8
  15. package/dist/api/dto/reports.d.ts +9 -7
  16. package/dist/api/dto/reviews.d.ts +9 -3
  17. package/dist/api/dto/worktree.d.ts +1 -1
  18. package/dist/api/index.d.ts +0 -1
  19. package/dist/api/index.js +1 -1
  20. package/dist/api/routes.d.ts +14 -12
  21. package/dist/api/routes.js +1 -1
  22. package/dist/build-root.js +1 -1
  23. package/dist/builtin-memory/00-runtime-base/00-authoring.md +10 -5
  24. package/dist/builtin-memory/04-orchestration-kernel.md +7 -7
  25. package/dist/builtin-memory/05-kinds/advisor/01-orchestrator.md +1 -1
  26. package/dist/builtin-memory/05-kinds/explore/00-base.md +2 -2
  27. package/dist/builtin-memory/05-kinds/explore/01-orchestrator.md +2 -2
  28. package/dist/builtin-memory/crouter-concepts/INDEX.md +2 -2
  29. package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
  30. package/dist/builtin-memory/crouter-concepts/memory.md +15 -15
  31. package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +1 -1
  32. package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +5 -5
  33. package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
  34. package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
  35. package/dist/builtin-memory/crouter-sdk/INDEX.md +2 -2
  36. package/dist/builtin-memory/crouter-sdk/README.md +5 -6
  37. package/dist/builtin-memory/crouter-sdk/errors.md +0 -13
  38. package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -1
  39. package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +2 -2
  40. package/dist/builtin-memory/crouter-sdk/nodes.md +0 -2
  41. package/dist/builtin-memory/crouter-sdk/resources.md +0 -1
  42. package/dist/builtin-memory/explore/exploration-doc.md +4 -4
  43. package/dist/builtin-memory/insights/capture.md +6 -6
  44. package/dist/builtin-memory/insights/init.md +14 -14
  45. package/dist/builtin-memory/internal/INDEX.md +4 -4
  46. package/dist/builtin-memory/internal/agent-shaping.md +20 -20
  47. package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
  48. package/dist/builtin-memory/internal/marketplaces.md +2 -2
  49. package/dist/builtin-memory/internal/memory-loading.md +31 -30
  50. package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
  51. package/dist/builtin-memory/internal/plugins.md +16 -14
  52. package/dist/builtin-memory/internal/storage-tiers.md +4 -4
  53. package/dist/builtin-memory/memory-read-orientation.md +1 -1
  54. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +32 -40
  55. package/dist/clients/attach/input/controller.js +1 -1
  56. package/dist/clients/attach/input/ref-autocomplete.js +1 -1
  57. package/dist/clients/attach/input/titled-editor.js +1 -1
  58. package/dist/clients/attach/render/chat-view.js +1 -1
  59. package/dist/clients/attach/render/crtr-output.d.ts +1 -2
  60. package/dist/clients/attach/render/crtr-output.js +17 -17
  61. package/dist/clients/attach/render/group-activity.d.ts +8 -8
  62. package/dist/clients/attach/render/group-activity.js +2 -2
  63. package/dist/clients/attach/render/group-recap.js +1 -1
  64. package/dist/clients/attach/render/tool-calls.d.ts +1 -1
  65. package/dist/clients/attach/session/profile-files.js +1 -1
  66. package/dist/clients/attach/slash/dispatch.js +1 -1
  67. package/dist/clients/attach/viewer.js +806 -1553
  68. package/dist/commands/api-client.d.ts +2 -0
  69. package/dist/commands/api-client.js +3 -3
  70. package/dist/commands/canvas/edges.d.ts +2 -0
  71. package/dist/commands/canvas/edges.js +2 -0
  72. package/dist/commands/canvas/list.d.ts +4 -0
  73. package/dist/commands/canvas/list.js +3 -0
  74. package/dist/commands/canvas/read.d.ts +8 -0
  75. package/dist/commands/canvas/read.js +5 -0
  76. package/dist/commands/canvas/search.d.ts +2 -0
  77. package/dist/commands/canvas/search.js +3 -0
  78. package/dist/commands/canvas/unwatch.d.ts +2 -0
  79. package/dist/commands/canvas/unwatch.js +1 -0
  80. package/dist/commands/canvas/watch.d.ts +3 -0
  81. package/dist/commands/canvas/watch.js +1 -0
  82. package/dist/commands/canvas-analytics.js +1 -1
  83. package/dist/commands/canvas-history/grep.js +4 -4
  84. package/dist/commands/canvas-history/read.js +2 -2
  85. package/dist/commands/canvas-history/search.js +7 -7
  86. package/dist/commands/canvas-history/shared.d.ts +0 -1
  87. package/dist/commands/canvas-history/shared.js +1 -1
  88. package/dist/commands/canvas-history/stats.js +2 -2
  89. package/dist/commands/canvas-history.js +1 -1
  90. package/dist/commands/canvas.js +1 -1
  91. package/dist/commands/doc/delete.d.ts +2 -0
  92. package/dist/commands/doc/delete.js +1 -0
  93. package/dist/commands/doc/edit.d.ts +2 -0
  94. package/dist/commands/doc/edit.js +1 -0
  95. package/dist/commands/doc/history.d.ts +2 -0
  96. package/dist/commands/doc/history.js +2 -0
  97. package/dist/commands/doc/lint.d.ts +2 -0
  98. package/dist/commands/doc/lint.js +2 -0
  99. package/dist/commands/doc/list.d.ts +2 -0
  100. package/dist/commands/doc/list.js +1 -0
  101. package/dist/commands/doc/move.d.ts +2 -0
  102. package/dist/commands/doc/move.js +1 -0
  103. package/dist/commands/doc/read.d.ts +2 -0
  104. package/dist/commands/doc/read.js +1 -0
  105. package/dist/commands/doc/shared.d.ts +25 -0
  106. package/dist/commands/doc/shared.js +2 -0
  107. package/dist/commands/doc/write.d.ts +2 -0
  108. package/dist/commands/doc/write.js +1 -0
  109. package/dist/commands/{memory.d.ts → doc.d.ts} +1 -1
  110. package/dist/commands/doc.js +1 -0
  111. package/dist/commands/human/review.js +1 -1
  112. package/dist/commands/node/bash.js +2 -2
  113. package/dist/commands/node/create.js +1 -1
  114. package/dist/commands/node/inspect.js +10 -10
  115. package/dist/commands/node/lifecycle.js +2 -2
  116. package/dist/commands/node/outcome.js +1 -1
  117. package/dist/commands/node/subscription.js +1 -1
  118. package/dist/commands/node-context.js +2 -2
  119. package/dist/commands/pkg/browse/catalog.js +1 -1
  120. package/dist/commands/pkg/browse/doc-view.js +1 -1
  121. package/dist/commands/pkg/browse/model.d.ts +9 -17
  122. package/dist/commands/pkg/plugin-inspect.js +1 -1
  123. package/dist/commands/pkg/plugin-manage.d.ts +4 -8
  124. package/dist/commands/pkg/plugin-manage.js +15 -17
  125. package/dist/commands/profile/list.js +1 -1
  126. package/dist/commands/profile/new.js +1 -1
  127. package/dist/commands/profile/project.js +1 -1
  128. package/dist/commands/profile/show.js +1 -1
  129. package/dist/commands/push.js +3 -3
  130. package/dist/commands/sys/config.js +1 -1
  131. package/dist/commands/sys/context/admin/actions.d.ts +18 -43
  132. package/dist/commands/sys/context/admin/actions.js +1 -2
  133. package/dist/commands/sys/context/admin/detail-panel.d.ts +17 -25
  134. package/dist/commands/sys/context/admin/detail-panel.js +2 -1
  135. package/dist/commands/sys/context/admin/docs-panel.d.ts +7 -6
  136. package/dist/commands/sys/context/admin/docs-panel.js +1 -1
  137. package/dist/commands/sys/context/admin/list-view.d.ts +12 -12
  138. package/dist/commands/sys/context/admin/list-view.js +1 -1
  139. package/dist/commands/sys/context/admin/model.d.ts +96 -69
  140. package/dist/commands/sys/context/admin/model.js +1 -1
  141. package/dist/commands/sys/context/admin/rail-panel.d.ts +7 -5
  142. package/dist/commands/sys/context/admin/rail-panel.js +1 -1
  143. package/dist/commands/sys/context/admin/read-view.d.ts +10 -14
  144. package/dist/commands/sys/context/admin/read-view.js +1 -2
  145. package/dist/commands/sys/context/admin/shell.d.ts +26 -31
  146. package/dist/commands/sys/context/admin/shell.js +1 -1
  147. package/dist/commands/sys/context/admin.js +2 -2
  148. package/dist/commands/sys/context/doc.js +2 -3
  149. package/dist/commands/sys/context/expose.js +2 -2
  150. package/dist/commands/sys/context/prompt-review.js +4 -4
  151. package/dist/commands/sys/context/resolve.d.ts +92 -65
  152. package/dist/commands/sys/context/resolve.js +7 -9
  153. package/dist/commands/sys/context.js +1 -1
  154. package/dist/commands/sys/doctor.js +1 -1
  155. package/dist/commands/sys/migrate.js +1 -1
  156. package/dist/commands/sys/panels/profiles-panel.d.ts +3 -1
  157. package/dist/commands/sys/panels/profiles-panel.js +1 -1
  158. package/dist/commands/sys/sync-deps.d.ts +6 -11
  159. package/dist/commands/sys/sync-deps.js +7 -8
  160. package/dist/commands/sys/sync-project-guidance.js +5 -4
  161. package/dist/commands/sys/sync-shared.d.ts +41 -4
  162. package/dist/commands/sys/sync-shared.js +1 -1
  163. package/dist/commands/sys/sync-skills.js +2 -2
  164. package/dist/commands/sys/sync.js +1 -1
  165. package/dist/core/bash-job-supervisor.d.ts +2 -3
  166. package/dist/core/bash-job-supervisor.js +3 -3
  167. package/dist/core/bash-jobs.d.ts +0 -5
  168. package/dist/core/bash-jobs.js +7 -7
  169. package/dist/core/bootstrap.js +2 -2
  170. package/dist/core/canvas/canvas.d.ts +6 -50
  171. package/dist/core/canvas/canvas.js +16 -21
  172. package/dist/core/canvas/db.d.ts +4 -1
  173. package/dist/core/canvas/db.js +2 -2
  174. package/dist/core/canvas/history.d.ts +11 -39
  175. package/dist/core/canvas/history.js +9 -20
  176. package/dist/core/canvas/install-id.d.ts +2 -2
  177. package/dist/core/canvas/install-id.js +1 -1
  178. package/dist/core/canvas/memory-reads.d.ts +5 -0
  179. package/dist/core/canvas/memory-reads.js +1 -1
  180. package/dist/core/canvas/migrations.js +215 -41
  181. package/dist/core/canvas/node-agent-paths.js +1 -1
  182. package/dist/core/canvas/node-tokens.js +1 -1
  183. package/dist/core/canvas/paths.d.ts +0 -4
  184. package/dist/core/canvas/paths.js +1 -1
  185. package/dist/core/canvas/remote-canvas-source.d.ts +0 -1
  186. package/dist/core/canvas/remote-canvas-source.js +1 -1
  187. package/dist/core/canvas/render-source.d.ts +9 -6
  188. package/dist/core/canvas/render-source.js +6 -6
  189. package/dist/core/canvas/sessions.js +2 -2
  190. package/dist/core/canvas/source.d.ts +6 -0
  191. package/dist/core/canvas/tree.d.ts +29 -0
  192. package/dist/core/canvas/tree.js +12 -0
  193. package/dist/core/canvas/types.d.ts +0 -20
  194. package/dist/core/command-plugins/bundle.js +1 -1
  195. package/dist/core/config.d.ts +1 -1
  196. package/dist/core/conversation-store/listener.js +4 -2
  197. package/dist/core/feed/feed.d.ts +9 -7
  198. package/dist/core/feed/feed.js +3 -7
  199. package/dist/core/feed/inbox.d.ts +3 -5
  200. package/dist/core/feed/inbox.js +1 -10
  201. package/dist/core/feed/messages.d.ts +33 -6
  202. package/dist/core/feed/messages.js +10 -7
  203. package/dist/core/feed/reports.d.ts +10 -0
  204. package/dist/core/feed/reports.js +2 -0
  205. package/dist/core/grants/remove.js +1 -1
  206. package/dist/core/graph/access.d.ts +24 -0
  207. package/dist/core/graph/access.js +8 -0
  208. package/dist/core/graph/bodies.d.ts +6 -0
  209. package/dist/core/graph/bodies.js +1 -0
  210. package/dist/core/graph/deletion.d.ts +9 -0
  211. package/dist/core/graph/deletion.js +5 -0
  212. package/dist/core/graph/diff.d.ts +4 -0
  213. package/dist/core/graph/diff.js +4 -0
  214. package/dist/core/graph/documents.d.ts +160 -0
  215. package/dist/core/graph/documents.js +7 -0
  216. package/dist/core/graph/edges.d.ts +24 -0
  217. package/dist/core/graph/edges.js +1 -0
  218. package/dist/core/graph/events.d.ts +26 -0
  219. package/dist/core/graph/events.js +6 -0
  220. package/dist/core/graph/exposures.d.ts +53 -0
  221. package/dist/core/graph/exposures.js +4 -0
  222. package/dist/core/graph/jobs.d.ts +31 -0
  223. package/dist/core/graph/jobs.js +2 -0
  224. package/dist/core/graph/names.d.ts +28 -0
  225. package/dist/core/graph/names.js +3 -0
  226. package/dist/core/graph/objects.d.ts +55 -0
  227. package/dist/core/graph/objects.js +9 -0
  228. package/dist/core/graph/package-docs.d.ts +31 -0
  229. package/dist/core/graph/package-docs.js +5 -0
  230. package/dist/core/graph/package-files.d.ts +20 -0
  231. package/dist/core/graph/package-files.js +2 -0
  232. package/dist/core/graph/reader.d.ts +21 -0
  233. package/dist/core/graph/reader.js +3 -0
  234. package/dist/core/graph/repo-sync/exchange.d.ts +34 -0
  235. package/dist/core/graph/repo-sync/exchange.js +2 -0
  236. package/dist/core/graph/repo-sync/identity.d.ts +30 -0
  237. package/dist/core/graph/repo-sync/identity.js +1 -0
  238. package/dist/core/graph/repo-sync/index.d.ts +4 -0
  239. package/dist/core/graph/repo-sync/index.js +1 -0
  240. package/dist/core/graph/repo-sync/mirror.d.ts +30 -0
  241. package/dist/core/graph/repo-sync/mirror.js +6 -0
  242. package/dist/core/graph/repo-sync/ref-format.d.ts +76 -0
  243. package/dist/core/graph/repo-sync/ref-format.js +2 -0
  244. package/dist/core/graph/repo-sync/repos.d.ts +17 -0
  245. package/dist/core/graph/repo-sync/repos.js +3 -0
  246. package/dist/core/graph/repo-sync/sync.d.ts +42 -0
  247. package/dist/core/graph/repo-sync/sync.js +2 -0
  248. package/dist/core/graph/rules.d.ts +26 -0
  249. package/dist/core/graph/rules.js +3 -0
  250. package/dist/core/graph/spaces/app.d.ts +3 -0
  251. package/dist/core/graph/spaces/app.js +1 -0
  252. package/dist/core/graph/spaces/index.d.ts +19 -0
  253. package/dist/core/graph/spaces/index.js +1 -0
  254. package/dist/core/graph/spaces/person.d.ts +5 -0
  255. package/dist/core/graph/spaces/person.js +2 -0
  256. package/dist/core/graph/spaces/repo.d.ts +4 -0
  257. package/dist/core/graph/spaces/repo.js +1 -0
  258. package/dist/core/graph/types.d.ts +75 -0
  259. package/dist/core/graph/types.js +1 -0
  260. package/dist/core/graph/watches.d.ts +62 -0
  261. package/dist/core/graph/watches.js +18 -0
  262. package/dist/core/human/feedback-companion.js +1 -1
  263. package/dist/core/human/requests.d.ts +3 -1
  264. package/dist/core/human/requests.js +6 -6
  265. package/dist/core/inspector/model.js +2 -2
  266. package/dist/core/io.js +5 -5
  267. package/dist/core/layout-migrate/index.d.ts +24 -1
  268. package/dist/core/layout-migrate/index.js +4 -4
  269. package/dist/core/layout-migrate/paths.d.ts +4 -0
  270. package/dist/core/layout-migrate/paths.js +1 -1
  271. package/dist/core/layout-migrate/stored-paths.d.ts +7 -0
  272. package/dist/core/layout-migrate/stored-paths.js +11 -11
  273. package/dist/core/layout-migrate/stores.d.ts +19 -6
  274. package/dist/core/layout-migrate/stores.js +3 -4
  275. package/dist/core/manifest.d.ts +0 -2
  276. package/dist/core/manifest.js +1 -1
  277. package/dist/core/{memory/extensions.d.ts → plugin-extensions.d.ts} +9 -10
  278. package/dist/core/plugin-extensions.js +1 -0
  279. package/dist/core/preview-registry.d.ts +1 -1
  280. package/dist/core/preview-registry.js +3 -2
  281. package/dist/core/profiles/manifest.d.ts +7 -7
  282. package/dist/core/profiles/manifest.js +1 -1
  283. package/dist/core/profiles/select.js +3 -3
  284. package/dist/core/review/birth.js +1 -1
  285. package/dist/core/review/companion.js +1 -1
  286. package/dist/core/review/stage.d.ts +12 -1
  287. package/dist/core/review/stage.js +1 -1
  288. package/dist/core/review/store.d.ts +2 -0
  289. package/dist/core/review/store.js +1 -1
  290. package/dist/core/review/types.d.ts +7 -1
  291. package/dist/core/runs/events.js +1 -1
  292. package/dist/core/runs/operations.js +5 -5
  293. package/dist/core/runs/questions.js +2 -2
  294. package/dist/core/runtime/bearings-render.d.ts +13 -7
  295. package/dist/core/runtime/bearings-render.js +12 -12
  296. package/dist/core/runtime/bearings.d.ts +8 -18
  297. package/dist/core/runtime/bearings.js +7 -7
  298. package/dist/core/runtime/broker/daemon-ops.d.ts +7 -12
  299. package/dist/core/runtime/broker/daemon-ops.js +1 -1
  300. package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
  301. package/dist/core/runtime/broker/fault-retry.js +1 -1
  302. package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
  303. package/dist/core/runtime/broker/frame-memory-refs.d.ts +7 -2
  304. package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
  305. package/dist/core/runtime/broker/inbox.d.ts +1 -4
  306. package/dist/core/runtime/broker/inbox.js +1 -10
  307. package/dist/core/runtime/broker/rebind.js +1 -1
  308. package/dist/core/runtime/broker/retry-card-elision.d.ts +7 -0
  309. package/dist/core/runtime/broker/retry-card-elision.js +1 -0
  310. package/dist/core/runtime/broker-extension-render.d.ts +0 -13
  311. package/dist/core/runtime/broker-extension-render.js +2 -4
  312. package/dist/core/runtime/broker-persona-guidance.js +3 -3
  313. package/dist/core/runtime/broker-protocol.d.ts +1 -1
  314. package/dist/core/runtime/broker.js +1 -1
  315. package/dist/core/runtime/close.d.ts +9 -4
  316. package/dist/core/runtime/close.js +1 -1
  317. package/dist/core/runtime/deliver-live.js +1 -1
  318. package/dist/core/runtime/kickoff.js +17 -19
  319. package/dist/core/runtime/launch-target.d.ts +7 -0
  320. package/dist/core/runtime/launch-target.js +1 -1
  321. package/dist/core/runtime/ledger.d.ts +10 -0
  322. package/dist/core/runtime/ledger.js +3 -0
  323. package/dist/core/runtime/lifecycle.js +2 -2
  324. package/dist/core/runtime/nodes.d.ts +10 -2
  325. package/dist/core/runtime/nodes.js +1 -1
  326. package/dist/core/runtime/outcome-document.d.ts +2 -2
  327. package/dist/core/runtime/outcome-document.js +1 -1
  328. package/dist/core/runtime/persona.js +2 -2
  329. package/dist/core/runtime/placement.js +1 -1
  330. package/dist/core/runtime/promote.d.ts +2 -2
  331. package/dist/core/runtime/promote.js +1 -1
  332. package/dist/core/runtime/prospective-inventory-cli.js +2 -2
  333. package/dist/core/runtime/recycle.js +1 -1
  334. package/dist/core/runtime/reopen.js +1 -1
  335. package/dist/core/runtime/revive.js +2 -2
  336. package/dist/core/runtime/roadmap.d.ts +17 -9
  337. package/dist/core/runtime/roadmap.js +4 -4
  338. package/dist/core/runtime/spawn-env.js +1 -1
  339. package/dist/core/runtime/spawn.d.ts +5 -3
  340. package/dist/core/runtime/spawn.js +2 -2
  341. package/dist/core/runtime/structured-output.d.ts +3 -1
  342. package/dist/core/runtime/structured-output.js +4 -4
  343. package/dist/core/scope.d.ts +1 -32
  344. package/dist/core/scope.js +1 -1
  345. package/dist/core/scoped-state/db.js +2 -1
  346. package/dist/core/scoped-state/migrate.js +2 -2
  347. package/dist/core/scoped-state/profiles.d.ts +11 -0
  348. package/dist/core/scoped-state/profiles.js +1 -1
  349. package/dist/core/scoped-state/schema.d.ts +1 -1
  350. package/dist/core/scoped-state/schema.js +7 -5
  351. package/dist/core/spaces/permissions.d.ts +0 -14
  352. package/dist/core/spaces/permissions.js +1 -1
  353. package/dist/core/spaces/stop.d.ts +13 -0
  354. package/dist/core/spaces/stop.js +2 -2
  355. package/dist/core/storage/tables.d.ts +1 -1
  356. package/dist/core/substrate/delivery/corpus.d.ts +21 -0
  357. package/dist/core/substrate/delivery/corpus.js +3 -0
  358. package/dist/core/substrate/delivery/deliver.d.ts +76 -0
  359. package/dist/core/substrate/delivery/deliver.js +6 -0
  360. package/dist/core/substrate/delivery/listings.d.ts +27 -0
  361. package/dist/core/substrate/delivery/listings.js +4 -0
  362. package/dist/core/substrate/delivery/match.d.ts +28 -0
  363. package/dist/core/substrate/delivery/match.js +1 -0
  364. package/dist/core/substrate/delivery/plan.d.ts +67 -0
  365. package/dist/core/substrate/delivery/plan.js +3 -0
  366. package/dist/core/substrate/delivery/render-boot.d.ts +20 -0
  367. package/dist/core/substrate/delivery/render-boot.js +54 -0
  368. package/dist/core/substrate/delivery/render-event.d.ts +47 -0
  369. package/dist/core/substrate/delivery/render-event.js +6 -0
  370. package/dist/core/substrate/delivery/sub-persona-menu.d.ts +2 -0
  371. package/dist/core/substrate/delivery/sub-persona-menu.js +6 -0
  372. package/dist/core/substrate/delivery/types.d.ts +30 -0
  373. package/dist/core/substrate/delivery/types.js +0 -0
  374. package/dist/core/substrate/gate-explain.d.ts +0 -13
  375. package/dist/core/substrate/gate-explain.js +1 -1
  376. package/dist/core/substrate/schema.d.ts +11 -139
  377. package/dist/core/substrate/schema.js +1 -1
  378. package/dist/core/substrate/subject-fields.d.ts +3 -0
  379. package/dist/core/substrate/subject.d.ts +2 -1
  380. package/dist/core/substrate/subject.js +1 -1
  381. package/dist/daemon/api/app-listener.js +11 -11
  382. package/dist/daemon/api/handlers/app-profiles.js +1 -1
  383. package/dist/daemon/api/handlers/bash-jobs.js +1 -2
  384. package/dist/daemon/api/handlers/broker-ops.js +1 -1
  385. package/dist/daemon/api/handlers/canvas.js +5 -5
  386. package/dist/daemon/api/handlers/daemon.js +1 -1
  387. package/dist/daemon/api/handlers/delivery.d.ts +2 -0
  388. package/dist/daemon/api/handlers/delivery.js +1 -0
  389. package/dist/daemon/api/handlers/{memory.d.ts → docs.d.ts} +1 -1
  390. package/dist/daemon/api/handlers/docs.js +1 -0
  391. package/dist/daemon/api/handlers/hook-exec.js +1 -1
  392. package/dist/daemon/api/handlers/messages.js +2 -2
  393. package/dist/daemon/api/handlers/modelauth.d.ts +3 -0
  394. package/dist/daemon/api/handlers/modelauth.js +1 -1
  395. package/dist/daemon/api/handlers/node-records.js +2 -2
  396. package/dist/daemon/api/handlers/nodes.js +1 -1
  397. package/dist/daemon/api/handlers/objects.d.ts +2 -0
  398. package/dist/daemon/api/handlers/objects.js +5 -0
  399. package/dist/daemon/api/handlers/package-docs.d.ts +2 -0
  400. package/dist/daemon/api/handlers/package-docs.js +1 -0
  401. package/dist/daemon/api/handlers/profiles.js +1 -1
  402. package/dist/daemon/api/handlers/reports.d.ts +2 -2
  403. package/dist/daemon/api/handlers/reports.js +4 -4
  404. package/dist/daemon/api/handlers/reviews.js +1 -1
  405. package/dist/daemon/api/handlers/vendor-status.d.ts +8 -0
  406. package/dist/daemon/api/handlers/vendor-status.js +1 -0
  407. package/dist/daemon/api/map.d.ts +2 -2
  408. package/dist/daemon/api/map.js +2 -2
  409. package/dist/daemon/api/operations.d.ts +1 -1
  410. package/dist/daemon/api/operations.js +1 -1
  411. package/dist/daemon/api/principal.d.ts +5 -0
  412. package/dist/daemon/api/principal.js +1 -1
  413. package/dist/daemon/api/reader.d.ts +17 -0
  414. package/dist/daemon/api/reader.js +1 -0
  415. package/dist/daemon/api/server.js +1 -1
  416. package/dist/daemon/control.d.ts +2 -3
  417. package/dist/daemon/crtrd.js +8 -6
  418. package/dist/daemon/fleet.js +4 -4
  419. package/dist/daemon/reconcilers/bash-deadline.d.ts +11 -1
  420. package/dist/daemon/reconcilers/bash-deadline.js +2 -1
  421. package/dist/daemon/reconcilers/broker-supervision.js +4 -4
  422. package/dist/daemon/reconcilers/live-obligation.js +1 -1
  423. package/dist/daemon/reconcilers/node-deadline.js +1 -1
  424. package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
  425. package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -0
  426. package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
  427. package/dist/daemon/review/deliver.js +2 -2
  428. package/dist/daemon/review/finish.js +1 -1
  429. package/dist/hook-authoring.d.ts +0 -1
  430. package/dist/hook-authoring.js +3 -3
  431. package/dist/migrations/004-canvas-documents/apply.d.ts +10 -0
  432. package/dist/migrations/004-canvas-documents/apply.js +1 -0
  433. package/dist/migrations/004-canvas-documents/fields.d.ts +24 -0
  434. package/dist/migrations/004-canvas-documents/fields.js +2 -0
  435. package/dist/migrations/004-canvas-documents/index.d.ts +16 -0
  436. package/dist/migrations/004-canvas-documents/index.js +2 -0
  437. package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +16 -0
  438. package/dist/migrations/004-canvas-documents/legacy/discover.js +1 -0
  439. package/dist/migrations/004-canvas-documents/legacy/history.d.ts +5 -0
  440. package/dist/migrations/004-canvas-documents/legacy/history.js +2 -0
  441. package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +7 -0
  442. package/dist/migrations/004-canvas-documents/legacy/nested.js +1 -0
  443. package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +14 -0
  444. package/dist/migrations/004-canvas-documents/legacy/parse.js +1 -0
  445. package/dist/migrations/004-canvas-documents/legacy/types.d.ts +91 -0
  446. package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
  447. package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +6 -0
  448. package/dist/migrations/004-canvas-documents/legacy-edges.js +18 -0
  449. package/dist/migrations/004-canvas-documents/plan.d.ts +102 -0
  450. package/dist/migrations/004-canvas-documents/plan.js +3 -0
  451. package/dist/migrations/004-canvas-documents/pointers.d.ts +23 -0
  452. package/dist/migrations/004-canvas-documents/pointers.js +4 -0
  453. package/dist/migrations/activation.d.ts +9 -18
  454. package/dist/migrations/activation.js +2 -2
  455. package/dist/pi-extensions/broker-local.d.ts +2 -2
  456. package/dist/pi-extensions/broker-local.js +2 -2
  457. package/dist/pi-extensions/canvas-bash-valve.js +5 -4
  458. package/dist/pi-extensions/canvas-context-intro.js +2 -2
  459. package/dist/pi-extensions/canvas-doc-substrate.d.ts +0 -1
  460. package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
  461. package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
  462. package/dist/pi-extensions/canvas-passive-context.js +1 -1
  463. package/dist/pi-extensions/canvas-recap.js +2 -2
  464. package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
  465. package/dist/pi-extensions/canvas-stophook.js +1 -1
  466. package/dist/prompts/review.js +3 -3
  467. package/dist/shared/env.d.ts +5 -0
  468. package/dist/shared/env.js +1 -1
  469. package/dist/shared/generated-context.js +2 -10
  470. package/dist/shared/inbox-entry-body.d.ts +22 -0
  471. package/dist/shared/inbox-entry-body.js +10 -0
  472. package/dist/{core/memory → shared}/inline-ref-guidance.d.ts +2 -2
  473. package/dist/shared/inline-ref-guidance.js +2 -0
  474. package/dist/types.d.ts +3 -1
  475. package/docs/cli/memory-and-preferences.md +12 -14
  476. package/docs/concepts/README.md +1 -1
  477. package/docs/concepts/lifecycle-and-wakes.md +1 -1
  478. package/docs/concepts/memory.md +15 -15
  479. package/docs/concepts/nodes-and-the-canvas.md +1 -1
  480. package/docs/concepts/profiles-kinds-and-modes.md +5 -5
  481. package/docs/concepts/scopes-and-trust.md +1 -1
  482. package/docs/concepts/why-a-daemon.md +1 -1
  483. package/docs/sdk/README.md +5 -6
  484. package/docs/sdk/errors.md +0 -13
  485. package/docs/sdk/guides/README.md +0 -1
  486. package/docs/sdk/nodes.md +0 -2
  487. package/docs/sdk/resources.md +0 -1
  488. package/package.json +2 -2
  489. package/packages/crouter-identity/package.json +1 -1
  490. package/runtime.lock.json +11 -11
  491. package/dist/api/dto/memory.d.ts +0 -171
  492. package/dist/api/dto/memory.js +0 -1
  493. package/dist/builtin-memory/crouter-sdk/guides/app-memory.md +0 -73
  494. package/dist/builtin-memory/crouter-sdk/memory.md +0 -87
  495. package/dist/commands/broker-permissions.d.ts +0 -2
  496. package/dist/commands/broker-permissions.js +0 -1
  497. package/dist/commands/memory/client.d.ts +0 -11
  498. package/dist/commands/memory/client.js +0 -1
  499. package/dist/commands/memory/delete.d.ts +0 -1
  500. package/dist/commands/memory/delete.js +0 -1
  501. package/dist/commands/memory/edit.d.ts +0 -1
  502. package/dist/commands/memory/edit.js +0 -21
  503. package/dist/commands/memory/find.d.ts +0 -1
  504. package/dist/commands/memory/find.js +0 -1
  505. package/dist/commands/memory/history.d.ts +0 -1
  506. package/dist/commands/memory/history.js +0 -5
  507. package/dist/commands/memory/lint.d.ts +0 -1
  508. package/dist/commands/memory/lint.js +0 -1
  509. package/dist/commands/memory/list.d.ts +0 -1
  510. package/dist/commands/memory/list.js +0 -1
  511. package/dist/commands/memory/move.d.ts +0 -1
  512. package/dist/commands/memory/move.js +0 -1
  513. package/dist/commands/memory/origin.d.ts +0 -1
  514. package/dist/commands/memory/origin.js +0 -1
  515. package/dist/commands/memory/read.d.ts +0 -1
  516. package/dist/commands/memory/read.js +0 -6
  517. package/dist/commands/memory/shared.d.ts +0 -22
  518. package/dist/commands/memory/shared.js +0 -1
  519. package/dist/commands/memory/write.d.ts +0 -1
  520. package/dist/commands/memory/write.js +0 -13
  521. package/dist/commands/memory.js +0 -1
  522. package/dist/commands/node-inspect-artifacts.d.ts +0 -1
  523. package/dist/commands/node-inspect-artifacts.js +0 -8
  524. package/dist/core/help/memory-extensions.d.ts +0 -3
  525. package/dist/core/help/memory-extensions.js +0 -2
  526. package/dist/core/memory/cli-selector.d.ts +0 -13
  527. package/dist/core/memory/cli-selector.js +0 -1
  528. package/dist/core/memory/doc-link-grammar.d.ts +0 -20
  529. package/dist/core/memory/doc-link-grammar.js +0 -2
  530. package/dist/core/memory/extensions.js +0 -1
  531. package/dist/core/memory/history.d.ts +0 -87
  532. package/dist/core/memory/history.js +0 -6
  533. package/dist/core/memory/identity.d.ts +0 -65
  534. package/dist/core/memory/identity.js +0 -1
  535. package/dist/core/memory/inline-ref-guidance.js +0 -2
  536. package/dist/core/memory/inline-ref-inventory.d.ts +0 -9
  537. package/dist/core/memory/inline-ref-inventory.js +0 -1
  538. package/dist/core/memory/lint.d.ts +0 -163
  539. package/dist/core/memory/lint.js +0 -2
  540. package/dist/core/memory/mutation-domain.d.ts +0 -113
  541. package/dist/core/memory/mutation-domain.js +0 -12
  542. package/dist/core/memory/mutations.d.ts +0 -74
  543. package/dist/core/memory/mutations.js +0 -1
  544. package/dist/core/memory/project-namespace.d.ts +0 -31
  545. package/dist/core/memory/project-namespace.js +0 -2
  546. package/dist/core/memory/repository-association.d.ts +0 -31
  547. package/dist/core/memory/repository-association.js +0 -1
  548. package/dist/core/memory/service.d.ts +0 -145
  549. package/dist/core/memory/service.js +0 -2
  550. package/dist/core/memory/tree.d.ts +0 -39
  551. package/dist/core/memory/tree.js +0 -1
  552. package/dist/core/memory-resolver.d.ts +0 -280
  553. package/dist/core/memory-resolver.js +0 -2
  554. package/dist/core/nested-stores.d.ts +0 -18
  555. package/dist/core/nested-stores.js +0 -1
  556. package/dist/core/runtime/memory.d.ts +0 -3
  557. package/dist/core/runtime/memory.js +0 -1
  558. package/dist/core/substrate/frontmatter-validation.d.ts +0 -11
  559. package/dist/core/substrate/frontmatter-validation.js +0 -1
  560. package/dist/core/substrate/gate.d.ts +0 -16
  561. package/dist/core/substrate/gate.js +0 -1
  562. package/dist/core/substrate/index.d.ts +0 -18
  563. package/dist/core/substrate/index.js +0 -1
  564. package/dist/core/substrate/injected-store.d.ts +0 -75
  565. package/dist/core/substrate/injected-store.js +0 -2
  566. package/dist/core/substrate/listings.d.ts +0 -28
  567. package/dist/core/substrate/listings.js +0 -1
  568. package/dist/core/substrate/memory-events.d.ts +0 -6
  569. package/dist/core/substrate/memory-events.js +0 -1
  570. package/dist/core/substrate/on-read-node.d.ts +0 -6
  571. package/dist/core/substrate/on-read-node.js +0 -1
  572. package/dist/core/substrate/on-read.d.ts +0 -101
  573. package/dist/core/substrate/on-read.js +0 -9
  574. package/dist/core/substrate/plan.d.ts +0 -94
  575. package/dist/core/substrate/plan.js +0 -1
  576. package/dist/core/substrate/render-node.d.ts +0 -12
  577. package/dist/core/substrate/render-node.js +0 -1
  578. package/dist/core/substrate/render.d.ts +0 -41
  579. package/dist/core/substrate/render.js +0 -65
  580. package/dist/core/substrate/session-cache.d.ts +0 -27
  581. package/dist/core/substrate/session-cache.js +0 -1
  582. package/dist/core/substrate/surface-match.d.ts +0 -73
  583. package/dist/core/substrate/surface-match.js +0 -1
  584. package/dist/daemon/api/handlers/memory.js +0 -5
  585. package/dist/migrations/001-surfaces-frontmatter.d.ts +0 -2
  586. package/dist/migrations/001-surfaces-frontmatter.js +0 -1
  587. package/dist/migrations/002-profile-project-memory.d.ts +0 -2
  588. package/dist/migrations/002-profile-project-memory.js +0 -1
  589. package/dist/migrations/003-repository-root-memory-identity/front-door.d.ts +0 -26
  590. package/dist/migrations/003-repository-root-memory-identity/front-door.js +0 -11
  591. package/dist/migrations/003-repository-root-memory-identity/index.d.ts +0 -2
  592. package/dist/migrations/003-repository-root-memory-identity/index.js +0 -5
  593. package/dist/migrations/003-repository-root-memory-identity/references.d.ts +0 -95
  594. package/dist/migrations/003-repository-root-memory-identity/references.js +0 -5
  595. package/dist/migrations/003-repository-root-memory-identity/repository-facts.d.ts +0 -39
  596. package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +0 -3
  597. package/dist/migrations/convergent.d.ts +0 -43
  598. package/dist/migrations/convergent.js +0 -2
  599. package/dist/migrations/corpus.d.ts +0 -75
  600. package/dist/migrations/corpus.js +0 -3
  601. package/dist/migrations/frontmatter-splice.d.ts +0 -15
  602. package/dist/migrations/frontmatter-splice.js +0 -8
  603. package/dist/migrations/profile-manifests.d.ts +0 -30
  604. package/dist/migrations/profile-manifests.js +0 -2
  605. package/dist/migrations/registry.d.ts +0 -7
  606. package/dist/migrations/registry.js +0 -1
  607. package/dist/migrations/runner.d.ts +0 -43
  608. package/dist/migrations/runner.js +0 -1
  609. package/dist/migrations/types.d.ts +0 -211
  610. package/dist/shared/birth-announcement.d.ts +0 -12
  611. package/dist/shared/birth-announcement.js +0 -1
  612. package/docs/sdk/guides/app-memory.md +0 -22
  613. package/docs/sdk/memory.md +0 -85
  614. /package/dist/{migrations/types.js → api/dto/delivery.js} +0 -0
  615. /package/dist/{core/memory → shared}/inline-ref-grammar.d.ts +0 -0
  616. /package/dist/{core/memory → shared}/inline-ref-grammar.js +0 -0
@@ -1,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};
@@ -1,31 +0,0 @@
1
- export type RepositoryKind = 'git' | 'non-git';
2
- export interface RepositoryAssociation {
3
- kind: RepositoryKind;
4
- repositoryRoot: string;
5
- repositoryKey: string;
6
- ownerRelativePath: string;
7
- declarationPath: string;
8
- }
9
- export type RepositoryAssociationFailureCode = 'no-project-root' | 'git-lookup-failed' | 'owner-outside-root' | 'owner-path-invalid';
10
- export type RepositoryAssociationResult = {
11
- ok: true;
12
- association: RepositoryAssociation;
13
- } | {
14
- ok: false;
15
- code: RepositoryAssociationFailureCode;
16
- ownerDir: string;
17
- repositoryRoot?: string;
18
- reason: string;
19
- };
20
- /** Normalize a POSIX-slash relative owner path into canonical segments. */
21
- export declare function normalizeOwnerRelativePath(relPosix: string): {
22
- ok: true;
23
- path: string;
24
- } | {
25
- ok: false;
26
- reason: string;
27
- };
28
- /** Associate one physical project-store owner with its repository identity. */
29
- export declare function associateRepository(ownerDir: string): RepositoryAssociationResult;
30
- /** Clear successful associations; failures are deliberately never cached. */
31
- export declare function resetRepositoryAssociationCache(): void;
@@ -1 +0,0 @@
1
- var O=Object.defineProperty;var a=(o,t)=>O(o,"name",{value:t,configurable:!0});import{existsSync as j,statSync as C}from"node:fs";import{homedir as N}from"node:os";import{dirname as _,isAbsolute as $,join as d,relative as h,resolve as g,sep as y}from"node:path";import{gitSync as b}from"../git.js";import{realpathOrSelf as l}from"../fs-utils.js";import{CRTR_DIR_NAME as f}from"../../types.js";import{INDEX_SEGMENT as R,slugCanonicalSegment as x,validateNamespace as L}from"./identity.js";const k=new Map,S=5e3;function P(o){const t=o.replace(/\\/g,"/");if(t===""||t===".")return{ok:!0,path:""};const r=t.split("/");for(const i of r)if(i===""||i==="."||i==="..")return{ok:!1,reason:`owner path contains invalid segment \`${i}\``};const e=r.map(x);for(let i=0;i<e.length;i++)if(e[i]==="")return{ok:!1,reason:`directory \`${r[i]}\` normalizes to an empty name segment`};const n=e.join("/");if(e[e.length-1].toLowerCase()===R.toLowerCase())return{ok:!1,reason:`owner path ends in reserved segment \`${R}\``};const s=L(n);return s.ok?{ok:!0,path:n}:{ok:!1,reason:s.reason}}a(P,"normalizeOwnerRelativePath");function B(o){const t=l(g(o)),r=k.get(t);if(r!==void 0)return{ok:!0,association:r};const e=b(["rev-parse","--path-format=absolute","--show-toplevel","--git-common-dir"],t,void 0,{timeoutMs:S});if(e.status===0||e.timedOut===!0||!/not a git repository/i.test(e.stderr)){if(e.timedOut===!0)return u("git-lookup-failed",t,`git lookup timed out after ${S}ms`);if(e.status!==0){const M=e.stderr.trim()||`git rev-parse exited with status ${e.status}`;return u("git-lookup-failed",t,`git lookup failed: ${M}`)}const i=e.stdout.split(/\r?\n/),w=i[0]?.trim()??"",v=i[1]?.trim()??"";if(w===""||v==="")return u("git-lookup-failed",t,"git lookup returned an empty repository root or common directory");const m=l(g(w)),I=`git:${l(g(v))}`,c=h(m,t).split(y).join("/");if($(c)||c===".."||c.startsWith("../"))return u("owner-outside-root",t,`owner ${t} is outside repository root ${m}`,m);const p=P(c);return p.ok?E({kind:"git",repositoryRoot:m,repositoryKey:I,ownerRelativePath:p.path,declarationPath:d(m,f,"memory","INDEX.md")},t):u("owner-path-invalid",t,p.reason,m)}const n=T(t);if(n===null)return u("no-project-root",t,`no ancestor ${f}/memory store found for ${t}`);const s=P(h(n,t).split(y).join("/"));return s.ok?E({kind:"non-git",repositoryRoot:n,repositoryKey:`path:${n}`,ownerRelativePath:s.path,declarationPath:d(n,f,"memory","INDEX.md")},t):u("owner-path-invalid",t,s.reason,n)}a(B,"associateRepository");function F(){k.clear()}a(F,"resetRepositoryAssociationCache");function E(o,t){return k.set(t,o),{ok:!0,association:o}}a(E,"remember");function u(o,t,r,e){return e===void 0?{ok:!1,code:o,ownerDir:t,reason:r}:{ok:!1,code:o,ownerDir:t,repositoryRoot:e,reason:r}}a(u,"failure");function T(o){const t=l(N()),r=z(o,t);let e=o,n=null;for(;(!r||e!==t)&&D(e)&&(n=e),!(r&&e===t);){const s=_(e);if(s===e)break;e=s}return n}a(T,"nonGitRepositoryRoot");function D(o){const t=d(o,f,"memory");try{return j(t)&&C(t).isDirectory()}catch{return!1}}a(D,"hasProjectMemoryStore");function z(o,t){const r=h(t,o);return r===""||r!==".."&&!r.startsWith(`..${y}`)&&!$(r)}a(z,"isWithin");export{B as associateRepository,P as normalizeOwnerRelativePath,F as resetRepositoryAssociationCache};
@@ -1,145 +0,0 @@
1
- import { type MemoryDoc, type MemoryScope, type MemoryStoreDescriptor, type MemoryTarget } from '../memory-resolver.js';
2
- import { type DeletedHistoryResolution, type HistoryRecord } from './history.js';
3
- import { type PrivacyLevel } from '../substrate/schema.js';
4
- export { createDoc, deleteDoc, moveDoc, updateDoc, type CreateDocInput, type DeleteDocInput, type MoveDocInput, type UpdateDocInput, } from './mutations.js';
5
- export interface MemoryServiceSelection {
6
- /** Resolution identity is always supplied by the caller; this service never uses ambient process state. */
7
- target: MemoryTarget;
8
- /** Restrict a target view to one source tier. Ignored when an exact store is supplied. */
9
- scope?: MemoryScope;
10
- /** An exact store already selected by the CLI or API boundary. */
11
- store?: MemoryStoreDescriptor | null;
12
- }
13
- export interface MemoryCandidateLocation {
14
- winner: boolean;
15
- scope: MemoryScope;
16
- store_root: string;
17
- physical_relative_path: string;
18
- path: string;
19
- }
20
- export declare function candidateLocation(doc: MemoryDoc, winner: MemoryDoc): MemoryCandidateLocation;
21
- /** Refuse an exact project store that normal resolution would not mount. */
22
- export declare function requireMountedStore(store: MemoryStoreDescriptor): MemoryStoreDescriptor;
23
- /** Normalize and validate the public canonical memory address. */
24
- export declare function requireCanonicalName(rawName: string): string;
25
- /** Return the name local to an exact store, rejecting a name outside its namespace. */
26
- export declare function requireLocalNameInStore(store: MemoryStoreDescriptor, rawName: string): string;
27
- /** Resolution precedence rank used for stable inventory ordering. */
28
- export declare function memoryScopeRank(scope: MemoryScope): number;
29
- export interface ListedMemoryDoc {
30
- name: string;
31
- kind: string;
32
- privacy: PrivacyLevel;
33
- scope: MemoryScope;
34
- path: string;
35
- storeRoot: string;
36
- physicalRelativePath: string;
37
- shortForm: string;
38
- slash: boolean;
39
- extensions: Record<string, Record<string, string | boolean | number>>;
40
- candidates: readonly MemoryDoc[];
41
- }
42
- /** Stable key used by inventory ordering and cursor resumption. */
43
- export declare function memoryListKey(doc: Pick<ListedMemoryDoc, 'scope' | 'kind' | 'name' | 'physicalRelativePath'>): string;
44
- /** Locale-aware total order for memory inventory keys. */
45
- export declare function compareMemoryListKeys(left: string, right: string): number;
46
- /** List the selected corpus. Target views deduplicate canonical names; exact stores retain physical collisions. */
47
- export declare function listDocs(selection: MemoryServiceSelection & {
48
- kind?: string;
49
- }): ListedMemoryDoc[];
50
- export interface MemorySearchPath {
51
- path: string;
52
- store_root: string;
53
- physical_relative_path: string;
54
- candidates?: readonly MemoryCandidateLocation[];
55
- }
56
- export interface MemoryRankedSearchHit extends MemorySearchPath {
57
- name: string;
58
- kind: string;
59
- privacy: PrivacyLevel;
60
- scope: MemoryScope;
61
- score: number;
62
- short_form: string;
63
- }
64
- export interface MemoryGrepSearchHit extends MemorySearchPath {
65
- name: string;
66
- privacy: PrivacyLevel;
67
- scope: MemoryScope;
68
- line: number;
69
- text: string;
70
- }
71
- export type MemorySearchResult = {
72
- mode: 'ranked';
73
- matches: number;
74
- hits: readonly MemoryRankedSearchHit[];
75
- } | {
76
- mode: 'grep';
77
- matches: number;
78
- hits: readonly MemoryGrepSearchHit[];
79
- };
80
- export interface SearchDocsInput extends MemoryServiceSelection {
81
- query: string;
82
- kind?: string;
83
- grep?: boolean;
84
- body?: boolean;
85
- minScore?: number;
86
- }
87
- /** Search the selected corpus using either ranked relevance or body-line regex matching. */
88
- export declare function searchDocs(input: SearchDocsInput): MemorySearchResult;
89
- export interface ReadDocInput extends MemoryServiceSelection {
90
- name: string;
91
- kind?: string;
92
- frontmatter?: boolean;
93
- interpolateNodePaths?: boolean;
94
- grantee?: string;
95
- }
96
- export type ReadDocResult = {
97
- kind: 'document';
98
- doc: MemoryDoc;
99
- candidates: readonly MemoryDoc[];
100
- content: string;
101
- links: readonly string[];
102
- listingByName: ReadonlyMap<string, MemoryDoc>;
103
- } | {
104
- kind: 'directory';
105
- name: string;
106
- listingByName: ReadonlyMap<string, MemoryDoc>;
107
- };
108
- /** Resolve a document or directory and return unexpanded source plus listing/link data. */
109
- export declare function readDoc(input: ReadDocInput): ReadDocResult;
110
- export interface HistoryRevision {
111
- revision: number;
112
- op: HistoryRecord['op'];
113
- at: string;
114
- node?: string;
115
- rationale?: string;
116
- verbatim?: true;
117
- body_changed: boolean;
118
- frontmatter_changed: string[];
119
- diff?: string;
120
- }
121
- export type ReadHistoryResult = {
122
- name: string;
123
- scope: MemoryScope;
124
- logPath: string;
125
- deleted?: DeletedHistoryResolution;
126
- total: number;
127
- record: {
128
- revision: number;
129
- } & HistoryRecord;
130
- } | {
131
- name: string;
132
- scope: MemoryScope;
133
- logPath: string;
134
- deleted?: DeletedHistoryResolution;
135
- total: number;
136
- revisions: readonly HistoryRevision[];
137
- };
138
- export interface ReadHistoryInput extends MemoryServiceSelection {
139
- name: string;
140
- limit: number;
141
- diff?: boolean;
142
- revision?: number;
143
- }
144
- /** Read one complete revision or a newest-first history summary from the selected corpus. */
145
- export declare function readHistory(input: ReadHistoryInput): ReadHistoryResult;
@@ -1,2 +0,0 @@
1
- var P=Object.defineProperty;var l=(e,n)=>P(e,"name",{value:n,configurable:!0});import{readFileBeneath as v}from"../spaces/open-beneath.js";import{notFound as w,usage as d}from"../errors.js";import{interpolateNodePaths as L}from"../canvas/paths.js";import{loadMemoryStoreView as q,loadMemoryTargetView as x,memoryStoresInPrecedence as M}from"../memory-resolver.js";import{canonicalSegments as k,stripNamespace as b,validateExplicitLocalName as F}from"./identity.js";import{memoryExtensionEffectiveCatalog as j,projectEffectiveMemoryExtensions as E}from"./extensions.js";import{historyLogPathForDoc as I,readHistoryRecords as B,resolveDeletedHistoryLogPath as K,summarizeChange as z,unifiedDiff as A}from"./history.js";import{docsByName as $,isDirName as S}from"../substrate/listings.js";import{effectivePrivacy as H,parseSubstrateDoc as _}from"../substrate/schema.js";import{literalBodySegment as T,serializeMemoryDocLiteral as V}from"./mutation-domain.js";import{createDoc as ue,deleteDoc as pe,moveDoc as ye,updateDoc as ge}from"./mutations.js";function O(e,n){return{winner:e===n,scope:e.scope,store_root:e.root,physical_relative_path:e.physicalRelativePath,path:e.path}}l(O,"candidateLocation");function y(e){if(e.scope!=="project"||e.mountStatus==="ready")return e;const n=e.ownerDir??e.storeRoot;if(e.mountStatus==="absent")throw d(`no memory store at ${e.storeRoot}`,{next:`Initialize it with \`crtr memory write <namespace> --dir ${n}\`, which declares the repository namespace.`});const a=e.repositoryRoot??n;throw d(e.diagnostic??`project memory store at ${e.storeRoot} does not declare a namespace`,{next:`Run \`crtr sys migrate --dir ${a}\`.`})}l(y,"requireMountedStore");function R(e){const n=k(e.trim()).join("/");if(n==="")throw d("memory document name required");const a=F(n);if(!a.ok)throw d(`invalid memory document name \`${e}\`: ${a.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 n}l(R,"requireCanonicalName");function U(e,n){y(e);const a=R(n);if(e.namespace==="")return a;const s=b(a,e.namespace);if(s===null)throw d(`\`${a}\` is not in the namespace of the store at ${e.storeRoot} (\`${e.namespace}\`)`,{memory:a,next:`Every document there answers at \`${e.namespace}/<local name>\`; the store's own document answers at \`${e.namespace}\`.`});return s}l(U,"requireLocalNameInStore");function W(e){return e==="node"?-1:e==="project"?0:e==="profile"?1:e==="user"?2:3}l(W,"memoryScopeRank");function g(e){return e.store!=null?q(y(e.store),!0,e.target):x(e.target,{...e.scope===void 0?{}:{scope:e.scope},includeDescendants:!0,quiet:!0,reportDiscovery:!1})}l(g,"selectedView");function N(e){return g(e).docs}l(N,"selectedDocs");function C(e){return`${String(W(e.scope)+10).padStart(2,"0")}:${e.kind}:${e.name}:${e.physicalRelativePath}`}l(C,"memoryListKey");function G(e,n){const[a,s,i,...o]=e.split(":"),[r,t,c,...h]=n.split(":"),f=Number(a)-Number(r);if(f!==0)return f;const m=s.localeCompare(t);if(m!==0)return m;const u=i.localeCompare(c);return u!==0?u:o.join(":").localeCompare(h.join(":"))}l(G,"compareMemoryListKeys");function ce(e){const n=N(e),a=e.store==null,s=new Map;for(const r of n){const t=s.get(r.name);t!==void 0?t.push(r):s.set(r.name,[r])}const i=new Set,o=[];for(const r of n){const t=_(r);if(!(t===null||e.kind!==void 0&&t.kind!==e.kind)){if(a){if(i.has(t.name))continue;i.add(t.name)}o.push({name:t.name,kind:t.kind,privacy:t.privacy,scope:t.scope,path:t.path,storeRoot:r.root,physicalRelativePath:r.physicalRelativePath,shortForm:t.shortForm,slash:t.slash,extensions:E(r.frontmatter?.extensions,j(r)),candidates:s.get(r.name)??[r]})}}return o.sort((r,t)=>G(C(r),C(t))),o}l(ce,"listDocs");function J(e){const n=N(e),a=e.store==null,s=new Map;for(const r of n){const t=s.get(r.name);t!==void 0?t.push(r):s.set(r.name,[r])}const i=new Set,o=[];for(const r of n){const t=_(r);if(!(t===null||e.kind!==void 0&&t.kind!==e.kind)){if(a){if(i.has(t.name))continue;i.add(t.name)}o.push({name:t.name,localName:r.localName,kind:t.kind,privacy:t.privacy,scope:t.scope,path:t.path,store_root:r.root,physical_relative_path:r.physicalRelativePath,routing:t.whenAndWhyToRead,shortForm:t.shortForm,candidates:s.get(r.name)??[r],body:t.body})}}return o}l(J,"searchUnits");function D(e){return{path:e.path,store_root:e.store_root,physical_relative_path:e.physical_relative_path,...e.candidates.length>1?{candidates:e.candidates.map(n=>O(n,e.candidates[0]))}:{}}}l(D,"searchPath");function me(e){if(e.grep===!0&&e.body===!0)throw d("--grep and --body are mutually exclusive (--grep always scans bodies).");if(e.grep===!0&&e.minScore!==void 0)throw d("--min-score is only available in ranked mode.");if(e.minScore!==void 0&&e.minScore<1)throw d("--min-score must be at least 1.");const n=J(e);if(e.grep===!0){let o;try{o=new RegExp(e.query)}catch{throw d(`invalid regex pattern: ${e.query}`)}const r=[];for(const t of n)t.body.split(`
2
- `).forEach((c,h)=>{o.test(c)&&r.push({name:t.name,privacy:t.privacy,scope:t.scope,line:h+1,text:c,...D(t)})});return r.sort((t,c)=>{const h=t.name.localeCompare(c.name);if(h!==0)return h;const f=t.scope.localeCompare(c.scope);if(f!==0)return f;const m=t.physical_relative_path.localeCompare(c.physical_relative_path);return m!==0?m:t.line-c.line}),{mode:"grep",matches:r.length,hits:r}}const a=e.query.toLowerCase().split(/\s+/).filter(o=>o.length>0);if(a.length===0)throw d("query must contain at least one non-whitespace term");const s=[];for(const o of n){const r=o.name.toLowerCase(),t=o.localName.toLowerCase(),c=o.physical_relative_path.toLowerCase(),h=o.routing.toLowerCase(),f=o.shortForm.toLowerCase(),m=e.body===!0?o.body.toLowerCase():null;let u=0;for(const p of a)(r.includes(p)||t.includes(p)||c.includes(p))&&(u+=10),h.includes(p)&&(u+=5),f.includes(p)&&(u+=3),m!==null&&m.includes(p)&&(u+=1);u>0&&s.push({unit:o,score:u})}s.sort((o,r)=>{if(r.score!==o.score)return r.score-o.score;const t=o.unit.scope.localeCompare(r.unit.scope);if(t!==0)return t;const c=o.unit.name.localeCompare(r.unit.name);return c!==0?c:o.unit.physical_relative_path.localeCompare(r.unit.physical_relative_path)});const i=e.minScore??(s.length===0?1:Math.max(1,Math.ceil(s[0].score/2)));return{mode:"ranked",matches:s.length,hits:s.filter(o=>o.score>=i).map(({unit:o,score:r})=>({name:o.name,kind:o.kind,privacy:o.privacy,scope:o.scope,score:r,short_form:o.shortForm,...D(o)}))}}l(me,"searchDocs");function le(e){const n=g(e),a=e.kind===void 0?{}:{kind:e.kind},s=n.candidates(e.name,a),i=$(n.docs);if(s===null){const m=k(e.name.trim()).join("/");if(m!==""&&S(i,m))return{kind:"directory",name:m,listingByName:i};n.resolve(e.name,a)}const o=s,r=e.store==null?i:$([...n.docs,...x(e.target,{includeDescendants:!0,quiet:!0,reportDiscovery:!1}).docs]),t=o.winner,c=e.frontmatter===!0?t.frontmatter!==null&&!("privacy"in t.frontmatter)?V({...t.frontmatter,privacy:H(t.frontmatter)},T(v(t.root,t.path).toString("utf8"))):v(t.root,t.path).toString("utf8"):t.body,h=e.interpolateNodePaths===!1||e.target.nodeId===null?c:L(c,e.target.nodeId,e.grantee??e.target.grantee),f=[...o.winner.body.matchAll(/\[\[([^\]]+)\]\]/g)].map(m=>m[1].trim()).filter(m=>r.has(m)||S(r,m));return{kind:"document",doc:o.winner,candidates:o.candidates,content:h,links:f,listingByName:i}}l(le,"readDoc");function Q(e){const a=g(e).candidates(e.name);if(a!==null){const o=a.winner;if(o.plugin!==void 0)throw d(`${o.name} belongs to the installed plugin "${o.plugin}" \u2014 a read-only corpus with no revision history.`,{memory:o.name,plugin:o.plugin});if(o.scope==="builtin")throw d(`${o.name} is a builtin document shipped with the package \u2014 a read-only corpus with no revision history.`,{memory:o.name,scope:"builtin"});return{name:o.name,scope:o.scope,root:o.root,logPath:I(o)}}const s=R(e.name),i=e.store!=null?[y(e.store)]:M(e.target,e.scope,!0,!1).filter(o=>o.mountStatus==="ready"&&o.scope!=="builtin"&&o.plugin===void 0);for(const o of i){if(o.namespace!==""&&b(s,o.namespace)===null||e.target.allowsStore?.(o,s)===!1)continue;const r=U(o,s),t=K(o.storeRoot,r);if(t!==null)return{name:s,scope:o.scope,root:o.storeRoot,logPath:t.logPath,deleted:t}}throw w(`no memory document or revision history found: ${e.name}`,{memory:e.name,next:"Run `crtr memory find <query>` to locate the document. A document that exists but has no history predates this surface or has never been mutated through it."})}l(Q,"historyLocation");function de(e){const n=Q(e),a=B(n.root,n.logPath);if(a.length===0)throw w(`no revision history recorded for ${n.name}`,{memory:n.name,next:"The document predates this surface or has never been mutated through `crtr memory write`/`edit`/`delete`. Its first edit records the pre-existing content in full."});if(e.revision!==void 0){if(e.revision<1||e.revision>a.length)throw d(`revision ${e.revision} is out of range for ${n.name} (1..${a.length})`,{memory:n.name,next:`Run \`crtr memory history ${n.name}\` to see which revisions exist.`});return{...n,total:a.length,record:{revision:e.revision,...a[e.revision-1]}}}const s=a.map((i,o)=>{const r=z(i.before,i.after);return{revision:o+1,op:i.op,at:i.at,...i.node===void 0?{}:{node:i.node},...i.rationale===void 0?{}:{rationale:i.rationale},...i.verbatim===!0?{verbatim:!0}:{},...r,...e.diff===!0?{diff:A(i.before,i.after)}:{}}}).reverse().slice(0,Math.max(0,e.limit));return{...n,total:a.length,revisions:s}}l(de,"readHistory");export{O as candidateLocation,G as compareMemoryListKeys,ue as createDoc,pe as deleteDoc,ce as listDocs,C as memoryListKey,W as memoryScopeRank,ye as moveDoc,le as readDoc,de as readHistory,R as requireCanonicalName,U as requireLocalNameInStore,y as requireMountedStore,me as searchDocs,ge as updateDoc};
@@ -1,39 +0,0 @@
1
- import type { MemoryDoc } from '../memory-resolver.js';
2
- /** One canonical directory row: its own document (when it has one) plus its
3
- * immediate members. */
4
- export interface MemoryTreeNode {
5
- /** Exact canonical identity. `''` is the corpus root, which holds no
6
- * document — every store's documents merge beneath it. */
7
- name: string;
8
- /** Sort key among siblings: the stored physical path segment, `NN-` ordering
9
- * prefix retained, or this node's canonical segment when no physical
10
- * segment aligns. */
11
- order: string;
12
- /** The winning document attached to this row, or null for a directory that
13
- * carries none. */
14
- document: MemoryDoc | null;
15
- /** Every physical document sharing this identity, in source order. */
16
- documentCandidates: readonly MemoryDoc[];
17
- /** Immediate children that have members of their own, ordered. Each may also
18
- * carry its own `document`. */
19
- childDirectories: readonly MemoryTreeNode[];
20
- /** Immediate childless members, ordered. A node's own document never appears
21
- * among its children. */
22
- childDocuments: readonly MemoryTreeDocumentNode[];
23
- }
24
- /** A childless node: it exists only because a document landed on it. */
25
- export interface MemoryTreeDocumentNode extends MemoryTreeNode {
26
- document: MemoryDoc;
27
- }
28
- export interface MemoryTree {
29
- root: MemoryTreeNode;
30
- /** The node at an exact canonical name, or null when nothing lives there. */
31
- node(name: string): MemoryTreeNode | null;
32
- /** Does this canonical name have members? True for the corpus root when the
33
- * corpus is non-empty. */
34
- isDirectory(name: string): boolean;
35
- }
36
- /** Merge a precedence-ordered corpus into the canonical tree. Documents sharing
37
- * one identity stay in source order behind that node, so its `document` is the
38
- * address winner. */
39
- export declare function buildMemoryTree(docs: readonly MemoryDoc[]): MemoryTree;
@@ -1 +0,0 @@
1
- var g=Object.defineProperty;var s=(e,n)=>g(e,"name",{value:n,configurable:!0});import{canonicalSegments as a,normalizeNameSegment as y}from"./identity.js";function w(e){const n=a(e.name),o=a(e.physicalRelativePath.replace(/\.md$/i,""));e.representation==="directory-index"&&o.pop();const i=[];for(let c=n.length-1,r=o.length-1;c>=0&&r>=0;c--,r--){const t=o[r];if(y(t)!==n[c])break;i.push([n.slice(0,c+1).join("/"),t])}return i}s(w,"physicalOrderSegments");function f(e){return e.childDirectories.length>0||e.childDocuments.length>0}s(f,"hasMembers");function D(e,n){return e.order.localeCompare(n.order)||e.name.localeCompare(n.name)}s(D,"compareNodes");function M(e){if(e.document===null)throw new Error(`memory tree: ${e.name} has neither a document nor members`);return e}s(M,"asDocumentNode");function p(e,n,o){const i=[...e.children.values()].map(t=>p(t,n,o)).sort(D),c=a(e.name),r={name:e.name,order:n.get(e.name)??c[c.length-1]??"",document:e.documents[0]??null,documentCandidates:e.documents,childDirectories:i.filter(f),childDocuments:i.filter(t=>!f(t)).map(M)};return o.set(r.name,r),r}s(p,"finalize");function b(e){const n={name:"",documents:[],children:new Map},o=new Map;for(const t of e){const l=a(t.name);if(l.length===0)continue;let u=n;for(let m=0;m<l.length;m++){const d=l[m];let h=u.children.get(d);h===void 0&&(h={name:l.slice(0,m+1).join("/"),documents:[],children:new Map},u.children.set(d,h)),u=h}u.documents.push(t);for(const[m,d]of w(t))o.has(m)||o.set(m,d)}const i=new Map,c=p(n,o,i),r=s(t=>i.get(a(t).join("/"))??null,"lookup");return{root:c,node:r,isDirectory:s(t=>{const l=r(t);return l!==null&&f(l)},"isDirectory")}}s(b,"buildMemoryTree");export{b as buildMemoryTree};