gsd-opencode 1.20.2 → 1.20.3

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 (25) hide show
  1. package/commands/gsd/gsd-check-profile.md +30 -0
  2. package/get-shit-done/bin/gsd-oc-commands/check-oc-config-json.cjs +169 -0
  3. package/get-shit-done/bin/gsd-oc-commands/check-opencode-json.cjs +86 -0
  4. package/get-shit-done/bin/gsd-oc-commands/get-profile.cjs +117 -0
  5. package/get-shit-done/bin/gsd-oc-commands/set-profile.cjs +357 -0
  6. package/get-shit-done/bin/gsd-oc-commands/update-opencode-json.cjs +199 -0
  7. package/get-shit-done/bin/gsd-oc-commands/validate-models.cjs +75 -0
  8. package/get-shit-done/bin/gsd-oc-lib/oc-config.cjs +205 -0
  9. package/get-shit-done/bin/gsd-oc-lib/oc-core.cjs +113 -0
  10. package/get-shit-done/bin/gsd-oc-lib/oc-models.cjs +133 -0
  11. package/get-shit-done/bin/gsd-oc-lib/oc-profile-config.cjs +409 -0
  12. package/get-shit-done/bin/gsd-oc-tools.cjs +130 -0
  13. package/get-shit-done/bin/lib/oc-config.cjs +200 -0
  14. package/get-shit-done/bin/lib/oc-core.cjs +114 -0
  15. package/get-shit-done/bin/lib/oc-models.cjs +133 -0
  16. package/get-shit-done/bin/test/fixtures/oc-config-invalid.json +14 -0
  17. package/get-shit-done/bin/test/fixtures/oc-config-valid.json +22 -0
  18. package/get-shit-done/bin/test/get-profile.test.cjs +447 -0
  19. package/get-shit-done/bin/test/oc-profile-config.test.cjs +377 -0
  20. package/get-shit-done/bin/test/pivot-profile.test.cjs +276 -0
  21. package/get-shit-done/bin/test/set-profile.test.cjs +301 -0
  22. package/get-shit-done/workflows/oc-check-profile.md +181 -0
  23. package/get-shit-done/workflows/oc-set-profile.md +83 -243
  24. package/get-shit-done/workflows/settings.md +4 -3
  25. package/package.json +2 -2
@@ -3,20 +3,19 @@
3
3
  You are executing the `/gsd-set-profile` command. Switch the project's active model profile (simple/smart/genius) with optional model reuse.
4
4
 
5
5
  This command reads/writes:
6
- - `.planning/config.json` — profile state (profile_type, models)
7
- - `opencode.json` — agent model assignments (derived from profile)
6
+ - `.planning/oc_config.json` — source of truth for profile state (profile_type, stage-to-model mapping)
7
+ - `opencode.json` — agent model assignments (derived from profile; updated automatically by CLI)
8
8
 
9
- Do NOT modify agent .md files. Profile switching updates `opencode.json` in the project root.
9
+ Do NOT modify agent .md files. Profile switching only updates these two JSON files.
10
10
  </role>
11
11
 
12
12
  <context>
13
- **Invocation styles:**
13
+ ## Invocation
14
14
 
15
- 1. No args (interactive wizard): `/gsd-set-profile`
16
- 2. Positional with type: `/gsd-set-profile simple|smart|genius`
17
- 3. With reuse flag: `/gsd-set-profile smart --reuse`
15
+ 1. **Interactive wizard (no args):** `/gsd-set-profile`
16
+ 2. **Direct switch (positional arg):** `/gsd-set-profile simple|smart|genius`
18
17
 
19
- **Stage-to-agent mapping (11 agents):**
18
+ ## Stage-to-Agent Mapping (11 agents)
20
19
 
21
20
  | Stage | Agents |
22
21
  |--------------|--------|
@@ -24,297 +23,138 @@ Do NOT modify agent .md files. Profile switching updates `opencode.json` in the
24
23
  | Execution | gsd-executor, gsd-debugger |
25
24
  | Verification | gsd-verifier, gsd-integration-checker |
26
25
 
27
- **Profile types:**
26
+ ## Profile Types
28
27
 
29
- - **Simple**: 1 model total all stages use same model
30
- - **Smart**: 2 models — planning+execution share model, verification uses different
31
- - **Genius**: 3 models each stage can have different model
32
-
33
- **Migration:** Old configs with `model_profile: quality / balanced / budget` are auto-migrated to genius profile.
34
- </context>
35
-
36
- <behavior>
37
-
38
- ## Step 1: Load and validate config
39
-
40
- read `.planning/config.json`. Handle these cases:
41
-
42
- **Case A: File missing or invalid**
43
- - Print: `Error: No GSD project found. Run /gsd-new-project first.`
44
- - Stop.
45
-
46
- **Case B: Legacy config (has model_profile but no profiles.profile_type)**
47
- - Auto-migrate to genius profile
48
- - Use OLD_PROFILE_MODEL_MAP to convert quality / balanced / budget → genius
49
-
50
- **Case C: Current config**
51
- - Use `profiles.profile_type` and `profiles.models`
52
-
53
- **Also check `opencode.json`:**
54
- - If missing, it will be created
55
- - If exists, merge agent assignments (preserve other keys)
28
+ | Profile | Models | Stage assignment |
29
+ |----------|--------|-----------------|
30
+ | Simple | 1 | All stages use the same model |
31
+ | Smart | 2 | Planning + Execution share one model; Verification uses a different model |
32
+ | Genius | 3 | Each stage uses a different model |
56
33
 
34
+ ## Output Format (reused throughout)
57
35
 
58
- ## Step 3: Display current state
59
-
60
- If profile exists:
36
+ When displaying profile state, always use this format:
61
37
 
62
38
  ```
63
- Active profile: {profile_type}
39
+ Active profile: **{profile_name}**
64
40
 
65
- Current configuration:
66
41
  | Stage | Model |
67
42
  |--------------|-------|
68
- | planning | {models.planning} |
69
- | execution | {models.execution} |
70
- | verification | {models.verification} |
71
- ```
72
-
73
- ## Step 4: Determine requested profile
74
-
75
- **A) Check for positional argument:**
76
- - If user typed `/gsd-set-profile simple|smart|genius`, use that as `newProfileType`
77
-
78
- **B) Interactive picker (no args):**
79
-
80
- Use question tool:
81
-
82
- ```
83
- header: "Profile Type"
84
- question: "Select a profile type for model configuration"
85
- options:
86
- - label: "Simple"
87
- description: "1 model for all gsd stages (easiest setup)"
88
- - label: "Smart"
89
- description: "2 models: advanced for planning & execution, cheaper for verification stages"
90
- - label: "Genius"
91
- description: "3 models: different model for planning, execution, or verification stages"
92
- - label: "Cancel"
93
- description: "Exit without changes"
43
+ | Planning | {models.planning} |
44
+ | Execution | {models.execution} |
45
+ | Verification | {models.verification} |
94
46
  ```
47
+ </context>
95
48
 
96
- If Cancel selected, print cancellation message and stop.
97
-
98
- **C) Invalid profile handling:**
99
-
100
- If invalid profile name:
101
- - Print: `Unknown profile type '{name}'. Valid options: simple, smart, genius`
102
- - Fall back to interactive picker
49
+ <behavior>
103
50
 
104
- ## Step 5: Handle --reuse flag
51
+ ## Step 1: Load current profile
105
52
 
106
- If `--reuse` flag present and current profile exists:
53
+ Run `get-profile` to read the current state from `.planning/oc_config.json`:
107
54
 
108
55
  ```bash
109
- node gsd-opencode/get-shit-done/bin/gsd-tools.cjs profile-switch {newProfileType} --reuse --raw
110
- ```
111
-
112
- Parse the reuse analysis:
113
- - Shows which stages can reuse existing models
114
- - Displays suggestions for each stage
115
-
116
- Present to user:
117
-
118
- ```
119
- Model Reuse Analysis for {newProfileType} profile:
120
-
121
- Current models:
122
- - Planning: {current.planning}
123
- - Execution: {current.execution}
124
- - Verification: {current.verification}
125
-
126
- Suggested reuse:
127
- {reuse analysis from tool}
128
-
129
- Use these suggestions? (yes/no)
56
+ node ~/.config/opencode/get-shit-done/bin/gsd-oc-tools.cjs get-profile
130
57
  ```
131
58
 
132
- If yes, proceed with suggested models.
133
- If no, run full model selection wizard.
134
-
135
- ## Step 6: Model selection wizard
136
-
137
- Based on profile type, prompt for models:
138
-
139
- ### Simple Profile (1 model)
140
-
141
- Use gsd-oc-select-model skill to select model for "Simple Profile - One model to rule them all".
142
-
143
- Store selected model. All stages will use this model.
144
-
145
- ### Smart Profile (2 models)
146
-
147
- Use gsd-oc-select-model skill twice.
148
-
149
- **First model** (planning + execution):
150
-
151
- Use gsd-oc-select-model skill to select model for "Smart Profile - Planning & Execution"
59
+ Parse the JSON response:
152
60
 
153
- **Second model** (verification):
61
+ - **`success: true`** — Extract `data` (keyed by profile name) containing `planning`, `execution`, `verification` model IDs. Display the profile using the Output Format. Continue to Step 2.
62
+ - **`success: false` with `CONFIG_NOT_FOUND`** — No profile exists yet. Skip display, go directly to Step 2.
154
63
 
155
- Use gsd-oc-select-model skill to select model for "Smart Profile - Verification"
64
+ ## Step 2: Determine target profile
156
65
 
157
- Store selected models.
66
+ ### Path A — Positional argument provided
158
67
 
159
- Planning + Execution will use First model selected.
160
- Verification will use Second model selected.
161
-
162
-
163
- ### Genius Profile (3 models)
164
-
165
- Use gsd-oc-select-model skill
166
-
167
-
168
- **First model** (planning):
169
-
170
- Use gsd-oc-select-model skill to select model for "Genius Profile - Planning"
171
-
172
- **Second model** (execution)
173
-
174
- Use gsd-oc-select-model skill to select model for "Genius Profile - Execution"
175
-
176
- **Thrid model** (verification):
177
-
178
- Use gsd-oc-select-model skill to select model for "Genius Profile - Verification"
179
-
180
- Store selected models.
181
-
182
- Planning will use First model selected.
183
- Execution will use Second model selected.
184
- Verification will use Third model selected.
185
-
186
-
187
-
188
- ## Step 7: Validate selected models
189
-
190
- Before writing files, validate models exist:
68
+ If the user typed `/gsd-set-profile {type}` where `{type}` is one of `simple`, `smart`, `genius`:
191
69
 
70
+ Attempt to switch to the saved profile:
192
71
  ```bash
193
- opencode models | grep -q "^{model}$" && echo "valid" || echo "invalid"
72
+ node ~/.config/opencode/get-shit-done/bin/gsd-oc-tools.cjs set-profile {type}
194
73
  ```
195
74
 
196
- If any model invalid:
197
- - Print error with list of missing models
198
- - Stop. Do NOT write config files.
199
-
200
- ## Step 8: Apply changes
75
+ - **`success: true`** — The profile already has saved model assignments. Display the updated configuration using the Output Format. Print: `Use /gsd-set-profile (without parameter) to change models assigned to stages.` **Stop.**
76
+ - **`PROFILE_NOT_FOUND` error** — No saved models for this profile type. Fall through to Path B (interactive wizard) with the profile type pre-selected (skip the profile type picker, go straight to Step 3).
201
77
 
202
- ### Save config.json
78
+ ### Path B — No argument (interactive wizard)
203
79
 
204
- Save config.json Or build and save manually:
80
+ Prompt the user to choose a profile type using the question tool:
205
81
 
206
82
  ```json
207
83
  {
208
- "profiles": {
209
- "profile_type": "{simple|smart|genius}",
210
- "models": {
211
- "planning": "{model}",
212
- "execution": "{model}",
213
- "verification": "{model}"
214
- }
215
- }
84
+ "header": "Profile Type",
85
+ "question": "Select a profile type for model configuration",
86
+ "options": [
87
+ { "label": "Simple", "description": "1 model for all GSD stages (easiest setup)" },
88
+ { "label": "Smart", "description": "2 models: advanced for planning & execution, cheaper for verification" },
89
+ { "label": "Genius", "description": "3 models: different model for each stage" },
90
+ { "label": "Cancel", "description": "Exit without changes" }
91
+ ]
216
92
  }
217
93
  ```
218
94
 
95
+ - If **Cancel** selected: print cancellation message and **stop**.
96
+ - If invalid profile name was provided as positional arg: print `Unknown profile type '{name}'. Valid options: simple, smart, genius` and show this picker.
219
97
 
220
- ## Step 8: Check for changes
221
-
222
- If no changes were made (all stages selected "Keep current"):
223
- ```
224
- No changes made to {targetProfile} profile.
225
- ```
226
- Stop.
227
-
228
- ## Step 9: Save changes
229
-
230
- Use the **write tool directly** to update files. Do NOT use bash, python, or other scripts—use native file writing.
98
+ ## Step 3: Model selection
231
99
 
232
- 1. **Update .planning/config.json:**
100
+ Based on the selected profile type, collect model choices. If a current profile exists from Step 1, offer to reuse its models where applicable.
233
101
 
234
- - Set `config.profiles.presets[targetProfile].planning` to selected value
235
- - Set `config.profiles.presets[targetProfile].execution` to selected value
236
- - Set `config.profiles.presets[targetProfile].verification` to selected value
237
- - write the config file (preserve all other keys)
102
+ ### Simple (1 model)
238
103
 
239
- 2. **Update opencode.json (only if targetProfile is active):**
104
+ Ask the user (via question tool) if they want to keep the current model (only if one exists from Step 1).
105
+ - **Yes:** Use existing model for all three stages. Go to Step 4.
106
+ - **No** (or no current model exists): Load the `gsd-oc-select-model` skill. Select one model for "Simple Profile - All stages".
240
107
 
241
- Check if `config.profiles.active_profile === targetProfile`. If so, regenerate `opencode.json` with the new effective models.
108
+ Assign the selected model to `planning`, `execution`, and `verification`.
242
109
 
243
- Compute effective models (preset + overrides):
244
- ```
245
- overrides = config.profiles.genius_overrides[targetProfile] || {}
246
- effective.planning = overrides.planning || newPreset.planning
247
- effective.execution = overrides.execution || newPreset.execution
248
- effective.verification = overrides.verification || newPreset.verification
249
- ```
110
+ ### Smart (2 models)
250
111
 
251
- Build agent config:
112
+ Load the `gsd-oc-select-model` skill, then:
252
113
 
253
- ```json
254
- {
255
- "$schema": "https://opencode.ai/config.json",
256
- "agent": {
257
- "gsd-planner": { "model": "{effective.planning}" },
258
- "gsd-plan-checker": { "model": "{effective.planning}" },
259
- "gsd-phase-researcher": { "model": "{effective.planning}" },
260
- "gsd-roadmapper": { "model": "{effective.planning}" },
261
- "gsd-project-researcher": { "model": "{effective.planning}" },
262
- "gsd-research-synthesizer": { "model": "{effective.planning}" },
263
- "gsd-codebase-mapper": { "model": "{effective.planning}" },
264
- "gsd-executor": { "model": "{effective.execution}" },
265
- "gsd-debugger": { "model": "{effective.execution}" },
266
- "gsd-verifier": { "model": "{effective.verification}" },
267
- "gsd-integration-checker": { "model": "{effective.verification}" },
268
- }
269
- }
270
- ```
114
+ 1. Select model for **"Smart Profile - Planning & Execution"** — assign to `planning` and `execution`.
115
+ 2. Select model for **"Smart Profile - Verification"** — assign to `verification`.
271
116
 
272
- If `opencode.json` already exists, merge the `agent` key (preserve other top-level keys).
117
+ ### Genius (3 models)
273
118
 
274
- ## Step 10: Report success
119
+ Load the `gsd-oc-select-model` skill, then:
275
120
 
276
- ```text
277
- Updated {targetProfile} profile:
121
+ 1. Select model for **"Genius Profile - Planning"** — assign to `planning`.
122
+ 2. Select model for **"Genius Profile - Execution"** — assign to `execution`.
123
+ 3. Select model for **"Genius Profile - Verification"** — assign to `verification`.
278
124
 
279
- | Stage | Model |
280
- |--------------|-------|
281
- | planning | {newPreset.planning} |
282
- | execution | {newPreset.execution} |
283
- | verification | {newPreset.verification} |
284
- ```
125
+ ## Step 4: Apply changes
285
126
 
286
- If `targetProfile` is the active profile:
287
- ```text
288
- Note: This is your active profile. Quit and relaunch OpenCode to apply model changes.
289
- ```
127
+ Using the collected values (`profile_name`, `model_for_planning_stage`, `model_for_execution_stage`, `model_for_verification_stage`), execute:
290
128
 
291
- If `targetProfile` is NOT the active profile:
292
- ```text
293
- To use this profile, run: /gsd-set-profile {targetProfile}
129
+ ```bash
130
+ node ~/.config/opencode/get-shit-done/bin/gsd-oc-tools.cjs set-profile '{profile_name}:{"planning": "{model_for_planning_stage}", "execution": "{model_for_execution_stage}", "verification": "{model_for_verification_stage}"}'
294
131
  ```
295
132
 
296
- </behavior>
133
+ Parse the response. On success, the CLI updates both `.planning/oc_config.json` and `opencode.json` (with automatic backup).
297
134
 
135
+ ## Step 5: Confirm result
298
136
 
299
- Parse output and write to `opencode.json`, merging with existing content.
137
+ Display the updated profile using the Output Format, prefixed with a checkmark:
300
138
 
301
- Note: Quit and relaunch OpenCode to apply model changes.
302
139
  ```
140
+ Done! Updated {profile_name} profile:
303
141
 
304
- If migration occurred:
305
- ```
306
- Auto-migrated from {old_profile} to genius profile
142
+ | Stage | Model |
143
+ |--------------|-------|
144
+ | Planning | {models.planning} |
145
+ | Execution | {models.execution} |
146
+ | Verification | {models.verification} |
307
147
  ```
308
148
 
149
+ We just updated the `./opencode.json` file. Apply the agent settings you need to **restart your opencode**.
150
+
309
151
  </behavior>
310
152
 
311
153
  <notes>
312
- - Use question tool for ALL user input
313
- - Always show full model IDs (e.g., `opencode/glm-4.7-free`)
314
- - Preserve all other config.json keys when writing
315
- - Do NOT rewrite agent .md files only update opencode.json
316
- - If opencode.json doesn't exist, create it
317
- - **Source of truth:** `config.json` stores profile_type and models; `opencode.json` is derived
318
- - When migrating, preserve old model_profile field for backward compat during transition
319
- - Model selection uses gsd-oc-select-model skill
154
+ - Use the question tool for ALL user input — never prompt via text.
155
+ - Always display full model IDs (e.g., `bailian-coding-plan/qwen3-coder-plus`), never abbreviate.
156
+ - All file reads/writes go through `gsd-oc-tools.cjs` do not manually edit JSON files.
157
+ - Backups are created automatically by the CLI when writing changes.
158
+ - `.planning/oc_config.json` is the source of truth; `opencode.json` is always derived from it.
159
+ - The `gsd-oc-select-model` skill handles paginated provider/model browsing — load it via the skill tool when model selection is needed.
320
160
  </notes>
@@ -45,7 +45,7 @@ question([
45
45
  options: [
46
46
  { label: "Simple", description: "One model for all agents (not flexible)" },
47
47
  { label: "Smart (Recommended)", description: "Two models: one for reseach and planing, other for execution and verification" },
48
- { label: "Custom (most flexible)", description: "Three models: different for every stage" }
48
+ { label: "Genius (most flexible)", description: "Three models: different for every stage" }
49
49
  ]
50
50
  },
51
51
  {
@@ -113,7 +113,7 @@ Merge new settings into existing config.json:
113
113
  ```json
114
114
  {
115
115
  ...existing_config,
116
- "model_profile": "simple" | "smart" | "custom",
116
+ "model_profile": "simple" | "smart" | "genius",
117
117
  "workflow": {
118
118
  "research": true/false,
119
119
  "plan_check": true/false,
@@ -128,6 +128,7 @@ Merge new settings into existing config.json:
128
128
  ```
129
129
 
130
130
  write updated config to `.planning/config.json`.
131
+
131
132
  </step>
132
133
 
133
134
  <step name="save_as_defaults">
@@ -183,7 +184,7 @@ Display:
183
184
 
184
185
  | Setting | Value |
185
186
  |----------------------|-------|
186
- | Model Profile | {simple/smart/custom} |
187
+ | Model Profile | {simple/smart/genius} |
187
188
  | Plan Researcher | {On/Off} |
188
189
  | Plan Checker | {On/Off} |
189
190
  | Execution Verifier | {On/Off} |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gsd-opencode",
3
- "version": "1.20.2",
3
+ "version": "1.20.3",
4
4
  "description": "GSD-OpenCode distribution manager - install, verify, and maintain your GSD-OpenCode installation",
5
5
  "type": "module",
6
6
  "main": "bin/gsd.js",
@@ -51,6 +51,6 @@
51
51
  "ora": "^9.3.0"
52
52
  },
53
53
  "devDependencies": {
54
- "vitest": "^3.0.0"
54
+ "vitest": "^3.2.4"
55
55
  }
56
56
  }