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
@@ -0,0 +1,303 @@
1
+ ---
2
+ name: gsd-settings
3
+ description: Interactive settings for model profiles, per-stage overrides, and workflow settings
4
+ tools:
5
+ read: true
6
+ write: true
7
+ bash: true
8
+ question: true
9
+ ---
10
+
11
+ <role>
12
+ You are executing the `/gsd-settings` command. Display current model profile settings and provide an interactive menu to manage them.
13
+
14
+ Files managed:
15
+
16
+ - `.planning/config.json` — profile state and workflow toggles (source of truth)
17
+ - `opencode.json` — agent model assignments (derived from config.json)
18
+
19
+ Do NOT modify agent .md files.
20
+ </role>
21
+
22
+ <context>
23
+ **Stage-to-agent mapping:**
24
+
25
+ - **Planning:** gsd-planner, gsd-plan-checker, gsd-phase-researcher, gsd-roadmapper, gsd-project-researcher, gsd-research-synthesizer, gsd-codebase-mapper
26
+ - **Execution:** gsd-executor, gsd-debugger
27
+ - **Verification:** gsd-verifier, gsd-integration-checker, gsd-set-profile, gsd-settings, gsd-set-model
28
+
29
+ **Model discovery:** Presets are user-defined, not hardcoded. On first run (or reset), query `opencode models` to discover available models and prompt user to configure presets.
30
+ </context>
31
+
32
+ <rules>
33
+ **UI Rules (apply throughout):**
34
+
35
+ - Always use the Question tool for user input — never print menus as text
36
+ - Custom/freeform answers are not allowed; re-prompt on invalid selection
37
+ - Apply changes immediately without extra confirmation prompts
38
+ - After any action except Exit, return to the main menu (Step 3 → Step 4)
39
+
40
+ **Config Rules:**
41
+
42
+ - Never overwrite existing presets — only create defaults for new/migrated projects
43
+ - Keep `model_profile` in sync with `profiles.active_profile`
44
+ - Merge into existing `opencode.json` (preserve non-agent keys)
45
+ </rules>
46
+
47
+ <behavior>
48
+
49
+ ## Step 1: Load Config
50
+
51
+ ```bash
52
+ ls .planning/ 2>/dev/null
53
+ ```
54
+
55
+ If `.planning/` not found: print `Error: No GSD project found. Run /gsd-new-project first.` and stop.
56
+
57
+ ```bash
58
+ cat .planning/config.json 2>/dev/null
59
+ ```
60
+
61
+ Handle config state:
62
+
63
+ - **Missing/invalid:** Run **Preset Setup Wizard** (see below), then continue
64
+ - **Legacy (no `profiles` key):** Run **Preset Setup Wizard**, preserve other existing keys
65
+ - **Current:** Use as-is
66
+
67
+ Ensure `workflow` section exists (defaults: `research: true`, `plan_check: true`, `verifier: true`).
68
+
69
+ ### Preset Setup Wizard
70
+
71
+ This wizard runs on first use or when "Reset presets" is selected. It queries available models and lets the user configure all three profiles.
72
+
73
+ **Step W1: Discover models**
74
+
75
+ ```bash
76
+ opencode models 2>/dev/null
77
+ ```
78
+
79
+ Parse the output to extract model IDs. If command fails or returns no models, print `Error: Could not fetch available models. Check your OpenCode installation.` and stop.
80
+
81
+ **Step W2: Configure each profile**
82
+
83
+ For each profile (quality, balanced, budget), use a multi-question call:
84
+
85
+ ```json
86
+ [
87
+ { "header": "{Profile} Profile - Planning", "question": "Which model for planning agents?", "options": ["{model1}", "{model2}", ...] },
88
+ { "header": "{Profile} Profile - Execution", "question": "Which model for execution agents?", "options": ["{model1}", "{model2}", ...] },
89
+ { "header": "{Profile} Profile - Verification", "question": "Which model for verification agents?", "options": ["{model1}", "{model2}", ...] }
90
+ ]
91
+ ```
92
+
93
+ **Step W3: Save config**
94
+
95
+ Create config with user selections:
96
+
97
+ ```json
98
+ {
99
+ "profiles": {
100
+ "active_profile": "balanced",
101
+ "presets": {
102
+ "quality": { "planning": "{user_selection}", "execution": "{user_selection}", "verification": "{user_selection}" },
103
+ "balanced": { "planning": "{user_selection}", "execution": "{user_selection}", "verification": "{user_selection}" },
104
+ "budget": { "planning": "{user_selection}", "execution": "{user_selection}", "verification": "{user_selection}" }
105
+ },
106
+ "custom_overrides": { "quality": {}, "balanced": {}, "budget": {} }
107
+ },
108
+ "workflow": { "research": true, "plan_check": true, "verifier": true }
109
+ }
110
+ ```
111
+
112
+ Print:
113
+
114
+ ```text
115
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
116
+ GSD ► PRESETS CONFIGURED
117
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
118
+
119
+ Your model presets have been saved. Use "Reset presets"
120
+ from the settings menu if available models change.
121
+
122
+ Note: Quit and relaunch OpenCode to apply model changes.
123
+ ```
124
+
125
+ ## Step 2: Compute Effective Models
126
+
127
+ ```text
128
+ activeProfile = config.profiles.active_profile
129
+ preset = config.profiles.presets[activeProfile]
130
+ overrides = config.profiles.custom_overrides[activeProfile] || {}
131
+
132
+ effective.planning = overrides.planning || preset.planning
133
+ effective.execution = overrides.execution || preset.execution
134
+ effective.verification = overrides.verification || preset.verification
135
+ ```
136
+
137
+ A stage is "overridden" if `overrides[stage]` exists and differs from `preset[stage]`.
138
+
139
+ ## Step 3: Display State
140
+
141
+ **Print this as text output (do NOT use Question tool here):**
142
+
143
+ ```text
144
+ Active profile: {activeProfile}
145
+
146
+ | Stage | Model |
147
+ |--------------|------------------------------------------|
148
+ | planning | {effective.planning}{* if overridden} |
149
+ | execution | {effective.execution}{* if overridden} |
150
+ | verification | {effective.verification}{* if overridden}|
151
+
152
+ {if any overridden: "* = overridden" else: "No overrides"}
153
+
154
+ Workflow:
155
+ | Toggle | Value |
156
+ |------------|------------------------|
157
+ | research | {workflow.research} |
158
+ | plan_check | {workflow.plan_check} |
159
+ | verifier | {workflow.verifier} |
160
+ ```
161
+
162
+ ## Step 4: Show Menu
163
+
164
+ Use Question tool (single prompt, not multi-question):
165
+
166
+ ```
167
+ header: "GSD Settings"
168
+ question: "Choose an action"
169
+ options:
170
+ - label: "Quick settings"
171
+ description: "Update profile and workflow toggles"
172
+ - label: "Set stage override"
173
+ description: "Set a per-stage model override for the active profile"
174
+ - label: "Clear stage override"
175
+ description: "Remove a per-stage override for the active profile"
176
+ - label: "Reset presets"
177
+ description: "Re-run model discovery and reconfigure all presets (clears overrides)"
178
+ - label: "Exit"
179
+ description: "Save and quit"
180
+ ```
181
+
182
+ ## Step 5: Handle Actions
183
+
184
+ ### Quick settings
185
+
186
+ Use multi-question call with pre-selected current values:
187
+
188
+ ```json
189
+ [
190
+ { "header": "Model", "question": "Which model profile?", "options": ["Quality", "Balanced", "Budget"] },
191
+ { "header": "Research", "question": "Spawn Plan Researcher?", "options": ["Yes", "No"] },
192
+ { "header": "Plan Check", "question": "Spawn Plan Checker?", "options": ["Yes", "No"] },
193
+ { "header": "Verifier", "question": "Spawn Execution Verifier?", "options": ["Yes", "No"] }
194
+ ]
195
+ ```
196
+
197
+ On selection:
198
+
199
+ - Map: Quality→`quality`, Balanced→`balanced`, Budget→`budget`
200
+ - Set `profiles.active_profile`, `model_profile`, and `workflow.*` accordingly
201
+ - Quick settings does NOT modify `presets` or `custom_overrides`
202
+ - If nothing changed, print `No changes.` and return to menu
203
+ - Otherwise save and print confirmation banner:
204
+
205
+ ```text
206
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
207
+ GSD ► SETTINGS UPDATED
208
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
209
+
210
+ | Setting | Value |
211
+ |--------------------|---------------------------|
212
+ | Model Profile | {quality|balanced|budget} |
213
+ | Plan Researcher | {On/Off} |
214
+ | Plan Checker | {On/Off} |
215
+ | Execution Verifier | {On/Off} |
216
+
217
+ Note: Quit and relaunch OpenCode to apply model changes.
218
+
219
+ Quick commands:
220
+ - /gsd-set-profile <profile>
221
+ - /gsd-plan-phase --research | --skip-research | --skip-verify
222
+ ```
223
+
224
+ ### Set stage override
225
+
226
+ 1. Pick stage: Planning / Execution / Verification / Cancel
227
+ 2. If Cancel, return to menu
228
+ 3. Fetch models via `opencode models` command
229
+ 4. If command fails: print error and stop
230
+ 5. Pick model from list (include Cancel option)
231
+ 6. Set `custom_overrides[activeProfile][stage]` = model
232
+ 7. Save, print "Saved", return to menu
233
+
234
+ ### Clear stage override
235
+
236
+ If no overrides exist for current profile, print `No overrides set for {activeProfile} profile.` and return to menu immediately.
237
+
238
+ Otherwise:
239
+
240
+ 1. Print current overrides:
241
+
242
+ ```text
243
+ Current overrides for {activeProfile} profile:
244
+ - planning: {model} (or omit if not overridden)
245
+ - execution: {model} (or omit if not overridden)
246
+ - verification: {model} (or omit if not overridden)
247
+ ```
248
+
249
+ 2. Pick stage: Planning / Execution / Verification / Cancel (only show stages that have overrides)
250
+ 3. If Cancel, return to menu
251
+ 4. Delete `custom_overrides[activeProfile][stage]`
252
+ 5. Save, print "Cleared {stage} override.", return to menu
253
+
254
+ ### Reset presets
255
+
256
+ Run the **Preset Setup Wizard** (see Step 1). This re-queries available models and lets the user reconfigure all three profiles from scratch. Existing `custom_overrides` are cleared. After completion, return to menu.
257
+
258
+ ### Exit
259
+
260
+ Print "Settings saved." and stop.
261
+
262
+ ## Save Changes
263
+
264
+ After any change, use the **write tool directly** to update both files. Do NOT use bash, python, or other scripts—use native file writing.
265
+
266
+ 1. Read existing `opencode.json` (if it exists) to preserve non-agent keys
267
+ 2. Write `.planning/config.json` with updated config
268
+ 3. Write `opencode.json` with merged agent mappings:
269
+
270
+ ```json
271
+ {
272
+ "$schema": "https://opencode.ai/config.json",
273
+ "agent": {
274
+ "gsd-planner": { "model": "{effective.planning}" },
275
+ "gsd-plan-checker": { "model": "{effective.planning}" },
276
+ "gsd-phase-researcher": { "model": "{effective.planning}" },
277
+ "gsd-roadmapper": { "model": "{effective.planning}" },
278
+ "gsd-project-researcher": { "model": "{effective.planning}" },
279
+ "gsd-research-synthesizer": { "model": "{effective.planning}" },
280
+ "gsd-codebase-mapper": { "model": "{effective.planning}" },
281
+ "gsd-executor": { "model": "{effective.execution}" },
282
+ "gsd-debugger": { "model": "{effective.execution}" },
283
+ "gsd-verifier": { "model": "{effective.verification}" },
284
+ "gsd-integration-checker": { "model": "{effective.verification}" },
285
+ "gsd-set-profile": { "model": "{effective.verification}" },
286
+ "gsd-settings": { "model": "{effective.verification}" },
287
+ "gsd-set-model": { "model": "{effective.verification}" }
288
+ }
289
+ }
290
+ ```
291
+
292
+ Preserve existing non-agent keys in `opencode.json`.
293
+
294
+ </behavior>
295
+
296
+ <notes>
297
+
298
+ - Menu loop until Exit — always return to Step 3 after actions
299
+ - Overrides are profile-scoped: `custom_overrides.{profile}.{stage}`
300
+ - Source of truth: `config.json`; `opencode.json` is derived
301
+ - OpenCode does not hot-reload model assignments; user must quit and relaunch to apply changes
302
+
303
+ </notes>
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Legacy compatibility shim for GSD-OpenCode CLI.
5
+ *
6
+ * This module maintains backward compatibility with the original CLI invocation
7
+ * patterns. It transforms legacy-style arguments to the new subcommand format
8
+ * and delegates to the main CLI entry point (gsd.js).
9
+ *
10
+ * Legacy patterns supported:
11
+ * - gsd-opencode --global -> gsd-opencode install --global
12
+ * - gsd-opencode --local -> gsd-opencode install --local
13
+ * - gsd-opencode -c /custom/path -> gsd-opencode install --config-dir /custom/path
14
+ * - gsd-opencode (no args) -> gsd-opencode install (interactive)
15
+ *
16
+ * This shim allows existing users and scripts to continue working without
17
+ * modification while the new subcommand interface is the preferred approach.
18
+ *
19
+ * @module gsd-install
20
+ * @deprecated Use 'gsd-opencode install' directly instead
21
+ */
22
+
23
+ import { fileURLToPath } from 'url';
24
+ import path from 'path';
25
+
26
+ /**
27
+ * Checks if arguments should trigger legacy transformation.
28
+ *
29
+ * Legacy patterns are:
30
+ * - Any flag starting with --global, -g, --local, -l, --config-dir, -c
31
+ * - No arguments at all (defaults to install)
32
+ *
33
+ * @param {string[]} args - Process arguments
34
+ * @returns {boolean} True if legacy pattern detected
35
+ * @private
36
+ */
37
+ function isLegacyPattern(args) {
38
+ const userArgs = args.slice(2);
39
+
40
+ // If no args, treat as legacy (will route to install)
41
+ if (userArgs.length === 0) {
42
+ return true;
43
+ }
44
+
45
+ // Check for legacy flags
46
+ const legacyFlags = ['--global', '-g', '--local', '-l', '--config-dir', '-c'];
47
+ return userArgs.some(arg =>
48
+ legacyFlags.some(flag => arg === flag || arg.startsWith(`${flag}=`))
49
+ );
50
+ }
51
+
52
+ /**
53
+ * Transform legacy arguments to new subcommand format.
54
+ *
55
+ * Adds 'install' as the first argument after the script path.
56
+ *
57
+ * @param {string[]} args - Process arguments
58
+ * @returns {string[]} Transformed arguments
59
+ * @private
60
+ */
61
+ function transformArgs(args) {
62
+ const userArgs = args.slice(2);
63
+
64
+ // If already has 'install', don't transform
65
+ if (userArgs[0] === 'install') {
66
+ return args;
67
+ }
68
+
69
+ // Transform: [flags...] -> ['install', flags...]
70
+ return [...args.slice(0, 2), 'install', ...userArgs];
71
+ }
72
+
73
+ /**
74
+ * Main shim function.
75
+ *
76
+ * Detects legacy patterns, transforms arguments if needed,
77
+ * and requires the main CLI entry point.
78
+ *
79
+ * @returns {void}
80
+ * @private
81
+ */
82
+ function main() {
83
+ const args = process.argv;
84
+
85
+ if (isLegacyPattern(args)) {
86
+ // Transform legacy args to new format
87
+ process.argv = transformArgs(args);
88
+
89
+ // In verbose mode, log the transformation
90
+ if (args.includes('--verbose') || args.includes('-v')) {
91
+ const __filename = fileURLToPath(import.meta.url);
92
+ console.error(`[legacy-shim] Transforming to: ${process.argv.slice(2).join(' ')}`);
93
+ }
94
+ }
95
+
96
+ // Delegate to main CLI
97
+ // Use dynamic import to handle ESM properly
98
+ const __filename = fileURLToPath(import.meta.url);
99
+ const __dirname = path.dirname(__filename);
100
+
101
+ import(path.join(__dirname, 'gsd.js'));
102
+ }
103
+
104
+ // Execute shim
105
+ main();