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