contentbit 0.4.2 → 0.6.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.
Files changed (57) hide show
  1. package/README.md +20 -2
  2. package/dist/bin.js +8183 -3889
  3. package/dist/cli-format.d.ts +17 -0
  4. package/dist/cli-format.d.ts.map +1 -0
  5. package/dist/cli-format.js +63 -0
  6. package/dist/commands/agents.d.ts +6 -1
  7. package/dist/commands/agents.d.ts.map +1 -1
  8. package/dist/commands/agents.js +13 -201
  9. package/dist/commands/brief.d.ts +12 -0
  10. package/dist/commands/brief.d.ts.map +1 -0
  11. package/dist/commands/brief.js +52 -0
  12. package/dist/commands/docs.d.ts +6 -1
  13. package/dist/commands/docs.d.ts.map +1 -1
  14. package/dist/commands/docs.js +5 -11
  15. package/dist/commands/doctor.d.ts +13 -1
  16. package/dist/commands/doctor.d.ts.map +1 -1
  17. package/dist/commands/doctor.js +124 -166
  18. package/dist/commands/init-targets.d.ts +27 -0
  19. package/dist/commands/init-targets.d.ts.map +1 -0
  20. package/dist/commands/init-targets.js +280 -0
  21. package/dist/commands/init.d.ts +12 -1
  22. package/dist/commands/init.d.ts.map +1 -1
  23. package/dist/commands/init.js +92 -340
  24. package/dist/commands/instructions.d.ts +8 -1
  25. package/dist/commands/instructions.d.ts.map +1 -1
  26. package/dist/commands/instructions.js +7 -15
  27. package/dist/commands/links.d.ts +7 -1
  28. package/dist/commands/links.d.ts.map +1 -1
  29. package/dist/commands/links.js +24 -37
  30. package/dist/commands/render.d.ts +8 -1
  31. package/dist/commands/render.d.ts.map +1 -1
  32. package/dist/commands/render.js +19 -24
  33. package/dist/commands/stats.d.ts +7 -1
  34. package/dist/commands/stats.d.ts.map +1 -1
  35. package/dist/commands/stats.js +28 -39
  36. package/dist/commands/studio.d.ts +13 -1
  37. package/dist/commands/studio.d.ts.map +1 -1
  38. package/dist/commands/studio.js +28 -39
  39. package/dist/commands/validate.d.ts +8 -1
  40. package/dist/commands/validate.d.ts.map +1 -1
  41. package/dist/commands/validate.js +39 -56
  42. package/dist/content-project.d.ts +12 -0
  43. package/dist/content-project.d.ts.map +1 -0
  44. package/dist/content-project.js +25 -0
  45. package/dist/link-options.d.ts +5 -0
  46. package/dist/link-options.d.ts.map +1 -1
  47. package/dist/link-options.js +5 -5
  48. package/dist/load-registry.d.ts +1 -3
  49. package/dist/load-registry.d.ts.map +1 -1
  50. package/dist/load-registry.js +1 -24
  51. package/dist/run.d.ts +10 -1
  52. package/dist/run.d.ts.map +1 -1
  53. package/dist/run.js +9603 -5307
  54. package/dist/seo-config.d.ts +12 -0
  55. package/dist/seo-config.d.ts.map +1 -0
  56. package/dist/seo-config.js +21 -0
  57. package/package.json +6 -5
@@ -0,0 +1,17 @@
1
+ import type { Diagnostic, Severity } from '@contentbit/core';
2
+ type Tone = 'error' | 'warning' | 'info' | 'success' | 'muted';
3
+ interface Row {
4
+ label: string;
5
+ value: string | number;
6
+ tone?: Tone;
7
+ }
8
+ export declare function color(text: string, tone: Tone | 'bold'): string;
9
+ export declare function section(title: string): string;
10
+ export declare function formatRows(rows: Row[]): string[];
11
+ export declare function formatCommandList(commands: string[]): string[];
12
+ export declare function formatDiagnosticForCli(diagnostic: Diagnostic, file: string): string;
13
+ export declare function displayPath(file: string): string;
14
+ export declare function severityLabel(severity: Severity): string;
15
+ export declare function severityTone(severity: Severity): Tone;
16
+ export {};
17
+ //# sourceMappingURL=cli-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-format.d.ts","sourceRoot":"","sources":["../src/cli-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG5D,KAAK,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;AAW9D,UAAU,GAAG;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAI/D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,CAQhD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE9D;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAExD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAIrD"}
@@ -0,0 +1,63 @@
1
+ import { isAbsolute, relative } from 'node:path';
2
+ const ANSI = {
3
+ bold: ['\u001b[1m', '\u001b[22m'],
4
+ error: ['\u001b[31m', '\u001b[39m'],
5
+ warning: ['\u001b[33m', '\u001b[39m'],
6
+ info: ['\u001b[36m', '\u001b[39m'],
7
+ success: ['\u001b[32m', '\u001b[39m'],
8
+ muted: ['\u001b[2m', '\u001b[22m'],
9
+ };
10
+ export function color(text, tone) {
11
+ if (!colorsEnabled())
12
+ return text;
13
+ const [open, close] = ANSI[tone];
14
+ return `${open}${text}${close}`;
15
+ }
16
+ export function section(title) {
17
+ return color(title, 'bold');
18
+ }
19
+ export function formatRows(rows) {
20
+ const width = Math.max(...rows.map((row) => row.label.length));
21
+ return rows.map((row) => {
22
+ const value = String(row.value);
23
+ return ` ${color(row.label.padEnd(width), 'muted')} ${row.tone ? color(value, row.tone) : value}`;
24
+ });
25
+ }
26
+ export function formatCommandList(commands) {
27
+ return commands.map((command) => ` ${color('$', 'muted')} ${command}`);
28
+ }
29
+ export function formatDiagnosticForCli(diagnostic, file) {
30
+ const location = `${displayPath(file)}:${diagnostic.position.start.line}:${diagnostic.position.start.column}`;
31
+ const lines = [
32
+ `${color(location, 'muted')} ${severityLabel(diagnostic.severity)} ${diagnostic.code}`,
33
+ ` ${diagnostic.message}`,
34
+ ];
35
+ if (diagnostic.hint)
36
+ lines.push(` ${color('hint', 'muted')} ${diagnostic.hint}`);
37
+ return lines.join('\n');
38
+ }
39
+ export function displayPath(file) {
40
+ const path = relative(process.cwd(), file);
41
+ if (path && !path.startsWith('..') && !isAbsolute(path))
42
+ return path;
43
+ return file;
44
+ }
45
+ export function severityLabel(severity) {
46
+ return color(severity, severityTone(severity));
47
+ }
48
+ export function severityTone(severity) {
49
+ if (severity === 'error')
50
+ return 'error';
51
+ if (severity === 'warning')
52
+ return 'warning';
53
+ return 'info';
54
+ }
55
+ function colorsEnabled() {
56
+ if (process.env.VITEST || process.env.NODE_ENV === 'test')
57
+ return false;
58
+ if ('NO_COLOR' in process.env || process.env.FORCE_COLOR === '0')
59
+ return false;
60
+ if (process.env.FORCE_COLOR)
61
+ return true;
62
+ return Boolean(process.stdout.isTTY);
63
+ }
@@ -7,5 +7,10 @@ export interface AgentOptions {
7
7
  }
8
8
  /** Install or refresh the agent integration. Shared by `agents` and `init`. */
9
9
  export declare function installAgentIntegration(cwd: string, options: AgentOptions, io: Io): Promise<void>;
10
- export declare function agentsCommand(args: string[], io: Io): Promise<number>;
10
+ export interface AgentsCommandInput {
11
+ claude?: boolean;
12
+ noAgentsMd?: boolean;
13
+ cwd?: string;
14
+ }
15
+ export declare function agentsCommand(input: AgentsCommandInput, io: Io): Promise<number>;
11
16
  //# sourceMappingURL=agents.d.ts.map
@@ -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;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"}
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AA6BnC,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,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAUtF"}
@@ -1,197 +1,17 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
- import { parseArgs } from 'node:util';
5
- // Everything here is static and project-independent by design: skills fetch
4
+ import agentsMdTemplate from './agent-templates/AGENTS.md?raw';
5
+ import auditSkill from './agent-templates/contentbit-audit/SKILL.md?raw';
6
+ import authorSkill from './agent-templates/contentbit-author/SKILL.md?raw';
7
+ // These templates are static and project-independent by design: skills fetch
6
8
  // live data (authoring guide, stats, diagnostics) by running the CLI, so the
7
9
  // registry stays the single source of truth and nothing can drift. Bump the
8
- // frontmatter version when a template changes; `contentbit agents` re-runs
9
- // overwrite in place.
10
- const TEMPLATE_VERSION = 3;
11
- const AUTHOR_SKILL = `---
12
- name: contentbit-author
13
- description: |
14
- Write or edit contentbit Markdown content (directive blocks like :::callout).
15
- Use when asked to create or modify content documents in a project that uses
16
- contentbit — blog posts, docs pages, changelogs, any Markdown covered by
17
- \`contentbit validate\`.
18
- version: ${TEMPLATE_VERSION}
19
- ---
20
-
21
- # Writing contentbit content
22
-
23
- contentbit documents are plain Markdown plus directive blocks
24
- (\`:::name{props} ... :::\`). Every block has a schema. Never guess block names,
25
- props, or body shapes — fetch the live guide from the project's registry first.
26
-
27
- ## Find the project conventions
28
-
29
- Check \`package.json\` for a \`content:check\` script. It holds the canonical
30
- validate invocation for this project: the content glob and, if present, the
31
- \`--registry <path>\` flag pointing at custom block definitions. Reuse both
32
- below. No script? Default to \`content/**/*.md\` with no \`--registry\` flag.
33
- If the project has a \`content:links\` script, use it for the internal-link
34
- index; otherwise run \`contentbit links <content glob>\` directly.
35
-
36
- ## The loop
37
-
38
- 1. **Fetch the authoring guide** (always — it covers this project's custom blocks):
39
-
40
- \`\`\`sh
41
- contentbit instructions --audience llm [--registry <path from content:check>]
42
- \`\`\`
43
-
44
- Read it before writing. It documents every available block: props, body
45
- shape, and when to use or avoid it.
46
-
47
- 2. **Write the document.** Plain Markdown everywhere; blocks only where the
48
- guide's use-when guidance fits. Keep frontmatter consistent with sibling
49
- documents in the same folder. If sibling documents use \`slug\`, \`linksTo\`,
50
- \`aliases\`, or \`keywords\`, run the link index first:
51
-
52
- \`\`\`sh
53
- contentbit links <content glob>
54
- \`\`\`
55
-
56
- Read \`.contentbit/link-index.json\` to pick existing slugs and related
57
- pages. Author only \`slug\`, \`linksTo\`, \`aliases\`, and \`keywords\` in
58
- frontmatter; never write derived \`linkedFrom\` into source files. When
59
- creating a linked page, include \`keywords.primary\` and
60
- \`keywords.secondary\` with search-intent phrases that would help future
61
- agents choose this page as a \`linksTo\` target.
62
-
63
- 3. **Validate and fix until clean:**
64
-
65
- \`\`\`sh
66
- contentbit validate <file> [--registry <path>]
67
- \`\`\`
68
-
69
- Diagnostics print to stderr as \`file:line:col severity CODE message\`, often
70
- with a \`hint:\` line suggesting the fix. Exit 0 means clean; exit 1 means
71
- errors remain. If the document has link frontmatter, validate the full
72
- content glob so cross-file links are checked against the whole graph. Fix
73
- every diagnostic and re-run. Never finish with a failing validate.
74
-
75
- 4. **Refresh internal links when present:**
76
-
77
- \`\`\`sh
78
- contentbit links <content glob> --fix
79
- \`\`\`
80
-
81
- \`--fix\` only rewrites \`linksTo\` values that point at known aliases. It
82
- does not invent links, remove aliases, or write backlinks. Re-run validate
83
- after it changes files.
84
-
85
- ## Failure modes
86
-
87
- - \`contentbit\` not found or no registry resolvable: the project is not set up.
88
- Say so and suggest \`npx contentbit@latest init\` — do not invent block syntax.
89
- - A block you want does not exist: use plain Markdown, or ask whether to define
90
- a custom block in the registry. Never emit an unregistered block name.
91
- `;
92
- const AUDIT_SKILL = `---
93
- name: contentbit-audit
94
- description: |
95
- Audit contentbit Markdown content health using document stats. Use when asked
96
- to audit, review, or find improvements across content — thin pages, missing
97
- structure, validation issues — in a project that uses contentbit.
98
- version: ${TEMPLATE_VERSION}
99
- ---
100
-
101
- # Auditing contentbit content
102
-
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\`.
109
-
110
- ## Gather
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:
115
-
116
- \`\`\`sh
117
- contentbit doctor "content/**/*.md" [--registry <path>]
118
- contentbit doctor "content/**/*.md" [--registry <path>] --json
119
- contentbit stats "content/**/*.md" [--registry <path>]
120
- contentbit links "content/**/*.md"
121
- \`\`\`
122
-
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
129
- \`keywords\`.
130
-
131
- ## Interpret
132
-
133
- Prioritize findings in the order \`doctor\` reports them:
134
-
135
- 1. **Validation errors and warnings** — broken content ships broken pages.
136
- 2. **Internal-link errors** — unresolved links, duplicate slugs, and alias
137
- conflicts from \`contentbit links\`.
138
- 3. **Orphans and self-links** — link warnings that point to isolated or noisy
139
- pages.
140
- 4. **Thin documents** — outline sections with very low word counts.
141
- 5. **Block-less documents** — \`blocks.byName\` empty where sibling documents
142
- use blocks; structure (steps, callouts, comparisons, faq) may be missing.
143
- 6. **Missing or inconsistent frontmatter** compared to sibling documents.
144
- 7. **Structural imbalance** — skipped heading levels, single-section walls of text.
145
-
146
- ## Report
147
-
148
- Report findings per file with concrete suggestions, ordered by priority. Do not
149
- edit files during the audit. To fix a finding, follow the contentbit-author
150
- skill (fetch the guide, edit, validate until clean) — offer that as a follow-up.
151
- `;
152
- const AGENTS_MD_BLOCK = `<!-- contentbit:start -->
153
-
154
- ## contentbit content (generated — edits inside this block are overwritten)
155
-
156
- This project validates Markdown content with contentbit. Documents are plain
157
- Markdown plus directive blocks (\`:::name{props} ... :::\`), each with a schema.
158
- The \`content:check\` script in package.json holds the canonical validate
159
- command — the content glob and the \`--registry\` flag — reuse its arguments.
160
- If the project has a \`content:links\` script, use it to build the internal-link
161
- index; otherwise run \`contentbit links <content glob>\`.
162
-
163
- When writing or editing content:
164
-
165
- 1. Fetch the live authoring guide first — never guess block syntax:
166
- \`contentbit instructions --audience llm [--registry <path>]\`
167
- 2. Write plain Markdown; use blocks where the guide's use-when guidance fits.
168
- 3. If sibling documents use \`slug\` / \`linksTo\`, read
169
- \`.contentbit/link-index.json\` from \`contentbit links <content glob>\` and
170
- author frontmatter links with existing slugs. When creating a linked page,
171
- include \`keywords.primary\` and \`keywords.secondary\` with search-intent
172
- phrases future agents can use to choose related pages.
173
- 4. Validate until clean (exit 0): \`contentbit validate <file> [--registry <path>]\`.
174
- Diagnostics print as \`file:line:col severity CODE message\` with fix hints.
175
- For link frontmatter, validate the full content glob so cross-file checks run.
176
-
177
- When auditing content health:
178
-
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.
187
- - \`contentbit links "content/**/*.md" [--fix]\` builds
188
- \`.contentbit/link-index.json\`, reports dangling links/orphans, and rewrites
189
- alias references in \`linksTo\` when \`--fix\` is used.
190
-
191
- If \`contentbit\` is unavailable, suggest \`npx contentbit@latest init\` instead
192
- of inventing block syntax.
193
-
194
- <!-- contentbit:end -->`;
10
+ // frontmatter version in each SKILL.md when a template changes; `contentbit
11
+ // agents` re-runs overwrite in place.
12
+ const AUTHOR_SKILL = authorSkill;
13
+ const AUDIT_SKILL = auditSkill;
14
+ const AGENTS_MD_BLOCK = agentsMdTemplate.trimEnd();
195
15
  const START = '<!-- contentbit:start -->';
196
16
  const END = '<!-- contentbit:end -->';
197
17
  /** Insert or replace the fenced contentbit block, leaving the rest untouched. */
@@ -235,18 +55,10 @@ export async function installAgentIntegration(cwd, options, io) {
235
55
  }
236
56
  }
237
57
  }
238
- export async function agentsCommand(args, io) {
239
- const { values } = parseArgs({
240
- args,
241
- options: {
242
- claude: { type: 'boolean', default: false },
243
- 'no-agents-md': { type: 'boolean', default: false },
244
- cwd: { type: 'string', default: process.cwd() },
245
- },
246
- });
247
- await installAgentIntegration(values.cwd, {
248
- claude: values.claude || undefined, // false means "detect", not "skip"
249
- agentsMd: !values['no-agents-md'],
58
+ export async function agentsCommand(input, io) {
59
+ await installAgentIntegration(input.cwd ?? process.cwd(), {
60
+ claude: input.claude || undefined, // false means "detect", not "skip"
61
+ agentsMd: !input.noAgentsMd,
250
62
  }, io);
251
63
  return 0;
252
64
  }
@@ -0,0 +1,12 @@
1
+ import type { Io } from '../run.js';
2
+ import { type LinkOptionValues } from '../link-options.js';
3
+ export interface BriefCommandInput extends LinkOptionValues {
4
+ target: string;
5
+ globs: string[];
6
+ registry?: string;
7
+ noGenericBlocks?: boolean;
8
+ seoConfig?: string;
9
+ json?: boolean;
10
+ }
11
+ export declare function briefCommand(input: BriefCommandInput, io: Io): Promise<number>;
12
+ //# sourceMappingURL=brief.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brief.d.ts","sourceRoot":"","sources":["../../src/commands/brief.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK/E,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA0CpF"}
@@ -0,0 +1,52 @@
1
+ import { createSeoBrief, formatSeoBriefMarkdown } from '@contentbit/core';
2
+ import { glob } from 'tinyglobby';
3
+ import { loadContentProject } from '../content-project.js';
4
+ import { linkResolverOptions } from '../link-options.js';
5
+ import { loadSeoConfig } from '../seo-config.js';
6
+ const DEFAULT_BRIEF_GLOBS = ['content/**/*.{md,mdx}'];
7
+ export async function briefCommand(input, io) {
8
+ const seoConfig = await loadSeoConfig({ seoConfig: input.seoConfig });
9
+ if (!seoConfig.config) {
10
+ io.stderr('brief: no SEO config found. Add contentbit.seo.config.ts or pass --seo-config <path>.');
11
+ return 2;
12
+ }
13
+ const includeGenericBlocks = !input.noGenericBlocks;
14
+ const explicitGlobs = input.globs.length > 0;
15
+ const globs = explicitGlobs ? input.globs : await defaultBriefGlobs();
16
+ const { scan } = await loadContentProject({
17
+ cmd: 'brief',
18
+ positionals: globs,
19
+ registry: input.registry,
20
+ includeGenericBlocks,
21
+ linkOptions: linkResolverOptions(input),
22
+ scan: { seoConfig: seoConfig.config, seoConfigPath: seoConfig.path },
23
+ allowEmpty: !explicitGlobs && globs.length === 0,
24
+ });
25
+ if (!scan.seo) {
26
+ io.stderr('brief: SEO scan did not produce a result.');
27
+ return 1;
28
+ }
29
+ const configErrors = scan.seo.findings.filter((finding) => finding.severity === 'error');
30
+ if (configErrors.length > 0) {
31
+ for (const finding of configErrors)
32
+ io.stderr(`${finding.file}: ${finding.message}`);
33
+ return 1;
34
+ }
35
+ let brief;
36
+ try {
37
+ brief = createSeoBrief(scan.seo, input.target);
38
+ }
39
+ catch (err) {
40
+ io.stderr(err instanceof Error ? `brief: ${err.message}` : `brief: ${String(err)}`);
41
+ return 1;
42
+ }
43
+ if (input.json)
44
+ io.stdout(JSON.stringify(brief, null, 2));
45
+ else
46
+ io.stdout(formatSeoBriefMarkdown(brief));
47
+ return 0;
48
+ }
49
+ async function defaultBriefGlobs() {
50
+ const matches = await glob(DEFAULT_BRIEF_GLOBS);
51
+ return matches.length > 0 ? DEFAULT_BRIEF_GLOBS : [];
52
+ }
@@ -1,3 +1,8 @@
1
1
  import type { Io } from '../run.js';
2
- export declare function docsCommand(args: string[], io: Io): Promise<number>;
2
+ export interface DocsCommandInput {
3
+ registry?: string;
4
+ noGenericBlocks?: boolean;
5
+ out?: string;
6
+ }
7
+ export declare function docsCommand(input: DocsCommandInput, io: Io): Promise<number>;
3
8
  //# sourceMappingURL=docs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAazE"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlF"}
@@ -1,17 +1,11 @@
1
- import { parseArgs } from 'node:util';
2
1
  import { loadRegistry } from '../load-registry.js';
3
- export async function docsCommand(args, io) {
4
- const { values } = parseArgs({
5
- args,
6
- options: {
7
- registry: { type: 'string' },
8
- out: { type: 'string' },
9
- },
2
+ export async function docsCommand(input, io) {
3
+ const registry = await loadRegistry(input.registry, {
4
+ includeGenericBlocks: !input.noGenericBlocks,
10
5
  });
11
- const registry = await loadRegistry(values.registry);
12
6
  const guide = registry.toAuthoringGuide({ audience: 'human', includeExamples: true });
13
- if (values.out)
14
- await io.writeFile(values.out, guide);
7
+ if (input.out)
8
+ await io.writeFile(input.out, guide);
15
9
  else
16
10
  io.stdout(guide);
17
11
  return 0;
@@ -1,3 +1,15 @@
1
1
  import type { Io } from '../run.js';
2
- export declare function doctorCommand(args: string[], io: Io): Promise<number>;
2
+ import { type LinkOptionValues } from '../link-options.js';
3
+ export interface DoctorCommandInput extends LinkOptionValues {
4
+ globs: string[];
5
+ registry?: string;
6
+ noGenericBlocks?: boolean;
7
+ strictWarnings?: boolean;
8
+ strictSeo?: boolean;
9
+ json?: boolean;
10
+ minSectionWords?: string;
11
+ seoConfig?: string;
12
+ noSeo?: boolean;
13
+ }
14
+ export declare function doctorCommand(input: DoctorCommandInput, io: Io): Promise<number>;
3
15
  //# sourceMappingURL=doctor.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAWnC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAiB/E,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAqDtF"}