skillmkt 0.4.1 → 0.4.3

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.
@@ -3,9 +3,9 @@ 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
- import { L } from '../lib/i18n.js';
8
+ import { L, lang, setUILang } from '../lib/i18n.js';
9
9
 
10
10
  export async function run(ctx) {
11
11
  ensureHub(ctx.hub);
@@ -15,11 +15,23 @@ export async function run(ctx) {
15
15
  }
16
16
 
17
17
  // 首问:初始化形态(写 ui.enabled——§3.11 自动接管与裸跑形态听它的)
18
- const mode = ctx.flags.ui === 'force' ? 'web' : ctx.flags.ui === 'off' ? 'cli'
19
- : (await choose(L('初始化方式?', 'Init method?'), [
20
- { label: L('Web 面板(推荐——探测结果、模型列表、harness 勾选可视化)', 'Web panel (recommended — visual probe results, model list, agent checkboxes)'), v: 'web' },
21
- { label: L('终端向导(纯键盘,SSH/无浏览器环境)', 'Terminal wizard (keyboard-only, for SSH/no-browser setups)'), v: 'cli' },
22
- ])).v;
18
+ let mode = ctx.flags.ui === 'force' ? 'web' : ctx.flags.ui === 'off' ? 'cli' : null;
19
+ while (!mode) {
20
+ const sel = await choose(L('初始化方式?', 'Init method?'), [
21
+ { label: L('Web 面板(推荐——探测结果、模型列表、harness 勾选可视化)', 'Web panel (recommended — visual probe results, model list, agent checkboxes)'), v: 'web' },
22
+ { label: L('终端向导(纯键盘,SSH/无浏览器环境)', 'Terminal wizard (keyboard-only, for SSH/no-browser setups)'), v: 'cli' },
23
+ { label: L('切换语言 / Switch language', 'Switch language / 切换语言'), v: 'lang' },
24
+ ]);
25
+ if (sel.v === 'lang') { // 立刻 zh↔en:写 config + 换语言重问
26
+ const next = lang() === 'zh' ? 'en' : 'zh';
27
+ const r = readConfig(ctx.hub)._raw;
28
+ r.ui = { ...(r.ui || {}), lang: next };
29
+ writeConfig(ctx.hub, r);
30
+ setUILang(next);
31
+ continue;
32
+ }
33
+ mode = sel.v;
34
+ }
23
35
 
24
36
  const raw = readConfig(ctx.hub)._raw;
25
37
  raw.ui = { ...(raw.ui || {}), enabled: mode === 'web' ? 'always' : 'auto' };
@@ -64,14 +76,15 @@ export async function run(ctx) {
64
76
  }
65
77
  const sel = await choose(L('选择模型端点:', 'Choose a model endpoint:'), opts);
66
78
  if (sel.v === 'manual') {
67
- // 手动输入交给 config set 提示
68
- info('→ skillmkt config set llm.base_url <url> && skillmkt config set llm.model <id>');
79
+ base_url = (await ask(L(' 服务地址 > ', ' Service URL > '))).trim() || null;
80
+ if (base_url) model = (await ask(L(' 模型名称 > ', ' Model name > '))).trim() || null;
69
81
  } else if (sel.v !== 'skip') {
70
82
  ({ base_url, model } = sel.v);
71
83
  }
72
84
  } else {
73
85
  info(L('未发现本地 LLM 服务(已扫本机所有监听端口)', 'No local LLM service found (all listening ports probed)'));
74
- info('→ skillmkt config set llm.base_url http://host:port/v1');
86
+ base_url = (await ask(L(' 服务地址(留空跳过)> ', ' Service URL (empty to skip) > '))).trim() || null;
87
+ if (base_url) model = (await ask(L(' 模型名称 > ', ' Model name > '))).trim() || null;
75
88
  }
76
89
 
77
90
  // API key 环境变量引用(不存真值)
package/client/lib/hub.js CHANGED
@@ -23,6 +23,7 @@ export function hubExists(hub) {
23
23
 
24
24
  export function ensureHub(hub) {
25
25
  for (const d of SUBDIRS) fs.mkdirSync(path.join(hub, d), { recursive: true });
26
+ if (!fs.existsSync(F(hub, 'library.yml'))) writeYAMLFile(F(hub, 'library.yml'), { version: 1, skills: {} }); // 让 hubExists 对"只初始化没装过"的 hub 也成立
26
27
  return hub;
27
28
  }
28
29
 
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillmkt",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "description": "Local-first agent skill manager: install, audit, merge, distribute.",
6
6
  "license": "MIT",