mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-01 15:03:57 +08:00
feat: add CLI settings export/import functionality
- Implemented exportSettings and importSettings APIs for CLI settings. - Added hooks useExportSettings and useImportSettings for managing export/import operations in the frontend. - Updated SettingsPage to include buttons for exporting and importing CLI settings. - Enhanced backend to handle export and import requests, including validation and conflict resolution. - Introduced new data structures for exported settings and import options. - Updated localization files to support new export/import features. - Refactored CLI tool configurations to remove hardcoded model defaults, allowing dynamic model retrieval.
This commit is contained in:
@@ -136,46 +136,32 @@ export interface ClaudeCliCombinedConfig extends ClaudeCliToolsConfig {
|
||||
|
||||
// ========== Default Config ==========
|
||||
|
||||
// Default tools config - no model defaults, models come from user's cli-tools.json
|
||||
const DEFAULT_TOOLS_CONFIG: ClaudeCliToolsConfig = {
|
||||
version: '3.4.0',
|
||||
tools: {
|
||||
gemini: {
|
||||
enabled: true,
|
||||
primaryModel: 'gemini-2.5-pro',
|
||||
secondaryModel: 'gemini-2.5-flash',
|
||||
availableModels: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.0-flash', 'gemini-2.0-flash-thinking', 'gemini-1.5-pro'],
|
||||
tags: [],
|
||||
type: 'builtin'
|
||||
},
|
||||
qwen: {
|
||||
enabled: true,
|
||||
primaryModel: 'coder-model',
|
||||
secondaryModel: 'coder-model',
|
||||
availableModels: ['coder-model', 'vision-model', 'qwen-2.5-coder', 'qwen-2.5-72b'],
|
||||
tags: [],
|
||||
type: 'builtin'
|
||||
},
|
||||
codex: {
|
||||
enabled: true,
|
||||
primaryModel: 'gpt-5.2',
|
||||
secondaryModel: 'gpt-5.2',
|
||||
availableModels: ['gpt-5.2', 'gpt-5', 'gpt5-codex', 'o3', 'o1'],
|
||||
tags: [],
|
||||
type: 'builtin'
|
||||
},
|
||||
claude: {
|
||||
enabled: true,
|
||||
primaryModel: 'sonnet',
|
||||
secondaryModel: 'haiku',
|
||||
availableModels: ['opus', 'sonnet', 'haiku'],
|
||||
tags: [],
|
||||
type: 'builtin'
|
||||
},
|
||||
opencode: {
|
||||
enabled: true,
|
||||
primaryModel: 'opencode/glm-4.7-free',
|
||||
secondaryModel: 'opencode/glm-4.7-free',
|
||||
availableModels: ['opencode/glm-4.7-free', 'opencode/deepseek-v3-free'],
|
||||
tags: [],
|
||||
type: 'builtin'
|
||||
}
|
||||
|
||||
@@ -958,12 +958,16 @@ async function executeCliTool(
|
||||
|
||||
// Merge custom env with process.env (custom env takes precedence)
|
||||
// Also include rulesEnv for $PROTO and $TMPL template variables
|
||||
const spawnEnv = {
|
||||
const spawnEnv: Record<string, string | undefined> = {
|
||||
...process.env,
|
||||
...customEnv,
|
||||
...(rulesEnv || {})
|
||||
};
|
||||
|
||||
// Unset CLAUDECODE to allow nested Claude Code sessions (SDK/subagent use case)
|
||||
// See: https://github.com/anthropics/claude-agent-sdk-python/issues/573
|
||||
delete spawnEnv.CLAUDECODE;
|
||||
|
||||
debugLog('SPAWN', `Spawning process`, {
|
||||
command,
|
||||
args,
|
||||
|
||||
@@ -23,13 +23,6 @@ const CODE_EXTENSIONS = [
|
||||
'.ts', '.tsx', '.js', '.jsx', '.py', '.sh', '.go', '.rs'
|
||||
];
|
||||
|
||||
// Default models for each tool
|
||||
const DEFAULT_MODELS: Record<string, string> = {
|
||||
gemini: 'gemini-2.5-flash',
|
||||
qwen: 'coder-model',
|
||||
codex: 'gpt5-codex'
|
||||
};
|
||||
|
||||
// Template paths (relative to user home directory)
|
||||
const TEMPLATE_BASE = '~/.ccw/workflows/cli-templates/prompts/documentation';
|
||||
|
||||
@@ -141,20 +134,21 @@ function buildCliCommand(tool: string, promptFile: string, model: string): strin
|
||||
// Build the cat/read command based on platform
|
||||
const catCmd = isWindows ? `Get-Content -Raw "${normalizedPath}" | ` : `cat "${normalizedPath}" | `;
|
||||
|
||||
// Build model flag only if model is specified
|
||||
const modelFlag = model ? ` -m "${model}"` : '';
|
||||
|
||||
switch (tool) {
|
||||
case 'qwen':
|
||||
return model === 'coder-model'
|
||||
? `${catCmd}qwen --yolo`
|
||||
: `${catCmd}qwen -m "${model}" --yolo`;
|
||||
return `${catCmd}qwen${modelFlag} --yolo`;
|
||||
case 'codex':
|
||||
// codex uses different syntax - prompt as exec argument
|
||||
if (isWindows) {
|
||||
return `codex --full-auto exec (Get-Content -Raw "${normalizedPath}") -m "${model}" --skip-git-repo-check -s danger-full-access`;
|
||||
return `codex --full-auto exec (Get-Content -Raw "${normalizedPath}")${modelFlag} --skip-git-repo-check -s danger-full-access`;
|
||||
}
|
||||
return `codex --full-auto exec "$(cat "${normalizedPath}")" -m "${model}" --skip-git-repo-check -s danger-full-access`;
|
||||
return `codex --full-auto exec "$(cat "${normalizedPath}")"${modelFlag} --skip-git-repo-check -s danger-full-access`;
|
||||
case 'gemini':
|
||||
default:
|
||||
return `${catCmd}gemini -m "${model}" --yolo`;
|
||||
return `${catCmd}gemini${modelFlag} --yolo`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +267,8 @@ export async function handler(params: Record<string, unknown>): Promise<ToolResu
|
||||
try {
|
||||
actualModel = getSecondaryModel(process.cwd(), tool);
|
||||
} catch {
|
||||
actualModel = DEFAULT_MODELS[tool] || DEFAULT_MODELS.gemini;
|
||||
// If config not available, don't specify model - let CLI decide
|
||||
actualModel = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user