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.
- package/LICENSE +21 -0
- package/README.md +284 -0
- package/dist/cli/config.d.ts +28 -0
- package/dist/cli/config.js +48 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/exit-codes.d.ts +13 -0
- package/dist/cli/exit-codes.js +39 -0
- package/dist/cli/exit-codes.js.map +1 -0
- package/dist/cli/format.d.ts +22 -0
- package/dist/cli/format.js +148 -0
- package/dist/cli/format.js.map +1 -0
- package/dist/cli/main.d.ts +16 -0
- package/dist/cli/main.js +1518 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/client/kernel-client.d.ts +97 -0
- package/dist/client/kernel-client.js +14 -0
- package/dist/client/kernel-client.js.map +1 -0
- package/dist/client/local.d.ts +26 -0
- package/dist/client/local.js +103 -0
- package/dist/client/local.js.map +1 -0
- package/dist/client/remote-mcp.d.ts +35 -0
- package/dist/client/remote-mcp.js +174 -0
- package/dist/client/remote-mcp.js.map +1 -0
- package/dist/embed/backfill.d.ts +24 -0
- package/dist/embed/backfill.js +33 -0
- package/dist/embed/backfill.js.map +1 -0
- package/dist/embed/chunker.d.ts +31 -0
- package/dist/embed/chunker.js +121 -0
- package/dist/embed/chunker.js.map +1 -0
- package/dist/embed/cmd-hook.d.ts +21 -0
- package/dist/embed/cmd-hook.js +100 -0
- package/dist/embed/cmd-hook.js.map +1 -0
- package/dist/embed/config.d.ts +61 -0
- package/dist/embed/config.js +109 -0
- package/dist/embed/config.js.map +1 -0
- package/dist/embed/hook.d.ts +38 -0
- package/dist/embed/hook.js +56 -0
- package/dist/embed/hook.js.map +1 -0
- package/dist/embed/http-hook.d.ts +13 -0
- package/dist/embed/http-hook.js +39 -0
- package/dist/embed/http-hook.js.map +1 -0
- package/dist/embed/worker.d.ts +62 -0
- package/dist/embed/worker.js +228 -0
- package/dist/embed/worker.js.map +1 -0
- package/dist/fixtures/hwe/characters/albion-ever.md +12 -0
- package/dist/fixtures/hwe/characters/cent.md +11 -0
- package/dist/fixtures/hwe/concepts/cent-demiurge-resonance.md +10 -0
- package/dist/fixtures/hwe/concepts/phase-looper.md +10 -0
- package/dist/fixtures/hwe/entities/demiurge.md +11 -0
- package/dist/fixtures/hwe/entities/monad.md +11 -0
- package/dist/fixtures/hwe/moc/globocorp-network.md +19 -0
- package/dist/fixtures/hwe/organizations/globocorp.md +11 -0
- package/dist/fixtures/hwe/readme.md +24 -0
- package/dist/fixtures/starship/crew/aria-okonkwo.md +14 -0
- package/dist/fixtures/starship/crew/bexley-orr.md +14 -0
- package/dist/fixtures/starship/crew/dax-thorne.md +14 -0
- package/dist/fixtures/starship/crew/isolde-marsh.md +16 -0
- package/dist/fixtures/starship/crew/kestrel-vance.md +15 -0
- package/dist/fixtures/starship/crew/quill-vasquez.md +14 -0
- package/dist/fixtures/starship/crew/soren-halloway.md +16 -0
- package/dist/fixtures/starship/encounters/the-drift-choir.md +14 -0
- package/dist/fixtures/starship/encounters/the-hollow-signal.md +16 -0
- package/dist/fixtures/starship/encounters/the-wandering-buoy.md +14 -0
- package/dist/fixtures/starship/equipment/coolant-loop-b.md +13 -0
- package/dist/fixtures/starship/equipment/emergency-ration-bars.md +12 -0
- package/dist/fixtures/starship/equipment/long-range-sensors.md +13 -0
- package/dist/fixtures/starship/equipment/plasma-manifold-3.md +15 -0
- package/dist/fixtures/starship/equipment/shuttle-corvid.md +13 -0
- package/dist/fixtures/starship/logs/marsh-4419-1.md +13 -0
- package/dist/fixtures/starship/logs/okonkwo-4415-1.md +13 -0
- package/dist/fixtures/starship/logs/orr-4413-1.md +13 -0
- package/dist/fixtures/starship/logs/orr-4420-1.md +12 -0
- package/dist/fixtures/starship/logs/thorne-4413-2.md +13 -0
- package/dist/fixtures/starship/logs/vance-4419-2.md +13 -0
- package/dist/fixtures/starship/misc/the-galley-ficus.md +11 -0
- package/dist/fixtures/starship/missions/the-cinder-run.md +17 -0
- package/dist/fixtures/starship/missions/the-drift-choir.md +17 -0
- package/dist/fixtures/starship/missions/the-hollow-signal.md +17 -0
- package/dist/fixtures/starship/missions/the-silent-beacon.md +17 -0
- package/dist/fixtures/starship/moc/crew.md +19 -0
- package/dist/fixtures/starship/moc/encounters.md +14 -0
- package/dist/fixtures/starship/moc/missions.md +15 -0
- package/dist/fixtures/starship/readme.md +60 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/auth/glob.d.ts +46 -0
- package/dist/kernel/auth/glob.js +112 -0
- package/dist/kernel/auth/glob.js.map +1 -0
- package/dist/kernel/auth/scope.d.ts +53 -0
- package/dist/kernel/auth/scope.js +83 -0
- package/dist/kernel/auth/scope.js.map +1 -0
- package/dist/kernel/casefold.d.ts +37 -0
- package/dist/kernel/casefold.js +44 -0
- package/dist/kernel/casefold.js.map +1 -0
- package/dist/kernel/constants.d.ts +21 -0
- package/dist/kernel/constants.js +22 -0
- package/dist/kernel/constants.js.map +1 -0
- package/dist/kernel/context.d.ts +70 -0
- package/dist/kernel/context.js +114 -0
- package/dist/kernel/context.js.map +1 -0
- package/dist/kernel/deletion.d.ts +50 -0
- package/dist/kernel/deletion.js +83 -0
- package/dist/kernel/deletion.js.map +1 -0
- package/dist/kernel/diff.d.ts +36 -0
- package/dist/kernel/diff.js +61 -0
- package/dist/kernel/diff.js.map +1 -0
- package/dist/kernel/errors.d.ts +37 -0
- package/dist/kernel/errors.js +55 -0
- package/dist/kernel/errors.js.map +1 -0
- package/dist/kernel/frontmatter-input.d.ts +32 -0
- package/dist/kernel/frontmatter-input.js +85 -0
- package/dist/kernel/frontmatter-input.js.map +1 -0
- package/dist/kernel/graph.d.ts +34 -0
- package/dist/kernel/graph.js +559 -0
- package/dist/kernel/graph.js.map +1 -0
- package/dist/kernel/history.d.ts +74 -0
- package/dist/kernel/history.js +143 -0
- package/dist/kernel/history.js.map +1 -0
- package/dist/kernel/kernel.d.ts +162 -0
- package/dist/kernel/kernel.js +675 -0
- package/dist/kernel/kernel.js.map +1 -0
- package/dist/kernel/path-config.d.ts +101 -0
- package/dist/kernel/path-config.js +171 -0
- package/dist/kernel/path-config.js.map +1 -0
- package/dist/kernel/query/ast.d.ts +24 -0
- package/dist/kernel/query/ast.js +52 -0
- package/dist/kernel/query/ast.js.map +1 -0
- package/dist/kernel/query/cel-parse.d.ts +37 -0
- package/dist/kernel/query/cel-parse.js +88 -0
- package/dist/kernel/query/cel-parse.js.map +1 -0
- package/dist/kernel/query/degrees.d.ts +31 -0
- package/dist/kernel/query/degrees.js +135 -0
- package/dist/kernel/query/degrees.js.map +1 -0
- package/dist/kernel/query/graph-ast.d.ts +51 -0
- package/dist/kernel/query/graph-ast.js +139 -0
- package/dist/kernel/query/graph-ast.js.map +1 -0
- package/dist/kernel/query/query.d.ts +56 -0
- package/dist/kernel/query/query.js +276 -0
- package/dist/kernel/query/query.js.map +1 -0
- package/dist/kernel/validation.d.ts +64 -0
- package/dist/kernel/validation.js +183 -0
- package/dist/kernel/validation.js.map +1 -0
- package/dist/kernel/version-id.d.ts +10 -0
- package/dist/kernel/version-id.js +21 -0
- package/dist/kernel/version-id.js.map +1 -0
- package/dist/kernel/wire.d.ts +148 -0
- package/dist/kernel/wire.js +6 -0
- package/dist/kernel/wire.js.map +1 -0
- package/dist/links/backfill.d.ts +28 -0
- package/dist/links/backfill.js +33 -0
- package/dist/links/backfill.js.map +1 -0
- package/dist/links/extract.d.ts +29 -0
- package/dist/links/extract.js +233 -0
- package/dist/links/extract.js.map +1 -0
- package/dist/links/link-config.d.ts +70 -0
- package/dist/links/link-config.js +107 -0
- package/dist/links/link-config.js.map +1 -0
- package/dist/links/maintain.d.ts +37 -0
- package/dist/links/maintain.js +91 -0
- package/dist/links/maintain.js.map +1 -0
- package/dist/links/repair.d.ts +46 -0
- package/dist/links/repair.js +96 -0
- package/dist/links/repair.js.map +1 -0
- package/dist/links/resolve.d.ts +41 -0
- package/dist/links/resolve.js +121 -0
- package/dist/links/resolve.js.map +1 -0
- package/dist/links/stale.d.ts +32 -0
- package/dist/links/stale.js +73 -0
- package/dist/links/stale.js.map +1 -0
- package/dist/markdown/content-hash.d.ts +34 -0
- package/dist/markdown/content-hash.js +46 -0
- package/dist/markdown/content-hash.js.map +1 -0
- package/dist/markdown/frontmatter.d.ts +69 -0
- package/dist/markdown/frontmatter.js +147 -0
- package/dist/markdown/frontmatter.js.map +1 -0
- package/dist/markdown/hash-backfill.d.ts +22 -0
- package/dist/markdown/hash-backfill.js +43 -0
- package/dist/markdown/hash-backfill.js.map +1 -0
- package/dist/mcp/query-syntax.d.ts +20 -0
- package/dist/mcp/query-syntax.js +194 -0
- package/dist/mcp/query-syntax.js.map +1 -0
- package/dist/mcp/render.d.ts +31 -0
- package/dist/mcp/render.js +110 -0
- package/dist/mcp/render.js.map +1 -0
- package/dist/mcp/server.d.ts +60 -0
- package/dist/mcp/server.js +170 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +93 -0
- package/dist/mcp/tools.js +1218 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/rest/conditional.d.ts +37 -0
- package/dist/rest/conditional.js +58 -0
- package/dist/rest/conditional.js.map +1 -0
- package/dist/rest/negotiate.d.ts +33 -0
- package/dist/rest/negotiate.js +54 -0
- package/dist/rest/negotiate.js.map +1 -0
- package/dist/rest/routes.d.ts +37 -0
- package/dist/rest/routes.js +744 -0
- package/dist/rest/routes.js.map +1 -0
- package/dist/seed/fixture-seed.d.ts +35 -0
- package/dist/seed/fixture-seed.js +75 -0
- package/dist/seed/fixture-seed.js.map +1 -0
- package/dist/seed/starship-config.d.ts +3 -0
- package/dist/seed/starship-config.js +5 -0
- package/dist/seed/starship-config.js.map +1 -0
- package/dist/server/headers.d.ts +36 -0
- package/dist/server/headers.js +30 -0
- package/dist/server/headers.js.map +1 -0
- package/dist/server/http-error.d.ts +53 -0
- package/dist/server/http-error.js +104 -0
- package/dist/server/http-error.js.map +1 -0
- package/dist/server/serve.d.ts +56 -0
- package/dist/server/serve.js +135 -0
- package/dist/server/serve.js.map +1 -0
- package/dist/shell/audit.d.ts +32 -0
- package/dist/shell/audit.js +28 -0
- package/dist/shell/audit.js.map +1 -0
- package/dist/shell/guard.d.ts +50 -0
- package/dist/shell/guard.js +176 -0
- package/dist/shell/guard.js.map +1 -0
- package/dist/shell/keys.d.ts +36 -0
- package/dist/shell/keys.js +64 -0
- package/dist/shell/keys.js.map +1 -0
- package/dist/shell/login.d.ts +56 -0
- package/dist/shell/login.js +130 -0
- package/dist/shell/login.js.map +1 -0
- package/dist/shell/oidc.d.ts +62 -0
- package/dist/shell/oidc.js +102 -0
- package/dist/shell/oidc.js.map +1 -0
- package/dist/shell/policy.d.ts +100 -0
- package/dist/shell/policy.js +232 -0
- package/dist/shell/policy.js.map +1 -0
- package/dist/shell/proxy-policy.d.ts +34 -0
- package/dist/shell/proxy-policy.js +120 -0
- package/dist/shell/proxy-policy.js.map +1 -0
- package/dist/shell/proxy.d.ts +47 -0
- package/dist/shell/proxy.js +253 -0
- package/dist/shell/proxy.js.map +1 -0
- package/dist/shell/serve.d.ts +86 -0
- package/dist/shell/serve.js +0 -0
- package/dist/shell/serve.js.map +1 -0
- package/dist/shell/stdio.d.ts +55 -0
- package/dist/shell/stdio.js +63 -0
- package/dist/shell/stdio.js.map +1 -0
- package/dist/storage/registry.d.ts +20 -0
- package/dist/storage/registry.js +38 -0
- package/dist/storage/registry.js.map +1 -0
- package/dist/storage/search-plan.d.ts +93 -0
- package/dist/storage/search-plan.js +15 -0
- package/dist/storage/search-plan.js.map +1 -0
- package/dist/storage/types.d.ts +448 -0
- package/dist/storage/types.js +14 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/storage/versions-since.d.ts +72 -0
- package/dist/storage/versions-since.js +92 -0
- package/dist/storage/versions-since.js.map +1 -0
- package/dist/storage-postgres/adapter.d.ts +17 -0
- package/dist/storage-postgres/adapter.js +782 -0
- package/dist/storage-postgres/adapter.js.map +1 -0
- package/dist/storage-postgres/compile-postgres.d.ts +22 -0
- package/dist/storage-postgres/compile-postgres.js +830 -0
- package/dist/storage-postgres/compile-postgres.js.map +1 -0
- package/dist/storage-postgres/errors.d.ts +34 -0
- package/dist/storage-postgres/errors.js +50 -0
- package/dist/storage-postgres/errors.js.map +1 -0
- package/dist/storage-postgres/migrations/0001_init.sql +113 -0
- package/dist/storage-postgres/migrations/0002_content_hash.sql +7 -0
- package/dist/storage-postgres/migrations/index.d.ts +22 -0
- package/dist/storage-postgres/migrations/index.js +70 -0
- package/dist/storage-postgres/migrations/index.js.map +1 -0
- package/dist/storage-sqlite/adapter.d.ts +2 -0
- package/dist/storage-sqlite/adapter.js +688 -0
- package/dist/storage-sqlite/adapter.js.map +1 -0
- package/dist/storage-sqlite/compile-filter.d.ts +41 -0
- package/dist/storage-sqlite/compile-filter.js +881 -0
- package/dist/storage-sqlite/compile-filter.js.map +1 -0
- package/dist/storage-sqlite/compile-sqlite.d.ts +19 -0
- package/dist/storage-sqlite/compile-sqlite.js +176 -0
- package/dist/storage-sqlite/compile-sqlite.js.map +1 -0
- package/dist/storage-sqlite/migrations/0001_init.sql +123 -0
- package/dist/storage-sqlite/migrations/0002_content_hash.sql +7 -0
- package/dist/storage-sqlite/migrations/index.d.ts +6 -0
- package/dist/storage-sqlite/migrations/index.js +41 -0
- package/dist/storage-sqlite/migrations/index.js.map +1 -0
- package/dist/storage-sqlite/vec.d.ts +40 -0
- package/dist/storage-sqlite/vec.js +62 -0
- package/dist/storage-sqlite/vec.js.map +1 -0
- package/dist/sync/cursor.d.ts +36 -0
- package/dist/sync/cursor.js +66 -0
- package/dist/sync/cursor.js.map +1 -0
- package/dist/sync/daemon.d.ts +40 -0
- package/dist/sync/daemon.js +202 -0
- package/dist/sync/daemon.js.map +1 -0
- package/dist/sync/feed.d.ts +38 -0
- package/dist/sync/feed.js +125 -0
- package/dist/sync/feed.js.map +1 -0
- package/dist/sync/fs-store.d.ts +8 -0
- package/dist/sync/fs-store.js +76 -0
- package/dist/sync/fs-store.js.map +1 -0
- package/dist/sync/intrinsics.d.ts +52 -0
- package/dist/sync/intrinsics.js +76 -0
- package/dist/sync/intrinsics.js.map +1 -0
- package/dist/sync/paths.d.ts +38 -0
- package/dist/sync/paths.js +56 -0
- package/dist/sync/paths.js.map +1 -0
- package/dist/sync/push.d.ts +48 -0
- package/dist/sync/push.js +328 -0
- package/dist/sync/push.js.map +1 -0
- package/dist/sync/reconcile.d.ts +54 -0
- package/dist/sync/reconcile.js +252 -0
- package/dist/sync/reconcile.js.map +1 -0
- package/dist/sync/run.d.ts +27 -0
- package/dist/sync/run.js +46 -0
- package/dist/sync/run.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- 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,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,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,CA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,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>;
|