gsd-opencode 1.22.1 → 1.30.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 (156) hide show
  1. package/agents/gsd-advisor-researcher.md +112 -0
  2. package/agents/gsd-assumptions-analyzer.md +110 -0
  3. package/agents/gsd-codebase-mapper.md +0 -2
  4. package/agents/gsd-debugger.md +118 -2
  5. package/agents/gsd-executor.md +24 -4
  6. package/agents/gsd-integration-checker.md +0 -2
  7. package/agents/gsd-nyquist-auditor.md +0 -2
  8. package/agents/gsd-phase-researcher.md +150 -5
  9. package/agents/gsd-plan-checker.md +70 -5
  10. package/agents/gsd-planner.md +49 -4
  11. package/agents/gsd-project-researcher.md +28 -3
  12. package/agents/gsd-research-synthesizer.md +0 -2
  13. package/agents/gsd-roadmapper.md +29 -2
  14. package/agents/gsd-ui-auditor.md +445 -0
  15. package/agents/gsd-ui-checker.md +305 -0
  16. package/agents/gsd-ui-researcher.md +368 -0
  17. package/agents/gsd-user-profiler.md +173 -0
  18. package/agents/gsd-verifier.md +123 -4
  19. package/commands/gsd/gsd-add-backlog.md +76 -0
  20. package/commands/gsd/gsd-audit-uat.md +24 -0
  21. package/commands/gsd/gsd-autonomous.md +41 -0
  22. package/commands/gsd/gsd-debug.md +5 -0
  23. package/commands/gsd/gsd-discuss-phase.md +10 -36
  24. package/commands/gsd/gsd-do.md +30 -0
  25. package/commands/gsd/gsd-execute-phase.md +20 -2
  26. package/commands/gsd/gsd-fast.md +30 -0
  27. package/commands/gsd/gsd-forensics.md +56 -0
  28. package/commands/gsd/gsd-list-workspaces.md +19 -0
  29. package/commands/gsd/gsd-manager.md +39 -0
  30. package/commands/gsd/gsd-milestone-summary.md +51 -0
  31. package/commands/gsd/gsd-new-workspace.md +44 -0
  32. package/commands/gsd/gsd-next.md +24 -0
  33. package/commands/gsd/gsd-note.md +34 -0
  34. package/commands/gsd/gsd-plan-phase.md +3 -1
  35. package/commands/gsd/gsd-plant-seed.md +28 -0
  36. package/commands/gsd/gsd-pr-branch.md +25 -0
  37. package/commands/gsd/gsd-profile-user.md +46 -0
  38. package/commands/gsd/gsd-quick.md +4 -2
  39. package/commands/gsd/gsd-reapply-patches.md +9 -8
  40. package/commands/gsd/gsd-remove-workspace.md +26 -0
  41. package/commands/gsd/gsd-research-phase.md +5 -0
  42. package/commands/gsd/gsd-review-backlog.md +61 -0
  43. package/commands/gsd/gsd-review.md +37 -0
  44. package/commands/gsd/gsd-session-report.md +19 -0
  45. package/commands/gsd/gsd-set-profile.md +24 -23
  46. package/commands/gsd/gsd-ship.md +23 -0
  47. package/commands/gsd/gsd-stats.md +18 -0
  48. package/commands/gsd/gsd-thread.md +127 -0
  49. package/commands/gsd/gsd-ui-phase.md +34 -0
  50. package/commands/gsd/gsd-ui-review.md +32 -0
  51. package/commands/gsd/gsd-workstreams.md +66 -0
  52. package/get-shit-done/bin/gsd-tools.cjs +410 -84
  53. package/get-shit-done/bin/lib/commands.cjs +429 -18
  54. package/get-shit-done/bin/lib/config.cjs +318 -45
  55. package/get-shit-done/bin/lib/core.cjs +822 -84
  56. package/get-shit-done/bin/lib/frontmatter.cjs +78 -41
  57. package/get-shit-done/bin/lib/init.cjs +836 -104
  58. package/get-shit-done/bin/lib/milestone.cjs +44 -33
  59. package/get-shit-done/bin/lib/model-profiles.cjs +68 -0
  60. package/get-shit-done/bin/lib/phase.cjs +293 -306
  61. package/get-shit-done/bin/lib/profile-output.cjs +952 -0
  62. package/get-shit-done/bin/lib/profile-pipeline.cjs +539 -0
  63. package/get-shit-done/bin/lib/roadmap.cjs +55 -24
  64. package/get-shit-done/bin/lib/security.cjs +382 -0
  65. package/get-shit-done/bin/lib/state.cjs +363 -53
  66. package/get-shit-done/bin/lib/template.cjs +2 -2
  67. package/get-shit-done/bin/lib/uat.cjs +282 -0
  68. package/get-shit-done/bin/lib/verify.cjs +104 -36
  69. package/get-shit-done/bin/lib/workstream.cjs +491 -0
  70. package/get-shit-done/references/checkpoints.md +12 -10
  71. package/get-shit-done/references/decimal-phase-calculation.md +2 -3
  72. package/get-shit-done/references/git-integration.md +47 -0
  73. package/get-shit-done/references/model-profile-resolution.md +2 -0
  74. package/get-shit-done/references/model-profiles.md +62 -16
  75. package/get-shit-done/references/phase-argument-parsing.md +2 -2
  76. package/get-shit-done/references/planning-config.md +3 -1
  77. package/get-shit-done/references/user-profiling.md +681 -0
  78. package/get-shit-done/references/workstream-flag.md +58 -0
  79. package/get-shit-done/templates/UAT.md +21 -3
  80. package/get-shit-done/templates/UI-SPEC.md +100 -0
  81. package/get-shit-done/templates/claude-md.md +122 -0
  82. package/get-shit-done/templates/config.json +10 -3
  83. package/get-shit-done/templates/context.md +61 -6
  84. package/get-shit-done/templates/dev-preferences.md +21 -0
  85. package/get-shit-done/templates/discussion-log.md +63 -0
  86. package/get-shit-done/templates/phase-prompt.md +46 -5
  87. package/get-shit-done/templates/project.md +2 -0
  88. package/get-shit-done/templates/state.md +2 -2
  89. package/get-shit-done/templates/user-profile.md +146 -0
  90. package/get-shit-done/workflows/add-phase.md +2 -2
  91. package/get-shit-done/workflows/add-tests.md +4 -4
  92. package/get-shit-done/workflows/add-todo.md +3 -3
  93. package/get-shit-done/workflows/audit-milestone.md +13 -5
  94. package/get-shit-done/workflows/audit-uat.md +109 -0
  95. package/get-shit-done/workflows/autonomous.md +891 -0
  96. package/get-shit-done/workflows/check-todos.md +2 -2
  97. package/get-shit-done/workflows/cleanup.md +4 -4
  98. package/get-shit-done/workflows/complete-milestone.md +9 -6
  99. package/get-shit-done/workflows/diagnose-issues.md +15 -3
  100. package/get-shit-done/workflows/discovery-phase.md +3 -3
  101. package/get-shit-done/workflows/discuss-phase-assumptions.md +653 -0
  102. package/get-shit-done/workflows/discuss-phase.md +411 -38
  103. package/get-shit-done/workflows/do.md +104 -0
  104. package/get-shit-done/workflows/execute-phase.md +405 -18
  105. package/get-shit-done/workflows/execute-plan.md +77 -12
  106. package/get-shit-done/workflows/fast.md +105 -0
  107. package/get-shit-done/workflows/forensics.md +265 -0
  108. package/get-shit-done/workflows/health.md +28 -6
  109. package/get-shit-done/workflows/help.md +124 -7
  110. package/get-shit-done/workflows/insert-phase.md +2 -2
  111. package/get-shit-done/workflows/list-phase-assumptions.md +2 -2
  112. package/get-shit-done/workflows/list-workspaces.md +56 -0
  113. package/get-shit-done/workflows/manager.md +362 -0
  114. package/get-shit-done/workflows/map-codebase.md +74 -13
  115. package/get-shit-done/workflows/milestone-summary.md +223 -0
  116. package/get-shit-done/workflows/new-milestone.md +120 -18
  117. package/get-shit-done/workflows/new-project.md +178 -39
  118. package/get-shit-done/workflows/new-workspace.md +237 -0
  119. package/get-shit-done/workflows/next.md +97 -0
  120. package/get-shit-done/workflows/node-repair.md +92 -0
  121. package/get-shit-done/workflows/note.md +156 -0
  122. package/get-shit-done/workflows/pause-work.md +62 -8
  123. package/get-shit-done/workflows/plan-milestone-gaps.md +4 -5
  124. package/get-shit-done/workflows/plan-phase.md +332 -33
  125. package/get-shit-done/workflows/plant-seed.md +169 -0
  126. package/get-shit-done/workflows/pr-branch.md +129 -0
  127. package/get-shit-done/workflows/profile-user.md +450 -0
  128. package/get-shit-done/workflows/progress.md +145 -20
  129. package/get-shit-done/workflows/quick.md +205 -49
  130. package/get-shit-done/workflows/remove-phase.md +2 -2
  131. package/get-shit-done/workflows/remove-workspace.md +90 -0
  132. package/get-shit-done/workflows/research-phase.md +11 -3
  133. package/get-shit-done/workflows/resume-project.md +35 -16
  134. package/get-shit-done/workflows/review.md +228 -0
  135. package/get-shit-done/workflows/session-report.md +146 -0
  136. package/get-shit-done/workflows/set-profile.md +2 -2
  137. package/get-shit-done/workflows/settings.md +79 -10
  138. package/get-shit-done/workflows/ship.md +228 -0
  139. package/get-shit-done/workflows/stats.md +60 -0
  140. package/get-shit-done/workflows/transition.md +147 -20
  141. package/get-shit-done/workflows/ui-phase.md +302 -0
  142. package/get-shit-done/workflows/ui-review.md +165 -0
  143. package/get-shit-done/workflows/update.md +108 -25
  144. package/get-shit-done/workflows/validate-phase.md +15 -8
  145. package/get-shit-done/workflows/verify-phase.md +16 -5
  146. package/get-shit-done/workflows/verify-work.md +72 -18
  147. package/package.json +1 -1
  148. package/skills/gsd-audit-milestone/SKILL.md +29 -0
  149. package/skills/gsd-cleanup/SKILL.md +19 -0
  150. package/skills/gsd-complete-milestone/SKILL.md +131 -0
  151. package/skills/gsd-discuss-phase/SKILL.md +54 -0
  152. package/skills/gsd-execute-phase/SKILL.md +49 -0
  153. package/skills/gsd-plan-phase/SKILL.md +37 -0
  154. package/skills/gsd-ui-phase/SKILL.md +24 -0
  155. package/skills/gsd-ui-review/SKILL.md +24 -0
  156. package/skills/gsd-verify-work/SKILL.md +30 -0
@@ -4,32 +4,81 @@
4
4
 
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
- const { output, error } = require('./core.cjs');
7
+ const { output, error, planningRoot } = require('./core.cjs');
8
+ const {
9
+ VALID_PROFILES,
10
+ getAgentToModelMapForProfile,
11
+ formatAgentToModelMapAsTable,
12
+ } = require('./model-profiles.cjs');
8
13
 
9
- function cmdConfigEnsureSection(cwd, raw) {
10
- const configPath = path.join(cwd, '.planning', 'config.json');
11
- const planningDir = path.join(cwd, '.planning');
14
+ const VALID_CONFIG_KEYS = new Set([
15
+ 'mode', 'granularity', 'parallelization', 'commit_docs', 'model_profile',
16
+ 'search_gitignored', 'brave_search', 'firecrawl', 'exa_search',
17
+ 'workflow.research', 'workflow.plan_check', 'workflow.verifier',
18
+ 'workflow.nyquist_validation', 'workflow.ui_phase', 'workflow.ui_safety_gate',
19
+ 'workflow.auto_advance', 'workflow.node_repair', 'workflow.node_repair_budget',
20
+ 'workflow.text_mode',
21
+ 'workflow.research_before_questions',
22
+ 'workflow.discuss_mode',
23
+ 'workflow.skip_discuss',
24
+ 'workflow._auto_chain_active',
25
+ 'git.branching_strategy', 'git.phase_branch_template', 'git.milestone_branch_template', 'git.quick_branch_template',
26
+ 'planning.commit_docs', 'planning.search_gitignored',
27
+ 'hooks.context_warnings',
28
+ ]);
12
29
 
13
- // Ensure .planning directory exists
14
- try {
15
- if (!fs.existsSync(planningDir)) {
16
- fs.mkdirSync(planningDir, { recursive: true });
17
- }
18
- } catch (err) {
19
- error('Failed to create .planning directory: ' + err.message);
20
- }
30
+ /**
31
+ * Check whether a config key path is valid.
32
+ * Supports exact matches from VALID_CONFIG_KEYS plus dynamic patterns
33
+ * like `agent_skills.<agent-type>` where the sub-key is freeform.
34
+ */
35
+ function isValidConfigKey(keyPath) {
36
+ if (VALID_CONFIG_KEYS.has(keyPath)) return true;
37
+ // Allow agent_skills.<agent-type> with any agent type string
38
+ if (/^agent_skills\.[a-zA-Z0-9_-]+$/.test(keyPath)) return true;
39
+ return false;
40
+ }
21
41
 
22
- // Check if config already exists
23
- if (fs.existsSync(configPath)) {
24
- const result = { created: false, reason: 'already_exists' };
25
- output(result, raw, 'exists');
26
- return;
42
+ const CONFIG_KEY_SUGGESTIONS = {
43
+ 'workflow.nyquist_validation_enabled': 'workflow.nyquist_validation',
44
+ 'agents.nyquist_validation_enabled': 'workflow.nyquist_validation',
45
+ 'nyquist.validation_enabled': 'workflow.nyquist_validation',
46
+ 'hooks.research_questions': 'workflow.research_before_questions',
47
+ 'workflow.research_questions': 'workflow.research_before_questions',
48
+ };
49
+
50
+ function validateKnownConfigKeyPath(keyPath) {
51
+ const suggested = CONFIG_KEY_SUGGESTIONS[keyPath];
52
+ if (suggested) {
53
+ error(`Unknown config key: ${keyPath}. Did you mean ${suggested}?`);
27
54
  }
55
+ }
28
56
 
29
- // Detect Brave Search API key availability
57
+ /**
58
+ * Build a fully-materialized config object for a new project.
59
+ *
60
+ * Merges (increasing priority):
61
+ * 1. Hardcoded defaults — every key that loadConfig() resolves, plus mode/granularity
62
+ * 2. User-level defaults from ~/.gsd/defaults.json (if present)
63
+ * 3. userChoices — the settings the user explicitly selected during /gsd-new-project
64
+ *
65
+ * Uses the canonical `git` namespace for branching keys (consistent with VALID_CONFIG_KEYS
66
+ * and the settings workflow). loadConfig() handles both flat and nested formats, so this
67
+ * is backward-compatible with existing projects that have flat keys.
68
+ *
69
+ * Returns a plain object — does NOT write any files.
70
+ */
71
+ function buildNewProjectConfig(userChoices) {
72
+ const choices = userChoices || {};
30
73
  const homedir = require('os').homedir();
74
+
75
+ // Detect API key availability
31
76
  const braveKeyFile = path.join(homedir, '.gsd', 'brave_api_key');
32
77
  const hasBraveSearch = !!(process.env.BRAVE_API_KEY || fs.existsSync(braveKeyFile));
78
+ const firecrawlKeyFile = path.join(homedir, '.gsd', 'firecrawl_api_key');
79
+ const hasFirecrawl = !!(process.env.FIRECRAWL_API_KEY || fs.existsSync(firecrawlKeyFile));
80
+ const exaKeyFile = path.join(homedir, '.gsd', 'exa_api_key');
81
+ const hasExaSearch = !!(process.env.EXA_API_KEY || fs.existsSync(exaKeyFile));
33
82
 
34
83
  // Load user-level defaults from ~/.gsd/defaults.json if available
35
84
  const globalDefaultsPath = path.join(homedir, '.gsd', 'defaults.json');
@@ -42,57 +91,184 @@ function cmdConfigEnsureSection(cwd, raw) {
42
91
  const depthToGranularity = { quick: 'coarse', standard: 'standard', comprehensive: 'fine' };
43
92
  userDefaults.granularity = depthToGranularity[userDefaults.depth] || userDefaults.depth;
44
93
  delete userDefaults.depth;
45
- try { fs.writeFileSync(globalDefaultsPath, JSON.stringify(userDefaults, null, 2), 'utf-8'); } catch {}
94
+ try {
95
+ fs.writeFileSync(globalDefaultsPath, JSON.stringify(userDefaults, null, 2), 'utf-8');
96
+ } catch { /* intentionally empty */ }
46
97
  }
47
98
  }
48
- } catch (err) {
49
- // Ignore malformed global defaults, fall back to hardcoded
99
+ } catch {
100
+ // Ignore malformed global defaults
50
101
  }
51
102
 
52
- // Create default config (user-level defaults override hardcoded defaults)
53
103
  const hardcoded = {
54
104
  model_profile: 'balanced',
55
105
  commit_docs: true,
106
+ parallelization: true,
56
107
  search_gitignored: false,
57
- branching_strategy: 'none',
58
- phase_branch_template: 'gsd/phase-{phase}-{slug}',
59
- milestone_branch_template: 'gsd/{milestone}-{slug}',
108
+ brave_search: hasBraveSearch,
109
+ firecrawl: hasFirecrawl,
110
+ exa_search: hasExaSearch,
111
+ git: {
112
+ branching_strategy: 'none',
113
+ phase_branch_template: 'gsd/phase-{phase}-{slug}',
114
+ milestone_branch_template: 'gsd/{milestone}-{slug}',
115
+ quick_branch_template: null,
116
+ },
60
117
  workflow: {
61
118
  research: true,
62
119
  plan_check: true,
63
120
  verifier: true,
64
121
  nyquist_validation: true,
122
+ auto_advance: false,
123
+ node_repair: true,
124
+ node_repair_budget: 2,
125
+ ui_phase: true,
126
+ ui_safety_gate: true,
127
+ text_mode: false,
128
+ research_before_questions: false,
129
+ discuss_mode: 'discuss',
130
+ skip_discuss: false,
65
131
  },
66
- parallelization: true,
67
- brave_search: hasBraveSearch,
132
+ hooks: {
133
+ context_warnings: true,
134
+ },
135
+ agent_skills: {},
68
136
  };
69
- const defaults = {
137
+
138
+ // Three-level deep merge: hardcoded <- userDefaults <- choices
139
+ return {
70
140
  ...hardcoded,
71
141
  ...userDefaults,
72
- workflow: { ...hardcoded.workflow, ...(userDefaults.workflow || {}) },
142
+ ...choices,
143
+ git: {
144
+ ...hardcoded.git,
145
+ ...(userDefaults.git || {}),
146
+ ...(choices.git || {}),
147
+ },
148
+ workflow: {
149
+ ...hardcoded.workflow,
150
+ ...(userDefaults.workflow || {}),
151
+ ...(choices.workflow || {}),
152
+ },
153
+ hooks: {
154
+ ...hardcoded.hooks,
155
+ ...(userDefaults.hooks || {}),
156
+ ...(choices.hooks || {}),
157
+ },
158
+ agent_skills: {
159
+ ...hardcoded.agent_skills,
160
+ ...(userDefaults.agent_skills || {}),
161
+ ...(choices.agent_skills || {}),
162
+ },
73
163
  };
164
+ }
165
+
166
+ /**
167
+ * Command: create a fully-materialized .planning/config.json for a new project.
168
+ *
169
+ * Accepts user-chosen settings as a JSON string (the keys the user explicitly
170
+ * configured during /gsd-new-project). All remaining keys are filled from
171
+ * hardcoded defaults and optional ~/.gsd/defaults.json.
172
+ *
173
+ * Idempotent: if config.json already exists, returns { created: false }.
174
+ */
175
+ function cmdConfigNewProject(cwd, choicesJson, raw) {
176
+ const planningBase = planningRoot(cwd);
177
+ const configPath = path.join(planningBase, 'config.json');
74
178
 
179
+ // Idempotent: don't overwrite existing config
180
+ if (fs.existsSync(configPath)) {
181
+ output({ created: false, reason: 'already_exists' }, raw, 'exists');
182
+ return;
183
+ }
184
+
185
+ // Parse user choices
186
+ let userChoices = {};
187
+ if (choicesJson && choicesJson.trim() !== '') {
188
+ try {
189
+ userChoices = JSON.parse(choicesJson);
190
+ } catch (err) {
191
+ error('Invalid JSON for config-new-project: ' + err.message);
192
+ }
193
+ }
194
+
195
+ // Ensure .planning directory exists
75
196
  try {
76
- fs.writeFileSync(configPath, JSON.stringify(defaults, null, 2), 'utf-8');
77
- const result = { created: true, path: '.planning/config.json' };
78
- output(result, raw, 'created');
197
+ if (!fs.existsSync(planningBase)) {
198
+ fs.mkdirSync(planningBase, { recursive: true });
199
+ }
79
200
  } catch (err) {
80
- error('Failed to create config.json: ' + err.message);
201
+ error('Failed to create .planning directory: ' + err.message);
202
+ }
203
+
204
+ const config = buildNewProjectConfig(userChoices);
205
+
206
+ try {
207
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
208
+ output({ created: true, path: '.planning/config.json' }, raw, 'created');
209
+ } catch (err) {
210
+ error('Failed to write config.json: ' + err.message);
81
211
  }
82
212
  }
83
213
 
84
- function cmdConfigSet(cwd, keyPath, value, raw) {
85
- const configPath = path.join(cwd, '.planning', 'config.json');
214
+ /**
215
+ * Ensures the config file exists (creates it if needed).
216
+ *
217
+ * Does not call `output()`, so can be used as one step in a command without triggering `exit(0)` in
218
+ * the happy path. But note that `error()` will still `exit(1)` out of the process.
219
+ */
220
+ function ensureConfigFile(cwd) {
221
+ const planningBase = planningRoot(cwd);
222
+ const configPath = path.join(planningBase, 'config.json');
86
223
 
87
- if (!keyPath) {
88
- error('Usage: config-set <key.path> <value>');
224
+ // Ensure .planning directory exists
225
+ try {
226
+ if (!fs.existsSync(planningBase)) {
227
+ fs.mkdirSync(planningBase, { recursive: true });
228
+ }
229
+ } catch (err) {
230
+ error('Failed to create .planning directory: ' + err.message);
89
231
  }
90
232
 
91
- // Parse value (handle booleans and numbers)
92
- let parsedValue = value;
93
- if (value === 'true') parsedValue = true;
94
- else if (value === 'false') parsedValue = false;
95
- else if (!isNaN(value) && value !== '') parsedValue = Number(value);
233
+ // Check if config already exists
234
+ if (fs.existsSync(configPath)) {
235
+ return { created: false, reason: 'already_exists' };
236
+ }
237
+
238
+ const config = buildNewProjectConfig({});
239
+
240
+ try {
241
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
242
+ return { created: true, path: '.planning/config.json' };
243
+ } catch (err) {
244
+ error('Failed to create config.json: ' + err.message);
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Command to ensure the config file exists (creates it if needed).
250
+ *
251
+ * Note that this exits the process (via `output()`) even in the happy path; use
252
+ * `ensureConfigFile()` directly if you need to avoid this.
253
+ */
254
+ function cmdConfigEnsureSection(cwd, raw) {
255
+ const ensureConfigFileResult = ensureConfigFile(cwd);
256
+ if (ensureConfigFileResult.created) {
257
+ output(ensureConfigFileResult, raw, 'created');
258
+ } else {
259
+ output(ensureConfigFileResult, raw, 'exists');
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Sets a value in the config file, allowing nested values via dot notation (e.g.,
265
+ * "workflow.research").
266
+ *
267
+ * Does not call `output()`, so can be used as one step in a command without triggering `exit(0)` in
268
+ * the happy path. But note that `error()` will still `exit(1)` out of the process.
269
+ */
270
+ function setConfigValue(cwd, keyPath, parsedValue) {
271
+ const configPath = path.join(planningRoot(cwd), 'config.json');
96
272
 
97
273
  // Load existing config or start with empty object
98
274
  let config = {};
@@ -114,20 +290,51 @@ function cmdConfigSet(cwd, keyPath, value, raw) {
114
290
  }
115
291
  current = current[key];
116
292
  }
293
+ const previousValue = current[keys[keys.length - 1]]; // Capture previous value before overwriting
117
294
  current[keys[keys.length - 1]] = parsedValue;
118
295
 
119
296
  // write back
120
297
  try {
121
298
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
122
- const result = { updated: true, key: keyPath, value: parsedValue };
123
- output(result, raw, `${keyPath}=${parsedValue}`);
299
+ return { updated: true, key: keyPath, value: parsedValue, previousValue };
124
300
  } catch (err) {
125
301
  error('Failed to write config.json: ' + err.message);
126
302
  }
127
303
  }
128
304
 
305
+ /**
306
+ * Command to set a value in the config file, allowing nested values via dot notation (e.g.,
307
+ * "workflow.research").
308
+ *
309
+ * Note that this exits the process (via `output()`) even in the happy path; use `setConfigValue()`
310
+ * directly if you need to avoid this.
311
+ */
312
+ function cmdConfigSet(cwd, keyPath, value, raw) {
313
+ if (!keyPath) {
314
+ error('Usage: config-set <key.path> <value>');
315
+ }
316
+
317
+ validateKnownConfigKeyPath(keyPath);
318
+
319
+ if (!isValidConfigKey(keyPath)) {
320
+ error(`Unknown config key: "${keyPath}". Valid keys: ${[...VALID_CONFIG_KEYS].sort().join(', ')}, agent_skills.<agent-type>`);
321
+ }
322
+
323
+ // Parse value (handle booleans, numbers, and JSON arrays/objects)
324
+ let parsedValue = value;
325
+ if (value === 'true') parsedValue = true;
326
+ else if (value === 'false') parsedValue = false;
327
+ else if (!isNaN(value) && value !== '') parsedValue = Number(value);
328
+ else if (typeof value === 'string' && (value.startsWith('[') || value.startsWith('{'))) {
329
+ try { parsedValue = JSON.parse(value); } catch { /* keep as string */ }
330
+ }
331
+
332
+ const setConfigValueResult = setConfigValue(cwd, keyPath, parsedValue);
333
+ output(setConfigValueResult, raw, `${keyPath}=${parsedValue}`);
334
+ }
335
+
129
336
  function cmdConfigGet(cwd, keyPath, raw) {
130
- const configPath = path.join(cwd, '.planning', 'config.json');
337
+ const configPath = path.join(planningRoot(cwd), 'config.json');
131
338
 
132
339
  if (!keyPath) {
133
340
  error('Usage: config-get <key.path>');
@@ -162,8 +369,74 @@ function cmdConfigGet(cwd, keyPath, raw) {
162
369
  output(current, raw, String(current));
163
370
  }
164
371
 
372
+ /**
373
+ * Command to set the model profile in the config file.
374
+ *
375
+ * Note that this exits the process (via `output()`) even in the happy path.
376
+ */
377
+ function cmdConfigSetModelProfile(cwd, profile, raw) {
378
+ if (!profile) {
379
+ error(`Usage: config-set-model-profile <${VALID_PROFILES.join('|')}>`);
380
+ }
381
+
382
+ const normalizedProfile = profile.toLowerCase().trim();
383
+ if (!VALID_PROFILES.includes(normalizedProfile)) {
384
+ error(`Invalid profile '${profile}'. Valid profiles: ${VALID_PROFILES.join(', ')}`);
385
+ }
386
+
387
+ // Ensure config exists (create if needed)
388
+ ensureConfigFile(cwd);
389
+
390
+ // Set the model profile in the config
391
+ const { previousValue } = setConfigValue(cwd, 'model_profile', normalizedProfile, raw);
392
+ const previousProfile = previousValue || 'balanced';
393
+
394
+ // Build result value / message and return
395
+ const agentToModelMap = getAgentToModelMapForProfile(normalizedProfile);
396
+ const result = {
397
+ updated: true,
398
+ profile: normalizedProfile,
399
+ previousProfile,
400
+ agentToModelMap,
401
+ };
402
+ const rawValue = getCmdConfigSetModelProfileResultMessage(
403
+ normalizedProfile,
404
+ previousProfile,
405
+ agentToModelMap
406
+ );
407
+ output(result, raw, rawValue);
408
+ }
409
+
410
+ /**
411
+ * Returns the message to display for the result of the `config-set-model-profile` command when
412
+ * displaying raw output.
413
+ */
414
+ function getCmdConfigSetModelProfileResultMessage(
415
+ normalizedProfile,
416
+ previousProfile,
417
+ agentToModelMap
418
+ ) {
419
+ const agentToModelTable = formatAgentToModelMapAsTable(agentToModelMap);
420
+ const didChange = previousProfile !== normalizedProfile;
421
+ const paragraphs = didChange
422
+ ? [
423
+ `✓ Model profile set to: ${normalizedProfile} (was: ${previousProfile})`,
424
+ 'Agents will now use:',
425
+ agentToModelTable,
426
+ 'Next spawned agents will use the new profile.',
427
+ ]
428
+ : [
429
+ `✓ Model profile is already set to: ${normalizedProfile}`,
430
+ 'Agents are using:',
431
+ agentToModelTable,
432
+ ];
433
+ return paragraphs.join('\n\n');
434
+ }
435
+
165
436
  module.exports = {
166
437
  cmdConfigEnsureSection,
167
438
  cmdConfigSet,
168
439
  cmdConfigGet,
440
+ cmdConfigSetModelProfile,
441
+ cmdConfigNewProject,
169
442
  };