skillmkt 0.4.7 → 0.4.9

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.
@@ -92,18 +92,40 @@ export async function run(ctx) {
92
92
  // 密钥:只在需要时问;粘贴的密钥用本机机器码加密存 config.yml
93
93
  let api_key = null, keyPlain = '';
94
94
  if (base_url && needKey) {
95
+ // 只列当前 shell 真设了的环境变量,加自填项——不再硬塞用户看不懂的名字
96
+ const envCands = ['SKILLMKT_API_KEY', 'OPENAI_API_KEY', 'OMLX_API_KEY'].filter((v) => process.env[v]);
95
97
  const ks = await choose(L('这个服务需要访问密钥,怎么提供?', 'This service needs an access key — how should it be provided?'), [
96
98
  { label: L('现在粘贴进来(只输一次,自动加密保存)', 'Paste it now (entered once, saved encrypted)'), v: 'paste' },
97
- { label: L('从环境变量 SKILLMKT_API_KEY 读(key 已在 shell 里时选)', 'Read env var SKILLMKT_API_KEY (if the key is already in your shell)'), v: 'env:SKILLMKT_API_KEY' },
98
- { label: L('从环境变量 OMLX_API_KEY 读', 'Read env var OMLX_API_KEY'), v: 'env:OMLX_API_KEY' },
99
+ ...envCands.map((v) => ({ label: L(`从环境变量 ${v} 读(当前 shell 已设置)`, `Read env var ${v} (set in this shell)`), v: `env:${v}` })),
100
+ { label: L('从别的环境变量读(自己填变量名)', 'Read another env var (type the name yourself)'), v: 'env-custom' },
99
101
  { label: L('不需要密钥', 'No key needed'), v: null },
100
102
  ]);
101
103
  if (ks.v === 'paste') {
102
- keyPlain = (await askSecret(L(' 密钥 > ', ' Key > '))).trim();
103
- if (keyPlain) api_key = encryptSecret(keyPlain);
104
- } else if (ks.v) api_key = ks.v;
105
- if (!keyPlain && api_key?.startsWith('env:')) keyPlain = process.env[api_key.slice(4)] ?? '';
106
- if (keyPlain) { try { models = await listModels(base_url, keyPlain); } catch { /* 密钥无效→手填模型 */ } }
104
+ for (;;) { // 粘贴后真验证:错密钥报"密钥错误"可重输,对了才放行
105
+ keyPlain = (await askSecret(L(' 密钥 > ', ' Key > '))).trim();
106
+ if (!keyPlain) break; // 留空放弃
107
+ try {
108
+ models = await listModels(base_url, keyPlain);
109
+ api_key = encryptSecret(keyPlain);
110
+ ok(L(`密钥有效,已加载 ${models.length} 个模型`, `Key valid — loaded ${models.length} models`));
111
+ break;
112
+ } catch (e) {
113
+ warn(L(`密钥错误(${e.message})——重输,或留空改手填`, `Wrong key (${e.message}) — re-enter, or leave empty to type the model yourself`));
114
+ keyPlain = '';
115
+ }
116
+ }
117
+ } else if (ks.v) {
118
+ const vn = ks.v === 'env-custom' ? (await ask(L(' 环境变量名 > ', ' Env var name > '))).trim() : ks.v.slice(4);
119
+ if (vn) {
120
+ api_key = `env:${vn}`;
121
+ keyPlain = process.env[vn] ?? '';
122
+ if (!keyPlain) warn(L(`环境变量 ${vn} 现在没设置——配置照存,export 之后就能用`, `env var ${vn} is not set — config saved anyway; works once you export it`));
123
+ else {
124
+ try { models = await listModels(base_url, keyPlain); }
125
+ catch (e) { warn(L(`用 ${vn} 验证失败(${e.message})——配置照存,模型手填`, `key in ${vn} failed verification (${e.message}) — config saved anyway, type the model manually`)); }
126
+ }
127
+ }
128
+ }
107
129
  }
108
130
 
109
131
  // 模型:拉到了就列出来选,拉不到手填
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillmkt",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "type": "module",
5
5
  "description": "Local-first agent skill manager: install, audit, merge, distribute.",
6
6
  "license": "MIT",