superbee 0.4.4-pre.7 → 0.4.4-pre.8

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.
@@ -7,4 +7,7 @@ export { PUBLICATION_BRIDGE_V0, PUBLICATION_SNAPSHOT_V1, type CapturePublication
7
7
  export type { CapturePublicationRuntimeOptions } from "./capture.js";
8
8
  export { assertPublicationSourceExclusions } from "./source-exclusions.js";
9
9
  export type { PublicationSourceInventory, PublicationSourceExclusions } from "./source-exclusions.js";
10
+ export { parseSiteManifestDoc, isSiteLabel, SITE_LABEL, SITE_TYPE, SITES_PREFIX, SITE_DOCUMENT_KEYS } from "./site-manifest-core.js";
11
+ export type { SiteManifest, SiteManifestError, SiteManifestParseResult, SitePresentationReference } from "./site-manifest-core.js";
12
+ export { readPublicationSiteManifest } from "./site-manifest.js";
10
13
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,49 @@
1
+ export declare const SITE_TYPE = "Site";
2
+ export declare const SITES_PREFIX = "sites/";
3
+ /** One site label leaves room for its workspace label in a combined DNS name. */
4
+ export declare const SITE_LABEL: RegExp;
5
+ export declare const isSiteLabel: (value: unknown) => value is string;
6
+ export declare const SITE_DOCUMENT_KEYS: readonly ["type", "title", "description", "presentation", "landing", "views", "audience", "capabilities", "options", "brand"];
7
+ export type SitePresentationReference = {
8
+ readonly kind: "package";
9
+ readonly name: string;
10
+ readonly version: string;
11
+ } | {
12
+ readonly kind: "repository";
13
+ readonly repository: string;
14
+ };
15
+ export interface SiteManifest {
16
+ readonly id: string;
17
+ readonly site: string;
18
+ readonly title: string;
19
+ readonly description?: string;
20
+ readonly presentation: SitePresentationReference;
21
+ readonly landing?: string;
22
+ readonly views: readonly string[];
23
+ readonly audience: "restricted";
24
+ readonly capabilities: readonly string[];
25
+ readonly options: Readonly<Record<string, unknown>>;
26
+ readonly brand?: {
27
+ readonly logo?: string;
28
+ readonly fonts?: readonly string[];
29
+ };
30
+ }
31
+ export interface SiteManifestError {
32
+ readonly code: "SITE_MANIFEST_INVALID";
33
+ readonly path: string;
34
+ readonly message: string;
35
+ }
36
+ export type SiteManifestParseResult = {
37
+ readonly ok: true;
38
+ readonly manifest: SiteManifest;
39
+ } | {
40
+ readonly ok: false;
41
+ readonly errors: readonly SiteManifestError[];
42
+ };
43
+ /** Standard OKF and managed metadata survive on the document; only Site fields enter this value.
44
+ * Presentation owners validate option semantics. Builders separately admit trusted resolved code. */
45
+ export declare function parseSiteManifestDoc(doc: {
46
+ readonly id: string;
47
+ readonly frontmatter: Readonly<Record<string, unknown>>;
48
+ }): SiteManifestParseResult;
49
+ //# sourceMappingURL=site-manifest.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Portable declaration surface, with no filesystem capture or credential handling. */
2
+ export { parseSiteManifestDoc, isSiteLabel, SITE_LABEL, SITE_TYPE, SITES_PREFIX, SITE_DOCUMENT_KEYS } from "./site-manifest-core.js";
3
+ export type { SiteManifest, SiteManifestError, SiteManifestParseResult, SitePresentationReference } from "./site-manifest-core.js";
4
+ export { readPublicationSiteManifest } from "./site-manifest.js";
5
+ //# sourceMappingURL=site-manifest-entry.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { type SiteManifestParseResult } from "./site-manifest-core.js";
2
+ import type { PublicationSnapshotV1 } from "./types.js";
3
+ /** Resolve only declarations and references in the frozen publication. This never resolves code. */
4
+ export declare function readPublicationSiteManifest(snapshot: Pick<PublicationSnapshotV1, "documents" | "views" | "blobs">, site: string): SiteManifestParseResult;
5
+ //# sourceMappingURL=site-manifest.d.ts.map
@@ -0,0 +1,212 @@
1
+ // ../core/src/errors.ts
2
+ var InvalidInputError = class extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "InvalidInputError";
6
+ }
7
+ };
8
+
9
+ // ../core/src/paths.ts
10
+ function assertPortablePath(value, label) {
11
+ if (/[\u0000-\u001f\u007f]/u.test(value) || /^[a-z]:/i.test(value)) {
12
+ throw new InvalidInputError(`${label} must not contain controls or start with a drive prefix.`);
13
+ }
14
+ if (value.includes("\\") || value.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
15
+ throw new InvalidInputError(`${label} must be canonical and bundle-relative.`);
16
+ }
17
+ }
18
+ function assertSafeConceptId(id) {
19
+ if (typeof id !== "string" || id.trim() === "") {
20
+ throw new InvalidInputError("Concept id must be a non-empty string.");
21
+ }
22
+ assertPortablePath(id, "Concept id");
23
+ const segments = id.split("/");
24
+ if (segments.slice(0, -1).some((seg) => seg.toLowerCase().endsWith(".md"))) {
25
+ throw new InvalidInputError(
26
+ `Concept id must not contain a non-final segment ending in '.md': '${id}' (it collides with a concept file at that path).`
27
+ );
28
+ }
29
+ }
30
+ var FORMAT_AT_EDGE = /^\p{Cf}|\p{Cf}$/u;
31
+ var FORMAT_INSIDE = /(?![\u200c\u200d])\p{Cf}/u;
32
+ function nonCanonicalDocumentId(id) {
33
+ const segments = id.split("/");
34
+ if (segments.some((segment) => segment !== segment.trim())) return "segment_whitespace";
35
+ if (segments.some((segment) => FORMAT_AT_EDGE.test(segment) || FORMAT_INSIDE.test(segment))) return "format_character";
36
+ if (id !== id.normalize("NFC")) return "not_nfc";
37
+ return null;
38
+ }
39
+ function assertSafeBlobKey(key) {
40
+ if (typeof key !== "string" || key.trim() === "") {
41
+ throw new InvalidInputError("Blob key must be a non-empty string.");
42
+ }
43
+ assertPortablePath(key, "Blob key");
44
+ const segments = key.split("/");
45
+ if (segments.some((seg) => seg.startsWith("."))) {
46
+ throw new InvalidInputError(`Blob key must not contain dot-prefixed segments: '${key}'.`);
47
+ }
48
+ if (segments.some((seg) => seg.toLowerCase().endsWith(".md"))) {
49
+ throw new InvalidInputError(
50
+ `Blob key '${key}' has a path segment ending in '.md' (checked case-insensitively, at any depth), which collides with the concept-document namespace \u2014 write it as a doc instead.`
51
+ );
52
+ }
53
+ }
54
+
55
+ // ../core/src/json-data.ts
56
+ function isJsonData(value, depth = 0) {
57
+ if (depth > 32) return false;
58
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
59
+ if (typeof value === "number") return Number.isFinite(value);
60
+ if (Array.isArray(value)) return value.every((item) => isJsonData(item, depth + 1));
61
+ if (value === null || typeof value !== "object") return false;
62
+ const proto = Object.getPrototypeOf(value);
63
+ if (proto !== null && Object.getPrototypeOf(proto) !== null) return false;
64
+ return Object.values(value).every((item) => item !== void 0 && isJsonData(item, depth + 1));
65
+ }
66
+
67
+ // ../core/src/okf-standard-fields.ts
68
+ var OKF_STANDARD_FIELD_NAMES = ["type", "title", "description", "resource", "tags", "status", "sources", "generated", "verified", "stale_after", "usage_window", "runtime", "computation", "parameters", "executor", "attester", "okf_version"];
69
+ function isOkfStandardField(field) {
70
+ return OKF_STANDARD_FIELD_NAMES.includes(field);
71
+ }
72
+
73
+ // ../core/src/managed-document-metadata.ts
74
+ var MANAGED_DOCUMENT_METADATA_FIELDS = /* @__PURE__ */ new Set([
75
+ "generated",
76
+ "verified",
77
+ "superbee_updated_by",
78
+ "actor",
79
+ "timestamp"
80
+ ]);
81
+ function isManagedDocumentMetadataField(field) {
82
+ return MANAGED_DOCUMENT_METADATA_FIELDS.has(field);
83
+ }
84
+
85
+ // ../core/src/site-manifest.ts
86
+ var SITE_TYPE = "Site";
87
+ var SITES_PREFIX = "sites/";
88
+ var SITE_LABEL = /^[a-z][a-z0-9-]{1,30}[a-z0-9]$/;
89
+ var isSiteLabel = (value) => typeof value === "string" && SITE_LABEL.test(value) && !value.includes("--");
90
+ var SITE_DOCUMENT_KEYS = ["type", "title", "description", "presentation", "landing", "views", "audience", "capabilities", "options", "brand"];
91
+ var record = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
92
+ var packageName = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
93
+ var exactVersion = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
94
+ var encoder = new TextEncoder();
95
+ function presentationReference(raw) {
96
+ if (typeof raw !== "string" || raw.length > 512) return void 0;
97
+ if (raw.startsWith("repo:")) {
98
+ const repository = raw.slice(5);
99
+ return /^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(repository) && !repository.endsWith(".git") ? { kind: "repository", repository } : void 0;
100
+ }
101
+ const at = raw.lastIndexOf("@");
102
+ if (at < 1) return void 0;
103
+ const name = raw.slice(0, at), version = raw.slice(at + 1), match = exactVersion.exec(version);
104
+ if (name.length > 214 || !packageName.test(name) || !match || !match.slice(1, 4).every((part) => Number.isSafeInteger(Number(part))) || match[4]?.split(".").some((part) => /^\d+$/.test(part) && (part.length > 1 && part.startsWith("0") || !Number.isSafeInteger(Number(part))))) return void 0;
105
+ return { kind: "package", name, version };
106
+ }
107
+ var concept = (raw) => {
108
+ if (typeof raw !== "string") return false;
109
+ try {
110
+ assertSafeConceptId(raw);
111
+ return nonCanonicalDocumentId(raw) === null;
112
+ } catch {
113
+ return false;
114
+ }
115
+ };
116
+ var blob = (raw) => {
117
+ if (typeof raw !== "string") return false;
118
+ try {
119
+ assertSafeBlobKey(raw);
120
+ return true;
121
+ } catch {
122
+ return false;
123
+ }
124
+ };
125
+ function parseSiteManifestDoc(doc) {
126
+ const errors = [];
127
+ const fail = (path, message) => {
128
+ errors.push({ code: "SITE_MANIFEST_INVALID", path, message });
129
+ };
130
+ const fm = record(doc?.frontmatter) ? doc.frontmatter : {};
131
+ const site = typeof doc?.id === "string" && doc.id.startsWith(SITES_PREFIX) ? doc.id.slice(SITES_PREFIX.length) : "";
132
+ if (!isSiteLabel(site)) fail("/id", "a Site lives at sites/<site>, using one site label");
133
+ if (fm.type !== SITE_TYPE) fail("/type", "type must be Site");
134
+ if (Object.keys(fm).some((key) => !SITE_DOCUMENT_KEYS.includes(key) && !isOkfStandardField(key) && !isManagedDocumentMetadataField(key)))
135
+ fail("", "unrecognized Site fields");
136
+ if (typeof fm.title !== "string" || fm.title.trim() === "" || encoder.encode(fm.title).byteLength > 512)
137
+ fail("/title", "title must be a nonempty string of at most 512 bytes");
138
+ if (fm.description !== void 0 && (typeof fm.description !== "string" || encoder.encode(fm.description).byteLength > 8192))
139
+ fail("/description", "description must be a string of at most 8192 bytes");
140
+ const presentation = presentationReference(fm.presentation);
141
+ if (!presentation) fail("/presentation", "presentation must name an exact npm version or repo:owner/name");
142
+ if (fm.audience !== "restricted") fail("/audience", "only the restricted audience is supported");
143
+ const list = (raw, path, maximum, valid) => {
144
+ if (!Array.isArray(raw) || raw.length > maximum || !raw.every(valid) || new Set(raw).size !== raw.length) {
145
+ fail(path, "expected a bounded list of unique valid references");
146
+ return [];
147
+ }
148
+ return [...raw];
149
+ };
150
+ const views = list(fm.views, "/views", 64, concept);
151
+ const capability = (v) => typeof v === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(v);
152
+ const capabilities = list(fm.capabilities ?? [], "/capabilities", 16, capability);
153
+ if (fm.landing !== void 0 && !concept(fm.landing)) fail("/landing", "landing must be a canonical document or View id");
154
+ const options = fm.options ?? {};
155
+ if (!record(options) || !isJsonData(options) || encoder.encode(JSON.stringify(options)).byteLength > 16384)
156
+ fail("/options", "options must be JSON data of at most 16384 bytes");
157
+ let brand;
158
+ if (fm.brand !== void 0) {
159
+ if (!record(fm.brand) || Object.keys(fm.brand).some((key) => key !== "logo" && key !== "fonts")) fail("/brand", "brand may only name a logo and fonts");
160
+ else {
161
+ if (fm.brand.logo !== void 0 && !blob(fm.brand.logo)) fail("/brand/logo", "logo must be a bundle blob reference");
162
+ const fonts = fm.brand.fonts === void 0 ? void 0 : list(fm.brand.fonts, "/brand/fonts", 16, blob);
163
+ brand = { ...typeof fm.brand.logo === "string" ? { logo: fm.brand.logo } : {}, ...fonts ? { fonts } : {} };
164
+ }
165
+ }
166
+ if (errors.length) return { ok: false, errors };
167
+ return { ok: true, manifest: {
168
+ id: doc.id,
169
+ site,
170
+ title: fm.title,
171
+ presentation,
172
+ audience: "restricted",
173
+ views,
174
+ capabilities,
175
+ options: JSON.parse(JSON.stringify(options)),
176
+ ...fm.description === void 0 ? {} : { description: fm.description },
177
+ ...fm.landing === void 0 ? {} : { landing: fm.landing },
178
+ ...brand ? { brand } : {}
179
+ } };
180
+ }
181
+
182
+ // ../publication/src/site-manifest.ts
183
+ function readPublicationSiteManifest(snapshot, site) {
184
+ const declarations = snapshot.documents.filter((doc) => doc.frontmatter.type === SITE_TYPE);
185
+ if (declarations.length !== 1 || declarations[0].id !== `${SITES_PREFIX}${site}`)
186
+ return { ok: false, errors: [{ code: "SITE_MANIFEST_INVALID", path: "/id", message: "the publication requires exactly one Site at sites/<site>" }] };
187
+ const parsed = parseSiteManifestDoc(declarations[0]);
188
+ if (!parsed.ok) return parsed;
189
+ const { manifest } = parsed;
190
+ const views = new Set(snapshot.views.map((view) => view.id));
191
+ const documents = new Set(snapshot.documents.map((doc) => doc.id));
192
+ const blobs = new Set(snapshot.blobs.map((blob2) => blob2.key));
193
+ const errors = [];
194
+ const fail = (path, message) => {
195
+ errors.push({ code: "SITE_MANIFEST_INVALID", path, message });
196
+ };
197
+ if (manifest.views.some((id) => !views.has(id))) fail("/views", "every declared View must be registered in this publication");
198
+ if (manifest.landing !== void 0 && !documents.has(manifest.landing)) fail("/landing", "landing must name a document or View in this publication");
199
+ if (manifest.landing !== void 0 && views.has(manifest.landing) && !manifest.views.includes(manifest.landing)) fail("/landing", "a landing View must be declared by this Site");
200
+ if (manifest.brand?.logo !== void 0 && !blobs.has(manifest.brand.logo)) fail("/brand/logo", "the logo must be a blob in this publication");
201
+ if (manifest.brand?.fonts?.some((key) => !blobs.has(key))) fail("/brand/fonts", "every font must be a blob in this publication");
202
+ return errors.length ? { ok: false, errors } : parsed;
203
+ }
204
+ export {
205
+ SITES_PREFIX,
206
+ SITE_DOCUMENT_KEYS,
207
+ SITE_LABEL,
208
+ SITE_TYPE,
209
+ isSiteLabel,
210
+ parseSiteManifestDoc,
211
+ readPublicationSiteManifest
212
+ };
@@ -30978,6 +30978,13 @@ function assertSafeConceptId(id) {
30978
30978
  }
30979
30979
  var FORMAT_AT_EDGE = new RegExp("^\\p{Cf}|\\p{Cf}$", "u");
30980
30980
  var FORMAT_INSIDE = new RegExp("(?![\\u200c\\u200d])\\p{Cf}", "u");
30981
+ function nonCanonicalDocumentId(id) {
30982
+ const segments = id.split("/");
30983
+ if (segments.some((segment) => segment !== segment.trim())) return "segment_whitespace";
30984
+ if (segments.some((segment) => FORMAT_AT_EDGE.test(segment) || FORMAT_INSIDE.test(segment))) return "format_character";
30985
+ if (id !== id.normalize("NFC")) return "not_nfc";
30986
+ return null;
30987
+ }
30981
30988
  function assertSafeBlobKey(key) {
30982
30989
  if (typeof key !== "string" || key.trim() === "") {
30983
30990
  throw new InvalidInputError("Blob key must be a non-empty string.");
@@ -32074,14 +32081,14 @@ async function readOwnerRecord(lockPath) {
32074
32081
  }
32075
32082
  async function resolveOwnerRecord(lockPath, started, waitMs, pollMs) {
32076
32083
  while (true) {
32077
- const record2 = await readOwnerRecord(lockPath);
32078
- if (record2.state !== "unreadable" || Date.now() - started >= waitMs) return record2;
32084
+ const record3 = await readOwnerRecord(lockPath);
32085
+ if (record3.state !== "unreadable" || Date.now() - started >= waitMs) return record3;
32079
32086
  await delay(pollMs);
32080
32087
  }
32081
32088
  }
32082
32089
  async function readOwner(lockPath) {
32083
- const record2 = await readOwnerRecord(lockPath);
32084
- return record2.state === "record" ? record2.owner : null;
32090
+ const record3 = await readOwnerRecord(lockPath);
32091
+ return record3.state === "record" ? record3.owner : null;
32085
32092
  }
32086
32093
  function processExists(pid) {
32087
32094
  try {
@@ -32276,12 +32283,12 @@ async function claimLockPath(lockPath, owner, waitMs, pollMs, policy) {
32276
32283
  }
32277
32284
  async function rollBackOwnClaim(lockPath, owner, claimed, waitMs, pollMs, policy) {
32278
32285
  const started = Date.now();
32279
- const record2 = await resolveOwnerRecord(lockPath, started, waitMs, pollMs);
32280
- if (record2.state === "record") {
32281
- if (record2.owner.token === owner.token) await removeReleasedLock(lockPath, owner, started, waitMs, pollMs, policy);
32286
+ const record3 = await resolveOwnerRecord(lockPath, started, waitMs, pollMs);
32287
+ if (record3.state === "record") {
32288
+ if (record3.owner.token === owner.token) await removeReleasedLock(lockPath, owner, started, waitMs, pollMs, policy);
32282
32289
  return;
32283
32290
  }
32284
- if (record2.state === "unreadable" || !await isClaimedDirectory(lockPath, claimed)) return;
32291
+ if (record3.state === "unreadable" || !await isClaimedDirectory(lockPath, claimed)) return;
32285
32292
  const remnant = releasedLockRemnantPath(lockPath, owner);
32286
32293
  await fs.rename(lockPath, remnant);
32287
32294
  await fs.rm(remnant, { recursive: true, force: true });
@@ -33662,11 +33669,11 @@ function isPlainObject(value) {
33662
33669
  const prototype = Object.getPrototypeOf(value);
33663
33670
  return prototype === Object.prototype || prototype === null;
33664
33671
  }
33665
- function hasOwn(record2, key) {
33666
- return Object.prototype.hasOwnProperty.call(record2, key);
33672
+ function hasOwn(record3, key) {
33673
+ return Object.prototype.hasOwnProperty.call(record3, key);
33667
33674
  }
33668
- function setOwn(record2, key, value) {
33669
- Object.defineProperty(record2, key, { value, enumerable: true, configurable: true, writable: true });
33675
+ function setOwn(record3, key, value) {
33676
+ Object.defineProperty(record3, key, { value, enumerable: true, configurable: true, writable: true });
33670
33677
  }
33671
33678
  function isScalar(value) {
33672
33679
  return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -44584,15 +44591,15 @@ function buildSnapshot(first) {
44584
44591
  if (!registration) {
44585
44592
  throw new PublicationError("INVALID_VIEW_REGISTRATION", "a View registration is invalid", { subject: doc.id });
44586
44593
  }
44587
- const blob = blobsByKey.get(registration.entry);
44588
- if (!blob) {
44594
+ const blob2 = blobsByKey.get(registration.entry);
44595
+ if (!blob2) {
44589
44596
  throw new PublicationError("VIEW_ENTRY_MISSING", "a registered View entry is missing", { subject: doc.id });
44590
44597
  }
44591
- if (registration.entryVersion && registration.entryVersion !== blob.version) {
44598
+ if (registration.entryVersion && registration.entryVersion !== blob2.version) {
44592
44599
  throw new PublicationError("VIEW_ENTRY_VERSION_MISMATCH", "a registered View entry no longer matches its pin", {
44593
44600
  subject: doc.id,
44594
44601
  expected: registration.entryVersion,
44595
- actual: blob.version
44602
+ actual: blob2.version
44596
44603
  });
44597
44604
  }
44598
44605
  const rawBlob = first.blobs.find((candidate) => candidate.key === registration.entry);
@@ -44613,8 +44620,8 @@ function buildSnapshot(first) {
44613
44620
  ...presentation === "workspace" || presentation === "inline" || presentation === "adaptive" ? { presentation } : {},
44614
44621
  access: resolveDeclaredAccess(doc.frontmatter),
44615
44622
  entry: registration.entry,
44616
- entryVersion: blob.version,
44617
- entryObject: blob.object
44623
+ entryVersion: blob2.version,
44624
+ entryObject: blob2.object
44618
44625
  });
44619
44626
  }
44620
44627
  views.sort((a, b) => compareCodeUnits(a.id, b.id));
@@ -45043,18 +45050,157 @@ function assertPublicationSourceExclusions(source, exclusions) {
45043
45050
  return slash > 0 && directories.has(fold(path6.slice(0, slash)));
45044
45051
  };
45045
45052
  const excludedType = (type) => type !== void 0 && type !== null && (types.has(kind(type)) || Array.isArray(type) && type.flat(Infinity).some((value) => types.has(kind(value))));
45046
- const count = source.documents.filter((document3) => excludedPath(document3.id) || excludedType(document3.frontmatter.type)).length + source.reserved.filter((file) => excludedPath(`${file.dir}/${file.name}`)).length + source.blobs.filter((blob) => excludedPath(blob.key)).length;
45053
+ const count = source.documents.filter((document3) => excludedPath(document3.id) || excludedType(document3.frontmatter.type)).length + source.reserved.filter((file) => excludedPath(`${file.dir}/${file.name}`)).length + source.blobs.filter((blob2) => excludedPath(blob2.key)).length;
45047
45054
  if (count > 0) throw new PublicationError("INVALID_BUNDLE", "the publication source contains excluded content", { details: { excludedEntries: count } });
45048
45055
  }
45056
+
45057
+ // ../core/src/json-data.ts
45058
+ function isJsonData(value, depth = 0) {
45059
+ if (depth > 32) return false;
45060
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
45061
+ if (typeof value === "number") return Number.isFinite(value);
45062
+ if (Array.isArray(value)) return value.every((item) => isJsonData(item, depth + 1));
45063
+ if (value === null || typeof value !== "object") return false;
45064
+ const proto = Object.getPrototypeOf(value);
45065
+ if (proto !== null && Object.getPrototypeOf(proto) !== null) return false;
45066
+ return Object.values(value).every((item) => item !== void 0 && isJsonData(item, depth + 1));
45067
+ }
45068
+
45069
+ // ../core/src/site-manifest.ts
45070
+ var SITE_TYPE = "Site";
45071
+ var SITES_PREFIX = "sites/";
45072
+ var SITE_LABEL = /^[a-z][a-z0-9-]{1,30}[a-z0-9]$/;
45073
+ var isSiteLabel = (value) => typeof value === "string" && SITE_LABEL.test(value) && !value.includes("--");
45074
+ var SITE_DOCUMENT_KEYS = ["type", "title", "description", "presentation", "landing", "views", "audience", "capabilities", "options", "brand"];
45075
+ var record2 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
45076
+ var packageName = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
45077
+ var exactVersion = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
45078
+ var encoder2 = new TextEncoder();
45079
+ function presentationReference(raw) {
45080
+ if (typeof raw !== "string" || raw.length > 512) return void 0;
45081
+ if (raw.startsWith("repo:")) {
45082
+ const repository = raw.slice(5);
45083
+ return /^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(repository) && !repository.endsWith(".git") ? { kind: "repository", repository } : void 0;
45084
+ }
45085
+ const at = raw.lastIndexOf("@");
45086
+ if (at < 1) return void 0;
45087
+ const name = raw.slice(0, at), version2 = raw.slice(at + 1), match = exactVersion.exec(version2);
45088
+ if (name.length > 214 || !packageName.test(name) || !match || !match.slice(1, 4).every((part) => Number.isSafeInteger(Number(part))) || match[4]?.split(".").some((part) => /^\d+$/.test(part) && (part.length > 1 && part.startsWith("0") || !Number.isSafeInteger(Number(part))))) return void 0;
45089
+ return { kind: "package", name, version: version2 };
45090
+ }
45091
+ var concept = (raw) => {
45092
+ if (typeof raw !== "string") return false;
45093
+ try {
45094
+ assertSafeConceptId(raw);
45095
+ return nonCanonicalDocumentId(raw) === null;
45096
+ } catch {
45097
+ return false;
45098
+ }
45099
+ };
45100
+ var blob = (raw) => {
45101
+ if (typeof raw !== "string") return false;
45102
+ try {
45103
+ assertSafeBlobKey(raw);
45104
+ return true;
45105
+ } catch {
45106
+ return false;
45107
+ }
45108
+ };
45109
+ function parseSiteManifestDoc(doc) {
45110
+ const errors = [];
45111
+ const fail2 = (path6, message) => {
45112
+ errors.push({ code: "SITE_MANIFEST_INVALID", path: path6, message });
45113
+ };
45114
+ const fm = record2(doc?.frontmatter) ? doc.frontmatter : {};
45115
+ const site = typeof doc?.id === "string" && doc.id.startsWith(SITES_PREFIX) ? doc.id.slice(SITES_PREFIX.length) : "";
45116
+ if (!isSiteLabel(site)) fail2("/id", "a Site lives at sites/<site>, using one site label");
45117
+ if (fm.type !== SITE_TYPE) fail2("/type", "type must be Site");
45118
+ if (Object.keys(fm).some((key) => !SITE_DOCUMENT_KEYS.includes(key) && !isOkfStandardField(key) && !isManagedDocumentMetadataField(key)))
45119
+ fail2("", "unrecognized Site fields");
45120
+ if (typeof fm.title !== "string" || fm.title.trim() === "" || encoder2.encode(fm.title).byteLength > 512)
45121
+ fail2("/title", "title must be a nonempty string of at most 512 bytes");
45122
+ if (fm.description !== void 0 && (typeof fm.description !== "string" || encoder2.encode(fm.description).byteLength > 8192))
45123
+ fail2("/description", "description must be a string of at most 8192 bytes");
45124
+ const presentation = presentationReference(fm.presentation);
45125
+ if (!presentation) fail2("/presentation", "presentation must name an exact npm version or repo:owner/name");
45126
+ if (fm.audience !== "restricted") fail2("/audience", "only the restricted audience is supported");
45127
+ const list3 = (raw, path6, maximum, valid) => {
45128
+ if (!Array.isArray(raw) || raw.length > maximum || !raw.every(valid) || new Set(raw).size !== raw.length) {
45129
+ fail2(path6, "expected a bounded list of unique valid references");
45130
+ return [];
45131
+ }
45132
+ return [...raw];
45133
+ };
45134
+ const views = list3(fm.views, "/views", 64, concept);
45135
+ const capability = (v) => typeof v === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(v);
45136
+ const capabilities = list3(fm.capabilities ?? [], "/capabilities", 16, capability);
45137
+ if (fm.landing !== void 0 && !concept(fm.landing)) fail2("/landing", "landing must be a canonical document or View id");
45138
+ const options = fm.options ?? {};
45139
+ if (!record2(options) || !isJsonData(options) || encoder2.encode(JSON.stringify(options)).byteLength > 16384)
45140
+ fail2("/options", "options must be JSON data of at most 16384 bytes");
45141
+ let brand;
45142
+ if (fm.brand !== void 0) {
45143
+ if (!record2(fm.brand) || Object.keys(fm.brand).some((key) => key !== "logo" && key !== "fonts")) fail2("/brand", "brand may only name a logo and fonts");
45144
+ else {
45145
+ if (fm.brand.logo !== void 0 && !blob(fm.brand.logo)) fail2("/brand/logo", "logo must be a bundle blob reference");
45146
+ const fonts = fm.brand.fonts === void 0 ? void 0 : list3(fm.brand.fonts, "/brand/fonts", 16, blob);
45147
+ brand = { ...typeof fm.brand.logo === "string" ? { logo: fm.brand.logo } : {}, ...fonts ? { fonts } : {} };
45148
+ }
45149
+ }
45150
+ if (errors.length) return { ok: false, errors };
45151
+ return { ok: true, manifest: {
45152
+ id: doc.id,
45153
+ site,
45154
+ title: fm.title,
45155
+ presentation,
45156
+ audience: "restricted",
45157
+ views,
45158
+ capabilities,
45159
+ options: JSON.parse(JSON.stringify(options)),
45160
+ ...fm.description === void 0 ? {} : { description: fm.description },
45161
+ ...fm.landing === void 0 ? {} : { landing: fm.landing },
45162
+ ...brand ? { brand } : {}
45163
+ } };
45164
+ }
45165
+
45166
+ // ../publication/src/site-manifest.ts
45167
+ function readPublicationSiteManifest(snapshot, site) {
45168
+ const declarations = snapshot.documents.filter((doc) => doc.frontmatter.type === SITE_TYPE);
45169
+ if (declarations.length !== 1 || declarations[0].id !== `${SITES_PREFIX}${site}`)
45170
+ return { ok: false, errors: [{ code: "SITE_MANIFEST_INVALID", path: "/id", message: "the publication requires exactly one Site at sites/<site>" }] };
45171
+ const parsed = parseSiteManifestDoc(declarations[0]);
45172
+ if (!parsed.ok) return parsed;
45173
+ const { manifest } = parsed;
45174
+ const views = new Set(snapshot.views.map((view) => view.id));
45175
+ const documents = new Set(snapshot.documents.map((doc) => doc.id));
45176
+ const blobs = new Set(snapshot.blobs.map((blob2) => blob2.key));
45177
+ const errors = [];
45178
+ const fail2 = (path6, message) => {
45179
+ errors.push({ code: "SITE_MANIFEST_INVALID", path: path6, message });
45180
+ };
45181
+ if (manifest.views.some((id) => !views.has(id))) fail2("/views", "every declared View must be registered in this publication");
45182
+ if (manifest.landing !== void 0 && !documents.has(manifest.landing)) fail2("/landing", "landing must name a document or View in this publication");
45183
+ if (manifest.landing !== void 0 && views.has(manifest.landing) && !manifest.views.includes(manifest.landing)) fail2("/landing", "a landing View must be declared by this Site");
45184
+ if (manifest.brand?.logo !== void 0 && !blobs.has(manifest.brand.logo)) fail2("/brand/logo", "the logo must be a blob in this publication");
45185
+ if (manifest.brand?.fonts?.some((key) => !blobs.has(key))) fail2("/brand/fonts", "every font must be a blob in this publication");
45186
+ return errors.length ? { ok: false, errors } : parsed;
45187
+ }
45049
45188
  export {
45050
45189
  PUBLICATION_BRIDGE_V0,
45051
45190
  PUBLICATION_SNAPSHOT_SCHEMA_V1,
45052
45191
  PUBLICATION_SNAPSHOT_V1,
45053
45192
  PublicationError,
45193
+ SITES_PREFIX,
45194
+ SITE_DOCUMENT_KEYS,
45195
+ SITE_LABEL,
45196
+ SITE_TYPE,
45054
45197
  assertPublicationSourceExclusions,
45055
45198
  capturePublicationSnapshot,
45056
45199
  createPublicationBridge,
45057
- isPublicationError
45200
+ isPublicationError,
45201
+ isSiteLabel,
45202
+ parseSiteManifestDoc,
45203
+ readPublicationSiteManifest
45058
45204
  };
45059
45205
  /*! Bundled license information:
45060
45206
 
package/dist/superbee.mjs CHANGED
@@ -44,7 +44,7 @@ var __toESM = (mod, isNodeMode, target3) => (target3 = mod != null ? __create(__
44
44
  var define_SUPERBEE_BUILD_IDENTITY_default;
45
45
  var init_define_SUPERBEE_BUILD_IDENTITY = __esm({
46
46
  "<define:__SUPERBEE_BUILD_IDENTITY__>"() {
47
- define_SUPERBEE_BUILD_IDENTITY_default = { schema: "superbee.build-identity.v1", package: { name: "superbee", version: "0.4.4-pre.7" }, source: { commit: "abebce5cd3309cd154955cd6d56ac8edeee23e2c", dirty: false }, artifact: { channel: "npm-package" }, compatibility_contracts: { skill: 1, hook: 1, mcp: 1 } };
47
+ define_SUPERBEE_BUILD_IDENTITY_default = { schema: "superbee.build-identity.v1", package: { name: "superbee", version: "0.4.4-pre.8" }, source: { commit: "670181d64d565efbc9506cf5a6e6d46a03186abf", dirty: false }, artifact: { channel: "npm-package" }, compatibility_contracts: { skill: 1, hook: 1, mcp: 1 } };
48
48
  }
49
49
  });
50
50
 
@@ -30554,6 +30554,25 @@ var init_machine_state = __esm({
30554
30554
  }
30555
30555
  });
30556
30556
 
30557
+ // ../core/src/json-data.ts
30558
+ function isJsonData(value, depth2 = 0) {
30559
+ if (depth2 > 32) return false;
30560
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
30561
+ if (typeof value === "number") return Number.isFinite(value);
30562
+ if (Array.isArray(value)) return value.every((item) => isJsonData(item, depth2 + 1));
30563
+ if (value === null || typeof value !== "object") return false;
30564
+ const proto = Object.getPrototypeOf(value);
30565
+ if (proto !== null && Object.getPrototypeOf(proto) !== null) return false;
30566
+ return Object.values(value).every((item) => item !== void 0 && isJsonData(item, depth2 + 1));
30567
+ }
30568
+ var init_json_data = __esm({
30569
+ "../core/src/json-data.ts"() {
30570
+ "use strict";
30571
+ init_define_SUPERBEE_BUILD_IDENTITY();
30572
+ init_define_SUPERBEE_UPDATE_POLICY();
30573
+ }
30574
+ });
30575
+
30557
30576
  // ../core/src/document-codec.ts
30558
30577
  var init_document_codec = __esm({
30559
30578
  "../core/src/document-codec.ts"() {
@@ -30584,16 +30603,6 @@ var init_target_consumer = __esm({
30584
30603
  });
30585
30604
 
30586
30605
  // ../core/src/source-engine/driver.ts
30587
- function isJsonData(value, depth2 = 0) {
30588
- if (depth2 > 32) return false;
30589
- if (value === null || typeof value === "string" || typeof value === "boolean") return true;
30590
- if (typeof value === "number") return Number.isFinite(value);
30591
- if (Array.isArray(value)) return value.every((item) => isJsonData(item, depth2 + 1));
30592
- if (!record9(value)) return false;
30593
- const proto = Object.getPrototypeOf(value);
30594
- if (proto !== null && Object.getPrototypeOf(proto) !== null) return false;
30595
- return Object.values(value).every((item) => item !== void 0 && isJsonData(item, depth2 + 1));
30596
- }
30597
30606
  function pageProblem(page) {
30598
30607
  if (!record9(page)) return "page_invalid";
30599
30608
  if (!Array.isArray(page.records) || typeof page.more !== "boolean" || typeof page.complete !== "boolean") return "page_invalid";
@@ -31035,6 +31044,8 @@ var init_driver = __esm({
31035
31044
  "use strict";
31036
31045
  init_define_SUPERBEE_BUILD_IDENTITY();
31037
31046
  init_define_SUPERBEE_UPDATE_POLICY();
31047
+ init_json_data();
31048
+ init_json_data();
31038
31049
  init_connectors();
31039
31050
  init_canonical();
31040
31051
  init_verification();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superbee",
3
- "version": "0.4.4-pre.7",
3
+ "version": "0.4.4-pre.8",
4
4
  "type": "module",
5
5
  "description": "Agent-facing Superbee CLI for reading and writing local OKF knowledge bundles: context notes, docs, cross-links, and live bundle Views.",
6
6
  "keywords": [
@@ -41,6 +41,10 @@
41
41
  "./portable-export": {
42
42
  "types": "./dist/portable-export.d.ts",
43
43
  "default": "./dist/portable-export.mjs"
44
+ },
45
+ "./publication/site-manifest": {
46
+ "types": "./dist/publication/site-manifest-entry.d.ts",
47
+ "default": "./dist/publication-site-manifest.mjs"
44
48
  }
45
49
  },
46
50
  "files": [