gsd-opencode 1.20.2 → 1.20.4

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 (27) hide show
  1. package/commands/gsd/gsd-check-profile.md +30 -0
  2. package/get-shit-done/bin/gsd-oc-commands/allow-read-config.cjs +235 -0
  3. package/get-shit-done/bin/gsd-oc-commands/check-oc-config-json.cjs +169 -0
  4. package/get-shit-done/bin/gsd-oc-commands/check-opencode-json.cjs +86 -0
  5. package/get-shit-done/bin/gsd-oc-commands/get-profile.cjs +117 -0
  6. package/get-shit-done/bin/gsd-oc-commands/set-profile.cjs +357 -0
  7. package/get-shit-done/bin/gsd-oc-commands/update-opencode-json.cjs +199 -0
  8. package/get-shit-done/bin/gsd-oc-commands/validate-models.cjs +75 -0
  9. package/get-shit-done/bin/gsd-oc-lib/oc-config.cjs +205 -0
  10. package/get-shit-done/bin/gsd-oc-lib/oc-core.cjs +113 -0
  11. package/get-shit-done/bin/gsd-oc-lib/oc-models.cjs +133 -0
  12. package/get-shit-done/bin/gsd-oc-lib/oc-profile-config.cjs +409 -0
  13. package/get-shit-done/bin/gsd-oc-tools.cjs +136 -0
  14. package/get-shit-done/bin/lib/oc-config.cjs +200 -0
  15. package/get-shit-done/bin/lib/oc-core.cjs +114 -0
  16. package/get-shit-done/bin/lib/oc-models.cjs +133 -0
  17. package/get-shit-done/bin/test/allow-read-config.test.cjs +262 -0
  18. package/get-shit-done/bin/test/fixtures/oc-config-invalid.json +14 -0
  19. package/get-shit-done/bin/test/fixtures/oc-config-valid.json +22 -0
  20. package/get-shit-done/bin/test/get-profile.test.cjs +447 -0
  21. package/get-shit-done/bin/test/oc-profile-config.test.cjs +377 -0
  22. package/get-shit-done/bin/test/pivot-profile.test.cjs +276 -0
  23. package/get-shit-done/bin/test/set-profile.test.cjs +301 -0
  24. package/get-shit-done/workflows/oc-check-profile.md +181 -0
  25. package/get-shit-done/workflows/oc-set-profile.md +98 -234
  26. package/get-shit-done/workflows/settings.md +4 -3
  27. package/package.json +2 -2
@@ -3,20 +3,20 @@
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
+ - `opencode.json` — external_directory permissions for reading GSD config folder (added automatically)
8
9
 
9
- Do NOT modify agent .md files. Profile switching updates `opencode.json` in the project root.
10
+ Do NOT modify agent .md files. Profile switching only updates these two JSON files.
10
11
  </role>
11
12
 
12
13
  <context>
13
- **Invocation styles:**
14
+ ## Invocation
14
15
 
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`
16
+ 1. **Interactive wizard (no args):** `/gsd-set-profile`
17
+ 2. **Direct switch (positional arg):** `/gsd-set-profile simple|smart|genius`
18
18
 
19
- **Stage-to-agent mapping (11 agents):**
19
+ ## Stage-to-Agent Mapping (11 agents)
20
20
 
21
21
  | Stage | Agents |
22
22
  |--------------|--------|
@@ -24,297 +24,161 @@ Do NOT modify agent .md files. Profile switching updates `opencode.json` in the
24
24
  | Execution | gsd-executor, gsd-debugger |
25
25
  | Verification | gsd-verifier, gsd-integration-checker |
26
26
 
27
- **Profile types:**
27
+ ## Profile Types
28
28
 
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
29
+ | Profile | Models | Stage assignment |
30
+ |----------|--------|-----------------|
31
+ | Simple | 1 | All stages use the same model |
32
+ | Smart | 2 | Planning + Execution share one model; Verification uses a different model |
33
+ | Genius | 3 | Each stage uses a different model |
32
34
 
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)
35
+ ## Output Format (reused throughout)
56
36
 
57
-
58
- ## Step 3: Display current state
59
-
60
- If profile exists:
37
+ When displaying profile state, always use this format:
61
38
 
62
39
  ```
63
- Active profile: {profile_type}
40
+ Active profile: **{profile_name}**
64
41
 
65
- Current configuration:
66
42
  | Stage | Model |
67
43
  |--------------|-------|
68
- | planning | {models.planning} |
69
- | execution | {models.execution} |
70
- | verification | {models.verification} |
44
+ | Planning | {models.planning} |
45
+ | Execution | {models.execution} |
46
+ | Verification | {models.verification} |
71
47
  ```
48
+ </context>
72
49
 
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`
50
+ <behavior>
77
51
 
78
- **B) Interactive picker (no args):**
52
+ ## Step 0: Ensure GSD config read permission
79
53
 
80
- Use question tool:
54
+ Before any profile operations, ensure opencode.json has permission to read the GSD config folder:
81
55
 
56
+ ```bash
57
+ node ~/.config/opencode/get-shit-done/bin/gsd-oc-tools.cjs allow-read-config --dry-run
82
58
  ```
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"
94
- ```
95
-
96
- If Cancel selected, print cancellation message and stop.
97
-
98
- **C) Invalid profile handling:**
99
59
 
100
- If invalid profile name:
101
- - Print: `Unknown profile type '{name}'. Valid options: simple, smart, genius`
102
- - Fall back to interactive picker
103
-
104
- ## Step 5: Handle --reuse flag
105
-
106
- If `--reuse` flag present and current profile exists:
60
+ Parse the response:
61
+ - **`success: true` with `action: "permission_exists"`** — Permission already configured. Continue to Step 1.
62
+ - **`success: true` with `action: "add_permission"`** — Permission would be added. Execute without `--dry-run`:
107
63
 
64
+ Attempt to switch to the saved profile:
108
65
  ```bash
109
- node gsd-opencode/get-shit-done/bin/gsd-tools.cjs profile-switch {newProfileType} --reuse --raw
66
+ node ~/.config/opencode/get-shit-done/bin/gsd-oc-tools.cjs allow-read-config
110
67
  ```
111
68
 
112
- Parse the reuse analysis:
113
- - Shows which stages can reuse existing models
114
- - Displays suggestions for each stage
69
+ - **`success: false`** — Handle error appropriately.
115
70
 
116
- Present to user:
71
+ This ensures gsd-opencode can access workflow files, templates, and configuration from `~/.config/opencode/get-shit-done/`.
117
72
 
118
- ```
119
- Model Reuse Analysis for {newProfileType} profile:
73
+ ## Step 1: Load current profile
120
74
 
121
- Current models:
122
- - Planning: {current.planning}
123
- - Execution: {current.execution}
124
- - Verification: {current.verification}
75
+ Run `get-profile` to read the current state from `.planning/oc_config.json`:
125
76
 
126
- Suggested reuse:
127
- {reuse analysis from tool}
128
-
129
- Use these suggestions? (yes/no)
77
+ ```bash
78
+ node ~/.config/opencode/get-shit-done/bin/gsd-oc-tools.cjs get-profile
130
79
  ```
131
80
 
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"
152
-
153
- **Second model** (verification):
154
-
155
- Use gsd-oc-select-model skill to select model for "Smart Profile - Verification"
156
-
157
- Store selected models.
158
-
159
- Planning + Execution will use First model selected.
160
- Verification will use Second model selected.
81
+ Parse the JSON response:
161
82
 
83
+ - **`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.
84
+ - **`success: false` with `CONFIG_NOT_FOUND`** — No profile exists yet. Skip display, go directly to Step 2.
162
85
 
163
- ### Genius Profile (3 models)
86
+ ## Step 2: Determine target profile
164
87
 
165
- Use gsd-oc-select-model skill
88
+ ### Path A — Positional argument provided
166
89
 
90
+ If the user typed `/gsd-set-profile {type}` where `{type}` is one of `simple`, `smart`, `genius`:
167
91
 
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:
191
-
92
+ Attempt to switch to the saved profile:
192
93
  ```bash
193
- opencode models | grep -q "^{model}$" && echo "valid" || echo "invalid"
94
+ node ~/.config/opencode/get-shit-done/bin/gsd-oc-tools.cjs set-profile {type}
194
95
  ```
195
96
 
196
- If any model invalid:
197
- - Print error with list of missing models
198
- - Stop. Do NOT write config files.
97
+ - **`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.**
98
+ - **`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).
199
99
 
200
- ## Step 8: Apply changes
100
+ ### Path B No argument (interactive wizard)
201
101
 
202
- ### Save config.json
203
-
204
- Save config.json Or build and save manually:
102
+ Prompt the user to choose a profile type using the question tool:
205
103
 
206
104
  ```json
207
105
  {
208
- "profiles": {
209
- "profile_type": "{simple|smart|genius}",
210
- "models": {
211
- "planning": "{model}",
212
- "execution": "{model}",
213
- "verification": "{model}"
214
- }
215
- }
106
+ "header": "Profile Type",
107
+ "question": "Select a profile type for model configuration",
108
+ "options": [
109
+ { "label": "Simple", "description": "1 model for all GSD stages (easiest setup)" },
110
+ { "label": "Smart", "description": "2 models: advanced for planning & execution, cheaper for verification" },
111
+ { "label": "Genius", "description": "3 models: different model for each stage" },
112
+ { "label": "Cancel", "description": "Exit without changes" }
113
+ ]
216
114
  }
217
115
  ```
218
116
 
117
+ - If **Cancel** selected: print cancellation message and **stop**.
118
+ - If invalid profile name was provided as positional arg: print `Unknown profile type '{name}'. Valid options: simple, smart, genius` and show this picker.
219
119
 
220
- ## Step 8: Check for changes
120
+ ## Step 3: Model selection
221
121
 
222
- If no changes were made (all stages selected "Keep current"):
223
- ```
224
- No changes made to {targetProfile} profile.
225
- ```
226
- Stop.
122
+ Based on the selected profile type, collect model choices. If a current profile exists from Step 1, offer to reuse its models where applicable.
227
123
 
228
- ## Step 9: Save changes
124
+ ### Simple (1 model)
229
125
 
230
- Use the **write tool directly** to update files. Do NOT use bash, python, or other scripts—use native file writing.
126
+ Ask the user (via question tool) if they want to keep the current model (only if one exists from Step 1).
127
+ - **Yes:** Use existing model for all three stages. Go to Step 4.
128
+ - **No** (or no current model exists): Load the `gsd-oc-select-model` skill. Select one model for "Simple Profile - All stages".
231
129
 
232
- 1. **Update .planning/config.json:**
130
+ Assign the selected model to `planning`, `execution`, and `verification`.
233
131
 
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)
132
+ ### Smart (2 models)
238
133
 
239
- 2. **Update opencode.json (only if targetProfile is active):**
134
+ Load the `gsd-oc-select-model` skill, then:
240
135
 
241
- Check if `config.profiles.active_profile === targetProfile`. If so, regenerate `opencode.json` with the new effective models.
136
+ 1. Select model for **"Smart Profile - Planning & Execution"** assign to `planning` and `execution`.
137
+ 2. Select model for **"Smart Profile - Verification"** — assign to `verification`.
242
138
 
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
- ```
139
+ ### Genius (3 models)
250
140
 
251
- Build agent config:
141
+ Load the `gsd-oc-select-model` skill, then:
252
142
 
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
- ```
143
+ 1. Select model for **"Genius Profile - Planning"** — assign to `planning`.
144
+ 2. Select model for **"Genius Profile - Execution"** — assign to `execution`.
145
+ 3. Select model for **"Genius Profile - Verification"** — assign to `verification`.
271
146
 
272
- If `opencode.json` already exists, merge the `agent` key (preserve other top-level keys).
147
+ ## Step 4: Apply changes
273
148
 
274
- ## Step 10: Report success
149
+ Using the collected values (`profile_name`, `model_for_planning_stage`, `model_for_execution_stage`, `model_for_verification_stage`), execute:
275
150
 
276
- ```text
277
- Updated {targetProfile} profile:
278
-
279
- | Stage | Model |
280
- |--------------|-------|
281
- | planning | {newPreset.planning} |
282
- | execution | {newPreset.execution} |
283
- | verification | {newPreset.verification} |
284
- ```
285
-
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
- ```
290
-
291
- If `targetProfile` is NOT the active profile:
292
- ```text
293
- To use this profile, run: /gsd-set-profile {targetProfile}
151
+ ```bash
152
+ 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
153
  ```
295
154
 
296
- </behavior>
155
+ Parse the response. On success, the CLI updates both `.planning/oc_config.json` and `opencode.json` (with automatic backup).
297
156
 
157
+ ## Step 5: Confirm result
298
158
 
299
- Parse output and write to `opencode.json`, merging with existing content.
159
+ Display the updated profile using the Output Format, prefixed with a checkmark:
300
160
 
301
- Note: Quit and relaunch OpenCode to apply model changes.
302
161
  ```
162
+ Done! Updated {profile_name} profile:
303
163
 
304
- If migration occurred:
305
- ```
306
- Auto-migrated from {old_profile} to genius profile
164
+ | Stage | Model |
165
+ |--------------|-------|
166
+ | Planning | {models.planning} |
167
+ | Execution | {models.execution} |
168
+ | Verification | {models.verification} |
307
169
  ```
308
170
 
171
+ We just updated the `./opencode.json` file. Apply the agent settings you need to **restart your opencode**.
172
+
173
+ Note: GSD config read permission has been configured to allow access to `~/.config/opencode/get-shit-done/`.
174
+
309
175
  </behavior>
310
176
 
311
177
  <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
178
+ - Use the question tool for ALL user input — never prompt via text.
179
+ - Always display full model IDs (e.g., `bailian-coding-plan/qwen3-coder-plus`), never abbreviate.
180
+ - All file reads/writes go through `gsd-oc-tools.cjs` do not manually edit JSON files.
181
+ - Backups are created automatically by the CLI when writing changes.
182
+ - `.planning/oc_config.json` is the source of truth; `opencode.json` is always derived from it.
183
+ - The `gsd-oc-select-model` skill handles paginated provider/model browsing — load it via the skill tool when model selection is needed.
320
184
  </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.4",
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
  }