gsd-opencode 1.10.2 → 1.20.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 (164) hide show
  1. package/agents/gsd-codebase-mapper.md +29 -3
  2. package/agents/gsd-debugger.md +19 -21
  3. package/agents/gsd-executor.md +213 -528
  4. package/agents/gsd-integration-checker.md +20 -0
  5. package/agents/gsd-phase-researcher.md +189 -267
  6. package/agents/gsd-plan-checker.md +278 -279
  7. package/agents/gsd-planner.md +299 -490
  8. package/agents/gsd-project-researcher.md +103 -345
  9. package/agents/gsd-research-synthesizer.md +5 -22
  10. package/agents/gsd-roadmapper.md +43 -6
  11. package/agents/gsd-verifier.md +158 -377
  12. package/{lib → bin/dm/lib}/constants.js +10 -3
  13. package/{src → bin/dm/src}/commands/install.js +5 -4
  14. package/{src → bin/dm/src}/commands/uninstall.js +3 -1
  15. package/{src → bin/dm/src}/services/backup-manager.js +1 -1
  16. package/{src → bin/dm/src}/services/config.js +1 -1
  17. package/{src → bin/dm/src}/services/file-ops.js +20 -4
  18. package/{src → bin/dm/src}/services/health-checker.js +3 -1
  19. package/{src → bin/dm/src}/services/repair-service.js +3 -1
  20. package/{src → bin/dm/src}/services/settings.js +1 -1
  21. package/{src → bin/dm/src}/services/update-service.js +2 -2
  22. package/bin/gsd-install.js +0 -0
  23. package/bin/gsd.js +9 -9
  24. package/commands/gsd/gsd-add-phase.md +43 -0
  25. package/commands/gsd/gsd-add-todo.md +47 -0
  26. package/commands/gsd/gsd-audit-milestone.md +36 -0
  27. package/commands/gsd/gsd-check-todos.md +45 -0
  28. package/commands/gsd/gsd-cleanup.md +18 -0
  29. package/commands/gsd/{complete-milestone.md → gsd-complete-milestone.md} +1 -1
  30. package/commands/gsd/{debug.md → gsd-debug.md} +16 -21
  31. package/commands/gsd/{discuss-phase.md → gsd-discuss-phase.md} +6 -9
  32. package/commands/gsd/gsd-execute-phase.md +41 -0
  33. package/commands/gsd/gsd-health.md +22 -0
  34. package/commands/gsd/gsd-help.md +22 -0
  35. package/commands/gsd/gsd-insert-phase.md +32 -0
  36. package/commands/gsd/gsd-join-discord.md +18 -0
  37. package/commands/gsd/{list-phase-assumptions.md → gsd-list-phase-assumptions.md} +3 -7
  38. package/commands/gsd/{map-codebase.md → gsd-map-codebase.md} +3 -3
  39. package/commands/gsd/gsd-new-milestone.md +44 -0
  40. package/commands/gsd/gsd-new-project.md +42 -0
  41. package/commands/gsd/gsd-pause-work.md +38 -0
  42. package/commands/gsd/gsd-plan-milestone-gaps.md +34 -0
  43. package/commands/gsd/gsd-plan-phase.md +44 -0
  44. package/commands/gsd/gsd-progress.md +24 -0
  45. package/commands/gsd/gsd-quick.md +41 -0
  46. package/commands/gsd/gsd-reapply-patches.md +119 -0
  47. package/commands/gsd/gsd-remove-phase.md +31 -0
  48. package/commands/gsd/{research-phase.md → gsd-research-phase.md} +38 -49
  49. package/commands/gsd/{resume-work.md → gsd-resume-work.md} +2 -2
  50. package/commands/gsd/gsd-set-profile.md +34 -0
  51. package/commands/gsd/gsd-settings.md +36 -0
  52. package/commands/gsd/gsd-update.md +37 -0
  53. package/commands/gsd/gsd-verify-work.md +38 -0
  54. package/get-shit-done/bin/gsd-tools.cjs +553 -0
  55. package/get-shit-done/bin/gsd-tools.test.cjs +2346 -0
  56. package/get-shit-done/bin/lib/commands.cjs +556 -0
  57. package/get-shit-done/bin/lib/config.cjs +162 -0
  58. package/get-shit-done/bin/lib/core.cjs +377 -0
  59. package/get-shit-done/bin/lib/frontmatter.cjs +299 -0
  60. package/get-shit-done/bin/lib/init.cjs +694 -0
  61. package/get-shit-done/bin/lib/milestone.cjs +215 -0
  62. package/get-shit-done/bin/lib/phase.cjs +877 -0
  63. package/get-shit-done/bin/lib/roadmap.cjs +298 -0
  64. package/get-shit-done/bin/lib/state.cjs +490 -0
  65. package/get-shit-done/bin/lib/template.cjs +222 -0
  66. package/get-shit-done/bin/lib/verify.cjs +772 -0
  67. package/get-shit-done/references/checkpoints.md +62 -364
  68. package/get-shit-done/references/decimal-phase-calculation.md +65 -0
  69. package/get-shit-done/references/git-integration.md +10 -16
  70. package/get-shit-done/references/git-planning-commit.md +38 -0
  71. package/get-shit-done/references/model-profile-resolution.md +34 -0
  72. package/get-shit-done/references/model-profiles.md +54 -66
  73. package/get-shit-done/references/phase-argument-parsing.md +61 -0
  74. package/get-shit-done/references/planning-config.md +112 -10
  75. package/get-shit-done/references/questioning.md +4 -0
  76. package/get-shit-done/references/ui-brand.md +1 -1
  77. package/get-shit-done/templates/UAT.md +1 -1
  78. package/get-shit-done/templates/VALIDATION.md +104 -0
  79. package/get-shit-done/templates/codebase/structure.md +6 -6
  80. package/get-shit-done/templates/config.json +37 -0
  81. package/get-shit-done/templates/context.md +2 -10
  82. package/get-shit-done/templates/continue-here.md +6 -6
  83. package/get-shit-done/templates/debug-subagent-prompt.md +2 -2
  84. package/get-shit-done/templates/discovery.md +6 -6
  85. package/get-shit-done/templates/milestone-archive.md +3 -3
  86. package/get-shit-done/templates/phase-prompt.md +9 -7
  87. package/get-shit-done/templates/planner-subagent-prompt.md +6 -6
  88. package/get-shit-done/templates/research-project/ARCHITECTURE.md +1 -1
  89. package/get-shit-done/templates/research.md +29 -6
  90. package/get-shit-done/templates/roadmap.md +1 -1
  91. package/get-shit-done/templates/state.md +0 -30
  92. package/get-shit-done/templates/summary-complex.md +59 -0
  93. package/get-shit-done/templates/summary-minimal.md +41 -0
  94. package/get-shit-done/templates/summary-standard.md +48 -0
  95. package/get-shit-done/templates/summary.md +16 -37
  96. package/get-shit-done/templates/user-setup.md +1 -13
  97. package/get-shit-done/templates/verification-report.md +5 -5
  98. package/get-shit-done/workflows/add-phase.md +111 -0
  99. package/{commands/gsd → get-shit-done/workflows}/add-todo.md +24 -60
  100. package/{commands/gsd → get-shit-done/workflows}/audit-milestone.md +83 -63
  101. package/{commands/gsd → get-shit-done/workflows}/check-todos.md +21 -73
  102. package/get-shit-done/workflows/cleanup.md +152 -0
  103. package/get-shit-done/workflows/complete-milestone.md +251 -312
  104. package/get-shit-done/workflows/diagnose-issues.md +6 -31
  105. package/get-shit-done/workflows/discovery-phase.md +11 -11
  106. package/get-shit-done/workflows/discuss-phase.md +156 -49
  107. package/get-shit-done/workflows/execute-phase.md +238 -396
  108. package/get-shit-done/workflows/execute-plan.md +180 -1609
  109. package/get-shit-done/workflows/health.md +156 -0
  110. package/{commands/gsd → get-shit-done/workflows}/help.md +33 -35
  111. package/get-shit-done/workflows/insert-phase.md +129 -0
  112. package/get-shit-done/workflows/list-phase-assumptions.md +3 -3
  113. package/get-shit-done/workflows/map-codebase.md +73 -80
  114. package/get-shit-done/workflows/new-milestone.md +382 -0
  115. package/{commands/gsd → get-shit-done/workflows}/new-project.md +281 -234
  116. package/get-shit-done/workflows/oc-set-profile.md +320 -0
  117. package/{commands/gsd → get-shit-done/workflows}/pause-work.md +31 -43
  118. package/{commands/gsd → get-shit-done/workflows}/plan-milestone-gaps.md +29 -50
  119. package/get-shit-done/workflows/plan-phase.md +478 -0
  120. package/{commands/gsd → get-shit-done/workflows}/progress.md +64 -47
  121. package/get-shit-done/workflows/quick.md +453 -0
  122. package/get-shit-done/workflows/remove-phase.md +154 -0
  123. package/get-shit-done/workflows/research-phase.md +73 -0
  124. package/get-shit-done/workflows/resume-project.md +17 -26
  125. package/get-shit-done/workflows/set-profile.md +80 -0
  126. package/get-shit-done/workflows/settings.md +213 -0
  127. package/get-shit-done/workflows/transition.md +84 -104
  128. package/{commands/gsd → get-shit-done/workflows}/update.md +70 -28
  129. package/get-shit-done/workflows/verify-phase.md +106 -492
  130. package/get-shit-done/workflows/verify-work.md +26 -53
  131. package/package.json +7 -4
  132. package/rules/gsd-oc-work-hard.md +36 -0
  133. package/skills/gsd-oc-select-model/SKILL.md +348 -0
  134. package/skills/gsd-oc-select-model/scripts/select-models.cjs +268 -0
  135. package/agents/gsd-set-model.md +0 -287
  136. package/agents/gsd-set-profile.md +0 -239
  137. package/agents/gsd-settings.md +0 -749
  138. package/bin/install.js +0 -323
  139. package/commands/gsd/add-phase.md +0 -207
  140. package/commands/gsd/execute-phase.md +0 -339
  141. package/commands/gsd/insert-phase.md +0 -227
  142. package/commands/gsd/new-milestone.md +0 -721
  143. package/commands/gsd/plan-phase.md +0 -525
  144. package/commands/gsd/quick.md +0 -309
  145. package/commands/gsd/remove-phase.md +0 -349
  146. package/commands/gsd/set-model.md +0 -77
  147. package/commands/gsd/set-profile.md +0 -46
  148. package/commands/gsd/settings.md +0 -33
  149. package/commands/gsd/verify-work.md +0 -219
  150. package/commands/gsd/whats-new.md +0 -124
  151. /package/{src → bin/dm/src}/commands/check.js +0 -0
  152. /package/{src → bin/dm/src}/commands/config.js +0 -0
  153. /package/{src → bin/dm/src}/commands/list.js +0 -0
  154. /package/{src → bin/dm/src}/commands/repair.js +0 -0
  155. /package/{src → bin/dm/src}/commands/update.js +0 -0
  156. /package/{src → bin/dm/src}/services/manifest-manager.js +0 -0
  157. /package/{src → bin/dm/src}/services/migration-service.js +0 -0
  158. /package/{src → bin/dm/src}/services/scope-manager.js +0 -0
  159. /package/{src → bin/dm/src}/services/structure-detector.js +0 -0
  160. /package/{src → bin/dm/src}/utils/hash.js +0 -0
  161. /package/{src → bin/dm/src}/utils/interactive.js +0 -0
  162. /package/{src → bin/dm/src}/utils/logger.js +0 -0
  163. /package/{src → bin/dm/src}/utils/npm-registry.js +0 -0
  164. /package/{src → bin/dm/src}/utils/path-resolver.js +0 -0
@@ -0,0 +1,553 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * GSD Tools — CLI utility for GSD workflow operations
5
+ *
6
+ * Replaces repetitive inline bash patterns across ~50 GSD command/workflow/agent files.
7
+ * Centralizes: config parsing, model resolution, phase lookup, git commits, summary verification.
8
+ *
9
+ * Usage: node gsd-tools.cjs <command> [args] [--raw]
10
+ *
11
+ * Atomic Commands:
12
+ * state load Load project config + state
13
+ * state update <field> <value> Update a STATE.md field
14
+ * state get [section] Get STATE.md content or section
15
+ * state patch --field val ... Batch update STATE.md fields
16
+ * resolve-model <agent-type> Get model for agent based on profile
17
+ * find-phase <phase> Find phase directory by number
18
+ * commit <message> [--files f1 f2] Commit planning docs
19
+ * verify-summary <path> Verify a SUMMARY.md file
20
+ * generate-slug <text> Convert text to URL-safe slug
21
+ * current-timestamp [format] Get timestamp (full|date|filename)
22
+ * list-todos [area] Count and enumerate pending todos
23
+ * verify-path-exists <path> Check file/directory existence
24
+ * config-ensure-section Initialize .planning/config.json
25
+ * history-digest Aggregate all SUMMARY.md data
26
+ * summary-extract <path> [--fields] Extract structured data from SUMMARY.md
27
+ * state-snapshot Structured parse of STATE.md
28
+ * phase-plan-index <phase> Index plans with waves and status
29
+ * websearch <query> Search web via Brave API (if configured)
30
+ * [--limit N] [--freshness day|week|month]
31
+ *
32
+ * Phase Operations:
33
+ * phase next-decimal <phase> Calculate next decimal phase number
34
+ * phase add <description> Append new phase to roadmap + create dir
35
+ * phase insert <after> <description> Insert decimal phase after existing
36
+ * phase remove <phase> [--force] Remove phase, renumber all subsequent
37
+ * phase complete <phase> Mark phase done, update state + roadmap
38
+ *
39
+ * Roadmap Operations:
40
+ * roadmap get-phase <phase> Extract phase section from ROADMAP.md
41
+ * roadmap analyze Full roadmap parse with disk status
42
+ * roadmap update-plan-progress <N> Update progress table row from disk (PLAN vs SUMMARY counts)
43
+ *
44
+ * Requirements Operations:
45
+ * requirements mark-complete <ids> Mark requirement IDs as complete in REQUIREMENTS.md
46
+ * Accepts: REQ-01,REQ-02 or REQ-01 REQ-02 or [REQ-01, REQ-02]
47
+ *
48
+ * Milestone Operations:
49
+ * milestone complete <version> Archive milestone, create MILESTONES.md
50
+ * [--name <name>]
51
+ * [--archive-phases] Move phase dirs to milestones/vX.Y-phases/
52
+ *
53
+ * Validation:
54
+ * validate consistency Check phase numbering, disk/roadmap sync
55
+ * validate health [--repair] Check .planning/ integrity, optionally repair
56
+ *
57
+ * Progress:
58
+ * progress [json|table|bar] Render progress in various formats
59
+ *
60
+ * Todos:
61
+ * todo complete <filename> Move todo from pending to completed
62
+ *
63
+ * Scaffolding:
64
+ * scaffold context --phase <N> Create CONTEXT.md template
65
+ * scaffold uat --phase <N> Create UAT.md template
66
+ * scaffold verification --phase <N> Create VERIFICATION.md template
67
+ * scaffold phase-dir --phase <N> Create phase directory
68
+ * --name <name>
69
+ *
70
+ * Frontmatter CRUD:
71
+ * frontmatter get <file> [--field k] Extract frontmatter as JSON
72
+ * frontmatter set <file> --field k Update single frontmatter field
73
+ * --value jsonVal
74
+ * frontmatter merge <file> Merge JSON into frontmatter
75
+ * --data '{json}'
76
+ * frontmatter validate <file> Validate required fields
77
+ * --schema plan|summary|verification
78
+ *
79
+ * Verification Suite:
80
+ * verify plan-structure <file> Check PLAN.md structure + tasks
81
+ * verify phase-completeness <phase> Check all plans have summaries
82
+ * verify references <file> Check @-refs + paths resolve
83
+ * verify commits <h1> [h2] ... Batch verify commit hashes
84
+ * verify artifacts <plan-file> Check must_haves.artifacts
85
+ * verify key-links <plan-file> Check must_haves.key_links
86
+ *
87
+ * Template Fill:
88
+ * template fill summary --phase N Create pre-filled SUMMARY.md
89
+ * [--plan M] [--name "..."]
90
+ * [--fields '{json}']
91
+ * template fill plan --phase N Create pre-filled PLAN.md
92
+ * [--plan M] [--type execute|tdd]
93
+ * [--wave N] [--fields '{json}']
94
+ * template fill verification Create pre-filled VERIFICATION.md
95
+ * --phase N [--fields '{json}']
96
+ *
97
+ * State Progression:
98
+ * state advance-plan Increment plan counter
99
+ * state record-metric --phase N Record execution metrics
100
+ * --plan M --duration Xmin
101
+ * [--tasks N] [--files N]
102
+ * state update-progress Recalculate progress bar
103
+ * state add-decision --summary "..." Add decision to STATE.md
104
+ * [--phase N] [--rationale "..."]
105
+ * state add-blocker --text "..." Add blocker
106
+ * state resolve-blocker --text "..." Remove blocker
107
+ * state record-session Update session continuity
108
+ * --stopped-at "..."
109
+ * [--resume-file path]
110
+ *
111
+ * Compound Commands (workflow-specific initialization):
112
+ * init execute-phase <phase> All context for execute-phase workflow
113
+ * init plan-phase <phase> All context for plan-phase workflow
114
+ * init new-project All context for new-project workflow
115
+ * init new-milestone All context for new-milestone workflow
116
+ * init quick <description> All context for quick workflow
117
+ * init resume All context for resume-project workflow
118
+ * init verify-work <phase> All context for verify-work workflow
119
+ * init phase-op <phase> Generic phase operation context
120
+ * init todos [area] All context for todo workflows
121
+ * init milestone-op All context for milestone operations
122
+ * init map-codebase All context for map-codebase workflow
123
+ * init progress All context for progress workflow
124
+ */
125
+
126
+ const { error } = require('./lib/core.cjs');
127
+ const state = require('./lib/state.cjs');
128
+ const phase = require('./lib/phase.cjs');
129
+ const roadmap = require('./lib/roadmap.cjs');
130
+ const verify = require('./lib/verify.cjs');
131
+ const config = require('./lib/config.cjs');
132
+ const template = require('./lib/template.cjs');
133
+ const milestone = require('./lib/milestone.cjs');
134
+ const commands = require('./lib/commands.cjs');
135
+ const init = require('./lib/init.cjs');
136
+ const frontmatter = require('./lib/frontmatter.cjs');
137
+
138
+ // ─── CLI Router ───────────────────────────────────────────────────────────────
139
+
140
+ async function main() {
141
+ const args = process.argv.slice(2);
142
+ const rawIndex = args.indexOf('--raw');
143
+ const raw = rawIndex !== -1;
144
+ if (rawIndex !== -1) args.splice(rawIndex, 1);
145
+
146
+ const command = args[0];
147
+ const cwd = process.cwd();
148
+
149
+ 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');
151
+ }
152
+
153
+ switch (command) {
154
+ case 'state': {
155
+ const subcommand = args[1];
156
+ if (subcommand === 'update') {
157
+ state.cmdStateUpdate(cwd, args[2], args[3]);
158
+ } else if (subcommand === 'get') {
159
+ state.cmdStateGet(cwd, args[2], raw);
160
+ } else if (subcommand === 'patch') {
161
+ const patches = {};
162
+ for (let i = 2; i < args.length; i += 2) {
163
+ const key = args[i].replace(/^--/, '');
164
+ const value = args[i + 1];
165
+ if (key && value !== undefined) {
166
+ patches[key] = value;
167
+ }
168
+ }
169
+ state.cmdStatePatch(cwd, patches, raw);
170
+ } else if (subcommand === 'advance-plan') {
171
+ state.cmdStateAdvancePlan(cwd, raw);
172
+ } else if (subcommand === 'record-metric') {
173
+ const phaseIdx = args.indexOf('--phase');
174
+ const planIdx = args.indexOf('--plan');
175
+ const durationIdx = args.indexOf('--duration');
176
+ const tasksIdx = args.indexOf('--tasks');
177
+ const filesIdx = args.indexOf('--files');
178
+ state.cmdStateRecordMetric(cwd, {
179
+ phase: phaseIdx !== -1 ? args[phaseIdx + 1] : null,
180
+ plan: planIdx !== -1 ? args[planIdx + 1] : null,
181
+ duration: durationIdx !== -1 ? args[durationIdx + 1] : null,
182
+ tasks: tasksIdx !== -1 ? args[tasksIdx + 1] : null,
183
+ files: filesIdx !== -1 ? args[filesIdx + 1] : null,
184
+ }, raw);
185
+ } else if (subcommand === 'update-progress') {
186
+ state.cmdStateUpdateProgress(cwd, raw);
187
+ } else if (subcommand === 'add-decision') {
188
+ const phaseIdx = args.indexOf('--phase');
189
+ const summaryIdx = args.indexOf('--summary');
190
+ const rationaleIdx = args.indexOf('--rationale');
191
+ state.cmdStateAddDecision(cwd, {
192
+ phase: phaseIdx !== -1 ? args[phaseIdx + 1] : null,
193
+ summary: summaryIdx !== -1 ? args[summaryIdx + 1] : null,
194
+ rationale: rationaleIdx !== -1 ? args[rationaleIdx + 1] : '',
195
+ }, raw);
196
+ } else if (subcommand === 'add-blocker') {
197
+ const textIdx = args.indexOf('--text');
198
+ state.cmdStateAddBlocker(cwd, textIdx !== -1 ? args[textIdx + 1] : null, raw);
199
+ } else if (subcommand === 'resolve-blocker') {
200
+ const textIdx = args.indexOf('--text');
201
+ state.cmdStateResolveBlocker(cwd, textIdx !== -1 ? args[textIdx + 1] : null, raw);
202
+ } else if (subcommand === 'record-session') {
203
+ const stoppedIdx = args.indexOf('--stopped-at');
204
+ const resumeIdx = args.indexOf('--resume-file');
205
+ state.cmdStateRecordSession(cwd, {
206
+ stopped_at: stoppedIdx !== -1 ? args[stoppedIdx + 1] : null,
207
+ resume_file: resumeIdx !== -1 ? args[resumeIdx + 1] : 'None',
208
+ }, raw);
209
+ } else {
210
+ state.cmdStateLoad(cwd, raw);
211
+ }
212
+ break;
213
+ }
214
+
215
+ case 'resolve-model': {
216
+ commands.cmdResolveModel(cwd, args[1], raw);
217
+ break;
218
+ }
219
+
220
+ case 'find-phase': {
221
+ phase.cmdFindPhase(cwd, args[1], raw);
222
+ break;
223
+ }
224
+
225
+ case 'commit': {
226
+ const amend = args.includes('--amend');
227
+ const message = args[1];
228
+ // Parse --files flag (collect args after --files, stopping at other flags)
229
+ const filesIndex = args.indexOf('--files');
230
+ const files = filesIndex !== -1 ? args.slice(filesIndex + 1).filter(a => !a.startsWith('--')) : [];
231
+ commands.cmdCommit(cwd, message, files, raw, amend);
232
+ break;
233
+ }
234
+
235
+ case 'verify-summary': {
236
+ const summaryPath = args[1];
237
+ const countIndex = args.indexOf('--check-count');
238
+ const checkCount = countIndex !== -1 ? parseInt(args[countIndex + 1], 10) : 2;
239
+ verify.cmdVerifySummary(cwd, summaryPath, checkCount, raw);
240
+ break;
241
+ }
242
+
243
+ case 'template': {
244
+ const subcommand = args[1];
245
+ if (subcommand === 'select') {
246
+ template.cmdTemplateSelect(cwd, args[2], raw);
247
+ } else if (subcommand === 'fill') {
248
+ const templateType = args[2];
249
+ const phaseIdx = args.indexOf('--phase');
250
+ const planIdx = args.indexOf('--plan');
251
+ const nameIdx = args.indexOf('--name');
252
+ const typeIdx = args.indexOf('--type');
253
+ const waveIdx = args.indexOf('--wave');
254
+ const fieldsIdx = args.indexOf('--fields');
255
+ template.cmdTemplateFill(cwd, templateType, {
256
+ phase: phaseIdx !== -1 ? args[phaseIdx + 1] : null,
257
+ plan: planIdx !== -1 ? args[planIdx + 1] : null,
258
+ name: nameIdx !== -1 ? args[nameIdx + 1] : null,
259
+ type: typeIdx !== -1 ? args[typeIdx + 1] : 'execute',
260
+ wave: waveIdx !== -1 ? args[waveIdx + 1] : '1',
261
+ fields: fieldsIdx !== -1 ? JSON.parse(args[fieldsIdx + 1]) : {},
262
+ }, raw);
263
+ } else {
264
+ error('Unknown template subcommand. Available: select, fill');
265
+ }
266
+ break;
267
+ }
268
+
269
+ case 'frontmatter': {
270
+ const subcommand = args[1];
271
+ const file = args[2];
272
+ if (subcommand === 'get') {
273
+ const fieldIdx = args.indexOf('--field');
274
+ frontmatter.cmdFrontmatterGet(cwd, file, fieldIdx !== -1 ? args[fieldIdx + 1] : null, raw);
275
+ } else if (subcommand === 'set') {
276
+ const fieldIdx = args.indexOf('--field');
277
+ const valueIdx = args.indexOf('--value');
278
+ frontmatter.cmdFrontmatterSet(cwd, file, fieldIdx !== -1 ? args[fieldIdx + 1] : null, valueIdx !== -1 ? args[valueIdx + 1] : undefined, raw);
279
+ } else if (subcommand === 'merge') {
280
+ const dataIdx = args.indexOf('--data');
281
+ frontmatter.cmdFrontmatterMerge(cwd, file, dataIdx !== -1 ? args[dataIdx + 1] : null, raw);
282
+ } else if (subcommand === 'validate') {
283
+ const schemaIdx = args.indexOf('--schema');
284
+ frontmatter.cmdFrontmatterValidate(cwd, file, schemaIdx !== -1 ? args[schemaIdx + 1] : null, raw);
285
+ } else {
286
+ error('Unknown frontmatter subcommand. Available: get, set, merge, validate');
287
+ }
288
+ break;
289
+ }
290
+
291
+ case 'verify': {
292
+ const subcommand = args[1];
293
+ if (subcommand === 'plan-structure') {
294
+ verify.cmdVerifyPlanStructure(cwd, args[2], raw);
295
+ } else if (subcommand === 'phase-completeness') {
296
+ verify.cmdVerifyPhaseCompleteness(cwd, args[2], raw);
297
+ } else if (subcommand === 'references') {
298
+ verify.cmdVerifyReferences(cwd, args[2], raw);
299
+ } else if (subcommand === 'commits') {
300
+ verify.cmdVerifyCommits(cwd, args.slice(2), raw);
301
+ } else if (subcommand === 'artifacts') {
302
+ verify.cmdVerifyArtifacts(cwd, args[2], raw);
303
+ } else if (subcommand === 'key-links') {
304
+ verify.cmdVerifyKeyLinks(cwd, args[2], raw);
305
+ } else {
306
+ error('Unknown verify subcommand. Available: plan-structure, phase-completeness, references, commits, artifacts, key-links');
307
+ }
308
+ break;
309
+ }
310
+
311
+ case 'generate-slug': {
312
+ commands.cmdGenerateSlug(args[1], raw);
313
+ break;
314
+ }
315
+
316
+ case 'current-timestamp': {
317
+ commands.cmdCurrentTimestamp(args[1] || 'full', raw);
318
+ break;
319
+ }
320
+
321
+ case 'list-todos': {
322
+ commands.cmdListTodos(cwd, args[1], raw);
323
+ break;
324
+ }
325
+
326
+ case 'verify-path-exists': {
327
+ commands.cmdVerifyPathExists(cwd, args[1], raw);
328
+ break;
329
+ }
330
+
331
+ case 'config-ensure-section': {
332
+ config.cmdConfigEnsureSection(cwd, raw);
333
+ break;
334
+ }
335
+
336
+ case 'config-set': {
337
+ config.cmdConfigSet(cwd, args[1], args[2], raw);
338
+ break;
339
+ }
340
+
341
+ case 'config-get': {
342
+ config.cmdConfigGet(cwd, args[1], raw);
343
+ break;
344
+ }
345
+
346
+ case 'history-digest': {
347
+ commands.cmdHistoryDigest(cwd, raw);
348
+ break;
349
+ }
350
+
351
+ case 'phases': {
352
+ const subcommand = args[1];
353
+ if (subcommand === 'list') {
354
+ const typeIndex = args.indexOf('--type');
355
+ const phaseIndex = args.indexOf('--phase');
356
+ const options = {
357
+ type: typeIndex !== -1 ? args[typeIndex + 1] : null,
358
+ phase: phaseIndex !== -1 ? args[phaseIndex + 1] : null,
359
+ includeArchived: args.includes('--include-archived'),
360
+ };
361
+ phase.cmdPhasesList(cwd, options, raw);
362
+ } else {
363
+ error('Unknown phases subcommand. Available: list');
364
+ }
365
+ break;
366
+ }
367
+
368
+ case 'roadmap': {
369
+ const subcommand = args[1];
370
+ if (subcommand === 'get-phase') {
371
+ roadmap.cmdRoadmapGetPhase(cwd, args[2], raw);
372
+ } else if (subcommand === 'analyze') {
373
+ roadmap.cmdRoadmapAnalyze(cwd, raw);
374
+ } else if (subcommand === 'update-plan-progress') {
375
+ roadmap.cmdRoadmapUpdatePlanProgress(cwd, args[2], raw);
376
+ } else {
377
+ error('Unknown roadmap subcommand. Available: get-phase, analyze, update-plan-progress');
378
+ }
379
+ break;
380
+ }
381
+
382
+ case 'requirements': {
383
+ const subcommand = args[1];
384
+ if (subcommand === 'mark-complete') {
385
+ milestone.cmdRequirementsMarkComplete(cwd, args.slice(2), raw);
386
+ } else {
387
+ error('Unknown requirements subcommand. Available: mark-complete');
388
+ }
389
+ break;
390
+ }
391
+
392
+ case 'phase': {
393
+ const subcommand = args[1];
394
+ if (subcommand === 'next-decimal') {
395
+ phase.cmdPhaseNextDecimal(cwd, args[2], raw);
396
+ } else if (subcommand === 'add') {
397
+ phase.cmdPhaseAdd(cwd, args.slice(2).join(' '), raw);
398
+ } else if (subcommand === 'insert') {
399
+ phase.cmdPhaseInsert(cwd, args[2], args.slice(3).join(' '), raw);
400
+ } else if (subcommand === 'remove') {
401
+ const forceFlag = args.includes('--force');
402
+ phase.cmdPhaseRemove(cwd, args[2], { force: forceFlag }, raw);
403
+ } else if (subcommand === 'complete') {
404
+ phase.cmdPhaseComplete(cwd, args[2], raw);
405
+ } else {
406
+ error('Unknown phase subcommand. Available: next-decimal, add, insert, remove, complete');
407
+ }
408
+ break;
409
+ }
410
+
411
+ case 'milestone': {
412
+ const subcommand = args[1];
413
+ if (subcommand === 'complete') {
414
+ const nameIndex = args.indexOf('--name');
415
+ const archivePhases = args.includes('--archive-phases');
416
+ // Collect --name value (everything after --name until next flag or end)
417
+ let milestoneName = null;
418
+ if (nameIndex !== -1) {
419
+ const nameArgs = [];
420
+ for (let i = nameIndex + 1; i < args.length; i++) {
421
+ if (args[i].startsWith('--')) break;
422
+ nameArgs.push(args[i]);
423
+ }
424
+ milestoneName = nameArgs.join(' ') || null;
425
+ }
426
+ milestone.cmdMilestoneComplete(cwd, args[2], { name: milestoneName, archivePhases }, raw);
427
+ } else {
428
+ error('Unknown milestone subcommand. Available: complete');
429
+ }
430
+ break;
431
+ }
432
+
433
+ case 'validate': {
434
+ const subcommand = args[1];
435
+ if (subcommand === 'consistency') {
436
+ verify.cmdValidateConsistency(cwd, raw);
437
+ } else if (subcommand === 'health') {
438
+ const repairFlag = args.includes('--repair');
439
+ verify.cmdValidateHealth(cwd, { repair: repairFlag }, raw);
440
+ } else {
441
+ error('Unknown validate subcommand. Available: consistency, health');
442
+ }
443
+ break;
444
+ }
445
+
446
+ case 'progress': {
447
+ const subcommand = args[1] || 'json';
448
+ commands.cmdProgressRender(cwd, subcommand, raw);
449
+ break;
450
+ }
451
+
452
+ case 'todo': {
453
+ const subcommand = args[1];
454
+ if (subcommand === 'complete') {
455
+ commands.cmdTodoComplete(cwd, args[2], raw);
456
+ } else {
457
+ error('Unknown todo subcommand. Available: complete');
458
+ }
459
+ break;
460
+ }
461
+
462
+ case 'scaffold': {
463
+ const scaffoldType = args[1];
464
+ const phaseIndex = args.indexOf('--phase');
465
+ const nameIndex = args.indexOf('--name');
466
+ const scaffoldOptions = {
467
+ phase: phaseIndex !== -1 ? args[phaseIndex + 1] : null,
468
+ name: nameIndex !== -1 ? args.slice(nameIndex + 1).join(' ') : null,
469
+ };
470
+ commands.cmdScaffold(cwd, scaffoldType, scaffoldOptions, raw);
471
+ break;
472
+ }
473
+
474
+ case 'init': {
475
+ const workflow = args[1];
476
+ switch (workflow) {
477
+ case 'execute-phase':
478
+ init.cmdInitExecutePhase(cwd, args[2], raw);
479
+ break;
480
+ case 'plan-phase':
481
+ init.cmdInitPlanPhase(cwd, args[2], raw);
482
+ break;
483
+ case 'new-project':
484
+ init.cmdInitNewProject(cwd, raw);
485
+ break;
486
+ case 'new-milestone':
487
+ init.cmdInitNewMilestone(cwd, raw);
488
+ break;
489
+ case 'quick':
490
+ init.cmdInitQuick(cwd, args.slice(2).join(' '), raw);
491
+ break;
492
+ case 'resume':
493
+ init.cmdInitResume(cwd, raw);
494
+ break;
495
+ case 'verify-work':
496
+ init.cmdInitVerifyWork(cwd, args[2], raw);
497
+ break;
498
+ case 'phase-op':
499
+ init.cmdInitPhaseOp(cwd, args[2], raw);
500
+ break;
501
+ case 'todos':
502
+ init.cmdInitTodos(cwd, args[2], raw);
503
+ break;
504
+ case 'milestone-op':
505
+ init.cmdInitMilestoneOp(cwd, raw);
506
+ break;
507
+ case 'map-codebase':
508
+ init.cmdInitMapCodebase(cwd, raw);
509
+ break;
510
+ case 'progress':
511
+ init.cmdInitProgress(cwd, raw);
512
+ break;
513
+ default:
514
+ error(`Unknown init workflow: ${workflow}\nAvailable: execute-phase, plan-phase, new-project, new-milestone, quick, resume, verify-work, phase-op, todos, milestone-op, map-codebase, progress`);
515
+ }
516
+ break;
517
+ }
518
+
519
+ case 'phase-plan-index': {
520
+ phase.cmdPhasePlanIndex(cwd, args[1], raw);
521
+ break;
522
+ }
523
+
524
+ case 'state-snapshot': {
525
+ state.cmdStateSnapshot(cwd, raw);
526
+ break;
527
+ }
528
+
529
+ case 'summary-extract': {
530
+ const summaryPath = args[1];
531
+ const fieldsIndex = args.indexOf('--fields');
532
+ const fields = fieldsIndex !== -1 ? args[fieldsIndex + 1].split(',') : null;
533
+ commands.cmdSummaryExtract(cwd, summaryPath, fields, raw);
534
+ break;
535
+ }
536
+
537
+ case 'websearch': {
538
+ const query = args[1];
539
+ const limitIdx = args.indexOf('--limit');
540
+ const freshnessIdx = args.indexOf('--freshness');
541
+ await commands.cmdWebsearch(query, {
542
+ limit: limitIdx !== -1 ? parseInt(args[limitIdx + 1], 10) : 10,
543
+ freshness: freshnessIdx !== -1 ? args[freshnessIdx + 1] : null,
544
+ }, raw);
545
+ break;
546
+ }
547
+
548
+ default:
549
+ error(`Unknown command: ${command}`);
550
+ }
551
+ }
552
+
553
+ main();