istarshine 1.2.2 → 1.2.4
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/bin/cli.js +1 -1
- package/lib/install.js +41 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
package/lib/install.js
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { fetch_json, download_file } from './api.js';
|
|
8
|
-
import { readFileSync, mkdirSync, existsSync } from 'fs';
|
|
8
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
9
9
|
import { join, resolve } from 'path';
|
|
10
|
+
import { homedir } from 'os';
|
|
10
11
|
import { extract_zip } from './zip.js';
|
|
11
12
|
import { resolve_api_key } from './config.js';
|
|
12
13
|
import { resolve_install_queue } from './deps.js';
|
|
@@ -80,7 +81,12 @@ async function install_single_skill(skill_name, options, auth_headers, chalk, in
|
|
|
80
81
|
console.log(chalk.yellow(` ⚠ ${auth_warning}`));
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
// 5.
|
|
84
|
+
// 5. 配置 openclaw.json 中该 skill 的 apiKey SecretRef 引用
|
|
85
|
+
if (api_key) {
|
|
86
|
+
setup_skill_entry(skill_name, chalk);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 6. 检查 SKILL.md 中的认证声明
|
|
84
90
|
check_skill_auth_declaration(target_dir, api_key, chalk);
|
|
85
91
|
}
|
|
86
92
|
|
|
@@ -174,6 +180,39 @@ export async function install_skill(skill_name, options) {
|
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
182
|
|
|
183
|
+
/**
|
|
184
|
+
* 在 openclaw.json 的 skills.entries 中配置该 skill 的 apiKey SecretRef 引用
|
|
185
|
+
* 仅写 entries,secrets 和 provider 由 config --api-key 负责
|
|
186
|
+
*
|
|
187
|
+
* @param {string} skill_name - skill 名称
|
|
188
|
+
* @param {object} chalk - chalk 实例
|
|
189
|
+
*/
|
|
190
|
+
function setup_skill_entry(skill_name, chalk) {
|
|
191
|
+
const config_path = join(homedir(), '.openclaw', 'openclaw.json');
|
|
192
|
+
|
|
193
|
+
if (!existsSync(config_path)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
const config = JSON.parse(readFileSync(config_path, 'utf8'));
|
|
199
|
+
|
|
200
|
+
if (!config.skills) config.skills = {};
|
|
201
|
+
if (!config.skills.entries) config.skills.entries = {};
|
|
202
|
+
if (!config.skills.entries[skill_name]) config.skills.entries[skill_name] = {};
|
|
203
|
+
config.skills.entries[skill_name].apiKey = {
|
|
204
|
+
source: 'file',
|
|
205
|
+
provider: 'filemain',
|
|
206
|
+
id: '/skills/istarshine/apiKey'
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
writeFileSync(config_path, JSON.stringify(config, null, 2), 'utf8');
|
|
210
|
+
console.log(chalk.green(' ✔ skills.entries.' + skill_name + '.apiKey → SecretRef'));
|
|
211
|
+
} catch (err) {
|
|
212
|
+
console.log(chalk.yellow(` ⚠ SecretRef entries 配置失败: ${err.message}`));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
177
216
|
/**
|
|
178
217
|
* 检查解压后的 SKILL.md 是否包含 api.auth 或 metadata.openclaw 声明
|
|
179
218
|
* 如果包含且未配置 API Key,输出配置引导提示
|