5478bab457
Addresses review feedback on #3486: 1. claude-thinking-legacy-alias now matches both claude-opus-4-6-thinking and claude-opus-4-7-thinking, canonicalizing both to claude-opus-4-7. The previous diff retargeted the regex to 4-7 only, which dropped backward compatibility for users still pinned to the 4-6 thinking suffix. 2. MODEL_TO_CATEGORY_MAP keeps the claude-opus-4-6 to unspecified-high entry alongside the new 4-7 entry. The map is order-independent from MODEL_VERSION_MAP, so preserving the 4-6 key avoids relying on a specific migration ordering for legacy agent configs. 3. Fix stale 'Claude Opus 4.6' labels and BDD test comments that the sed-based bump missed.
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
/**
|
|
* @deprecated LEGACY MIGRATION ONLY
|
|
*
|
|
* This map exists solely for migrating old configs that used hardcoded model strings.
|
|
* It maps legacy model strings to semantic category names, allowing users to migrate
|
|
* from explicit model configs to category-based configs.
|
|
*
|
|
* DO NOT add new entries here. New agents should use:
|
|
* - Category-based config (preferred): { category: "unspecified-high" }
|
|
* - Or inherit from OpenCode's config.model
|
|
*
|
|
* This map will be removed in a future major version once migration period ends.
|
|
*/
|
|
export const MODEL_TO_CATEGORY_MAP: Record<string, string> = {
|
|
"google/gemini-3.1-pro": "visual-engineering",
|
|
"google/gemini-3-flash": "writing",
|
|
"openai/gpt-5.4": "ultrabrain",
|
|
"anthropic/claude-haiku-4-5": "quick",
|
|
"anthropic/claude-opus-4-6": "unspecified-high",
|
|
"anthropic/claude-opus-4-7": "unspecified-high",
|
|
"anthropic/claude-sonnet-4-6": "unspecified-low",
|
|
}
|
|
|
|
export function migrateAgentConfigToCategory(config: Record<string, unknown>): {
|
|
migrated: Record<string, unknown>
|
|
changed: boolean
|
|
} {
|
|
const { model, ...rest } = config
|
|
if (typeof model !== "string") {
|
|
return { migrated: config, changed: false }
|
|
}
|
|
|
|
const category = MODEL_TO_CATEGORY_MAP[model]
|
|
if (!category) {
|
|
return { migrated: config, changed: false }
|
|
}
|
|
|
|
return {
|
|
migrated: { category, ...rest },
|
|
changed: true,
|
|
}
|
|
}
|
|
|
|
export function shouldDeleteAgentConfig(
|
|
config: Record<string, unknown>,
|
|
category: string
|
|
): boolean {
|
|
const { DEFAULT_CATEGORIES } = require("../../tools/delegate-task/constants")
|
|
const defaults = DEFAULT_CATEGORIES[category]
|
|
if (!defaults) return false
|
|
|
|
const keys = Object.keys(config).filter((k) => k !== "category")
|
|
if (keys.length === 0) return true
|
|
|
|
for (const key of keys) {
|
|
if (config[key] !== (defaults as Record<string, unknown>)[key]) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|