mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-09-14 20:16:53 +08:00
f1b521dffa
* docs: rebuild docs site from docs-lab
Replace the docs site's source tree with docs-lab, a page-by-page rebuild
of the OpenSpec docs (40 pages: Start / Guides / Customize / Multi-repo /
Reference / Help).
- Point website/docs.sync.config.mjs at ../docs-lab and restructure the
sidebar into nested groups; sync script gains nested meta.json emission,
leading-quote descriptions, idempotent writes, and diagram asset copying
- Remove the marketing landing page; / now redirects to /docs
(meta-refresh page + Cloudflare _redirects)
- Add remark plugins (faq, file-steps, gfm-alert) and the FileSteps
component backing the new page formats
- Add install.md at the repo root, curled by docs-lab/start/installation.md
as an agent-executable install prompt
- Add the docs authoring skills (.agents/skills/{write,draft,verify}-
openspec-docs); docs-lab/README.md links into write-openspec-docs
The old docs/ tree is now unused by the site and left for a follow-up.
Claude-Session: https://claude.ai/code/session_01BMMLYNJQPKXx1QHpnDn4ho
* docs: hold back unwritten pages, add worksets, drop diagram drafts
- website: comment out Overview, Guides, Architecture, Help, Legacy in
docs.sync.config.mjs until those pages are written; temporary
/docs -> /docs/installation redirect (Cloudflare _redirects + static
export meta-refresh fallback in page.tsx)
- docs-lab: new multi-repo/worksets.md page, published under Multi-repo
- docs-lab: content revisions across start/, customize/, reference/,
help/, multi-repo/; add review notes (Notes.md)
- remove docs-lab/diagrams option-* drafts and their website copies
- write-openspec-docs skill: add spoken-flow sentence rule
* docs: address review on PR #1649
- sync-docs: read the existing output directly instead of exists-then-read
(CodeQL TOCTOU alert)
- hold back the headings-only Environment variables and Stores reference
pages until written; links to them fall back to their GitHub source
- sources.md: cutover keeps docs/ in place and points at public/_redirects
- setup.md: label the workflow tree as the default set plus two optional ones
* docs: two review nits (spoken-flow rule, XDG_DATA_HOME note)
75 lines
2.3 KiB
TypeScript
75 lines
2.3 KiB
TypeScript
// Turns the FAQ page's `##` question sections into Fumadocs Accordion
|
|
// elements, the same mdxJsxFlowElement injection remarkGfmAlert and
|
|
// remarkFileSteps use, so the doc stays plain headings on GitHub while the
|
|
// site renders a collapsible FAQ.
|
|
//
|
|
// Applies only to files named `faq` (the synced content/docs/faq.md); every
|
|
// other page keeps its headings. Each accordion gets a GitHub-style slug id so
|
|
// existing `#heading-anchor` deep links still open the right question.
|
|
// getLLMText (lib/source.ts) round-trips the accordions back to `##` headings.
|
|
|
|
interface Node {
|
|
type: string;
|
|
depth?: number;
|
|
value?: string;
|
|
children?: Node[];
|
|
[key: string]: unknown;
|
|
}
|
|
|
|
function toText(node: Node): string {
|
|
if (node.type === 'text' || node.type === 'inlineCode') return node.value ?? '';
|
|
return (node.children ?? []).map(toText).join('');
|
|
}
|
|
|
|
// Matches github-slugger for plain-text titles, which is what the sync'd
|
|
// heading anchors used.
|
|
function slugify(title: string): string {
|
|
return title
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9 -]/g, '')
|
|
.trim()
|
|
.replace(/\s+/g, '-');
|
|
}
|
|
|
|
function accordion(title: string, children: Node[]): Node {
|
|
return {
|
|
type: 'mdxJsxFlowElement',
|
|
name: 'Accordion',
|
|
attributes: [
|
|
{ type: 'mdxJsxAttribute', name: 'title', value: title },
|
|
{ type: 'mdxJsxAttribute', name: 'id', value: slugify(title) },
|
|
],
|
|
children,
|
|
};
|
|
}
|
|
|
|
export function remarkFaq() {
|
|
return (tree: Node, file: { stem?: string | null }) => {
|
|
if (file.stem !== 'faq' || !tree.children) return;
|
|
|
|
const first = tree.children.findIndex(
|
|
(child) => child.type === 'heading' && child.depth === 2,
|
|
);
|
|
if (first === -1) return;
|
|
|
|
const accordions: Node[] = [];
|
|
let title: string | undefined;
|
|
let body: Node[] = [];
|
|
for (const child of tree.children.slice(first)) {
|
|
if (child.type === 'heading' && child.depth === 2) {
|
|
if (title !== undefined) accordions.push(accordion(title, body));
|
|
title = toText(child);
|
|
body = [];
|
|
} else {
|
|
body.push(child);
|
|
}
|
|
}
|
|
if (title !== undefined) accordions.push(accordion(title, body));
|
|
|
|
tree.children = [
|
|
...tree.children.slice(0, first),
|
|
{ type: 'mdxJsxFlowElement', name: 'Accordions', attributes: [], children: accordions },
|
|
];
|
|
};
|
|
}
|