* 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:
@@ -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)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user