* docs(adr): add ADR-0003 model catalog module * fix(#3229): add shared model catalog as source of truth for agent profiles and runtime tier defaults Research / design (ADR-0003): - Existing drift came from 4 independent model truths: 1. CJS model-profiles.cjs 2. SDK config-query.ts stale copy (18 agents) 3. settings-advanced.md runtime tier table 4. session-runner Claude-only profile map - New design: one machine-readable Model Catalog Module in sdk/shared/ that both packages ship and consume. Implementation: - sdk/shared/model-catalog.json — canonical source of truth for: - full 33-agent registry - per-agent golden (quality) alias + balanced/budget aliases - adaptive derivation from routingTier - agent→phaseType map - agent→dynamic-routing default tier map - runtime tier defaults for all supported runtimes - get-shit-done/bin/lib/model-catalog.cjs — CJS adapter over the catalog - sdk/src/model-catalog.ts — SDK adapter over the same catalog - CJS model-profiles.cjs now re-exports derived data from model-catalog.cjs - SDK config-query.ts now re-exports MODEL_PROFILES/VALID_PROFILES from model-catalog.ts instead of maintaining its own list - sdk/src/query/helpers.ts runtime list now comes from the catalog (fixes hermes drift) - sdk/src/session-runner.ts Claude profile→model-id mapping now resolves via catalog - docs/CONFIGURATION.md + settings-advanced.md runtime tables updated to match catalog Behavior changes: - resolve-model now covers every shipped agent file on disk (33 agents) - unknown-agent fallback is profile-semantic, not hardcoded sonnet: quality→opus, budget→haiku, balanced/adaptive→sonnet, inherit→inherit - Group B runtimes remain known runtimes but do not get built-in tier defaults Tests (RED→GREEN): - root tests: shipped agent files must equal MODEL_PROFILES keys - sdk tests: shipped agent files must equal MODEL_PROFILES keys - direct fix assertion: gsd-code-reviewer resolves to opus under quality with no unknown_agent - runtime defaults parity test: settings-advanced.md + CONFIGURATION.md tables must match catalog - helper tests: hermes included in SUPPORTED_RUNTIMES and getRuntimeConfigDir() Closes #3229 * chore(changeset): update #3229 changeset pr field to 3230 * fix(ci): update inherit fallback expectations and inventory parity for model catalog
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"shared",
|
||||
"prompts"
|
||||
],
|
||||
"repository": {
|
||||
|
||||
122
sdk/shared/model-catalog.json
Normal file
122
sdk/shared/model-catalog.json
Normal file
@@ -0,0 +1,122 @@
|
||||
{
|
||||
"profiles": ["quality", "balanced", "budget", "adaptive", "inherit"],
|
||||
"phaseTypes": ["planning", "discuss", "research", "execution", "verification", "completion"],
|
||||
"adaptiveTierMap": {
|
||||
"heavy": "opus",
|
||||
"standard": "sonnet",
|
||||
"light": "haiku"
|
||||
},
|
||||
"runtimeTierDefaults": {
|
||||
"claude": {
|
||||
"opus": { "model": "claude-opus-4-7" },
|
||||
"sonnet": { "model": "claude-sonnet-4-6" },
|
||||
"haiku": { "model": "claude-haiku-4-5" }
|
||||
},
|
||||
"codex": {
|
||||
"opus": { "model": "gpt-5.4", "reasoning_effort": "xhigh" },
|
||||
"sonnet": { "model": "gpt-5.3-codex", "reasoning_effort": "medium" },
|
||||
"haiku": { "model": "gpt-5.4-mini", "reasoning_effort": "medium" }
|
||||
},
|
||||
"gemini": {
|
||||
"opus": { "model": "gemini-3-pro" },
|
||||
"sonnet": { "model": "gemini-3-flash" },
|
||||
"haiku": { "model": "gemini-2.5-flash-lite" }
|
||||
},
|
||||
"qwen": {
|
||||
"opus": { "model": "qwen3-max-2026-01-23" },
|
||||
"sonnet": { "model": "qwen3-coder-plus" },
|
||||
"haiku": { "model": "qwen3-coder-next" }
|
||||
},
|
||||
"opencode": {
|
||||
"opus": { "model": "anthropic/claude-opus-4-7" },
|
||||
"sonnet": { "model": "anthropic/claude-sonnet-4-6" },
|
||||
"haiku": { "model": "anthropic/claude-haiku-4-5" }
|
||||
},
|
||||
"copilot": {
|
||||
"opus": { "model": "claude-opus-4-7" },
|
||||
"sonnet": { "model": "claude-sonnet-4-6" },
|
||||
"haiku": { "model": "claude-haiku-4-5" }
|
||||
},
|
||||
"hermes": {
|
||||
"opus": { "model": "anthropic/claude-opus-4-7" },
|
||||
"sonnet": { "model": "anthropic/claude-sonnet-4-6" },
|
||||
"haiku": { "model": "anthropic/claude-haiku-4-5" }
|
||||
},
|
||||
"kilo": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
},
|
||||
"cline": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
},
|
||||
"cursor": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
},
|
||||
"windsurf": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
},
|
||||
"augment": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
},
|
||||
"trae": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
},
|
||||
"codebuddy": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
},
|
||||
"antigravity": {
|
||||
"opus": null,
|
||||
"sonnet": null,
|
||||
"haiku": null
|
||||
}
|
||||
},
|
||||
"agents": {
|
||||
"gsd-planner": { "golden": "opus", "balanced": "opus", "budget": "sonnet", "phaseType": "planning", "routingTier": "heavy" },
|
||||
"gsd-roadmapper": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "planning", "routingTier": "heavy" },
|
||||
"gsd-executor": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "execution", "routingTier": "standard" },
|
||||
"gsd-phase-researcher": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "standard" },
|
||||
"gsd-project-researcher": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "standard" },
|
||||
"gsd-research-synthesizer": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "light" },
|
||||
"gsd-debugger": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "execution", "routingTier": "heavy" },
|
||||
"gsd-codebase-mapper": { "golden": "sonnet", "balanced": "haiku", "budget": "haiku", "phaseType": "research", "routingTier": "light" },
|
||||
"gsd-verifier": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "standard" },
|
||||
"gsd-plan-checker": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "light" },
|
||||
"gsd-integration-checker": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "light" },
|
||||
"gsd-nyquist-auditor": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "light" },
|
||||
"gsd-pattern-mapper": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "planning", "routingTier": "light" },
|
||||
"gsd-ui-researcher": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "standard" },
|
||||
"gsd-ui-checker": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "light" },
|
||||
"gsd-ui-auditor": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "light" },
|
||||
"gsd-doc-writer": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "execution", "routingTier": "standard" },
|
||||
"gsd-doc-verifier": { "golden": "sonnet", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "light" },
|
||||
|
||||
"gsd-advisor-researcher": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "standard" },
|
||||
"gsd-ai-researcher": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "standard" },
|
||||
"gsd-assumptions-analyzer": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "discuss", "routingTier": "heavy" },
|
||||
"gsd-code-fixer": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "execution", "routingTier": "standard" },
|
||||
"gsd-code-reviewer": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "verification", "routingTier": "standard" },
|
||||
"gsd-debug-session-manager": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "execution", "routingTier": "heavy" },
|
||||
"gsd-doc-classifier": { "golden": "sonnet", "balanced": "haiku", "budget": "haiku", "phaseType": "research", "routingTier": "light" },
|
||||
"gsd-doc-synthesizer": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "standard" },
|
||||
"gsd-domain-researcher": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "standard" },
|
||||
"gsd-eval-auditor": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "verification", "routingTier": "standard" },
|
||||
"gsd-eval-planner": { "golden": "opus", "balanced": "opus", "budget": "sonnet", "phaseType": "planning", "routingTier": "heavy" },
|
||||
"gsd-framework-selector": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "planning", "routingTier": "heavy" },
|
||||
"gsd-intel-updater": { "golden": "opus", "balanced": "sonnet", "budget": "haiku", "phaseType": "research", "routingTier": "light" },
|
||||
"gsd-security-auditor": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "verification", "routingTier": "heavy" },
|
||||
"gsd-user-profiler": { "golden": "opus", "balanced": "sonnet", "budget": "sonnet", "phaseType": "research", "routingTier": "heavy" }
|
||||
}
|
||||
}
|
||||
70
sdk/src/model-catalog.ts
Normal file
70
sdk/src/model-catalog.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
interface RuntimeTierEntry {
|
||||
model: string;
|
||||
reasoning_effort?: string;
|
||||
}
|
||||
|
||||
type RuntimeTierTable = Record<string, Record<string, RuntimeTierEntry | null>>;
|
||||
|
||||
interface AgentCatalogEntry {
|
||||
golden: 'opus' | 'sonnet' | 'haiku';
|
||||
balanced: 'opus' | 'sonnet' | 'haiku';
|
||||
budget: 'opus' | 'sonnet' | 'haiku';
|
||||
phaseType: string;
|
||||
routingTier: 'light' | 'standard' | 'heavy';
|
||||
}
|
||||
|
||||
interface ModelCatalog {
|
||||
profiles: string[];
|
||||
phaseTypes: string[];
|
||||
adaptiveTierMap: Record<'light' | 'standard' | 'heavy', 'opus' | 'sonnet' | 'haiku'>;
|
||||
runtimeTierDefaults: RuntimeTierTable;
|
||||
agents: Record<string, AgentCatalogEntry>;
|
||||
}
|
||||
|
||||
const CATALOG_PATH = new URL('../shared/model-catalog.json', import.meta.url);
|
||||
export const catalog: ModelCatalog = JSON.parse(readFileSync(fileURLToPath(CATALOG_PATH), 'utf-8'));
|
||||
|
||||
export const VALID_PROFILES: string[] = [...catalog.profiles];
|
||||
export const SUPPORTED_RUNTIMES = Object.keys(catalog.runtimeTierDefaults);
|
||||
export type Runtime = (typeof SUPPORTED_RUNTIMES)[number];
|
||||
|
||||
export const MODEL_PROFILES: Record<string, Record<string, string>> = Object.fromEntries(
|
||||
Object.entries(catalog.agents).map(([agent, meta]) => [agent, {
|
||||
quality: meta.golden,
|
||||
balanced: meta.balanced,
|
||||
budget: meta.budget,
|
||||
adaptive: catalog.adaptiveTierMap[meta.routingTier],
|
||||
}])
|
||||
);
|
||||
|
||||
export const AGENT_TO_PHASE_TYPE: Record<string, string> = Object.fromEntries(
|
||||
Object.entries(catalog.agents).map(([agent, meta]) => [agent, meta.phaseType])
|
||||
);
|
||||
|
||||
export const AGENT_DEFAULT_TIERS: Record<string, string> = Object.fromEntries(
|
||||
Object.entries(catalog.agents).map(([agent, meta]) => [agent, meta.routingTier])
|
||||
);
|
||||
|
||||
export function getAgentToModelMapForProfile(normalizedProfile: string): Record<string, string> {
|
||||
const profile = VALID_PROFILES.includes(normalizedProfile) ? normalizedProfile : 'balanced';
|
||||
const out: Record<string, string> = {};
|
||||
for (const [agent, profiles] of Object.entries(MODEL_PROFILES)) {
|
||||
out[agent] = profile === 'inherit' ? 'inherit' : profiles[profile] ?? profiles.balanced;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function resolveRuntimeTierDefault(runtime: string, alias: 'opus' | 'sonnet' | 'haiku'): RuntimeTierEntry | null {
|
||||
return catalog.runtimeTierDefaults[runtime]?.[alias] ?? null;
|
||||
}
|
||||
|
||||
export function runtimesWithReasoningEffort(): Set<string> {
|
||||
return new Set(
|
||||
Object.entries(catalog.runtimeTierDefaults)
|
||||
.filter(([, tiers]) => Object.values(tiers).some((entry) => entry && entry.reasoning_effort))
|
||||
.map(([runtime]) => runtime)
|
||||
);
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { mkdtemp, writeFile, mkdir, rm } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { mkdtemp, writeFile, mkdir, rm, readdir } from 'node:fs/promises';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { GSDError, ErrorClassification, exitCodeFor } from '../errors.js';
|
||||
|
||||
@@ -121,16 +121,36 @@ describe('resolveModel', () => {
|
||||
expect(data).not.toHaveProperty('unknown_agent');
|
||||
});
|
||||
|
||||
it('returns unknown_agent flag for unknown agent', async () => {
|
||||
it('resolves shipped-but-previously-missing agents without unknown_agent (#3229)', async () => {
|
||||
const { resolveModel } = await import('./config-query.js');
|
||||
await writeFile(
|
||||
join(tmpDir, '.planning', 'config.json'),
|
||||
JSON.stringify({ model_profile: 'balanced' }),
|
||||
JSON.stringify({ model_profile: 'quality' }),
|
||||
);
|
||||
const result = await resolveModel(['unknown-agent'], tmpDir);
|
||||
const result = await resolveModel(['gsd-code-reviewer'], tmpDir);
|
||||
const data = result.data as Record<string, unknown>;
|
||||
expect(data).toHaveProperty('model', 'sonnet');
|
||||
expect(data).toHaveProperty('unknown_agent', true);
|
||||
expect(data).toHaveProperty('model', 'opus');
|
||||
expect(data).toHaveProperty('profile', 'quality');
|
||||
expect(data).not.toHaveProperty('unknown_agent');
|
||||
});
|
||||
|
||||
it('returns profile-semantic fallback for truly unknown agents (#3229)', async () => {
|
||||
const { resolveModel } = await import('./config-query.js');
|
||||
await writeFile(
|
||||
join(tmpDir, '.planning', 'config.json'),
|
||||
JSON.stringify({ model_profile: 'quality' }),
|
||||
);
|
||||
const quality = (await resolveModel(['unknown-agent'], tmpDir)).data as Record<string, unknown>;
|
||||
expect(quality).toHaveProperty('model', 'opus');
|
||||
expect(quality).toHaveProperty('unknown_agent', true);
|
||||
|
||||
await writeFile(
|
||||
join(tmpDir, '.planning', 'config.json'),
|
||||
JSON.stringify({ model_profile: 'budget' }),
|
||||
);
|
||||
const budget = (await resolveModel(['unknown-agent'], tmpDir)).data as Record<string, unknown>;
|
||||
expect(budget).toHaveProperty('model', 'haiku');
|
||||
expect(budget).toHaveProperty('unknown_agent', true);
|
||||
});
|
||||
|
||||
it('throws GSDError when no agent type provided', async () => {
|
||||
@@ -195,12 +215,17 @@ describe('resolveModel', () => {
|
||||
// ─── MODEL_PROFILES ─────────────────────────────────────────────────────────
|
||||
|
||||
describe('MODEL_PROFILES', () => {
|
||||
it('contains all 18 agent entries (sync with model-profiles.cjs)', async () => {
|
||||
it('contains every shipped gsd agent file on disk (#3229)', async () => {
|
||||
const { MODEL_PROFILES } = await import('./config-query.js');
|
||||
expect(Object.keys(MODEL_PROFILES)).toHaveLength(18);
|
||||
const repoRoot = resolve(process.cwd(), '..');
|
||||
const agentFiles = (await readdir(join(repoRoot, 'agents')))
|
||||
.filter((f) => /^gsd-.*\.md$/.test(f))
|
||||
.map((f) => f.replace(/\.md$/, ''))
|
||||
.sort();
|
||||
expect(Object.keys(MODEL_PROFILES).sort()).toEqual(agentFiles);
|
||||
});
|
||||
|
||||
it('has quality/balanced/budget/adaptive for each agent', async () => {
|
||||
it('has quality/balanced/budget/adaptive for each shipped agent', async () => {
|
||||
const { MODEL_PROFILES } = await import('./config-query.js');
|
||||
for (const agent of Object.keys(MODEL_PROFILES)) {
|
||||
expect(MODEL_PROFILES[agent]).toHaveProperty('quality');
|
||||
@@ -214,9 +239,9 @@ describe('MODEL_PROFILES', () => {
|
||||
// ─── VALID_PROFILES ─────────────────────────────────────────────────────────
|
||||
|
||||
describe('VALID_PROFILES', () => {
|
||||
it('contains the four profile names', async () => {
|
||||
it('contains quality, balanced, budget, adaptive, and inherit', async () => {
|
||||
const { VALID_PROFILES } = await import('./config-query.js');
|
||||
expect(VALID_PROFILES).toEqual(['quality', 'balanced', 'budget', 'adaptive']);
|
||||
expect(VALID_PROFILES.sort()).toEqual(['adaptive', 'balanced', 'budget', 'inherit', 'quality']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -23,50 +23,8 @@ import { loadConfig } from '../config.js';
|
||||
import { planningPaths } from './helpers.js';
|
||||
import { maskIfSecret } from './secrets.js';
|
||||
import type { QueryHandler } from './utils.js';
|
||||
|
||||
// ─── MODEL_PROFILES ─────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Mapping of GSD agent type to model alias for each profile tier.
|
||||
*
|
||||
* Ported from get-shit-done/bin/lib/model-profiles.cjs.
|
||||
*/
|
||||
export const MODEL_PROFILES: Record<string, Record<string, string>> = {
|
||||
'gsd-planner': { quality: 'opus', balanced: 'opus', budget: 'sonnet', adaptive: 'opus' },
|
||||
'gsd-roadmapper': { quality: 'opus', balanced: 'sonnet', budget: 'sonnet', adaptive: 'sonnet' },
|
||||
'gsd-executor': { quality: 'opus', balanced: 'sonnet', budget: 'sonnet', adaptive: 'sonnet' },
|
||||
'gsd-phase-researcher': { quality: 'opus', balanced: 'sonnet', budget: 'haiku', adaptive: 'sonnet' },
|
||||
'gsd-project-researcher': { quality: 'opus', balanced: 'sonnet', budget: 'haiku', adaptive: 'sonnet' },
|
||||
'gsd-research-synthesizer': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-debugger': { quality: 'opus', balanced: 'sonnet', budget: 'sonnet', adaptive: 'opus' },
|
||||
'gsd-codebase-mapper': { quality: 'sonnet', balanced: 'haiku', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-verifier': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'sonnet' },
|
||||
'gsd-plan-checker': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-integration-checker': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-nyquist-auditor': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-pattern-mapper': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-ui-researcher': { quality: 'opus', balanced: 'sonnet', budget: 'haiku', adaptive: 'sonnet' },
|
||||
'gsd-ui-checker': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-ui-auditor': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
'gsd-doc-writer': { quality: 'opus', balanced: 'sonnet', budget: 'haiku', adaptive: 'sonnet' },
|
||||
'gsd-doc-verifier': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku', adaptive: 'haiku' },
|
||||
};
|
||||
|
||||
/** Valid model profile names. */
|
||||
export const VALID_PROFILES: string[] = Object.keys(MODEL_PROFILES['gsd-planner']);
|
||||
|
||||
/**
|
||||
* Flat map of agent name → model alias for one profile tier (matches `model-profiles.cjs`).
|
||||
*/
|
||||
export function getAgentToModelMapForProfile(normalizedProfile: string): Record<string, string> {
|
||||
const profile = VALID_PROFILES.includes(normalizedProfile) ? normalizedProfile : 'balanced';
|
||||
const agentToModelMap: Record<string, string> = {};
|
||||
for (const [agent, profileToModelMap] of Object.entries(MODEL_PROFILES)) {
|
||||
const mapped = profileToModelMap[profile] ?? profileToModelMap.balanced;
|
||||
agentToModelMap[agent] = mapped ?? 'sonnet';
|
||||
}
|
||||
return agentToModelMap;
|
||||
}
|
||||
export { MODEL_PROFILES, VALID_PROFILES, getAgentToModelMapForProfile } from '../model-catalog.js';
|
||||
import { MODEL_PROFILES, VALID_PROFILES, getAgentToModelMapForProfile } from '../model-catalog.js';
|
||||
|
||||
// ─── configGet ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -204,7 +162,12 @@ export const resolveModel: QueryHandler = async (args, projectDir, workstream) =
|
||||
// Fall back to profile lookup
|
||||
const agentModels = MODEL_PROFILES[agentType];
|
||||
if (!agentModels) {
|
||||
return { data: { model: 'sonnet', profile, unknown_agent: true } };
|
||||
const semanticFallback =
|
||||
profile === 'quality' ? 'opus'
|
||||
: profile === 'budget' ? 'haiku'
|
||||
: profile === 'inherit' ? 'inherit'
|
||||
: 'sonnet';
|
||||
return { data: { model: semanticFallback, profile, unknown_agent: true } };
|
||||
}
|
||||
|
||||
if (profile === 'inherit') {
|
||||
|
||||
@@ -285,7 +285,7 @@ const RUNTIME_ENV_VARS = [
|
||||
'OPENCODE_CONFIG', 'KILO_CONFIG_DIR', 'KILO_CONFIG', 'XDG_CONFIG_HOME',
|
||||
'GEMINI_CONFIG_DIR', 'CODEX_HOME', 'COPILOT_CONFIG_DIR', 'ANTIGRAVITY_CONFIG_DIR',
|
||||
'CURSOR_CONFIG_DIR', 'WINDSURF_CONFIG_DIR', 'AUGMENT_CONFIG_DIR', 'TRAE_CONFIG_DIR',
|
||||
'QWEN_CONFIG_DIR', 'CODEBUDDY_CONFIG_DIR', 'CLINE_CONFIG_DIR',
|
||||
'QWEN_CONFIG_DIR', 'CODEBUDDY_CONFIG_DIR', 'CLINE_CONFIG_DIR', 'HERMES_HOME',
|
||||
] as const;
|
||||
|
||||
describe('getRuntimeConfigDir', () => {
|
||||
@@ -315,6 +315,7 @@ describe('getRuntimeConfigDir', () => {
|
||||
qwen: join(homedir(), '.qwen'),
|
||||
codebuddy: join(homedir(), '.codebuddy'),
|
||||
cline: join(homedir(), '.cline'),
|
||||
hermes: join(homedir(), '.hermes'),
|
||||
};
|
||||
|
||||
for (const runtime of SUPPORTED_RUNTIMES) {
|
||||
@@ -336,6 +337,7 @@ describe('getRuntimeConfigDir', () => {
|
||||
['qwen', 'QWEN_CONFIG_DIR', '/x/qwen'],
|
||||
['codebuddy', 'CODEBUDDY_CONFIG_DIR', '/x/codebuddy'],
|
||||
['cline', 'CLINE_CONFIG_DIR', '/x/cline'],
|
||||
['hermes', 'HERMES_HOME', '/x/hermes'],
|
||||
['opencode', 'OPENCODE_CONFIG_DIR', '/x/opencode'],
|
||||
['kilo', 'KILO_CONFIG_DIR', '/x/kilo'],
|
||||
];
|
||||
|
||||
@@ -23,19 +23,11 @@ import { existsSync, statSync, readFileSync } from 'node:fs';
|
||||
import { homedir } from 'node:os';
|
||||
import { GSDError, ErrorClassification } from '../errors.js';
|
||||
import { relPlanningPath } from '../workstream-utils.js';
|
||||
export { SUPPORTED_RUNTIMES, type Runtime } from '../model-catalog.js';
|
||||
import { SUPPORTED_RUNTIMES, type Runtime } from '../model-catalog.js';
|
||||
|
||||
// ─── Runtime-aware agents directory resolution ─────────────────────────────
|
||||
|
||||
/**
|
||||
* Supported GSD runtimes. Kept in sync with `bin/install.js:getGlobalDir()`.
|
||||
*/
|
||||
export const SUPPORTED_RUNTIMES = [
|
||||
'claude', 'opencode', 'kilo', 'gemini', 'codex', 'copilot', 'antigravity',
|
||||
'cursor', 'windsurf', 'augment', 'trae', 'qwen', 'codebuddy', 'cline',
|
||||
] as const;
|
||||
|
||||
export type Runtime = (typeof SUPPORTED_RUNTIMES)[number];
|
||||
|
||||
function expandTilde(p: string): string {
|
||||
return p.startsWith('~/') || p === '~' ? join(homedir(), p.slice(1)) : p;
|
||||
}
|
||||
@@ -82,6 +74,10 @@ export function getRuntimeConfigDir(runtime: Runtime): string {
|
||||
return process.env.CODEBUDDY_CONFIG_DIR ? expandTilde(process.env.CODEBUDDY_CONFIG_DIR) : join(homedir(), '.codebuddy');
|
||||
case 'cline':
|
||||
return process.env.CLINE_CONFIG_DIR ? expandTilde(process.env.CLINE_CONFIG_DIR) : join(homedir(), '.cline');
|
||||
case 'hermes':
|
||||
return process.env.HERMES_HOME ? expandTilde(process.env.HERMES_HOME) : join(homedir(), '.hermes');
|
||||
default:
|
||||
throw new Error(`Unknown runtime: ${String(runtime)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import { buildExecutorPrompt, parseAgentTools, DEFAULT_ALLOWED_TOOLS } from './p
|
||||
import type { GSDEventStream, EventStreamContext } from './event-stream.js';
|
||||
import { getToolsForPhase } from './tool-scoping.js';
|
||||
import { detectRuntime } from './query/helpers.js';
|
||||
import { resolveRuntimeTierDefault } from './model-catalog.js';
|
||||
|
||||
// ─── Model resolution ────────────────────────────────────────────────────────
|
||||
|
||||
@@ -50,12 +51,13 @@ function resolveModel(options?: SessionOptions, config?: GSDConfig): string | un
|
||||
}
|
||||
|
||||
if (config?.model_profile) {
|
||||
const profileMap: Record<string, string> = {
|
||||
balanced: 'claude-sonnet-4-6',
|
||||
quality: 'claude-opus-4-6',
|
||||
speed: 'claude-haiku-4-5',
|
||||
};
|
||||
return profileMap[config.model_profile] ?? config.model_profile;
|
||||
const profile = String(config.model_profile).toLowerCase();
|
||||
const tier = profile === 'quality' ? 'opus'
|
||||
: (profile === 'budget' || profile === 'speed') ? 'haiku'
|
||||
: (profile === 'balanced' || profile === 'adaptive') ? 'sonnet'
|
||||
: null;
|
||||
if (!tier) return config.model_profile;
|
||||
return resolveRuntimeTierDefault('claude', tier)?.model;
|
||||
}
|
||||
|
||||
return undefined; // Let SDK use its default
|
||||
|
||||
Reference in New Issue
Block a user