@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,101 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { parseFrontmatter } from "./mdx.js";
|
|
4
|
-
function resolveLocaleDirs({
|
|
5
|
-
projectRoot,
|
|
6
|
-
docsDir,
|
|
7
|
-
locales
|
|
8
|
-
}) {
|
|
9
|
-
if (locales === void 0) return void 0;
|
|
10
|
-
const defaultDir = resolveConfiguredDir(projectRoot, docsDir);
|
|
11
|
-
const defaultRoot = canonicalExistingRoot(defaultDir);
|
|
12
|
-
const roots = /* @__PURE__ */ new Map([
|
|
13
|
-
[defaultRoot, { label: "default docsDir", dir: defaultDir }]
|
|
14
|
-
]);
|
|
15
|
-
const resolved = {};
|
|
16
|
-
for (const [locale, config] of Object.entries(locales)) {
|
|
17
|
-
if (config === null || typeof config !== "object" || typeof config.dir !== "string") {
|
|
18
|
-
throw new TypeError(
|
|
19
|
-
`resource-docs: locale "${locale}" must configure a content directory as { dir: string }`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
const dir = resolveConfiguredDir(projectRoot, config.dir);
|
|
23
|
-
const canonicalDir = canonicalExistingRoot(dir);
|
|
24
|
-
const previous = roots.get(canonicalDir);
|
|
25
|
-
if (previous !== void 0) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`resource-docs: locale "${locale}" directory "${dir}" overlaps ${previous.label} at "${canonicalDir}". Configure a distinct content directory (or remove/rename the conflicting locale).`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
roots.set(canonicalDir, { label: `locale "${locale}"`, dir });
|
|
31
|
-
resolved[locale] = { dir };
|
|
32
|
-
}
|
|
33
|
-
return resolved;
|
|
34
|
-
}
|
|
35
|
-
function resolveConfiguredDir(projectRoot, input) {
|
|
36
|
-
return path.isAbsolute(input) ? input : path.resolve(projectRoot, input);
|
|
37
|
-
}
|
|
38
|
-
function canonicalExistingRoot(dir) {
|
|
39
|
-
const normalized = path.normalize(dir);
|
|
40
|
-
try {
|
|
41
|
-
return path.normalize(fs.realpathSync.native(normalized));
|
|
42
|
-
} catch {
|
|
43
|
-
return normalized;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function ensureDir(dir) {
|
|
47
|
-
if (!fs.existsSync(dir)) {
|
|
48
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function cleanDir(dir) {
|
|
52
|
-
if (!fs.existsSync(dir)) return;
|
|
53
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
54
|
-
}
|
|
55
|
-
function writeGeneratedIndex(absPath, mdx, routePrefix) {
|
|
56
|
-
if (fs.existsSync(absPath)) {
|
|
57
|
-
let existing;
|
|
58
|
-
try {
|
|
59
|
-
existing = fs.readFileSync(absPath, "utf8");
|
|
60
|
-
} catch (error) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
`resource-docs: cannot inspect existing locale index "${absPath}" before writing (${error instanceof Error ? error.message : String(error)}). Remove or rename the file, then retry.`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
const parsed = parseFrontmatter(existing);
|
|
66
|
-
if (parsed?.data.generated !== true) {
|
|
67
|
-
const remedy = routePrefix === void 0 ? "add this route to defaultLocaleOnlyPrefixes" : `add "${routePrefix}" to defaultLocaleOnlyPrefixes`;
|
|
68
|
-
throw new Error(
|
|
69
|
-
`resource-docs: refusing to overwrite authored locale index "${absPath}" because its frontmatter does not contain generated: true. Remove or rename the file, or ${remedy} to keep this locale's file authoritative, then retry.`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
ensureDir(path.dirname(absPath));
|
|
74
|
-
fs.writeFileSync(absPath, mdx);
|
|
75
|
-
}
|
|
76
|
-
function removeGeneratedIndex(absPath) {
|
|
77
|
-
if (!fs.existsSync(absPath)) return;
|
|
78
|
-
let existing;
|
|
79
|
-
try {
|
|
80
|
-
existing = fs.readFileSync(absPath, "utf8");
|
|
81
|
-
} catch (error) {
|
|
82
|
-
throw new Error(
|
|
83
|
-
`resource-docs: cannot inspect existing locale index "${absPath}" before removing it (${error instanceof Error ? error.message : String(error)}). Remove or rename the file, then retry.`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
if (parseFrontmatter(existing)?.data.generated === true) {
|
|
87
|
-
fs.unlinkSync(absPath);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function listFiles(dir) {
|
|
91
|
-
if (!fs.existsSync(dir)) return [];
|
|
92
|
-
return fs.readdirSync(dir, { withFileTypes: true }).filter((d) => d.isFile()).map((d) => d.name).sort();
|
|
93
|
-
}
|
|
94
|
-
export {
|
|
95
|
-
cleanDir,
|
|
96
|
-
ensureDir,
|
|
97
|
-
listFiles,
|
|
98
|
-
removeGeneratedIndex,
|
|
99
|
-
resolveLocaleDirs,
|
|
100
|
-
writeGeneratedIndex
|
|
101
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { escapeForMdx } from "./escape-for-mdx.js";
|
|
2
|
-
export { cleanDir, ensureDir, listFiles, removeGeneratedIndex, resolveLocaleDirs, writeGeneratedIndex, type ResolveLocaleDirsOptions, type ResourceLocaleConfig, } from "./fs.js";
|
|
3
|
-
export { resolveLabel, resolveResourceLabel, type ResolveResourceLabelOptions, type ResourceTranslations, } from "./labels.js";
|
|
4
|
-
export { shouldEmitResourceLocaleRoute, type ResourceLocaleRouteOptions, } from "./locale-routes.js";
|
|
5
|
-
export { assertNotIndexReserved, escapeTitle, formatFrontmatterString, parseFrontmatter, type FrontmatterStringRenderer, type MdxFileWriter, writeCategoryIndex, writeUnlistedSubPage, } from "./mdx.js";
|
|
6
|
-
export { isRepoRelativeLink, rewriteMarkdownLinks, downgradeRepoRelativeLinks, } from "./links.js";
|
|
7
|
-
export { escapeMarkdownTableCell, renderCodeFence, } from "./markdown-structure.js";
|
|
8
|
-
export { EXCLUDED_DIR_NAMES, findNamedFiles } from "./walk.js";
|
|
9
|
-
export { generateSkillsCategory, getScriptDescription, getSkillFileTree, getSkillReferences, type GenerateSkillsCategoryOptions, type RenderExtraHeader, type SkillItem, type SkillReference, } from "./skills.js";
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { escapeForMdx } from "./escape-for-mdx.js";
|
|
2
|
-
import {
|
|
3
|
-
cleanDir,
|
|
4
|
-
ensureDir,
|
|
5
|
-
listFiles,
|
|
6
|
-
removeGeneratedIndex,
|
|
7
|
-
resolveLocaleDirs,
|
|
8
|
-
writeGeneratedIndex
|
|
9
|
-
} from "./fs.js";
|
|
10
|
-
import {
|
|
11
|
-
resolveLabel,
|
|
12
|
-
resolveResourceLabel
|
|
13
|
-
} from "./labels.js";
|
|
14
|
-
import {
|
|
15
|
-
shouldEmitResourceLocaleRoute
|
|
16
|
-
} from "./locale-routes.js";
|
|
17
|
-
import {
|
|
18
|
-
assertNotIndexReserved,
|
|
19
|
-
escapeTitle,
|
|
20
|
-
formatFrontmatterString,
|
|
21
|
-
parseFrontmatter,
|
|
22
|
-
writeCategoryIndex,
|
|
23
|
-
writeUnlistedSubPage
|
|
24
|
-
} from "./mdx.js";
|
|
25
|
-
import {
|
|
26
|
-
isRepoRelativeLink,
|
|
27
|
-
rewriteMarkdownLinks,
|
|
28
|
-
downgradeRepoRelativeLinks
|
|
29
|
-
} from "./links.js";
|
|
30
|
-
import {
|
|
31
|
-
escapeMarkdownTableCell,
|
|
32
|
-
renderCodeFence
|
|
33
|
-
} from "./markdown-structure.js";
|
|
34
|
-
import { EXCLUDED_DIR_NAMES, findNamedFiles } from "./walk.js";
|
|
35
|
-
import {
|
|
36
|
-
generateSkillsCategory,
|
|
37
|
-
getScriptDescription,
|
|
38
|
-
getSkillFileTree,
|
|
39
|
-
getSkillReferences
|
|
40
|
-
} from "./skills.js";
|
|
41
|
-
export {
|
|
42
|
-
EXCLUDED_DIR_NAMES,
|
|
43
|
-
assertNotIndexReserved,
|
|
44
|
-
cleanDir,
|
|
45
|
-
downgradeRepoRelativeLinks,
|
|
46
|
-
ensureDir,
|
|
47
|
-
escapeForMdx,
|
|
48
|
-
escapeMarkdownTableCell,
|
|
49
|
-
escapeTitle,
|
|
50
|
-
findNamedFiles,
|
|
51
|
-
formatFrontmatterString,
|
|
52
|
-
generateSkillsCategory,
|
|
53
|
-
getScriptDescription,
|
|
54
|
-
getSkillFileTree,
|
|
55
|
-
getSkillReferences,
|
|
56
|
-
isRepoRelativeLink,
|
|
57
|
-
listFiles,
|
|
58
|
-
parseFrontmatter,
|
|
59
|
-
removeGeneratedIndex,
|
|
60
|
-
renderCodeFence,
|
|
61
|
-
resolveLabel,
|
|
62
|
-
resolveLocaleDirs,
|
|
63
|
-
resolveResourceLabel,
|
|
64
|
-
rewriteMarkdownLinks,
|
|
65
|
-
shouldEmitResourceLocaleRoute,
|
|
66
|
-
writeCategoryIndex,
|
|
67
|
-
writeGeneratedIndex,
|
|
68
|
-
writeUnlistedSubPage
|
|
69
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type ResourceTranslations = Record<string, Record<string, string>>;
|
|
2
|
-
export interface ResolveResourceLabelOptions {
|
|
3
|
-
/** UI-string translation table, keyed by locale then translation key. */
|
|
4
|
-
translations?: ResourceTranslations;
|
|
5
|
-
/** Locale for the page currently being generated. */
|
|
6
|
-
locale: string;
|
|
7
|
-
/** Configured default locale, if one was supplied by the caller. */
|
|
8
|
-
defaultLocale?: string;
|
|
9
|
-
/** Translation key to resolve. */
|
|
10
|
-
key: string;
|
|
11
|
-
/** English literal emitted by the pre-i18n generator. */
|
|
12
|
-
fallbackLiteral: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Resolve a generated-resource label with the same fallback order as `t()`.
|
|
16
|
-
*
|
|
17
|
-
* The caller must provide the English literal that the generator used before
|
|
18
|
-
* localization. Keeping that literal as the final fallback prevents a
|
|
19
|
-
* missing translation from leaking an implementation key such as
|
|
20
|
-
* `resource.claude.title` into frontmatter or page output.
|
|
21
|
-
*/
|
|
22
|
-
export declare function resolveResourceLabel({ translations, locale, defaultLocale, key, fallbackLiteral, }: ResolveResourceLabelOptions): string;
|
|
23
|
-
/** Short alias for callers that already work in the resource-docs namespace. */
|
|
24
|
-
export declare const resolveLabel: typeof resolveResourceLabel;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function resolveResourceLabel({
|
|
2
|
-
translations,
|
|
3
|
-
locale,
|
|
4
|
-
defaultLocale,
|
|
5
|
-
key,
|
|
6
|
-
fallbackLiteral
|
|
7
|
-
}) {
|
|
8
|
-
return translations?.[locale]?.[key] ?? (defaultLocale === void 0 ? void 0 : translations?.[defaultLocale]?.[key]) ?? translations?.en?.[key] ?? fallbackLiteral;
|
|
9
|
-
}
|
|
10
|
-
const resolveLabel = resolveResourceLabel;
|
|
11
|
-
export {
|
|
12
|
-
resolveLabel,
|
|
13
|
-
resolveResourceLabel
|
|
14
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether a markdown link target is a repo-relative file reference
|
|
3
|
-
* (`./wrangler.toml`, `../../schema/photos.sql`, `foo/bar.md`) rather than
|
|
4
|
-
* something the doc site can resolve: an absolute URL (`https://…`), a
|
|
5
|
-
* protocol-relative URL (`//…`), a site-absolute path (`/docs/…`), a pure
|
|
6
|
-
* anchor (`#…`), or a scheme (`mailto:`, `tel:`).
|
|
7
|
-
*/
|
|
8
|
-
export declare function isRepoRelativeLink(url: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Rewrite markdown link destinations outside fenced and inline code.
|
|
11
|
-
* Returning `undefined` from `rewrite` leaves that link unchanged.
|
|
12
|
-
*/
|
|
13
|
-
export declare function rewriteMarkdownLinks(content: string, rewrite: (url: string) => string | undefined): string;
|
|
14
|
-
/**
|
|
15
|
-
* Downgrade repo-relative markdown links in a mirrored `CLAUDE.md` body to
|
|
16
|
-
* inline code so they don't dangle in the flattened mirror tree (#2411).
|
|
17
|
-
*
|
|
18
|
-
* A `CLAUDE.md`'s relative links point at real repo files (correct for an
|
|
19
|
-
* in-repo reader), but the mirror flattens each file into a single
|
|
20
|
-
* `claude-md/<name>.mdx` page with no counterpart for those targets — left as
|
|
21
|
-
* links they surface as `broken link:` warnings on every affected page. Inline
|
|
22
|
-
* code keeps the reference legible (`` `wrangler.toml` ``) without a href.
|
|
23
|
-
*
|
|
24
|
-
* Code spans are preserved verbatim: a `[x](./y)` inside a fenced block or an
|
|
25
|
-
* inline-code span is literal text, not a link, and must not be rewritten.
|
|
26
|
-
*/
|
|
27
|
-
export declare function downgradeRepoRelativeLinks(content: string, keep?: (url: string) => boolean): string;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
function isRepoRelativeLink(url) {
|
|
2
|
-
const trimmed = url.trim();
|
|
3
|
-
if (trimmed === "") return false;
|
|
4
|
-
if (trimmed.startsWith("#")) return false;
|
|
5
|
-
if (trimmed.startsWith("/")) return false;
|
|
6
|
-
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) return false;
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
function transformMarkdownLinks(content, transform) {
|
|
10
|
-
const blockPlaceholder = "\0CRLINK_BLOCK_";
|
|
11
|
-
const inlinePlaceholder = "\0CRLINK_INLINE_";
|
|
12
|
-
const codeBlocks = [];
|
|
13
|
-
const withBlocks = content.replace(/(`{3,}|~{3,})[^\n]*\n[\s\S]*?\1/g, (match) => {
|
|
14
|
-
codeBlocks.push(match);
|
|
15
|
-
return `${blockPlaceholder}${codeBlocks.length - 1}\0`;
|
|
16
|
-
});
|
|
17
|
-
const transformed = withBlocks.split(new RegExp(`(${blockPlaceholder}\\d+\0)`, "g")).map((part) => {
|
|
18
|
-
if (new RegExp(`^${blockPlaceholder}\\d+\0$`).test(part)) return part;
|
|
19
|
-
const inlineCodes = [];
|
|
20
|
-
const withInline = part.replace(
|
|
21
|
-
/(`{1,3})(?!`)([\s\S]*?[^`])\1(?!`)/g,
|
|
22
|
-
(match) => {
|
|
23
|
-
inlineCodes.push(match);
|
|
24
|
-
return `${inlinePlaceholder}${inlineCodes.length - 1}\0`;
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
const rewritten = withInline.replace(
|
|
28
|
-
/!?\[([^\]]*)\]\(([^)]+)\)/g,
|
|
29
|
-
(match, text, url) => transform(match, text, url)
|
|
30
|
-
);
|
|
31
|
-
return rewritten.replace(
|
|
32
|
-
new RegExp(`${inlinePlaceholder}(\\d+)\0`, "g"),
|
|
33
|
-
(_, idx) => inlineCodes[Number(idx)] ?? ""
|
|
34
|
-
);
|
|
35
|
-
}).join("");
|
|
36
|
-
return transformed.replace(
|
|
37
|
-
new RegExp(`${blockPlaceholder}(\\d+)\0`, "g"),
|
|
38
|
-
(_, idx) => codeBlocks[Number(idx)] ?? ""
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
function rewriteMarkdownLinks(content, rewrite) {
|
|
42
|
-
return transformMarkdownLinks(content, (match, _text, url) => {
|
|
43
|
-
const replacement = rewrite(url);
|
|
44
|
-
if (replacement === void 0) return match;
|
|
45
|
-
const urlStart = match.length - url.length - 1;
|
|
46
|
-
if (urlStart < 0 || match.slice(urlStart, urlStart + url.length) !== url) {
|
|
47
|
-
return match;
|
|
48
|
-
}
|
|
49
|
-
return `${match.slice(0, urlStart)}${replacement}${match.slice(urlStart + url.length)}`;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function downgradeRepoRelativeLinks(content, keep) {
|
|
53
|
-
return transformMarkdownLinks(
|
|
54
|
-
content,
|
|
55
|
-
(match, text, url) => isRepoRelativeLink(url) && !(keep?.(url) ?? false) ? `\`${text}\`` : match
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
downgradeRepoRelativeLinks,
|
|
60
|
-
isRepoRelativeLink,
|
|
61
|
-
rewriteMarkdownLinks
|
|
62
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface ResourceLocaleRouteOptions {
|
|
2
|
-
/** Route slug below `/docs/`, without a locale prefix. */
|
|
3
|
-
slug: string;
|
|
4
|
-
/** Locale whose physical index would be emitted. */
|
|
5
|
-
locale: string;
|
|
6
|
-
/** Locale served from the unprefixed default docs root. */
|
|
7
|
-
defaultLocale?: string;
|
|
8
|
-
/** Default-locale-only route prefixes in their `/docs/.../` form. */
|
|
9
|
-
defaultLocaleOnlyPrefixes?: readonly string[];
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Whether a generated resource index has a route in the requested locale.
|
|
13
|
-
* Matching deliberately mirrors `url-helpers.isDefaultLocaleOnlyPath`: the
|
|
14
|
-
* default-locale-shaped route gets a trailing slash and uses prefix matching.
|
|
15
|
-
*/
|
|
16
|
-
export declare function shouldEmitResourceLocaleRoute({ slug, locale, defaultLocale, defaultLocaleOnlyPrefixes, }: ResourceLocaleRouteOptions): boolean;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function shouldEmitResourceLocaleRoute({
|
|
2
|
-
slug,
|
|
3
|
-
locale,
|
|
4
|
-
defaultLocale = "en",
|
|
5
|
-
defaultLocaleOnlyPrefixes = []
|
|
6
|
-
}) {
|
|
7
|
-
if (locale === defaultLocale) return true;
|
|
8
|
-
const normalizedSlug = slug.replace(/^\/+|\/+$/g, "");
|
|
9
|
-
const routePath = `/docs/${normalizedSlug}/`;
|
|
10
|
-
return !defaultLocaleOnlyPrefixes.some((prefix) => routePath.startsWith(prefix));
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
shouldEmitResourceLocaleRoute
|
|
14
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare function parseFrontmatter(content: string): import("../../../frontmatter/index.js").ParsedFrontmatter | null;
|
|
2
|
-
export declare function escapeTitle(s: string): string;
|
|
3
|
-
export type FrontmatterStringRenderer = (value: string) => string;
|
|
4
|
-
/**
|
|
5
|
-
* Write one generated MDX file. The callback seam lets locale indexes use
|
|
6
|
-
* `writeGeneratedIndex` (which protects authored files) while the default
|
|
7
|
-
* locale keeps the historical direct-write behaviour.
|
|
8
|
-
*/
|
|
9
|
-
export type MdxFileWriter = (absolutePath: string, content: string) => void;
|
|
10
|
-
export declare function formatFrontmatterString(value: string): string;
|
|
11
|
-
export declare function writeCategoryIndex(outputDir: string, label: string, position: number, description: string, renderString?: FrontmatterStringRenderer, writeFile?: MdxFileWriter): void;
|
|
12
|
-
/**
|
|
13
|
-
* Writes an unlisted sub-page MDX file. Used for skill references, scripts,
|
|
14
|
-
* and assets.
|
|
15
|
-
*
|
|
16
|
-
* The route is derived from the file's path within the content collection —
|
|
17
|
-
* deliberately NOT from an explicit `slug:`. zfb's `resolveMarkdownLinks`
|
|
18
|
-
* resolves relative links against the source file path, so the on-disk
|
|
19
|
-
* location of these pages must match the URL the skill page links to. Writing
|
|
20
|
-
* them at `<dir>/ref-<name>.mdx` (siblings of the skill's `index.mdx`) is what
|
|
21
|
-
* makes the `./ref-<name>` links resolve (#2411).
|
|
22
|
-
*/
|
|
23
|
-
export declare function writeUnlistedSubPage(outputPath: string, title: string, body: string, renderString?: FrontmatterStringRenderer): void;
|
|
24
|
-
/**
|
|
25
|
-
* Guards that the given name/slug is not the reserved "index" value.
|
|
26
|
-
* Throws with a contextual message if it is.
|
|
27
|
-
*/
|
|
28
|
-
export declare function assertNotIndexReserved(nameOrSlug: string, errorMessage: string): void;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { matter } from "../../../frontmatter/index.js";
|
|
4
|
-
function parseFrontmatter(content) {
|
|
5
|
-
try {
|
|
6
|
-
return matter(content);
|
|
7
|
-
} catch {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function escapeTitle(s) {
|
|
12
|
-
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
13
|
-
}
|
|
14
|
-
function formatFrontmatterString(value) {
|
|
15
|
-
const formatterRequiresQuotes = /["']/.test(value) || /^[?:-]/.test(value) || /^(?:yes|no|on|off)$/iu.test(value) || /^\+?(?:nan|inf(?:inity)?)$/iu.test(value);
|
|
16
|
-
if (!/[\r\n]/.test(value)) {
|
|
17
|
-
try {
|
|
18
|
-
const parsed = matter(`---
|
|
19
|
-
value: ${value}
|
|
20
|
-
---
|
|
21
|
-
`).data.value;
|
|
22
|
-
if (parsed === value && !formatterRequiresQuotes) return value;
|
|
23
|
-
} catch {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return JSON.stringify(value);
|
|
27
|
-
}
|
|
28
|
-
function writeCategoryIndex(outputDir, label, position, description, renderString = (value) => `"${escapeTitle(value)}"`, writeFile = (absolutePath, content) => fs.writeFileSync(absolutePath, content)) {
|
|
29
|
-
const mdx = `---
|
|
30
|
-
title: ${renderString(label)}
|
|
31
|
-
description: ${renderString(description)}
|
|
32
|
-
sidebar_position: ${position}
|
|
33
|
-
category_no_page: true
|
|
34
|
-
generated: true
|
|
35
|
-
---
|
|
36
|
-
`;
|
|
37
|
-
writeFile(path.join(outputDir, "index.mdx"), mdx);
|
|
38
|
-
}
|
|
39
|
-
function writeUnlistedSubPage(outputPath, title, body, renderString = (value) => `"${escapeTitle(value)}"`) {
|
|
40
|
-
fs.writeFileSync(
|
|
41
|
-
outputPath,
|
|
42
|
-
`---
|
|
43
|
-
title: ${renderString(title)}
|
|
44
|
-
unlisted: true
|
|
45
|
-
generated: true
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
${body}
|
|
49
|
-
`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
function assertNotIndexReserved(nameOrSlug, errorMessage) {
|
|
53
|
-
if (nameOrSlug === "index") {
|
|
54
|
-
throw new Error(errorMessage);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export {
|
|
58
|
-
assertNotIndexReserved,
|
|
59
|
-
escapeTitle,
|
|
60
|
-
formatFrontmatterString,
|
|
61
|
-
parseFrontmatter,
|
|
62
|
-
writeCategoryIndex,
|
|
63
|
-
writeUnlistedSubPage
|
|
64
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type FrontmatterStringRenderer } from "./mdx.js";
|
|
2
|
-
export interface SkillReference {
|
|
3
|
-
name: string;
|
|
4
|
-
title: string;
|
|
5
|
-
content: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SkillItem {
|
|
8
|
-
name: string;
|
|
9
|
-
dir: string;
|
|
10
|
-
description: string;
|
|
11
|
-
references: SkillReference[];
|
|
12
|
-
}
|
|
13
|
-
export type RenderExtraHeader = (skillAbsDir: string) => string;
|
|
14
|
-
export interface GenerateSkillsCategoryOptions {
|
|
15
|
-
skillsDirs: string[];
|
|
16
|
-
outputDir: string;
|
|
17
|
-
label: string;
|
|
18
|
-
position: number;
|
|
19
|
-
description: string;
|
|
20
|
-
sourceLabel: string;
|
|
21
|
-
renderExtraHeader?: RenderExtraHeader;
|
|
22
|
-
renderFrontmatterString?: FrontmatterStringRenderer;
|
|
23
|
-
}
|
|
24
|
-
export declare function getSkillFileTree(skillDir: string, subDirs: {
|
|
25
|
-
name: string;
|
|
26
|
-
files: string[];
|
|
27
|
-
}[]): string;
|
|
28
|
-
export declare function getScriptDescription(filePath: string): string;
|
|
29
|
-
export declare function getSkillReferences(skillsDir: string, skillDir: string): SkillReference[];
|
|
30
|
-
/**
|
|
31
|
-
* Generate a category containing Claude/Codex-shaped skill packages.
|
|
32
|
-
*
|
|
33
|
-
* Roots are considered in order. A root reached through more than one path is
|
|
34
|
-
* visited once; when distinct roots contain the same skill name, the first
|
|
35
|
-
* root wins and the later package is skipped.
|
|
36
|
-
*/
|
|
37
|
-
export declare function generateSkillsCategory({ skillsDirs, outputDir, label, position, description, sourceLabel, renderExtraHeader, renderFrontmatterString, }: GenerateSkillsCategoryOptions): SkillItem[];
|