diff --git a/.ua/index.json b/.ua/index.json index dd1adc4..db6b629 100644 --- a/.ua/index.json +++ b/.ua/index.json @@ -1,6 +1,6 @@ { "$schema": "ui-arch-registry-index/0.1", - "generatedAt": "2026-10-26T08:26:18.408Z", + "generatedAt": "2026-10-26T08:29:05.311Z", "repoRoot": ".", "packages": [ { @@ -3681,6 +3681,7 @@ "steps": [ "装好依赖后先跑 npm run check 确认基线全绿(build → demo → style → typecheck → smoke → index → verify)", "查组件:ua list 看全量,ua search <关键词> 按 id/标题/参数名/参数说明/步骤模糊找(「处理中」这类说明里的词也能搜到,命中非 id 标题时会标出命中字段;拼错会回相近 id),ua info <组件id> 看 props/步骤/示例(ua info <包名> 看单包 api 与约定,加 --json 出原始清单)", + "查配方:ua recipes 列全量(编号 / 标题 / 用到的组件),ua recipes <编号> 看骨架代码与要点(--json 给脚本用;MCP 里对应 list_recipes / get_recipe)", "查令牌:ua tokens 打印全部 --ua-* 变量(颜色带暗色值),--json 输出结构化数组;写样式前先查,禁止硬编码", "改完清单跑 npm run docs:同时刷新人类文档站与 llms-full.txt(Agent 首选喂料)", "在 ~/.workbuddy/mcp.json 注册 ua mcp 后,Agent 可直接调 list_components / get_component / search_components / get_tokens / list_recipes / get_recipe" diff --git a/AGENTS.md b/AGENTS.md index 20a742c..9c4c757 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -50,7 +50,7 @@ 可用工具:`list_components` / `get_component` / `search_components` / `get_tokens`(返回 --ua-* 令牌清单,避免硬编码颜色间距)/ `list_recipes` / `get_recipe`(取跨组件组合配方:骨架代码 + 要点 + 用到的组件 id,配好再逐个 `get_component` 查参数)。 -2. **CLI**:`node packages/tools/cli/bin/ua.js list [--json|--components] | search <关键词> | info [--json] | index | docs | style | verify | changelog`(`--json` 给脚本与 Agent 用,不必解析文本);`search` 覆盖 id / 标题 / 参数名 / 参数说明 / 步骤五层,命中非 id 标题时会标出命中字段(如「← 参数说明含『处理中』」),`--json` 附带 `matched` 字段 +2. **CLI**:`node packages/tools/cli/bin/ua.js list [--json|--components] | search <关键词> | info [--json] | recipes [编号] [--json] | index | docs | style | verify | changelog`(`--json` 给脚本与 Agent 用,不必解析文本);`search` 覆盖 id / 标题 / 参数名 / 参数说明 / 步骤五层,命中非 id 标题时会标出命中字段(如「← 参数说明含『处理中』」),`--json` 附带 `matched` 字段 3. **静态索引**:`.ua/index.json`(机器可读索引)、`llms.txt`(速览)或 **`llms-full.txt`(全量 Agent 文档:逐组件参数 / 回调 / 手把手步骤 / 令牌 / 组合配方,无图形纯文本,喂给 Agent 首选)**。 diff --git a/llms-full.txt b/llms-full.txt index 03d1d6c..033331e 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -1,6 +1,6 @@ # @ui-arch 组件库 Agent 文档(无图形版) -> 自动生成于 2026-10-26T08:26:18.408Z,数据源:各包 ua.manifest.json,勿手改。人类版文档站:apps/docs/index.html。 +> 自动生成于 2026-10-26T08:29:05.311Z,数据源:各包 ua.manifest.json,勿手改。人类版文档站:apps/docs/index.html。 > 组件 = 普通函数,传 props 返回 DOM;状态用 signal 双向绑定:读 signal() 写 signal(v)。 ## 快速上手 @@ -42,9 +42,10 @@ 1. 装好依赖后先跑 npm run check 确认基线全绿(build → demo → style → typecheck → smoke → index → verify) 2. 查组件:ua list 看全量,ua search <关键词> 按 id/标题/参数名/参数说明/步骤模糊找(「处理中」这类说明里的词也能搜到,命中非 id 标题时会标出命中字段;拼错会回相近 id),ua info <组件id> 看 props/步骤/示例(ua info <包名> 看单包 api 与约定,加 --json 出原始清单) -3. 查令牌:ua tokens 打印全部 --ua-* 变量(颜色带暗色值),--json 输出结构化数组;写样式前先查,禁止硬编码 -4. 改完清单跑 npm run docs:同时刷新人类文档站与 llms-full.txt(Agent 首选喂料) -5. 在 ~/.workbuddy/mcp.json 注册 ua mcp 后,Agent 可直接调 list_components / get_component / search_components / get_tokens / list_recipes / get_recipe +3. 查配方:ua recipes 列全量(编号 / 标题 / 用到的组件),ua recipes <编号> 看骨架代码与要点(--json 给脚本用;MCP 里对应 list_recipes / get_recipe) +4. 查令牌:ua tokens 打印全部 --ua-* 变量(颜色带暗色值),--json 输出结构化数组;写样式前先查,禁止硬编码 +5. 改完清单跑 npm run docs:同时刷新人类文档站与 llms-full.txt(Agent 首选喂料) +6. 在 ~/.workbuddy/mcp.json 注册 ua mcp 后,Agent 可直接调 list_components / get_component / search_components / get_tokens / list_recipes / get_recipe ## @ui-arch/ui(skin-dom)v0.1.0 diff --git a/packages/tools/cli/bin/ua.js b/packages/tools/cli/bin/ua.js index 52825d0..7ed6a83 100644 --- a/packages/tools/cli/bin/ua.js +++ b/packages/tools/cli/bin/ua.js @@ -452,6 +452,37 @@ function parseRecipes() { return out; } +/*** 从配方正文里认出用到的组件 id(词边界匹配,避免 toast 命中 toastError),CLI 与 MCP 共用一份 ***/ +function recipeComps(r) { + const ids = collectComponents().map((x) => x.comp.id); + const body = `${r.code}\n${r.text}`; // 代码块 + 正文一起扫:要点里也会点名组件 + return ids.filter((id) => new RegExp('\\b' + id + '\\b').test(body)).sort(); +} + +/*** 列出组合配方(编号 / 标题 / 用到的组件),或按编号打印单条配方全文;MCP 没注册时也能查配方 ***/ +function cmdRecipes(args = []) { + const id = args.find((a) => !a.startsWith('--')); + const list = parseRecipes(); + if (!list.length) return console.error('recipes.md 里没有配方'); + const asJson = args.includes('--json'); + if (id) { + const hit = list.find((r) => r.id === id); + if (!hit) { + console.error(`recipe not found: ${id}(可用 ${list.map((r) => r.id).join(' / ')})`); + return process.exit(1); + } + if (asJson) return console.log(JSON.stringify({ id: hit.id, title: hit.title, components: recipeComps(hit), code: hit.code, notes: hit.notes }, null, 2)); + return console.log(`# 配方 ${hit.id}:${hit.title} +用到的组件:${recipeComps(hit).join(' / ')} + +${hit.text}`); + } + if (asJson) return console.log(JSON.stringify(list.map((r) => ({ id: r.id, title: r.title, components: recipeComps(r) })), null, 2)); + for (const r of list) console.log(`${String(r.id).padEnd(4)} ${r.title} [${recipeComps(r).join(' / ')}]`); + console.log(` +共 ${list.length} 条配方;看骨架与要点:ua recipes <编号>(MCP 里对应 get_recipe)`); +} + /*** 渲染 Agent 文档(llms-full.txt):无图形纯文本,逐组件参数 / 回调 / 步骤 / 约定全量收录 ***/ function renderAgentDocs(index, tokens) { const lines = [ @@ -636,9 +667,7 @@ function cmdMcp() { throw new Error(`MCP 工具注册表与 MCP_TOOL_NAMES 不一致:${tools.map((t) => t.name).join(',')}`); // 常量是文档校验的基准,先自证 } - /*** 从配方正文里认出用到的组件 id(按词边界匹配,避免 toast 命中 toastError) ***/ - const recipeComponents = (r) => - compIds.filter((id) => new RegExp(`\\b${id}\\b`).test(`${r.code}\n${r.text}`)).sort(); + const recipeComponents = (r) => recipeComps(r).filter((id) => compIds.includes(id)); // 与 CLI recipes 共用同一抽取逻辑 const send = (obj) => process.stdout.write(JSON.stringify(obj) + '\n'); @@ -1378,6 +1407,9 @@ switch (cmd) { } cmdInfo(args[0], args.slice(1)); break; + case 'recipes': + cmdRecipes(args); + break; case 'docs': cmdDocs(); break; diff --git a/packages/tools/cli/ua.manifest.json b/packages/tools/cli/ua.manifest.json index 8ea0c87..3323a26 100644 --- a/packages/tools/cli/ua.manifest.json +++ b/packages/tools/cli/ua.manifest.json @@ -37,6 +37,7 @@ "steps": [ "装好依赖后先跑 npm run check 确认基线全绿(build → demo → style → typecheck → smoke → index → verify)", "查组件:ua list 看全量,ua search <关键词> 按 id/标题/参数名/参数说明/步骤模糊找(「处理中」这类说明里的词也能搜到,命中非 id 标题时会标出命中字段;拼错会回相近 id),ua info <组件id> 看 props/步骤/示例(ua info <包名> 看单包 api 与约定,加 --json 出原始清单)", + "查配方:ua recipes 列全量(编号 / 标题 / 用到的组件),ua recipes <编号> 看骨架代码与要点(--json 给脚本用;MCP 里对应 list_recipes / get_recipe)", "查令牌:ua tokens 打印全部 --ua-* 变量(颜色带暗色值),--json 输出结构化数组;写样式前先查,禁止硬编码", "改完清单跑 npm run docs:同时刷新人类文档站与 llms-full.txt(Agent 首选喂料)", "在 ~/.workbuddy/mcp.json 注册 ua mcp 后,Agent 可直接调 list_components / get_component / search_components / get_tokens / list_recipes / get_recipe"