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
@@ -2,25 +2,17 @@ import { spawn } from 'node:child_process';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
4
4
  import { join } from 'node:path';
5
- import { parseArgs } from 'node:util';
6
5
  import { loadRegistry } from '../load-registry.js';
7
6
  import { installAgentIntegration } from './agents.js';
8
- const TARGETS = ['react', 'html', 'markdown', 'astro'];
9
- /** Markdown library choices per target; the first entry is the default. */
10
- const MD_CHOICES = {
11
- react: ['react-markdown', 'none'],
12
- html: ['marked', 'markdown-it', 'none'],
13
- markdown: ['none'],
14
- // @contentbit/astro ships its own marked-based default; nothing to install.
15
- astro: ['none'],
16
- };
7
+ import { detectTarget, TARGET_ADAPTERS, TARGETS } from './init-targets.js';
17
8
  const REGISTRY_TEMPLATE = `// Custom block definitions for this project. The CLI and your app share
18
9
  // this module — Node 22.18+ imports TypeScript directly:
19
10
  //
20
11
  // contentbit validate "content/**/*.md" --registry ./blocks/registry.ts
21
12
  //
22
13
  // Definitions stay framework-free (the CLI and every render target use
23
- // them); React components live next door in blocks/components.tsx.
14
+ // them); render components live next door in blocks/components.tsx or
15
+ // framework-specific component files copied from the shadcn registry.
24
16
  // Docs: https://contentbit.dev/docs/guides/custom-blocks
25
17
  import { defineBlock, markdownBody, type BlockDefinition } from '@contentbit/core'
26
18
  import { z } from 'zod'
@@ -42,42 +34,6 @@ export const quote = defineBlock({
42
34
 
43
35
  export default [quote] satisfies BlockDefinition<unknown>[]
44
36
  `;
45
- /** blocks/components.tsx — React components for custom blocks, next to their definitions. */
46
- function blockComponentsTemplate(styled) {
47
- const body = styled
48
- ? ` return (
49
- <figure className="my-6 border-s-2 ps-4">
50
- <blockquote className="text-lg italic">{ctx.renderMarkdown(data.markdown)}</blockquote>
51
- <figcaption className="text-muted-foreground mt-2 text-sm">
52
- — {String(node.props.author)}
53
- {node.props.role ? \`, \${String(node.props.role)}\` : null}
54
- </figcaption>
55
- </figure>
56
- )`
57
- : ` return (
58
- <figure style={{ margin: '1.5rem 0', borderLeft: '2px solid #d4d4d4', paddingLeft: '1rem' }}>
59
- <blockquote style={{ fontStyle: 'italic' }}>{ctx.renderMarkdown(data.markdown)}</blockquote>
60
- <figcaption style={{ marginTop: '0.5rem', fontSize: '0.875rem', opacity: 0.7 }}>
61
- — {String(node.props.author)}
62
- {node.props.role ? \`, \${String(node.props.role)}\` : null}
63
- </figcaption>
64
- </figure>
65
- )`;
66
- return `import type { BlockComponent, BlockComponentProps } from '@contentbit/react'
67
-
68
- // One React component per custom block, keyed by block name. Definitions
69
- // live in ./registry.ts — add a block there, add its component here, and
70
- // the rest of the app never changes.
71
- function QuoteBlock({ node, ctx }: BlockComponentProps) {
72
- const data = node.data as { markdown: string }
73
- ${body}
74
- }
75
-
76
- export const blockComponents: Record<string, BlockComponent> = {
77
- quote: QuoteBlock,
78
- }
79
- `;
80
- }
81
37
  const EXAMPLE_CONTENT = `---
82
38
  slug: hello-content-blocks
83
39
  linksTo:
@@ -132,183 +88,57 @@ references in \`linksTo\` are rewritten to the current slug, while \`aliases\`
132
88
  stays as the rename record.
133
89
  :::
134
90
  `;
135
- /** The wrapper component: styled pack or headless, with or without a Markdown lib. */
136
- function reactComponent(styled, mdWired, blocksImport) {
137
- const mdImport = mdWired ? "import ReactMarkdown from 'react-markdown'\n" : '';
138
- const mdProp = mdWired
139
- ? '\n renderMarkdown={(md) => <ReactMarkdown>{md}</ReactMarkdown>}'
140
- : `\n // TODO: plug your Markdown library in here, e.g. react-markdown.
141
- // One function renders all prose: https://contentbit.dev/docs/guides/markdown
142
- // renderMarkdown={(md) => <Markdown source={md} />}`;
143
- const rendererImport = styled
144
- ? `\n// The styled pack installed by shadcn. Yours to edit.
145
- import { ContentRenderer } from '@/components/content-blocks/content-renderer'`
146
- : '';
147
- const renderer = styled ? 'ContentRenderer' : 'ContentBlocks';
148
- const reactImport = styled ? '' : "import { ContentBlocks } from '@contentbit/react'\n";
149
- return `'use client'
150
-
151
- import { genericBlocks } from '@contentbit/blocks'
152
- import { createBlockRegistry, parseDocument, stripFrontmatter, validateDocument } from '@contentbit/core'
153
- ${reactImport}${mdImport}${rendererImport}
154
- // Everything block-related lives in the blocks/ folder: definitions in
155
- // registry.ts (shared with the validate CLI), components in components.tsx.
156
- import customBlocks from '${blocksImport}/registry'
157
- import { blockComponents } from '${blocksImport}/components'
158
-
159
- const registry = createBlockRegistry().use(genericBlocks()).use(customBlocks)
160
-
161
- export function Content({ source }: { source: string }) {
162
- const result = validateDocument(parseDocument(stripFrontmatter(source)), registry)
163
- return (
164
- <${renderer}
165
- document={result.document}
166
- components={blockComponents}${mdProp}
167
- />
168
- )
169
- }
170
- `;
171
- }
172
- function htmlRenderScript(md) {
173
- const wiring = md === 'marked'
174
- ? `import { marked } from 'marked'
175
-
176
- const renderMarkdown = (md) => marked.parse(md, { async: false })`
177
- : md === 'markdown-it'
178
- ? `import MarkdownIt from 'markdown-it'
179
-
180
- const mdIt = new MarkdownIt() // html: false by default — raw HTML stays escaped
181
- const renderMarkdown = (md) => mdIt.render(md)`
182
- : `// TODO: plug a Markdown library in here (marked, markdown-it, remark).
183
- const renderMarkdown = undefined`;
184
- return `// Render content/example.md to example.html. Run: node scripts/render-example.mjs
185
- import { genericBlocks } from '@contentbit/blocks'
186
- import { createBlockRegistry, parseDocument, stripFrontmatter, validateDocument } from '@contentbit/core'
187
- import { renderToHtml } from '@contentbit/html'
188
- import { readFile, writeFile } from 'node:fs/promises'
189
- ${wiring}
190
-
191
- const source = await readFile('content/example.md', 'utf8')
192
- const registry = createBlockRegistry().use(genericBlocks())
193
- const result = validateDocument(parseDocument(stripFrontmatter(source)), registry)
194
- const html = renderToHtml(result.document, { renderMarkdown })
195
- await writeFile('example.html', html, 'utf8')
196
- console.log('wrote example.html')
197
- `;
198
- }
199
- /** Where the component and example page belong for the detected framework. */
200
- function detectFramework(cwd, deps) {
201
- if ((deps['@tanstack/react-start'] || deps['@tanstack/react-router']) &&
202
- existsSync(join(cwd, 'src/routes'))) {
203
- return {
204
- framework: 'tanstack',
205
- componentPath: 'src/components/content-blocks.tsx',
206
- pagePath: 'src/routes/example.tsx',
207
- };
208
- }
209
- if (deps.next) {
210
- const appDir = existsSync(join(cwd, 'src/app')) ? 'src/app' : 'app';
211
- if (existsSync(join(cwd, appDir))) {
212
- return {
213
- framework: 'next',
214
- componentPath: 'components/content-blocks.tsx',
215
- pagePath: `${appDir}/example/page.tsx`,
216
- };
217
- }
218
- }
219
- return { framework: null, componentPath: 'components/content-blocks.tsx', pagePath: null };
220
- }
221
- const TANSTACK_PAGE = `import { createFileRoute } from '@tanstack/react-router'
222
-
223
- import { Content } from '../components/content-blocks'
224
- // Vite's ?raw import inlines the Markdown as a string at build time.
225
- import source from '../../content/example.md?raw'
226
-
227
- export const Route = createFileRoute('/example')({ component: ExamplePage })
228
-
229
- function ExamplePage() {
230
- return (
231
- <main style={{ maxWidth: '42rem', margin: '0 auto', padding: '3rem 1.5rem' }}>
232
- <Content source={source} />
233
- </main>
234
- )
235
- }
236
- `;
237
- const NEXT_PAGE = `import { readFile } from 'node:fs/promises'
238
-
239
- // If your project has no "@/" path alias, switch to a relative import.
240
- import { Content } from '@/components/content-blocks'
241
-
242
- export default async function ExamplePage() {
243
- const source = await readFile('content/example.md', 'utf8')
244
- return (
245
- <main style={{ maxWidth: '42rem', margin: '0 auto', padding: '3rem 1.5rem' }}>
246
- <Content source={source} />
247
- </main>
248
- )
249
- }
250
- `;
251
- const ASTRO_CONTENT_CONFIG = `import { defineCollection } from 'astro:content'
252
- import { glob } from 'astro/loaders'
253
-
254
- export const collections = {
255
- articles: defineCollection({
256
- // Astro's builtin Markdown loader. Entry bodies are parsed and validated
257
- // where they render (see src/pages/example.astro); \`contentbit validate\`
258
- // covers the same files in CI.
259
- loader: glob({ pattern: '**/*.md', base: './content' }),
260
- }),
261
- }
262
- `;
263
- const ASTRO_QUOTE_BLOCK = `---
264
- // The Astro component for the custom \`quote\` block defined in blocks/registry.ts.
265
- // Block props arrive as component props; nested content arrives via <slot />.
266
- interface Props {
267
- author: string
268
- role?: string
269
- }
270
-
271
- const { author, role } = Astro.props
272
- ---
273
-
274
- <figure style="margin: 1.5rem 0; border-left: 2px solid #d4d4d4; padding-left: 1rem;">
275
- <blockquote style="font-style: italic;"><slot /></blockquote>
276
- <figcaption style="margin-top: 0.5rem; font-size: 0.875rem; opacity: 0.7;">
277
- — {author}{role ? \`, \${role}\` : null}
278
- </figcaption>
279
- </figure>
280
- `;
281
- /** The example page: styled pack renderer or the headless ContentBlocks. */
282
- function astroPage(styled) {
283
- const importLine = styled
284
- ? "import ContentRenderer from '../components/content-blocks/content-renderer.astro'"
285
- : "import { ContentBlocks } from '@contentbit/astro/components'";
286
- const renderer = styled ? 'ContentRenderer' : 'ContentBlocks';
287
- return `---
288
- import { genericBlocks } from '@contentbit/blocks'
289
- import { createBlockRegistry, parseDocument, validateDocument } from '@contentbit/core'
290
- import { getEntry } from 'astro:content'
291
-
292
- ${importLine}
293
-
294
- // Definitions in blocks/registry.ts are shared with the validate CLI.
295
- import customBlocks from '../../blocks/registry'
296
- import QuoteBlock from '../../blocks/QuoteBlock.astro'
297
-
298
- // Entry ids are the file path relative to the collection base, minus ".md".
299
- const entry = await getEntry('articles', 'example')
300
- if (!entry?.body) throw new Error('Entry "example" not found in the articles collection.')
301
-
302
- const registry = createBlockRegistry().use(genericBlocks()).use(customBlocks)
303
- // Static pages render at build time, so invalid blocks fail the build here.
304
- const result = validateDocument(parseDocument(entry.body), registry)
305
- ---
306
-
307
- <main style="max-width: 42rem; margin: 0 auto; padding: 3rem 1.5rem;">
308
- <${renderer} document={result.document} components={{ quote: QuoteBlock }} />
309
- </main>
91
+ const SEO_CONFIG_TEMPLATE = `import { defineSeoConfig } from '@contentbit/core'
92
+
93
+ export default defineSeoConfig({
94
+ pageTypes: {
95
+ alternative: {
96
+ requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
97
+ requiredSections: [
98
+ { id: 'overview', headings: ['Overview', 'Summary'] },
99
+ { id: 'alternatives', headings: ['Best alternatives', 'Top alternatives'] },
100
+ { id: 'comparison', headings: ['Comparison', 'Feature comparison'] },
101
+ { id: 'faq', headings: ['FAQ', 'Frequently asked questions'] },
102
+ ],
103
+ requiredBlocks: ['comparison'],
104
+ recommendedBlocks: ['faq', 'key-metrics'],
105
+ minOutgoingLinks: 2,
106
+ },
107
+ comparison: {
108
+ requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
109
+ requiredSections: [
110
+ { id: 'overview', headings: ['Overview', 'Summary'] },
111
+ { id: 'comparison', headings: ['Comparison', 'Feature comparison'] },
112
+ { id: 'recommendation', headings: ['Recommendation', 'Which should you choose?'] },
113
+ ],
114
+ requiredBlocks: ['comparison'],
115
+ recommendedBlocks: ['faq'],
116
+ minOutgoingLinks: 2,
117
+ },
118
+ integration: {
119
+ requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
120
+ requiredSections: [
121
+ { id: 'overview', headings: ['Overview', 'Summary'] },
122
+ { id: 'setup', headings: ['Setup', 'How to connect'] },
123
+ { id: 'use-cases', headings: ['Use cases', 'Common workflows'] },
124
+ ],
125
+ recommendedBlocks: ['steps', 'faq'],
126
+ minOutgoingLinks: 2,
127
+ },
128
+ 'use-case': {
129
+ requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
130
+ requiredSections: [
131
+ { id: 'overview', headings: ['Overview', 'Summary'] },
132
+ { id: 'workflow', headings: ['Workflow', 'How it works'] },
133
+ { id: 'outcomes', headings: ['Outcomes', 'Results'] },
134
+ ],
135
+ recommendedBlocks: ['steps', 'key-metrics'],
136
+ minOutgoingLinks: 2,
137
+ },
138
+ },
139
+ pages: {},
140
+ })
310
141
  `;
311
- }
312
142
  function detectPackageManager(cwd) {
313
143
  // The project's lockfile outranks however the CLI itself was launched.
314
144
  const locks = [
@@ -367,7 +197,7 @@ async function installStyledPack(cwd, pack, noInstall, io) {
367
197
  io.stdout(`installing the styled pack: shadcn add ${pack}`);
368
198
  const code = await runInstall(bin, [...prefix, 'shadcn@latest', 'add', pack, '--yes'], cwd);
369
199
  if (code !== 0)
370
- io.stderr('styled pack install failed; falling back to headless defaults');
200
+ io.stderr('styled pack install failed; falling back to the headless renderer');
371
201
  return code === 0;
372
202
  }
373
203
  /** Write a file unless it already exists; returns what happened for the summary. */
@@ -382,21 +212,8 @@ async function scaffold(path, content) {
382
212
  return 'created';
383
213
  }
384
214
  }
385
- export async function initCommand(args, io) {
386
- const { values } = parseArgs({
387
- args,
388
- options: {
389
- target: { type: 'string', short: 't' },
390
- md: { type: 'string' },
391
- yes: { type: 'boolean', short: 'y', default: false },
392
- cwd: { type: 'string', default: process.cwd() },
393
- 'no-install': { type: 'boolean', default: false },
394
- 'no-page': { type: 'boolean', default: false },
395
- 'no-styled': { type: 'boolean', default: false },
396
- 'no-agents': { type: 'boolean', default: false },
397
- },
398
- });
399
- const cwd = values.cwd;
215
+ export async function initCommand(input, io) {
216
+ const cwd = input.cwd ?? process.cwd();
400
217
  // A project to init into is required.
401
218
  let pkg;
402
219
  const pkgPath = join(cwd, 'package.json');
@@ -407,19 +224,18 @@ export async function initCommand(args, io) {
407
224
  io.stderr('No package.json found. Run this inside a project (npm init first).');
408
225
  return 1;
409
226
  }
227
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
410
228
  // Resolve the render target: flag > prompt (interactive) > detection.
411
- const hasReact = Boolean(pkg.dependencies?.react ?? pkg.devDependencies?.react);
412
- const hasAstro = Boolean(pkg.dependencies?.astro ?? pkg.devDependencies?.astro);
413
- const detected = hasAstro ? 'astro' : hasReact ? 'react' : 'html';
229
+ const detected = detectTarget(deps);
414
230
  let target;
415
- if (values.target) {
416
- if (!TARGETS.includes(values.target)) {
417
- io.stderr(`Unknown target "${values.target}". Use one of: ${TARGETS.join(', ')}`);
231
+ if (input.target) {
232
+ if (!TARGETS.includes(input.target)) {
233
+ io.stderr(`Unknown target "${input.target}". Use one of: ${TARGETS.join(', ')}`);
418
234
  return 2;
419
235
  }
420
- target = values.target;
236
+ target = input.target;
421
237
  }
422
- else if (!values.yes && process.stdin.isTTY && process.stdout.isTTY) {
238
+ else if (!input.yes && process.stdin.isTTY && process.stdout.isTTY) {
423
239
  const { isCancel, select } = await import('@clack/prompts');
424
240
  const answer = await select({
425
241
  message: 'Render target?',
@@ -427,7 +243,6 @@ export async function initCommand(args, io) {
427
243
  options: [
428
244
  { value: 'react', label: 'React', hint: 'ContentBlocks component' },
429
245
  { value: 'astro', label: 'Astro', hint: 'content collections + .astro components' },
430
- { value: 'html', label: 'Static HTML', hint: 'renderToHtml, no framework' },
431
246
  { value: 'markdown', label: 'Plain Markdown', hint: 'fallback rendering only' },
432
247
  ],
433
248
  });
@@ -438,18 +253,19 @@ export async function initCommand(args, io) {
438
253
  else {
439
254
  target = detected;
440
255
  }
256
+ const adapter = TARGET_ADAPTERS[target];
441
257
  // Resolve the Markdown library: flag > prompt (interactive) > target default.
442
258
  // The default gives working prose rendering out of the box; 'none' opts out.
443
- const choices = MD_CHOICES[target];
259
+ const choices = adapter.markdownChoices;
444
260
  let md;
445
- if (values.md) {
446
- if (!choices.includes(values.md)) {
447
- io.stderr(`Unknown markdown library "${values.md}". Use one of: ${choices.join(', ')}`);
261
+ if (input.md) {
262
+ if (!choices.includes(input.md)) {
263
+ io.stderr(`Unknown markdown library "${input.md}". Use one of: ${choices.join(', ')}`);
448
264
  return 2;
449
265
  }
450
- md = values.md;
266
+ md = input.md;
451
267
  }
452
- else if (choices.length > 1 && !values.yes && process.stdin.isTTY && process.stdout.isTTY) {
268
+ else if (choices.length > 1 && !input.yes && process.stdin.isTTY && process.stdout.isTTY) {
453
269
  const { isCancel, select } = await import('@clack/prompts');
454
270
  const answer = await select({
455
271
  message: 'Markdown library for prose rendering?',
@@ -468,16 +284,8 @@ export async function initCommand(args, io) {
468
284
  md = choices[0];
469
285
  }
470
286
  // Install runtime packages plus the CLI as a dev dependency.
471
- const runtime = ['@contentbit/core', '@contentbit/blocks', 'zod'];
472
- if (target === 'react')
473
- runtime.push('@contentbit/react');
474
- if (target === 'html')
475
- runtime.push('@contentbit/html');
476
- if (target === 'astro')
477
- runtime.push('@contentbit/astro');
478
- if (md !== 'none')
479
- runtime.push(md);
480
- if (values['no-install']) {
287
+ const runtime = adapter.runtimeDependencies(md);
288
+ if (input.noInstall) {
481
289
  io.stdout(`skipped install: ${runtime.join(' ')} + contentbit (dev)`);
482
290
  }
483
291
  else {
@@ -492,63 +300,24 @@ export async function initCommand(args, io) {
492
300
  return 1;
493
301
  }
494
302
  }
303
+ const plan = await adapter.createPlan({
304
+ cwd,
305
+ deps,
306
+ md,
307
+ noPage: Boolean(input.noPage),
308
+ noStyled: Boolean(input.noStyled),
309
+ io,
310
+ installStyledPack: (pack) => installStyledPack(cwd, pack, Boolean(input.noInstall), io),
311
+ });
495
312
  // Scaffold project files; never overwrite.
496
313
  const files = [
497
314
  ['blocks/registry.ts', REGISTRY_TEMPLATE],
498
315
  ['content/example.md', EXAMPLE_CONTENT],
499
316
  ['content/related.md', RELATED_CONTENT],
317
+ ...plan.files,
500
318
  ];
501
- const layout = detectFramework(cwd, { ...pkg.dependencies, ...pkg.devDependencies });
502
- // shadcn project? Pull the styled component pack from the contentbit registry.
503
- let styled = false;
504
- const componentsJsonPath = join(cwd, 'components.json');
505
- if (target === 'react' && !values['no-styled'] && existsSync(componentsJsonPath)) {
506
- styled = await installStyledPack(cwd, '@contentbit/generic-pack', values['no-install'], io);
507
- }
508
- if (target === 'react') {
509
- const depth = layout.componentPath.split('/').length - 1;
510
- const blocksImport = `${'../'.repeat(depth)}blocks`;
511
- files.push(['blocks/components.tsx', blockComponentsTemplate(styled)]);
512
- files.push([
513
- layout.componentPath,
514
- reactComponent(styled, md === 'react-markdown', blocksImport),
515
- ]);
516
- // A visible page in the framework's own routing convention.
517
- if (!values['no-page'] && layout.pagePath) {
518
- files.push([layout.pagePath, layout.framework === 'tanstack' ? TANSTACK_PAGE : NEXT_PAGE]);
519
- }
520
- }
521
- if (target === 'html') {
522
- files.push([
523
- 'scripts/render-example.mjs',
524
- htmlRenderScript(md),
525
- ]);
526
- }
527
- if (target === 'astro') {
528
- let astroStyled = false;
529
- if (!values['no-styled'] && existsSync(componentsJsonPath)) {
530
- astroStyled = await installStyledPack(cwd, '@contentbit/astro-pack', values['no-install'], io);
531
- }
532
- files.push(['blocks/QuoteBlock.astro', ASTRO_QUOTE_BLOCK]);
533
- // Every config filename Astro resolves (src/content.config.* plus the
534
- // legacy src/content/config.* location), so we never scaffold a second
535
- // config that Astro would silently ignore.
536
- const configCandidates = ['ts', 'mts', 'mjs', 'js'].flatMap((ext) => [
537
- `src/content.config.${ext}`,
538
- `src/content/config.${ext}`,
539
- ]);
540
- const existingConfig = configCandidates.find((p) => existsSync(join(cwd, p)));
541
- if (existingConfig) {
542
- io.stdout(`content config exists (${existingConfig}); add this collection manually:`);
543
- io.stdout(ASTRO_CONTENT_CONFIG);
544
- io.stdout('the example page expects the "articles" collection above');
545
- }
546
- else {
547
- files.push(['src/content.config.ts', ASTRO_CONTENT_CONFIG]);
548
- }
549
- if (!values['no-page'])
550
- files.push(['src/pages/example.astro', astroPage(astroStyled)]);
551
- }
319
+ if (input.seo)
320
+ files.push(['contentbit.seo.config.ts', SEO_CONFIG_TEMPLATE]);
552
321
  for (const [rel, content] of files) {
553
322
  const result = await scaffold(join(cwd, rel), content);
554
323
  io.stdout(`${result}: ${rel}`);
@@ -594,37 +363,20 @@ export async function initCommand(args, io) {
594
363
  io.stdout('created: contentbit-guide.md (LLM authoring instructions)');
595
364
  // Coding-agent integration: an AGENTS.md block for every agent, plus Claude
596
365
  // Code skills when a .claude/ directory exists. `contentbit agents` refreshes.
597
- if (!values['no-agents']) {
366
+ if (!input.noAgents) {
598
367
  await installAgentIntegration(cwd, {}, io);
599
368
  io.stdout('Agent integration installed — try asking your agent:');
600
369
  io.stdout(' "write a blog post about X" or "audit my content"');
601
370
  }
602
371
  io.stdout('');
603
372
  io.stdout('Done. Next steps:');
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`);
607
- io.stdout(` Build the link index: ${detectPackageManager(cwd)} run content:links`);
608
- if (target === 'react') {
609
- if (!values['no-page'] && layout.pagePath) {
610
- io.stdout(' 2. Start the dev server and open /example to see the article rendered.');
611
- }
612
- else {
613
- io.stdout(' 2. Render it: import { Content } from "./components/content-blocks"');
614
- io.stdout(' <Content source={...content/example.md as a string} />');
615
- }
616
- io.stdout(' 3. Styled components: pnpm dlx shadcn@latest add @contentbit/generic-pack');
617
- }
618
- else if (target === 'astro') {
619
- io.stdout(' 2. Start the dev server and open /example to see the article rendered.');
620
- io.stdout(' 3. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack');
621
- }
622
- else if (target === 'html') {
623
- io.stdout(' 2. Render it: node scripts/render-example.mjs && open example.html');
624
- }
625
- else {
626
- io.stdout(' 2. Render it: contentbit render content/example.md --target markdown');
627
- }
373
+ const pm = detectPackageManager(cwd);
374
+ io.stdout(` 1. Browse content locally: ${pm} run studio`);
375
+ io.stdout(` Inspect content health: ${pm} run content:doctor`);
376
+ io.stdout(` Validate the starter content: ${pm} run content:check`);
377
+ io.stdout(` Build the link index: ${pm} run content:links`);
378
+ for (const line of plan.nextSteps)
379
+ io.stdout(line);
628
380
  io.stdout(' Docs: https://contentbit.dev/docs');
629
381
  return 0;
630
382
  }
@@ -1,3 +1,10 @@
1
1
  import type { Io } from '../run.js';
2
- export declare function instructionsCommand(args: string[], io: Io): Promise<number>;
2
+ export interface InstructionsCommandInput {
3
+ audience?: string;
4
+ noExamples?: boolean;
5
+ registry?: string;
6
+ noGenericBlocks?: boolean;
7
+ out?: string;
8
+ }
9
+ export declare function instructionsCommand(input: InstructionsCommandInput, io: Io): Promise<number>;
3
10
  //# sourceMappingURL=instructions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/commands/instructions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBjF"}
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/commands/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,wBAAwB,EAC/B,EAAE,EAAE,EAAE,GACL,OAAO,CAAC,MAAM,CAAC,CAWjB"}
@@ -1,22 +1,14 @@
1
- import { parseArgs } from 'node:util';
2
1
  import { loadRegistry } from '../load-registry.js';
3
- export async function instructionsCommand(args, io) {
4
- const { values } = parseArgs({
5
- args,
6
- options: {
7
- audience: { type: 'string', default: 'llm' },
8
- 'no-examples': { type: 'boolean', default: false },
9
- registry: { type: 'string' },
10
- out: { type: 'string' },
11
- },
2
+ export async function instructionsCommand(input, io) {
3
+ const registry = await loadRegistry(input.registry, {
4
+ includeGenericBlocks: !input.noGenericBlocks,
12
5
  });
13
- const registry = await loadRegistry(values.registry);
14
6
  const guide = registry.toAuthoringGuide({
15
- audience: values.audience === 'human' ? 'human' : 'llm',
16
- includeExamples: !values['no-examples'],
7
+ audience: input.audience === 'human' ? 'human' : 'llm',
8
+ includeExamples: !input.noExamples,
17
9
  });
18
- if (values.out)
19
- await io.writeFile(values.out, guide);
10
+ if (input.out)
11
+ await io.writeFile(input.out, guide);
20
12
  else
21
13
  io.stdout(guide);
22
14
  return 0;
@@ -1,3 +1,9 @@
1
1
  import type { Io } from '../run.js';
2
- export declare function linksCommand(args: string[], io: Io): Promise<number>;
2
+ import { type LinkOptionValues } from '../link-options.js';
3
+ export interface LinksCommandInput extends LinkOptionValues {
4
+ globs: string[];
5
+ out?: string;
6
+ fix?: boolean;
7
+ }
8
+ export declare function linksCommand(input: LinksCommandInput, io: Io): Promise<number>;
3
9
  //# sourceMappingURL=links.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/commands/links.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAKnC,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAuF1E"}
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/commands/links.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG/E,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA2EpF"}