mrplex 0.0.1

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 (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +284 -0
  3. package/dist/cli/config.d.ts +28 -0
  4. package/dist/cli/config.js +48 -0
  5. package/dist/cli/config.js.map +1 -0
  6. package/dist/cli/exit-codes.d.ts +13 -0
  7. package/dist/cli/exit-codes.js +39 -0
  8. package/dist/cli/exit-codes.js.map +1 -0
  9. package/dist/cli/format.d.ts +22 -0
  10. package/dist/cli/format.js +148 -0
  11. package/dist/cli/format.js.map +1 -0
  12. package/dist/cli/main.d.ts +16 -0
  13. package/dist/cli/main.js +1518 -0
  14. package/dist/cli/main.js.map +1 -0
  15. package/dist/client/kernel-client.d.ts +97 -0
  16. package/dist/client/kernel-client.js +14 -0
  17. package/dist/client/kernel-client.js.map +1 -0
  18. package/dist/client/local.d.ts +26 -0
  19. package/dist/client/local.js +103 -0
  20. package/dist/client/local.js.map +1 -0
  21. package/dist/client/remote-mcp.d.ts +35 -0
  22. package/dist/client/remote-mcp.js +174 -0
  23. package/dist/client/remote-mcp.js.map +1 -0
  24. package/dist/embed/backfill.d.ts +24 -0
  25. package/dist/embed/backfill.js +33 -0
  26. package/dist/embed/backfill.js.map +1 -0
  27. package/dist/embed/chunker.d.ts +31 -0
  28. package/dist/embed/chunker.js +121 -0
  29. package/dist/embed/chunker.js.map +1 -0
  30. package/dist/embed/cmd-hook.d.ts +21 -0
  31. package/dist/embed/cmd-hook.js +100 -0
  32. package/dist/embed/cmd-hook.js.map +1 -0
  33. package/dist/embed/config.d.ts +61 -0
  34. package/dist/embed/config.js +109 -0
  35. package/dist/embed/config.js.map +1 -0
  36. package/dist/embed/hook.d.ts +38 -0
  37. package/dist/embed/hook.js +56 -0
  38. package/dist/embed/hook.js.map +1 -0
  39. package/dist/embed/http-hook.d.ts +13 -0
  40. package/dist/embed/http-hook.js +39 -0
  41. package/dist/embed/http-hook.js.map +1 -0
  42. package/dist/embed/worker.d.ts +62 -0
  43. package/dist/embed/worker.js +228 -0
  44. package/dist/embed/worker.js.map +1 -0
  45. package/dist/fixtures/hwe/characters/albion-ever.md +12 -0
  46. package/dist/fixtures/hwe/characters/cent.md +11 -0
  47. package/dist/fixtures/hwe/concepts/cent-demiurge-resonance.md +10 -0
  48. package/dist/fixtures/hwe/concepts/phase-looper.md +10 -0
  49. package/dist/fixtures/hwe/entities/demiurge.md +11 -0
  50. package/dist/fixtures/hwe/entities/monad.md +11 -0
  51. package/dist/fixtures/hwe/moc/globocorp-network.md +19 -0
  52. package/dist/fixtures/hwe/organizations/globocorp.md +11 -0
  53. package/dist/fixtures/hwe/readme.md +24 -0
  54. package/dist/fixtures/starship/crew/aria-okonkwo.md +14 -0
  55. package/dist/fixtures/starship/crew/bexley-orr.md +14 -0
  56. package/dist/fixtures/starship/crew/dax-thorne.md +14 -0
  57. package/dist/fixtures/starship/crew/isolde-marsh.md +16 -0
  58. package/dist/fixtures/starship/crew/kestrel-vance.md +15 -0
  59. package/dist/fixtures/starship/crew/quill-vasquez.md +14 -0
  60. package/dist/fixtures/starship/crew/soren-halloway.md +16 -0
  61. package/dist/fixtures/starship/encounters/the-drift-choir.md +14 -0
  62. package/dist/fixtures/starship/encounters/the-hollow-signal.md +16 -0
  63. package/dist/fixtures/starship/encounters/the-wandering-buoy.md +14 -0
  64. package/dist/fixtures/starship/equipment/coolant-loop-b.md +13 -0
  65. package/dist/fixtures/starship/equipment/emergency-ration-bars.md +12 -0
  66. package/dist/fixtures/starship/equipment/long-range-sensors.md +13 -0
  67. package/dist/fixtures/starship/equipment/plasma-manifold-3.md +15 -0
  68. package/dist/fixtures/starship/equipment/shuttle-corvid.md +13 -0
  69. package/dist/fixtures/starship/logs/marsh-4419-1.md +13 -0
  70. package/dist/fixtures/starship/logs/okonkwo-4415-1.md +13 -0
  71. package/dist/fixtures/starship/logs/orr-4413-1.md +13 -0
  72. package/dist/fixtures/starship/logs/orr-4420-1.md +12 -0
  73. package/dist/fixtures/starship/logs/thorne-4413-2.md +13 -0
  74. package/dist/fixtures/starship/logs/vance-4419-2.md +13 -0
  75. package/dist/fixtures/starship/misc/the-galley-ficus.md +11 -0
  76. package/dist/fixtures/starship/missions/the-cinder-run.md +17 -0
  77. package/dist/fixtures/starship/missions/the-drift-choir.md +17 -0
  78. package/dist/fixtures/starship/missions/the-hollow-signal.md +17 -0
  79. package/dist/fixtures/starship/missions/the-silent-beacon.md +17 -0
  80. package/dist/fixtures/starship/moc/crew.md +19 -0
  81. package/dist/fixtures/starship/moc/encounters.md +14 -0
  82. package/dist/fixtures/starship/moc/missions.md +15 -0
  83. package/dist/fixtures/starship/readme.md +60 -0
  84. package/dist/index.d.ts +1 -0
  85. package/dist/index.js +3 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/kernel/auth/glob.d.ts +46 -0
  88. package/dist/kernel/auth/glob.js +112 -0
  89. package/dist/kernel/auth/glob.js.map +1 -0
  90. package/dist/kernel/auth/scope.d.ts +53 -0
  91. package/dist/kernel/auth/scope.js +83 -0
  92. package/dist/kernel/auth/scope.js.map +1 -0
  93. package/dist/kernel/casefold.d.ts +37 -0
  94. package/dist/kernel/casefold.js +44 -0
  95. package/dist/kernel/casefold.js.map +1 -0
  96. package/dist/kernel/constants.d.ts +21 -0
  97. package/dist/kernel/constants.js +22 -0
  98. package/dist/kernel/constants.js.map +1 -0
  99. package/dist/kernel/context.d.ts +70 -0
  100. package/dist/kernel/context.js +114 -0
  101. package/dist/kernel/context.js.map +1 -0
  102. package/dist/kernel/deletion.d.ts +50 -0
  103. package/dist/kernel/deletion.js +83 -0
  104. package/dist/kernel/deletion.js.map +1 -0
  105. package/dist/kernel/diff.d.ts +36 -0
  106. package/dist/kernel/diff.js +61 -0
  107. package/dist/kernel/diff.js.map +1 -0
  108. package/dist/kernel/errors.d.ts +37 -0
  109. package/dist/kernel/errors.js +55 -0
  110. package/dist/kernel/errors.js.map +1 -0
  111. package/dist/kernel/frontmatter-input.d.ts +32 -0
  112. package/dist/kernel/frontmatter-input.js +85 -0
  113. package/dist/kernel/frontmatter-input.js.map +1 -0
  114. package/dist/kernel/graph.d.ts +34 -0
  115. package/dist/kernel/graph.js +559 -0
  116. package/dist/kernel/graph.js.map +1 -0
  117. package/dist/kernel/history.d.ts +74 -0
  118. package/dist/kernel/history.js +143 -0
  119. package/dist/kernel/history.js.map +1 -0
  120. package/dist/kernel/kernel.d.ts +162 -0
  121. package/dist/kernel/kernel.js +675 -0
  122. package/dist/kernel/kernel.js.map +1 -0
  123. package/dist/kernel/path-config.d.ts +101 -0
  124. package/dist/kernel/path-config.js +171 -0
  125. package/dist/kernel/path-config.js.map +1 -0
  126. package/dist/kernel/query/ast.d.ts +24 -0
  127. package/dist/kernel/query/ast.js +52 -0
  128. package/dist/kernel/query/ast.js.map +1 -0
  129. package/dist/kernel/query/cel-parse.d.ts +37 -0
  130. package/dist/kernel/query/cel-parse.js +88 -0
  131. package/dist/kernel/query/cel-parse.js.map +1 -0
  132. package/dist/kernel/query/degrees.d.ts +31 -0
  133. package/dist/kernel/query/degrees.js +135 -0
  134. package/dist/kernel/query/degrees.js.map +1 -0
  135. package/dist/kernel/query/graph-ast.d.ts +51 -0
  136. package/dist/kernel/query/graph-ast.js +139 -0
  137. package/dist/kernel/query/graph-ast.js.map +1 -0
  138. package/dist/kernel/query/query.d.ts +56 -0
  139. package/dist/kernel/query/query.js +276 -0
  140. package/dist/kernel/query/query.js.map +1 -0
  141. package/dist/kernel/validation.d.ts +64 -0
  142. package/dist/kernel/validation.js +183 -0
  143. package/dist/kernel/validation.js.map +1 -0
  144. package/dist/kernel/version-id.d.ts +10 -0
  145. package/dist/kernel/version-id.js +21 -0
  146. package/dist/kernel/version-id.js.map +1 -0
  147. package/dist/kernel/wire.d.ts +148 -0
  148. package/dist/kernel/wire.js +6 -0
  149. package/dist/kernel/wire.js.map +1 -0
  150. package/dist/links/backfill.d.ts +28 -0
  151. package/dist/links/backfill.js +33 -0
  152. package/dist/links/backfill.js.map +1 -0
  153. package/dist/links/extract.d.ts +29 -0
  154. package/dist/links/extract.js +233 -0
  155. package/dist/links/extract.js.map +1 -0
  156. package/dist/links/link-config.d.ts +70 -0
  157. package/dist/links/link-config.js +107 -0
  158. package/dist/links/link-config.js.map +1 -0
  159. package/dist/links/maintain.d.ts +37 -0
  160. package/dist/links/maintain.js +91 -0
  161. package/dist/links/maintain.js.map +1 -0
  162. package/dist/links/repair.d.ts +46 -0
  163. package/dist/links/repair.js +96 -0
  164. package/dist/links/repair.js.map +1 -0
  165. package/dist/links/resolve.d.ts +41 -0
  166. package/dist/links/resolve.js +121 -0
  167. package/dist/links/resolve.js.map +1 -0
  168. package/dist/links/stale.d.ts +32 -0
  169. package/dist/links/stale.js +73 -0
  170. package/dist/links/stale.js.map +1 -0
  171. package/dist/markdown/content-hash.d.ts +34 -0
  172. package/dist/markdown/content-hash.js +46 -0
  173. package/dist/markdown/content-hash.js.map +1 -0
  174. package/dist/markdown/frontmatter.d.ts +69 -0
  175. package/dist/markdown/frontmatter.js +147 -0
  176. package/dist/markdown/frontmatter.js.map +1 -0
  177. package/dist/markdown/hash-backfill.d.ts +22 -0
  178. package/dist/markdown/hash-backfill.js +43 -0
  179. package/dist/markdown/hash-backfill.js.map +1 -0
  180. package/dist/mcp/query-syntax.d.ts +20 -0
  181. package/dist/mcp/query-syntax.js +194 -0
  182. package/dist/mcp/query-syntax.js.map +1 -0
  183. package/dist/mcp/render.d.ts +31 -0
  184. package/dist/mcp/render.js +110 -0
  185. package/dist/mcp/render.js.map +1 -0
  186. package/dist/mcp/server.d.ts +60 -0
  187. package/dist/mcp/server.js +170 -0
  188. package/dist/mcp/server.js.map +1 -0
  189. package/dist/mcp/tools.d.ts +93 -0
  190. package/dist/mcp/tools.js +1218 -0
  191. package/dist/mcp/tools.js.map +1 -0
  192. package/dist/rest/conditional.d.ts +37 -0
  193. package/dist/rest/conditional.js +58 -0
  194. package/dist/rest/conditional.js.map +1 -0
  195. package/dist/rest/negotiate.d.ts +33 -0
  196. package/dist/rest/negotiate.js +54 -0
  197. package/dist/rest/negotiate.js.map +1 -0
  198. package/dist/rest/routes.d.ts +37 -0
  199. package/dist/rest/routes.js +744 -0
  200. package/dist/rest/routes.js.map +1 -0
  201. package/dist/seed/fixture-seed.d.ts +35 -0
  202. package/dist/seed/fixture-seed.js +75 -0
  203. package/dist/seed/fixture-seed.js.map +1 -0
  204. package/dist/seed/starship-config.d.ts +3 -0
  205. package/dist/seed/starship-config.js +5 -0
  206. package/dist/seed/starship-config.js.map +1 -0
  207. package/dist/server/headers.d.ts +36 -0
  208. package/dist/server/headers.js +30 -0
  209. package/dist/server/headers.js.map +1 -0
  210. package/dist/server/http-error.d.ts +53 -0
  211. package/dist/server/http-error.js +104 -0
  212. package/dist/server/http-error.js.map +1 -0
  213. package/dist/server/serve.d.ts +56 -0
  214. package/dist/server/serve.js +135 -0
  215. package/dist/server/serve.js.map +1 -0
  216. package/dist/shell/audit.d.ts +32 -0
  217. package/dist/shell/audit.js +28 -0
  218. package/dist/shell/audit.js.map +1 -0
  219. package/dist/shell/guard.d.ts +50 -0
  220. package/dist/shell/guard.js +176 -0
  221. package/dist/shell/guard.js.map +1 -0
  222. package/dist/shell/keys.d.ts +36 -0
  223. package/dist/shell/keys.js +64 -0
  224. package/dist/shell/keys.js.map +1 -0
  225. package/dist/shell/login.d.ts +56 -0
  226. package/dist/shell/login.js +130 -0
  227. package/dist/shell/login.js.map +1 -0
  228. package/dist/shell/oidc.d.ts +62 -0
  229. package/dist/shell/oidc.js +102 -0
  230. package/dist/shell/oidc.js.map +1 -0
  231. package/dist/shell/policy.d.ts +100 -0
  232. package/dist/shell/policy.js +232 -0
  233. package/dist/shell/policy.js.map +1 -0
  234. package/dist/shell/proxy-policy.d.ts +34 -0
  235. package/dist/shell/proxy-policy.js +120 -0
  236. package/dist/shell/proxy-policy.js.map +1 -0
  237. package/dist/shell/proxy.d.ts +47 -0
  238. package/dist/shell/proxy.js +253 -0
  239. package/dist/shell/proxy.js.map +1 -0
  240. package/dist/shell/serve.d.ts +86 -0
  241. package/dist/shell/serve.js +0 -0
  242. package/dist/shell/serve.js.map +1 -0
  243. package/dist/shell/stdio.d.ts +55 -0
  244. package/dist/shell/stdio.js +63 -0
  245. package/dist/shell/stdio.js.map +1 -0
  246. package/dist/storage/registry.d.ts +20 -0
  247. package/dist/storage/registry.js +38 -0
  248. package/dist/storage/registry.js.map +1 -0
  249. package/dist/storage/search-plan.d.ts +93 -0
  250. package/dist/storage/search-plan.js +15 -0
  251. package/dist/storage/search-plan.js.map +1 -0
  252. package/dist/storage/types.d.ts +448 -0
  253. package/dist/storage/types.js +14 -0
  254. package/dist/storage/types.js.map +1 -0
  255. package/dist/storage/versions-since.d.ts +72 -0
  256. package/dist/storage/versions-since.js +92 -0
  257. package/dist/storage/versions-since.js.map +1 -0
  258. package/dist/storage-postgres/adapter.d.ts +17 -0
  259. package/dist/storage-postgres/adapter.js +782 -0
  260. package/dist/storage-postgres/adapter.js.map +1 -0
  261. package/dist/storage-postgres/compile-postgres.d.ts +22 -0
  262. package/dist/storage-postgres/compile-postgres.js +830 -0
  263. package/dist/storage-postgres/compile-postgres.js.map +1 -0
  264. package/dist/storage-postgres/errors.d.ts +34 -0
  265. package/dist/storage-postgres/errors.js +50 -0
  266. package/dist/storage-postgres/errors.js.map +1 -0
  267. package/dist/storage-postgres/migrations/0001_init.sql +113 -0
  268. package/dist/storage-postgres/migrations/0002_content_hash.sql +7 -0
  269. package/dist/storage-postgres/migrations/index.d.ts +22 -0
  270. package/dist/storage-postgres/migrations/index.js +70 -0
  271. package/dist/storage-postgres/migrations/index.js.map +1 -0
  272. package/dist/storage-sqlite/adapter.d.ts +2 -0
  273. package/dist/storage-sqlite/adapter.js +688 -0
  274. package/dist/storage-sqlite/adapter.js.map +1 -0
  275. package/dist/storage-sqlite/compile-filter.d.ts +41 -0
  276. package/dist/storage-sqlite/compile-filter.js +881 -0
  277. package/dist/storage-sqlite/compile-filter.js.map +1 -0
  278. package/dist/storage-sqlite/compile-sqlite.d.ts +19 -0
  279. package/dist/storage-sqlite/compile-sqlite.js +176 -0
  280. package/dist/storage-sqlite/compile-sqlite.js.map +1 -0
  281. package/dist/storage-sqlite/migrations/0001_init.sql +123 -0
  282. package/dist/storage-sqlite/migrations/0002_content_hash.sql +7 -0
  283. package/dist/storage-sqlite/migrations/index.d.ts +6 -0
  284. package/dist/storage-sqlite/migrations/index.js +41 -0
  285. package/dist/storage-sqlite/migrations/index.js.map +1 -0
  286. package/dist/storage-sqlite/vec.d.ts +40 -0
  287. package/dist/storage-sqlite/vec.js +62 -0
  288. package/dist/storage-sqlite/vec.js.map +1 -0
  289. package/dist/sync/cursor.d.ts +36 -0
  290. package/dist/sync/cursor.js +66 -0
  291. package/dist/sync/cursor.js.map +1 -0
  292. package/dist/sync/daemon.d.ts +40 -0
  293. package/dist/sync/daemon.js +202 -0
  294. package/dist/sync/daemon.js.map +1 -0
  295. package/dist/sync/feed.d.ts +38 -0
  296. package/dist/sync/feed.js +125 -0
  297. package/dist/sync/feed.js.map +1 -0
  298. package/dist/sync/fs-store.d.ts +8 -0
  299. package/dist/sync/fs-store.js +76 -0
  300. package/dist/sync/fs-store.js.map +1 -0
  301. package/dist/sync/intrinsics.d.ts +52 -0
  302. package/dist/sync/intrinsics.js +76 -0
  303. package/dist/sync/intrinsics.js.map +1 -0
  304. package/dist/sync/paths.d.ts +38 -0
  305. package/dist/sync/paths.js +56 -0
  306. package/dist/sync/paths.js.map +1 -0
  307. package/dist/sync/push.d.ts +48 -0
  308. package/dist/sync/push.js +328 -0
  309. package/dist/sync/push.js.map +1 -0
  310. package/dist/sync/reconcile.d.ts +54 -0
  311. package/dist/sync/reconcile.js +252 -0
  312. package/dist/sync/reconcile.js.map +1 -0
  313. package/dist/sync/run.d.ts +27 -0
  314. package/dist/sync/run.js +46 -0
  315. package/dist/sync/run.js.map +1 -0
  316. package/dist/version.d.ts +2 -0
  317. package/dist/version.js +5 -0
  318. package/dist/version.js.map +1 -0
  319. package/package.json +80 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Kernel error catalog. Every kernel-emitted error has a stable `code` and
3
+ * a JSON-serializable `data` payload — design §4.3.
4
+ *
5
+ * M0 surfaces only the read-time subset; writes and auth land in M1.
6
+ */
7
+ export class KernelError extends Error {
8
+ code;
9
+ data;
10
+ constructor(code, data, message) {
11
+ super(message ?? code);
12
+ this.code = code;
13
+ this.data = data;
14
+ this.name = "KernelError";
15
+ }
16
+ }
17
+ /**
18
+ * Runtime set matching KernelErrorCode. Used by the remote MCP client to
19
+ * validate an incoming `code` string before rehydrating a KernelError —
20
+ * otherwise a rogue server could inject unknown codes and break clients
21
+ * that switch exhaustively.
22
+ */
23
+ export const KERNEL_ERROR_CODES = new Set([
24
+ "repo_not_found",
25
+ "doc_not_found",
26
+ "version_not_found",
27
+ "version_not_in_document",
28
+ "slug_invalid",
29
+ "path_invalid",
30
+ "frontmatter_invalid",
31
+ "filter_invalid",
32
+ "link_config_invalid",
33
+ "stale_prev",
34
+ "create_conflict",
35
+ "path_taken",
36
+ "slug_taken",
37
+ "forbidden",
38
+ "precondition_required",
39
+ "payload_too_large",
40
+ "semantic_unavailable",
41
+ ]);
42
+ /** Type guard — check whether an arbitrary string is a known catalog code. */
43
+ export function isKernelErrorCode(code) {
44
+ return KERNEL_ERROR_CODES.has(code);
45
+ }
46
+ export const repoNotFound = (slug) => new KernelError("repo_not_found", { slug });
47
+ export const docNotFound = (repo, path) => new KernelError("doc_not_found", { repo, path });
48
+ export const versionNotFound = (versionId) => new KernelError("version_not_found", { version_id: versionId });
49
+ export const versionNotInDocument = (versionId, repo, path) => new KernelError("version_not_in_document", { version_id: versionId, repo, path });
50
+ // `forbidden` (§8.4): the scope claim supplied with this call excludes the
51
+ // target. Still HTTP 403; still omits resource details so out-of-claim and
52
+ // nonexistent look identical (shells can hand mrplex errors to their untrusted
53
+ // callers unfiltered). `unauthorized` is gone — the engine trusts every caller.
54
+ export const forbidden = () => new KernelError("forbidden", {});
55
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/kernel/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6BH,MAAM,OAAO,WAAyC,SAAQ,KAAK;IAE/C;IACA;IAFlB,YACkB,IAAqB,EACrB,IAAO,EACvB,OAAgB;QAEhB,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;QAJP,SAAI,GAAJ,IAAI,CAAiB;QACrB,SAAI,GAAJ,IAAI,CAAG;QAIvB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiC,IAAI,GAAG,CAAkB;IACvF,gBAAgB;IAChB,eAAe;IACf,mBAAmB;IACnB,yBAAyB;IACzB,cAAc;IACd,cAAc;IACd,qBAAqB;IACrB,gBAAgB;IAChB,qBAAqB;IACrB,YAAY;IACZ,iBAAiB;IACjB,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,uBAAuB;IACvB,mBAAmB;IACnB,sBAAsB;CACvB,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAuB,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAE1F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CACxD,IAAI,WAAW,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAE,EAAE,CACnD,IAAI,WAAW,CAAC,mBAAmB,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAiB,EAAE,IAAY,EAAE,IAAY,EAAE,EAAE,CACpF,IAAI,WAAW,CAAC,yBAAyB,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAEpF,2EAA2E;AAC3E,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Canonicalize the two frontmatter input forms into the pair stored on
3
+ * `versions`. Design §3.2:
4
+ *
5
+ * Writes supply exactly ONE of:
6
+ * • frontmatter_raw — verbatim YAML source; parsed → JSON for the index
7
+ * • frontmatter — structured JSON; serialized → canonical YAML
8
+ * The other is derived. Supplying both → `frontmatter_invalid`.
9
+ *
10
+ * On read, the raw form is what `Accept: text/markdown` returns — so a
11
+ * write via `frontmatter_raw` round-trips byte-exact. A write via
12
+ * `frontmatter` (structured) does NOT preserve comments/key order from any
13
+ * prior version; the caller opted into that by choosing the structured form.
14
+ */
15
+ import { type FrontmatterJson } from "../markdown/frontmatter.js";
16
+ export type FrontmatterInput = {
17
+ frontmatter?: FrontmatterJson;
18
+ frontmatter_raw?: string;
19
+ };
20
+ export type CanonicalFrontmatter = {
21
+ frontmatter: FrontmatterJson;
22
+ frontmatter_raw: string;
23
+ };
24
+ /**
25
+ * Take a write's frontmatter input and produce the canonical (raw, parsed)
26
+ * pair. Enforces the §3.2 "exactly one" rule and surfaces YAML errors as
27
+ * `frontmatter_invalid`.
28
+ *
29
+ * If neither is supplied, throws `frontmatter_invalid` (callers that want
30
+ * "carry over from prev" should pass prev's frontmatter_raw explicitly).
31
+ */
32
+ export declare function canonicalizeFrontmatter(input: FrontmatterInput): CanonicalFrontmatter;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Canonicalize the two frontmatter input forms into the pair stored on
3
+ * `versions`. Design §3.2:
4
+ *
5
+ * Writes supply exactly ONE of:
6
+ * • frontmatter_raw — verbatim YAML source; parsed → JSON for the index
7
+ * • frontmatter — structured JSON; serialized → canonical YAML
8
+ * The other is derived. Supplying both → `frontmatter_invalid`.
9
+ *
10
+ * On read, the raw form is what `Accept: text/markdown` returns — so a
11
+ * write via `frontmatter_raw` round-trips byte-exact. A write via
12
+ * `frontmatter` (structured) does NOT preserve comments/key order from any
13
+ * prior version; the caller opted into that by choosing the structured form.
14
+ */
15
+ import { stringify as stringifyYaml } from "yaml";
16
+ import { extractSystemProperties, parse as parseFrontmatter, } from "../markdown/frontmatter.js";
17
+ import { INTRINSIC_SIGIL } from "./constants.js";
18
+ import { KernelError } from "./errors.js";
19
+ /**
20
+ * Take a write's frontmatter input and produce the canonical (raw, parsed)
21
+ * pair. Enforces the §3.2 "exactly one" rule and surfaces YAML errors as
22
+ * `frontmatter_invalid`.
23
+ *
24
+ * If neither is supplied, throws `frontmatter_invalid` (callers that want
25
+ * "carry over from prev" should pass prev's frontmatter_raw explicitly).
26
+ */
27
+ export function canonicalizeFrontmatter(input) {
28
+ const hasRaw = input.frontmatter_raw !== undefined;
29
+ const hasStruct = input.frontmatter !== undefined;
30
+ if (hasRaw && hasStruct) {
31
+ throw new KernelError("frontmatter_invalid", {
32
+ reason: "supply exactly one of frontmatter | frontmatter_raw, not both",
33
+ });
34
+ }
35
+ if (!hasRaw && !hasStruct) {
36
+ throw new KernelError("frontmatter_invalid", {
37
+ reason: "one of frontmatter | frontmatter_raw is required",
38
+ });
39
+ }
40
+ if (hasRaw) {
41
+ // Strip system properties (`$*`) before parsing/storing. Surfaces that
42
+ // support the $version round-trip already peel it off; this is
43
+ // belt-and-braces so no surface can accidentally poison storage with
44
+ // reserved keys.
45
+ const raw = stripSystemProps(input.frontmatter_raw);
46
+ try {
47
+ const parsed = parseFrontmatter(raw);
48
+ return { frontmatter: parsed, frontmatter_raw: raw };
49
+ }
50
+ catch (err) {
51
+ throw new KernelError("frontmatter_invalid", {
52
+ reason: err.message,
53
+ });
54
+ }
55
+ }
56
+ // Structured branch — serialize to canonical YAML.
57
+ const structuredInput = input.frontmatter;
58
+ if (structuredInput === null ||
59
+ typeof structuredInput !== "object" ||
60
+ Array.isArray(structuredInput)) {
61
+ throw new KernelError("frontmatter_invalid", {
62
+ reason: "structured frontmatter must be a map",
63
+ });
64
+ }
65
+ const structured = stripSystemKeys(structuredInput);
66
+ // Empty map → empty raw (round-trips as "no frontmatter block" via the
67
+ // markdown/frontmatter.split rule).
68
+ if (Object.keys(structured).length === 0) {
69
+ return { frontmatter: structured, frontmatter_raw: "" };
70
+ }
71
+ const rawFromStructured = stringifyYaml(structured);
72
+ return { frontmatter: structured, frontmatter_raw: rawFromStructured };
73
+ }
74
+ function stripSystemProps(raw) {
75
+ return extractSystemProperties(raw).raw;
76
+ }
77
+ function stripSystemKeys(obj) {
78
+ const out = {};
79
+ for (const [k, v] of Object.entries(obj)) {
80
+ if (!k.startsWith(INTRINSIC_SIGIL))
81
+ out[k] = v;
82
+ }
83
+ return out;
84
+ }
85
+ //# sourceMappingURL=frontmatter-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter-input.js","sourceRoot":"","sources":["../../src/kernel/frontmatter-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EAEL,uBAAuB,EACvB,KAAK,IAAI,gBAAgB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAY1C;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAuB;IAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,KAAK,SAAS,CAAC;IACnD,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC;IAElD,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE;YAC3C,MAAM,EAAE,+DAA+D;SACxE,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE;YAC3C,MAAM,EAAE,kDAAkD;SAC3D,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,uEAAuE;QACvE,+DAA+D;QAC/D,qEAAqE;QACrE,iBAAiB;QACjB,MAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,eAAyB,CAAC,CAAC;QAC9D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACrC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC;QACvD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE;gBAC3C,MAAM,EAAG,GAAa,CAAC,OAAO;aAC/B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,MAAM,eAAe,GAAG,KAAK,CAAC,WAA8B,CAAC;IAC7D,IACE,eAAe,KAAK,IAAI;QACxB,OAAO,eAAe,KAAK,QAAQ;QACnC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAC9B,CAAC;QACD,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE;YAC3C,MAAM,EAAE,sCAAsC;SAC/C,CAAC,CAAC;IACL,CAAC;IACD,MAAM,UAAU,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC;IACpD,uEAAuE;IACvE,oCAAoC;IACpC,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;IAC1D,CAAC;IACD,MAAM,iBAAiB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IACpD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AACzE,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAW;IACnC,OAAO,uBAAuB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;AAC1C,CAAC;AAED,SAAS,eAAe,CAAC,GAAoB;IAC3C,MAAM,GAAG,GAAoB,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * kernel.graph — the graph read surface (docs/graph-plan.md).
3
+ *
4
+ * A read-only BFS neighborhood expansion over the repo-local `links` derived
5
+ * index. Given a root set, expand outward under a direction lens, honoring
6
+ * scope and `filter` as *visibility* (traversal happens inside the visible
7
+ * subgraph), and return documents, distinct induced links, a behavioral
8
+ * frontier, and truncation metadata.
9
+ *
10
+ * The whole thing is expressed in the system's own vocabulary — documents and
11
+ * links — with no node/edge layer. See §5 for the pinned decisions.
12
+ *
13
+ * Visibility reuse: rather than re-implement scope/sigil/filter evaluation,
14
+ * every visibility check runs through the existing `versions_search` path via
15
+ * a `SearchPlan`. `$degrees` is bound per round by rewriting the parsed filter
16
+ * to an integer constant (degrees.ts), so both dialect compilers stay unaware
17
+ * of it. This is the "reuse the SearchPlan path" mandate of §4.3.
18
+ */
19
+ import type { Storage } from "../storage/types.js";
20
+ import { type ClaimMatcher } from "./auth/scope.js";
21
+ import { type PathConfig } from "./path-config.js";
22
+ import type { GraphResult, GraphSpec } from "./wire.js";
23
+ export declare const DEFAULT_DEGREES = 1;
24
+ export declare const MAX_DEGREES = 5;
25
+ export declare const DEFAULT_MAX_DOCUMENTS = 100;
26
+ export declare const HARD_MAX_DOCUMENTS = 500;
27
+ export declare const LINKS_CEILING = 5000;
28
+ export type GraphDeps = {
29
+ storage: Storage;
30
+ serverPathConfig: PathConfig;
31
+ /** Effective path config for the target repo (for exact root normalization). */
32
+ pathConfig: PathConfig;
33
+ };
34
+ export declare function runGraph(claims: ClaimMatcher[] | null, spec: GraphSpec, deps: GraphDeps): Promise<GraphResult>;