gsdd-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +528 -0
  3. package/agents/DISTILLATION.md +306 -0
  4. package/agents/README.md +53 -0
  5. package/agents/debugger.md +82 -0
  6. package/agents/executor.md +394 -0
  7. package/agents/integration-checker.md +318 -0
  8. package/agents/mapper.md +103 -0
  9. package/agents/planner.md +296 -0
  10. package/agents/researcher.md +84 -0
  11. package/agents/roadmapper.md +296 -0
  12. package/agents/synthesizer.md +236 -0
  13. package/agents/verifier.md +337 -0
  14. package/bin/adapters/agents.mjs +33 -0
  15. package/bin/adapters/claude.mjs +145 -0
  16. package/bin/adapters/codex.mjs +58 -0
  17. package/bin/adapters/index.mjs +20 -0
  18. package/bin/adapters/opencode.mjs +237 -0
  19. package/bin/gsdd.mjs +102 -0
  20. package/bin/lib/cli-utils.mjs +28 -0
  21. package/bin/lib/health.mjs +248 -0
  22. package/bin/lib/init.mjs +379 -0
  23. package/bin/lib/manifest.mjs +134 -0
  24. package/bin/lib/models.mjs +379 -0
  25. package/bin/lib/phase.mjs +237 -0
  26. package/bin/lib/rendering.mjs +95 -0
  27. package/bin/lib/templates.mjs +207 -0
  28. package/distilled/DESIGN.md +1286 -0
  29. package/distilled/README.md +169 -0
  30. package/distilled/SKILL.md +85 -0
  31. package/distilled/templates/agents.block.md +90 -0
  32. package/distilled/templates/agents.md +13 -0
  33. package/distilled/templates/auth-matrix.md +78 -0
  34. package/distilled/templates/codebase/architecture.md +110 -0
  35. package/distilled/templates/codebase/concerns.md +95 -0
  36. package/distilled/templates/codebase/conventions.md +193 -0
  37. package/distilled/templates/codebase/stack.md +96 -0
  38. package/distilled/templates/delegates/mapper-arch.md +26 -0
  39. package/distilled/templates/delegates/mapper-concerns.md +27 -0
  40. package/distilled/templates/delegates/mapper-quality.md +28 -0
  41. package/distilled/templates/delegates/mapper-tech.md +25 -0
  42. package/distilled/templates/delegates/plan-checker.md +55 -0
  43. package/distilled/templates/delegates/researcher-architecture.md +30 -0
  44. package/distilled/templates/delegates/researcher-features.md +30 -0
  45. package/distilled/templates/delegates/researcher-pitfalls.md +30 -0
  46. package/distilled/templates/delegates/researcher-stack.md +30 -0
  47. package/distilled/templates/delegates/researcher-synthesizer.md +31 -0
  48. package/distilled/templates/research/architecture.md +57 -0
  49. package/distilled/templates/research/features.md +23 -0
  50. package/distilled/templates/research/pitfalls.md +46 -0
  51. package/distilled/templates/research/stack.md +45 -0
  52. package/distilled/templates/research/summary.md +67 -0
  53. package/distilled/templates/roadmap.md +62 -0
  54. package/distilled/templates/spec.md +110 -0
  55. package/distilled/workflows/audit-milestone.md +220 -0
  56. package/distilled/workflows/execute.md +270 -0
  57. package/distilled/workflows/map-codebase.md +246 -0
  58. package/distilled/workflows/new-project.md +418 -0
  59. package/distilled/workflows/pause.md +121 -0
  60. package/distilled/workflows/plan.md +383 -0
  61. package/distilled/workflows/progress.md +199 -0
  62. package/distilled/workflows/quick.md +187 -0
  63. package/distilled/workflows/resume.md +152 -0
  64. package/distilled/workflows/verify.md +307 -0
  65. package/package.json +45 -0
@@ -0,0 +1,134 @@
1
+ // manifest.mjs — Generation manifest for template versioning
2
+
3
+ import { createHash } from 'crypto';
4
+ import { existsSync, readFileSync, writeFileSync, readdirSync, statSync } from 'fs';
5
+ import { join, relative } from 'path';
6
+
7
+ const MANIFEST_FILENAME = 'generation-manifest.json';
8
+
9
+ /**
10
+ * SHA-256 hex digest of file contents.
11
+ */
12
+ export function fileHash(filePath) {
13
+ const content = readFileSync(filePath);
14
+ return createHash('sha256').update(content).digest('hex');
15
+ }
16
+
17
+ /**
18
+ * Recursive { relativePath: sha256 } map for a directory.
19
+ * Normalizes backslashes to forward slashes for cross-platform consistency.
20
+ */
21
+ export function hashDirectory(dir, baseDir = dir) {
22
+ const result = {};
23
+ if (!existsSync(dir)) return result;
24
+
25
+ for (const entry of readdirSync(dir)) {
26
+ const fullPath = join(dir, entry);
27
+ const stat = statSync(fullPath);
28
+ if (stat.isDirectory()) {
29
+ Object.assign(result, hashDirectory(fullPath, baseDir));
30
+ } else {
31
+ const rel = relative(baseDir, fullPath).replace(/\\/g, '/');
32
+ result[rel] = fileHash(fullPath);
33
+ }
34
+ }
35
+
36
+ return result;
37
+ }
38
+
39
+ /**
40
+ * Build a full manifest snapshot from installed project files.
41
+ */
42
+ export function buildManifest({ planningDir, frameworkVersion }) {
43
+ const templatesDir = join(planningDir, 'templates');
44
+ const rolesDir = join(templatesDir, 'roles');
45
+
46
+ // Template subcategories
47
+ const delegatesHashes = hashDirectory(join(templatesDir, 'delegates'), join(templatesDir, 'delegates'));
48
+ const researchHashes = hashDirectory(join(templatesDir, 'research'), join(templatesDir, 'research'));
49
+ const codebaseHashes = hashDirectory(join(templatesDir, 'codebase'), join(templatesDir, 'codebase'));
50
+
51
+ // Root-level template .md files (agents.block.md, spec.md, roadmap.md, etc.)
52
+ const rootHashes = {};
53
+ if (existsSync(templatesDir)) {
54
+ for (const entry of readdirSync(templatesDir)) {
55
+ const fullPath = join(templatesDir, entry);
56
+ if (statSync(fullPath).isFile() && entry.endsWith('.md')) {
57
+ rootHashes[entry] = fileHash(fullPath);
58
+ }
59
+ }
60
+ }
61
+
62
+ // Role contracts
63
+ const rolesHashes = {};
64
+ if (existsSync(rolesDir)) {
65
+ for (const entry of readdirSync(rolesDir)) {
66
+ if (entry.endsWith('.md')) {
67
+ rolesHashes[entry] = fileHash(join(rolesDir, entry));
68
+ }
69
+ }
70
+ }
71
+
72
+ return {
73
+ frameworkVersion,
74
+ generatedAt: new Date().toISOString(),
75
+ templates: {
76
+ delegates: delegatesHashes,
77
+ research: researchHashes,
78
+ codebase: codebaseHashes,
79
+ root: rootHashes,
80
+ },
81
+ roles: rolesHashes,
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Read existing manifest from planningDir, or return null if missing/corrupt.
87
+ */
88
+ export function readManifest(planningDir) {
89
+ const manifestPath = join(planningDir, MANIFEST_FILENAME);
90
+ if (!existsSync(manifestPath)) return null;
91
+
92
+ try {
93
+ return JSON.parse(readFileSync(manifestPath, 'utf-8'));
94
+ } catch {
95
+ return null;
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Write generation-manifest.json to planningDir.
101
+ */
102
+ export function writeManifest(planningDir, manifest) {
103
+ const manifestPath = join(planningDir, MANIFEST_FILENAME);
104
+ writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
105
+ }
106
+
107
+ /**
108
+ * Compare installed files vs manifest hashes.
109
+ * Returns { modified: string[], unchanged: string[], missing: string[] }
110
+ * where each string is a relative filename.
111
+ */
112
+ export function detectModifications(installedDir, manifestHashes) {
113
+ const modified = [];
114
+ const unchanged = [];
115
+ const missing = [];
116
+
117
+ if (!manifestHashes) return { modified, unchanged, missing };
118
+
119
+ for (const [file, expectedHash] of Object.entries(manifestHashes)) {
120
+ const fullPath = join(installedDir, file);
121
+ if (!existsSync(fullPath)) {
122
+ missing.push(file);
123
+ continue;
124
+ }
125
+ const currentHash = fileHash(fullPath);
126
+ if (currentHash === expectedHash) {
127
+ unchanged.push(file);
128
+ } else {
129
+ modified.push(file);
130
+ }
131
+ }
132
+
133
+ return { modified, unchanged, missing };
134
+ }
@@ -0,0 +1,379 @@
1
+ // models.mjs — Model profile management, config CRUD, and validation constants
2
+ //
3
+ // IMPORTANT: No module-scope process.cwd() — ESM caching means sub-modules
4
+ // evaluate once, so CWD must be computed inside function bodies.
5
+
6
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
7
+ import { join } from 'path';
8
+ import { CLAUDE_MODEL_PROFILES } from '../adapters/claude.mjs';
9
+ import { detectOpenCodeConfiguredModel } from '../adapters/opencode.mjs';
10
+ import { parseFlagValue, output } from './cli-utils.mjs';
11
+
12
+ export const DEFAULT_GIT_PROTOCOL = {
13
+ branch: 'Follow the existing repo or team branching convention. Use a feature branch for significant changes when no convention exists.',
14
+ commit: 'Group changes logically and follow the existing repo conventions. Do not mention phase, plan, or task IDs unless explicitly requested.',
15
+ pr: 'Follow the existing repo or team review workflow. Do not assume PR creation, timing, or naming unless explicitly requested.',
16
+ };
17
+
18
+ export const VALID_MODEL_PROFILES = ['quality', 'balanced', 'budget'];
19
+ export const PORTABLE_AGENT_IDS = ['plan-checker'];
20
+ export const MODEL_RUNTIME_IDS = ['claude', 'opencode', 'codex'];
21
+ export const MODEL_ID_PATTERN = /^[a-zA-Z0-9._\/:@-]+$/;
22
+
23
+ export function normalizeModelProfile(value) {
24
+ return VALID_MODEL_PROFILES.includes(value) ? value : 'balanced';
25
+ }
26
+
27
+ export function buildDefaultConfig({ autoAdvance = false } = {}) {
28
+ const config = {
29
+ researchDepth: 'balanced',
30
+ parallelization: true,
31
+ commitDocs: true,
32
+ modelProfile: 'balanced',
33
+ workflow: { research: true, planCheck: true, verifier: true },
34
+ gitProtocol: { ...DEFAULT_GIT_PROTOCOL },
35
+ initVersion: 'v1.1',
36
+ };
37
+ if (autoAdvance) config.autoAdvance = true;
38
+ return config;
39
+ }
40
+
41
+ export function isProjectInitialized(cwd = process.cwd()) {
42
+ return existsSync(join(cwd, '.planning', 'config.json'));
43
+ }
44
+
45
+ export function loadProjectModelConfig(cwd = process.cwd()) {
46
+ const configPath = join(cwd, '.planning', 'config.json');
47
+ if (!existsSync(configPath)) return buildDefaultConfig();
48
+
49
+ try {
50
+ return {
51
+ ...buildDefaultConfig(),
52
+ ...JSON.parse(readFileSync(configPath, 'utf-8')),
53
+ };
54
+ } catch (e) {
55
+ console.error(`WARNING: .planning/config.json is malformed (${e.message}). Using defaults.`);
56
+ return buildDefaultConfig();
57
+ }
58
+ }
59
+
60
+ function loadConfigForMutation(cwd = process.cwd()) {
61
+ const configPath = join(cwd, '.planning', 'config.json');
62
+ let raw;
63
+ try {
64
+ raw = readFileSync(configPath, 'utf-8');
65
+ } catch (e) {
66
+ return { ok: false, error: `could not read config file (${e.message})` };
67
+ }
68
+ try {
69
+ return { ok: true, config: { ...buildDefaultConfig(), ...JSON.parse(raw) } };
70
+ } catch (e) {
71
+ return { ok: false, error: `malformed JSON (${e.message})` };
72
+ }
73
+ }
74
+
75
+ export function ensureProjectConfig(cwd = process.cwd()) {
76
+ mkdirSync(join(cwd, '.planning'), { recursive: true });
77
+ const config = loadProjectModelConfig(cwd);
78
+ writeProjectConfig(config, cwd);
79
+ return config;
80
+ }
81
+
82
+ export function writeProjectConfig(config, cwd = process.cwd()) {
83
+ const configPath = join(cwd, '.planning', 'config.json');
84
+ writeFileSync(configPath, JSON.stringify(config, null, 2));
85
+ }
86
+
87
+ export function getPortableAgentProfile(config, agentId) {
88
+ const override = config.agentModelProfiles?.[agentId];
89
+ if (VALID_MODEL_PROFILES.includes(override)) return override;
90
+ return normalizeModelProfile(config.modelProfile);
91
+ }
92
+
93
+ export function getRuntimeModelOverride(config, runtime, agentId) {
94
+ const override = config.runtimeModelOverrides?.[runtime]?.[agentId];
95
+ return typeof override === 'string' && override.trim() ? override.trim() : null;
96
+ }
97
+
98
+ export function resolveRuntimeAgentModel({ cwd = process.cwd(), runtime, agentId, profileMap = null }) {
99
+ const config = loadProjectModelConfig(cwd);
100
+ const runtimeOverride = getRuntimeModelOverride(config, runtime, agentId);
101
+ if (runtimeOverride) return runtimeOverride;
102
+
103
+ if (!profileMap) return null;
104
+ const profile = getPortableAgentProfile(config, agentId);
105
+ return profileMap[profile] ?? profileMap.balanced ?? null;
106
+ }
107
+
108
+ export function getRuntimeAgentModelState({ config, runtime, agentId, profileMap = null }) {
109
+ const runtimeOverride = getRuntimeModelOverride(config, runtime, agentId);
110
+ if (runtimeOverride) {
111
+ return {
112
+ mode: 'override',
113
+ model: runtimeOverride,
114
+ source: 'runtimeOverride',
115
+ };
116
+ }
117
+
118
+ if (!profileMap) {
119
+ return {
120
+ mode: 'inherit',
121
+ model: null,
122
+ runtimeDetectedModel: null,
123
+ };
124
+ }
125
+
126
+ const agentOverride = config.agentModelProfiles?.[agentId];
127
+ const profile = getPortableAgentProfile(config, agentId);
128
+ return {
129
+ mode: 'mapped',
130
+ model: profileMap[profile] ?? profileMap.balanced ?? null,
131
+ source: VALID_MODEL_PROFILES.includes(agentOverride) ? 'agentModelProfile' : 'modelProfile',
132
+ };
133
+ }
134
+
135
+ export function cmdModels(...modelArgs) {
136
+ const subcommand = modelArgs[0] || 'show';
137
+
138
+ switch (subcommand) {
139
+ case 'show':
140
+ return cmdModelsShow();
141
+ case 'profile':
142
+ return cmdModelsProfile(modelArgs[1]);
143
+ case 'agent-profile':
144
+ return cmdModelsAgentProfile(modelArgs.slice(1));
145
+ case 'clear-agent-profile':
146
+ return cmdModelsClearAgentProfile(modelArgs.slice(1));
147
+ case 'set':
148
+ return cmdModelsSetRuntimeOverride(modelArgs.slice(1));
149
+ case 'clear':
150
+ return cmdModelsClearRuntimeOverride(modelArgs.slice(1));
151
+ default:
152
+ console.error('Usage: gsdd models [show|profile|agent-profile|clear-agent-profile|set|clear]');
153
+ process.exitCode = 1;
154
+ }
155
+ }
156
+
157
+ function cmdModelsShow() {
158
+ const cwd = process.cwd();
159
+ const config = loadProjectModelConfig(cwd);
160
+ const ocOverride = getRuntimeModelOverride(config, 'opencode', 'plan-checker');
161
+ const ocDetected = detectOpenCodeConfiguredModel(cwd);
162
+ const codexOverride = getRuntimeModelOverride(config, 'codex', 'plan-checker');
163
+ output({
164
+ modelProfile: normalizeModelProfile(config.modelProfile),
165
+ agentModelProfiles: config.agentModelProfiles || {},
166
+ runtimeModelOverrides: config.runtimeModelOverrides || {},
167
+ effective: {
168
+ claude: {
169
+ 'plan-checker': getRuntimeAgentModelState({
170
+ config,
171
+ runtime: 'claude',
172
+ agentId: 'plan-checker',
173
+ profileMap: CLAUDE_MODEL_PROFILES,
174
+ }),
175
+ },
176
+ opencode: {
177
+ 'plan-checker': {
178
+ mode: ocOverride ? 'override' : 'inherit',
179
+ model: ocOverride,
180
+ runtimeDetectedModel: ocDetected,
181
+ },
182
+ },
183
+ codex: {
184
+ 'plan-checker': {
185
+ mode: codexOverride ? 'override' : 'inherit',
186
+ model: codexOverride,
187
+ },
188
+ },
189
+ },
190
+ detectedRuntimeModels: {
191
+ opencode: ocDetected,
192
+ },
193
+ hints: !ocOverride ? {
194
+ opencode: 'OpenCode currently inherits its runtime model unless you set an explicit override. Use gsdd models set --runtime opencode --agent plan-checker --model <provider/model-id> to inject an explicit checker model.',
195
+ } : undefined,
196
+ });
197
+ }
198
+
199
+ function cmdModelsProfile(profile) {
200
+ if (!VALID_MODEL_PROFILES.includes(profile)) {
201
+ console.error(`ERROR: Invalid profile "${profile}". Valid profiles: ${VALID_MODEL_PROFILES.join(', ')}`);
202
+ process.exitCode = 1;
203
+ return;
204
+ }
205
+
206
+ if (!isProjectInitialized()) {
207
+ console.error('ERROR: Project not initialized. Run gsdd init first.');
208
+ process.exitCode = 1;
209
+ return;
210
+ }
211
+
212
+ const result = loadConfigForMutation();
213
+ if (!result.ok) {
214
+ console.error(`ERROR: .planning/config.json is malformed (${result.error}). Fix the file manually before running model mutations.`);
215
+ process.exitCode = 1;
216
+ return;
217
+ }
218
+
219
+ result.config.modelProfile = profile;
220
+ writeProjectConfig(result.config);
221
+ console.log(` - set modelProfile to ${profile}`);
222
+ console.log(' Run gsdd update to regenerate adapter files.');
223
+ }
224
+
225
+ function cmdModelsAgentProfile(args) {
226
+ const agent = parseFlagValue(args, '--agent').value;
227
+ const profile = parseFlagValue(args, '--profile').value;
228
+
229
+ if (!PORTABLE_AGENT_IDS.includes(agent)) {
230
+ console.error(`ERROR: Invalid agent "${agent}". Valid agents: ${PORTABLE_AGENT_IDS.join(', ')}`);
231
+ process.exitCode = 1;
232
+ return;
233
+ }
234
+ if (!VALID_MODEL_PROFILES.includes(profile)) {
235
+ console.error(`ERROR: Invalid profile "${profile}". Valid profiles: ${VALID_MODEL_PROFILES.join(', ')}`);
236
+ process.exitCode = 1;
237
+ return;
238
+ }
239
+
240
+ if (!isProjectInitialized()) {
241
+ console.error('ERROR: Project not initialized. Run gsdd init first.');
242
+ process.exitCode = 1;
243
+ return;
244
+ }
245
+
246
+ const result = loadConfigForMutation();
247
+ if (!result.ok) {
248
+ console.error(`ERROR: .planning/config.json is malformed (${result.error}). Fix the file manually before running model mutations.`);
249
+ process.exitCode = 1;
250
+ return;
251
+ }
252
+
253
+ result.config.agentModelProfiles = result.config.agentModelProfiles || {};
254
+ result.config.agentModelProfiles[agent] = profile;
255
+ writeProjectConfig(result.config);
256
+ console.log(` - set ${agent} semantic profile to ${profile}`);
257
+ console.log(' Run gsdd update to regenerate adapter files.');
258
+ }
259
+
260
+ function cmdModelsClearAgentProfile(args) {
261
+ const agent = parseFlagValue(args, '--agent').value;
262
+ if (!PORTABLE_AGENT_IDS.includes(agent)) {
263
+ console.error(`ERROR: Invalid agent "${agent}". Valid agents: ${PORTABLE_AGENT_IDS.join(', ')}`);
264
+ process.exitCode = 1;
265
+ return;
266
+ }
267
+
268
+ if (!isProjectInitialized()) {
269
+ console.error('ERROR: Project not initialized. Run gsdd init first.');
270
+ process.exitCode = 1;
271
+ return;
272
+ }
273
+
274
+ const result = loadConfigForMutation();
275
+ if (!result.ok) {
276
+ console.error(`ERROR: .planning/config.json is malformed (${result.error}). Fix the file manually before running model mutations.`);
277
+ process.exitCode = 1;
278
+ return;
279
+ }
280
+
281
+ if (result.config.agentModelProfiles) {
282
+ delete result.config.agentModelProfiles[agent];
283
+ if (Object.keys(result.config.agentModelProfiles).length === 0) {
284
+ delete result.config.agentModelProfiles;
285
+ }
286
+ }
287
+ writeProjectConfig(result.config);
288
+ console.log(` - cleared semantic profile override for ${agent}`);
289
+ console.log(' Run gsdd update to regenerate adapter files.');
290
+ }
291
+
292
+ function cmdModelsSetRuntimeOverride(args) {
293
+ const runtime = parseFlagValue(args, '--runtime').value;
294
+ const agent = parseFlagValue(args, '--agent').value;
295
+ const model = parseFlagValue(args, '--model').value;
296
+
297
+ if (!MODEL_RUNTIME_IDS.includes(runtime)) {
298
+ console.error(`ERROR: Invalid runtime "${runtime}". Valid runtimes: ${MODEL_RUNTIME_IDS.join(', ')}`);
299
+ process.exitCode = 1;
300
+ return;
301
+ }
302
+ if (!PORTABLE_AGENT_IDS.includes(agent)) {
303
+ console.error(`ERROR: Invalid agent "${agent}". Valid agents: ${PORTABLE_AGENT_IDS.join(', ')}`);
304
+ process.exitCode = 1;
305
+ return;
306
+ }
307
+ if (!model) {
308
+ console.error('ERROR: --model requires a value.');
309
+ process.exitCode = 1;
310
+ return;
311
+ }
312
+ if (!MODEL_ID_PATTERN.test(model.trim())) {
313
+ console.error('ERROR: Model ID contains invalid characters. Only alphanumeric, dots, hyphens, underscores, forward slashes, colons, and @ are allowed.');
314
+ process.exitCode = 1;
315
+ return;
316
+ }
317
+
318
+ if (!isProjectInitialized()) {
319
+ console.error('ERROR: Project not initialized. Run gsdd init first.');
320
+ process.exitCode = 1;
321
+ return;
322
+ }
323
+
324
+ const result = loadConfigForMutation();
325
+ if (!result.ok) {
326
+ console.error(`ERROR: .planning/config.json is malformed (${result.error}). Fix the file manually before running model mutations.`);
327
+ process.exitCode = 1;
328
+ return;
329
+ }
330
+
331
+ result.config.runtimeModelOverrides = result.config.runtimeModelOverrides || {};
332
+ result.config.runtimeModelOverrides[runtime] = result.config.runtimeModelOverrides[runtime] || {};
333
+ result.config.runtimeModelOverrides[runtime][agent] = model.trim();
334
+ writeProjectConfig(result.config);
335
+ console.log(` - set ${runtime} runtime override for ${agent}`);
336
+ console.log(' Run gsdd update to regenerate adapter files.');
337
+ }
338
+
339
+ function cmdModelsClearRuntimeOverride(args) {
340
+ const runtime = parseFlagValue(args, '--runtime').value;
341
+ const agent = parseFlagValue(args, '--agent').value;
342
+
343
+ if (!MODEL_RUNTIME_IDS.includes(runtime)) {
344
+ console.error(`ERROR: Invalid runtime "${runtime}". Valid runtimes: ${MODEL_RUNTIME_IDS.join(', ')}`);
345
+ process.exitCode = 1;
346
+ return;
347
+ }
348
+ if (!PORTABLE_AGENT_IDS.includes(agent)) {
349
+ console.error(`ERROR: Invalid agent "${agent}". Valid agents: ${PORTABLE_AGENT_IDS.join(', ')}`);
350
+ process.exitCode = 1;
351
+ return;
352
+ }
353
+
354
+ if (!isProjectInitialized()) {
355
+ console.error('ERROR: Project not initialized. Run gsdd init first.');
356
+ process.exitCode = 1;
357
+ return;
358
+ }
359
+
360
+ const result = loadConfigForMutation();
361
+ if (!result.ok) {
362
+ console.error(`ERROR: .planning/config.json is malformed (${result.error}). Fix the file manually before running model mutations.`);
363
+ process.exitCode = 1;
364
+ return;
365
+ }
366
+
367
+ if (result.config.runtimeModelOverrides?.[runtime]) {
368
+ delete result.config.runtimeModelOverrides[runtime][agent];
369
+ if (Object.keys(result.config.runtimeModelOverrides[runtime]).length === 0) {
370
+ delete result.config.runtimeModelOverrides[runtime];
371
+ }
372
+ if (Object.keys(result.config.runtimeModelOverrides).length === 0) {
373
+ delete result.config.runtimeModelOverrides;
374
+ }
375
+ }
376
+ writeProjectConfig(result.config);
377
+ console.log(` - cleared ${runtime} runtime override for ${agent}`);
378
+ console.log(' Run gsdd update to regenerate adapter files.');
379
+ }