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/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/dist/commands/agents.js
CHANGED
|
@@ -7,7 +7,7 @@ import { parseArgs } from 'node:util';
|
|
|
7
7
|
// registry stays the single source of truth and nothing can drift. Bump the
|
|
8
8
|
// frontmatter version when a template changes; `contentbit agents` re-runs
|
|
9
9
|
// overwrite in place.
|
|
10
|
-
const TEMPLATE_VERSION =
|
|
10
|
+
const TEMPLATE_VERSION = 3;
|
|
11
11
|
const AUTHOR_SKILL = `---
|
|
12
12
|
name: contentbit-author
|
|
13
13
|
description: |
|
|
@@ -100,32 +100,37 @@ version: ${TEMPLATE_VERSION}
|
|
|
100
100
|
|
|
101
101
|
# Auditing contentbit content
|
|
102
102
|
|
|
103
|
-
\`contentbit
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
\`contentbit doctor\` is the first audit command. It reads content once, runs
|
|
104
|
+
block validation, link validation, and document stats, then prints a ranked
|
|
105
|
+
repair plan. It is read-only: it does not write the link index and never edits
|
|
106
|
+
source files. \`contentbit stats\` remains useful when you need raw JSON metrics.
|
|
107
|
+
\`contentbit links\` builds the frontmatter-authored internal-link graph and can
|
|
108
|
+
heal alias references with \`--fix\`.
|
|
107
109
|
|
|
108
110
|
## Gather
|
|
109
111
|
|
|
110
|
-
Check \`package.json\` for
|
|
111
|
-
|
|
112
|
+
Check \`package.json\` for \`content:doctor\` first. If it exists, run it. If it
|
|
113
|
+
does not, use \`content:check\` to find this project's content glob and
|
|
114
|
+
\`--registry\` flag, then run:
|
|
112
115
|
|
|
113
116
|
\`\`\`sh
|
|
117
|
+
contentbit doctor "content/**/*.md" [--registry <path>]
|
|
118
|
+
contentbit doctor "content/**/*.md" [--registry <path>] --json
|
|
114
119
|
contentbit stats "content/**/*.md" [--registry <path>]
|
|
115
120
|
contentbit links "content/**/*.md"
|
|
116
121
|
\`\`\`
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
per-section word counts, \`blocks.byName\` usage counts,
|
|
121
|
-
a \`validation\` summary (\`errors\`/\`warnings\`).
|
|
122
|
-
\`contentbit links\`
|
|
123
|
-
|
|
123
|
+
\`doctor --json\` prints a stable report with summary counts and ranked
|
|
124
|
+
findings. \`stats\` prints per-file metrics: frontmatter data, a heading
|
|
125
|
+
\`outline\` with per-section word counts, \`blocks.byName\` usage counts,
|
|
126
|
+
\`links.domains\`, and a \`validation\` summary (\`errors\`/\`warnings\`).
|
|
127
|
+
\`contentbit links\` writes \`.contentbit/link-index.json\`, whose pages contain
|
|
128
|
+
\`slug\`, resolved \`linksTo\`, derived \`linkedFrom\`, \`aliases\`, and
|
|
124
129
|
\`keywords\`.
|
|
125
130
|
|
|
126
131
|
## Interpret
|
|
127
132
|
|
|
128
|
-
Prioritize findings in
|
|
133
|
+
Prioritize findings in the order \`doctor\` reports them:
|
|
129
134
|
|
|
130
135
|
1. **Validation errors and warnings** — broken content ships broken pages.
|
|
131
136
|
2. **Internal-link errors** — unresolved links, duplicate slugs, and alias
|
|
@@ -171,10 +176,14 @@ When writing or editing content:
|
|
|
171
176
|
|
|
172
177
|
When auditing content health:
|
|
173
178
|
|
|
174
|
-
- \`contentbit
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
- \`contentbit doctor "content/**/*.md" [--registry <path>]\` prints a ranked,
|
|
180
|
+
read-only repair plan: validation issues, link issues, thin sections,
|
|
181
|
+
block-less long documents, and missing image alt text.
|
|
182
|
+
- \`contentbit doctor "content/**/*.md" [--registry <path>] --json\` prints the
|
|
183
|
+
same findings as structured JSON for agents and CI.
|
|
184
|
+
- \`contentbit stats "content/**/*.md" [--registry <path>]\` prints raw JSON
|
|
185
|
+
stats: outline word counts, block usage, link domains, and validation
|
|
186
|
+
error/warning counts.
|
|
178
187
|
- \`contentbit links "content/**/*.md" [--fix]\` builds
|
|
179
188
|
\`.contentbit/link-index.json\`, reports dangling links/orphans, and rewrites
|
|
180
189
|
alias references in \`linksTo\` when \`--fix\` is used.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AA4BnC,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkH3E"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { analyzeDocument, buildLinkIndex, extractFrontmatter, parseDocument, stripFrontmatter, validateDocument, validateLinks, } from '@contentbit/core';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { glob } from 'tinyglobby';
|
|
5
|
+
import { linkResolverOptions } from '../link-options.js';
|
|
6
|
+
import { loadRegistry } from '../load-registry.js';
|
|
7
|
+
const DEFAULT_MIN_SECTION_WORDS = 25;
|
|
8
|
+
const BLOCKLESS_WORDS = 250;
|
|
9
|
+
export async function doctorCommand(args, io) {
|
|
10
|
+
const { values, positionals } = parseArgs({
|
|
11
|
+
args,
|
|
12
|
+
allowPositionals: true,
|
|
13
|
+
options: {
|
|
14
|
+
registry: { type: 'string' },
|
|
15
|
+
'strict-warnings': { type: 'boolean', default: false },
|
|
16
|
+
json: { type: 'boolean', default: false },
|
|
17
|
+
'min-section-words': { type: 'string' },
|
|
18
|
+
'link-resolve': { type: 'string' },
|
|
19
|
+
'locale-field': { type: 'string' },
|
|
20
|
+
'slug-field': { type: 'string' },
|
|
21
|
+
'key-field': { type: 'string' },
|
|
22
|
+
'default-locale': { type: 'string' },
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
if (positionals.length === 0) {
|
|
26
|
+
io.stderr('doctor: provide at least one file or glob.');
|
|
27
|
+
return 2;
|
|
28
|
+
}
|
|
29
|
+
const minSectionWords = parseMinSectionWords(values['min-section-words']);
|
|
30
|
+
if (minSectionWords === null) {
|
|
31
|
+
io.stderr('doctor: --min-section-words must be a non-negative integer.');
|
|
32
|
+
return 2;
|
|
33
|
+
}
|
|
34
|
+
const files = (await glob(positionals, { absolute: true })).sort();
|
|
35
|
+
if (files.length === 0) {
|
|
36
|
+
io.stderr(`doctor: no files matched ${positionals.join(' ')}`);
|
|
37
|
+
return 2;
|
|
38
|
+
}
|
|
39
|
+
const registry = await loadRegistry(values.registry);
|
|
40
|
+
const linkOptions = linkResolverOptions(values);
|
|
41
|
+
const findings = [];
|
|
42
|
+
const linkInputs = [];
|
|
43
|
+
for (const file of files) {
|
|
44
|
+
const source = await readFile(file, 'utf8');
|
|
45
|
+
const frontmatter = extractFrontmatter(source);
|
|
46
|
+
linkInputs.push({ path: file, data: frontmatter?.data ?? {} });
|
|
47
|
+
const validation = validateDocument(parseDocument(stripFrontmatter(source)), registry);
|
|
48
|
+
for (const diagnostic of validation.diagnostics) {
|
|
49
|
+
findings.push(findingFromDiagnostic('validation', file, diagnostic));
|
|
50
|
+
}
|
|
51
|
+
const stats = analyzeDocument(source, { path: file });
|
|
52
|
+
for (const section of stats.outline) {
|
|
53
|
+
if (section.words < minSectionWords) {
|
|
54
|
+
findings.push({
|
|
55
|
+
severity: 'info',
|
|
56
|
+
source: 'stats',
|
|
57
|
+
code: 'CB_THIN_SECTION',
|
|
58
|
+
file,
|
|
59
|
+
line: section.line,
|
|
60
|
+
column: 1,
|
|
61
|
+
message: `section "${section.text}" has ${section.words} words`,
|
|
62
|
+
hint: `Add detail or merge it with a nearby section. Threshold: ${minSectionWords} words.`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (stats.length.words >= BLOCKLESS_WORDS && stats.blocks.total === 0) {
|
|
67
|
+
findings.push({
|
|
68
|
+
severity: 'info',
|
|
69
|
+
source: 'stats',
|
|
70
|
+
code: 'CB_BLOCKLESS_DOCUMENT',
|
|
71
|
+
file,
|
|
72
|
+
message: `document has ${stats.length.words} words and no structured blocks`,
|
|
73
|
+
hint: 'Consider a callout, steps, comparison, FAQ, or another registered block if it clarifies the page.',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (stats.images.missingAlt > 0) {
|
|
77
|
+
findings.push({
|
|
78
|
+
severity: 'info',
|
|
79
|
+
source: 'stats',
|
|
80
|
+
code: 'CB_IMAGE_ALT_MISSING',
|
|
81
|
+
file,
|
|
82
|
+
message: `${stats.images.missingAlt} image(s) are missing alt text`,
|
|
83
|
+
hint: 'Add descriptive alt text for meaningful images; use empty alt only for decorative images.',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let linkGraph;
|
|
88
|
+
if (hasLinkFrontmatter(linkInputs, linkOptions.slugField)) {
|
|
89
|
+
for (const { file, diagnostic } of validateLinks(linkInputs, linkOptions)) {
|
|
90
|
+
findings.push(findingFromDiagnostic('links', file, diagnostic));
|
|
91
|
+
}
|
|
92
|
+
const index = buildLinkIndex(linkInputs, linkOptions);
|
|
93
|
+
let links = 0;
|
|
94
|
+
for (const page of index.pages.values())
|
|
95
|
+
links += page.linksTo.length;
|
|
96
|
+
linkGraph = {
|
|
97
|
+
pages: index.pages.size,
|
|
98
|
+
links,
|
|
99
|
+
orphans: [...index.pages.values()].filter((page) => page.linkedFrom.length === 0).length,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
findings.sort(compareFindings);
|
|
103
|
+
const report = {
|
|
104
|
+
files: files.length,
|
|
105
|
+
summary: summarize(findings),
|
|
106
|
+
...(linkGraph ? { linkGraph } : {}),
|
|
107
|
+
findings,
|
|
108
|
+
};
|
|
109
|
+
if (values.json)
|
|
110
|
+
io.stdout(JSON.stringify(report, null, 2));
|
|
111
|
+
else
|
|
112
|
+
io.stdout(formatReport(report, positionals, values.registry, hasAliases(linkInputs)));
|
|
113
|
+
if (report.summary.errors > 0)
|
|
114
|
+
return 1;
|
|
115
|
+
if (report.summary.warnings > 0 && values['strict-warnings'])
|
|
116
|
+
return 1;
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
function parseMinSectionWords(value) {
|
|
120
|
+
if (value === undefined)
|
|
121
|
+
return DEFAULT_MIN_SECTION_WORDS;
|
|
122
|
+
if (!/^\d+$/.test(value))
|
|
123
|
+
return null;
|
|
124
|
+
return Number(value);
|
|
125
|
+
}
|
|
126
|
+
function findingFromDiagnostic(source, file, diagnostic) {
|
|
127
|
+
return {
|
|
128
|
+
severity: diagnostic.severity,
|
|
129
|
+
source,
|
|
130
|
+
code: diagnostic.code,
|
|
131
|
+
file,
|
|
132
|
+
line: diagnostic.position.start.line,
|
|
133
|
+
column: diagnostic.position.start.column,
|
|
134
|
+
message: diagnostic.message,
|
|
135
|
+
...(diagnostic.hint ? { hint: diagnostic.hint } : {}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function hasLinkFrontmatter(inputs, configuredSlugField) {
|
|
139
|
+
const slugField = configuredSlugField ?? 'slug';
|
|
140
|
+
return inputs.some((input) => Object.prototype.hasOwnProperty.call(input.data, slugField));
|
|
141
|
+
}
|
|
142
|
+
function hasAliases(inputs) {
|
|
143
|
+
return inputs.some((input) => Array.isArray(input.data.aliases) && input.data.aliases.length > 0);
|
|
144
|
+
}
|
|
145
|
+
function summarize(findings) {
|
|
146
|
+
return {
|
|
147
|
+
errors: findings.filter((f) => f.severity === 'error').length,
|
|
148
|
+
warnings: findings.filter((f) => f.severity === 'warning').length,
|
|
149
|
+
suggestions: findings.filter((f) => f.severity === 'info').length,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function compareFindings(a, b) {
|
|
153
|
+
return (rank(a) - rank(b) ||
|
|
154
|
+
a.file.localeCompare(b.file) ||
|
|
155
|
+
(a.line ?? 0) - (b.line ?? 0) ||
|
|
156
|
+
(a.column ?? 0) - (b.column ?? 0) ||
|
|
157
|
+
a.code.localeCompare(b.code));
|
|
158
|
+
}
|
|
159
|
+
function rank(finding) {
|
|
160
|
+
if (finding.severity === 'error' && finding.source === 'validation')
|
|
161
|
+
return 0;
|
|
162
|
+
if (finding.severity === 'error' && finding.source === 'links')
|
|
163
|
+
return 1;
|
|
164
|
+
if (finding.severity === 'warning')
|
|
165
|
+
return 2;
|
|
166
|
+
if (finding.code === 'CB_THIN_SECTION')
|
|
167
|
+
return 3;
|
|
168
|
+
if (finding.code === 'CB_BLOCKLESS_DOCUMENT')
|
|
169
|
+
return 4;
|
|
170
|
+
if (finding.code === 'CB_IMAGE_ALT_MISSING')
|
|
171
|
+
return 5;
|
|
172
|
+
return 6;
|
|
173
|
+
}
|
|
174
|
+
function formatReport(report, globs, registryPath, aliasFixMayApply) {
|
|
175
|
+
const lines = [];
|
|
176
|
+
lines.push('contentbit doctor');
|
|
177
|
+
lines.push(`${report.files} file(s): ${report.summary.errors} errors, ${report.summary.warnings} warnings, ${report.summary.suggestions} suggestions`);
|
|
178
|
+
if (report.linkGraph) {
|
|
179
|
+
lines.push(`${report.linkGraph.pages} linked page(s), ${report.linkGraph.links} link(s), ${report.linkGraph.orphans} orphan(s)`);
|
|
180
|
+
}
|
|
181
|
+
lines.push('');
|
|
182
|
+
if (report.findings.length === 0) {
|
|
183
|
+
lines.push('No findings. Content looks healthy.');
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
lines.push('Repair plan:');
|
|
187
|
+
report.findings.forEach((finding, index) => {
|
|
188
|
+
lines.push(`${index + 1}. ${formatFinding(finding)}`);
|
|
189
|
+
if (finding.hint)
|
|
190
|
+
lines.push(` hint: ${finding.hint}`);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
lines.push('');
|
|
194
|
+
lines.push('Next commands:');
|
|
195
|
+
lines.push(`- contentbit validate ${formatGlobs(globs)}${registryPath ? ` --registry ${formatArg(registryPath)}` : ''}`);
|
|
196
|
+
if (report.linkGraph) {
|
|
197
|
+
lines.push(`- contentbit links ${formatGlobs(globs)}`);
|
|
198
|
+
if (aliasFixMayApply && report.summary.errors === 0)
|
|
199
|
+
lines.push(`- contentbit links ${formatGlobs(globs)} --fix`);
|
|
200
|
+
}
|
|
201
|
+
lines.push(`- contentbit doctor ${formatGlobs(globs)} --json`);
|
|
202
|
+
return lines.join('\n');
|
|
203
|
+
}
|
|
204
|
+
function formatFinding(finding) {
|
|
205
|
+
const location = finding.line !== undefined && finding.column !== undefined
|
|
206
|
+
? `${finding.file}:${finding.line}:${finding.column}`
|
|
207
|
+
: finding.file;
|
|
208
|
+
return `[${finding.severity}] ${finding.source} ${finding.code} ${location} - ${finding.message}`;
|
|
209
|
+
}
|
|
210
|
+
function formatGlobs(globs) {
|
|
211
|
+
return globs.map(formatArg).join(' ');
|
|
212
|
+
}
|
|
213
|
+
function formatArg(value) {
|
|
214
|
+
return /\s/.test(value) ? JSON.stringify(value) : value;
|
|
215
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAianC,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAianC,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAqPzE"}
|
package/dist/commands/init.js
CHANGED
|
@@ -565,7 +565,19 @@ export async function initCommand(args, io) {
|
|
|
565
565
|
fresh.scripts['content:links'] = 'contentbit links "content/**/*.md"';
|
|
566
566
|
io.stdout('added script: content:links');
|
|
567
567
|
}
|
|
568
|
-
if (!
|
|
568
|
+
if (!fresh.scripts['content:doctor']) {
|
|
569
|
+
fresh.scripts['content:doctor'] =
|
|
570
|
+
'contentbit doctor "content/**/*.md" --registry ./blocks/registry.ts';
|
|
571
|
+
io.stdout('added script: content:doctor');
|
|
572
|
+
}
|
|
573
|
+
if (!fresh.scripts.studio) {
|
|
574
|
+
fresh.scripts.studio = 'contentbit studio "content/**/*.md" --registry ./blocks/registry.ts';
|
|
575
|
+
io.stdout('added script: studio');
|
|
576
|
+
}
|
|
577
|
+
if (!pkg.scripts?.['content:check'] ||
|
|
578
|
+
!pkg.scripts?.['content:links'] ||
|
|
579
|
+
!pkg.scripts?.['content:doctor'] ||
|
|
580
|
+
!pkg.scripts?.studio) {
|
|
569
581
|
await writeFile(pkgPath, `${JSON.stringify(fresh, null, 2)}\n`, 'utf8');
|
|
570
582
|
}
|
|
571
583
|
// Generate the LLM authoring guide from the registry, ready to paste into a prompt.
|
|
@@ -589,7 +601,9 @@ export async function initCommand(args, io) {
|
|
|
589
601
|
}
|
|
590
602
|
io.stdout('');
|
|
591
603
|
io.stdout('Done. Next steps:');
|
|
592
|
-
io.stdout(` 1.
|
|
604
|
+
io.stdout(` 1. Browse content locally: ${detectPackageManager(cwd)} run studio`);
|
|
605
|
+
io.stdout(` Inspect content health: ${detectPackageManager(cwd)} run content:doctor`);
|
|
606
|
+
io.stdout(` Validate the starter content: ${detectPackageManager(cwd)} run content:check`);
|
|
593
607
|
io.stdout(` Build the link index: ${detectPackageManager(cwd)} run content:links`);
|
|
594
608
|
if (target === 'react') {
|
|
595
609
|
if (!values['no-page'] && layout.pagePath) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../src/commands/studio.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAiE3E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { glob } from 'tinyglobby';
|
|
3
|
+
import { linkResolverOptions } from '../link-options.js';
|
|
4
|
+
export async function studioCommand(args, io) {
|
|
5
|
+
const { values, positionals } = parseArgs({
|
|
6
|
+
args,
|
|
7
|
+
allowPositionals: true,
|
|
8
|
+
options: {
|
|
9
|
+
registry: { type: 'string' },
|
|
10
|
+
port: { type: 'string' },
|
|
11
|
+
host: { type: 'string' },
|
|
12
|
+
'no-open': { type: 'boolean', default: false },
|
|
13
|
+
'min-section-words': { type: 'string' },
|
|
14
|
+
'link-resolve': { type: 'string' },
|
|
15
|
+
'locale-field': { type: 'string' },
|
|
16
|
+
'slug-field': { type: 'string' },
|
|
17
|
+
'key-field': { type: 'string' },
|
|
18
|
+
'default-locale': { type: 'string' },
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
if (positionals.length === 0) {
|
|
22
|
+
io.stderr('studio: provide at least one file or glob.');
|
|
23
|
+
return 2;
|
|
24
|
+
}
|
|
25
|
+
const port = parsePort(values.port);
|
|
26
|
+
if (port === null) {
|
|
27
|
+
io.stderr('studio: --port must be an integer between 0 and 65535.');
|
|
28
|
+
return 2;
|
|
29
|
+
}
|
|
30
|
+
const minSectionWords = parseMinSectionWords(values['min-section-words']);
|
|
31
|
+
if (minSectionWords === null) {
|
|
32
|
+
io.stderr('studio: --min-section-words must be a non-negative integer.');
|
|
33
|
+
return 2;
|
|
34
|
+
}
|
|
35
|
+
const files = await glob(positionals, { absolute: true });
|
|
36
|
+
if (files.length === 0) {
|
|
37
|
+
io.stderr(`studio: no files matched ${positionals.join(' ')}`);
|
|
38
|
+
return 2;
|
|
39
|
+
}
|
|
40
|
+
const { startStudio } = (await import('@contentbit/studio'));
|
|
41
|
+
const server = await startStudio({
|
|
42
|
+
globs: positionals,
|
|
43
|
+
registryPath: values.registry,
|
|
44
|
+
host: values.host,
|
|
45
|
+
...(port !== undefined ? { port } : {}),
|
|
46
|
+
open: !values['no-open'],
|
|
47
|
+
linkOptions: linkResolverOptions(values),
|
|
48
|
+
minSectionWords,
|
|
49
|
+
});
|
|
50
|
+
io.stdout(`contentbit studio running at ${server.url}`);
|
|
51
|
+
io.stdout('Press Ctrl+C to stop.');
|
|
52
|
+
const close = () => {
|
|
53
|
+
void server.close();
|
|
54
|
+
};
|
|
55
|
+
process.once('SIGINT', close);
|
|
56
|
+
process.once('SIGTERM', close);
|
|
57
|
+
await server.closed;
|
|
58
|
+
process.off('SIGINT', close);
|
|
59
|
+
process.off('SIGTERM', close);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
function parsePort(value) {
|
|
63
|
+
if (value === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
if (!/^\d+$/.test(value))
|
|
66
|
+
return null;
|
|
67
|
+
const port = Number(value);
|
|
68
|
+
return port >= 0 && port <= 65535 ? port : null;
|
|
69
|
+
}
|
|
70
|
+
function parseMinSectionWords(value) {
|
|
71
|
+
if (value === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
if (!/^\d+$/.test(value))
|
|
74
|
+
return null;
|
|
75
|
+
return Number(value);
|
|
76
|
+
}
|
package/dist/run.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export interface Io {
|
|
|
3
3
|
stderr(line: string): void;
|
|
4
4
|
writeFile(path: string, content: string): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
export declare const USAGE = "Usage: contentbit <init|validate|stats|render|instructions|docs|agents|links> [options]\n\n init [-t react|html|markdown|astro] [--md ...] [-y] [--no-install] [--no-page] [--no-agents]\n agents [--claude] [--no-agents-md]\n\n validate <globs...> [--registry <module.
|
|
6
|
+
export declare const USAGE = "Usage: contentbit <init|validate|doctor|studio|stats|render|instructions|docs|agents|links> [options]\n\n init [-t react|html|markdown|astro] [--md ...] [-y] [--no-install] [--no-page] [--no-agents]\n agents [--claude] [--no-agents-md]\n\n validate <globs...> [--registry <module.ts>] [--strict-warnings] [--link-resolve <mode>]\n doctor <globs...> [--registry <module.ts>] [--strict-warnings] [--json] [--min-section-words <n>] [--link-resolve <mode>]\n studio <globs...> [--registry <module.ts>] [--port <n>] [--host <host>] [--no-open] [--link-resolve <mode>]\n stats <globs...> [--registry <module.ts>] [--no-validate]\n render <file> --target html|markdown [--registry <module.ts>] [--out <file>]\n instructions [--audience llm|human] [--no-examples] [--registry <module.ts>] [--out <file>]\n docs [--registry <module.ts>] [--out <file>]\n links <globs...> [--fix] [--out <file>] [--link-resolve <mode>]";
|
|
7
7
|
export declare function run(argv: string[], io: Io): Promise<number>;
|
|
8
8
|
//# sourceMappingURL=run.d.ts.map
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,EAAE;IACjB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxD;AAED,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,EAAE;IACjB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxD;AAED,eAAO,MAAM,KAAK,25BAYgD,CAAA;AAiBlE,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAcjE"}
|