Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
211 lines
5.8 KiB
JavaScript
211 lines
5.8 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Generates docs/docs_map.md from source docs headings for LLM navigation.
|
|
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
import { join, relative } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const ROOT = process.cwd();
|
|
const DOCS_DIR = join(ROOT, "docs");
|
|
const OUTPUT_PATH = join(DOCS_DIR, "docs_map.md");
|
|
const MARKDOWN_EXTENSIONS = /\.mdx?$/iu;
|
|
const EXCLUDED_DIRS = new Set([
|
|
".generated",
|
|
"archive",
|
|
"assets",
|
|
"images",
|
|
"internal",
|
|
"research",
|
|
"snippets",
|
|
]);
|
|
const EXCLUDED_FILES = new Set(["AGENTS.md", "CLAUDE.md", "docs_map.md"]);
|
|
|
|
if (!existsSync(DOCS_DIR)) {
|
|
console.error("docs:map: missing docs directory. Run from repo root.");
|
|
process.exit(1);
|
|
}
|
|
if (!statSync(DOCS_DIR).isDirectory()) {
|
|
console.error("docs:map: docs path is not a directory.");
|
|
process.exit(1);
|
|
}
|
|
|
|
function normalizeSlashes(value) {
|
|
return value.replace(/\\/gu, "/");
|
|
}
|
|
|
|
function isMarkdownFile(name) {
|
|
return MARKDOWN_EXTENSIONS.test(name);
|
|
}
|
|
|
|
function shouldSkipFile(relativePath) {
|
|
const parts = normalizeSlashes(relativePath).split("/");
|
|
if (parts.some((part) => part.startsWith("."))) {
|
|
return true;
|
|
}
|
|
if (parts.some((part) => EXCLUDED_DIRS.has(part))) {
|
|
return true;
|
|
}
|
|
return EXCLUDED_FILES.has(parts.at(-1));
|
|
}
|
|
|
|
function walkMarkdownFiles(dir, base = dir) {
|
|
const files = [];
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
if (entry.name.startsWith(".")) {
|
|
continue;
|
|
}
|
|
const fullPath = join(dir, entry.name);
|
|
const relativePath = relative(base, fullPath);
|
|
if (entry.isDirectory()) {
|
|
if (EXCLUDED_DIRS.has(entry.name)) {
|
|
continue;
|
|
}
|
|
files.push(...walkMarkdownFiles(fullPath, base));
|
|
continue;
|
|
}
|
|
if (!entry.isFile() || !isMarkdownFile(entry.name) || shouldSkipFile(relativePath)) {
|
|
continue;
|
|
}
|
|
files.push(normalizeSlashes(relativePath));
|
|
}
|
|
return files.toSorted((left, right) => (left < right ? -1 : left > right ? 1 : 0));
|
|
}
|
|
|
|
function stripFrontmatter(raw) {
|
|
if (!raw.startsWith("---\n") && !raw.startsWith("---\r\n")) {
|
|
return raw;
|
|
}
|
|
const lines = raw.split(/\r?\n/u);
|
|
for (let index = 1; index < lines.length; index += 1) {
|
|
if (lines[index] === "---" || lines[index] === "...") {
|
|
return lines.slice(index + 1).join("\n");
|
|
}
|
|
}
|
|
return raw;
|
|
}
|
|
|
|
function escapeMarkdownHtmlText(value) {
|
|
return value.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">");
|
|
}
|
|
|
|
function cleanHeadingText(value) {
|
|
const normalized = value
|
|
.replace(/\s+#+\s*$/u, "")
|
|
.replace(/\[([^\]]+)\]\([^)]*\)/gu, "$1")
|
|
.replace(/[*_~`]/gu, "")
|
|
.replace(/\s+/gu, " ")
|
|
.trim();
|
|
// Docs map is Markdown consumed by humans and agents. Escape HTML instead of
|
|
// trying to strip tags so malformed source headings cannot reintroduce markup.
|
|
return escapeMarkdownHtmlText(normalized);
|
|
}
|
|
|
|
function extractHeadings(raw) {
|
|
const headings = [];
|
|
const lines = stripFrontmatter(raw).split(/\r?\n/u);
|
|
let fenceMarker = null;
|
|
|
|
for (const rawLine of lines) {
|
|
const trimmed = rawLine.trim();
|
|
const fenceMatch = /^(?<marker>`{3,}|~{3,})/u.exec(trimmed);
|
|
if (fenceMatch) {
|
|
const marker = fenceMatch.groups.marker[0];
|
|
fenceMarker = fenceMarker === marker ? null : (fenceMarker ?? marker);
|
|
continue;
|
|
}
|
|
if (fenceMarker) {
|
|
continue;
|
|
}
|
|
|
|
const match = /^(#{1,4})\s+(.+)$/u.exec(rawLine);
|
|
if (!match) {
|
|
continue;
|
|
}
|
|
const text = cleanHeadingText(match[2]);
|
|
if (text) {
|
|
headings.push({ depth: match[1].length, text });
|
|
}
|
|
}
|
|
|
|
return headings;
|
|
}
|
|
|
|
function routeForFile(relativePath) {
|
|
const withoutExtension = relativePath.replace(/\.mdx?$/iu, "");
|
|
if (withoutExtension === "index") {
|
|
return "/";
|
|
}
|
|
if (withoutExtension.endsWith("/index")) {
|
|
return `/${withoutExtension.slice(0, -"/index".length)}`;
|
|
}
|
|
return `/${withoutExtension}`;
|
|
}
|
|
|
|
function renderDocsMap() {
|
|
const files = walkMarkdownFiles(DOCS_DIR);
|
|
const lines = [
|
|
"---",
|
|
'summary: "Generated heading map for OpenClaw docs pages"',
|
|
'read_when: "Finding which docs page covers a topic before reading the page"',
|
|
'title: "Docs map"',
|
|
"---",
|
|
"",
|
|
"# OpenClaw docs map",
|
|
"",
|
|
"This file is generated from `docs/**/*.md` and `docs/**/*.mdx` headings to help agents navigate the documentation tree.",
|
|
"Do not edit it by hand; run `pnpm docs:map:gen`.",
|
|
"",
|
|
];
|
|
|
|
for (const relativePath of files) {
|
|
const fullPath = join(DOCS_DIR, relativePath);
|
|
const headings = extractHeadings(readFileSync(fullPath, "utf8"));
|
|
lines.push(`## ${relativePath}`);
|
|
lines.push("");
|
|
lines.push(`- Route: ${routeForFile(relativePath)}`);
|
|
if (headings.length === 0) {
|
|
lines.push("- Headings: none");
|
|
} else {
|
|
lines.push("- Headings:");
|
|
for (const heading of headings) {
|
|
lines.push(` - H${heading.depth}: ${heading.text}`);
|
|
}
|
|
}
|
|
lines.push("");
|
|
}
|
|
|
|
return `${lines.join("\n").trimEnd()}\n`;
|
|
}
|
|
|
|
function main() {
|
|
const check = process.argv.includes("--check");
|
|
const content = renderDocsMap();
|
|
|
|
if (check) {
|
|
if (!existsSync(OUTPUT_PATH)) {
|
|
console.error("docs:map: docs/docs_map.md is missing. Run `pnpm docs:map:gen`.");
|
|
process.exit(1);
|
|
}
|
|
const current = readFileSync(OUTPUT_PATH, "utf8");
|
|
if (current !== content) {
|
|
console.error("docs:map: docs/docs_map.md is out of date. Run `pnpm docs:map:gen`.");
|
|
process.exit(1);
|
|
}
|
|
console.log("docs:map: docs/docs_map.md is up to date.");
|
|
return;
|
|
}
|
|
|
|
writeFileSync(OUTPUT_PATH, content, "utf8");
|
|
console.log(`docs:map: wrote ${normalizeSlashes(relative(ROOT, OUTPUT_PATH))}.`);
|
|
}
|
|
|
|
const isMain = process.argv[1] ? fileURLToPath(import.meta.url) === process.argv[1] : false;
|
|
|
|
if (isMain) {
|
|
main();
|
|
}
|
|
|
|
export const testing = {
|
|
cleanHeadingText,
|
|
};
|