@takazudo/zudo-doc 13.0.0 → 14.0.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/CHANGELOG.md +28 -0
- package/bin/zudo-doc.mjs +32 -0
- package/dist/config.d.ts +10 -27
- package/dist/doc-content-header/index.js +1 -1
- package/dist/doc-page-renderer/index.js +3 -1
- package/dist/doc-sources/types.d.ts +65 -0
- package/dist/doc-sources/types.js +0 -0
- package/dist/docs-schema/index.d.ts +3 -0
- package/dist/docs-schema/index.js +4 -0
- package/dist/frontmatter-preview-defaults/index.js +3 -0
- package/dist/i18n-defaults/index.js +36 -50
- package/dist/plugins/{codex-resources.d.ts → doc-sources.d.ts} +0 -1
- package/dist/plugins/doc-sources.js +40 -0
- package/dist/plugins/internal/doc-sources/discover.d.ts +33 -0
- package/dist/plugins/internal/doc-sources/discover.js +176 -0
- package/dist/plugins/internal/doc-sources/glob.d.ts +8 -0
- package/dist/plugins/internal/doc-sources/glob.js +80 -0
- package/dist/plugins/internal/doc-sources/labels.d.ts +8 -0
- package/dist/plugins/internal/doc-sources/labels.js +7 -0
- package/dist/plugins/internal/doc-sources/locale-routes.d.ts +6 -0
- package/dist/plugins/internal/doc-sources/locale-routes.js +8 -0
- package/dist/plugins/internal/doc-sources/model.d.ts +64 -0
- package/dist/plugins/internal/doc-sources/model.js +0 -0
- package/dist/plugins/internal/doc-sources/normalize.d.ts +20 -0
- package/dist/plugins/internal/doc-sources/normalize.js +192 -0
- package/dist/plugins/internal/doc-sources/plan.d.ts +28 -0
- package/dist/plugins/internal/doc-sources/plan.js +350 -0
- package/dist/plugins/internal/doc-sources/presets.d.ts +12 -0
- package/dist/plugins/internal/doc-sources/presets.js +182 -0
- package/dist/plugins/internal/doc-sources/reconcile.d.ts +20 -0
- package/dist/plugins/internal/doc-sources/reconcile.js +182 -0
- package/dist/plugins/internal/doc-sources/render/codex-agent.d.ts +2 -0
- package/dist/plugins/internal/doc-sources/render/codex-agent.js +45 -0
- package/dist/plugins/internal/doc-sources/render/codex-config.d.ts +2 -0
- package/dist/plugins/internal/doc-sources/render/codex-config.js +45 -0
- package/dist/plugins/internal/doc-sources/render/codex-hooks.d.ts +2 -0
- package/dist/plugins/internal/doc-sources/render/codex-hooks.js +66 -0
- package/dist/plugins/internal/doc-sources/render/codex-rules.d.ts +2 -0
- package/dist/plugins/internal/{codex-resources/rules.js → doc-sources/render/codex-rules.js} +16 -89
- package/dist/plugins/internal/{resource-docs-shared → doc-sources/render}/escape-for-mdx.js +1 -1
- package/dist/plugins/internal/doc-sources/render/frontmatter.d.ts +9 -0
- package/dist/plugins/internal/doc-sources/render/frontmatter.js +38 -0
- package/dist/plugins/internal/doc-sources/render/links.d.ts +25 -0
- package/dist/plugins/internal/doc-sources/render/links.js +109 -0
- package/dist/plugins/internal/{resource-docs-shared → doc-sources/render}/markdown-structure.d.ts +4 -0
- package/dist/plugins/internal/{resource-docs-shared → doc-sources/render}/markdown-structure.js +37 -1
- package/dist/plugins/internal/doc-sources/render/skill.d.ts +10 -0
- package/dist/plugins/internal/doc-sources/render/skill.js +97 -0
- package/dist/plugins/internal/doc-sources/render/types.d.ts +7 -0
- package/dist/plugins/internal/doc-sources/render/types.js +6 -0
- package/dist/plugins/internal/doc-sources/run.d.ts +53 -0
- package/dist/plugins/internal/doc-sources/run.js +110 -0
- package/dist/plugins/internal/doc-sources/watch.d.ts +33 -0
- package/dist/plugins/internal/doc-sources/watch.js +187 -0
- package/dist/plugins/routes.js +1 -1
- package/dist/preset.d.ts +3 -19
- package/dist/preset.js +23 -30
- package/dist/route-context-payload/index.js +4 -1
- package/dist/settings-defaults.js +1 -2
- package/dist/settings.d.ts +4 -10
- package/package.json +15 -19
- package/dist/plugins/claude-resources.d.ts +0 -4
- package/dist/plugins/claude-resources.js +0 -45
- package/dist/plugins/codex-resources.js +0 -45
- package/dist/plugins/internal/claude-resources/generate.d.ts +0 -31
- package/dist/plugins/internal/claude-resources/generate.js +0 -375
- package/dist/plugins/internal/claude-resources/index.d.ts +0 -54
- package/dist/plugins/internal/claude-resources/index.js +0 -33
- package/dist/plugins/internal/codex-resources/agents-md.d.ts +0 -6
- package/dist/plugins/internal/codex-resources/agents-md.js +0 -83
- package/dist/plugins/internal/codex-resources/agents.d.ts +0 -7
- package/dist/plugins/internal/codex-resources/agents.js +0 -117
- package/dist/plugins/internal/codex-resources/config.d.ts +0 -6
- package/dist/plugins/internal/codex-resources/config.js +0 -124
- package/dist/plugins/internal/codex-resources/generate.d.ts +0 -29
- package/dist/plugins/internal/codex-resources/generate.js +0 -46
- package/dist/plugins/internal/codex-resources/hooks.d.ts +0 -6
- package/dist/plugins/internal/codex-resources/hooks.js +0 -187
- package/dist/plugins/internal/codex-resources/index.d.ts +0 -33
- package/dist/plugins/internal/codex-resources/index.js +0 -33
- package/dist/plugins/internal/codex-resources/overview.d.ts +0 -10
- package/dist/plugins/internal/codex-resources/overview.js +0 -163
- package/dist/plugins/internal/codex-resources/rules.d.ts +0 -6
- package/dist/plugins/internal/codex-resources/skills.d.ts +0 -2
- package/dist/plugins/internal/codex-resources/skills.js +0 -97
- package/dist/plugins/internal/codex-resources/utils.d.ts +0 -14
- package/dist/plugins/internal/codex-resources/utils.js +0 -80
- package/dist/plugins/internal/resource-docs-shared/fs.d.ts +0 -36
- package/dist/plugins/internal/resource-docs-shared/fs.js +0 -101
- package/dist/plugins/internal/resource-docs-shared/index.d.ts +0 -9
- package/dist/plugins/internal/resource-docs-shared/index.js +0 -69
- package/dist/plugins/internal/resource-docs-shared/labels.d.ts +0 -24
- package/dist/plugins/internal/resource-docs-shared/labels.js +0 -14
- package/dist/plugins/internal/resource-docs-shared/links.d.ts +0 -27
- package/dist/plugins/internal/resource-docs-shared/links.js +0 -62
- package/dist/plugins/internal/resource-docs-shared/locale-routes.d.ts +0 -16
- package/dist/plugins/internal/resource-docs-shared/locale-routes.js +0 -14
- package/dist/plugins/internal/resource-docs-shared/mdx.d.ts +0 -28
- package/dist/plugins/internal/resource-docs-shared/mdx.js +0 -64
- package/dist/plugins/internal/resource-docs-shared/skills.d.ts +0 -37
- package/dist/plugins/internal/resource-docs-shared/skills.js +0 -340
- package/dist/plugins/internal/resource-docs-shared/walk.d.ts +0 -20
- package/dist/plugins/internal/resource-docs-shared/walk.js +0 -41
- /package/dist/plugins/internal/{resource-docs-shared → doc-sources/render}/escape-for-mdx.d.ts +0 -0
|
@@ -26,7 +26,10 @@ function createRouteContextPayload(input) {
|
|
|
26
26
|
...input.locales !== void 0 ? { locales: input.locales } : {},
|
|
27
27
|
...input.categories !== void 0 ? { headerNav: [...input.categories] } : {},
|
|
28
28
|
...input.themePack !== void 0 ? { themePack: input.themePack } : {},
|
|
29
|
-
...input.settings
|
|
29
|
+
...input.settings,
|
|
30
|
+
// Document-source configuration is private build-time filesystem data;
|
|
31
|
+
// a browser payload never carries it.
|
|
32
|
+
docSources: []
|
|
30
33
|
};
|
|
31
34
|
settings.themePack = resolveConfiguredThemePack({
|
|
32
35
|
themePack: settings.themePack,
|
package/dist/settings.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DateFormatPattern } from "./format-date/index.js";
|
|
2
|
+
import type { DocSourceEntry } from "./doc-sources/types.js";
|
|
2
3
|
import type { CategoryListOptions } from "./category-list/model.js";
|
|
3
4
|
/**
|
|
4
5
|
* Tag governance enforcement level.
|
|
@@ -594,16 +595,8 @@ export interface Settings {
|
|
|
594
595
|
bodyFootUtilArea: BodyFootUtilAreaConfig | false;
|
|
595
596
|
htmlPreview: HtmlPreviewConfig | undefined;
|
|
596
597
|
versions: VersionConfig[] | false;
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
projectRoot?: string;
|
|
600
|
-
scanRoot?: string;
|
|
601
|
-
} | false;
|
|
602
|
-
codexResources: {
|
|
603
|
-
codexDir: string;
|
|
604
|
-
projectRoot?: string;
|
|
605
|
-
scanRoot?: string;
|
|
606
|
-
} | false;
|
|
598
|
+
/** Files outside `docsDir` baked into nested documentation routes. */
|
|
599
|
+
docSources: DocSourceEntry[];
|
|
607
600
|
defaultLocaleOnlyPrefixes: string[];
|
|
608
601
|
footer: FooterConfig | false;
|
|
609
602
|
headerNav: HeaderNavItem[];
|
|
@@ -766,3 +759,4 @@ export interface Settings {
|
|
|
766
759
|
*/
|
|
767
760
|
themePacks?: string[];
|
|
768
761
|
}
|
|
762
|
+
export type { DocSourceAssetSelection, DocSourceCustomEntry, DocSourceEntry, DocSourceFormat, DocSourceMapping, DocSourceMissingPolicy, DocSourcePresetEntry, DocSourcePresetName, } from "./doc-sources/types.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zudo-doc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "zudo-doc framework primitives layer that sits on top of zfb's engine — sidebar, theme, TOC, breadcrumb, layouts, head injection, View Transitions, SSR-skip wrappers (per ADR-003).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -183,13 +183,9 @@
|
|
|
183
183
|
"types": "./dist/plugins/search-index.d.ts",
|
|
184
184
|
"default": "./dist/plugins/search-index.js"
|
|
185
185
|
},
|
|
186
|
-
"./plugins/
|
|
187
|
-
"types": "./dist/plugins/
|
|
188
|
-
"default": "./dist/plugins/
|
|
189
|
-
},
|
|
190
|
-
"./plugins/codex-resources": {
|
|
191
|
-
"types": "./dist/plugins/codex-resources.d.ts",
|
|
192
|
-
"default": "./dist/plugins/codex-resources.js"
|
|
186
|
+
"./plugins/doc-sources": {
|
|
187
|
+
"types": "./dist/plugins/doc-sources.d.ts",
|
|
188
|
+
"default": "./dist/plugins/doc-sources.js"
|
|
193
189
|
},
|
|
194
190
|
"./plugins/routes": {
|
|
195
191
|
"types": "./dist/plugins/routes.d.ts",
|
|
@@ -769,10 +765,10 @@
|
|
|
769
765
|
"peerDependencies": {
|
|
770
766
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
771
767
|
"@takazudo/zdtp": "^0.5.2 || ^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0",
|
|
772
|
-
"@takazudo/zfb": "^7.
|
|
773
|
-
"@takazudo/zfb-md-wasm": "^7.
|
|
774
|
-
"@takazudo/zfb-runtime": "^7.
|
|
775
|
-
"@takazudo/zudo-doc-history-server": "^
|
|
768
|
+
"@takazudo/zfb": "^7.2.0",
|
|
769
|
+
"@takazudo/zfb-md-wasm": "^7.2.0",
|
|
770
|
+
"@takazudo/zfb-runtime": "^7.2.0",
|
|
771
|
+
"@takazudo/zudo-doc-history-server": "^14.0.0",
|
|
776
772
|
"diff": "^8.0.0 || ^9.0.0",
|
|
777
773
|
"katex": "^0.18.2 || ^0.19.0",
|
|
778
774
|
"zod": "^4.3.6"
|
|
@@ -798,7 +794,7 @@
|
|
|
798
794
|
}
|
|
799
795
|
},
|
|
800
796
|
"dependencies": {
|
|
801
|
-
"@inquirer/prompts": "^8.
|
|
797
|
+
"@inquirer/prompts": "^8.8.1",
|
|
802
798
|
"esbuild": "^0.28.2",
|
|
803
799
|
"fs-extra": "^11.4.1",
|
|
804
800
|
"minimist": "^1.2.8",
|
|
@@ -812,22 +808,22 @@
|
|
|
812
808
|
"devDependencies": {
|
|
813
809
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
814
810
|
"@takazudo/mdx-formatter": "1.3.1",
|
|
815
|
-
"@takazudo/zfb": "7.
|
|
816
|
-
"@takazudo/zfb-md-wasm": "7.
|
|
817
|
-
"@takazudo/zfb-runtime": "7.
|
|
811
|
+
"@takazudo/zfb": "7.2.0",
|
|
812
|
+
"@takazudo/zfb-md-wasm": "7.2.0",
|
|
813
|
+
"@takazudo/zfb-runtime": "7.2.0",
|
|
818
814
|
"@types/fs-extra": "^11.0.4",
|
|
819
815
|
"@types/minimist": "^1.2.5",
|
|
820
816
|
"@types/node": "^26.6.6",
|
|
821
817
|
"@types/pluralize": "^0.0.33",
|
|
818
|
+
"@typescript/typescript6": "^6.0.2",
|
|
822
819
|
"diff8": "npm:diff@8.0.4",
|
|
823
820
|
"happy-dom": "^21.0.4",
|
|
824
821
|
"katex": "^0.19.1",
|
|
825
|
-
"@typescript/typescript6": "^6.0.2",
|
|
826
822
|
"tsup": "^9.0.0",
|
|
827
823
|
"typescript": "^7.0.2",
|
|
828
|
-
"vitest": "5.1.
|
|
824
|
+
"vitest": "5.1.1",
|
|
829
825
|
"zod": "^4.6.7",
|
|
830
|
-
"@takazudo/zudo-doc-history-server": "
|
|
826
|
+
"@takazudo/zudo-doc-history-server": "14.0.0"
|
|
831
827
|
},
|
|
832
828
|
"scripts": {
|
|
833
829
|
"gen:search-widget-script": "node scripts/gen-search-widget-script.mjs",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { runClaudeResourcesPreStep } from "./internal/claude-resources/index.js";
|
|
2
|
-
import { runClaudeResourcesPreStep as runClaudeResourcesPreStep2 } from "./internal/claude-resources/index.js";
|
|
3
|
-
const PLUGIN_NAME = "@takazudo/zudo-doc-claude-resources";
|
|
4
|
-
const plugin = {
|
|
5
|
-
name: PLUGIN_NAME,
|
|
6
|
-
async preBuild(ctx) {
|
|
7
|
-
const claudeDir = ctx.options["claudeDir"];
|
|
8
|
-
if (typeof claudeDir !== "string" || claudeDir.length === 0) {
|
|
9
|
-
throw new Error(
|
|
10
|
-
`[${PLUGIN_NAME}] preBuild: options.claudeDir must be a non-empty string (got ${JSON.stringify(claudeDir)})`
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
const projectRootOpt = ctx.options["projectRoot"];
|
|
14
|
-
const scanRootOpt = ctx.options["scanRoot"];
|
|
15
|
-
const docsDirOpt = ctx.options["docsDir"];
|
|
16
|
-
const localesOpt = ctx.options["locales"];
|
|
17
|
-
const defaultLocaleOpt = ctx.options["defaultLocale"];
|
|
18
|
-
const translationsOpt = ctx.options["translations"];
|
|
19
|
-
const defaultLocaleOnlyPrefixesOpt = ctx.options["defaultLocaleOnlyPrefixes"];
|
|
20
|
-
const result = await runClaudeResourcesPreStep({
|
|
21
|
-
claudeDir,
|
|
22
|
-
projectRoot: typeof projectRootOpt === "string" ? projectRootOpt : ctx.projectRoot,
|
|
23
|
-
scanRoot: typeof scanRootOpt === "string" ? scanRootOpt : void 0,
|
|
24
|
-
docsDir: typeof docsDirOpt === "string" ? docsDirOpt : "src/content/docs",
|
|
25
|
-
locales: isRecord(localesOpt) ? localesOpt : void 0,
|
|
26
|
-
defaultLocale: typeof defaultLocaleOpt === "string" ? defaultLocaleOpt : void 0,
|
|
27
|
-
translations: isRecord(translationsOpt) ? translationsOpt : void 0,
|
|
28
|
-
defaultLocaleOnlyPrefixes: isStringArray(defaultLocaleOnlyPrefixesOpt) ? defaultLocaleOnlyPrefixesOpt : void 0
|
|
29
|
-
});
|
|
30
|
-
ctx.logger.info(
|
|
31
|
-
`claude-resources: ${result.claudemd} CLAUDE.md, ${result.commands} commands, ${result.skills} skills, ${result.agents} agents`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function isRecord(value) {
|
|
36
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
|
-
}
|
|
38
|
-
function isStringArray(value) {
|
|
39
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
40
|
-
}
|
|
41
|
-
var claude_resources_default = plugin;
|
|
42
|
-
export {
|
|
43
|
-
claude_resources_default as default,
|
|
44
|
-
runClaudeResourcesPreStep2 as runClaudeResourcesPreStep
|
|
45
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { runCodexResourcesPreStep } from "./internal/codex-resources/index.js";
|
|
2
|
-
import { runCodexResourcesPreStep as runCodexResourcesPreStep2 } from "./internal/codex-resources/index.js";
|
|
3
|
-
const PLUGIN_NAME = "@takazudo/zudo-doc-codex-resources";
|
|
4
|
-
const plugin = {
|
|
5
|
-
name: PLUGIN_NAME,
|
|
6
|
-
async preBuild(ctx) {
|
|
7
|
-
const codexDir = ctx.options["codexDir"];
|
|
8
|
-
if (typeof codexDir !== "string" || codexDir.length === 0) {
|
|
9
|
-
throw new Error(
|
|
10
|
-
`[${PLUGIN_NAME}] preBuild: options.codexDir must be a non-empty string (got ${JSON.stringify(codexDir)})`
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
const projectRootOpt = ctx.options["projectRoot"];
|
|
14
|
-
const scanRootOpt = ctx.options["scanRoot"];
|
|
15
|
-
const docsDirOpt = ctx.options["docsDir"];
|
|
16
|
-
const localesOpt = ctx.options["locales"];
|
|
17
|
-
const defaultLocaleOpt = ctx.options["defaultLocale"];
|
|
18
|
-
const translationsOpt = ctx.options["translations"];
|
|
19
|
-
const defaultLocaleOnlyPrefixesOpt = ctx.options["defaultLocaleOnlyPrefixes"];
|
|
20
|
-
const result = runCodexResourcesPreStep({
|
|
21
|
-
codexDir,
|
|
22
|
-
projectRoot: typeof projectRootOpt === "string" ? projectRootOpt : ctx.projectRoot,
|
|
23
|
-
scanRoot: typeof scanRootOpt === "string" ? scanRootOpt : void 0,
|
|
24
|
-
docsDir: typeof docsDirOpt === "string" ? docsDirOpt : "src/content/docs",
|
|
25
|
-
locales: isRecord(localesOpt) ? localesOpt : void 0,
|
|
26
|
-
defaultLocale: typeof defaultLocaleOpt === "string" ? defaultLocaleOpt : void 0,
|
|
27
|
-
translations: isRecord(translationsOpt) ? translationsOpt : void 0,
|
|
28
|
-
defaultLocaleOnlyPrefixes: isStringArray(defaultLocaleOnlyPrefixesOpt) ? defaultLocaleOnlyPrefixesOpt : void 0
|
|
29
|
-
});
|
|
30
|
-
ctx.logger.info(
|
|
31
|
-
`codex-resources: ${result.agentsMd} AGENTS.md, ${result.config} config, ${result.agents} agents, ${result.hooks} hooks, ${result.rules} rules, ${result.skills} skills`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function isRecord(value) {
|
|
36
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
|
-
}
|
|
38
|
-
function isStringArray(value) {
|
|
39
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
40
|
-
}
|
|
41
|
-
var codex_resources_default = plugin;
|
|
42
|
-
export {
|
|
43
|
-
codex_resources_default as default,
|
|
44
|
-
runCodexResourcesPreStep2 as runCodexResourcesPreStep
|
|
45
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type ResourceLocaleConfig, type ResourceTranslations } from "../resource-docs-shared/index.js";
|
|
2
|
-
export interface ClaudeResourcesConfig {
|
|
3
|
-
claudeDir: string;
|
|
4
|
-
/**
|
|
5
|
-
* The doc site's own root. Anchors project-specific excludes and defaults
|
|
6
|
-
* `scanRoot`. Note this does NOT itself decide where the `CLAUDE.md` walk
|
|
7
|
-
* runs — that is `scanRoot`.
|
|
8
|
-
*/
|
|
9
|
-
projectRoot?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Root of the `CLAUDE.md` walk and the base for the generated pages'
|
|
12
|
-
* relative paths, titles, and slugs. Defaults to `projectRoot`, so a caller
|
|
13
|
-
* that sets only `projectRoot` gets the pre-`scanRoot` behaviour.
|
|
14
|
-
*/
|
|
15
|
-
scanRoot?: string;
|
|
16
|
-
docsDir: string;
|
|
17
|
-
/** Additional locale content roots, resolved by the runner when possible. */
|
|
18
|
-
locales?: Record<string, ResourceLocaleConfig>;
|
|
19
|
-
/** Default locale code (the unprefixed docs directory). */
|
|
20
|
-
defaultLocale?: string;
|
|
21
|
-
/** UI-string translation table used by localized generated indexes. */
|
|
22
|
-
translations?: ResourceTranslations;
|
|
23
|
-
/** Route prefixes that must not receive non-default-locale indexes. */
|
|
24
|
-
defaultLocaleOnlyPrefixes?: string[];
|
|
25
|
-
}
|
|
26
|
-
export declare function generateClaudeResourcesDocs(config: ClaudeResourcesConfig): {
|
|
27
|
-
claudemd: number;
|
|
28
|
-
commands: number;
|
|
29
|
-
skills: number;
|
|
30
|
-
agents: number;
|
|
31
|
-
};
|
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
assertNotIndexReserved,
|
|
5
|
-
cleanDir,
|
|
6
|
-
downgradeRepoRelativeLinks,
|
|
7
|
-
ensureDir,
|
|
8
|
-
escapeForMdx,
|
|
9
|
-
formatFrontmatterString,
|
|
10
|
-
findNamedFiles,
|
|
11
|
-
generateSkillsCategory,
|
|
12
|
-
parseFrontmatter,
|
|
13
|
-
removeGeneratedIndex,
|
|
14
|
-
resolveLocaleDirs,
|
|
15
|
-
resolveResourceLabel,
|
|
16
|
-
shouldEmitResourceLocaleRoute,
|
|
17
|
-
writeCategoryIndex,
|
|
18
|
-
writeGeneratedIndex
|
|
19
|
-
} from "../resource-docs-shared/index.js";
|
|
20
|
-
const DEFAULT_RESOURCE_LOCALE = "en";
|
|
21
|
-
function resourceLabel(config, locale, key, fallbackLiteral) {
|
|
22
|
-
return resolveResourceLabel({
|
|
23
|
-
translations: config.translations,
|
|
24
|
-
locale,
|
|
25
|
-
defaultLocale: config.defaultLocale,
|
|
26
|
-
key,
|
|
27
|
-
fallbackLiteral
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function defaultResourceLabel(config, key, fallbackLiteral) {
|
|
31
|
-
return resourceLabel(
|
|
32
|
-
config,
|
|
33
|
-
config.defaultLocale ?? DEFAULT_RESOURCE_LOCALE,
|
|
34
|
-
key,
|
|
35
|
-
fallbackLiteral
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
function generateClaudemdDocs(config) {
|
|
39
|
-
const projectRoot = config.projectRoot ?? config.claudeDir;
|
|
40
|
-
const scanRoot = config.scanRoot ?? projectRoot;
|
|
41
|
-
const outputDir = path.join(config.docsDir, "claude-md");
|
|
42
|
-
cleanDir(outputDir);
|
|
43
|
-
const excludeDirs = [
|
|
44
|
-
path.join(scanRoot, "e2e", "fixtures"),
|
|
45
|
-
path.join(projectRoot, "e2e", "fixtures"),
|
|
46
|
-
path.join(config.docsDir)
|
|
47
|
-
];
|
|
48
|
-
const files = findNamedFiles(scanRoot, excludeDirs, ["CLAUDE.md"]);
|
|
49
|
-
if (files.length === 0) return [];
|
|
50
|
-
ensureDir(outputDir);
|
|
51
|
-
const items = [];
|
|
52
|
-
for (const filePath of files) {
|
|
53
|
-
const relPath = path.relative(scanRoot, filePath);
|
|
54
|
-
const displayPath = `/${relPath}`;
|
|
55
|
-
const dirPart = path.dirname(relPath);
|
|
56
|
-
const slug = dirPart === "." ? "root" : dirPart.replace(/\//g, "--");
|
|
57
|
-
items.push({ displayPath, slug, relPath, absPath: filePath });
|
|
58
|
-
}
|
|
59
|
-
items.sort((a, b) => {
|
|
60
|
-
if (a.slug === "root") return -1;
|
|
61
|
-
if (b.slug === "root") return 1;
|
|
62
|
-
return a.displayPath.localeCompare(b.displayPath);
|
|
63
|
-
});
|
|
64
|
-
const emittedSlugs = /* @__PURE__ */ new Map();
|
|
65
|
-
items.forEach((item, index) => {
|
|
66
|
-
assertNotIndexReserved(
|
|
67
|
-
item.slug,
|
|
68
|
-
`claude-resources: "${item.relPath}" maps to the reserved slug "index", which is used for the category metadata file. Rename the directory to resolve the conflict.`
|
|
69
|
-
);
|
|
70
|
-
const previous = emittedSlugs.get(item.slug);
|
|
71
|
-
if (previous !== void 0) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`claude-resources: slug collision \u2014 "${item.slug}" is produced by both "${previous}" and "${item.relPath}". Rename one of the directories to resolve the conflict.`
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
emittedSlugs.set(item.slug, item.relPath);
|
|
77
|
-
const content = fs.readFileSync(item.absPath, "utf8");
|
|
78
|
-
const mdx = `---
|
|
79
|
-
title: ${formatFrontmatterString(item.displayPath)}
|
|
80
|
-
description: ${formatFrontmatterString(`CLAUDE.md at ${item.displayPath}`)}
|
|
81
|
-
sidebar_position: ${index + 1}
|
|
82
|
-
sidebar_label: ${formatFrontmatterString(item.relPath)}
|
|
83
|
-
generated: true
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
**Path:** \`${item.relPath}\`
|
|
87
|
-
|
|
88
|
-
${escapeForMdx(downgradeRepoRelativeLinks(content.trim()))}
|
|
89
|
-
`;
|
|
90
|
-
fs.writeFileSync(path.join(outputDir, `${item.slug}.mdx`), mdx);
|
|
91
|
-
});
|
|
92
|
-
writeCategoryIndex(
|
|
93
|
-
outputDir,
|
|
94
|
-
defaultResourceLabel(config, "resource.claudeMd.label", "CLAUDE.md"),
|
|
95
|
-
900,
|
|
96
|
-
defaultResourceLabel(
|
|
97
|
-
config,
|
|
98
|
-
"resource.claudeMd.description",
|
|
99
|
-
"Project-specific instructions"
|
|
100
|
-
),
|
|
101
|
-
formatFrontmatterString
|
|
102
|
-
);
|
|
103
|
-
return items;
|
|
104
|
-
}
|
|
105
|
-
function generateCommandsDocs(config) {
|
|
106
|
-
const commandsDir = path.join(config.claudeDir, "commands");
|
|
107
|
-
const outputDir = path.join(config.docsDir, "claude-commands");
|
|
108
|
-
cleanDir(outputDir);
|
|
109
|
-
if (!fs.existsSync(commandsDir)) return [];
|
|
110
|
-
const files = fs.readdirSync(commandsDir).filter((f) => f.endsWith(".md"));
|
|
111
|
-
if (files.length === 0) return [];
|
|
112
|
-
ensureDir(outputDir);
|
|
113
|
-
const items = [];
|
|
114
|
-
for (const file of files) {
|
|
115
|
-
const content = fs.readFileSync(path.join(commandsDir, file), "utf8");
|
|
116
|
-
const parsed = parseFrontmatter(content);
|
|
117
|
-
if (!parsed) continue;
|
|
118
|
-
const name = file.replace(/\.md$/, "");
|
|
119
|
-
assertNotIndexReserved(
|
|
120
|
-
name,
|
|
121
|
-
`claude-resources: ".claude/commands/index.md" uses the reserved name "index", which is used for the category metadata file. Rename the command file to resolve the conflict.`
|
|
122
|
-
);
|
|
123
|
-
const description = parsed.data.description || "";
|
|
124
|
-
items.push({ name, description });
|
|
125
|
-
const mdx = `---
|
|
126
|
-
title: ${formatFrontmatterString(name)}
|
|
127
|
-
description: ${formatFrontmatterString(description)}
|
|
128
|
-
sidebar_label: ${formatFrontmatterString(name)}
|
|
129
|
-
generated: true
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
${escapeForMdx(downgradeRepoRelativeLinks(parsed.content.trim()))}
|
|
133
|
-
`;
|
|
134
|
-
fs.writeFileSync(path.join(outputDir, `${name}.mdx`), mdx);
|
|
135
|
-
}
|
|
136
|
-
items.sort((a, b) => a.name.localeCompare(b.name));
|
|
137
|
-
writeCategoryIndex(
|
|
138
|
-
outputDir,
|
|
139
|
-
defaultResourceLabel(config, "resource.claudeCommands.label", "Commands"),
|
|
140
|
-
901,
|
|
141
|
-
defaultResourceLabel(
|
|
142
|
-
config,
|
|
143
|
-
"resource.claudeCommands.description",
|
|
144
|
-
"Custom slash commands"
|
|
145
|
-
),
|
|
146
|
-
formatFrontmatterString
|
|
147
|
-
);
|
|
148
|
-
return items;
|
|
149
|
-
}
|
|
150
|
-
function generateSkillsDocs(config) {
|
|
151
|
-
return generateSkillsCategory({
|
|
152
|
-
skillsDirs: [path.join(config.claudeDir, "skills")],
|
|
153
|
-
outputDir: path.join(config.docsDir, "claude-skills"),
|
|
154
|
-
label: defaultResourceLabel(config, "resource.claudeSkills.label", "Skills"),
|
|
155
|
-
position: 902,
|
|
156
|
-
description: defaultResourceLabel(
|
|
157
|
-
config,
|
|
158
|
-
"resource.claudeSkills.description",
|
|
159
|
-
"Skill packages"
|
|
160
|
-
),
|
|
161
|
-
sourceLabel: ".claude/skills",
|
|
162
|
-
renderFrontmatterString: formatFrontmatterString
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function generateAgentsDocs(config) {
|
|
166
|
-
const agentsDir = path.join(config.claudeDir, "agents");
|
|
167
|
-
const outputDir = path.join(config.docsDir, "claude-agents");
|
|
168
|
-
cleanDir(outputDir);
|
|
169
|
-
if (!fs.existsSync(agentsDir)) return [];
|
|
170
|
-
const files = fs.readdirSync(agentsDir).filter((f) => f.endsWith(".md"));
|
|
171
|
-
if (files.length === 0) return [];
|
|
172
|
-
ensureDir(outputDir);
|
|
173
|
-
const items = [];
|
|
174
|
-
for (const file of files) {
|
|
175
|
-
const content = fs.readFileSync(path.join(agentsDir, file), "utf8");
|
|
176
|
-
const parsed = parseFrontmatter(content);
|
|
177
|
-
if (!parsed) continue;
|
|
178
|
-
const name = parsed.data.name || file.replace(/\.md$/, "");
|
|
179
|
-
const description = parsed.data.description || "";
|
|
180
|
-
const model = parsed.data.model || "";
|
|
181
|
-
const fileSlug = file.replace(/\.md$/, "");
|
|
182
|
-
assertNotIndexReserved(
|
|
183
|
-
fileSlug,
|
|
184
|
-
`claude-resources: ".claude/agents/index.md" uses the reserved name "index", which is used for the category metadata file. Rename the agent file to resolve the conflict.`
|
|
185
|
-
);
|
|
186
|
-
items.push({ name, file: fileSlug, description, model });
|
|
187
|
-
const modelBadge = model ? `**Model:** \`${model}\`
|
|
188
|
-
` : "";
|
|
189
|
-
const mdx = `---
|
|
190
|
-
title: ${formatFrontmatterString(name)}
|
|
191
|
-
description: ${formatFrontmatterString(description)}
|
|
192
|
-
sidebar_label: ${formatFrontmatterString(name)}
|
|
193
|
-
generated: true
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
${modelBadge}
|
|
197
|
-
${escapeForMdx(downgradeRepoRelativeLinks(parsed.content.trim()))}
|
|
198
|
-
`;
|
|
199
|
-
fs.writeFileSync(path.join(outputDir, `${fileSlug}.mdx`), mdx);
|
|
200
|
-
}
|
|
201
|
-
items.sort((a, b) => a.name.localeCompare(b.name));
|
|
202
|
-
writeCategoryIndex(
|
|
203
|
-
outputDir,
|
|
204
|
-
defaultResourceLabel(config, "resource.claudeAgents.label", "Agents"),
|
|
205
|
-
903,
|
|
206
|
-
defaultResourceLabel(
|
|
207
|
-
config,
|
|
208
|
-
"resource.claudeAgents.description",
|
|
209
|
-
"Custom subagents"
|
|
210
|
-
),
|
|
211
|
-
formatFrontmatterString
|
|
212
|
-
);
|
|
213
|
-
return items;
|
|
214
|
-
}
|
|
215
|
-
function generateOverviewIndex(config, {
|
|
216
|
-
hasCommands,
|
|
217
|
-
hasSkills,
|
|
218
|
-
hasAgents,
|
|
219
|
-
hasClaudemd
|
|
220
|
-
}) {
|
|
221
|
-
const outputDir = path.join(config.docsDir, "claude");
|
|
222
|
-
cleanDir(outputDir);
|
|
223
|
-
ensureDir(outputDir);
|
|
224
|
-
const categorySlugs = [];
|
|
225
|
-
if (hasClaudemd) categorySlugs.push("claude-md");
|
|
226
|
-
if (hasSkills) categorySlugs.push("claude-skills");
|
|
227
|
-
if (hasAgents) categorySlugs.push("claude-agents");
|
|
228
|
-
if (hasCommands) categorySlugs.push("claude-commands");
|
|
229
|
-
const index = renderOverviewIndex(
|
|
230
|
-
config,
|
|
231
|
-
config.defaultLocale ?? DEFAULT_RESOURCE_LOCALE,
|
|
232
|
-
categorySlugs
|
|
233
|
-
);
|
|
234
|
-
fs.writeFileSync(path.join(outputDir, "index.mdx"), index);
|
|
235
|
-
for (const [locale, localeConfig] of Object.entries(config.locales ?? {})) {
|
|
236
|
-
emitLocaleCategoryIndexes(config, locale, localeConfig.dir, {
|
|
237
|
-
hasCommands,
|
|
238
|
-
hasSkills,
|
|
239
|
-
hasAgents,
|
|
240
|
-
hasClaudemd
|
|
241
|
-
});
|
|
242
|
-
const overviewPath = path.join(localeConfig.dir, "claude", "index.mdx");
|
|
243
|
-
if (shouldEmitResourceLocaleRoute({
|
|
244
|
-
slug: "claude",
|
|
245
|
-
locale,
|
|
246
|
-
defaultLocale: config.defaultLocale,
|
|
247
|
-
defaultLocaleOnlyPrefixes: config.defaultLocaleOnlyPrefixes
|
|
248
|
-
})) {
|
|
249
|
-
writeGeneratedIndex(
|
|
250
|
-
overviewPath,
|
|
251
|
-
renderOverviewIndex(config, locale, categorySlugs),
|
|
252
|
-
"/docs/claude/"
|
|
253
|
-
);
|
|
254
|
-
} else {
|
|
255
|
-
removeGeneratedIndex(overviewPath);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function renderOverviewIndex(config, locale, categorySlugs) {
|
|
260
|
-
return `---
|
|
261
|
-
title: ${formatFrontmatterString(resourceLabel(config, locale, "resource.claude.title", "Claude"))}
|
|
262
|
-
description: ${formatFrontmatterString(resourceLabel(
|
|
263
|
-
config,
|
|
264
|
-
locale,
|
|
265
|
-
"resource.claude.description",
|
|
266
|
-
"Claude Code configuration reference."
|
|
267
|
-
))}
|
|
268
|
-
sidebar_position: 899
|
|
269
|
-
generated: true
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## ${escapeForMdx(resourceLabel(config, locale, "resource.resources", "Resources"))}
|
|
273
|
-
|
|
274
|
-
<CategoryNav categories={${JSON.stringify(categorySlugs)}} />
|
|
275
|
-
`;
|
|
276
|
-
}
|
|
277
|
-
function emitLocaleCategoryIndexes(config, locale, localeDir, presence) {
|
|
278
|
-
writeLocaleCategoryIndex(
|
|
279
|
-
config,
|
|
280
|
-
locale,
|
|
281
|
-
localeDir,
|
|
282
|
-
"claude-md",
|
|
283
|
-
presence.hasClaudemd,
|
|
284
|
-
"resource.claudeMd.label",
|
|
285
|
-
"CLAUDE.md",
|
|
286
|
-
900,
|
|
287
|
-
"resource.claudeMd.description",
|
|
288
|
-
"Project-specific instructions"
|
|
289
|
-
);
|
|
290
|
-
writeLocaleCategoryIndex(
|
|
291
|
-
config,
|
|
292
|
-
locale,
|
|
293
|
-
localeDir,
|
|
294
|
-
"claude-commands",
|
|
295
|
-
presence.hasCommands,
|
|
296
|
-
"resource.claudeCommands.label",
|
|
297
|
-
"Commands",
|
|
298
|
-
901,
|
|
299
|
-
"resource.claudeCommands.description",
|
|
300
|
-
"Custom slash commands"
|
|
301
|
-
);
|
|
302
|
-
writeLocaleCategoryIndex(
|
|
303
|
-
config,
|
|
304
|
-
locale,
|
|
305
|
-
localeDir,
|
|
306
|
-
"claude-skills",
|
|
307
|
-
presence.hasSkills,
|
|
308
|
-
"resource.claudeSkills.label",
|
|
309
|
-
"Skills",
|
|
310
|
-
902,
|
|
311
|
-
"resource.claudeSkills.description",
|
|
312
|
-
"Skill packages"
|
|
313
|
-
);
|
|
314
|
-
writeLocaleCategoryIndex(
|
|
315
|
-
config,
|
|
316
|
-
locale,
|
|
317
|
-
localeDir,
|
|
318
|
-
"claude-agents",
|
|
319
|
-
presence.hasAgents,
|
|
320
|
-
"resource.claudeAgents.label",
|
|
321
|
-
"Agents",
|
|
322
|
-
903,
|
|
323
|
-
"resource.claudeAgents.description",
|
|
324
|
-
"Custom subagents"
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
function writeLocaleCategoryIndex(config, locale, localeDir, categoryDir, present, labelKey, fallbackLabel, position, descriptionKey, fallbackDescription) {
|
|
328
|
-
const indexPath = path.join(localeDir, categoryDir, "index.mdx");
|
|
329
|
-
if (!present || !shouldEmitResourceLocaleRoute({
|
|
330
|
-
slug: categoryDir,
|
|
331
|
-
locale,
|
|
332
|
-
defaultLocale: config.defaultLocale,
|
|
333
|
-
defaultLocaleOnlyPrefixes: config.defaultLocaleOnlyPrefixes
|
|
334
|
-
})) {
|
|
335
|
-
removeGeneratedIndex(indexPath);
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
writeCategoryIndex(
|
|
339
|
-
path.join(localeDir, categoryDir),
|
|
340
|
-
resourceLabel(config, locale, labelKey, fallbackLabel),
|
|
341
|
-
position,
|
|
342
|
-
resourceLabel(config, locale, descriptionKey, fallbackDescription),
|
|
343
|
-
formatFrontmatterString,
|
|
344
|
-
(absolutePath, content) => writeGeneratedIndex(absolutePath, content, `/docs/${categoryDir}/`)
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
function generateClaudeResourcesDocs(config) {
|
|
348
|
-
const normalizedConfig = config.locales === void 0 ? config : {
|
|
349
|
-
...config,
|
|
350
|
-
locales: resolveLocaleDirs({
|
|
351
|
-
projectRoot: path.resolve(config.projectRoot ?? config.claudeDir),
|
|
352
|
-
docsDir: config.docsDir,
|
|
353
|
-
locales: config.locales
|
|
354
|
-
})
|
|
355
|
-
};
|
|
356
|
-
const claudemds = generateClaudemdDocs(normalizedConfig);
|
|
357
|
-
const commands = generateCommandsDocs(normalizedConfig);
|
|
358
|
-
const skills = generateSkillsDocs(normalizedConfig);
|
|
359
|
-
const agents = generateAgentsDocs(normalizedConfig);
|
|
360
|
-
generateOverviewIndex(normalizedConfig, {
|
|
361
|
-
hasClaudemd: claudemds.length > 0,
|
|
362
|
-
hasCommands: commands.length > 0,
|
|
363
|
-
hasSkills: skills.length > 0,
|
|
364
|
-
hasAgents: agents.length > 0
|
|
365
|
-
});
|
|
366
|
-
return {
|
|
367
|
-
claudemd: claudemds.length,
|
|
368
|
-
commands: commands.length,
|
|
369
|
-
skills: skills.length,
|
|
370
|
-
agents: agents.length
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
export {
|
|
374
|
-
generateClaudeResourcesDocs
|
|
375
|
-
};
|