mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
feat: 添加标签颜色变体和验证功能,增强工具配置管理
This commit is contained in:
@@ -185,6 +185,24 @@ export function getToolConfig(baseDir: string, tool: string): CliToolConfig {
|
||||
return config.tools[tool] || DEFAULT_CONFIG.tools[tool];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and sanitize tags array
|
||||
* @param tags - Raw tags array from user input
|
||||
* @returns Sanitized tags array
|
||||
*/
|
||||
function validateTags(tags: string[] | undefined): string[] | undefined {
|
||||
if (!tags || !Array.isArray(tags)) return undefined;
|
||||
|
||||
const MAX_TAGS = 10;
|
||||
const MAX_TAG_LENGTH = 30;
|
||||
|
||||
return tags
|
||||
.filter(tag => typeof tag === 'string')
|
||||
.map(tag => tag.trim())
|
||||
.filter(tag => tag.length > 0 && tag.length <= MAX_TAG_LENGTH)
|
||||
.slice(0, MAX_TAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update configuration for a specific tool
|
||||
* Returns the updated tool config
|
||||
@@ -206,7 +224,7 @@ export function updateToolConfig(
|
||||
enabled: updates.enabled !== undefined ? updates.enabled : currentToolConfig.enabled,
|
||||
primaryModel: updates.primaryModel || currentToolConfig.primaryModel,
|
||||
secondaryModel: updates.secondaryModel || currentToolConfig.secondaryModel,
|
||||
tags: updates.tags !== undefined ? updates.tags : currentToolConfig.tags
|
||||
tags: updates.tags !== undefined ? validateTags(updates.tags) : currentToolConfig.tags
|
||||
};
|
||||
|
||||
// Save updated config
|
||||
|
||||
Reference in New Issue
Block a user