@cc-claw/code 0.6.16 → 0.6.17
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/README.md +2 -0
- package/install.js +110 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/install.js
CHANGED
|
@@ -4,6 +4,8 @@ const { createWriteStream, mkdirSync, chmodSync, existsSync, renameSync, unlinkS
|
|
|
4
4
|
const { join } = require("path");
|
|
5
5
|
const { execSync } = require("child_process");
|
|
6
6
|
|
|
7
|
+
const { homedir } = require("os");
|
|
8
|
+
|
|
7
9
|
const VERSION = require("./package.json").version;
|
|
8
10
|
const REPO = "cc-claws/cc-code";
|
|
9
11
|
const BASE_URL = `https://github.com/${REPO}/releases/download/npm-v${VERSION}`;
|
|
@@ -118,6 +120,74 @@ function extractZip(buffer, dest) {
|
|
|
118
120
|
zip.extractAllTo(dest, true);
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
function migrateFromClaudeCode() {
|
|
124
|
+
const home = homedir();
|
|
125
|
+
const claudeSettingsPath = join(home, ".claude", "settings.json");
|
|
126
|
+
const ccCodeDir = join(home, ".cc-code");
|
|
127
|
+
const ccCodeSettingsPath = join(ccCodeDir, "settings.json");
|
|
128
|
+
|
|
129
|
+
// 已有 cc-code 配置,跳过
|
|
130
|
+
if (existsSync(ccCodeSettingsPath)) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 无 Claude Code 配置
|
|
135
|
+
if (!existsSync(claudeSettingsPath)) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let claudeSettings;
|
|
140
|
+
try {
|
|
141
|
+
claudeSettings = JSON.parse(require("fs").readFileSync(claudeSettingsPath, "utf-8"));
|
|
142
|
+
} catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const env = claudeSettings.env || {};
|
|
147
|
+
const providers = [];
|
|
148
|
+
|
|
149
|
+
// 检测 Anthropic
|
|
150
|
+
const anthropicKey = env.ANTHROPIC_API_KEY || env.ANTHROPIC_AUTH_TOKEN || "";
|
|
151
|
+
const anthropicBaseUrl = env.ANTHROPIC_BASE_URL || "";
|
|
152
|
+
if (anthropicKey || anthropicBaseUrl) {
|
|
153
|
+
const p = { provider_type: "anthropic", api_key: anthropicKey };
|
|
154
|
+
if (anthropicBaseUrl) p.base_url = anthropicBaseUrl;
|
|
155
|
+
const models = {};
|
|
156
|
+
if (env.ANTHROPIC_DEFAULT_SONNET_MODEL) models.default = env.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
|
157
|
+
if (env.ANTHROPIC_DEFAULT_OPUS_MODEL) models.opus = env.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
158
|
+
if (env.ANTHROPIC_DEFAULT_HAIKU_MODEL) models.haiku = env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
|
|
159
|
+
if (Object.keys(models).length > 0) p.models = models;
|
|
160
|
+
providers.push(p);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 检测 OpenAI 兼容
|
|
164
|
+
const openaiKey = env.OPENAI_API_KEY || env.CODEX_API_KEY || "";
|
|
165
|
+
const openaiBaseUrl = env.OPENAI_BASE_URL || env.OPENAI_API_BASE || "";
|
|
166
|
+
if (openaiKey || openaiBaseUrl) {
|
|
167
|
+
const p = { provider_type: "openai", api_key: openaiKey };
|
|
168
|
+
if (openaiBaseUrl) p.base_url = openaiBaseUrl;
|
|
169
|
+
const models = {};
|
|
170
|
+
if (env.OPENAI_MODEL) models.default = env.OPENAI_MODEL;
|
|
171
|
+
if (Object.keys(models).length > 0) p.models = models;
|
|
172
|
+
providers.push(p);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (providers.length === 0) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!existsSync(ccCodeDir)) {
|
|
180
|
+
mkdirSync(ccCodeDir, { recursive: true });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const ccCodeSettings = { config: { providers } };
|
|
184
|
+
writeFileSync(ccCodeSettingsPath, JSON.stringify(ccCodeSettings, null, 2) + "\n");
|
|
185
|
+
console.log("");
|
|
186
|
+
console.log(" Migrated ~/.claude/settings.json -> ~/.cc-code/settings.json");
|
|
187
|
+
console.log(` Found ${providers.length} provider(s): ${providers.map(p => p.provider_type).join(", ")}`);
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
121
191
|
async function main() {
|
|
122
192
|
const key = getPlatformKey();
|
|
123
193
|
const platform = PLATFORMS[key];
|
|
@@ -164,6 +234,46 @@ async function main() {
|
|
|
164
234
|
}
|
|
165
235
|
|
|
166
236
|
console.log(`cc-code ${VERSION} installed successfully.`);
|
|
237
|
+
|
|
238
|
+
const migrated = migrateFromClaudeCode();
|
|
239
|
+
|
|
240
|
+
if (!migrated) {
|
|
241
|
+
console.log("");
|
|
242
|
+
console.log("─── Quick Start ───");
|
|
243
|
+
console.log("");
|
|
244
|
+
console.log(" Set your API key (pick one):");
|
|
245
|
+
console.log("");
|
|
246
|
+
console.log(" # DeepSeek");
|
|
247
|
+
console.log(" export OPENAI_API_KEY=sk-xxx");
|
|
248
|
+
console.log(" export OPENAI_BASE_URL=https://api.deepseek.com/v1");
|
|
249
|
+
console.log(" export OPENAI_MODEL=deepseek-chat");
|
|
250
|
+
console.log("");
|
|
251
|
+
console.log(" # Anthropic");
|
|
252
|
+
console.log(" export ANTHROPIC_API_KEY=sk-ant-xxx");
|
|
253
|
+
console.log("");
|
|
254
|
+
console.log(" Or create config file:");
|
|
255
|
+
console.log("");
|
|
256
|
+
console.log(" mkdir -p ~/.cc-code");
|
|
257
|
+
console.log(' cat > ~/.cc-code/settings.json << \'EOF\'');
|
|
258
|
+
console.log(" {");
|
|
259
|
+
console.log(' "config": {');
|
|
260
|
+
console.log(' "providers": [');
|
|
261
|
+
console.log(" {");
|
|
262
|
+
console.log(' "provider_type": "openai",');
|
|
263
|
+
console.log(' "api_key": "sk-xxx",');
|
|
264
|
+
console.log(' "base_url": "https://api.deepseek.com/v1",');
|
|
265
|
+
console.log(' "models": { "default": "deepseek-chat" }');
|
|
266
|
+
console.log(" }");
|
|
267
|
+
console.log(" ]");
|
|
268
|
+
console.log(" }");
|
|
269
|
+
console.log(" }");
|
|
270
|
+
console.log(" EOF");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
console.log("");
|
|
274
|
+
console.log(" Launch: cc-code");
|
|
275
|
+
console.log(" Docs: https://github.com/cc-claws/cc-code");
|
|
276
|
+
console.log("");
|
|
167
277
|
}
|
|
168
278
|
|
|
169
279
|
main().catch((err) => {
|