contentbit 0.3.0 → 0.4.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 +37 -8
- package/dist/bin.js +367 -49
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +27 -18
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +215 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +16 -2
- package/dist/commands/studio.d.ts +3 -0
- package/dist/commands/studio.d.ts.map +1 -0
- package/dist/commands/studio.js +76 -0
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +367 -49
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,16 +1,42 @@
|
|
|
1
1
|
# contentbit
|
|
2
2
|
|
|
3
|
-
CLI for [
|
|
4
|
-
|
|
5
|
-
from your
|
|
3
|
+
CLI for [contentbit](https://contentbit.dev): initialize projects, validate
|
|
4
|
+
structured Markdown blocks, print ranked health reports, build internal-link
|
|
5
|
+
indexes, render content, and give LLMs live authoring instructions from your
|
|
6
|
+
registry.
|
|
7
|
+
|
|
8
|
+
Fast path:
|
|
6
9
|
|
|
7
10
|
```bash
|
|
8
|
-
# scaffold
|
|
9
|
-
# a custom-block registry, and LLM authoring instructions
|
|
11
|
+
# scaffold packages, starter content, registry, renderer, scripts, and LLM-agent files
|
|
10
12
|
pnpm dlx contentbit@latest init
|
|
11
13
|
|
|
12
|
-
# validate
|
|
13
|
-
|
|
14
|
+
# run the generated validate script, including your custom registry
|
|
15
|
+
pnpm run content:check
|
|
16
|
+
|
|
17
|
+
# open the local read-only Studio dashboard
|
|
18
|
+
pnpm run studio
|
|
19
|
+
|
|
20
|
+
# inspect validation, links, and content-quality suggestions together
|
|
21
|
+
pnpm run content:doctor
|
|
22
|
+
|
|
23
|
+
# refresh AGENTS.md and Claude Code skills for LLM agents
|
|
24
|
+
contentbit agents
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Everyday commands:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# exits 1 with file:line:col diagnostics and fix hints
|
|
31
|
+
contentbit validate "content/**/*.md" --registry ./blocks/registry.ts
|
|
32
|
+
|
|
33
|
+
# ranked repair plan: validation, links, thin sections, block-less long docs,
|
|
34
|
+
# and missing image alt text; add --json for agents/CI
|
|
35
|
+
contentbit doctor "content/**/*.md" --registry ./blocks/registry.ts
|
|
36
|
+
|
|
37
|
+
# local read-only web app for previews, stats, diagnostics, links, and keywords
|
|
38
|
+
contentbit studio "content/**/*.md" --registry ./blocks/registry.ts
|
|
39
|
+
contentbit studio "content/**/*.md" --registry ./blocks/registry.ts --no-open
|
|
14
40
|
|
|
15
41
|
# structured JSON stats for one document: outline, word counts,
|
|
16
42
|
# block census, links, validation summary — quick context for LLMs
|
|
@@ -27,6 +53,9 @@ contentbit instructions --audience llm --out guide.md
|
|
|
27
53
|
contentbit render article.md --target html
|
|
28
54
|
```
|
|
29
55
|
|
|
30
|
-
Point `--registry ./blocks/registry.
|
|
56
|
+
Point `--registry ./blocks/registry.ts` at a module to add custom blocks.
|
|
57
|
+
LLM agents should read the same registry with `contentbit instructions`, write
|
|
58
|
+
plain Markdown with registered blocks, then run `contentbit validate` until it
|
|
59
|
+
exits 0.
|
|
31
60
|
|
|
32
61
|
Docs: [contentbit.dev/docs](https://contentbit.dev/docs)
|
package/dist/bin.js
CHANGED
|
@@ -16392,7 +16392,7 @@ function validateLinks(inputs, options = {}) {
|
|
|
16392
16392
|
}
|
|
16393
16393
|
const index = buildLinkIndex(inputs, resolvedOptions);
|
|
16394
16394
|
const lookup = buildLookup(index.pages, resolvedOptions);
|
|
16395
|
-
for (const {
|
|
16395
|
+
for (const { fm } of validInputs) {
|
|
16396
16396
|
const page = index.pages.get(pageMapKey(frontmatterIdentity(fm, resolvedOptions), resolvedOptions));
|
|
16397
16397
|
if (!page)
|
|
16398
16398
|
continue;
|
|
@@ -17091,7 +17091,7 @@ var TEMPLATE_VERSION, AUTHOR_SKILL, AUDIT_SKILL, AGENTS_MD_BLOCK, START, END;
|
|
|
17091
17091
|
var init_agents = __esm({
|
|
17092
17092
|
"src/commands/agents.ts"() {
|
|
17093
17093
|
"use strict";
|
|
17094
|
-
TEMPLATE_VERSION =
|
|
17094
|
+
TEMPLATE_VERSION = 3;
|
|
17095
17095
|
AUTHOR_SKILL = `---
|
|
17096
17096
|
name: contentbit-author
|
|
17097
17097
|
description: |
|
|
@@ -17184,32 +17184,37 @@ version: ${TEMPLATE_VERSION}
|
|
|
17184
17184
|
|
|
17185
17185
|
# Auditing contentbit content
|
|
17186
17186
|
|
|
17187
|
-
\`contentbit
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
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\`.
|
|
17191
17193
|
|
|
17192
17194
|
## Gather
|
|
17193
17195
|
|
|
17194
|
-
Check \`package.json\` for
|
|
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:
|
|
17196
17199
|
|
|
17197
17200
|
\`\`\`sh
|
|
17201
|
+
contentbit doctor "content/**/*.md" [--registry <path>]
|
|
17202
|
+
contentbit doctor "content/**/*.md" [--registry <path>] --json
|
|
17198
17203
|
contentbit stats "content/**/*.md" [--registry <path>]
|
|
17199
17204
|
contentbit links "content/**/*.md"
|
|
17200
17205
|
\`\`\`
|
|
17201
17206
|
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
per-section word counts, \`blocks.byName\` usage counts,
|
|
17205
|
-
a \`validation\` summary (\`errors\`/\`warnings\`).
|
|
17206
|
-
\`contentbit links\`
|
|
17207
|
-
|
|
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
|
|
17208
17213
|
\`keywords\`.
|
|
17209
17214
|
|
|
17210
17215
|
## Interpret
|
|
17211
17216
|
|
|
17212
|
-
Prioritize findings in
|
|
17217
|
+
Prioritize findings in the order \`doctor\` reports them:
|
|
17213
17218
|
|
|
17214
17219
|
1. **Validation errors and warnings** \u2014 broken content ships broken pages.
|
|
17215
17220
|
2. **Internal-link errors** \u2014 unresolved links, duplicate slugs, and alias
|
|
@@ -17255,10 +17260,14 @@ When writing or editing content:
|
|
|
17255
17260
|
|
|
17256
17261
|
When auditing content health:
|
|
17257
17262
|
|
|
17258
|
-
- \`contentbit
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
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.
|
|
17262
17271
|
- \`contentbit links "content/**/*.md" [--fix]\` builds
|
|
17263
17272
|
\`.contentbit/link-index.json\`, reports dangling links/orphans, and rewrites
|
|
17264
17273
|
alias references in \`linksTo\` when \`--fix\` is used.
|
|
@@ -17640,7 +17649,15 @@ async function initCommand(args, io) {
|
|
|
17640
17649
|
fresh.scripts["content:links"] = 'contentbit links "content/**/*.md"';
|
|
17641
17650
|
io.stdout("added script: content:links");
|
|
17642
17651
|
}
|
|
17643
|
-
if (!
|
|
17652
|
+
if (!fresh.scripts["content:doctor"]) {
|
|
17653
|
+
fresh.scripts["content:doctor"] = 'contentbit doctor "content/**/*.md" --registry ./blocks/registry.ts';
|
|
17654
|
+
io.stdout("added script: content:doctor");
|
|
17655
|
+
}
|
|
17656
|
+
if (!fresh.scripts.studio) {
|
|
17657
|
+
fresh.scripts.studio = 'contentbit studio "content/**/*.md" --registry ./blocks/registry.ts';
|
|
17658
|
+
io.stdout("added script: studio");
|
|
17659
|
+
}
|
|
17660
|
+
if (!pkg.scripts?.["content:check"] || !pkg.scripts?.["content:links"] || !pkg.scripts?.["content:doctor"] || !pkg.scripts?.studio) {
|
|
17644
17661
|
await writeFile2(pkgPath, `${JSON.stringify(fresh, null, 2)}
|
|
17645
17662
|
`, "utf8");
|
|
17646
17663
|
}
|
|
@@ -17660,7 +17677,9 @@ async function initCommand(args, io) {
|
|
|
17660
17677
|
}
|
|
17661
17678
|
io.stdout("");
|
|
17662
17679
|
io.stdout("Done. Next steps:");
|
|
17663
|
-
io.stdout(` 1.
|
|
17680
|
+
io.stdout(` 1. Browse content locally: ${detectPackageManager(cwd)} run studio`);
|
|
17681
|
+
io.stdout(` Inspect content health: ${detectPackageManager(cwd)} run content:doctor`);
|
|
17682
|
+
io.stdout(` Validate the starter content: ${detectPackageManager(cwd)} run content:check`);
|
|
17664
17683
|
io.stdout(` Build the link index: ${detectPackageManager(cwd)} run content:links`);
|
|
17665
17684
|
if (target === "react") {
|
|
17666
17685
|
if (!values["no-page"] && layout.pagePath) {
|
|
@@ -17937,16 +17956,311 @@ var init_validate2 = __esm({
|
|
|
17937
17956
|
}
|
|
17938
17957
|
});
|
|
17939
17958
|
|
|
17959
|
+
// src/commands/doctor.ts
|
|
17960
|
+
var doctor_exports = {};
|
|
17961
|
+
__export(doctor_exports, {
|
|
17962
|
+
doctorCommand: () => doctorCommand
|
|
17963
|
+
});
|
|
17964
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
17965
|
+
import { parseArgs as parseArgs4 } from "node:util";
|
|
17966
|
+
import { glob as glob2 } from "tinyglobby";
|
|
17967
|
+
async function doctorCommand(args, io) {
|
|
17968
|
+
const { values, positionals } = parseArgs4({
|
|
17969
|
+
args,
|
|
17970
|
+
allowPositionals: true,
|
|
17971
|
+
options: {
|
|
17972
|
+
registry: { type: "string" },
|
|
17973
|
+
"strict-warnings": { type: "boolean", default: false },
|
|
17974
|
+
json: { type: "boolean", default: false },
|
|
17975
|
+
"min-section-words": { type: "string" },
|
|
17976
|
+
"link-resolve": { type: "string" },
|
|
17977
|
+
"locale-field": { type: "string" },
|
|
17978
|
+
"slug-field": { type: "string" },
|
|
17979
|
+
"key-field": { type: "string" },
|
|
17980
|
+
"default-locale": { type: "string" }
|
|
17981
|
+
}
|
|
17982
|
+
});
|
|
17983
|
+
if (positionals.length === 0) {
|
|
17984
|
+
io.stderr("doctor: provide at least one file or glob.");
|
|
17985
|
+
return 2;
|
|
17986
|
+
}
|
|
17987
|
+
const minSectionWords = parseMinSectionWords(values["min-section-words"]);
|
|
17988
|
+
if (minSectionWords === null) {
|
|
17989
|
+
io.stderr("doctor: --min-section-words must be a non-negative integer.");
|
|
17990
|
+
return 2;
|
|
17991
|
+
}
|
|
17992
|
+
const files = (await glob2(positionals, { absolute: true })).sort();
|
|
17993
|
+
if (files.length === 0) {
|
|
17994
|
+
io.stderr(`doctor: no files matched ${positionals.join(" ")}`);
|
|
17995
|
+
return 2;
|
|
17996
|
+
}
|
|
17997
|
+
const registry2 = await loadRegistry(values.registry);
|
|
17998
|
+
const linkOptions = linkResolverOptions(values);
|
|
17999
|
+
const findings = [];
|
|
18000
|
+
const linkInputs = [];
|
|
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);
|
|
18060
|
+
const report = {
|
|
18061
|
+
files: files.length,
|
|
18062
|
+
summary: summarize(findings),
|
|
18063
|
+
...linkGraph ? { linkGraph } : {},
|
|
18064
|
+
findings
|
|
18065
|
+
};
|
|
18066
|
+
if (values.json) io.stdout(JSON.stringify(report, null, 2));
|
|
18067
|
+
else io.stdout(formatReport(report, positionals, values.registry, hasAliases(linkInputs)));
|
|
18068
|
+
if (report.summary.errors > 0) return 1;
|
|
18069
|
+
if (report.summary.warnings > 0 && values["strict-warnings"]) return 1;
|
|
18070
|
+
return 0;
|
|
18071
|
+
}
|
|
18072
|
+
function parseMinSectionWords(value) {
|
|
18073
|
+
if (value === void 0) return DEFAULT_MIN_SECTION_WORDS;
|
|
18074
|
+
if (!/^\d+$/.test(value)) return null;
|
|
18075
|
+
return Number(value);
|
|
18076
|
+
}
|
|
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
|
+
function hasAliases(inputs) {
|
|
18094
|
+
return inputs.some((input) => Array.isArray(input.data.aliases) && input.data.aliases.length > 0);
|
|
18095
|
+
}
|
|
18096
|
+
function summarize(findings) {
|
|
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) {
|
|
18116
|
+
const lines = [];
|
|
18117
|
+
lines.push("contentbit doctor");
|
|
18118
|
+
lines.push(
|
|
18119
|
+
`${report.files} file(s): ${report.summary.errors} errors, ${report.summary.warnings} warnings, ${report.summary.suggestions} suggestions`
|
|
18120
|
+
);
|
|
18121
|
+
if (report.linkGraph) {
|
|
18122
|
+
lines.push(
|
|
18123
|
+
`${report.linkGraph.pages} linked page(s), ${report.linkGraph.links} link(s), ${report.linkGraph.orphans} orphan(s)`
|
|
18124
|
+
);
|
|
18125
|
+
}
|
|
18126
|
+
lines.push("");
|
|
18127
|
+
if (report.findings.length === 0) {
|
|
18128
|
+
lines.push("No findings. Content looks healthy.");
|
|
18129
|
+
} else {
|
|
18130
|
+
lines.push("Repair plan:");
|
|
18131
|
+
report.findings.forEach((finding, index) => {
|
|
18132
|
+
lines.push(`${index + 1}. ${formatFinding(finding)}`);
|
|
18133
|
+
if (finding.hint) lines.push(` hint: ${finding.hint}`);
|
|
18134
|
+
});
|
|
18135
|
+
}
|
|
18136
|
+
lines.push("");
|
|
18137
|
+
lines.push("Next commands:");
|
|
18138
|
+
lines.push(
|
|
18139
|
+
`- contentbit validate ${formatGlobs(globs)}${registryPath ? ` --registry ${formatArg(registryPath)}` : ""}`
|
|
18140
|
+
);
|
|
18141
|
+
if (report.linkGraph) {
|
|
18142
|
+
lines.push(`- contentbit links ${formatGlobs(globs)}`);
|
|
18143
|
+
if (aliasFixMayApply && report.summary.errors === 0)
|
|
18144
|
+
lines.push(`- contentbit links ${formatGlobs(globs)} --fix`);
|
|
18145
|
+
}
|
|
18146
|
+
lines.push(`- contentbit doctor ${formatGlobs(globs)} --json`);
|
|
18147
|
+
return lines.join("\n");
|
|
18148
|
+
}
|
|
18149
|
+
function formatFinding(finding) {
|
|
18150
|
+
const location = finding.line !== void 0 && finding.column !== void 0 ? `${finding.file}:${finding.line}:${finding.column}` : finding.file;
|
|
18151
|
+
return `[${finding.severity}] ${finding.source} ${finding.code} ${location} - ${finding.message}`;
|
|
18152
|
+
}
|
|
18153
|
+
function formatGlobs(globs) {
|
|
18154
|
+
return globs.map(formatArg).join(" ");
|
|
18155
|
+
}
|
|
18156
|
+
function formatArg(value) {
|
|
18157
|
+
return /\s/.test(value) ? JSON.stringify(value) : value;
|
|
18158
|
+
}
|
|
18159
|
+
var DEFAULT_MIN_SECTION_WORDS, BLOCKLESS_WORDS;
|
|
18160
|
+
var init_doctor = __esm({
|
|
18161
|
+
"src/commands/doctor.ts"() {
|
|
18162
|
+
"use strict";
|
|
18163
|
+
init_dist();
|
|
18164
|
+
init_link_options();
|
|
18165
|
+
init_load_registry();
|
|
18166
|
+
DEFAULT_MIN_SECTION_WORDS = 25;
|
|
18167
|
+
BLOCKLESS_WORDS = 250;
|
|
18168
|
+
}
|
|
18169
|
+
});
|
|
18170
|
+
|
|
18171
|
+
// src/commands/studio.ts
|
|
18172
|
+
var studio_exports = {};
|
|
18173
|
+
__export(studio_exports, {
|
|
18174
|
+
studioCommand: () => studioCommand
|
|
18175
|
+
});
|
|
18176
|
+
import { parseArgs as parseArgs5 } from "node:util";
|
|
18177
|
+
import { glob as glob3 } from "tinyglobby";
|
|
18178
|
+
async function studioCommand(args, io) {
|
|
18179
|
+
const { values, positionals } = parseArgs5({
|
|
18180
|
+
args,
|
|
18181
|
+
allowPositionals: true,
|
|
18182
|
+
options: {
|
|
18183
|
+
registry: { type: "string" },
|
|
18184
|
+
port: { type: "string" },
|
|
18185
|
+
host: { type: "string" },
|
|
18186
|
+
"no-open": { type: "boolean", default: false },
|
|
18187
|
+
"min-section-words": { type: "string" },
|
|
18188
|
+
"link-resolve": { type: "string" },
|
|
18189
|
+
"locale-field": { type: "string" },
|
|
18190
|
+
"slug-field": { type: "string" },
|
|
18191
|
+
"key-field": { type: "string" },
|
|
18192
|
+
"default-locale": { type: "string" }
|
|
18193
|
+
}
|
|
18194
|
+
});
|
|
18195
|
+
if (positionals.length === 0) {
|
|
18196
|
+
io.stderr("studio: provide at least one file or glob.");
|
|
18197
|
+
return 2;
|
|
18198
|
+
}
|
|
18199
|
+
const port = parsePort(values.port);
|
|
18200
|
+
if (port === null) {
|
|
18201
|
+
io.stderr("studio: --port must be an integer between 0 and 65535.");
|
|
18202
|
+
return 2;
|
|
18203
|
+
}
|
|
18204
|
+
const minSectionWords = parseMinSectionWords2(values["min-section-words"]);
|
|
18205
|
+
if (minSectionWords === null) {
|
|
18206
|
+
io.stderr("studio: --min-section-words must be a non-negative integer.");
|
|
18207
|
+
return 2;
|
|
18208
|
+
}
|
|
18209
|
+
const files = await glob3(positionals, { absolute: true });
|
|
18210
|
+
if (files.length === 0) {
|
|
18211
|
+
io.stderr(`studio: no files matched ${positionals.join(" ")}`);
|
|
18212
|
+
return 2;
|
|
18213
|
+
}
|
|
18214
|
+
const { startStudio } = await import("@contentbit/studio");
|
|
18215
|
+
const server = await startStudio({
|
|
18216
|
+
globs: positionals,
|
|
18217
|
+
registryPath: values.registry,
|
|
18218
|
+
host: values.host,
|
|
18219
|
+
...port !== void 0 ? { port } : {},
|
|
18220
|
+
open: !values["no-open"],
|
|
18221
|
+
linkOptions: linkResolverOptions(values),
|
|
18222
|
+
minSectionWords
|
|
18223
|
+
});
|
|
18224
|
+
io.stdout(`contentbit studio running at ${server.url}`);
|
|
18225
|
+
io.stdout("Press Ctrl+C to stop.");
|
|
18226
|
+
const close = () => {
|
|
18227
|
+
void server.close();
|
|
18228
|
+
};
|
|
18229
|
+
process.once("SIGINT", close);
|
|
18230
|
+
process.once("SIGTERM", close);
|
|
18231
|
+
await server.closed;
|
|
18232
|
+
process.off("SIGINT", close);
|
|
18233
|
+
process.off("SIGTERM", close);
|
|
18234
|
+
return 0;
|
|
18235
|
+
}
|
|
18236
|
+
function parsePort(value) {
|
|
18237
|
+
if (value === void 0) return void 0;
|
|
18238
|
+
if (!/^\d+$/.test(value)) return null;
|
|
18239
|
+
const port = Number(value);
|
|
18240
|
+
return port >= 0 && port <= 65535 ? port : null;
|
|
18241
|
+
}
|
|
18242
|
+
function parseMinSectionWords2(value) {
|
|
18243
|
+
if (value === void 0) return void 0;
|
|
18244
|
+
if (!/^\d+$/.test(value)) return null;
|
|
18245
|
+
return Number(value);
|
|
18246
|
+
}
|
|
18247
|
+
var init_studio = __esm({
|
|
18248
|
+
"src/commands/studio.ts"() {
|
|
18249
|
+
"use strict";
|
|
18250
|
+
init_link_options();
|
|
18251
|
+
}
|
|
18252
|
+
});
|
|
18253
|
+
|
|
17940
18254
|
// src/commands/stats.ts
|
|
17941
18255
|
var stats_exports = {};
|
|
17942
18256
|
__export(stats_exports, {
|
|
17943
18257
|
statsCommand: () => statsCommand
|
|
17944
18258
|
});
|
|
17945
|
-
import { readFile as
|
|
17946
|
-
import { parseArgs as
|
|
17947
|
-
import { glob as
|
|
18259
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
18260
|
+
import { parseArgs as parseArgs6 } from "node:util";
|
|
18261
|
+
import { glob as glob4 } from "tinyglobby";
|
|
17948
18262
|
async function fileStats(file2, registry2) {
|
|
17949
|
-
const source = await
|
|
18263
|
+
const source = await readFile5(file2, "utf8");
|
|
17950
18264
|
const stats = analyzeDocument(source, { path: file2 });
|
|
17951
18265
|
if (registry2) {
|
|
17952
18266
|
const result = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
|
|
@@ -17961,7 +18275,7 @@ async function fileStats(file2, registry2) {
|
|
|
17961
18275
|
return stats;
|
|
17962
18276
|
}
|
|
17963
18277
|
async function statsCommand(args, io) {
|
|
17964
|
-
const { values, positionals } =
|
|
18278
|
+
const { values, positionals } = parseArgs6({
|
|
17965
18279
|
args,
|
|
17966
18280
|
allowPositionals: true,
|
|
17967
18281
|
options: {
|
|
@@ -17973,7 +18287,7 @@ async function statsCommand(args, io) {
|
|
|
17973
18287
|
io.stderr("stats: provide at least one file or glob.");
|
|
17974
18288
|
return 2;
|
|
17975
18289
|
}
|
|
17976
|
-
const files = await
|
|
18290
|
+
const files = await glob4(positionals, { absolute: true });
|
|
17977
18291
|
if (files.length === 0) {
|
|
17978
18292
|
io.stderr(`stats: no files matched ${positionals.join(" ")}`);
|
|
17979
18293
|
return 2;
|
|
@@ -18131,10 +18445,10 @@ var render_exports = {};
|
|
|
18131
18445
|
__export(render_exports, {
|
|
18132
18446
|
renderCommand: () => renderCommand
|
|
18133
18447
|
});
|
|
18134
|
-
import { readFile as
|
|
18135
|
-
import { parseArgs as
|
|
18448
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
18449
|
+
import { parseArgs as parseArgs7 } from "node:util";
|
|
18136
18450
|
async function renderCommand(args, io) {
|
|
18137
|
-
const { values, positionals } =
|
|
18451
|
+
const { values, positionals } = parseArgs7({
|
|
18138
18452
|
args,
|
|
18139
18453
|
allowPositionals: true,
|
|
18140
18454
|
options: {
|
|
@@ -18149,7 +18463,7 @@ async function renderCommand(args, io) {
|
|
|
18149
18463
|
return 2;
|
|
18150
18464
|
}
|
|
18151
18465
|
const registry2 = await loadRegistry(values.registry);
|
|
18152
|
-
const source = await
|
|
18466
|
+
const source = await readFile6(file2, "utf8");
|
|
18153
18467
|
const result = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
|
|
18154
18468
|
if (!result.ok) {
|
|
18155
18469
|
for (const d of result.diagnostics) io.stderr(formatDiagnostic(d, file2));
|
|
@@ -18175,9 +18489,9 @@ var instructions_exports = {};
|
|
|
18175
18489
|
__export(instructions_exports, {
|
|
18176
18490
|
instructionsCommand: () => instructionsCommand
|
|
18177
18491
|
});
|
|
18178
|
-
import { parseArgs as
|
|
18492
|
+
import { parseArgs as parseArgs8 } from "node:util";
|
|
18179
18493
|
async function instructionsCommand(args, io) {
|
|
18180
|
-
const { values } =
|
|
18494
|
+
const { values } = parseArgs8({
|
|
18181
18495
|
args,
|
|
18182
18496
|
options: {
|
|
18183
18497
|
audience: { type: "string", default: "llm" },
|
|
@@ -18207,9 +18521,9 @@ var docs_exports = {};
|
|
|
18207
18521
|
__export(docs_exports, {
|
|
18208
18522
|
docsCommand: () => docsCommand
|
|
18209
18523
|
});
|
|
18210
|
-
import { parseArgs as
|
|
18524
|
+
import { parseArgs as parseArgs9 } from "node:util";
|
|
18211
18525
|
async function docsCommand(args, io) {
|
|
18212
|
-
const { values } =
|
|
18526
|
+
const { values } = parseArgs9({
|
|
18213
18527
|
args,
|
|
18214
18528
|
options: {
|
|
18215
18529
|
registry: { type: "string" },
|
|
@@ -18230,11 +18544,11 @@ var init_docs = __esm({
|
|
|
18230
18544
|
});
|
|
18231
18545
|
|
|
18232
18546
|
// src/links-io.ts
|
|
18233
|
-
import { readFile as
|
|
18547
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
18234
18548
|
async function collectLinkInputs(files) {
|
|
18235
18549
|
const inputs = [];
|
|
18236
18550
|
for (const path of files) {
|
|
18237
|
-
const source = await
|
|
18551
|
+
const source = await readFile7(path, "utf8");
|
|
18238
18552
|
const fm = extractFrontmatter(source);
|
|
18239
18553
|
inputs.push({ path, data: fm?.data ?? {} });
|
|
18240
18554
|
}
|
|
@@ -18252,12 +18566,12 @@ var links_exports = {};
|
|
|
18252
18566
|
__export(links_exports, {
|
|
18253
18567
|
linksCommand: () => linksCommand
|
|
18254
18568
|
});
|
|
18255
|
-
import { mkdir as mkdir3, readFile as
|
|
18569
|
+
import { mkdir as mkdir3, readFile as readFile8 } from "node:fs/promises";
|
|
18256
18570
|
import { dirname, join as join3 } from "node:path";
|
|
18257
|
-
import { parseArgs as
|
|
18258
|
-
import { glob as
|
|
18571
|
+
import { parseArgs as parseArgs10 } from "node:util";
|
|
18572
|
+
import { glob as glob5 } from "tinyglobby";
|
|
18259
18573
|
async function linksCommand(args, io) {
|
|
18260
|
-
const { values, positionals } =
|
|
18574
|
+
const { values, positionals } = parseArgs10({
|
|
18261
18575
|
args,
|
|
18262
18576
|
allowPositionals: true,
|
|
18263
18577
|
options: {
|
|
@@ -18274,7 +18588,7 @@ async function linksCommand(args, io) {
|
|
|
18274
18588
|
io.stderr("links: provide at least one file or glob.");
|
|
18275
18589
|
return 2;
|
|
18276
18590
|
}
|
|
18277
|
-
const files = (await
|
|
18591
|
+
const files = (await glob5(positionals, { absolute: true })).sort();
|
|
18278
18592
|
if (files.length === 0) {
|
|
18279
18593
|
io.stderr(`links: no files matched ${positionals.join(" ")}`);
|
|
18280
18594
|
return 2;
|
|
@@ -18293,7 +18607,7 @@ async function linksCommand(args, io) {
|
|
|
18293
18607
|
io.stderr("links: --fix skipped because link errors must be resolved first.");
|
|
18294
18608
|
} else if (values.fix && index.aliases.size > 0) {
|
|
18295
18609
|
for (const file2 of files) {
|
|
18296
|
-
const source = await
|
|
18610
|
+
const source = await readFile8(file2, "utf8");
|
|
18297
18611
|
const fm = extractFrontmatter(source);
|
|
18298
18612
|
if (!fm) continue;
|
|
18299
18613
|
const lines = source.split("\n");
|
|
@@ -18348,20 +18662,24 @@ var init_links2 = __esm({
|
|
|
18348
18662
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
18349
18663
|
|
|
18350
18664
|
// src/run.ts
|
|
18351
|
-
var USAGE = `Usage: contentbit <init|validate|stats|render|instructions|docs|agents|links> [options]
|
|
18665
|
+
var USAGE = `Usage: contentbit <init|validate|doctor|studio|stats|render|instructions|docs|agents|links> [options]
|
|
18352
18666
|
|
|
18353
18667
|
init [-t react|html|markdown|astro] [--md ...] [-y] [--no-install] [--no-page] [--no-agents]
|
|
18354
18668
|
agents [--claude] [--no-agents-md]
|
|
18355
18669
|
|
|
18356
|
-
validate <globs...> [--registry <module.
|
|
18357
|
-
|
|
18358
|
-
|
|
18359
|
-
|
|
18360
|
-
|
|
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>]
|
|
18361
18677
|
links <globs...> [--fix] [--out <file>] [--link-resolve <mode>]`;
|
|
18362
18678
|
var commands = {
|
|
18363
18679
|
init: async () => (await Promise.resolve().then(() => (init_init(), init_exports))).initCommand,
|
|
18364
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,
|
|
18365
18683
|
stats: async () => (await Promise.resolve().then(() => (init_stats(), stats_exports))).statsCommand,
|
|
18366
18684
|
render: async () => (await Promise.resolve().then(() => (init_render2(), render_exports))).renderCommand,
|
|
18367
18685
|
instructions: async () => (await Promise.resolve().then(() => (init_instructions(), instructions_exports))).instructionsCommand,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAkNnC,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,+EAA+E;AAC/E,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,EACrB,EAAE,EAAE,EAAE,GACL,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB3E"}
|