mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
Refactor execution modes and CLI integration across agents
- Updated code-developer, tdd-developer, and test-fix-agent to streamline execution modes based on task.meta.execution_config.method. - Removed legacy command handling and introduced CLI handoff for 'cli' execution method. - Enhanced buildCliHandoffPrompt to include task JSON path and improved context handling. - Updated task-generate-agent and task-generate-tdd to reflect new execution method mappings and removed command field from implementation_approach. - Improved CLI settings validation in CliSettingsModal with format and length checks. - Added localization for new CLI settings messages in English and Chinese. - Enhanced GPU selector to use localized strings for GPU types. - Introduced TypeScript LSP setup documentation for better user guidance.
This commit is contained in:
@@ -116,6 +116,16 @@ export function CliSettingsModal({ open, onClose, cliSettings }: CliSettingsModa
|
||||
|
||||
if (!name.trim()) {
|
||||
newErrors.name = formatMessage({ id: 'apiSettings.validation.nameRequired' });
|
||||
} else {
|
||||
// Validate name format: must start with letter, followed by letters/numbers/hyphens/underscores
|
||||
const namePattern = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
||||
if (!namePattern.test(name.trim())) {
|
||||
newErrors.name = formatMessage({ id: 'apiSettings.cliSettings.nameFormatHint' });
|
||||
}
|
||||
// Validate name length
|
||||
if (name.trim().length > 32) {
|
||||
newErrors.name = formatMessage({ id: 'apiSettings.cliSettings.nameTooLong' }, { max: 32 });
|
||||
}
|
||||
}
|
||||
|
||||
if (mode === 'provider-based') {
|
||||
@@ -219,7 +229,11 @@ export function CliSettingsModal({ open, onClose, cliSettings }: CliSettingsModa
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
placeholder={formatMessage({ id: 'apiSettings.cliSettings.namePlaceholder' })}
|
||||
className={errors.name ? 'border-destructive' : ''}
|
||||
maxLength={32}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatMessage({ id: 'apiSettings.cliSettings.nameFormatHint' })}
|
||||
</p>
|
||||
{errors.name && <p className="text-sm text-destructive">{errors.name}</p>}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ function DeviceCard({ device, isSelected, onSelect, isSelecting }: DeviceCardPro
|
||||
)}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatMessage({ id: 'codexlens.gpu.type' })}: {device.type === 'discrete' ? '独立显卡' : '集成显卡'}
|
||||
{formatMessage({ id: 'codexlens.gpu.type' })}: {formatMessage({ id: device.type === 'discrete' ? 'codexlens.gpu.discrete' : 'codexlens.gpu.integrated' })}
|
||||
</p>
|
||||
{device.memory?.total && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
|
||||
@@ -289,6 +289,8 @@
|
||||
"descriptionPlaceholder": "Optional description for this configuration",
|
||||
"selectProvider": "Select a provider",
|
||||
"includeCoAuthoredBy": "Include co-authored-by in commits",
|
||||
"nameFormatHint": "Letters, numbers, hyphens, underscores only. Used as: ccw cli --tool [name]",
|
||||
"nameTooLong": "Name must be {max} characters or less",
|
||||
"validation": {
|
||||
"providerRequired": "Please select a provider",
|
||||
"authOrBaseUrlRequired": "Please enter auth token or base URL"
|
||||
|
||||
@@ -142,6 +142,8 @@
|
||||
"notAvailable": "GPU functionality not available",
|
||||
"unknownDevice": "Unknown device",
|
||||
"type": "Type",
|
||||
"discrete": "Discrete GPU",
|
||||
"integrated": "Integrated GPU",
|
||||
"driver": "Driver Version",
|
||||
"memory": "Memory"
|
||||
},
|
||||
|
||||
@@ -289,6 +289,8 @@
|
||||
"descriptionPlaceholder": "此配置的可选描述",
|
||||
"selectProvider": "选择提供商",
|
||||
"includeCoAuthoredBy": "在提交中包含 co-authored-by",
|
||||
"nameFormatHint": "仅限字母、数字、连字符和下划线。用作:ccw cli --tool [名称]",
|
||||
"nameTooLong": "名称必须在 {max} 个字符以内",
|
||||
"validation": {
|
||||
"providerRequired": "请选择提供商",
|
||||
"authOrBaseUrlRequired": "请输入认证令牌或基础 URL"
|
||||
|
||||
@@ -142,6 +142,8 @@
|
||||
"notAvailable": "GPU 功能不可用",
|
||||
"unknownDevice": "未知设备",
|
||||
"type": "类型",
|
||||
"discrete": "独立显卡",
|
||||
"integrated": "集成显卡",
|
||||
"driver": "驱动版本",
|
||||
"memory": "显存"
|
||||
},
|
||||
|
||||
@@ -446,9 +446,9 @@ export function SettingsPage() {
|
||||
{/* System Theme Toggle (Backward Compatibility) */}
|
||||
<div className="flex items-center justify-between pt-4 border-t border-border">
|
||||
<div>
|
||||
<p className="font-medium text-foreground">系统跟随</p>
|
||||
<p className="font-medium text-foreground">{formatMessage({ id: 'settings.appearance.systemFollow' })}</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
使用系统的深色/浅色模式设置
|
||||
{formatMessage({ id: 'settings.appearance.systemFollowDesc' })}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
|
||||
@@ -421,7 +421,7 @@ async function showToolConfigModal(toolName) {
|
||||
var status = cliToolStatus[toolName] || {};
|
||||
|
||||
if (!toolConfig) {
|
||||
toolConfig = { enabled: true, primaryModel: '', secondaryModel: '' };
|
||||
toolConfig = { enabled: true, primaryModel: '', secondaryModel: '', type: 'builtin' };
|
||||
}
|
||||
|
||||
var content = buildToolConfigModalContent(toolName, toolConfig, models, status);
|
||||
@@ -1163,7 +1163,7 @@ function initToolConfigModalEvents(tool, currentConfig, models) {
|
||||
}
|
||||
|
||||
// Only include settingsFile for builtin claude tool
|
||||
if (tool === 'claude' && config.type === 'builtin') {
|
||||
if (tool === 'claude' && currentConfig.type === 'builtin') {
|
||||
updateData.settingsFile = settingsFile || null;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,10 +228,13 @@ function getGlobalSettingsPath(): string {
|
||||
*/
|
||||
function resolveConfigPath(projectDir: string): { path: string; source: 'project' | 'global' | 'default' } {
|
||||
const globalPath = getGlobalConfigPath();
|
||||
debugLog(`[HYPOTHESIS-1] Checking for global config at: ${globalPath}`);
|
||||
if (fs.existsSync(globalPath)) {
|
||||
debugLog(`[HYPOTHESIS-1] Global config found. Using source: 'global'`);
|
||||
return { path: globalPath, source: 'global' };
|
||||
}
|
||||
|
||||
debugLog(`[HYPOTHESIS-1] Global config NOT found. Using source: 'default'`);
|
||||
// Return global path for default (will be created there)
|
||||
return { path: globalPath, source: 'default' };
|
||||
}
|
||||
@@ -278,15 +281,13 @@ function backupConfigFile(filePath: string): string {
|
||||
|
||||
/**
|
||||
* Ensure tool has required fields (for backward compatibility)
|
||||
* Preserves ALL fields from original tool object
|
||||
*/
|
||||
function ensureToolTags(tool: Partial<ClaudeCliTool>): ClaudeCliTool {
|
||||
return {
|
||||
...tool, // Preserve all original fields (including availableModels, type, id, etc.)
|
||||
enabled: tool.enabled ?? true,
|
||||
primaryModel: tool.primaryModel,
|
||||
secondaryModel: tool.secondaryModel,
|
||||
tags: tool.tags ?? [],
|
||||
envFile: tool.envFile,
|
||||
settingsFile: tool.settingsFile
|
||||
tags: tool.tags ?? []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -509,10 +510,12 @@ export async function ensureClaudeCliToolsAsync(projectDir: string, createInProj
|
||||
* Automatically migrates older config versions to v3.2.0
|
||||
*/
|
||||
export function loadClaudeCliTools(projectDir: string): ClaudeCliToolsConfig & { _source?: string } {
|
||||
debugLog(`[DIAGNOSIS] Starting to load claude cli tools for projectDir: ${projectDir}`);
|
||||
const resolved = resolveConfigPath(projectDir);
|
||||
|
||||
try {
|
||||
if (resolved.source === 'default') {
|
||||
debugLog('[DIAGNOSIS] Resolved source is "default", returning default config.');
|
||||
return { ...DEFAULT_TOOLS_CONFIG, _source: 'default' };
|
||||
}
|
||||
|
||||
@@ -526,9 +529,8 @@ export function loadClaudeCliTools(projectDir: string): ClaudeCliToolsConfig & {
|
||||
const mergedTools: Record<string, ClaudeCliTool> = {};
|
||||
for (const [key, tool] of Object.entries(migrated.tools || {})) {
|
||||
mergedTools[key] = {
|
||||
...ensureToolTags(tool),
|
||||
type: tool.type ?? 'builtin',
|
||||
id: tool.id // Preserve id for api-endpoint type
|
||||
...ensureToolTags(tool), // Now preserves all fields including availableModels, type, id
|
||||
type: tool.type ?? 'builtin' // Ensure type has default value
|
||||
};
|
||||
}
|
||||
|
||||
@@ -554,6 +556,7 @@ export function loadClaudeCliTools(projectDir: string): ClaudeCliToolsConfig & {
|
||||
debugLog(`[claude-cli-tools] Loaded tools config from ${resolved.source}: ${resolved.path}`);
|
||||
return config;
|
||||
} catch (err) {
|
||||
console.error('[HYPOTHESIS-2] Error loading or parsing tools config. Falling back to default. Error:', err);
|
||||
console.error('[claude-cli-tools] Error loading tools config:', err);
|
||||
return { ...DEFAULT_TOOLS_CONFIG, _source: 'default' };
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ export interface CliToolConfig {
|
||||
secondaryModel: string;
|
||||
tags?: string[];
|
||||
envFile?: string | null;
|
||||
type?: 'builtin' | 'cli-wrapper' | 'api-endpoint'; // Tool type for frontend routing
|
||||
settingsFile?: string | null; // Claude CLI settings file path
|
||||
}
|
||||
|
||||
export interface CliConfig {
|
||||
@@ -156,7 +158,9 @@ export function getFullConfigResponse(baseDir: string): {
|
||||
primaryModel: tool.primaryModel ?? '',
|
||||
secondaryModel: tool.secondaryModel ?? '',
|
||||
tags: tool.tags,
|
||||
envFile: tool.envFile
|
||||
envFile: tool.envFile,
|
||||
type: tool.type, // Preserve type field for frontend routing
|
||||
settingsFile: tool.settingsFile // Preserve settingsFile for Claude CLI
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user