feat: enhance role-tier structure for models and update related configurations
This commit is contained in:
49
lib/tiers.ts
49
lib/tiers.ts
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
export const DEV_TIERS = ["junior", "medior", "senior"] as const;
|
||||
export const QA_TIERS = ["qa"] as const;
|
||||
export const QA_TIERS = ["qa-engineer", "manual-tester"] as const;
|
||||
export const ALL_TIERS = [...DEV_TIERS, ...QA_TIERS] as const;
|
||||
|
||||
export type DevTier = (typeof DEV_TIERS)[number];
|
||||
@@ -17,7 +17,21 @@ export const DEFAULT_MODELS: Record<Tier, string> = {
|
||||
junior: "anthropic/claude-haiku-4-5",
|
||||
medior: "anthropic/claude-sonnet-4-5",
|
||||
senior: "anthropic/claude-opus-4-5",
|
||||
qa: "anthropic/claude-sonnet-4-5",
|
||||
"qa-engineer": "anthropic/claude-sonnet-4-5",
|
||||
"manual-tester": "anthropic/claude-haiku-4-5",
|
||||
};
|
||||
|
||||
/** Default models by role-tier structure. */
|
||||
export const DEFAULT_MODELS_BY_ROLE = {
|
||||
dev: {
|
||||
junior: "anthropic/claude-haiku-4-5",
|
||||
medior: "anthropic/claude-sonnet-4-5",
|
||||
senior: "anthropic/claude-opus-4-5",
|
||||
},
|
||||
qa: {
|
||||
"qa-engineer": "anthropic/claude-sonnet-4-5",
|
||||
"manual-tester": "anthropic/claude-haiku-4-5",
|
||||
},
|
||||
};
|
||||
|
||||
/** Emoji used in announcements per tier. */
|
||||
@@ -25,7 +39,8 @@ export const TIER_EMOJI: Record<Tier, string> = {
|
||||
junior: "⚡",
|
||||
medior: "🔧",
|
||||
senior: "🧠",
|
||||
qa: "🔍",
|
||||
"qa-engineer": "🔍",
|
||||
"manual-tester": "👀",
|
||||
};
|
||||
|
||||
/** Check if a string is a valid tier name. */
|
||||
@@ -42,16 +57,31 @@ export function isDevTier(value: string): value is DevTier {
|
||||
* Resolve a tier name to a full model ID.
|
||||
*
|
||||
* Resolution order:
|
||||
* 1. Plugin config `models` map (user overrides)
|
||||
* 2. DEFAULT_MODELS (hardcoded defaults)
|
||||
* 3. Treat input as raw model ID (passthrough for non-tier values)
|
||||
* 1. Plugin config `models.<role>.<tier>` nested structure (user overrides)
|
||||
* 2. Plugin config `models.<tier>` flat structure (backward compatibility)
|
||||
* 3. DEFAULT_MODELS (hardcoded defaults)
|
||||
* 4. Treat input as raw model ID (passthrough for non-tier values)
|
||||
*/
|
||||
export function resolveTierToModel(
|
||||
tier: string,
|
||||
pluginConfig?: Record<string, unknown>,
|
||||
role?: "dev" | "qa",
|
||||
): string {
|
||||
const models = (pluginConfig as { models?: Record<string, string> })?.models;
|
||||
return models?.[tier] ?? DEFAULT_MODELS[tier as Tier] ?? tier;
|
||||
const models = (pluginConfig as { models?: Record<string, unknown> })?.models;
|
||||
|
||||
// Try nested role-tier structure first
|
||||
if (role && models && typeof models === "object") {
|
||||
const roleModels = models[role] as Record<string, string> | undefined;
|
||||
if (roleModels?.[tier]) return roleModels[tier];
|
||||
}
|
||||
|
||||
// Fall back to flat structure for backward compatibility
|
||||
if (models && typeof models === "object") {
|
||||
const flatModel = (models as Record<string, string>)[tier];
|
||||
if (flatModel) return flatModel;
|
||||
}
|
||||
|
||||
return DEFAULT_MODELS[tier as Tier] ?? tier;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,5 +92,6 @@ export const TIER_MIGRATION: Record<string, string> = {
|
||||
haiku: "junior",
|
||||
sonnet: "medior",
|
||||
opus: "senior",
|
||||
grok: "qa",
|
||||
grok: "qa-engineer",
|
||||
qa: "qa-engineer",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user