agent-method 1.5.12

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 (108) hide show
  1. package/README.md +343 -0
  2. package/bin/wwa.js +115 -0
  3. package/docs/internal/cli-commands.yaml +259 -0
  4. package/docs/internal/doc-tokens.yaml +1103 -0
  5. package/docs/internal/feature-registry.yaml +1643 -0
  6. package/lib/boundaries.js +247 -0
  7. package/lib/cli/add.js +170 -0
  8. package/lib/cli/casestudy.js +1000 -0
  9. package/lib/cli/check.js +323 -0
  10. package/lib/cli/close.js +838 -0
  11. package/lib/cli/completion.js +735 -0
  12. package/lib/cli/deps.js +234 -0
  13. package/lib/cli/digest.js +73 -0
  14. package/lib/cli/doc-review.js +486 -0
  15. package/lib/cli/docs.js +315 -0
  16. package/lib/cli/helpers.js +198 -0
  17. package/lib/cli/implement.js +169 -0
  18. package/lib/cli/init.js +280 -0
  19. package/lib/cli/pipeline.js +206 -0
  20. package/lib/cli/plan.js +140 -0
  21. package/lib/cli/record.js +98 -0
  22. package/lib/cli/refine.js +202 -0
  23. package/lib/cli/report-helpers.js +113 -0
  24. package/lib/cli/review.js +76 -0
  25. package/lib/cli/routable.js +109 -0
  26. package/lib/cli/route.js +101 -0
  27. package/lib/cli/scan.js +133 -0
  28. package/lib/cli/serve.js +23 -0
  29. package/lib/cli/status.js +65 -0
  30. package/lib/cli/update-docs.js +574 -0
  31. package/lib/cli/upgrade.js +222 -0
  32. package/lib/cli/watch.js +32 -0
  33. package/lib/dependencies.js +196 -0
  34. package/lib/init.js +692 -0
  35. package/lib/mcp-server.js +612 -0
  36. package/lib/pipeline.js +907 -0
  37. package/lib/registry.js +132 -0
  38. package/lib/watcher.js +165 -0
  39. package/package.json +54 -0
  40. package/templates/README.md +363 -0
  41. package/templates/entry-points/.cursorrules +90 -0
  42. package/templates/entry-points/AGENT.md +90 -0
  43. package/templates/entry-points/CLAUDE.md +88 -0
  44. package/templates/extensions/MANIFEST.md +110 -0
  45. package/templates/extensions/analytical-system.md +96 -0
  46. package/templates/extensions/code-project.md +77 -0
  47. package/templates/extensions/data-exploration.md +117 -0
  48. package/templates/full/.context/BASE.md +101 -0
  49. package/templates/full/.context/COMPOSITION.md +47 -0
  50. package/templates/full/.context/INDEX.yaml +56 -0
  51. package/templates/full/.context/METHODOLOGY.md +246 -0
  52. package/templates/full/.context/PROTOCOL.yaml +169 -0
  53. package/templates/full/.context/REGISTRY.md +75 -0
  54. package/templates/full/.cursorrules +90 -0
  55. package/templates/full/AGENT.md +90 -0
  56. package/templates/full/CLAUDE.md +90 -0
  57. package/templates/full/Management/DIGEST.md +23 -0
  58. package/templates/full/Management/STATUS.md +46 -0
  59. package/templates/full/PLAN.md +67 -0
  60. package/templates/full/PROJECT-PROFILE.md +61 -0
  61. package/templates/full/PROJECT.md +80 -0
  62. package/templates/full/REQUIREMENTS.md +30 -0
  63. package/templates/full/ROADMAP.md +39 -0
  64. package/templates/full/Reviews/INDEX.md +41 -0
  65. package/templates/full/Reviews/backlog.md +52 -0
  66. package/templates/full/Reviews/plan.md +43 -0
  67. package/templates/full/Reviews/project.md +41 -0
  68. package/templates/full/Reviews/requirements.md +42 -0
  69. package/templates/full/Reviews/roadmap.md +41 -0
  70. package/templates/full/Reviews/state.md +56 -0
  71. package/templates/full/SESSION-LOG.md +102 -0
  72. package/templates/full/STATE.md +42 -0
  73. package/templates/full/SUMMARY.md +27 -0
  74. package/templates/full/agentWorkflows/INDEX.md +42 -0
  75. package/templates/full/agentWorkflows/observations.md +65 -0
  76. package/templates/full/agentWorkflows/patterns.md +68 -0
  77. package/templates/full/agentWorkflows/sessions.md +92 -0
  78. package/templates/full/intro/README.md +39 -0
  79. package/templates/full/registry/feature-registry.yaml +25 -0
  80. package/templates/full/registry/features/catalog.yaml +743 -0
  81. package/templates/full/registry/features/protocol.yaml +121 -0
  82. package/templates/full/registry/features/routing.yaml +358 -0
  83. package/templates/full/registry/features/workflows.yaml +404 -0
  84. package/templates/full/todos/backlog.md +19 -0
  85. package/templates/starter/.context/BASE.md +66 -0
  86. package/templates/starter/.context/INDEX.yaml +51 -0
  87. package/templates/starter/.context/METHODOLOGY.md +228 -0
  88. package/templates/starter/.context/PROTOCOL.yaml +165 -0
  89. package/templates/starter/.cursorrules +90 -0
  90. package/templates/starter/AGENT.md +90 -0
  91. package/templates/starter/CLAUDE.md +90 -0
  92. package/templates/starter/Management/DIGEST.md +23 -0
  93. package/templates/starter/Management/STATUS.md +46 -0
  94. package/templates/starter/PLAN.md +67 -0
  95. package/templates/starter/PROJECT-PROFILE.md +44 -0
  96. package/templates/starter/PROJECT.md +80 -0
  97. package/templates/starter/ROADMAP.md +39 -0
  98. package/templates/starter/Reviews/INDEX.md +75 -0
  99. package/templates/starter/SESSION-LOG.md +102 -0
  100. package/templates/starter/STATE.md +42 -0
  101. package/templates/starter/SUMMARY.md +27 -0
  102. package/templates/starter/agentWorkflows/INDEX.md +61 -0
  103. package/templates/starter/intro/README.md +37 -0
  104. package/templates/starter/registry/feature-registry.yaml +25 -0
  105. package/templates/starter/registry/features/catalog.yaml +743 -0
  106. package/templates/starter/registry/features/protocol.yaml +121 -0
  107. package/templates/starter/registry/features/routing.yaml +358 -0
  108. package/templates/starter/registry/features/workflows.yaml +404 -0
@@ -0,0 +1,735 @@
1
+ /** wwa completion — generate shell completion scripts. */
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // Command / option tree (single source of truth for completions)
5
+ // ---------------------------------------------------------------------------
6
+
7
+ const COMMANDS = [
8
+ "check", "scan", "route", "refine", "status", "upgrade", "init",
9
+ "plan", "implement", "review", "digest", "close",
10
+ "casestudy", "docs",
11
+ "project-discovery", "context-refresh", "phase-complete", "backlog",
12
+ "plan-create", "dependency-analysis", "debt-assessment",
13
+ "docs-update", "cross-reference",
14
+ "add", "record",
15
+ "pipeline", "serve", "watch", "completion",
16
+ ];
17
+
18
+ const PIPELINE_SUBCOMMANDS = ["classify", "select", "resolve", "cascade", "test"];
19
+
20
+ const PROJECT_TYPES = ["code", "context", "data", "mix", "general"];
21
+ const TIERS = ["starter", "full"];
22
+ const RUNTIMES = ["claude", "cursor", "all"];
23
+ const PROFILES = ["lite", "standard", "full"];
24
+ const ONBOARDING_MODES = ["greenfield", "brownfield", "auto"];
25
+ const STAGES = ["initialize", "scope", "plan", "execute", "verify", "close"];
26
+ const WORKFLOWS = ["WF-01", "WF-02", "WF-03", "WF-04", "WF-05", "WF-06", "WF-07", "WF-08"];
27
+ const SHELLS = ["bash", "zsh", "fish", "powershell"];
28
+
29
+ const CMD_OPTIONS = {
30
+ check: ["--project-type", "-p", "--registry", "--json"],
31
+ scan: ["--registry", "--json", "--no-overview"],
32
+ route: ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
33
+ refine: ["--output", "-o", "--json"],
34
+ status: ["--json"],
35
+ upgrade: ["--dry-run"],
36
+ init: ["--tier", "--runtime", "--profile", "--onboarding", "--registry", "--json", "--describe"],
37
+ plan: ["--json"],
38
+ implement: ["--json"],
39
+ review: ["--json"],
40
+ digest: ["--status", "--json"],
41
+ close: ["--json"],
42
+ casestudy: ["--output", "-o", "--name", "--json"],
43
+ docs: ["--json"],
44
+ serve: ["--registry"],
45
+ watch: ["--registry"],
46
+ completion:["--install"],
47
+ "project-discovery": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
48
+ "context-refresh": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
49
+ "phase-complete": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
50
+ "backlog": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
51
+ "plan-create": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
52
+ "dependency-analysis": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
53
+ "debt-assessment": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
54
+ "docs-update": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
55
+ "cross-reference": ["--project-type", "-p", "--stage", "-s", "--first-session", "--registry", "--json"],
56
+ add: ["--directory", "-d", "--file", "--dry-run", "--json"],
57
+ record: ["--directory", "-d", "--dry-run", "--json"],
58
+ };
59
+
60
+ const ADD_TYPES = ["backlog", "decision", "finding", "session", "summary"];
61
+
62
+ const PIPELINE_OPTIONS = {
63
+ classify: ["--project-type", "-p", "--registry", "--json"],
64
+ select: ["--first-session", "--registry", "--json"],
65
+ resolve: ["--registry", "--json"],
66
+ cascade: ["--context", "--registry", "--json"],
67
+ test: ["--registry"],
68
+ };
69
+
70
+ // ---------------------------------------------------------------------------
71
+ // Bash completion script
72
+ // ---------------------------------------------------------------------------
73
+
74
+ function bashScript() {
75
+ return `# wwa bash completion — auto-generated by wwa completion bash
76
+ # Add to ~/.bashrc: eval "$(wwa completion bash)"
77
+
78
+ _wwa_completions() {
79
+ local cur prev cmd subcmd
80
+ COMPREPLY=()
81
+ cur="\${COMP_WORDS[COMP_CWORD]}"
82
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
83
+
84
+ # Determine the command (first non-option arg after wwa)
85
+ cmd=""
86
+ subcmd=""
87
+ for ((i=1; i<COMP_CWORD; i++)); do
88
+ case "\${COMP_WORDS[i]}" in
89
+ -*) ;;
90
+ *)
91
+ if [[ -z "$cmd" ]]; then
92
+ cmd="\${COMP_WORDS[i]}"
93
+ elif [[ "$cmd" == "pipeline" && -z "$subcmd" ]]; then
94
+ subcmd="\${COMP_WORDS[i]}"
95
+ fi
96
+ ;;
97
+ esac
98
+ done
99
+
100
+ # Complete command names
101
+ if [[ -z "$cmd" ]]; then
102
+ COMPREPLY=( $(compgen -W "${COMMANDS.join(" ")}" -- "$cur") )
103
+ return
104
+ fi
105
+
106
+ # Complete pipeline subcommands
107
+ if [[ "$cmd" == "pipeline" && -z "$subcmd" ]]; then
108
+ COMPREPLY=( $(compgen -W "${PIPELINE_SUBCOMMANDS.join(" ")}" -- "$cur") )
109
+ return
110
+ fi
111
+
112
+ # Complete add type (first positional)
113
+ if [[ "$cmd" == "add" && "$prev" == "add" ]]; then
114
+ COMPREPLY=( $(compgen -W "${ADD_TYPES.join(" ")}" -- "$cur") )
115
+ return
116
+ fi
117
+
118
+ # Complete option values
119
+ case "$prev" in
120
+ -p|--project-type)
121
+ COMPREPLY=( $(compgen -W "${PROJECT_TYPES.join(" ")}" -- "$cur") )
122
+ return ;;
123
+ --tier)
124
+ COMPREPLY=( $(compgen -W "${TIERS.join(" ")}" -- "$cur") )
125
+ return ;;
126
+ --runtime)
127
+ COMPREPLY=( $(compgen -W "${RUNTIMES.join(" ")}" -- "$cur") )
128
+ return ;;
129
+ --profile|--context)
130
+ COMPREPLY=( $(compgen -W "${PROFILES.join(" ")}" -- "$cur") )
131
+ return ;;
132
+ --onboarding)
133
+ COMPREPLY=( $(compgen -W "${ONBOARDING_MODES.join(" ")}" -- "$cur") )
134
+ return ;;
135
+ -s|--stage)
136
+ COMPREPLY=( $(compgen -W "${STAGES.join(" ")}" -- "$cur") )
137
+ return ;;
138
+ esac
139
+
140
+ # Complete options for pipeline subcommands
141
+ if [[ "$cmd" == "pipeline" && -n "$subcmd" ]]; then
142
+ local opts="${Object.entries(PIPELINE_OPTIONS).map(([k, v]) => `${k}) opts="${v.join(" ")}" ;;`).join("\n ")}"
143
+ case "$subcmd" in
144
+ ${Object.entries(PIPELINE_OPTIONS).map(([k, v]) => `${k}) COMPREPLY=( $(compgen -W "${v.join(" ")}" -- "$cur") ) ;;`).join("\n ")}
145
+ esac
146
+ return
147
+ fi
148
+
149
+ # Complete init positional arg (project type)
150
+ if [[ "$cmd" == "init" && "$cur" != -* ]]; then
151
+ COMPREPLY=( $(compgen -W "${PROJECT_TYPES.join(" ")}" -- "$cur") )
152
+ return
153
+ fi
154
+
155
+ # Complete docs directory (first positional) — Phase 7r
156
+ if [[ "$cmd" == "docs" && "$cur" != -* ]]; then
157
+ COMPREPLY=( $(compgen -d -- "$cur") )
158
+ return
159
+ fi
160
+
161
+ # Complete completion positional arg (shell name)
162
+ if [[ "$cmd" == "completion" && "$cur" != -* ]]; then
163
+ COMPREPLY=( $(compgen -W "${SHELLS.join(" ")}" -- "$cur") )
164
+ return
165
+ fi
166
+
167
+ # Complete options for the current command
168
+ case "$cmd" in
169
+ ${Object.entries(CMD_OPTIONS).map(([k, v]) => `${k}) COMPREPLY=( $(compgen -W "${v.join(" ")}" -- "$cur") ) ;;`).join("\n ")}
170
+ esac
171
+ }
172
+
173
+ complete -o default -F _wwa_completions wwa
174
+ complete -o default -F _wwa_completions agent-method
175
+ `;
176
+ }
177
+
178
+ // ---------------------------------------------------------------------------
179
+ // Zsh completion script
180
+ // ---------------------------------------------------------------------------
181
+
182
+ function zshScript() {
183
+ return `#compdef wwa agent-method
184
+ # wwa zsh completion — auto-generated by wwa completion zsh
185
+ # Add to ~/.zshrc: eval "$(wwa completion zsh)"
186
+
187
+ _wwa() {
188
+ local -a commands pipeline_commands project_types tiers runtimes profiles stages shells
189
+
190
+ commands=(
191
+ 'check:Validate your entry point and project setup'
192
+ 'scan:Detect project type from directory contents'
193
+ 'route:Show how a query routes through the pipeline'
194
+ 'refine:Extract a refinement report from session history'
195
+ 'status:Check if your methodology version is current'
196
+ 'upgrade:Update your project to the latest methodology version'
197
+ 'init:Set up a new project with methodology templates'
198
+ 'plan:Display current plan status from PLAN.md'
199
+ 'implement:Show implementation guidance for the current plan step'
200
+ 'review:Display project review dashboard'
201
+ 'digest:Show management digest'
202
+ 'close:Session close checklist and cascade reminders'
203
+ 'pipeline:Advanced pipeline commands for debugging'
204
+ 'serve:Start MCP server on stdio transport'
205
+ 'watch:Watch files and validate on save'
206
+ 'completion:Generate shell completion scripts'
207
+ )
208
+
209
+ pipeline_commands=(
210
+ 'classify:Classify a natural language query'
211
+ 'select:Select workflow for a query type'
212
+ 'resolve:Resolve features for a workflow stage'
213
+ 'cascade:Compute cascade chain from a trigger'
214
+ 'test:Run YAML test fixtures'
215
+ )
216
+
217
+ project_types=(${PROJECT_TYPES.map(t => `'${t}'`).join(" ")})
218
+ tiers=(${TIERS.map(t => `'${t}'`).join(" ")})
219
+ runtimes=(${RUNTIMES.map(t => `'${t}'`).join(" ")})
220
+ profiles=(${PROFILES.map(t => `'${t}'`).join(" ")})
221
+ stages=(${STAGES.map(t => `'${t}'`).join(" ")})
222
+ shells=(${SHELLS.map(t => `'${t}'`).join(" ")})
223
+
224
+ _arguments -C \\
225
+ '1:command:->command' \\
226
+ '*::arg:->args'
227
+
228
+ case $state in
229
+ command)
230
+ _describe 'wwa command' commands
231
+ ;;
232
+ args)
233
+ case $words[1] in
234
+ check)
235
+ _arguments \\
236
+ '(-p --project-type)'{-p,--project-type}'[Project type]:type:($project_types)' \\
237
+ '--registry[Path to feature-registry.yaml]:file:_files' \\
238
+ '--json[Output as JSON]' \\
239
+ '1:entry-point:_files'
240
+ ;;
241
+ scan)
242
+ _arguments \\
243
+ '--registry[Path to feature-registry.yaml]:file:_files' \\
244
+ '--json[Output as JSON]' \\
245
+ '1:directory:_directories'
246
+ ;;
247
+ route)
248
+ _arguments \\
249
+ '(-p --project-type)'{-p,--project-type}'[Project type]:type:($project_types)' \\
250
+ '(-s --stage)'{-s,--stage}'[Workflow stage]:stage:($stages)' \\
251
+ '--first-session[Force WF-04 bootstrap]' \\
252
+ '--registry[Path to feature-registry.yaml]:file:_files' \\
253
+ '--json[Output as JSON]' \\
254
+ '1:query:'
255
+ ;;
256
+ refine)
257
+ _arguments \\
258
+ '(-o --output)'{-o,--output}'[Output file]:file:_files' \\
259
+ '--json[Output as JSON]' \\
260
+ '1:session-log:_files'
261
+ ;;
262
+ status)
263
+ _arguments '--json[Output as JSON]' '1:directory:_directories'
264
+ ;;
265
+ upgrade)
266
+ _arguments '--dry-run[Show changes without modifying]' '1:directory:_directories'
267
+ ;;
268
+ init)
269
+ _arguments \\
270
+ '--tier[Template tier]:tier:($tiers)' \\
271
+ '--runtime[Agent runtime]:runtime:($runtimes)' \\
272
+ '--profile[Integration profile]:profile:($profiles)' \\
273
+ '--onboarding[Onboarding mode]:mode:(greenfield brownfield auto)' \\
274
+ '--registry[Path to feature-registry.yaml]:file:_files' \\
275
+ '--json[Output as JSON]' \\
276
+ '--describe[Describe without creating files]' \\
277
+ '1:project-type:($project_types)' \\
278
+ '2:directory:_directories'
279
+ ;;
280
+ plan|implement|review|close)
281
+ _arguments '--json[Output as JSON]' '1:directory:_directories'
282
+ ;;
283
+ digest)
284
+ _arguments '--status[Show STATUS.md instead]' '--json[Output as JSON]' '1:directory:_directories'
285
+ ;;
286
+ casestudy)
287
+ _arguments \\
288
+ '(-o --output)'{-o,--output}'[Output file]:file:_files' \\
289
+ '--name[Project name override]:name:' \\
290
+ '--json[Output as JSON]' \\
291
+ '1:directory:_directories'
292
+ ;;
293
+ docs)
294
+ _arguments '--json[Output as JSON]' '1:directory:_directories'
295
+ ;;
296
+ project-discovery|context-refresh|phase-complete|backlog|plan-create|dependency-analysis|debt-assessment|docs-update|cross-reference)
297
+ _arguments \\
298
+ '(-p --project-type)'{-p,--project-type}'[Project type]:type:($project_types)' \\
299
+ '(-s --stage)'{-s,--stage}'[Workflow stage]:stage:($stages)' \\
300
+ '--first-session[Force WF-04 bootstrap]' \\
301
+ '--registry[Path to feature-registry.yaml]:file:_files' \\
302
+ '--json[Output as JSON]'
303
+ ;;
304
+ add)
305
+ _arguments \\
306
+ '(-d --directory)'{-d,--directory}'[Project directory]:dir:_directories' \\
307
+ '--file[Read content from file]:file:_files' \\
308
+ '--dry-run[Show what would be written]' \\
309
+ '--json[Output as JSON]' \\
310
+ '1:type:(backlog decision finding session summary)' \\
311
+ '*:content:'
312
+ ;;
313
+ pipeline)
314
+ _arguments '1:subcommand:->pipeline_sub' '*::arg:->pipeline_args'
315
+ case $state in
316
+ pipeline_sub)
317
+ _describe 'pipeline subcommand' pipeline_commands
318
+ ;;
319
+ pipeline_args)
320
+ case $words[1] in
321
+ classify)
322
+ _arguments \\
323
+ '(-p --project-type)'{-p,--project-type}'[Project type]:type:($project_types)' \\
324
+ '--registry[Path to registry]:file:_files' \\
325
+ '--json[Output as JSON]' \\
326
+ '1:query:'
327
+ ;;
328
+ select)
329
+ _arguments \\
330
+ '--first-session[Force WF-04]' \\
331
+ '--registry[Path to registry]:file:_files' \\
332
+ '--json[Output as JSON]' \\
333
+ '1:query-type:' \\
334
+ '2:project-type:($project_types)'
335
+ ;;
336
+ resolve)
337
+ _arguments \\
338
+ '--registry[Path to registry]:file:_files' \\
339
+ '--json[Output as JSON]' \\
340
+ '1:workflow-id:(WF-01 WF-02 WF-03 WF-04 WF-05 WF-06 WF-07 WF-08)' \\
341
+ '2:stage:($stages)'
342
+ ;;
343
+ cascade)
344
+ _arguments \\
345
+ '--context[Cascade context]:context:($project_types universal)' \\
346
+ '--registry[Path to registry]:file:_files' \\
347
+ '--json[Output as JSON]' \\
348
+ '1:trigger:'
349
+ ;;
350
+ test)
351
+ _arguments '--registry[Path to registry]:file:_files' '*:fixtures:_files'
352
+ ;;
353
+ esac
354
+ ;;
355
+ esac
356
+ ;;
357
+ serve)
358
+ _arguments '--registry[Path to feature-registry.yaml]:file:_files'
359
+ ;;
360
+ watch)
361
+ _arguments '--registry[Path to feature-registry.yaml]:file:_files' '1:directory:_directories'
362
+ ;;
363
+ completion)
364
+ _arguments '--install[Install to shell profile]' '1:shell:($shells)'
365
+ ;;
366
+ esac
367
+ ;;
368
+ esac
369
+ }
370
+
371
+ compdef _wwa wwa
372
+ compdef _wwa agent-method
373
+ `;
374
+ }
375
+
376
+ // ---------------------------------------------------------------------------
377
+ // Fish completion script
378
+ // ---------------------------------------------------------------------------
379
+
380
+ function fishScript() {
381
+ const lines = [
382
+ "# wwa fish completion — auto-generated by wwa completion fish",
383
+ "# Add to ~/.config/fish/completions/wwa.fish",
384
+ "",
385
+ "# Disable file completions by default",
386
+ "complete -c wwa -f",
387
+ "complete -c agent-method -f",
388
+ "",
389
+ "# Commands",
390
+ ];
391
+
392
+ const cmdDescs = {
393
+ check: "Validate your entry point",
394
+ scan: "Detect project type",
395
+ route: "Show query routing",
396
+ refine: "Extract refinement report",
397
+ status: "Check methodology version",
398
+ upgrade: "Update methodology files",
399
+ init: "Set up a new project",
400
+ plan: "Display current plan status",
401
+ implement: "Show implementation guidance",
402
+ review: "Display project review dashboard",
403
+ digest: "Show management digest",
404
+ close: "Session close checklist",
405
+ casestudy: "Extract structured case study",
406
+ docs: "Show docs coverage report",
407
+ "project-discovery": "Run project discovery workflow",
408
+ "context-refresh": "Run context refresh workflow",
409
+ "phase-complete": "Run phase completion workflow",
410
+ backlog: "Show routing for backlog",
411
+ "plan-create": "Run planning workflow",
412
+ "dependency-analysis": "Run dependency analysis workflow",
413
+ "debt-assessment": "Run debt assessment workflow",
414
+ "docs-update": "Run docs update workflow",
415
+ "cross-reference": "Run cross-reference workflow",
416
+ add: "Append to backlog, decision, finding, session, summary",
417
+ record: "Record last CLI run summary to SESSION-LOG.md",
418
+ pipeline: "Advanced pipeline commands",
419
+ serve: "Start MCP server",
420
+ watch: "Watch files for changes",
421
+ completion: "Generate shell completions",
422
+ };
423
+
424
+ for (const [cmd, desc] of Object.entries(cmdDescs)) {
425
+ lines.push(`complete -c wwa -n "__fish_use_subcommand" -a "${cmd}" -d "${desc}"`);
426
+ lines.push(`complete -c agent-method -n "__fish_use_subcommand" -a "${cmd}" -d "${desc}"`);
427
+ }
428
+
429
+ lines.push("", "# Pipeline subcommands");
430
+ const pipeDescs = {
431
+ classify: "Classify a query", select: "Select workflow",
432
+ resolve: "Resolve features", cascade: "Compute cascade",
433
+ test: "Run test fixtures",
434
+ };
435
+ for (const [sub, desc] of Object.entries(pipeDescs)) {
436
+ lines.push(`complete -c wwa -n "__fish_seen_subcommand_from pipeline" -a "${sub}" -d "${desc}"`);
437
+ lines.push(`complete -c agent-method -n "__fish_seen_subcommand_from pipeline" -a "${sub}" -d "${desc}"`);
438
+ }
439
+
440
+ lines.push("", "# Global options");
441
+ lines.push(`complete -c wwa -l json -d "Output as JSON"`);
442
+ lines.push(`complete -c wwa -l registry -d "Path to feature-registry.yaml" -rF`);
443
+ lines.push(`complete -c agent-method -l json -d "Output as JSON"`);
444
+ lines.push(`complete -c agent-method -l registry -d "Path to feature-registry.yaml" -rF`);
445
+
446
+ lines.push("", "# Project type completions for -p/--project-type and init");
447
+ for (const bin of ["wwa", "agent-method"]) {
448
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from check route init" -s p -l project-type -xa "${PROJECT_TYPES.join(" ")}" -d "Project type"`);
449
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from init" -xa "${PROJECT_TYPES.join(" ")}"`);
450
+ }
451
+
452
+ lines.push("", "# Command-specific options");
453
+ for (const bin of ["wwa", "agent-method"]) {
454
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from route" -s s -l stage -xa "${STAGES.join(" ")}" -d "Workflow stage"`);
455
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from route" -l first-session -d "Force WF-04 bootstrap"`);
456
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from refine" -s o -l output -d "Output file" -rF`);
457
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from upgrade" -l dry-run -d "Show changes without modifying"`);
458
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from init" -l tier -xa "${TIERS.join(" ")}" -d "Template tier"`);
459
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from init" -l runtime -xa "${RUNTIMES.join(" ")}" -d "Agent runtime"`);
460
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from init" -l profile -xa "${PROFILES.join(" ")}" -d "Integration profile"`);
461
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from init" -l onboarding -xa "${ONBOARDING_MODES.join(" ")}" -d "Onboarding mode"`);
462
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from init" -l describe -d "Describe without creating files"`);
463
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from casestudy" -s o -l output -d "Output file" -rF`);
464
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from casestudy" -l name -d "Project name override"`);
465
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from digest" -l status -d "Show STATUS.md instead"`);
466
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from completion" -xa "${SHELLS.join(" ")}"`);
467
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from completion" -l install -d "Install to shell profile"`);
468
+ const routableCmds = "project-discovery context-refresh phase-complete backlog plan-create dependency-analysis debt-assessment docs-update cross-reference";
469
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from ${routableCmds}" -s p -l project-type -xa "${PROJECT_TYPES.join(" ")}" -d "Project type"`);
470
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from ${routableCmds}" -s s -l stage -xa "${STAGES.join(" ")}" -d "Workflow stage"`);
471
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from ${routableCmds}" -l first-session -d "Force WF-04 bootstrap"`);
472
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from add" -s d -l directory -d "Project directory" -a "(pwd)"`);
473
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from add" -l file -d "Read content from file" -rF`);
474
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from add" -l dry-run -d "Show what would be written"`);
475
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from add" -xa "${ADD_TYPES.join(" ")}" -d "Type (backlog, decision, finding, session, summary)"`);
476
+ lines.push(`complete -c ${bin} -n "__fish_seen_subcommand_from docs" -xa "(__fish_complete_directories)" -d "Project directory"`);
477
+ }
478
+
479
+ lines.push("");
480
+ return lines.join("\n");
481
+ }
482
+
483
+ // ---------------------------------------------------------------------------
484
+ // PowerShell completion script
485
+ // ---------------------------------------------------------------------------
486
+
487
+ function powershellScript() {
488
+ return `# wwa PowerShell completion — auto-generated by wwa completion powershell
489
+ # Add to $PROFILE: wwa completion powershell | Out-String | Invoke-Expression
490
+
491
+ $wwaCommands = @(${COMMANDS.map(c => `'${c}'`).join(", ")})
492
+ $wwaPipelineSubs = @(${PIPELINE_SUBCOMMANDS.map(c => `'${c}'`).join(", ")})
493
+ $wwaAddTypes = @(${ADD_TYPES.map(c => `'${c}'`).join(", ")})
494
+ $wwaProjectTypes = @(${PROJECT_TYPES.map(c => `'${c}'`).join(", ")})
495
+ $wwaTiers = @(${TIERS.map(c => `'${c}'`).join(", ")})
496
+ $wwaRuntimes = @(${RUNTIMES.map(c => `'${c}'`).join(", ")})
497
+ $wwaProfiles = @(${PROFILES.map(c => `'${c}'`).join(", ")})
498
+ $wwaOnboarding = @(${ONBOARDING_MODES.map(c => `'${c}'`).join(", ")})
499
+ $wwaStages = @(${STAGES.map(c => `'${c}'`).join(", ")})
500
+ $wwaWorkflows = @(${WORKFLOWS.map(c => `'${c}'`).join(", ")})
501
+ $wwaShells = @(${SHELLS.map(c => `'${c}'`).join(", ")})
502
+
503
+ Register-ArgumentCompleter -CommandName wwa, agent-method -ScriptBlock {
504
+ param($wordToComplete, $commandAst, $cursorPosition)
505
+
506
+ $tokens = $commandAst.ToString().Substring(0, $cursorPosition).Trim() -split '\\s+'
507
+ $cmd = if ($tokens.Count -gt 1) { $tokens[1] } else { '' }
508
+ $subcmd = if ($tokens.Count -gt 2 -and $cmd -eq 'pipeline') { $tokens[2] } else { '' }
509
+ $prev = if ($tokens.Count -gt 1) { $tokens[-2] } else { '' }
510
+
511
+ # Option value completions
512
+ switch ($prev) {
513
+ { $_ -in '-p', '--project-type' } { $wwaProjectTypes | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }; return }
514
+ '--tier' { $wwaTiers | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }; return }
515
+ '--runtime' { $wwaRuntimes | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }; return }
516
+ { $_ -in '--profile', '--context' } { $wwaProfiles | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }; return }
517
+ '--onboarding' { $wwaOnboarding | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }; return }
518
+ { $_ -in '-s', '--stage' } { $wwaStages | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }; return }
519
+ }
520
+
521
+ # Command completions
522
+ if (-not $cmd -or ($tokens.Count -eq 2 -and $wordToComplete)) {
523
+ $wwaCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
524
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
525
+ }
526
+ return
527
+ }
528
+
529
+ # Pipeline subcommand completions
530
+ if ($cmd -eq 'pipeline' -and (-not $subcmd -or ($tokens.Count -eq 3 -and $wordToComplete))) {
531
+ $wwaPipelineSubs | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
532
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
533
+ }
534
+ return
535
+ }
536
+
537
+ # Init project type completions
538
+ if ($cmd -eq 'init' -and $wordToComplete -notlike '-*') {
539
+ $wwaProjectTypes | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
540
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
541
+ }
542
+ return
543
+ }
544
+
545
+ # Completion shell name completions
546
+ if ($cmd -eq 'completion' -and $wordToComplete -notlike '-*') {
547
+ $wwaShells | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
548
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
549
+ }
550
+ return
551
+ }
552
+
553
+ # Pipeline resolve workflow completions
554
+ if ($cmd -eq 'pipeline' -and $subcmd -eq 'resolve' -and $tokens.Count -eq 4 -and $wordToComplete) {
555
+ $wwaWorkflows | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
556
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
557
+ }
558
+ return
559
+ }
560
+
561
+ # Add type completions (first positional after add)
562
+ if ($cmd -eq 'add' -and $tokens.Count -eq 3 -and $wordToComplete) {
563
+ $wwaAddTypes | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
564
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
565
+ }
566
+ return
567
+ }
568
+
569
+ # docs directory completions (first positional) — Phase 7r
570
+ if ($cmd -eq 'docs' -and $wordToComplete -notlike '-*') {
571
+ try {
572
+ Get-ChildItem -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "$wordToComplete*" } | ForEach-Object {
573
+ [System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Name)
574
+ }
575
+ } catch {}
576
+ return
577
+ }
578
+
579
+ # Option completions per command
580
+ $opts = @()
581
+ switch ($cmd) {
582
+ 'check' { $opts = @('--project-type', '-p', '--registry', '--json') }
583
+ 'scan' { $opts = @('--registry', '--json', '--no-overview') }
584
+ 'route' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
585
+ 'refine' { $opts = @('--output', '-o', '--json') }
586
+ 'status' { $opts = @('--json') }
587
+ 'upgrade' { $opts = @('--dry-run') }
588
+ 'init' { $opts = @('--tier', '--runtime', '--profile', '--onboarding', '--registry', '--json', '--describe') }
589
+ 'plan' { $opts = @('--json') }
590
+ 'implement' { $opts = @('--json') }
591
+ 'review' { $opts = @('--json') }
592
+ 'digest' { $opts = @('--status', '--json') }
593
+ 'close' { $opts = @('--json') }
594
+ 'casestudy' { $opts = @('--output', '-o', '--name', '--json') }
595
+ 'docs' { $opts = @('--json') }
596
+ 'project-discovery' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
597
+ 'context-refresh' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
598
+ 'phase-complete' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
599
+ 'backlog' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
600
+ 'plan-create' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
601
+ 'dependency-analysis' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
602
+ 'debt-assessment' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
603
+ 'docs-update' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
604
+ 'cross-reference' { $opts = @('--project-type', '-p', '--stage', '-s', '--first-session', '--registry', '--json') }
605
+ 'add' { $opts = @('--directory', '-d', '--file', '--dry-run', '--json') }
606
+ 'record' { $opts = @('--directory', '-d', '--dry-run', '--json') }
607
+ 'serve' { $opts = @('--registry') }
608
+ 'watch' { $opts = @('--registry') }
609
+ 'completion' { $opts = @('--install') }
610
+ 'pipeline' {
611
+ switch ($subcmd) {
612
+ 'classify' { $opts = @('--project-type', '-p', '--registry', '--json') }
613
+ 'select' { $opts = @('--first-session', '--registry', '--json') }
614
+ 'resolve' { $opts = @('--registry', '--json') }
615
+ 'cascade' { $opts = @('--context', '--registry', '--json') }
616
+ 'test' { $opts = @('--registry') }
617
+ }
618
+ }
619
+ }
620
+
621
+ $opts | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
622
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterName', $_)
623
+ }
624
+ }
625
+ `;
626
+ }
627
+
628
+ // ---------------------------------------------------------------------------
629
+ // Shell profile paths and install logic
630
+ // ---------------------------------------------------------------------------
631
+
632
+ import { existsSync, readFileSync, appendFileSync } from "node:fs";
633
+ import { join } from "node:path";
634
+ import { homedir } from "node:os";
635
+
636
+ function detectShell() {
637
+ const shell = process.env.SHELL || "";
638
+ if (shell.includes("zsh")) return "zsh";
639
+ if (shell.includes("fish")) return "fish";
640
+ if (shell.includes("bash")) return "bash";
641
+ // Windows: check for PowerShell
642
+ if (process.env.PSModulePath || process.platform === "win32") return "powershell";
643
+ return "bash";
644
+ }
645
+
646
+ function getScript(shell) {
647
+ switch (shell) {
648
+ case "bash": return bashScript();
649
+ case "zsh": return zshScript();
650
+ case "fish": return fishScript();
651
+ case "powershell": return powershellScript();
652
+ default:
653
+ console.error(`Unknown shell: ${shell}\nSupported: ${SHELLS.join(", ")}`);
654
+ process.exit(1);
655
+ }
656
+ }
657
+
658
+ function getProfilePath(shell) {
659
+ const home = homedir();
660
+ switch (shell) {
661
+ case "bash": return join(home, ".bashrc");
662
+ case "zsh": return join(home, ".zshrc");
663
+ case "fish": return join(home, ".config", "fish", "completions", "wwa.fish");
664
+ case "powershell": return process.env.PROFILE || join(home, "Documents", "PowerShell", "Microsoft.PowerShell_profile.ps1");
665
+ default: return null;
666
+ }
667
+ }
668
+
669
+ function installSnippet(shell) {
670
+ switch (shell) {
671
+ case "bash": return '\n# wwa shell completion\neval "$(wwa completion bash)"\n';
672
+ case "zsh": return '\n# wwa shell completion\neval "$(wwa completion zsh)"\n';
673
+ case "fish": return null; // fish uses a file, not a snippet
674
+ case "powershell": return '\n# wwa shell completion\nwwa completion powershell | Out-String | Invoke-Expression\n';
675
+ default: return null;
676
+ }
677
+ }
678
+
679
+ // ---------------------------------------------------------------------------
680
+ // Register command
681
+ // ---------------------------------------------------------------------------
682
+
683
+ export function register(program) {
684
+ program
685
+ .command("completion [shell]")
686
+ .description("Generate shell completion scripts (bash, zsh, fish, powershell)")
687
+ .option("--install", "Install completions to your shell profile")
688
+ .action(async (shell, opts) => {
689
+ shell = shell || detectShell();
690
+
691
+ if (!SHELLS.includes(shell)) {
692
+ console.error(`Unknown shell: ${shell}\nSupported: ${SHELLS.join(", ")}`);
693
+ process.exit(1);
694
+ }
695
+
696
+ if (opts.install) {
697
+ const profilePath = getProfilePath(shell);
698
+
699
+ if (shell === "fish") {
700
+ // Fish uses a completions file directly
701
+ const { mkdirSync } = await import("node:fs");
702
+ const dir = join(homedir(), ".config", "fish", "completions");
703
+ mkdirSync(dir, { recursive: true });
704
+ const { writeFileSync } = await import("node:fs");
705
+ writeFileSync(profilePath, getScript(shell), "utf-8");
706
+ console.log(`Completions written to ${profilePath}`);
707
+ console.log("Restart your shell or run: source ~/.config/fish/config.fish");
708
+ return;
709
+ }
710
+
711
+ const snippet = installSnippet(shell);
712
+ if (!snippet) {
713
+ console.error(`Cannot auto-install for ${shell}. Output the script manually:\n wwa completion ${shell}`);
714
+ process.exit(1);
715
+ }
716
+
717
+ // Check if already installed
718
+ if (existsSync(profilePath)) {
719
+ const content = readFileSync(profilePath, "utf-8");
720
+ if (content.includes("wwa completion")) {
721
+ console.log(`Completions already installed in ${profilePath}`);
722
+ return;
723
+ }
724
+ }
725
+
726
+ appendFileSync(profilePath, snippet, "utf-8");
727
+ console.log(`Completions added to ${profilePath}`);
728
+ console.log(`Restart your shell or run: source ${profilePath}`);
729
+ return;
730
+ }
731
+
732
+ // Print the script to stdout for eval
733
+ process.stdout.write(getScript(shell));
734
+ });
735
+ }