zcf
- Version 3.5.1
- Published
- 792 kB
- 16 dependencies
- MIT license
Install
npm i zcfyarn add zcfpnpm add zcfOverview
Zero-Config Code Flow - One-click configuration tool for Code Cli
Index
Variables
- AI_OUTPUT_LANGUAGES
- API_DEFAULT_URL
- API_ENV_KEY
- ClAUDE_CONFIG_FILE
- CLAUDE_DIR
- CLAUDE_MD_FILE
- CLAUDE_VSC_CONFIG_FILE
- CODE_TOOL_ALIASES
- CODE_TOOL_BANNERS
- CODE_TOOL_TYPES
- CODEX_AGENTS_FILE
- CODEX_AUTH_FILE
- CODEX_CONFIG_FILE
- CODEX_DIR
- CODEX_PROMPTS_DIR
- DEFAULT_CODE_TOOL_TYPE
- LANG_LABELS
- LEGACY_ZCF_CONFIG_FILES
- SETTINGS_FILE
- SUPPORTED_LANGS
- ZCF_CONFIG_DIR
- ZCF_CONFIG_FILE
Functions
- addCompletedOnboarding()
- applyAiLanguageDirective()
- backupExistingConfig()
- backupMcpConfig()
- buildMcpServerConfig()
- cleanupPermissions()
- commandExists()
- configureApi()
- copyConfigFiles()
- createHomebrewSymlink()
- detectInstalledVersion()
- displayVerificationResult()
- ensureApiKeyApproved()
- ensureClaudeDir()
- executeInstallMethod()
- fixWindowsMcpConfig()
- getAiOutputLanguageLabel()
- getExistingApiConfig()
- getExistingModelConfig()
- getInstallationStatus()
- getMcpConfigPath()
- getPlatform()
- handleInstallFailure()
- importRecommendedEnv()
- importRecommendedPermissions()
- init()
- installClaudeCode()
- installCodex()
- isClaudeCodeInstalled()
- isCodeToolType()
- isCodexInstalled()
- isLocalClaudeCodeInstalled()
- manageApiKeyApproval()
- mergeAndCleanPermissions()
- mergeConfigs()
- mergeMcpServers()
- mergeSettingsFile()
- openSettingsJson()
- promptApiConfigurationAction()
- readMcpConfig()
- removeApiKeyFromRejected()
- removeLocalClaudeCode()
- resolveCodeToolType()
- selectInstallMethod()
- setInstallMethod()
- setPrimaryApiKey()
- switchToOfficialLogin()
- uninstallCodeTool()
- updateCustomModel()
- updateDefaultModel()
- verifyInstallation()
- writeMcpConfig()
Interfaces
Type Aliases
Variables
variable AI_OUTPUT_LANGUAGES
const AI_OUTPUT_LANGUAGES: { readonly 'zh-CN': { readonly directive: 'Always respond in Chinese-simplified' }; readonly en: { readonly directive: 'Always respond in English' }; readonly custom: { readonly directive: '' };};variable API_DEFAULT_URL
const API_DEFAULT_URL: string;variable API_ENV_KEY
const API_ENV_KEY: string;variable ClAUDE_CONFIG_FILE
const ClAUDE_CONFIG_FILE: string;variable CLAUDE_DIR
const CLAUDE_DIR: string;variable CLAUDE_MD_FILE
const CLAUDE_MD_FILE: string;variable CLAUDE_VSC_CONFIG_FILE
const CLAUDE_VSC_CONFIG_FILE: string;variable CODE_TOOL_ALIASES
const CODE_TOOL_ALIASES: Record<string, 'claude-code' | 'codex'>;variable CODE_TOOL_BANNERS
const CODE_TOOL_BANNERS: Record<'claude-code' | 'codex', string>;variable CODE_TOOL_TYPES
const CODE_TOOL_TYPES: readonly ['claude-code', 'codex'];variable CODEX_AGENTS_FILE
const CODEX_AGENTS_FILE: string;variable CODEX_AUTH_FILE
const CODEX_AUTH_FILE: string;variable CODEX_CONFIG_FILE
const CODEX_CONFIG_FILE: string;variable CODEX_DIR
const CODEX_DIR: string;variable CODEX_PROMPTS_DIR
const CODEX_PROMPTS_DIR: string;variable DEFAULT_CODE_TOOL_TYPE
const DEFAULT_CODE_TOOL_TYPE: 'claude-code' | 'codex';variable LANG_LABELS
const LANG_LABELS: { readonly 'zh-CN': '简体中文'; readonly en: 'English' };variable LEGACY_ZCF_CONFIG_FILES
const LEGACY_ZCF_CONFIG_FILES: string[];variable SETTINGS_FILE
const SETTINGS_FILE: string;variable SUPPORTED_LANGS
const SUPPORTED_LANGS: readonly ['zh-CN', 'en'];variable ZCF_CONFIG_DIR
const ZCF_CONFIG_DIR: string;variable ZCF_CONFIG_FILE
const ZCF_CONFIG_FILE: string;Functions
function addCompletedOnboarding
addCompletedOnboarding: () => void;function applyAiLanguageDirective
applyAiLanguageDirective: (aiOutputLang: AiOutputLanguage | string) => void;function backupExistingConfig
backupExistingConfig: () => string | null;function backupMcpConfig
backupMcpConfig: () => string | null;function buildMcpServerConfig
buildMcpServerConfig: ( baseConfig: McpServerConfig, apiKey?: string, placeholder?: string, envVarName?: string) => McpServerConfig;function cleanupPermissions
cleanupPermissions: ( templatePermissions: string[], userPermissions: string[]) => string[];Clean up permissions array by removing invalid and redundant entries
Parameter templatePermissions
Permissions from template (source of truth)
Parameter userPermissions
User's existing permissions
Returns
Cleaned permissions array
function commandExists
commandExists: (command: string) => Promise<boolean>;function configureApi
configureApi: (apiConfig: ApiConfig | null) => ApiConfig | null;function copyConfigFiles
copyConfigFiles: (onlyMd?: boolean) => void;function createHomebrewSymlink
createHomebrewSymlink: ( command: string, sourcePath: string) => Promise<SymlinkResult>;Create symlink in Homebrew bin directory for commands installed via npm This handles the case where npm global packages are installed to /opt/homebrew/Cellar/node/{version}/bin/ but that path is not in the user's PATH
function detectInstalledVersion
detectInstalledVersion: (codeType: CodeType) => Promise<string | null>;Detect installed version of a code tool Returns version string or null if not installed
function displayVerificationResult
displayVerificationResult: ( result: VerificationResult, codeType: CodeType) => void;Display verification result to user with appropriate messages
function ensureApiKeyApproved
ensureApiKeyApproved: ( config: ClaudeConfiguration, apiKey: string) => ClaudeConfiguration;Ensures that an API key is in the approved list and not in the rejected list
Parameter config
Claude configuration object
Parameter apiKey
The API key to manage
Returns
Updated configuration with API key properly approved
function ensureClaudeDir
ensureClaudeDir: () => void;function executeInstallMethod
executeInstallMethod: ( method: InstallMethod, codeType: CodeType) => Promise<boolean>;Execute installation using specified method
function fixWindowsMcpConfig
fixWindowsMcpConfig: (config: ClaudeConfiguration) => ClaudeConfiguration;function getAiOutputLanguageLabel
getAiOutputLanguageLabel: (lang: AiOutputLanguage) => string;function getExistingApiConfig
getExistingApiConfig: () => ApiConfig | null;Get existing API configuration from settings.json
function getExistingModelConfig
getExistingModelConfig: () => | 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom' | null;Get existing model configuration from settings.json
function getInstallationStatus
getInstallationStatus: () => Promise<InstallationStatus>;function getMcpConfigPath
getMcpConfigPath: () => string;function getPlatform
getPlatform: () => 'windows' | 'macos' | 'linux';function handleInstallFailure
handleInstallFailure: ( codeType: CodeType, failedMethods: InstallMethod[]) => Promise<boolean>;Handle installation failure with retry options
function importRecommendedEnv
importRecommendedEnv: () => Promise<void>;function importRecommendedPermissions
importRecommendedPermissions: () => Promise<void>;function init
init: (options?: InitOptions) => Promise<void>;function installClaudeCode
installClaudeCode: (skipMethodSelection?: boolean) => Promise<void>;Install Claude Code with method selection support
Parameter skipMethodSelection
If true, use default npm installation
function installCodex
installCodex: (skipMethodSelection?: boolean) => Promise<void>;Install Codex with method selection support
Parameter skipMethodSelection
If true, use default npm installation
function isClaudeCodeInstalled
isClaudeCodeInstalled: () => Promise<boolean>;function isCodeToolType
isCodeToolType: (value: any) => value is 'claude-code' | 'codex';function isCodexInstalled
isCodexInstalled: () => Promise<boolean>;Check if Codex is installed
function isLocalClaudeCodeInstalled
isLocalClaudeCodeInstalled: () => Promise<boolean>;Check if local Claude Code installation exists
function manageApiKeyApproval
manageApiKeyApproval: (apiKey: string) => void;Manages API key approval status by reading config, updating it, and writing it back
Parameter apiKey
The API key to ensure is approved (e.g., 'sk-zcf-x-ccr')
function mergeAndCleanPermissions
mergeAndCleanPermissions: ( templatePermissions: string[] | undefined, userPermissions: string[] | undefined) => string[];Merge and clean permissions arrays Combines template and user permissions while removing invalid/redundant entries
Parameter templatePermissions
Permissions from template
Parameter userPermissions
User's existing permissions
Returns
Merged and cleaned permissions array
function mergeConfigs
mergeConfigs: (sourceFile: string, targetFile: string) => void;function mergeMcpServers
mergeMcpServers: ( existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>) => ClaudeConfiguration;function mergeSettingsFile
mergeSettingsFile: (templatePath: string, targetPath: string) => void;Merge settings.json intelligently Preserves user's environment variables and custom configurations
function openSettingsJson
openSettingsJson: () => Promise<void>;function promptApiConfigurationAction
promptApiConfigurationAction: () => Promise< 'modify-partial' | 'modify-all' | 'keep-existing' | null>;Prompt user for API configuration action when existing config is found Returns the user's choice for how to handle existing configuration
function readMcpConfig
readMcpConfig: () => ClaudeConfiguration | null;function removeApiKeyFromRejected
removeApiKeyFromRejected: ( config: ClaudeConfiguration, apiKey: string) => ClaudeConfiguration;Removes an API key from the rejected list
Parameter config
Claude configuration object
Parameter apiKey
The API key to remove from rejected list
Returns
Updated configuration with API key removed from rejected list
function removeLocalClaudeCode
removeLocalClaudeCode: () => Promise<void>;Remove local Claude Code installation
function resolveCodeToolType
resolveCodeToolType: (value: unknown) => CodeToolType;function selectInstallMethod
selectInstallMethod: ( codeType: CodeType, excludeMethods?: InstallMethod[]) => Promise<InstallMethod | null>;Select installation method interactively
function setInstallMethod
setInstallMethod: (method: InstallMethod, codeType?: CodeType) => Promise<void>;Set installMethod in both ~/.claude.json and zcf-config This ensures Claude Code knows it was installed via npm for proper auto-updates
function setPrimaryApiKey
setPrimaryApiKey: () => void;Sets the primaryApiKey field in ~/.claude/config.json (VSCode extension config) This is required for Claude Code 2.0 to properly recognize third-party API configurations and prevent redirecting to official login page
function switchToOfficialLogin
switchToOfficialLogin: () => boolean;Switch to official login mode - remove all third-party API configurations Removes: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY from settings.json Removes: primaryApiKey from ~/.claude/config.json
function uninstallCodeTool
uninstallCodeTool: (codeType: CodeType) => Promise<boolean>;Uninstall code tool based on install method
Parameter codeType
Type of code tool to uninstall
Returns
true if uninstalled successfully
function updateCustomModel
updateCustomModel: ( primaryModel?: string, haikuModel?: string, sonnetModel?: string, opusModel?: string) => void;Update custom model configuration using environment variables
Parameter primaryModel
Primary model name for general tasks
Parameter haikuModel
Default Haiku model (optional)
Parameter sonnetModel
Default Sonnet model (optional)
Parameter opusModel
Default Opus model (optional)
function updateDefaultModel
updateDefaultModel: ( model: 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom') => void;Update the default model configuration in settings.json
Parameter model
The model type to set: opus, sonnet, sonnet[1m], default, or custom Note: 'custom' model type is handled differently - it should use environment variables instead
function verifyInstallation
verifyInstallation: (codeType: CodeType) => Promise<VerificationResult>;Verify installation by checking command availability and version If command is not in PATH but found in Homebrew paths, attempt to create symlink
function writeMcpConfig
writeMcpConfig: (config: ClaudeConfiguration) => void;Interfaces
interface ApiConfig
interface ApiConfig {}API configuration for Claude Code
interface ClaudeConfiguration
interface ClaudeConfiguration {}property customApiKeyResponses
customApiKeyResponses?: { approved: string[]; rejected: string[];};property env
env?: Record<string, string>;property hasCompletedOnboarding
hasCompletedOnboarding?: boolean;property installMethod
installMethod?: InstallMethod$1;property mcpServers
mcpServers: Record<string, McpServerConfig>;property primaryApiKey
primaryApiKey?: string;interface InstallationStatus
interface InstallationStatus {}Get installation status for both global and local Claude Code
interface McpServerConfig
interface McpServerConfig {}interface McpService
interface McpService {}property apiKeyEnvVar
apiKeyEnvVar?: string;property apiKeyPlaceholder
apiKeyPlaceholder?: string;property apiKeyPrompt
apiKeyPrompt?: string;property config
config: McpServerConfig;property description
description: string;property id
id: string;property name
name: string;property requiresApiKey
requiresApiKey: boolean;interface VerificationResult
interface VerificationResult {}Installation verification result
property commandPath
commandPath: string | null;property error
error?: string;property needsSymlink
needsSymlink: boolean;property success
success: boolean;property symlinkCreated
symlinkCreated: boolean;property version
version: string | null;Type Aliases
type AiOutputLanguage
type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES;type CodeToolType
type CodeToolType = (typeof CODE_TOOL_TYPES)[number];type SupportedLang
type SupportedLang = (typeof SUPPORTED_LANGS)[number];Package Files (1)
Dependencies (16)
Dev Dependencies (19)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/zcf.
- Markdown[](https://www.jsdocs.io/package/zcf)
- HTML<a href="https://www.jsdocs.io/package/zcf"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4137 ms. - Missing or incorrect documentation? Open an issue for this package.