@takazudo/zudo-doc 5.8.0 → 5.10.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 (104) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +1 -1
  3. package/dist/chrome/derive.d.ts +1 -1
  4. package/dist/chrome/derive.js +24 -2
  5. package/dist/config-assertions/index.d.ts +30 -0
  6. package/dist/config-assertions/index.js +41 -1
  7. package/dist/config.d.ts +18 -0
  8. package/dist/config.js +1 -0
  9. package/dist/doc-content-header/index.js +6 -0
  10. package/dist/doc-metainfo-area/index.js +1 -14
  11. package/dist/doc-page-renderer/index.d.ts +3 -3
  12. package/dist/doc-page-renderer/index.js +1 -1
  13. package/dist/doc-page-shell/index.d.ts +6 -0
  14. package/dist/doc-pager/index.d.ts +6 -0
  15. package/dist/doc-pager/index.js +5 -2
  16. package/dist/docs-schema/index.d.ts +11 -0
  17. package/dist/docs-schema/index.js +8 -1
  18. package/dist/format-date/index.d.ts +12 -0
  19. package/dist/format-date/index.js +64 -0
  20. package/dist/frontmatter-preview-defaults/index.js +6 -1
  21. package/dist/header/header.js +9 -1
  22. package/dist/home-page/index.js +3 -1
  23. package/dist/html-preview-wrapper/highlight-runtime.d.ts +7 -7
  24. package/dist/html-preview-wrapper/highlight-runtime.js +1 -1
  25. package/dist/i18n-defaults/index.js +3 -0
  26. package/dist/integrations/changelog/emit.js +19 -2
  27. package/dist/mdx-components/index.d.ts +4 -1
  28. package/dist/mdx-components/index.js +3 -1
  29. package/dist/nav-indexing/index.d.ts +2 -0
  30. package/dist/nav-indexing/index.js +2 -0
  31. package/dist/nav-indexing/note-tray-index.d.ts +29 -0
  32. package/dist/nav-indexing/note-tray-index.js +120 -0
  33. package/dist/note-tray-index/index.d.ts +45 -0
  34. package/dist/note-tray-index/index.js +52 -0
  35. package/dist/note-tray-model/index.d.ts +31 -0
  36. package/dist/note-tray-model/index.js +74 -0
  37. package/dist/plugins/codex-resources.d.ts +4 -0
  38. package/dist/plugins/codex-resources.js +31 -0
  39. package/dist/plugins/internal/claude-resources/generate.js +20 -291
  40. package/dist/plugins/internal/codex-resources/agents-md.d.ts +6 -0
  41. package/dist/plugins/internal/codex-resources/agents-md.js +70 -0
  42. package/dist/plugins/internal/codex-resources/agents.d.ts +7 -0
  43. package/dist/plugins/internal/codex-resources/agents.js +104 -0
  44. package/dist/plugins/internal/codex-resources/config.d.ts +6 -0
  45. package/dist/plugins/internal/codex-resources/config.js +111 -0
  46. package/dist/plugins/internal/codex-resources/generate.d.ts +20 -0
  47. package/dist/plugins/internal/codex-resources/generate.js +34 -0
  48. package/dist/plugins/internal/codex-resources/hooks.d.ts +6 -0
  49. package/dist/plugins/internal/codex-resources/hooks.js +174 -0
  50. package/dist/plugins/internal/codex-resources/index.d.ts +24 -0
  51. package/dist/plugins/internal/codex-resources/index.js +21 -0
  52. package/dist/plugins/internal/codex-resources/overview.d.ts +10 -0
  53. package/dist/plugins/internal/codex-resources/overview.js +33 -0
  54. package/dist/plugins/internal/codex-resources/rules.d.ts +6 -0
  55. package/dist/plugins/internal/codex-resources/rules.js +255 -0
  56. package/dist/plugins/internal/codex-resources/skills.d.ts +2 -0
  57. package/dist/plugins/internal/codex-resources/skills.js +84 -0
  58. package/dist/plugins/internal/codex-resources/utils.d.ts +14 -0
  59. package/dist/plugins/internal/codex-resources/utils.js +80 -0
  60. package/dist/plugins/internal/resource-docs-shared/fs.d.ts +3 -0
  61. package/dist/plugins/internal/resource-docs-shared/fs.js +19 -0
  62. package/dist/plugins/internal/resource-docs-shared/index.d.ts +7 -0
  63. package/dist/plugins/internal/resource-docs-shared/index.js +44 -0
  64. package/dist/plugins/internal/resource-docs-shared/links.d.ts +22 -0
  65. package/dist/plugins/internal/resource-docs-shared/links.js +44 -0
  66. package/dist/plugins/internal/resource-docs-shared/markdown-structure.d.ts +9 -0
  67. package/dist/plugins/internal/resource-docs-shared/markdown-structure.js +22 -0
  68. package/dist/plugins/internal/resource-docs-shared/mdx.d.ts +23 -0
  69. package/dist/plugins/internal/resource-docs-shared/mdx.js +63 -0
  70. package/dist/plugins/internal/resource-docs-shared/skills.d.ts +37 -0
  71. package/dist/plugins/internal/resource-docs-shared/skills.js +318 -0
  72. package/dist/plugins/internal/resource-docs-shared/walk.d.ts +20 -0
  73. package/dist/plugins/internal/resource-docs-shared/walk.js +41 -0
  74. package/dist/preset.d.ts +19 -0
  75. package/dist/preset.js +16 -1
  76. package/dist/safelist.css +1 -1
  77. package/dist/settings.d.ts +5 -0
  78. package/dist/sidebar/types.d.ts +6 -0
  79. package/dist/sidebar-tree/build-tree.js +8 -0
  80. package/dist/sidebar-tree/types.d.ts +12 -0
  81. package/dist/sidebar-tree-island/index.js +175 -1
  82. package/dist/sidebar-utils/index.d.ts +6 -0
  83. package/dist/site-schema/doc-route-entries.js +2 -0
  84. package/dist/site-schema/index.d.ts +1 -0
  85. package/dist/site-schema/index.js +3 -1
  86. package/dist/site-schema/nav-tree.js +17 -2
  87. package/dist/site-schema/note-tray-validate.d.ts +7 -0
  88. package/dist/site-schema/note-tray-validate.js +94 -0
  89. package/dist/site-schema/types.d.ts +11 -0
  90. package/dist/site-tree-nav-island/index.d.ts +5 -1
  91. package/dist/site-tree-nav-island/index.js +119 -12
  92. package/dist/theme-packs/drift/pack.css +6 -1
  93. package/dist/theme-packs/hearth/pack.css +5 -0
  94. package/dist/theme-packs/sakura/pack.css +6 -0
  95. package/dist/theme-packs/scandi/pack.css +7 -7
  96. package/dist/theme-packs/timberline/pack.css +5 -0
  97. package/eject/doc-pager/index.tsx +9 -0
  98. package/eject/header/header.tsx +26 -1
  99. package/eject/sidebar/types.ts +6 -0
  100. package/eject/sidebar-tree-island/index.tsx +238 -6
  101. package/eject/site-tree-nav-island/index.tsx +166 -16
  102. package/package.json +25 -8
  103. /package/dist/plugins/internal/{claude-resources → resource-docs-shared}/escape-for-mdx.d.ts +0 -0
  104. /package/dist/plugins/internal/{claude-resources → resource-docs-shared}/escape-for-mdx.js +0 -0
@@ -0,0 +1,80 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ export declare function ensureDir(dir: string): void;
2
+ export declare function cleanDir(dir: string): void;
3
+ export declare function listFiles(dir: string): string[];
@@ -0,0 +1,19 @@
1
+ import fs from "node:fs";
2
+ function ensureDir(dir) {
3
+ if (!fs.existsSync(dir)) {
4
+ fs.mkdirSync(dir, { recursive: true });
5
+ }
6
+ }
7
+ function cleanDir(dir) {
8
+ if (!fs.existsSync(dir)) return;
9
+ fs.rmSync(dir, { recursive: true, force: true });
10
+ }
11
+ function listFiles(dir) {
12
+ if (!fs.existsSync(dir)) return [];
13
+ return fs.readdirSync(dir, { withFileTypes: true }).filter((d) => d.isFile()).map((d) => d.name).sort();
14
+ }
15
+ export {
16
+ cleanDir,
17
+ ensureDir,
18
+ listFiles
19
+ };
@@ -0,0 +1,7 @@
1
+ export { escapeForMdx } from "./escape-for-mdx.js";
2
+ export { cleanDir, ensureDir, listFiles } from "./fs.js";
3
+ export { assertNotIndexReserved, escapeTitle, formatFrontmatterString, parseFrontmatter, type FrontmatterStringRenderer, writeCategoryIndex, writeUnlistedSubPage, } from "./mdx.js";
4
+ export { isRepoRelativeLink, downgradeRepoRelativeLinks } from "./links.js";
5
+ export { escapeMarkdownTableCell, renderCodeFence, } from "./markdown-structure.js";
6
+ export { EXCLUDED_DIR_NAMES, findNamedFiles } from "./walk.js";
7
+ export { generateSkillsCategory, getScriptDescription, getSkillFileTree, getSkillReferences, type GenerateSkillsCategoryOptions, type RenderExtraHeader, type SkillItem, type SkillReference, } from "./skills.js";
@@ -0,0 +1,44 @@
1
+ import { escapeForMdx } from "./escape-for-mdx.js";
2
+ import { cleanDir, ensureDir, listFiles } from "./fs.js";
3
+ import {
4
+ assertNotIndexReserved,
5
+ escapeTitle,
6
+ formatFrontmatterString,
7
+ parseFrontmatter,
8
+ writeCategoryIndex,
9
+ writeUnlistedSubPage
10
+ } from "./mdx.js";
11
+ import { isRepoRelativeLink, downgradeRepoRelativeLinks } from "./links.js";
12
+ import {
13
+ escapeMarkdownTableCell,
14
+ renderCodeFence
15
+ } from "./markdown-structure.js";
16
+ import { EXCLUDED_DIR_NAMES, findNamedFiles } from "./walk.js";
17
+ import {
18
+ generateSkillsCategory,
19
+ getScriptDescription,
20
+ getSkillFileTree,
21
+ getSkillReferences
22
+ } from "./skills.js";
23
+ export {
24
+ EXCLUDED_DIR_NAMES,
25
+ assertNotIndexReserved,
26
+ cleanDir,
27
+ downgradeRepoRelativeLinks,
28
+ ensureDir,
29
+ escapeForMdx,
30
+ escapeMarkdownTableCell,
31
+ escapeTitle,
32
+ findNamedFiles,
33
+ formatFrontmatterString,
34
+ generateSkillsCategory,
35
+ getScriptDescription,
36
+ getSkillFileTree,
37
+ getSkillReferences,
38
+ isRepoRelativeLink,
39
+ listFiles,
40
+ parseFrontmatter,
41
+ renderCodeFence,
42
+ writeCategoryIndex,
43
+ writeUnlistedSubPage
44
+ };
@@ -0,0 +1,22 @@
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
+ * Downgrade repo-relative markdown links in a mirrored `CLAUDE.md` body to
11
+ * inline code so they don't dangle in the flattened mirror tree (#2411).
12
+ *
13
+ * A `CLAUDE.md`'s relative links point at real repo files (correct for an
14
+ * in-repo reader), but the mirror flattens each file into a single
15
+ * `claude-md/<name>.mdx` page with no counterpart for those targets — left as
16
+ * links they surface as `broken link:` warnings on every affected page. Inline
17
+ * code keeps the reference legible (`` `wrangler.toml` ``) without a href.
18
+ *
19
+ * Code spans are preserved verbatim: a `[x](./y)` inside a fenced block or an
20
+ * inline-code span is literal text, not a link, and must not be rewritten.
21
+ */
22
+ export declare function downgradeRepoRelativeLinks(content: string): string;
@@ -0,0 +1,44 @@
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 downgradeRepoRelativeLinks(content) {
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) => isRepoRelativeLink(url) ? `\`${text}\`` : match
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
+ export {
42
+ downgradeRepoRelativeLinks,
43
+ isRepoRelativeLink
44
+ };
@@ -0,0 +1,9 @@
1
+ /** Render source inside a Markdown fence that cannot be closed by the source. */
2
+ export declare function renderCodeFence(source: string, language?: string): string;
3
+ /**
4
+ * Render an arbitrary value as a structurally safe Markdown table cell.
5
+ *
6
+ * Code-span delimiters are chosen from the value itself. Pipes are escaped
7
+ * for the surrounding table and physical newlines are collapsed to spaces.
8
+ */
9
+ export declare function escapeMarkdownTableCell(value: unknown): string;
@@ -0,0 +1,22 @@
1
+ function renderCodeFence(source, language = "") {
2
+ const runs = source.match(/`+/g) ?? [];
3
+ const longestRun = runs.reduce((max, run) => Math.max(max, run.length), 0);
4
+ const fence = "`".repeat(Math.max(3, longestRun + 1));
5
+ const trailingNewline = source.endsWith("\n") ? "" : "\n";
6
+ return `${fence}${language}
7
+ ${source}${trailingNewline}${fence}`;
8
+ }
9
+ function escapeMarkdownTableCell(value) {
10
+ if (value === void 0 || value === null || value === "") return "\u2014";
11
+ const content = String(value).replace(/\r\n?|\n/g, " ").replace(/\|/g, "\\|");
12
+ if (content === "") return "\u2014";
13
+ const runs = content.match(/`+/g) ?? [];
14
+ const longestRun = runs.reduce((max, run) => Math.max(max, run.length), 0);
15
+ const delimiter = "`".repeat(Math.max(1, longestRun + 1));
16
+ const needsPadding = /^[` ]|[` ]$/.test(content);
17
+ return needsPadding ? `${delimiter} ${content} ${delimiter}` : `${delimiter}${content}${delimiter}`;
18
+ }
19
+ export {
20
+ escapeMarkdownTableCell,
21
+ renderCodeFence
22
+ };
@@ -0,0 +1,23 @@
1
+ import matter from "gray-matter";
2
+ export declare function parseFrontmatter(content: string): matter.GrayMatterFile<string> | null;
3
+ export declare function escapeTitle(s: string): string;
4
+ export type FrontmatterStringRenderer = (value: string) => string;
5
+ export declare function formatFrontmatterString(value: string): string;
6
+ export declare function writeCategoryIndex(outputDir: string, label: string, position: number, description: string, renderString?: FrontmatterStringRenderer): void;
7
+ /**
8
+ * Writes an unlisted sub-page MDX file. Used for skill references, scripts,
9
+ * and assets.
10
+ *
11
+ * The route is derived from the file's path within the content collection —
12
+ * deliberately NOT from an explicit `slug:`. zfb's `resolveMarkdownLinks`
13
+ * resolves relative links against the source file path, so the on-disk
14
+ * location of these pages must match the URL the skill page links to. Writing
15
+ * them at `<dir>/ref-<name>.mdx` (siblings of the skill's `index.mdx`) is what
16
+ * makes the `./ref-<name>` links resolve (#2411).
17
+ */
18
+ export declare function writeUnlistedSubPage(outputPath: string, title: string, body: string, renderString?: FrontmatterStringRenderer): void;
19
+ /**
20
+ * Guards that the given name/slug is not the reserved "index" value.
21
+ * Throws with a contextual message if it is.
22
+ */
23
+ export declare function assertNotIndexReserved(nameOrSlug: string, errorMessage: string): void;
@@ -0,0 +1,63 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import matter from "gray-matter";
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
+ if (!/[\r\n]/.test(value)) {
16
+ try {
17
+ const parsed = matter(`---
18
+ value: ${value}
19
+ ---
20
+ `).data.value;
21
+ if (parsed === value) return value;
22
+ } catch {
23
+ }
24
+ }
25
+ return JSON.stringify(value);
26
+ }
27
+ function writeCategoryIndex(outputDir, label, position, description, renderString = (value) => `"${escapeTitle(value)}"`) {
28
+ const mdx = `---
29
+ title: ${renderString(label)}
30
+ description: ${renderString(description)}
31
+ sidebar_position: ${position}
32
+ category_no_page: true
33
+ generated: true
34
+ ---
35
+ `;
36
+ fs.writeFileSync(path.join(outputDir, "index.mdx"), mdx);
37
+ }
38
+ function writeUnlistedSubPage(outputPath, title, body, renderString = (value) => `"${escapeTitle(value)}"`) {
39
+ fs.writeFileSync(
40
+ outputPath,
41
+ `---
42
+ title: ${renderString(title)}
43
+ unlisted: true
44
+ generated: true
45
+ ---
46
+
47
+ ${body}
48
+ `
49
+ );
50
+ }
51
+ function assertNotIndexReserved(nameOrSlug, errorMessage) {
52
+ if (nameOrSlug === "index") {
53
+ throw new Error(errorMessage);
54
+ }
55
+ }
56
+ export {
57
+ assertNotIndexReserved,
58
+ escapeTitle,
59
+ formatFrontmatterString,
60
+ parseFrontmatter,
61
+ writeCategoryIndex,
62
+ writeUnlistedSubPage
63
+ };
@@ -0,0 +1,37 @@
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[];