gsd-opencode 1.9.1 → 1.10.1

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/agents/gsd-debugger.md +5 -5
  2. package/agents/gsd-set-model.md +287 -0
  3. package/agents/gsd-set-profile.md +239 -0
  4. package/agents/gsd-settings.md +303 -0
  5. package/bin/gsd-install.js +105 -0
  6. package/bin/gsd.js +352 -0
  7. package/bin/install.js +81 -1
  8. package/{command → commands}/gsd/add-phase.md +1 -1
  9. package/{command → commands}/gsd/audit-milestone.md +1 -1
  10. package/{command → commands}/gsd/debug.md +3 -3
  11. package/{command → commands}/gsd/discuss-phase.md +1 -1
  12. package/{command → commands}/gsd/execute-phase.md +1 -1
  13. package/{command → commands}/gsd/list-phase-assumptions.md +1 -1
  14. package/{command → commands}/gsd/map-codebase.md +1 -1
  15. package/{command → commands}/gsd/new-milestone.md +1 -1
  16. package/{command → commands}/gsd/new-project.md +71 -6
  17. package/{command → commands}/gsd/plan-phase.md +2 -2
  18. package/{command → commands}/gsd/research-phase.md +1 -1
  19. package/commands/gsd/set-model.md +77 -0
  20. package/commands/gsd/set-profile.md +46 -0
  21. package/commands/gsd/settings.md +33 -0
  22. package/{command → commands}/gsd/verify-work.md +1 -1
  23. package/get-shit-done/references/model-profiles.md +67 -36
  24. package/get-shit-done/workflows/list-phase-assumptions.md +1 -1
  25. package/get-shit-done/workflows/verify-work.md +5 -5
  26. package/lib/constants.js +193 -0
  27. package/package.json +34 -20
  28. package/src/commands/check.js +329 -0
  29. package/src/commands/config.js +337 -0
  30. package/src/commands/install.js +608 -0
  31. package/src/commands/list.js +256 -0
  32. package/src/commands/repair.js +519 -0
  33. package/src/commands/uninstall.js +732 -0
  34. package/src/commands/update.js +444 -0
  35. package/src/services/backup-manager.js +585 -0
  36. package/src/services/config.js +262 -0
  37. package/src/services/file-ops.js +830 -0
  38. package/src/services/health-checker.js +475 -0
  39. package/src/services/manifest-manager.js +301 -0
  40. package/src/services/migration-service.js +831 -0
  41. package/src/services/repair-service.js +846 -0
  42. package/src/services/scope-manager.js +303 -0
  43. package/src/services/settings.js +553 -0
  44. package/src/services/structure-detector.js +240 -0
  45. package/src/services/update-service.js +863 -0
  46. package/src/utils/hash.js +71 -0
  47. package/src/utils/interactive.js +222 -0
  48. package/src/utils/logger.js +128 -0
  49. package/src/utils/npm-registry.js +255 -0
  50. package/src/utils/path-resolver.js +226 -0
  51. package/command/gsd/set-profile.md +0 -111
  52. package/command/gsd/settings.md +0 -136
  53. /package/{command → commands}/gsd/add-todo.md +0 -0
  54. /package/{command → commands}/gsd/check-todos.md +0 -0
  55. /package/{command → commands}/gsd/complete-milestone.md +0 -0
  56. /package/{command → commands}/gsd/help.md +0 -0
  57. /package/{command → commands}/gsd/insert-phase.md +0 -0
  58. /package/{command → commands}/gsd/pause-work.md +0 -0
  59. /package/{command → commands}/gsd/plan-milestone-gaps.md +0 -0
  60. /package/{command → commands}/gsd/progress.md +0 -0
  61. /package/{command → commands}/gsd/quick.md +0 -0
  62. /package/{command → commands}/gsd/remove-phase.md +0 -0
  63. /package/{command → commands}/gsd/resume-work.md +0 -0
  64. /package/{command → commands}/gsd/update.md +0 -0
  65. /package/{command → commands}/gsd/whats-new.md +0 -0
@@ -836,17 +836,17 @@ The file IS the debugging brain.
836
836
  ls .planning/debug/*.md 2>/dev/null | grep -v resolved
837
837
  ```
838
838
 
839
- **If active sessions exist AND no $ARGUMENTS:**
839
+ **If active sessions exist AND no `$ARGUMENTS`:**
840
840
  - Display sessions with status, hypothesis, next action
841
841
  - Wait for user to select (number) or describe new issue (text)
842
842
 
843
- **If active sessions exist AND $ARGUMENTS:**
843
+ **If active sessions exist AND `$ARGUMENTS`:**
844
844
  - Start new session (continue to create_debug_file)
845
845
 
846
- **If no active sessions AND no $ARGUMENTS:**
846
+ **If no active sessions AND no `$ARGUMENTS`:**
847
847
  - Prompt: "No active sessions. Describe the issue to start."
848
848
 
849
- **If no active sessions AND $ARGUMENTS:**
849
+ **If no active sessions AND `$ARGUMENTS`:**
850
850
  - Continue to create_debug_file
851
851
  </step>
852
852
 
@@ -857,7 +857,7 @@ ls .planning/debug/*.md 2>/dev/null | grep -v resolved
857
857
  2. `mkdir -p .planning/debug`
858
858
  3. Create file with initial state:
859
859
  - status: gathering
860
- - trigger: verbatim $ARGUMENTS
860
+ - trigger: verbatim `$ARGUMENTS`
861
861
  - Current Focus: next_action = "gather symptoms"
862
862
  - Symptoms: empty
863
863
  4. Proceed to symptom_gathering
@@ -0,0 +1,287 @@
1
+ ---
2
+ name: gsd-set-model
3
+ description: Configure models for a specific profile's stages
4
+ tools:
5
+ read: true
6
+ write: true
7
+ bash: true
8
+ question: true
9
+ ---
10
+
11
+ <role>
12
+ You are executing the `/gsd-set-model` command. Configure the models assigned to each stage (planning, execution, verification) for a specific profile preset.
13
+
14
+ This command reads/writes two files:
15
+ - `.planning/config.json` — profile state (active_profile, presets, custom_overrides)
16
+ - `opencode.json` — agent model assignments (OpenCode's native config)
17
+
18
+ Do NOT modify agent .md files. This command updates profile presets, not overrides.
19
+ </role>
20
+
21
+ <context>
22
+ **Invocation styles:**
23
+
24
+ 1. No args (interactive): `/gsd-set-model`
25
+ 2. Positional: `/gsd-set-model quality` or `balanced` or `budget`
26
+
27
+ **Stage-to-agent mapping (11 agents):**
28
+
29
+ | Stage | Agents |
30
+ |--------------|--------|
31
+ | Planning | gsd-planner, gsd-plan-checker, gsd-phase-researcher, gsd-roadmapper, gsd-project-researcher, gsd-research-synthesizer, gsd-codebase-mapper |
32
+ | Execution | gsd-executor, gsd-debugger |
33
+ | Verification | gsd-verifier, gsd-integration-checker, gsd-set-profile, gsd-settings, gsd-set-model |
34
+
35
+ **Profile presets:** Stored in `.planning/config.json` under `profiles.presets.{profile}`. Each profile has three keys: `planning`, `execution`, `verification`.
36
+ </context>
37
+
38
+ <behavior>
39
+
40
+ ## Step 1: Read config file
41
+
42
+ Read `.planning/config.json`. Handle these cases:
43
+
44
+ **Case A: File missing or no `.planning/` directory**
45
+ - Print: `Error: No GSD project found. Run /gsd-new-project first.`
46
+ - Stop.
47
+
48
+ **Case B: File exists but no `profiles.presets` key**
49
+ - Print: `Error: No model presets configured. Run /gsd-settings first to initialize your profiles.`
50
+ - Stop.
51
+
52
+ **Case C: File exists with `profiles.presets` key**
53
+ - Use as-is
54
+
55
+ ## Step 2: Determine target profile
56
+
57
+ **A) Check for positional argument:**
58
+ - If user typed `/gsd-set-model quality` (or balanced/budget), use that as `targetProfile`
59
+
60
+ **B) Interactive picker (no args):**
61
+
62
+ Use Question tool:
63
+
64
+ ```
65
+ header: "Configure Profile"
66
+ question: "Which profile do you want to configure?"
67
+ options:
68
+ - label: "Quality"
69
+ description: "Configure models for the quality profile"
70
+ - label: "Balanced"
71
+ description: "Configure models for the balanced profile"
72
+ - label: "Budget"
73
+ description: "Configure models for the budget profile"
74
+ - label: "Cancel"
75
+ description: "Exit without changes"
76
+ ```
77
+
78
+ Input rules:
79
+ - For this command, custom/freeform answers are NOT allowed.
80
+ - If the user's selection is not exactly one of the option labels, print an error and re-run the same Question prompt.
81
+
82
+ If user selects Cancel:
83
+ ```
84
+ Configuration cancelled.
85
+ ```
86
+ Stop.
87
+
88
+ **C) Invalid profile handling:**
89
+
90
+ If an invalid profile name is provided:
91
+ - Print: `Unknown profile '{name}'. Valid options: quality, balanced, budget`
92
+ - Fall back to interactive picker
93
+
94
+ ## Step 3: Display information BEFORE prompting
95
+
96
+ **IMPORTANT: Complete ALL display output in this step before asking any questions.**
97
+
98
+ ### 3a. Show current configuration
99
+
100
+ Get current preset from `config.profiles.presets[targetProfile]` and print:
101
+
102
+ ```text
103
+ Configuring models for: {targetProfile}
104
+
105
+ Current configuration:
106
+ | Stage | Model |
107
+ |-------|-------|
108
+ | planning | {preset.planning} |
109
+ | execution | {preset.execution} |
110
+ | verification | {preset.verification} |
111
+ ```
112
+
113
+ ### 3b. Discover and display available models
114
+
115
+ Run:
116
+
117
+ ```bash
118
+ opencode models 2>/dev/null
119
+ ```
120
+
121
+ Parse the output to extract model IDs in `provider/model` format. Store these in a list for validation.
122
+
123
+ If command fails or returns no models:
124
+ ```text
125
+ Error: Could not fetch available models. Check your OpenCode installation.
126
+ ```
127
+ Stop.
128
+
129
+ **Print** the tip below after running opencode models:
130
+
131
+ ```text
132
+ Tip: Models prefixed with "opencode/" require an OpenCode Zen subscription.
133
+ To see only one provider's models: opencode models <provider>
134
+ ```
135
+
136
+ ### 3c. Print input instructions
137
+
138
+ ```text
139
+ Enter model selection for each stage (you may press Enter to keep the current value).
140
+ ```
141
+
142
+ **Do NOT proceed to Step 4 until all of the above is printed.**
143
+
144
+ ## Step 4: Prompt for model selection
145
+
146
+ Now prompt the user for each stage. Ask one question at a time.
147
+
148
+ ### Planning Stage
149
+
150
+ Use Question tool with free-form input allowed:
151
+
152
+ ```
153
+ header: "{targetProfile} Profile - Planning"
154
+ question: "Enter model ID for planning agents (or press Enter to keep current)"
155
+ placeholder: "{preset.planning}"
156
+ allowFreeform: true
157
+ options:
158
+ - label: "Keep current"
159
+ description: "{preset.planning}"
160
+ ```
161
+
162
+ ### Execution Stage
163
+
164
+ ```
165
+ header: "{targetProfile} Profile - Execution"
166
+ question: "Enter model ID for execution agents (or press Enter to keep current)"
167
+ placeholder: "{preset.execution}"
168
+ allowFreeform: true
169
+ options:
170
+ - label: "Keep current"
171
+ description: "{preset.execution}"
172
+ ```
173
+
174
+ ### Verification Stage
175
+
176
+ ```
177
+ header: "{targetProfile} Profile - Verification"
178
+ question: "Enter model ID for verification agents (or press Enter to keep current)"
179
+ placeholder: "{preset.verification}"
180
+ allowFreeform: true
181
+ options:
182
+ - label: "Keep current"
183
+ description: "{preset.verification}"
184
+ ```
185
+
186
+ **Input handling for each stage:**
187
+
188
+ 1. If user selects "Keep current" or enters empty/blank input, retain the existing value
189
+ 2. If user enters a model ID:
190
+ - Validate it exists in the available models list
191
+ - If invalid, print error and re-prompt:
192
+ ```
193
+ Invalid model ID: '{input}'. Please enter a valid model from the list above.
194
+ ```
195
+ - If valid, use the entered model ID
196
+
197
+ ## Step 5: Check for changes
198
+
199
+ If no changes were made (all stages selected "Keep current"):
200
+ ```
201
+ No changes made to {targetProfile} profile.
202
+ ```
203
+ Stop.
204
+
205
+ ## Step 6: Save changes
206
+
207
+ Use the **write tool directly** to update files. Do NOT use bash, python, or other scripts—use native file writing.
208
+
209
+ 1. **Update .planning/config.json:**
210
+
211
+ - Set `config.profiles.presets[targetProfile].planning` to selected value
212
+ - Set `config.profiles.presets[targetProfile].execution` to selected value
213
+ - Set `config.profiles.presets[targetProfile].verification` to selected value
214
+ - Write the config file (preserve all other keys)
215
+
216
+ 2. **Update opencode.json (only if targetProfile is active):**
217
+
218
+ Check if `config.profiles.active_profile === targetProfile`. If so, regenerate `opencode.json` with the new effective models.
219
+
220
+ Compute effective models (preset + overrides):
221
+ ```
222
+ overrides = config.profiles.custom_overrides[targetProfile] || {}
223
+ effective.planning = overrides.planning || newPreset.planning
224
+ effective.execution = overrides.execution || newPreset.execution
225
+ effective.verification = overrides.verification || newPreset.verification
226
+ ```
227
+
228
+ Build agent config:
229
+
230
+ ```json
231
+ {
232
+ "$schema": "https://opencode.ai/config.json",
233
+ "agent": {
234
+ "gsd-planner": { "model": "{effective.planning}" },
235
+ "gsd-plan-checker": { "model": "{effective.planning}" },
236
+ "gsd-phase-researcher": { "model": "{effective.planning}" },
237
+ "gsd-roadmapper": { "model": "{effective.planning}" },
238
+ "gsd-project-researcher": { "model": "{effective.planning}" },
239
+ "gsd-research-synthesizer": { "model": "{effective.planning}" },
240
+ "gsd-codebase-mapper": { "model": "{effective.planning}" },
241
+ "gsd-executor": { "model": "{effective.execution}" },
242
+ "gsd-debugger": { "model": "{effective.execution}" },
243
+ "gsd-verifier": { "model": "{effective.verification}" },
244
+ "gsd-integration-checker": { "model": "{effective.verification}" },
245
+ "gsd-set-profile": { "model": "{effective.verification}" },
246
+ "gsd-settings": { "model": "{effective.verification}" },
247
+ "gsd-set-model": { "model": "{effective.verification}" }
248
+ }
249
+ }
250
+ ```
251
+
252
+ If `opencode.json` already exists, merge the `agent` key (preserve other top-level keys).
253
+
254
+ 3. **Report success:**
255
+
256
+ ```text
257
+ ✓ Updated {targetProfile} profile:
258
+
259
+ | Stage | Model |
260
+ |--------------|-------|
261
+ | planning | {newPreset.planning} |
262
+ | execution | {newPreset.execution} |
263
+ | verification | {newPreset.verification} |
264
+ ```
265
+
266
+ If `targetProfile` is the active profile:
267
+ ```text
268
+ Note: This is your active profile. Quit and relaunch OpenCode to apply model changes.
269
+ ```
270
+
271
+ If `targetProfile` is NOT the active profile:
272
+ ```text
273
+ To use this profile, run: /gsd-set-profile {targetProfile}
274
+ ```
275
+
276
+ </behavior>
277
+
278
+ <notes>
279
+ - Display available models first, then accept free-form input for model selection
280
+ - Validate entered model IDs against the available models list
281
+ - Always show full model IDs (e.g., `opencode/claude-sonnet-4`)
282
+ - Preserve all other config.json keys when writing (deep merge)
283
+ - Do NOT rewrite agent .md files — only update config.json and opencode.json
284
+ - This command modifies **presets**, not overrides. Use `/gsd-settings` for per-stage overrides.
285
+ - **Source of truth:** `config.json` stores profiles/presets/overrides; `opencode.json` is **derived** from the effective models
286
+ - OpenCode shows all available models regardless of subscription status. Users without Zen can filter with `opencode models github-copilot`
287
+ </notes>
@@ -0,0 +1,239 @@
1
+ ---
2
+ name: gsd-set-profile
3
+ description: Switch between model profiles with confirmation workflow
4
+ tools:
5
+ question: true
6
+ ---
7
+
8
+ <role>
9
+ You are executing the `/gsd-set-profile` command. Switch the project's active model profile (quality/balanced/budget) with a clear before/after preview and confirmation workflow.
10
+
11
+ This command reads/writes two files:
12
+ - `.planning/config.json` — profile state (active_profile, presets, custom_overrides)
13
+ - `opencode.json` — agent model assignments (OpenCode's native config)
14
+
15
+ Do NOT modify agent .md files. Profile switching updates `opencode.json` in the project root.
16
+ </role>
17
+
18
+ <context>
19
+ **Invocation styles:**
20
+
21
+ 1. No args (interactive picker): `/gsd-set-profile`
22
+ 2. Positional: `/gsd-set-profile quality` or `balanced` or `budget`
23
+ 3. Flags: `--quality` or `-q`, `--balanced` or `-b`, `--budget` or `-u`
24
+
25
+ Precedence: Positional > Flags > Interactive picker
26
+
27
+ **Stage-to-agent mapping (11 agents):**
28
+
29
+ | Stage | Agents |
30
+ |--------------|--------|
31
+ | Planning | gsd-planner, gsd-plan-checker, gsd-phase-researcher, gsd-roadmapper, gsd-project-researcher, gsd-research-synthesizer, gsd-codebase-mapper |
32
+ | Execution | gsd-executor, gsd-debugger |
33
+ | Verification | gsd-verifier, gsd-integration-checker, gsd-set-profile, gsd-settings, gsd-set-model |
34
+
35
+ **Profile presets:** Defined in `.planning/config.json` (user-configurable via `/gsd-settings`). No hardcoded defaults—presets are discovered dynamically on first run.
36
+ </context>
37
+
38
+ <behavior>
39
+
40
+ ## Step 1: Read config file
41
+
42
+ Read `.planning/config.json`. Handle these cases:
43
+
44
+ **Case A: File missing or no `profiles.presets` key**
45
+ - Print: `Error: No model presets configured. Run /gsd-settings first to set up your profiles.`
46
+ - Stop.
47
+
48
+ **Case B: File exists with `profiles.presets` key**
49
+ - Use as-is
50
+
51
+ **Also check `opencode.json`:**
52
+ - If missing, it will be created when changes are saved
53
+ - If exists, it will be merged (preserve non-agent keys)
54
+
55
+ ## Step 2: Compute effective models for current profile
56
+
57
+ 1. Get `currentProfile` = `config.profiles.active_profile` (default: "balanced")
58
+ 2. Get `preset` = `config.profiles.presets[currentProfile]`
59
+ 3. Get `overrides` = `config.profiles.custom_overrides[currentProfile]` (may be undefined)
60
+ 4. Compute effective models:
61
+ - `planning` = overrides?.planning || preset.planning
62
+ - `execution` = overrides?.execution || preset.execution
63
+ - `verification` = overrides?.verification || preset.verification
64
+
65
+ ## Step 3: Display current state
66
+
67
+ Print:
68
+
69
+ ```
70
+ Active profile: {currentProfile}
71
+
72
+ Current configuration:
73
+ | Stage | Model |
74
+ |--------------|-------|
75
+ | planning | {current.planning} |
76
+ | execution | {current.execution} |
77
+ | verification | {current.verification} |
78
+ ```
79
+
80
+ ## Step 4: Determine requested profile
81
+
82
+ **A) Check for positional argument:**
83
+ - If user typed `/gsd-set-profile quality` (or balanced/budget), use that as `newProfile`
84
+
85
+ **B) Check for flags:**
86
+ - `--quality` or `-q` → quality
87
+ - `--balanced` or `-b` → balanced
88
+ - `--budget` or `-u` → budget
89
+
90
+ **C) Interactive picker (no args/flags):**
91
+
92
+ Build options dynamically from `config.profiles.presets`:
93
+
94
+ Use Question tool:
95
+
96
+ ```
97
+ header: "Model profile"
98
+ question: "Select a profile"
99
+ options:
100
+ - label: "Quality"
101
+ description: "{preset.quality.planning} / {preset.quality.execution} / {preset.quality.verification}"
102
+ - label: "Balanced"
103
+ description: "{preset.balanced.planning} / {preset.balanced.execution} / {preset.balanced.verification}"
104
+ - label: "Budget"
105
+ description: "{preset.budget.planning} / {preset.budget.execution} / {preset.budget.verification}"
106
+ - label: "Cancel"
107
+ description: "Exit without changes"
108
+ ```
109
+
110
+ (Substitute actual model IDs from `config.profiles.presets` for each profile.)
111
+
112
+ Input rules:
113
+ - OpenCode's Question UI may display a "Type your own answer" option.
114
+ - For this command, custom/freeform answers are NOT allowed.
115
+ - If the user's selection is not exactly one of the option labels, print an error and re-run the same Question prompt.
116
+
117
+ If user selects Cancel, print the cancellation message (Step 5) and stop.
118
+
119
+ **D) Invalid profile handling:**
120
+
121
+ If an invalid profile name is provided:
122
+ - Print: `Unknown profile '{name}'. Valid options: quality, balanced, budget`
123
+ - Fall back to interactive picker
124
+
125
+ ## Step 5: Handle edge cases
126
+
127
+ **If user selected Cancel:**
128
+ ```
129
+ Profile change cancelled. Current profile: {currentProfile}
130
+ ```
131
+ Stop.
132
+
133
+ **If newProfile === currentProfile:**
134
+ ```
135
+ Profile '{currentProfile}' is already active.
136
+ ```
137
+ Re-print current configuration table and stop.
138
+
139
+ ## Step 5.5: Validate selected models exist in OpenCode
140
+
141
+ Before writing any files, validate that the effective models for `newProfile` are actually available in the current OpenCode installation.
142
+
143
+ Run:
144
+
145
+ ```bash
146
+ opencode models
147
+ ```
148
+
149
+ Parse the output and extract valid model IDs in `provider/model` format.
150
+
151
+ Validate that all three effective model IDs exist in that list:
152
+
153
+ - `{new.planning}`
154
+ - `{new.execution}`
155
+ - `{new.verification}`
156
+
157
+ If `opencode models` fails, or any model is missing:
158
+
159
+ Print an error like:
160
+
161
+ ```text
162
+ Error: One or more selected models are not available in OpenCode.
163
+
164
+ Missing:
165
+ - {missingModel1}
166
+ - {missingModel2}
167
+
168
+ Run `opencode models` to see what is available, then update presets/overrides via /gsd-settings.
169
+ ```
170
+
171
+ Stop. Do NOT write `.planning/config.json` and do NOT update `opencode.json`.
172
+
173
+ ## Step 6: Apply changes
174
+
175
+ Use the **write tool directly** to update both files. Do NOT use bash, python, or other scripts—use native file writing.
176
+
177
+ 1. **Update .planning/config.json:**
178
+
179
+ - Set `config.profiles.active_profile` to `newProfile`
180
+ - Also set `config.model_profile` to `newProfile` (for orchestrators that read this key)
181
+ - Write the config file (preserve all other keys)
182
+
183
+ 2. **Update opencode.json:**
184
+
185
+ Build agent config from effective stage models for `newProfile`:
186
+
187
+ ```json
188
+ {
189
+ "$schema": "https://opencode.ai/config.json",
190
+ "agent": {
191
+ "gsd-planner": { "model": "{new.planning}" },
192
+ "gsd-plan-checker": { "model": "{new.planning}" },
193
+ "gsd-phase-researcher": { "model": "{new.planning}" },
194
+ "gsd-roadmapper": { "model": "{new.planning}" },
195
+ "gsd-project-researcher": { "model": "{new.planning}" },
196
+ "gsd-research-synthesizer": { "model": "{new.planning}" },
197
+ "gsd-codebase-mapper": { "model": "{new.planning}" },
198
+ "gsd-executor": { "model": "{new.execution}" },
199
+ "gsd-debugger": { "model": "{new.execution}" },
200
+ "gsd-verifier": { "model": "{new.verification}" },
201
+ "gsd-integration-checker": { "model": "{new.verification}" },
202
+ "gsd-set-profile": { "model": "{new.verification}" },
203
+ "gsd-settings": { "model": "{new.verification}" },
204
+ "gsd-set-model": { "model": "{new.verification}" }
205
+ }
206
+ }
207
+ ```
208
+
209
+ If `opencode.json` already exists, merge the `agent` key (preserve other top-level keys).
210
+
211
+ 3. **Report success:**
212
+
213
+ ```text
214
+ ✓ Active profile set to: {newProfile}
215
+
216
+ Current configuration:
217
+ | Stage | Model |
218
+ |--------------|-------|
219
+ | planning | {new.planning} |
220
+ | execution | {new.execution} |
221
+ | verification | {new.verification} |
222
+
223
+ Note: OpenCode loads `opencode.json` at startup and does not hot-reload model/agent assignments. Fully quit and relaunch OpenCode to apply this profile change.
224
+ ```
225
+
226
+ Important: Do NOT print any tooling transcript (e.g., `python -m json.tool ...`) or a separate `Updated:` file list. The success message above is the complete user-facing output.
227
+
228
+ </behavior>
229
+
230
+ <notes>
231
+ - Use the Question tool for ALL user input (never ask user to type numbers)
232
+ - Always show full model IDs (e.g., `opencode/glm-4.7-free`)
233
+ - Preserve all other config.json keys when writing (deep merge)
234
+ - Do NOT rewrite agent .md files — only update opencode.json
235
+ - If opencode.json doesn't exist, create it
236
+ - Overrides are scoped per profile at `profiles.custom_overrides.{profile}.{stage}`
237
+ - **Source of truth:** `config.json` stores profiles/presets/overrides; `opencode.json` is **derived** from the effective models
238
+ - When regenerating `opencode.json`, read the new profile from `config.json`, compute effective models (preset + overrides), then write the agent mappings
239
+ </notes>