mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-03 05:19:21 +00:00
refactor(hooks): use provider_models mapping for image analysis
Changes ImageAnalysisConfig from providers array to provider_models mapping for granular vision model control per CLIProxy provider. Breaking change: config.yaml image_analysis section now uses provider_models instead of providers/model fields. Provider-to-model mappings: - agy → gemini-2.5-flash - gemini → gemini-2.5-flash - codex → gpt-5.1-codex-mini - kiro → kiro-claude-haiku-4-5 - ghcp → claude-haiku-4.5 - claude → claude-haiku-4-5-20251001 Hook checks CCS_CURRENT_PROVIDER against provider_models and skips if no vision model configured for that provider.
This commit is contained in:
1 parent
9662490a74
commit
40caff13ad
6 files changed
+113
-30
No files matched your search
@@ -9,25 +9,34 @@
|
||||
|
||||
import { getImageAnalysisConfig } from '../../config/unified-config-loader';
|
||||
|
||||
/**
|
||||
* Serialize provider_models map to env var format: provider:model,provider:model
|
||||
*/
|
||||
function serializeProviderModels(providerModels: Record<string, string>): string {
|
||||
return Object.entries(providerModels)
|
||||
.map(([provider, model]) => `${provider}:${model}`)
|
||||
.join(',');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image analysis hook environment variables.
|
||||
* These env vars control the hook's behavior via Claude Code hook system.
|
||||
*
|
||||
* @param profileName - Current profile name (to determine if native Claude)
|
||||
* @param provider - Current CLIProxy provider (e.g., 'agy', 'gemini', 'codex')
|
||||
* @returns Environment variables for image analysis hook
|
||||
*/
|
||||
export function getImageAnalysisHookEnv(profileName?: string): Record<string, string> {
|
||||
export function getImageAnalysisHookEnv(provider?: string): Record<string, string> {
|
||||
const config = getImageAnalysisConfig();
|
||||
|
||||
// Native Claude profiles (no CLIProxy) should skip image analysis
|
||||
const isNativeProfile = !profileName || ['claude', 'anthropic'].includes(profileName);
|
||||
const skipImageAnalysis = isNativeProfile || !config.enabled;
|
||||
// Check if current provider has a vision model configured
|
||||
const hasVisionModel = provider && config.provider_models[provider];
|
||||
const skipImageAnalysis = !config.enabled || !hasVisionModel;
|
||||
|
||||
return {
|
||||
CCS_IMAGE_ANALYSIS_ENABLED: config.enabled ? '1' : '0',
|
||||
CCS_IMAGE_ANALYSIS_MODEL: config.model || 'gemini-2.5-flash',
|
||||
CCS_IMAGE_ANALYSIS_TIMEOUT: String(Number(config.timeout) || 60),
|
||||
CCS_IMAGE_ANALYSIS_PROVIDERS: config.providers.join(','),
|
||||
CCS_IMAGE_ANALYSIS_PROVIDER_MODELS: serializeProviderModels(config.provider_models),
|
||||
CCS_CURRENT_PROVIDER: provider || '',
|
||||
CCS_IMAGE_ANALYSIS_SKIP: skipImageAnalysis ? '1' : '0',
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user