skillmkt 0.4.1 → 0.4.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/init.js +5 -4
- package/client/lib/prompt.js +9 -0
- package/package.json +1 -1
package/client/commands/init.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import { ensureHub, writeConfig, readConfig } from '../lib/hub.js';
|
|
4
4
|
import { probeEndpoints, chat } from '../lib/llm.js';
|
|
5
5
|
import { openURL, readDaemon, pidAlive } from '../lib/daemon.js';
|
|
6
|
-
import { choose, confirm } from '../lib/prompt.js';
|
|
6
|
+
import { choose, confirm, ask } from '../lib/prompt.js';
|
|
7
7
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
8
8
|
import { L } from '../lib/i18n.js';
|
|
9
9
|
|
|
@@ -64,14 +64,15 @@ export async function run(ctx) {
|
|
|
64
64
|
}
|
|
65
65
|
const sel = await choose(L('选择模型端点:', 'Choose a model endpoint:'), opts);
|
|
66
66
|
if (sel.v === 'manual') {
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
base_url = (await ask(L(' 服务地址 > ', ' Service URL > '))).trim() || null;
|
|
68
|
+
if (base_url) model = (await ask(L(' 模型名称 > ', ' Model name > '))).trim() || null;
|
|
69
69
|
} else if (sel.v !== 'skip') {
|
|
70
70
|
({ base_url, model } = sel.v);
|
|
71
71
|
}
|
|
72
72
|
} else {
|
|
73
73
|
info(L('未发现本地 LLM 服务(已扫本机所有监听端口)', 'No local LLM service found (all listening ports probed)'));
|
|
74
|
-
|
|
74
|
+
base_url = (await ask(L(' 服务地址(留空跳过)> ', ' Service URL (empty to skip) > '))).trim() || null;
|
|
75
|
+
if (base_url) model = (await ask(L(' 模型名称 > ', ' Model name > '))).trim() || null;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
// API key 环境变量引用(不存真值)
|
package/client/lib/prompt.js
CHANGED
|
@@ -22,6 +22,15 @@ export async function choose(question, options) {
|
|
|
22
22
|
return options[n - 1] ?? options[0];
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// 自由文本输入(非 TTY 返回空串)
|
|
26
|
+
export async function ask(question) {
|
|
27
|
+
if (!process.stdin.isTTY) return '';
|
|
28
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
29
|
+
const ans = await new Promise((res) => rl.question(question, res));
|
|
30
|
+
rl.close();
|
|
31
|
+
return ans;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
// 多选:序号逗号/空格分隔;回车=保持预勾选;0/none=全不选。返回选中的下标数组
|
|
26
35
|
export async function multiChoose(question, options, { checked = [] } = {}) {
|
|
27
36
|
if (!process.stdin.isTTY) return checked;
|