zcf 1.1.5 → 1.2.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/README.md CHANGED
@@ -285,6 +285,16 @@ node bin/zcf.mjs
285
285
  2. 检查 `~/.claude/` 目录下的配置文件
286
286
  3. 确保 Claude Code 已正确安装
287
287
 
288
+ ### Windows 平台支持
289
+
290
+ ZCF 已完全支持 Windows 平台:
291
+
292
+ - **自动检测**:在 Windows 系统上会自动使用兼容的 `cmd /c npx` 格式
293
+ - **配置修复**:现有的错误配置会在更新时自动修复
294
+ - **零配置**:Windows 用户无需任何额外操作,与 macOS/Linux 体验一致
295
+
296
+ 如果在 Windows 上遇到 MCP 连接问题,运行 `npx zcf` 会自动修复配置格式。
297
+
288
298
  ## 🙏 鸣谢
289
299
 
290
300
  本项目的部分 Prompt 参考了以下优秀作品:
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.CeJug3gT.mjs';
4
+ import { v as displayBanner, x as selectScriptLanguage, y as readZcfConfig, I as I18N, S as SETTINGS_FILE, d as SUPPORTED_LANGS, L as LANG_LABELS, z as resolveAiOutputLanguage, B as updatePromptOnly, D as updateZcfConfig, E as version, i as init } from './shared/zcf.D3MMT8L8.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 McpConfiguration {
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 MCP_CONFIG_FILE: string;
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];
@@ -206,11 +207,13 @@ declare function mergeConfigs(sourceFile: string, targetFile: string): void;
206
207
  declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
207
208
 
208
209
  declare function getMcpConfigPath(): string;
209
- declare function readMcpConfig(): McpConfiguration | null;
210
- declare function writeMcpConfig(config: McpConfiguration): void;
210
+ declare function readMcpConfig(): ClaudeConfiguration | null;
211
+ declare function writeMcpConfig(config: ClaudeConfiguration): void;
211
212
  declare function backupMcpConfig(): string | null;
212
- declare function mergeMcpServers(existing: McpConfiguration | null, newServers: Record<string, McpServerConfig>): McpConfiguration;
213
+ declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
213
214
  declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
215
+ declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
216
+ declare function addCompletedOnboarding(): void;
214
217
 
215
- export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
216
- export type { AiOutputLanguage, ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
218
+ 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, fixWindowsMcpConfig, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
219
+ 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 McpConfiguration {
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 MCP_CONFIG_FILE: string;
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];
@@ -206,11 +207,13 @@ declare function mergeConfigs(sourceFile: string, targetFile: string): void;
206
207
  declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void;
207
208
 
208
209
  declare function getMcpConfigPath(): string;
209
- declare function readMcpConfig(): McpConfiguration | null;
210
- declare function writeMcpConfig(config: McpConfiguration): void;
210
+ declare function readMcpConfig(): ClaudeConfiguration | null;
211
+ declare function writeMcpConfig(config: ClaudeConfiguration): void;
211
212
  declare function backupMcpConfig(): string | null;
212
- declare function mergeMcpServers(existing: McpConfiguration | null, newServers: Record<string, McpServerConfig>): McpConfiguration;
213
+ declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
213
214
  declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
215
+ declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
216
+ declare function addCompletedOnboarding(): void;
214
217
 
215
- export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, I18N, LANG_LABELS, MCP_CONFIG_FILE, MCP_SERVICES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_FILE, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
216
- export type { AiOutputLanguage, ApiConfig, McpConfiguration, McpServerConfig, McpService, SupportedLang };
218
+ 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, fixWindowsMcpConfig, getMcpConfigPath, getPlatform, init, installClaudeCode, isClaudeCodeInstalled, mergeConfigs, mergeMcpServers, readMcpConfig, writeMcpConfig };
219
+ 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 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.CeJug3gT.mjs';
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, u 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, t as fixWindowsMcpConfig, 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.D3MMT8L8.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.5";
9
+ const version = "1.2.0";
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 MCP_CONFIG_FILE = join(homedir(), ".claude.json");
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 = {
@@ -415,6 +415,15 @@ function getPlatform() {
415
415
  if (p === "darwin") return "macos";
416
416
  return "linux";
417
417
  }
418
+ function isWindows() {
419
+ return getPlatform() === "windows";
420
+ }
421
+ function getMcpCommand() {
422
+ if (isWindows()) {
423
+ return ["cmd", "/c", "npx"];
424
+ }
425
+ return ["npx"];
426
+ }
418
427
  async function commandExists(command) {
419
428
  try {
420
429
  const cmd = getPlatform() === "windows" ? "where" : "which";
@@ -444,14 +453,14 @@ async function installClaudeCode(lang) {
444
453
  }
445
454
 
446
455
  function getMcpConfigPath() {
447
- return MCP_CONFIG_FILE;
456
+ return ClAUDE_CONFIG_FILE;
448
457
  }
449
458
  function readMcpConfig() {
450
- if (!existsSync(MCP_CONFIG_FILE)) {
459
+ if (!existsSync(ClAUDE_CONFIG_FILE)) {
451
460
  return null;
452
461
  }
453
462
  try {
454
- const content = readFileSync(MCP_CONFIG_FILE, "utf-8");
463
+ const content = readFileSync(ClAUDE_CONFIG_FILE, "utf-8");
455
464
  return JSON.parse(content);
456
465
  } catch (error) {
457
466
  console.error("Failed to parse MCP config:", error);
@@ -459,14 +468,14 @@ function readMcpConfig() {
459
468
  }
460
469
  }
461
470
  function writeMcpConfig(config) {
462
- const dir = dirname(MCP_CONFIG_FILE);
471
+ const dir = dirname(ClAUDE_CONFIG_FILE);
463
472
  if (!existsSync(dir)) {
464
473
  mkdirSync(dir, { recursive: true });
465
474
  }
466
- writeFileSync(MCP_CONFIG_FILE, JSON.stringify(config, null, 2));
475
+ writeFileSync(ClAUDE_CONFIG_FILE, JSON.stringify(config, null, 2));
467
476
  }
468
477
  function backupMcpConfig() {
469
- if (!existsSync(MCP_CONFIG_FILE)) {
478
+ if (!existsSync(ClAUDE_CONFIG_FILE)) {
470
479
  return null;
471
480
  }
472
481
  const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
@@ -476,7 +485,7 @@ function backupMcpConfig() {
476
485
  if (!existsSync(backupBaseDir)) {
477
486
  mkdirSync(backupBaseDir, { recursive: true });
478
487
  }
479
- const content = readFileSync(MCP_CONFIG_FILE, "utf-8");
488
+ const content = readFileSync(ClAUDE_CONFIG_FILE, "utf-8");
480
489
  writeFileSync(backupPath, content);
481
490
  return backupPath;
482
491
  } catch (error) {
@@ -492,11 +501,19 @@ function mergeMcpServers(existing, newServers) {
492
501
  Object.assign(config.mcpServers, newServers);
493
502
  return config;
494
503
  }
504
+ function applyPlatformCommand(config) {
505
+ if (config.command === "npx" && isWindows()) {
506
+ const mcpCmd = getMcpCommand();
507
+ config.command = mcpCmd[0];
508
+ config.args = [...mcpCmd.slice(1), ...config.args || []];
509
+ }
510
+ }
495
511
  function buildMcpServerConfig(baseConfig, apiKey, placeholder = "YOUR_EXA_API_KEY") {
512
+ const config = JSON.parse(JSON.stringify(baseConfig));
513
+ applyPlatformCommand(config);
496
514
  if (!apiKey) {
497
- return { ...baseConfig };
515
+ return config;
498
516
  }
499
- const config = JSON.parse(JSON.stringify(baseConfig));
500
517
  if (config.args) {
501
518
  config.args = config.args.map((arg) => arg.replace(placeholder, apiKey));
502
519
  }
@@ -505,6 +522,32 @@ function buildMcpServerConfig(baseConfig, apiKey, placeholder = "YOUR_EXA_API_KE
505
522
  }
506
523
  return config;
507
524
  }
525
+ function fixWindowsMcpConfig(config) {
526
+ if (!isWindows() || !config.mcpServers) {
527
+ return config;
528
+ }
529
+ const fixed = { ...config };
530
+ for (const [, serverConfig] of Object.entries(fixed.mcpServers)) {
531
+ if (serverConfig && typeof serverConfig === "object" && "command" in serverConfig) {
532
+ applyPlatformCommand(serverConfig);
533
+ }
534
+ }
535
+ return fixed;
536
+ }
537
+ function addCompletedOnboarding() {
538
+ try {
539
+ let config = readMcpConfig();
540
+ if (!config) {
541
+ config = { mcpServers: {} };
542
+ }
543
+ config.hasCompletedOnboarding = true;
544
+ config = fixWindowsMcpConfig(config);
545
+ writeMcpConfig(config);
546
+ } catch (error) {
547
+ console.error("Failed to add hasCompletedOnboarding flag:", error);
548
+ throw error;
549
+ }
550
+ }
508
551
 
509
552
  function readZcfConfig() {
510
553
  try {
@@ -838,6 +881,11 @@ async function init(options = {}) {
838
881
  console.log(ansis.green(`\u2714 ${i18n.apiConfigSuccess}`));
839
882
  console.log(ansis.gray(` URL: ${configuredApi.url}`));
840
883
  console.log(ansis.gray(` Key: ${formatApiKeyDisplay(configuredApi.key)}`));
884
+ try {
885
+ addCompletedOnboarding();
886
+ } catch (error) {
887
+ console.error(ansis.red("Failed to set onboarding completion flag:"), error);
888
+ }
841
889
  }
842
890
  }
843
891
  if (!onlyUpdateDocs) {
@@ -852,6 +900,9 @@ async function init(options = {}) {
852
900
  process.exit(0);
853
901
  }
854
902
  if (mcpResponse.shouldConfigureMcp) {
903
+ if (isWindows()) {
904
+ console.log(ansis.blue(`\u2139 ${scriptLang === "zh-CN" ? "\u68C0\u6D4B\u5230 Windows \u7CFB\u7EDF\uFF0C\u5C06\u81EA\u52A8\u914D\u7F6E\u517C\u5BB9\u683C\u5F0F" : "Windows detected, will configure compatible format"}`));
905
+ }
855
906
  const choices = [
856
907
  {
857
908
  title: ansis.bold(i18n.allServices),
@@ -910,7 +961,8 @@ async function init(options = {}) {
910
961
  newServers[service.id] = config;
911
962
  }
912
963
  const existingConfig = readMcpConfig();
913
- const mergedConfig = mergeMcpServers(existingConfig, newServers);
964
+ let mergedConfig = mergeMcpServers(existingConfig, newServers);
965
+ mergedConfig = fixWindowsMcpConfig(mergedConfig);
914
966
  try {
915
967
  writeMcpConfig(mergedConfig);
916
968
  console.log(ansis.green(`\u2714 ${i18n.mcpConfigSuccess}`));
@@ -933,4 +985,4 @@ async function init(options = {}) {
933
985
  }
934
986
  }
935
987
 
936
- export { AI_OUTPUT_LANGUAGES as A, version as B, CLAUDE_DIR as C, I18N as I, LANG_LABELS as L, MCP_CONFIG_FILE as M, SETTINGS_FILE as S, ZCF_CONFIG_FILE as Z, CLAUDE_MD_FILE as a, SUPPORTED_LANGS as b, commandExists as c, MCP_SERVICES 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, displayBanner as t, selectScriptLanguage as u, readZcfConfig as v, writeMcpConfig as w, resolveAiOutputLanguage as x, updatePromptOnly as y, updateZcfConfig as z };
988
+ export { AI_OUTPUT_LANGUAGES as A, updatePromptOnly as B, CLAUDE_DIR as C, updateZcfConfig as D, version as E, 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, fixWindowsMcpConfig as t, addCompletedOnboarding as u, displayBanner as v, writeMcpConfig as w, selectScriptLanguage as x, readZcfConfig as y, resolveAiOutputLanguage as z };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zcf",
3
3
  "type": "module",
4
- "version": "1.1.5",
4
+ "version": "1.2.0",
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",