zcf 2.4.0 → 2.4.1
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 +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{zcf.BvmvOF3q.mjs → zcf.CYdvtE_u.mjs} +53 -13
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import ansis from 'ansis';
|
|
3
3
|
import cac from 'cac';
|
|
4
|
-
import {
|
|
4
|
+
import { h as SUPPORTED_LANGS, I as I18N, L as LANG_LABELS, G as updateZcfConfig, Z as ZCF_CONFIG_FILE, o as openSettingsJson, b as importRecommendedPermissions, a as importRecommendedEnv, H as readZcfConfig, J as resolveAiOutputLanguage, v as applyAiLanguageDirective, K as configureAiPersonality, u as updateDefaultModel, N as isWindows, x as readMcpConfig, E as fixWindowsMcpConfig, y as writeMcpConfig, O as selectMcpServices, z as backupMcpConfig, M as MCP_SERVICES, D as buildMcpServerConfig, B as mergeMcpServers, t as getExistingApiConfig, P as formatApiKeyDisplay, Q as modifyApiConfigPartially, R as validateApiKey, q as configureApi, T as displayBanner, U as selectScriptLanguage, S as SETTINGS_FILE, V as updatePromptOnly, W as version, X as handleExitPromptError, Y as handleGeneralError, _ as displayBannerWithInfo, i as init } from './shared/zcf.CYdvtE_u.mjs';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import { existsSync, unlinkSync } from 'node:fs';
|
|
7
7
|
import 'pathe';
|
package/dist/index.d.mts
CHANGED
|
@@ -224,6 +224,7 @@ declare const I18N: {
|
|
|
224
224
|
permissionsImportSuccess: string;
|
|
225
225
|
openingSettingsJson: string;
|
|
226
226
|
spaceToSelectReturn: string;
|
|
227
|
+
windowsDetected: string;
|
|
227
228
|
};
|
|
228
229
|
en: {
|
|
229
230
|
selectScriptLang: string;
|
|
@@ -394,6 +395,7 @@ declare const I18N: {
|
|
|
394
395
|
permissionsImportSuccess: string;
|
|
395
396
|
openingSettingsJson: string;
|
|
396
397
|
spaceToSelectReturn: string;
|
|
398
|
+
windowsDetected: string;
|
|
397
399
|
};
|
|
398
400
|
};
|
|
399
401
|
declare const MCP_SERVICES: McpService[];
|
|
@@ -452,5 +454,25 @@ declare function importRecommendedEnv(): Promise<void>;
|
|
|
452
454
|
declare function importRecommendedPermissions(): Promise<void>;
|
|
453
455
|
declare function openSettingsJson(): Promise<void>;
|
|
454
456
|
|
|
455
|
-
|
|
457
|
+
/**
|
|
458
|
+
* Clean up and deduplicate permissions array
|
|
459
|
+
* Removes invalid and redundant permissions based on template
|
|
460
|
+
*/
|
|
461
|
+
/**
|
|
462
|
+
* Clean up permissions array by removing invalid and redundant entries
|
|
463
|
+
* @param templatePermissions - Permissions from template (source of truth)
|
|
464
|
+
* @param userPermissions - User's existing permissions
|
|
465
|
+
* @returns Cleaned permissions array
|
|
466
|
+
*/
|
|
467
|
+
declare function cleanupPermissions(templatePermissions: string[], userPermissions: string[]): string[];
|
|
468
|
+
/**
|
|
469
|
+
* Merge and clean permissions arrays
|
|
470
|
+
* Combines template and user permissions while removing invalid/redundant entries
|
|
471
|
+
* @param templatePermissions - Permissions from template
|
|
472
|
+
* @param userPermissions - User's existing permissions
|
|
473
|
+
* @returns Merged and cleaned permissions array
|
|
474
|
+
*/
|
|
475
|
+
declare function mergeAndCleanPermissions(templatePermissions: string[] | undefined, userPermissions: string[] | undefined): string[];
|
|
476
|
+
|
|
477
|
+
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, cleanupPermissions, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, fixWindowsMcpConfig, getExistingApiConfig, getMcpConfigPath, getPlatform, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, isClaudeCodeInstalled, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, readMcpConfig, updateDefaultModel, writeMcpConfig };
|
|
456
478
|
export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, McpServerConfig, McpService, SupportedLang };
|
package/dist/index.d.ts
CHANGED
|
@@ -224,6 +224,7 @@ declare const I18N: {
|
|
|
224
224
|
permissionsImportSuccess: string;
|
|
225
225
|
openingSettingsJson: string;
|
|
226
226
|
spaceToSelectReturn: string;
|
|
227
|
+
windowsDetected: string;
|
|
227
228
|
};
|
|
228
229
|
en: {
|
|
229
230
|
selectScriptLang: string;
|
|
@@ -394,6 +395,7 @@ declare const I18N: {
|
|
|
394
395
|
permissionsImportSuccess: string;
|
|
395
396
|
openingSettingsJson: string;
|
|
396
397
|
spaceToSelectReturn: string;
|
|
398
|
+
windowsDetected: string;
|
|
397
399
|
};
|
|
398
400
|
};
|
|
399
401
|
declare const MCP_SERVICES: McpService[];
|
|
@@ -452,5 +454,25 @@ declare function importRecommendedEnv(): Promise<void>;
|
|
|
452
454
|
declare function importRecommendedPermissions(): Promise<void>;
|
|
453
455
|
declare function openSettingsJson(): Promise<void>;
|
|
454
456
|
|
|
455
|
-
|
|
457
|
+
/**
|
|
458
|
+
* Clean up and deduplicate permissions array
|
|
459
|
+
* Removes invalid and redundant permissions based on template
|
|
460
|
+
*/
|
|
461
|
+
/**
|
|
462
|
+
* Clean up permissions array by removing invalid and redundant entries
|
|
463
|
+
* @param templatePermissions - Permissions from template (source of truth)
|
|
464
|
+
* @param userPermissions - User's existing permissions
|
|
465
|
+
* @returns Cleaned permissions array
|
|
466
|
+
*/
|
|
467
|
+
declare function cleanupPermissions(templatePermissions: string[], userPermissions: string[]): string[];
|
|
468
|
+
/**
|
|
469
|
+
* Merge and clean permissions arrays
|
|
470
|
+
* Combines template and user permissions while removing invalid/redundant entries
|
|
471
|
+
* @param templatePermissions - Permissions from template
|
|
472
|
+
* @param userPermissions - User's existing permissions
|
|
473
|
+
* @returns Merged and cleaned permissions array
|
|
474
|
+
*/
|
|
475
|
+
declare function mergeAndCleanPermissions(templatePermissions: string[] | undefined, userPermissions: string[] | undefined): string[];
|
|
476
|
+
|
|
477
|
+
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, cleanupPermissions, commandExists, configureApi, copyConfigFiles, ensureClaudeDir, fixWindowsMcpConfig, getExistingApiConfig, getMcpConfigPath, getPlatform, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, isClaudeCodeInstalled, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, readMcpConfig, updateDefaultModel, writeMcpConfig };
|
|
456
478
|
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,
|
|
1
|
+
export { A as AI_OUTPUT_LANGUAGES, C as CLAUDE_DIR, e as CLAUDE_MD_FILE, f as ClAUDE_CONFIG_FILE, I as I18N, L as LANG_LABELS, M as MCP_SERVICES, S as SETTINGS_FILE, h as SUPPORTED_LANGS, Z as ZCF_CONFIG_FILE, F as addCompletedOnboarding, v as applyAiLanguageDirective, n as backupExistingConfig, z as backupMcpConfig, D as buildMcpServerConfig, d as cleanupPermissions, c as commandExists, q as configureApi, p as copyConfigFiles, l as ensureClaudeDir, E as fixWindowsMcpConfig, t as getExistingApiConfig, w as getMcpConfigPath, g as getPlatform, a as importRecommendedEnv, b as importRecommendedPermissions, i as init, k as installClaudeCode, j as isClaudeCodeInstalled, m as mergeAndCleanPermissions, r as mergeConfigs, B as mergeMcpServers, s as mergeSettingsFile, o as openSettingsJson, x as readMcpConfig, u as updateDefaultModel, y as writeMcpConfig } from './shared/zcf.CYdvtE_u.mjs';
|
|
2
2
|
import 'inquirer';
|
|
3
3
|
import 'ansis';
|
|
4
4
|
import 'node:fs';
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
import { exec } from 'tinyexec';
|
|
8
8
|
import { homedir, platform } from 'node:os';
|
|
9
9
|
|
|
10
|
-
const version = "2.4.
|
|
10
|
+
const version = "2.4.1";
|
|
11
11
|
const homepage = "https://github.com/UfoMiao/zcf";
|
|
12
12
|
|
|
13
13
|
const CLAUDE_DIR = join(homedir(), ".claude");
|
|
@@ -212,7 +212,9 @@ const I18N = {
|
|
|
212
212
|
permissionsImportSuccess: "\u6743\u9650\u914D\u7F6E\u5DF2\u5BFC\u5165",
|
|
213
213
|
openingSettingsJson: "\u6B63\u5728\u6253\u5F00 settings.json...",
|
|
214
214
|
// Misc
|
|
215
|
-
spaceToSelectReturn: "- \u7A7A\u683C\u9009\u62E9\uFF0C\u56DE\u8F66\u63D0\u4EA4"
|
|
215
|
+
spaceToSelectReturn: "- \u7A7A\u683C\u9009\u62E9\uFF0C\u56DE\u8F66\u63D0\u4EA4",
|
|
216
|
+
// Windows detection
|
|
217
|
+
windowsDetected: "\u68C0\u6D4B\u5230 Windows \u7CFB\u7EDF\uFF0C\u5C06\u81EA\u52A8\u914D\u7F6E\u517C\u5BB9\u683C\u5F0F"
|
|
216
218
|
},
|
|
217
219
|
en: {
|
|
218
220
|
selectScriptLang: "Select ZCF display language",
|
|
@@ -400,7 +402,9 @@ const I18N = {
|
|
|
400
402
|
permissionsImportSuccess: "Permissions imported",
|
|
401
403
|
openingSettingsJson: "Opening settings.json...",
|
|
402
404
|
// Misc
|
|
403
|
-
spaceToSelectReturn: "- Space to select. Return to submit"
|
|
405
|
+
spaceToSelectReturn: "- Space to select. Return to submit",
|
|
406
|
+
// Windows detection
|
|
407
|
+
windowsDetected: "Windows detected, will configure compatible format"
|
|
404
408
|
}
|
|
405
409
|
};
|
|
406
410
|
const MCP_SERVICES = [
|
|
@@ -868,6 +872,36 @@ function deepClone(obj) {
|
|
|
868
872
|
return obj;
|
|
869
873
|
}
|
|
870
874
|
|
|
875
|
+
function cleanupPermissions(templatePermissions, userPermissions) {
|
|
876
|
+
const templateSet = new Set(templatePermissions);
|
|
877
|
+
const cleanedPermissions = userPermissions.filter((permission) => {
|
|
878
|
+
if (["mcp__.*", "mcp__*", "mcp__(*)"].includes(permission)) {
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
for (const templatePerm of templatePermissions) {
|
|
882
|
+
if (permission === templatePerm) {
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
if (permission.startsWith(templatePerm)) {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return true;
|
|
890
|
+
});
|
|
891
|
+
const merged = [...templateSet];
|
|
892
|
+
for (const permission of cleanedPermissions) {
|
|
893
|
+
if (!templateSet.has(permission)) {
|
|
894
|
+
merged.push(permission);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return merged;
|
|
898
|
+
}
|
|
899
|
+
function mergeAndCleanPermissions(templatePermissions, userPermissions) {
|
|
900
|
+
const template = templatePermissions || [];
|
|
901
|
+
const user = userPermissions || [];
|
|
902
|
+
return cleanupPermissions(template, user);
|
|
903
|
+
}
|
|
904
|
+
|
|
871
905
|
function ensureClaudeDir() {
|
|
872
906
|
ensureDir(CLAUDE_DIR);
|
|
873
907
|
}
|
|
@@ -991,9 +1025,9 @@ function mergeSettingsFile(templatePath, targetPath) {
|
|
|
991
1025
|
});
|
|
992
1026
|
mergedSettings.env = mergedEnv;
|
|
993
1027
|
if (mergedSettings.permissions && mergedSettings.permissions.allow) {
|
|
994
|
-
mergedSettings.permissions.allow =
|
|
995
|
-
templateSettings.permissions?.allow
|
|
996
|
-
existingSettings.permissions?.allow
|
|
1028
|
+
mergedSettings.permissions.allow = mergeAndCleanPermissions(
|
|
1029
|
+
templateSettings.permissions?.allow,
|
|
1030
|
+
existingSettings.permissions?.allow
|
|
997
1031
|
);
|
|
998
1032
|
}
|
|
999
1033
|
writeJsonConfig(targetPath, mergedSettings);
|
|
@@ -1680,11 +1714,7 @@ async function init(options = {}) {
|
|
|
1680
1714
|
}
|
|
1681
1715
|
if (shouldConfigureMcp) {
|
|
1682
1716
|
if (isWindows()) {
|
|
1683
|
-
console.log(
|
|
1684
|
-
ansis.blue(
|
|
1685
|
-
`\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"}`
|
|
1686
|
-
)
|
|
1687
|
-
);
|
|
1717
|
+
console.log(ansis.blue(`\u2139 ${I18N[scriptLang].windowsDetected}`));
|
|
1688
1718
|
}
|
|
1689
1719
|
const selectedServices = await selectMcpServices(scriptLang);
|
|
1690
1720
|
if (selectedServices === void 0) {
|
|
@@ -1778,7 +1808,17 @@ async function importRecommendedEnv() {
|
|
|
1778
1808
|
async function importRecommendedPermissions() {
|
|
1779
1809
|
const templateSettings = getTemplateSettings();
|
|
1780
1810
|
const currentSettings = loadCurrentSettings();
|
|
1781
|
-
|
|
1811
|
+
if (templateSettings.permissions && templateSettings.permissions.allow) {
|
|
1812
|
+
currentSettings.permissions = {
|
|
1813
|
+
...templateSettings.permissions,
|
|
1814
|
+
allow: mergeAndCleanPermissions(
|
|
1815
|
+
templateSettings.permissions.allow,
|
|
1816
|
+
currentSettings.permissions?.allow
|
|
1817
|
+
)
|
|
1818
|
+
};
|
|
1819
|
+
} else {
|
|
1820
|
+
currentSettings.permissions = templateSettings.permissions;
|
|
1821
|
+
}
|
|
1782
1822
|
saveSettings(currentSettings);
|
|
1783
1823
|
}
|
|
1784
1824
|
async function openSettingsJson() {
|
|
@@ -1813,4 +1853,4 @@ async function openSettingsJson() {
|
|
|
1813
1853
|
}
|
|
1814
1854
|
}
|
|
1815
1855
|
|
|
1816
|
-
export { AI_OUTPUT_LANGUAGES as A,
|
|
1856
|
+
export { AI_OUTPUT_LANGUAGES as A, mergeMcpServers as B, CLAUDE_DIR as C, buildMcpServerConfig as D, fixWindowsMcpConfig as E, addCompletedOnboarding as F, updateZcfConfig as G, readZcfConfig as H, I18N as I, resolveAiOutputLanguage as J, configureAiPersonality as K, LANG_LABELS as L, MCP_SERVICES as M, isWindows as N, selectMcpServices as O, formatApiKeyDisplay as P, modifyApiConfigPartially as Q, validateApiKey as R, SETTINGS_FILE as S, displayBanner as T, selectScriptLanguage as U, updatePromptOnly as V, version as W, handleExitPromptError as X, handleGeneralError as Y, ZCF_CONFIG_FILE as Z, displayBannerWithInfo as _, importRecommendedEnv as a, importRecommendedPermissions as b, commandExists as c, cleanupPermissions as d, CLAUDE_MD_FILE as e, ClAUDE_CONFIG_FILE as f, getPlatform as g, SUPPORTED_LANGS as h, init as i, isClaudeCodeInstalled as j, installClaudeCode as k, ensureClaudeDir as l, mergeAndCleanPermissions as m, backupExistingConfig as n, openSettingsJson as o, copyConfigFiles as p, configureApi as q, mergeConfigs as r, mergeSettingsFile as s, getExistingApiConfig as t, updateDefaultModel as u, applyAiLanguageDirective as v, getMcpConfigPath as w, readMcpConfig as x, writeMcpConfig as y, backupMcpConfig as z };
|
package/package.json
CHANGED