skillmkt 0.3.1 → 0.3.2
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/client/commands/install.js +19 -2
- package/client/lib/prompt.js +15 -0
- package/package.json +1 -1
|
@@ -8,8 +8,9 @@ import { fetchRef } from '../lib/registries/index.js';
|
|
|
8
8
|
import { auditDir, stripFilter, writeScan } from '../lib/audit.js';
|
|
9
9
|
import { readSkillDir, copyDir, rmDir, walk, treeHash } from '../lib/package.js';
|
|
10
10
|
import { projectSkill, resolveTargets } from '../lib/project.js';
|
|
11
|
+
import { primaryDir } from '../lib/scanner.js';
|
|
11
12
|
import { cacheLookup } from '../lib/state.js';
|
|
12
|
-
import { confirm } from '../lib/prompt.js';
|
|
13
|
+
import { confirm, multiChoose } from '../lib/prompt.js';
|
|
13
14
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
14
15
|
|
|
15
16
|
// 来源取证:.git remote → skills-lock.json → .market-skills.json → frontmatter
|
|
@@ -128,10 +129,26 @@ export async function run(ctx) {
|
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
// ④ 投影目标:收编默认仅原 harness;其余 --to/--target/default_targets(空则全部 installed)
|
|
131
|
-
|
|
132
|
+
let targets = adopted && !flags.target
|
|
132
133
|
? [{ id: adopted.harnessId, dir: path.dirname(adopted.from), mode: 'copy' }]
|
|
133
134
|
: resolveTargets(ctx, { allowAdopted: ctx.harnesses.filter((h) => h.state === 'installed').map((h) => h.id) });
|
|
134
135
|
|
|
136
|
+
// TTY 自选:未显式 --to/--target/--scope/--yes 且非收编 → 候选=解析结果∪全部可投影 agent,预勾选=解析结果
|
|
137
|
+
if (ctx.tty && !ctx.flags.yes && !flags.to && !flags.target && !flags.scope && !adopted) {
|
|
138
|
+
const pool = [...targets];
|
|
139
|
+
const have = new Set(pool.map((t) => t.id));
|
|
140
|
+
for (const h of ctx.harnesses) {
|
|
141
|
+
if (h.detectOnly || h.state === 'absent' || have.has(h.id)) continue;
|
|
142
|
+
const dir = primaryDir(h);
|
|
143
|
+
if (dir) pool.push({ id: h.id, dir, mode: 'copy' });
|
|
144
|
+
}
|
|
145
|
+
if (pool.length) {
|
|
146
|
+
const checked = pool.map((_, i) => i).slice(0, targets.length);
|
|
147
|
+
const idx = await multiChoose(`装到哪些位置?`, pool.map((t) => `${t.id} → ${t.dir}`), { checked });
|
|
148
|
+
targets = idx.map((i) => pool[i]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
135
152
|
// ⑤ 投影 + lock
|
|
136
153
|
const results = [];
|
|
137
154
|
const lockTargets = {};
|
package/client/lib/prompt.js
CHANGED
|
@@ -20,3 +20,18 @@ export async function choose(question, options) {
|
|
|
20
20
|
const n = parseInt(ans, 10);
|
|
21
21
|
return options[n - 1] ?? options[0];
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
// 多选:序号逗号/空格分隔;回车=保持预勾选;0/none=全不选。返回选中的下标数组
|
|
25
|
+
export async function multiChoose(question, options, { checked = [] } = {}) {
|
|
26
|
+
if (!process.stdin.isTTY) return checked;
|
|
27
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
28
|
+
process.stderr.write(`${question}(序号逗号分隔,回车=当前勾选,0=全不装)\n`);
|
|
29
|
+
options.forEach((o, i) => process.stderr.write(` ${checked.includes(i) ? '[x]' : '[ ]'} ${i + 1}. ${o.label || o}\n`));
|
|
30
|
+
const ans = await new Promise((res) => rl.question('> ', res));
|
|
31
|
+
rl.close();
|
|
32
|
+
const t = ans.trim().toLowerCase();
|
|
33
|
+
if (!t) return checked;
|
|
34
|
+
if (t === '0' || t === 'none') return [];
|
|
35
|
+
const idx = t.split(/[,\s]+/).map((x) => parseInt(x, 10) - 1).filter((i) => i >= 0 && i < options.length);
|
|
36
|
+
return [...new Set(idx)];
|
|
37
|
+
}
|