contentbit 0.5.0 → 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.
- package/README.md +13 -0
- package/dist/bin.js +4802 -501
- package/dist/commands/agents.d.ts +6 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +4 -13
- package/dist/commands/brief.d.ts +12 -0
- package/dist/commands/brief.d.ts.map +1 -0
- package/dist/commands/brief.js +52 -0
- package/dist/commands/docs.d.ts +6 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +5 -14
- package/dist/commands/doctor.d.ts +13 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +58 -34
- package/dist/commands/init.d.ts +12 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +70 -31
- package/dist/commands/instructions.d.ts +8 -1
- package/dist/commands/instructions.d.ts.map +1 -1
- package/dist/commands/instructions.js +7 -18
- package/dist/commands/links.d.ts +7 -1
- package/dist/commands/links.d.ts.map +1 -1
- package/dist/commands/links.js +11 -28
- package/dist/commands/render.d.ts +8 -1
- package/dist/commands/render.d.ts.map +1 -1
- package/dist/commands/render.js +8 -20
- package/dist/commands/stats.d.ts +7 -1
- package/dist/commands/stats.d.ts.map +1 -1
- package/dist/commands/stats.js +7 -17
- package/dist/commands/studio.d.ts +13 -1
- package/dist/commands/studio.d.ts.map +1 -1
- package/dist/commands/studio.js +17 -30
- package/dist/commands/validate.d.ts +8 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +6 -21
- package/dist/content-project.d.ts +2 -22
- package/dist/content-project.d.ts.map +1 -1
- package/dist/content-project.js +13 -22
- package/dist/link-options.d.ts +5 -0
- package/dist/link-options.d.ts.map +1 -1
- package/dist/link-options.js +5 -5
- package/dist/load-registry.d.ts +1 -6
- package/dist/load-registry.d.ts.map +1 -1
- package/dist/load-registry.js +1 -26
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4800 -499
- package/dist/seo-config.d.ts +12 -0
- package/dist/seo-config.d.ts.map +1 -0
- package/dist/seo-config.js +21 -0
- package/package.json +6 -4
|
@@ -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
|
|
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":"
|
|
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"}
|
package/dist/commands/agents.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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
4
|
import agentsMdTemplate from './agent-templates/AGENTS.md?raw';
|
|
6
5
|
import auditSkill from './agent-templates/contentbit-audit/SKILL.md?raw';
|
|
7
6
|
import authorSkill from './agent-templates/contentbit-author/SKILL.md?raw';
|
|
@@ -56,18 +55,10 @@ export async function installAgentIntegration(cwd, options, io) {
|
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
export async function agentsCommand(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
claude: { type: 'boolean', default: false },
|
|
64
|
-
'no-agents-md': { type: 'boolean', default: false },
|
|
65
|
-
cwd: { type: 'string', default: process.cwd() },
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
await installAgentIntegration(values.cwd, {
|
|
69
|
-
claude: values.claude || undefined, // false means "detect", not "skip"
|
|
70
|
-
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,
|
|
71
62
|
}, io);
|
|
72
63
|
return 0;
|
|
73
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
|
+
}
|
package/dist/commands/docs.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
export
|
|
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":"
|
|
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"}
|
package/dist/commands/docs.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { parseArgs } from 'node:util';
|
|
2
1
|
import { loadRegistry } from '../load-registry.js';
|
|
3
|
-
export async function docsCommand(
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
options: {
|
|
7
|
-
registry: { type: 'string' },
|
|
8
|
-
'no-generic-blocks': { type: 'boolean', default: false },
|
|
9
|
-
out: { type: 'string' },
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
const registry = await loadRegistry(values.registry, {
|
|
13
|
-
includeGenericBlocks: !values['no-generic-blocks'],
|
|
2
|
+
export async function docsCommand(input, io) {
|
|
3
|
+
const registry = await loadRegistry(input.registry, {
|
|
4
|
+
includeGenericBlocks: !input.noGenericBlocks,
|
|
14
5
|
});
|
|
15
6
|
const guide = registry.toAuthoringGuide({ audience: 'human', includeExamples: true });
|
|
16
|
-
if (
|
|
17
|
-
await io.writeFile(
|
|
7
|
+
if (input.out)
|
|
8
|
+
await io.writeFile(input.out, guide);
|
|
18
9
|
else
|
|
19
10
|
io.stdout(guide);
|
|
20
11
|
return 0;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
|
|
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":"AAOA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;
|
|
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"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,53 +1,51 @@
|
|
|
1
1
|
import { DEFAULT_MIN_SECTION_WORDS, } from '@contentbit/core';
|
|
2
|
-
import { parseArgs } from 'node:util';
|
|
3
2
|
import { color, displayPath, formatCommandList, formatRows, section, severityLabel, } from '../cli-format.js';
|
|
4
3
|
import { loadContentProject } from '../content-project.js';
|
|
5
4
|
import { linkResolverOptions } from '../link-options.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
allowPositionals: true,
|
|
10
|
-
options: {
|
|
11
|
-
registry: { type: 'string' },
|
|
12
|
-
'no-generic-blocks': { type: 'boolean', default: false },
|
|
13
|
-
'strict-warnings': { type: 'boolean', default: false },
|
|
14
|
-
json: { type: 'boolean', default: false },
|
|
15
|
-
'min-section-words': { type: 'string' },
|
|
16
|
-
'link-resolve': { type: 'string' },
|
|
17
|
-
'locale-field': { type: 'string' },
|
|
18
|
-
'slug-field': { type: 'string' },
|
|
19
|
-
'key-field': { type: 'string' },
|
|
20
|
-
'default-locale': { type: 'string' },
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
const minSectionWords = parseMinSectionWords(values['min-section-words']);
|
|
5
|
+
import { loadSeoConfig } from '../seo-config.js';
|
|
6
|
+
export async function doctorCommand(input, io) {
|
|
7
|
+
const minSectionWords = parseMinSectionWords(input.minSectionWords);
|
|
24
8
|
if (minSectionWords === null) {
|
|
25
9
|
io.stderr('doctor: --min-section-words must be a non-negative integer.');
|
|
26
10
|
return 2;
|
|
27
11
|
}
|
|
28
|
-
const includeGenericBlocks = !
|
|
12
|
+
const includeGenericBlocks = !input.noGenericBlocks;
|
|
13
|
+
const linkOptions = linkResolverOptions(input);
|
|
14
|
+
const seoConfig = await loadSeoConfig({ seoConfig: input.seoConfig, noSeo: input.noSeo });
|
|
29
15
|
const { files, scan } = await loadContentProject({
|
|
30
16
|
cmd: 'doctor',
|
|
31
|
-
positionals,
|
|
32
|
-
registry:
|
|
17
|
+
positionals: input.globs,
|
|
18
|
+
registry: input.registry,
|
|
33
19
|
includeGenericBlocks,
|
|
34
|
-
linkOptions
|
|
35
|
-
scan: { minSectionWords },
|
|
20
|
+
linkOptions,
|
|
21
|
+
scan: { minSectionWords, seoConfig: seoConfig.config, seoConfigPath: seoConfig.path },
|
|
36
22
|
});
|
|
37
23
|
const report = {
|
|
38
24
|
files: files.length,
|
|
39
25
|
summary: scan.summary,
|
|
40
26
|
...(scan.linkGraph ? { linkGraph: scan.linkGraph } : {}),
|
|
27
|
+
...(scan.seo
|
|
28
|
+
? {
|
|
29
|
+
seo: {
|
|
30
|
+
schemaVersion: scan.seo.schemaVersion,
|
|
31
|
+
pages: scan.seo.pages.length,
|
|
32
|
+
findings: scan.seo.findings,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
: {}),
|
|
41
36
|
findings: scan.findings,
|
|
42
37
|
};
|
|
43
|
-
if (
|
|
38
|
+
if (input.json)
|
|
44
39
|
io.stdout(JSON.stringify(report, null, 2));
|
|
45
40
|
else
|
|
46
|
-
io.stdout(formatReport(report,
|
|
41
|
+
io.stdout(formatReport(report, input.globs, input.registry, includeGenericBlocks, linkOptions, hasAliases(scan.linkInputs)));
|
|
47
42
|
if (report.summary.errors > 0)
|
|
48
43
|
return 1;
|
|
49
|
-
if (report.summary.warnings > 0 &&
|
|
44
|
+
if (report.summary.warnings > 0 && input.strictWarnings)
|
|
50
45
|
return 1;
|
|
46
|
+
if (input.strictSeo && report.seo?.findings.some((finding) => finding.severity === 'warning')) {
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
51
49
|
return 0;
|
|
52
50
|
}
|
|
53
51
|
function parseMinSectionWords(value) {
|
|
@@ -60,7 +58,7 @@ function parseMinSectionWords(value) {
|
|
|
60
58
|
function hasAliases(inputs) {
|
|
61
59
|
return inputs.some((input) => Array.isArray(input.data.aliases) && input.data.aliases.length > 0);
|
|
62
60
|
}
|
|
63
|
-
function formatReport(report, globs, registryPath, includeGenericBlocks, aliasFixMayApply) {
|
|
61
|
+
function formatReport(report, globs, registryPath, includeGenericBlocks, linkOptions, aliasFixMayApply) {
|
|
64
62
|
const lines = [];
|
|
65
63
|
lines.push(section('contentbit doctor'));
|
|
66
64
|
lines.push('');
|
|
@@ -96,6 +94,18 @@ function formatReport(report, globs, registryPath, includeGenericBlocks, aliasFi
|
|
|
96
94
|
},
|
|
97
95
|
]));
|
|
98
96
|
}
|
|
97
|
+
if (report.seo) {
|
|
98
|
+
lines.push('');
|
|
99
|
+
lines.push(section('SEO'));
|
|
100
|
+
lines.push(...formatRows([
|
|
101
|
+
{ label: 'Pages', value: report.seo.pages },
|
|
102
|
+
{
|
|
103
|
+
label: 'Findings',
|
|
104
|
+
value: report.seo.findings.length,
|
|
105
|
+
tone: report.seo.findings.length > 0 ? 'warning' : 'success',
|
|
106
|
+
},
|
|
107
|
+
]));
|
|
108
|
+
}
|
|
99
109
|
lines.push('');
|
|
100
110
|
if (report.findings.length === 0) {
|
|
101
111
|
lines.push(color('No findings. Content looks healthy.', 'success'));
|
|
@@ -108,15 +118,15 @@ function formatReport(report, globs, registryPath, includeGenericBlocks, aliasFi
|
|
|
108
118
|
}
|
|
109
119
|
lines.push('');
|
|
110
120
|
lines.push(section('Next Commands'));
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
];
|
|
121
|
+
const registryArgs = formatRegistryArgs(registryPath, includeGenericBlocks);
|
|
122
|
+
const linkArgs = formatLinkArgs(linkOptions);
|
|
123
|
+
const commands = [`contentbit validate ${formatGlobs(globs)}${registryArgs}${linkArgs}`];
|
|
114
124
|
if (report.linkGraph) {
|
|
115
|
-
commands.push(`contentbit links ${formatGlobs(globs)}`);
|
|
125
|
+
commands.push(`contentbit links ${formatGlobs(globs)}${linkArgs}`);
|
|
116
126
|
if (aliasFixMayApply && report.summary.errors === 0)
|
|
117
|
-
commands.push(`contentbit links ${formatGlobs(globs)} --fix`);
|
|
127
|
+
commands.push(`contentbit links ${formatGlobs(globs)}${linkArgs} --fix`);
|
|
118
128
|
}
|
|
119
|
-
commands.push(`contentbit doctor ${formatGlobs(globs)}${
|
|
129
|
+
commands.push(`contentbit doctor ${formatGlobs(globs)}${registryArgs}${linkArgs} --json`);
|
|
120
130
|
lines.push(...formatCommandList(commands));
|
|
121
131
|
return lines.join('\n');
|
|
122
132
|
}
|
|
@@ -147,3 +157,17 @@ function formatRegistryArgs(registryPath, includeGenericBlocks) {
|
|
|
147
157
|
args.push('--no-generic-blocks');
|
|
148
158
|
return args.length > 0 ? ` ${args.join(' ')}` : '';
|
|
149
159
|
}
|
|
160
|
+
function formatLinkArgs(options) {
|
|
161
|
+
const args = [];
|
|
162
|
+
if (options.resolve)
|
|
163
|
+
args.push('--link-resolve', options.resolve);
|
|
164
|
+
if (options.localeField)
|
|
165
|
+
args.push('--locale-field', formatArg(options.localeField));
|
|
166
|
+
if (options.slugField)
|
|
167
|
+
args.push('--slug-field', formatArg(options.slugField));
|
|
168
|
+
if (options.keyField)
|
|
169
|
+
args.push('--key-field', formatArg(options.keyField));
|
|
170
|
+
if (options.defaultLocale)
|
|
171
|
+
args.push('--default-locale', formatArg(options.defaultLocale));
|
|
172
|
+
return args.length > 0 ? ` ${args.join(' ')}` : '';
|
|
173
|
+
}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
export
|
|
2
|
+
export interface InitCommandInput {
|
|
3
|
+
target?: string;
|
|
4
|
+
md?: string;
|
|
5
|
+
yes?: boolean;
|
|
6
|
+
cwd?: string;
|
|
7
|
+
noInstall?: boolean;
|
|
8
|
+
noPage?: boolean;
|
|
9
|
+
noStyled?: boolean;
|
|
10
|
+
noAgents?: boolean;
|
|
11
|
+
seo?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function initCommand(input: InitCommandInput, io: Io): Promise<number>;
|
|
3
14
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AA+NnC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+KlF"}
|
package/dist/commands/init.js
CHANGED
|
@@ -2,7 +2,6 @@ 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
7
|
import { detectTarget, TARGET_ADAPTERS, TARGETS } from './init-targets.js';
|
|
@@ -89,6 +88,57 @@ references in \`linksTo\` are rewritten to the current slug, while \`aliases\`
|
|
|
89
88
|
stays as the rename record.
|
|
90
89
|
:::
|
|
91
90
|
`;
|
|
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
|
+
})
|
|
141
|
+
`;
|
|
92
142
|
function detectPackageManager(cwd) {
|
|
93
143
|
// The project's lockfile outranks however the CLI itself was launched.
|
|
94
144
|
const locks = [
|
|
@@ -162,21 +212,8 @@ async function scaffold(path, content) {
|
|
|
162
212
|
return 'created';
|
|
163
213
|
}
|
|
164
214
|
}
|
|
165
|
-
export async function initCommand(
|
|
166
|
-
const
|
|
167
|
-
args,
|
|
168
|
-
options: {
|
|
169
|
-
target: { type: 'string', short: 't' },
|
|
170
|
-
md: { type: 'string' },
|
|
171
|
-
yes: { type: 'boolean', short: 'y', default: false },
|
|
172
|
-
cwd: { type: 'string', default: process.cwd() },
|
|
173
|
-
'no-install': { type: 'boolean', default: false },
|
|
174
|
-
'no-page': { type: 'boolean', default: false },
|
|
175
|
-
'no-styled': { type: 'boolean', default: false },
|
|
176
|
-
'no-agents': { type: 'boolean', default: false },
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
const cwd = values.cwd;
|
|
215
|
+
export async function initCommand(input, io) {
|
|
216
|
+
const cwd = input.cwd ?? process.cwd();
|
|
180
217
|
// A project to init into is required.
|
|
181
218
|
let pkg;
|
|
182
219
|
const pkgPath = join(cwd, 'package.json');
|
|
@@ -191,14 +228,14 @@ export async function initCommand(args, io) {
|
|
|
191
228
|
// Resolve the render target: flag > prompt (interactive) > detection.
|
|
192
229
|
const detected = detectTarget(deps);
|
|
193
230
|
let target;
|
|
194
|
-
if (
|
|
195
|
-
if (!TARGETS.includes(
|
|
196
|
-
io.stderr(`Unknown target "${
|
|
231
|
+
if (input.target) {
|
|
232
|
+
if (!TARGETS.includes(input.target)) {
|
|
233
|
+
io.stderr(`Unknown target "${input.target}". Use one of: ${TARGETS.join(', ')}`);
|
|
197
234
|
return 2;
|
|
198
235
|
}
|
|
199
|
-
target =
|
|
236
|
+
target = input.target;
|
|
200
237
|
}
|
|
201
|
-
else if (!
|
|
238
|
+
else if (!input.yes && process.stdin.isTTY && process.stdout.isTTY) {
|
|
202
239
|
const { isCancel, select } = await import('@clack/prompts');
|
|
203
240
|
const answer = await select({
|
|
204
241
|
message: 'Render target?',
|
|
@@ -221,14 +258,14 @@ export async function initCommand(args, io) {
|
|
|
221
258
|
// The default gives working prose rendering out of the box; 'none' opts out.
|
|
222
259
|
const choices = adapter.markdownChoices;
|
|
223
260
|
let md;
|
|
224
|
-
if (
|
|
225
|
-
if (!choices.includes(
|
|
226
|
-
io.stderr(`Unknown markdown library "${
|
|
261
|
+
if (input.md) {
|
|
262
|
+
if (!choices.includes(input.md)) {
|
|
263
|
+
io.stderr(`Unknown markdown library "${input.md}". Use one of: ${choices.join(', ')}`);
|
|
227
264
|
return 2;
|
|
228
265
|
}
|
|
229
|
-
md =
|
|
266
|
+
md = input.md;
|
|
230
267
|
}
|
|
231
|
-
else if (choices.length > 1 && !
|
|
268
|
+
else if (choices.length > 1 && !input.yes && process.stdin.isTTY && process.stdout.isTTY) {
|
|
232
269
|
const { isCancel, select } = await import('@clack/prompts');
|
|
233
270
|
const answer = await select({
|
|
234
271
|
message: 'Markdown library for prose rendering?',
|
|
@@ -248,7 +285,7 @@ export async function initCommand(args, io) {
|
|
|
248
285
|
}
|
|
249
286
|
// Install runtime packages plus the CLI as a dev dependency.
|
|
250
287
|
const runtime = adapter.runtimeDependencies(md);
|
|
251
|
-
if (
|
|
288
|
+
if (input.noInstall) {
|
|
252
289
|
io.stdout(`skipped install: ${runtime.join(' ')} + contentbit (dev)`);
|
|
253
290
|
}
|
|
254
291
|
else {
|
|
@@ -267,10 +304,10 @@ export async function initCommand(args, io) {
|
|
|
267
304
|
cwd,
|
|
268
305
|
deps,
|
|
269
306
|
md,
|
|
270
|
-
noPage: Boolean(
|
|
271
|
-
noStyled: Boolean(
|
|
307
|
+
noPage: Boolean(input.noPage),
|
|
308
|
+
noStyled: Boolean(input.noStyled),
|
|
272
309
|
io,
|
|
273
|
-
installStyledPack: (pack) => installStyledPack(cwd, pack,
|
|
310
|
+
installStyledPack: (pack) => installStyledPack(cwd, pack, Boolean(input.noInstall), io),
|
|
274
311
|
});
|
|
275
312
|
// Scaffold project files; never overwrite.
|
|
276
313
|
const files = [
|
|
@@ -279,6 +316,8 @@ export async function initCommand(args, io) {
|
|
|
279
316
|
['content/related.md', RELATED_CONTENT],
|
|
280
317
|
...plan.files,
|
|
281
318
|
];
|
|
319
|
+
if (input.seo)
|
|
320
|
+
files.push(['contentbit.seo.config.ts', SEO_CONFIG_TEMPLATE]);
|
|
282
321
|
for (const [rel, content] of files) {
|
|
283
322
|
const result = await scaffold(join(cwd, rel), content);
|
|
284
323
|
io.stdout(`${result}: ${rel}`);
|
|
@@ -324,7 +363,7 @@ export async function initCommand(args, io) {
|
|
|
324
363
|
io.stdout('created: contentbit-guide.md (LLM authoring instructions)');
|
|
325
364
|
// Coding-agent integration: an AGENTS.md block for every agent, plus Claude
|
|
326
365
|
// Code skills when a .claude/ directory exists. `contentbit agents` refreshes.
|
|
327
|
-
if (!
|
|
366
|
+
if (!input.noAgents) {
|
|
328
367
|
await installAgentIntegration(cwd, {}, io);
|
|
329
368
|
io.stdout('Agent integration installed — try asking your agent:');
|
|
330
369
|
io.stdout(' "write a blog post about X" or "audit my content"');
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
export
|
|
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":"
|
|
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,25 +1,14 @@
|
|
|
1
|
-
import { parseArgs } from 'node:util';
|
|
2
1
|
import { loadRegistry } from '../load-registry.js';
|
|
3
|
-
export async function instructionsCommand(
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
options: {
|
|
7
|
-
audience: { type: 'string', default: 'llm' },
|
|
8
|
-
'no-examples': { type: 'boolean', default: false },
|
|
9
|
-
registry: { type: 'string' },
|
|
10
|
-
'no-generic-blocks': { type: 'boolean', default: false },
|
|
11
|
-
out: { type: 'string' },
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
const registry = await loadRegistry(values.registry, {
|
|
15
|
-
includeGenericBlocks: !values['no-generic-blocks'],
|
|
2
|
+
export async function instructionsCommand(input, io) {
|
|
3
|
+
const registry = await loadRegistry(input.registry, {
|
|
4
|
+
includeGenericBlocks: !input.noGenericBlocks,
|
|
16
5
|
});
|
|
17
6
|
const guide = registry.toAuthoringGuide({
|
|
18
|
-
audience:
|
|
19
|
-
includeExamples: !
|
|
7
|
+
audience: input.audience === 'human' ? 'human' : 'llm',
|
|
8
|
+
includeExamples: !input.noExamples,
|
|
20
9
|
});
|
|
21
|
-
if (
|
|
22
|
-
await io.writeFile(
|
|
10
|
+
if (input.out)
|
|
11
|
+
await io.writeFile(input.out, guide);
|
|
23
12
|
else
|
|
24
13
|
io.stdout(guide);
|
|
25
14
|
return 0;
|
package/dist/commands/links.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
|
|
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":"AAWA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;
|
|
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"}
|