luminae-helper 0.0.8 → 0.0.10
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/README.md +63 -49
- package/package.json +1 -1
- package/src/lib/constants.js +4 -0
- package/src/lib/ui.js +209 -12
package/README.md
CHANGED
|
@@ -1,70 +1,84 @@
|
|
|
1
1
|
# luminae-helper
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## 功能
|
|
6
|
-
|
|
7
|
-
- **多选交互**:Skill 和目标工具均支持 Checkbox 多选
|
|
8
|
-
- **自动检测**:自动检测本机已安装的 AI 工具
|
|
9
|
-
- **导航支持**:每个步骤均支持返回上一步和退出
|
|
10
|
-
- Checkbox 步骤:Esc 返回上一步,Ctrl+C 退出
|
|
11
|
-
- 预览确认步骤:显式选项(确认/返回/退出)
|
|
12
|
-
- **安装/卸载**:支持安装和卸载操作
|
|
13
|
-
|
|
14
|
-
## 支持的工具
|
|
15
|
-
|
|
16
|
-
| 工具 | 命令 | Skill 安装方式 |
|
|
17
|
-
|------|------|---------------|
|
|
18
|
-
| Claude Code | `claude` | `~/.claude/commands/<skill>.md` |
|
|
19
|
-
| Cursor | `cursor` | `~/.cursor/commands/<skill>.md` |
|
|
20
|
-
| OpenCode | `opencode` | `~/.opencode/skills/<skill>/` (目录) |
|
|
21
|
-
| Trae | `trae` | `~/.trae/commands/<skill>.md` |
|
|
22
|
-
| OpenClaw | `openclaw` | `~/.openclaw/skills/<skill>/` (目录) |
|
|
23
|
-
| Nanobot | `nanobot` | `~/.nanobot/skills/<skill>/` (目录) |
|
|
24
|
-
| Hermes Agent | `hermes` | `~/.hermes/skills/<skill>/` (目录) |
|
|
25
|
-
| ZeroClaw | `zeroclaw` | `~/.zeroclaw/skills/<skill>/` (目录) |
|
|
3
|
+
将 AI skill 安装到本地 AI 编码工具的交互式 CLI。
|
|
26
4
|
|
|
27
5
|
## 安装
|
|
28
6
|
|
|
29
7
|
```bash
|
|
30
|
-
|
|
31
|
-
cd tools/luminae-helper
|
|
32
|
-
|
|
33
|
-
# 安装依赖
|
|
34
|
-
npm install
|
|
35
|
-
|
|
36
|
-
# 链接到全局(可选)
|
|
37
|
-
npm link
|
|
8
|
+
npm install -g luminae-helper
|
|
38
9
|
```
|
|
39
10
|
|
|
40
11
|
## 使用
|
|
41
12
|
|
|
42
13
|
```bash
|
|
43
|
-
#
|
|
44
|
-
node src/cli.js
|
|
45
|
-
|
|
46
|
-
# 或链接后
|
|
14
|
+
# 交互模式(默认)
|
|
47
15
|
luminae-helper
|
|
16
|
+
|
|
17
|
+
# 查看版本
|
|
18
|
+
luminae-helper --version
|
|
19
|
+
luminae-helper -v
|
|
20
|
+
|
|
21
|
+
# 检查是否有新版本
|
|
22
|
+
luminae-helper outdated
|
|
48
23
|
```
|
|
49
24
|
|
|
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:
|
|
47
|
+
|
|
48
|
+
- `identity` — 项目类型检测与 agent 身份设定
|
|
49
|
+
- `git-commit` — Git commit 流程
|
|
50
|
+
- `git-commit-msg` — Git commit message 生成
|
|
51
|
+
- `git-push` — Git push 流程
|
|
52
|
+
|
|
50
53
|
## 操作流程
|
|
51
54
|
|
|
52
|
-
1.
|
|
53
|
-
2. 多选
|
|
54
|
-
3.
|
|
55
|
-
4.
|
|
56
|
-
5.
|
|
55
|
+
1. 主菜单:选择 **安装** 或 **卸载**
|
|
56
|
+
2. 多选 skill/command(空格切换勾选,回车确认)
|
|
57
|
+
3. 多选目标工具(仅显示本机已安装的)
|
|
58
|
+
4. 预览确认
|
|
59
|
+
5. 执行;失败时自动重试可重试项
|
|
60
|
+
|
|
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`。
|
|
57
75
|
|
|
58
|
-
|
|
59
|
-
- Checkbox 步骤:列表底部显示导航项(灰显,不可勾选),Esc 返回上一步,Ctrl+C 退出
|
|
60
|
-
- 确认步骤:显式选择「返回上一步」或「退出」
|
|
76
|
+
## 源码与变更
|
|
61
77
|
|
|
62
|
-
|
|
78
|
+
源码:https://github.com/evenweiss/ai-toolkit/tree/main/tools/luminae-helper
|
|
63
79
|
|
|
64
|
-
|
|
65
|
-
2. 在 `tools/luminae-helper` 下执行 `npm install` 或 `npm run sync-skills`,会把根目录 `skills/` 同步到本包内的 `skills/`(该目录已 `.gitignore`,勿在包内手改副本)。
|
|
66
|
-
3. Skill 元数据与安装目标由 `src/lib/constants.js` 的 `discoverSkills()` 自动扫描包内 `skills/` 生成,一般无需再手写 `SKILLS` 数组。
|
|
80
|
+
变更日志:[CHANGELOG.md](./CHANGELOG.md)
|
|
67
81
|
|
|
68
|
-
##
|
|
82
|
+
## License
|
|
69
83
|
|
|
70
|
-
|
|
84
|
+
MIT
|
package/package.json
CHANGED
package/src/lib/constants.js
CHANGED
|
@@ -140,6 +140,7 @@ function generateInstallTargets(skillId, skillType) {
|
|
|
140
140
|
targets.push({
|
|
141
141
|
toolId: tool.id,
|
|
142
142
|
installMode: "file",
|
|
143
|
+
conversion: null,
|
|
143
144
|
destPath: () => join(tool.commandDir(), `${skillId}.md`),
|
|
144
145
|
});
|
|
145
146
|
} else if (supportsSkill) {
|
|
@@ -147,6 +148,7 @@ function generateInstallTargets(skillId, skillType) {
|
|
|
147
148
|
targets.push({
|
|
148
149
|
toolId: tool.id,
|
|
149
150
|
installMode: "dir",
|
|
151
|
+
conversion: "command-to-skill",
|
|
150
152
|
destPath: () => join(tool.skillDir(), skillId),
|
|
151
153
|
});
|
|
152
154
|
}
|
|
@@ -155,6 +157,7 @@ function generateInstallTargets(skillId, skillType) {
|
|
|
155
157
|
targets.push({
|
|
156
158
|
toolId: tool.id,
|
|
157
159
|
installMode: "dir",
|
|
160
|
+
conversion: null,
|
|
158
161
|
destPath: () => join(tool.skillDir(), skillId),
|
|
159
162
|
});
|
|
160
163
|
} else if (supportsCommand) {
|
|
@@ -162,6 +165,7 @@ function generateInstallTargets(skillId, skillType) {
|
|
|
162
165
|
targets.push({
|
|
163
166
|
toolId: tool.id,
|
|
164
167
|
installMode: "file",
|
|
168
|
+
conversion: "skill-to-command",
|
|
165
169
|
destPath: () => join(tool.commandDir(), `${skillId}.md`),
|
|
166
170
|
});
|
|
167
171
|
}
|
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
|
-
* @
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
{
|