@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,87 +0,0 @@
1
- import type { MemoryDoc } from '../memory-resolver.js';
2
- /** Sidecar tree name under a store's `memory/` dir. Dot-prefixed and holding
3
- * only `.jsonl`, so every substrate scan (which filters to `*.md`, and in
4
- * `lint`'s case skips dot-dirs outright) passes it over without an exclusion
5
- * rule of its own. */
6
- export declare const HISTORY_DIR = ".history";
7
- /** File operations only — deliberately not a review lifecycle. */
8
- export type HistoryOp = 'create' | 'edit' | 'delete' | 'move';
9
- export interface HistoryActor {
10
- cwd: string;
11
- node?: string;
12
- }
13
- export interface HistoryRecord {
14
- op: HistoryOp;
15
- at: string;
16
- /** Authoring node id; absent for a human at a bare CLI. */
17
- node?: string;
18
- cwd: string;
19
- /** The canonical name this document answered to before a `move`; absent otherwise. */
20
- from?: string;
21
- /** Why this revision happened. Required on `edit`, absent otherwise. */
22
- rationale?: string;
23
- /** True when the body was declared a verbatim payload from the principal. */
24
- verbatim?: boolean;
25
- /** Complete document text before the mutation; empty for `create`. */
26
- before: string;
27
- /** Complete document text after the mutation; empty for `delete`. */
28
- after: string;
29
- }
30
- /** The log path for a document, derived from its PHYSICAL path so the history
31
- * tree mirrors the doc tree exactly (`memory/area/topic.md` →
32
- * `memory/.history/area/topic.jsonl`). `memoryRoot` is the store's `memory/`
33
- * dir the doc lives under. */
34
- export declare function historyLogPathFor(memoryRoot: string, docPath: string): string;
35
- /** Stamp the runtime-owned fields of a record. Field insertion order IS the
36
- * serialized key order — the on-disk shape consumers read. */
37
- export declare function buildHistoryRecord(input: {
38
- op: HistoryOp;
39
- actor?: HistoryActor;
40
- from?: string;
41
- rationale?: string;
42
- verbatim?: boolean;
43
- before: string;
44
- after: string;
45
- }): HistoryRecord;
46
- /** Derive a live document's sidecar from its descriptor. The descriptor's
47
- * physical path is authoritative: canonical names carry a project namespace,
48
- * while sidecars remain in the owning store's physical tree. */
49
- export declare function historyLogPathForDoc(doc: Pick<MemoryDoc, 'root' | 'path'>): string;
50
- export interface DeletedHistoryCandidate {
51
- path: string;
52
- representation: 'directory-index' | 'leaf-file';
53
- winner: boolean;
54
- }
55
- export interface DeletedHistoryResolution {
56
- logPath: string;
57
- candidates: readonly DeletedHistoryCandidate[];
58
- collision?: {
59
- paths: readonly string[];
60
- winner: string;
61
- };
62
- }
63
- /** Resolve a deleted document's physical history without reintroducing a
64
- * canonical-name fallback. `localName` is already stripped of the selected
65
- * project's exact namespace. The directory-index sidecar is deliberately
66
- * probed first, and therefore wins deterministically if both physical forms
67
- * survive; callers can expose `candidates`/`collision` for diagnostics. */
68
- export declare function resolveDeletedHistoryLogPath(storeRoot: string, localName: string): DeletedHistoryResolution | null;
69
- /** Append one record. Single write of one line — concurrent appends interleave
70
- * whole records, and every record stands alone, so no lock is needed. */
71
- /** Append beneath `root`, the store root the log mirrors. */
72
- export declare function appendHistoryRecord(root: string, logPath: string, record: HistoryRecord): void;
73
- /** Every record in a log beneath `root` (the store root it mirrors), oldest
74
- * first (append order). Revision numbers are 1-based positions in this array. */
75
- export declare function readHistoryRecords(root: string, logPath: string): HistoryRecord[];
76
- export interface ChangeSummary {
77
- body_changed: boolean;
78
- /** Frontmatter field names whose values differ between the two texts. */
79
- frontmatter_changed: string[];
80
- }
81
- /** What one record changed, derived from its own two texts. `last-updated` is
82
- * excluded: the runtime stamps it on every edit, so listing it says nothing. */
83
- export declare function summarizeChange(before: string, after: string): ChangeSummary;
84
- /** Unified diff between two document texts, computed at read time. Dependency
85
- * free (an LCS over lines) — memory docs are lint-capped small, so the
86
- * quadratic table is never a cost. */
87
- export declare function unifiedDiff(before: string, after: string, context?: number): string;
@@ -1,6 +0,0 @@
1
- var M=Object.defineProperty;var l=(t,o)=>M(t,"name",{value:o,configurable:!0});import{readdirSync as j}from"node:fs";import{join as x,relative as _}from"node:path";import{appendFileBeneath as A,readTextBeneathIfExists as T}from"../spaces/open-beneath.js";import{envNodeCwd as H,envNodeId as J}from"../../shared/env.js";import{general as D}from"../errors.js";import{parseFrontmatterGeneric as $}from"../frontmatter.js";import{normalizeNameSegment as N}from"./identity.js";const F=".history";function R(t,o){const e=_(t,o);if(e===""||e.startsWith(".."))throw D(`memory document ${o} is not inside its store root ${t}`);return x(t,F,e.replace(/\.md$/i,"")+".jsonl")}l(R,"historyLogPathFor");function Z(t){const o=J(),e=t.actor??{cwd:H()??process.cwd(),...o===void 0?{}:{node:o}};return{op:t.op,at:new Date().toISOString(),...e.node!==void 0?{node:e.node}:{},cwd:e.cwd,...t.from!==void 0?{from:t.from}:{},...t.rationale!==void 0?{rationale:t.rationale}:{},...t.verbatim===!0?{verbatim:!0}:{},before:t.before,after:t.after}}l(Z,"buildHistoryRecord");function tt(t){return R(t.root,t.path)}l(tt,"historyLogPathForDoc");function W(t,o){let e;try{e=j(t,{withFileTypes:!0})}catch{return[]}return e.filter(n=>n.isDirectory()&&N(n.name)===o).sort((n,i)=>n.name===o?-1:i.name===o?1:n.name.localeCompare(i.name)).map(n=>x(t,n.name))}l(W,"matchingDirs");function P(t,o){let e;try{e=j(t,{withFileTypes:!0})}catch{return[]}return e.filter(n=>n.isFile()&&n.name.endsWith(".jsonl")&&N(n.name.slice(0,-6))===o).sort((n,i)=>n.name===`${o}.jsonl`?-1:i.name===`${o}.jsonl`?1:n.name.localeCompare(i.name)).map(n=>x(t,n.name))}l(P,"matchingFiles");function I(t,o,e){let n=[t];for(const i of o)if(n=n.flatMap(a=>W(a,i)),n.length===0)return[];return n.flatMap(i=>P(i,e))}l(I,"historyFilesForSegments");function et(t,o){const e=o.split("/").filter(s=>s!=="").map(N),n=x(t,F),i=I(n,e,"INDEX"),a=e.length===0?[]:I(n,e.slice(0,-1),e[e.length-1]),r=[...i.map(s=>({path:s,representation:"directory-index",winner:!1})),...a.map(s=>({path:s,representation:"leaf-file",winner:!1}))];return r.length===0?null:(r[0].winner=!0,{logPath:r[0].path,candidates:r,...r.length>1?{collision:{paths:r.map(s=>s.path),winner:r[0].path}}:{}})}l(et,"resolveDeletedHistoryLogPath");function nt(t,o,e){A(t,o,JSON.stringify(e)+`
2
- `)}l(nt,"appendHistoryRecord");function ot(t,o){const e=T(t,o);if(e===null)return[];const n=e.split(`
3
- `),i=[];for(let a=0;a<n.length;a+=1){const r=n[a];if(r.trim()!=="")try{i.push(JSON.parse(r))}catch{throw D(`corrupt history record at ${o}:${a+1} \u2014 the line is not valid JSON`,{next:"Inspect that line directly; the surrounding records are self-contained and still readable."})}}return i}l(ot,"readHistoryRecords");function rt(t,o){const e=$(t),n=$(o),i=e.data??{},a=n.data??{},r=new Set([...Object.keys(i),...Object.keys(a)]);r.delete("last-updated");const s=[...r].filter(c=>JSON.stringify(i[c])!==JSON.stringify(a[c])).sort((c,f)=>c.localeCompare(f));return{body_changed:e.body!==n.body,frontmatter_changed:s}}l(rt,"summarizeChange");function it(t,o,e=3){const{lines:n,terminated:i}=L(t),{lines:a,terminated:r}=L(o),s=k(E(n,i),E(a,r)),c=[];for(let d=0;d<s.length;d+=1){if(s[d].tag===" ")continue;const p=Math.max(0,d-e),g=Math.min(s.length,d+e+1),u=c[c.length-1];u!==void 0&&p<=u.to?u.to=Math.max(u.to,g):c.push({from:p,to:g})}if(c.length===0)return"";const f=[],w=[];let b=0,O=0;for(const d of s)f.push(b),w.push(O),d.tag!=="+"&&(b+=1),d.tag!=="-"&&(O+=1);const y=[];for(const{from:d,to:p}of c){const g=s.slice(d,p),u=g.filter(h=>h.tag!=="+").length,S=g.filter(h=>h.tag!=="-").length;y.push(`@@ -${u===0?0:f[d]+1},${u} +${S===0?0:w[d]+1},${S} @@`);for(let h=d;h<p;h+=1){const m=s[h];y.push(m.tag+(m.tag==="+"?a[m.index]:n[m.index]));const v=m.tag!=="+"&&!i&&f[h]===n.length-1,C=m.tag!=="-"&&!r&&w[h]===a.length-1;(v||C)&&y.push(B)}}return y.join(`
4
- `)}l(it,"unifiedDiff");const B="\",K="\0no-newline-at-eof";function E(t,o){return o||t.length===0?t:t.map((e,n)=>n===t.length-1?e+K:e)}l(E,"diffKeys");function L(t){if(t==="")return{lines:[],terminated:!0};const o=t.endsWith(`
5
- `),e=t.split(`
6
- `);return o&&e.pop(),{lines:e,terminated:o}}l(L,"toLines");function k(t,o){const e=t.length,n=o.length,i=Array.from({length:e+1},()=>new Array(n+1).fill(0));for(let c=e-1;c>=0;c-=1)for(let f=n-1;f>=0;f-=1)i[c][f]=t[c]===o[f]?i[c+1][f+1]+1:Math.max(i[c+1][f],i[c][f+1]);const a=[];let r=0,s=0;for(;r<e&&s<n;)t[r]===o[s]?(a.push({tag:" ",index:r}),r+=1,s+=1):i[r+1][s]>=i[r][s+1]?(a.push({tag:"-",index:r}),r+=1):(a.push({tag:"+",index:s}),s+=1);for(;r<e;r+=1)a.push({tag:"-",index:r});for(;s<n;s+=1)a.push({tag:"+",index:s});return a}l(k,"diffOps");export{F as HISTORY_DIR,nt as appendHistoryRecord,Z as buildHistoryRecord,R as historyLogPathFor,tt as historyLogPathForDoc,ot as readHistoryRecords,et as resolveDeletedHistoryLogPath,rt as summarizeChange,it as unifiedDiff};
@@ -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};