skillfree 0.1.69 โ†’ 0.1.70

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.69",
3
+ "version": "0.1.70",
4
4
  "description": "๐Ÿฆž ไธ€ไธช API๏ผŒๆปก่ถณๆ‰€ๆœ‰้พ™่™พๆŠ€่ƒฝ้œ€ๆฑ‚",
5
5
  "main": "bin/skillfree.js",
6
6
  "bin": {
@@ -4,36 +4,24 @@ const path = require('path')
4
4
  const os = require('os')
5
5
  const { saveConfig, BASE_URL } = require('../lib/client')
6
6
 
7
- // โ”€โ”€ ๅนณๅฐ โ†’ ๆŠ€่ƒฝๅฎ‰่ฃ…่ทฏๅพ„ๆ˜ ๅฐ„๏ผˆไธŽ postinstall.js ไฟๆŒไธ€่‡ด๏ผ‰โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
8
- const PLATFORM_PATHS = {
9
- openclaw: [
10
- path.join(os.homedir(), '.openclaw', 'skills', 'skillfree'),
11
- path.join(os.homedir(), '.agents', 'skills', 'skillfree'),
12
- ],
13
- claude: [
14
- path.join(os.homedir(), '.claude', 'skills', 'skillfree'),
15
- ],
16
- codex: [
17
- path.join(os.homedir(), '.codex', 'skills', 'skillfree'),
18
- ],
19
- continue: [
20
- path.join(os.homedir(), '.continue', 'skills', 'skillfree'),
21
- ],
22
- cursor: [
23
- path.join(os.homedir(), '.cursor', 'skills', 'skillfree'),
24
- ],
25
- }
26
-
27
7
  /**
28
- * ๅฐ† apiKey ๅ†™ๅ…ฅๅ„ๅนณๅฐ้…็ฝฎ + shell ็Žฏๅขƒๅ˜้‡
8
+ * ๅฐ† apiKey ๆณจๅ…ฅๅˆฐๅ„ๅนณๅฐ้…็ฝฎ + shell ็Žฏๅขƒๅ˜้‡
9
+ *
10
+ * ๅ„ๅนณๅฐๆณจๅ…ฅๆ–นๅผ๏ผš
11
+ * openclaw โ†’ ~/.openclaw/openclaw.json (skills.entries.skillfree.apiKey)
12
+ * hermes โ†’ ~/.hermes/.env (SKILLFREE_API_KEY=xxx)
13
+ * claude โ†’ ~/.claude/settings.json (env.SKILLFREE_API_KEY)
14
+ * codex โ†’ ๆ— ไธ“็”จ้…็ฝฎ๏ผŒ่ตฐ shell ็Žฏๅขƒๅ˜้‡ๅณๅฏ
15
+ * ้€š็”จ โ†’ ~/.zshrc / ~/.bash_profile (export SKILLFREE_API_KEY=xxx)
29
16
  */
30
17
  function injectToOpenclaw(apiKey) {
31
- // 1. OpenClaw: ๅ†™ๅ…ฅ openclaw.json
32
- const openclawDir = path.join(os.homedir(), '.openclaw')
33
- const cfgPath = path.join(openclawDir, 'openclaw.json')
34
- if (fs.existsSync(openclawDir) && fs.existsSync(cfgPath)) {
18
+ const HOME = os.homedir()
19
+
20
+ // โ”€โ”€ 1. OpenClaw: ๅ†™ๅ…ฅ openclaw.json โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
21
+ const openclawCfgPath = path.join(HOME, '.openclaw', 'openclaw.json')
22
+ if (fs.existsSync(path.join(HOME, '.openclaw')) && fs.existsSync(openclawCfgPath)) {
35
23
  let cfg = {}
36
- try { cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8')) } catch {}
24
+ try { cfg = JSON.parse(fs.readFileSync(openclawCfgPath, 'utf8')) } catch {}
37
25
  cfg.skills = cfg.skills || {}
38
26
  cfg.skills.entries = cfg.skills.entries || {}
39
27
  cfg.skills.entries['skillfree'] = {
@@ -42,38 +30,102 @@ function injectToOpenclaw(apiKey) {
42
30
  apiKey,
43
31
  }
44
32
  try {
45
- fs.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2) + '\n')
46
- console.log('โœ… openclaw.json ๅทฒๆ›ดๆ–ฐ๏ผŒOpenClaw ไธ‹ๆฌกๅฏๅŠจ่‡ชๅŠจ่ฏ†ๅˆซ skillfree skill')
33
+ fs.writeFileSync(openclawCfgPath, JSON.stringify(cfg, null, 2) + '\n')
34
+ console.log('โœ… [OpenClaw] openclaw.json ๅทฒๆ›ดๆ–ฐ')
35
+ } catch (e) {
36
+ console.warn('โš ๏ธ [OpenClaw] ๆ— ๆณ•ๅ†™ๅ…ฅ openclaw.json๏ผš', e.message)
37
+ }
38
+ }
39
+
40
+ // โ”€โ”€ 2. Hermes: ๅ†™ๅ…ฅ ~/.hermes/.env โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
41
+ const hermesDir = path.join(HOME, '.hermes')
42
+ if (fs.existsSync(hermesDir)) {
43
+ const hermesEnvPath = path.join(hermesDir, '.env')
44
+ _injectEnvFile(hermesEnvPath, 'SKILLFREE_API_KEY', apiKey)
45
+ console.log('โœ… [Hermes] ~/.hermes/.env ๅทฒๅ†™ๅ…ฅ SKILLFREE_API_KEY')
46
+ }
47
+
48
+ // โ”€โ”€ 3. Claude Code: ๅ†™ๅ…ฅ ~/.claude/settings.json โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
49
+ const claudeDir = path.join(HOME, '.claude')
50
+ if (fs.existsSync(claudeDir)) {
51
+ const claudeSettingsPath = path.join(claudeDir, 'settings.json')
52
+ let settings = {}
53
+ if (fs.existsSync(claudeSettingsPath)) {
54
+ try { settings = JSON.parse(fs.readFileSync(claudeSettingsPath, 'utf8')) } catch {}
55
+ }
56
+ settings.env = settings.env || {}
57
+ settings.env['SKILLFREE_API_KEY'] = apiKey
58
+ try {
59
+ fs.writeFileSync(claudeSettingsPath, JSON.stringify(settings, null, 2) + '\n')
60
+ console.log('โœ… [Claude Code] ~/.claude/settings.json ๅทฒๅ†™ๅ…ฅ SKILLFREE_API_KEY')
61
+ } catch (e) {
62
+ console.warn('โš ๏ธ [Claude Code] ๆ— ๆณ•ๅ†™ๅ…ฅ settings.json๏ผš', e.message)
63
+ }
64
+ }
65
+
66
+ // โ”€โ”€ 4. Codex: ๅ†™ๅ…ฅ ~/.codex/config.json โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
67
+ const codexDir = path.join(HOME, '.codex')
68
+ if (fs.existsSync(codexDir)) {
69
+ const codexCfgPath = path.join(codexDir, 'config.json')
70
+ let cfg = {}
71
+ if (fs.existsSync(codexCfgPath)) {
72
+ try { cfg = JSON.parse(fs.readFileSync(codexCfgPath, 'utf8')) } catch {}
73
+ }
74
+ cfg.env = cfg.env || {}
75
+ cfg.env['SKILLFREE_API_KEY'] = apiKey
76
+ try {
77
+ fs.writeFileSync(codexCfgPath, JSON.stringify(cfg, null, 2) + '\n')
78
+ console.log('โœ… [Codex] ~/.codex/config.json ๅทฒๅ†™ๅ…ฅ SKILLFREE_API_KEY')
47
79
  } catch (e) {
48
- console.warn('โš ๏ธ ๆ— ๆณ•ๅ†™ๅ…ฅ openclaw.json๏ผˆๆƒ้™้—ฎ้ข˜๏ผŸ๏ผ‰๏ผš', e.message)
80
+ console.warn('โš ๏ธ [Codex] ๆ— ๆณ•ๅ†™ๅ…ฅ config.json๏ผš', e.message)
49
81
  }
50
82
  }
51
83
 
52
- // 2. ๅ†™ๅ…ฅ shell ้…็ฝฎๆ–‡ไปถ๏ผˆ~/.zshrc ๆˆ– ~/.bash_profile๏ผ‰
84
+ // โ”€โ”€ 5. ้€š็”จ๏ผšๅ†™ๅ…ฅ shell ้…็ฝฎๆ–‡ไปถ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
53
85
  const exportLine = `\nexport SKILLFREE_API_KEY="${apiKey}"\n`
54
86
  const shellFiles = [
55
- path.join(os.homedir(), '.zshrc'),
56
- path.join(os.homedir(), '.bash_profile'),
87
+ path.join(HOME, '.zshrc'),
88
+ path.join(HOME, '.bash_profile'),
57
89
  ]
58
90
  let wrote = false
59
91
  for (const f of shellFiles) {
60
92
  if (fs.existsSync(f)) {
61
93
  const content = fs.readFileSync(f, 'utf8')
62
94
  if (content.includes('SKILLFREE_API_KEY')) {
63
- const updated = content.replace(/\nexport SKILLFREE_API_KEY=.*\n?/g, exportLine)
64
- fs.writeFileSync(f, updated)
95
+ fs.writeFileSync(f, content.replace(/\nexport SKILLFREE_API_KEY=.*\n?/g, exportLine))
65
96
  } else {
66
97
  fs.appendFileSync(f, exportLine)
67
98
  }
68
- console.log(`โœ… ${path.basename(f)} ๅทฒๅ†™ๅ…ฅ SKILLFREE_API_KEY`)
99
+ console.log(`โœ… [Shell] ${path.basename(f)} ๅทฒๅ†™ๅ…ฅ SKILLFREE_API_KEY`)
69
100
  wrote = true
70
101
  break
71
102
  }
72
103
  }
73
104
  if (!wrote) {
74
105
  fs.writeFileSync(shellFiles[0], `# SkillFree API Key${exportLine}`)
75
- console.log('โœ… ~/.zshrc ๅทฒๅˆ›ๅปบๅนถๅ†™ๅ…ฅ SKILLFREE_API_KEY')
106
+ console.log('โœ… [Shell] ~/.zshrc ๅทฒๅˆ›ๅปบๅนถๅ†™ๅ…ฅ SKILLFREE_API_KEY')
107
+ }
108
+ }
109
+
110
+ /**
111
+ * ๅ‘ .env ๆ–‡ไปถๆณจๅ…ฅๆˆ–ๆ›ดๆ–ฐไธ€ไธช KEY=value ่กŒ
112
+ */
113
+ function _injectEnvFile(envPath, key, value) {
114
+ const line = `${key}="${value}"`
115
+ let content = ''
116
+ if (fs.existsSync(envPath)) {
117
+ content = fs.readFileSync(envPath, 'utf8')
118
+ if (content.includes(key + '=')) {
119
+ // ๆ›ฟๆขๅทฒๆœ‰่กŒ
120
+ content = content.replace(new RegExp(`^${key}=.*$`, 'm'), line)
121
+ } else {
122
+ content = content.trimEnd() + '\n' + line + '\n'
123
+ }
124
+ } else {
125
+ content = line + '\n'
76
126
  }
127
+ fs.mkdirSync(path.dirname(envPath), { recursive: true })
128
+ fs.writeFileSync(envPath, content)
77
129
  }
78
130
 
79
131
  function printQuickExamples() {