skillfree 0.1.38 → 0.1.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillfree",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "description": "🦞 一个 API,满足所有龙虾技能需求",
5
5
  "main": "bin/skillfree.js",
6
6
  "bin": {
package/postinstall.js CHANGED
@@ -58,8 +58,18 @@ function injectOpenclawConfig(apiKey) {
58
58
  if (!fs.existsSync(openclawDir)) return
59
59
 
60
60
  const cfgPath = path.join(openclawDir, 'openclaw.json')
61
+
62
+ // ⚠️ 关键:文件不存在时直接 return,绝不用空对象覆盖
63
+ if (!fs.existsSync(cfgPath)) return
64
+
61
65
  let cfg = {}
62
- try { cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8')) } catch {}
66
+ try {
67
+ cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'))
68
+ } catch (e) {
69
+ // JSON 解析失败(文件损坏等)→ 同样放弃写入,不覆盖
70
+ console.warn('⚠️ openclaw.json 解析失败,跳过自动配置(文件可能损坏)')
71
+ return
72
+ }
63
73
 
64
74
  cfg.skills = cfg.skills || {}
65
75
  cfg.skills.entries = cfg.skills.entries || {}
@@ -12,9 +12,14 @@ function injectToOpenclaw(apiKey) {
12
12
  // 1. 写入 openclaw.json
13
13
  const openclawDir = path.join(os.homedir(), '.openclaw')
14
14
  const cfgPath = path.join(openclawDir, 'openclaw.json')
15
- if (fs.existsSync(openclawDir)) {
15
+ if (fs.existsSync(openclawDir) && fs.existsSync(cfgPath)) {
16
16
  let cfg = {}
17
- try { cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8')) } catch {}
17
+ try {
18
+ cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'))
19
+ } catch (e) {
20
+ console.warn('⚠️ openclaw.json 解析失败,跳过自动配置')
21
+ return
22
+ }
18
23
  cfg.skills = cfg.skills || {}
19
24
  cfg.skills.entries = cfg.skills.entries || {}
20
25
  cfg.skills.entries['skillfree'] = {
Binary file
Binary file