contentbit 0.3.0 → 0.4.1

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/dist/run.js CHANGED
@@ -16391,7 +16391,7 @@ function validateLinks(inputs, options = {}) {
16391
16391
  }
16392
16392
  const index = buildLinkIndex(inputs, resolvedOptions);
16393
16393
  const lookup = buildLookup(index.pages, resolvedOptions);
16394
- for (const { path, fm } of validInputs) {
16394
+ for (const { fm } of validInputs) {
16395
16395
  const page = index.pages.get(pageMapKey(frontmatterIdentity(fm, resolvedOptions), resolvedOptions));
16396
16396
  if (!page)
16397
16397
  continue;
@@ -17090,7 +17090,7 @@ var TEMPLATE_VERSION, AUTHOR_SKILL, AUDIT_SKILL, AGENTS_MD_BLOCK, START, END;
17090
17090
  var init_agents = __esm({
17091
17091
  "src/commands/agents.ts"() {
17092
17092
  "use strict";
17093
- TEMPLATE_VERSION = 2;
17093
+ TEMPLATE_VERSION = 3;
17094
17094
  AUTHOR_SKILL = `---
17095
17095
  name: contentbit-author
17096
17096
  description: |
@@ -17183,32 +17183,37 @@ version: ${TEMPLATE_VERSION}
17183
17183
 
17184
17184
  # Auditing contentbit content
17185
17185
 
17186
- \`contentbit stats\` analyzes documents and prints JSON to stdout. It is a read
17187
- tool: it always exits 0, even when documents have validation errors.
17188
- \`contentbit links\` builds the frontmatter-authored internal-link graph and
17189
- prints link diagnostics.
17186
+ \`contentbit doctor\` is the first audit command. It reads content once, runs
17187
+ block validation, link validation, and document stats, then prints a ranked
17188
+ repair plan. It is read-only: it does not write the link index and never edits
17189
+ source files. \`contentbit stats\` remains useful when you need raw JSON metrics.
17190
+ \`contentbit links\` builds the frontmatter-authored internal-link graph and can
17191
+ heal alias references with \`--fix\`.
17190
17192
 
17191
17193
  ## Gather
17192
17194
 
17193
- Check \`package.json\` for the \`content:check\` script to find this project's
17194
- content glob and \`--registry\` flag, then:
17195
+ Check \`package.json\` for \`content:doctor\` first. If it exists, run it. If it
17196
+ does not, use \`content:check\` to find this project's content glob and
17197
+ \`--registry\` flag, then run:
17195
17198
 
17196
17199
  \`\`\`sh
17200
+ contentbit doctor "content/**/*.md" [--registry <path>]
17201
+ contentbit doctor "content/**/*.md" [--registry <path>] --json
17197
17202
  contentbit stats "content/**/*.md" [--registry <path>]
17198
17203
  contentbit links "content/**/*.md"
17199
17204
  \`\`\`
17200
17205
 
17201
- One matched file prints a single stats object; multiple files print an array.
17202
- Each entry includes the file path, frontmatter data, a heading \`outline\` with
17203
- per-section word counts, \`blocks.byName\` usage counts, \`links.domains\`, and
17204
- a \`validation\` summary (\`errors\`/\`warnings\`).
17205
- \`contentbit links\` also writes \`.contentbit/link-index.json\`, whose pages
17206
- contain \`slug\`, resolved \`linksTo\`, derived \`linkedFrom\`, \`aliases\`, and
17206
+ \`doctor --json\` prints a stable report with summary counts and ranked
17207
+ findings. \`stats\` prints per-file metrics: frontmatter data, a heading
17208
+ \`outline\` with per-section word counts, \`blocks.byName\` usage counts,
17209
+ \`links.domains\`, and a \`validation\` summary (\`errors\`/\`warnings\`).
17210
+ \`contentbit links\` writes \`.contentbit/link-index.json\`, whose pages contain
17211
+ \`slug\`, resolved \`linksTo\`, derived \`linkedFrom\`, \`aliases\`, and
17207
17212
  \`keywords\`.
17208
17213
 
17209
17214
  ## Interpret
17210
17215
 
17211
- Prioritize findings in this order:
17216
+ Prioritize findings in the order \`doctor\` reports them:
17212
17217
 
17213
17218
  1. **Validation errors and warnings** \u2014 broken content ships broken pages.
17214
17219
  2. **Internal-link errors** \u2014 unresolved links, duplicate slugs, and alias
@@ -17254,10 +17259,14 @@ When writing or editing content:
17254
17259
 
17255
17260
  When auditing content health:
17256
17261
 
17257
- - \`contentbit stats "content/**/*.md" [--registry <path>]\` prints JSON stats
17258
- and always exits 0: outline word counts, block usage, link domains, and
17259
- validation error/warning counts. Flag validation issues, thin documents, and
17260
- block-less pages first.
17262
+ - \`contentbit doctor "content/**/*.md" [--registry <path>]\` prints a ranked,
17263
+ read-only repair plan: validation issues, link issues, thin sections,
17264
+ block-less long documents, and missing image alt text.
17265
+ - \`contentbit doctor "content/**/*.md" [--registry <path>] --json\` prints the
17266
+ same findings as structured JSON for agents and CI.
17267
+ - \`contentbit stats "content/**/*.md" [--registry <path>]\` prints raw JSON
17268
+ stats: outline word counts, block usage, link domains, and validation
17269
+ error/warning counts.
17261
17270
  - \`contentbit links "content/**/*.md" [--fix]\` builds
17262
17271
  \`.contentbit/link-index.json\`, reports dangling links/orphans, and rewrites
17263
17272
  alias references in \`linksTo\` when \`--fix\` is used.
@@ -17639,7 +17648,15 @@ async function initCommand(args, io) {
17639
17648
  fresh.scripts["content:links"] = 'contentbit links "content/**/*.md"';
17640
17649
  io.stdout("added script: content:links");
17641
17650
  }
17642
- if (!pkg.scripts?.["content:check"] || !pkg.scripts?.["content:links"]) {
17651
+ if (!fresh.scripts["content:doctor"]) {
17652
+ fresh.scripts["content:doctor"] = 'contentbit doctor "content/**/*.md" --registry ./blocks/registry.ts';
17653
+ io.stdout("added script: content:doctor");
17654
+ }
17655
+ if (!fresh.scripts.studio) {
17656
+ fresh.scripts.studio = 'contentbit studio "content/**/*.md" --registry ./blocks/registry.ts';
17657
+ io.stdout("added script: studio");
17658
+ }
17659
+ if (!pkg.scripts?.["content:check"] || !pkg.scripts?.["content:links"] || !pkg.scripts?.["content:doctor"] || !pkg.scripts?.studio) {
17643
17660
  await writeFile2(pkgPath, `${JSON.stringify(fresh, null, 2)}
17644
17661
  `, "utf8");
17645
17662
  }
@@ -17659,7 +17676,9 @@ async function initCommand(args, io) {
17659
17676
  }
17660
17677
  io.stdout("");
17661
17678
  io.stdout("Done. Next steps:");
17662
- io.stdout(` 1. Validate the starter content: ${detectPackageManager(cwd)} run content:check`);
17679
+ io.stdout(` 1. Browse content locally: ${detectPackageManager(cwd)} run studio`);
17680
+ io.stdout(` Inspect content health: ${detectPackageManager(cwd)} run content:doctor`);
17681
+ io.stdout(` Validate the starter content: ${detectPackageManager(cwd)} run content:check`);
17663
17682
  io.stdout(` Build the link index: ${detectPackageManager(cwd)} run content:links`);
17664
17683
  if (target === "react") {
17665
17684
  if (!values["no-page"] && layout.pagePath) {
@@ -17936,16 +17955,311 @@ var init_validate2 = __esm({
17936
17955
  }
17937
17956
  });
17938
17957
 
17958
+ // src/commands/doctor.ts
17959
+ var doctor_exports = {};
17960
+ __export(doctor_exports, {
17961
+ doctorCommand: () => doctorCommand
17962
+ });
17963
+ import { readFile as readFile4 } from "node:fs/promises";
17964
+ import { parseArgs as parseArgs4 } from "node:util";
17965
+ import { glob as glob2 } from "tinyglobby";
17966
+ async function doctorCommand(args, io) {
17967
+ const { values, positionals } = parseArgs4({
17968
+ args,
17969
+ allowPositionals: true,
17970
+ options: {
17971
+ registry: { type: "string" },
17972
+ "strict-warnings": { type: "boolean", default: false },
17973
+ json: { type: "boolean", default: false },
17974
+ "min-section-words": { type: "string" },
17975
+ "link-resolve": { type: "string" },
17976
+ "locale-field": { type: "string" },
17977
+ "slug-field": { type: "string" },
17978
+ "key-field": { type: "string" },
17979
+ "default-locale": { type: "string" }
17980
+ }
17981
+ });
17982
+ if (positionals.length === 0) {
17983
+ io.stderr("doctor: provide at least one file or glob.");
17984
+ return 2;
17985
+ }
17986
+ const minSectionWords = parseMinSectionWords(values["min-section-words"]);
17987
+ if (minSectionWords === null) {
17988
+ io.stderr("doctor: --min-section-words must be a non-negative integer.");
17989
+ return 2;
17990
+ }
17991
+ const files = (await glob2(positionals, { absolute: true })).sort();
17992
+ if (files.length === 0) {
17993
+ io.stderr(`doctor: no files matched ${positionals.join(" ")}`);
17994
+ return 2;
17995
+ }
17996
+ const registry2 = await loadRegistry(values.registry);
17997
+ const linkOptions = linkResolverOptions(values);
17998
+ const findings = [];
17999
+ const linkInputs = [];
18000
+ for (const file2 of files) {
18001
+ const source = await readFile4(file2, "utf8");
18002
+ const frontmatter = extractFrontmatter(source);
18003
+ linkInputs.push({ path: file2, data: frontmatter?.data ?? {} });
18004
+ const validation = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
18005
+ for (const diagnostic of validation.diagnostics) {
18006
+ findings.push(findingFromDiagnostic("validation", file2, diagnostic));
18007
+ }
18008
+ const stats = analyzeDocument(source, { path: file2 });
18009
+ for (const section of stats.outline) {
18010
+ if (section.words < minSectionWords) {
18011
+ findings.push({
18012
+ severity: "info",
18013
+ source: "stats",
18014
+ code: "CB_THIN_SECTION",
18015
+ file: file2,
18016
+ line: section.line,
18017
+ column: 1,
18018
+ message: `section "${section.text}" has ${section.words} words`,
18019
+ hint: `Add detail or merge it with a nearby section. Threshold: ${minSectionWords} words.`
18020
+ });
18021
+ }
18022
+ }
18023
+ if (stats.length.words >= BLOCKLESS_WORDS && stats.blocks.total === 0) {
18024
+ findings.push({
18025
+ severity: "info",
18026
+ source: "stats",
18027
+ code: "CB_BLOCKLESS_DOCUMENT",
18028
+ file: file2,
18029
+ message: `document has ${stats.length.words} words and no structured blocks`,
18030
+ hint: "Consider a callout, steps, comparison, FAQ, or another registered block if it clarifies the page."
18031
+ });
18032
+ }
18033
+ if (stats.images.missingAlt > 0) {
18034
+ findings.push({
18035
+ severity: "info",
18036
+ source: "stats",
18037
+ code: "CB_IMAGE_ALT_MISSING",
18038
+ file: file2,
18039
+ message: `${stats.images.missingAlt} image(s) are missing alt text`,
18040
+ hint: "Add descriptive alt text for meaningful images; use empty alt only for decorative images."
18041
+ });
18042
+ }
18043
+ }
18044
+ let linkGraph;
18045
+ if (hasLinkFrontmatter(linkInputs, linkOptions.slugField)) {
18046
+ for (const { file: file2, diagnostic } of validateLinks(linkInputs, linkOptions)) {
18047
+ findings.push(findingFromDiagnostic("links", file2, diagnostic));
18048
+ }
18049
+ const index = buildLinkIndex(linkInputs, linkOptions);
18050
+ let links = 0;
18051
+ for (const page of index.pages.values()) links += page.linksTo.length;
18052
+ linkGraph = {
18053
+ pages: index.pages.size,
18054
+ links,
18055
+ orphans: [...index.pages.values()].filter((page) => page.linkedFrom.length === 0).length
18056
+ };
18057
+ }
18058
+ findings.sort(compareFindings);
18059
+ const report = {
18060
+ files: files.length,
18061
+ summary: summarize(findings),
18062
+ ...linkGraph ? { linkGraph } : {},
18063
+ findings
18064
+ };
18065
+ if (values.json) io.stdout(JSON.stringify(report, null, 2));
18066
+ else io.stdout(formatReport(report, positionals, values.registry, hasAliases(linkInputs)));
18067
+ if (report.summary.errors > 0) return 1;
18068
+ if (report.summary.warnings > 0 && values["strict-warnings"]) return 1;
18069
+ return 0;
18070
+ }
18071
+ function parseMinSectionWords(value) {
18072
+ if (value === void 0) return DEFAULT_MIN_SECTION_WORDS;
18073
+ if (!/^\d+$/.test(value)) return null;
18074
+ return Number(value);
18075
+ }
18076
+ function findingFromDiagnostic(source, file2, diagnostic) {
18077
+ return {
18078
+ severity: diagnostic.severity,
18079
+ source,
18080
+ code: diagnostic.code,
18081
+ file: file2,
18082
+ line: diagnostic.position.start.line,
18083
+ column: diagnostic.position.start.column,
18084
+ message: diagnostic.message,
18085
+ ...diagnostic.hint ? { hint: diagnostic.hint } : {}
18086
+ };
18087
+ }
18088
+ function hasLinkFrontmatter(inputs, configuredSlugField) {
18089
+ const slugField = configuredSlugField ?? "slug";
18090
+ return inputs.some((input) => Object.prototype.hasOwnProperty.call(input.data, slugField));
18091
+ }
18092
+ function hasAliases(inputs) {
18093
+ return inputs.some((input) => Array.isArray(input.data.aliases) && input.data.aliases.length > 0);
18094
+ }
18095
+ function summarize(findings) {
18096
+ return {
18097
+ errors: findings.filter((f) => f.severity === "error").length,
18098
+ warnings: findings.filter((f) => f.severity === "warning").length,
18099
+ suggestions: findings.filter((f) => f.severity === "info").length
18100
+ };
18101
+ }
18102
+ function compareFindings(a, b) {
18103
+ return rank(a) - rank(b) || a.file.localeCompare(b.file) || (a.line ?? 0) - (b.line ?? 0) || (a.column ?? 0) - (b.column ?? 0) || a.code.localeCompare(b.code);
18104
+ }
18105
+ function rank(finding) {
18106
+ if (finding.severity === "error" && finding.source === "validation") return 0;
18107
+ if (finding.severity === "error" && finding.source === "links") return 1;
18108
+ if (finding.severity === "warning") return 2;
18109
+ if (finding.code === "CB_THIN_SECTION") return 3;
18110
+ if (finding.code === "CB_BLOCKLESS_DOCUMENT") return 4;
18111
+ if (finding.code === "CB_IMAGE_ALT_MISSING") return 5;
18112
+ return 6;
18113
+ }
18114
+ function formatReport(report, globs, registryPath, aliasFixMayApply) {
18115
+ const lines = [];
18116
+ lines.push("contentbit doctor");
18117
+ lines.push(
18118
+ `${report.files} file(s): ${report.summary.errors} errors, ${report.summary.warnings} warnings, ${report.summary.suggestions} suggestions`
18119
+ );
18120
+ if (report.linkGraph) {
18121
+ lines.push(
18122
+ `${report.linkGraph.pages} linked page(s), ${report.linkGraph.links} link(s), ${report.linkGraph.orphans} orphan(s)`
18123
+ );
18124
+ }
18125
+ lines.push("");
18126
+ if (report.findings.length === 0) {
18127
+ lines.push("No findings. Content looks healthy.");
18128
+ } else {
18129
+ lines.push("Repair plan:");
18130
+ report.findings.forEach((finding, index) => {
18131
+ lines.push(`${index + 1}. ${formatFinding(finding)}`);
18132
+ if (finding.hint) lines.push(` hint: ${finding.hint}`);
18133
+ });
18134
+ }
18135
+ lines.push("");
18136
+ lines.push("Next commands:");
18137
+ lines.push(
18138
+ `- contentbit validate ${formatGlobs(globs)}${registryPath ? ` --registry ${formatArg(registryPath)}` : ""}`
18139
+ );
18140
+ if (report.linkGraph) {
18141
+ lines.push(`- contentbit links ${formatGlobs(globs)}`);
18142
+ if (aliasFixMayApply && report.summary.errors === 0)
18143
+ lines.push(`- contentbit links ${formatGlobs(globs)} --fix`);
18144
+ }
18145
+ lines.push(`- contentbit doctor ${formatGlobs(globs)} --json`);
18146
+ return lines.join("\n");
18147
+ }
18148
+ function formatFinding(finding) {
18149
+ const location = finding.line !== void 0 && finding.column !== void 0 ? `${finding.file}:${finding.line}:${finding.column}` : finding.file;
18150
+ return `[${finding.severity}] ${finding.source} ${finding.code} ${location} - ${finding.message}`;
18151
+ }
18152
+ function formatGlobs(globs) {
18153
+ return globs.map(formatArg).join(" ");
18154
+ }
18155
+ function formatArg(value) {
18156
+ return /\s/.test(value) ? JSON.stringify(value) : value;
18157
+ }
18158
+ var DEFAULT_MIN_SECTION_WORDS, BLOCKLESS_WORDS;
18159
+ var init_doctor = __esm({
18160
+ "src/commands/doctor.ts"() {
18161
+ "use strict";
18162
+ init_dist();
18163
+ init_link_options();
18164
+ init_load_registry();
18165
+ DEFAULT_MIN_SECTION_WORDS = 25;
18166
+ BLOCKLESS_WORDS = 250;
18167
+ }
18168
+ });
18169
+
18170
+ // src/commands/studio.ts
18171
+ var studio_exports = {};
18172
+ __export(studio_exports, {
18173
+ studioCommand: () => studioCommand
18174
+ });
18175
+ import { parseArgs as parseArgs5 } from "node:util";
18176
+ import { glob as glob3 } from "tinyglobby";
18177
+ async function studioCommand(args, io) {
18178
+ const { values, positionals } = parseArgs5({
18179
+ args,
18180
+ allowPositionals: true,
18181
+ options: {
18182
+ registry: { type: "string" },
18183
+ port: { type: "string" },
18184
+ host: { type: "string" },
18185
+ "no-open": { type: "boolean", default: false },
18186
+ "min-section-words": { type: "string" },
18187
+ "link-resolve": { type: "string" },
18188
+ "locale-field": { type: "string" },
18189
+ "slug-field": { type: "string" },
18190
+ "key-field": { type: "string" },
18191
+ "default-locale": { type: "string" }
18192
+ }
18193
+ });
18194
+ if (positionals.length === 0) {
18195
+ io.stderr("studio: provide at least one file or glob.");
18196
+ return 2;
18197
+ }
18198
+ const port = parsePort(values.port);
18199
+ if (port === null) {
18200
+ io.stderr("studio: --port must be an integer between 0 and 65535.");
18201
+ return 2;
18202
+ }
18203
+ const minSectionWords = parseMinSectionWords2(values["min-section-words"]);
18204
+ if (minSectionWords === null) {
18205
+ io.stderr("studio: --min-section-words must be a non-negative integer.");
18206
+ return 2;
18207
+ }
18208
+ const files = await glob3(positionals, { absolute: true });
18209
+ if (files.length === 0) {
18210
+ io.stderr(`studio: no files matched ${positionals.join(" ")}`);
18211
+ return 2;
18212
+ }
18213
+ const { startStudio } = await import("@contentbit/studio");
18214
+ const server = await startStudio({
18215
+ globs: positionals,
18216
+ registryPath: values.registry,
18217
+ host: values.host,
18218
+ ...port !== void 0 ? { port } : {},
18219
+ open: !values["no-open"],
18220
+ linkOptions: linkResolverOptions(values),
18221
+ minSectionWords
18222
+ });
18223
+ io.stdout(`contentbit studio running at ${server.url}`);
18224
+ io.stdout("Press Ctrl+C to stop.");
18225
+ const close = () => {
18226
+ void server.close();
18227
+ };
18228
+ process.once("SIGINT", close);
18229
+ process.once("SIGTERM", close);
18230
+ await server.closed;
18231
+ process.off("SIGINT", close);
18232
+ process.off("SIGTERM", close);
18233
+ return 0;
18234
+ }
18235
+ function parsePort(value) {
18236
+ if (value === void 0) return void 0;
18237
+ if (!/^\d+$/.test(value)) return null;
18238
+ const port = Number(value);
18239
+ return port >= 0 && port <= 65535 ? port : null;
18240
+ }
18241
+ function parseMinSectionWords2(value) {
18242
+ if (value === void 0) return void 0;
18243
+ if (!/^\d+$/.test(value)) return null;
18244
+ return Number(value);
18245
+ }
18246
+ var init_studio = __esm({
18247
+ "src/commands/studio.ts"() {
18248
+ "use strict";
18249
+ init_link_options();
18250
+ }
18251
+ });
18252
+
17939
18253
  // src/commands/stats.ts
17940
18254
  var stats_exports = {};
17941
18255
  __export(stats_exports, {
17942
18256
  statsCommand: () => statsCommand
17943
18257
  });
17944
- import { readFile as readFile4 } from "node:fs/promises";
17945
- import { parseArgs as parseArgs4 } from "node:util";
17946
- import { glob as glob2 } from "tinyglobby";
18258
+ import { readFile as readFile5 } from "node:fs/promises";
18259
+ import { parseArgs as parseArgs6 } from "node:util";
18260
+ import { glob as glob4 } from "tinyglobby";
17947
18261
  async function fileStats(file2, registry2) {
17948
- const source = await readFile4(file2, "utf8");
18262
+ const source = await readFile5(file2, "utf8");
17949
18263
  const stats = analyzeDocument(source, { path: file2 });
17950
18264
  if (registry2) {
17951
18265
  const result = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
@@ -17960,7 +18274,7 @@ async function fileStats(file2, registry2) {
17960
18274
  return stats;
17961
18275
  }
17962
18276
  async function statsCommand(args, io) {
17963
- const { values, positionals } = parseArgs4({
18277
+ const { values, positionals } = parseArgs6({
17964
18278
  args,
17965
18279
  allowPositionals: true,
17966
18280
  options: {
@@ -17972,7 +18286,7 @@ async function statsCommand(args, io) {
17972
18286
  io.stderr("stats: provide at least one file or glob.");
17973
18287
  return 2;
17974
18288
  }
17975
- const files = await glob2(positionals, { absolute: true });
18289
+ const files = await glob4(positionals, { absolute: true });
17976
18290
  if (files.length === 0) {
17977
18291
  io.stderr(`stats: no files matched ${positionals.join(" ")}`);
17978
18292
  return 2;
@@ -18130,10 +18444,10 @@ var render_exports = {};
18130
18444
  __export(render_exports, {
18131
18445
  renderCommand: () => renderCommand
18132
18446
  });
18133
- import { readFile as readFile5 } from "node:fs/promises";
18134
- import { parseArgs as parseArgs5 } from "node:util";
18447
+ import { readFile as readFile6 } from "node:fs/promises";
18448
+ import { parseArgs as parseArgs7 } from "node:util";
18135
18449
  async function renderCommand(args, io) {
18136
- const { values, positionals } = parseArgs5({
18450
+ const { values, positionals } = parseArgs7({
18137
18451
  args,
18138
18452
  allowPositionals: true,
18139
18453
  options: {
@@ -18148,7 +18462,7 @@ async function renderCommand(args, io) {
18148
18462
  return 2;
18149
18463
  }
18150
18464
  const registry2 = await loadRegistry(values.registry);
18151
- const source = await readFile5(file2, "utf8");
18465
+ const source = await readFile6(file2, "utf8");
18152
18466
  const result = validateDocument(parseDocument(stripFrontmatter(source)), registry2);
18153
18467
  if (!result.ok) {
18154
18468
  for (const d of result.diagnostics) io.stderr(formatDiagnostic(d, file2));
@@ -18174,9 +18488,9 @@ var instructions_exports = {};
18174
18488
  __export(instructions_exports, {
18175
18489
  instructionsCommand: () => instructionsCommand
18176
18490
  });
18177
- import { parseArgs as parseArgs6 } from "node:util";
18491
+ import { parseArgs as parseArgs8 } from "node:util";
18178
18492
  async function instructionsCommand(args, io) {
18179
- const { values } = parseArgs6({
18493
+ const { values } = parseArgs8({
18180
18494
  args,
18181
18495
  options: {
18182
18496
  audience: { type: "string", default: "llm" },
@@ -18206,9 +18520,9 @@ var docs_exports = {};
18206
18520
  __export(docs_exports, {
18207
18521
  docsCommand: () => docsCommand
18208
18522
  });
18209
- import { parseArgs as parseArgs7 } from "node:util";
18523
+ import { parseArgs as parseArgs9 } from "node:util";
18210
18524
  async function docsCommand(args, io) {
18211
- const { values } = parseArgs7({
18525
+ const { values } = parseArgs9({
18212
18526
  args,
18213
18527
  options: {
18214
18528
  registry: { type: "string" },
@@ -18229,11 +18543,11 @@ var init_docs = __esm({
18229
18543
  });
18230
18544
 
18231
18545
  // src/links-io.ts
18232
- import { readFile as readFile6 } from "node:fs/promises";
18546
+ import { readFile as readFile7 } from "node:fs/promises";
18233
18547
  async function collectLinkInputs(files) {
18234
18548
  const inputs = [];
18235
18549
  for (const path of files) {
18236
- const source = await readFile6(path, "utf8");
18550
+ const source = await readFile7(path, "utf8");
18237
18551
  const fm = extractFrontmatter(source);
18238
18552
  inputs.push({ path, data: fm?.data ?? {} });
18239
18553
  }
@@ -18251,12 +18565,12 @@ var links_exports = {};
18251
18565
  __export(links_exports, {
18252
18566
  linksCommand: () => linksCommand
18253
18567
  });
18254
- import { mkdir as mkdir3, readFile as readFile7 } from "node:fs/promises";
18568
+ import { mkdir as mkdir3, readFile as readFile8 } from "node:fs/promises";
18255
18569
  import { dirname, join as join3 } from "node:path";
18256
- import { parseArgs as parseArgs8 } from "node:util";
18257
- import { glob as glob3 } from "tinyglobby";
18570
+ import { parseArgs as parseArgs10 } from "node:util";
18571
+ import { glob as glob5 } from "tinyglobby";
18258
18572
  async function linksCommand(args, io) {
18259
- const { values, positionals } = parseArgs8({
18573
+ const { values, positionals } = parseArgs10({
18260
18574
  args,
18261
18575
  allowPositionals: true,
18262
18576
  options: {
@@ -18273,7 +18587,7 @@ async function linksCommand(args, io) {
18273
18587
  io.stderr("links: provide at least one file or glob.");
18274
18588
  return 2;
18275
18589
  }
18276
- const files = (await glob3(positionals, { absolute: true })).sort();
18590
+ const files = (await glob5(positionals, { absolute: true })).sort();
18277
18591
  if (files.length === 0) {
18278
18592
  io.stderr(`links: no files matched ${positionals.join(" ")}`);
18279
18593
  return 2;
@@ -18292,7 +18606,7 @@ async function linksCommand(args, io) {
18292
18606
  io.stderr("links: --fix skipped because link errors must be resolved first.");
18293
18607
  } else if (values.fix && index.aliases.size > 0) {
18294
18608
  for (const file2 of files) {
18295
- const source = await readFile7(file2, "utf8");
18609
+ const source = await readFile8(file2, "utf8");
18296
18610
  const fm = extractFrontmatter(source);
18297
18611
  if (!fm) continue;
18298
18612
  const lines = source.split("\n");
@@ -18344,20 +18658,24 @@ var init_links2 = __esm({
18344
18658
  });
18345
18659
 
18346
18660
  // src/run.ts
18347
- var USAGE = `Usage: contentbit <init|validate|stats|render|instructions|docs|agents|links> [options]
18661
+ var USAGE = `Usage: contentbit <init|validate|doctor|studio|stats|render|instructions|docs|agents|links> [options]
18348
18662
 
18349
18663
  init [-t react|html|markdown|astro] [--md ...] [-y] [--no-install] [--no-page] [--no-agents]
18350
18664
  agents [--claude] [--no-agents-md]
18351
18665
 
18352
- validate <globs...> [--registry <module.mjs>] [--strict-warnings] [--link-resolve <mode>]
18353
- stats <globs...> [--registry <module.mjs>] [--no-validate]
18354
- render <file> --target html|markdown [--registry <module.mjs>] [--out <file>]
18355
- instructions [--audience llm|human] [--no-examples] [--registry <module.mjs>] [--out <file>]
18356
- docs [--registry <module.mjs>] [--out <file>]
18666
+ validate <globs...> [--registry <module.ts>] [--strict-warnings] [--link-resolve <mode>]
18667
+ doctor <globs...> [--registry <module.ts>] [--strict-warnings] [--json] [--min-section-words <n>] [--link-resolve <mode>]
18668
+ studio <globs...> [--registry <module.ts>] [--port <n>] [--host <host>] [--no-open] [--link-resolve <mode>]
18669
+ stats <globs...> [--registry <module.ts>] [--no-validate]
18670
+ render <file> --target html|markdown [--registry <module.ts>] [--out <file>]
18671
+ instructions [--audience llm|human] [--no-examples] [--registry <module.ts>] [--out <file>]
18672
+ docs [--registry <module.ts>] [--out <file>]
18357
18673
  links <globs...> [--fix] [--out <file>] [--link-resolve <mode>]`;
18358
18674
  var commands = {
18359
18675
  init: async () => (await Promise.resolve().then(() => (init_init(), init_exports))).initCommand,
18360
18676
  validate: async () => (await Promise.resolve().then(() => (init_validate2(), validate_exports))).validateCommand,
18677
+ doctor: async () => (await Promise.resolve().then(() => (init_doctor(), doctor_exports))).doctorCommand,
18678
+ studio: async () => (await Promise.resolve().then(() => (init_studio(), studio_exports))).studioCommand,
18361
18679
  stats: async () => (await Promise.resolve().then(() => (init_stats(), stats_exports))).statsCommand,
18362
18680
  render: async () => (await Promise.resolve().then(() => (init_render2(), render_exports))).renderCommand,
18363
18681
  instructions: async () => (await Promise.resolve().then(() => (init_instructions(), instructions_exports))).instructionsCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentbit",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "CLI for Content Blocks: validate, render, and generate LLM authoring instructions from your registry.",
5
5
  "keywords": [
6
6
  "cli",
@@ -37,9 +37,10 @@
37
37
  "dependencies": {
38
38
  "@clack/prompts": "^1.5.1",
39
39
  "tinyglobby": "^0.2.10",
40
- "@contentbit/blocks": "0.3.0",
41
- "@contentbit/core": "0.3.0",
42
- "@contentbit/html": "0.3.0"
40
+ "@contentbit/blocks": "0.4.1",
41
+ "@contentbit/core": "0.4.1",
42
+ "@contentbit/html": "0.4.1",
43
+ "@contentbit/studio": "0.4.1"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/node": "^25.0.9",