zcf 1.1.3 → 1.1.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.
package/README.md CHANGED
@@ -75,9 +75,11 @@ npx zcf u # 仅导入工作流:快速添加 AI 工作流和命令系统
75
75
 
76
76
  ### 🔐 API 配置
77
77
 
78
- - 自定义 API 支持
79
- - API Key 自动配置
80
- - 支持稍后在 claude 命令中配置(如 OAuth)
78
+ - 支持两种认证方式:
79
+ - **Auth Token**:适用于通过 OAuth 或浏览器登录获取的令牌
80
+ - **API Key**:适用于从 Anthropic Console 获取的 API 密钥
81
+ - 自定义 API URL 支持
82
+ - 支持稍后在 claude 命令中配置
81
83
 
82
84
  ### 💾 配置管理
83
85
 
@@ -112,12 +114,15 @@ $ npx zcf
112
114
 
113
115
  ✔ Claude Code 安装成功
114
116
 
115
- ? 是否配置 API
116
- 配置 API
117
- 跳过(稍后在 claude 命令中自行配置,如 OAuth)
117
+ ? 选择 API 认证方式
118
+ 使用 Auth Token (OAuth 认证)
119
+ 适用于通过 OAuth 或浏览器登录获取的令牌
120
+ 使用 API Key (密钥认证)
121
+ 适用于从 Anthropic Console 获取的 API 密钥
122
+ 跳过(稍后手动配置)
118
123
 
119
124
  ? 请输入 API URL: https://api.anthropic.com
120
- ? 请输入 API Key: sk-xxx
125
+ ? 请输入 Auth Token 或 API Key: xxx
121
126
 
122
127
  ? 检测到已有配置文件,如何处理?
123
128
  ❯ 备份并覆盖全部
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 { t as displayBanner, u as selectScriptLanguage, v as readZcfConfig, I as I18N, S as SETTINGS_FILE, b as SUPPORTED_LANGS, L as LANG_LABELS, x as resolveAiOutputLanguage, y as updatePromptOnly, z as updateZcfConfig, B as version, i as init } from './shared/zcf.EL2e1-Wq.mjs';
4
+ import { t as displayBanner, u as selectScriptLanguage, v as readZcfConfig, I as I18N, S as SETTINGS_FILE, b as SUPPORTED_LANGS, L as LANG_LABELS, x as resolveAiOutputLanguage, y as updatePromptOnly, z as updateZcfConfig, B as version, i as init } from './shared/zcf.DK7kfRoM.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
@@ -70,9 +70,13 @@ declare const I18N: {
70
70
  installFailed: string;
71
71
  npmNotFound: string;
72
72
  configureApi: string;
73
- customApi: string;
73
+ useAuthToken: string;
74
+ authTokenDesc: string;
75
+ useApiKey: string;
76
+ apiKeyDesc: string;
74
77
  skipApi: string;
75
78
  enterApiUrl: string;
79
+ enterAuthToken: string;
76
80
  enterApiKey: string;
77
81
  existingConfig: string;
78
82
  backupAndOverwrite: string;
@@ -120,9 +124,13 @@ declare const I18N: {
120
124
  installFailed: string;
121
125
  npmNotFound: string;
122
126
  configureApi: string;
123
- customApi: string;
127
+ useAuthToken: string;
128
+ authTokenDesc: string;
129
+ useApiKey: string;
130
+ apiKeyDesc: string;
124
131
  skipApi: string;
125
132
  enterApiUrl: string;
133
+ enterAuthToken: string;
126
134
  enterApiKey: string;
127
135
  existingConfig: string;
128
136
  backupAndOverwrite: string;
@@ -177,6 +185,7 @@ declare function copyConfigFiles(lang: SupportedLang, onlyMd?: boolean): void;
177
185
  interface ApiConfig {
178
186
  url: string;
179
187
  key: string;
188
+ authType?: 'auth_token' | 'api_key';
180
189
  }
181
190
  declare function configureApi(apiConfig: ApiConfig | null): void;
182
191
  declare function mergeConfigs(sourceFile: string, targetFile: string): void;
package/dist/index.d.ts CHANGED
@@ -70,9 +70,13 @@ declare const I18N: {
70
70
  installFailed: string;
71
71
  npmNotFound: string;
72
72
  configureApi: string;
73
- customApi: string;
73
+ useAuthToken: string;
74
+ authTokenDesc: string;
75
+ useApiKey: string;
76
+ apiKeyDesc: string;
74
77
  skipApi: string;
75
78
  enterApiUrl: string;
79
+ enterAuthToken: string;
76
80
  enterApiKey: string;
77
81
  existingConfig: string;
78
82
  backupAndOverwrite: string;
@@ -120,9 +124,13 @@ declare const I18N: {
120
124
  installFailed: string;
121
125
  npmNotFound: string;
122
126
  configureApi: string;
123
- customApi: string;
127
+ useAuthToken: string;
128
+ authTokenDesc: string;
129
+ useApiKey: string;
130
+ apiKeyDesc: string;
124
131
  skipApi: string;
125
132
  enterApiUrl: string;
133
+ enterAuthToken: string;
126
134
  enterApiKey: string;
127
135
  existingConfig: string;
128
136
  backupAndOverwrite: string;
@@ -177,6 +185,7 @@ declare function copyConfigFiles(lang: SupportedLang, onlyMd?: boolean): void;
177
185
  interface ApiConfig {
178
186
  url: string;
179
187
  key: string;
188
+ authType?: 'auth_token' | 'api_key';
180
189
  }
181
190
  declare function configureApi(apiConfig: ApiConfig | null): void;
182
191
  declare function mergeConfigs(sourceFile: string, targetFile: string): void;
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 MCP_CONFIG_FILE, d as MCP_SERVICES, S as SETTINGS_FILE, b as SUPPORTED_LANGS, Z as ZCF_CONFIG_FILE, 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.EL2e1-Wq.mjs';
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 MCP_CONFIG_FILE, d as MCP_SERVICES, S as SETTINGS_FILE, b as SUPPORTED_LANGS, Z as ZCF_CONFIG_FILE, 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.DK7kfRoM.mjs';
2
2
  import '@posva/prompts';
3
3
  import 'ansis';
4
4
  import 'node:fs';
@@ -6,7 +6,7 @@ import { join, dirname } from 'pathe';
6
6
  import dayjs from 'dayjs';
7
7
  import { exec } from 'tinyexec';
8
8
 
9
- const version = "1.1.3";
9
+ const version = "1.1.4";
10
10
 
11
11
  const CLAUDE_DIR = join(homedir(), ".claude");
12
12
  const SETTINGS_FILE = join(CLAUDE_DIR, "settings.json");
@@ -39,10 +39,14 @@ const I18N = {
39
39
  installSuccess: "Claude Code \u5B89\u88C5\u6210\u529F",
40
40
  installFailed: "Claude Code \u5B89\u88C5\u5931\u8D25",
41
41
  npmNotFound: "npm \u672A\u5B89\u88C5\u3002\u8BF7\u5148\u5B89\u88C5 Node.js \u548C npm\u3002",
42
- configureApi: "\u662F\u5426\u914D\u7F6E API\uFF1F",
43
- customApi: "\u914D\u7F6E API",
44
- skipApi: "\u8DF3\u8FC7\uFF08\u7A0D\u540E\u5728 claude \u547D\u4EE4\u4E2D\u81EA\u884C\u914D\u7F6E\uFF0C\u5982 OAuth\uFF09",
42
+ configureApi: "\u9009\u62E9 API \u8BA4\u8BC1\u65B9\u5F0F",
43
+ useAuthToken: "\u4F7F\u7528 Auth Token (OAuth \u8BA4\u8BC1)",
44
+ authTokenDesc: "\u9002\u7528\u4E8E\u901A\u8FC7 OAuth \u6216\u6D4F\u89C8\u5668\u767B\u5F55\u83B7\u53D6\u7684\u4EE4\u724C",
45
+ useApiKey: "\u4F7F\u7528 API Key (\u5BC6\u94A5\u8BA4\u8BC1)",
46
+ apiKeyDesc: "\u9002\u7528\u4E8E\u4ECE Anthropic Console \u83B7\u53D6\u7684 API \u5BC6\u94A5",
47
+ skipApi: "\u8DF3\u8FC7\uFF08\u7A0D\u540E\u624B\u52A8\u914D\u7F6E\uFF09",
45
48
  enterApiUrl: "\u8BF7\u8F93\u5165 API URL",
49
+ enterAuthToken: "\u8BF7\u8F93\u5165 Auth Token",
46
50
  enterApiKey: "\u8BF7\u8F93\u5165 API Key",
47
51
  existingConfig: "\u68C0\u6D4B\u5230\u5DF2\u6709\u914D\u7F6E\u6587\u4EF6\uFF0C\u5982\u4F55\u5904\u7406\uFF1F",
48
52
  backupAndOverwrite: "\u5907\u4EFD\u5E76\u8986\u76D6\u5168\u90E8",
@@ -89,10 +93,14 @@ const I18N = {
89
93
  installSuccess: "Claude Code installed successfully",
90
94
  installFailed: "Failed to install Claude Code",
91
95
  npmNotFound: "npm is not installed. Please install Node.js and npm first.",
92
- configureApi: "Configure API?",
93
- customApi: "Configure API",
94
- skipApi: "Skip (configure later in claude command, e.g., OAuth)",
96
+ configureApi: "Select API authentication method",
97
+ useAuthToken: "Use Auth Token (OAuth authentication)",
98
+ authTokenDesc: "For tokens obtained via OAuth or browser login",
99
+ useApiKey: "Use API Key (Key authentication)",
100
+ apiKeyDesc: "For API keys from Anthropic Console",
101
+ skipApi: "Skip (configure manually later)",
95
102
  enterApiUrl: "Enter API URL",
103
+ enterAuthToken: "Enter Auth Token",
96
104
  enterApiKey: "Enter API Key",
97
105
  existingConfig: "Existing config detected. How to proceed?",
98
106
  backupAndOverwrite: "Backup and overwrite all",
@@ -338,7 +346,11 @@ function configureApi(apiConfig) {
338
346
  console.error("Failed to parse existing settings.json, using defaults:", error);
339
347
  }
340
348
  }
341
- settings.env.ANTHROPIC_AUTH_TOKEN = apiConfig.key;
349
+ if (apiConfig.authType === "api_key") {
350
+ settings.env.ANTHROPIC_API_KEY = apiConfig.key;
351
+ } else {
352
+ settings.env.ANTHROPIC_AUTH_TOKEN = apiConfig.key;
353
+ }
342
354
  settings.env.ANTHROPIC_BASE_URL = apiConfig.url;
343
355
  writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2));
344
356
  }
@@ -692,8 +704,20 @@ async function init(options = {}) {
692
704
  name: "apiChoice",
693
705
  message: i18n.configureApi,
694
706
  choices: [
695
- { title: i18n.customApi, value: "custom" },
696
- { title: i18n.skipApi, value: "skip" }
707
+ {
708
+ title: i18n.useAuthToken,
709
+ value: "auth_token",
710
+ description: ansis.gray(i18n.authTokenDesc)
711
+ },
712
+ {
713
+ title: i18n.useApiKey,
714
+ value: "api_key",
715
+ description: ansis.gray(i18n.apiKeyDesc)
716
+ },
717
+ {
718
+ title: i18n.skipApi,
719
+ value: "skip"
720
+ }
697
721
  ]
698
722
  });
699
723
  if (!apiResponse.apiChoice) {
@@ -701,7 +725,7 @@ async function init(options = {}) {
701
725
  process.exit(0);
702
726
  }
703
727
  const apiChoice = apiResponse.apiChoice;
704
- if (apiChoice === "custom") {
728
+ if (apiChoice === "auth_token" || apiChoice === "api_key") {
705
729
  const urlResponse = await prompts({
706
730
  type: "text",
707
731
  name: "url",
@@ -721,18 +745,19 @@ async function init(options = {}) {
721
745
  process.exit(0);
722
746
  }
723
747
  const url = urlResponse.url;
748
+ const keyMessage = apiChoice === "auth_token" ? i18n.enterAuthToken : i18n.enterApiKey;
724
749
  const keyResponse = await prompts({
725
750
  type: "text",
726
751
  name: "key",
727
- message: i18n.enterApiKey,
728
- validate: (value) => !!value || "API Key is required"
752
+ message: keyMessage,
753
+ validate: (value) => !!value || `${apiChoice === "auth_token" ? "Auth Token" : "API Key"} is required`
729
754
  });
730
755
  if (keyResponse.key === void 0) {
731
756
  console.log(ansis.yellow(i18n.cancelled));
732
757
  process.exit(0);
733
758
  }
734
759
  const key = keyResponse.key;
735
- apiConfig = { url, key };
760
+ apiConfig = { url, key, authType: apiChoice };
736
761
  }
737
762
  }
738
763
  if (action === "backup") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zcf",
3
3
  "type": "module",
4
- "version": "1.1.3",
4
+ "version": "1.1.4",
5
5
  "description": "Zero-Config Claude-Code Flow - One-click configuration tool for Claude Code",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/UfoMiao/zcf#readme",