luminae-helper 0.0.9 → 0.0.12

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 ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.0.12
4
+
5
+ - Split the public CLI engine into its own `luminae-helper` repository.
6
+ - Load public command/skill content from `evenweiss/ai-agent-skills` at build time.
7
+ - Export `runCli()` so wrapper packages can reuse the CLI engine with their own bundled content.
package/README.md CHANGED
@@ -1,84 +1,50 @@
1
1
  # luminae-helper
2
2
 
3
- 将 AI skill 安装到本地 AI 编码工具的交互式 CLI。
3
+ Install public AI agent commands/skills into local AI coding tools.
4
4
 
5
- ## 安装
5
+ The package bundles a build-time snapshot from `evenweiss/ai-agent-skills`; runtime installation is local-only and does not fetch GitHub.
6
+
7
+ ## Install
6
8
 
7
9
  ```bash
8
- npm install -g luminae-helper
10
+ npm install -g luminae-helper --registry https://registry.npmjs.org/
9
11
  ```
10
12
 
11
- ## 使用
13
+ ## Use
12
14
 
13
15
  ```bash
14
- # 交互模式(默认)
15
16
  luminae-helper
16
-
17
- # 查看版本
18
17
  luminae-helper --version
19
- luminae-helper -v
20
-
21
- # 检查是否有新版本
22
18
  luminae-helper outdated
23
19
  ```
24
20
 
25
- ## 功能
26
-
27
- - **多选交互**:skill 和目标工具均支持 Checkbox 多选
28
- - **自动检测**:通过 `which`/`where` 检测本机已安装的 AI 工具
29
- - **安装防护**:往 SKILL.md 注入 `managed-by: luminae-helper` 标识,卸载时校验,避免误删用户文件
30
- - **失败重试**:安装失败自动重试 2 次;"不支持"等不可重试项单独汇总
31
- - **原子替换**:dir 模式安装先拷到临时目录,再 rename 替换;失败可回滚
32
-
33
- ## 支持的 AI 工具
34
-
35
- | 工具 | 命令 | commandDir | skillDir |
36
- |------|------|-----------|----------|
37
- | Claude Code | `claude` | `~/.claude/commands/` | `~/.claude/skills/` |
38
- | Codex | `codex` | — | `~/.codex/skills/` |
39
- | Cursor | `cursor` | — | `~/.cursor/skills/` |
40
- | Hermes Agent | `hermes` | — | `~/.hermes/skills/` |
41
- | OpenCode | `opencode` | — | `~/.opencode/skills/` |
42
- | Trae | `trae` | `~/.trae/commands/` | — |
43
-
44
- ## 包含的 skill
45
-
46
- 本版本包含以下通用 skill:
21
+ ## Supported tools
47
22
 
48
- - `identity` — 项目类型检测与 agent 身份设定
49
- - `git-commit` — Git commit 流程
50
- - `git-commit-msg` — Git commit message 生成
51
- - `git-push` — Git push 流程
23
+ | Tool | command source | skill source |
24
+ |---|---|---|
25
+ | Claude Code | `~/.claude/commands/` | `~/.claude/skills/` |
26
+ | Codex | — | `~/.codex/skills/` |
27
+ | Cursor | — | `~/.cursor/skills/` |
28
+ | Hermes Agent | — | `~/.hermes/skills/` |
29
+ | OpenCode | — | `~/.opencode/skills/` |
30
+ | Trae | `~/.trae/commands/` | — |
52
31
 
53
- ## 操作流程
32
+ ## Build-time skill source
54
33
 
55
- 1. 主菜单:选择 **安装** 或 **卸载**
56
- 2. 多选 skill/command(空格切换勾选,回车确认)
57
- 3. 多选目标工具(仅显示本机已安装的)
58
- 4. 预览确认
59
- 5. 执行;失败时自动重试可重试项
34
+ For local development, keep `ai-agent-skills` as a sibling directory or set:
60
35
 
61
- 任何步骤可用 Esc 返回上一步、Ctrl+C 退出。
62
-
63
- ## 安装规则
64
-
65
- 源目录决定优先安装方式,工具能力决定 fallback:
66
-
67
- | skill 源 | 工具能力 | 安装方式 |
68
- |---------|---------|---------|
69
- | `commands/` | 支持 commandDir | file 模式:`commandDir/<id>.md` |
70
- | `commands/` | 仅支持 skillDir | dir 模式(fallback):`skillDir/<id>/` |
71
- | `skills/` | 支持 skillDir | dir 模式:`skillDir/<id>/` |
72
- | `skills/` | 仅支持 commandDir | file 模式(fallback):`commandDir/<id>.md` |
73
-
74
- 例:Claude Code(双模式)→ `commands/identity` 装到 `~/.claude/commands/identity.md`。
36
+ ```bash
37
+ LUMINAE_SKILLS_SOURCE=/path/to/ai-agent-skills npm run sync-skills
38
+ ```
75
39
 
76
- ## 源码与变更
40
+ Publishing runs `scripts/fetch-skills.js --strict` and bundles `commands/` / `skills/` into the tarball.
77
41
 
78
- 源码:https://github.com/evenweiss/ai-toolkit/tree/main/tools/luminae-helper
42
+ ## Library API
79
43
 
80
- 变更日志:[CHANGELOG.md](./CHANGELOG.md)
44
+ ```js
45
+ import { runCli } from "luminae-helper";
81
46
 
82
- ## License
47
+ await runCli({ argv: process.argv.slice(2), packageRoot: import.meta.dirname });
48
+ ```
83
49
 
84
- MIT
50
+ `packageRoot` lets wrapper packages provide their own bundled `commands/` and `skills/` while reusing the CLI engine.
package/package.json CHANGED
@@ -1,22 +1,31 @@
1
1
  {
2
2
  "name": "luminae-helper",
3
- "version": "0.0.9",
4
- "description": "Install AI skills to coding tools (Claude Code, Cursor, OpenCode, Trae, etc.)",
3
+ "version": "0.0.12",
4
+ "description": "Install public AI agent skills to coding tools",
5
5
  "type": "module",
6
- "main": "src/cli.js",
6
+ "main": "src/index.js",
7
7
  "bin": {
8
8
  "luminae-helper": "src/cli.js"
9
9
  },
10
10
  "files": [
11
11
  "src/cli.js",
12
+ "src/index.js",
12
13
  "src/lib/*.js",
13
14
  "src/utils/*.js",
15
+ "scripts/fetch-skills.js",
14
16
  "commands/",
15
17
  "skills/",
16
- "README.md"
18
+ "README.md",
19
+ "CHANGELOG.md"
17
20
  ],
18
21
  "scripts": {
19
- "start": "node src/cli.js"
22
+ "start": "node src/cli.js",
23
+ "dev": "node --watch src/cli.js",
24
+ "test": "vitest run",
25
+ "sync-skills": "node scripts/fetch-skills.js",
26
+ "prepare": "node scripts/fetch-skills.js",
27
+ "prepack": "node scripts/fetch-skills.js --strict",
28
+ "prepublishOnly": "node scripts/fetch-skills.js --strict"
20
29
  },
21
30
  "keywords": [
22
31
  "claude",
@@ -24,14 +33,13 @@
24
33
  "opencode",
25
34
  "trae",
26
35
  "skills",
27
- "ai-toolkit",
36
+ "ai-agent",
28
37
  "cli"
29
38
  ],
30
39
  "license": "MIT",
31
40
  "repository": {
32
41
  "type": "git",
33
- "url": "git+https://github.com/evenweiss/ai-toolkit.git",
34
- "directory": "tools/luminae-helper"
42
+ "url": "git+https://github.com/evenweiss/luminae-helper.git"
35
43
  },
36
44
  "engines": {
37
45
  "node": ">=18.0.0"
@@ -48,7 +56,7 @@
48
56
  "devDependencies": {
49
57
  "vitest": "^4.1.6"
50
58
  },
51
- "publishConfig": {
52
- "registry": "https://registry.npmjs.org/"
59
+ "exports": {
60
+ ".": "./src/index.js"
53
61
  }
54
62
  }
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, statSync } from "node:fs";
3
+ import { execFileSync } from "node:child_process";
4
+ import { join } from "node:path";
5
+ import { tmpdir } from "node:os";
6
+
7
+ const strict = process.argv.includes("--strict");
8
+ const scriptDir = import.meta.dirname;
9
+ const packageRoot = join(scriptDir, "..");
10
+ const sourceRepo = process.env.LUMINAE_SKILLS_SOURCE || join(packageRoot, "..", "ai-agent-skills");
11
+ const remote = process.env.LUMINAE_SKILLS_REPO || "https://github.com/evenweiss/ai-agent-skills.git";
12
+ const copyDirs = ["commands", "skills"];
13
+ const skip = new Set(["node_modules", ".git", ".DS_Store", "Thumbs.db"]);
14
+
15
+ function hasSkillTree(root) {
16
+ if (!existsSync(root)) return false;
17
+ for (const name of readdirSync(root)) {
18
+ const child = join(root, name);
19
+ if (statSync(child).isDirectory() && existsSync(join(child, "SKILL.md"))) return true;
20
+ }
21
+ return false;
22
+ }
23
+
24
+ function copyDir(from, to) {
25
+ rmSync(to, { recursive: true, force: true });
26
+ if (!existsSync(from)) return false;
27
+ cpSync(from, to, {
28
+ recursive: true,
29
+ filter: (src) => !skip.has(src.split(/[/\\]/).pop()),
30
+ });
31
+ return true;
32
+ }
33
+
34
+ function resolveSource() {
35
+ if (copyDirs.some(d => hasSkillTree(join(sourceRepo, d)))) return sourceRepo;
36
+ const tmp = mkdtempSync(join(tmpdir(), "luminae-skills-"));
37
+ try {
38
+ execFileSync("git", ["clone", "--depth", "1", remote, tmp], { stdio: "inherit" });
39
+ return tmp;
40
+ } catch (e) {
41
+ rmSync(tmp, { recursive: true, force: true });
42
+ if (strict) throw e;
43
+ return null;
44
+ }
45
+ }
46
+
47
+ function main() {
48
+ const srcRoot = resolveSource();
49
+ if (!srcRoot) {
50
+ if (copyDirs.some(d => hasSkillTree(join(packageRoot, d)))) {
51
+ console.error("[fetch-skills] skipped: no source available, bundled skills already exist");
52
+ return;
53
+ }
54
+ console.warn("[fetch-skills] warning: no source available and no bundled skills found");
55
+ return;
56
+ }
57
+
58
+ let copied = 0;
59
+ for (const dir of copyDirs) {
60
+ const from = join(srcRoot, dir);
61
+ const to = join(packageRoot, dir);
62
+ if (hasSkillTree(from)) {
63
+ copyDir(from, to);
64
+ copied += 1;
65
+ console.error(`[fetch-skills] copied ${dir}: ${from} -> ${to}`);
66
+ } else {
67
+ rmSync(to, { recursive: true, force: true });
68
+ mkdirSync(to, { recursive: true });
69
+ }
70
+ }
71
+
72
+ if (strict && copied === 0) {
73
+ console.error("[fetch-skills] --strict: source contains no commands/ or skills/ entries");
74
+ process.exit(1);
75
+ }
76
+ }
77
+
78
+ main();
package/src/cli.js CHANGED
@@ -1,34 +1,8 @@
1
1
  #!/usr/bin/env node
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { runCli } from "./index.js";
2
5
 
3
- import { runInteractive, TERM_GUTTER } from "./lib/ui.js";
4
- import { printVersion, checkOutdated } from "./utils/version.js";
5
-
6
- const args = process.argv.slice(2);
7
-
8
- // --version / -v
9
- if (args.includes("--version") || args.includes("-v")) {
10
- printVersion();
11
- process.exit(0);
12
- }
13
-
14
- // outdated 子命令
15
- if (args[0] === "outdated") {
16
- await checkOutdated();
17
- process.exit(0);
18
- }
19
-
20
- // 默认:交互模式
21
- async function main() {
22
- try {
23
- await runInteractive();
24
- } catch (error) {
25
- if (error?.name === "ExitPromptError") {
26
- console.log("\n" + TERM_GUTTER + "👋 Bye!\n");
27
- process.exit(0);
28
- }
29
- console.error("\n" + TERM_GUTTER + "Error:", error.message ?? String(error));
30
- process.exit(1);
31
- }
32
- }
33
-
34
- main();
6
+ const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const code = await runCli({ argv: process.argv.slice(2), packageRoot });
8
+ process.exit(code);
package/src/index.js ADDED
@@ -0,0 +1,31 @@
1
+ export async function runCli(options = {}) {
2
+ const argv = Array.isArray(options.argv) ? options.argv : process.argv.slice(2);
3
+ if (options.packageRoot) {
4
+ globalThis.__LUMINAE_PACKAGE_ROOT__ = options.packageRoot;
5
+ }
6
+
7
+ const { runInteractive, TERM_GUTTER } = await import("./lib/ui.js");
8
+ const { printVersion, checkOutdated } = await import("./utils/version.js");
9
+
10
+ if (argv.includes("--version") || argv.includes("-v")) {
11
+ printVersion();
12
+ return 0;
13
+ }
14
+
15
+ if (argv[0] === "outdated") {
16
+ await checkOutdated();
17
+ return 0;
18
+ }
19
+
20
+ try {
21
+ await runInteractive();
22
+ return 0;
23
+ } catch (error) {
24
+ if (error?.name === "ExitPromptError") {
25
+ console.log("\n" + TERM_GUTTER + "👋 Bye!\n");
26
+ return 0;
27
+ }
28
+ console.error("\n" + TERM_GUTTER + "Error:", error.message ?? String(error));
29
+ return 1;
30
+ }
31
+ }
@@ -64,6 +64,10 @@ export const TOOLS = [
64
64
  * Package root = <luminae-helper>/
65
65
  */
66
66
  function getPackageDir() {
67
+ if (globalThis.__LUMINAE_PACKAGE_ROOT__) {
68
+ return globalThis.__LUMINAE_PACKAGE_ROOT__;
69
+ }
70
+
67
71
  const selfDir = import.meta.dirname;
68
72
  if (selfDir.endsWith("/src/lib") || selfDir.endsWith("\\src\\lib")) {
69
73
  return join(selfDir, "..", "..");
@@ -140,6 +144,7 @@ function generateInstallTargets(skillId, skillType) {
140
144
  targets.push({
141
145
  toolId: tool.id,
142
146
  installMode: "file",
147
+ conversion: null,
143
148
  destPath: () => join(tool.commandDir(), `${skillId}.md`),
144
149
  });
145
150
  } else if (supportsSkill) {
@@ -147,6 +152,7 @@ function generateInstallTargets(skillId, skillType) {
147
152
  targets.push({
148
153
  toolId: tool.id,
149
154
  installMode: "dir",
155
+ conversion: "command-to-skill",
150
156
  destPath: () => join(tool.skillDir(), skillId),
151
157
  });
152
158
  }
@@ -155,6 +161,7 @@ function generateInstallTargets(skillId, skillType) {
155
161
  targets.push({
156
162
  toolId: tool.id,
157
163
  installMode: "dir",
164
+ conversion: null,
158
165
  destPath: () => join(tool.skillDir(), skillId),
159
166
  });
160
167
  } else if (supportsCommand) {
@@ -162,6 +169,7 @@ function generateInstallTargets(skillId, skillType) {
162
169
  targets.push({
163
170
  toolId: tool.id,
164
171
  installMode: "file",
172
+ conversion: "skill-to-command",
165
173
  destPath: () => join(tool.commandDir(), `${skillId}.md`),
166
174
  });
167
175
  }
package/src/lib/ui.js CHANGED
@@ -20,6 +20,14 @@ export const TERM_GUTTER = " ";
20
20
  */
21
21
  const inquirerContext = { clearPromptOnDone: true };
22
22
 
23
+ /**
24
+ * 转换提示开关:true 时保持当前交互流程,安装前逐工具询问是否允许 fallback 转换;
25
+ * false 时用户无感知,安装阶段自动转换,仅在完成后汇总告知哪些内容发生了转换。
26
+ *
27
+ * 这是代码内开关,暂不暴露 CLI 参数或配置项,便于后续确认是否开启转换提示。
28
+ */
29
+ const SHOW_CONVERSION_CONFIRM_PROMPT = false;
30
+
23
31
  /**
24
32
  * 在关闭一个 inquirer prompt 之后、再 `printBanner` 或打开下一个 prompt 之前调用。
25
33
  * 使用 `setImmediate` 推迟到当前轮询阶段之后,让 readline 的 `close`、MuteStream 的 flush
@@ -76,6 +84,130 @@ export function parseCheckboxResult(ans) {
76
84
  return "back";
77
85
  }
78
86
 
87
+ /**
88
+ * 找出安装时会发生“源类型 != 目标工具能力”的 fallback 转换。
89
+ * @param {string[]} skillIds
90
+ * @param {string[]} toolIds
91
+ * @returns {Map<string, { tool: object, items: { skill: object, target: object }[] }>}
92
+ */
93
+ export function collectConversionFallbacks(skillIds, toolIds) {
94
+ const result = new Map();
95
+ const sids = asIdArray(skillIds);
96
+ const tids = asIdArray(toolIds);
97
+
98
+ for (const toolId of tids) {
99
+ const tool = TOOLS.find(t => t.id === toolId);
100
+ if (!tool) continue;
101
+
102
+ const items = [];
103
+ for (const skillId of sids) {
104
+ const skill = SKILLS.find(s => s.id === skillId);
105
+ if (!skill) continue;
106
+
107
+ const target = skill.installTargets?.find(tgt => tgt.toolId === toolId);
108
+ if (target?.conversion) items.push({ skill, target });
109
+ }
110
+
111
+ if (items.length > 0) result.set(toolId, { tool, items });
112
+ }
113
+
114
+ return result;
115
+ }
116
+
117
+ function conversionDescription(conversion) {
118
+ if (conversion === "command-to-skill") return "command 源 → skill 目录";
119
+ if (conversion === "skill-to-command") return "skill 源 → command 文件";
120
+ return "fallback 转换";
121
+ }
122
+
123
+ function installModeDescription(target) {
124
+ if (!target) return "未知";
125
+ if (target.conversion) return `转换:${conversionDescription(target.conversion)}`;
126
+ return target.installMode === "file" ? "原生 command 文件" : "原生 skill 目录";
127
+ }
128
+
129
+ function stripAnsi(text) {
130
+ return String(text).replace(/\x1b\[[0-9;]*m/g, "");
131
+ }
132
+
133
+ function displayWidth(text) {
134
+ const width = wcswidth(stripAnsi(text));
135
+ return width < 0 ? stripAnsi(text).length : width;
136
+ }
137
+
138
+ function padCell(text, width) {
139
+ const value = String(text);
140
+ return value + " ".repeat(Math.max(0, width - displayWidth(value)));
141
+ }
142
+
143
+ function printResultTable(title, rows) {
144
+ if (rows.length === 0) return;
145
+
146
+ const headers = ["工具", "内容", "状态", "安装方式"];
147
+ const data = rows.map(row => [row.toolName, row.skillName, row.status, row.mode]);
148
+ const widths = headers.map((header, idx) => Math.max(displayWidth(header), ...data.map(row => displayWidth(row[idx]))));
149
+ const gap = " ";
150
+ const formatRow = (cells) => TERM_GUTTER + cells.map((cell, idx) => padCell(cell, widths[idx])).join(gap);
151
+
152
+ console.log(chalk.cyan.bold(TERM_GUTTER + title));
153
+ console.log(formatRow(headers.map(header => chalk.gray(header))));
154
+ console.log(TERM_GUTTER + widths.map(width => chalk.gray("─".repeat(width))).join(gap));
155
+ for (const row of rows) {
156
+ console.log(formatRow([row.toolName, row.skillName, row.status, row.mode]));
157
+ }
158
+ console.log();
159
+ }
160
+
161
+ function mergeResultRows(...rowGroups) {
162
+ const merged = new Map();
163
+ for (const rows of rowGroups) {
164
+ for (const row of rows) merged.set(row.key, row);
165
+ }
166
+ return [...merged.values()];
167
+ }
168
+
169
+ // ── Step 3: Fallback conversion confirm(每个目标工具单独确认)──
170
+ async function stepConfirmConversionFallbacks(skillIds, toolIds) {
171
+ const fallbacks = collectConversionFallbacks(skillIds, toolIds);
172
+ const skippedKeys = new Set();
173
+
174
+ if (fallbacks.size === 0) return { action: "continue", skippedKeys };
175
+
176
+ for (const [toolId, { tool, items }] of fallbacks) {
177
+ await afterPromptFlush();
178
+ printBanner();
179
+ printSectionTitle("━━━ 兼容安装确认 ━━━");
180
+
181
+ console.log(chalk.yellow(TERM_GUTTER + `${tool.name} 不原生支持以下源类型,需要转换安装:\n`));
182
+ for (const { skill, target } of items) {
183
+ console.log(TERM_GUTTER + TERM_GUTTER + `- ${skill.name}:${conversionDescription(target.conversion)}`);
184
+ }
185
+ console.log();
186
+
187
+ const ans = await Select(
188
+ {
189
+ message: `是否允许对 ${tool.name} 使用以上兼容转换?`,
190
+ choices: [
191
+ { name: "✓ 允许转换并安装", value: "allow" },
192
+ { name: "- 跳过该工具的这些转换项", value: "skip" },
193
+ { name: "↩ 返回上一步", value: "back" },
194
+ { name: "✕ 退出", value: "exit" },
195
+ ],
196
+ theme: { prefix: chalk.cyan(" ◆"), style: { highlight: (t) => chalk.cyan(t) } },
197
+ },
198
+ inquirerContext
199
+ ).catch(() => "back");
200
+
201
+ if (ans === "back") return { action: "back", skippedKeys };
202
+ if (ans === "exit") return { action: "exit", skippedKeys };
203
+ if (ans === "skip") {
204
+ for (const { skill } of items) skippedKeys.add(`${toolId}::${skill.id}`);
205
+ }
206
+ }
207
+
208
+ return { action: "continue", skippedKeys };
209
+ }
210
+
79
211
  /**
80
212
  * 在列表末尾追加「返回 / 退出」两项(`value` 为 `__back__` / `__exit__`)。
81
213
  * 由 `checkbox-with-action-rows` 渲染为功能行:方向键移上去后按回车即触发,空格不会勾选。
@@ -227,9 +359,10 @@ async function stepPreviewConfirm(isUninstall) {
227
359
  * @param {boolean} isUninstall
228
360
  * @param {Set<string>|null} failedKeys - 若提供,只执行 key 在此集合中的组合;否则执行全部
229
361
  * key 格式: `${toolId}::${skillId}`
230
- * @returns {{ allSuccess: boolean, failedKeys: Set<string> }}
362
+ * @param {Set<string>} skippedKeys - 用户明确跳过的兼容转换项
363
+ * @returns {{ allSuccess: boolean, failedKeys: Set<string>, permanentFailedKeys: Set<string>, resultRows: object[] }}
231
364
  */
232
- async function stepExecute(skillIds, toolIds, installedTools, isUninstall, failedKeys = null) {
365
+ async function stepExecute(skillIds, toolIds, installedTools, isUninstall, failedKeys = null, skippedKeys = new Set()) {
233
366
  const sids = asIdArray(skillIds);
234
367
  const tids = asIdArray(toolIds);
235
368
  await afterPromptFlush();
@@ -242,6 +375,10 @@ async function stepExecute(skillIds, toolIds, installedTools, isUninstall, faile
242
375
  const retryableFailedKeys = new Set();
243
376
  /** 不可重试的失败(不支持、未注册等) */
244
377
  const permanentFailedKeys = new Set();
378
+ /** 本轮执行结果,用于最终表格展示 */
379
+ const resultRows = [];
380
+ const total = tids.length * sids.length;
381
+ let current = 0;
245
382
 
246
383
  for (const toolId of tids) {
247
384
  const tool = TOOLS.find(t => t.id === toolId);
@@ -251,6 +388,7 @@ async function stepExecute(skillIds, toolIds, installedTools, isUninstall, faile
251
388
  }
252
389
 
253
390
  for (const skillId of sids) {
391
+ current += 1;
254
392
  const skill = SKILLS.find(s => s.id === skillId);
255
393
  if (!skill) {
256
394
  console.log(chalk.gray(TERM_GUTTER + "- Skill " + skillId + " 未识别,跳过"));
@@ -258,12 +396,32 @@ async function stepExecute(skillIds, toolIds, installedTools, isUninstall, faile
258
396
  }
259
397
 
260
398
  const key = `${toolId}::${skillId}`;
399
+ if (skippedKeys.has(key)) {
400
+ const target = skill.installTargets?.find(tgt => tgt.toolId === toolId);
401
+ const reason = target?.conversion ? conversionDescription(target.conversion) : "用户跳过";
402
+ resultRows.push({
403
+ key,
404
+ toolName: tool.name,
405
+ skillName: skill.name,
406
+ status: chalk.gray("已跳过"),
407
+ mode: target?.conversion ? `跳过转换:${reason}` : "用户跳过",
408
+ });
409
+ continue;
410
+ }
261
411
  // 如果是重试模式,只执行之前失败的组合
262
412
  if (failedKeys && !failedKeys.has(key)) continue;
263
413
 
264
- const supported = skill.installTargets?.some(tgt => tgt.toolId === toolId);
265
- if (!supported) {
266
- console.log(chalk.yellow(TERM_GUTTER + "- " + skill.name + " × " + tool.name + " (不支持,跳过)"));
414
+ console.log(chalk.gray(TERM_GUTTER + `正在${isUninstall ? "卸载" : "安装"} ${current}/${total}:${skill.name} → ${tool.name}`));
415
+
416
+ const target = skill.installTargets?.find(tgt => tgt.toolId === toolId);
417
+ if (!target) {
418
+ resultRows.push({
419
+ key,
420
+ toolName: tool.name,
421
+ skillName: skill.name,
422
+ status: chalk.yellow("不支持"),
423
+ mode: "不适用",
424
+ });
267
425
  allSuccess = false;
268
426
  permanentFailedKeys.add(key);
269
427
  continue;
@@ -272,9 +430,21 @@ async function stepExecute(skillIds, toolIds, installedTools, isUninstall, faile
272
430
  if (isUninstall) {
273
431
  const result = uninstallSkillFromTool(skill, tool);
274
432
  if (result.success) {
275
- console.log(chalk.green(TERM_GUTTER + "✓ " + skill.name + " - " + tool.name));
433
+ resultRows.push({
434
+ key,
435
+ toolName: tool.name,
436
+ skillName: skill.name,
437
+ status: chalk.green("已卸载"),
438
+ mode: installModeDescription(target),
439
+ });
276
440
  } else {
277
- console.log(chalk.yellow(TERM_GUTTER + "- " + skill.name + " - " + tool.name + " (" + result.message + ")"));
441
+ resultRows.push({
442
+ key,
443
+ toolName: tool.name,
444
+ skillName: skill.name,
445
+ status: chalk.yellow("未卸载"),
446
+ mode: result.message,
447
+ });
278
448
  allSuccess = false;
279
449
  // "未安装" 不可重试,"非本工具安装" 也不可重试
280
450
  permanentFailedKeys.add(key);
@@ -282,9 +452,21 @@ async function stepExecute(skillIds, toolIds, installedTools, isUninstall, faile
282
452
  } else {
283
453
  const result = installSkillToTool(skill, tool);
284
454
  if (result.success) {
285
- console.log(chalk.green(TERM_GUTTER + "✓ " + skill.name + " → " + tool.name));
455
+ resultRows.push({
456
+ key,
457
+ toolName: tool.name,
458
+ skillName: skill.name,
459
+ status: chalk.green("已安装"),
460
+ mode: installModeDescription(target),
461
+ });
286
462
  } else {
287
- console.log(chalk.red(TERM_GUTTER + "✗ " + skill.name + " → " + tool.name + ": " + result.message));
463
+ resultRows.push({
464
+ key,
465
+ toolName: tool.name,
466
+ skillName: skill.name,
467
+ status: chalk.red("失败"),
468
+ mode: result.message,
469
+ });
288
470
  allSuccess = false;
289
471
  // 安装失败可能是临时 I/O 问题,可重试
290
472
  retryableFailedKeys.add(key);
@@ -303,7 +485,7 @@ async function stepExecute(skillIds, toolIds, installedTools, isUninstall, faile
303
485
  console.log(chalk.yellow(TERM_GUTTER + `⚠ 部分操作失败(${parts.join(",")}),请检查错误信息。\n`));
304
486
  }
305
487
 
306
- return { allSuccess, failedKeys: retryableFailedKeys, permanentFailedKeys };
488
+ return { allSuccess, failedKeys: retryableFailedKeys, permanentFailedKeys, resultRows };
307
489
  }
308
490
 
309
491
  // ── Unified flow (install / uninstall) ──
@@ -332,6 +514,7 @@ async function runFlow(isUninstall) {
332
514
  let step = 1;
333
515
  let selectedSkillIds = null;
334
516
  let selectedToolIds = null;
517
+ let skippedConversionKeys = new Set();
335
518
 
336
519
  while (true) {
337
520
  if (step === 1) {
@@ -345,15 +528,23 @@ async function runFlow(isUninstall) {
345
528
  if (result === "back") { step = 1; continue; }
346
529
  if (result === "exit") return "exit";
347
530
  selectedToolIds = result;
531
+ skippedConversionKeys = new Set();
348
532
  step = 3;
349
533
  } else if (step === 3) {
350
534
  const result = await stepPreviewConfirm(isUninstall);
351
535
  if (result === "back") { step = 2; continue; }
352
536
  if (result === "exit") return "exit";
537
+ if (!isUninstall && SHOW_CONVERSION_CONFIRM_PROMPT) {
538
+ const fallbackResult = await stepConfirmConversionFallbacks(selectedSkillIds, selectedToolIds);
539
+ if (fallbackResult.action === "back") { step = 2; continue; }
540
+ if (fallbackResult.action === "exit") return "exit";
541
+ skippedConversionKeys = fallbackResult.skippedKeys;
542
+ }
353
543
  step = 4;
354
544
  } else if (step === 4) {
355
- const { allSuccess, failedKeys, permanentFailedKeys } = await stepExecute(selectedSkillIds, selectedToolIds, installedTools, isUninstall);
545
+ const { allSuccess, failedKeys, permanentFailedKeys, resultRows } = await stepExecute(selectedSkillIds, selectedToolIds, installedTools, isUninstall, null, skippedConversionKeys);
356
546
  if (allSuccess) {
547
+ printResultTable(isUninstall ? "卸载结果" : "安装结果", resultRows);
357
548
  await input(
358
549
  {
359
550
  message: "按任意键退出...",
@@ -369,16 +560,19 @@ async function runFlow(isUninstall) {
369
560
  let retrySuccess = false;
370
561
  let retryFailedKeys = failedKeys;
371
562
  let accumulatedPermanent = new Set(permanentFailedKeys);
563
+ let accumulatedResultRows = [...resultRows];
372
564
  while (attempt < 3) {
373
565
  console.log(chalk.yellow(TERM_GUTTER + `第 ${attempt} 次重试(${retryFailedKeys.size} 项)...\n`));
374
- const retryResult = await stepExecute(selectedSkillIds, selectedToolIds, installedTools, isUninstall, retryFailedKeys);
566
+ const retryResult = await stepExecute(selectedSkillIds, selectedToolIds, installedTools, isUninstall, retryFailedKeys, skippedConversionKeys);
375
567
  retrySuccess = retryResult.allSuccess;
376
568
  retryFailedKeys = retryResult.failedKeys;
569
+ accumulatedResultRows = mergeResultRows(accumulatedResultRows, retryResult.resultRows);
377
570
  for (const k of retryResult.permanentFailedKeys) accumulatedPermanent.add(k);
378
571
  if (retrySuccess) break;
379
572
  attempt++;
380
573
  }
381
574
  if (retrySuccess && accumulatedPermanent.size === 0) {
575
+ printResultTable("安装结果", accumulatedResultRows);
382
576
  await input(
383
577
  {
384
578
  message: "按任意键退出...",
@@ -389,6 +583,7 @@ async function runFlow(isUninstall) {
389
583
  return "exit";
390
584
  } else if (retrySuccess && accumulatedPermanent.size > 0) {
391
585
  // 重试成功但仍有不可重试的失败项(如"不支持")
586
+ printResultTable("安装结果", accumulatedResultRows);
392
587
  console.log(chalk.yellow(TERM_GUTTER + `⚠ ${accumulatedPermanent.size} 项不可重试的操作已跳过(不支持或非本工具安装)\n`));
393
588
  await input(
394
589
  {
@@ -401,6 +596,7 @@ async function runFlow(isUninstall) {
401
596
  }
402
597
  } else if (permanentFailedKeys.size > 0 && failedKeys.size === 0) {
403
598
  // 全部是 permanent 失败,无重试价值
599
+ printResultTable(isUninstall ? "卸载结果" : "安装结果", resultRows);
404
600
  console.log(chalk.yellow(TERM_GUTTER + `⚠ ${permanentFailedKeys.size} 项操作不可执行(不支持或非本工具安装),已跳过\n`));
405
601
  await input(
406
602
  {
@@ -411,6 +607,7 @@ async function runFlow(isUninstall) {
411
607
  ).catch(() => {});
412
608
  return "back";
413
609
  }
610
+ printResultTable(isUninstall ? "卸载结果" : "安装结果", resultRows);
414
611
  console.log(chalk.red(TERM_GUTTER + "❌ 操作未能全部成功,请手动检查。\n"));
415
612
  await input(
416
613
  {
@@ -460,5 +657,5 @@ export async function runInteractive() {
460
657
  }
461
658
 
462
659
  console.log(chalk.gray("\n" + TERM_GUTTER + "👋 Bye!\n"));
463
- process.exit(0);
660
+ return;
464
661
  }
@@ -10,7 +10,8 @@ export const TERM_GUTTER = " ";
10
10
  * package.json 在 <package>/,需要上跳两级
11
11
  */
12
12
  function readPackageJson() {
13
- const pkgPath = join(import.meta.dirname, "..", "..", "package.json");
13
+ const packageRoot = globalThis.__LUMINAE_PACKAGE_ROOT__ || join(import.meta.dirname, "..", "..");
14
+ const pkgPath = join(packageRoot, "package.json");
14
15
  return JSON.parse(readFileSync(pkgPath, "utf-8"));
15
16
  }
16
17