pumpkinai-config 1.5.2 → 1.5.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.
Files changed (2) hide show
  1. package/claude-ide.js +62 -9
  2. package/package.json +1 -1
package/claude-ide.js CHANGED
@@ -65,6 +65,12 @@ function getSettingsPaths() {
65
65
  }
66
66
  }
67
67
 
68
+ // 检查 IDE 是否安装(检查配置目录是否存在)
69
+ function checkIDEInstalled(settingsPath) {
70
+ const dir = path.dirname(settingsPath);
71
+ return fs.existsSync(dir);
72
+ }
73
+
68
74
  // 读取 JSON 文件(带注释处理)
69
75
  function readJsonFile(filePath) {
70
76
  try {
@@ -101,6 +107,32 @@ function writeJsonFile(filePath, data) {
101
107
  }
102
108
  }
103
109
 
110
+ // 创建 ~/.claude/config.json
111
+ function createClaudeConfig() {
112
+ const homeDir = os.homedir();
113
+ const claudeDir = path.join(homeDir, '.claude');
114
+ const configPath = path.join(claudeDir, 'config.json');
115
+
116
+ log('\n[配置] 创建 Claude 配置文件...', 'cyan');
117
+
118
+ try {
119
+ // 确保 .claude 目录存在
120
+ if (!fs.existsSync(claudeDir)) {
121
+ fs.mkdirSync(claudeDir, { recursive: true });
122
+ log(`[创建] 目录: ${claudeDir}`, 'green');
123
+ }
124
+
125
+ // 创建 config.json
126
+ const config = { primaryApiKey: "1" };
127
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf8');
128
+ log(`[成功] 配置文件: ${configPath}`, 'green');
129
+ return true;
130
+ } catch (error) {
131
+ log(`[错误] 创建配置文件失败: ${error.message}`, 'red');
132
+ return false;
133
+ }
134
+ }
135
+
104
136
  // 配置 IDE 的 settings.json
105
137
  function configureIDESettings(settingsPath, ideName, apiKey) {
106
138
  log(`\n[配置] 正在配置 ${ideName}...`, 'cyan');
@@ -177,6 +209,7 @@ function showCompletionInfo(configuredIDEs) {
177
209
  log(' * ANTHROPIC_BASE_URL = https://code.ppchat.vip', 'reset');
178
210
  log(' * ANTHROPIC_AUTH_TOKEN = sk-xxx...', 'reset');
179
211
  log(' * CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = 1', 'reset');
212
+ log(` * ~/.claude/config.json (primaryApiKey)`, 'reset');
180
213
 
181
214
  log('\n[下一步]', 'cyan');
182
215
  log(' 请重启 VSCode / Cursor 使配置生效', 'yellow');
@@ -202,9 +235,23 @@ async function main() {
202
235
  // 获取配置文件路径
203
236
  const paths = getSettingsPaths();
204
237
 
205
- log('[信息] 检测到的配置文件路径:', 'cyan');
206
- log(` VSCode: ${paths.vscode}`, 'reset');
207
- log(` Cursor: ${paths.cursor}`, 'reset');
238
+ // 检查哪些 IDE 已安装
239
+ const vscodeInstalled = checkIDEInstalled(paths.vscode);
240
+ const cursorInstalled = checkIDEInstalled(paths.cursor);
241
+
242
+ if (!vscodeInstalled && !cursorInstalled) {
243
+ log('[错误] 未检测到 VSCode 或 Cursor 安装', 'red');
244
+ log(' 请先安装 VSCode 或 Cursor', 'yellow');
245
+ process.exit(1);
246
+ }
247
+
248
+ log('[信息] 检测到的 IDE:', 'cyan');
249
+ if (vscodeInstalled) {
250
+ log(` VSCode: ${paths.vscode}`, 'green');
251
+ }
252
+ if (cursorInstalled) {
253
+ log(` Cursor: ${paths.cursor}`, 'green');
254
+ }
208
255
 
209
256
  // 显示粘贴提示
210
257
  if (process.platform === 'win32') {
@@ -222,16 +269,22 @@ async function main() {
222
269
 
223
270
  const configuredIDEs = [];
224
271
 
225
- // 配置 VSCode
226
- if (configureIDESettings(paths.vscode, 'VSCode', apiKey)) {
227
- configuredIDEs.push('VSCode');
272
+ // 只配置已安装的 IDE
273
+ if (vscodeInstalled) {
274
+ if (configureIDESettings(paths.vscode, 'VSCode', apiKey)) {
275
+ configuredIDEs.push('VSCode');
276
+ }
228
277
  }
229
278
 
230
- // 配置 Cursor
231
- if (configureIDESettings(paths.cursor, 'Cursor', apiKey)) {
232
- configuredIDEs.push('Cursor');
279
+ if (cursorInstalled) {
280
+ if (configureIDESettings(paths.cursor, 'Cursor', apiKey)) {
281
+ configuredIDEs.push('Cursor');
282
+ }
233
283
  }
234
284
 
285
+ // 创建 ~/.claude/config.json
286
+ createClaudeConfig();
287
+
235
288
  if (configuredIDEs.length === 0) {
236
289
  log('\n[错误] 没有成功配置任何 IDE', 'red');
237
290
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumpkinai-config",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "PumpkinAI 一键安装配置工具 - 支持 Codex 和 Claude Code",
5
5
  "main": "codex-setup.js",
6
6
  "bin": {