|
6 | 6 | } from "./cli-schema.mjs"; |
7 | 7 | import { ENGINES, ENGINE_ALIASES } from "./engines.mjs"; |
8 | 8 | import { TOOLS } from "./tools.mjs"; |
| 9 | +import { moshVocabulary } from "./commands.mjs"; |
9 | 10 |
|
10 | 11 | export const COMPLETION_SHELLS = ["bash", "zsh", "fish", "powershell"]; |
11 | 12 |
|
@@ -54,6 +55,16 @@ export function completionModel() { |
54 | 55 | skills: uniqueEntries(SKILL_VERBS), |
55 | 56 | skillSources: uniqueEntries(SKILL_VERBS.filter(({ acceptsSource }) => acceptsSource)), |
56 | 57 | shells: COMPLETION_SHELLS.map((name) => entry(name, `generate ${name} completion`)), |
| 58 | + // `moshcode help <topic>` accepts anything help can answer for: a command, |
| 59 | + // an engine, a tool, or a moshscript verb (PRD 0006 R16). Offering the same |
| 60 | + // set here is what keeps tab-completion and help one discoverability |
| 61 | + // surface rather than two that disagree. |
| 62 | + helpTopics: uniqueEntries([ |
| 63 | + ...CORE_CLI_COMMANDS.filter(({ name }) => !name.startsWith("-")), |
| 64 | + ...engines, |
| 65 | + ...tools, |
| 66 | + ...moshVocabulary().all().map((c) => entry(c.name, c.summary || "moshscript verb")), |
| 67 | + ]), |
57 | 68 | }; |
58 | 69 | } |
59 | 70 |
|
@@ -110,6 +121,7 @@ ${powershellEntries("MoshcodeCompletionMcpServerSpecs", model.mcpServerSpecs)} |
110 | 121 | ${powershellEntries("MoshcodeCompletionSkills", model.skills)} |
111 | 122 | ${powershellEntries("MoshcodeCompletionSkillSources", model.skillSources)} |
112 | 123 | ${powershellEntries("MoshcodeCompletionShells", model.shells)} |
| 124 | +${powershellEntries("MoshcodeCompletionHelpTopics", model.helpTopics)} |
113 | 125 | ${powershellEntries("MoshcodeCompletionJson", optionEntries("--json", "print JSON"))} |
114 | 126 | ${powershellEntries("MoshcodeCompletionLogin", optionEntries("--browser -b --device -d", "authentication mode"))} |
115 | 127 | ${powershellEntries("MoshcodeCompletionRun", optionEntries("--dry-run --max -n", "run option"))} |
@@ -154,6 +166,9 @@ Register-ArgumentCompleter -Native -CommandName moshcode -ScriptBlock { |
154 | 166 | { $_ -in @('upgrade', 'update') } { |
155 | 167 | $choices = $script:MoshcodeCompletionUpgrade |
156 | 168 | } |
| 169 | + 'help' { |
| 170 | + if ($argumentIndex -eq 2) { $choices = $script:MoshcodeCompletionHelpTopics } |
| 171 | + } |
157 | 172 | 'completion' { |
158 | 173 | if ($argumentIndex -eq 2) { $choices = $script:MoshcodeCompletionShells } |
159 | 174 | } |
@@ -244,6 +259,9 @@ _moshcode_completion() { |
244 | 259 | completion) |
245 | 260 | (( COMP_CWORD == 2 )) && choices="${names(model.shells)}" |
246 | 261 | ;; |
| 262 | + help) |
| 263 | + (( COMP_CWORD == 2 )) && choices="${names(model.helpTopics)}" |
| 264 | + ;; |
247 | 265 | mcp) |
248 | 266 | if (( COMP_CWORD == 2 )); then |
249 | 267 | choices="${names(model.mcp)}" |
@@ -350,6 +368,12 @@ _moshcode() { |
350 | 368 | _describe "shell" choices |
351 | 369 | fi |
352 | 370 | ;; |
| 371 | + help) |
| 372 | + if (( CURRENT == 3 )); then |
| 373 | + choices=(${zshValues(model.helpTopics)}) |
| 374 | + _describe "help topic" choices |
| 375 | + fi |
| 376 | + ;; |
353 | 377 | mcp) |
354 | 378 | if (( CURRENT == 3 )); then |
355 | 379 | choices=(${zshValues(model.mcp)}) |
@@ -458,6 +482,7 @@ ${fishEntries(atSecondToken("install"), model.install)} |
458 | 482 | ${fishEntries(atSecondToken("uninstall remove"), model.uninstall)} |
459 | 483 | ${fishEntries("__moshcode_command_is upgrade update", model.upgrade)} |
460 | 484 | ${fishEntries(atSecondToken("completion"), model.shells)} |
| 485 | +${fishEntries(atSecondToken("help"), model.helpTopics)} |
461 | 486 | ${fishEntries(atSecondToken("mcp"), model.mcp)} |
462 | 487 | ${fishEntries(atSecondToken("skill skills"), model.skills)} |
463 | 488 | complete -c moshcode -n '__moshcode_nested_is mcp list' -l json -d 'print JSON' |
|
0 commit comments