UNPKG

accf

Version:

Claude-Code Flow - One-click configuration tool for Claude Code

219 lines (208 loc) 9.78 kB
declare const CLAUDE_DIR: string; declare const SETTINGS_FILE: string; declare const CLAUDE_MD_FILE: string; declare const ClAUDE_CONFIG_FILE: string; declare const CLAUDE_VSC_CONFIG_FILE: string; declare const ZCF_CONFIG_DIR: string; declare const ZCF_CONFIG_FILE: string; declare const LEGACY_ZCF_CONFIG_FILES: string[]; declare const CODE_TOOL_TYPES: readonly ["claude-code", "codex"]; type CodeToolType = (typeof CODE_TOOL_TYPES)[number]; declare const DEFAULT_CODE_TOOL_TYPE: CodeToolType; declare const CODE_TOOL_BANNERS: Record<CodeToolType, string>; declare function isCodeToolType(value: any): value is CodeToolType; declare const SUPPORTED_LANGS: readonly ["zh-CN", "en"]; type SupportedLang = (typeof SUPPORTED_LANGS)[number]; declare const LANG_LABELS: { readonly 'zh-CN': "简体中文"; readonly en: "English"; }; declare 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: ""; }; }; type AiOutputLanguage = keyof typeof AI_OUTPUT_LANGUAGES; declare function getAiOutputLanguageLabel(lang: AiOutputLanguage): string; interface InitOptions { configLang?: SupportedLang; aiOutputLang?: AiOutputLanguage | string; force?: boolean; skipBanner?: boolean; skipPrompt?: boolean; codeType?: CodeToolType | string; configAction?: 'new' | 'backup' | 'merge' | 'docs-only' | 'skip'; apiType?: 'auth_token' | 'api_key' | 'ccr_proxy' | 'skip'; apiKey?: string; apiUrl?: string; mcpServices?: string[] | string | boolean; workflows?: string[] | string | boolean; outputStyles?: string[] | string | boolean; defaultOutputStyle?: string; allLang?: string; installCometixLine?: string | boolean; } declare function init(options?: InitOptions): Promise<void>; interface McpService { id: string; name: string; description: string; requiresApiKey: boolean; apiKeyPrompt?: string; apiKeyPlaceholder?: string; apiKeyEnvVar?: string; config: McpServerConfig; } interface McpServerConfig { type: 'stdio' | 'sse'; command?: string; args?: string[]; url?: string; env?: Record<string, string>; startup_timeout_ms?: number; } interface ClaudeConfiguration { mcpServers: Record<string, McpServerConfig>; hasCompletedOnboarding?: boolean; customApiKeyResponses?: { approved: string[]; rejected: string[]; }; env?: Record<string, string>; primaryApiKey?: string; } declare function getMcpConfigPath(): string; declare function readMcpConfig(): ClaudeConfiguration | null; declare function writeMcpConfig(config: ClaudeConfiguration): void; declare function backupMcpConfig(): string | null; declare function mergeMcpServers(existing: ClaudeConfiguration | null, newServers: Record<string, McpServerConfig>): ClaudeConfiguration; declare function buildMcpServerConfig(baseConfig: McpServerConfig, apiKey?: string, placeholder?: string, envVarName?: string): McpServerConfig; declare function fixWindowsMcpConfig(config: ClaudeConfiguration): ClaudeConfiguration; declare function addCompletedOnboarding(): void; /** * Ensures that an API key is in the approved list and not in the rejected list * @param config - Claude configuration object * @param apiKey - The API key to manage * @returns Updated configuration with API key properly approved */ declare function ensureApiKeyApproved(config: ClaudeConfiguration, apiKey: string): ClaudeConfiguration; /** * Removes an API key from the rejected list * @param config - Claude configuration object * @param apiKey - The API key to remove from rejected list * @returns Updated configuration with API key removed from rejected list */ declare function removeApiKeyFromRejected(config: ClaudeConfiguration, apiKey: string): ClaudeConfiguration; /** * Manages API key approval status by reading config, updating it, and writing it back * @param apiKey - The API key to ensure is approved (e.g., 'sk-zcf-x-ccr') */ declare function manageApiKeyApproval(apiKey: string): 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 */ declare function setPrimaryApiKey(): void; /** * API configuration for Claude Code */ interface ApiConfig { url: string; key: string; authType?: 'auth_token' | 'api_key'; } declare function ensureClaudeDir(): void; declare function backupExistingConfig(): string | null; declare function copyConfigFiles(onlyMd?: boolean): void; declare function configureApi(apiConfig: ApiConfig | null): ApiConfig | null; declare function mergeConfigs(sourceFile: string, targetFile: string): void; /** * Update custom model configuration using environment variables * @param primaryModel - Primary model name for general tasks * @param fastModel - Fast model name for background tasks (optional) */ declare function updateCustomModel(primaryModel?: string, fastModel?: string): void; /** * Update the default model configuration in settings.json * @param 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 */ declare function updateDefaultModel(model: 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom'): void; /** * Merge settings.json intelligently * Preserves user's environment variables and custom configurations */ declare function mergeSettingsFile(templatePath: string, targetPath: string): void; /** * Get existing model configuration from settings.json */ declare function getExistingModelConfig(): 'opus' | 'sonnet' | 'sonnet[1m]' | 'default' | 'custom' | null; /** * Get existing API configuration from settings.json */ declare function getExistingApiConfig(): ApiConfig | null; declare function applyAiLanguageDirective(aiOutputLang: AiOutputLanguage | string): void; /** * 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 * Removes: hasCompletedOnboarding from ~/.claude.json */ declare function switchToOfficialLogin(): boolean; /** * Prompt user for API configuration action when existing config is found * Returns the user's choice for how to handle existing configuration */ declare function promptApiConfigurationAction(): Promise<'modify-partial' | 'modify-all' | 'keep-existing' | null>; declare function isClaudeCodeInstalled(): Promise<boolean>; declare function installClaudeCode(): Promise<void>; /** * Check if local Claude Code installation exists */ declare function isLocalClaudeCodeInstalled(): Promise<boolean>; /** * Get installation status for both global and local Claude Code */ interface InstallationStatus { hasGlobal: boolean; hasLocal: boolean; localPath: string; } declare function getInstallationStatus(): Promise<InstallationStatus>; /** * Remove local Claude Code installation */ declare function removeLocalClaudeCode(): Promise<void>; /** * Clean up and deduplicate permissions array * Removes invalid and redundant permissions based on template */ /** * Clean up permissions array by removing invalid and redundant entries * @param templatePermissions - Permissions from template (source of truth) * @param userPermissions - User's existing permissions * @returns Cleaned permissions array */ declare function cleanupPermissions(templatePermissions: string[], userPermissions: string[]): string[]; /** * Merge and clean permissions arrays * Combines template and user permissions while removing invalid/redundant entries * @param templatePermissions - Permissions from template * @param userPermissions - User's existing permissions * @returns Merged and cleaned permissions array */ declare function mergeAndCleanPermissions(templatePermissions: string[] | undefined, userPermissions: string[] | undefined): string[]; declare function getPlatform(): 'windows' | 'macos' | 'linux'; declare function commandExists(command: string): Promise<boolean>; declare function importRecommendedEnv(): Promise<void>; declare function importRecommendedPermissions(): Promise<void>; declare function openSettingsJson(): Promise<void>; export { AI_OUTPUT_LANGUAGES, CLAUDE_DIR, CLAUDE_MD_FILE, CLAUDE_VSC_CONFIG_FILE, CODE_TOOL_BANNERS, CODE_TOOL_TYPES, ClAUDE_CONFIG_FILE, DEFAULT_CODE_TOOL_TYPE, LANG_LABELS, LEGACY_ZCF_CONFIG_FILES, SETTINGS_FILE, SUPPORTED_LANGS, ZCF_CONFIG_DIR, ZCF_CONFIG_FILE, addCompletedOnboarding, applyAiLanguageDirective, backupExistingConfig, backupMcpConfig, buildMcpServerConfig, cleanupPermissions, commandExists, configureApi, copyConfigFiles, ensureApiKeyApproved, ensureClaudeDir, fixWindowsMcpConfig, getAiOutputLanguageLabel, getExistingApiConfig, getExistingModelConfig, getInstallationStatus, getMcpConfigPath, getPlatform, importRecommendedEnv, importRecommendedPermissions, init, installClaudeCode, isClaudeCodeInstalled, isCodeToolType, isLocalClaudeCodeInstalled, manageApiKeyApproval, mergeAndCleanPermissions, mergeConfigs, mergeMcpServers, mergeSettingsFile, openSettingsJson, promptApiConfigurationAction, readMcpConfig, removeApiKeyFromRejected, removeLocalClaudeCode, setPrimaryApiKey, switchToOfficialLogin, updateCustomModel, updateDefaultModel, writeMcpConfig }; export type { AiOutputLanguage, ApiConfig, ClaudeConfiguration, CodeToolType, InstallationStatus, McpServerConfig, McpService, SupportedLang };