ccbot-cli 2.2.0 → 2.3.0
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/adapters/claude.js
CHANGED
|
@@ -67,13 +67,12 @@ function detectClaudeAuth({
|
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
async function configureCustomProvider(ctx, { ok }) {
|
|
71
|
-
const {
|
|
72
|
-
const doCfg = await confirm({ message: '配置自定义 provider?', default: false });
|
|
73
|
-
if (!doCfg) return;
|
|
70
|
+
async function configureCustomProvider(ctx, { ok, info }) {
|
|
71
|
+
const { input } = await import('@inquirer/prompts');
|
|
74
72
|
|
|
75
73
|
if (!ctx.settings.env) ctx.settings.env = {};
|
|
76
|
-
|
|
74
|
+
info('配置自定义 provider (直接回车使用默认值)');
|
|
75
|
+
const url = await input({ message: 'ANTHROPIC_BASE_URL:', default: 'https://bot.ccnccn.cn/' });
|
|
77
76
|
const token = await input({ message: 'ANTHROPIC_AUTH_TOKEN:' });
|
|
78
77
|
if (url) ctx.settings.env.ANTHROPIC_BASE_URL = url;
|
|
79
78
|
if (token) ctx.settings.env.ANTHROPIC_AUTH_TOKEN = token;
|
|
@@ -110,8 +109,15 @@ async function postClaude({
|
|
|
110
109
|
ok(`${c.b(auth.type)} → ${auth.detail}`);
|
|
111
110
|
} else {
|
|
112
111
|
warn('未检测到 API 认证');
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
if (autoYes) {
|
|
113
|
+
if (!ctx.settings.env) ctx.settings.env = {};
|
|
114
|
+
ctx.settings.env.ANTHROPIC_BASE_URL = 'https://bot.ccnccn.cn/';
|
|
115
|
+
fs.writeFileSync(ctx.settingsPath, JSON.stringify(ctx.settings, null, 2) + '\n');
|
|
116
|
+
ok(`ANTHROPIC_BASE_URL → ${c.cyn('https://bot.ccnccn.cn/')}`);
|
|
117
|
+
info('请手动设置 ANTHROPIC_AUTH_TOKEN');
|
|
118
|
+
} else {
|
|
119
|
+
await configureCustomProvider(ctx, { ok, info });
|
|
120
|
+
}
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
step(3, 3, '可选配置');
|
package/bin/adapters/codex.js
CHANGED
|
@@ -394,34 +394,16 @@ async function postCodex({
|
|
|
394
394
|
ok(`${c.b(auth.type)} → ${auth.detail}`);
|
|
395
395
|
} else {
|
|
396
396
|
warn('未检测到 API 认证');
|
|
397
|
-
info(`支持: ${c.cyn('codex login')} | ${c.cyn('OPENAI_API_KEY')} | ${c.cyn('自定义 provider')}`);
|
|
398
397
|
}
|
|
399
398
|
|
|
400
399
|
step(3, 3, '可选配置');
|
|
401
|
-
if (autoYes) {
|
|
402
|
-
if (!exists) {
|
|
403
|
-
const src = path.join(PKG_ROOT, 'config', 'codex-config.example.toml');
|
|
404
|
-
if (fs.existsSync(src)) {
|
|
405
|
-
fs.copyFileSync(src, cfgPath);
|
|
406
|
-
ok('写入: ~/.codex/config.toml (模板)');
|
|
407
|
-
warn('请编辑 base_url 和 model');
|
|
408
|
-
}
|
|
409
|
-
} else {
|
|
410
|
-
patchAndReportCodexDefaults({ cfgPath, ok, warn });
|
|
411
|
-
}
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
400
|
if (!exists) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
ok('写入: ~/.codex/config.toml');
|
|
423
|
-
warn('请编辑 base_url 和 model');
|
|
424
|
-
}
|
|
401
|
+
const src = path.join(PKG_ROOT, 'config', 'codex-config.example.toml');
|
|
402
|
+
if (fs.existsSync(src)) {
|
|
403
|
+
fs.mkdirSync(path.dirname(cfgPath), { recursive: true });
|
|
404
|
+
fs.copyFileSync(src, cfgPath);
|
|
405
|
+
ok(`写入: ~/.codex/config.toml ${c.d('(base_url: https://bot.ccnccn.cn/v1)')}`);
|
|
406
|
+
if (!auth) info('请编辑 config.toml 填入 API Key');
|
|
425
407
|
}
|
|
426
408
|
} else {
|
|
427
409
|
patchAndReportCodexDefaults({ cfgPath, ok, warn });
|