From 301e65d7d254940f2532c0cdba6d7b429b707ac8 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Tue, 17 Nov 2026 19:55:24 +0800 Subject: [PATCH 1/2] feat(website): redesign Playbook with directory groups and editorial layout --- website/README.md | 33 +- website/scripts/build.mjs | 21 +- website/scripts/site-ui.test.mjs | 202 ++- website/src/app.js | 1113 +++++++++++---- website/src/index.html | 5 +- website/src/playbook-data.js | 742 ++++++++++ website/src/search.js | 43 +- website/src/styles.css | 2163 ++++++++++++++++++++++++++---- 8 files changed, 3813 insertions(+), 509 deletions(-) create mode 100644 website/src/playbook-data.js diff --git a/website/README.md b/website/README.md index 5f79174093..45cc923ad7 100644 --- a/website/README.md +++ b/website/README.md @@ -1,33 +1,26 @@ # OpenBitFun Playbook -OpenBitFun Playbook is the public, bilingual manual for OpenBitFun's user-facing -features and settings. It does not maintain its own list. The build consumes -`../docs/interactive-capabilities/capabilities.json`, generated from the single -semantic source at `../src/shared/interactive-capabilities/catalog.json`. +OpenBitFun Playbook () is the bilingual (`zh-CN` / `en-US`) user handbook for OpenBitFun's features and settings. -Desktop Tauri commands are audited separately as implementation coverage. They -never become website pages or user-visible search entries. +It consumes `../docs/interactive-capabilities/capabilities.json`, generated from `../src/shared/interactive-capabilities/catalog.json` via `pnpm run capabilities:generate` — sharing the same semantic source of truth as in-app Global Search (`⌘K`) and the `OpenBitFunControl` agent tool while presenting warm, task-oriented guidance for human readers. -The same generated runtime projection powers OpenBitFun search and the -`OpenBitFunControl` agent tool. Search results carry a documented item ID when a -query matches a settings subview, so entries such as Shortcuts, Editor, and -Hooks open the exact view instead of only the parent settings page. Complex or -unsafe workflows remain UI-guided; the agent surface exposes only typed, -reviewed operations and options rather than raw Tauri commands. +## Architecture & UX Highlights + +- **Task-Oriented Functional Directory**: Organizes features and settings into practical workflow groups in pedagogical order, paired with a 4-step Quick Start path and real-world scenario guides on the home page. +- **Additive Playbook Schema Support**: Consumes optional `catalog.playbook` (`hero`, `gettingStarted`, `scenarios`, `directoryGroups`), per-capability guide metadata (`directoryGroupId`, `order`, `entryPathZh/En`, `shortcut`, `highlightsZh/En`, `scenariosZh/En`, `tipsZh/En`, `relatedIds`), and per-item `descriptionZh/En`, with built-in fallbacks when fields are omitted. +- **In-Page Quick Jump (`⌘K` / `Ctrl+K`)**: Opens an instant bilingual search modal from any page without losing reading context, and deep-links matched sub-capabilities (`?focus=#item-`). +- **Canonical Theme Governance**: Consumes `@openbitfun/design-tokens` and `@openbitfun/theme-openbitfun` (`System`, `Light`, `Dark`) with zero raw color literals or token fallbacks. + +## Commands ```bash pnpm run capabilities:generate pnpm run website:dev pnpm run website:test pnpm run website:build +pnpm run theme:color-audit:website ``` -The color theme defaults to the operating-system preference. The header control -lets readers explicitly choose System, Light, or Dark; an explicit choice is -stored only in that browser. - -Every build writes `dist/release.json`. Deploy using its `releaseId`, which -changes for either catalog or website-source changes, so a presentation-only -update never mutates an older release directory. +## Immutable Release Deployment -The production origin is . +Every build emits `dist/release.json` containing an immutable `releaseId` hashed from the catalog digest, website sources, design tokens, theme CSS, and brand assets. Deploy each `dist/` output into an immutable `releases//` directory and atomically repoint the `current` symlink. diff --git a/website/scripts/build.mjs b/website/scripts/build.mjs index 57c0c15736..326566e916 100644 --- a/website/scripts/build.mjs +++ b/website/scripts/build.mjs @@ -39,9 +39,10 @@ function embeddedJson(value) { return JSON.stringify(value).replaceAll('<', '\\u003c'); } -function renderPage(template, { title, description, url, pageData, assetVersion }) { +function renderPage(template, { title, heading, description, url, pageData, assetVersion }) { return template .replaceAll('__PAGE_TITLE__', escapeHtml(title)) + .replaceAll('__PAGE_HEADING__', escapeHtml(heading ?? title)) .replaceAll('__PAGE_DESCRIPTION__', escapeHtml(description)) .replaceAll('__PAGE_URL__', escapeHtml(url)) .replaceAll('__ASSET_VERSION__', escapeHtml(assetVersion)) @@ -55,6 +56,7 @@ async function main() { const catalog = JSON.parse(await readFile(catalogPath, 'utf8')); const template = await readFile(path.join(sourceRoot, 'index.html'), 'utf8'); const appSource = await readFile(path.join(sourceRoot, 'app.js'), 'utf8'); + const playbookDataSource = await readFile(path.join(sourceRoot, 'playbook-data.js'), 'utf8'); const searchSource = await readFile(path.join(sourceRoot, 'search.js'), 'utf8'); const stylesSource = await readFile(path.join(sourceRoot, 'styles.css'), 'utf8'); const designTokensSource = await readFile(designTokensCssPath, 'utf8'); @@ -73,6 +75,7 @@ async function main() { .update(catalog.digest) .update(template) .update(appSource) + .update(playbookDataSource) .update(searchSource) .update(stylesSource) .update(designTokensSource) @@ -87,8 +90,11 @@ async function main() { await mkdir(path.join(outputRoot, 'assets'), { recursive: true }); await writeFile( path.join(outputRoot, 'assets/app.js'), - appSource.replace("'./search.js'", `'./search.js?v=${assetVersion}'`), + appSource + .replace("'./search.js'", `'./search.js?v=${assetVersion}'`) + .replace("'./playbook-data.js'", `'./playbook-data.js?v=${assetVersion}'`), ); + await writeFile(path.join(outputRoot, 'assets/playbook-data.js'), playbookDataSource); await writeFile(path.join(outputRoot, 'assets/search.js'), searchSource); await writeFile(path.join(outputRoot, 'assets/design-tokens.css'), designTokensSource); await writeFile(path.join(outputRoot, 'assets/theme.css'), themeSource); @@ -115,9 +121,11 @@ async function main() { }, null, 2)}\n`, ); - const homeDescription = `Learn ${catalog.counts.features} OpenBitFun features and ${catalog.counts.settings} settings pages in Chinese or English.`; + const homeDescription = catalog.playbook?.hero?.subtitleZh + || `OpenBitFun 实用使用指南:涵盖 ${catalog.counts.features} 项核心功能与 ${catalog.counts.settings} 个设置页面的上手步骤、常见场景与智能体协作指令。`; await writeFile(path.join(outputRoot, 'index.html'), renderPage(template, { - title: 'OpenBitFun Playbook — Features, settings, and practical guides', + title: 'OpenBitFun 使用指南 · Playbook — 功能目录、上手步骤与设置参考', + heading: 'OpenBitFun Playbook', description: homeDescription, url: `${catalog.origin}/`, assetVersion, @@ -128,8 +136,9 @@ async function main() { const directory = path.join(outputRoot, 'capabilities', capability.id); await mkdir(directory, { recursive: true }); await writeFile(path.join(directory, 'index.html'), renderPage(template, { - title: `${capability.titleEn} / ${capability.titleZh} — OpenBitFun Playbook`, - description: capability.summaryEn, + title: `${capability.titleZh} / ${capability.titleEn} — OpenBitFun Playbook`, + heading: `${capability.titleZh} · ${capability.titleEn}`, + description: `${capability.summaryZh} ${capability.summaryEn}`, url: capability.docsUrl, assetVersion, pageData: { kind: 'capability', capabilityId: capability.id, digest: catalog.digest }, diff --git a/website/scripts/site-ui.test.mjs b/website/scripts/site-ui.test.mjs index 552e32d85d..4148321b66 100644 --- a/website/scripts/site-ui.test.mjs +++ b/website/scripts/site-ui.test.mjs @@ -8,7 +8,12 @@ import { promisify } from 'node:util'; import { fileURLToPath } from 'node:url'; import test from 'node:test'; -import { matchingItems, scoreTextMatch, searchCapabilities } from '../src/search.js'; +import { + normalizePlaybookCatalog, + resolveAdjacentCapabilities, + resolveRelatedCapabilities, +} from '../src/playbook-data.js'; +import { matchingItems, scoreCapability, scoreTextMatch, searchCapabilities } from '../src/search.js'; const execFileAsync = promisify(execFile); const websiteRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); @@ -19,8 +24,19 @@ await execFileAsync(process.execPath, [path.join(websiteRoot, 'scripts/build.mjs cwd: repositoryRoot, }); -const [appSource, searchSource, stylesSource, templateSource, builtIndex, builtApp, releaseSource, catalogSource] = await Promise.all([ +const [ + appSource, + playbookDataSource, + searchSource, + stylesSource, + templateSource, + builtIndex, + builtApp, + releaseSource, + catalogSource, +] = await Promise.all([ readFile(path.join(sourceRoot, 'app.js'), 'utf8'), + readFile(path.join(sourceRoot, 'playbook-data.js'), 'utf8'), readFile(path.join(sourceRoot, 'search.js'), 'utf8'), readFile(path.join(sourceRoot, 'styles.css'), 'utf8'), readFile(path.join(sourceRoot, 'index.html'), 'utf8'), @@ -53,8 +69,8 @@ test('theme contract defaults to system and exposes all three choices', () => { assert.match(appSource, /documentElement\.dataset\.colorScheme = resolvedTheme\(\)/u); }); -test('hero title, search, and statistics remain in layout flow', () => { - assert.match(appSource, /

\$\{text\([\s\S]*?[\s\S]*?/u); +test('hero title, search, and statistics remain in layout flow without CAD grid or tilts', () => { + assert.match(appSource, /

\$\{escapeHtml\(localized\(hero, 'title'\)\)\}<\/span>/u); assert.match(appSource, /
[\s\S]*?