zcf 1.1.4 → 1.1.6
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/dist/cli.mjs +1 -1
- package/dist/index.d.mts +24 -8
- package/dist/index.d.ts +24 -8
- package/dist/index.mjs +1 -1
- package/dist/shared/{zcf.DK7kfRoM.mjs → zcf.Dke_fzoC.mjs} +115 -43
- package/package.json +1 -1
- package/templates/settings.json +2 -3
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import cac from 'cac';
|
|
3
3
|
import ansis from 'ansis';
|
|
4
|
-
import {
|
|
4
|
+
import { u as displayBanner, v as selectScriptLanguage, x as readZcfConfig, I as I18N, S as SETTINGS_FILE, d as SUPPORTED_LANGS, L as LANG_LABELS, y as resolveAiOutputLanguage, z as updatePromptOnly, B as updateZcfConfig, D as version, i as init } from './shared/zcf.Dke_fzoC.mjs';
|
|
5
5
|
import prompts from '@posva/prompts';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import 'node:os';
|
package/dist/index.d.mts
CHANGED
|
@@ -23,14 +23,15 @@ interface McpServerConfig {
|
|
|
23
23
|
url?: string;
|
|
24
24
|
env?: Record<string, string>;
|
|
25
25
|
}
|
|
26
|
-
interface
|
|
26
|
+
interface ClaudeConfiguration {
|
|
27
27
|
mcpServers: Record<string, McpServerConfig>;
|
|
28
|
+
hasCompletedOnboarding?: boolean;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
declare const CLAUDE_DIR: string;
|
|
31
32
|
declare const SETTINGS_FILE: string;
|
|
32
33
|
declare const CLAUDE_MD_FILE: string;
|
|
33
|
-
declare const
|
|
34
|
+
declare const ClAUDE_CONFIG_FILE: string;
|
|
34
35
|
declare const ZCF_CONFIG_FILE: string;
|
|
35
36
|
declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
|
|
36
37
|
type SupportedLang = (typeof SUPPORTED_LANGS)[number];
|
|
@@ -100,6 +101,13 @@ declare const I18N: {
|
|
|
100
101
|
yes: string;
|
|
101
102
|
no: string;
|
|
102
103
|
cancelled: string;
|
|
104
|
+
apiKeyValidation: {
|
|
105
|
+
empty: string;
|
|
106
|
+
invalid: string;
|
|
107
|
+
tooShort: string;
|
|
108
|
+
tooLong: string;
|
|
109
|
+
example: string;
|
|
110
|
+
};
|
|
103
111
|
noExistingConfig: string;
|
|
104
112
|
updatingPrompts: string;
|
|
105
113
|
updateConfigLangPrompt: string;
|
|
@@ -154,6 +162,13 @@ declare const I18N: {
|
|
|
154
162
|
yes: string;
|
|
155
163
|
no: string;
|
|
156
164
|
cancelled: string;
|
|
165
|
+
apiKeyValidation: {
|
|
166
|
+
empty: string;
|
|
167
|
+
invalid: string;
|
|
168
|
+
tooShort: string;
|
|
169
|
+
tooLong: string;
|
|
170
|
+
example: string;
|
|
171
|
+
};
|
|
157
172
|
noExistingConfig: string;
|
|
158
173
|
updatingPrompts: string;
|
|
159
174
|
updateConfigLangPrompt: string;
|
|
@@ -187,16 +202,17 @@ interface ApiConfig {
|
|
|
187
202
|
key: string;
|
|
188
203
|
authType?: 'auth_token' | 'api_key';
|
|
189
204
|
}
|
|
190
|
-
declare function configureApi(apiConfig: ApiConfig | null):
|
|
205
|
+
declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
|
|
191
206
|
declare function mergeConfigs(sourceFile: string, targetFile: string): void;
|
|
192
207
|
declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
|
|
193
208
|
|
|
194
209
|
declare function getMcpConfigPath(): string;
|
|
195
|
-
declare function readMcpConfig():
|
|
196
|
-
declare function writeMcpConfig(config:
|
|
210
|
+
declare function readMcpConfig(): ClaudeConfiguration | null;
|
|
211
|
+
declare function writeMcpConfig(config: ClaudeConfiguration): void;
|
|
197
212
|
declare function backupMcpConfig(): string | null;
|
|
198
|
-
declare function mergeMcpServers(existing:
|
|
213
|
+
declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
|
|
199
214
|
declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
|
|
215
|
+
declare function addCompletedOnboarding(): void;
|
|
200
216
|
|
|
201
|
-
export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS,
|
|
202
|
-
export type { AiOutputLanguage, ApiConfig,
|
|
217
|
+
export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, ClAUDE_CONFIG_FILE, I18N, LANG_LABELS, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
|
|
218
|
+
export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, McpServerConfig, McpService, SupportedLang };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,14 +23,15 @@ interface McpServerConfig {
|
|
|
23
23
|
url?: string;
|
|
24
24
|
env?: Record<string, string>;
|
|
25
25
|
}
|
|
26
|
-
interface
|
|
26
|
+
interface ClaudeConfiguration {
|
|
27
27
|
mcpServers: Record<string, McpServerConfig>;
|
|
28
|
+
hasCompletedOnboarding?: boolean;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
declare const CLAUDE_DIR: string;
|
|
31
32
|
declare const SETTINGS_FILE: string;
|
|
32
33
|
declare const CLAUDE_MD_FILE: string;
|
|
33
|
-
declare const
|
|
34
|
+
declare const ClAUDE_CONFIG_FILE: string;
|
|
34
35
|
declare const ZCF_CONFIG_FILE: string;
|
|
35
36
|
declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"];
|
|
36
37
|
type SupportedLang = (typeof SUPPORTED_LANGS)[number];
|
|
@@ -100,6 +101,13 @@ declare const I18N: {
|
|
|
100
101
|
yes: string;
|
|
101
102
|
no: string;
|
|
102
103
|
cancelled: string;
|
|
104
|
+
apiKeyValidation: {
|
|
105
|
+
empty: string;
|
|
106
|
+
invalid: string;
|
|
107
|
+
tooShort: string;
|
|
108
|
+
tooLong: string;
|
|
109
|
+
example: string;
|
|
110
|
+
};
|
|
103
111
|
noExistingConfig: string;
|
|
104
112
|
updatingPrompts: string;
|
|
105
113
|
updateConfigLangPrompt: string;
|
|
@@ -154,6 +162,13 @@ declare const I18N: {
|
|
|
154
162
|
yes: string;
|
|
155
163
|
no: string;
|
|
156
164
|
cancelled: string;
|
|
165
|
+
apiKeyValidation: {
|
|
166
|
+
empty: string;
|
|
167
|
+
invalid: string;
|
|
168
|
+
tooShort: string;
|
|
169
|
+
tooLong: string;
|
|
170
|
+
example: string;
|
|
171
|
+
};
|
|
157
172
|
noExistingConfig: string;
|
|
158
173
|
updatingPrompts: string;
|
|
159
174
|
updateConfigLangPrompt: string;
|
|
@@ -187,16 +202,17 @@ interface ApiConfig {
|
|
|
187
202
|
key: string;
|
|
188
203
|
authType?: 'auth_token' | 'api_key';
|
|
189
204
|
}
|
|
190
|
-
declare function configureApi(apiConfig: ApiConfig | null):
|
|
205
|
+
declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null;
|
|
191
206
|
declare function mergeConfigs(sourceFile: string, targetFile: string): void;
|
|
192
207
|
declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
|
|
193
208
|
|
|
194
209
|
declare function getMcpConfigPath(): string;
|
|
195
|
-
declare function readMcpConfig():
|
|
196
|
-
declare function writeMcpConfig(config:
|
|
210
|
+
declare function readMcpConfig(): ClaudeConfiguration | null;
|
|
211
|
+
declare function writeMcpConfig(config: ClaudeConfiguration): void;
|
|
197
212
|
declare function backupMcpConfig(): string | null;
|
|
198
|
-
declare function mergeMcpServers(existing:
|
|
213
|
+
declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
|
|
199
214
|
declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
|
|
215
|
+
declare function addCompletedOnboarding(): void;
|
|
200
216
|
|
|
201
|
-
export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS,
|
|
202
|
-
export type { AiOutputLanguage, ApiConfig,
|
|
217
|
+
export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, ClAUDE_CONFIG_FILE, I18N, LANG_LABELS, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
|
|
218
|
+
export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, McpServerConfig, McpService, SupportedLang };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AI_OUTPUT_LANGUAGES, C as CLAUDE_DIR, a as CLAUDE_MD_FILE, I as I18N, L as LANG_LABELS, M as
|
|
1
|
+
export { A as AI_OUTPUT_LANGUAGES, C as CLAUDE_DIR, a as CLAUDE_MD_FILE, b as ClAUDE_CONFIG_FILE, I as I18N, L as LANG_LABELS, M as MCP_SERVICES, S as SETTINGS_FILE, d as SUPPORTED_LANGS, Z as ZCF_CONFIG_FILE, t as addCompletedOnboarding, n as applyAiLanguageDirective, j as backupExistingConfig, p as backupMcpConfig, s as buildMcpServerConfig, c as commandExists, l as configureApi, k as copyConfigFiles, h as ensureClaudeDir, o as getMcpConfigPath, g as getPlatform, i as init, f as installClaudeCode, e as isClaudeCodeInstalled, m as mergeConfigs, q as mergeMcpServers, r as readMcpConfig, w as writeMcpConfig } from './shared/zcf.Dke_fzoC.mjs';
|
|
2
2
|
import '@posva/prompts';
|
|
3
3
|
import 'ansis';
|
|
4
4
|
import 'node:fs';
|
|
@@ -6,12 +6,12 @@ import { join, dirname } from 'pathe';
|
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { exec } from 'tinyexec';
|
|
8
8
|
|
|
9
|
-
const version = "1.1.
|
|
9
|
+
const version = "1.1.6";
|
|
10
10
|
|
|
11
11
|
const CLAUDE_DIR = join(homedir(), ".claude");
|
|
12
12
|
const SETTINGS_FILE = join(CLAUDE_DIR, "settings.json");
|
|
13
13
|
const CLAUDE_MD_FILE = join(CLAUDE_DIR, "CLAUDE.md");
|
|
14
|
-
const
|
|
14
|
+
const ClAUDE_CONFIG_FILE = join(homedir(), ".claude.json");
|
|
15
15
|
const ZCF_CONFIG_FILE = join(homedir(), ".zcf.json");
|
|
16
16
|
const SUPPORTED_LANGS = ["zh-CN", "en"];
|
|
17
17
|
const LANG_LABELS = {
|
|
@@ -70,6 +70,13 @@ const I18N = {
|
|
|
70
70
|
yes: "\u662F",
|
|
71
71
|
no: "\u5426",
|
|
72
72
|
cancelled: "\u64CD\u4F5C\u5DF2\u53D6\u6D88",
|
|
73
|
+
apiKeyValidation: {
|
|
74
|
+
empty: "API Key \u4E0D\u80FD\u4E3A\u7A7A",
|
|
75
|
+
invalid: "API Key \u683C\u5F0F\u65E0\u6548\u3002\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\uFF08_\uFF09\u548C\u8FDE\u5B57\u7B26\uFF08-\uFF09",
|
|
76
|
+
tooShort: "API Key \u957F\u5EA6\u592A\u77ED\uFF08\u81F3\u5C11\u9700\u8981 1 \u4E2A\u5B57\u7B26\uFF09",
|
|
77
|
+
tooLong: "API Key \u957F\u5EA6\u592A\u957F\uFF08\u6700\u591A 256 \u4E2A\u5B57\u7B26\uFF09",
|
|
78
|
+
example: "\u793A\u4F8B\u683C\u5F0F: sk-abcdef123456_789xyz"
|
|
79
|
+
},
|
|
73
80
|
noExistingConfig: "\u672A\u627E\u5230\u73B0\u6709\u914D\u7F6E\u3002\u8BF7\u5148\u8FD0\u884C `zcf`\u3002",
|
|
74
81
|
updatingPrompts: "\u6B63\u5728\u66F4\u65B0 Claude Code Prompt \u6587\u6863...",
|
|
75
82
|
updateConfigLangPrompt: "\u9009\u62E9\u914D\u7F6E\u8BED\u8A00",
|
|
@@ -124,6 +131,13 @@ const I18N = {
|
|
|
124
131
|
yes: "Yes",
|
|
125
132
|
no: "No",
|
|
126
133
|
cancelled: "Operation cancelled",
|
|
134
|
+
apiKeyValidation: {
|
|
135
|
+
empty: "API Key cannot be empty",
|
|
136
|
+
invalid: "Invalid API Key format. Only letters, numbers, underscores (_) and hyphens (-) are allowed",
|
|
137
|
+
tooShort: "API Key is too short (minimum 1 characters required)",
|
|
138
|
+
tooLong: "API Key is too long (maximum 256 characters allowed)",
|
|
139
|
+
example: "Example format: sk-abcdef123456_789xyz"
|
|
140
|
+
},
|
|
127
141
|
noExistingConfig: "No existing configuration found. Please run `zcf` first.",
|
|
128
142
|
updatingPrompts: "Updating Claude Code prompt documents...",
|
|
129
143
|
updateConfigLangPrompt: "Select configuration language",
|
|
@@ -307,41 +321,30 @@ function copyDirectory(src, dest) {
|
|
|
307
321
|
}
|
|
308
322
|
}
|
|
309
323
|
}
|
|
324
|
+
function getDefaultSettings() {
|
|
325
|
+
try {
|
|
326
|
+
const currentFileUrl = new URL(import.meta.url);
|
|
327
|
+
const currentFilePath = currentFileUrl.pathname;
|
|
328
|
+
const distDir = dirname(dirname(currentFilePath));
|
|
329
|
+
const rootDir = dirname(distDir);
|
|
330
|
+
const templateSettingsPath = join(rootDir, "templates", "settings.json");
|
|
331
|
+
if (existsSync(templateSettingsPath)) {
|
|
332
|
+
const content = readFileSync(templateSettingsPath, "utf-8");
|
|
333
|
+
return JSON.parse(content);
|
|
334
|
+
}
|
|
335
|
+
} catch (error) {
|
|
336
|
+
console.error("Failed to read template settings.json:", error);
|
|
337
|
+
return {};
|
|
338
|
+
}
|
|
339
|
+
}
|
|
310
340
|
function configureApi(apiConfig) {
|
|
311
|
-
if (!apiConfig) return;
|
|
312
|
-
let settings =
|
|
313
|
-
$schema: "https://json.schemastore.org/claude-code-settings.json",
|
|
314
|
-
env: {},
|
|
315
|
-
includeCoAuthoredBy: false,
|
|
316
|
-
permissions: {
|
|
317
|
-
allow: [
|
|
318
|
-
"Bash(*)",
|
|
319
|
-
"LS(*)",
|
|
320
|
-
"Read(*)",
|
|
321
|
-
"Write(*)",
|
|
322
|
-
"Edit(*)",
|
|
323
|
-
"MultiEdit(*)",
|
|
324
|
-
"Glob(*)",
|
|
325
|
-
"Grep(*)",
|
|
326
|
-
"WebFetch(*)",
|
|
327
|
-
"WebSearch(*)",
|
|
328
|
-
"TodoWrite(*)",
|
|
329
|
-
"NotebookRead(*)",
|
|
330
|
-
"NotebookEdit(*)"
|
|
331
|
-
],
|
|
332
|
-
deny: []
|
|
333
|
-
},
|
|
334
|
-
hooks: {},
|
|
335
|
-
model: "opus"
|
|
336
|
-
};
|
|
341
|
+
if (!apiConfig) return null;
|
|
342
|
+
let settings = getDefaultSettings();
|
|
337
343
|
if (existsSync(SETTINGS_FILE)) {
|
|
338
344
|
const content = readFileSync(SETTINGS_FILE, "utf-8");
|
|
339
345
|
try {
|
|
340
346
|
const existingSettings = JSON.parse(content);
|
|
341
|
-
settings =
|
|
342
|
-
if (existingSettings.env) {
|
|
343
|
-
settings.env = { ...settings.env, ...existingSettings.env };
|
|
344
|
-
}
|
|
347
|
+
settings = deepMerge(settings, existingSettings);
|
|
345
348
|
} catch (error) {
|
|
346
349
|
console.error("Failed to parse existing settings.json, using defaults:", error);
|
|
347
350
|
}
|
|
@@ -353,6 +356,7 @@ function configureApi(apiConfig) {
|
|
|
353
356
|
}
|
|
354
357
|
settings.env.ANTHROPIC_BASE_URL = apiConfig.url;
|
|
355
358
|
writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2));
|
|
359
|
+
return apiConfig;
|
|
356
360
|
}
|
|
357
361
|
function mergeConfigs(sourceFile, targetFile) {
|
|
358
362
|
if (!existsSync(sourceFile)) return;
|
|
@@ -440,14 +444,14 @@ async function installClaudeCode(lang) {
|
|
|
440
444
|
}
|
|
441
445
|
|
|
442
446
|
function getMcpConfigPath() {
|
|
443
|
-
return
|
|
447
|
+
return ClAUDE_CONFIG_FILE;
|
|
444
448
|
}
|
|
445
449
|
function readMcpConfig() {
|
|
446
|
-
if (!existsSync(
|
|
450
|
+
if (!existsSync(ClAUDE_CONFIG_FILE)) {
|
|
447
451
|
return null;
|
|
448
452
|
}
|
|
449
453
|
try {
|
|
450
|
-
const content = readFileSync(
|
|
454
|
+
const content = readFileSync(ClAUDE_CONFIG_FILE, "utf-8");
|
|
451
455
|
return JSON.parse(content);
|
|
452
456
|
} catch (error) {
|
|
453
457
|
console.error("Failed to parse MCP config:", error);
|
|
@@ -455,14 +459,14 @@ function readMcpConfig() {
|
|
|
455
459
|
}
|
|
456
460
|
}
|
|
457
461
|
function writeMcpConfig(config) {
|
|
458
|
-
const dir = dirname(
|
|
462
|
+
const dir = dirname(ClAUDE_CONFIG_FILE);
|
|
459
463
|
if (!existsSync(dir)) {
|
|
460
464
|
mkdirSync(dir, { recursive: true });
|
|
461
465
|
}
|
|
462
|
-
writeFileSync(
|
|
466
|
+
writeFileSync(ClAUDE_CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
463
467
|
}
|
|
464
468
|
function backupMcpConfig() {
|
|
465
|
-
if (!existsSync(
|
|
469
|
+
if (!existsSync(ClAUDE_CONFIG_FILE)) {
|
|
466
470
|
return null;
|
|
467
471
|
}
|
|
468
472
|
const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
|
|
@@ -472,7 +476,7 @@ function backupMcpConfig() {
|
|
|
472
476
|
if (!existsSync(backupBaseDir)) {
|
|
473
477
|
mkdirSync(backupBaseDir, { recursive: true });
|
|
474
478
|
}
|
|
475
|
-
const content = readFileSync(
|
|
479
|
+
const content = readFileSync(ClAUDE_CONFIG_FILE, "utf-8");
|
|
476
480
|
writeFileSync(backupPath, content);
|
|
477
481
|
return backupPath;
|
|
478
482
|
} catch (error) {
|
|
@@ -501,6 +505,19 @@ function buildMcpServerConfig(baseConfig, apiKey, placeholder = "YOUR_EXA_API_KE
|
|
|
501
505
|
}
|
|
502
506
|
return config;
|
|
503
507
|
}
|
|
508
|
+
function addCompletedOnboarding() {
|
|
509
|
+
try {
|
|
510
|
+
let config = readMcpConfig();
|
|
511
|
+
if (!config) {
|
|
512
|
+
config = { mcpServers: {} };
|
|
513
|
+
}
|
|
514
|
+
config.hasCompletedOnboarding = true;
|
|
515
|
+
writeMcpConfig(config);
|
|
516
|
+
} catch (error) {
|
|
517
|
+
console.error("Failed to add hasCompletedOnboarding flag:", error);
|
|
518
|
+
throw error;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
504
521
|
|
|
505
522
|
function readZcfConfig() {
|
|
506
523
|
try {
|
|
@@ -609,6 +626,42 @@ async function resolveAiOutputLanguage(scriptLang, commandLineOption, savedConfi
|
|
|
609
626
|
return await selectAiOutputLanguage(scriptLang, scriptLang);
|
|
610
627
|
}
|
|
611
628
|
|
|
629
|
+
function validateApiKey(apiKey, lang = "zh-CN") {
|
|
630
|
+
const i18n = I18N[lang];
|
|
631
|
+
if (!apiKey || apiKey.trim() === "") {
|
|
632
|
+
return {
|
|
633
|
+
isValid: false,
|
|
634
|
+
error: i18n.apiKeyValidation.empty
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
const apiKeyPattern = /^[A-Za-z0-9_-]+$/;
|
|
638
|
+
if (!apiKeyPattern.test(apiKey)) {
|
|
639
|
+
return {
|
|
640
|
+
isValid: false,
|
|
641
|
+
error: i18n.apiKeyValidation.invalid
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
if (apiKey.length < 1) {
|
|
645
|
+
return {
|
|
646
|
+
isValid: false,
|
|
647
|
+
error: i18n.apiKeyValidation.tooShort
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
if (apiKey.length > 256) {
|
|
651
|
+
return {
|
|
652
|
+
isValid: false,
|
|
653
|
+
error: i18n.apiKeyValidation.tooLong
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
return { isValid: true };
|
|
657
|
+
}
|
|
658
|
+
function formatApiKeyDisplay(apiKey) {
|
|
659
|
+
if (!apiKey || apiKey.length < 12) {
|
|
660
|
+
return apiKey;
|
|
661
|
+
}
|
|
662
|
+
return `${apiKey.substring(0, 8)}...${apiKey.substring(apiKey.length - 4)}`;
|
|
663
|
+
}
|
|
664
|
+
|
|
612
665
|
async function updatePromptOnly(configLang, scriptLang, aiOutputLang) {
|
|
613
666
|
const i18n = I18N[scriptLang];
|
|
614
667
|
const backupDir = backupExistingConfig();
|
|
@@ -750,13 +803,23 @@ async function init(options = {}) {
|
|
|
750
803
|
type: "text",
|
|
751
804
|
name: "key",
|
|
752
805
|
message: keyMessage,
|
|
753
|
-
validate: (value) =>
|
|
806
|
+
validate: (value) => {
|
|
807
|
+
if (!value) {
|
|
808
|
+
return `${apiChoice === "auth_token" ? "Auth Token" : "API Key"} is required`;
|
|
809
|
+
}
|
|
810
|
+
const validation = validateApiKey(value, scriptLang);
|
|
811
|
+
if (!validation.isValid) {
|
|
812
|
+
return validation.error || "Invalid API Key format";
|
|
813
|
+
}
|
|
814
|
+
return true;
|
|
815
|
+
}
|
|
754
816
|
});
|
|
755
817
|
if (keyResponse.key === void 0) {
|
|
756
818
|
console.log(ansis.yellow(i18n.cancelled));
|
|
757
819
|
process.exit(0);
|
|
758
820
|
}
|
|
759
821
|
const key = keyResponse.key;
|
|
822
|
+
console.log(ansis.gray(` API Key: ${formatApiKeyDisplay(key)}`));
|
|
760
823
|
apiConfig = { url, key, authType: apiChoice };
|
|
761
824
|
}
|
|
762
825
|
}
|
|
@@ -783,8 +846,17 @@ async function init(options = {}) {
|
|
|
783
846
|
}
|
|
784
847
|
applyAiLanguageDirective(aiOutputLang);
|
|
785
848
|
if (apiConfig && !onlyUpdateDocs) {
|
|
786
|
-
configureApi(apiConfig);
|
|
787
|
-
|
|
849
|
+
const configuredApi = configureApi(apiConfig);
|
|
850
|
+
if (configuredApi) {
|
|
851
|
+
console.log(ansis.green(`\u2714 ${i18n.apiConfigSuccess}`));
|
|
852
|
+
console.log(ansis.gray(` URL: ${configuredApi.url}`));
|
|
853
|
+
console.log(ansis.gray(` Key: ${formatApiKeyDisplay(configuredApi.key)}`));
|
|
854
|
+
try {
|
|
855
|
+
addCompletedOnboarding();
|
|
856
|
+
} catch (error) {
|
|
857
|
+
console.error(ansis.red("Failed to set onboarding completion flag:"), error);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
788
860
|
}
|
|
789
861
|
if (!onlyUpdateDocs) {
|
|
790
862
|
const mcpResponse = await prompts({
|
|
@@ -879,4 +951,4 @@ async function init(options = {}) {
|
|
|
879
951
|
}
|
|
880
952
|
}
|
|
881
953
|
|
|
882
|
-
export { AI_OUTPUT_LANGUAGES as A,
|
|
954
|
+
export { AI_OUTPUT_LANGUAGES as A, updateZcfConfig as B, CLAUDE_DIR as C, version as D, I18N as I, LANG_LABELS as L, MCP_SERVICES as M, SETTINGS_FILE as S, ZCF_CONFIG_FILE as Z, CLAUDE_MD_FILE as a, ClAUDE_CONFIG_FILE as b, commandExists as c, SUPPORTED_LANGS as d, isClaudeCodeInstalled as e, installClaudeCode as f, getPlatform as g, ensureClaudeDir as h, init as i, backupExistingConfig as j, copyConfigFiles as k, configureApi as l, mergeConfigs as m, applyAiLanguageDirective as n, getMcpConfigPath as o, backupMcpConfig as p, mergeMcpServers as q, readMcpConfig as r, buildMcpServerConfig as s, addCompletedOnboarding as t, displayBanner as u, selectScriptLanguage as v, writeMcpConfig as w, readZcfConfig as x, resolveAiOutputLanguage as y, updatePromptOnly as z };
|
package/package.json
CHANGED
package/templates/settings.json
CHANGED