@yottameta/yotta-skills 0.3.0 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # 更新日志
2
2
 
3
+ ## v0.5.0 (2026-08-31)
4
+
5
+ 方案 A(其他已装技能候选编排):路由输出从「只编排元阁组合」扩展为「组合 + 并列候选提示」。
6
+
7
+ - 新增 `--route` / `route_request` 输出「其他已装技能候选」:注册表中非元阁家族的已装技能,按 frontmatter `description` 与需求文本做本地机械匹配(英文词项 + 中文二字组交集),Top N(默认 3)并列展示,标注来源、得分、命中词项与扫描状态。
8
+ - 安全边界:只读 frontmatter `description` 做机械匹配,不读取全文指令、不做语义推理、不自动调用;候选默认标注「未扫描」,使用/安装前需先做装前安全扫描;数据不出本机。
9
+ - 确定性:同输入同输出,无状态、无个人数据;候选不参与组合融合排序,7 个静态组合输出保持不变。
10
+ - CLI 文本输出追加「其他已装技能候选」段;`--json` 追加 `other_skill_candidates` / `other_skills_note` 字段;MCP `route_request` 同步。
11
+ - 测试:路由核心新增候选匹配 / 元技能排除 / Top N 与排序 / 确定性 / 空结果;CLI JSON 与文本输出用例。
12
+ - 版本升至 0.5.0。
13
+
14
+ ## v0.4.0 (2026-08-31)
15
+
16
+ 阶段 C(O1 静态编排 playbook + 路由指引):从「知道装了什么」升级为「给出该用哪几个、什么顺序」。
17
+
18
+ - 新增静态编排 playbook(7 个场景组合):输出呈现、长生命周期、交付质量门、装前安全门、造技能发版、安全事件响应、入口安装。
19
+ - 新增 CLI `--route "<需求摘要>"`:先更新本地注册表,再输出候选组合、调用顺序、技能角色、置信度、命中依据、已装/缺失状态、安装命令与应用模式提醒;支持 `--json`。
20
+ - 新增 MCP `route_request` 工具,与 CLI 复用同一套路由核心;MCP 工具扩展为四个。
21
+ - 缺失技能只建议安装,不自动安装;安装命令需用户确认并先执行装前安全扫描。应用模式默认显式调用,切换为按场景自动调用需用户确认。
22
+ - 文档:SKILL.md / README 中英 / orchestration.md / tutorial.md 同步「编排路由」层与边界;banner 同步升级为编排层定位。
23
+ - 测试:新增路由核心(playbook 完整性 / 命中顺序 / 缺失建议 / 无匹配兜底 / 应用模式)、CLI JSON 与文本输出、MCP e2e 用例。
24
+ - 版本升至 0.4.0。
25
+
3
26
  ## v0.3.0 (2026-08-31)
4
27
 
5
28
  阶段 B(D2 re-index 自动钩子):新装技能自动被发现。
package/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  <h1 align="center">yotta-skills · 元阁 (YuanGe)</h1>
8
8
 
9
- <p align="center">YottaMeta's skill-family <b>orchestration planner + one-command installer</b>: plan which skills to combine for a task, then one <code>npx</code> line installs the published <code>yotta-*</code> skills (currently <b>22</b>) into any agent or directory.</p>
10
- <p align="center">List the family, install everything, incrementally update, preview with <code>--dry-run</code>, pin exact versions — idempotent and zero-dependency (Node.js 18+), pure npm ecosystem.</p>
9
+ <p align="center">YottaMeta's skill-family <b>orchestration router, inventory, and one-command installer</b>: route which skills to combine for a task, then one <code>npx</code> line installs the published <code>yotta-*</code> skills (currently <b>22</b>) into any agent or directory.</p>
10
+ <p align="center">List the family, route a task, install everything, incrementally update, preview with <code>--dry-run</code>, pin exact versions - idempotent and zero-dependency (Node.js 18+), pure npm ecosystem.</p>
11
11
  <p align="center">This package contains <b>no skill bodies</b> — only a manifest, a downloader, a placer and a summary. Each skill still comes from its own npm package.</p>
12
12
 
13
13
  <p align="center">
@@ -25,12 +25,13 @@ Installing the whole YottaMeta family used to mean running <code>npx</code> for
25
25
 
26
26
  元阁 is also the **family orchestration planner**: given a task, check the orchestration table first — which skills to combine, in what order, and why — then install exactly those. The decision table ships in the package as <code>references/orchestration.md</code> and is summarized in <code>SKILL.md</code>.
27
27
 
28
- - **List** — see the whole family: slug, Chinese name, package, version and a one-line description.
28
+ - **List** - see the whole family: slug, Chinese name, package, version and a one-line description.
29
+ - **Orchestration routing** - <code>--route</code> turns a task summary into a candidate combination, call order, per-skill roles, confidence, evidence, installed/missing status, and an install command; it only suggests installation and never installs automatically.
29
30
  - **Install** — install everything (or a subset) into an agent's default user-level directory or any directory.
30
31
  - **Update** — incremental update: add missing skills, upgrade version-skewed ones.
31
32
  - **Idempotent** — a skill already at the manifest version is skipped; re-running is safe.
32
33
  - **Pre-install summary** — if yotta-verify (元信) is available, each skill is scanned first; the verdict is informational only.
33
- - **Inventory / re-index** — scan the skill directories on this machine and keep a local registry (<code>~/.yottaskills/registry.json</code>); self-contained, no other skills required. Newly installed skills are discovered automatically: <code>install</code> / <code>update</code> re-index the registry afterwards, and <code>--reindex</code> re-scans on demand (e.g. at session start). An optional <code>yotta-skills</code> MCP (on-demand, not resident) exposes <code>list_installed_skills</code> / <code>describe_skill</code> / <code>reindex</code>; see <code>SKILL.md</code> for the config.
34
+ - **Inventory / re-index** - scan the skill directories on this machine and keep a local registry (<code>~/.yottaskills/registry.json</code>); self-contained, no other skills required. Newly installed skills are discovered automatically: <code>install</code> / <code>update</code> re-index the registry afterwards, and <code>--reindex</code> re-scans on demand (e.g. at session start). An optional <code>yotta-skills</code> MCP (on-demand, not resident) exposes <code>list_installed_skills</code> / <code>describe_skill</code> / <code>reindex</code> / <code>route_request</code>; see <code>SKILL.md</code> for the config.
34
35
 
35
36
  Boundaries: it only downloads, places and summarizes — it does **not** develop skill content, does **not** bundle any skill body, and does **not** use <code>-g</code> global installs. It never writes outside the target you specify.
36
37
 
@@ -55,6 +56,9 @@ npx -y @yottameta/yotta-skills update --agent codex
55
56
  # Preview what would be installed (no network, no changes)
56
57
  npx -y @yottameta/yotta-skills --dry-run
57
58
 
59
+ # Route a task to a combination, call order, and missing-skill install suggestion
60
+ npx -y @yottameta/yotta-skills --route "Review this code carefully before release"
61
+
58
62
  # Inventory installed skills on this machine (self-contained scan, no other skills needed)
59
63
  npx -y @yottameta/yotta-skills --inventory
60
64
 
@@ -75,6 +79,7 @@ Requirements: Node.js 18+, npm, and system <code>tar</code> (built into Windows
75
79
  | `update [--agent <name> \| --dir <path>]` | Incremental update: add missing, upgrade version-skewed |
76
80
  | `--inventory` | Inventory installed skills: scan skill directories and update the local registry (self-contained); `--json` for JSON, `--project` adds project-level dirs |
77
81
  | `--reindex` | Re-index the registry: re-scan skill directories and merge changes incrementally (session start / after installing skills; `--rescan` is a synonym); `--json` for JSON |
82
+ | `--route <task-summary>` | Static orchestration routing: return a combination, call order, per-skill roles, confidence, evidence, installed/missing status, and an install suggestion; also lists other installed (non-YottaMeta) skills as candidates matched mechanically against their frontmatter description, tagged "not scanned", read-only and never auto-invoked; `--json` for JSON, `--project` adds project-level dirs |
78
83
  | `--no-reindex` | Do not re-index the registry automatically after `install` / `update` |
79
84
  | `--dry-run` | Preview the install / update list; no network, no changes |
80
85
  | `--pin` | Lock the exact manifest versions (default: range, latest patch of the same major) |
package/README.zh-CN.md CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  <h1 align="center">yotta-skills · 元阁 (YuanGe)</h1>
8
8
 
9
- <p align="center">YottaMeta 的<b>技能生态编排策划 + 全家一键安装器</b>:先按场景规划该组合哪几个技能,再一条 <code>npx</code> 命令把已发布的全部
9
+ <p align="center">YottaMeta 的<b>技能生态编排路由 + 全家一键安装器 + 技能盘点</b>:先按需求路由该组合哪几个技能,再一条 <code>npx</code> 命令把已发布的全部
10
10
  <code>yotta-*</code> 技能(当前 <b>22</b> 个)装进指定智能体或目录。</p>
11
- <p align="center">看清单、装全家、增量更新、<code>--dry-run</code> 预览、<code>--pin</code> 锁版本——
11
+ <p align="center">看清单、路由组合、装全家、增量更新、<code>--dry-run</code> 预览、<code>--pin</code> 锁版本--
12
12
  幂等、零依赖(Node.js 18+)、纯 npm 生态。</p>
13
13
  <p align="center">本包<b>不含任何技能本体</b>——只做「清单 + 下载 + 落位 + 汇总」;每个技能仍走各自 npm 包。</p>
14
14
 
@@ -28,12 +28,13 @@
28
28
 
29
29
  元阁也是全家的**编排策划层**:接到需求先查「编排策划」组合表——该组合哪几个技能、按什么顺序、各自强在哪——再按需安装恰好那几个。决策表随包提供(<code>references/orchestration.md</code>),<code>SKILL.md</code> 中有摘要。
30
30
 
31
- - **看清单**——全家技能一览:slug / 中文名 / 包名 / 版本 / 一句话说明。
31
+ - **看清单**--全家技能一览:slug / 中文名 / 包名 / 版本 / 一句话说明。
32
+ - **编排路由**--`--route` 按需求摘要输出候选组合、调用顺序、技能角色、置信度、依据、已装/缺失状态与安装命令;非元阁家族已装技能按 frontmatter description 机械匹配作并列候选(标注来源与未扫描状态,只读不自动调用);只建议安装,不自动安装。
32
33
  - **安装**——装全家(或指定技能)到智能体默认用户级目录或任意目录。
33
34
  - **更新**——增量更新:补齐缺失技能、升级版本不一致的技能。
34
35
  - **幂等**——已在清单版本的技能跳过;重复运行安全。
35
36
  - **装前摘要**——若装了元信(yotta-verify),先对每个待装技能做一次装前扫描;verdict 仅提示、不拦截。
36
- - **盘点 / re-index**——扫描本机各智能体技能目录,维护本地注册表(<code>~/.yottaskills/registry.json</code>);自包含,不需要任何其他技能。新装技能自动被发现:<code>install</code> / <code>update</code> 完成后自动重扫注册表,<code>--reindex</code> 可随时手动重扫(如会话开工)。可选 <code>yotta-skills</code> MCP(按需加载、不常驻)提供 <code>list_installed_skills</code> / <code>describe_skill</code> / <code>reindex</code> 三工具,配置见 <code>SKILL.md</code>。
37
+ - **盘点 / re-index**--扫描本机各智能体技能目录,维护本地注册表(<code>~/.yottaskills/registry.json</code>);自包含,不需要任何其他技能。新装技能自动被发现:<code>install</code> / <code>update</code> 完成后自动重扫注册表,<code>--reindex</code> 可随时手动重扫(如会话开工)。可选 <code>yotta-skills</code> MCP(按需加载、不常驻)提供 <code>list_installed_skills</code> / <code>describe_skill</code> / <code>reindex</code> / <code>route_request</code> 四工具,配置见 <code>SKILL.md</code>。
37
38
 
38
39
  边界:只做「下载 + 落位 + 汇总」——**不**开发技能内容、**不**内置任何技能本体、**不**用 <code>-g</code>
39
40
  全局安装;只在你指定的目标内写文件。
@@ -59,6 +60,9 @@ npx -y @yottameta/yotta-skills update --agent codex
59
60
  # 预览将安装清单(不联网、不改动)
60
61
  npx -y @yottameta/yotta-skills --dry-run
61
62
 
63
+ # 按需求摘要给出组合、顺序与缺失技能安装建议
64
+ npx -y @yottameta/yotta-skills --route "检查代码质量,别糊弄"
65
+
62
66
  # 盘点本机已装技能(自包含扫描,不依赖任何元技能)
63
67
  npx -y @yottameta/yotta-skills --inventory
64
68
 
@@ -79,6 +83,7 @@ npx -y @yottameta/yotta-skills --reindex
79
83
  | `update [--agent <name> \| --dir <path>]` | 增量更新:补齐缺失、升级版本不一致的技能 |
80
84
  | `--inventory` | 盘点已装技能:扫描技能目录并更新本地注册表(自包含);`--json` 输出 JSON、`--project` 附扫项目级目录 |
81
85
  | `--reindex` | 重扫注册表:扫描技能目录并增量合并变化(会话开工 / 装技能后自动调用;`--rescan` 同义);`--json` 输出 JSON |
86
+ | `--route <需求摘要>` | 静态编排路由:输出组合、调用顺序、技能角色、置信度、依据、已装/缺失状态与安装建议;`--json` 输出 JSON、`--project` 附扫项目级目录 |
82
87
  | `--no-reindex` | 安装 / 更新后不自动重扫注册表 |
83
88
  | `--dry-run` | 预览将执行的安装 / 更新清单;不联网、不改动 |
84
89
  | `--pin` | 锁死清单精确版本(默认 range:跟随同 major 最新 patch) |
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: yotta-skills
3
- version: 0.3.0
4
- description: 元阁 —— 元阁全家技能的总编排策划 + 一键安装器 + 技能盘点。策划层:按场景给出「该组合哪几个元技能、组合强在哪、怎么自动装+自动用」;安装层:一条命令把 YottaMeta 已发布的全部 yotta-* 技能装进指定智能体或目录;盘点层:--inventory / --reindex 扫描本机已装技能生成/更新注册表,新装技能自动被发现(install/update 后自动 re-index,会话开工可先跑 --reindex;自包含零依赖,不依赖任何元技能);MCP 按需加载(可选:list_installed_skills/describe_skill/reindex,不常驻,未加载降级 CLI)。支持 --list 清单 / install / update / --inventory / --reindex / --dry-run 预览 / --pin 锁版本。触发:需要批量安装或更新元阁全家技能、按场景组合多个元技能、盘点或查看本机已装技能、重扫技能注册表、给某个智能体或目录一次性铺齐 yotta-* 技能、预览安装清单、锁版本安装、或用户说 元阁/装全家/一次装齐/yotta-skills/install-all/更新全家/盘点技能/查看已装技能 等。边界(Do NOT trigger):只做「组合策划 + 清单 + 下载 + 落位 + 汇总 + 盘点 + re-index」,不含技能本体、不做技能内容开发、不 -g 污染全局;装前摘要仅供参考,安装决策由用户确认。
3
+ version: 0.5.0
4
+ description: 元阁 -- 元阁全家技能的总编排策划 + 编排路由 + 一键安装器 + 技能盘点。路由层:--route / route_request 按需求摘要给出候选组合、调用顺序、角色、置信度、依据、已装/缺失状态与安装命令,只建议不自动安装;非元阁家族已装技能按 frontmatter description 机械匹配作并列候选(标注来源与未扫描状态,只读不自动调用);策划层:按场景给出「该组合哪几个元技能、组合强在哪、怎么自动装+自动用」;安装层:一条命令把 YottaMeta 已发布的全部 yotta-* 技能装进指定智能体或目录;盘点层:--inventory / --reindex 扫描本机已装技能生成/更新注册表,新装技能自动被发现(install/update 后自动 re-index,会话开工可先跑 --reindex;自包含零依赖,不依赖任何元技能);MCP 按需加载(可选:list_installed_skills/describe_skill/reindex/route_request,不常驻,未加载降级 CLI)。支持 --list 清单 / --route 路由 / install / update / --inventory / --reindex / --dry-run 预览 / --pin 锁版本。触发:需要批量安装或更新元阁全家技能、按场景组合多个元技能、路由或判断该用哪些技能、盘点或查看本机已装技能、重扫技能注册表、给某个智能体或目录一次性铺齐 yotta-* 技能、预览安装清单、锁版本安装、或用户说 元阁/装全家/一次装齐/yotta-skills/install-all/更新全家/该用哪个技能/路由技能/盘点技能/查看已装技能 等。边界(Do NOT trigger):只做「组合策划 + 静态路由建议 + 清单 + 下载 + 落位 + 汇总 + 盘点 + re-index」,不含技能本体、不做技能内容开发、不 -g 污染全局、不自动安装缺失技能;装前摘要仅供参考,安装决策由用户确认。
5
5
  license: MIT
6
6
  metadata:
7
7
  zh_name: 元阁
@@ -27,8 +27,9 @@ metadata:
27
27
 
28
28
  # 元阁(yotta-skills)
29
29
 
30
- **元阁全家的总编排策划 + 一键安装 + 技能盘点**,一句话三层:
30
+ **元阁全家的总编排策划 + 编排路由 + 一键安装 + 技能盘点**,一句话四层:
31
31
 
32
+ - **路由层(该用哪几个)**:`--route "<需求摘要>"` / MCP `route_request` 查本地注册表与静态编排 playbook,输出候选组合、调用顺序、每个技能角色、置信度、依据、已装/缺失状态与安装命令;非元阁家族已装技能按 frontmatter description 机械匹配作并列候选(标注来源与未扫描状态,只读不自动调用);只建议安装,不自动安装。
32
33
  - **策划层(怎么用)**:接到需求,先按「编排策划」定位命中哪个组合——哪些元技能搭配起来最强、适合什么场景、AI 该怎么自动装并自动用起来。
33
34
  - **安装层(怎么装)**:一条 `npx -y @yottameta/yotta-skills` 把组合/全家装进指定智能体或目录——`--list` 看清单、`install` 装、`update` 增量更新、`--dry-run` 预览、`--pin` 锁版本。
34
35
  - **盘点层(已装了什么)**:`--inventory` / `--reindex` 扫描本机各智能体技能目录,生成/更新本地注册表;装技能后自动 re-index,新装技能自动被发现——自包含扫描,不依赖任何元技能。
@@ -117,6 +118,7 @@ npx -y @yottameta/yotta-skills --reindex
117
118
  | `update [--agent <name> \| --dir <path>]` | 增量更新:补齐缺失技能、升级版本不一致的技能 |
118
119
  | `--inventory` | 盘点本机已装技能:扫描技能目录生成/更新注册表(自包含,不依赖元技能);`--json` 输出 JSON、`--project` 附扫项目级目录 |
119
120
  | `--reindex` | 重扫注册表:扫描技能目录并增量合并变化(会话开工 / 装技能后自动调用);`--json` 输出 JSON、`--project` 附扫项目级目录;`--rescan` 同义 |
121
+ | `--route <需求摘要>` | 静态编排路由:输出组合、调用顺序、技能角色、置信度、依据、已装/缺失状态与安装建议;`--json` 输出 JSON、`--project` 附扫项目级目录 |
120
122
  | `--no-reindex` | 安装 / 更新后不自动重扫注册表 |
121
123
  | `--dry-run` | 预览将执行的安装 / 更新清单;不联网、不改动 |
122
124
  | `--pin` | 锁死清单精确版本(默认 range:跟随同 major 最新 patch) |
@@ -156,10 +158,28 @@ npx -y @yottameta/yotta-skills --inventory --dir ~/my-skills --project
156
158
  让新装 / 更新的技能自动进入注册表。
157
159
  - **手动**:`yotta-skills --reindex`(`--rescan` 同义);`--json` 机器可读、`--project` 附扫项目级目录。
158
160
 
161
+ ## 编排路由(--route)
162
+
163
+ 把需求摘要交给静态编排 playbook 和本地注册表,得到一组可执行建议:
164
+
165
+ ```bash
166
+ # 文本输出:组合、调用顺序、角色、置信度、依据、缺失技能安装命令
167
+ npx -y @yottameta/yotta-skills --route "帮我润色输出,要规范可复制,别有 AI 味"
168
+
169
+ # 机器可读(JSON)
170
+ npx -y @yottameta/yotta-skills --route "检查代码质量,别糊弄" --json
171
+ ```
172
+
173
+ - **输出**:候选组合、调用顺序、每个技能的角色、置信度、命中依据、已装/缺失状态、安装命令与应用模式提醒。
174
+ - **缺失技能**:只给安装命令,不自动安装;安装前应先做装前安全扫描,决定权在用户。
175
+ - **应用模式**:默认用户显式调用;切换为「按场景自动调用」需要用户确认。
176
+ - **无明确匹配**:低置信度回退到「入口 + 安装」组合,先澄清需求再继续。
177
+ - **边界**:路由是建议,不保证完全正确;关键动作由用户确认,数据不出本机。
178
+
159
179
  ### MCP:按需加载(可选)
160
180
 
161
181
  本技能自带一个 MCP server:`yotta-skills`(`scripts/yotta-skills-mcp.py`,零依赖、数据不出本机),
162
- 提供 `list_installed_skills`(盘点)/ `describe_skill`(单技能详情)/ `reindex`(强制重扫)三个工具。
182
+ 提供 `list_installed_skills`(盘点)/ `describe_skill`(单技能详情)/ `reindex`(强制重扫)/ `route_request`(静态编排路由)四个工具。
163
183
 
164
184
  **按需加载,不走常驻**:本技能与 MCP 均为按需触发。默认以 CLI 为主
165
185
  (`npx -y @yottameta/yotta-skills --inventory`);需要让 AI 通过工具直接调用时,再按下面配置启用:
@@ -178,9 +198,9 @@ npx -y @yottameta/yotta-skills --inventory --dir ~/my-skills --project
178
198
  ```
179
199
  > `<技能目录>` = 本技能实际安装目录,**不要写死盘符路径**;Windows 用 `python`,Linux/macOS 用 `python3`。
180
200
  3. **提醒用户**:改 `mcpServers` 后多数客户端需**重启 / 重载一次** MCP server 才生效;加载后应看到
181
- `list_installed_skills` / `describe_skill` / `reindex` 三个工具。
201
+ `list_installed_skills` / `describe_skill` / `reindex` / `route_request` 四个工具。
182
202
  4. **降级兜底(重要)**:若客户端未暴露 MCP 工具 / 无法改配置 / server 未加载,**自动降级 CLI**
183
- (同一套扫描核心、结果一致):`npx -y @yottameta/yotta-skills --inventory / --reindex ...`。
203
+ (同一套扫描与路由核心、结果一致):`npx -y @yottameta/yotta-skills --inventory / --reindex / --route ...`。
184
204
 
185
205
  ## 版本策略
186
206
 
package/assets/banner.png CHANGED
Binary file
@@ -131,7 +131,7 @@ function parseArgs(argv) {
131
131
  list: false, dryRun: false, pin: false, skipScan: false, force: false,
132
132
  help: false, version: false, agent: null, dir: null, npm: null,
133
133
  python: null, verify: null, command: null, skill: null, rest: [],
134
- inventory: false, reindex: false, noReindex: false, json: false, project: false,
134
+ inventory: false, reindex: false, noReindex: false, json: false, project: false, route: null,
135
135
  };
136
136
  const positionals = [];
137
137
  for (let i = 0; i < argv.length; i++) {
@@ -145,6 +145,12 @@ function parseArgs(argv) {
145
145
  else if (a === '--help' || a === '-h') opts.help = true;
146
146
  else if (a === '--version' || a === '-v') opts.version = true;
147
147
  else if (a === '--inventory' || a === '--inv') opts.inventory = true;
148
+ else if (a === '--route') {
149
+ const value = argv[i + 1];
150
+ if (value === undefined || value.startsWith('--')) die('--route 缺少需求摘要');
151
+ opts.route = value;
152
+ i++;
153
+ }
148
154
  else if (a === '--reindex' || a === '--rescan') opts.reindex = true;
149
155
  else if (a === '--no-reindex') opts.noReindex = true;
150
156
  else if (a === '--json') opts.json = true;
@@ -439,6 +445,7 @@ function printHelp() {
439
445
  out(' yotta-skills --dry-run 预览将安装清单(不联网、不改动)');
440
446
  out(' yotta-skills --inventory 盘点本机已装技能(自研扫描,不依赖任何元技能)');
441
447
  out(' yotta-skills --reindex 重扫注册表(会话开工 / 装技能后自动调用;增量合并)');
448
+ out(' yotta-skills --route "<需求摘要>" 给出场景组合、调用顺序、缺失技能安装建议');
442
449
  out('');
443
450
  out('选项:');
444
451
  out(' --agent <name> 智能体键名(--list 可查看;未知智能体请用 --dir)');
@@ -449,7 +456,8 @@ function printHelp() {
449
456
  out(' --npm <path> 指定 npm 可执行文件(默认 npm / npm.cmd)');
450
457
  out(' --python <path> 指定 python 可执行文件(元信 scan 用)');
451
458
  out(' --verify <path> 指定 yotta_verify.py 路径(默认找目标目录已装的元信)');
452
- out(' --json inventory / reindex 时输出 JSON');
459
+ out(' --json inventory / reindex / route 时输出 JSON');
460
+ out(' --route <需求> 静态编排路由(输出组合 / 顺序 / 依据 / 缺失技能建议)');
453
461
  out(' --project inventory / reindex 时附加扫描当前项目 .agents/skills / .codex/skills');
454
462
  out(' --no-reindex 安装 / 更新后不自动重扫注册表');
455
463
  out(' -h, --help 帮助');
@@ -521,6 +529,45 @@ function runReindex(opts) {
521
529
  out('注册表: ' + scan.registryPath());
522
530
  }
523
531
 
532
+ /** --route:静态编排路由,输出组合、顺序、角色、缺失技能建议与其他已装技能候选。 */
533
+ function runRoute(opts) {
534
+ const { routeRequest, defaultYottaSlugs } = require('../lib/route');
535
+ const { registry } = reindexRegistry(opts);
536
+ const yottaSlugs = new Set([...defaultYottaSlugs(), ...MANIFEST.map((s) => s.slug)]);
537
+ const result = routeRequest(opts.route, { registry, yottaSlugs });
538
+ if (opts.json) {
539
+ out(JSON.stringify(result, null, 2));
540
+ return;
541
+ }
542
+ out('路由结果: ' + result.playbook.name + '(置信度: ' + result.confidence + ')');
543
+ out('适配意图: ' + result.playbook.intent);
544
+ out('依据: ' + (result.matched_keywords.length ? result.matched_keywords.join('、') : '无明确匹配,回退到入口澄清'));
545
+ out('');
546
+ out('调用顺序:');
547
+ for (const skill of result.skills) {
548
+ out(' ' + skill.order + '. ' + skill.slug + ' [' + (skill.installed ? '已装' : '缺失') + '] - ' + skill.role);
549
+ }
550
+ if (result.missing_skills.length) {
551
+ out('');
552
+ out('缺失技能: ' + result.missing_skills.map((skill) => skill.slug).join(', '));
553
+ out('安装命令: ' + result.install_command);
554
+ out('安全提示: 安装前请先执行装前安全扫描;本命令不会自动安装。');
555
+ }
556
+ if (result.other_skill_candidates.length) {
557
+ out('');
558
+ out('其他已装技能候选(非元阁家族,仅本地机械匹配 frontmatter description):');
559
+ for (const c of result.other_skill_candidates) {
560
+ out(' - ' + c.slug + ' v' + c.version + ' [' + (c.sources || []).join(',') + ']');
561
+ out(' 匹配: ' + c.matched_terms.join('、') + '(得分 ' + c.score + ')· 扫描状态: ' + (c.scan_status === 'not_scanned' ? '未扫描' : c.scan_status));
562
+ out(' ' + (c.description || ''));
563
+ }
564
+ out('安全提示: 其他已装技能只读 frontmatter description 做机械匹配,不读取全文指令、不自动调用;使用/安装前请先执行装前安全扫描,决定权在用户。');
565
+ }
566
+ out('');
567
+ out('应用模式: 显式调用(可经用户确认后切换为按场景自动调用)');
568
+ out('说明: ' + result.disclaimer);
569
+ }
570
+
524
571
  /** 装技能后自动 re-index(--no-reindex 关闭):把本次落位结果反映进注册表。best-effort:失败不阻断安装。 */
525
572
  function maybeAutoReindex(opts, dest) {
526
573
  if (opts.noReindex || opts.dryRun || !dest) return;
@@ -543,6 +590,7 @@ function main() {
543
590
  if (opts.list) { printList(opts); return; }
544
591
  if (opts.inventory && !opts.command) { runInventory(opts); return; }
545
592
  if (opts.reindex && !opts.command) { runReindex(opts); return; }
593
+ if (opts.route && !opts.command) { runRoute(opts); return; }
546
594
 
547
595
  const command = opts.command || 'install';
548
596
  let dest = resolveTargetDir(opts);
package/lib/route.js ADDED
@@ -0,0 +1,238 @@
1
+ 'use strict';
2
+
3
+ const PLAYBOOKS = [
4
+ {
5
+ id: 'output-standard',
6
+ name: '输出呈现标准',
7
+ intent: '让输出先判型渲染为可复制格式,再去除 AI 味。',
8
+ keywords: ['输出', '呈现', '渲染', '排版', '可复制', 'AI味', 'AI 味', '润色', '文档', '报告'],
9
+ skills: [
10
+ { slug: 'yotta-present', order: 1, role: '判断内容形态并渲染为可复制 Markdown / 纯文本。' },
11
+ { slug: 'yotta-humanize', order: 2, role: '检测中文 AI 腔,并按用户原意做确定性改写。' },
12
+ ],
13
+ },
14
+ {
15
+ id: 'long-lived-agent',
16
+ name: '长生命周期智能体',
17
+ intent: '让智能体跨会话恢复状态、记忆、经验与历史。',
18
+ keywords: ['长期', '跨会话', '忘了我', '别忘了我', '记忆', '上下文', '状态', '历史'],
19
+ skills: [
20
+ { slug: 'yotta-workflow', order: 1, role: '开工读取项目状态,会话结束更新状态并留下次接续记录。' },
21
+ { slug: 'yotta-memory', order: 2, role: '按权限边界保存与恢复跨会话记忆。' },
22
+ { slug: 'yotta-learn', order: 3, role: '沉淀错误、纠正与洞见,供后续会话复用。' },
23
+ { slug: 'yotta-logs', order: 4, role: '按需检索历史会话与日志记录。' },
24
+ ],
25
+ },
26
+ {
27
+ id: 'delivery-quality-gate',
28
+ name: '交付质量门',
29
+ intent: '交付前做防敷衍、代码质量与发布守门检查。',
30
+ keywords: ['检查', '代码', '质量', '别糊弄', '敷衍', '评审', '发布', '守门', '交付'],
31
+ skills: [
32
+ { slug: 'yotta-anti-shallow', order: 1, role: '强制先分析、再执行、后自检,防止表面化交付。' },
33
+ { slug: 'yotta-code-quality', order: 2, role: '按十二类腐化风险做结对式代码质量评审。' },
34
+ { slug: 'yotta-publish-guard', order: 3, role: '发布前校验版本、发布件与分发通道一致性。' },
35
+ ],
36
+ },
37
+ {
38
+ id: 'preinstall-security-gate',
39
+ name: '装前安全门',
40
+ intent: '安装其他来源技能、插件或 MCP 前做安全判定。',
41
+ keywords: ['安装', '装前', '其他来源', '技能', '插件', 'MCP', '安全扫描'],
42
+ skills: [
43
+ { slug: 'yotta-verify', order: 1, role: '执行确定性装前扫描并给出安全判定。' },
44
+ { slug: 'yotta-vetter', order: 2, role: '按四阶段协议审查来源、代码、权限与风险。' },
45
+ { slug: 'yotta-security-audit', order: 3, role: '做深度静态检测与安全基线兜底。' },
46
+ ],
47
+ },
48
+ {
49
+ id: 'skill-build-publish',
50
+ name: '造技能 / 发版',
51
+ intent: '创建合规技能包,并在发布前完成守门检查。',
52
+ keywords: ['造一个', '新 skill', '新技能', '脚手架', '发版', '发布技能', '技能包'],
53
+ skills: [
54
+ { slug: 'yotta-skill-creator', order: 1, role: '生成符合规范的技能目录与发布件结构。' },
55
+ { slug: 'yotta-publish-guard', order: 2, role: '校验版本四件、发布件与分发通道。' },
56
+ ],
57
+ },
58
+ {
59
+ id: 'security-incident-response',
60
+ name: '安全事件响应',
61
+ intent: '从日志、情报、样本、密钥、供应链与资产侦察看清事件链路。',
62
+ keywords: ['日志', '攻击', '安全事件', '入侵', 'IOC', '威胁情报', '样本', '密钥泄露', '供应链', '资产', '侦察'],
63
+ skills: [
64
+ { slug: 'yotta-logwatch', order: 1, role: '分析安全日志并识别攻击链与告警聚合。' },
65
+ { slug: 'yotta-intel', order: 2, role: '提取、去武器化并规范化威胁情报 IOC。' },
66
+ { slug: 'yotta-triage', order: 3, role: '对可疑样本做静态初筛。' },
67
+ { slug: 'yotta-secret', order: 4, role: '扫描密钥与凭据泄露源头。' },
68
+ { slug: 'yotta-chain', order: 5, role: '校验依赖供应链与 lockfile 一致性。' },
69
+ { slug: 'yotta-recon', order: 6, role: '在授权范围内做端口、服务与版本指纹侦察。' },
70
+ ],
71
+ },
72
+ {
73
+ id: 'entry-install',
74
+ name: '入口 + 安装',
75
+ intent: '需求方向不明确时先澄清意图,再按需安装合适技能。',
76
+ keywords: ['不知道用哪个', '需求模糊', '该用哪个', '怎么说', '技能该用哪个'],
77
+ skills: [
78
+ { slug: 'yotta-prompt', order: 1, role: '澄清需求意图并串联到合适的技能方向。' },
79
+ { slug: 'yotta-skills', order: 2, role: '按场景组合安装所需技能,不默认安装全家。' },
80
+ ],
81
+ },
82
+ ];
83
+
84
+ const OTHER_SKILLS_NOTE = '其他已装技能仅作并列候选提示:机械匹配 frontmatter description,未做语义推理、未读取全文指令、未自动调用;数据不出本机。';
85
+ const OTHER_SKILL_NOTE = '非元阁家族技能:仅按 frontmatter description 本地机械匹配;不读取全文指令、不自动调用;使用/安装前请先做装前安全扫描。';
86
+ const EN_STOPWORDS = new Set([
87
+ 'a', 'an', 'the', 'and', 'or', 'of', 'to', 'in', 'on', 'for', 'with', 'from',
88
+ 'this', 'that', 'is', 'are', 'was', 'were', 'be', 'been', 'your', 'you', 'our',
89
+ 'we', 'it', 'at', 'by', 'as', 'not', 'no', 'so', 'do', 'does',
90
+ ]);
91
+
92
+ /** 元阁家族 slug 集合:playbook 引用 + 已知不入 playbook 的元技能(如 yotta-chart)。 */
93
+ function defaultYottaSlugs() {
94
+ const set = new Set(['yotta-chart']);
95
+ for (const playbook of PLAYBOOKS) {
96
+ for (const skill of playbook.skills) set.add(skill.slug);
97
+ }
98
+ return Array.from(set);
99
+ }
100
+
101
+ /** 英文词项:≥3 字母的单词,过滤停用词(保留出现顺序、去重)。 */
102
+ function enTokens(text) {
103
+ const tokens = [];
104
+ const seen = new Set();
105
+ for (const m of String(text || '').toLowerCase().match(/[a-z][a-z0-9]{2,}/g) || []) {
106
+ if (EN_STOPWORDS.has(m) || seen.has(m)) continue;
107
+ seen.add(m);
108
+ tokens.push(m);
109
+ }
110
+ return tokens;
111
+ }
112
+
113
+ /** 中文词项:CJK 连续片段内相邻两字 bigram(零依赖确定性分词)。 */
114
+ function cjkBigrams(text) {
115
+ const bigrams = [];
116
+ const seen = new Set();
117
+ for (const m of String(text || '').match(/[\u4e00-\u9fff]+/g) || []) {
118
+ for (let i = 0; i < m.length - 1; i++) {
119
+ const g = m.slice(i, i + 2);
120
+ if (seen.has(g)) continue;
121
+ seen.add(g);
122
+ bigrams.push(g);
123
+ }
124
+ }
125
+ return bigrams;
126
+ }
127
+
128
+ /** 需求与候选文本的词项匹配:英文 token + 中文 bigram 交集,按需求侧出现顺序输出。 */
129
+ function scoreOtherSkill(request, record) {
130
+ const candidateText = [record.description, record.slug].filter(Boolean).join(' ');
131
+ const reqTokens = enTokens(request);
132
+ const reqBigrams = cjkBigrams(request);
133
+ const candTokens = new Set(enTokens(candidateText));
134
+ const candBigrams = new Set(cjkBigrams(candidateText));
135
+ const matched = [];
136
+ for (const item of reqTokens) if (candTokens.has(item)) matched.push(item);
137
+ for (const item of reqBigrams) if (candBigrams.has(item)) matched.push(item);
138
+ return { score: matched.length, matched_terms: matched };
139
+ }
140
+
141
+ function normalizeText(text) {
142
+ return String(text || '').toLowerCase().replace(/\s+/g, '');
143
+ }
144
+
145
+ function scorePlaybook(request, playbook) {
146
+ const text = normalizeText(request);
147
+ const matchedKeywords = [];
148
+ let score = 0;
149
+ for (const keyword of playbook.keywords) {
150
+ if (text.includes(normalizeText(keyword))) {
151
+ matchedKeywords.push(keyword);
152
+ score += normalizeText(keyword).length >= 3 ? 2 : 1;
153
+ }
154
+ }
155
+ return { score, matchedKeywords };
156
+ }
157
+
158
+ function routeRequest(request, options) {
159
+ const registry = (options && options.registry) || { skills: {} };
160
+ const installed = registry.skills || {};
161
+ const yottaSlugs = new Set((options && options.yottaSlugs) || defaultYottaSlugs());
162
+ const otherSkillsTopN = (options && options.otherSkillsTopN) || 3;
163
+ const ranked = PLAYBOOKS
164
+ .map((playbook) => ({ playbook, ...scorePlaybook(request, playbook) }))
165
+ .sort((a, b) => b.score - a.score || a.playbook.id.localeCompare(b.playbook.id));
166
+ const best = ranked[0];
167
+ const runnerUp = ranked[1];
168
+ const fallback = !best || best.score === 0;
169
+ const playbook = fallback
170
+ ? PLAYBOOKS.find((item) => item.id === 'entry-install')
171
+ : best.playbook;
172
+ const matchedKeywords = fallback ? [] : best.matchedKeywords;
173
+ const margin = fallback ? 0 : best.score - (runnerUp ? runnerUp.score : 0);
174
+ const confidence = !fallback && best.score >= 3 && margin >= 1
175
+ ? 'high'
176
+ : (!fallback && best.score >= 1 ? 'medium' : 'low');
177
+
178
+ const skills = playbook.skills.map((skill) => {
179
+ const record = installed[skill.slug];
180
+ const isInstalled = Boolean(record && record.status !== 'gone');
181
+ return {
182
+ ...skill,
183
+ installed: isInstalled,
184
+ version: isInstalled ? record.version || '' : '',
185
+ sources: isInstalled ? record.sources || [] : [],
186
+ };
187
+ });
188
+ const missingSkills = skills
189
+ .filter((skill) => !skill.installed)
190
+ .map((skill) => ({ slug: skill.slug, scan_required: true }));
191
+ const installCommand = missingSkills.length
192
+ ? 'npx -y @yottameta/yotta-skills install '
193
+ + missingSkills.map((skill) => skill.slug).join(' ')
194
+ + ' --dir <skills-dir>'
195
+ : null;
196
+
197
+ const otherCandidates = Object.values(installed)
198
+ .filter((record) => record && record.status !== 'gone' && !yottaSlugs.has(record.slug))
199
+ .map((record) => ({ record, ...scoreOtherSkill(request, record) }))
200
+ .filter((item) => item.score > 0)
201
+ .sort((a, b) => b.score - a.score || a.record.slug.localeCompare(b.record.slug))
202
+ .slice(0, otherSkillsTopN)
203
+ .map(({ record, score, matched_terms }) => ({
204
+ slug: record.slug,
205
+ version: record.version || '',
206
+ sources: record.sources || [],
207
+ description: record.description || '',
208
+ score,
209
+ matched_terms,
210
+ scan_status: 'not_scanned',
211
+ note: OTHER_SKILL_NOTE,
212
+ }));
213
+
214
+ return {
215
+ request,
216
+ playbook: {
217
+ id: playbook.id,
218
+ name: playbook.name,
219
+ intent: playbook.intent,
220
+ },
221
+ confidence,
222
+ matched_keywords: matchedKeywords,
223
+ skills,
224
+ missing_skills: missingSkills,
225
+ install_command: installCommand,
226
+ auto_install: false,
227
+ application_mode: {
228
+ default: 'explicit',
229
+ options: ['explicit', 'scene-auto'],
230
+ note: '默认用户显式调用;切换为按场景自动调用需要用户确认。',
231
+ },
232
+ disclaimer: '路由建议不保证完全正确;关键动作应由用户确认,数据不出本机。',
233
+ other_skill_candidates: otherCandidates,
234
+ other_skills_note: OTHER_SKILLS_NOTE,
235
+ };
236
+ }
237
+
238
+ module.exports = { PLAYBOOKS, defaultYottaSlugs, routeRequest };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yottameta/yotta-skills",
3
- "version": "0.3.0",
4
- "description": "YuanGe (元阁) — one-command installer for the whole YottaMeta skill family: list, install, and update all published yotta-* skills into any agent (npx one-shot, zero dependencies, Node.js only).",
3
+ "version": "0.5.0",
4
+ "description": "YuanGe (元阁) - orchestration routing, inventory, and one-command installer for the YottaMeta skill family (zero dependencies, Node.js only).",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "agent-skills",
@@ -6,6 +6,22 @@
6
6
 
7
7
  ---
8
8
 
9
+ ## 〇、编排路由(--route / route_request)
10
+
11
+ 把需求摘要交给静态 playbook 与本地注册表,得到一组建议:
12
+
13
+ ```bash
14
+ npx -y @yottameta/yotta-skills --route "帮我润色输出,要规范可复制,别有 AI 味"
15
+ ```
16
+
17
+ - **输出**:候选组合、调用顺序、每个技能的角色、置信度、命中依据、已装/缺失状态、安装命令与应用模式提醒;如本机装了非元阁家族技能,还会给出其他已装技能候选(仅按 frontmatter description 机械匹配,标注来源与未扫描状态)。
18
+ - **缺失技能**:只给安装命令,不自动安装;安装前先做装前安全扫描,决定权在用户。
19
+ - **应用模式**:默认用户显式调用;切换为「按场景自动调用」需要用户确认。
20
+ - **无明确匹配**:低置信度回退到「入口 + 安装」组合,先澄清需求再继续。
21
+ - **边界**:路由是建议,不保证完全正确;关键动作由用户确认,数据不出本机。其他已装技能候选只读 frontmatter description、不读取全文指令、不自动调用;使用/安装前先做装前安全扫描。
22
+
23
+ ---
24
+
9
25
  ## 一、技能家族全景(24 技能 / 8 家族)
10
26
 
11
27
  | 家族 | 技能(中文名 / slug) | 一句话能力 |
@@ -118,4 +118,15 @@ npx -y @yottameta/yotta-skills --reindex
118
118
  - `install` / `update` 完成后会自动重扫注册表(`~/.yottaskills/registry.json`),新装 / 更新的
119
119
  技能随即出现在 `--inventory` / `--reindex` 里;`--no-reindex` 可关闭自动重扫。
120
120
  - 建议每会话开工先跑一次 `--reindex`(快速增量,只合并变化),让后装的技能自动被看见。
121
+
122
+ ## 编排路由(--route)
123
+
124
+ 当你不知道「这个需求该用哪几个技能」,可以先把需求摘要交给元阁:
125
+
126
+ ```bash
127
+ npx -y @yottameta/yotta-skills --route "检查代码质量,别糊弄"
128
+ ```
129
+
130
+ 输出会告诉你命中哪个组合、按什么顺序调用、每个技能负责什么、哪些已装、哪些缺失,以及缺失技能的安装命令。元阁只给建议,不会自动安装;安装前请先做装前安全扫描,并由用户确认。
121
131
  - `--json` 输出机器可读结果(含新增 / 更新 / 消失),适合脚本与钩子。
132
+ - 如果本机还装了非元阁家族技能,`--route` 会额外列出「其他已装技能候选」:只按 frontmatter description 与需求文本做本地机械匹配,标注来源、得分、命中词项与扫描状态(默认未扫描),不读取全文指令、不自动调用;使用/安装前请先做装前安全扫描。
@@ -6,6 +6,7 @@ stdio MCP server(JSON-RPC 2.0,换行分隔),把元阁技能扫描核心
6
6
  list_installed_skills 盘点本机已装技能(读本地注册表;未生成则先扫描一次)
7
7
  describe_skill 查看单个技能详情(slug / 版本 / 功能 / 来源)
8
8
  reindex 强制重新扫描并更新注册表
9
+ route_request 按需求摘要给出静态编排路由建议
9
10
 
10
11
  自包含原则:扫描由元阁自带核心(bin/yotta-skills.js --inventory / --reindex)完成,
11
12
  不依赖任何元技能;数据只写本机 ~/.yottaskills/registry.json,不出本机。
@@ -23,7 +24,7 @@ import subprocess
23
24
  import sys
24
25
  from pathlib import Path
25
26
 
26
- VERSION = "0.3.0"
27
+ VERSION = "0.5.0"
27
28
  TOOL_NAME = "yotta-skills"
28
29
  CN_NAME = "元阁"
29
30
  MCP_PROTOCOL = "2025-03-26"
@@ -138,10 +139,24 @@ def _tool_reindex(arguments): # noqa: ARG001
138
139
  "isError": False}
139
140
 
140
141
 
142
+ def _tool_route(arguments):
143
+ request = str(arguments.get("request") or "").strip()
144
+ if not request:
145
+ return _tool_error("route_request 需要 request 参数")
146
+ stdout = _run_cli(["--route", request, "--json"])
147
+ try:
148
+ payload = json.loads(stdout)
149
+ except json.JSONDecodeError as e:
150
+ return _tool_error("route_request 输出解析失败:%s" % e)
151
+ return {"content": [{"type": "text", "text": json.dumps(payload, ensure_ascii=False, indent=2)}],
152
+ "isError": False}
153
+
154
+
141
155
  TOOL_HANDLERS = {
142
156
  "list_installed_skills": _tool_list,
143
157
  "describe_skill": _tool_describe,
144
158
  "reindex": _tool_reindex,
159
+ "route_request": _tool_route,
145
160
  }
146
161
 
147
162
 
@@ -167,6 +182,14 @@ def mcp_tools():
167
182
  {},
168
183
  [],
169
184
  ),
185
+ _tool_spec(
186
+ "route_request",
187
+ "按需求摘要给出静态编排路由建议:候选组合、调用顺序、每个技能角色、置信度、依据、已装/缺失状态与安装命令。"
188
+ "并给出其他已装技能候选(仅按 frontmatter description 本地机械匹配、标注未扫描状态,不读取全文指令、不自动调用)。"
189
+ "只建议安装,不自动安装;数据不出本机。",
190
+ {"request": {"type": "string", "description": "用户需求摘要"}},
191
+ ["request"],
192
+ ),
170
193
  ]
171
194
 
172
195