@takazudo/zudo-doc 5.14.0 → 5.16.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 (101) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/asset-components/asset-card.js +3 -1
  3. package/dist/asset-components/asset-code.js +2 -0
  4. package/dist/asset-components/shared.d.ts +5 -0
  5. package/dist/asset-components/shared.js +7 -0
  6. package/dist/asset-index-page/index.d.ts +1 -0
  7. package/dist/asset-index-page/index.js +10 -9
  8. package/dist/asset-page/index.d.ts +20 -2
  9. package/dist/asset-page/index.js +43 -24
  10. package/dist/asset-path/index.d.ts +2 -0
  11. package/dist/asset-path/index.js +11 -1
  12. package/dist/chrome/derive.js +31 -6
  13. package/dist/compiled.css +12 -0
  14. package/dist/config.d.ts +15 -6
  15. package/dist/config.js +2 -0
  16. package/dist/content/content-link.d.ts +5 -1
  17. package/dist/content/content-link.js +4 -1
  18. package/dist/doc-content-header/index.js +1 -1
  19. package/dist/doc-page-shell/index.js +1 -1
  20. package/dist/factory-context/index.d.ts +7 -3
  21. package/dist/header-with-defaults/index.js +2 -0
  22. package/dist/home-page/index.js +1 -1
  23. package/dist/html-preview-wrapper/html-preview-wrapper.d.ts +41 -7
  24. package/dist/html-preview-wrapper/html-preview-wrapper.js +86 -2
  25. package/dist/html-preview-wrapper/html-preview.d.ts +29 -4
  26. package/dist/html-preview-wrapper/html-preview.js +64 -6
  27. package/dist/html-preview-wrapper/index.d.ts +1 -1
  28. package/dist/html-preview-wrapper/preview-auto-height.d.ts +24 -0
  29. package/dist/html-preview-wrapper/preview-auto-height.js +120 -0
  30. package/dist/html-preview-wrapper/preview-base.d.ts +21 -1
  31. package/dist/html-preview-wrapper/preview-base.js +99 -50
  32. package/dist/i18n-defaults/index.d.ts +5 -3
  33. package/dist/i18n-defaults/index.js +89 -0
  34. package/dist/i18n-version/language-switcher.d.ts +10 -5
  35. package/dist/i18n-version/language-switcher.js +115 -22
  36. package/dist/i18n-version/types.d.ts +1 -1
  37. package/dist/mdx-components/index.d.ts +4 -0
  38. package/dist/mdx-components/index.js +11 -2
  39. package/dist/nav-indexing/versions-page-content.js +1 -1
  40. package/dist/plugins/claude-resources.js +15 -1
  41. package/dist/plugins/codex-resources.js +15 -1
  42. package/dist/plugins/internal/asset-viewer/asset-pages.d.ts +53 -0
  43. package/dist/plugins/internal/asset-viewer/asset-pages.js +98 -0
  44. package/dist/plugins/internal/asset-viewer/scan.d.ts +18 -1
  45. package/dist/plugins/internal/asset-viewer/scan.js +34 -27
  46. package/dist/plugins/internal/claude-resources/generate.d.ts +9 -0
  47. package/dist/plugins/internal/claude-resources/generate.js +188 -18
  48. package/dist/plugins/internal/claude-resources/index.d.ts +9 -0
  49. package/dist/plugins/internal/claude-resources/index.js +13 -1
  50. package/dist/plugins/internal/codex-resources/agents-md.js +15 -2
  51. package/dist/plugins/internal/codex-resources/agents.js +15 -2
  52. package/dist/plugins/internal/codex-resources/config.js +15 -2
  53. package/dist/plugins/internal/codex-resources/generate.d.ts +9 -0
  54. package/dist/plugins/internal/codex-resources/generate.js +19 -7
  55. package/dist/plugins/internal/codex-resources/hooks.js +15 -2
  56. package/dist/plugins/internal/codex-resources/index.d.ts +9 -0
  57. package/dist/plugins/internal/codex-resources/index.js +13 -1
  58. package/dist/plugins/internal/codex-resources/overview.js +136 -7
  59. package/dist/plugins/internal/codex-resources/rules.js +15 -2
  60. package/dist/plugins/internal/codex-resources/skills.js +16 -3
  61. package/dist/plugins/internal/llms-txt/assets.d.ts +24 -0
  62. package/dist/plugins/internal/llms-txt/assets.js +65 -0
  63. package/dist/plugins/internal/llms-txt/dev-middleware.d.ts +5 -0
  64. package/dist/plugins/internal/llms-txt/dev-middleware.js +9 -1
  65. package/dist/plugins/internal/llms-txt/emit.js +21 -5
  66. package/dist/plugins/internal/llms-txt/generate.d.ts +3 -3
  67. package/dist/plugins/internal/llms-txt/generate.js +55 -2
  68. package/dist/plugins/internal/llms-txt/index.d.ts +4 -1
  69. package/dist/plugins/internal/llms-txt/index.js +4 -0
  70. package/dist/plugins/internal/llms-txt/types.d.ts +24 -0
  71. package/dist/plugins/internal/llms-txt/types.js +4 -0
  72. package/dist/plugins/internal/resource-docs-shared/fs.d.ts +33 -0
  73. package/dist/plugins/internal/resource-docs-shared/fs.js +82 -1
  74. package/dist/plugins/internal/resource-docs-shared/index.d.ts +4 -2
  75. package/dist/plugins/internal/resource-docs-shared/index.js +21 -1
  76. package/dist/plugins/internal/resource-docs-shared/labels.d.ts +24 -0
  77. package/dist/plugins/internal/resource-docs-shared/labels.js +14 -0
  78. package/dist/plugins/internal/resource-docs-shared/locale-routes.d.ts +16 -0
  79. package/dist/plugins/internal/resource-docs-shared/locale-routes.js +14 -0
  80. package/dist/plugins/internal/resource-docs-shared/mdx.d.ts +7 -1
  81. package/dist/plugins/internal/resource-docs-shared/mdx.js +2 -2
  82. package/dist/plugins/internal/search-index/collect.js +46 -1
  83. package/dist/plugins/internal/search-index/types.d.ts +6 -1
  84. package/dist/plugins/llms-txt.js +9 -1
  85. package/dist/plugins/routes.js +14 -0
  86. package/dist/plugins/search-index.js +10 -1
  87. package/dist/preset.d.ts +9 -1
  88. package/dist/preset.js +25 -4
  89. package/dist/route-context/index.js +5 -17
  90. package/dist/route-enumerators/index.d.ts +14 -1
  91. package/dist/route-enumerators/index.js +38 -0
  92. package/dist/routes/locale-files-path.d.ts +29 -0
  93. package/dist/routes/locale-files-path.js +52 -0
  94. package/dist/safelist.css +1 -1
  95. package/dist/settings.d.ts +15 -0
  96. package/dist/tag-pages/index.js +2 -2
  97. package/eject/asset-components/asset-card.tsx +2 -0
  98. package/eject/asset-components/asset-code.tsx +2 -0
  99. package/eject/asset-components/shared.tsx +16 -0
  100. package/package.json +13 -9
  101. package/routes-src/locale-files-path.tsx +73 -0
@@ -1,4 +1,5 @@
1
1
  import { generateClaudeResourcesDocs, type ClaudeResourcesConfig } from "./generate.js";
2
+ import { type ResourceLocaleConfig, type ResourceTranslations } from "../resource-docs-shared/index.js";
2
3
  /** Options accepted by the plugin's generator runner. */
3
4
  export interface ClaudeResourcesPluginOptions {
4
5
  /**
@@ -34,6 +35,14 @@ export interface ClaudeResourcesPluginOptions {
34
35
  * match the existing Astro integration's behaviour.
35
36
  */
36
37
  docsDir?: string;
38
+ /** Additional locale content roots, keyed by locale code. */
39
+ locales?: Record<string, ResourceLocaleConfig>;
40
+ /** Default locale code (the unprefixed docs directory). */
41
+ defaultLocale?: string;
42
+ /** UI-string translation table used by localized generated indexes. */
43
+ translations?: ResourceTranslations;
44
+ /** Route prefixes that must not receive non-default-locale indexes. */
45
+ defaultLocaleOnlyPrefixes?: string[];
37
46
  }
38
47
  /**
39
48
  * Imperative pre-step runner. Resolves relative paths against
@@ -2,17 +2,29 @@ import path from "node:path";
2
2
  import {
3
3
  generateClaudeResourcesDocs
4
4
  } from "./generate.js";
5
+ import {
6
+ resolveLocaleDirs
7
+ } from "../resource-docs-shared/index.js";
5
8
  function runClaudeResourcesPreStep(options) {
6
9
  const projectRoot = path.resolve(options.projectRoot ?? process.cwd());
7
10
  const claudeDir = path.isAbsolute(options.claudeDir) ? options.claudeDir : path.resolve(projectRoot, options.claudeDir);
8
11
  const scanRoot = options.scanRoot === void 0 ? projectRoot : path.isAbsolute(options.scanRoot) ? options.scanRoot : path.resolve(projectRoot, options.scanRoot);
9
12
  const docsDirInput = options.docsDir ?? "src/content/docs";
10
13
  const docsDir = path.isAbsolute(docsDirInput) ? docsDirInput : path.resolve(projectRoot, docsDirInput);
14
+ const locales = resolveLocaleDirs({
15
+ projectRoot,
16
+ docsDir,
17
+ locales: options.locales
18
+ });
11
19
  return generateClaudeResourcesDocs({
12
20
  claudeDir,
13
21
  projectRoot,
14
22
  scanRoot,
15
- docsDir
23
+ docsDir,
24
+ locales,
25
+ defaultLocale: options.defaultLocale,
26
+ translations: options.translations,
27
+ defaultLocaleOnlyPrefixes: options.defaultLocaleOnlyPrefixes
16
28
  });
17
29
  }
18
30
  export {
@@ -8,6 +8,7 @@ import {
8
8
  escapeForMdx,
9
9
  escapeMarkdownTableCell,
10
10
  findNamedFiles,
11
+ resolveResourceLabel,
11
12
  writeCategoryIndex
12
13
  } from "../resource-docs-shared/index.js";
13
14
  import { assertUniqueSlug, writeGeneratedPage } from "./utils.js";
@@ -58,9 +59,21 @@ ${escapeForMdx(
58
59
  });
59
60
  writeCategoryIndex(
60
61
  outputDir,
61
- "AGENTS.md",
62
+ resolveResourceLabel({
63
+ translations: config.translations,
64
+ locale: config.defaultLocale ?? "en",
65
+ defaultLocale: config.defaultLocale,
66
+ key: "resource.codexAgentsMd.label",
67
+ fallbackLiteral: "AGENTS.md"
68
+ }),
62
69
  905,
63
- "Project instructions for Codex",
70
+ resolveResourceLabel({
71
+ translations: config.translations,
72
+ locale: config.defaultLocale ?? "en",
73
+ defaultLocale: config.defaultLocale,
74
+ key: "resource.codexAgentsMd.description",
75
+ fallbackLiteral: "Project instructions for Codex"
76
+ }),
64
77
  formatFrontmatterString
65
78
  );
66
79
  return items.map(({ relPath, slug }) => ({ relPath, slug }));
@@ -8,6 +8,7 @@ import {
8
8
  escapeForMdx,
9
9
  escapeMarkdownTableCell,
10
10
  renderCodeFence,
11
+ resolveResourceLabel,
11
12
  writeCategoryIndex
12
13
  } from "../resource-docs-shared/index.js";
13
14
  import {
@@ -91,9 +92,21 @@ ${renderCodeFence(source, "toml")}`);
91
92
  if (items.length > 0) {
92
93
  writeCategoryIndex(
93
94
  outputDir,
94
- "Agents",
95
+ resolveResourceLabel({
96
+ translations: config.translations,
97
+ locale: config.defaultLocale ?? "en",
98
+ defaultLocale: config.defaultLocale,
99
+ key: "resource.codexAgents.label",
100
+ fallbackLiteral: "Agents"
101
+ }),
95
102
  907,
96
- "Custom subagents",
103
+ resolveResourceLabel({
104
+ translations: config.translations,
105
+ locale: config.defaultLocale ?? "en",
106
+ defaultLocale: config.defaultLocale,
107
+ key: "resource.codexAgents.description",
108
+ fallbackLiteral: "Custom subagents"
109
+ }),
97
110
  formatFrontmatterString
98
111
  );
99
112
  }
@@ -7,6 +7,7 @@ import {
7
7
  ensureDir,
8
8
  escapeMarkdownTableCell,
9
9
  renderCodeFence,
10
+ resolveResourceLabel,
10
11
  writeCategoryIndex
11
12
  } from "../resource-docs-shared/index.js";
12
13
  import {
@@ -98,9 +99,21 @@ function generateConfigCategory(config) {
98
99
  if (items.length > 0) {
99
100
  writeCategoryIndex(
100
101
  outputDir,
101
- "Config",
102
+ resolveResourceLabel({
103
+ translations: config.translations,
104
+ locale: config.defaultLocale ?? "en",
105
+ defaultLocale: config.defaultLocale,
106
+ key: "resource.codexConfig.label",
107
+ fallbackLiteral: "Config"
108
+ }),
102
109
  906,
103
- "config.toml and profiles",
110
+ resolveResourceLabel({
111
+ translations: config.translations,
112
+ locale: config.defaultLocale ?? "en",
113
+ defaultLocale: config.defaultLocale,
114
+ key: "resource.codexConfig.description",
115
+ fallbackLiteral: "config.toml and profiles"
116
+ }),
104
117
  formatFrontmatterString
105
118
  );
106
119
  }
@@ -1,3 +1,4 @@
1
+ import { type ResourceLocaleConfig, type ResourceTranslations } from "../resource-docs-shared/index.js";
1
2
  export interface CodexResourcesConfig {
2
3
  codexDir: string;
3
4
  /** The doc site's own root and the default value of `scanRoot`. */
@@ -9,6 +10,14 @@ export interface CodexResourcesConfig {
9
10
  */
10
11
  scanRoot?: string;
11
12
  docsDir: string;
13
+ /** Additional locale content roots, resolved by the runner when possible. */
14
+ locales?: Record<string, ResourceLocaleConfig>;
15
+ /** Default locale code (the unprefixed docs directory). */
16
+ defaultLocale?: string;
17
+ /** UI-string translation table used by localized generated indexes. */
18
+ translations?: ResourceTranslations;
19
+ /** Route prefixes that must not receive non-default-locale indexes. */
20
+ defaultLocaleOnlyPrefixes?: string[];
12
21
  }
13
22
  export declare function generateCodexResourcesDocs(config: CodexResourcesConfig): {
14
23
  agentsMd: number;
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  import { generateAgentsMdCategory } from "./agents-md.js";
2
3
  import { generateAgentsCategory } from "./agents.js";
3
4
  import { generateConfigCategory } from "./config.js";
@@ -5,14 +6,25 @@ import { generateHooksCategory } from "./hooks.js";
5
6
  import { generateOverview } from "./overview.js";
6
7
  import { generateRulesCategory } from "./rules.js";
7
8
  import { generateSkillsCategoryDocs } from "./skills.js";
9
+ import {
10
+ resolveLocaleDirs
11
+ } from "../resource-docs-shared/index.js";
8
12
  function generateCodexResourcesDocs(config) {
9
- const agentsMd = generateAgentsMdCategory(config);
10
- const configItems = generateConfigCategory(config);
11
- const agents = generateAgentsCategory(config);
12
- const hooks = generateHooksCategory(config);
13
- const rules = generateRulesCategory(config);
14
- const skills = generateSkillsCategoryDocs(config);
15
- generateOverview(config, {
13
+ const normalizedConfig = config.locales === void 0 ? config : {
14
+ ...config,
15
+ locales: resolveLocaleDirs({
16
+ projectRoot: path.resolve(config.projectRoot ?? config.codexDir),
17
+ docsDir: config.docsDir,
18
+ locales: config.locales
19
+ })
20
+ };
21
+ const agentsMd = generateAgentsMdCategory(normalizedConfig);
22
+ const configItems = generateConfigCategory(normalizedConfig);
23
+ const agents = generateAgentsCategory(normalizedConfig);
24
+ const hooks = generateHooksCategory(normalizedConfig);
25
+ const rules = generateRulesCategory(normalizedConfig);
26
+ const skills = generateSkillsCategoryDocs(normalizedConfig);
27
+ generateOverview(normalizedConfig, {
16
28
  agentsMd: agentsMd.length > 0,
17
29
  config: configItems.length > 0,
18
30
  agents: agents.length > 0,
@@ -6,6 +6,7 @@ import {
6
6
  ensureDir,
7
7
  getScriptDescription,
8
8
  renderCodeFence,
9
+ resolveResourceLabel,
9
10
  writeCategoryIndex
10
11
  } from "../resource-docs-shared/index.js";
11
12
  import {
@@ -161,9 +162,21 @@ function generateHooksCategory(config) {
161
162
  if (items.length > 0) {
162
163
  writeCategoryIndex(
163
164
  outputDir,
164
- "Hooks",
165
+ resolveResourceLabel({
166
+ translations: config.translations,
167
+ locale: config.defaultLocale ?? "en",
168
+ defaultLocale: config.defaultLocale,
169
+ key: "resource.codexHooks.label",
170
+ fallbackLiteral: "Hooks"
171
+ }),
165
172
  908,
166
- "Lifecycle hooks",
173
+ resolveResourceLabel({
174
+ translations: config.translations,
175
+ locale: config.defaultLocale ?? "en",
176
+ defaultLocale: config.defaultLocale,
177
+ key: "resource.codexHooks.description",
178
+ fallbackLiteral: "Lifecycle hooks"
179
+ }),
167
180
  formatFrontmatterString
168
181
  );
169
182
  }
@@ -1,4 +1,5 @@
1
1
  import { generateCodexResourcesDocs, type CodexResourcesConfig } from "./generate.js";
2
+ import { type ResourceLocaleConfig, type ResourceTranslations } from "../resource-docs-shared/index.js";
2
3
  export interface CodexResourcesPluginOptions {
3
4
  /**
4
5
  * Path to the project's `.codex/` directory. Resolved against
@@ -19,6 +20,14 @@ export interface CodexResourcesPluginOptions {
19
20
  scanRoot?: string;
20
21
  /** Output directory, anchored to `projectRoot` when relative. */
21
22
  docsDir?: string;
23
+ /** Additional locale content roots, keyed by locale code. */
24
+ locales?: Record<string, ResourceLocaleConfig>;
25
+ /** Default locale code (the unprefixed docs directory). */
26
+ defaultLocale?: string;
27
+ /** UI-string translation table used by localized generated indexes. */
28
+ translations?: ResourceTranslations;
29
+ /** Route prefixes that must not receive non-default-locale indexes. */
30
+ defaultLocaleOnlyPrefixes?: string[];
22
31
  }
23
32
  export declare function runCodexResourcesPreStep(options: CodexResourcesPluginOptions): ReturnType<typeof generateCodexResourcesDocs>;
24
33
  export { generateCodexResourcesDocs, type CodexResourcesConfig };
@@ -2,17 +2,29 @@ import path from "node:path";
2
2
  import {
3
3
  generateCodexResourcesDocs
4
4
  } from "./generate.js";
5
+ import {
6
+ resolveLocaleDirs
7
+ } from "../resource-docs-shared/index.js";
5
8
  function runCodexResourcesPreStep(options) {
6
9
  const projectRoot = path.resolve(options.projectRoot ?? process.cwd());
7
10
  const codexDir = path.isAbsolute(options.codexDir) ? options.codexDir : path.resolve(projectRoot, options.codexDir);
8
11
  const scanRoot = options.scanRoot === void 0 ? projectRoot : path.isAbsolute(options.scanRoot) ? options.scanRoot : path.resolve(projectRoot, options.scanRoot);
9
12
  const docsDirInput = options.docsDir ?? "src/content/docs";
10
13
  const docsDir = path.isAbsolute(docsDirInput) ? docsDirInput : path.resolve(projectRoot, docsDirInput);
14
+ const locales = resolveLocaleDirs({
15
+ projectRoot,
16
+ docsDir,
17
+ locales: options.locales
18
+ });
11
19
  return generateCodexResourcesDocs({
12
20
  codexDir,
13
21
  projectRoot,
14
22
  scanRoot,
15
- docsDir
23
+ docsDir,
24
+ locales,
25
+ defaultLocale: options.defaultLocale,
26
+ translations: options.translations,
27
+ defaultLocaleOnlyPrefixes: options.defaultLocaleOnlyPrefixes
16
28
  });
17
29
  }
18
30
  export {
@@ -1,7 +1,16 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { formatFrontmatterString } from "../resource-docs-shared/index.js";
4
- import { cleanDir, ensureDir } from "../resource-docs-shared/index.js";
3
+ import {
4
+ cleanDir,
5
+ ensureDir,
6
+ escapeForMdx,
7
+ formatFrontmatterString,
8
+ removeGeneratedIndex,
9
+ resolveResourceLabel,
10
+ shouldEmitResourceLocaleRoute,
11
+ writeCategoryIndex,
12
+ writeGeneratedIndex
13
+ } from "../resource-docs-shared/index.js";
5
14
  function generateOverview(config, presence) {
6
15
  const outputDir = path.join(config.docsDir, "codex");
7
16
  cleanDir(outputDir);
@@ -15,17 +24,137 @@ function generateOverview(config, presence) {
15
24
  if (presence.skills) slugs.push("codex-skills");
16
25
  fs.writeFileSync(
17
26
  path.join(outputDir, "index.mdx"),
18
- `---
19
- title: ${formatFrontmatterString("Codex")}
20
- description: ${formatFrontmatterString("OpenAI Codex configuration reference.")}
27
+ renderOverview(config, config.defaultLocale ?? "en", slugs)
28
+ );
29
+ for (const [locale, localeConfig] of Object.entries(config.locales ?? {})) {
30
+ emitLocaleCategoryIndexes(config, locale, localeConfig.dir, presence);
31
+ const overviewPath = path.join(localeConfig.dir, "codex", "index.mdx");
32
+ if (shouldEmitResourceLocaleRoute({
33
+ slug: "codex",
34
+ locale,
35
+ defaultLocale: config.defaultLocale,
36
+ defaultLocaleOnlyPrefixes: config.defaultLocaleOnlyPrefixes
37
+ })) {
38
+ writeGeneratedIndex(
39
+ overviewPath,
40
+ renderOverview(config, locale, slugs)
41
+ );
42
+ } else {
43
+ removeGeneratedIndex(overviewPath);
44
+ }
45
+ }
46
+ }
47
+ function renderOverview(config, locale, slugs) {
48
+ return `---
49
+ title: ${formatFrontmatterString(resolveResourceLabel({
50
+ translations: config.translations,
51
+ locale,
52
+ defaultLocale: config.defaultLocale,
53
+ key: "resource.codex.title",
54
+ fallbackLiteral: "Codex"
55
+ }))}
56
+ description: ${formatFrontmatterString(resolveResourceLabel({
57
+ translations: config.translations,
58
+ locale,
59
+ defaultLocale: config.defaultLocale,
60
+ key: "resource.codex.description",
61
+ fallbackLiteral: "OpenAI Codex configuration reference."
62
+ }))}
21
63
  sidebar_position: 904
22
64
  generated: true
23
65
  ---
24
66
 
25
- ## Resources
67
+ ## ${escapeForMdx(resolveResourceLabel({
68
+ translations: config.translations,
69
+ locale,
70
+ defaultLocale: config.defaultLocale,
71
+ key: "resource.resources",
72
+ fallbackLiteral: "Resources"
73
+ }))}
26
74
 
27
75
  <CategoryNav categories={${JSON.stringify(slugs)}} />
28
- `
76
+ `;
77
+ }
78
+ function emitLocaleCategoryIndexes(config, locale, localeDir, presence) {
79
+ const write = (slug, keyPrefix, fallbackLabel, present, position, fallbackDescription) => {
80
+ const indexPath = path.join(localeDir, slug, "index.mdx");
81
+ if (!present || !shouldEmitResourceLocaleRoute({
82
+ slug,
83
+ locale,
84
+ defaultLocale: config.defaultLocale,
85
+ defaultLocaleOnlyPrefixes: config.defaultLocaleOnlyPrefixes
86
+ })) {
87
+ removeGeneratedIndex(indexPath);
88
+ return;
89
+ }
90
+ writeCategoryIndex(
91
+ path.join(localeDir, slug),
92
+ resolveResourceLabel({
93
+ translations: config.translations,
94
+ locale,
95
+ defaultLocale: config.defaultLocale,
96
+ key: `${keyPrefix}.label`,
97
+ fallbackLiteral: fallbackLabel
98
+ }),
99
+ position,
100
+ resolveResourceLabel({
101
+ translations: config.translations,
102
+ locale,
103
+ defaultLocale: config.defaultLocale,
104
+ key: `${keyPrefix}.description`,
105
+ fallbackLiteral: fallbackDescription
106
+ }),
107
+ formatFrontmatterString,
108
+ writeGeneratedIndex
109
+ );
110
+ };
111
+ write(
112
+ "codex-agents-md",
113
+ "resource.codexAgentsMd",
114
+ "AGENTS.md",
115
+ presence.agentsMd,
116
+ 905,
117
+ "Project instructions for Codex"
118
+ );
119
+ write(
120
+ "codex-config",
121
+ "resource.codexConfig",
122
+ "Config",
123
+ presence.config,
124
+ 906,
125
+ "config.toml and profiles"
126
+ );
127
+ write(
128
+ "codex-agents",
129
+ "resource.codexAgents",
130
+ "Agents",
131
+ presence.agents,
132
+ 907,
133
+ "Custom subagents"
134
+ );
135
+ write(
136
+ "codex-hooks",
137
+ "resource.codexHooks",
138
+ "Hooks",
139
+ presence.hooks,
140
+ 908,
141
+ "Lifecycle hooks"
142
+ );
143
+ write(
144
+ "codex-rules",
145
+ "resource.codexRules",
146
+ "Rules",
147
+ presence.rules,
148
+ 909,
149
+ "Command approval rules"
150
+ );
151
+ write(
152
+ "codex-skills",
153
+ "resource.codexSkills",
154
+ "Skills",
155
+ presence.skills,
156
+ 910,
157
+ "Skill packages"
29
158
  );
30
159
  }
31
160
  export {
@@ -5,6 +5,7 @@ import {
5
5
  cleanDir,
6
6
  ensureDir,
7
7
  renderCodeFence,
8
+ resolveResourceLabel,
8
9
  writeCategoryIndex
9
10
  } from "../resource-docs-shared/index.js";
10
11
  import {
@@ -242,9 +243,21 @@ function generateRulesCategory(config) {
242
243
  if (items.length > 0) {
243
244
  writeCategoryIndex(
244
245
  outputDir,
245
- "Rules",
246
+ resolveResourceLabel({
247
+ translations: config.translations,
248
+ locale: config.defaultLocale ?? "en",
249
+ defaultLocale: config.defaultLocale,
250
+ key: "resource.codexRules.label",
251
+ fallbackLiteral: "Rules"
252
+ }),
246
253
  909,
247
- "Command approval rules",
254
+ resolveResourceLabel({
255
+ translations: config.translations,
256
+ locale: config.defaultLocale ?? "en",
257
+ defaultLocale: config.defaultLocale,
258
+ key: "resource.codexRules.description",
259
+ fallbackLiteral: "Command approval rules"
260
+ }),
248
261
  formatFrontmatterString
249
262
  );
250
263
  }
@@ -4,7 +4,8 @@ import { matter } from "../../../frontmatter/index.js";
4
4
  import {
5
5
  escapeForMdx,
6
6
  formatFrontmatterString,
7
- generateSkillsCategory
7
+ generateSkillsCategory,
8
+ resolveResourceLabel
8
9
  } from "../resource-docs-shared/index.js";
9
10
  import { isRecord, warn } from "./utils.js";
10
11
  function optionalMetadataString(record, field, filePath) {
@@ -71,9 +72,21 @@ function generateSkillsCategoryDocs(config) {
71
72
  path.join(scanRoot, ".agents", "skills")
72
73
  ],
73
74
  outputDir: path.join(config.docsDir, "codex-skills"),
74
- label: "Skills",
75
+ label: resolveResourceLabel({
76
+ translations: config.translations,
77
+ locale: config.defaultLocale ?? "en",
78
+ defaultLocale: config.defaultLocale,
79
+ key: "resource.codexSkills.label",
80
+ fallbackLiteral: "Skills"
81
+ }),
75
82
  position: 910,
76
- description: "Skill packages",
83
+ description: resolveResourceLabel({
84
+ translations: config.translations,
85
+ locale: config.defaultLocale ?? "en",
86
+ defaultLocale: config.defaultLocale,
87
+ key: "resource.codexSkills.description",
88
+ fallbackLiteral: "Skill packages"
89
+ }),
77
90
  sourceLabel: ".codex/skills",
78
91
  renderExtraHeader: renderOpenAiMetadata,
79
92
  renderFrontmatterString: formatFrontmatterString
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Materialize the shared asset-viewer descriptors for llms.txt output.
3
+ *
4
+ * The descriptor scanner owns the asset-viewer/indexing gates and URL rules;
5
+ * this adapter only reads the bounded text body needed by llms-full.txt.
6
+ * Keeping it separate from the emitter lets build and dev use precisely the
7
+ * same data preparation path.
8
+ */
9
+ import { type AssetScanProjection } from "../asset-viewer/asset-pages.js";
10
+ import { type LlmsAssetEntry } from "./types.js";
11
+ export interface LlmsAssetLoadOptions {
12
+ /** Runtime project root supplied by the zfb plugin wrapper. */
13
+ projectRoot?: string;
14
+ /** Shared serialized asset-viewer projection from the preset. */
15
+ assetScan?: AssetScanProjection;
16
+ /** Optional canonical site origin, matching document-entry URL behavior. */
17
+ siteUrl?: string;
18
+ }
19
+ /**
20
+ * Collect and materialize all llms-indexed assets. Missing runtime inputs are
21
+ * treated as the legacy no-assets case so direct unit callers and consumers
22
+ * that do not run through zfb remain byte-compatible.
23
+ */
24
+ export declare function loadLlmsAssetEntries(options: LlmsAssetLoadOptions): LlmsAssetEntry[];
@@ -0,0 +1,65 @@
1
+ import { closeSync, openSync, readSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { StringDecoder } from "node:string_decoder";
4
+ import {
5
+ collectAssetPageDescriptors
6
+ } from "../asset-viewer/asset-pages.js";
7
+ import {
8
+ LLMS_ASSET_TEXT_CAP_BYTES
9
+ } from "./types.js";
10
+ function readTextPrefix(filePath) {
11
+ const sample = Buffer.alloc(LLMS_ASSET_TEXT_CAP_BYTES + 1);
12
+ const fd = openSync(filePath, "r");
13
+ try {
14
+ let offset = 0;
15
+ while (offset < sample.length) {
16
+ const bytesRead = readSync(fd, sample, offset, sample.length - offset, offset);
17
+ if (bytesRead === 0) break;
18
+ offset += bytesRead;
19
+ }
20
+ const decoder = new StringDecoder("utf8");
21
+ return {
22
+ content: decoder.write(sample.subarray(0, offset)),
23
+ truncated: offset > LLMS_ASSET_TEXT_CAP_BYTES
24
+ };
25
+ } finally {
26
+ closeSync(fd);
27
+ }
28
+ }
29
+ function toLlmsAssetEntry(descriptor, projectRoot, assetScan, siteUrl) {
30
+ const url = siteUrl ? `${siteUrl.replace(/\/$/, "")}${descriptor.url}` : descriptor.url;
31
+ if (!descriptor.isText) {
32
+ return {
33
+ path: descriptor.path,
34
+ url,
35
+ ...descriptor.locale === void 0 ? {} : { locale: descriptor.locale },
36
+ isText: false
37
+ };
38
+ }
39
+ const body = readTextPrefix(
40
+ resolve(projectRoot, "public", assetScan.assetViewerDir, descriptor.path)
41
+ );
42
+ return {
43
+ path: descriptor.path,
44
+ url,
45
+ ...descriptor.locale === void 0 ? {} : { locale: descriptor.locale },
46
+ isText: true,
47
+ content: body.content,
48
+ truncated: body.truncated
49
+ };
50
+ }
51
+ function loadLlmsAssetEntries(options) {
52
+ const { projectRoot, assetScan, siteUrl } = options;
53
+ if (projectRoot === void 0 || assetScan === void 0) return [];
54
+ const descriptors = collectAssetPageDescriptors({
55
+ projectRoot,
56
+ assetScan,
57
+ consumer: "llmsTxt"
58
+ });
59
+ return descriptors.map(
60
+ (descriptor) => toLlmsAssetEntry(descriptor, projectRoot, assetScan, siteUrl)
61
+ );
62
+ }
63
+ export {
64
+ loadLlmsAssetEntries
65
+ };
@@ -1,5 +1,6 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { LlmsTxtLocaleConfig, LlmsTxtSiteMeta } from "./types.js";
3
+ import type { AssetScanProjection } from "../asset-viewer/asset-pages.js";
3
4
  /** Connect-style middleware signature — works as a Vite plugin middleware. */
4
5
  export type LlmsTxtNextFn = (err?: unknown) => void;
5
6
  export type LlmsTxtMiddleware = (req: IncomingMessage, res: ServerResponse, next: LlmsTxtNextFn) => void;
@@ -22,6 +23,10 @@ export interface LlmsTxtDevMiddlewareOptions extends LlmsTxtSiteMeta {
22
23
  defaultLocaleDir: string;
23
24
  /** Additional locales (e.g. `[{ code: "ja", dir: "src/content/docs-ja" }]`). */
24
25
  locales?: LlmsTxtLocaleConfig[];
26
+ /** Runtime project root; injected by the zfb plugin wrapper, never serialized in the preset. */
27
+ projectRoot?: string;
28
+ /** Shared asset-viewer projection; consumed by the asset indexing wave. */
29
+ assetScan?: AssetScanProjection;
25
30
  }
26
31
  /**
27
32
  * Build a dev-server middleware that responds to GET requests for
@@ -1,3 +1,4 @@
1
+ import { loadLlmsAssetEntries } from "./assets.js";
1
2
  import { generateLlmsFullTxt, generateLlmsTxt } from "./generate.js";
2
3
  import { loadDocEntries } from "./load.js";
3
4
  const LLMS_KIND_PATTERN = /^(?:\/(.+?))?\/(llms|llms-full)\.txt$/;
@@ -39,7 +40,14 @@ function createLlmsTxtDevMiddleware(options, logger) {
39
40
  base,
40
41
  siteUrl
41
42
  });
42
- const body = match.kind === "llms" ? generateLlmsTxt(entries, meta) : generateLlmsFullTxt(entries, meta);
43
+ const assets = loadLlmsAssetEntries({
44
+ projectRoot: options.projectRoot,
45
+ assetScan: options.assetScan,
46
+ siteUrl
47
+ }).filter(
48
+ (asset) => match.locale === null ? asset.locale === void 0 : asset.locale === match.locale
49
+ );
50
+ const body = match.kind === "llms" ? generateLlmsTxt(entries, meta, assets) : generateLlmsFullTxt(entries, meta, assets);
43
51
  res.statusCode = 200;
44
52
  res.setHeader("Content-Type", "text/plain; charset=utf-8");
45
53
  res.end(body);