@yottameta/yotta-skills 0.2.0 → 0.3.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,25 @@
1
1
  # 更新日志
2
2
 
3
+ ## v0.3.0 (2026-08-31)
4
+
5
+ 阶段 B(D2 re-index 自动钩子):新装技能自动被发现。
6
+
7
+ - 新增 CLI `--reindex`:重扫所有技能目录并增量合并注册表,变化聚焦输出(文本 / `--json` 机器可读),供会话开工与钩子调用;`--rescan` 为同义别名。
8
+ - 装技能后自动 re-index:`install` / `update` 完成后自动重扫注册表,把本次落位结果反映进 `~/.yottaskills/registry.json`(新增 / 更新 / 消失随输出列出);`--no-reindex` 可关闭。
9
+ - 会话开工 re-scan:SKILL.md「使用须知」护栏补「会话开工先跑一次 `yotta-skills --reindex`」;注册表 `note` 口径同步 `--inventory / --reindex`。
10
+ - MCP `reindex` 工具改走 `--reindex --json`(同一套扫描核心);CLI 等价命令注明。
11
+ - 文档:SKILL.md / README 中英 / references/install-flow.md / tutorial.md 同步 re-index 用法。
12
+ - 测试:新增 `--reindex`(含幂等)与装后自动 re-index(含 `--no-reindex` 关闭)用例;全量用例全绿。
13
+ - 版本升至 0.3.0。
14
+
15
+ ## v0.2.1 (2026-08-31)
16
+
17
+ MCP 配置说明补全(按需加载口径)。
18
+
19
+ - SKILL.md「技能盘点」节补「MCP:按需加载(可选)」:明确本技能与 MCP 均为按需触发、不走常驻;mcpServers 配置 JSON 示例、按需写入步骤(用后可移除)、重启/重载提示、未加载降级 CLI 兜底;frontmatter description 同步按需加载口径。
20
+ - 测试:mcp-e2e serverInfo.version 断言改为动态读 package.json;python 探测加候选兜底(YOTTA_TEST_PYTHON / python / python3 / Scoop python38),Windows 无需手动设环境变量。
21
+ - 版本升至 0.2.1。
22
+
3
23
  ## v0.2.0 (2026-08-31)
4
24
 
5
25
  技能生态盘点层(阶段 A):元阁从「编排策划 + 安装器」升级为「编排策划 + 安装器 + 技能盘点」。
package/README.md CHANGED
@@ -30,7 +30,7 @@ Installing the whole YottaMeta family used to mean running <code>npx</code> for
30
30
  - **Update** — incremental update: add missing skills, upgrade version-skewed ones.
31
31
  - **Idempotent** — a skill already at the manifest version is skipped; re-running is safe.
32
32
  - **Pre-install summary** — if yotta-verify (元信) is available, each skill is scanned first; the verdict is informational only.
33
- - **Inventory** — scan the skill directories on this machine and keep a local registry (<code>~/.yottaskills/registry.json</code>); self-contained, no other skills required.
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
34
 
35
35
  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
36
 
@@ -57,6 +57,9 @@ npx -y @yottameta/yotta-skills --dry-run
57
57
 
58
58
  # Inventory installed skills on this machine (self-contained scan, no other skills needed)
59
59
  npx -y @yottameta/yotta-skills --inventory
60
+
61
+ # Re-index the registry (session start / after installing skills; incremental)
62
+ npx -y @yottameta/yotta-skills --reindex
60
63
  ```
61
64
 
62
65
  Requirements: Node.js 18+, npm, and system <code>tar</code> (built into Windows 10+ / macOS / most Linux distributions).
@@ -71,6 +74,8 @@ Requirements: Node.js 18+, npm, and system <code>tar</code> (built into Windows
71
74
  | `install <skill>... [--agent <name> \| --dir <path>]` | Install only the given skills |
72
75
  | `update [--agent <name> \| --dir <path>]` | Incremental update: add missing, upgrade version-skewed |
73
76
  | `--inventory` | Inventory installed skills: scan skill directories and update the local registry (self-contained); `--json` for JSON, `--project` adds project-level dirs |
77
+ | `--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 |
78
+ | `--no-reindex` | Do not re-index the registry automatically after `install` / `update` |
74
79
  | `--dry-run` | Preview the install / update list; no network, no changes |
75
80
  | `--pin` | Lock the exact manifest versions (default: range, latest patch of the same major) |
76
81
  | `--force` | Reinstall even when already at the latest version |
@@ -141,12 +146,12 @@ The full 22-skill manifest with Chinese names, package names, versions and descr
141
146
 
142
147
  ## How it works
143
148
 
144
- For each skill in the manifest: `npm pack <pkg>@<spec>` into a temp directory → `tar -xzf` → optional yotta-verify pre-install summary → replace `<dest>/<slug>` → summary report. Details: `references/install-flow.md`; beginner tutorial (Chinese): `references/tutorial.md`.
149
+ For each skill in the manifest: `npm pack <pkg>@<spec>` into a temp directory → `tar -xzf` → optional yotta-verify pre-install summary → replace `<dest>/<slug>` → summary report. After `install` / `update` finishes, the local skill registry is re-indexed automatically so newly installed skills show up in `--inventory` / `--reindex` (disable with `--no-reindex`). Details: `references/install-flow.md`; beginner tutorial (Chinese): `references/tutorial.md`.
145
150
 
146
151
  ## Development & validation
147
152
 
148
153
  ```bash
149
- # Run the test suite (12 cases) from the skill directory
154
+ # Run the test suite from the skill directory
150
155
  npm test
151
156
  ```
152
157
 
package/README.zh-CN.md CHANGED
@@ -33,7 +33,7 @@
33
33
  - **更新**——增量更新:补齐缺失技能、升级版本不一致的技能。
34
34
  - **幂等**——已在清单版本的技能跳过;重复运行安全。
35
35
  - **装前摘要**——若装了元信(yotta-verify),先对每个待装技能做一次装前扫描;verdict 仅提示、不拦截。
36
- - **盘点**——扫描本机各智能体技能目录,维护本地注册表(<code>~/.yottaskills/registry.json</code>);自包含,不需要任何其他技能。
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
37
 
38
38
  边界:只做「下载 + 落位 + 汇总」——**不**开发技能内容、**不**内置任何技能本体、**不**用 <code>-g</code>
39
39
  全局安装;只在你指定的目标内写文件。
@@ -61,6 +61,9 @@ npx -y @yottameta/yotta-skills --dry-run
61
61
 
62
62
  # 盘点本机已装技能(自包含扫描,不依赖任何元技能)
63
63
  npx -y @yottameta/yotta-skills --inventory
64
+
65
+ # 重扫注册表(会话开工 / 新装技能后,增量合并变化)
66
+ npx -y @yottameta/yotta-skills --reindex
64
67
  ```
65
68
 
66
69
  前置:Node.js 18+、npm、系统 tar(Windows 10+ / macOS / 多数 Linux 自带)。
@@ -75,6 +78,8 @@ npx -y @yottameta/yotta-skills --inventory
75
78
  | `install <skill>... [--agent <name> \| --dir <path>]` | 只装指定的一个或多个技能 |
76
79
  | `update [--agent <name> \| --dir <path>]` | 增量更新:补齐缺失、升级版本不一致的技能 |
77
80
  | `--inventory` | 盘点已装技能:扫描技能目录并更新本地注册表(自包含);`--json` 输出 JSON、`--project` 附扫项目级目录 |
81
+ | `--reindex` | 重扫注册表:扫描技能目录并增量合并变化(会话开工 / 装技能后自动调用;`--rescan` 同义);`--json` 输出 JSON |
82
+ | `--no-reindex` | 安装 / 更新后不自动重扫注册表 |
78
83
  | `--dry-run` | 预览将执行的安装 / 更新清单;不联网、不改动 |
79
84
  | `--pin` | 锁死清单精确版本(默认 range:跟随同 major 最新 patch) |
80
85
  | `--force` | 已是最新也重新安装 |
@@ -150,13 +155,14 @@ bash install.sh --list # 列出智能体 -> 默认目录
150
155
  ## 工作原理
151
156
 
152
157
  对清单里每个技能:`npm pack <pkg>@<spec>` 到临时目录 → `tar -xzf` 解压 → 可选元信装前摘要 →
153
- 替换 `<dest>/<slug>` → 汇总报告。细节见 `references/install-flow.md`;新手中文教程见
154
- `references/tutorial.md`。
158
+ 替换 `<dest>/<slug>` → 汇总报告。`install` / `update` 完成后自动重扫本地技能注册表,
159
+ 新装技能随即出现在 `--inventory` / `--reindex` 里(可用 `--no-reindex` 关闭)。
160
+ 细节见 `references/install-flow.md`;新手中文教程见 `references/tutorial.md`。
155
161
 
156
162
  ## 开发与校验
157
163
 
158
164
  ```bash
159
- # 在技能目录内跑测试(12 个用例)
165
+ # 在技能目录内跑测试
160
166
  npm test
161
167
  ```
162
168
 
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: yotta-skills
3
- version: 0.2.0
4
- description: 元阁 —— 元阁全家技能的总编排策划 + 一键安装器 + 技能盘点。策划层:按场景给出「该组合哪几个元技能、组合强在哪、怎么自动装+自动用」;安装层:一条命令把 YottaMeta 已发布的全部 yotta-* 技能装进指定智能体或目录;盘点层:--inventory 扫描本机已装技能生成注册表(自包含零依赖,不依赖任何元技能)。支持 --list 清单 / install / update / --inventory / --dry-run 预览 / --pin 锁版本。触发:需要批量安装或更新元阁全家技能、按场景组合多个元技能、盘点或查看本机已装技能、给某个智能体或目录一次性铺齐 yotta-* 技能、预览安装清单、锁版本安装、或用户说 元阁/装全家/一次装齐/yotta-skills/install-all/更新全家/盘点技能/查看已装技能 等。边界(Do NOT trigger):只做「组合策划 + 清单 + 下载 + 落位 + 汇总 + 盘点」,不含技能本体、不做技能内容开发、不 -g 污染全局;装前摘要仅供参考,安装决策由用户确认。
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 污染全局;装前摘要仅供参考,安装决策由用户确认。
5
5
  license: MIT
6
6
  metadata:
7
7
  zh_name: 元阁
@@ -15,7 +15,8 @@ metadata:
15
15
 
16
16
  **写入内容(逐字)**:
17
17
 
18
- > **元阁编排**:单技能是零件,组合才是系统。接到需求,先查「元阁编排策划」命中哪个组合
18
+ > **元阁编排**:单技能是零件,组合才是系统。会话开工先跑一次 `yotta-skills --reindex`
19
+ > (重扫本机技能注册表,新装技能自动被看见)。接到需求,先查「元阁编排策划」命中哪个组合
19
20
  > (输出呈现标准 / 长生命周期 / 交付质量门 / 装前安全门 / 造技能发版 / 安全事件响应 / 入口安装),
20
21
  > 再按需自动安装并应用。完整决策表见技能 `yotta-skills/references/orchestration.md`。
21
22
 
@@ -30,7 +31,7 @@ metadata:
30
31
 
31
32
  - **策划层(怎么用)**:接到需求,先按「编排策划」定位命中哪个组合——哪些元技能搭配起来最强、适合什么场景、AI 该怎么自动装并自动用起来。
32
33
  - **安装层(怎么装)**:一条 `npx -y @yottameta/yotta-skills` 把组合/全家装进指定智能体或目录——`--list` 看清单、`install` 装、`update` 增量更新、`--dry-run` 预览、`--pin` 锁版本。
33
- - **盘点层(已装了什么)**:`--inventory` 扫描本机各智能体技能目录,生成/更新本地注册表——自包含扫描,不依赖任何元技能。
34
+ - **盘点层(已装了什么)**:`--inventory` / `--reindex` 扫描本机各智能体技能目录,生成/更新本地注册表;装技能后自动 re-index,新装技能自动被发现——自包含扫描,不依赖任何元技能。
34
35
 
35
36
  每个技能仍走各自独立的 npm 包(版本源唯一);本包只做「清单 + 下载 + 落位 + 汇总」,**不内置任何技能本体**。
36
37
  > **本包不含技能本体**:拿到它只代表有了「编排策划 + 安装工具」;真正装齐需运行 `install`。
@@ -100,6 +101,9 @@ npx -y @yottameta/yotta-skills --dry-run
100
101
 
101
102
  # 盘点本机已装技能(自包含扫描,不依赖任何元技能)
102
103
  npx -y @yottameta/yotta-skills --inventory
104
+
105
+ # 重扫注册表(会话开工 / 新装技能后,增量合并变化)
106
+ npx -y @yottameta/yotta-skills --reindex
103
107
  ```
104
108
 
105
109
  ## 命令与选项
@@ -112,6 +116,8 @@ npx -y @yottameta/yotta-skills --inventory
112
116
  | `install <skill>... [--agent <name> \| --dir <path>]` | 只装指定的一个或多个技能 |
113
117
  | `update [--agent <name> \| --dir <path>]` | 增量更新:补齐缺失技能、升级版本不一致的技能 |
114
118
  | `--inventory` | 盘点本机已装技能:扫描技能目录生成/更新注册表(自包含,不依赖元技能);`--json` 输出 JSON、`--project` 附扫项目级目录 |
119
+ | `--reindex` | 重扫注册表:扫描技能目录并增量合并变化(会话开工 / 装技能后自动调用);`--json` 输出 JSON、`--project` 附扫项目级目录;`--rescan` 同义 |
120
+ | `--no-reindex` | 安装 / 更新后不自动重扫注册表 |
115
121
  | `--dry-run` | 预览将执行的安装 / 更新清单;不联网、不改动 |
116
122
  | `--pin` | 锁死清单精确版本(默认 range:跟随同 major 最新 patch) |
117
123
  | `--force` | 已是最新也重新安装 |
@@ -142,9 +148,39 @@ npx -y @yottameta/yotta-skills --inventory --dir ~/my-skills --project
142
148
 
143
149
  注册表增量合并:新增(added)/ 更新(updated)/ 消失(gone)随输出列出;同名技能来自多个目录时合并来源,版本不一致记录冲突。
144
150
 
145
- **MCP(按需加载)**:`scripts/yotta-skills-mcp.py` 提供三个工具——
146
- `list_installed_skills`(盘点)/ `describe_skill`(单技能详情)/ `reindex`(强制重扫),
147
- 走 stdio JSON-RPC,数据不出本机。需要时按需加载,不常驻。
151
+ ### re-index:新装技能自动被发现
152
+
153
+ - **装技能后自动**:`install` / `update` 完成后自动重扫注册表,把本次落位结果反映进
154
+ `~/.yottaskills/registry.json`(新增 / 更新 / 消失随输出列出);`--no-reindex` 可关闭。
155
+ - **会话开工**:建议每会话开工先跑一次 `yotta-skills --reindex`(快速增量,只合并变化),
156
+ 让新装 / 更新的技能自动进入注册表。
157
+ - **手动**:`yotta-skills --reindex`(`--rescan` 同义);`--json` 机器可读、`--project` 附扫项目级目录。
158
+
159
+ ### MCP:按需加载(可选)
160
+
161
+ 本技能自带一个 MCP server:`yotta-skills`(`scripts/yotta-skills-mcp.py`,零依赖、数据不出本机),
162
+ 提供 `list_installed_skills`(盘点)/ `describe_skill`(单技能详情)/ `reindex`(强制重扫)三个工具。
163
+
164
+ **按需加载,不走常驻**:本技能与 MCP 均为按需触发。默认以 CLI 为主
165
+ (`npx -y @yottameta/yotta-skills --inventory`);需要让 AI 通过工具直接调用时,再按下面配置启用:
166
+
167
+ 1. **检查当前客户端的 `mcpServers`** 是否已有 `yotta-skills` 条目;已有 → 直接使用。
168
+ 2. **没有 → 按需写入**下面这一条 server 配置(用后可移除,不要求常驻):
169
+ ```json
170
+ {
171
+ "mcpServers": {
172
+ "yotta-skills": {
173
+ "command": "python",
174
+ "args": ["<技能目录>/scripts/yotta-skills-mcp.py"]
175
+ }
176
+ }
177
+ }
178
+ ```
179
+ > `<技能目录>` = 本技能实际安装目录,**不要写死盘符路径**;Windows 用 `python`,Linux/macOS 用 `python3`。
180
+ 3. **提醒用户**:改 `mcpServers` 后多数客户端需**重启 / 重载一次** MCP server 才生效;加载后应看到
181
+ `list_installed_skills` / `describe_skill` / `reindex` 三个工具。
182
+ 4. **降级兜底(重要)**:若客户端未暴露 MCP 工具 / 无法改配置 / server 未加载,**自动降级 CLI**
183
+ (同一套扫描核心、结果一致):`npx -y @yottameta/yotta-skills --inventory / --reindex ...`。
148
184
 
149
185
  ## 版本策略
150
186
 
@@ -22,7 +22,7 @@ const os = require('os');
22
22
  const { spawnSync } = require('child_process');
23
23
 
24
24
  const PKG_ROOT = path.join(__dirname, '..');
25
- let VERSION = '0.2.0';
25
+ let VERSION = '0.2.1';
26
26
  try { VERSION = require(path.join(PKG_ROOT, 'package.json')).version; } catch (_) { /* keep fallback */ }
27
27
 
28
28
  function loadManifest() {
@@ -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, rescan: false, json: false, project: false,
134
+ inventory: false, reindex: false, noReindex: false, json: false, project: false,
135
135
  };
136
136
  const positionals = [];
137
137
  for (let i = 0; i < argv.length; i++) {
@@ -145,7 +145,8 @@ 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 === '--rescan') opts.rescan = true;
148
+ else if (a === '--reindex' || a === '--rescan') opts.reindex = true;
149
+ else if (a === '--no-reindex') opts.noReindex = true;
149
150
  else if (a === '--json') opts.json = true;
150
151
  else if (a === '--project') opts.project = true;
151
152
  else if (a === '--agent') opts.agent = take('--agent').toLowerCase();
@@ -437,6 +438,7 @@ function printHelp() {
437
438
  out(' yotta-skills update --agent <name> 增量更新已装技能(补齐缺失 / 版本不一致)');
438
439
  out(' yotta-skills --dry-run 预览将安装清单(不联网、不改动)');
439
440
  out(' yotta-skills --inventory 盘点本机已装技能(自研扫描,不依赖任何元技能)');
441
+ out(' yotta-skills --reindex 重扫注册表(会话开工 / 装技能后自动调用;增量合并)');
440
442
  out('');
441
443
  out('选项:');
442
444
  out(' --agent <name> 智能体键名(--list 可查看;未知智能体请用 --dir)');
@@ -447,8 +449,9 @@ function printHelp() {
447
449
  out(' --npm <path> 指定 npm 可执行文件(默认 npm / npm.cmd)');
448
450
  out(' --python <path> 指定 python 可执行文件(元信 scan 用)');
449
451
  out(' --verify <path> 指定 yotta_verify.py 路径(默认找目标目录已装的元信)');
450
- out(' --json inventory 时输出 JSON');
451
- out(' --project inventory 时附加扫描当前项目 .agents/skills / .codex/skills');
452
+ out(' --json inventory / reindex 时输出 JSON');
453
+ out(' --project inventory / reindex 时附加扫描当前项目 .agents/skills / .codex/skills');
454
+ out(' --no-reindex 安装 / 更新后不自动重扫注册表');
452
455
  out(' -h, --help 帮助');
453
456
  out(' -v, --version 版本');
454
457
  out('');
@@ -458,8 +461,9 @@ function printHelp() {
458
461
 
459
462
 
460
463
 
461
- // ── 技能盘点(--inventory,自研零依赖扫描) ────────────────────────────────
462
- function runInventory(opts) {
464
+ // ── 技能盘点 / re-index(自研零依赖扫描核心) ────────────────────────────────
465
+ /** 重扫所有技能根目录并增量合并进注册表;返回 { result, registry, changes }。 */
466
+ function reindexRegistry(opts) {
463
467
  const scan = require('../lib/skills-scan');
464
468
  const extraDirs = opts.dir ? [opts.dir] : [];
465
469
  const roots = scan.defaultRoots({ extraDirs: extraDirs, project: opts.project });
@@ -467,6 +471,12 @@ function runInventory(opts) {
467
471
  const prev = scan.readRegistry();
468
472
  const { registry, changes } = scan.mergeRegistry(result, prev);
469
473
  scan.saveRegistry(registry);
474
+ return { result, registry, changes };
475
+ }
476
+
477
+ function runInventory(opts) {
478
+ const scan = require('../lib/skills-scan');
479
+ const { result, registry, changes } = reindexRegistry(opts);
470
480
  if (opts.json) {
471
481
  out(JSON.stringify({
472
482
  generated_at: registry.updated,
@@ -486,13 +496,53 @@ function runInventory(opts) {
486
496
  }
487
497
  }
488
498
 
499
+ /** --reindex:重扫 + 增量合并,变化聚焦输出(供会话开工 / 钩子使用)。 */
500
+ function runReindex(opts) {
501
+ const scan = require('../lib/skills-scan');
502
+ const { result, registry, changes } = reindexRegistry(opts);
503
+ if (opts.json) {
504
+ out(JSON.stringify({
505
+ reindexed_at: registry.updated,
506
+ note: registry.note,
507
+ count: Object.values(registry.skills).filter((s) => s.status !== 'gone').length,
508
+ changes: changes,
509
+ errors: result.errors,
510
+ scanned: result.scanned,
511
+ }, null, 2));
512
+ return;
513
+ }
514
+ out('re-index 完成: 新增 ' + changes.added.length + ' / 更新 ' + changes.updated.length + ' / 消失 ' + changes.gone.length);
515
+ for (const slug of changes.added) out(' + ' + slug);
516
+ for (const slug of changes.updated) out(' ~ ' + slug);
517
+ for (const slug of changes.gone) out(' - ' + slug);
518
+ if (result.errors.length) {
519
+ out('跳过不存在目录 ' + result.errors.length + ' 个');
520
+ }
521
+ out('注册表: ' + scan.registryPath());
522
+ }
523
+
524
+ /** 装技能后自动 re-index(--no-reindex 关闭):把本次落位结果反映进注册表。best-effort:失败不阻断安装。 */
525
+ function maybeAutoReindex(opts, dest) {
526
+ if (opts.noReindex || opts.dryRun || !dest) return;
527
+ const scan = require('../lib/skills-scan');
528
+ try {
529
+ const { changes } = reindexRegistry({ ...opts, dir: dest });
530
+ out('');
531
+ out('已自动 re-index 注册表(新增 ' + changes.added.length + ' / 更新 ' + changes.updated.length + ' / 消失 ' + changes.gone.length + ';注册表: ' + scan.registryPath() + ')');
532
+ } catch (e) {
533
+ out('');
534
+ out('提示: 自动 re-index 跳过(' + e.message + ');稍后可手动 --reindex 重扫');
535
+ }
536
+ }
537
+
489
538
  // ── main ───────────────────────────────────────────────────────────────────
490
539
  function main() {
491
540
  const opts = parseArgs(process.argv.slice(2));
492
541
  if (opts.help) { printHelp(); return; }
493
542
  if (opts.version) { out('yotta-skills v' + VERSION); return; }
494
543
  if (opts.list) { printList(opts); return; }
495
- if (opts.inventory) { runInventory(opts); return; }
544
+ if (opts.inventory && !opts.command) { runInventory(opts); return; }
545
+ if (opts.reindex && !opts.command) { runReindex(opts); return; }
496
546
 
497
547
  const command = opts.command || 'install';
498
548
  let dest = resolveTargetDir(opts);
@@ -518,6 +568,7 @@ function main() {
518
568
 
519
569
  if (command === 'update') runUpdate(opts, dest);
520
570
  else runInstall(opts, dest);
571
+ maybeAutoReindex(opts, dest);
521
572
  }
522
573
 
523
574
  main();
@@ -267,7 +267,7 @@ function mergeRegistry(scanResult, previous) {
267
267
  }
268
268
  const registry = {
269
269
  updated: now,
270
- note: '本地技能注册表(yotta-skills --inventory 生成)。数据不出本机。',
270
+ note: '本地技能注册表(yotta-skills --inventory / --reindex 生成)。数据不出本机。',
271
271
  skills: next,
272
272
  };
273
273
  return { registry, changes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yottameta/yotta-skills",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
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).",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -13,6 +13,8 @@
13
13
  4. 元信装前摘要(若引擎可用;`--skip-scan` 关闭);
14
14
  5. 删除目标 `<dest>/<slug>` 后重新复制(跳过规则见下);
15
15
  6. 汇总报告:✔ 成功 / - 跳过(已是最新)/ ✘ 失败;有失败项时退出码 1。
16
+ 7. 全部完成后自动 re-index 本地技能注册表(`~/.yottaskills/registry.json`):重扫技能根目录并增量合并,
17
+ 新装 / 更新的技能随即进入注册表(`--no-reindex` 可关闭;`--dry-run` 不触发)。
16
18
 
17
19
  ## 复制跳过规则
18
20
 
@@ -22,6 +24,14 @@
22
24
  因此装进技能目录的是「技能本体」(SKILL.md / references / scripts 等),不含 npm
23
25
  安装器自身、测试夹具与 Python 字节码缓存。
24
26
 
27
+ ## re-index(装技能后自动重扫注册表)
28
+
29
+ - `install` / `update` 完成后,CLI 自动调用 `--reindex`(同一套 `lib/skills-scan.js` 扫描核心):
30
+ 重扫技能根目录 → 增量合并进 `~/.yottaskills/registry.json`(新增 / 更新 / 消失)。
31
+ - `--no-reindex` 关闭自动重扫;`--reindex` 也可单独手动执行(会话开工 / 新装技能后)。
32
+ - 与 `--inventory` 的区别:`--inventory` 侧重「盘点展示」(文本表格 / JSON 全量),
33
+ `--reindex` 侧重「变化合并」(增量、输出聚焦新增 / 更新 / 消失,适合钩子与脚本)。
34
+
25
35
  ## 幂等与版本判断
26
36
 
27
37
  - 读取目标 `<dest>/<slug>/SKILL.md` 的 frontmatter `version`;
@@ -104,3 +104,18 @@ npx -y @yottameta/yotta-skills install --agent codex --skip-scan # 跳过装前
104
104
  - **目标未指定**:当前目录没有项目级技能目录时报错(退出码 4),加 `--agent` 或
105
105
  `--dir`。
106
106
  - **已有旧版本**:默认按 range 覆盖升级到最新 patch;`--pin` 则锁定清单版本。
107
+
108
+ ## 11. 盘点已装技能与 re-index(新装技能自动被发现)
109
+
110
+ ```bash
111
+ # 盘点本机已装技能(文本表格)
112
+ npx -y @yottameta/yotta-skills --inventory
113
+
114
+ # 重扫注册表(会话开工 / 新装技能后,增量合并变化)
115
+ npx -y @yottameta/yotta-skills --reindex
116
+ ```
117
+
118
+ - `install` / `update` 完成后会自动重扫注册表(`~/.yottaskills/registry.json`),新装 / 更新的
119
+ 技能随即出现在 `--inventory` / `--reindex` 里;`--no-reindex` 可关闭自动重扫。
120
+ - 建议每会话开工先跑一次 `--reindex`(快速增量,只合并变化),让后装的技能自动被看见。
121
+ - `--json` 输出机器可读结果(含新增 / 更新 / 消失),适合脚本与钩子。
@@ -7,7 +7,7 @@ stdio MCP server(JSON-RPC 2.0,换行分隔),把元阁技能扫描核心
7
7
  describe_skill 查看单个技能详情(slug / 版本 / 功能 / 来源)
8
8
  reindex 强制重新扫描并更新注册表
9
9
 
10
- 自包含原则:扫描由元阁自带核心(bin/yotta-skills.js --inventory)完成,
10
+ 自包含原则:扫描由元阁自带核心(bin/yotta-skills.js --inventory / --reindex)完成,
11
11
  不依赖任何元技能;数据只写本机 ~/.yottaskills/registry.json,不出本机。
12
12
 
13
13
  运行:python scripts/yotta-skills-mcp.py
@@ -23,7 +23,7 @@ import subprocess
23
23
  import sys
24
24
  from pathlib import Path
25
25
 
26
- VERSION = "0.2.0"
26
+ VERSION = "0.3.0"
27
27
  TOOL_NAME = "yotta-skills"
28
28
  CN_NAME = "元阁"
29
29
  MCP_PROTOCOL = "2025-03-26"
@@ -123,13 +123,13 @@ def _tool_describe(arguments):
123
123
 
124
124
 
125
125
  def _tool_reindex(arguments): # noqa: ARG001
126
- stdout = _run_cli(["--inventory", "--json"])
126
+ stdout = _run_cli(["--reindex", "--json"])
127
127
  try:
128
128
  data = json.loads(stdout)
129
129
  except json.JSONDecodeError as e:
130
130
  return _tool_error("reindex 输出解析失败:%s" % e)
131
131
  payload = {
132
- "count": len(data.get("skills", [])),
132
+ "count": data.get("count", len(data.get("skills", []))),
133
133
  "changes": data.get("changes"),
134
134
  "errors": data.get("errors"),
135
135
  "registry": str(REGISTRY_FILE),
@@ -163,7 +163,7 @@ def mcp_tools():
163
163
  ),
164
164
  _tool_spec(
165
165
  "reindex",
166
- "强制重新扫描所有技能目录并更新本地注册表,返回本次变化(新增 / 更新 / 消失)。",
166
+ "强制重新扫描所有技能目录并更新本地注册表,返回本次变化(新增 / 更新 / 消失);CLI 等价命令:yotta-skills --reindex。",
167
167
  {},
168
168
  [],
169
169
  ),