@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
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
formatFrontmatterString,
|
|
5
|
-
cleanDir,
|
|
6
|
-
ensureDir,
|
|
7
|
-
getScriptDescription,
|
|
8
|
-
renderCodeFence,
|
|
9
|
-
resolveResourceLabel,
|
|
10
|
-
writeCategoryIndex
|
|
11
|
-
} from "../resource-docs-shared/index.js";
|
|
12
|
-
import {
|
|
13
|
-
assertUniqueSlug,
|
|
14
|
-
filenameSlug,
|
|
15
|
-
isRecord,
|
|
16
|
-
languageForFilename,
|
|
17
|
-
renderTableRow,
|
|
18
|
-
warn,
|
|
19
|
-
writeGeneratedPage
|
|
20
|
-
} from "./utils.js";
|
|
21
|
-
function readHookRows(filePath, source) {
|
|
22
|
-
let parsed;
|
|
23
|
-
try {
|
|
24
|
-
parsed = JSON.parse(source);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
warn(filePath, `unable to parse JSON, skipping hooks.json page: ${String(error)}`);
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
if (!isRecord(parsed) || !isRecord(parsed.hooks)) {
|
|
30
|
-
warn(filePath, "hooks.hooks must be a non-null object; skipping hooks.json page");
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const rows = [];
|
|
34
|
-
for (const [event, groups] of Object.entries(parsed.hooks)) {
|
|
35
|
-
if (!Array.isArray(groups)) {
|
|
36
|
-
warn(filePath, `hooks.${event} must be an array; skipping event`);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
for (const [groupIndex, group] of groups.entries()) {
|
|
40
|
-
if (!isRecord(group) || !Array.isArray(group.hooks)) {
|
|
41
|
-
warn(
|
|
42
|
-
filePath,
|
|
43
|
-
`hooks.${event}[${groupIndex}].hooks must be an array; skipping group`
|
|
44
|
-
);
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
for (const [handlerIndex, handler] of group.hooks.entries()) {
|
|
48
|
-
if (!isRecord(handler) || typeof handler.command !== "string") {
|
|
49
|
-
warn(
|
|
50
|
-
filePath,
|
|
51
|
-
`hooks.${event}[${groupIndex}].hooks[${handlerIndex}] must be an object with a string command; skipping row`
|
|
52
|
-
);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
rows.push({
|
|
56
|
-
event,
|
|
57
|
-
matcher: group.matcher,
|
|
58
|
-
type: handler.type,
|
|
59
|
-
command: handler.command,
|
|
60
|
-
timeout: handler.timeout,
|
|
61
|
-
async: handler.async
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return rows;
|
|
67
|
-
}
|
|
68
|
-
function generateHooksJson(config, outputDir, emitted) {
|
|
69
|
-
const filePath = path.join(config.codexDir, "hooks.json");
|
|
70
|
-
if (!fs.existsSync(filePath)) return null;
|
|
71
|
-
let source;
|
|
72
|
-
try {
|
|
73
|
-
source = fs.readFileSync(filePath, "utf8");
|
|
74
|
-
} catch (error) {
|
|
75
|
-
warn(filePath, `unable to read hooks.json, skipping page: ${String(error)}`);
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
const rows = readHookRows(filePath, source);
|
|
79
|
-
if (rows === null) return null;
|
|
80
|
-
const slug = "hooks-json";
|
|
81
|
-
assertUniqueSlug("hook", slug, "hooks.json", emitted);
|
|
82
|
-
const tableRows = rows.map((row) => renderTableRow([
|
|
83
|
-
row.event,
|
|
84
|
-
row.matcher,
|
|
85
|
-
row.type,
|
|
86
|
-
row.command,
|
|
87
|
-
row.timeout,
|
|
88
|
-
row.async
|
|
89
|
-
]));
|
|
90
|
-
const body = [
|
|
91
|
-
"| Event | Matcher | Type | Command | Timeout | Async |",
|
|
92
|
-
"| --- | --- | --- | --- | --- | --- |",
|
|
93
|
-
...tableRows.length > 0 ? tableRows : [renderTableRow(Array.from({ length: 6 }))],
|
|
94
|
-
"",
|
|
95
|
-
"## Source",
|
|
96
|
-
"",
|
|
97
|
-
renderCodeFence(source, "json")
|
|
98
|
-
].join("\n");
|
|
99
|
-
writeGeneratedPage({
|
|
100
|
-
outputPath: path.join(outputDir, `${slug}.mdx`),
|
|
101
|
-
title: "hooks.json",
|
|
102
|
-
description: "Codex lifecycle hook configuration",
|
|
103
|
-
sidebarLabel: "hooks.json",
|
|
104
|
-
body
|
|
105
|
-
});
|
|
106
|
-
return { filename: "hooks.json", slug };
|
|
107
|
-
}
|
|
108
|
-
function generateHookScripts(config, outputDir, emitted) {
|
|
109
|
-
const hooksDir = path.join(config.codexDir, "hooks");
|
|
110
|
-
if (!fs.existsSync(hooksDir)) return [];
|
|
111
|
-
let entries;
|
|
112
|
-
try {
|
|
113
|
-
entries = fs.readdirSync(hooksDir, { withFileTypes: true });
|
|
114
|
-
} catch (error) {
|
|
115
|
-
warn(hooksDir, `unable to read hooks directory: ${String(error)}`);
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
const items = [];
|
|
119
|
-
for (const entry of entries.filter((item) => item.isFile()).sort(
|
|
120
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
121
|
-
)) {
|
|
122
|
-
const filePath = path.join(hooksDir, entry.name);
|
|
123
|
-
const slug = filenameSlug(entry.name);
|
|
124
|
-
assertUniqueSlug("hook", slug, filePath, emitted);
|
|
125
|
-
let source;
|
|
126
|
-
try {
|
|
127
|
-
source = fs.readFileSync(filePath, "utf8");
|
|
128
|
-
} catch (error) {
|
|
129
|
-
warn(filePath, `unable to read hook script, skipping file: ${String(error)}`);
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
const scriptDescription = getScriptDescription(filePath).replace(/^ — /, "");
|
|
133
|
-
writeGeneratedPage({
|
|
134
|
-
outputPath: path.join(outputDir, `${slug}.mdx`),
|
|
135
|
-
title: entry.name,
|
|
136
|
-
description: scriptDescription,
|
|
137
|
-
sidebarLabel: entry.name,
|
|
138
|
-
body: `## Source
|
|
139
|
-
|
|
140
|
-
${renderCodeFence(
|
|
141
|
-
source,
|
|
142
|
-
languageForFilename(entry.name)
|
|
143
|
-
)}`
|
|
144
|
-
});
|
|
145
|
-
items.push({ filename: entry.name, slug });
|
|
146
|
-
}
|
|
147
|
-
return items;
|
|
148
|
-
}
|
|
149
|
-
function generateHooksCategory(config) {
|
|
150
|
-
const outputDir = path.join(config.docsDir, "codex-hooks");
|
|
151
|
-
cleanDir(outputDir);
|
|
152
|
-
const hasJson = fs.existsSync(path.join(config.codexDir, "hooks.json"));
|
|
153
|
-
const hasScripts = fs.existsSync(path.join(config.codexDir, "hooks"));
|
|
154
|
-
if (!hasJson && !hasScripts) return [];
|
|
155
|
-
ensureDir(outputDir);
|
|
156
|
-
const emitted = /* @__PURE__ */ new Map();
|
|
157
|
-
const jsonItem = generateHooksJson(config, outputDir, emitted);
|
|
158
|
-
const items = [
|
|
159
|
-
...jsonItem ? [jsonItem] : [],
|
|
160
|
-
...generateHookScripts(config, outputDir, emitted)
|
|
161
|
-
];
|
|
162
|
-
if (items.length > 0) {
|
|
163
|
-
writeCategoryIndex(
|
|
164
|
-
outputDir,
|
|
165
|
-
resolveResourceLabel({
|
|
166
|
-
translations: config.translations,
|
|
167
|
-
locale: config.defaultLocale ?? "en",
|
|
168
|
-
defaultLocale: config.defaultLocale,
|
|
169
|
-
key: "resource.codexHooks.label",
|
|
170
|
-
fallbackLiteral: "Hooks"
|
|
171
|
-
}),
|
|
172
|
-
908,
|
|
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
|
-
}),
|
|
180
|
-
formatFrontmatterString
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
return items;
|
|
184
|
-
}
|
|
185
|
-
export {
|
|
186
|
-
generateHooksCategory
|
|
187
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { generateCodexResourcesDocs, type CodexResourcesConfig } from "./generate.js";
|
|
2
|
-
import { type ResourceLocaleConfig, type ResourceTranslations } from "../resource-docs-shared/index.js";
|
|
3
|
-
export interface CodexResourcesPluginOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Path to the project's `.codex/` directory. Resolved against
|
|
6
|
-
* `projectRoot` when relative.
|
|
7
|
-
*/
|
|
8
|
-
codexDir: string;
|
|
9
|
-
/**
|
|
10
|
-
* Anchor for `codexDir`, `docsDir`, and relative `scanRoot` paths, and the
|
|
11
|
-
* default value of `scanRoot`. Defaults to `process.cwd()`.
|
|
12
|
-
*/
|
|
13
|
-
projectRoot?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Repo-wide discovery root, defaulting to `projectRoot`. It governs both the
|
|
16
|
-
* `AGENTS.md` / `AGENTS.override.md` walk (including relative titles/slugs)
|
|
17
|
-
* and the repo-level `.agents/skills/` root. `codexDir` and `docsDir` remain
|
|
18
|
-
* anchored to `projectRoot`.
|
|
19
|
-
*/
|
|
20
|
-
scanRoot?: string;
|
|
21
|
-
/** Output directory, anchored to `projectRoot` when relative. */
|
|
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[];
|
|
31
|
-
}
|
|
32
|
-
export declare function runCodexResourcesPreStep(options: CodexResourcesPluginOptions): ReturnType<typeof generateCodexResourcesDocs>;
|
|
33
|
-
export { generateCodexResourcesDocs, type CodexResourcesConfig };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
generateCodexResourcesDocs
|
|
4
|
-
} from "./generate.js";
|
|
5
|
-
import {
|
|
6
|
-
resolveLocaleDirs
|
|
7
|
-
} from "../resource-docs-shared/index.js";
|
|
8
|
-
function runCodexResourcesPreStep(options) {
|
|
9
|
-
const projectRoot = path.resolve(options.projectRoot ?? process.cwd());
|
|
10
|
-
const codexDir = path.isAbsolute(options.codexDir) ? options.codexDir : path.resolve(projectRoot, options.codexDir);
|
|
11
|
-
const scanRoot = options.scanRoot === void 0 ? projectRoot : path.isAbsolute(options.scanRoot) ? options.scanRoot : path.resolve(projectRoot, options.scanRoot);
|
|
12
|
-
const docsDirInput = options.docsDir ?? "src/content/docs";
|
|
13
|
-
const docsDir = path.isAbsolute(docsDirInput) ? docsDirInput : path.resolve(projectRoot, docsDirInput);
|
|
14
|
-
const locales = resolveLocaleDirs({
|
|
15
|
-
projectRoot,
|
|
16
|
-
docsDir,
|
|
17
|
-
locales: options.locales
|
|
18
|
-
});
|
|
19
|
-
return generateCodexResourcesDocs({
|
|
20
|
-
codexDir,
|
|
21
|
-
projectRoot,
|
|
22
|
-
scanRoot,
|
|
23
|
-
docsDir,
|
|
24
|
-
locales,
|
|
25
|
-
defaultLocale: options.defaultLocale,
|
|
26
|
-
translations: options.translations,
|
|
27
|
-
defaultLocaleOnlyPrefixes: options.defaultLocaleOnlyPrefixes
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
generateCodexResourcesDocs,
|
|
32
|
-
runCodexResourcesPreStep
|
|
33
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CodexResourcesConfig } from "./generate.js";
|
|
2
|
-
export interface CodexCategoryPresence {
|
|
3
|
-
agentsMd: boolean;
|
|
4
|
-
config: boolean;
|
|
5
|
-
agents: boolean;
|
|
6
|
-
hooks: boolean;
|
|
7
|
-
rules: boolean;
|
|
8
|
-
skills: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare function generateOverview(config: CodexResourcesConfig, presence: CodexCategoryPresence): void;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
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";
|
|
14
|
-
function generateOverview(config, presence) {
|
|
15
|
-
const outputDir = path.join(config.docsDir, "codex");
|
|
16
|
-
cleanDir(outputDir);
|
|
17
|
-
ensureDir(outputDir);
|
|
18
|
-
const slugs = [];
|
|
19
|
-
if (presence.agentsMd) slugs.push("codex-agents-md");
|
|
20
|
-
if (presence.config) slugs.push("codex-config");
|
|
21
|
-
if (presence.agents) slugs.push("codex-agents");
|
|
22
|
-
if (presence.hooks) slugs.push("codex-hooks");
|
|
23
|
-
if (presence.rules) slugs.push("codex-rules");
|
|
24
|
-
if (presence.skills) slugs.push("codex-skills");
|
|
25
|
-
fs.writeFileSync(
|
|
26
|
-
path.join(outputDir, "index.mdx"),
|
|
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
|
-
"/docs/codex/"
|
|
42
|
-
);
|
|
43
|
-
} else {
|
|
44
|
-
removeGeneratedIndex(overviewPath);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function renderOverview(config, locale, slugs) {
|
|
49
|
-
return `---
|
|
50
|
-
title: ${formatFrontmatterString(resolveResourceLabel({
|
|
51
|
-
translations: config.translations,
|
|
52
|
-
locale,
|
|
53
|
-
defaultLocale: config.defaultLocale,
|
|
54
|
-
key: "resource.codex.title",
|
|
55
|
-
fallbackLiteral: "Codex"
|
|
56
|
-
}))}
|
|
57
|
-
description: ${formatFrontmatterString(resolveResourceLabel({
|
|
58
|
-
translations: config.translations,
|
|
59
|
-
locale,
|
|
60
|
-
defaultLocale: config.defaultLocale,
|
|
61
|
-
key: "resource.codex.description",
|
|
62
|
-
fallbackLiteral: "OpenAI Codex configuration reference."
|
|
63
|
-
}))}
|
|
64
|
-
sidebar_position: 904
|
|
65
|
-
generated: true
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## ${escapeForMdx(resolveResourceLabel({
|
|
69
|
-
translations: config.translations,
|
|
70
|
-
locale,
|
|
71
|
-
defaultLocale: config.defaultLocale,
|
|
72
|
-
key: "resource.resources",
|
|
73
|
-
fallbackLiteral: "Resources"
|
|
74
|
-
}))}
|
|
75
|
-
|
|
76
|
-
<CategoryNav categories={${JSON.stringify(slugs)}} />
|
|
77
|
-
`;
|
|
78
|
-
}
|
|
79
|
-
function emitLocaleCategoryIndexes(config, locale, localeDir, presence) {
|
|
80
|
-
const write = (slug, keyPrefix, fallbackLabel, present, position, fallbackDescription) => {
|
|
81
|
-
const indexPath = path.join(localeDir, slug, "index.mdx");
|
|
82
|
-
if (!present || !shouldEmitResourceLocaleRoute({
|
|
83
|
-
slug,
|
|
84
|
-
locale,
|
|
85
|
-
defaultLocale: config.defaultLocale,
|
|
86
|
-
defaultLocaleOnlyPrefixes: config.defaultLocaleOnlyPrefixes
|
|
87
|
-
})) {
|
|
88
|
-
removeGeneratedIndex(indexPath);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
writeCategoryIndex(
|
|
92
|
-
path.join(localeDir, slug),
|
|
93
|
-
resolveResourceLabel({
|
|
94
|
-
translations: config.translations,
|
|
95
|
-
locale,
|
|
96
|
-
defaultLocale: config.defaultLocale,
|
|
97
|
-
key: `${keyPrefix}.label`,
|
|
98
|
-
fallbackLiteral: fallbackLabel
|
|
99
|
-
}),
|
|
100
|
-
position,
|
|
101
|
-
resolveResourceLabel({
|
|
102
|
-
translations: config.translations,
|
|
103
|
-
locale,
|
|
104
|
-
defaultLocale: config.defaultLocale,
|
|
105
|
-
key: `${keyPrefix}.description`,
|
|
106
|
-
fallbackLiteral: fallbackDescription
|
|
107
|
-
}),
|
|
108
|
-
formatFrontmatterString,
|
|
109
|
-
(absolutePath, content) => writeGeneratedIndex(absolutePath, content, `/docs/${slug}/`)
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
write(
|
|
113
|
-
"codex-agents-md",
|
|
114
|
-
"resource.codexAgentsMd",
|
|
115
|
-
"AGENTS.md",
|
|
116
|
-
presence.agentsMd,
|
|
117
|
-
905,
|
|
118
|
-
"Project instructions for Codex"
|
|
119
|
-
);
|
|
120
|
-
write(
|
|
121
|
-
"codex-config",
|
|
122
|
-
"resource.codexConfig",
|
|
123
|
-
"Config",
|
|
124
|
-
presence.config,
|
|
125
|
-
906,
|
|
126
|
-
"config.toml and profiles"
|
|
127
|
-
);
|
|
128
|
-
write(
|
|
129
|
-
"codex-agents",
|
|
130
|
-
"resource.codexAgents",
|
|
131
|
-
"Agents",
|
|
132
|
-
presence.agents,
|
|
133
|
-
907,
|
|
134
|
-
"Custom subagents"
|
|
135
|
-
);
|
|
136
|
-
write(
|
|
137
|
-
"codex-hooks",
|
|
138
|
-
"resource.codexHooks",
|
|
139
|
-
"Hooks",
|
|
140
|
-
presence.hooks,
|
|
141
|
-
908,
|
|
142
|
-
"Lifecycle hooks"
|
|
143
|
-
);
|
|
144
|
-
write(
|
|
145
|
-
"codex-rules",
|
|
146
|
-
"resource.codexRules",
|
|
147
|
-
"Rules",
|
|
148
|
-
presence.rules,
|
|
149
|
-
909,
|
|
150
|
-
"Command approval rules"
|
|
151
|
-
);
|
|
152
|
-
write(
|
|
153
|
-
"codex-skills",
|
|
154
|
-
"resource.codexSkills",
|
|
155
|
-
"Skills",
|
|
156
|
-
presence.skills,
|
|
157
|
-
910,
|
|
158
|
-
"Skill packages"
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
export {
|
|
162
|
-
generateOverview
|
|
163
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { matter } from "../../../frontmatter/index.js";
|
|
4
|
-
import {
|
|
5
|
-
escapeForMdx,
|
|
6
|
-
formatFrontmatterString,
|
|
7
|
-
generateSkillsCategory,
|
|
8
|
-
resolveResourceLabel
|
|
9
|
-
} from "../resource-docs-shared/index.js";
|
|
10
|
-
import { isRecord, warn } from "./utils.js";
|
|
11
|
-
function optionalMetadataString(record, field, filePath) {
|
|
12
|
-
const value = record[field];
|
|
13
|
-
if (value === void 0) return void 0;
|
|
14
|
-
if (typeof value === "string") return value;
|
|
15
|
-
warn(filePath, `${field} must be a string; omitting it`);
|
|
16
|
-
return void 0;
|
|
17
|
-
}
|
|
18
|
-
function renderOpenAiMetadata(skillAbsDir) {
|
|
19
|
-
const filePath = path.join(skillAbsDir, "agents", "openai.yaml");
|
|
20
|
-
if (!fs.existsSync(filePath)) return "";
|
|
21
|
-
let data;
|
|
22
|
-
try {
|
|
23
|
-
const yaml = fs.readFileSync(filePath, "utf8");
|
|
24
|
-
data = matter(`---
|
|
25
|
-
${yaml}
|
|
26
|
-
---
|
|
27
|
-
`).data;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
warn(filePath, `unable to parse YAML, omitting metadata: ${String(error)}`);
|
|
30
|
-
return "";
|
|
31
|
-
}
|
|
32
|
-
if (!isRecord(data)) {
|
|
33
|
-
warn(filePath, "YAML root must be an object; omitting metadata");
|
|
34
|
-
return "";
|
|
35
|
-
}
|
|
36
|
-
let interfaceData;
|
|
37
|
-
if (data.interface !== void 0) {
|
|
38
|
-
if (isRecord(data.interface)) interfaceData = data.interface;
|
|
39
|
-
else warn(filePath, "interface must be an object; omitting interface metadata");
|
|
40
|
-
}
|
|
41
|
-
let policy;
|
|
42
|
-
if (data.policy !== void 0) {
|
|
43
|
-
if (isRecord(data.policy)) policy = data.policy;
|
|
44
|
-
else warn(filePath, "policy must be an object; omitting policy metadata");
|
|
45
|
-
}
|
|
46
|
-
const displayName = interfaceData ? optionalMetadataString(interfaceData, "display_name", filePath) : void 0;
|
|
47
|
-
const shortDescription = interfaceData ? optionalMetadataString(interfaceData, "short_description", filePath) : void 0;
|
|
48
|
-
let explicitOnly = false;
|
|
49
|
-
if (policy?.allow_implicit_invocation !== void 0) {
|
|
50
|
-
if (typeof policy.allow_implicit_invocation === "boolean") {
|
|
51
|
-
explicitOnly = policy.allow_implicit_invocation === false;
|
|
52
|
-
} else {
|
|
53
|
-
warn(
|
|
54
|
-
filePath,
|
|
55
|
-
"policy.allow_implicit_invocation must be a boolean; omitting invocation metadata"
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return [
|
|
60
|
-
displayName ? `**Display name:** ${escapeForMdx(displayName)}` : "",
|
|
61
|
-
shortDescription ? `**Short description:** ${escapeForMdx(shortDescription)}` : "",
|
|
62
|
-
explicitOnly ? `**Invocation:** explicit only (\`$${path.basename(skillAbsDir)}\`)` : ""
|
|
63
|
-
].filter(Boolean).join("\n");
|
|
64
|
-
}
|
|
65
|
-
function generateSkillsCategoryDocs(config) {
|
|
66
|
-
const projectRoot = config.projectRoot ?? config.codexDir;
|
|
67
|
-
const scanRoot = config.scanRoot ?? projectRoot;
|
|
68
|
-
return generateSkillsCategory({
|
|
69
|
-
skillsDirs: [
|
|
70
|
-
path.join(config.codexDir, "skills"),
|
|
71
|
-
path.join(projectRoot, ".agents", "skills"),
|
|
72
|
-
path.join(scanRoot, ".agents", "skills")
|
|
73
|
-
],
|
|
74
|
-
outputDir: path.join(config.docsDir, "codex-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
|
-
}),
|
|
82
|
-
position: 910,
|
|
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
|
-
}),
|
|
90
|
-
sourceLabel: ".codex/skills",
|
|
91
|
-
renderExtraHeader: renderOpenAiMetadata,
|
|
92
|
-
renderFrontmatterString: formatFrontmatterString
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
export {
|
|
96
|
-
generateSkillsCategoryDocs
|
|
97
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare function warn(filePath: string, message: string): void;
|
|
2
|
-
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
3
|
-
export declare function filenameSlug(filename: string): string;
|
|
4
|
-
export declare function renderTableRow(values: unknown[]): string;
|
|
5
|
-
export declare function assertUniqueSlug(resource: string, slug: string, filePath: string, emitted: Map<string, string>): void;
|
|
6
|
-
export declare function writeGeneratedPage({ outputPath, title, description, sidebarLabel, sidebarPosition, body, }: {
|
|
7
|
-
outputPath: string;
|
|
8
|
-
title: string;
|
|
9
|
-
description: string;
|
|
10
|
-
sidebarLabel?: string;
|
|
11
|
-
sidebarPosition?: number;
|
|
12
|
-
body: string;
|
|
13
|
-
}): void;
|
|
14
|
-
export declare function languageForFilename(filename: string): string;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
assertNotIndexReserved,
|
|
5
|
-
escapeMarkdownTableCell,
|
|
6
|
-
formatFrontmatterString
|
|
7
|
-
} from "../resource-docs-shared/index.js";
|
|
8
|
-
function warn(filePath, message) {
|
|
9
|
-
console.warn(`${filePath}: ${message}`);
|
|
10
|
-
}
|
|
11
|
-
function isRecord(value) {
|
|
12
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
-
}
|
|
14
|
-
function filenameSlug(filename) {
|
|
15
|
-
return filename.replace(/\./g, "-");
|
|
16
|
-
}
|
|
17
|
-
function renderTableRow(values) {
|
|
18
|
-
return `| ${values.map(escapeMarkdownTableCell).join(" | ")} |`;
|
|
19
|
-
}
|
|
20
|
-
function assertUniqueSlug(resource, slug, filePath, emitted) {
|
|
21
|
-
assertNotIndexReserved(
|
|
22
|
-
slug,
|
|
23
|
-
`codex-resources: "${filePath}" maps to the reserved slug "index", which is used for the category metadata file. Rename the file or directory to resolve the conflict.`
|
|
24
|
-
);
|
|
25
|
-
const previous = emitted.get(slug);
|
|
26
|
-
if (previous !== void 0) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`codex-resources: ${resource} slug collision \u2014 "${slug}" is produced by both "${previous}" and "${filePath}". Rename one of the files to resolve the conflict.`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
emitted.set(slug, filePath);
|
|
32
|
-
}
|
|
33
|
-
function writeGeneratedPage({
|
|
34
|
-
outputPath,
|
|
35
|
-
title,
|
|
36
|
-
description,
|
|
37
|
-
sidebarLabel,
|
|
38
|
-
sidebarPosition,
|
|
39
|
-
body
|
|
40
|
-
}) {
|
|
41
|
-
const position = sidebarPosition === void 0 ? "" : `sidebar_position: ${sidebarPosition}
|
|
42
|
-
`;
|
|
43
|
-
const label = sidebarLabel === void 0 ? "" : `sidebar_label: ${formatFrontmatterString(sidebarLabel)}
|
|
44
|
-
`;
|
|
45
|
-
fs.writeFileSync(
|
|
46
|
-
outputPath,
|
|
47
|
-
`---
|
|
48
|
-
title: ${formatFrontmatterString(title)}
|
|
49
|
-
description: ${formatFrontmatterString(description)}
|
|
50
|
-
${position}${label}generated: true
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
${body.trim()}
|
|
54
|
-
`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
function languageForFilename(filename) {
|
|
58
|
-
switch (path.extname(filename).toLowerCase()) {
|
|
59
|
-
case ".sh":
|
|
60
|
-
return "bash";
|
|
61
|
-
case ".py":
|
|
62
|
-
return "python";
|
|
63
|
-
case ".js":
|
|
64
|
-
case ".mjs":
|
|
65
|
-
return "javascript";
|
|
66
|
-
case ".ts":
|
|
67
|
-
return "typescript";
|
|
68
|
-
default:
|
|
69
|
-
return "";
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
assertUniqueSlug,
|
|
74
|
-
filenameSlug,
|
|
75
|
-
isRecord,
|
|
76
|
-
languageForFilename,
|
|
77
|
-
renderTableRow,
|
|
78
|
-
warn,
|
|
79
|
-
writeGeneratedPage
|
|
80
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export interface ResourceLocaleConfig {
|
|
2
|
-
dir: string;
|
|
3
|
-
}
|
|
4
|
-
export interface ResolveLocaleDirsOptions {
|
|
5
|
-
/** Project root used to resolve project-relative content directories. */
|
|
6
|
-
projectRoot: string;
|
|
7
|
-
/** Default-locale content directory, already resolved or project-relative. */
|
|
8
|
-
docsDir: string;
|
|
9
|
-
/** Additional locale directories, keyed by locale code. */
|
|
10
|
-
locales?: Record<string, ResourceLocaleConfig>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Resolve additional locale content roots using the same rules as the
|
|
14
|
-
* generator's default `docsDir`: absolute values pass through, while relative
|
|
15
|
-
* values resolve against `projectRoot`.
|
|
16
|
-
*
|
|
17
|
-
* Generated locale indexes are written into these roots by a later emission
|
|
18
|
-
* step. Rejecting duplicate roots here is important because a recursive clean
|
|
19
|
-
* or a generated index for one locale must never target another locale's tree.
|
|
20
|
-
*/
|
|
21
|
-
export declare function resolveLocaleDirs({ projectRoot, docsDir, locales, }: ResolveLocaleDirsOptions): Record<string, ResourceLocaleConfig> | undefined;
|
|
22
|
-
export declare function ensureDir(dir: string): void;
|
|
23
|
-
export declare function cleanDir(dir: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* Write one generated locale index without deleting or overwriting authored
|
|
26
|
-
* content. A missing file is created; an existing file is only replaced when
|
|
27
|
-
* its frontmatter explicitly carries `generated: true`.
|
|
28
|
-
*/
|
|
29
|
-
export declare function writeGeneratedIndex(absPath: string, mdx: string, routePrefix?: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Remove a generated locale index that is no longer backed by a source
|
|
32
|
-
* category. Authored files are intentionally left untouched: locale trees
|
|
33
|
-
* can contain downstream overrides and are never recursively cleaned.
|
|
34
|
-
*/
|
|
35
|
-
export declare function removeGeneratedIndex(absPath: string): void;
|
|
36
|
-
export declare function listFiles(dir: string): string[];
|