zcf 1.1.6 → 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 +10 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{zcf.Dke_fzoC.mjs → zcf.D3MMT8L8.mjs} +39 -5
- package/package.json +1 -1
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 {
|
|
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
|
@@ -212,7 +212,8 @@ declare function writeMcpConfig(config: ClaudeConfiguration): void;
|
|
|
212
212
|
declare function backupMcpConfig(): string | null;
|
|
213
213
|
declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
|
|
214
214
|
declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
|
|
215
|
+
declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
|
|
215
216
|
declare function addCompletedOnboarding(): void;
|
|
216
217
|
|
|
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 { 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 };
|
|
218
219
|
export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, McpServerConfig, McpService, SupportedLang };
|
package/dist/index.d.ts
CHANGED
|
@@ -212,7 +212,8 @@ declare function writeMcpConfig(config: ClaudeConfiguration): void;
|
|
|
212
212
|
declare function backupMcpConfig(): string | null;
|
|
213
213
|
declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration;
|
|
214
214
|
declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string): McpServerConfig;
|
|
215
|
+
declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration;
|
|
215
216
|
declare function addCompletedOnboarding(): void;
|
|
216
217
|
|
|
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 { 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 };
|
|
218
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, 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,
|
|
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,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.
|
|
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");
|
|
@@ -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";
|
|
@@ -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
|
|
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,18 @@ 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
|
+
}
|
|
508
537
|
function addCompletedOnboarding() {
|
|
509
538
|
try {
|
|
510
539
|
let config = readMcpConfig();
|
|
@@ -512,6 +541,7 @@ function addCompletedOnboarding() {
|
|
|
512
541
|
config = { mcpServers: {} };
|
|
513
542
|
}
|
|
514
543
|
config.hasCompletedOnboarding = true;
|
|
544
|
+
config = fixWindowsMcpConfig(config);
|
|
515
545
|
writeMcpConfig(config);
|
|
516
546
|
} catch (error) {
|
|
517
547
|
console.error("Failed to add hasCompletedOnboarding flag:", error);
|
|
@@ -870,6 +900,9 @@ async function init(options = {}) {
|
|
|
870
900
|
process.exit(0);
|
|
871
901
|
}
|
|
872
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
|
+
}
|
|
873
906
|
const choices = [
|
|
874
907
|
{
|
|
875
908
|
title: ansis.bold(i18n.allServices),
|
|
@@ -928,7 +961,8 @@ async function init(options = {}) {
|
|
|
928
961
|
newServers[service.id] = config;
|
|
929
962
|
}
|
|
930
963
|
const existingConfig = readMcpConfig();
|
|
931
|
-
|
|
964
|
+
let mergedConfig = mergeMcpServers(existingConfig, newServers);
|
|
965
|
+
mergedConfig = fixWindowsMcpConfig(mergedConfig);
|
|
932
966
|
try {
|
|
933
967
|
writeMcpConfig(mergedConfig);
|
|
934
968
|
console.log(ansis.green(`\u2714 ${i18n.mcpConfigSuccess}`));
|
|
@@ -951,4 +985,4 @@ async function init(options = {}) {
|
|
|
951
985
|
}
|
|
952
986
|
}
|
|
953
987
|
|
|
954
|
-
export { AI_OUTPUT_LANGUAGES as A,
|
|
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