contentbit 0.4.1 → 0.5.0
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 +7 -2
- package/dist/bin.js +1609 -1616
- package/dist/cli-format.d.ts +17 -0
- package/dist/cli-format.d.ts.map +1 -0
- package/dist/cli-format.js +63 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +9 -188
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +4 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +80 -146
- package/dist/commands/init-targets.d.ts +27 -0
- package/dist/commands/init-targets.d.ts.map +1 -0
- package/dist/commands/init-targets.js +280 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +26 -313
- package/dist/commands/instructions.d.ts.map +1 -1
- package/dist/commands/instructions.js +4 -1
- package/dist/commands/links.d.ts.map +1 -1
- package/dist/commands/links.js +18 -14
- package/dist/commands/render.d.ts.map +1 -1
- package/dist/commands/render.js +17 -10
- package/dist/commands/stats.d.ts.map +1 -1
- package/dist/commands/stats.js +33 -34
- package/dist/commands/studio.d.ts.map +1 -1
- package/dist/commands/studio.js +14 -12
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +39 -41
- package/dist/content-project.d.ts +32 -0
- package/dist/content-project.d.ts.map +1 -0
- package/dist/content-project.js +34 -0
- package/dist/load-registry.d.ts +4 -1
- package/dist/load-registry.d.ts.map +1 -1
- package/dist/load-registry.js +4 -2
- package/dist/run.d.ts +10 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +1613 -1618
- package/package.json +4 -5
package/dist/run.js
CHANGED
|
@@ -8,17 +8,66 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
// src/cli-format.ts
|
|
12
|
+
import { isAbsolute, relative } from "node:path";
|
|
13
|
+
function color(text, tone) {
|
|
14
|
+
if (!colorsEnabled()) return text;
|
|
15
|
+
const [open, close] = ANSI[tone];
|
|
16
|
+
return `${open}${text}${close}`;
|
|
17
|
+
}
|
|
18
|
+
function section(title) {
|
|
19
|
+
return color(title, "bold");
|
|
20
|
+
}
|
|
21
|
+
function formatRows(rows) {
|
|
22
|
+
const width = Math.max(...rows.map((row) => row.label.length));
|
|
23
|
+
return rows.map((row) => {
|
|
24
|
+
const value = String(row.value);
|
|
25
|
+
return ` ${color(row.label.padEnd(width), "muted")} ${row.tone ? color(value, row.tone) : value}`;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function formatCommandList(commands2) {
|
|
29
|
+
return commands2.map((command) => ` ${color("$", "muted")} ${command}`);
|
|
30
|
+
}
|
|
31
|
+
function formatDiagnosticForCli(diagnostic, file2) {
|
|
32
|
+
const location = `${displayPath(file2)}:${diagnostic.position.start.line}:${diagnostic.position.start.column}`;
|
|
33
|
+
const lines = [
|
|
34
|
+
`${color(location, "muted")} ${severityLabel(diagnostic.severity)} ${diagnostic.code}`,
|
|
35
|
+
` ${diagnostic.message}`
|
|
36
|
+
];
|
|
37
|
+
if (diagnostic.hint) lines.push(` ${color("hint", "muted")} ${diagnostic.hint}`);
|
|
17
38
|
return lines.join("\n");
|
|
18
39
|
}
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
function displayPath(file2) {
|
|
41
|
+
const path = relative(process.cwd(), file2);
|
|
42
|
+
if (path && !path.startsWith("..") && !isAbsolute(path)) return path;
|
|
43
|
+
return file2;
|
|
44
|
+
}
|
|
45
|
+
function severityLabel(severity) {
|
|
46
|
+
return color(severity, severityTone(severity));
|
|
47
|
+
}
|
|
48
|
+
function severityTone(severity) {
|
|
49
|
+
if (severity === "error") return "error";
|
|
50
|
+
if (severity === "warning") return "warning";
|
|
51
|
+
return "info";
|
|
52
|
+
}
|
|
53
|
+
function colorsEnabled() {
|
|
54
|
+
if (process.env.VITEST || process.env.NODE_ENV === "test") return false;
|
|
55
|
+
if ("NO_COLOR" in process.env || process.env.FORCE_COLOR === "0") return false;
|
|
56
|
+
if (process.env.FORCE_COLOR) return true;
|
|
57
|
+
return Boolean(process.stdout.isTTY);
|
|
58
|
+
}
|
|
59
|
+
var ANSI;
|
|
60
|
+
var init_cli_format = __esm({
|
|
61
|
+
"src/cli-format.ts"() {
|
|
21
62
|
"use strict";
|
|
63
|
+
ANSI = {
|
|
64
|
+
bold: ["\x1B[1m", "\x1B[22m"],
|
|
65
|
+
error: ["\x1B[31m", "\x1B[39m"],
|
|
66
|
+
warning: ["\x1B[33m", "\x1B[39m"],
|
|
67
|
+
info: ["\x1B[36m", "\x1B[39m"],
|
|
68
|
+
success: ["\x1B[32m", "\x1B[39m"],
|
|
69
|
+
muted: ["\x1B[2m", "\x1B[22m"]
|
|
70
|
+
};
|
|
22
71
|
}
|
|
23
72
|
});
|
|
24
73
|
|
|
@@ -530,9 +579,9 @@ function analyzeDocument(source, options = {}) {
|
|
|
530
579
|
let words = 0;
|
|
531
580
|
function addWords(count) {
|
|
532
581
|
words += count;
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
535
|
-
|
|
582
|
+
const section2 = outline[outline.length - 1];
|
|
583
|
+
if (section2)
|
|
584
|
+
section2.words += count;
|
|
536
585
|
}
|
|
537
586
|
function recordLink(url2, text, line) {
|
|
538
587
|
const external = EXTERNAL_URL_RE.test(url2);
|
|
@@ -696,858 +745,398 @@ var init_analyze = __esm({
|
|
|
696
745
|
}
|
|
697
746
|
});
|
|
698
747
|
|
|
699
|
-
//
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
var init_position = __esm({
|
|
713
|
-
"../core/dist/position.js"() {
|
|
714
|
-
"use strict";
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
// ../core/dist/authoring.js
|
|
719
|
-
function typeLabel(def) {
|
|
720
|
-
switch (def.type) {
|
|
721
|
-
case "enum":
|
|
722
|
-
return `one of ${Object.values(def.entries ?? {}).join("|")}`;
|
|
723
|
-
case "literal":
|
|
724
|
-
return `one of ${(def.values ?? []).map(String).join("|")}`;
|
|
725
|
-
case "union":
|
|
726
|
-
return `one of ${(def.options ?? []).map((o) => typeLabel(o.def).replace(/^one of /, "")).join("|")}`;
|
|
727
|
-
default:
|
|
728
|
-
return def.type;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
function describeProps(schema) {
|
|
732
|
-
const root = schema.def;
|
|
733
|
-
if (root.type !== "object" || !root.shape)
|
|
734
|
-
return [];
|
|
735
|
-
const lines = [];
|
|
736
|
-
for (const [name, field] of Object.entries(root.shape)) {
|
|
737
|
-
let current = field;
|
|
738
|
-
let optional2 = false;
|
|
739
|
-
let defaultValue;
|
|
740
|
-
let description = current.description;
|
|
741
|
-
while (["optional", "default", "nullable"].includes(current.def.type)) {
|
|
742
|
-
optional2 = true;
|
|
743
|
-
if (current.def.type === "default") {
|
|
744
|
-
const dv = current.def.defaultValue;
|
|
745
|
-
defaultValue = typeof dv === "function" ? dv() : dv;
|
|
746
|
-
}
|
|
747
|
-
if (!current.def.innerType)
|
|
748
|
-
break;
|
|
749
|
-
current = current.def.innerType;
|
|
750
|
-
description ??= current.description;
|
|
751
|
-
}
|
|
752
|
-
const presence = defaultValue !== void 0 ? `(optional, default: ${String(defaultValue)})` : optional2 ? "(optional)" : "(required)";
|
|
753
|
-
const suffix = description ? ` \u2014 ${description}` : "";
|
|
754
|
-
lines.push(`- ${name}: ${typeLabel(current.def)} ${presence}${suffix}`);
|
|
755
|
-
}
|
|
756
|
-
return lines;
|
|
757
|
-
}
|
|
758
|
-
function generateAuthoringGuide(defs, opts = {}) {
|
|
759
|
-
const includeExamples = opts.includeExamples ?? true;
|
|
760
|
-
const includeAvoid = opts.includeAvoidRules ?? true;
|
|
761
|
-
const sections = [];
|
|
762
|
-
if ((opts.audience ?? "llm") === "llm")
|
|
763
|
-
sections.push(LLM_PREAMBLE);
|
|
764
|
-
for (const def of defs) {
|
|
765
|
-
const lines = [`## ${def.name}`, ""];
|
|
766
|
-
lines.push(def.childOnly ? `${def.description} (child block \u2014 only inside a parent that allows it)` : def.description);
|
|
767
|
-
if (def.props) {
|
|
768
|
-
const props = describeProps(def.props);
|
|
769
|
-
if (props.length > 0)
|
|
770
|
-
lines.push("", "Props:", ...props);
|
|
771
|
-
}
|
|
772
|
-
lines.push("", `Content: ${def.content.describe()}`);
|
|
773
|
-
if (def.authoring.useWhen.length > 0) {
|
|
774
|
-
lines.push("", "Use when:", ...def.authoring.useWhen.map((u) => `- ${u}`));
|
|
748
|
+
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
749
|
+
// @__NO_SIDE_EFFECTS__
|
|
750
|
+
function $constructor(name, initializer3, params) {
|
|
751
|
+
function init(inst, def) {
|
|
752
|
+
if (!inst._zod) {
|
|
753
|
+
Object.defineProperty(inst, "_zod", {
|
|
754
|
+
value: {
|
|
755
|
+
def,
|
|
756
|
+
constr: _,
|
|
757
|
+
traits: /* @__PURE__ */ new Set()
|
|
758
|
+
},
|
|
759
|
+
enumerable: false
|
|
760
|
+
});
|
|
775
761
|
}
|
|
776
|
-
if (
|
|
777
|
-
|
|
762
|
+
if (inst._zod.traits.has(name)) {
|
|
763
|
+
return;
|
|
778
764
|
}
|
|
779
|
-
|
|
780
|
-
|
|
765
|
+
inst._zod.traits.add(name);
|
|
766
|
+
initializer3(inst, def);
|
|
767
|
+
const proto = _.prototype;
|
|
768
|
+
const keys = Object.keys(proto);
|
|
769
|
+
for (let i = 0; i < keys.length; i++) {
|
|
770
|
+
const k = keys[i];
|
|
771
|
+
if (!(k in inst)) {
|
|
772
|
+
inst[k] = proto[k].bind(inst);
|
|
773
|
+
}
|
|
781
774
|
}
|
|
782
|
-
sections.push(lines.join("\n"));
|
|
783
775
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
var LLM_PREAMBLE;
|
|
787
|
-
var init_authoring = __esm({
|
|
788
|
-
"../core/dist/authoring.js"() {
|
|
789
|
-
"use strict";
|
|
790
|
-
LLM_PREAMBLE = `# Content block authoring rules
|
|
791
|
-
|
|
792
|
-
- write regular Markdown by default; use blocks only when they improve scanning or structure
|
|
793
|
-
- never invent block names \u2014 only the blocks documented below exist
|
|
794
|
-
- follow each block's syntax exactly; props use {key="value"} on the open line
|
|
795
|
-
- close every :::block with a line containing only :::
|
|
796
|
-
- validate generated content and fix diagnostics rather than bypassing them
|
|
797
|
-
`;
|
|
776
|
+
const Parent = params?.Parent ?? Object;
|
|
777
|
+
class Definition extends Parent {
|
|
798
778
|
}
|
|
799
|
-
});
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
779
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
780
|
+
function _(def) {
|
|
781
|
+
var _a3;
|
|
782
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
783
|
+
init(inst, def);
|
|
784
|
+
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
785
|
+
for (const fn of inst._zod.deferred) {
|
|
786
|
+
fn();
|
|
787
|
+
}
|
|
788
|
+
return inst;
|
|
805
789
|
}
|
|
806
|
-
|
|
790
|
+
Object.defineProperty(_, "init", { value: init });
|
|
791
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
792
|
+
value: (inst) => {
|
|
793
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
794
|
+
return true;
|
|
795
|
+
return inst?._zod?.traits?.has(name);
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
Object.defineProperty(_, "name", { value: name });
|
|
799
|
+
return _;
|
|
807
800
|
}
|
|
808
|
-
function
|
|
809
|
-
|
|
801
|
+
function config(newConfig) {
|
|
802
|
+
if (newConfig)
|
|
803
|
+
Object.assign(globalConfig, newConfig);
|
|
804
|
+
return globalConfig;
|
|
810
805
|
}
|
|
811
|
-
var
|
|
812
|
-
var
|
|
813
|
-
"
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
this.add(def);
|
|
822
|
-
return this;
|
|
823
|
-
}
|
|
824
|
-
add(def) {
|
|
825
|
-
const d = def;
|
|
826
|
-
if (this.defs.has(d.name)) {
|
|
827
|
-
throw new Error(`Duplicate block "${d.name}". Namespace it (e.g. "acme-${d.name}") or remove the duplicate.`);
|
|
828
|
-
}
|
|
829
|
-
this.defs.set(d.name, d);
|
|
830
|
-
return this;
|
|
831
|
-
}
|
|
832
|
-
get(name) {
|
|
833
|
-
return this.defs.get(name);
|
|
834
|
-
}
|
|
835
|
-
all() {
|
|
836
|
-
return [...this.defs.values()];
|
|
806
|
+
var _a, NEVER, $brand, $ZodAsyncError, $ZodEncodeError, globalConfig;
|
|
807
|
+
var init_core = __esm({
|
|
808
|
+
"../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js"() {
|
|
809
|
+
NEVER = /* @__PURE__ */ Object.freeze({
|
|
810
|
+
status: "aborted"
|
|
811
|
+
});
|
|
812
|
+
$brand = /* @__PURE__ */ Symbol("zod_brand");
|
|
813
|
+
$ZodAsyncError = class extends Error {
|
|
814
|
+
constructor() {
|
|
815
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
837
816
|
}
|
|
838
|
-
|
|
839
|
-
|
|
817
|
+
};
|
|
818
|
+
$ZodEncodeError = class extends Error {
|
|
819
|
+
constructor(name) {
|
|
820
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
821
|
+
this.name = "ZodEncodeError";
|
|
840
822
|
}
|
|
841
823
|
};
|
|
824
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
825
|
+
globalConfig = globalThis.__zod_globalConfig;
|
|
842
826
|
}
|
|
843
827
|
});
|
|
844
828
|
|
|
845
|
-
//
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
}
|
|
915
|
-
return { rows };
|
|
916
|
-
}
|
|
917
|
-
};
|
|
829
|
+
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
|
|
830
|
+
var util_exports = {};
|
|
831
|
+
__export(util_exports, {
|
|
832
|
+
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
|
|
833
|
+
Class: () => Class,
|
|
834
|
+
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
835
|
+
aborted: () => aborted,
|
|
836
|
+
allowsEval: () => allowsEval,
|
|
837
|
+
assert: () => assert,
|
|
838
|
+
assertEqual: () => assertEqual,
|
|
839
|
+
assertIs: () => assertIs,
|
|
840
|
+
assertNever: () => assertNever,
|
|
841
|
+
assertNotEqual: () => assertNotEqual,
|
|
842
|
+
assignProp: () => assignProp,
|
|
843
|
+
base64ToUint8Array: () => base64ToUint8Array,
|
|
844
|
+
base64urlToUint8Array: () => base64urlToUint8Array,
|
|
845
|
+
cached: () => cached,
|
|
846
|
+
captureStackTrace: () => captureStackTrace,
|
|
847
|
+
cleanEnum: () => cleanEnum,
|
|
848
|
+
cleanRegex: () => cleanRegex,
|
|
849
|
+
clone: () => clone,
|
|
850
|
+
cloneDef: () => cloneDef,
|
|
851
|
+
createTransparentProxy: () => createTransparentProxy,
|
|
852
|
+
defineLazy: () => defineLazy,
|
|
853
|
+
esc: () => esc,
|
|
854
|
+
escapeRegex: () => escapeRegex,
|
|
855
|
+
explicitlyAborted: () => explicitlyAborted,
|
|
856
|
+
extend: () => extend,
|
|
857
|
+
finalizeIssue: () => finalizeIssue,
|
|
858
|
+
floatSafeRemainder: () => floatSafeRemainder,
|
|
859
|
+
getElementAtPath: () => getElementAtPath,
|
|
860
|
+
getEnumValues: () => getEnumValues,
|
|
861
|
+
getLengthableOrigin: () => getLengthableOrigin,
|
|
862
|
+
getParsedType: () => getParsedType,
|
|
863
|
+
getSizableOrigin: () => getSizableOrigin,
|
|
864
|
+
hexToUint8Array: () => hexToUint8Array,
|
|
865
|
+
isObject: () => isObject,
|
|
866
|
+
isPlainObject: () => isPlainObject,
|
|
867
|
+
issue: () => issue,
|
|
868
|
+
joinValues: () => joinValues,
|
|
869
|
+
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
870
|
+
merge: () => merge,
|
|
871
|
+
mergeDefs: () => mergeDefs,
|
|
872
|
+
normalizeParams: () => normalizeParams,
|
|
873
|
+
nullish: () => nullish,
|
|
874
|
+
numKeys: () => numKeys,
|
|
875
|
+
objectClone: () => objectClone,
|
|
876
|
+
omit: () => omit,
|
|
877
|
+
optionalKeys: () => optionalKeys,
|
|
878
|
+
parsedType: () => parsedType,
|
|
879
|
+
partial: () => partial,
|
|
880
|
+
pick: () => pick,
|
|
881
|
+
prefixIssues: () => prefixIssues,
|
|
882
|
+
primitiveTypes: () => primitiveTypes,
|
|
883
|
+
promiseAllObject: () => promiseAllObject,
|
|
884
|
+
propertyKeyTypes: () => propertyKeyTypes,
|
|
885
|
+
randomString: () => randomString,
|
|
886
|
+
required: () => required,
|
|
887
|
+
safeExtend: () => safeExtend,
|
|
888
|
+
shallowClone: () => shallowClone,
|
|
889
|
+
slugify: () => slugify,
|
|
890
|
+
stringifyPrimitive: () => stringifyPrimitive,
|
|
891
|
+
uint8ArrayToBase64: () => uint8ArrayToBase64,
|
|
892
|
+
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
|
|
893
|
+
uint8ArrayToHex: () => uint8ArrayToHex,
|
|
894
|
+
unwrapMessage: () => unwrapMessage
|
|
895
|
+
});
|
|
896
|
+
function assertEqual(val) {
|
|
897
|
+
return val;
|
|
918
898
|
}
|
|
919
|
-
function
|
|
899
|
+
function assertNotEqual(val) {
|
|
900
|
+
return val;
|
|
901
|
+
}
|
|
902
|
+
function assertIs(_arg) {
|
|
903
|
+
}
|
|
904
|
+
function assertNever(_x) {
|
|
905
|
+
throw new Error("Unexpected value in exhaustive check");
|
|
906
|
+
}
|
|
907
|
+
function assert(_) {
|
|
908
|
+
}
|
|
909
|
+
function getEnumValues(entries) {
|
|
910
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
911
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
912
|
+
return values;
|
|
913
|
+
}
|
|
914
|
+
function joinValues(array2, separator = "|") {
|
|
915
|
+
return array2.map((val) => stringifyPrimitive(val)).join(separator);
|
|
916
|
+
}
|
|
917
|
+
function jsonStringifyReplacer(_, value) {
|
|
918
|
+
if (typeof value === "bigint")
|
|
919
|
+
return value.toString();
|
|
920
|
+
return value;
|
|
921
|
+
}
|
|
922
|
+
function cached(getter) {
|
|
923
|
+
const set2 = false;
|
|
920
924
|
return {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
for (let i = 0; i < bodyLines.length; i++) {
|
|
927
|
-
const line = bodyLines[i];
|
|
928
|
-
if (line.trim() === "")
|
|
929
|
-
continue;
|
|
930
|
-
const m = line.match(MARKERS[opts.marker]);
|
|
931
|
-
if (!m) {
|
|
932
|
-
report({
|
|
933
|
-
code: "CB_ITEM_SYNTAX",
|
|
934
|
-
severity: "warning",
|
|
935
|
-
message: `:::${node.name} expects ${opts.marker} list items. Ignored: "${line.trim()}".`,
|
|
936
|
-
blockName: node.name,
|
|
937
|
-
position: bodyLineRange(node, i)
|
|
938
|
-
});
|
|
939
|
-
continue;
|
|
940
|
-
}
|
|
941
|
-
if (opts.marker === "signed")
|
|
942
|
-
items.push({ text: m[2], sign: m[1] });
|
|
943
|
-
else
|
|
944
|
-
items.push({ text: m[1] });
|
|
945
|
-
}
|
|
946
|
-
if (opts.minItems !== void 0 && items.length < opts.minItems) {
|
|
947
|
-
report(blockDiag(node, "CB_ITEM_COUNT", `:::${node.name} needs at least ${opts.minItems} items, found ${items.length}.`));
|
|
948
|
-
}
|
|
949
|
-
if (opts.maxItems !== void 0 && items.length > opts.maxItems) {
|
|
950
|
-
report(blockDiag(node, "CB_ITEM_COUNT", `:::${node.name} allows at most ${opts.maxItems} items, found ${items.length}.`));
|
|
925
|
+
get value() {
|
|
926
|
+
if (!set2) {
|
|
927
|
+
const value = getter();
|
|
928
|
+
Object.defineProperty(this, "value", { value });
|
|
929
|
+
return value;
|
|
951
930
|
}
|
|
952
|
-
|
|
931
|
+
throw new Error("cached value already set");
|
|
953
932
|
}
|
|
954
933
|
};
|
|
955
934
|
}
|
|
956
|
-
function
|
|
957
|
-
return
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
severity: "error",
|
|
979
|
-
message: `"::${child.name}" is not allowed inside :::${node.name}. Allowed: ${opts.allowed.join(", ")}.`,
|
|
980
|
-
blockName: node.name,
|
|
981
|
-
position: child.openPosition
|
|
982
|
-
});
|
|
983
|
-
continue;
|
|
984
|
-
}
|
|
985
|
-
blocks.push(child);
|
|
986
|
-
}
|
|
987
|
-
for (const name of opts.required ?? []) {
|
|
988
|
-
if (!blocks.some((b) => b.name === name)) {
|
|
989
|
-
report(blockDiag(node, "CB_CHILD_MISSING", `:::${node.name} requires a ::${name} child.`));
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
const count = blocks.length;
|
|
993
|
-
if (opts.minChildren !== void 0 && count < opts.minChildren) {
|
|
994
|
-
report(blockDiag(node, "CB_CHILD_COUNT", `:::${node.name} needs at least ${opts.minChildren} children, found ${count}.`));
|
|
935
|
+
function nullish(input) {
|
|
936
|
+
return input === null || input === void 0;
|
|
937
|
+
}
|
|
938
|
+
function cleanRegex(source) {
|
|
939
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
940
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
941
|
+
return source.slice(start, end);
|
|
942
|
+
}
|
|
943
|
+
function floatSafeRemainder(val, step) {
|
|
944
|
+
const ratio = val / step;
|
|
945
|
+
const roundedRatio = Math.round(ratio);
|
|
946
|
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
947
|
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
948
|
+
return 0;
|
|
949
|
+
return ratio - roundedRatio;
|
|
950
|
+
}
|
|
951
|
+
function defineLazy(object2, key, getter) {
|
|
952
|
+
let value = void 0;
|
|
953
|
+
Object.defineProperty(object2, key, {
|
|
954
|
+
get() {
|
|
955
|
+
if (value === EVALUATING) {
|
|
956
|
+
return void 0;
|
|
995
957
|
}
|
|
996
|
-
if (
|
|
997
|
-
|
|
958
|
+
if (value === void 0) {
|
|
959
|
+
value = EVALUATING;
|
|
960
|
+
value = getter();
|
|
998
961
|
}
|
|
999
|
-
return
|
|
1000
|
-
}
|
|
1001
|
-
|
|
962
|
+
return value;
|
|
963
|
+
},
|
|
964
|
+
set(v) {
|
|
965
|
+
Object.defineProperty(object2, key, {
|
|
966
|
+
value: v
|
|
967
|
+
// configurable: true,
|
|
968
|
+
});
|
|
969
|
+
},
|
|
970
|
+
configurable: true
|
|
971
|
+
});
|
|
1002
972
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
"../core/dist/content-models.js"() {
|
|
1006
|
-
"use strict";
|
|
1007
|
-
init_position();
|
|
1008
|
-
ROW_RE = /^\s*-\s+(.*)$/;
|
|
1009
|
-
UNESCAPED_PIPE = /(?<!\\)\|/;
|
|
1010
|
-
MARKERS = {
|
|
1011
|
-
bullet: /^\s*-\s+(.*)$/,
|
|
1012
|
-
ordered: /^\s*\d+[.)]\s+(.*)$/,
|
|
1013
|
-
signed: /^\s*([+-])\s+(.*)$/
|
|
1014
|
-
};
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
// ../core/dist/validate.js
|
|
1019
|
-
function isValidatedBlock(node) {
|
|
1020
|
-
return node.type === "block" && "data" in node && "definition" in node;
|
|
973
|
+
function objectClone(obj) {
|
|
974
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
1021
975
|
}
|
|
1022
|
-
function
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
if (!allowed.includes(protocol)) {
|
|
1030
|
-
report({
|
|
1031
|
-
code: "CB_URL_PROTOCOL",
|
|
1032
|
-
severity: "error",
|
|
1033
|
-
message: `URL protocol "${protocol}" is not allowed.`,
|
|
1034
|
-
hint: `Allowed: ${allowed.join(", ")}. Configure via validateDocument options.allowedProtocols.`,
|
|
1035
|
-
position
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
976
|
+
function assignProp(target, prop, value) {
|
|
977
|
+
Object.defineProperty(target, prop, {
|
|
978
|
+
value,
|
|
979
|
+
writable: true,
|
|
980
|
+
enumerable: true,
|
|
981
|
+
configurable: true
|
|
982
|
+
});
|
|
1039
983
|
}
|
|
1040
|
-
function
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
};
|
|
1046
|
-
const diagnostics = [...parsed.diagnostics];
|
|
1047
|
-
const report = (d) => diagnostics.push(d);
|
|
1048
|
-
function walk(nodes, parent, depth) {
|
|
1049
|
-
for (const node of nodes) {
|
|
1050
|
-
if (node.type === "markdown") {
|
|
1051
|
-
checkUrls(node.value, node.position, opts.allowedProtocols, report);
|
|
1052
|
-
continue;
|
|
1053
|
-
}
|
|
1054
|
-
if (depth > opts.maxDepth) {
|
|
1055
|
-
report({
|
|
1056
|
-
code: "CB_NESTING_DEPTH",
|
|
1057
|
-
severity: "error",
|
|
1058
|
-
message: `Block "${node.name}" exceeds the maximum nesting depth of ${opts.maxDepth}.`,
|
|
1059
|
-
blockName: node.name,
|
|
1060
|
-
position: node.openPosition
|
|
1061
|
-
});
|
|
1062
|
-
continue;
|
|
1063
|
-
}
|
|
1064
|
-
const def = registry2.get(node.name);
|
|
1065
|
-
if (!def) {
|
|
1066
|
-
report({
|
|
1067
|
-
code: "CB_UNKNOWN_BLOCK",
|
|
1068
|
-
severity: opts.unknownBlocks,
|
|
1069
|
-
message: `Unknown block "${node.name}".`,
|
|
1070
|
-
hint: `Known blocks: ${registry2.all().map((d) => d.name).join(", ")}.`,
|
|
1071
|
-
blockName: node.name,
|
|
1072
|
-
position: node.openPosition
|
|
1073
|
-
});
|
|
1074
|
-
continue;
|
|
1075
|
-
}
|
|
1076
|
-
let valid = true;
|
|
1077
|
-
if (def.childOnly && parent === null) {
|
|
1078
|
-
valid = false;
|
|
1079
|
-
report({
|
|
1080
|
-
code: "CB_CHILD_ONLY",
|
|
1081
|
-
severity: "error",
|
|
1082
|
-
message: `"${node.name}" is a child block and cannot be used at the top level.`,
|
|
1083
|
-
blockName: node.name,
|
|
1084
|
-
position: node.openPosition
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
|
-
if (def.props) {
|
|
1088
|
-
const result = def.props.safeParse(node.props);
|
|
1089
|
-
if (result.success) {
|
|
1090
|
-
node.props = result.data;
|
|
1091
|
-
} else {
|
|
1092
|
-
valid = false;
|
|
1093
|
-
for (const issue2 of result.error.issues) {
|
|
1094
|
-
report({
|
|
1095
|
-
code: "CB_PROPS_INVALID",
|
|
1096
|
-
severity: "error",
|
|
1097
|
-
message: `${node.name}: prop "${issue2.path.join(".") || "(root)"}" ${issue2.message}`,
|
|
1098
|
-
blockName: node.name,
|
|
1099
|
-
position: node.openPosition
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
const before = diagnostics.length;
|
|
1105
|
-
const data = def.content.parse(node, report);
|
|
1106
|
-
let contentError = false;
|
|
1107
|
-
for (let j = before; j < diagnostics.length; j++) {
|
|
1108
|
-
if (diagnostics[j].severity === "error") {
|
|
1109
|
-
contentError = true;
|
|
1110
|
-
break;
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
if (contentError)
|
|
1114
|
-
valid = false;
|
|
1115
|
-
if (valid) {
|
|
1116
|
-
;
|
|
1117
|
-
node.data = data;
|
|
1118
|
-
node.definition = def;
|
|
1119
|
-
}
|
|
1120
|
-
walk(node.children, node, depth + 1);
|
|
1121
|
-
}
|
|
984
|
+
function mergeDefs(...defs) {
|
|
985
|
+
const mergedDescriptors = {};
|
|
986
|
+
for (const def of defs) {
|
|
987
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
988
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
1122
989
|
}
|
|
1123
|
-
|
|
1124
|
-
const ok = !diagnostics.some((d) => d.severity === "error");
|
|
1125
|
-
return { ok, document: parsed.document, diagnostics };
|
|
990
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
1126
991
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
"../core/dist/validate.js"() {
|
|
1130
|
-
"use strict";
|
|
1131
|
-
LINK_URL_RE = /\]\(([^)\s]+)/g;
|
|
1132
|
-
HAS_SCHEME_RE = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
1133
|
-
}
|
|
1134
|
-
});
|
|
1135
|
-
|
|
1136
|
-
// ../core/dist/render-markdown.js
|
|
1137
|
-
function renderToMarkdown(document, opts = {}) {
|
|
1138
|
-
const ctx = {
|
|
1139
|
-
renderNodes(nodes) {
|
|
1140
|
-
return nodes.map((node) => {
|
|
1141
|
-
if (node.type === "markdown")
|
|
1142
|
-
return node.value.trim();
|
|
1143
|
-
const renderer = opts.renderers?.[node.name];
|
|
1144
|
-
if (renderer && isValidatedBlock(node))
|
|
1145
|
-
return renderer(node, ctx).trim();
|
|
1146
|
-
return node.body.trim();
|
|
1147
|
-
}).filter((s) => s !== "").join("\n\n");
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
return ctx.renderNodes(document.children) + "\n";
|
|
992
|
+
function cloneDef(schema) {
|
|
993
|
+
return mergeDefs(schema._zod.def);
|
|
1151
994
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
function init(inst, def) {
|
|
1163
|
-
if (!inst._zod) {
|
|
1164
|
-
Object.defineProperty(inst, "_zod", {
|
|
1165
|
-
value: {
|
|
1166
|
-
def,
|
|
1167
|
-
constr: _,
|
|
1168
|
-
traits: /* @__PURE__ */ new Set()
|
|
1169
|
-
},
|
|
1170
|
-
enumerable: false
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
if (inst._zod.traits.has(name)) {
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
inst._zod.traits.add(name);
|
|
1177
|
-
initializer3(inst, def);
|
|
1178
|
-
const proto = _.prototype;
|
|
1179
|
-
const keys = Object.keys(proto);
|
|
995
|
+
function getElementAtPath(obj, path) {
|
|
996
|
+
if (!path)
|
|
997
|
+
return obj;
|
|
998
|
+
return path.reduce((acc, key) => acc?.[key], obj);
|
|
999
|
+
}
|
|
1000
|
+
function promiseAllObject(promisesObj) {
|
|
1001
|
+
const keys = Object.keys(promisesObj);
|
|
1002
|
+
const promises = keys.map((key) => promisesObj[key]);
|
|
1003
|
+
return Promise.all(promises).then((results) => {
|
|
1004
|
+
const resolvedObj = {};
|
|
1180
1005
|
for (let i = 0; i < keys.length; i++) {
|
|
1181
|
-
|
|
1182
|
-
if (!(k in inst)) {
|
|
1183
|
-
inst[k] = proto[k].bind(inst);
|
|
1184
|
-
}
|
|
1006
|
+
resolvedObj[keys[i]] = results[i];
|
|
1185
1007
|
}
|
|
1008
|
+
return resolvedObj;
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
function randomString(length = 10) {
|
|
1012
|
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
1013
|
+
let str = "";
|
|
1014
|
+
for (let i = 0; i < length; i++) {
|
|
1015
|
+
str += chars[Math.floor(Math.random() * chars.length)];
|
|
1186
1016
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1017
|
+
return str;
|
|
1018
|
+
}
|
|
1019
|
+
function esc(str) {
|
|
1020
|
+
return JSON.stringify(str);
|
|
1021
|
+
}
|
|
1022
|
+
function slugify(input) {
|
|
1023
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1024
|
+
}
|
|
1025
|
+
function isObject(data) {
|
|
1026
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
1027
|
+
}
|
|
1028
|
+
function isPlainObject(o) {
|
|
1029
|
+
if (isObject(o) === false)
|
|
1030
|
+
return false;
|
|
1031
|
+
const ctor = o.constructor;
|
|
1032
|
+
if (ctor === void 0)
|
|
1033
|
+
return true;
|
|
1034
|
+
if (typeof ctor !== "function")
|
|
1035
|
+
return true;
|
|
1036
|
+
const prot = ctor.prototype;
|
|
1037
|
+
if (isObject(prot) === false)
|
|
1038
|
+
return false;
|
|
1039
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
1040
|
+
return false;
|
|
1189
1041
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1042
|
+
return true;
|
|
1043
|
+
}
|
|
1044
|
+
function shallowClone(o) {
|
|
1045
|
+
if (isPlainObject(o))
|
|
1046
|
+
return { ...o };
|
|
1047
|
+
if (Array.isArray(o))
|
|
1048
|
+
return [...o];
|
|
1049
|
+
if (o instanceof Map)
|
|
1050
|
+
return new Map(o);
|
|
1051
|
+
if (o instanceof Set)
|
|
1052
|
+
return new Set(o);
|
|
1053
|
+
return o;
|
|
1054
|
+
}
|
|
1055
|
+
function numKeys(data) {
|
|
1056
|
+
let keyCount = 0;
|
|
1057
|
+
for (const key in data) {
|
|
1058
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
1059
|
+
keyCount++;
|
|
1198
1060
|
}
|
|
1199
|
-
return inst;
|
|
1200
1061
|
}
|
|
1201
|
-
|
|
1202
|
-
Object.defineProperty(_, Symbol.hasInstance, {
|
|
1203
|
-
value: (inst) => {
|
|
1204
|
-
if (params?.Parent && inst instanceof params.Parent)
|
|
1205
|
-
return true;
|
|
1206
|
-
return inst?._zod?.traits?.has(name);
|
|
1207
|
-
}
|
|
1208
|
-
});
|
|
1209
|
-
Object.defineProperty(_, "name", { value: name });
|
|
1210
|
-
return _;
|
|
1062
|
+
return keyCount;
|
|
1211
1063
|
}
|
|
1212
|
-
function
|
|
1213
|
-
|
|
1214
|
-
Object.assign(globalConfig, newConfig);
|
|
1215
|
-
return globalConfig;
|
|
1216
|
-
}
|
|
1217
|
-
var _a, NEVER, $brand, $ZodAsyncError, $ZodEncodeError, globalConfig;
|
|
1218
|
-
var init_core = __esm({
|
|
1219
|
-
"../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js"() {
|
|
1220
|
-
NEVER = /* @__PURE__ */ Object.freeze({
|
|
1221
|
-
status: "aborted"
|
|
1222
|
-
});
|
|
1223
|
-
$brand = /* @__PURE__ */ Symbol("zod_brand");
|
|
1224
|
-
$ZodAsyncError = class extends Error {
|
|
1225
|
-
constructor() {
|
|
1226
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
$ZodEncodeError = class extends Error {
|
|
1230
|
-
constructor(name) {
|
|
1231
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
1232
|
-
this.name = "ZodEncodeError";
|
|
1233
|
-
}
|
|
1234
|
-
};
|
|
1235
|
-
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
1236
|
-
globalConfig = globalThis.__zod_globalConfig;
|
|
1237
|
-
}
|
|
1238
|
-
});
|
|
1239
|
-
|
|
1240
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
|
|
1241
|
-
var util_exports = {};
|
|
1242
|
-
__export(util_exports, {
|
|
1243
|
-
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
|
|
1244
|
-
Class: () => Class,
|
|
1245
|
-
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
1246
|
-
aborted: () => aborted,
|
|
1247
|
-
allowsEval: () => allowsEval,
|
|
1248
|
-
assert: () => assert,
|
|
1249
|
-
assertEqual: () => assertEqual,
|
|
1250
|
-
assertIs: () => assertIs,
|
|
1251
|
-
assertNever: () => assertNever,
|
|
1252
|
-
assertNotEqual: () => assertNotEqual,
|
|
1253
|
-
assignProp: () => assignProp,
|
|
1254
|
-
base64ToUint8Array: () => base64ToUint8Array,
|
|
1255
|
-
base64urlToUint8Array: () => base64urlToUint8Array,
|
|
1256
|
-
cached: () => cached,
|
|
1257
|
-
captureStackTrace: () => captureStackTrace,
|
|
1258
|
-
cleanEnum: () => cleanEnum,
|
|
1259
|
-
cleanRegex: () => cleanRegex,
|
|
1260
|
-
clone: () => clone,
|
|
1261
|
-
cloneDef: () => cloneDef,
|
|
1262
|
-
createTransparentProxy: () => createTransparentProxy,
|
|
1263
|
-
defineLazy: () => defineLazy,
|
|
1264
|
-
esc: () => esc,
|
|
1265
|
-
escapeRegex: () => escapeRegex,
|
|
1266
|
-
explicitlyAborted: () => explicitlyAborted,
|
|
1267
|
-
extend: () => extend,
|
|
1268
|
-
finalizeIssue: () => finalizeIssue,
|
|
1269
|
-
floatSafeRemainder: () => floatSafeRemainder,
|
|
1270
|
-
getElementAtPath: () => getElementAtPath,
|
|
1271
|
-
getEnumValues: () => getEnumValues,
|
|
1272
|
-
getLengthableOrigin: () => getLengthableOrigin,
|
|
1273
|
-
getParsedType: () => getParsedType,
|
|
1274
|
-
getSizableOrigin: () => getSizableOrigin,
|
|
1275
|
-
hexToUint8Array: () => hexToUint8Array,
|
|
1276
|
-
isObject: () => isObject,
|
|
1277
|
-
isPlainObject: () => isPlainObject,
|
|
1278
|
-
issue: () => issue,
|
|
1279
|
-
joinValues: () => joinValues,
|
|
1280
|
-
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
1281
|
-
merge: () => merge,
|
|
1282
|
-
mergeDefs: () => mergeDefs,
|
|
1283
|
-
normalizeParams: () => normalizeParams,
|
|
1284
|
-
nullish: () => nullish,
|
|
1285
|
-
numKeys: () => numKeys,
|
|
1286
|
-
objectClone: () => objectClone,
|
|
1287
|
-
omit: () => omit,
|
|
1288
|
-
optionalKeys: () => optionalKeys,
|
|
1289
|
-
parsedType: () => parsedType,
|
|
1290
|
-
partial: () => partial,
|
|
1291
|
-
pick: () => pick,
|
|
1292
|
-
prefixIssues: () => prefixIssues,
|
|
1293
|
-
primitiveTypes: () => primitiveTypes,
|
|
1294
|
-
promiseAllObject: () => promiseAllObject,
|
|
1295
|
-
propertyKeyTypes: () => propertyKeyTypes,
|
|
1296
|
-
randomString: () => randomString,
|
|
1297
|
-
required: () => required,
|
|
1298
|
-
safeExtend: () => safeExtend,
|
|
1299
|
-
shallowClone: () => shallowClone,
|
|
1300
|
-
slugify: () => slugify,
|
|
1301
|
-
stringifyPrimitive: () => stringifyPrimitive,
|
|
1302
|
-
uint8ArrayToBase64: () => uint8ArrayToBase64,
|
|
1303
|
-
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
|
|
1304
|
-
uint8ArrayToHex: () => uint8ArrayToHex,
|
|
1305
|
-
unwrapMessage: () => unwrapMessage
|
|
1306
|
-
});
|
|
1307
|
-
function assertEqual(val) {
|
|
1308
|
-
return val;
|
|
1309
|
-
}
|
|
1310
|
-
function assertNotEqual(val) {
|
|
1311
|
-
return val;
|
|
1312
|
-
}
|
|
1313
|
-
function assertIs(_arg) {
|
|
1314
|
-
}
|
|
1315
|
-
function assertNever(_x) {
|
|
1316
|
-
throw new Error("Unexpected value in exhaustive check");
|
|
1317
|
-
}
|
|
1318
|
-
function assert(_) {
|
|
1319
|
-
}
|
|
1320
|
-
function getEnumValues(entries) {
|
|
1321
|
-
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
1322
|
-
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
1323
|
-
return values;
|
|
1324
|
-
}
|
|
1325
|
-
function joinValues(array2, separator = "|") {
|
|
1326
|
-
return array2.map((val) => stringifyPrimitive(val)).join(separator);
|
|
1327
|
-
}
|
|
1328
|
-
function jsonStringifyReplacer(_, value) {
|
|
1329
|
-
if (typeof value === "bigint")
|
|
1330
|
-
return value.toString();
|
|
1331
|
-
return value;
|
|
1332
|
-
}
|
|
1333
|
-
function cached(getter) {
|
|
1334
|
-
const set2 = false;
|
|
1335
|
-
return {
|
|
1336
|
-
get value() {
|
|
1337
|
-
if (!set2) {
|
|
1338
|
-
const value = getter();
|
|
1339
|
-
Object.defineProperty(this, "value", { value });
|
|
1340
|
-
return value;
|
|
1341
|
-
}
|
|
1342
|
-
throw new Error("cached value already set");
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
}
|
|
1346
|
-
function nullish(input) {
|
|
1347
|
-
return input === null || input === void 0;
|
|
1064
|
+
function escapeRegex(str) {
|
|
1065
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1348
1066
|
}
|
|
1349
|
-
function
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1352
|
-
|
|
1067
|
+
function clone(inst, def, params) {
|
|
1068
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
1069
|
+
if (!def || params?.parent)
|
|
1070
|
+
cl._zod.parent = inst;
|
|
1071
|
+
return cl;
|
|
1353
1072
|
}
|
|
1354
|
-
function
|
|
1355
|
-
const
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
if (
|
|
1359
|
-
return
|
|
1360
|
-
|
|
1073
|
+
function normalizeParams(_params) {
|
|
1074
|
+
const params = _params;
|
|
1075
|
+
if (!params)
|
|
1076
|
+
return {};
|
|
1077
|
+
if (typeof params === "string")
|
|
1078
|
+
return { error: () => params };
|
|
1079
|
+
if (params?.message !== void 0) {
|
|
1080
|
+
if (params?.error !== void 0)
|
|
1081
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
1082
|
+
params.error = params.message;
|
|
1083
|
+
}
|
|
1084
|
+
delete params.message;
|
|
1085
|
+
if (typeof params.error === "string")
|
|
1086
|
+
return { ...params, error: () => params.error };
|
|
1087
|
+
return params;
|
|
1361
1088
|
}
|
|
1362
|
-
function
|
|
1363
|
-
let
|
|
1364
|
-
|
|
1365
|
-
get() {
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1369
|
-
if (value === void 0) {
|
|
1370
|
-
value = EVALUATING;
|
|
1371
|
-
value = getter();
|
|
1372
|
-
}
|
|
1373
|
-
return value;
|
|
1089
|
+
function createTransparentProxy(getter) {
|
|
1090
|
+
let target;
|
|
1091
|
+
return new Proxy({}, {
|
|
1092
|
+
get(_, prop, receiver) {
|
|
1093
|
+
target ?? (target = getter());
|
|
1094
|
+
return Reflect.get(target, prop, receiver);
|
|
1374
1095
|
},
|
|
1375
|
-
set(
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
// configurable: true,
|
|
1379
|
-
});
|
|
1096
|
+
set(_, prop, value, receiver) {
|
|
1097
|
+
target ?? (target = getter());
|
|
1098
|
+
return Reflect.set(target, prop, value, receiver);
|
|
1380
1099
|
},
|
|
1381
|
-
|
|
1100
|
+
has(_, prop) {
|
|
1101
|
+
target ?? (target = getter());
|
|
1102
|
+
return Reflect.has(target, prop);
|
|
1103
|
+
},
|
|
1104
|
+
deleteProperty(_, prop) {
|
|
1105
|
+
target ?? (target = getter());
|
|
1106
|
+
return Reflect.deleteProperty(target, prop);
|
|
1107
|
+
},
|
|
1108
|
+
ownKeys(_) {
|
|
1109
|
+
target ?? (target = getter());
|
|
1110
|
+
return Reflect.ownKeys(target);
|
|
1111
|
+
},
|
|
1112
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
1113
|
+
target ?? (target = getter());
|
|
1114
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
1115
|
+
},
|
|
1116
|
+
defineProperty(_, prop, descriptor) {
|
|
1117
|
+
target ?? (target = getter());
|
|
1118
|
+
return Reflect.defineProperty(target, prop, descriptor);
|
|
1119
|
+
}
|
|
1382
1120
|
});
|
|
1383
1121
|
}
|
|
1384
|
-
function
|
|
1385
|
-
|
|
1122
|
+
function stringifyPrimitive(value) {
|
|
1123
|
+
if (typeof value === "bigint")
|
|
1124
|
+
return value.toString() + "n";
|
|
1125
|
+
if (typeof value === "string")
|
|
1126
|
+
return `"${value}"`;
|
|
1127
|
+
return `${value}`;
|
|
1386
1128
|
}
|
|
1387
|
-
function
|
|
1388
|
-
Object.
|
|
1389
|
-
|
|
1390
|
-
writable: true,
|
|
1391
|
-
enumerable: true,
|
|
1392
|
-
configurable: true
|
|
1129
|
+
function optionalKeys(shape) {
|
|
1130
|
+
return Object.keys(shape).filter((k) => {
|
|
1131
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
1393
1132
|
});
|
|
1394
1133
|
}
|
|
1395
|
-
function
|
|
1396
|
-
const
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
1402
|
-
}
|
|
1403
|
-
function cloneDef(schema) {
|
|
1404
|
-
return mergeDefs(schema._zod.def);
|
|
1405
|
-
}
|
|
1406
|
-
function getElementAtPath(obj, path) {
|
|
1407
|
-
if (!path)
|
|
1408
|
-
return obj;
|
|
1409
|
-
return path.reduce((acc, key) => acc?.[key], obj);
|
|
1410
|
-
}
|
|
1411
|
-
function promiseAllObject(promisesObj) {
|
|
1412
|
-
const keys = Object.keys(promisesObj);
|
|
1413
|
-
const promises = keys.map((key) => promisesObj[key]);
|
|
1414
|
-
return Promise.all(promises).then((results) => {
|
|
1415
|
-
const resolvedObj = {};
|
|
1416
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1417
|
-
resolvedObj[keys[i]] = results[i];
|
|
1418
|
-
}
|
|
1419
|
-
return resolvedObj;
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
function randomString(length = 10) {
|
|
1423
|
-
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
1424
|
-
let str = "";
|
|
1425
|
-
for (let i = 0; i < length; i++) {
|
|
1426
|
-
str += chars[Math.floor(Math.random() * chars.length)];
|
|
1427
|
-
}
|
|
1428
|
-
return str;
|
|
1429
|
-
}
|
|
1430
|
-
function esc(str) {
|
|
1431
|
-
return JSON.stringify(str);
|
|
1432
|
-
}
|
|
1433
|
-
function slugify(input) {
|
|
1434
|
-
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1435
|
-
}
|
|
1436
|
-
function isObject(data) {
|
|
1437
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
1438
|
-
}
|
|
1439
|
-
function isPlainObject(o) {
|
|
1440
|
-
if (isObject(o) === false)
|
|
1441
|
-
return false;
|
|
1442
|
-
const ctor = o.constructor;
|
|
1443
|
-
if (ctor === void 0)
|
|
1444
|
-
return true;
|
|
1445
|
-
if (typeof ctor !== "function")
|
|
1446
|
-
return true;
|
|
1447
|
-
const prot = ctor.prototype;
|
|
1448
|
-
if (isObject(prot) === false)
|
|
1449
|
-
return false;
|
|
1450
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
1451
|
-
return false;
|
|
1452
|
-
}
|
|
1453
|
-
return true;
|
|
1454
|
-
}
|
|
1455
|
-
function shallowClone(o) {
|
|
1456
|
-
if (isPlainObject(o))
|
|
1457
|
-
return { ...o };
|
|
1458
|
-
if (Array.isArray(o))
|
|
1459
|
-
return [...o];
|
|
1460
|
-
if (o instanceof Map)
|
|
1461
|
-
return new Map(o);
|
|
1462
|
-
if (o instanceof Set)
|
|
1463
|
-
return new Set(o);
|
|
1464
|
-
return o;
|
|
1465
|
-
}
|
|
1466
|
-
function numKeys(data) {
|
|
1467
|
-
let keyCount = 0;
|
|
1468
|
-
for (const key in data) {
|
|
1469
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
1470
|
-
keyCount++;
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
return keyCount;
|
|
1474
|
-
}
|
|
1475
|
-
function escapeRegex(str) {
|
|
1476
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1477
|
-
}
|
|
1478
|
-
function clone(inst, def, params) {
|
|
1479
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
1480
|
-
if (!def || params?.parent)
|
|
1481
|
-
cl._zod.parent = inst;
|
|
1482
|
-
return cl;
|
|
1483
|
-
}
|
|
1484
|
-
function normalizeParams(_params) {
|
|
1485
|
-
const params = _params;
|
|
1486
|
-
if (!params)
|
|
1487
|
-
return {};
|
|
1488
|
-
if (typeof params === "string")
|
|
1489
|
-
return { error: () => params };
|
|
1490
|
-
if (params?.message !== void 0) {
|
|
1491
|
-
if (params?.error !== void 0)
|
|
1492
|
-
throw new Error("Cannot specify both `message` and `error` params");
|
|
1493
|
-
params.error = params.message;
|
|
1494
|
-
}
|
|
1495
|
-
delete params.message;
|
|
1496
|
-
if (typeof params.error === "string")
|
|
1497
|
-
return { ...params, error: () => params.error };
|
|
1498
|
-
return params;
|
|
1499
|
-
}
|
|
1500
|
-
function createTransparentProxy(getter) {
|
|
1501
|
-
let target;
|
|
1502
|
-
return new Proxy({}, {
|
|
1503
|
-
get(_, prop, receiver) {
|
|
1504
|
-
target ?? (target = getter());
|
|
1505
|
-
return Reflect.get(target, prop, receiver);
|
|
1506
|
-
},
|
|
1507
|
-
set(_, prop, value, receiver) {
|
|
1508
|
-
target ?? (target = getter());
|
|
1509
|
-
return Reflect.set(target, prop, value, receiver);
|
|
1510
|
-
},
|
|
1511
|
-
has(_, prop) {
|
|
1512
|
-
target ?? (target = getter());
|
|
1513
|
-
return Reflect.has(target, prop);
|
|
1514
|
-
},
|
|
1515
|
-
deleteProperty(_, prop) {
|
|
1516
|
-
target ?? (target = getter());
|
|
1517
|
-
return Reflect.deleteProperty(target, prop);
|
|
1518
|
-
},
|
|
1519
|
-
ownKeys(_) {
|
|
1520
|
-
target ?? (target = getter());
|
|
1521
|
-
return Reflect.ownKeys(target);
|
|
1522
|
-
},
|
|
1523
|
-
getOwnPropertyDescriptor(_, prop) {
|
|
1524
|
-
target ?? (target = getter());
|
|
1525
|
-
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
1526
|
-
},
|
|
1527
|
-
defineProperty(_, prop, descriptor) {
|
|
1528
|
-
target ?? (target = getter());
|
|
1529
|
-
return Reflect.defineProperty(target, prop, descriptor);
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
}
|
|
1533
|
-
function stringifyPrimitive(value) {
|
|
1534
|
-
if (typeof value === "bigint")
|
|
1535
|
-
return value.toString() + "n";
|
|
1536
|
-
if (typeof value === "string")
|
|
1537
|
-
return `"${value}"`;
|
|
1538
|
-
return `${value}`;
|
|
1539
|
-
}
|
|
1540
|
-
function optionalKeys(shape) {
|
|
1541
|
-
return Object.keys(shape).filter((k) => {
|
|
1542
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
function pick(schema, mask) {
|
|
1546
|
-
const currDef = schema._zod.def;
|
|
1547
|
-
const checks = currDef.checks;
|
|
1548
|
-
const hasChecks = checks && checks.length > 0;
|
|
1549
|
-
if (hasChecks) {
|
|
1550
|
-
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
1134
|
+
function pick(schema, mask) {
|
|
1135
|
+
const currDef = schema._zod.def;
|
|
1136
|
+
const checks = currDef.checks;
|
|
1137
|
+
const hasChecks = checks && checks.length > 0;
|
|
1138
|
+
if (hasChecks) {
|
|
1139
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
1551
1140
|
}
|
|
1552
1141
|
const def = mergeDefs(schema._zod.def, {
|
|
1553
1142
|
get shape() {
|
|
@@ -7145,13 +6734,13 @@ var init_he = __esm({
|
|
|
7145
6734
|
return `${sizing?.longLabel ?? "\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${subject} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${issue2.maximum.toString()} ${sizing?.unit ?? ""} ${issue2.inclusive ? "\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA" : "\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();
|
|
7146
6735
|
}
|
|
7147
6736
|
if (issue2.origin === "number") {
|
|
7148
|
-
const
|
|
7149
|
-
return `\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${subject} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${
|
|
6737
|
+
const comparison = issue2.inclusive ? `\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${issue2.maximum}` : `\u05E7\u05D8\u05DF \u05DE-${issue2.maximum}`;
|
|
6738
|
+
return `\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${subject} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${comparison}`;
|
|
7150
6739
|
}
|
|
7151
6740
|
if (issue2.origin === "array" || issue2.origin === "set") {
|
|
7152
6741
|
const verb = issue2.origin === "set" ? "\u05E6\u05E8\u05D9\u05DB\u05D4" : "\u05E6\u05E8\u05D9\u05DA";
|
|
7153
|
-
const
|
|
7154
|
-
return `\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${subject} ${verb} \u05DC\u05D4\u05DB\u05D9\u05DC ${
|
|
6742
|
+
const comparison = issue2.inclusive ? `${issue2.maximum} ${sizing?.unit ?? ""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA` : `\u05E4\u05D7\u05D5\u05EA \u05DE-${issue2.maximum} ${sizing?.unit ?? ""}`;
|
|
6743
|
+
return `\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${subject} ${verb} \u05DC\u05D4\u05DB\u05D9\u05DC ${comparison}`.trim();
|
|
7155
6744
|
}
|
|
7156
6745
|
const adj = issue2.inclusive ? "<=" : "<";
|
|
7157
6746
|
const be = verbFor(issue2.origin ?? "value");
|
|
@@ -7167,8 +6756,8 @@ var init_he = __esm({
|
|
|
7167
6756
|
return `${sizing?.shortLabel ?? "\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${subject} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${issue2.minimum.toString()} ${sizing?.unit ?? ""} ${issue2.inclusive ? "\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8" : "\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();
|
|
7168
6757
|
}
|
|
7169
6758
|
if (issue2.origin === "number") {
|
|
7170
|
-
const
|
|
7171
|
-
return `\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${subject} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${
|
|
6759
|
+
const comparison = issue2.inclusive ? `\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${issue2.minimum}` : `\u05D2\u05D3\u05D5\u05DC \u05DE-${issue2.minimum}`;
|
|
6760
|
+
return `\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${subject} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${comparison}`;
|
|
7172
6761
|
}
|
|
7173
6762
|
if (issue2.origin === "array" || issue2.origin === "set") {
|
|
7174
6763
|
const verb = issue2.origin === "set" ? "\u05E6\u05E8\u05D9\u05DB\u05D4" : "\u05E6\u05E8\u05D9\u05DA";
|
|
@@ -7176,8 +6765,8 @@ var init_he = __esm({
|
|
|
7176
6765
|
const singularPhrase = issue2.origin === "set" ? "\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3" : "\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3";
|
|
7177
6766
|
return `\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${subject} ${verb} \u05DC\u05D4\u05DB\u05D9\u05DC ${singularPhrase}`;
|
|
7178
6767
|
}
|
|
7179
|
-
const
|
|
7180
|
-
return `\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${subject} ${verb} \u05DC\u05D4\u05DB\u05D9\u05DC ${
|
|
6768
|
+
const comparison = issue2.inclusive ? `${issue2.minimum} ${sizing?.unit ?? ""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8` : `\u05D9\u05D5\u05EA\u05E8 \u05DE-${issue2.minimum} ${sizing?.unit ?? ""}`;
|
|
6769
|
+
return `\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${subject} ${verb} \u05DC\u05D4\u05DB\u05D9\u05DC ${comparison}`.trim();
|
|
7181
6770
|
}
|
|
7182
6771
|
const adj = issue2.inclusive ? ">=" : ">";
|
|
7183
6772
|
const be = verbFor(issue2.origin ?? "value");
|
|
@@ -16650,14 +16239,640 @@ var init_links = __esm({
|
|
|
16650
16239
|
}
|
|
16651
16240
|
});
|
|
16652
16241
|
|
|
16242
|
+
// ../core/dist/validate.js
|
|
16243
|
+
function isValidatedDocument(document) {
|
|
16244
|
+
return document.__contentbitValidatedDocument === true;
|
|
16245
|
+
}
|
|
16246
|
+
function isValidatedBlock(node) {
|
|
16247
|
+
return node.type === "block" && "data" in node && "definition" in node;
|
|
16248
|
+
}
|
|
16249
|
+
function checkUrls(value, position, allowed, report) {
|
|
16250
|
+
for (const match of value.matchAll(LINK_URL_RE)) {
|
|
16251
|
+
const url2 = match[1];
|
|
16252
|
+
const scheme = url2.match(HAS_SCHEME_RE);
|
|
16253
|
+
if (!scheme)
|
|
16254
|
+
continue;
|
|
16255
|
+
const protocol = `${scheme[0].slice(0, -1).toLowerCase()}:`;
|
|
16256
|
+
if (!allowed.includes(protocol)) {
|
|
16257
|
+
report({
|
|
16258
|
+
code: "CB_URL_PROTOCOL",
|
|
16259
|
+
severity: "error",
|
|
16260
|
+
message: `URL protocol "${protocol}" is not allowed.`,
|
|
16261
|
+
hint: `Allowed: ${allowed.join(", ")}. Configure via validateDocument options.allowedProtocols.`,
|
|
16262
|
+
position
|
|
16263
|
+
});
|
|
16264
|
+
}
|
|
16265
|
+
}
|
|
16266
|
+
}
|
|
16267
|
+
function validateDocument(parsed, registry2, options = {}) {
|
|
16268
|
+
const opts = {
|
|
16269
|
+
unknownBlocks: options.unknownBlocks ?? "error",
|
|
16270
|
+
maxDepth: options.maxDepth ?? 4,
|
|
16271
|
+
allowedProtocols: options.allowedProtocols ?? ["http:", "https:", "mailto:"]
|
|
16272
|
+
};
|
|
16273
|
+
const diagnostics = [...parsed.diagnostics];
|
|
16274
|
+
const report = (d) => diagnostics.push(d);
|
|
16275
|
+
function walk(nodes, parent, depth) {
|
|
16276
|
+
for (const node of nodes) {
|
|
16277
|
+
if (node.type === "markdown") {
|
|
16278
|
+
checkUrls(node.value, node.position, opts.allowedProtocols, report);
|
|
16279
|
+
continue;
|
|
16280
|
+
}
|
|
16281
|
+
if (depth > opts.maxDepth) {
|
|
16282
|
+
report({
|
|
16283
|
+
code: "CB_NESTING_DEPTH",
|
|
16284
|
+
severity: "error",
|
|
16285
|
+
message: `Block "${node.name}" exceeds the maximum nesting depth of ${opts.maxDepth}.`,
|
|
16286
|
+
blockName: node.name,
|
|
16287
|
+
position: node.openPosition
|
|
16288
|
+
});
|
|
16289
|
+
continue;
|
|
16290
|
+
}
|
|
16291
|
+
const def = registry2.get(node.name);
|
|
16292
|
+
if (!def) {
|
|
16293
|
+
report({
|
|
16294
|
+
code: "CB_UNKNOWN_BLOCK",
|
|
16295
|
+
severity: opts.unknownBlocks,
|
|
16296
|
+
message: `Unknown block "${node.name}".`,
|
|
16297
|
+
hint: `Known blocks: ${registry2.all().map((d) => d.name).join(", ")}.`,
|
|
16298
|
+
blockName: node.name,
|
|
16299
|
+
position: node.openPosition
|
|
16300
|
+
});
|
|
16301
|
+
continue;
|
|
16302
|
+
}
|
|
16303
|
+
let valid = true;
|
|
16304
|
+
if (def.childOnly && parent === null) {
|
|
16305
|
+
valid = false;
|
|
16306
|
+
report({
|
|
16307
|
+
code: "CB_CHILD_ONLY",
|
|
16308
|
+
severity: "error",
|
|
16309
|
+
message: `"${node.name}" is a child block and cannot be used at the top level.`,
|
|
16310
|
+
blockName: node.name,
|
|
16311
|
+
position: node.openPosition
|
|
16312
|
+
});
|
|
16313
|
+
}
|
|
16314
|
+
if (def.props) {
|
|
16315
|
+
const result = def.props.safeParse(node.props);
|
|
16316
|
+
if (result.success) {
|
|
16317
|
+
node.props = result.data;
|
|
16318
|
+
} else {
|
|
16319
|
+
valid = false;
|
|
16320
|
+
for (const issue2 of result.error.issues) {
|
|
16321
|
+
report({
|
|
16322
|
+
code: "CB_PROPS_INVALID",
|
|
16323
|
+
severity: "error",
|
|
16324
|
+
message: `${node.name}: prop "${issue2.path.join(".") || "(root)"}" ${issue2.message}`,
|
|
16325
|
+
blockName: node.name,
|
|
16326
|
+
position: node.openPosition
|
|
16327
|
+
});
|
|
16328
|
+
}
|
|
16329
|
+
}
|
|
16330
|
+
}
|
|
16331
|
+
const before = diagnostics.length;
|
|
16332
|
+
const data = def.content.parse(node, report);
|
|
16333
|
+
let contentError = false;
|
|
16334
|
+
for (let j = before; j < diagnostics.length; j++) {
|
|
16335
|
+
if (diagnostics[j].severity === "error") {
|
|
16336
|
+
contentError = true;
|
|
16337
|
+
break;
|
|
16338
|
+
}
|
|
16339
|
+
}
|
|
16340
|
+
if (contentError)
|
|
16341
|
+
valid = false;
|
|
16342
|
+
if (valid) {
|
|
16343
|
+
;
|
|
16344
|
+
node.data = data;
|
|
16345
|
+
node.definition = def;
|
|
16346
|
+
}
|
|
16347
|
+
walk(node.children, node, depth + 1);
|
|
16348
|
+
}
|
|
16349
|
+
}
|
|
16350
|
+
walk(parsed.document.children, null, 1);
|
|
16351
|
+
const ok = !diagnostics.some((d) => d.severity === "error");
|
|
16352
|
+
return { ok, document: markValidatedDocument(parsed.document), diagnostics };
|
|
16353
|
+
}
|
|
16354
|
+
function markValidatedDocument(document) {
|
|
16355
|
+
if (!isValidatedDocument(document)) {
|
|
16356
|
+
Object.defineProperty(document, "__contentbitValidatedDocument", {
|
|
16357
|
+
value: true,
|
|
16358
|
+
enumerable: false
|
|
16359
|
+
});
|
|
16360
|
+
}
|
|
16361
|
+
return document;
|
|
16362
|
+
}
|
|
16363
|
+
var LINK_URL_RE, HAS_SCHEME_RE;
|
|
16364
|
+
var init_validate = __esm({
|
|
16365
|
+
"../core/dist/validate.js"() {
|
|
16366
|
+
"use strict";
|
|
16367
|
+
LINK_URL_RE = /\]\(([^)\s]+)/g;
|
|
16368
|
+
HAS_SCHEME_RE = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
16369
|
+
}
|
|
16370
|
+
});
|
|
16371
|
+
|
|
16372
|
+
// ../core/dist/project-scan.js
|
|
16373
|
+
function scanContentProject(files, registry2, options = {}) {
|
|
16374
|
+
const includeStatsFindings = options.includeStatsFindings ?? true;
|
|
16375
|
+
const minSectionWords = options.minSectionWords ?? DEFAULT_MIN_SECTION_WORDS;
|
|
16376
|
+
const scannedFiles = [];
|
|
16377
|
+
const findings = [];
|
|
16378
|
+
const linkInputs = [];
|
|
16379
|
+
for (const file2 of files) {
|
|
16380
|
+
const frontmatter = extractFrontmatter(file2.source)?.data ?? {};
|
|
16381
|
+
linkInputs.push({ path: file2.path, data: frontmatter });
|
|
16382
|
+
const validation = validateDocument(parseDocument(stripFrontmatter(file2.source)), registry2);
|
|
16383
|
+
const fileFindings = validation.diagnostics.map((diagnostic) => findingFromDiagnostic("validation", file2.path, diagnostic));
|
|
16384
|
+
const stats = analyzeDocument(file2.source, { path: file2.path });
|
|
16385
|
+
if (includeStatsFindings) {
|
|
16386
|
+
fileFindings.push(...statsFindings(file2.path, stats, minSectionWords));
|
|
16387
|
+
}
|
|
16388
|
+
findings.push(...fileFindings);
|
|
16389
|
+
scannedFiles.push({
|
|
16390
|
+
path: file2.path,
|
|
16391
|
+
source: file2.source,
|
|
16392
|
+
frontmatter,
|
|
16393
|
+
stats,
|
|
16394
|
+
validation,
|
|
16395
|
+
findings: fileFindings
|
|
16396
|
+
});
|
|
16397
|
+
}
|
|
16398
|
+
let linkIndex;
|
|
16399
|
+
let linkGraph;
|
|
16400
|
+
if (hasLinkFrontmatter(linkInputs, options.linkOptions?.slugField)) {
|
|
16401
|
+
for (const { file: file2, diagnostic } of validateLinks(linkInputs, options.linkOptions)) {
|
|
16402
|
+
const finding = findingFromDiagnostic("links", file2, diagnostic);
|
|
16403
|
+
findings.push(finding);
|
|
16404
|
+
const scanned = scannedFiles.find((item) => item.path === file2);
|
|
16405
|
+
if (scanned)
|
|
16406
|
+
scanned.findings.push(finding);
|
|
16407
|
+
}
|
|
16408
|
+
linkIndex = buildLinkIndex(linkInputs, options.linkOptions);
|
|
16409
|
+
linkGraph = linkGraphSummary(linkIndex);
|
|
16410
|
+
}
|
|
16411
|
+
findings.sort(compareContentProjectFindings);
|
|
16412
|
+
for (const file2 of scannedFiles)
|
|
16413
|
+
file2.findings.sort(compareContentProjectFindings);
|
|
16414
|
+
return {
|
|
16415
|
+
files: scannedFiles,
|
|
16416
|
+
findings,
|
|
16417
|
+
summary: summarizeContentProjectFindings(findings),
|
|
16418
|
+
linkInputs,
|
|
16419
|
+
...linkIndex ? { linkIndex } : {},
|
|
16420
|
+
...linkGraph ? { linkGraph } : {}
|
|
16421
|
+
};
|
|
16422
|
+
}
|
|
16423
|
+
function summarizeContentProjectFindings(findings) {
|
|
16424
|
+
return {
|
|
16425
|
+
errors: findings.filter((finding) => finding.severity === "error").length,
|
|
16426
|
+
warnings: findings.filter((finding) => finding.severity === "warning").length,
|
|
16427
|
+
suggestions: findings.filter((finding) => finding.severity === "info").length
|
|
16428
|
+
};
|
|
16429
|
+
}
|
|
16430
|
+
function compareContentProjectFindings(a, b) {
|
|
16431
|
+
return findingRank(a) - findingRank(b) || a.file.localeCompare(b.file) || (a.line ?? 0) - (b.line ?? 0) || (a.column ?? 0) - (b.column ?? 0) || a.code.localeCompare(b.code);
|
|
16432
|
+
}
|
|
16433
|
+
function findingFromDiagnostic(source, file2, diagnostic) {
|
|
16434
|
+
return {
|
|
16435
|
+
severity: diagnostic.severity,
|
|
16436
|
+
source,
|
|
16437
|
+
code: diagnostic.code,
|
|
16438
|
+
file: file2,
|
|
16439
|
+
line: diagnostic.position.start.line,
|
|
16440
|
+
column: diagnostic.position.start.column,
|
|
16441
|
+
message: diagnostic.message,
|
|
16442
|
+
...diagnostic.hint ? { hint: diagnostic.hint } : {}
|
|
16443
|
+
};
|
|
16444
|
+
}
|
|
16445
|
+
function statsFindings(file2, stats, minSectionWords) {
|
|
16446
|
+
const findings = [];
|
|
16447
|
+
for (const section2 of stats.outline) {
|
|
16448
|
+
if (section2.words < minSectionWords) {
|
|
16449
|
+
findings.push({
|
|
16450
|
+
severity: "info",
|
|
16451
|
+
source: "stats",
|
|
16452
|
+
code: "CB_THIN_SECTION",
|
|
16453
|
+
file: file2,
|
|
16454
|
+
line: section2.line,
|
|
16455
|
+
column: 1,
|
|
16456
|
+
message: `section "${section2.text}" has ${section2.words} words`,
|
|
16457
|
+
hint: `Add detail or merge it with a nearby section. Threshold: ${minSectionWords} words.`
|
|
16458
|
+
});
|
|
16459
|
+
}
|
|
16460
|
+
}
|
|
16461
|
+
if (stats.length.words >= BLOCKLESS_WORDS && stats.blocks.total === 0) {
|
|
16462
|
+
findings.push({
|
|
16463
|
+
severity: "info",
|
|
16464
|
+
source: "stats",
|
|
16465
|
+
code: "CB_BLOCKLESS_DOCUMENT",
|
|
16466
|
+
file: file2,
|
|
16467
|
+
message: `document has ${stats.length.words} words and no structured blocks`,
|
|
16468
|
+
hint: "Consider a callout, steps, comparison, FAQ, or another registered block if it clarifies the page."
|
|
16469
|
+
});
|
|
16470
|
+
}
|
|
16471
|
+
if (stats.images.missingAlt > 0) {
|
|
16472
|
+
findings.push({
|
|
16473
|
+
severity: "info",
|
|
16474
|
+
source: "stats",
|
|
16475
|
+
code: "CB_IMAGE_ALT_MISSING",
|
|
16476
|
+
file: file2,
|
|
16477
|
+
message: `${stats.images.missingAlt} image(s) are missing alt text`,
|
|
16478
|
+
hint: "Add descriptive alt text for meaningful images; use empty alt only for decorative images."
|
|
16479
|
+
});
|
|
16480
|
+
}
|
|
16481
|
+
return findings;
|
|
16482
|
+
}
|
|
16483
|
+
function hasLinkFrontmatter(inputs, configuredSlugField) {
|
|
16484
|
+
const slugField = configuredSlugField ?? "slug";
|
|
16485
|
+
return inputs.some((input) => Object.prototype.hasOwnProperty.call(input.data, slugField));
|
|
16486
|
+
}
|
|
16487
|
+
function linkGraphSummary(index) {
|
|
16488
|
+
let links = 0;
|
|
16489
|
+
for (const page of index.pages.values())
|
|
16490
|
+
links += page.linksTo.length;
|
|
16491
|
+
return {
|
|
16492
|
+
pages: index.pages.size,
|
|
16493
|
+
links,
|
|
16494
|
+
orphans: [...index.pages.values()].filter((page) => page.linkedFrom.length === 0).length
|
|
16495
|
+
};
|
|
16496
|
+
}
|
|
16497
|
+
function findingRank(finding) {
|
|
16498
|
+
if (finding.severity === "error" && finding.source === "validation")
|
|
16499
|
+
return 0;
|
|
16500
|
+
if (finding.severity === "error" && finding.source === "links")
|
|
16501
|
+
return 1;
|
|
16502
|
+
if (finding.severity === "warning")
|
|
16503
|
+
return 2;
|
|
16504
|
+
if (finding.code === "CB_THIN_SECTION")
|
|
16505
|
+
return 3;
|
|
16506
|
+
if (finding.code === "CB_BLOCKLESS_DOCUMENT")
|
|
16507
|
+
return 4;
|
|
16508
|
+
if (finding.code === "CB_IMAGE_ALT_MISSING")
|
|
16509
|
+
return 5;
|
|
16510
|
+
return 6;
|
|
16511
|
+
}
|
|
16512
|
+
var DEFAULT_MIN_SECTION_WORDS, BLOCKLESS_WORDS;
|
|
16513
|
+
var init_project_scan = __esm({
|
|
16514
|
+
"../core/dist/project-scan.js"() {
|
|
16515
|
+
"use strict";
|
|
16516
|
+
init_analyze();
|
|
16517
|
+
init_frontmatter();
|
|
16518
|
+
init_links();
|
|
16519
|
+
init_parser();
|
|
16520
|
+
init_validate();
|
|
16521
|
+
DEFAULT_MIN_SECTION_WORDS = 25;
|
|
16522
|
+
BLOCKLESS_WORDS = 250;
|
|
16523
|
+
}
|
|
16524
|
+
});
|
|
16525
|
+
|
|
16526
|
+
// ../core/dist/position.js
|
|
16527
|
+
function bodyLineRange(node, bodyLineIndex) {
|
|
16528
|
+
const bodyLines = node.body.split("\n");
|
|
16529
|
+
const text = bodyLines[bodyLineIndex] ?? "";
|
|
16530
|
+
let offset = node.openPosition.end.offset + 1;
|
|
16531
|
+
for (let i = 0; i < bodyLineIndex; i++)
|
|
16532
|
+
offset += bodyLines[i].length + 1;
|
|
16533
|
+
const line = node.openPosition.start.line + 1 + bodyLineIndex;
|
|
16534
|
+
return {
|
|
16535
|
+
start: { line, column: 1, offset },
|
|
16536
|
+
end: { line, column: text.length + 1, offset: offset + text.length }
|
|
16537
|
+
};
|
|
16538
|
+
}
|
|
16539
|
+
var init_position = __esm({
|
|
16540
|
+
"../core/dist/position.js"() {
|
|
16541
|
+
"use strict";
|
|
16542
|
+
}
|
|
16543
|
+
});
|
|
16544
|
+
|
|
16545
|
+
// ../core/dist/authoring.js
|
|
16546
|
+
function typeLabel(def) {
|
|
16547
|
+
switch (def.type) {
|
|
16548
|
+
case "enum":
|
|
16549
|
+
return `one of ${Object.values(def.entries ?? {}).join("|")}`;
|
|
16550
|
+
case "literal":
|
|
16551
|
+
return `one of ${(def.values ?? []).map(String).join("|")}`;
|
|
16552
|
+
case "union":
|
|
16553
|
+
return `one of ${(def.options ?? []).map((o) => typeLabel(o.def).replace(/^one of /, "")).join("|")}`;
|
|
16554
|
+
default:
|
|
16555
|
+
return def.type;
|
|
16556
|
+
}
|
|
16557
|
+
}
|
|
16558
|
+
function describeProps(schema) {
|
|
16559
|
+
const root = schema.def;
|
|
16560
|
+
if (root.type !== "object" || !root.shape)
|
|
16561
|
+
return [];
|
|
16562
|
+
const lines = [];
|
|
16563
|
+
for (const [name, field] of Object.entries(root.shape)) {
|
|
16564
|
+
let current = field;
|
|
16565
|
+
let optional2 = false;
|
|
16566
|
+
let defaultValue;
|
|
16567
|
+
let description = current.description;
|
|
16568
|
+
while (["optional", "default", "nullable"].includes(current.def.type)) {
|
|
16569
|
+
optional2 = true;
|
|
16570
|
+
if (current.def.type === "default") {
|
|
16571
|
+
const dv = current.def.defaultValue;
|
|
16572
|
+
defaultValue = typeof dv === "function" ? dv() : dv;
|
|
16573
|
+
}
|
|
16574
|
+
if (!current.def.innerType)
|
|
16575
|
+
break;
|
|
16576
|
+
current = current.def.innerType;
|
|
16577
|
+
description ??= current.description;
|
|
16578
|
+
}
|
|
16579
|
+
const presence = defaultValue !== void 0 ? `(optional, default: ${String(defaultValue)})` : optional2 ? "(optional)" : "(required)";
|
|
16580
|
+
const suffix = description ? ` \u2014 ${description}` : "";
|
|
16581
|
+
lines.push(`- ${name}: ${typeLabel(current.def)} ${presence}${suffix}`);
|
|
16582
|
+
}
|
|
16583
|
+
return lines;
|
|
16584
|
+
}
|
|
16585
|
+
function generateAuthoringGuide(defs, opts = {}) {
|
|
16586
|
+
const includeExamples = opts.includeExamples ?? true;
|
|
16587
|
+
const includeAvoid = opts.includeAvoidRules ?? true;
|
|
16588
|
+
const sections = [];
|
|
16589
|
+
if ((opts.audience ?? "llm") === "llm")
|
|
16590
|
+
sections.push(LLM_PREAMBLE);
|
|
16591
|
+
for (const def of defs) {
|
|
16592
|
+
const lines = [`## ${def.name}`, ""];
|
|
16593
|
+
lines.push(def.childOnly ? `${def.description} (child block \u2014 only inside a parent that allows it)` : def.description);
|
|
16594
|
+
if (def.props) {
|
|
16595
|
+
const props = describeProps(def.props);
|
|
16596
|
+
if (props.length > 0)
|
|
16597
|
+
lines.push("", "Props:", ...props);
|
|
16598
|
+
}
|
|
16599
|
+
lines.push("", `Content: ${def.content.describe()}`);
|
|
16600
|
+
if (def.authoring.useWhen.length > 0) {
|
|
16601
|
+
lines.push("", "Use when:", ...def.authoring.useWhen.map((u) => `- ${u}`));
|
|
16602
|
+
}
|
|
16603
|
+
if (includeAvoid && def.authoring.avoidWhen.length > 0) {
|
|
16604
|
+
lines.push("", "Avoid when:", ...def.authoring.avoidWhen.map((a) => `- ${a}`));
|
|
16605
|
+
}
|
|
16606
|
+
if (includeExamples && def.authoring.example.trim() !== "") {
|
|
16607
|
+
lines.push("", "Example:", "", "```md", def.authoring.example, "```");
|
|
16608
|
+
}
|
|
16609
|
+
sections.push(lines.join("\n"));
|
|
16610
|
+
}
|
|
16611
|
+
return sections.join("\n\n") + "\n";
|
|
16612
|
+
}
|
|
16613
|
+
var LLM_PREAMBLE;
|
|
16614
|
+
var init_authoring = __esm({
|
|
16615
|
+
"../core/dist/authoring.js"() {
|
|
16616
|
+
"use strict";
|
|
16617
|
+
LLM_PREAMBLE = `# Content block authoring rules
|
|
16618
|
+
|
|
16619
|
+
- write regular Markdown by default; use blocks only when they improve scanning or structure
|
|
16620
|
+
- never invent block names \u2014 only the blocks documented below exist
|
|
16621
|
+
- follow each block's syntax exactly; props use {key="value"} on the open line
|
|
16622
|
+
- close every :::block with a line containing only :::
|
|
16623
|
+
- validate generated content and fix diagnostics rather than bypassing them
|
|
16624
|
+
`;
|
|
16625
|
+
}
|
|
16626
|
+
});
|
|
16627
|
+
|
|
16628
|
+
// ../core/dist/registry.js
|
|
16629
|
+
function defineBlock(def) {
|
|
16630
|
+
if (!KEBAB_RE.test(def.name)) {
|
|
16631
|
+
throw new Error(`Block name "${def.name}" must be lowercase kebab-case.`);
|
|
16632
|
+
}
|
|
16633
|
+
return def;
|
|
16634
|
+
}
|
|
16635
|
+
function createBlockRegistry() {
|
|
16636
|
+
return new BlockRegistry();
|
|
16637
|
+
}
|
|
16638
|
+
var KEBAB_RE, BlockRegistry;
|
|
16639
|
+
var init_registry = __esm({
|
|
16640
|
+
"../core/dist/registry.js"() {
|
|
16641
|
+
"use strict";
|
|
16642
|
+
init_authoring();
|
|
16643
|
+
KEBAB_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
16644
|
+
BlockRegistry = class {
|
|
16645
|
+
defs = /* @__PURE__ */ new Map();
|
|
16646
|
+
use(pack) {
|
|
16647
|
+
for (const def of pack)
|
|
16648
|
+
this.add(def);
|
|
16649
|
+
return this;
|
|
16650
|
+
}
|
|
16651
|
+
add(def) {
|
|
16652
|
+
const d = def;
|
|
16653
|
+
if (this.defs.has(d.name)) {
|
|
16654
|
+
throw new Error(`Duplicate block "${d.name}". Namespace it (e.g. "acme-${d.name}") or remove the duplicate.`);
|
|
16655
|
+
}
|
|
16656
|
+
this.defs.set(d.name, d);
|
|
16657
|
+
return this;
|
|
16658
|
+
}
|
|
16659
|
+
get(name) {
|
|
16660
|
+
return this.defs.get(name);
|
|
16661
|
+
}
|
|
16662
|
+
all() {
|
|
16663
|
+
return [...this.defs.values()];
|
|
16664
|
+
}
|
|
16665
|
+
toAuthoringGuide(opts = {}) {
|
|
16666
|
+
return generateAuthoringGuide(this.all(), opts);
|
|
16667
|
+
}
|
|
16668
|
+
};
|
|
16669
|
+
}
|
|
16670
|
+
});
|
|
16671
|
+
|
|
16672
|
+
// ../core/dist/content-models.js
|
|
16673
|
+
function blockDiag(node, code, message, hint, severity = "error") {
|
|
16674
|
+
return { code, severity, message, hint, blockName: node.name, position: node.openPosition };
|
|
16675
|
+
}
|
|
16676
|
+
function markdownBody(opts = {}) {
|
|
16677
|
+
const required2 = opts.required ?? true;
|
|
16678
|
+
return {
|
|
16679
|
+
kind: "markdown",
|
|
16680
|
+
describe: () => "Markdown body",
|
|
16681
|
+
parse(node, report) {
|
|
16682
|
+
const markdown = node.body.trim();
|
|
16683
|
+
if (required2 && markdown === "") {
|
|
16684
|
+
report(blockDiag(node, "CB_BODY_EMPTY", `:::${node.name} requires a body.`));
|
|
16685
|
+
} else if (opts.minLength !== void 0 && markdown.length < opts.minLength) {
|
|
16686
|
+
report(blockDiag(node, "CB_BODY_LENGTH", `:::${node.name} body is shorter than ${opts.minLength} characters.`, void 0, "warning"));
|
|
16687
|
+
}
|
|
16688
|
+
if (opts.maxLength !== void 0 && markdown.length > opts.maxLength) {
|
|
16689
|
+
report(blockDiag(node, "CB_BODY_LENGTH", `:::${node.name} body exceeds ${opts.maxLength} characters.`, void 0, "warning"));
|
|
16690
|
+
}
|
|
16691
|
+
return { markdown };
|
|
16692
|
+
}
|
|
16693
|
+
};
|
|
16694
|
+
}
|
|
16695
|
+
function pipeRows(opts) {
|
|
16696
|
+
const required2 = opts.columns.length - (opts.optionalColumns ?? 0);
|
|
16697
|
+
return {
|
|
16698
|
+
kind: "rows",
|
|
16699
|
+
describe: () => `List rows: \`- ${opts.columns.join(" | ")}\`${opts.optionalColumns ? ` (last ${opts.optionalColumns} optional)` : ""}`,
|
|
16700
|
+
parse(node, report) {
|
|
16701
|
+
const rows = [];
|
|
16702
|
+
const bodyLines = node.body.split("\n");
|
|
16703
|
+
for (let i = 0; i < bodyLines.length; i++) {
|
|
16704
|
+
const line = bodyLines[i];
|
|
16705
|
+
if (line.trim() === "")
|
|
16706
|
+
continue;
|
|
16707
|
+
const m = line.match(ROW_RE);
|
|
16708
|
+
if (!m) {
|
|
16709
|
+
report({
|
|
16710
|
+
code: "CB_ROW_SYNTAX",
|
|
16711
|
+
severity: "warning",
|
|
16712
|
+
message: `:::${node.name} rows must start with "- ". Ignored: "${line.trim()}".`,
|
|
16713
|
+
blockName: node.name,
|
|
16714
|
+
position: bodyLineRange(node, i)
|
|
16715
|
+
});
|
|
16716
|
+
continue;
|
|
16717
|
+
}
|
|
16718
|
+
const cells = m[1].split(UNESCAPED_PIPE).map((c) => c.replace(/\\\|/g, "|").trim());
|
|
16719
|
+
if (cells.length < required2 || cells.length > opts.columns.length) {
|
|
16720
|
+
report({
|
|
16721
|
+
code: "CB_ROW_COLUMNS",
|
|
16722
|
+
severity: "error",
|
|
16723
|
+
message: `:::${node.name} rows require ${opts.columns.length} columns (${opts.columns.join(" | ")}). Found ${cells.length}.`,
|
|
16724
|
+
hint: `Format: - ${opts.columns.join(" | ")}`,
|
|
16725
|
+
blockName: node.name,
|
|
16726
|
+
position: bodyLineRange(node, i)
|
|
16727
|
+
});
|
|
16728
|
+
continue;
|
|
16729
|
+
}
|
|
16730
|
+
const row = {};
|
|
16731
|
+
opts.columns.forEach((col, idx) => {
|
|
16732
|
+
row[col] = cells[idx] ?? "";
|
|
16733
|
+
});
|
|
16734
|
+
rows.push(row);
|
|
16735
|
+
}
|
|
16736
|
+
if (opts.minRows !== void 0 && rows.length < opts.minRows) {
|
|
16737
|
+
report(blockDiag(node, "CB_ROW_COUNT", `:::${node.name} needs at least ${opts.minRows} rows, found ${rows.length}.`));
|
|
16738
|
+
}
|
|
16739
|
+
if (opts.maxRows !== void 0 && rows.length > opts.maxRows) {
|
|
16740
|
+
report(blockDiag(node, "CB_ROW_COUNT", `:::${node.name} allows at most ${opts.maxRows} rows, found ${rows.length}.`));
|
|
16741
|
+
}
|
|
16742
|
+
return { rows };
|
|
16743
|
+
}
|
|
16744
|
+
};
|
|
16745
|
+
}
|
|
16746
|
+
function listItems(opts) {
|
|
16747
|
+
return {
|
|
16748
|
+
kind: "list",
|
|
16749
|
+
describe: () => opts.marker === "ordered" ? "Ordered list: `1. item`" : opts.marker === "signed" ? "Signed list: `+ positive` / `- negative`" : "Bullet list: `- item`",
|
|
16750
|
+
parse(node, report) {
|
|
16751
|
+
const items = [];
|
|
16752
|
+
const bodyLines = node.body.split("\n");
|
|
16753
|
+
for (let i = 0; i < bodyLines.length; i++) {
|
|
16754
|
+
const line = bodyLines[i];
|
|
16755
|
+
if (line.trim() === "")
|
|
16756
|
+
continue;
|
|
16757
|
+
const m = line.match(MARKERS[opts.marker]);
|
|
16758
|
+
if (!m) {
|
|
16759
|
+
report({
|
|
16760
|
+
code: "CB_ITEM_SYNTAX",
|
|
16761
|
+
severity: "warning",
|
|
16762
|
+
message: `:::${node.name} expects ${opts.marker} list items. Ignored: "${line.trim()}".`,
|
|
16763
|
+
blockName: node.name,
|
|
16764
|
+
position: bodyLineRange(node, i)
|
|
16765
|
+
});
|
|
16766
|
+
continue;
|
|
16767
|
+
}
|
|
16768
|
+
if (opts.marker === "signed")
|
|
16769
|
+
items.push({ text: m[2], sign: m[1] });
|
|
16770
|
+
else
|
|
16771
|
+
items.push({ text: m[1] });
|
|
16772
|
+
}
|
|
16773
|
+
if (opts.minItems !== void 0 && items.length < opts.minItems) {
|
|
16774
|
+
report(blockDiag(node, "CB_ITEM_COUNT", `:::${node.name} needs at least ${opts.minItems} items, found ${items.length}.`));
|
|
16775
|
+
}
|
|
16776
|
+
if (opts.maxItems !== void 0 && items.length > opts.maxItems) {
|
|
16777
|
+
report(blockDiag(node, "CB_ITEM_COUNT", `:::${node.name} allows at most ${opts.maxItems} items, found ${items.length}.`));
|
|
16778
|
+
}
|
|
16779
|
+
return { items };
|
|
16780
|
+
}
|
|
16781
|
+
};
|
|
16782
|
+
}
|
|
16783
|
+
function childBlocks(opts) {
|
|
16784
|
+
return {
|
|
16785
|
+
kind: "children",
|
|
16786
|
+
describe: () => `Child blocks: ${opts.allowed.map((n) => `\`::${n}\``).join(", ")}`,
|
|
16787
|
+
parse(node, report) {
|
|
16788
|
+
const blocks = [];
|
|
16789
|
+
for (const child of node.children) {
|
|
16790
|
+
if (child.type === "markdown") {
|
|
16791
|
+
if (child.value.trim() !== "") {
|
|
16792
|
+
report({
|
|
16793
|
+
code: "CB_UNEXPECTED_CONTENT",
|
|
16794
|
+
severity: "warning",
|
|
16795
|
+
message: `:::${node.name} only accepts ${opts.allowed.map((n) => `::${n}`).join(", ")} children; loose text is ignored.`,
|
|
16796
|
+
blockName: node.name,
|
|
16797
|
+
position: child.position
|
|
16798
|
+
});
|
|
16799
|
+
}
|
|
16800
|
+
continue;
|
|
16801
|
+
}
|
|
16802
|
+
if (!opts.allowed.includes(child.name)) {
|
|
16803
|
+
report({
|
|
16804
|
+
code: "CB_CHILD_NOT_ALLOWED",
|
|
16805
|
+
severity: "error",
|
|
16806
|
+
message: `"::${child.name}" is not allowed inside :::${node.name}. Allowed: ${opts.allowed.join(", ")}.`,
|
|
16807
|
+
blockName: node.name,
|
|
16808
|
+
position: child.openPosition
|
|
16809
|
+
});
|
|
16810
|
+
continue;
|
|
16811
|
+
}
|
|
16812
|
+
blocks.push(child);
|
|
16813
|
+
}
|
|
16814
|
+
for (const name of opts.required ?? []) {
|
|
16815
|
+
if (!blocks.some((b) => b.name === name)) {
|
|
16816
|
+
report(blockDiag(node, "CB_CHILD_MISSING", `:::${node.name} requires a ::${name} child.`));
|
|
16817
|
+
}
|
|
16818
|
+
}
|
|
16819
|
+
const count = blocks.length;
|
|
16820
|
+
if (opts.minChildren !== void 0 && count < opts.minChildren) {
|
|
16821
|
+
report(blockDiag(node, "CB_CHILD_COUNT", `:::${node.name} needs at least ${opts.minChildren} children, found ${count}.`));
|
|
16822
|
+
}
|
|
16823
|
+
if (opts.maxChildren !== void 0 && count > opts.maxChildren) {
|
|
16824
|
+
report(blockDiag(node, "CB_CHILD_COUNT", `:::${node.name} allows at most ${opts.maxChildren} children, found ${count}.`));
|
|
16825
|
+
}
|
|
16826
|
+
return { blocks };
|
|
16827
|
+
}
|
|
16828
|
+
};
|
|
16829
|
+
}
|
|
16830
|
+
var ROW_RE, UNESCAPED_PIPE, MARKERS;
|
|
16831
|
+
var init_content_models = __esm({
|
|
16832
|
+
"../core/dist/content-models.js"() {
|
|
16833
|
+
"use strict";
|
|
16834
|
+
init_position();
|
|
16835
|
+
ROW_RE = /^\s*-\s+(.*)$/;
|
|
16836
|
+
UNESCAPED_PIPE = /(?<!\\)\|/;
|
|
16837
|
+
MARKERS = {
|
|
16838
|
+
bullet: /^\s*-\s+(.*)$/,
|
|
16839
|
+
ordered: /^\s*\d+[.)]\s+(.*)$/,
|
|
16840
|
+
signed: /^\s*([+-])\s+(.*)$/
|
|
16841
|
+
};
|
|
16842
|
+
}
|
|
16843
|
+
});
|
|
16844
|
+
|
|
16845
|
+
// ../core/dist/render-markdown.js
|
|
16846
|
+
function renderToMarkdown(document, opts = {}) {
|
|
16847
|
+
const ctx = {
|
|
16848
|
+
renderNodes(nodes) {
|
|
16849
|
+
return nodes.map((node) => {
|
|
16850
|
+
if (node.type === "markdown")
|
|
16851
|
+
return node.value.trim();
|
|
16852
|
+
const renderer = opts.renderers?.[node.name];
|
|
16853
|
+
if (renderer && isValidatedBlock(node))
|
|
16854
|
+
return renderer(node, ctx).trim();
|
|
16855
|
+
return node.body.trim();
|
|
16856
|
+
}).filter((s) => s !== "").join("\n\n");
|
|
16857
|
+
}
|
|
16858
|
+
};
|
|
16859
|
+
return ctx.renderNodes(document.children) + "\n";
|
|
16860
|
+
}
|
|
16861
|
+
var init_render_markdown = __esm({
|
|
16862
|
+
"../core/dist/render-markdown.js"() {
|
|
16863
|
+
"use strict";
|
|
16864
|
+
init_validate();
|
|
16865
|
+
}
|
|
16866
|
+
});
|
|
16867
|
+
|
|
16653
16868
|
// ../core/dist/index.js
|
|
16654
16869
|
var init_dist = __esm({
|
|
16655
16870
|
"../core/dist/index.js"() {
|
|
16656
16871
|
"use strict";
|
|
16657
|
-
init_diagnostics();
|
|
16658
16872
|
init_parser();
|
|
16659
16873
|
init_frontmatter();
|
|
16660
16874
|
init_analyze();
|
|
16875
|
+
init_project_scan();
|
|
16661
16876
|
init_registry();
|
|
16662
16877
|
init_content_models();
|
|
16663
16878
|
init_validate();
|
|
@@ -16987,8 +17202,9 @@ var init_dist2 = __esm({
|
|
|
16987
17202
|
|
|
16988
17203
|
// src/load-registry.ts
|
|
16989
17204
|
import { pathToFileURL } from "node:url";
|
|
16990
|
-
async function loadRegistry(registryPath) {
|
|
16991
|
-
const registry2 = createBlockRegistry()
|
|
17205
|
+
async function loadRegistry(registryPath, options = {}) {
|
|
17206
|
+
const registry2 = createBlockRegistry();
|
|
17207
|
+
if (options.includeGenericBlocks !== false) registry2.use(genericBlocks());
|
|
16992
17208
|
if (registryPath) {
|
|
16993
17209
|
let mod;
|
|
16994
17210
|
try {
|
|
@@ -17018,6 +17234,30 @@ var init_load_registry = __esm({
|
|
|
17018
17234
|
}
|
|
17019
17235
|
});
|
|
17020
17236
|
|
|
17237
|
+
// src/commands/agent-templates/AGENTS.md?raw
|
|
17238
|
+
var AGENTS_default;
|
|
17239
|
+
var init_AGENTS = __esm({
|
|
17240
|
+
"src/commands/agent-templates/AGENTS.md?raw"() {
|
|
17241
|
+
AGENTS_default = '<!-- contentbit:start -->\n\n## contentbit content (generated \u2014 edits inside this block are overwritten)\n\nThis project validates Markdown content with contentbit. Documents are plain\nMarkdown plus directive blocks (`:::name{props} ... :::`), each with a schema.\nThe `content:check` script in package.json holds the canonical validate\ncommand \u2014 the content glob plus any `--registry` and `--no-generic-blocks`\nflags \u2014 reuse its arguments.\nIf the project has a `content:links` script, use it to build the internal-link\nindex; otherwise run `contentbit links <content glob>`.\n\nWhen writing or editing content:\n\n1. Fetch the live authoring guide first \u2014 never guess block syntax:\n `contentbit instructions --audience llm [--registry <path>] [--no-generic-blocks]`\n2. Write plain Markdown; use blocks where the guide\'s use-when guidance fits.\n3. If sibling documents use `slug` / `linksTo`, read\n `.contentbit/link-index.json` from `contentbit links <content glob>` and\n author frontmatter links with existing slugs. When creating a linked page,\n include `keywords.primary` and `keywords.secondary` with search-intent\n phrases future agents can use to choose related pages.\n4. Validate until clean (exit 0): `contentbit validate <file> [--registry <path>] [--no-generic-blocks]`.\n Diagnostics print as `file:line:col severity CODE message` with fix hints.\n For link frontmatter, validate the full content glob so cross-file checks run.\n\nWhen auditing content health:\n\n- `contentbit doctor "content/**/*.md" [--registry <path>] [--no-generic-blocks]` prints a ranked,\n read-only repair plan: validation issues, link issues, thin sections,\n block-less long documents, and missing image alt text.\n- `contentbit doctor "content/**/*.md" [--registry <path>] [--no-generic-blocks] --json` prints the\n same findings as structured JSON for agents and CI.\n- `contentbit stats "content/**/*.md" [--registry <path>] [--no-generic-blocks]` prints raw JSON\n stats: outline word counts, block usage, link domains, and validation\n error/warning counts.\n- `contentbit links "content/**/*.md" [--fix]` builds\n `.contentbit/link-index.json`, reports dangling links/orphans, and rewrites\n alias references in `linksTo` when `--fix` is used.\n\nIf `contentbit` is unavailable, suggest `npx contentbit@latest init` instead\nof inventing block syntax.\n\n<!-- contentbit:end -->\n';
|
|
17242
|
+
}
|
|
17243
|
+
});
|
|
17244
|
+
|
|
17245
|
+
// src/commands/agent-templates/contentbit-audit/SKILL.md?raw
|
|
17246
|
+
var SKILL_default;
|
|
17247
|
+
var init_SKILL = __esm({
|
|
17248
|
+
"src/commands/agent-templates/contentbit-audit/SKILL.md?raw"() {
|
|
17249
|
+
SKILL_default = '---\nname: contentbit-audit\ndescription: |\n Audit contentbit Markdown content health using document stats. Use when asked\n to audit, review, or find improvements across content \u2014 thin pages, missing\n structure, validation issues \u2014 in a project that uses contentbit.\nversion: 4\n---\n\n# Auditing contentbit content\n\n`contentbit doctor` is the first audit command. It reads content once, runs\nblock validation, link validation, and document stats, then prints a ranked\nrepair plan. It is read-only: it does not write the link index and never edits\nsource files. `contentbit stats` remains useful when you need raw JSON metrics.\n`contentbit links` builds the frontmatter-authored internal-link graph and can\nheal alias references with `--fix`.\n\n## Gather\n\nCheck `package.json` for `content:doctor` first. If it exists, run it. If it\ndoes not, use `content:check` to find this project\'s content glob and\n`--registry` / `--no-generic-blocks` flags, then run:\n\n```sh\ncontentbit doctor "content/**/*.md" [--registry <path>] [--no-generic-blocks]\ncontentbit doctor "content/**/*.md" [--registry <path>] [--no-generic-blocks] --json\ncontentbit stats "content/**/*.md" [--registry <path>] [--no-generic-blocks]\ncontentbit links "content/**/*.md"\n```\n\n`doctor --json` prints a stable report with summary counts and ranked\nfindings. `stats` prints per-file metrics: frontmatter data, a heading\n`outline` with per-section word counts, `blocks.byName` usage counts,\n`links.domains`, and a `validation` summary (`errors`/`warnings`).\n`contentbit links` writes `.contentbit/link-index.json`, whose pages contain\n`slug`, resolved `linksTo`, derived `linkedFrom`, `aliases`, and\n`keywords`.\n\n## Interpret\n\nPrioritize findings in the order `doctor` reports them:\n\n1. **Validation errors and warnings** \u2014 broken content ships broken pages.\n2. **Internal-link errors** \u2014 unresolved links, duplicate slugs, and alias\n conflicts from `contentbit links`.\n3. **Orphans and self-links** \u2014 link warnings that point to isolated or noisy\n pages.\n4. **Thin documents** \u2014 outline sections with very low word counts.\n5. **Block-less documents** \u2014 `blocks.byName` empty where sibling documents\n use blocks; structure (steps, callouts, comparisons, faq) may be missing.\n6. **Missing or inconsistent frontmatter** compared to sibling documents.\n7. **Structural imbalance** \u2014 skipped heading levels, single-section walls of text.\n\n## Report\n\nReport findings per file with concrete suggestions, ordered by priority. Do not\nedit files during the audit. To fix a finding, follow the contentbit-author\nskill (fetch the guide, edit, validate until clean) \u2014 offer that as a follow-up.\n';
|
|
17250
|
+
}
|
|
17251
|
+
});
|
|
17252
|
+
|
|
17253
|
+
// src/commands/agent-templates/contentbit-author/SKILL.md?raw
|
|
17254
|
+
var SKILL_default2;
|
|
17255
|
+
var init_SKILL2 = __esm({
|
|
17256
|
+
"src/commands/agent-templates/contentbit-author/SKILL.md?raw"() {
|
|
17257
|
+
SKILL_default2 = "---\nname: contentbit-author\ndescription: |\n Write or edit contentbit Markdown content (directive blocks like :::callout).\n Use when asked to create or modify content documents in a project that uses\n contentbit \u2014 blog posts, docs pages, changelogs, any Markdown covered by\n `contentbit validate`.\nversion: 4\n---\n\n# Writing contentbit content\n\ncontentbit documents are plain Markdown plus directive blocks\n(`:::name{props} ... :::`). Every block has a schema. Never guess block names,\nprops, or body shapes \u2014 fetch the live guide from the project's registry first.\n\n## Find the project conventions\n\nCheck `package.json` for a `content:check` script. It holds the canonical\nvalidate invocation for this project: the content glob and, if present, the\n`--registry <path>` and `--no-generic-blocks` flags. Reuse those arguments\nbelow. No script? Default to `content/**/*.md` with no `--registry` flag.\nIf the project has a `content:links` script, use it for the internal-link\nindex; otherwise run `contentbit links <content glob>` directly.\n\n## The loop\n\n1. **Fetch the authoring guide** (always \u2014 it covers this project's custom blocks):\n\n ```sh\n contentbit instructions --audience llm [--registry <path from content:check>] [--no-generic-blocks]\n ```\n\n Read it before writing. It documents every available block: props, body\n shape, and when to use or avoid it.\n\n2. **Write the document.** Plain Markdown everywhere; blocks only where the\n guide's use-when guidance fits. Keep frontmatter consistent with sibling\n documents in the same folder. If sibling documents use `slug`, `linksTo`,\n `aliases`, or `keywords`, run the link index first:\n\n ```sh\n contentbit links <content glob>\n ```\n\n Read `.contentbit/link-index.json` to pick existing slugs and related\n pages. Author only `slug`, `linksTo`, `aliases`, and `keywords` in\n frontmatter; never write derived `linkedFrom` into source files. When\n creating a linked page, include `keywords.primary` and\n `keywords.secondary` with search-intent phrases that would help future\n agents choose this page as a `linksTo` target.\n\n3. **Validate and fix until clean:**\n\n ```sh\n contentbit validate <file> [--registry <path>] [--no-generic-blocks]\n ```\n\n Diagnostics print to stderr as `file:line:col severity CODE message`, often\n with a `hint:` line suggesting the fix. Exit 0 means clean; exit 1 means\n errors remain. If the document has link frontmatter, validate the full\n content glob so cross-file links are checked against the whole graph. Fix\n every diagnostic and re-run. Never finish with a failing validate.\n\n4. **Refresh internal links when present:**\n\n ```sh\n contentbit links <content glob> --fix\n ```\n\n `--fix` only rewrites `linksTo` values that point at known aliases. It\n does not invent links, remove aliases, or write backlinks. Re-run validate\n after it changes files.\n\n## Failure modes\n\n- `contentbit` not found or no registry resolvable: the project is not set up.\n Say so and suggest `npx contentbit@latest init` \u2014 do not invent block syntax.\n- A block you want does not exist: use plain Markdown, or ask whether to define\n a custom block in the registry. Never emit an unregistered block name.\n";
|
|
17258
|
+
}
|
|
17259
|
+
});
|
|
17260
|
+
|
|
17021
17261
|
// src/commands/agents.ts
|
|
17022
17262
|
var agents_exports = {};
|
|
17023
17263
|
__export(agents_exports, {
|
|
@@ -17086,210 +17326,24 @@ async function agentsCommand(args, io) {
|
|
|
17086
17326
|
);
|
|
17087
17327
|
return 0;
|
|
17088
17328
|
}
|
|
17089
|
-
var
|
|
17329
|
+
var AUTHOR_SKILL, AUDIT_SKILL, AGENTS_MD_BLOCK, START, END;
|
|
17090
17330
|
var init_agents = __esm({
|
|
17091
17331
|
"src/commands/agents.ts"() {
|
|
17092
17332
|
"use strict";
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
contentbit \u2014 blog posts, docs pages, changelogs, any Markdown covered by
|
|
17100
|
-
\`contentbit validate\`.
|
|
17101
|
-
version: ${TEMPLATE_VERSION}
|
|
17102
|
-
---
|
|
17103
|
-
|
|
17104
|
-
# Writing contentbit content
|
|
17105
|
-
|
|
17106
|
-
contentbit documents are plain Markdown plus directive blocks
|
|
17107
|
-
(\`:::name{props} ... :::\`). Every block has a schema. Never guess block names,
|
|
17108
|
-
props, or body shapes \u2014 fetch the live guide from the project's registry first.
|
|
17109
|
-
|
|
17110
|
-
## Find the project conventions
|
|
17111
|
-
|
|
17112
|
-
Check \`package.json\` for a \`content:check\` script. It holds the canonical
|
|
17113
|
-
validate invocation for this project: the content glob and, if present, the
|
|
17114
|
-
\`--registry <path>\` flag pointing at custom block definitions. Reuse both
|
|
17115
|
-
below. No script? Default to \`content/**/*.md\` with no \`--registry\` flag.
|
|
17116
|
-
If the project has a \`content:links\` script, use it for the internal-link
|
|
17117
|
-
index; otherwise run \`contentbit links <content glob>\` directly.
|
|
17118
|
-
|
|
17119
|
-
## The loop
|
|
17120
|
-
|
|
17121
|
-
1. **Fetch the authoring guide** (always \u2014 it covers this project's custom blocks):
|
|
17122
|
-
|
|
17123
|
-
\`\`\`sh
|
|
17124
|
-
contentbit instructions --audience llm [--registry <path from content:check>]
|
|
17125
|
-
\`\`\`
|
|
17126
|
-
|
|
17127
|
-
Read it before writing. It documents every available block: props, body
|
|
17128
|
-
shape, and when to use or avoid it.
|
|
17129
|
-
|
|
17130
|
-
2. **Write the document.** Plain Markdown everywhere; blocks only where the
|
|
17131
|
-
guide's use-when guidance fits. Keep frontmatter consistent with sibling
|
|
17132
|
-
documents in the same folder. If sibling documents use \`slug\`, \`linksTo\`,
|
|
17133
|
-
\`aliases\`, or \`keywords\`, run the link index first:
|
|
17134
|
-
|
|
17135
|
-
\`\`\`sh
|
|
17136
|
-
contentbit links <content glob>
|
|
17137
|
-
\`\`\`
|
|
17138
|
-
|
|
17139
|
-
Read \`.contentbit/link-index.json\` to pick existing slugs and related
|
|
17140
|
-
pages. Author only \`slug\`, \`linksTo\`, \`aliases\`, and \`keywords\` in
|
|
17141
|
-
frontmatter; never write derived \`linkedFrom\` into source files. When
|
|
17142
|
-
creating a linked page, include \`keywords.primary\` and
|
|
17143
|
-
\`keywords.secondary\` with search-intent phrases that would help future
|
|
17144
|
-
agents choose this page as a \`linksTo\` target.
|
|
17145
|
-
|
|
17146
|
-
3. **Validate and fix until clean:**
|
|
17147
|
-
|
|
17148
|
-
\`\`\`sh
|
|
17149
|
-
contentbit validate <file> [--registry <path>]
|
|
17150
|
-
\`\`\`
|
|
17151
|
-
|
|
17152
|
-
Diagnostics print to stderr as \`file:line:col severity CODE message\`, often
|
|
17153
|
-
with a \`hint:\` line suggesting the fix. Exit 0 means clean; exit 1 means
|
|
17154
|
-
errors remain. If the document has link frontmatter, validate the full
|
|
17155
|
-
content glob so cross-file links are checked against the whole graph. Fix
|
|
17156
|
-
every diagnostic and re-run. Never finish with a failing validate.
|
|
17157
|
-
|
|
17158
|
-
4. **Refresh internal links when present:**
|
|
17159
|
-
|
|
17160
|
-
\`\`\`sh
|
|
17161
|
-
contentbit links <content glob> --fix
|
|
17162
|
-
\`\`\`
|
|
17163
|
-
|
|
17164
|
-
\`--fix\` only rewrites \`linksTo\` values that point at known aliases. It
|
|
17165
|
-
does not invent links, remove aliases, or write backlinks. Re-run validate
|
|
17166
|
-
after it changes files.
|
|
17167
|
-
|
|
17168
|
-
## Failure modes
|
|
17169
|
-
|
|
17170
|
-
- \`contentbit\` not found or no registry resolvable: the project is not set up.
|
|
17171
|
-
Say so and suggest \`npx contentbit@latest init\` \u2014 do not invent block syntax.
|
|
17172
|
-
- A block you want does not exist: use plain Markdown, or ask whether to define
|
|
17173
|
-
a custom block in the registry. Never emit an unregistered block name.
|
|
17174
|
-
`;
|
|
17175
|
-
AUDIT_SKILL = `---
|
|
17176
|
-
name: contentbit-audit
|
|
17177
|
-
description: |
|
|
17178
|
-
Audit contentbit Markdown content health using document stats. Use when asked
|
|
17179
|
-
to audit, review, or find improvements across content \u2014 thin pages, missing
|
|
17180
|
-
structure, validation issues \u2014 in a project that uses contentbit.
|
|
17181
|
-
version: ${TEMPLATE_VERSION}
|
|
17182
|
-
---
|
|
17183
|
-
|
|
17184
|
-
# Auditing contentbit content
|
|
17185
|
-
|
|
17186
|
-
\`contentbit doctor\` is the first audit command. It reads content once, runs
|
|
17187
|
-
block validation, link validation, and document stats, then prints a ranked
|
|
17188
|
-
repair plan. It is read-only: it does not write the link index and never edits
|
|
17189
|
-
source files. \`contentbit stats\` remains useful when you need raw JSON metrics.
|
|
17190
|
-
\`contentbit links\` builds the frontmatter-authored internal-link graph and can
|
|
17191
|
-
heal alias references with \`--fix\`.
|
|
17192
|
-
|
|
17193
|
-
## Gather
|
|
17194
|
-
|
|
17195
|
-
Check \`package.json\` for \`content:doctor\` first. If it exists, run it. If it
|
|
17196
|
-
does not, use \`content:check\` to find this project's content glob and
|
|
17197
|
-
\`--registry\` flag, then run:
|
|
17198
|
-
|
|
17199
|
-
\`\`\`sh
|
|
17200
|
-
contentbit doctor "content/**/*.md" [--registry <path>]
|
|
17201
|
-
contentbit doctor "content/**/*.md" [--registry <path>] --json
|
|
17202
|
-
contentbit stats "content/**/*.md" [--registry <path>]
|
|
17203
|
-
contentbit links "content/**/*.md"
|
|
17204
|
-
\`\`\`
|
|
17205
|
-
|
|
17206
|
-
\`doctor --json\` prints a stable report with summary counts and ranked
|
|
17207
|
-
findings. \`stats\` prints per-file metrics: frontmatter data, a heading
|
|
17208
|
-
\`outline\` with per-section word counts, \`blocks.byName\` usage counts,
|
|
17209
|
-
\`links.domains\`, and a \`validation\` summary (\`errors\`/\`warnings\`).
|
|
17210
|
-
\`contentbit links\` writes \`.contentbit/link-index.json\`, whose pages contain
|
|
17211
|
-
\`slug\`, resolved \`linksTo\`, derived \`linkedFrom\`, \`aliases\`, and
|
|
17212
|
-
\`keywords\`.
|
|
17213
|
-
|
|
17214
|
-
## Interpret
|
|
17215
|
-
|
|
17216
|
-
Prioritize findings in the order \`doctor\` reports them:
|
|
17217
|
-
|
|
17218
|
-
1. **Validation errors and warnings** \u2014 broken content ships broken pages.
|
|
17219
|
-
2. **Internal-link errors** \u2014 unresolved links, duplicate slugs, and alias
|
|
17220
|
-
conflicts from \`contentbit links\`.
|
|
17221
|
-
3. **Orphans and self-links** \u2014 link warnings that point to isolated or noisy
|
|
17222
|
-
pages.
|
|
17223
|
-
4. **Thin documents** \u2014 outline sections with very low word counts.
|
|
17224
|
-
5. **Block-less documents** \u2014 \`blocks.byName\` empty where sibling documents
|
|
17225
|
-
use blocks; structure (steps, callouts, comparisons, faq) may be missing.
|
|
17226
|
-
6. **Missing or inconsistent frontmatter** compared to sibling documents.
|
|
17227
|
-
7. **Structural imbalance** \u2014 skipped heading levels, single-section walls of text.
|
|
17228
|
-
|
|
17229
|
-
## Report
|
|
17230
|
-
|
|
17231
|
-
Report findings per file with concrete suggestions, ordered by priority. Do not
|
|
17232
|
-
edit files during the audit. To fix a finding, follow the contentbit-author
|
|
17233
|
-
skill (fetch the guide, edit, validate until clean) \u2014 offer that as a follow-up.
|
|
17234
|
-
`;
|
|
17235
|
-
AGENTS_MD_BLOCK = `<!-- contentbit:start -->
|
|
17236
|
-
|
|
17237
|
-
## contentbit content (generated \u2014 edits inside this block are overwritten)
|
|
17238
|
-
|
|
17239
|
-
This project validates Markdown content with contentbit. Documents are plain
|
|
17240
|
-
Markdown plus directive blocks (\`:::name{props} ... :::\`), each with a schema.
|
|
17241
|
-
The \`content:check\` script in package.json holds the canonical validate
|
|
17242
|
-
command \u2014 the content glob and the \`--registry\` flag \u2014 reuse its arguments.
|
|
17243
|
-
If the project has a \`content:links\` script, use it to build the internal-link
|
|
17244
|
-
index; otherwise run \`contentbit links <content glob>\`.
|
|
17245
|
-
|
|
17246
|
-
When writing or editing content:
|
|
17247
|
-
|
|
17248
|
-
1. Fetch the live authoring guide first \u2014 never guess block syntax:
|
|
17249
|
-
\`contentbit instructions --audience llm [--registry <path>]\`
|
|
17250
|
-
2. Write plain Markdown; use blocks where the guide's use-when guidance fits.
|
|
17251
|
-
3. If sibling documents use \`slug\` / \`linksTo\`, read
|
|
17252
|
-
\`.contentbit/link-index.json\` from \`contentbit links <content glob>\` and
|
|
17253
|
-
author frontmatter links with existing slugs. When creating a linked page,
|
|
17254
|
-
include \`keywords.primary\` and \`keywords.secondary\` with search-intent
|
|
17255
|
-
phrases future agents can use to choose related pages.
|
|
17256
|
-
4. Validate until clean (exit 0): \`contentbit validate <file> [--registry <path>]\`.
|
|
17257
|
-
Diagnostics print as \`file:line:col severity CODE message\` with fix hints.
|
|
17258
|
-
For link frontmatter, validate the full content glob so cross-file checks run.
|
|
17259
|
-
|
|
17260
|
-
When auditing content health:
|
|
17261
|
-
|
|
17262
|
-
- \`contentbit doctor "content/**/*.md" [--registry <path>]\` prints a ranked,
|
|
17263
|
-
read-only repair plan: validation issues, link issues, thin sections,
|
|
17264
|
-
block-less long documents, and missing image alt text.
|
|
17265
|
-
- \`contentbit doctor "content/**/*.md" [--registry <path>] --json\` prints the
|
|
17266
|
-
same findings as structured JSON for agents and CI.
|
|
17267
|
-
- \`contentbit stats "content/**/*.md" [--registry <path>]\` prints raw JSON
|
|
17268
|
-
stats: outline word counts, block usage, link domains, and validation
|
|
17269
|
-
error/warning counts.
|
|
17270
|
-
- \`contentbit links "content/**/*.md" [--fix]\` builds
|
|
17271
|
-
\`.contentbit/link-index.json\`, reports dangling links/orphans, and rewrites
|
|
17272
|
-
alias references in \`linksTo\` when \`--fix\` is used.
|
|
17273
|
-
|
|
17274
|
-
If \`contentbit\` is unavailable, suggest \`npx contentbit@latest init\` instead
|
|
17275
|
-
of inventing block syntax.
|
|
17276
|
-
|
|
17277
|
-
<!-- contentbit:end -->`;
|
|
17333
|
+
init_AGENTS();
|
|
17334
|
+
init_SKILL();
|
|
17335
|
+
init_SKILL2();
|
|
17336
|
+
AUTHOR_SKILL = SKILL_default2;
|
|
17337
|
+
AUDIT_SKILL = SKILL_default;
|
|
17338
|
+
AGENTS_MD_BLOCK = AGENTS_default.trimEnd();
|
|
17278
17339
|
START = "<!-- contentbit:start -->";
|
|
17279
17340
|
END = "<!-- contentbit:end -->";
|
|
17280
17341
|
}
|
|
17281
17342
|
});
|
|
17282
17343
|
|
|
17283
|
-
// src/commands/init.ts
|
|
17284
|
-
var init_exports = {};
|
|
17285
|
-
__export(init_exports, {
|
|
17286
|
-
initCommand: () => initCommand
|
|
17287
|
-
});
|
|
17288
|
-
import { spawn } from "node:child_process";
|
|
17344
|
+
// src/commands/init-targets.ts
|
|
17289
17345
|
import { existsSync as existsSync2 } from "node:fs";
|
|
17290
|
-
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
17291
17346
|
import { join as join2 } from "node:path";
|
|
17292
|
-
import { parseArgs as parseArgs2 } from "node:util";
|
|
17293
17347
|
function blockComponentsTemplate(styled) {
|
|
17294
17348
|
const body = styled ? ` return (
|
|
17295
17349
|
<figure className="my-6 border-s-2 ps-4">
|
|
@@ -17357,29 +17411,6 @@ export function Content({ source }: { source: string }) {
|
|
|
17357
17411
|
}
|
|
17358
17412
|
`;
|
|
17359
17413
|
}
|
|
17360
|
-
function htmlRenderScript(md) {
|
|
17361
|
-
const wiring = md === "marked" ? `import { marked } from 'marked'
|
|
17362
|
-
|
|
17363
|
-
const renderMarkdown = (md) => marked.parse(md, { async: false })` : md === "markdown-it" ? `import MarkdownIt from 'markdown-it'
|
|
17364
|
-
|
|
17365
|
-
const mdIt = new MarkdownIt() // html: false by default \u2014 raw HTML stays escaped
|
|
17366
|
-
const renderMarkdown = (md) => mdIt.render(md)` : `// TODO: plug a Markdown library in here (marked, markdown-it, remark).
|
|
17367
|
-
const renderMarkdown = undefined`;
|
|
17368
|
-
return `// Render content/example.md to example.html. Run: node scripts/render-example.mjs
|
|
17369
|
-
import { genericBlocks } from '@contentbit/blocks'
|
|
17370
|
-
import { createBlockRegistry, parseDocument, stripFrontmatter, validateDocument } from '@contentbit/core'
|
|
17371
|
-
import { renderToHtml } from '@contentbit/html'
|
|
17372
|
-
import { readFile, writeFile } from 'node:fs/promises'
|
|
17373
|
-
${wiring}
|
|
17374
|
-
|
|
17375
|
-
const source = await readFile('content/example.md', 'utf8')
|
|
17376
|
-
const registry = createBlockRegistry().use(genericBlocks())
|
|
17377
|
-
const result = validateDocument(parseDocument(stripFrontmatter(source)), registry)
|
|
17378
|
-
const html = renderToHtml(result.document, { renderMarkdown })
|
|
17379
|
-
await writeFile('example.html', html, 'utf8')
|
|
17380
|
-
console.log('wrote example.html')
|
|
17381
|
-
`;
|
|
17382
|
-
}
|
|
17383
17414
|
function detectFramework(cwd, deps) {
|
|
17384
17415
|
if ((deps["@tanstack/react-start"] || deps["@tanstack/react-router"]) && existsSync2(join2(cwd, "src/routes"))) {
|
|
17385
17416
|
return {
|
|
@@ -17428,6 +17459,164 @@ const result = validateDocument(parseDocument(entry.body), registry)
|
|
|
17428
17459
|
</main>
|
|
17429
17460
|
`;
|
|
17430
17461
|
}
|
|
17462
|
+
function runtimeWith(...extra) {
|
|
17463
|
+
return [...RUNTIME_BASE, ...extra];
|
|
17464
|
+
}
|
|
17465
|
+
function reactRuntime(md) {
|
|
17466
|
+
return runtimeWith("@contentbit/react", ...md === "none" ? [] : [md]);
|
|
17467
|
+
}
|
|
17468
|
+
async function createReactPlan(ctx) {
|
|
17469
|
+
const files = [];
|
|
17470
|
+
const layout = detectFramework(ctx.cwd, ctx.deps);
|
|
17471
|
+
const componentsJsonPath = join2(ctx.cwd, "components.json");
|
|
17472
|
+
const styled = !ctx.noStyled && existsSync2(componentsJsonPath) && await ctx.installStyledPack("@contentbit/generic-pack");
|
|
17473
|
+
const depth = layout.componentPath.split("/").length - 1;
|
|
17474
|
+
const blocksImport = `${"../".repeat(depth)}blocks`;
|
|
17475
|
+
files.push(["blocks/components.tsx", blockComponentsTemplate(styled)]);
|
|
17476
|
+
files.push([
|
|
17477
|
+
layout.componentPath,
|
|
17478
|
+
reactComponent(styled, ctx.md === "react-markdown", blocksImport)
|
|
17479
|
+
]);
|
|
17480
|
+
if (!ctx.noPage && layout.pagePath) {
|
|
17481
|
+
files.push([layout.pagePath, layout.framework === "tanstack" ? TANSTACK_PAGE : NEXT_PAGE]);
|
|
17482
|
+
}
|
|
17483
|
+
const nextSteps = !ctx.noPage && layout.pagePath ? [" 2. Start the dev server and open /example to see the article rendered."] : [
|
|
17484
|
+
' 2. Render it: import { Content } from "./components/content-blocks"',
|
|
17485
|
+
" <Content source={...content/example.md as a string} />"
|
|
17486
|
+
];
|
|
17487
|
+
nextSteps.push(" 3. Styled components: pnpm dlx shadcn@latest add @contentbit/generic-pack");
|
|
17488
|
+
return { files, nextSteps };
|
|
17489
|
+
}
|
|
17490
|
+
async function createAstroPlan(ctx) {
|
|
17491
|
+
const files = [["blocks/QuoteBlock.astro", ASTRO_QUOTE_BLOCK]];
|
|
17492
|
+
const componentsJsonPath = join2(ctx.cwd, "components.json");
|
|
17493
|
+
const styled = !ctx.noStyled && existsSync2(componentsJsonPath) && await ctx.installStyledPack("@contentbit/astro-pack");
|
|
17494
|
+
const configCandidates = ["ts", "mts", "mjs", "js"].flatMap((ext) => [
|
|
17495
|
+
`src/content.config.${ext}`,
|
|
17496
|
+
`src/content/config.${ext}`
|
|
17497
|
+
]);
|
|
17498
|
+
const existingConfig = configCandidates.find((p) => existsSync2(join2(ctx.cwd, p)));
|
|
17499
|
+
if (existingConfig) {
|
|
17500
|
+
ctx.io.stdout(`content config exists (${existingConfig}); add this collection manually:`);
|
|
17501
|
+
ctx.io.stdout(ASTRO_CONTENT_CONFIG);
|
|
17502
|
+
ctx.io.stdout('the example page expects the "articles" collection above');
|
|
17503
|
+
} else {
|
|
17504
|
+
files.push(["src/content.config.ts", ASTRO_CONTENT_CONFIG]);
|
|
17505
|
+
}
|
|
17506
|
+
if (!ctx.noPage) files.push(["src/pages/example.astro", astroPage(styled)]);
|
|
17507
|
+
return {
|
|
17508
|
+
files,
|
|
17509
|
+
nextSteps: [
|
|
17510
|
+
" 2. Start the dev server and open /example to see the article rendered.",
|
|
17511
|
+
" 3. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack"
|
|
17512
|
+
]
|
|
17513
|
+
};
|
|
17514
|
+
}
|
|
17515
|
+
function detectTarget(deps) {
|
|
17516
|
+
const hasReact = Boolean(deps.react);
|
|
17517
|
+
const hasAstro = Boolean(deps.astro);
|
|
17518
|
+
return hasAstro ? "astro" : hasReact ? "react" : "markdown";
|
|
17519
|
+
}
|
|
17520
|
+
var TARGETS, RUNTIME_BASE, TANSTACK_PAGE, NEXT_PAGE, ASTRO_CONTENT_CONFIG, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
|
|
17521
|
+
var init_init_targets = __esm({
|
|
17522
|
+
"src/commands/init-targets.ts"() {
|
|
17523
|
+
"use strict";
|
|
17524
|
+
TARGETS = ["react", "markdown", "astro"];
|
|
17525
|
+
RUNTIME_BASE = ["@contentbit/core", "@contentbit/blocks", "zod"];
|
|
17526
|
+
TANSTACK_PAGE = `import { createFileRoute } from '@tanstack/react-router'
|
|
17527
|
+
|
|
17528
|
+
import { Content } from '../components/content-blocks'
|
|
17529
|
+
// Vite's ?raw import inlines the Markdown as a string at build time.
|
|
17530
|
+
import source from '../../content/example.md?raw'
|
|
17531
|
+
|
|
17532
|
+
export const Route = createFileRoute('/example')({ component: ExamplePage })
|
|
17533
|
+
|
|
17534
|
+
function ExamplePage() {
|
|
17535
|
+
return (
|
|
17536
|
+
<main style={{ maxWidth: '42rem', margin: '0 auto', padding: '3rem 1.5rem' }}>
|
|
17537
|
+
<Content source={source} />
|
|
17538
|
+
</main>
|
|
17539
|
+
)
|
|
17540
|
+
}
|
|
17541
|
+
`;
|
|
17542
|
+
NEXT_PAGE = `import { readFile } from 'node:fs/promises'
|
|
17543
|
+
|
|
17544
|
+
// If your project has no "@/" path alias, switch to a relative import.
|
|
17545
|
+
import { Content } from '@/components/content-blocks'
|
|
17546
|
+
|
|
17547
|
+
export default async function ExamplePage() {
|
|
17548
|
+
const source = await readFile('content/example.md', 'utf8')
|
|
17549
|
+
return (
|
|
17550
|
+
<main style={{ maxWidth: '42rem', margin: '0 auto', padding: '3rem 1.5rem' }}>
|
|
17551
|
+
<Content source={source} />
|
|
17552
|
+
</main>
|
|
17553
|
+
)
|
|
17554
|
+
}
|
|
17555
|
+
`;
|
|
17556
|
+
ASTRO_CONTENT_CONFIG = `import { defineCollection } from 'astro:content'
|
|
17557
|
+
import { glob } from 'astro/loaders'
|
|
17558
|
+
|
|
17559
|
+
export const collections = {
|
|
17560
|
+
articles: defineCollection({
|
|
17561
|
+
// Astro's builtin Markdown loader. Entry bodies are parsed and validated
|
|
17562
|
+
// where they render (see src/pages/example.astro); \`contentbit validate\`
|
|
17563
|
+
// covers the same files in CI.
|
|
17564
|
+
loader: glob({ pattern: '**/*.md', base: './content' }),
|
|
17565
|
+
}),
|
|
17566
|
+
}
|
|
17567
|
+
`;
|
|
17568
|
+
ASTRO_QUOTE_BLOCK = `---
|
|
17569
|
+
// The Astro component for the custom \`quote\` block defined in blocks/registry.ts.
|
|
17570
|
+
// Block props arrive as component props; nested content arrives via <slot />.
|
|
17571
|
+
interface Props {
|
|
17572
|
+
author: string
|
|
17573
|
+
role?: string
|
|
17574
|
+
}
|
|
17575
|
+
|
|
17576
|
+
const { author, role } = Astro.props
|
|
17577
|
+
---
|
|
17578
|
+
|
|
17579
|
+
<figure style="margin: 1.5rem 0; border-left: 2px solid #d4d4d4; padding-left: 1rem;">
|
|
17580
|
+
<blockquote style="font-style: italic;"><slot /></blockquote>
|
|
17581
|
+
<figcaption style="margin-top: 0.5rem; font-size: 0.875rem; opacity: 0.7;">
|
|
17582
|
+
\u2014 {author}{role ? \`, \${role}\` : null}
|
|
17583
|
+
</figcaption>
|
|
17584
|
+
</figure>
|
|
17585
|
+
`;
|
|
17586
|
+
TARGET_ADAPTERS = {
|
|
17587
|
+
react: {
|
|
17588
|
+
markdownChoices: ["react-markdown", "none"],
|
|
17589
|
+
runtimeDependencies: reactRuntime,
|
|
17590
|
+
createPlan: createReactPlan
|
|
17591
|
+
},
|
|
17592
|
+
markdown: {
|
|
17593
|
+
markdownChoices: ["none"],
|
|
17594
|
+
runtimeDependencies: () => runtimeWith(),
|
|
17595
|
+
createPlan: async () => ({
|
|
17596
|
+
files: [],
|
|
17597
|
+
nextSteps: [" 2. Render it: contentbit render content/example.md"]
|
|
17598
|
+
})
|
|
17599
|
+
},
|
|
17600
|
+
astro: {
|
|
17601
|
+
// Astro projects usually reuse their host Markdown pipeline.
|
|
17602
|
+
markdownChoices: ["none"],
|
|
17603
|
+
runtimeDependencies: () => runtimeWith("@contentbit/astro"),
|
|
17604
|
+
createPlan: createAstroPlan
|
|
17605
|
+
}
|
|
17606
|
+
};
|
|
17607
|
+
}
|
|
17608
|
+
});
|
|
17609
|
+
|
|
17610
|
+
// src/commands/init.ts
|
|
17611
|
+
var init_exports = {};
|
|
17612
|
+
__export(init_exports, {
|
|
17613
|
+
initCommand: () => initCommand
|
|
17614
|
+
});
|
|
17615
|
+
import { spawn } from "node:child_process";
|
|
17616
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
17617
|
+
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
17618
|
+
import { join as join3 } from "node:path";
|
|
17619
|
+
import { parseArgs as parseArgs2 } from "node:util";
|
|
17431
17620
|
function detectPackageManager(cwd) {
|
|
17432
17621
|
const locks = [
|
|
17433
17622
|
["pnpm-lock.yaml", "pnpm"],
|
|
@@ -17437,7 +17626,7 @@ function detectPackageManager(cwd) {
|
|
|
17437
17626
|
["package-lock.json", "npm"]
|
|
17438
17627
|
];
|
|
17439
17628
|
for (const [file2, pm] of locks) {
|
|
17440
|
-
if (
|
|
17629
|
+
if (existsSync3(join3(cwd, file2))) return pm;
|
|
17441
17630
|
}
|
|
17442
17631
|
const agent = process.env.npm_config_user_agent ?? "";
|
|
17443
17632
|
for (const pm of ["pnpm", "yarn", "bun"]) {
|
|
@@ -17463,7 +17652,7 @@ function runInstall(pm, args, cwd) {
|
|
|
17463
17652
|
});
|
|
17464
17653
|
}
|
|
17465
17654
|
async function installStyledPack(cwd, pack, noInstall, io) {
|
|
17466
|
-
const componentsJsonPath =
|
|
17655
|
+
const componentsJsonPath = join3(cwd, "components.json");
|
|
17467
17656
|
const componentsJson = JSON.parse(await readFile2(componentsJsonPath, "utf8"));
|
|
17468
17657
|
componentsJson.registries ??= {};
|
|
17469
17658
|
if (!componentsJson.registries["@contentbit"]) {
|
|
@@ -17479,7 +17668,7 @@ async function installStyledPack(cwd, pack, noInstall, io) {
|
|
|
17479
17668
|
const [bin, prefix] = dlxCommand(detectPackageManager(cwd));
|
|
17480
17669
|
io.stdout(`installing the styled pack: shadcn add ${pack}`);
|
|
17481
17670
|
const code = await runInstall(bin, [...prefix, "shadcn@latest", "add", pack, "--yes"], cwd);
|
|
17482
|
-
if (code !== 0) io.stderr("styled pack install failed; falling back to headless
|
|
17671
|
+
if (code !== 0) io.stderr("styled pack install failed; falling back to the headless renderer");
|
|
17483
17672
|
return code === 0;
|
|
17484
17673
|
}
|
|
17485
17674
|
async function scaffold(path, content) {
|
|
@@ -17487,7 +17676,7 @@ async function scaffold(path, content) {
|
|
|
17487
17676
|
await readFile2(path, "utf8");
|
|
17488
17677
|
return "skipped";
|
|
17489
17678
|
} catch {
|
|
17490
|
-
await mkdir2(
|
|
17679
|
+
await mkdir2(join3(path, ".."), { recursive: true });
|
|
17491
17680
|
await writeFile2(path, content, "utf8");
|
|
17492
17681
|
return "created";
|
|
17493
17682
|
}
|
|
@@ -17508,16 +17697,15 @@ async function initCommand(args, io) {
|
|
|
17508
17697
|
});
|
|
17509
17698
|
const cwd = values.cwd;
|
|
17510
17699
|
let pkg;
|
|
17511
|
-
const pkgPath =
|
|
17700
|
+
const pkgPath = join3(cwd, "package.json");
|
|
17512
17701
|
try {
|
|
17513
17702
|
pkg = JSON.parse(await readFile2(pkgPath, "utf8"));
|
|
17514
17703
|
} catch {
|
|
17515
17704
|
io.stderr("No package.json found. Run this inside a project (npm init first).");
|
|
17516
17705
|
return 1;
|
|
17517
17706
|
}
|
|
17518
|
-
const
|
|
17519
|
-
const
|
|
17520
|
-
const detected = hasAstro ? "astro" : hasReact ? "react" : "html";
|
|
17707
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
17708
|
+
const detected = detectTarget(deps);
|
|
17521
17709
|
let target;
|
|
17522
17710
|
if (values.target) {
|
|
17523
17711
|
if (!TARGETS.includes(values.target)) {
|
|
@@ -17533,7 +17721,6 @@ async function initCommand(args, io) {
|
|
|
17533
17721
|
options: [
|
|
17534
17722
|
{ value: "react", label: "React", hint: "ContentBlocks component" },
|
|
17535
17723
|
{ value: "astro", label: "Astro", hint: "content collections + .astro components" },
|
|
17536
|
-
{ value: "html", label: "Static HTML", hint: "renderToHtml, no framework" },
|
|
17537
17724
|
{ value: "markdown", label: "Plain Markdown", hint: "fallback rendering only" }
|
|
17538
17725
|
]
|
|
17539
17726
|
});
|
|
@@ -17542,7 +17729,8 @@ async function initCommand(args, io) {
|
|
|
17542
17729
|
} else {
|
|
17543
17730
|
target = detected;
|
|
17544
17731
|
}
|
|
17545
|
-
const
|
|
17732
|
+
const adapter = TARGET_ADAPTERS[target];
|
|
17733
|
+
const choices = adapter.markdownChoices;
|
|
17546
17734
|
let md;
|
|
17547
17735
|
if (values.md) {
|
|
17548
17736
|
if (!choices.includes(values.md)) {
|
|
@@ -17566,76 +17754,38 @@ async function initCommand(args, io) {
|
|
|
17566
17754
|
} else {
|
|
17567
17755
|
md = choices[0];
|
|
17568
17756
|
}
|
|
17569
|
-
const runtime =
|
|
17570
|
-
if (target === "react") runtime.push("@contentbit/react");
|
|
17571
|
-
if (target === "html") runtime.push("@contentbit/html");
|
|
17572
|
-
if (target === "astro") runtime.push("@contentbit/astro");
|
|
17573
|
-
if (md !== "none") runtime.push(md);
|
|
17757
|
+
const runtime = adapter.runtimeDependencies(md);
|
|
17574
17758
|
if (values["no-install"]) {
|
|
17575
17759
|
io.stdout(`skipped install: ${runtime.join(" ")} + contentbit (dev)`);
|
|
17576
17760
|
} else {
|
|
17577
|
-
const
|
|
17578
|
-
io.stdout(`installing with ${
|
|
17579
|
-
if (await runInstall(
|
|
17761
|
+
const pm2 = detectPackageManager(cwd);
|
|
17762
|
+
io.stdout(`installing with ${pm2}: ${runtime.join(" ")}`);
|
|
17763
|
+
if (await runInstall(pm2, installArgs(pm2, false, runtime), cwd) !== 0) {
|
|
17580
17764
|
io.stderr("install failed");
|
|
17581
17765
|
return 1;
|
|
17582
17766
|
}
|
|
17583
|
-
if (await runInstall(
|
|
17767
|
+
if (await runInstall(pm2, installArgs(pm2, true, ["contentbit"]), cwd) !== 0) {
|
|
17584
17768
|
io.stderr("install failed");
|
|
17585
17769
|
return 1;
|
|
17586
17770
|
}
|
|
17587
17771
|
}
|
|
17772
|
+
const plan = await adapter.createPlan({
|
|
17773
|
+
cwd,
|
|
17774
|
+
deps,
|
|
17775
|
+
md,
|
|
17776
|
+
noPage: Boolean(values["no-page"]),
|
|
17777
|
+
noStyled: Boolean(values["no-styled"]),
|
|
17778
|
+
io,
|
|
17779
|
+
installStyledPack: (pack) => installStyledPack(cwd, pack, values["no-install"], io)
|
|
17780
|
+
});
|
|
17588
17781
|
const files = [
|
|
17589
17782
|
["blocks/registry.ts", REGISTRY_TEMPLATE],
|
|
17590
17783
|
["content/example.md", EXAMPLE_CONTENT],
|
|
17591
|
-
["content/related.md", RELATED_CONTENT]
|
|
17784
|
+
["content/related.md", RELATED_CONTENT],
|
|
17785
|
+
...plan.files
|
|
17592
17786
|
];
|
|
17593
|
-
const layout = detectFramework(cwd, { ...pkg.dependencies, ...pkg.devDependencies });
|
|
17594
|
-
let styled = false;
|
|
17595
|
-
const componentsJsonPath = join2(cwd, "components.json");
|
|
17596
|
-
if (target === "react" && !values["no-styled"] && existsSync2(componentsJsonPath)) {
|
|
17597
|
-
styled = await installStyledPack(cwd, "@contentbit/generic-pack", values["no-install"], io);
|
|
17598
|
-
}
|
|
17599
|
-
if (target === "react") {
|
|
17600
|
-
const depth = layout.componentPath.split("/").length - 1;
|
|
17601
|
-
const blocksImport = `${"../".repeat(depth)}blocks`;
|
|
17602
|
-
files.push(["blocks/components.tsx", blockComponentsTemplate(styled)]);
|
|
17603
|
-
files.push([
|
|
17604
|
-
layout.componentPath,
|
|
17605
|
-
reactComponent(styled, md === "react-markdown", blocksImport)
|
|
17606
|
-
]);
|
|
17607
|
-
if (!values["no-page"] && layout.pagePath) {
|
|
17608
|
-
files.push([layout.pagePath, layout.framework === "tanstack" ? TANSTACK_PAGE : NEXT_PAGE]);
|
|
17609
|
-
}
|
|
17610
|
-
}
|
|
17611
|
-
if (target === "html") {
|
|
17612
|
-
files.push([
|
|
17613
|
-
"scripts/render-example.mjs",
|
|
17614
|
-
htmlRenderScript(md)
|
|
17615
|
-
]);
|
|
17616
|
-
}
|
|
17617
|
-
if (target === "astro") {
|
|
17618
|
-
let astroStyled = false;
|
|
17619
|
-
if (!values["no-styled"] && existsSync2(componentsJsonPath)) {
|
|
17620
|
-
astroStyled = await installStyledPack(cwd, "@contentbit/astro-pack", values["no-install"], io);
|
|
17621
|
-
}
|
|
17622
|
-
files.push(["blocks/QuoteBlock.astro", ASTRO_QUOTE_BLOCK]);
|
|
17623
|
-
const configCandidates = ["ts", "mts", "mjs", "js"].flatMap((ext) => [
|
|
17624
|
-
`src/content.config.${ext}`,
|
|
17625
|
-
`src/content/config.${ext}`
|
|
17626
|
-
]);
|
|
17627
|
-
const existingConfig = configCandidates.find((p) => existsSync2(join2(cwd, p)));
|
|
17628
|
-
if (existingConfig) {
|
|
17629
|
-
io.stdout(`content config exists (${existingConfig}); add this collection manually:`);
|
|
17630
|
-
io.stdout(ASTRO_CONTENT_CONFIG);
|
|
17631
|
-
io.stdout('the example page expects the "articles" collection above');
|
|
17632
|
-
} else {
|
|
17633
|
-
files.push(["src/content.config.ts", ASTRO_CONTENT_CONFIG]);
|
|
17634
|
-
}
|
|
17635
|
-
if (!values["no-page"]) files.push(["src/pages/example.astro", astroPage(astroStyled)]);
|
|
17636
|
-
}
|
|
17637
17787
|
for (const [rel, content] of files) {
|
|
17638
|
-
const result = await scaffold(
|
|
17788
|
+
const result = await scaffold(join3(cwd, rel), content);
|
|
17639
17789
|
io.stdout(`${result}: ${rel}`);
|
|
17640
17790
|
}
|
|
17641
17791
|
const fresh = JSON.parse(await readFile2(pkgPath, "utf8"));
|
|
@@ -17662,12 +17812,12 @@ async function initCommand(args, io) {
|
|
|
17662
17812
|
}
|
|
17663
17813
|
let registry2;
|
|
17664
17814
|
try {
|
|
17665
|
-
registry2 = await loadRegistry(
|
|
17815
|
+
registry2 = await loadRegistry(join3(cwd, "blocks/registry.ts"));
|
|
17666
17816
|
} catch {
|
|
17667
17817
|
registry2 = await loadRegistry();
|
|
17668
17818
|
}
|
|
17669
17819
|
const guide = registry2.toAuthoringGuide({ audience: "llm", includeExamples: true });
|
|
17670
|
-
await writeFile2(
|
|
17820
|
+
await writeFile2(join3(cwd, "contentbit-guide.md"), guide, "utf8");
|
|
17671
17821
|
io.stdout("created: contentbit-guide.md (LLM authoring instructions)");
|
|
17672
17822
|
if (!values["no-agents"]) {
|
|
17673
17823
|
await installAgentIntegration(cwd, {}, io);
|
|
@@ -17676,50 +17826,30 @@ async function initCommand(args, io) {
|
|
|
17676
17826
|
}
|
|
17677
17827
|
io.stdout("");
|
|
17678
17828
|
io.stdout("Done. Next steps:");
|
|
17679
|
-
|
|
17680
|
-
io.stdout(`
|
|
17681
|
-
io.stdout(`
|
|
17682
|
-
io.stdout(`
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
io.stdout(" 2. Start the dev server and open /example to see the article rendered.");
|
|
17686
|
-
} else {
|
|
17687
|
-
io.stdout(' 2. Render it: import { Content } from "./components/content-blocks"');
|
|
17688
|
-
io.stdout(" <Content source={...content/example.md as a string} />");
|
|
17689
|
-
}
|
|
17690
|
-
io.stdout(" 3. Styled components: pnpm dlx shadcn@latest add @contentbit/generic-pack");
|
|
17691
|
-
} else if (target === "astro") {
|
|
17692
|
-
io.stdout(" 2. Start the dev server and open /example to see the article rendered.");
|
|
17693
|
-
io.stdout(" 3. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack");
|
|
17694
|
-
} else if (target === "html") {
|
|
17695
|
-
io.stdout(" 2. Render it: node scripts/render-example.mjs && open example.html");
|
|
17696
|
-
} else {
|
|
17697
|
-
io.stdout(" 2. Render it: contentbit render content/example.md --target markdown");
|
|
17698
|
-
}
|
|
17829
|
+
const pm = detectPackageManager(cwd);
|
|
17830
|
+
io.stdout(` 1. Browse content locally: ${pm} run studio`);
|
|
17831
|
+
io.stdout(` Inspect content health: ${pm} run content:doctor`);
|
|
17832
|
+
io.stdout(` Validate the starter content: ${pm} run content:check`);
|
|
17833
|
+
io.stdout(` Build the link index: ${pm} run content:links`);
|
|
17834
|
+
for (const line of plan.nextSteps) io.stdout(line);
|
|
17699
17835
|
io.stdout(" Docs: https://contentbit.dev/docs");
|
|
17700
17836
|
return 0;
|
|
17701
17837
|
}
|
|
17702
|
-
var
|
|
17838
|
+
var REGISTRY_TEMPLATE, EXAMPLE_CONTENT, RELATED_CONTENT;
|
|
17703
17839
|
var init_init = __esm({
|
|
17704
17840
|
"src/commands/init.ts"() {
|
|
17705
17841
|
"use strict";
|
|
17706
17842
|
init_load_registry();
|
|
17707
17843
|
init_agents();
|
|
17708
|
-
|
|
17709
|
-
MD_CHOICES = {
|
|
17710
|
-
react: ["react-markdown", "none"],
|
|
17711
|
-
html: ["marked", "markdown-it", "none"],
|
|
17712
|
-
markdown: ["none"],
|
|
17713
|
-
// @contentbit/astro ships its own marked-based default; nothing to install.
|
|
17714
|
-
astro: ["none"]
|
|
17715
|
-
};
|
|
17844
|
+
init_init_targets();
|
|
17716
17845
|
REGISTRY_TEMPLATE = `// Custom block definitions for this project. The CLI and your app share
|
|
17717
17846
|
// this module \u2014 Node 22.18+ imports TypeScript directly:
|
|
17718
17847
|
//
|
|
17719
17848
|
// contentbit validate "content/**/*.md" --registry ./blocks/registry.ts
|
|
17720
17849
|
//
|
|
17721
17850
|
// Definitions stay framework-free (the CLI and every render target use
|
|
17722
|
-
// them);
|
|
17851
|
+
// them); render components live next door in blocks/components.tsx or
|
|
17852
|
+
// framework-specific component files copied from the shadcn registry.
|
|
17723
17853
|
// Docs: https://contentbit.dev/docs/guides/custom-blocks
|
|
17724
17854
|
import { defineBlock, markdownBody, type BlockDefinition } from '@contentbit/core'
|
|
17725
17855
|
import { z } from 'zod'
|
|
@@ -17778,86 +17908,62 @@ weaves flowers and leaves.
|
|
|
17778
17908
|
slug: related-contentbit-workflows
|
|
17779
17909
|
linksTo:
|
|
17780
17910
|
- hello-content-blocks
|
|
17781
|
-
keywords:
|
|
17782
|
-
primary: contentbit workflow
|
|
17783
|
-
secondary: [validation loop, internal links]
|
|
17784
|
-
---
|
|
17785
|
-
|
|
17786
|
-
# Related contentbit workflows
|
|
17787
|
-
|
|
17788
|
-
This supporting page exists to show internal links in frontmatter. The link
|
|
17789
|
-
graph is authored once with \`slug\` and \`linksTo\`, then contentbit derives
|
|
17790
|
-
\`linkedFrom\` in \`.contentbit/link-index.json\`.
|
|
17791
|
-
|
|
17792
|
-
:::callout{type="note"}
|
|
17793
|
-
Run \`contentbit links "content/**/*.md" --fix\` after renaming a page. Alias
|
|
17794
|
-
references in \`linksTo\` are rewritten to the current slug, while \`aliases\`
|
|
17795
|
-
stays as the rename record.
|
|
17796
|
-
:::
|
|
17797
|
-
`;
|
|
17798
|
-
TANSTACK_PAGE = `import { createFileRoute } from '@tanstack/react-router'
|
|
17799
|
-
|
|
17800
|
-
import { Content } from '../components/content-blocks'
|
|
17801
|
-
// Vite's ?raw import inlines the Markdown as a string at build time.
|
|
17802
|
-
import source from '../../content/example.md?raw'
|
|
17803
|
-
|
|
17804
|
-
export const Route = createFileRoute('/example')({ component: ExamplePage })
|
|
17805
|
-
|
|
17806
|
-
function ExamplePage() {
|
|
17807
|
-
return (
|
|
17808
|
-
<main style={{ maxWidth: '42rem', margin: '0 auto', padding: '3rem 1.5rem' }}>
|
|
17809
|
-
<Content source={source} />
|
|
17810
|
-
</main>
|
|
17811
|
-
)
|
|
17812
|
-
}
|
|
17813
|
-
`;
|
|
17814
|
-
NEXT_PAGE = `import { readFile } from 'node:fs/promises'
|
|
17815
|
-
|
|
17816
|
-
// If your project has no "@/" path alias, switch to a relative import.
|
|
17817
|
-
import { Content } from '@/components/content-blocks'
|
|
17818
|
-
|
|
17819
|
-
export default async function ExamplePage() {
|
|
17820
|
-
const source = await readFile('content/example.md', 'utf8')
|
|
17821
|
-
return (
|
|
17822
|
-
<main style={{ maxWidth: '42rem', margin: '0 auto', padding: '3rem 1.5rem' }}>
|
|
17823
|
-
<Content source={source} />
|
|
17824
|
-
</main>
|
|
17825
|
-
)
|
|
17826
|
-
}
|
|
17827
|
-
`;
|
|
17828
|
-
ASTRO_CONTENT_CONFIG = `import { defineCollection } from 'astro:content'
|
|
17829
|
-
import { glob } from 'astro/loaders'
|
|
17830
|
-
|
|
17831
|
-
export const collections = {
|
|
17832
|
-
articles: defineCollection({
|
|
17833
|
-
// Astro's builtin Markdown loader. Entry bodies are parsed and validated
|
|
17834
|
-
// where they render (see src/pages/example.astro); \`contentbit validate\`
|
|
17835
|
-
// covers the same files in CI.
|
|
17836
|
-
loader: glob({ pattern: '**/*.md', base: './content' }),
|
|
17837
|
-
}),
|
|
17838
|
-
}
|
|
17839
|
-
`;
|
|
17840
|
-
ASTRO_QUOTE_BLOCK = `---
|
|
17841
|
-
// The Astro component for the custom \`quote\` block defined in blocks/registry.ts.
|
|
17842
|
-
// Block props arrive as component props; nested content arrives via <slot />.
|
|
17843
|
-
interface Props {
|
|
17844
|
-
author: string
|
|
17845
|
-
role?: string
|
|
17846
|
-
}
|
|
17847
|
-
|
|
17848
|
-
const { author, role } = Astro.props
|
|
17911
|
+
keywords:
|
|
17912
|
+
primary: contentbit workflow
|
|
17913
|
+
secondary: [validation loop, internal links]
|
|
17849
17914
|
---
|
|
17850
17915
|
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17916
|
+
# Related contentbit workflows
|
|
17917
|
+
|
|
17918
|
+
This supporting page exists to show internal links in frontmatter. The link
|
|
17919
|
+
graph is authored once with \`slug\` and \`linksTo\`, then contentbit derives
|
|
17920
|
+
\`linkedFrom\` in \`.contentbit/link-index.json\`.
|
|
17921
|
+
|
|
17922
|
+
:::callout{type="note"}
|
|
17923
|
+
Run \`contentbit links "content/**/*.md" --fix\` after renaming a page. Alias
|
|
17924
|
+
references in \`linksTo\` are rewritten to the current slug, while \`aliases\`
|
|
17925
|
+
stays as the rename record.
|
|
17926
|
+
:::
|
|
17857
17927
|
`;
|
|
17858
17928
|
}
|
|
17859
17929
|
});
|
|
17860
17930
|
|
|
17931
|
+
// src/content-project.ts
|
|
17932
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
17933
|
+
import { glob } from "tinyglobby";
|
|
17934
|
+
async function resolveContentFiles(positionals, cmd) {
|
|
17935
|
+
if (positionals.length === 0) {
|
|
17936
|
+
throw new CliError(2, `${cmd}: provide at least one file or glob.`);
|
|
17937
|
+
}
|
|
17938
|
+
const files = (await glob(positionals, { absolute: true })).sort();
|
|
17939
|
+
if (files.length === 0) {
|
|
17940
|
+
throw new CliError(2, `${cmd}: no files matched ${positionals.join(" ")}`);
|
|
17941
|
+
}
|
|
17942
|
+
return files;
|
|
17943
|
+
}
|
|
17944
|
+
async function loadContentProject(input) {
|
|
17945
|
+
const files = await resolveContentFiles(input.positionals, input.cmd);
|
|
17946
|
+
const registry2 = await loadRegistry(input.registry, {
|
|
17947
|
+
includeGenericBlocks: input.includeGenericBlocks
|
|
17948
|
+
});
|
|
17949
|
+
const sources = await Promise.all(
|
|
17950
|
+
files.map(async (path) => ({ path, source: await readFile3(path, "utf8") }))
|
|
17951
|
+
);
|
|
17952
|
+
const scan = scanContentProject(sources, registry2, {
|
|
17953
|
+
linkOptions: input.linkOptions,
|
|
17954
|
+
...input.scan
|
|
17955
|
+
});
|
|
17956
|
+
return { files, registry: registry2, sources, linkOptions: input.linkOptions, scan };
|
|
17957
|
+
}
|
|
17958
|
+
var init_content_project = __esm({
|
|
17959
|
+
"src/content-project.ts"() {
|
|
17960
|
+
"use strict";
|
|
17961
|
+
init_dist();
|
|
17962
|
+
init_load_registry();
|
|
17963
|
+
init_run();
|
|
17964
|
+
}
|
|
17965
|
+
});
|
|
17966
|
+
|
|
17861
17967
|
// src/link-options.ts
|
|
17862
17968
|
function linkResolverOptions(values) {
|
|
17863
17969
|
const out = {};
|
|
@@ -17893,15 +17999,14 @@ var validate_exports = {};
|
|
|
17893
17999
|
__export(validate_exports, {
|
|
17894
18000
|
validateCommand: () => validateCommand
|
|
17895
18001
|
});
|
|
17896
|
-
import { readFile as readFile3 } from "node:fs/promises";
|
|
17897
18002
|
import { parseArgs as parseArgs3 } from "node:util";
|
|
17898
|
-
import { glob } from "tinyglobby";
|
|
17899
18003
|
async function validateCommand(args, io) {
|
|
17900
18004
|
const { values, positionals } = parseArgs3({
|
|
17901
18005
|
args,
|
|
17902
18006
|
allowPositionals: true,
|
|
17903
18007
|
options: {
|
|
17904
18008
|
registry: { type: "string" },
|
|
18009
|
+
"no-generic-blocks": { type: "boolean", default: false },
|
|
17905
18010
|
"strict-warnings": { type: "boolean", default: false },
|
|
17906
18011
|
"link-resolve": { type: "string" },
|
|
17907
18012
|
"locale-field": { type: "string" },
|
|
@@ -17910,48 +18015,55 @@ async function validateCommand(args, io) {
|
|
|
17910
18015
|
"default-locale": { type: "string" }
|
|
17911
18016
|
}
|
|
17912
18017
|
});
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
}
|
|
17922
|
-
const registry2 = await loadRegistry(values.registry);
|
|
17923
|
-
const linkOptions = linkResolverOptions(values);
|
|
18018
|
+
const { files, scan } = await loadContentProject({
|
|
18019
|
+
cmd: "validate",
|
|
18020
|
+
positionals,
|
|
18021
|
+
registry: values.registry,
|
|
18022
|
+
includeGenericBlocks: !values["no-generic-blocks"],
|
|
18023
|
+
linkOptions: linkResolverOptions(values),
|
|
18024
|
+
scan: { includeStatsFindings: false }
|
|
18025
|
+
});
|
|
17924
18026
|
let errors = 0;
|
|
17925
18027
|
let warnings = 0;
|
|
17926
|
-
const
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
const result = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
|
|
17931
|
-
for (const d of result.diagnostics) {
|
|
17932
|
-
io.stderr(formatDiagnostic(d, file2));
|
|
17933
|
-
if (d.severity === "error") errors++;
|
|
17934
|
-
else if (d.severity === "warning") warnings++;
|
|
17935
|
-
}
|
|
18028
|
+
for (const finding of scan.findings) {
|
|
18029
|
+
io.stderr(formatDiagnosticForCli(diagnosticFromFinding(finding), finding.file));
|
|
18030
|
+
if (finding.severity === "error") errors++;
|
|
18031
|
+
else if (finding.severity === "warning") warnings++;
|
|
17936
18032
|
}
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
18033
|
+
io.stdout(
|
|
18034
|
+
[
|
|
18035
|
+
section("Validation"),
|
|
18036
|
+
...formatRows([
|
|
18037
|
+
{ label: "Files", value: files.length },
|
|
18038
|
+
{ label: "Errors", value: errors, tone: errors > 0 ? "error" : "success" },
|
|
18039
|
+
{ label: "Warnings", value: warnings, tone: warnings > 0 ? "warning" : "success" }
|
|
18040
|
+
])
|
|
18041
|
+
].join("\n")
|
|
18042
|
+
);
|
|
17945
18043
|
if (errors > 0) return 1;
|
|
17946
18044
|
if (warnings > 0 && values["strict-warnings"]) return 1;
|
|
17947
18045
|
return 0;
|
|
17948
18046
|
}
|
|
18047
|
+
function diagnosticFromFinding(finding) {
|
|
18048
|
+
const line = finding.line ?? 1;
|
|
18049
|
+
const column = finding.column ?? 1;
|
|
18050
|
+
return {
|
|
18051
|
+
code: finding.code,
|
|
18052
|
+
severity: finding.severity,
|
|
18053
|
+
message: finding.message,
|
|
18054
|
+
...finding.hint ? { hint: finding.hint } : {},
|
|
18055
|
+
position: {
|
|
18056
|
+
start: { line, column, offset: 0 },
|
|
18057
|
+
end: { line, column, offset: 0 }
|
|
18058
|
+
}
|
|
18059
|
+
};
|
|
18060
|
+
}
|
|
17949
18061
|
var init_validate2 = __esm({
|
|
17950
18062
|
"src/commands/validate.ts"() {
|
|
17951
18063
|
"use strict";
|
|
17952
|
-
|
|
18064
|
+
init_cli_format();
|
|
18065
|
+
init_content_project();
|
|
17953
18066
|
init_link_options();
|
|
17954
|
-
init_load_registry();
|
|
17955
18067
|
}
|
|
17956
18068
|
});
|
|
17957
18069
|
|
|
@@ -17960,15 +18072,14 @@ var doctor_exports = {};
|
|
|
17960
18072
|
__export(doctor_exports, {
|
|
17961
18073
|
doctorCommand: () => doctorCommand
|
|
17962
18074
|
});
|
|
17963
|
-
import { readFile as readFile4 } from "node:fs/promises";
|
|
17964
18075
|
import { parseArgs as parseArgs4 } from "node:util";
|
|
17965
|
-
import { glob as glob2 } from "tinyglobby";
|
|
17966
18076
|
async function doctorCommand(args, io) {
|
|
17967
18077
|
const { values, positionals } = parseArgs4({
|
|
17968
18078
|
args,
|
|
17969
18079
|
allowPositionals: true,
|
|
17970
18080
|
options: {
|
|
17971
18081
|
registry: { type: "string" },
|
|
18082
|
+
"no-generic-blocks": { type: "boolean", default: false },
|
|
17972
18083
|
"strict-warnings": { type: "boolean", default: false },
|
|
17973
18084
|
json: { type: "boolean", default: false },
|
|
17974
18085
|
"min-section-words": { type: "string" },
|
|
@@ -17979,91 +18090,37 @@ async function doctorCommand(args, io) {
|
|
|
17979
18090
|
"default-locale": { type: "string" }
|
|
17980
18091
|
}
|
|
17981
18092
|
});
|
|
17982
|
-
if (positionals.length === 0) {
|
|
17983
|
-
io.stderr("doctor: provide at least one file or glob.");
|
|
17984
|
-
return 2;
|
|
17985
|
-
}
|
|
17986
18093
|
const minSectionWords = parseMinSectionWords(values["min-section-words"]);
|
|
17987
18094
|
if (minSectionWords === null) {
|
|
17988
18095
|
io.stderr("doctor: --min-section-words must be a non-negative integer.");
|
|
17989
18096
|
return 2;
|
|
17990
18097
|
}
|
|
17991
|
-
const
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
for (const file2 of files) {
|
|
18001
|
-
const source = await readFile4(file2, "utf8");
|
|
18002
|
-
const frontmatter = extractFrontmatter(source);
|
|
18003
|
-
linkInputs.push({ path: file2, data: frontmatter?.data ?? {} });
|
|
18004
|
-
const validation = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
|
|
18005
|
-
for (const diagnostic of validation.diagnostics) {
|
|
18006
|
-
findings.push(findingFromDiagnostic("validation", file2, diagnostic));
|
|
18007
|
-
}
|
|
18008
|
-
const stats = analyzeDocument(source, { path: file2 });
|
|
18009
|
-
for (const section of stats.outline) {
|
|
18010
|
-
if (section.words < minSectionWords) {
|
|
18011
|
-
findings.push({
|
|
18012
|
-
severity: "info",
|
|
18013
|
-
source: "stats",
|
|
18014
|
-
code: "CB_THIN_SECTION",
|
|
18015
|
-
file: file2,
|
|
18016
|
-
line: section.line,
|
|
18017
|
-
column: 1,
|
|
18018
|
-
message: `section "${section.text}" has ${section.words} words`,
|
|
18019
|
-
hint: `Add detail or merge it with a nearby section. Threshold: ${minSectionWords} words.`
|
|
18020
|
-
});
|
|
18021
|
-
}
|
|
18022
|
-
}
|
|
18023
|
-
if (stats.length.words >= BLOCKLESS_WORDS && stats.blocks.total === 0) {
|
|
18024
|
-
findings.push({
|
|
18025
|
-
severity: "info",
|
|
18026
|
-
source: "stats",
|
|
18027
|
-
code: "CB_BLOCKLESS_DOCUMENT",
|
|
18028
|
-
file: file2,
|
|
18029
|
-
message: `document has ${stats.length.words} words and no structured blocks`,
|
|
18030
|
-
hint: "Consider a callout, steps, comparison, FAQ, or another registered block if it clarifies the page."
|
|
18031
|
-
});
|
|
18032
|
-
}
|
|
18033
|
-
if (stats.images.missingAlt > 0) {
|
|
18034
|
-
findings.push({
|
|
18035
|
-
severity: "info",
|
|
18036
|
-
source: "stats",
|
|
18037
|
-
code: "CB_IMAGE_ALT_MISSING",
|
|
18038
|
-
file: file2,
|
|
18039
|
-
message: `${stats.images.missingAlt} image(s) are missing alt text`,
|
|
18040
|
-
hint: "Add descriptive alt text for meaningful images; use empty alt only for decorative images."
|
|
18041
|
-
});
|
|
18042
|
-
}
|
|
18043
|
-
}
|
|
18044
|
-
let linkGraph;
|
|
18045
|
-
if (hasLinkFrontmatter(linkInputs, linkOptions.slugField)) {
|
|
18046
|
-
for (const { file: file2, diagnostic } of validateLinks(linkInputs, linkOptions)) {
|
|
18047
|
-
findings.push(findingFromDiagnostic("links", file2, diagnostic));
|
|
18048
|
-
}
|
|
18049
|
-
const index = buildLinkIndex(linkInputs, linkOptions);
|
|
18050
|
-
let links = 0;
|
|
18051
|
-
for (const page of index.pages.values()) links += page.linksTo.length;
|
|
18052
|
-
linkGraph = {
|
|
18053
|
-
pages: index.pages.size,
|
|
18054
|
-
links,
|
|
18055
|
-
orphans: [...index.pages.values()].filter((page) => page.linkedFrom.length === 0).length
|
|
18056
|
-
};
|
|
18057
|
-
}
|
|
18058
|
-
findings.sort(compareFindings);
|
|
18098
|
+
const includeGenericBlocks = !values["no-generic-blocks"];
|
|
18099
|
+
const { files, scan } = await loadContentProject({
|
|
18100
|
+
cmd: "doctor",
|
|
18101
|
+
positionals,
|
|
18102
|
+
registry: values.registry,
|
|
18103
|
+
includeGenericBlocks,
|
|
18104
|
+
linkOptions: linkResolverOptions(values),
|
|
18105
|
+
scan: { minSectionWords }
|
|
18106
|
+
});
|
|
18059
18107
|
const report = {
|
|
18060
18108
|
files: files.length,
|
|
18061
|
-
summary:
|
|
18062
|
-
...linkGraph ? { linkGraph } : {},
|
|
18063
|
-
findings
|
|
18109
|
+
summary: scan.summary,
|
|
18110
|
+
...scan.linkGraph ? { linkGraph: scan.linkGraph } : {},
|
|
18111
|
+
findings: scan.findings
|
|
18064
18112
|
};
|
|
18065
18113
|
if (values.json) io.stdout(JSON.stringify(report, null, 2));
|
|
18066
|
-
else
|
|
18114
|
+
else
|
|
18115
|
+
io.stdout(
|
|
18116
|
+
formatReport(
|
|
18117
|
+
report,
|
|
18118
|
+
positionals,
|
|
18119
|
+
values.registry,
|
|
18120
|
+
includeGenericBlocks,
|
|
18121
|
+
hasAliases(scan.linkInputs)
|
|
18122
|
+
)
|
|
18123
|
+
);
|
|
18067
18124
|
if (report.summary.errors > 0) return 1;
|
|
18068
18125
|
if (report.summary.warnings > 0 && values["strict-warnings"]) return 1;
|
|
18069
18126
|
return 0;
|
|
@@ -18073,81 +18130,83 @@ function parseMinSectionWords(value) {
|
|
|
18073
18130
|
if (!/^\d+$/.test(value)) return null;
|
|
18074
18131
|
return Number(value);
|
|
18075
18132
|
}
|
|
18076
|
-
function findingFromDiagnostic(source, file2, diagnostic) {
|
|
18077
|
-
return {
|
|
18078
|
-
severity: diagnostic.severity,
|
|
18079
|
-
source,
|
|
18080
|
-
code: diagnostic.code,
|
|
18081
|
-
file: file2,
|
|
18082
|
-
line: diagnostic.position.start.line,
|
|
18083
|
-
column: diagnostic.position.start.column,
|
|
18084
|
-
message: diagnostic.message,
|
|
18085
|
-
...diagnostic.hint ? { hint: diagnostic.hint } : {}
|
|
18086
|
-
};
|
|
18087
|
-
}
|
|
18088
|
-
function hasLinkFrontmatter(inputs, configuredSlugField) {
|
|
18089
|
-
const slugField = configuredSlugField ?? "slug";
|
|
18090
|
-
return inputs.some((input) => Object.prototype.hasOwnProperty.call(input.data, slugField));
|
|
18091
|
-
}
|
|
18092
18133
|
function hasAliases(inputs) {
|
|
18093
18134
|
return inputs.some((input) => Array.isArray(input.data.aliases) && input.data.aliases.length > 0);
|
|
18094
18135
|
}
|
|
18095
|
-
function
|
|
18096
|
-
return {
|
|
18097
|
-
errors: findings.filter((f) => f.severity === "error").length,
|
|
18098
|
-
warnings: findings.filter((f) => f.severity === "warning").length,
|
|
18099
|
-
suggestions: findings.filter((f) => f.severity === "info").length
|
|
18100
|
-
};
|
|
18101
|
-
}
|
|
18102
|
-
function compareFindings(a, b) {
|
|
18103
|
-
return rank(a) - rank(b) || a.file.localeCompare(b.file) || (a.line ?? 0) - (b.line ?? 0) || (a.column ?? 0) - (b.column ?? 0) || a.code.localeCompare(b.code);
|
|
18104
|
-
}
|
|
18105
|
-
function rank(finding) {
|
|
18106
|
-
if (finding.severity === "error" && finding.source === "validation") return 0;
|
|
18107
|
-
if (finding.severity === "error" && finding.source === "links") return 1;
|
|
18108
|
-
if (finding.severity === "warning") return 2;
|
|
18109
|
-
if (finding.code === "CB_THIN_SECTION") return 3;
|
|
18110
|
-
if (finding.code === "CB_BLOCKLESS_DOCUMENT") return 4;
|
|
18111
|
-
if (finding.code === "CB_IMAGE_ALT_MISSING") return 5;
|
|
18112
|
-
return 6;
|
|
18113
|
-
}
|
|
18114
|
-
function formatReport(report, globs, registryPath, aliasFixMayApply) {
|
|
18136
|
+
function formatReport(report, globs, registryPath, includeGenericBlocks, aliasFixMayApply) {
|
|
18115
18137
|
const lines = [];
|
|
18116
|
-
lines.push("contentbit doctor");
|
|
18138
|
+
lines.push(section("contentbit doctor"));
|
|
18139
|
+
lines.push("");
|
|
18140
|
+
lines.push(section("Health"));
|
|
18117
18141
|
lines.push(
|
|
18118
|
-
|
|
18142
|
+
...formatRows([
|
|
18143
|
+
{ label: "Files", value: report.files },
|
|
18144
|
+
{
|
|
18145
|
+
label: "Errors",
|
|
18146
|
+
value: report.summary.errors,
|
|
18147
|
+
tone: report.summary.errors > 0 ? "error" : "success"
|
|
18148
|
+
},
|
|
18149
|
+
{
|
|
18150
|
+
label: "Warnings",
|
|
18151
|
+
value: report.summary.warnings,
|
|
18152
|
+
tone: report.summary.warnings > 0 ? "warning" : "success"
|
|
18153
|
+
},
|
|
18154
|
+
{
|
|
18155
|
+
label: "Suggestions",
|
|
18156
|
+
value: report.summary.suggestions,
|
|
18157
|
+
tone: report.summary.suggestions > 0 ? "info" : "success"
|
|
18158
|
+
}
|
|
18159
|
+
])
|
|
18119
18160
|
);
|
|
18120
18161
|
if (report.linkGraph) {
|
|
18162
|
+
lines.push("");
|
|
18163
|
+
lines.push(section("Link Graph"));
|
|
18121
18164
|
lines.push(
|
|
18122
|
-
|
|
18165
|
+
...formatRows([
|
|
18166
|
+
{ label: "Pages", value: report.linkGraph.pages },
|
|
18167
|
+
{ label: "Links", value: report.linkGraph.links },
|
|
18168
|
+
{
|
|
18169
|
+
label: "Orphans",
|
|
18170
|
+
value: report.linkGraph.orphans,
|
|
18171
|
+
tone: report.linkGraph.orphans > 0 ? "warning" : "success"
|
|
18172
|
+
}
|
|
18173
|
+
])
|
|
18123
18174
|
);
|
|
18124
18175
|
}
|
|
18125
18176
|
lines.push("");
|
|
18126
18177
|
if (report.findings.length === 0) {
|
|
18127
|
-
lines.push("No findings. Content looks healthy.");
|
|
18178
|
+
lines.push(color("No findings. Content looks healthy.", "success"));
|
|
18128
18179
|
} else {
|
|
18129
|
-
lines.push("Repair
|
|
18180
|
+
lines.push(section("Repair Plan"));
|
|
18130
18181
|
report.findings.forEach((finding, index) => {
|
|
18131
|
-
lines.push(
|
|
18132
|
-
if (finding.hint) lines.push(` hint: ${finding.hint}`);
|
|
18182
|
+
lines.push(...formatFinding(index + 1, finding));
|
|
18133
18183
|
});
|
|
18134
18184
|
}
|
|
18135
18185
|
lines.push("");
|
|
18136
|
-
lines.push("Next
|
|
18137
|
-
|
|
18138
|
-
|
|
18139
|
-
|
|
18186
|
+
lines.push(section("Next Commands"));
|
|
18187
|
+
const commands2 = [
|
|
18188
|
+
`contentbit validate ${formatGlobs(globs)}${formatRegistryArgs(registryPath, includeGenericBlocks)}`
|
|
18189
|
+
];
|
|
18140
18190
|
if (report.linkGraph) {
|
|
18141
|
-
|
|
18191
|
+
commands2.push(`contentbit links ${formatGlobs(globs)}`);
|
|
18142
18192
|
if (aliasFixMayApply && report.summary.errors === 0)
|
|
18143
|
-
|
|
18193
|
+
commands2.push(`contentbit links ${formatGlobs(globs)} --fix`);
|
|
18144
18194
|
}
|
|
18145
|
-
|
|
18195
|
+
commands2.push(
|
|
18196
|
+
`contentbit doctor ${formatGlobs(globs)}${formatRegistryArgs(registryPath, includeGenericBlocks)} --json`
|
|
18197
|
+
);
|
|
18198
|
+
lines.push(...formatCommandList(commands2));
|
|
18146
18199
|
return lines.join("\n");
|
|
18147
18200
|
}
|
|
18148
|
-
function formatFinding(finding) {
|
|
18149
|
-
const location = finding.line !== void 0 && finding.column !== void 0 ? `${finding.file}:${finding.line}:${finding.column}` : finding.file;
|
|
18150
|
-
|
|
18201
|
+
function formatFinding(index, finding) {
|
|
18202
|
+
const location = finding.line !== void 0 && finding.column !== void 0 ? `${displayPath(finding.file)}:${finding.line}:${finding.column}` : displayPath(finding.file);
|
|
18203
|
+
const lines = [
|
|
18204
|
+
` ${index}. ${severityLabel(finding.severity)} ${finding.source} ${finding.code}`,
|
|
18205
|
+
` ${color("at", "muted")} ${location}`,
|
|
18206
|
+
` ${finding.message}`
|
|
18207
|
+
];
|
|
18208
|
+
if (finding.hint) lines.push(` ${color("hint", "muted")} ${finding.hint}`);
|
|
18209
|
+
return lines;
|
|
18151
18210
|
}
|
|
18152
18211
|
function formatGlobs(globs) {
|
|
18153
18212
|
return globs.map(formatArg).join(" ");
|
|
@@ -18155,15 +18214,19 @@ function formatGlobs(globs) {
|
|
|
18155
18214
|
function formatArg(value) {
|
|
18156
18215
|
return /\s/.test(value) ? JSON.stringify(value) : value;
|
|
18157
18216
|
}
|
|
18158
|
-
|
|
18217
|
+
function formatRegistryArgs(registryPath, includeGenericBlocks) {
|
|
18218
|
+
const args = [];
|
|
18219
|
+
if (registryPath) args.push("--registry", formatArg(registryPath));
|
|
18220
|
+
if (!includeGenericBlocks) args.push("--no-generic-blocks");
|
|
18221
|
+
return args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
18222
|
+
}
|
|
18159
18223
|
var init_doctor = __esm({
|
|
18160
18224
|
"src/commands/doctor.ts"() {
|
|
18161
18225
|
"use strict";
|
|
18162
18226
|
init_dist();
|
|
18227
|
+
init_cli_format();
|
|
18228
|
+
init_content_project();
|
|
18163
18229
|
init_link_options();
|
|
18164
|
-
init_load_registry();
|
|
18165
|
-
DEFAULT_MIN_SECTION_WORDS = 25;
|
|
18166
|
-
BLOCKLESS_WORDS = 250;
|
|
18167
18230
|
}
|
|
18168
18231
|
});
|
|
18169
18232
|
|
|
@@ -18173,7 +18236,6 @@ __export(studio_exports, {
|
|
|
18173
18236
|
studioCommand: () => studioCommand
|
|
18174
18237
|
});
|
|
18175
18238
|
import { parseArgs as parseArgs5 } from "node:util";
|
|
18176
|
-
import { glob as glob3 } from "tinyglobby";
|
|
18177
18239
|
async function studioCommand(args, io) {
|
|
18178
18240
|
const { values, positionals } = parseArgs5({
|
|
18179
18241
|
args,
|
|
@@ -18183,6 +18245,7 @@ async function studioCommand(args, io) {
|
|
|
18183
18245
|
port: { type: "string" },
|
|
18184
18246
|
host: { type: "string" },
|
|
18185
18247
|
"no-open": { type: "boolean", default: false },
|
|
18248
|
+
"no-generic-blocks": { type: "boolean", default: false },
|
|
18186
18249
|
"min-section-words": { type: "string" },
|
|
18187
18250
|
"link-resolve": { type: "string" },
|
|
18188
18251
|
"locale-field": { type: "string" },
|
|
@@ -18191,10 +18254,6 @@ async function studioCommand(args, io) {
|
|
|
18191
18254
|
"default-locale": { type: "string" }
|
|
18192
18255
|
}
|
|
18193
18256
|
});
|
|
18194
|
-
if (positionals.length === 0) {
|
|
18195
|
-
io.stderr("studio: provide at least one file or glob.");
|
|
18196
|
-
return 2;
|
|
18197
|
-
}
|
|
18198
18257
|
const port = parsePort(values.port);
|
|
18199
18258
|
if (port === null) {
|
|
18200
18259
|
io.stderr("studio: --port must be an integer between 0 and 65535.");
|
|
@@ -18205,23 +18264,27 @@ async function studioCommand(args, io) {
|
|
|
18205
18264
|
io.stderr("studio: --min-section-words must be a non-negative integer.");
|
|
18206
18265
|
return 2;
|
|
18207
18266
|
}
|
|
18208
|
-
|
|
18209
|
-
if (files.length === 0) {
|
|
18210
|
-
io.stderr(`studio: no files matched ${positionals.join(" ")}`);
|
|
18211
|
-
return 2;
|
|
18212
|
-
}
|
|
18267
|
+
await resolveContentFiles(positionals, "studio");
|
|
18213
18268
|
const { startStudio } = await import("@contentbit/studio");
|
|
18214
18269
|
const server = await startStudio({
|
|
18215
18270
|
globs: positionals,
|
|
18216
18271
|
registryPath: values.registry,
|
|
18272
|
+
includeGenericBlocks: !values["no-generic-blocks"],
|
|
18217
18273
|
host: values.host,
|
|
18218
18274
|
...port !== void 0 ? { port } : {},
|
|
18219
18275
|
open: !values["no-open"],
|
|
18220
18276
|
linkOptions: linkResolverOptions(values),
|
|
18221
18277
|
minSectionWords
|
|
18222
18278
|
});
|
|
18223
|
-
io.stdout(
|
|
18224
|
-
|
|
18279
|
+
io.stdout(
|
|
18280
|
+
[
|
|
18281
|
+
section("contentbit studio"),
|
|
18282
|
+
...formatRows([
|
|
18283
|
+
{ label: "URL", value: server.url, tone: "info" },
|
|
18284
|
+
{ label: "Stop", value: "Ctrl+C" }
|
|
18285
|
+
])
|
|
18286
|
+
].join("\n")
|
|
18287
|
+
);
|
|
18225
18288
|
const close = () => {
|
|
18226
18289
|
void server.close();
|
|
18227
18290
|
};
|
|
@@ -18246,6 +18309,8 @@ function parseMinSectionWords2(value) {
|
|
|
18246
18309
|
var init_studio = __esm({
|
|
18247
18310
|
"src/commands/studio.ts"() {
|
|
18248
18311
|
"use strict";
|
|
18312
|
+
init_cli_format();
|
|
18313
|
+
init_content_project();
|
|
18249
18314
|
init_link_options();
|
|
18250
18315
|
}
|
|
18251
18316
|
});
|
|
@@ -18255,187 +18320,51 @@ var stats_exports = {};
|
|
|
18255
18320
|
__export(stats_exports, {
|
|
18256
18321
|
statsCommand: () => statsCommand
|
|
18257
18322
|
});
|
|
18258
|
-
import { readFile as
|
|
18323
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
18259
18324
|
import { parseArgs as parseArgs6 } from "node:util";
|
|
18260
|
-
import { glob as glob4 } from "tinyglobby";
|
|
18261
|
-
async function fileStats(file2, registry2) {
|
|
18262
|
-
const source = await readFile5(file2, "utf8");
|
|
18263
|
-
const stats = analyzeDocument(source, { path: file2 });
|
|
18264
|
-
if (registry2) {
|
|
18265
|
-
const result = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
|
|
18266
|
-
let errors = 0;
|
|
18267
|
-
let warnings = 0;
|
|
18268
|
-
for (const d of result.diagnostics) {
|
|
18269
|
-
if (d.severity === "error") errors++;
|
|
18270
|
-
else if (d.severity === "warning") warnings++;
|
|
18271
|
-
}
|
|
18272
|
-
stats.validation = { errors, warnings };
|
|
18273
|
-
}
|
|
18274
|
-
return stats;
|
|
18275
|
-
}
|
|
18276
18325
|
async function statsCommand(args, io) {
|
|
18277
18326
|
const { values, positionals } = parseArgs6({
|
|
18278
18327
|
args,
|
|
18279
18328
|
allowPositionals: true,
|
|
18280
18329
|
options: {
|
|
18281
18330
|
registry: { type: "string" },
|
|
18331
|
+
"no-generic-blocks": { type: "boolean", default: false },
|
|
18282
18332
|
"no-validate": { type: "boolean", default: false }
|
|
18283
18333
|
}
|
|
18284
18334
|
});
|
|
18285
|
-
|
|
18286
|
-
io.stderr("stats: provide at least one file or glob.");
|
|
18287
|
-
return 2;
|
|
18288
|
-
}
|
|
18289
|
-
const files = await glob4(positionals, { absolute: true });
|
|
18290
|
-
if (files.length === 0) {
|
|
18291
|
-
io.stderr(`stats: no files matched ${positionals.join(" ")}`);
|
|
18292
|
-
return 2;
|
|
18293
|
-
}
|
|
18294
|
-
const registry2 = values["no-validate"] ? null : await loadRegistry(values.registry);
|
|
18295
|
-
const all = [];
|
|
18296
|
-
for (const file2 of files.sort()) {
|
|
18297
|
-
all.push(await fileStats(file2, registry2));
|
|
18298
|
-
}
|
|
18335
|
+
const all = values["no-validate"] ? await statsOnly(positionals) : await statsWithValidation(values, positionals);
|
|
18299
18336
|
io.stdout(JSON.stringify(all.length === 1 ? all[0] : all, null, 2));
|
|
18300
18337
|
return 0;
|
|
18301
18338
|
}
|
|
18302
|
-
|
|
18303
|
-
|
|
18304
|
-
|
|
18305
|
-
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
}
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
"use strict";
|
|
18317
|
-
}
|
|
18318
|
-
});
|
|
18319
|
-
|
|
18320
|
-
// ../html/dist/blocks.js
|
|
18321
|
-
var callout, steps, keyMetrics, quickRef, comparison, prosCons, tabs, faq, genericHtmlRenderers;
|
|
18322
|
-
var init_blocks = __esm({
|
|
18323
|
-
"../html/dist/blocks.js"() {
|
|
18324
|
-
"use strict";
|
|
18325
|
-
init_dist2();
|
|
18326
|
-
init_dist();
|
|
18327
|
-
callout = (node, ctx) => {
|
|
18328
|
-
const data = node.data;
|
|
18329
|
-
const type = ctx.escape(String(node.props.type ?? "note"));
|
|
18330
|
-
const title = node.props.title;
|
|
18331
|
-
const titleHtml = title ? `<div class="${ctx.cls("callout-title")}">${ctx.escape(title)}</div>` : "";
|
|
18332
|
-
return `<aside class="${ctx.cls("callout")} ${ctx.cls(`callout-${type}`)}">${titleHtml}${ctx.renderMarkdown(data.markdown)}</aside>`;
|
|
18333
|
-
};
|
|
18334
|
-
steps = (node, ctx) => {
|
|
18335
|
-
const data = node.data;
|
|
18336
|
-
const items = data.items.map((i) => `<li>${ctx.escape(i.text)}</li>`).join("");
|
|
18337
|
-
return `<ol class="${ctx.cls("steps")}">${items}</ol>`;
|
|
18338
|
-
};
|
|
18339
|
-
keyMetrics = (node, ctx) => {
|
|
18340
|
-
const data = node.data;
|
|
18341
|
-
const items = data.rows.map((r) => `<div class="${ctx.cls("key-metrics-item")}"><span class="${ctx.cls("key-metrics-value")}">${ctx.escape(r.value)}</span><span class="${ctx.cls("key-metrics-label")}">${ctx.escape(r.label)}</span></div>`).join("");
|
|
18342
|
-
return `<div class="${ctx.cls("key-metrics")}">${items}</div>`;
|
|
18343
|
-
};
|
|
18344
|
-
quickRef = (node, ctx) => {
|
|
18345
|
-
const data = node.data;
|
|
18346
|
-
const rows = data.rows.map((r) => `<div class="${ctx.cls("quick-ref-row")}"><dt>${ctx.escape(r.key)}</dt><dd>${ctx.escape(r.value)}</dd></div>`).join("");
|
|
18347
|
-
return `<dl class="${ctx.cls("quick-ref")}">${rows}</dl>`;
|
|
18348
|
-
};
|
|
18349
|
-
comparison = (node, ctx) => {
|
|
18350
|
-
const data = node.data;
|
|
18351
|
-
const head = `<thead><tr><th scope="col"></th><th scope="col">${ctx.escape(String(node.props.left))}</th><th scope="col">${ctx.escape(String(node.props.right))}</th></tr></thead>`;
|
|
18352
|
-
const rows = data.rows.map((r) => `<tr><th scope="row">${ctx.escape(r.label)}</th><td>${ctx.escape(r.left)}</td><td>${ctx.escape(r.right)}</td></tr>`).join("");
|
|
18353
|
-
return `<table class="${ctx.cls("comparison")}">${head}<tbody>${rows}</tbody></table>`;
|
|
18354
|
-
};
|
|
18355
|
-
prosCons = (node, ctx) => {
|
|
18356
|
-
const { pros, cons } = splitProsCons(node.data);
|
|
18357
|
-
const list = (cls, title, items) => `<div class="${ctx.cls(cls)}"><div class="${ctx.cls("pros-cons-heading")}">${title}</div><ul>${items.map((i) => `<li>${ctx.escape(i)}</li>`).join("")}</ul></div>`;
|
|
18358
|
-
return `<div class="${ctx.cls("pros-cons")}">${list("pros-cons-pros", "Pros", pros)}${list("pros-cons-cons", "Cons", cons)}</div>`;
|
|
18359
|
-
};
|
|
18360
|
-
tabs = (node, ctx) => {
|
|
18361
|
-
const data = node.data;
|
|
18362
|
-
const sections = data.blocks.map((tab) => {
|
|
18363
|
-
const body = isValidatedBlock(tab) ? tab.data.markdown : tab.body;
|
|
18364
|
-
return `<section class="${ctx.cls("tab")}"><h3 class="${ctx.cls("tab-title")}">${ctx.escape(String(tab.props.title))}</h3>${ctx.renderMarkdown(body)}</section>`;
|
|
18365
|
-
}).join("");
|
|
18366
|
-
return `<div class="${ctx.cls("tabs")}">${sections}</div>`;
|
|
18367
|
-
};
|
|
18368
|
-
faq = (node, ctx) => {
|
|
18369
|
-
const data = node.data;
|
|
18370
|
-
const items = data.blocks.map((item) => {
|
|
18371
|
-
const body = isValidatedBlock(item) ? item.data.markdown : item.body;
|
|
18372
|
-
return `<details class="${ctx.cls("faq-item")}"><summary>${ctx.escape(String(item.props.question))}</summary>${ctx.renderMarkdown(body)}</details>`;
|
|
18373
|
-
}).join("");
|
|
18374
|
-
return `<div class="${ctx.cls("faq")}">${items}</div>`;
|
|
18375
|
-
};
|
|
18376
|
-
genericHtmlRenderers = {
|
|
18377
|
-
callout,
|
|
18378
|
-
steps,
|
|
18379
|
-
"key-metrics": keyMetrics,
|
|
18380
|
-
"quick-ref": quickRef,
|
|
18381
|
-
comparison,
|
|
18382
|
-
"pros-cons": prosCons,
|
|
18383
|
-
tabs,
|
|
18384
|
-
faq
|
|
18385
|
-
};
|
|
18386
|
-
}
|
|
18387
|
-
});
|
|
18388
|
-
|
|
18389
|
-
// ../html/dist/render.js
|
|
18390
|
-
function fallbackMarkdown(md) {
|
|
18391
|
-
return md.trim().split(/\n{2,}/).map((p) => `<p>${escapeHtml(p)}</p>`).join("\n");
|
|
18392
|
-
}
|
|
18393
|
-
function invalidBlockHtml(node, prefix) {
|
|
18394
|
-
return `<div class="${prefix}invalid" data-cb-invalid="${escapeHtml(node.name)}"><pre>${escapeHtml(node.body)}</pre></div>`;
|
|
18395
|
-
}
|
|
18396
|
-
function unrenderableBlockError(name) {
|
|
18397
|
-
return new Error(`Cannot render block "${name}": not validated or no renderer registered.`);
|
|
18398
|
-
}
|
|
18399
|
-
function renderToHtml(document, opts = {}) {
|
|
18400
|
-
const prefix = opts.classPrefix ?? "cb-";
|
|
18401
|
-
const renderMarkdown = opts.renderMarkdown ?? fallbackMarkdown;
|
|
18402
|
-
const renderers = { ...genericHtmlRenderers, ...opts.renderers };
|
|
18403
|
-
const onInvalid = opts.onInvalid ?? "fallback";
|
|
18404
|
-
const ctx = {
|
|
18405
|
-
cls: (name) => `${prefix}${name}`,
|
|
18406
|
-
escape: escapeHtml,
|
|
18407
|
-
renderMarkdown,
|
|
18408
|
-
renderNodes(nodes) {
|
|
18409
|
-
return nodes.map((node) => {
|
|
18410
|
-
if (node.type === "markdown")
|
|
18411
|
-
return renderMarkdown(node.value);
|
|
18412
|
-
const renderer = renderers[node.name];
|
|
18413
|
-
if (renderer && isValidatedBlock(node))
|
|
18414
|
-
return renderer(node, ctx);
|
|
18415
|
-
if (onInvalid === "strict")
|
|
18416
|
-
throw unrenderableBlockError(node.name);
|
|
18417
|
-
if (onInvalid === "annotated")
|
|
18418
|
-
return invalidBlockHtml(node, prefix);
|
|
18419
|
-
return fallbackMarkdown(node.body);
|
|
18420
|
-
}).join("\n");
|
|
18339
|
+
async function statsWithValidation(values, positionals) {
|
|
18340
|
+
const { scan } = await loadContentProject({
|
|
18341
|
+
cmd: "stats",
|
|
18342
|
+
positionals,
|
|
18343
|
+
registry: values.registry,
|
|
18344
|
+
includeGenericBlocks: !values["no-generic-blocks"],
|
|
18345
|
+
linkOptions: {}
|
|
18346
|
+
});
|
|
18347
|
+
return scan.files.map((file2) => {
|
|
18348
|
+
let errors = 0;
|
|
18349
|
+
let warnings = 0;
|
|
18350
|
+
for (const d of file2.validation.diagnostics) {
|
|
18351
|
+
if (d.severity === "error") errors++;
|
|
18352
|
+
else if (d.severity === "warning") warnings++;
|
|
18421
18353
|
}
|
|
18422
|
-
|
|
18423
|
-
|
|
18354
|
+
return { ...file2.stats, validation: { errors, warnings } };
|
|
18355
|
+
});
|
|
18424
18356
|
}
|
|
18425
|
-
|
|
18426
|
-
"
|
|
18357
|
+
async function statsOnly(positionals) {
|
|
18358
|
+
const files = await resolveContentFiles(positionals, "stats");
|
|
18359
|
+
return Promise.all(
|
|
18360
|
+
files.map(async (file2) => analyzeDocument(await readFile4(file2, "utf8"), { path: file2 }))
|
|
18361
|
+
);
|
|
18362
|
+
}
|
|
18363
|
+
var init_stats = __esm({
|
|
18364
|
+
"src/commands/stats.ts"() {
|
|
18427
18365
|
"use strict";
|
|
18428
18366
|
init_dist();
|
|
18429
|
-
|
|
18430
|
-
init_escape();
|
|
18431
|
-
}
|
|
18432
|
-
});
|
|
18433
|
-
|
|
18434
|
-
// ../html/dist/index.js
|
|
18435
|
-
var init_dist3 = __esm({
|
|
18436
|
-
"../html/dist/index.js"() {
|
|
18437
|
-
"use strict";
|
|
18438
|
-
init_render();
|
|
18367
|
+
init_content_project();
|
|
18439
18368
|
}
|
|
18440
18369
|
});
|
|
18441
18370
|
|
|
@@ -18444,42 +18373,56 @@ var render_exports = {};
|
|
|
18444
18373
|
__export(render_exports, {
|
|
18445
18374
|
renderCommand: () => renderCommand
|
|
18446
18375
|
});
|
|
18447
|
-
import { readFile as
|
|
18376
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
18448
18377
|
import { parseArgs as parseArgs7 } from "node:util";
|
|
18449
18378
|
async function renderCommand(args, io) {
|
|
18450
18379
|
const { values, positionals } = parseArgs7({
|
|
18451
18380
|
args,
|
|
18452
18381
|
allowPositionals: true,
|
|
18453
18382
|
options: {
|
|
18454
|
-
target: { type: "string", default: "
|
|
18383
|
+
target: { type: "string", default: "markdown" },
|
|
18455
18384
|
registry: { type: "string" },
|
|
18385
|
+
"no-generic-blocks": { type: "boolean", default: false },
|
|
18456
18386
|
out: { type: "string" }
|
|
18457
18387
|
}
|
|
18458
18388
|
});
|
|
18459
18389
|
const file2 = positionals[0];
|
|
18460
|
-
if (!file2 || values.target !== "
|
|
18461
|
-
io.stderr(
|
|
18390
|
+
if (!file2 || values.target !== "markdown") {
|
|
18391
|
+
io.stderr(
|
|
18392
|
+
"render: usage: render <file> [--target markdown] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]"
|
|
18393
|
+
);
|
|
18462
18394
|
return 2;
|
|
18463
18395
|
}
|
|
18464
|
-
const
|
|
18465
|
-
const
|
|
18396
|
+
const includeGenericBlocks = !values["no-generic-blocks"];
|
|
18397
|
+
const registry2 = await loadRegistry(values.registry, { includeGenericBlocks });
|
|
18398
|
+
const source = await readFile5(file2, "utf8");
|
|
18466
18399
|
const result = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
|
|
18467
18400
|
if (!result.ok) {
|
|
18468
|
-
for (const d of result.diagnostics) io.stderr(
|
|
18401
|
+
for (const d of result.diagnostics) io.stderr(formatDiagnosticForCli(d, file2));
|
|
18469
18402
|
return 1;
|
|
18470
18403
|
}
|
|
18471
|
-
const output =
|
|
18404
|
+
const output = renderToMarkdown(result.document, {
|
|
18405
|
+
renderers: includeGenericBlocks ? genericMarkdownRenderers : genericMarkdownFallbackRenderers
|
|
18406
|
+
});
|
|
18472
18407
|
if (values.out) await io.writeFile(values.out, output);
|
|
18473
18408
|
else io.stdout(output);
|
|
18474
18409
|
return 0;
|
|
18475
18410
|
}
|
|
18476
|
-
var
|
|
18411
|
+
var genericMarkdownFallbackRenderers;
|
|
18412
|
+
var init_render = __esm({
|
|
18477
18413
|
"src/commands/render.ts"() {
|
|
18478
18414
|
"use strict";
|
|
18479
18415
|
init_dist2();
|
|
18480
18416
|
init_dist();
|
|
18481
|
-
|
|
18417
|
+
init_cli_format();
|
|
18482
18418
|
init_load_registry();
|
|
18419
|
+
genericMarkdownFallbackRenderers = Object.fromEntries(
|
|
18420
|
+
Object.keys(genericMarkdownRenderers).map((name) => [
|
|
18421
|
+
name,
|
|
18422
|
+
((node) => `${node.body}
|
|
18423
|
+
`)
|
|
18424
|
+
])
|
|
18425
|
+
);
|
|
18483
18426
|
}
|
|
18484
18427
|
});
|
|
18485
18428
|
|
|
@@ -18496,10 +18439,13 @@ async function instructionsCommand(args, io) {
|
|
|
18496
18439
|
audience: { type: "string", default: "llm" },
|
|
18497
18440
|
"no-examples": { type: "boolean", default: false },
|
|
18498
18441
|
registry: { type: "string" },
|
|
18442
|
+
"no-generic-blocks": { type: "boolean", default: false },
|
|
18499
18443
|
out: { type: "string" }
|
|
18500
18444
|
}
|
|
18501
18445
|
});
|
|
18502
|
-
const registry2 = await loadRegistry(values.registry
|
|
18446
|
+
const registry2 = await loadRegistry(values.registry, {
|
|
18447
|
+
includeGenericBlocks: !values["no-generic-blocks"]
|
|
18448
|
+
});
|
|
18503
18449
|
const guide = registry2.toAuthoringGuide({
|
|
18504
18450
|
audience: values.audience === "human" ? "human" : "llm",
|
|
18505
18451
|
includeExamples: !values["no-examples"]
|
|
@@ -18526,10 +18472,13 @@ async function docsCommand(args, io) {
|
|
|
18526
18472
|
args,
|
|
18527
18473
|
options: {
|
|
18528
18474
|
registry: { type: "string" },
|
|
18475
|
+
"no-generic-blocks": { type: "boolean", default: false },
|
|
18529
18476
|
out: { type: "string" }
|
|
18530
18477
|
}
|
|
18531
18478
|
});
|
|
18532
|
-
const registry2 = await loadRegistry(values.registry
|
|
18479
|
+
const registry2 = await loadRegistry(values.registry, {
|
|
18480
|
+
includeGenericBlocks: !values["no-generic-blocks"]
|
|
18481
|
+
});
|
|
18533
18482
|
const guide = registry2.toAuthoringGuide({ audience: "human", includeExamples: true });
|
|
18534
18483
|
if (values.out) await io.writeFile(values.out, guide);
|
|
18535
18484
|
else io.stdout(guide);
|
|
@@ -18543,11 +18492,11 @@ var init_docs = __esm({
|
|
|
18543
18492
|
});
|
|
18544
18493
|
|
|
18545
18494
|
// src/links-io.ts
|
|
18546
|
-
import { readFile as
|
|
18495
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
18547
18496
|
async function collectLinkInputs(files) {
|
|
18548
18497
|
const inputs = [];
|
|
18549
18498
|
for (const path of files) {
|
|
18550
|
-
const source = await
|
|
18499
|
+
const source = await readFile6(path, "utf8");
|
|
18551
18500
|
const fm = extractFrontmatter(source);
|
|
18552
18501
|
inputs.push({ path, data: fm?.data ?? {} });
|
|
18553
18502
|
}
|
|
@@ -18565,10 +18514,9 @@ var links_exports = {};
|
|
|
18565
18514
|
__export(links_exports, {
|
|
18566
18515
|
linksCommand: () => linksCommand
|
|
18567
18516
|
});
|
|
18568
|
-
import { mkdir as mkdir3, readFile as
|
|
18569
|
-
import { dirname, join as
|
|
18517
|
+
import { mkdir as mkdir3, readFile as readFile7 } from "node:fs/promises";
|
|
18518
|
+
import { dirname, join as join4 } from "node:path";
|
|
18570
18519
|
import { parseArgs as parseArgs10 } from "node:util";
|
|
18571
|
-
import { glob as glob5 } from "tinyglobby";
|
|
18572
18520
|
async function linksCommand(args, io) {
|
|
18573
18521
|
const { values, positionals } = parseArgs10({
|
|
18574
18522
|
args,
|
|
@@ -18583,21 +18531,13 @@ async function linksCommand(args, io) {
|
|
|
18583
18531
|
"default-locale": { type: "string" }
|
|
18584
18532
|
}
|
|
18585
18533
|
});
|
|
18586
|
-
|
|
18587
|
-
io.stderr("links: provide at least one file or glob.");
|
|
18588
|
-
return 2;
|
|
18589
|
-
}
|
|
18590
|
-
const files = (await glob5(positionals, { absolute: true })).sort();
|
|
18591
|
-
if (files.length === 0) {
|
|
18592
|
-
io.stderr(`links: no files matched ${positionals.join(" ")}`);
|
|
18593
|
-
return 2;
|
|
18594
|
-
}
|
|
18534
|
+
const files = await resolveContentFiles(positionals, "links");
|
|
18595
18535
|
const inputs = await collectLinkInputs(files);
|
|
18596
18536
|
const linkOptions = linkResolverOptions(values);
|
|
18597
18537
|
let errors = 0;
|
|
18598
18538
|
let warnings = 0;
|
|
18599
18539
|
for (const { file: file2, diagnostic } of validateLinks(inputs, linkOptions)) {
|
|
18600
|
-
io.stderr(
|
|
18540
|
+
io.stderr(formatDiagnosticForCli(diagnostic, file2));
|
|
18601
18541
|
if (diagnostic.severity === "error") errors++;
|
|
18602
18542
|
else if (diagnostic.severity === "warning") warnings++;
|
|
18603
18543
|
}
|
|
@@ -18606,7 +18546,7 @@ async function linksCommand(args, io) {
|
|
|
18606
18546
|
io.stderr("links: --fix skipped because link errors must be resolved first.");
|
|
18607
18547
|
} else if (values.fix && index.aliases.size > 0) {
|
|
18608
18548
|
for (const file2 of files) {
|
|
18609
|
-
const source = await
|
|
18549
|
+
const source = await readFile7(file2, "utf8");
|
|
18610
18550
|
const fm = extractFrontmatter(source);
|
|
18611
18551
|
if (!fm) continue;
|
|
18612
18552
|
const lines = source.split("\n");
|
|
@@ -18633,16 +18573,27 @@ async function linksCommand(args, io) {
|
|
|
18633
18573
|
}
|
|
18634
18574
|
}
|
|
18635
18575
|
}
|
|
18636
|
-
const outPath = values.out ??
|
|
18576
|
+
const outPath = values.out ?? join4(process.cwd(), ".contentbit", "link-index.json");
|
|
18637
18577
|
await mkdir3(dirname(outPath), { recursive: true });
|
|
18638
18578
|
await io.writeFile(outPath, JSON.stringify(serializeLinkIndex(index), null, 2) + "\n");
|
|
18639
18579
|
let edges = 0;
|
|
18640
18580
|
for (const p of index.pages.values()) edges += p.linksTo.length;
|
|
18641
18581
|
const orphans = [...index.pages.values()].filter((p) => p.linkedFrom.length === 0).length;
|
|
18642
18582
|
io.stdout(
|
|
18643
|
-
|
|
18583
|
+
[
|
|
18584
|
+
section("Link Index"),
|
|
18585
|
+
...formatRows([
|
|
18586
|
+
{ label: "Pages", value: index.pages.size },
|
|
18587
|
+
{ label: "Links", value: edges },
|
|
18588
|
+
{ label: "Orphans", value: orphans, tone: orphans > 0 ? "warning" : "success" },
|
|
18589
|
+
{ label: "Errors", value: errors, tone: errors > 0 ? "error" : "success" },
|
|
18590
|
+
{ label: "Warnings", value: warnings, tone: warnings > 0 ? "warning" : "success" }
|
|
18591
|
+
]),
|
|
18592
|
+
"",
|
|
18593
|
+
section("Written"),
|
|
18594
|
+
` ${outPath}`
|
|
18595
|
+
].join("\n")
|
|
18644
18596
|
);
|
|
18645
|
-
io.stdout(`index written to ${outPath}`);
|
|
18646
18597
|
return errors > 0 ? 1 : 0;
|
|
18647
18598
|
}
|
|
18648
18599
|
function escapeRe(s) {
|
|
@@ -18652,37 +18603,14 @@ var init_links2 = __esm({
|
|
|
18652
18603
|
"src/commands/links.ts"() {
|
|
18653
18604
|
"use strict";
|
|
18654
18605
|
init_dist();
|
|
18606
|
+
init_cli_format();
|
|
18607
|
+
init_content_project();
|
|
18655
18608
|
init_link_options();
|
|
18656
18609
|
init_links_io();
|
|
18657
18610
|
}
|
|
18658
18611
|
});
|
|
18659
18612
|
|
|
18660
18613
|
// src/run.ts
|
|
18661
|
-
var USAGE = `Usage: contentbit <init|validate|doctor|studio|stats|render|instructions|docs|agents|links> [options]
|
|
18662
|
-
|
|
18663
|
-
init [-t react|html|markdown|astro] [--md ...] [-y] [--no-install] [--no-page] [--no-agents]
|
|
18664
|
-
agents [--claude] [--no-agents-md]
|
|
18665
|
-
|
|
18666
|
-
validate <globs...> [--registry <module.ts>] [--strict-warnings] [--link-resolve <mode>]
|
|
18667
|
-
doctor <globs...> [--registry <module.ts>] [--strict-warnings] [--json] [--min-section-words <n>] [--link-resolve <mode>]
|
|
18668
|
-
studio <globs...> [--registry <module.ts>] [--port <n>] [--host <host>] [--no-open] [--link-resolve <mode>]
|
|
18669
|
-
stats <globs...> [--registry <module.ts>] [--no-validate]
|
|
18670
|
-
render <file> --target html|markdown [--registry <module.ts>] [--out <file>]
|
|
18671
|
-
instructions [--audience llm|human] [--no-examples] [--registry <module.ts>] [--out <file>]
|
|
18672
|
-
docs [--registry <module.ts>] [--out <file>]
|
|
18673
|
-
links <globs...> [--fix] [--out <file>] [--link-resolve <mode>]`;
|
|
18674
|
-
var commands = {
|
|
18675
|
-
init: async () => (await Promise.resolve().then(() => (init_init(), init_exports))).initCommand,
|
|
18676
|
-
validate: async () => (await Promise.resolve().then(() => (init_validate2(), validate_exports))).validateCommand,
|
|
18677
|
-
doctor: async () => (await Promise.resolve().then(() => (init_doctor(), doctor_exports))).doctorCommand,
|
|
18678
|
-
studio: async () => (await Promise.resolve().then(() => (init_studio(), studio_exports))).studioCommand,
|
|
18679
|
-
stats: async () => (await Promise.resolve().then(() => (init_stats(), stats_exports))).statsCommand,
|
|
18680
|
-
render: async () => (await Promise.resolve().then(() => (init_render2(), render_exports))).renderCommand,
|
|
18681
|
-
instructions: async () => (await Promise.resolve().then(() => (init_instructions(), instructions_exports))).instructionsCommand,
|
|
18682
|
-
docs: async () => (await Promise.resolve().then(() => (init_docs(), docs_exports))).docsCommand,
|
|
18683
|
-
agents: async () => (await Promise.resolve().then(() => (init_agents(), agents_exports))).agentsCommand,
|
|
18684
|
-
links: async () => (await Promise.resolve().then(() => (init_links2(), links_exports))).linksCommand
|
|
18685
|
-
};
|
|
18686
18614
|
async function run(argv, io) {
|
|
18687
18615
|
const [name, ...rest] = argv;
|
|
18688
18616
|
const loader = name ? commands[name] : void 0;
|
|
@@ -18694,11 +18622,78 @@ async function run(argv, io) {
|
|
|
18694
18622
|
const command = await loader();
|
|
18695
18623
|
return await command(rest, io);
|
|
18696
18624
|
} catch (err) {
|
|
18697
|
-
|
|
18625
|
+
if (err instanceof CliError) {
|
|
18626
|
+
io.stderr(err.message);
|
|
18627
|
+
return err.exitCode;
|
|
18628
|
+
}
|
|
18629
|
+
io.stderr(
|
|
18630
|
+
[
|
|
18631
|
+
section(`contentbit ${name}`),
|
|
18632
|
+
` ${color("error", "error")} ${err instanceof Error ? err.message : String(err)}`
|
|
18633
|
+
].join("\n")
|
|
18634
|
+
);
|
|
18698
18635
|
return 1;
|
|
18699
18636
|
}
|
|
18700
18637
|
}
|
|
18638
|
+
var CliError, USAGE, commands;
|
|
18639
|
+
var init_run = __esm({
|
|
18640
|
+
"src/run.ts"() {
|
|
18641
|
+
init_cli_format();
|
|
18642
|
+
CliError = class extends Error {
|
|
18643
|
+
constructor(exitCode, message) {
|
|
18644
|
+
super(message);
|
|
18645
|
+
this.exitCode = exitCode;
|
|
18646
|
+
this.name = "CliError";
|
|
18647
|
+
}
|
|
18648
|
+
exitCode;
|
|
18649
|
+
};
|
|
18650
|
+
USAGE = `contentbit
|
|
18651
|
+
|
|
18652
|
+
Usage:
|
|
18653
|
+
contentbit <command> [options]
|
|
18654
|
+
|
|
18655
|
+
Commands:
|
|
18656
|
+
init scaffold Content Blocks into a project
|
|
18657
|
+
validate check Markdown blocks and internal links
|
|
18658
|
+
doctor inspect content health and repair suggestions
|
|
18659
|
+
studio browse content locally
|
|
18660
|
+
stats print document stats as JSON
|
|
18661
|
+
render render one file to plain Markdown
|
|
18662
|
+
instructions print LLM authoring instructions
|
|
18663
|
+
docs print human authoring docs
|
|
18664
|
+
agents install coding-agent guidance
|
|
18665
|
+
links build or fix the internal link index
|
|
18666
|
+
|
|
18667
|
+
Setup:
|
|
18668
|
+
init [-t react|markdown|astro] [--md ...] [-y] [--no-install] [--no-page] [--no-agents]
|
|
18669
|
+
agents [--claude] [--no-agents-md]
|
|
18670
|
+
|
|
18671
|
+
Common:
|
|
18672
|
+
validate <globs...> [--registry <module.ts>] [--no-generic-blocks] [--strict-warnings] [--link-resolve <mode>]
|
|
18673
|
+
doctor <globs...> [--registry <module.ts>] [--no-generic-blocks] [--strict-warnings] [--json] [--min-section-words <n>] [--link-resolve <mode>]
|
|
18674
|
+
studio <globs...> [--registry <module.ts>] [--port <n>] [--host <host>] [--no-open] [--no-generic-blocks] [--link-resolve <mode>]
|
|
18675
|
+
stats <globs...> [--registry <module.ts>] [--no-generic-blocks] [--no-validate]
|
|
18676
|
+
render <file> [--target markdown] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]
|
|
18677
|
+
instructions [--audience llm|human] [--no-examples] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]
|
|
18678
|
+
docs [--registry <module.ts>] [--no-generic-blocks] [--out <file>]
|
|
18679
|
+
links <globs...> [--fix] [--out <file>] [--link-resolve <mode>]`;
|
|
18680
|
+
commands = {
|
|
18681
|
+
init: async () => (await Promise.resolve().then(() => (init_init(), init_exports))).initCommand,
|
|
18682
|
+
validate: async () => (await Promise.resolve().then(() => (init_validate2(), validate_exports))).validateCommand,
|
|
18683
|
+
doctor: async () => (await Promise.resolve().then(() => (init_doctor(), doctor_exports))).doctorCommand,
|
|
18684
|
+
studio: async () => (await Promise.resolve().then(() => (init_studio(), studio_exports))).studioCommand,
|
|
18685
|
+
stats: async () => (await Promise.resolve().then(() => (init_stats(), stats_exports))).statsCommand,
|
|
18686
|
+
render: async () => (await Promise.resolve().then(() => (init_render(), render_exports))).renderCommand,
|
|
18687
|
+
instructions: async () => (await Promise.resolve().then(() => (init_instructions(), instructions_exports))).instructionsCommand,
|
|
18688
|
+
docs: async () => (await Promise.resolve().then(() => (init_docs(), docs_exports))).docsCommand,
|
|
18689
|
+
agents: async () => (await Promise.resolve().then(() => (init_agents(), agents_exports))).agentsCommand,
|
|
18690
|
+
links: async () => (await Promise.resolve().then(() => (init_links2(), links_exports))).linksCommand
|
|
18691
|
+
};
|
|
18692
|
+
}
|
|
18693
|
+
});
|
|
18694
|
+
init_run();
|
|
18701
18695
|
export {
|
|
18696
|
+
CliError,
|
|
18702
18697
|
USAGE,
|
|
18703
18698
|
run
|
|
18704
18699
|
};
|