gsd-opencode 1.20.3 → 1.22.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 (114) hide show
  1. package/agents/gsd-codebase-mapper.md +9 -1
  2. package/agents/gsd-debugger.md +66 -10
  3. package/agents/gsd-executor.md +36 -16
  4. package/agents/gsd-integration-checker.md +2 -0
  5. package/agents/gsd-nyquist-auditor.md +178 -0
  6. package/agents/gsd-phase-researcher.md +28 -34
  7. package/agents/gsd-plan-checker.md +42 -78
  8. package/agents/gsd-planner.md +139 -24
  9. package/agents/gsd-project-researcher.md +11 -1
  10. package/agents/gsd-research-synthesizer.md +13 -3
  11. package/agents/gsd-roadmapper.md +25 -15
  12. package/agents/gsd-verifier.md +29 -6
  13. package/bin/dm/lib/constants.js +6 -1
  14. package/bin/dm/src/services/file-ops.js +14 -1
  15. package/commands/gsd/gsd-add-phase.md +6 -6
  16. package/commands/gsd/gsd-add-tests.md +41 -0
  17. package/commands/gsd/gsd-add-todo.md +7 -7
  18. package/commands/gsd/gsd-audit-milestone.md +9 -9
  19. package/commands/gsd/gsd-check-profile.md +3 -3
  20. package/commands/gsd/gsd-check-todos.md +7 -7
  21. package/commands/gsd/gsd-cleanup.md +2 -2
  22. package/commands/gsd/gsd-complete-milestone.md +6 -6
  23. package/commands/gsd/gsd-debug.md +11 -7
  24. package/commands/gsd/gsd-discuss-phase.md +26 -19
  25. package/commands/gsd/gsd-execute-phase.md +13 -13
  26. package/commands/gsd/gsd-health.md +7 -7
  27. package/commands/gsd/gsd-help.md +2 -2
  28. package/commands/gsd/gsd-insert-phase.md +6 -6
  29. package/commands/gsd/gsd-join-discord.md +1 -1
  30. package/commands/gsd/gsd-list-phase-assumptions.md +6 -6
  31. package/commands/gsd/gsd-map-codebase.md +8 -8
  32. package/commands/gsd/gsd-new-milestone.md +12 -12
  33. package/commands/gsd/gsd-new-project.md +12 -12
  34. package/commands/gsd/gsd-pause-work.md +6 -6
  35. package/commands/gsd/gsd-plan-milestone-gaps.md +9 -9
  36. package/commands/gsd/gsd-plan-phase.md +14 -13
  37. package/commands/gsd/gsd-progress.md +8 -8
  38. package/commands/gsd/gsd-quick.md +17 -13
  39. package/commands/gsd/gsd-reapply-patches.md +19 -11
  40. package/commands/gsd/gsd-remove-phase.md +7 -7
  41. package/commands/gsd/gsd-research-phase.md +12 -11
  42. package/commands/gsd/gsd-resume-work.md +8 -8
  43. package/commands/gsd/gsd-set-profile.md +6 -6
  44. package/commands/gsd/gsd-settings.md +7 -7
  45. package/commands/gsd/gsd-update.md +5 -5
  46. package/commands/gsd/gsd-validate-phase.md +35 -0
  47. package/commands/gsd/gsd-verify-work.md +11 -11
  48. package/get-shit-done/bin/gsd-oc-commands/allow-read-config.cjs +235 -0
  49. package/get-shit-done/bin/gsd-oc-tools.cjs +11 -5
  50. package/get-shit-done/bin/gsd-tools.cjs +45 -6
  51. package/get-shit-done/bin/lib/commands.cjs +11 -19
  52. package/get-shit-done/bin/lib/config.cjs +8 -1
  53. package/get-shit-done/bin/lib/core.cjs +131 -16
  54. package/get-shit-done/bin/lib/init.cjs +28 -12
  55. package/get-shit-done/bin/lib/milestone.cjs +34 -8
  56. package/get-shit-done/bin/lib/phase.cjs +74 -50
  57. package/get-shit-done/bin/lib/roadmap.cjs +7 -7
  58. package/get-shit-done/bin/lib/state.cjs +294 -63
  59. package/get-shit-done/bin/lib/template.cjs +3 -3
  60. package/get-shit-done/bin/lib/verify.cjs +56 -8
  61. package/get-shit-done/bin/test/allow-read-config.test.cjs +262 -0
  62. package/get-shit-done/references/checkpoints.md +1 -1
  63. package/get-shit-done/references/decimal-phase-calculation.md +6 -6
  64. package/get-shit-done/references/git-integration.md +3 -3
  65. package/get-shit-done/references/git-planning-commit.md +2 -2
  66. package/get-shit-done/references/model-profile-resolution.md +1 -1
  67. package/get-shit-done/references/model-profiles.md +1 -0
  68. package/get-shit-done/references/phase-argument-parsing.md +4 -4
  69. package/get-shit-done/references/planning-config.md +10 -6
  70. package/get-shit-done/references/questioning.md +17 -0
  71. package/get-shit-done/references/verification-patterns.md +1 -1
  72. package/get-shit-done/templates/DEBUG.md +7 -2
  73. package/get-shit-done/templates/VALIDATION.md +18 -46
  74. package/get-shit-done/templates/codebase/structure.md +3 -3
  75. package/get-shit-done/templates/config.json +2 -2
  76. package/get-shit-done/templates/context.md +14 -0
  77. package/get-shit-done/templates/phase-prompt.md +10 -10
  78. package/get-shit-done/templates/retrospective.md +54 -0
  79. package/get-shit-done/templates/roadmap.md +1 -1
  80. package/get-shit-done/workflows/add-phase.md +3 -2
  81. package/get-shit-done/workflows/add-tests.md +351 -0
  82. package/get-shit-done/workflows/add-todo.md +4 -3
  83. package/get-shit-done/workflows/audit-milestone.md +40 -5
  84. package/get-shit-done/workflows/check-todos.md +3 -2
  85. package/get-shit-done/workflows/cleanup.md +1 -1
  86. package/get-shit-done/workflows/complete-milestone.md +69 -5
  87. package/get-shit-done/workflows/diagnose-issues.md +2 -2
  88. package/get-shit-done/workflows/discovery-phase.md +6 -6
  89. package/get-shit-done/workflows/discuss-phase.md +194 -58
  90. package/get-shit-done/workflows/execute-phase.md +29 -23
  91. package/get-shit-done/workflows/execute-plan.md +22 -18
  92. package/get-shit-done/workflows/health.md +5 -2
  93. package/get-shit-done/workflows/help.md +4 -1
  94. package/get-shit-done/workflows/insert-phase.md +3 -2
  95. package/get-shit-done/workflows/map-codebase.md +3 -2
  96. package/get-shit-done/workflows/new-milestone.md +12 -10
  97. package/get-shit-done/workflows/new-project.md +44 -49
  98. package/get-shit-done/workflows/oc-set-profile.md +24 -0
  99. package/get-shit-done/workflows/pause-work.md +2 -2
  100. package/get-shit-done/workflows/plan-milestone-gaps.md +3 -3
  101. package/get-shit-done/workflows/plan-phase.md +155 -73
  102. package/get-shit-done/workflows/progress.md +8 -7
  103. package/get-shit-done/workflows/quick.md +158 -10
  104. package/get-shit-done/workflows/remove-phase.md +5 -4
  105. package/get-shit-done/workflows/research-phase.md +5 -4
  106. package/get-shit-done/workflows/resume-project.md +3 -2
  107. package/get-shit-done/workflows/set-profile.md +3 -2
  108. package/get-shit-done/workflows/settings.md +6 -6
  109. package/get-shit-done/workflows/transition.md +5 -5
  110. package/get-shit-done/workflows/update.md +45 -19
  111. package/get-shit-done/workflows/validate-phase.md +167 -0
  112. package/get-shit-done/workflows/verify-phase.md +10 -9
  113. package/get-shit-done/workflows/verify-work.md +18 -4
  114. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: gsd-settings
3
3
  description: Configure GSD workflow toggles and model profile
4
- allowed-tools:
5
- - read
6
- - write
7
- - bash
8
- - question
4
+ permissions:
5
+ read: true
6
+ write: true
7
+ bash: true
8
+ question: true
9
9
  ---
10
10
 
11
11
  <objective>
@@ -20,11 +20,11 @@ Routes to the settings workflow which handles:
20
20
  </objective>
21
21
 
22
22
  <execution_context>
23
- @~/.config/opencode/get-shit-done/workflows/settings.md
23
+ @$HOME/.config/opencode/get-shit-done/workflows/settings.md
24
24
  </execution_context>
25
25
 
26
26
  <process>
27
- **Follow the settings workflow** from `@~/.config/opencode/get-shit-done/workflows/settings.md`.
27
+ **Follow the settings workflow** from `@$HOME/.config/opencode/get-shit-done/workflows/settings.md`.
28
28
 
29
29
  The workflow handles all logic including:
30
30
  1. Config file creation with defaults if missing
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: gsd-update
3
3
  description: Update GSD to latest version with changelog display
4
- allowed-tools:
5
- - bash
6
- - question
4
+ permissions:
5
+ bash: true
6
+ question: true
7
7
  ---
8
8
 
9
9
  <objective>
@@ -19,11 +19,11 @@ Routes to the update workflow which handles:
19
19
  </objective>
20
20
 
21
21
  <execution_context>
22
- @~/.config/opencode/get-shit-done/workflows/update.md
22
+ @$HOME/.config/opencode/get-shit-done/workflows/update.md
23
23
  </execution_context>
24
24
 
25
25
  <process>
26
- **Follow the update workflow** from `@~/.config/opencode/get-shit-done/workflows/update.md`.
26
+ **Follow the update workflow** from `@$HOME/.config/opencode/get-shit-done/workflows/update.md`.
27
27
 
28
28
  The workflow handles all logic including:
29
29
  1. Installed version detection (local/global)
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: gsd-validate-phase
3
+ description: Retroactively audit and fill Nyquist validation gaps for a completed phase
4
+ argument-hint: "[phase number]"
5
+ permissions:
6
+ read: true
7
+ write: true
8
+ edit: true
9
+ bash: true
10
+ glob: true
11
+ grep: true
12
+ task: true
13
+ question: true
14
+ ---
15
+ <objective>
16
+ Audit Nyquist validation coverage for a completed phase. Three states:
17
+ - (A) VALIDATION.md exists — audit and fill gaps
18
+ - (B) No VALIDATION.md, SUMMARY.md exists — reconstruct from artifacts
19
+ - (C) Phase not executed — exit with guidance
20
+
21
+ Output: updated VALIDATION.md + generated test files.
22
+ </objective>
23
+
24
+ <execution_context>
25
+ @$HOME/.config/opencode/get-shit-done/workflows/validate-phase.md
26
+ </execution_context>
27
+
28
+ <context>
29
+ Phase: $ARGUMENTS — optional, defaults to last completed phase.
30
+ </context>
31
+
32
+ <process>
33
+ Execute @$HOME/.config/opencode/get-shit-done/workflows/validate-phase.md.
34
+ Preserve all workflow gates.
35
+ </process>
@@ -2,14 +2,14 @@
2
2
  name: gsd-verify-work
3
3
  description: Validate built features through conversational UAT
4
4
  argument-hint: "[phase number, e.g., '4']"
5
- allowed-tools:
6
- - read
7
- - bash
8
- - glob
9
- - grep
10
- - edit
11
- - write
12
- - task
5
+ permissions:
6
+ read: true
7
+ bash: true
8
+ glob: true
9
+ grep: true
10
+ edit: true
11
+ write: true
12
+ task: true
13
13
  ---
14
14
  <objective>
15
15
  Validate built features through conversational testing with persistent state.
@@ -20,8 +20,8 @@ Output: {phase_num}-UAT.md tracking all test results. If issues found: diagnosed
20
20
  </objective>
21
21
 
22
22
  <execution_context>
23
- @~/.config/opencode/get-shit-done/workflows/verify-work.md
24
- @~/.config/opencode/get-shit-done/templates/UAT.md
23
+ @$HOME/.config/opencode/get-shit-done/workflows/verify-work.md
24
+ @$HOME/.config/opencode/get-shit-done/templates/UAT.md
25
25
  </execution_context>
26
26
 
27
27
  <context>
@@ -33,6 +33,6 @@ Context files are resolved inside the workflow (`init verify-work`) and delegate
33
33
  </context>
34
34
 
35
35
  <process>
36
- Execute the verify-work workflow from @~/.config/opencode/get-shit-done/workflows/verify-work.md end-to-end.
36
+ Execute the verify-work workflow from @$HOME/.config/opencode/get-shit-done/workflows/verify-work.md end-to-end.
37
37
  Preserve all workflow gates (session management, test presentation, diagnosis, fix planning, routing).
38
38
  </process>
@@ -0,0 +1,235 @@
1
+ /**
2
+ * allow-read-config.cjs — Add external_directory permission to read GSD config folder
3
+ *
4
+ * Creates or updates local opencode.json with permission to access:
5
+ * ~/.config/opencode/get-shit-done/
6
+ *
7
+ * This allows gsd-opencode commands to read workflow files, templates, and
8
+ * configuration from the global GSD installation directory.
9
+ *
10
+ * Usage:
11
+ * node allow-read-config.cjs # Add read permission
12
+ * node allow-read-config.cjs --dry-run # Preview changes
13
+ * node allow-read-config.cjs --verbose # Verbose output
14
+ */
15
+
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+ const os = require('os');
19
+ const { output, error, createBackup } = require('../gsd-oc-lib/oc-core.cjs');
20
+
21
+ /**
22
+ * Error codes for allow-read-config operations
23
+ */
24
+ const ERROR_CODES = {
25
+ WRITE_FAILED: 'WRITE_FAILED',
26
+ APPLY_FAILED: 'APPLY_FAILED',
27
+ ROLLBACK_FAILED: 'ROLLBACK_FAILED',
28
+ INVALID_ARGS: 'INVALID_ARGS'
29
+ };
30
+
31
+ /**
32
+ * Get the GSD config directory path
33
+ * Uses environment variable if set, otherwise defaults to ~/.config/opencode/get-shit-done
34
+ *
35
+ * @returns {string} GSD config directory path
36
+ */
37
+ function getGsdConfigDir() {
38
+ const envDir = process.env.OPENCODE_CONFIG_DIR;
39
+ if (envDir) {
40
+ return envDir;
41
+ }
42
+
43
+ const homeDir = os.homedir();
44
+ return path.join(homeDir, '.config', 'opencode', 'get-shit-done');
45
+ }
46
+
47
+ /**
48
+ * Build the external_directory permission pattern
49
+ *
50
+ * @param {string} gsdDir - GSD config directory
51
+ * @returns {string} Permission pattern with wildcard
52
+ */
53
+ function buildPermissionPattern(gsdDir) {
54
+ // Use ** for recursive matching (all subdirectories and files)
55
+ return `${gsdDir}/**`;
56
+ }
57
+
58
+ /**
59
+ * Check if permission already exists in opencode.json
60
+ *
61
+ * @param {Object} opencodeData - Parsed opencode.json content
62
+ * @param {string} pattern - Permission pattern to check
63
+ * @returns {boolean} True if permission exists
64
+ */
65
+ function permissionExists(opencodeData, pattern) {
66
+ const permissions = opencodeData.permission;
67
+
68
+ if (!permissions) {
69
+ return false;
70
+ }
71
+
72
+ const externalDirPerms = permissions.external_directory;
73
+ if (!externalDirPerms || typeof externalDirPerms !== 'object') {
74
+ return false;
75
+ }
76
+
77
+ // Check if the pattern exists and is set to "allow"
78
+ return externalDirPerms[pattern] === 'allow';
79
+ }
80
+
81
+ /**
82
+ * Main command function
83
+ *
84
+ * @param {string} cwd - Current working directory
85
+ * @param {string[]} args - Command line arguments
86
+ */
87
+ function allowReadConfig(cwd, args) {
88
+ const verbose = args.includes('--verbose');
89
+ const dryRun = args.includes('--dry-run');
90
+ const raw = args.includes('--raw');
91
+
92
+ const log = verbose ? (...args) => console.error('[allow-read-config]', ...args) : () => {};
93
+
94
+ const opencodePath = path.join(cwd, 'opencode.json');
95
+ const backupsDir = path.join(cwd, '.planning', 'backups');
96
+ const gsdConfigDir = getGsdConfigDir();
97
+ const permissionPattern = buildPermissionPattern(gsdConfigDir);
98
+
99
+ log('Starting allow-read-config command');
100
+ log(`GSD config directory: ${gsdConfigDir}`);
101
+ log(`Permission pattern: ${permissionPattern}`);
102
+
103
+ // Check for invalid arguments
104
+ const validFlags = ['--verbose', '--dry-run', '--raw'];
105
+ const invalidArgs = args.filter(arg =>
106
+ arg.startsWith('--') && !validFlags.includes(arg)
107
+ );
108
+
109
+ if (invalidArgs.length > 0) {
110
+ error(`Unknown arguments: ${invalidArgs.join(', ')}`, 'INVALID_ARGS');
111
+ }
112
+
113
+ // Load or create opencode.json
114
+ let opencodeData;
115
+ let fileExisted = false;
116
+
117
+ if (fs.existsSync(opencodePath)) {
118
+ try {
119
+ const content = fs.readFileSync(opencodePath, 'utf8');
120
+ opencodeData = JSON.parse(content);
121
+ fileExisted = true;
122
+ log('Loaded existing opencode.json');
123
+ } catch (err) {
124
+ error(`Failed to parse opencode.json: ${err.message}`, 'INVALID_JSON');
125
+ }
126
+ } else {
127
+ // Create initial opencode.json structure
128
+ opencodeData = {
129
+ "$schema": "https://opencode.ai/config.json"
130
+ };
131
+ log('Creating new opencode.json');
132
+ }
133
+
134
+ // Check if permission already exists
135
+ const exists = permissionExists(opencodeData, permissionPattern);
136
+
137
+ if (exists) {
138
+ log('Permission already exists');
139
+ output({
140
+ success: true,
141
+ data: {
142
+ dryRun: dryRun,
143
+ action: 'permission_exists',
144
+ pattern: permissionPattern,
145
+ message: 'Permission already configured'
146
+ }
147
+ });
148
+ process.exit(0);
149
+ }
150
+
151
+ // Dry-run mode - preview changes
152
+ if (dryRun) {
153
+ log('Dry-run mode - no changes will be made');
154
+
155
+ const changes = [];
156
+ if (!fileExisted) {
157
+ changes.push('Create opencode.json');
158
+ }
159
+ changes.push(`Add external_directory permission: ${permissionPattern}`);
160
+
161
+ output({
162
+ success: true,
163
+ data: {
164
+ dryRun: true,
165
+ action: 'add_permission',
166
+ pattern: permissionPattern,
167
+ gsdConfigDir: gsdConfigDir,
168
+ changes: changes,
169
+ message: fileExisted ? 'Would update opencode.json' : 'Would create opencode.json'
170
+ }
171
+ });
172
+ process.exit(0);
173
+ }
174
+
175
+ // Create backup if file exists
176
+ let backupPath = null;
177
+ if (fileExisted) {
178
+ // Ensure backup directory exists
179
+ if (!fs.existsSync(backupsDir)) {
180
+ fs.mkdirSync(backupsDir, { recursive: true });
181
+ }
182
+
183
+ backupPath = createBackup(opencodePath, backupsDir);
184
+ log(`Backup created: ${backupPath}`);
185
+ }
186
+
187
+ // Initialize permission structure if needed
188
+ if (!opencodeData.permission) {
189
+ opencodeData.permission = {};
190
+ }
191
+
192
+ if (!opencodeData.permission.external_directory) {
193
+ opencodeData.permission.external_directory = {};
194
+ }
195
+
196
+ // Add the permission
197
+ opencodeData.permission.external_directory[permissionPattern] = 'allow';
198
+
199
+ log('Permission added to opencode.json');
200
+
201
+ // Write updated opencode.json
202
+ try {
203
+ fs.writeFileSync(opencodePath, JSON.stringify(opencodeData, null, 2) + '\n', 'utf8');
204
+ log('Updated opencode.json');
205
+ } catch (err) {
206
+ // Rollback if backup exists
207
+ if (backupPath) {
208
+ try {
209
+ fs.copyFileSync(backupPath, opencodePath);
210
+ } catch (rollbackErr) {
211
+ error(
212
+ `Failed to write opencode.json AND failed to rollback: ${rollbackErr.message}`,
213
+ 'ROLLBACK_FAILED'
214
+ );
215
+ }
216
+ }
217
+ error(`Failed to write opencode.json: ${err.message}`, 'WRITE_FAILED');
218
+ }
219
+
220
+ output({
221
+ success: true,
222
+ data: {
223
+ action: 'add_permission',
224
+ pattern: permissionPattern,
225
+ gsdConfigDir: gsdConfigDir,
226
+ opencodePath: opencodePath,
227
+ backup: backupPath,
228
+ created: !fileExisted,
229
+ message: fileExisted ? 'opencode.json updated' : 'opencode.json created'
230
+ }
231
+ });
232
+ process.exit(0);
233
+ }
234
+
235
+ module.exports = allowReadConfig;
@@ -16,6 +16,7 @@
16
16
  * validate-models Validate model IDs against opencode catalog
17
17
  * set-profile Switch profile with interactive model selection
18
18
  * get-profile Get current profile or specific profile from oc_config.json
19
+ * allow-read-config Add external_directory permission to read GSD config folder
19
20
  * help Show this help message
20
21
  */
21
22
 
@@ -50,12 +51,13 @@ Available Commands:
50
51
  validate-models Validate one or more model IDs against opencode catalog
51
52
  set-profile Switch profile with interactive model selection wizard
52
53
  get-profile Get current profile or specific profile from oc_config.json
54
+ allow-read-config Add external_directory permission to read ~/.config/opencode/get-shit-done/**
53
55
  help Show this help message
54
56
 
55
57
  Options:
56
58
  --verbose Enable verbose output (stderr)
57
- --raw Output raw values instead of JSON envelope
58
- --dry-run Preview changes without applying (update-opencode-json)
59
+ --raw Output raw value instead of JSON envelope
60
+ --dry-run Preview changes without applying (update-opencode-json, allow-read-config)
59
61
 
60
62
  Examples:
61
63
  node gsd-oc-tools.cjs check-opencode-json
@@ -66,6 +68,8 @@ Examples:
66
68
  node gsd-oc-tools.cjs get-profile
67
69
  node gsd-oc-tools.cjs get-profile genius
68
70
  node gsd-oc-tools.cjs get-profile --raw
71
+ node gsd-oc-tools.cjs allow-read-config
72
+ node gsd-oc-tools.cjs allow-read-config --dry-run
69
73
  `.trim();
70
74
 
71
75
  console.log(helpText);
@@ -121,9 +125,11 @@ switch (command) {
121
125
  break;
122
126
  }
123
127
 
124
-
125
-
126
-
128
+ case 'allow-read-config': {
129
+ const allowReadConfig = require('./gsd-oc-commands/allow-read-config.cjs');
130
+ allowReadConfig(cwd, flags);
131
+ break;
132
+ }
127
133
 
128
134
  default:
129
135
  error(`Unknown command: ${command}\nRun 'node gsd-oc-tools.cjs help' for available commands.`);
@@ -10,6 +10,7 @@
10
10
  *
11
11
  * Atomic Commands:
12
12
  * state load Load project config + state
13
+ * state json Output STATE.md frontmatter as JSON
13
14
  * state update <field> <value> Update a STATE.md field
14
15
  * state get [section] Get STATE.md content or section
15
16
  * state patch --field val ... Batch update STATE.md fields
@@ -102,7 +103,9 @@
102
103
  * state update-progress Recalculate progress bar
103
104
  * state add-decision --summary "..." Add decision to STATE.md
104
105
  * [--phase N] [--rationale "..."]
106
+ * [--summary-file path] [--rationale-file path]
105
107
  * state add-blocker --text "..." Add blocker
108
+ * [--text-file path]
106
109
  * state resolve-blocker --text "..." Remove blocker
107
110
  * state record-session Update session continuity
108
111
  * --stopped-at "..."
@@ -123,6 +126,8 @@
123
126
  * init progress All context for progress workflow
124
127
  */
125
128
 
129
+ const fs = require('fs');
130
+ const path = require('path');
126
131
  const { error } = require('./lib/core.cjs');
127
132
  const state = require('./lib/state.cjs');
128
133
  const phase = require('./lib/phase.cjs');
@@ -139,21 +144,43 @@ const frontmatter = require('./lib/frontmatter.cjs');
139
144
 
140
145
  async function main() {
141
146
  const args = process.argv.slice(2);
147
+
148
+ // Optional cwd override for sandboxed subagents running outside project root.
149
+ let cwd = process.cwd();
150
+ const cwdEqArg = args.find(arg => arg.startsWith('--cwd='));
151
+ const cwdIdx = args.indexOf('--cwd');
152
+ if (cwdEqArg) {
153
+ const value = cwdEqArg.slice('--cwd='.length).trim();
154
+ if (!value) error('Missing value for --cwd');
155
+ args.splice(args.indexOf(cwdEqArg), 1);
156
+ cwd = path.resolve(value);
157
+ } else if (cwdIdx !== -1) {
158
+ const value = args[cwdIdx + 1];
159
+ if (!value || value.startsWith('--')) error('Missing value for --cwd');
160
+ args.splice(cwdIdx, 2);
161
+ cwd = path.resolve(value);
162
+ }
163
+
164
+ if (!fs.existsSync(cwd) || !fs.statSync(cwd).isDirectory()) {
165
+ error(`Invalid --cwd: ${cwd}`);
166
+ }
167
+
142
168
  const rawIndex = args.indexOf('--raw');
143
169
  const raw = rawIndex !== -1;
144
170
  if (rawIndex !== -1) args.splice(rawIndex, 1);
145
171
 
146
172
  const command = args[0];
147
- const cwd = process.cwd();
148
173
 
149
174
  if (!command) {
150
- error('Usage: gsd-tools <command> [args] [--raw]\nCommands: state, resolve-model, find-phase, commit, verify-summary, verify, frontmatter, template, generate-slug, current-timestamp, list-todos, verify-path-exists, config-ensure-section, init');
175
+ error('Usage: gsd-tools <command> [args] [--raw] [--cwd <path>]\nCommands: state, resolve-model, find-phase, commit, verify-summary, verify, frontmatter, template, generate-slug, current-timestamp, list-todos, verify-path-exists, config-ensure-section, init');
151
176
  }
152
177
 
153
178
  switch (command) {
154
179
  case 'state': {
155
180
  const subcommand = args[1];
156
- if (subcommand === 'update') {
181
+ if (subcommand === 'json') {
182
+ state.cmdStateJson(cwd, raw);
183
+ } else if (subcommand === 'update') {
157
184
  state.cmdStateUpdate(cwd, args[2], args[3]);
158
185
  } else if (subcommand === 'get') {
159
186
  state.cmdStateGet(cwd, args[2], raw);
@@ -187,15 +214,23 @@ async function main() {
187
214
  } else if (subcommand === 'add-decision') {
188
215
  const phaseIdx = args.indexOf('--phase');
189
216
  const summaryIdx = args.indexOf('--summary');
217
+ const summaryFileIdx = args.indexOf('--summary-file');
190
218
  const rationaleIdx = args.indexOf('--rationale');
219
+ const rationaleFileIdx = args.indexOf('--rationale-file');
191
220
  state.cmdStateAddDecision(cwd, {
192
221
  phase: phaseIdx !== -1 ? args[phaseIdx + 1] : null,
193
222
  summary: summaryIdx !== -1 ? args[summaryIdx + 1] : null,
223
+ summary_file: summaryFileIdx !== -1 ? args[summaryFileIdx + 1] : null,
194
224
  rationale: rationaleIdx !== -1 ? args[rationaleIdx + 1] : '',
225
+ rationale_file: rationaleFileIdx !== -1 ? args[rationaleFileIdx + 1] : null,
195
226
  }, raw);
196
227
  } else if (subcommand === 'add-blocker') {
197
228
  const textIdx = args.indexOf('--text');
198
- state.cmdStateAddBlocker(cwd, textIdx !== -1 ? args[textIdx + 1] : null, raw);
229
+ const textFileIdx = args.indexOf('--text-file');
230
+ state.cmdStateAddBlocker(cwd, {
231
+ text: textIdx !== -1 ? args[textIdx + 1] : null,
232
+ text_file: textFileIdx !== -1 ? args[textFileIdx + 1] : null,
233
+ }, raw);
199
234
  } else if (subcommand === 'resolve-blocker') {
200
235
  const textIdx = args.indexOf('--text');
201
236
  state.cmdStateResolveBlocker(cwd, textIdx !== -1 ? args[textIdx + 1] : null, raw);
@@ -224,9 +259,13 @@ async function main() {
224
259
 
225
260
  case 'commit': {
226
261
  const amend = args.includes('--amend');
227
- const message = args[1];
228
- // Parse --files flag (collect args after --files, stopping at other flags)
229
262
  const filesIndex = args.indexOf('--files');
263
+ // Collect all positional args between command name and first flag,
264
+ // then join them — handles both quoted ("multi word msg") and
265
+ // unquoted (multi word msg) invocations from different shells
266
+ const endIndex = filesIndex !== -1 ? filesIndex : args.length;
267
+ const messageArgs = args.slice(1, endIndex).filter(a => !a.startsWith('--'));
268
+ const message = messageArgs.join(' ') || undefined;
230
269
  const files = filesIndex !== -1 ? args.slice(filesIndex + 1).filter(a => !a.startsWith('--')) : [];
231
270
  commands.cmdCommit(cwd, message, files, raw, amend);
232
271
  break;
@@ -4,7 +4,7 @@
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  const { execSync } = require('child_process');
7
- const { safeReadFile, loadConfig, isGitIgnored, execGit, normalizePhaseName, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, resolveModelInternal, MODEL_PROFILES, output, error, findPhaseInternal } = require('./core.cjs');
7
+ const { safeReadFile, loadConfig, isGitIgnored, execGit, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, resolveModelInternal, MODEL_PROFILES, toPosixPath, output, error, findPhaseInternal } = require('./core.cjs');
8
8
  const { extractFrontmatter } = require('./frontmatter.cjs');
9
9
 
10
10
  function cmdGenerateSlug(text, raw) {
@@ -68,7 +68,7 @@ function cmdListTodos(cwd, area, raw) {
68
68
  created: createdMatch ? createdMatch[1].trim() : 'unknown',
69
69
  title: titleMatch ? titleMatch[1].trim() : 'Untitled',
70
70
  area: todoArea,
71
- path: path.join('.planning', 'todos', 'pending', file),
71
+ path: toPosixPath(path.join('.planning', 'todos', 'pending', file)),
72
72
  });
73
73
  } catch {}
74
74
  }
@@ -204,17 +204,12 @@ function cmdResolveModel(cwd, agentType, raw) {
204
204
 
205
205
  const config = loadConfig(cwd);
206
206
  const profile = config.model_profile || 'balanced';
207
+ const model = resolveModelInternal(cwd, agentType);
207
208
 
208
209
  const agentModels = MODEL_PROFILES[agentType];
209
- if (!agentModels) {
210
- const result = { model: 'sonnet', profile, unknown_agent: true };
211
- output(result, raw, 'sonnet');
212
- return;
213
- }
214
-
215
- const resolved = agentModels[profile] || agentModels['balanced'] || 'sonnet';
216
- const model = resolved === 'opus' ? 'inherit' : resolved;
217
- const result = { model, profile };
210
+ const result = agentModels
211
+ ? { model, profile }
212
+ : { model, profile, unknown_agent: true };
218
213
  output(result, raw, model);
219
214
  }
220
215
 
@@ -304,6 +299,7 @@ function cmdSummaryExtract(cwd, summaryPath, fields, raw) {
304
299
  tech_added: (fm['tech-stack'] && fm['tech-stack'].added) || [],
305
300
  patterns: fm['patterns-established'] || [],
306
301
  decisions: parseDecisions(fm['key-decisions']),
302
+ requirements_completed: fm['requirements-completed'] || [],
307
303
  };
308
304
 
309
305
  // If fields specified, filter to only those fields
@@ -394,14 +390,10 @@ function cmdProgressRender(cwd, format, raw) {
394
390
 
395
391
  try {
396
392
  const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
397
- const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).sort((a, b) => {
398
- const aNum = parseFloat(a.match(/^(\d+(?:\.\d+)?)/)?.[1] || '0');
399
- const bNum = parseFloat(b.match(/^(\d+(?:\.\d+)?)/)?.[1] || '0');
400
- return aNum - bNum;
401
- });
393
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).sort((a, b) => comparePhaseNum(a, b));
402
394
 
403
395
  for (const dir of dirs) {
404
- const dm = dir.match(/^(\d+(?:\.\d+)?)-?(.*)/);
396
+ const dm = dir.match(/^(\d+(?:\.\d+)*)-?(.*)/);
405
397
  const phaseNum = dm ? dm[1] : dir;
406
398
  const phaseName = dm && dm[2] ? dm[2].replace(/-/g, ' ') : '';
407
399
  const phaseFiles = fs.readdirSync(path.join(phasesDir, dir));
@@ -421,7 +413,7 @@ function cmdProgressRender(cwd, format, raw) {
421
413
  }
422
414
  } catch {}
423
415
 
424
- const percent = totalPlans > 0 ? Math.round((totalSummaries / totalPlans) * 100) : 0;
416
+ const percent = totalPlans > 0 ? Math.min(100, Math.round((totalSummaries / totalPlans) * 100)) : 0;
425
417
 
426
418
  if (format === 'table') {
427
419
  // Render markdown table
@@ -536,7 +528,7 @@ function cmdScaffold(cwd, type, options, raw) {
536
528
  }
537
529
 
538
530
  fs.writeFileSync(filePath, content, 'utf-8');
539
- const relPath = path.relative(cwd, filePath);
531
+ const relPath = toPosixPath(path.relative(cwd, filePath));
540
532
  output({ created: true, path: relPath }, raw, relPath);
541
533
  }
542
534
 
@@ -37,6 +37,13 @@ function cmdConfigEnsureSection(cwd, raw) {
37
37
  try {
38
38
  if (fs.existsSync(globalDefaultsPath)) {
39
39
  userDefaults = JSON.parse(fs.readFileSync(globalDefaultsPath, 'utf-8'));
40
+ // Migrate deprecated "depth" key to "granularity"
41
+ if ('depth' in userDefaults && !('granularity' in userDefaults)) {
42
+ const depthToGranularity = { quick: 'coarse', standard: 'standard', comprehensive: 'fine' };
43
+ userDefaults.granularity = depthToGranularity[userDefaults.depth] || userDefaults.depth;
44
+ delete userDefaults.depth;
45
+ try { fs.writeFileSync(globalDefaultsPath, JSON.stringify(userDefaults, null, 2), 'utf-8'); } catch {}
46
+ }
40
47
  }
41
48
  } catch (err) {
42
49
  // Ignore malformed global defaults, fall back to hardcoded
@@ -54,7 +61,7 @@ function cmdConfigEnsureSection(cwd, raw) {
54
61
  research: true,
55
62
  plan_check: true,
56
63
  verifier: true,
57
- nyquist_validation: false,
64
+ nyquist_validation: true,
58
65
  },
59
66
  parallelization: true,
60
67
  brave_search: hasBraveSearch,