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