@dedesfr/prompter 0.6.15 → 0.7.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.
- package/CHANGELOG.md +5 -0
- package/dist/cli/index.js +144 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/archive.d.ts +11 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/archive.js +280 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/change.d.ts +35 -0
- package/dist/commands/change.d.ts.map +1 -0
- package/dist/commands/change.js +277 -0
- package/dist/commands/change.js.map +1 -0
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +198 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/list.d.ts +2 -2
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +153 -47
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/show.d.ts +14 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +132 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/spec.d.ts +15 -0
- package/dist/commands/spec.d.ts.map +1 -0
- package/dist/commands/spec.js +225 -0
- package/dist/commands/spec.js.map +1 -0
- package/dist/commands/validate.d.ts +24 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +294 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/core/artifact-graph/graph.d.ts +56 -0
- package/dist/core/artifact-graph/graph.d.ts.map +1 -0
- package/dist/core/artifact-graph/graph.js +141 -0
- package/dist/core/artifact-graph/graph.js.map +1 -0
- package/dist/core/artifact-graph/index.d.ts +7 -0
- package/dist/core/artifact-graph/index.d.ts.map +1 -0
- package/dist/core/artifact-graph/index.js +13 -0
- package/dist/core/artifact-graph/index.js.map +1 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +130 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts.map +1 -0
- package/dist/core/artifact-graph/instruction-loader.js +173 -0
- package/dist/core/artifact-graph/instruction-loader.js.map +1 -0
- package/dist/core/artifact-graph/resolver.d.ts +61 -0
- package/dist/core/artifact-graph/resolver.d.ts.map +1 -0
- package/dist/core/artifact-graph/resolver.js +187 -0
- package/dist/core/artifact-graph/resolver.js.map +1 -0
- package/dist/core/artifact-graph/schema.d.ts +13 -0
- package/dist/core/artifact-graph/schema.d.ts.map +1 -0
- package/dist/core/artifact-graph/schema.js +108 -0
- package/dist/core/artifact-graph/schema.js.map +1 -0
- package/dist/core/artifact-graph/state.d.ts +12 -0
- package/dist/core/artifact-graph/state.d.ts.map +1 -0
- package/dist/core/artifact-graph/state.js +54 -0
- package/dist/core/artifact-graph/state.js.map +1 -0
- package/dist/core/artifact-graph/types.d.ts +45 -0
- package/dist/core/artifact-graph/types.d.ts.map +1 -0
- package/dist/core/artifact-graph/types.js +43 -0
- package/dist/core/artifact-graph/types.js.map +1 -0
- package/dist/core/completions/command-registry.d.ts +7 -0
- package/dist/core/completions/command-registry.d.ts.map +1 -0
- package/dist/core/completions/command-registry.js +380 -0
- package/dist/core/completions/command-registry.js.map +1 -0
- package/dist/core/completions/completion-provider.d.ts +60 -0
- package/dist/core/completions/completion-provider.d.ts.map +1 -0
- package/dist/core/completions/completion-provider.js +102 -0
- package/dist/core/completions/completion-provider.js.map +1 -0
- package/dist/core/completions/generators/bash-generator.d.ts +32 -0
- package/dist/core/completions/generators/bash-generator.d.ts.map +1 -0
- package/dist/core/completions/generators/bash-generator.js +174 -0
- package/dist/core/completions/generators/bash-generator.js.map +1 -0
- package/dist/core/completions/generators/fish-generator.d.ts +32 -0
- package/dist/core/completions/generators/fish-generator.d.ts.map +1 -0
- package/dist/core/completions/generators/fish-generator.js +157 -0
- package/dist/core/completions/generators/fish-generator.js.map +1 -0
- package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
- package/dist/core/completions/generators/powershell-generator.d.ts.map +1 -0
- package/dist/core/completions/generators/powershell-generator.js +207 -0
- package/dist/core/completions/generators/powershell-generator.js.map +1 -0
- package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
- package/dist/core/completions/generators/zsh-generator.d.ts.map +1 -0
- package/dist/core/completions/generators/zsh-generator.js +250 -0
- package/dist/core/completions/generators/zsh-generator.js.map +1 -0
- package/dist/core/completions/templates/bash-templates.d.ts +6 -0
- package/dist/core/completions/templates/bash-templates.d.ts.map +1 -0
- package/dist/core/completions/templates/bash-templates.js +24 -0
- package/dist/core/completions/templates/bash-templates.js.map +1 -0
- package/dist/core/completions/templates/fish-templates.d.ts +7 -0
- package/dist/core/completions/templates/fish-templates.d.ts.map +1 -0
- package/dist/core/completions/templates/fish-templates.js +39 -0
- package/dist/core/completions/templates/fish-templates.js.map +1 -0
- package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
- package/dist/core/completions/templates/powershell-templates.d.ts.map +1 -0
- package/dist/core/completions/templates/powershell-templates.js +25 -0
- package/dist/core/completions/templates/powershell-templates.js.map +1 -0
- package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
- package/dist/core/completions/templates/zsh-templates.d.ts.map +1 -0
- package/dist/core/completions/templates/zsh-templates.js +36 -0
- package/dist/core/completions/templates/zsh-templates.js.map +1 -0
- package/dist/core/completions/types.d.ts +78 -0
- package/dist/core/completions/types.d.ts.map +1 -0
- package/dist/core/completions/types.js +2 -0
- package/dist/core/completions/types.js.map +1 -0
- package/dist/core/config-schema.d.ts +76 -0
- package/dist/core/config-schema.d.ts.map +1 -0
- package/dist/core/config-schema.js +200 -0
- package/dist/core/config-schema.js.map +1 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +18 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/configurators/slash/antigravity.d.ts.map +1 -1
- package/dist/core/configurators/slash/antigravity.js +6 -0
- package/dist/core/configurators/slash/antigravity.js.map +1 -1
- package/dist/core/configurators/slash/base.js +1 -1
- package/dist/core/configurators/slash/base.js.map +1 -1
- package/dist/core/configurators/slash/claude.d.ts.map +1 -1
- package/dist/core/configurators/slash/claude.js +6 -0
- package/dist/core/configurators/slash/claude.js.map +1 -1
- package/dist/core/configurators/slash/codex.d.ts.map +1 -1
- package/dist/core/configurators/slash/codex.js +6 -0
- package/dist/core/configurators/slash/codex.js.map +1 -1
- package/dist/core/configurators/slash/github-copilot.d.ts.map +1 -1
- package/dist/core/configurators/slash/github-copilot.js +6 -0
- package/dist/core/configurators/slash/github-copilot.js.map +1 -1
- package/dist/core/configurators/slash/kilocode.d.ts.map +1 -1
- package/dist/core/configurators/slash/kilocode.js +6 -0
- package/dist/core/configurators/slash/kilocode.js.map +1 -1
- package/dist/core/configurators/slash/opencode.d.ts.map +1 -1
- package/dist/core/configurators/slash/opencode.js +6 -0
- package/dist/core/configurators/slash/opencode.js.map +1 -1
- package/dist/core/converters/json-converter.d.ts +6 -0
- package/dist/core/converters/json-converter.d.ts.map +1 -0
- package/dist/core/converters/json-converter.js +51 -0
- package/dist/core/converters/json-converter.js.map +1 -0
- package/dist/core/global-config.d.ts +39 -0
- package/dist/core/global-config.d.ts.map +1 -0
- package/dist/core/global-config.js +115 -0
- package/dist/core/global-config.js.map +1 -0
- package/dist/core/parsers/change-parser.d.ts +13 -0
- package/dist/core/parsers/change-parser.d.ts.map +1 -0
- package/dist/core/parsers/change-parser.js +193 -0
- package/dist/core/parsers/change-parser.js.map +1 -0
- package/dist/core/parsers/markdown-parser.d.ts +22 -0
- package/dist/core/parsers/markdown-parser.d.ts.map +1 -0
- package/dist/core/parsers/markdown-parser.js +187 -0
- package/dist/core/parsers/markdown-parser.js.map +1 -0
- package/dist/core/parsers/requirement-blocks.d.ts +37 -0
- package/dist/core/parsers/requirement-blocks.d.ts.map +1 -0
- package/dist/core/parsers/requirement-blocks.js +201 -0
- package/dist/core/parsers/requirement-blocks.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +3 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +66 -0
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/schemas/base.schema.d.ts +13 -0
- package/dist/core/schemas/base.schema.d.ts.map +1 -0
- package/dist/core/schemas/base.schema.js +13 -0
- package/dist/core/schemas/base.schema.js.map +1 -0
- package/dist/core/schemas/change.schema.d.ts +73 -0
- package/dist/core/schemas/change.schema.d.ts.map +1 -0
- package/dist/core/schemas/change.schema.js +31 -0
- package/dist/core/schemas/change.schema.js.map +1 -0
- package/dist/core/schemas/index.d.ts +4 -0
- package/dist/core/schemas/index.d.ts.map +1 -0
- package/dist/core/schemas/index.js +4 -0
- package/dist/core/schemas/index.js.map +1 -0
- package/dist/core/schemas/spec.schema.d.ts +18 -0
- package/dist/core/schemas/spec.schema.d.ts.map +1 -0
- package/dist/core/schemas/spec.schema.js +15 -0
- package/dist/core/schemas/spec.schema.js.map +1 -0
- package/dist/core/specs-apply.d.ts +73 -0
- package/dist/core/specs-apply.d.ts.map +1 -0
- package/dist/core/specs-apply.js +384 -0
- package/dist/core/specs-apply.js.map +1 -0
- package/dist/core/styles/palette.d.ts +7 -0
- package/dist/core/styles/palette.d.ts.map +1 -0
- package/dist/core/styles/palette.js +8 -0
- package/dist/core/styles/palette.js.map +1 -0
- package/dist/core/templates/slash-command-templates.d.ts +1 -1
- package/dist/core/templates/slash-command-templates.d.ts.map +1 -1
- package/dist/core/templates/slash-command-templates.js +4 -1
- package/dist/core/templates/slash-command-templates.js.map +1 -1
- package/dist/core/validation/constants.d.ts +34 -0
- package/dist/core/validation/constants.d.ts.map +1 -0
- package/dist/core/validation/constants.js +40 -0
- package/dist/core/validation/constants.js.map +1 -0
- package/dist/core/validation/types.d.ts +18 -0
- package/dist/core/validation/types.d.ts.map +1 -0
- package/dist/core/validation/types.js +2 -0
- package/dist/core/validation/types.js.map +1 -0
- package/dist/core/validation/validator.d.ts +33 -0
- package/dist/core/validation/validator.d.ts.map +1 -0
- package/dist/core/validation/validator.js +409 -0
- package/dist/core/validation/validator.js.map +1 -0
- package/dist/core/view.d.ts +8 -0
- package/dist/core/view.d.ts.map +1 -0
- package/dist/core/view.js +168 -0
- package/dist/core/view.js.map +1 -0
- package/dist/utils/change-metadata.d.ts +47 -0
- package/dist/utils/change-metadata.d.ts.map +1 -0
- package/dist/utils/change-metadata.js +130 -0
- package/dist/utils/change-metadata.js.map +1 -0
- package/dist/utils/change-utils.d.ts +51 -0
- package/dist/utils/change-utils.d.ts.map +1 -0
- package/dist/utils/change-utils.js +100 -0
- package/dist/utils/change-utils.js.map +1 -0
- package/dist/utils/file-system.d.ts +25 -0
- package/dist/utils/file-system.d.ts.map +1 -0
- package/dist/utils/file-system.js +218 -0
- package/dist/utils/file-system.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/interactive.d.ts +18 -0
- package/dist/utils/interactive.d.ts.map +1 -0
- package/dist/utils/interactive.js +21 -0
- package/dist/utils/interactive.js.map +1 -0
- package/dist/utils/item-discovery.d.ts +4 -0
- package/dist/utils/item-discovery.d.ts.map +1 -0
- package/dist/utils/item-discovery.js +72 -0
- package/dist/utils/item-discovery.js.map +1 -0
- package/dist/utils/match.d.ts +3 -0
- package/dist/utils/match.d.ts.map +1 -0
- package/dist/utils/match.js +22 -0
- package/dist/utils/match.js.map +1 -0
- package/dist/utils/shell-detection.d.ts +20 -0
- package/dist/utils/shell-detection.d.ts.map +1 -0
- package/dist/utils/shell-detection.js +41 -0
- package/dist/utils/shell-detection.js.map +1 -0
- package/dist/utils/task-progress.d.ts +8 -0
- package/dist/utils/task-progress.d.ts.map +1 -0
- package/dist/utils/task-progress.js +36 -0
- package/dist/utils/task-progress.js.map +1 -0
- package/docs/tasks.md +1 -1
- package/package.json +6 -2
- package/prompt/apply.md +17 -0
- package/prompt/archive.md +21 -0
- package/prompt/proposal.md +22 -0
- package/src/cli/index.ts +151 -16
- package/src/commands/archive.ts +302 -0
- package/src/commands/change.ts +292 -0
- package/src/commands/config.ts +233 -0
- package/src/commands/list.ts +176 -66
- package/src/commands/show.ts +138 -0
- package/src/commands/spec.ts +251 -0
- package/src/commands/validate.ts +326 -0
- package/src/core/artifact-graph/graph.ts +167 -0
- package/src/core/artifact-graph/index.ts +44 -0
- package/src/core/artifact-graph/instruction-loader.ts +302 -0
- package/src/core/artifact-graph/resolver.ts +226 -0
- package/src/core/artifact-graph/schema.ts +124 -0
- package/src/core/artifact-graph/state.ts +64 -0
- package/src/core/artifact-graph/types.ts +65 -0
- package/src/core/completions/command-registry.ts +382 -0
- package/src/core/completions/completion-provider.ts +128 -0
- package/src/core/completions/generators/bash-generator.ts +191 -0
- package/src/core/completions/generators/fish-generator.ts +188 -0
- package/src/core/completions/generators/powershell-generator.ts +223 -0
- package/src/core/completions/generators/zsh-generator.ts +281 -0
- package/src/core/completions/templates/bash-templates.ts +24 -0
- package/src/core/completions/templates/fish-templates.ts +40 -0
- package/src/core/completions/templates/powershell-templates.ts +25 -0
- package/src/core/completions/templates/zsh-templates.ts +36 -0
- package/src/core/completions/types.ts +90 -0
- package/src/core/config-schema.ts +230 -0
- package/src/core/config.ts +18 -0
- package/src/core/configurators/slash/antigravity.ts +6 -0
- package/src/core/configurators/slash/base.ts +1 -1
- package/src/core/configurators/slash/claude.ts +6 -0
- package/src/core/configurators/slash/codex.ts +6 -0
- package/src/core/configurators/slash/github-copilot.ts +6 -0
- package/src/core/configurators/slash/kilocode.ts +6 -0
- package/src/core/configurators/slash/opencode.ts +6 -0
- package/src/core/converters/json-converter.ts +62 -0
- package/src/core/global-config.ts +136 -0
- package/src/core/parsers/change-parser.ts +234 -0
- package/src/core/parsers/markdown-parser.ts +237 -0
- package/src/core/parsers/requirement-blocks.ts +234 -0
- package/src/core/prompt-templates.ts +69 -0
- package/src/core/schemas/base.schema.ts +20 -0
- package/src/core/schemas/change.schema.ts +42 -0
- package/src/core/schemas/index.ts +20 -0
- package/src/core/schemas/spec.schema.ts +17 -0
- package/src/core/specs-apply.ts +483 -0
- package/src/core/styles/palette.ts +8 -0
- package/src/core/templates/slash-command-templates.ts +7 -1
- package/src/core/validation/constants.ts +48 -0
- package/src/core/validation/types.ts +19 -0
- package/src/core/validation/validator.ts +449 -0
- package/src/core/view.ts +219 -0
- package/src/utils/change-metadata.ts +171 -0
- package/src/utils/change-utils.ts +131 -0
- package/src/utils/file-system.ts +252 -0
- package/src/utils/index.ts +12 -0
- package/src/utils/interactive.ts +29 -0
- package/src/utils/item-discovery.ts +66 -0
- package/src/utils/match.ts +26 -0
- package/src/utils/shell-detection.ts +62 -0
- package/src/utils/task-progress.ts +43 -0
- package/dist/commands/ai-humanizer.d.ts +0 -11
- package/dist/commands/ai-humanizer.d.ts.map +0 -1
- package/dist/commands/ai-humanizer.js +0 -97
- package/dist/commands/ai-humanizer.js.map +0 -1
- package/dist/commands/api-contract-generator.d.ts +0 -11
- package/dist/commands/api-contract-generator.d.ts.map +0 -1
- package/dist/commands/api-contract-generator.js +0 -97
- package/dist/commands/api-contract-generator.js.map +0 -1
- package/dist/commands/design-system.d.ts +0 -11
- package/dist/commands/design-system.d.ts.map +0 -1
- package/dist/commands/design-system.js +0 -97
- package/dist/commands/design-system.js.map +0 -1
- package/dist/commands/document-explainer.d.ts +0 -11
- package/dist/commands/document-explainer.d.ts.map +0 -1
- package/dist/commands/document-explainer.js +0 -97
- package/dist/commands/document-explainer.js.map +0 -1
- package/dist/commands/epic-generator.d.ts +0 -11
- package/dist/commands/epic-generator.d.ts.map +0 -1
- package/dist/commands/epic-generator.js +0 -97
- package/dist/commands/epic-generator.js.map +0 -1
- package/dist/commands/erd-generator.d.ts +0 -11
- package/dist/commands/erd-generator.d.ts.map +0 -1
- package/dist/commands/erd-generator.js +0 -97
- package/dist/commands/erd-generator.js.map +0 -1
- package/dist/commands/fsd-generator.d.ts +0 -11
- package/dist/commands/fsd-generator.d.ts.map +0 -1
- package/dist/commands/fsd-generator.js +0 -97
- package/dist/commands/fsd-generator.js.map +0 -1
- package/dist/commands/prd-agent-generator.d.ts +0 -11
- package/dist/commands/prd-agent-generator.d.ts.map +0 -1
- package/dist/commands/prd-agent-generator.js +0 -95
- package/dist/commands/prd-agent-generator.js.map +0 -1
- package/dist/commands/prd-generator.d.ts +0 -11
- package/dist/commands/prd-generator.d.ts.map +0 -1
- package/dist/commands/prd-generator.js +0 -97
- package/dist/commands/prd-generator.js.map +0 -1
- package/dist/commands/product-brief.d.ts +0 -11
- package/dist/commands/product-brief.d.ts.map +0 -1
- package/dist/commands/product-brief.js +0 -97
- package/dist/commands/product-brief.js.map +0 -1
- package/dist/commands/skill-creator.d.ts +0 -11
- package/dist/commands/skill-creator.d.ts.map +0 -1
- package/dist/commands/skill-creator.js +0 -101
- package/dist/commands/skill-creator.js.map +0 -1
- package/dist/commands/story-generator.d.ts +0 -11
- package/dist/commands/story-generator.d.ts.map +0 -1
- package/dist/commands/story-generator.js +0 -97
- package/dist/commands/story-generator.js.map +0 -1
- package/dist/commands/tdd-generator.d.ts +0 -11
- package/dist/commands/tdd-generator.d.ts.map +0 -1
- package/dist/commands/tdd-generator.js +0 -97
- package/dist/commands/tdd-generator.js.map +0 -1
- package/dist/commands/tdd-lite-generator.d.ts +0 -11
- package/dist/commands/tdd-lite-generator.d.ts.map +0 -1
- package/dist/commands/tdd-lite-generator.js +0 -97
- package/dist/commands/tdd-lite-generator.js.map +0 -1
- package/dist/commands/wireframe-generator.d.ts +0 -11
- package/dist/commands/wireframe-generator.d.ts.map +0 -1
- package/dist/commands/wireframe-generator.js +0 -97
- package/dist/commands/wireframe-generator.js.map +0 -1
- package/src/commands/ai-humanizer.ts +0 -118
- package/src/commands/api-contract-generator.ts +0 -118
- package/src/commands/design-system.ts +0 -118
- package/src/commands/document-explainer.ts +0 -118
- package/src/commands/epic-generator.ts +0 -118
- package/src/commands/erd-generator.ts +0 -118
- package/src/commands/fsd-generator.ts +0 -118
- package/src/commands/prd-agent-generator.ts +0 -115
- package/src/commands/prd-generator.ts +0 -118
- package/src/commands/product-brief.ts +0 -118
- package/src/commands/skill-creator.ts +0 -123
- package/src/commands/story-generator.ts +0 -118
- package/src/commands/tdd-generator.ts +0 -118
- package/src/commands/tdd-lite-generator.ts +0 -118
- package/src/commands/wireframe-generator.ts +0 -118
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { CommandDefinition, FlagDefinition } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Common flags used across multiple commands
|
|
5
|
+
*/
|
|
6
|
+
const COMMON_FLAGS = {
|
|
7
|
+
json: {
|
|
8
|
+
name: 'json',
|
|
9
|
+
description: 'Output as JSON',
|
|
10
|
+
} as FlagDefinition,
|
|
11
|
+
jsonValidation: {
|
|
12
|
+
name: 'json',
|
|
13
|
+
description: 'Output validation results as JSON',
|
|
14
|
+
} as FlagDefinition,
|
|
15
|
+
strict: {
|
|
16
|
+
name: 'strict',
|
|
17
|
+
description: 'Enable strict validation mode',
|
|
18
|
+
} as FlagDefinition,
|
|
19
|
+
noInteractive: {
|
|
20
|
+
name: 'no-interactive',
|
|
21
|
+
description: 'Disable interactive prompts',
|
|
22
|
+
} as FlagDefinition,
|
|
23
|
+
type: {
|
|
24
|
+
name: 'type',
|
|
25
|
+
description: 'Specify item type when ambiguous',
|
|
26
|
+
takesValue: true,
|
|
27
|
+
values: ['change', 'spec'],
|
|
28
|
+
} as FlagDefinition,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Registry of all Prompter CLI commands with their flags and metadata.
|
|
33
|
+
* This registry is used to generate shell completion scripts.
|
|
34
|
+
*/
|
|
35
|
+
export const COMMAND_REGISTRY: CommandDefinition[] = [
|
|
36
|
+
{
|
|
37
|
+
name: 'init',
|
|
38
|
+
description: 'Initialize Prompter in your project',
|
|
39
|
+
acceptsPositional: true,
|
|
40
|
+
positionalType: 'path',
|
|
41
|
+
flags: [
|
|
42
|
+
{
|
|
43
|
+
name: 'tools',
|
|
44
|
+
description: 'Configure AI tools non-interactively (e.g., "all", "none", or comma-separated tool IDs)',
|
|
45
|
+
takesValue: true,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'update',
|
|
51
|
+
description: 'Update Prompter instruction files',
|
|
52
|
+
acceptsPositional: true,
|
|
53
|
+
positionalType: 'path',
|
|
54
|
+
flags: [],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'list',
|
|
58
|
+
description: 'List items (changes by default, or specs with --specs)',
|
|
59
|
+
flags: [
|
|
60
|
+
{
|
|
61
|
+
name: 'specs',
|
|
62
|
+
description: 'List specs instead of changes',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'changes',
|
|
66
|
+
description: 'List changes explicitly (default)',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'view',
|
|
72
|
+
description: 'Display an interactive dashboard of specs and changes',
|
|
73
|
+
flags: [],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'validate',
|
|
77
|
+
description: 'Validate changes and specs',
|
|
78
|
+
acceptsPositional: true,
|
|
79
|
+
positionalType: 'change-or-spec-id',
|
|
80
|
+
flags: [
|
|
81
|
+
{
|
|
82
|
+
name: 'all',
|
|
83
|
+
description: 'Validate all changes and specs',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'changes',
|
|
87
|
+
description: 'Validate all changes',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'specs',
|
|
91
|
+
description: 'Validate all specs',
|
|
92
|
+
},
|
|
93
|
+
COMMON_FLAGS.type,
|
|
94
|
+
COMMON_FLAGS.strict,
|
|
95
|
+
COMMON_FLAGS.jsonValidation,
|
|
96
|
+
{
|
|
97
|
+
name: 'concurrency',
|
|
98
|
+
description: 'Max concurrent validations (defaults to env PROMPTER_CONCURRENCY or 6)',
|
|
99
|
+
takesValue: true,
|
|
100
|
+
},
|
|
101
|
+
COMMON_FLAGS.noInteractive,
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'show',
|
|
106
|
+
description: 'Show a change or spec',
|
|
107
|
+
acceptsPositional: true,
|
|
108
|
+
positionalType: 'change-or-spec-id',
|
|
109
|
+
flags: [
|
|
110
|
+
COMMON_FLAGS.json,
|
|
111
|
+
COMMON_FLAGS.type,
|
|
112
|
+
COMMON_FLAGS.noInteractive,
|
|
113
|
+
{
|
|
114
|
+
name: 'deltas-only',
|
|
115
|
+
description: 'Show only deltas (JSON only, change-specific)',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'requirements-only',
|
|
119
|
+
description: 'Alias for --deltas-only (deprecated, change-specific)',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'requirements',
|
|
123
|
+
description: 'Show only requirements, exclude scenarios (JSON only, spec-specific)',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'no-scenarios',
|
|
127
|
+
description: 'Exclude scenario content (JSON only, spec-specific)',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'requirement',
|
|
131
|
+
short: 'r',
|
|
132
|
+
description: 'Show specific requirement by ID (JSON only, spec-specific)',
|
|
133
|
+
takesValue: true,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'archive',
|
|
139
|
+
description: 'Archive a completed change and update main specs',
|
|
140
|
+
acceptsPositional: true,
|
|
141
|
+
positionalType: 'change-id',
|
|
142
|
+
flags: [
|
|
143
|
+
{
|
|
144
|
+
name: 'yes',
|
|
145
|
+
short: 'y',
|
|
146
|
+
description: 'Skip confirmation prompts',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'skip-specs',
|
|
150
|
+
description: 'Skip spec update operations',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'no-validate',
|
|
154
|
+
description: 'Skip validation (not recommended)',
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'feedback',
|
|
160
|
+
description: 'Submit feedback about Prompter',
|
|
161
|
+
acceptsPositional: true,
|
|
162
|
+
flags: [
|
|
163
|
+
{
|
|
164
|
+
name: 'body',
|
|
165
|
+
description: 'Detailed description for the feedback',
|
|
166
|
+
takesValue: true,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'change',
|
|
172
|
+
description: 'Manage Prompter change proposals (deprecated)',
|
|
173
|
+
flags: [],
|
|
174
|
+
subcommands: [
|
|
175
|
+
{
|
|
176
|
+
name: 'show',
|
|
177
|
+
description: 'Show a change proposal',
|
|
178
|
+
acceptsPositional: true,
|
|
179
|
+
positionalType: 'change-id',
|
|
180
|
+
flags: [
|
|
181
|
+
COMMON_FLAGS.json,
|
|
182
|
+
{
|
|
183
|
+
name: 'deltas-only',
|
|
184
|
+
description: 'Show only deltas (JSON only)',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'requirements-only',
|
|
188
|
+
description: 'Alias for --deltas-only (deprecated)',
|
|
189
|
+
},
|
|
190
|
+
COMMON_FLAGS.noInteractive,
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'list',
|
|
195
|
+
description: 'List all active changes (deprecated)',
|
|
196
|
+
flags: [
|
|
197
|
+
COMMON_FLAGS.json,
|
|
198
|
+
{
|
|
199
|
+
name: 'long',
|
|
200
|
+
description: 'Show id and title with counts',
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'validate',
|
|
206
|
+
description: 'Validate a change proposal',
|
|
207
|
+
acceptsPositional: true,
|
|
208
|
+
positionalType: 'change-id',
|
|
209
|
+
flags: [
|
|
210
|
+
COMMON_FLAGS.strict,
|
|
211
|
+
COMMON_FLAGS.jsonValidation,
|
|
212
|
+
COMMON_FLAGS.noInteractive,
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'spec',
|
|
219
|
+
description: 'Manage Prompter specifications',
|
|
220
|
+
flags: [],
|
|
221
|
+
subcommands: [
|
|
222
|
+
{
|
|
223
|
+
name: 'show',
|
|
224
|
+
description: 'Show a specification',
|
|
225
|
+
acceptsPositional: true,
|
|
226
|
+
positionalType: 'spec-id',
|
|
227
|
+
flags: [
|
|
228
|
+
COMMON_FLAGS.json,
|
|
229
|
+
{
|
|
230
|
+
name: 'requirements',
|
|
231
|
+
description: 'Show only requirements, exclude scenarios (JSON only)',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: 'no-scenarios',
|
|
235
|
+
description: 'Exclude scenario content (JSON only)',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'requirement',
|
|
239
|
+
short: 'r',
|
|
240
|
+
description: 'Show specific requirement by ID (JSON only)',
|
|
241
|
+
takesValue: true,
|
|
242
|
+
},
|
|
243
|
+
COMMON_FLAGS.noInteractive,
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: 'list',
|
|
248
|
+
description: 'List all specifications',
|
|
249
|
+
flags: [
|
|
250
|
+
COMMON_FLAGS.json,
|
|
251
|
+
{
|
|
252
|
+
name: 'long',
|
|
253
|
+
description: 'Show id and title with counts',
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'validate',
|
|
259
|
+
description: 'Validate a specification',
|
|
260
|
+
acceptsPositional: true,
|
|
261
|
+
positionalType: 'spec-id',
|
|
262
|
+
flags: [
|
|
263
|
+
COMMON_FLAGS.strict,
|
|
264
|
+
COMMON_FLAGS.jsonValidation,
|
|
265
|
+
COMMON_FLAGS.noInteractive,
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'completion',
|
|
272
|
+
description: 'Manage shell completions for Prompter CLI',
|
|
273
|
+
flags: [],
|
|
274
|
+
subcommands: [
|
|
275
|
+
{
|
|
276
|
+
name: 'generate',
|
|
277
|
+
description: 'Generate completion script for a shell (outputs to stdout)',
|
|
278
|
+
acceptsPositional: true,
|
|
279
|
+
positionalType: 'shell',
|
|
280
|
+
flags: [],
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: 'install',
|
|
284
|
+
description: 'Install completion script for a shell',
|
|
285
|
+
acceptsPositional: true,
|
|
286
|
+
positionalType: 'shell',
|
|
287
|
+
flags: [
|
|
288
|
+
{
|
|
289
|
+
name: 'verbose',
|
|
290
|
+
description: 'Show detailed installation output',
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: 'uninstall',
|
|
296
|
+
description: 'Uninstall completion script for a shell',
|
|
297
|
+
acceptsPositional: true,
|
|
298
|
+
positionalType: 'shell',
|
|
299
|
+
flags: [
|
|
300
|
+
{
|
|
301
|
+
name: 'yes',
|
|
302
|
+
short: 'y',
|
|
303
|
+
description: 'Skip confirmation prompts',
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: 'config',
|
|
311
|
+
description: 'View and modify global Prompter configuration',
|
|
312
|
+
flags: [
|
|
313
|
+
{
|
|
314
|
+
name: 'scope',
|
|
315
|
+
description: 'Config scope (only "global" supported currently)',
|
|
316
|
+
takesValue: true,
|
|
317
|
+
values: ['global'],
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
subcommands: [
|
|
321
|
+
{
|
|
322
|
+
name: 'path',
|
|
323
|
+
description: 'Show config file location',
|
|
324
|
+
flags: [],
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: 'list',
|
|
328
|
+
description: 'Show all current settings',
|
|
329
|
+
flags: [
|
|
330
|
+
COMMON_FLAGS.json,
|
|
331
|
+
],
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: 'get',
|
|
335
|
+
description: 'Get a specific value (raw, scriptable)',
|
|
336
|
+
acceptsPositional: true,
|
|
337
|
+
flags: [],
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: 'set',
|
|
341
|
+
description: 'Set a value (auto-coerce types)',
|
|
342
|
+
acceptsPositional: true,
|
|
343
|
+
flags: [
|
|
344
|
+
{
|
|
345
|
+
name: 'string',
|
|
346
|
+
description: 'Force value to be stored as string',
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: 'allow-unknown',
|
|
350
|
+
description: 'Allow setting unknown keys',
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: 'unset',
|
|
356
|
+
description: 'Remove a key (revert to default)',
|
|
357
|
+
acceptsPositional: true,
|
|
358
|
+
flags: [],
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: 'reset',
|
|
362
|
+
description: 'Reset configuration to defaults',
|
|
363
|
+
flags: [
|
|
364
|
+
{
|
|
365
|
+
name: 'all',
|
|
366
|
+
description: 'Reset all configuration (required)',
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: 'yes',
|
|
370
|
+
short: 'y',
|
|
371
|
+
description: 'Skip confirmation prompts',
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
name: 'edit',
|
|
377
|
+
description: 'Open config in $EDITOR',
|
|
378
|
+
flags: [],
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
},
|
|
382
|
+
];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { getActiveChangeIds, getSpecIds } from '../../utils/item-discovery.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cache entry for completion data
|
|
5
|
+
*/
|
|
6
|
+
interface CacheEntry<T> {
|
|
7
|
+
data: T;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Provides dynamic completion suggestions for Prompter items (changes and specs).
|
|
13
|
+
* Implements a 2-second cache to avoid excessive file system operations during
|
|
14
|
+
* tab completion.
|
|
15
|
+
*/
|
|
16
|
+
export class CompletionProvider {
|
|
17
|
+
private readonly cacheTTL: number;
|
|
18
|
+
private changeCache: CacheEntry<string[]> | null = null;
|
|
19
|
+
private specCache: CacheEntry<string[]> | null = null;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new completion provider
|
|
23
|
+
*
|
|
24
|
+
* @param cacheTTLMs - Cache time-to-live in milliseconds (default: 2000ms)
|
|
25
|
+
* @param projectRoot - Project root directory (default: process.cwd())
|
|
26
|
+
*/
|
|
27
|
+
constructor(
|
|
28
|
+
private readonly cacheTTLMs: number = 2000,
|
|
29
|
+
private readonly projectRoot: string = process.cwd()
|
|
30
|
+
) {
|
|
31
|
+
this.cacheTTL = cacheTTLMs;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get all active change IDs for completion
|
|
36
|
+
*
|
|
37
|
+
* @returns Array of change IDs
|
|
38
|
+
*/
|
|
39
|
+
async getChangeIds(): Promise<string[]> {
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
|
|
42
|
+
// Check if cache is valid
|
|
43
|
+
if (this.changeCache && now - this.changeCache.timestamp < this.cacheTTL) {
|
|
44
|
+
return this.changeCache.data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Fetch fresh data
|
|
48
|
+
const changeIds = await getActiveChangeIds(this.projectRoot);
|
|
49
|
+
|
|
50
|
+
// Update cache
|
|
51
|
+
this.changeCache = {
|
|
52
|
+
data: changeIds,
|
|
53
|
+
timestamp: now,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return changeIds;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get all spec IDs for completion
|
|
61
|
+
*
|
|
62
|
+
* @returns Array of spec IDs
|
|
63
|
+
*/
|
|
64
|
+
async getSpecIds(): Promise<string[]> {
|
|
65
|
+
const now = Date.now();
|
|
66
|
+
|
|
67
|
+
// Check if cache is valid
|
|
68
|
+
if (this.specCache && now - this.specCache.timestamp < this.cacheTTL) {
|
|
69
|
+
return this.specCache.data;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Fetch fresh data
|
|
73
|
+
const specIds = await getSpecIds(this.projectRoot);
|
|
74
|
+
|
|
75
|
+
// Update cache
|
|
76
|
+
this.specCache = {
|
|
77
|
+
data: specIds,
|
|
78
|
+
timestamp: now,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return specIds;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get both change and spec IDs for completion
|
|
86
|
+
*
|
|
87
|
+
* @returns Object with changeIds and specIds arrays
|
|
88
|
+
*/
|
|
89
|
+
async getAllIds(): Promise<{ changeIds: string[]; specIds: string[] }> {
|
|
90
|
+
const [changeIds, specIds] = await Promise.all([
|
|
91
|
+
this.getChangeIds(),
|
|
92
|
+
this.getSpecIds(),
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
return { changeIds, specIds };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Clear all cached data
|
|
100
|
+
*/
|
|
101
|
+
clearCache(): void {
|
|
102
|
+
this.changeCache = null;
|
|
103
|
+
this.specCache = null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get cache statistics for debugging
|
|
108
|
+
*
|
|
109
|
+
* @returns Cache status information
|
|
110
|
+
*/
|
|
111
|
+
getCacheStats(): {
|
|
112
|
+
changeCache: { valid: boolean; age?: number };
|
|
113
|
+
specCache: { valid: boolean; age?: number };
|
|
114
|
+
} {
|
|
115
|
+
const now = Date.now();
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
changeCache: {
|
|
119
|
+
valid: this.changeCache !== null && now - this.changeCache.timestamp < this.cacheTTL,
|
|
120
|
+
age: this.changeCache ? now - this.changeCache.timestamp : undefined,
|
|
121
|
+
},
|
|
122
|
+
specCache: {
|
|
123
|
+
valid: this.specCache !== null && now - this.specCache.timestamp < this.cacheTTL,
|
|
124
|
+
age: this.specCache ? now - this.specCache.timestamp : undefined,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { CompletionGenerator, CommandDefinition, FlagDefinition } from '../types.js';
|
|
2
|
+
import { BASH_DYNAMIC_HELPERS } from '../templates/bash-templates.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generates Bash completion scripts for the Prompter CLI.
|
|
6
|
+
* Follows Bash completion conventions using complete builtin and COMPREPLY array.
|
|
7
|
+
*/
|
|
8
|
+
export class BashGenerator implements CompletionGenerator {
|
|
9
|
+
readonly shell = 'bash' as const;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Generate a Bash completion script
|
|
13
|
+
*
|
|
14
|
+
* @param commands - Command definitions to generate completions for
|
|
15
|
+
* @returns Bash completion script as a string
|
|
16
|
+
*/
|
|
17
|
+
generate(commands: CommandDefinition[]): string {
|
|
18
|
+
// Build command list for top-level completions
|
|
19
|
+
const commandList = commands.map(c => this.escapeCommandName(c.name)).join(' ');
|
|
20
|
+
|
|
21
|
+
// Build command cases using push() for loop clarity
|
|
22
|
+
const caseLines: string[] = [];
|
|
23
|
+
for (const cmd of commands) {
|
|
24
|
+
caseLines.push(` ${cmd.name})`);
|
|
25
|
+
caseLines.push(...this.generateCommandCase(cmd, ' '));
|
|
26
|
+
caseLines.push(' ;;');
|
|
27
|
+
}
|
|
28
|
+
const commandCases = caseLines.join('\n');
|
|
29
|
+
|
|
30
|
+
// Dynamic completion helpers from template
|
|
31
|
+
const helpers = BASH_DYNAMIC_HELPERS;
|
|
32
|
+
|
|
33
|
+
// Assemble final script with template literal
|
|
34
|
+
return `# Bash completion script for Prompter CLI
|
|
35
|
+
# Auto-generated - do not edit manually
|
|
36
|
+
|
|
37
|
+
_prompter_completion() {
|
|
38
|
+
local cur prev words cword
|
|
39
|
+
|
|
40
|
+
# Use _init_completion if available (from bash-completion package)
|
|
41
|
+
# The -n : option prevents colons from being treated as word separators
|
|
42
|
+
# (important for spec/change IDs that may contain colons)
|
|
43
|
+
# Otherwise, fall back to manual initialization
|
|
44
|
+
if declare -F _init_completion >/dev/null 2>&1; then
|
|
45
|
+
_init_completion -n : || return
|
|
46
|
+
else
|
|
47
|
+
# Manual fallback when bash-completion is not installed
|
|
48
|
+
COMPREPLY=()
|
|
49
|
+
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
50
|
+
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
51
|
+
words=("\${COMP_WORDS[@]}")
|
|
52
|
+
cword=$COMP_CWORD
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
local cmd="\${words[1]}"
|
|
56
|
+
local subcmd="\${words[2]}"
|
|
57
|
+
|
|
58
|
+
# Top-level commands
|
|
59
|
+
if [[ $cword -eq 1 ]]; then
|
|
60
|
+
local commands="${commandList}"
|
|
61
|
+
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
|
|
62
|
+
return 0
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# Command-specific completion
|
|
66
|
+
case "$cmd" in
|
|
67
|
+
${commandCases}
|
|
68
|
+
esac
|
|
69
|
+
|
|
70
|
+
return 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
${helpers}
|
|
74
|
+
complete -F _prompter_completion prompter
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generate completion case logic for a command
|
|
80
|
+
*/
|
|
81
|
+
private generateCommandCase(cmd: CommandDefinition, indent: string): string[] {
|
|
82
|
+
const lines: string[] = [];
|
|
83
|
+
|
|
84
|
+
// Handle subcommands
|
|
85
|
+
if (cmd.subcommands && cmd.subcommands.length > 0) {
|
|
86
|
+
// First, check if user is typing a flag for the parent command
|
|
87
|
+
if (cmd.flags.length > 0) {
|
|
88
|
+
lines.push(`${indent}if [[ "$cur" == -* ]]; then`);
|
|
89
|
+
const flags = cmd.flags.map(f => {
|
|
90
|
+
const parts: string[] = [];
|
|
91
|
+
if (f.short) parts.push(`-${f.short}`);
|
|
92
|
+
parts.push(`--${f.name}`);
|
|
93
|
+
return parts.join(' ');
|
|
94
|
+
}).join(' ');
|
|
95
|
+
lines.push(`${indent} local flags="${flags}"`);
|
|
96
|
+
lines.push(`${indent} COMPREPLY=($(compgen -W "$flags" -- "$cur"))`);
|
|
97
|
+
lines.push(`${indent} return 0`);
|
|
98
|
+
lines.push(`${indent}fi`);
|
|
99
|
+
lines.push('');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
lines.push(`${indent}if [[ $cword -eq 2 ]]; then`);
|
|
103
|
+
lines.push(`${indent} local subcommands="` + cmd.subcommands.map(s => this.escapeCommandName(s.name)).join(' ') + '"');
|
|
104
|
+
lines.push(`${indent} COMPREPLY=($(compgen -W "$subcommands" -- "$cur"))`);
|
|
105
|
+
lines.push(`${indent} return 0`);
|
|
106
|
+
lines.push(`${indent}fi`);
|
|
107
|
+
lines.push('');
|
|
108
|
+
lines.push(`${indent}case "$subcmd" in`);
|
|
109
|
+
|
|
110
|
+
for (const subcmd of cmd.subcommands) {
|
|
111
|
+
lines.push(`${indent} ${subcmd.name})`);
|
|
112
|
+
lines.push(...this.generateArgumentCompletion(subcmd, indent + ' '));
|
|
113
|
+
lines.push(`${indent} ;;`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
lines.push(`${indent}esac`);
|
|
117
|
+
} else {
|
|
118
|
+
// No subcommands, just complete arguments
|
|
119
|
+
lines.push(...this.generateArgumentCompletion(cmd, indent));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return lines;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Generate argument completion (flags and positional arguments)
|
|
127
|
+
*/
|
|
128
|
+
private generateArgumentCompletion(cmd: CommandDefinition, indent: string): string[] {
|
|
129
|
+
const lines: string[] = [];
|
|
130
|
+
|
|
131
|
+
// Check for flag completion
|
|
132
|
+
if (cmd.flags.length > 0) {
|
|
133
|
+
lines.push(`${indent}if [[ "$cur" == -* ]]; then`);
|
|
134
|
+
const flags = cmd.flags.map(f => {
|
|
135
|
+
const parts: string[] = [];
|
|
136
|
+
if (f.short) parts.push(`-${f.short}`);
|
|
137
|
+
parts.push(`--${f.name}`);
|
|
138
|
+
return parts.join(' ');
|
|
139
|
+
}).join(' ');
|
|
140
|
+
lines.push(`${indent} local flags="${flags}"`);
|
|
141
|
+
lines.push(`${indent} COMPREPLY=($(compgen -W "$flags" -- "$cur"))`);
|
|
142
|
+
lines.push(`${indent} return 0`);
|
|
143
|
+
lines.push(`${indent}fi`);
|
|
144
|
+
lines.push('');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Handle positional completions
|
|
148
|
+
if (cmd.acceptsPositional) {
|
|
149
|
+
lines.push(...this.generatePositionalCompletion(cmd.positionalType, indent));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return lines;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Generate positional argument completion based on type
|
|
157
|
+
*/
|
|
158
|
+
private generatePositionalCompletion(positionalType: string | undefined, indent: string): string[] {
|
|
159
|
+
const lines: string[] = [];
|
|
160
|
+
|
|
161
|
+
switch (positionalType) {
|
|
162
|
+
case 'change-id':
|
|
163
|
+
lines.push(`${indent}_prompter_complete_changes`);
|
|
164
|
+
break;
|
|
165
|
+
case 'spec-id':
|
|
166
|
+
lines.push(`${indent}_prompter_complete_specs`);
|
|
167
|
+
break;
|
|
168
|
+
case 'change-or-spec-id':
|
|
169
|
+
lines.push(`${indent}_prompter_complete_items`);
|
|
170
|
+
break;
|
|
171
|
+
case 'shell':
|
|
172
|
+
lines.push(`${indent}local shells="zsh bash fish powershell"`);
|
|
173
|
+
lines.push(`${indent}COMPREPLY=($(compgen -W "$shells" -- "$cur"))`);
|
|
174
|
+
break;
|
|
175
|
+
case 'path':
|
|
176
|
+
lines.push(`${indent}COMPREPLY=($(compgen -f -- "$cur"))`);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return lines;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Escape command/subcommand names for safe use in Bash scripts
|
|
186
|
+
*/
|
|
187
|
+
private escapeCommandName(name: string): string {
|
|
188
|
+
// Escape shell metacharacters to prevent command injection
|
|
189
|
+
return name.replace(/["\$`\\]/g, '\\$&');
|
|
190
|
+
}
|
|
191
|
+
}
|