@takazudo/zudo-doc 13.0.1 → 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 +21 -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,340 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { escapeForMdx } from "./escape-for-mdx.js";
|
|
4
|
-
import {
|
|
5
|
-
downgradeRepoRelativeLinks,
|
|
6
|
-
rewriteMarkdownLinks
|
|
7
|
-
} from "./links.js";
|
|
8
|
-
import {
|
|
9
|
-
assertNotIndexReserved,
|
|
10
|
-
escapeTitle,
|
|
11
|
-
parseFrontmatter,
|
|
12
|
-
writeCategoryIndex,
|
|
13
|
-
writeUnlistedSubPage
|
|
14
|
-
} from "./mdx.js";
|
|
15
|
-
import { cleanDir, ensureDir, listFiles } from "./fs.js";
|
|
16
|
-
function getSkillFileTree(skillDir, subDirs) {
|
|
17
|
-
const lines = [`${skillDir}/`];
|
|
18
|
-
const entries = [{ isDir: false, name: "SKILL.md" }];
|
|
19
|
-
for (const sub of subDirs) {
|
|
20
|
-
entries.push({ isDir: true, name: sub.name, children: sub.files });
|
|
21
|
-
}
|
|
22
|
-
for (let i = 0; i < entries.length; i++) {
|
|
23
|
-
const entry = entries[i];
|
|
24
|
-
if (!entry) continue;
|
|
25
|
-
const isLast = i === entries.length - 1;
|
|
26
|
-
const prefix = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
27
|
-
if (!entry.isDir) {
|
|
28
|
-
lines.push(`${prefix}${entry.name}`);
|
|
29
|
-
} else {
|
|
30
|
-
lines.push(`${prefix}${entry.name}/`);
|
|
31
|
-
for (let j = 0; j < entry.children.length; j++) {
|
|
32
|
-
const child = entry.children[j];
|
|
33
|
-
if (!child) continue;
|
|
34
|
-
const childIsLast = j === entry.children.length - 1;
|
|
35
|
-
const continuation = isLast ? " " : "\u2502 ";
|
|
36
|
-
const childPrefix = childIsLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
37
|
-
lines.push(`${continuation}${childPrefix}${child}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return lines.join("\n");
|
|
42
|
-
}
|
|
43
|
-
function getScriptDescription(filePath) {
|
|
44
|
-
try {
|
|
45
|
-
const topLines = fs.readFileSync(filePath, "utf8").split("\n", 2);
|
|
46
|
-
const firstLine = topLines[0] ?? "";
|
|
47
|
-
const commentLine = firstLine.startsWith("#!") ? topLines[1] ?? "" : firstLine;
|
|
48
|
-
const match = commentLine.match(/^(?:#|\/\/)\s*(.+)/);
|
|
49
|
-
return match ? ` \u2014 ${match[1]}` : "";
|
|
50
|
-
} catch {
|
|
51
|
-
return "";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function getSkillReferences(skillsDir, skillDir) {
|
|
55
|
-
const refsDir = path.join(skillsDir, skillDir, "references");
|
|
56
|
-
if (!fs.existsSync(refsDir)) return [];
|
|
57
|
-
let files;
|
|
58
|
-
try {
|
|
59
|
-
files = fs.readdirSync(refsDir);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.warn(
|
|
62
|
-
`resource-docs: unable to read references directory "${refsDir}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
63
|
-
);
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
return files.filter((f) => f.endsWith(".md")).flatMap((f) => {
|
|
67
|
-
const refPath = path.join(refsDir, f);
|
|
68
|
-
let content;
|
|
69
|
-
try {
|
|
70
|
-
content = fs.readFileSync(refPath, "utf8");
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.warn(
|
|
73
|
-
`resource-docs: unable to read skill reference "${refPath}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
74
|
-
);
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
const name = f.replace(/\.md$/, "");
|
|
78
|
-
const h1Match = content.match(/^#\s+(.+)$/m);
|
|
79
|
-
const title = h1Match?.[1] ?? name;
|
|
80
|
-
return [{ name, title, content }];
|
|
81
|
-
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
82
|
-
}
|
|
83
|
-
function realPathOrWarn(filePath) {
|
|
84
|
-
try {
|
|
85
|
-
return fs.realpathSync(filePath);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.warn(
|
|
88
|
-
`resource-docs: unable to resolve skills directory "${filePath}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
89
|
-
);
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function readSkillDirs(skillsDir) {
|
|
94
|
-
let entries;
|
|
95
|
-
try {
|
|
96
|
-
entries = fs.readdirSync(skillsDir);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.warn(
|
|
99
|
-
`resource-docs: unable to read skills directory "${skillsDir}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
100
|
-
);
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
return entries.filter((dir) => {
|
|
104
|
-
if (dir.startsWith(".")) return false;
|
|
105
|
-
const skillPath = path.join(skillsDir, dir);
|
|
106
|
-
try {
|
|
107
|
-
return fs.statSync(skillPath).isDirectory() && fs.existsSync(path.join(skillPath, "SKILL.md"));
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.warn(
|
|
110
|
-
`resource-docs: unable to read skill directory "${skillPath}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
111
|
-
);
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function readSkillFiles(dir) {
|
|
117
|
-
try {
|
|
118
|
-
return listFiles(dir);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.warn(
|
|
121
|
-
`resource-docs: unable to read skill files in "${dir}", skipping them: ${error instanceof Error ? error.message : String(error)}`
|
|
122
|
-
);
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function readFrontmatterString(value, field, skillFile) {
|
|
127
|
-
if (value === void 0) return void 0;
|
|
128
|
-
if (typeof value === "string") return value;
|
|
129
|
-
console.warn(
|
|
130
|
-
`resource-docs: skill frontmatter field "${field}" in "${skillFile}" must be a string; using the fallback value.`
|
|
131
|
-
);
|
|
132
|
-
return void 0;
|
|
133
|
-
}
|
|
134
|
-
function generateSkillsCategory({
|
|
135
|
-
skillsDirs,
|
|
136
|
-
outputDir,
|
|
137
|
-
label,
|
|
138
|
-
position,
|
|
139
|
-
description,
|
|
140
|
-
sourceLabel,
|
|
141
|
-
renderExtraHeader,
|
|
142
|
-
renderFrontmatterString
|
|
143
|
-
}) {
|
|
144
|
-
cleanDir(outputDir);
|
|
145
|
-
const roots = [];
|
|
146
|
-
const seenRoots = /* @__PURE__ */ new Set();
|
|
147
|
-
for (const skillsDir of skillsDirs) {
|
|
148
|
-
if (!fs.existsSync(skillsDir)) continue;
|
|
149
|
-
const realDir = realPathOrWarn(skillsDir);
|
|
150
|
-
if (realDir === null || seenRoots.has(realDir)) continue;
|
|
151
|
-
seenRoots.add(realDir);
|
|
152
|
-
roots.push({ sourceDir: skillsDir, realDir });
|
|
153
|
-
}
|
|
154
|
-
if (roots.length === 0) return [];
|
|
155
|
-
const discovered = [];
|
|
156
|
-
const seenSkillDirs = /* @__PURE__ */ new Set();
|
|
157
|
-
const seenNames = /* @__PURE__ */ new Map();
|
|
158
|
-
for (const root of roots) {
|
|
159
|
-
for (const dir of readSkillDirs(root.sourceDir)) {
|
|
160
|
-
const skillAbsDir = path.join(root.sourceDir, dir);
|
|
161
|
-
const realSkillDir = realPathOrWarn(skillAbsDir);
|
|
162
|
-
if (realSkillDir === null || seenSkillDirs.has(realSkillDir)) continue;
|
|
163
|
-
seenSkillDirs.add(realSkillDir);
|
|
164
|
-
const previous = seenNames.get(dir);
|
|
165
|
-
if (previous !== void 0) {
|
|
166
|
-
console.warn(
|
|
167
|
-
`resource-docs: skill "${dir}" from "${root.sourceDir}" conflicts with the skill from "${previous}"; keeping the first one.`
|
|
168
|
-
);
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
seenNames.set(dir, root.sourceDir);
|
|
172
|
-
discovered.push({ sourceDir: root.sourceDir, dir, skillAbsDir, realSkillDir });
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (discovered.length === 0) return [];
|
|
176
|
-
ensureDir(outputDir);
|
|
177
|
-
const items = [];
|
|
178
|
-
const resourcePrefix = sourceLabel.startsWith(".claude/") ? "claude-resources" : "codex-resources";
|
|
179
|
-
for (const discoveredSkill of discovered) {
|
|
180
|
-
const { sourceDir, dir, skillAbsDir } = discoveredSkill;
|
|
181
|
-
assertNotIndexReserved(
|
|
182
|
-
dir,
|
|
183
|
-
`${resourcePrefix}: skill directory "${sourceLabel}/index/" uses the reserved name "index", which is used for the category metadata file. Rename the skill directory to resolve the conflict.`
|
|
184
|
-
);
|
|
185
|
-
let content;
|
|
186
|
-
try {
|
|
187
|
-
content = fs.readFileSync(path.join(skillAbsDir, "SKILL.md"), "utf8");
|
|
188
|
-
} catch (error) {
|
|
189
|
-
console.warn(
|
|
190
|
-
`resource-docs: unable to read skill "${skillAbsDir}/SKILL.md", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
191
|
-
);
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
const parsed = parseFrontmatter(content);
|
|
195
|
-
if (!parsed) continue;
|
|
196
|
-
const skillFile = path.join(skillAbsDir, "SKILL.md");
|
|
197
|
-
const name = readFrontmatterString(parsed.data.name, "name", skillFile) || dir;
|
|
198
|
-
const skillDescription = readFrontmatterString(parsed.data.description, "description", skillFile) || "";
|
|
199
|
-
const references = getSkillReferences(sourceDir, dir);
|
|
200
|
-
items.push({ name, dir, description: skillDescription, references });
|
|
201
|
-
const scriptFiles = readSkillFiles(path.join(skillAbsDir, "scripts"));
|
|
202
|
-
const assetFiles = readSkillFiles(path.join(skillAbsDir, "assets"));
|
|
203
|
-
const refFiles = references.map((r) => `${r.name}.md`);
|
|
204
|
-
const subDirs = [];
|
|
205
|
-
if (scriptFiles.length > 0) subDirs.push({ name: "scripts", files: scriptFiles });
|
|
206
|
-
if (refFiles.length > 0) subDirs.push({ name: "references", files: refFiles });
|
|
207
|
-
if (assetFiles.length > 0) subDirs.push({ name: "assets", files: assetFiles });
|
|
208
|
-
let fileStructureSection = "";
|
|
209
|
-
if (subDirs.length > 0) {
|
|
210
|
-
const tree = `\`\`\`
|
|
211
|
-
${getSkillFileTree(dir, subDirs)}
|
|
212
|
-
\`\`\``;
|
|
213
|
-
const links = [];
|
|
214
|
-
for (const ref of references) {
|
|
215
|
-
links.push(`- [references/${ref.name}.md](./ref-${ref.name})`);
|
|
216
|
-
}
|
|
217
|
-
for (const f of scriptFiles.filter((s) => s.endsWith(".md"))) {
|
|
218
|
-
const slug = f.replace(/\.md$/, "");
|
|
219
|
-
links.push(`- [scripts/${f}](./script-${slug})`);
|
|
220
|
-
}
|
|
221
|
-
for (const f of assetFiles.filter((a) => a.endsWith(".md"))) {
|
|
222
|
-
const slug = f.replace(/\.md$/, "");
|
|
223
|
-
links.push(`- [assets/${f}](./asset-${slug})`);
|
|
224
|
-
}
|
|
225
|
-
const linkList = links.length > 0 ? `
|
|
226
|
-
|
|
227
|
-
${links.join("\n")}` : "";
|
|
228
|
-
fileStructureSection = `## File Structure
|
|
229
|
-
|
|
230
|
-
${tree}${linkList}`;
|
|
231
|
-
}
|
|
232
|
-
const shortDesc = skillDescription.length > 200 ? skillDescription.substring(0, 200) + "..." : skillDescription;
|
|
233
|
-
let extraHeader = "";
|
|
234
|
-
if (renderExtraHeader) {
|
|
235
|
-
try {
|
|
236
|
-
extraHeader = renderExtraHeader(skillAbsDir).trim();
|
|
237
|
-
} catch (error) {
|
|
238
|
-
console.warn(
|
|
239
|
-
`resource-docs: unable to render extra metadata for skill "${skillAbsDir}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
const skillLinkRewrites = /* @__PURE__ */ new Map();
|
|
244
|
-
for (const ref of references) {
|
|
245
|
-
skillLinkRewrites.set(`references/${ref.name}.md`, `./ref-${ref.name}`);
|
|
246
|
-
}
|
|
247
|
-
for (const f of scriptFiles.filter((s) => s.endsWith(".md"))) {
|
|
248
|
-
const slug = f.replace(/\.md$/, "");
|
|
249
|
-
skillLinkRewrites.set(`scripts/${f}`, `./script-${slug}`);
|
|
250
|
-
}
|
|
251
|
-
for (const f of assetFiles.filter((a) => a.endsWith(".md"))) {
|
|
252
|
-
const slug = f.replace(/\.md$/, "");
|
|
253
|
-
skillLinkRewrites.set(`assets/${f}`, `./asset-${slug}`);
|
|
254
|
-
}
|
|
255
|
-
const emittedSkillLinks = new Set(skillLinkRewrites.values());
|
|
256
|
-
const skillBody = downgradeRepoRelativeLinks(
|
|
257
|
-
rewriteMarkdownLinks(
|
|
258
|
-
parsed.content.trim(),
|
|
259
|
-
(url) => skillLinkRewrites.get(url)
|
|
260
|
-
),
|
|
261
|
-
(url) => emittedSkillLinks.has(url)
|
|
262
|
-
);
|
|
263
|
-
const body = [
|
|
264
|
-
extraHeader,
|
|
265
|
-
fileStructureSection,
|
|
266
|
-
escapeForMdx(skillBody)
|
|
267
|
-
].filter(Boolean).join("\n\n");
|
|
268
|
-
const renderString = renderFrontmatterString ?? ((value) => `"${escapeTitle(value)}"`);
|
|
269
|
-
const mdx = `---
|
|
270
|
-
title: ${renderString(name)}
|
|
271
|
-
description: ${renderString(shortDesc)}
|
|
272
|
-
sidebar_label: ${renderString(name)}
|
|
273
|
-
generated: true
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
${body}`;
|
|
277
|
-
const skillDirOut = path.join(outputDir, dir);
|
|
278
|
-
ensureDir(skillDirOut);
|
|
279
|
-
fs.writeFileSync(path.join(skillDirOut, "index.mdx"), mdx);
|
|
280
|
-
for (const ref of references) {
|
|
281
|
-
writeUnlistedSubPage(
|
|
282
|
-
path.join(skillDirOut, `ref-${ref.name}.mdx`),
|
|
283
|
-
ref.title,
|
|
284
|
-
escapeForMdx(downgradeRepoRelativeLinks(ref.content.trim())),
|
|
285
|
-
renderFrontmatterString
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
for (const f of scriptFiles.filter((s) => s.endsWith(".md"))) {
|
|
289
|
-
const slug = f.replace(/\.md$/, "");
|
|
290
|
-
const scriptPath = path.join(skillAbsDir, "scripts", f);
|
|
291
|
-
let raw;
|
|
292
|
-
try {
|
|
293
|
-
raw = fs.readFileSync(scriptPath, "utf8");
|
|
294
|
-
} catch (error) {
|
|
295
|
-
console.warn(
|
|
296
|
-
`resource-docs: unable to read skill script "${scriptPath}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
297
|
-
);
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
const h1Match = raw.match(/^#\s+(.+)$/m);
|
|
301
|
-
const title = h1Match?.[1] ?? slug;
|
|
302
|
-
writeUnlistedSubPage(
|
|
303
|
-
path.join(skillDirOut, `script-${slug}.mdx`),
|
|
304
|
-
title,
|
|
305
|
-
escapeForMdx(downgradeRepoRelativeLinks(raw.trim())),
|
|
306
|
-
renderFrontmatterString
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
for (const f of assetFiles.filter((a) => a.endsWith(".md"))) {
|
|
310
|
-
const slug = f.replace(/\.md$/, "");
|
|
311
|
-
const assetPath = path.join(skillAbsDir, "assets", f);
|
|
312
|
-
let raw;
|
|
313
|
-
try {
|
|
314
|
-
raw = fs.readFileSync(assetPath, "utf8");
|
|
315
|
-
} catch (error) {
|
|
316
|
-
console.warn(
|
|
317
|
-
`resource-docs: unable to read skill asset "${assetPath}", skipping it: ${error instanceof Error ? error.message : String(error)}`
|
|
318
|
-
);
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const h1Match = raw.match(/^#\s+(.+)$/m);
|
|
322
|
-
const title = h1Match?.[1] ?? slug;
|
|
323
|
-
writeUnlistedSubPage(
|
|
324
|
-
path.join(skillDirOut, `asset-${slug}.mdx`),
|
|
325
|
-
title,
|
|
326
|
-
escapeForMdx(downgradeRepoRelativeLinks(raw.trim())),
|
|
327
|
-
renderFrontmatterString
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
items.sort((a, b) => a.name.localeCompare(b.name));
|
|
332
|
-
writeCategoryIndex(outputDir, label, position, description, renderFrontmatterString);
|
|
333
|
-
return items;
|
|
334
|
-
}
|
|
335
|
-
export {
|
|
336
|
-
generateSkillsCategory,
|
|
337
|
-
getScriptDescription,
|
|
338
|
-
getSkillFileTree,
|
|
339
|
-
getSkillReferences
|
|
340
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Directory names skipped by basename at ANY depth of the walk.
|
|
3
|
-
*
|
|
4
|
-
* These are build output, vendored trees, and tooling scratch dirs that can
|
|
5
|
-
* belong to *any* project under the scan root, not just the one at its top
|
|
6
|
-
* level. Anchoring them to the scan root (the pre-#3200 behaviour) meant a
|
|
7
|
-
* doc site in a repo subdirectory with `scanRoot` widened to the repo root
|
|
8
|
-
* still walked its own `dist/`, `public/`, `out/`, and `test-results/` on
|
|
9
|
-
* every build — the exact nested layout `scanRoot` exists for.
|
|
10
|
-
*
|
|
11
|
-
* `.git` needs no entry here: dot-prefixed entries are already skipped at any
|
|
12
|
-
* depth by the loop below.
|
|
13
|
-
*/
|
|
14
|
-
export declare const EXCLUDED_DIR_NAMES: Set<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Find named regular files without following symlinked directories.
|
|
17
|
-
* Excludes are path-segment-boundary-aware, and dot-prefixed entries are
|
|
18
|
-
* skipped at every depth.
|
|
19
|
-
*/
|
|
20
|
-
export declare function findNamedFiles(dir: string, excludeDirs: string[], fileNames: string[]): string[];
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
const EXCLUDED_DIR_NAMES = /* @__PURE__ */ new Set([
|
|
4
|
-
"node_modules",
|
|
5
|
-
"worktrees",
|
|
6
|
-
"dist",
|
|
7
|
-
"out",
|
|
8
|
-
"public",
|
|
9
|
-
"__inbox",
|
|
10
|
-
"test-results"
|
|
11
|
-
]);
|
|
12
|
-
function findNamedFiles(dir, excludeDirs, fileNames) {
|
|
13
|
-
const results = [];
|
|
14
|
-
if (!fs.existsSync(dir)) return results;
|
|
15
|
-
const excludes = excludeDirs.map(
|
|
16
|
-
(d) => d.endsWith(path.sep) ? d.slice(0, -path.sep.length) : d
|
|
17
|
-
);
|
|
18
|
-
const names = new Set(fileNames);
|
|
19
|
-
for (const item of fs.readdirSync(dir)) {
|
|
20
|
-
if (EXCLUDED_DIR_NAMES.has(item)) continue;
|
|
21
|
-
if (item.startsWith(".")) continue;
|
|
22
|
-
const itemPath = path.join(dir, item);
|
|
23
|
-
if (excludes.some((d) => itemPath === d || itemPath.startsWith(d + path.sep))) continue;
|
|
24
|
-
let stat;
|
|
25
|
-
try {
|
|
26
|
-
stat = fs.lstatSync(itemPath);
|
|
27
|
-
} catch {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (stat.isDirectory()) {
|
|
31
|
-
results.push(...findNamedFiles(itemPath, excludes, fileNames));
|
|
32
|
-
} else if (stat.isFile() && names.has(item)) {
|
|
33
|
-
results.push(itemPath);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return results;
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
EXCLUDED_DIR_NAMES,
|
|
40
|
-
findNamedFiles
|
|
41
|
-
};
|
/package/dist/plugins/internal/{resource-docs-shared → doc-sources/render}/escape-for-mdx.d.ts
RENAMED
|
File without changes
|