superbee 0.4.2 → 0.4.3-pre.10
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/README.md +11 -1
- package/SKILL.md +2 -2
- package/dist/portable-export.mjs +2 -0
- package/dist/publication-bridge.mjs +408 -18
- package/dist/publication.mjs +456 -27
- package/dist/superbee.mjs +26199 -14590
- package/package.json +2 -2
- package/references/hosted-checkout.md +99 -5
package/dist/publication.mjs
CHANGED
|
@@ -31111,6 +31111,8 @@ function assertSafeConceptId(id) {
|
|
|
31111
31111
|
);
|
|
31112
31112
|
}
|
|
31113
31113
|
}
|
|
31114
|
+
var FORMAT_AT_EDGE = new RegExp("^\\p{Cf}|\\p{Cf}$", "u");
|
|
31115
|
+
var FORMAT_INSIDE = new RegExp("(?![\\u200c\\u200d])\\p{Cf}", "u");
|
|
31114
31116
|
function assertSafeBlobKey(key) {
|
|
31115
31117
|
if (typeof key !== "string" || key.trim() === "") {
|
|
31116
31118
|
throw new InvalidInputError("Blob key must be a non-empty string.");
|
|
@@ -31153,7 +31155,8 @@ function isExternalHref(href) {
|
|
|
31153
31155
|
const h = href.trim();
|
|
31154
31156
|
return /^[a-z][a-z0-9+.-]*:\/\//i.test(h) || h.startsWith("mailto:") || h.startsWith("#");
|
|
31155
31157
|
}
|
|
31156
|
-
function extractMarkdownLinks(
|
|
31158
|
+
function extractMarkdownLinks(source, options = {}) {
|
|
31159
|
+
const body = options.skipCode ? maskMarkdownCode(source) : source;
|
|
31157
31160
|
const out = [];
|
|
31158
31161
|
let textOpen = -1;
|
|
31159
31162
|
let afterClose;
|
|
@@ -31165,8 +31168,8 @@ function extractMarkdownLinks(body) {
|
|
|
31165
31168
|
if (char === ")") {
|
|
31166
31169
|
if (hrefRest.open === 0 || body[hrefRest.open - 1] !== "!") {
|
|
31167
31170
|
out.push({
|
|
31168
|
-
text:
|
|
31169
|
-
href:
|
|
31171
|
+
text: source.slice(hrefRest.open + 1, hrefRest.close),
|
|
31172
|
+
href: source.slice(hrefRest.hrefStart, cursor)
|
|
31170
31173
|
});
|
|
31171
31174
|
}
|
|
31172
31175
|
textOpen = -1;
|
|
@@ -31197,6 +31200,150 @@ function extractMarkdownLinks(body) {
|
|
|
31197
31200
|
}
|
|
31198
31201
|
return out;
|
|
31199
31202
|
}
|
|
31203
|
+
function leadingIndent(line, from, startColumn) {
|
|
31204
|
+
let columns = 0;
|
|
31205
|
+
let index2 = from;
|
|
31206
|
+
while (index2 < line.length) {
|
|
31207
|
+
const char = line[index2];
|
|
31208
|
+
if (char === " ") columns += 1;
|
|
31209
|
+
else if (char === " ") columns += 4 - (startColumn + columns) % 4;
|
|
31210
|
+
else break;
|
|
31211
|
+
index2++;
|
|
31212
|
+
}
|
|
31213
|
+
return { columns, chars: index2 - from };
|
|
31214
|
+
}
|
|
31215
|
+
var FENCE_OPEN = /^(`{3,}|~{3,})(.*)$/;
|
|
31216
|
+
var LIST_MARKER = /^([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
31217
|
+
var THEMATIC_BREAK = /^(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
31218
|
+
var ATX_HEADING = /^#{1,6}(?:[ \t]|$)/;
|
|
31219
|
+
function maskMarkdownCode(body) {
|
|
31220
|
+
const out = body.split("");
|
|
31221
|
+
const blank = (from, to) => {
|
|
31222
|
+
for (let index2 = from; index2 < to; index2++) if (out[index2] !== "\n" && out[index2] !== "\r") out[index2] = " ";
|
|
31223
|
+
};
|
|
31224
|
+
const lists = [];
|
|
31225
|
+
let fence = null;
|
|
31226
|
+
let inParagraph = false;
|
|
31227
|
+
let segmentStart = -1;
|
|
31228
|
+
const closeSegment = (end) => {
|
|
31229
|
+
if (segmentStart >= 0) maskCodeSpans(body, segmentStart, end, blank);
|
|
31230
|
+
segmentStart = -1;
|
|
31231
|
+
};
|
|
31232
|
+
let lineStart = 0;
|
|
31233
|
+
while (lineStart <= body.length) {
|
|
31234
|
+
const newline = body.indexOf("\n", lineStart);
|
|
31235
|
+
const lineEnd = newline < 0 ? body.length : newline;
|
|
31236
|
+
const line = body.slice(lineStart, lineEnd);
|
|
31237
|
+
let contentAt = 0;
|
|
31238
|
+
let quotes = 0;
|
|
31239
|
+
for (let match = /^ {0,3}> ?/.exec(line); match; match = /^ {0,3}> ?/.exec(line.slice(contentAt))) {
|
|
31240
|
+
if (fence && quotes >= fence.quotes) break;
|
|
31241
|
+
contentAt += match[0].length;
|
|
31242
|
+
quotes++;
|
|
31243
|
+
}
|
|
31244
|
+
const { columns: indent2, chars } = leadingIndent(line, contentAt, contentAt);
|
|
31245
|
+
const rest = line.slice(contentAt + chars).replace(/\r$/, "");
|
|
31246
|
+
const isBlank = rest.trim() === "";
|
|
31247
|
+
if (fence && (quotes < fence.quotes || !isBlank && indent2 < fence.container)) fence = null;
|
|
31248
|
+
if (fence) {
|
|
31249
|
+
const close = indent2 - fence.container <= 3 ? FENCE_OPEN.exec(rest) : null;
|
|
31250
|
+
if (close && close[1][0] === fence.char && close[1].length >= fence.length && close[2].trim() === "") fence = null;
|
|
31251
|
+
blank(lineStart, lineEnd);
|
|
31252
|
+
} else if (isBlank) {
|
|
31253
|
+
closeSegment(lineStart);
|
|
31254
|
+
inParagraph = false;
|
|
31255
|
+
} else {
|
|
31256
|
+
if (!inParagraph) while (lists.length > 0 && lists[lists.length - 1] > indent2) lists.pop();
|
|
31257
|
+
let container = lists.length > 0 ? lists[lists.length - 1] : 0;
|
|
31258
|
+
let relative = indent2 - container;
|
|
31259
|
+
let text4 = rest;
|
|
31260
|
+
let textAt = lineStart + contentAt + chars;
|
|
31261
|
+
const marker = relative <= 3 && !THEMATIC_BREAK.test(text4) ? LIST_MARKER.exec(text4) : null;
|
|
31262
|
+
if (marker) {
|
|
31263
|
+
closeSegment(lineStart);
|
|
31264
|
+
const markerEnd = indent2 + marker[1].length;
|
|
31265
|
+
const spacing = leadingIndent(marker[2], 0, contentAt + markerEnd).columns;
|
|
31266
|
+
const wide = marker[2] === "" || spacing >= 5;
|
|
31267
|
+
lists.push(markerEnd + (wide ? 1 : spacing));
|
|
31268
|
+
container = lists[lists.length - 1];
|
|
31269
|
+
text4 = text4.slice(marker[1].length + (wide ? 0 : marker[2].length));
|
|
31270
|
+
textAt += marker[1].length + (wide ? 0 : marker[2].length);
|
|
31271
|
+
relative = wide ? Math.max(spacing - 1, 0) : 0;
|
|
31272
|
+
inParagraph = false;
|
|
31273
|
+
}
|
|
31274
|
+
const open = relative <= 3 ? FENCE_OPEN.exec(text4) : null;
|
|
31275
|
+
if (open && !(open[1][0] === "`" && open[2].includes("`"))) {
|
|
31276
|
+
closeSegment(lineStart);
|
|
31277
|
+
fence = { char: open[1][0], length: open[1].length, container, quotes };
|
|
31278
|
+
blank(textAt, lineEnd);
|
|
31279
|
+
inParagraph = false;
|
|
31280
|
+
} else if (!inParagraph && relative >= 4) {
|
|
31281
|
+
closeSegment(lineStart);
|
|
31282
|
+
blank(textAt, lineEnd);
|
|
31283
|
+
} else if (ATX_HEADING.test(text4) || THEMATIC_BREAK.test(text4)) {
|
|
31284
|
+
closeSegment(lineStart);
|
|
31285
|
+
maskCodeSpans(body, textAt, lineEnd, blank);
|
|
31286
|
+
inParagraph = false;
|
|
31287
|
+
} else {
|
|
31288
|
+
if (segmentStart < 0) segmentStart = textAt;
|
|
31289
|
+
inParagraph = text4.trim() !== "";
|
|
31290
|
+
}
|
|
31291
|
+
}
|
|
31292
|
+
if (newline < 0) break;
|
|
31293
|
+
lineStart = newline + 1;
|
|
31294
|
+
}
|
|
31295
|
+
closeSegment(body.length);
|
|
31296
|
+
return out.join("");
|
|
31297
|
+
}
|
|
31298
|
+
function maskCodeSpans(body, from, to, blank) {
|
|
31299
|
+
const runs = [];
|
|
31300
|
+
for (let index2 = from; index2 < to; ) {
|
|
31301
|
+
if (body[index2] !== "`") {
|
|
31302
|
+
index2++;
|
|
31303
|
+
continue;
|
|
31304
|
+
}
|
|
31305
|
+
let end = index2;
|
|
31306
|
+
while (end < to && body[end] === "`") end++;
|
|
31307
|
+
runs.push({ at: index2, length: end - index2 });
|
|
31308
|
+
index2 = end;
|
|
31309
|
+
}
|
|
31310
|
+
const byLength = /* @__PURE__ */ new Map();
|
|
31311
|
+
runs.forEach((run, position2) => {
|
|
31312
|
+
const list3 = byLength.get(run.length);
|
|
31313
|
+
if (list3) list3.push(position2);
|
|
31314
|
+
else byLength.set(run.length, [position2]);
|
|
31315
|
+
});
|
|
31316
|
+
const next = /* @__PURE__ */ new Map();
|
|
31317
|
+
const nextRun = (length, after) => {
|
|
31318
|
+
const list3 = byLength.get(length);
|
|
31319
|
+
if (!list3) return -1;
|
|
31320
|
+
let cursor = next.get(length) ?? 0;
|
|
31321
|
+
while (cursor < list3.length && list3[cursor] <= after) cursor++;
|
|
31322
|
+
next.set(length, cursor);
|
|
31323
|
+
return cursor < list3.length ? list3[cursor] : -1;
|
|
31324
|
+
};
|
|
31325
|
+
let escapeScan = from;
|
|
31326
|
+
let escaped = false;
|
|
31327
|
+
for (let position2 = 0; position2 < runs.length; position2++) {
|
|
31328
|
+
let { at, length } = runs[position2];
|
|
31329
|
+
for (; escapeScan < at; escapeScan++) escaped = body[escapeScan] === "\\" ? !escaped : false;
|
|
31330
|
+
if (escaped) {
|
|
31331
|
+
at += 1;
|
|
31332
|
+
length -= 1;
|
|
31333
|
+
escaped = false;
|
|
31334
|
+
if (length === 0) continue;
|
|
31335
|
+
const list3 = byLength.get(length);
|
|
31336
|
+
if (!list3) continue;
|
|
31337
|
+
}
|
|
31338
|
+
const closer = nextRun(length, position2);
|
|
31339
|
+
if (closer < 0) continue;
|
|
31340
|
+
const close = runs[closer];
|
|
31341
|
+
blank(at, close.at + close.length);
|
|
31342
|
+
position2 = closer;
|
|
31343
|
+
escapeScan = close.at + close.length;
|
|
31344
|
+
escaped = false;
|
|
31345
|
+
}
|
|
31346
|
+
}
|
|
31200
31347
|
function resolveConceptId(fromId, href) {
|
|
31201
31348
|
const target = (href.split("#")[0] ?? "").split("?")[0]?.trim() ?? "";
|
|
31202
31349
|
if (target === "" || isExternalHref(target)) return null;
|
|
@@ -31269,13 +31416,22 @@ function matchesFilter(doc, filter) {
|
|
|
31269
31416
|
}
|
|
31270
31417
|
return true;
|
|
31271
31418
|
}
|
|
31272
|
-
function
|
|
31273
|
-
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return
|
|
31419
|
+
function sourceIdentityOf(entry) {
|
|
31420
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return void 0;
|
|
31274
31421
|
const row = entry;
|
|
31422
|
+
const identity = {};
|
|
31423
|
+
for (const key of ["resource", "id"]) {
|
|
31424
|
+
if (Object.hasOwn(row, key) && typeof row[key] === "string") identity[key] = row[key];
|
|
31425
|
+
}
|
|
31426
|
+
return identity;
|
|
31427
|
+
}
|
|
31428
|
+
function matchesSourceIdentity(entry, identity) {
|
|
31429
|
+
const own3 = sourceIdentityOf(entry);
|
|
31430
|
+
if (!own3) return false;
|
|
31275
31431
|
for (const key of ["resource", "id"]) {
|
|
31276
31432
|
const expected = identity[key];
|
|
31277
31433
|
if (expected === void 0) continue;
|
|
31278
|
-
if (
|
|
31434
|
+
if (own3[key] === void 0 || own3[key] !== expected) return false;
|
|
31279
31435
|
}
|
|
31280
31436
|
return true;
|
|
31281
31437
|
}
|
|
@@ -31994,6 +32150,12 @@ async function probeSegment(port, candidate, rel, segment) {
|
|
|
31994
32150
|
function hasExact(listing, segment) {
|
|
31995
32151
|
return listing.some((entry) => entry.name === segment);
|
|
31996
32152
|
}
|
|
32153
|
+
function freshListings(port) {
|
|
32154
|
+
return async (dir) => {
|
|
32155
|
+
const listing = await port.entries(dir);
|
|
32156
|
+
return listing === null ? null : { has: (name) => hasExact(listing, name) };
|
|
32157
|
+
};
|
|
32158
|
+
}
|
|
31997
32159
|
async function walkExact(port, rootResolved, segments, rel) {
|
|
31998
32160
|
let parent = rootResolved;
|
|
31999
32161
|
for (let index2 = 0; index2 < segments.length; index2++) {
|
|
@@ -32025,14 +32187,14 @@ async function recordWalk(port, rootResolved, segments, rel) {
|
|
|
32025
32187
|
}
|
|
32026
32188
|
return recorded;
|
|
32027
32189
|
}
|
|
32028
|
-
async function confirmedWalk(port, rootResolved, segments, rel, recorded, handle) {
|
|
32190
|
+
async function confirmedWalk(port, rootResolved, segments, rel, recorded, handle, listings = freshListings(port)) {
|
|
32029
32191
|
let parent = rootResolved;
|
|
32030
32192
|
for (let index2 = 0; index2 < segments.length; index2++) {
|
|
32031
32193
|
const segment = segments[index2];
|
|
32032
32194
|
const candidate = path2.join(parent, segment);
|
|
32033
|
-
const listing = await
|
|
32195
|
+
const listing = await listings(parent);
|
|
32034
32196
|
if (listing === null) return "absent";
|
|
32035
|
-
const listed =
|
|
32197
|
+
const listed = listing.has(segment);
|
|
32036
32198
|
if (handle !== null && index2 === segments.length - 1) {
|
|
32037
32199
|
const verdict = classifyLeaf({ listed, probe: await probeSegment(port, candidate, rel, segment), handle });
|
|
32038
32200
|
if (verdict === "aliased") throw new FilesystemIdentityAliasError(rel, segment);
|
|
@@ -32052,13 +32214,15 @@ function countRestart(restarts, rel) {
|
|
|
32052
32214
|
return restarts + 1;
|
|
32053
32215
|
}
|
|
32054
32216
|
async function observeExact(port, root, rel, read) {
|
|
32217
|
+
return observeWith(port, path2.resolve(root), rel, read, freshListings(port));
|
|
32218
|
+
}
|
|
32219
|
+
async function observeWith(port, rootResolved, rel, read, listings, onExact) {
|
|
32055
32220
|
const segments = relSegments(rel);
|
|
32056
|
-
const rootResolved = path2.resolve(root);
|
|
32057
32221
|
const target = path2.join(rootResolved, ...segments);
|
|
32058
32222
|
for (let restarts = 0; ; ) {
|
|
32059
32223
|
const recorded = await recordWalk(port, rootResolved, segments, rel);
|
|
32060
32224
|
if (recorded === null) return { state: "absent" };
|
|
32061
|
-
const verified = await confirmedWalk(port, rootResolved, segments, rel, recorded, null);
|
|
32225
|
+
const verified = await confirmedWalk(port, rootResolved, segments, rel, recorded, null, listings);
|
|
32062
32226
|
if (verified === "absent") return { state: "absent" };
|
|
32063
32227
|
if (verified === "restart") {
|
|
32064
32228
|
restarts = countRestart(restarts, rel);
|
|
@@ -32080,11 +32244,14 @@ async function observeExact(port, root, rel, read) {
|
|
|
32080
32244
|
try {
|
|
32081
32245
|
value = await read(opened.handle, target);
|
|
32082
32246
|
if (value === null) return { state: "absent" };
|
|
32083
|
-
verdict = await confirmedWalk(port, rootResolved, segments, rel, recorded, opened);
|
|
32247
|
+
verdict = await confirmedWalk(port, rootResolved, segments, rel, recorded, opened, listings);
|
|
32084
32248
|
} finally {
|
|
32085
32249
|
await port.close(opened.handle);
|
|
32086
32250
|
}
|
|
32087
|
-
if (verdict === "exact")
|
|
32251
|
+
if (verdict === "exact") {
|
|
32252
|
+
onExact?.(recorded, { dev: opened.dev, ino: opened.ino });
|
|
32253
|
+
return { state: "exact", value };
|
|
32254
|
+
}
|
|
32088
32255
|
if (verdict === "absent") return { state: "absent" };
|
|
32089
32256
|
restarts = countRestart(restarts, rel);
|
|
32090
32257
|
}
|
|
@@ -32103,6 +32270,100 @@ async function probeExact(port, root, rel) {
|
|
|
32103
32270
|
restarts = countRestart(restarts, rel);
|
|
32104
32271
|
}
|
|
32105
32272
|
}
|
|
32273
|
+
var SETTLED_AFTER_NS = 3000000000n;
|
|
32274
|
+
function witnessKey(witness) {
|
|
32275
|
+
return `${witness.dev}:${witness.ino}:${witness.mtimeNs}:${witness.ctimeNs}`;
|
|
32276
|
+
}
|
|
32277
|
+
function openObservationPass(port, root, now = Date.now) {
|
|
32278
|
+
const rootResolved = path2.resolve(root);
|
|
32279
|
+
const kept = /* @__PURE__ */ new Map();
|
|
32280
|
+
const reusedVerdicts = [];
|
|
32281
|
+
const fresh = freshListings(port);
|
|
32282
|
+
const witnessOf = port.directoryWitness?.bind(port);
|
|
32283
|
+
const settled = (witness) => {
|
|
32284
|
+
const nowNs = BigInt(Math.floor(now())) * 1000000n;
|
|
32285
|
+
const latest = witness.mtimeNs > witness.ctimeNs ? witness.mtimeNs : witness.ctimeNs;
|
|
32286
|
+
return nowNs - latest >= SETTLED_AFTER_NS;
|
|
32287
|
+
};
|
|
32288
|
+
const listingsFor = () => {
|
|
32289
|
+
let reused = false;
|
|
32290
|
+
if (witnessOf === void 0) return { source: fresh, reused: () => false };
|
|
32291
|
+
const source = async (dir) => {
|
|
32292
|
+
const keep = kept.get(dir);
|
|
32293
|
+
if (keep !== void 0) {
|
|
32294
|
+
const current = await witnessOf(dir);
|
|
32295
|
+
if (current !== null && witnessKey(current) === keep.witness) {
|
|
32296
|
+
reused = true;
|
|
32297
|
+
return keep.names;
|
|
32298
|
+
}
|
|
32299
|
+
kept.delete(dir);
|
|
32300
|
+
}
|
|
32301
|
+
const before = await witnessOf(dir);
|
|
32302
|
+
const listing = await port.entries(dir);
|
|
32303
|
+
if (listing === null) return null;
|
|
32304
|
+
const names = new Set(listing.map((entry) => entry.name));
|
|
32305
|
+
const after = await witnessOf(dir);
|
|
32306
|
+
if (before !== null && after !== null && witnessKey(before) === witnessKey(after) && settled(after)) {
|
|
32307
|
+
kept.set(dir, { witness: witnessKey(after), names });
|
|
32308
|
+
}
|
|
32309
|
+
return names;
|
|
32310
|
+
};
|
|
32311
|
+
return { source, reused: () => reused };
|
|
32312
|
+
};
|
|
32313
|
+
return {
|
|
32314
|
+
async observe(rel, read) {
|
|
32315
|
+
const listings = listingsFor();
|
|
32316
|
+
let exact;
|
|
32317
|
+
let observed;
|
|
32318
|
+
try {
|
|
32319
|
+
observed = await observeWith(port, rootResolved, rel, read, listings.source, (recorded, handle) => {
|
|
32320
|
+
exact = { rel, segments: relSegments(rel), recorded, handle };
|
|
32321
|
+
});
|
|
32322
|
+
} catch (error) {
|
|
32323
|
+
if (!listings.reused()) throw error;
|
|
32324
|
+
return observeExact(port, rootResolved, rel, read);
|
|
32325
|
+
}
|
|
32326
|
+
if (!listings.reused()) return observed;
|
|
32327
|
+
if (observed.state === "absent") return observeExact(port, rootResolved, rel, read);
|
|
32328
|
+
if (exact !== void 0) reusedVerdicts.push(exact);
|
|
32329
|
+
return observed;
|
|
32330
|
+
},
|
|
32331
|
+
async finish() {
|
|
32332
|
+
const retry = /* @__PURE__ */ new Set();
|
|
32333
|
+
const endListings = /* @__PURE__ */ new Map();
|
|
32334
|
+
const listedAtEnd = async (dir) => {
|
|
32335
|
+
if (!endListings.has(dir)) {
|
|
32336
|
+
const listing = await port.entries(dir);
|
|
32337
|
+
endListings.set(dir, listing === null ? null : new Set(listing.map((entry) => entry.name)));
|
|
32338
|
+
}
|
|
32339
|
+
return endListings.get(dir);
|
|
32340
|
+
};
|
|
32341
|
+
try {
|
|
32342
|
+
for (const verdict of reusedVerdicts) {
|
|
32343
|
+
if (!await holdsAtEnd(port, rootResolved, verdict, listedAtEnd)) retry.add(verdict.rel);
|
|
32344
|
+
}
|
|
32345
|
+
} finally {
|
|
32346
|
+
kept.clear();
|
|
32347
|
+
reusedVerdicts.length = 0;
|
|
32348
|
+
}
|
|
32349
|
+
return [...retry];
|
|
32350
|
+
}
|
|
32351
|
+
};
|
|
32352
|
+
}
|
|
32353
|
+
async function holdsAtEnd(port, rootResolved, verdict, listedAtEnd) {
|
|
32354
|
+
let parent = rootResolved;
|
|
32355
|
+
for (let index2 = 0; index2 < verdict.segments.length; index2++) {
|
|
32356
|
+
const segment = verdict.segments[index2];
|
|
32357
|
+
const listing = await listedAtEnd(parent);
|
|
32358
|
+
if (listing === null || !listing.has(segment)) return false;
|
|
32359
|
+
const candidate = path2.join(parent, segment);
|
|
32360
|
+
const probed = await port.probe(candidate);
|
|
32361
|
+
const expected = index2 === verdict.segments.length - 1 ? verdict.handle : verdict.recorded[index2];
|
|
32362
|
+
if (probed === null || probed.kind === "symlink" || !sameWitness(probed, expected)) return false;
|
|
32363
|
+
parent = candidate;
|
|
32364
|
+
}
|
|
32365
|
+
return true;
|
|
32366
|
+
}
|
|
32106
32367
|
var linkUnsupportedRoots = /* @__PURE__ */ new WeakMap();
|
|
32107
32368
|
function unsupportedLinkRoots(port) {
|
|
32108
32369
|
let roots = linkUnsupportedRoots.get(port);
|
|
@@ -32256,8 +32517,56 @@ function kindOf(stats) {
|
|
|
32256
32517
|
if (stats.isFile()) return "file";
|
|
32257
32518
|
return "other";
|
|
32258
32519
|
}
|
|
32520
|
+
var LOCAL_LINUX_FILESYSTEMS = /* @__PURE__ */ new Set([
|
|
32521
|
+
61267,
|
|
32522
|
+
// ext2/3/4
|
|
32523
|
+
1481003842,
|
|
32524
|
+
// xfs
|
|
32525
|
+
2435016766,
|
|
32526
|
+
// btrfs
|
|
32527
|
+
16914836,
|
|
32528
|
+
// tmpfs
|
|
32529
|
+
2240043254,
|
|
32530
|
+
// ramfs
|
|
32531
|
+
2035054128,
|
|
32532
|
+
// overlayfs
|
|
32533
|
+
801189825,
|
|
32534
|
+
// zfs
|
|
32535
|
+
4076150800,
|
|
32536
|
+
// f2fs
|
|
32537
|
+
3393526350,
|
|
32538
|
+
// bcachefs
|
|
32539
|
+
19780,
|
|
32540
|
+
// vfat
|
|
32541
|
+
538032816,
|
|
32542
|
+
// exfat
|
|
32543
|
+
1936094318,
|
|
32544
|
+
// ntfs3
|
|
32545
|
+
18475
|
|
32546
|
+
// hfsplus
|
|
32547
|
+
]);
|
|
32548
|
+
function directoryWitnessTrusted(platform, filesystemType) {
|
|
32549
|
+
if (platform !== "linux") return true;
|
|
32550
|
+
return filesystemType !== null && LOCAL_LINUX_FILESYSTEMS.has(filesystemType);
|
|
32551
|
+
}
|
|
32552
|
+
function witnessTrust() {
|
|
32553
|
+
const devices = /* @__PURE__ */ new Map();
|
|
32554
|
+
return (dev, dir) => {
|
|
32555
|
+
if (process.platform !== "linux") return Promise.resolve(true);
|
|
32556
|
+
let trusted = devices.get(dev);
|
|
32557
|
+
if (trusted === void 0) {
|
|
32558
|
+
trusted = fs2.statfs(dir).then(
|
|
32559
|
+
(info) => directoryWitnessTrusted("linux", Number(info.type)),
|
|
32560
|
+
() => false
|
|
32561
|
+
);
|
|
32562
|
+
devices.set(dev, trusted);
|
|
32563
|
+
}
|
|
32564
|
+
return trusted;
|
|
32565
|
+
};
|
|
32566
|
+
}
|
|
32259
32567
|
function createNodeFilesystemIdentityPort(hostPolicy) {
|
|
32260
32568
|
const policy = captureFilesystemHostPolicy(hostPolicy);
|
|
32569
|
+
const witnessTrustedOn = witnessTrust();
|
|
32261
32570
|
return Object.freeze({
|
|
32262
32571
|
isTransientOpenError: policy.isTransientOpenError,
|
|
32263
32572
|
isReplacementConflict: policy.isReplacementConflict,
|
|
@@ -32280,6 +32589,17 @@ function createNodeFilesystemIdentityPort(hostPolicy) {
|
|
|
32280
32589
|
throw err;
|
|
32281
32590
|
}
|
|
32282
32591
|
},
|
|
32592
|
+
async directoryWitness(dir) {
|
|
32593
|
+
let stats;
|
|
32594
|
+
try {
|
|
32595
|
+
stats = await fs2.stat(dir, { bigint: true });
|
|
32596
|
+
} catch (err) {
|
|
32597
|
+
if (isAbsentPathError(err)) return null;
|
|
32598
|
+
throw err;
|
|
32599
|
+
}
|
|
32600
|
+
if (!await witnessTrustedOn(stats.dev, dir)) return null;
|
|
32601
|
+
return { dev: stats.dev, ino: stats.ino, mtimeNs: stats.mtimeNs, ctimeNs: stats.ctimeNs };
|
|
32602
|
+
},
|
|
32283
32603
|
async open(target) {
|
|
32284
32604
|
const handle = await fs2.open(target, "r");
|
|
32285
32605
|
try {
|
|
@@ -32590,10 +32910,11 @@ var FilesystemBackend = class _FilesystemBackend {
|
|
|
32590
32910
|
return void 0;
|
|
32591
32911
|
}
|
|
32592
32912
|
}
|
|
32593
|
-
async #readWithEdition(id, edition) {
|
|
32913
|
+
async #readWithEdition(id, edition, pass) {
|
|
32594
32914
|
assertSafeConceptId(id);
|
|
32595
32915
|
const rel = pathFromConceptId(id);
|
|
32596
|
-
const
|
|
32916
|
+
const read = (handle) => readBytes(this.#port, handle);
|
|
32917
|
+
const observed = pass ? await pass.observe(rel, read) : await observeExact(this.#port, this.#root, rel, read);
|
|
32597
32918
|
if (observed.state === "absent") throw notFound(this.#root, rel);
|
|
32598
32919
|
const raw = observed.value.toString("utf8");
|
|
32599
32920
|
const { frontmatter: frontmatter2, body } = parseMarkdown(raw, rel, { okfVersion: await edition() });
|
|
@@ -32608,7 +32929,12 @@ var FilesystemBackend = class _FilesystemBackend {
|
|
|
32608
32929
|
}
|
|
32609
32930
|
let editionPromise;
|
|
32610
32931
|
const edition = () => editionPromise ??= this.#readEdition();
|
|
32611
|
-
|
|
32932
|
+
const pass = openObservationPass(this.#port, this.#root);
|
|
32933
|
+
for (const id of ids) out.push(await this.#readWithEdition(id, edition, pass));
|
|
32934
|
+
const retry = new Set(await pass.finish());
|
|
32935
|
+
for (let index2 = 0; index2 < ids.length; index2++) {
|
|
32936
|
+
if (retry.has(pathFromConceptId(ids[index2]))) out[index2] = await this.#readWithEdition(ids[index2], edition);
|
|
32937
|
+
}
|
|
32612
32938
|
return out;
|
|
32613
32939
|
}
|
|
32614
32940
|
async write(id, doc, options = {}) {
|
|
@@ -32768,14 +33094,36 @@ function publicationContext(backend) {
|
|
|
32768
33094
|
return context;
|
|
32769
33095
|
}
|
|
32770
33096
|
async function readRawFilesystemDocument(backend, id) {
|
|
33097
|
+
return readRawDocumentIn(backend, id);
|
|
33098
|
+
}
|
|
33099
|
+
async function readRawDocumentIn(backend, id, pass) {
|
|
32771
33100
|
assertSafeConceptId(id);
|
|
32772
33101
|
const { root, port } = publicationContext(backend);
|
|
32773
33102
|
const rel = pathFromConceptId(id);
|
|
32774
|
-
const
|
|
33103
|
+
const read = (handle) => readBytes(port, handle);
|
|
33104
|
+
const observed = pass ? await pass.observe(rel, read) : await observeExact(port, root, rel, read);
|
|
32775
33105
|
if (observed.state === "absent") throw notFound(root, rel);
|
|
32776
33106
|
const raw = new TextDecoder("utf-8", { fatal: true }).decode(observed.value);
|
|
32777
33107
|
return { bytes: observed.value.slice(), version: versionOfBytes(raw) };
|
|
32778
33108
|
}
|
|
33109
|
+
function openRawFilesystemDocumentPass(backend) {
|
|
33110
|
+
const { root, port } = publicationContext(backend);
|
|
33111
|
+
const pass = openObservationPass(port, root);
|
|
33112
|
+
const ids = /* @__PURE__ */ new Map();
|
|
33113
|
+
return {
|
|
33114
|
+
read(id) {
|
|
33115
|
+
assertSafeConceptId(id);
|
|
33116
|
+
ids.set(pathFromConceptId(id), id);
|
|
33117
|
+
return readRawDocumentIn(backend, id, pass);
|
|
33118
|
+
},
|
|
33119
|
+
async finish() {
|
|
33120
|
+
return (await pass.finish()).flatMap((rel) => {
|
|
33121
|
+
const id = ids.get(rel);
|
|
33122
|
+
return id === void 0 ? [] : [id];
|
|
33123
|
+
});
|
|
33124
|
+
}
|
|
33125
|
+
};
|
|
33126
|
+
}
|
|
32779
33127
|
async function readRawFilesystemReserved(backend, dir, name) {
|
|
32780
33128
|
assertSafeReservedDir(dir);
|
|
32781
33129
|
assertSafeReservedFilename(name);
|
|
@@ -32836,6 +33184,23 @@ setDefaultBackendFactory((root) => new FilesystemBackend(root));
|
|
|
32836
33184
|
// ../core/src/kinds.ts
|
|
32837
33185
|
var CONVENTIONS_PREFIX = "conventions/";
|
|
32838
33186
|
var CONVENTION_TYPE = "Convention";
|
|
33187
|
+
var KIND_FIELD_TYPES = [
|
|
33188
|
+
"date",
|
|
33189
|
+
"datetime",
|
|
33190
|
+
"https-url",
|
|
33191
|
+
"https-url-list",
|
|
33192
|
+
"integer",
|
|
33193
|
+
"number",
|
|
33194
|
+
"boolean",
|
|
33195
|
+
"slug",
|
|
33196
|
+
"string-list",
|
|
33197
|
+
"latitude",
|
|
33198
|
+
"longitude"
|
|
33199
|
+
];
|
|
33200
|
+
var KIND_FIELD_TYPE_SET = new Set(KIND_FIELD_TYPES);
|
|
33201
|
+
function isKindFieldType(value) {
|
|
33202
|
+
return typeof value === "string" && KIND_FIELD_TYPE_SET.has(value);
|
|
33203
|
+
}
|
|
32839
33204
|
function buildKindRegistry(docs, initialWarnings = [], options = {}) {
|
|
32840
33205
|
const accepted = /* @__PURE__ */ new Map();
|
|
32841
33206
|
const warnings = [...initialWarnings];
|
|
@@ -32987,7 +33352,8 @@ var VALID_FIELDS_KEYS = /* @__PURE__ */ new Set([
|
|
|
32987
33352
|
"values",
|
|
32988
33353
|
"value_descriptions",
|
|
32989
33354
|
"terminal",
|
|
32990
|
-
"descriptions"
|
|
33355
|
+
"descriptions",
|
|
33356
|
+
"types"
|
|
32991
33357
|
]);
|
|
32992
33358
|
var MISPLACED_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["enum", "enums", "values", "constraints"]);
|
|
32993
33359
|
var CLAIM_COORDINATE_KEYS = [
|
|
@@ -33027,7 +33393,7 @@ function parseConventionDoc(doc, options = {}) {
|
|
|
33027
33393
|
if (!VALID_FIELDS_KEYS.has(key)) {
|
|
33028
33394
|
warnings.push({
|
|
33029
33395
|
code: "KIND_CONVENTION_UNKNOWN_FIELDS_KEY",
|
|
33030
|
-
message: `kind convention '${doc.id}' declares an unrecognized key 'fields.${key}' (valid keys: fields.required, fields.optional, fields.values, fields.value_descriptions, fields.terminal, fields.descriptions); ignoring it.`,
|
|
33396
|
+
message: `kind convention '${doc.id}' declares an unrecognized key 'fields.${key}' (valid keys: fields.required, fields.optional, fields.values, fields.value_descriptions, fields.terminal, fields.descriptions, fields.types); ignoring it.`,
|
|
33031
33397
|
field: `fields.${key}`,
|
|
33032
33398
|
severity: "warning"
|
|
33033
33399
|
});
|
|
@@ -33084,6 +33450,51 @@ function parseConventionDoc(doc, options = {}) {
|
|
|
33084
33450
|
});
|
|
33085
33451
|
}
|
|
33086
33452
|
}
|
|
33453
|
+
const typesSource = fieldsRaw.types;
|
|
33454
|
+
const types = {};
|
|
33455
|
+
if (typesSource !== void 0) {
|
|
33456
|
+
if (!isPlainObject(typesSource)) {
|
|
33457
|
+
warnings.push({
|
|
33458
|
+
code: "KIND_CONVENTION_BAD_SHAPE",
|
|
33459
|
+
message: `kind convention '${doc.id}' has a non-map 'fields.types' (${describeShape(typesSource)}; expected a map of field name -> type); ignoring it.`,
|
|
33460
|
+
field: "fields.types",
|
|
33461
|
+
severity: "warning"
|
|
33462
|
+
});
|
|
33463
|
+
} else {
|
|
33464
|
+
for (const [field, declared] of Object.entries(typesSource)) {
|
|
33465
|
+
if (dropReserved(field, `fields.types.${field}`)) continue;
|
|
33466
|
+
if (!isKindFieldType(declared)) {
|
|
33467
|
+
warnings.push({
|
|
33468
|
+
code: "KIND_CONVENTION_UNKNOWN_FIELD_TYPE",
|
|
33469
|
+
message: `kind convention '${doc.id}' declares 'fields.types.${field}' as ${isScalar(declared) ? `'${String(declared)}'` : describeShape(declared)}, which is not a field type (valid types: ${KIND_FIELD_TYPES.join(", ")}); ignoring it.`,
|
|
33470
|
+
field: `fields.types.${field}`,
|
|
33471
|
+
severity: "warning"
|
|
33472
|
+
});
|
|
33473
|
+
continue;
|
|
33474
|
+
}
|
|
33475
|
+
if (!declaredFieldNames.has(field)) {
|
|
33476
|
+
warnings.push({
|
|
33477
|
+
code: "KIND_CONVENTION_UNDECLARED_TYPES_FIELD",
|
|
33478
|
+
message: `kind convention '${doc.id}' declares 'fields.types.${field}' but '${field}' is not in fields.required or fields.optional; ignoring it.`,
|
|
33479
|
+
field: `fields.types.${field}`,
|
|
33480
|
+
severity: "warning"
|
|
33481
|
+
});
|
|
33482
|
+
continue;
|
|
33483
|
+
}
|
|
33484
|
+
setOwn(types, field, declared);
|
|
33485
|
+
}
|
|
33486
|
+
}
|
|
33487
|
+
}
|
|
33488
|
+
for (const field of Object.keys(values)) {
|
|
33489
|
+
if (types[field] !== "https-url-list") continue;
|
|
33490
|
+
warnings.push({
|
|
33491
|
+
code: "KIND_CONVENTION_VALUES_TYPE_MISMATCH",
|
|
33492
|
+
message: `kind convention '${doc.id}' declares 'fields.values.${field}' on a field of type 'https-url-list', which cannot carry an enum; ignoring the values.`,
|
|
33493
|
+
field: `fields.values.${field}`,
|
|
33494
|
+
severity: "warning"
|
|
33495
|
+
});
|
|
33496
|
+
delete values[field];
|
|
33497
|
+
}
|
|
33087
33498
|
const valueDescriptionsSource = fieldsRaw.value_descriptions;
|
|
33088
33499
|
const valueDescriptions = {};
|
|
33089
33500
|
if (valueDescriptionsSource !== void 0) {
|
|
@@ -33376,6 +33787,7 @@ function parseConventionDoc(doc, options = {}) {
|
|
|
33376
33787
|
governs,
|
|
33377
33788
|
fields: { required, optional, values, valueDescriptions, terminal, descriptions }
|
|
33378
33789
|
};
|
|
33790
|
+
if (Object.keys(types).length > 0) kind2.fields.types = types;
|
|
33379
33791
|
if (description !== void 0) kind2.description = description;
|
|
33380
33792
|
if (path6 !== void 0) kind2.path = path6;
|
|
33381
33793
|
if (links !== void 0) kind2.links = links;
|
|
@@ -42435,6 +42847,10 @@ function gfmFromMarkdown() {
|
|
|
42435
42847
|
|
|
42436
42848
|
// ../markdown-renderer/src/index.tsx
|
|
42437
42849
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
42850
|
+
function renderableConceptId(fromId, raw) {
|
|
42851
|
+
if (/^okf:/i.test(raw.trim())) return null;
|
|
42852
|
+
return resolveConceptId(fromId, raw);
|
|
42853
|
+
}
|
|
42438
42854
|
var MAX_BODY_CHARS = 262144;
|
|
42439
42855
|
var MAX_NODES = 2e4;
|
|
42440
42856
|
var MAX_DEPTH = 40;
|
|
@@ -42450,6 +42866,9 @@ function textOf(node2) {
|
|
|
42450
42866
|
if (!Array.isArray(children)) return "";
|
|
42451
42867
|
return children.map((child) => textOf(child)).join("");
|
|
42452
42868
|
}
|
|
42869
|
+
function renderTextFallback(node2, index2) {
|
|
42870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-markdown-fallback", children: textOf(node2) }, index2);
|
|
42871
|
+
}
|
|
42453
42872
|
function isBlankInline(node2) {
|
|
42454
42873
|
if (node2.type === "break") return true;
|
|
42455
42874
|
if (node2.type === "text") return (node2.value ?? "").trim() === "";
|
|
@@ -42460,7 +42879,7 @@ function isBareLinkBlock(node2, fromId) {
|
|
|
42460
42879
|
let sawLink = false;
|
|
42461
42880
|
for (const child of node2.children) {
|
|
42462
42881
|
if (isBlankInline(child)) continue;
|
|
42463
|
-
if (child.type === "link" &&
|
|
42882
|
+
if (child.type === "link" && renderableConceptId(fromId, child.url ?? "") !== null) {
|
|
42464
42883
|
sawLink = true;
|
|
42465
42884
|
continue;
|
|
42466
42885
|
}
|
|
@@ -42544,7 +42963,7 @@ function renderNode(node2, state, depth, index2) {
|
|
|
42544
42963
|
state.count++;
|
|
42545
42964
|
if (depth > MAX_DEPTH) {
|
|
42546
42965
|
state.bounded = true;
|
|
42547
|
-
return
|
|
42966
|
+
return renderTextFallback(node2, index2);
|
|
42548
42967
|
}
|
|
42549
42968
|
switch (node2.type) {
|
|
42550
42969
|
case "text":
|
|
@@ -42588,7 +43007,7 @@ function renderNode(node2, state, depth, index2) {
|
|
|
42588
43007
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}, index2);
|
|
42589
43008
|
case "link": {
|
|
42590
43009
|
const raw = node2.url ?? "";
|
|
42591
|
-
const resolved =
|
|
43010
|
+
const resolved = renderableConceptId(state.options.fromId, raw);
|
|
42592
43011
|
const children = renderChildren(node2, state, depth);
|
|
42593
43012
|
if (resolved === null) {
|
|
42594
43013
|
const external = admitExternalLink(raw, state.options.externalLinkHosts);
|
|
@@ -42645,7 +43064,7 @@ function renderNode(node2, state, depth, index2) {
|
|
|
42645
43064
|
case "html":
|
|
42646
43065
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-raw-html", children: node2.value }, index2);
|
|
42647
43066
|
default:
|
|
42648
|
-
return
|
|
43067
|
+
return renderTextFallback(node2, index2);
|
|
42649
43068
|
}
|
|
42650
43069
|
}
|
|
42651
43070
|
function renderEdgeList(links, state, index2) {
|
|
@@ -42657,14 +43076,14 @@ function renderEdgeList(links, state, index2) {
|
|
|
42657
43076
|
break;
|
|
42658
43077
|
}
|
|
42659
43078
|
state.count++;
|
|
42660
|
-
const to =
|
|
43079
|
+
const to = renderableConceptId(fromId, links[i].url ?? "");
|
|
42661
43080
|
if (to === null) continue;
|
|
42662
43081
|
const verb = textOf(links[i]).trim();
|
|
42663
43082
|
const target = titleFor?.(to) ?? to;
|
|
42664
43083
|
if (state.options.profile === "inert") {
|
|
42665
43084
|
rows.push(
|
|
42666
43085
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "doc-edge-row", "data-aslite-doc-id": to, children: [
|
|
42667
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-verb", children: verb }),
|
|
43086
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-verb doc-markdown-fallback", children: verb }),
|
|
42668
43087
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-arrow", "aria-hidden": "true", children: "\u2192" }),
|
|
42669
43088
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-target", children: target })
|
|
42670
43089
|
] }, i)
|
|
@@ -42679,7 +43098,7 @@ function renderEdgeList(links, state, index2) {
|
|
|
42679
43098
|
href: documentHref(to, state.options),
|
|
42680
43099
|
onClick: (event) => navigateDoc(event, to, state.options),
|
|
42681
43100
|
children: [
|
|
42682
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-verb", children: verb }),
|
|
43101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-verb doc-markdown-fallback", children: verb }),
|
|
42683
43102
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-arrow", "aria-hidden": "true", children: "\u2192" }),
|
|
42684
43103
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "doc-edge-target", children: target })
|
|
42685
43104
|
]
|
|
@@ -43605,10 +44024,20 @@ async function readInventory(backend, limits) {
|
|
|
43605
44024
|
return bytes;
|
|
43606
44025
|
};
|
|
43607
44026
|
const documents = [];
|
|
44027
|
+
const documentPass = openRawFilesystemDocumentPass(backend);
|
|
43608
44028
|
for (const id of documentIds) {
|
|
43609
|
-
const row = await
|
|
44029
|
+
const row = await documentPass.read(id);
|
|
43610
44030
|
documents.push({ id, version: row.version, bytes: admitBytes(row.bytes, id) });
|
|
43611
44031
|
}
|
|
44032
|
+
for (const id of await documentPass.finish()) {
|
|
44033
|
+
const row = await readRawFilesystemDocument(backend, id).catch((error) => {
|
|
44034
|
+
if (error?.code !== "ENOENT") throw error;
|
|
44035
|
+
return null;
|
|
44036
|
+
});
|
|
44037
|
+
if (row === null || documents.some((document3) => document3.id === id && document3.version !== row.version)) {
|
|
44038
|
+
throw new PublicationError("SOURCE_CHANGED", "a publication object changed during capture", { retryable: true });
|
|
44039
|
+
}
|
|
44040
|
+
}
|
|
43612
44041
|
const reserved = [];
|
|
43613
44042
|
for (const identity of reservedIds) {
|
|
43614
44043
|
const row = await readRawFilesystemReserved(backend, identity.dir, identity.name);
|