openspec-cn 0.23.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/LICENSE +22 -0
- package/README.md +153 -0
- package/bin/openspec.js +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +480 -0
- package/dist/commands/change.d.ts +35 -0
- package/dist/commands/change.js +277 -0
- package/dist/commands/completion.d.ts +72 -0
- package/dist/commands/completion.js +257 -0
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.js +198 -0
- package/dist/commands/feedback.d.ts +9 -0
- package/dist/commands/feedback.js +183 -0
- package/dist/commands/schema.d.ts +6 -0
- package/dist/commands/schema.js +869 -0
- package/dist/commands/show.d.ts +14 -0
- package/dist/commands/show.js +132 -0
- package/dist/commands/spec.d.ts +15 -0
- package/dist/commands/spec.js +225 -0
- package/dist/commands/validate.d.ts +24 -0
- package/dist/commands/validate.js +294 -0
- package/dist/commands/workflow/index.d.ts +17 -0
- package/dist/commands/workflow/index.js +12 -0
- package/dist/commands/workflow/instructions.d.ts +29 -0
- package/dist/commands/workflow/instructions.js +381 -0
- package/dist/commands/workflow/new-change.d.ts +11 -0
- package/dist/commands/workflow/new-change.js +44 -0
- package/dist/commands/workflow/schemas.d.ts +10 -0
- package/dist/commands/workflow/schemas.js +34 -0
- package/dist/commands/workflow/shared.d.ts +52 -0
- package/dist/commands/workflow/shared.js +111 -0
- package/dist/commands/workflow/status.d.ts +14 -0
- package/dist/commands/workflow/status.js +58 -0
- package/dist/commands/workflow/templates.d.ts +16 -0
- package/dist/commands/workflow/templates.js +68 -0
- package/dist/core/archive.d.ts +11 -0
- package/dist/core/archive.js +280 -0
- package/dist/core/artifact-graph/graph.d.ts +56 -0
- package/dist/core/artifact-graph/graph.js +141 -0
- package/dist/core/artifact-graph/index.d.ts +7 -0
- package/dist/core/artifact-graph/index.js +13 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +143 -0
- package/dist/core/artifact-graph/instruction-loader.js +214 -0
- package/dist/core/artifact-graph/resolver.d.ts +81 -0
- package/dist/core/artifact-graph/resolver.js +257 -0
- package/dist/core/artifact-graph/schema.d.ts +13 -0
- package/dist/core/artifact-graph/schema.js +108 -0
- package/dist/core/artifact-graph/state.d.ts +12 -0
- package/dist/core/artifact-graph/state.js +54 -0
- package/dist/core/artifact-graph/types.d.ts +45 -0
- package/dist/core/artifact-graph/types.js +43 -0
- package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
- package/dist/core/command-generation/adapters/amazon-q.js +26 -0
- package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
- package/dist/core/command-generation/adapters/antigravity.js +26 -0
- package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
- package/dist/core/command-generation/adapters/auggie.js +27 -0
- package/dist/core/command-generation/adapters/claude.d.ts +13 -0
- package/dist/core/command-generation/adapters/claude.js +50 -0
- package/dist/core/command-generation/adapters/cline.d.ts +14 -0
- package/dist/core/command-generation/adapters/cline.js +27 -0
- package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
- package/dist/core/command-generation/adapters/codebuddy.js +28 -0
- package/dist/core/command-generation/adapters/codex.d.ts +13 -0
- package/dist/core/command-generation/adapters/codex.js +27 -0
- package/dist/core/command-generation/adapters/continue.d.ts +13 -0
- package/dist/core/command-generation/adapters/continue.js +28 -0
- package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
- package/dist/core/command-generation/adapters/costrict.js +27 -0
- package/dist/core/command-generation/adapters/crush.d.ts +13 -0
- package/dist/core/command-generation/adapters/crush.js +30 -0
- package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
- package/dist/core/command-generation/adapters/cursor.js +44 -0
- package/dist/core/command-generation/adapters/factory.d.ts +13 -0
- package/dist/core/command-generation/adapters/factory.js +27 -0
- package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
- package/dist/core/command-generation/adapters/gemini.js +26 -0
- package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
- package/dist/core/command-generation/adapters/github-copilot.js +26 -0
- package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
- package/dist/core/command-generation/adapters/iflow.js +29 -0
- package/dist/core/command-generation/adapters/index.d.ts +27 -0
- package/dist/core/command-generation/adapters/index.js +27 -0
- package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/kilocode.js +23 -0
- package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
- package/dist/core/command-generation/adapters/opencode.js +26 -0
- package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
- package/dist/core/command-generation/adapters/qoder.js +30 -0
- package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
- package/dist/core/command-generation/adapters/qwen.js +26 -0
- package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/roocode.js +27 -0
- package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
- package/dist/core/command-generation/adapters/windsurf.js +51 -0
- package/dist/core/command-generation/generator.d.ts +21 -0
- package/dist/core/command-generation/generator.js +27 -0
- package/dist/core/command-generation/index.d.ts +22 -0
- package/dist/core/command-generation/index.js +24 -0
- package/dist/core/command-generation/registry.d.ts +36 -0
- package/dist/core/command-generation/registry.js +88 -0
- package/dist/core/command-generation/types.d.ts +55 -0
- package/dist/core/command-generation/types.js +8 -0
- package/dist/core/completions/command-registry.d.ts +7 -0
- package/dist/core/completions/command-registry.js +456 -0
- package/dist/core/completions/completion-provider.d.ts +60 -0
- package/dist/core/completions/completion-provider.js +102 -0
- package/dist/core/completions/factory.d.ts +64 -0
- package/dist/core/completions/factory.js +75 -0
- package/dist/core/completions/generators/bash-generator.d.ts +32 -0
- package/dist/core/completions/generators/bash-generator.js +174 -0
- package/dist/core/completions/generators/fish-generator.d.ts +32 -0
- package/dist/core/completions/generators/fish-generator.js +157 -0
- package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
- package/dist/core/completions/generators/powershell-generator.js +207 -0
- package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
- package/dist/core/completions/generators/zsh-generator.js +250 -0
- package/dist/core/completions/installers/bash-installer.d.ts +87 -0
- package/dist/core/completions/installers/bash-installer.js +318 -0
- package/dist/core/completions/installers/fish-installer.d.ts +43 -0
- package/dist/core/completions/installers/fish-installer.js +143 -0
- package/dist/core/completions/installers/powershell-installer.d.ts +88 -0
- package/dist/core/completions/installers/powershell-installer.js +327 -0
- package/dist/core/completions/installers/zsh-installer.d.ts +125 -0
- package/dist/core/completions/installers/zsh-installer.js +449 -0
- package/dist/core/completions/templates/bash-templates.d.ts +6 -0
- package/dist/core/completions/templates/bash-templates.js +24 -0
- package/dist/core/completions/templates/fish-templates.d.ts +7 -0
- package/dist/core/completions/templates/fish-templates.js +39 -0
- package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
- package/dist/core/completions/templates/powershell-templates.js +25 -0
- package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
- package/dist/core/completions/templates/zsh-templates.js +36 -0
- package/dist/core/completions/types.d.ts +79 -0
- package/dist/core/completions/types.js +2 -0
- package/dist/core/config-prompts.d.ts +9 -0
- package/dist/core/config-prompts.js +34 -0
- package/dist/core/config-schema.d.ts +76 -0
- package/dist/core/config-schema.js +200 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.js +30 -0
- package/dist/core/converters/json-converter.d.ts +6 -0
- package/dist/core/converters/json-converter.js +51 -0
- package/dist/core/global-config.d.ts +39 -0
- package/dist/core/global-config.js +115 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +3 -0
- package/dist/core/init.d.ts +32 -0
- package/dist/core/init.js +433 -0
- package/dist/core/legacy-cleanup.d.ts +162 -0
- package/dist/core/legacy-cleanup.js +501 -0
- package/dist/core/list.d.ts +9 -0
- package/dist/core/list.js +171 -0
- package/dist/core/parsers/change-parser.d.ts +13 -0
- package/dist/core/parsers/change-parser.js +193 -0
- package/dist/core/parsers/markdown-parser.d.ts +22 -0
- package/dist/core/parsers/markdown-parser.js +187 -0
- package/dist/core/parsers/requirement-blocks.d.ts +37 -0
- package/dist/core/parsers/requirement-blocks.js +201 -0
- package/dist/core/project-config.d.ts +64 -0
- package/dist/core/project-config.js +223 -0
- package/dist/core/schemas/base.schema.d.ts +13 -0
- package/dist/core/schemas/base.schema.js +13 -0
- package/dist/core/schemas/change.schema.d.ts +73 -0
- package/dist/core/schemas/change.schema.js +31 -0
- package/dist/core/schemas/index.d.ts +4 -0
- package/dist/core/schemas/index.js +4 -0
- package/dist/core/schemas/spec.schema.d.ts +18 -0
- package/dist/core/schemas/spec.schema.js +15 -0
- package/dist/core/shared/index.d.ts +8 -0
- package/dist/core/shared/index.js +8 -0
- package/dist/core/shared/skill-generation.d.ts +41 -0
- package/dist/core/shared/skill-generation.js +74 -0
- package/dist/core/shared/tool-detection.d.ts +66 -0
- package/dist/core/shared/tool-detection.js +140 -0
- package/dist/core/specs-apply.d.ts +73 -0
- package/dist/core/specs-apply.js +384 -0
- package/dist/core/styles/palette.d.ts +7 -0
- package/dist/core/styles/palette.js +8 -0
- package/dist/core/templates/index.d.ts +8 -0
- package/dist/core/templates/index.js +9 -0
- package/dist/core/templates/skill-templates.d.ts +112 -0
- package/dist/core/templates/skill-templates.js +2893 -0
- package/dist/core/update.d.ts +42 -0
- package/dist/core/update.js +306 -0
- package/dist/core/validation/constants.d.ts +34 -0
- package/dist/core/validation/constants.js +40 -0
- package/dist/core/validation/types.d.ts +18 -0
- package/dist/core/validation/types.js +2 -0
- package/dist/core/validation/validator.d.ts +33 -0
- package/dist/core/validation/validator.js +409 -0
- package/dist/core/view.d.ts +8 -0
- package/dist/core/view.js +168 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/prompts/searchable-multi-select.d.ts +27 -0
- package/dist/prompts/searchable-multi-select.js +149 -0
- package/dist/telemetry/config.d.ts +32 -0
- package/dist/telemetry/config.js +68 -0
- package/dist/telemetry/index.d.ts +31 -0
- package/dist/telemetry/index.js +145 -0
- package/dist/ui/ascii-patterns.d.ts +16 -0
- package/dist/ui/ascii-patterns.js +133 -0
- package/dist/ui/welcome-screen.d.ts +10 -0
- package/dist/ui/welcome-screen.js +146 -0
- package/dist/utils/change-metadata.d.ts +51 -0
- package/dist/utils/change-metadata.js +147 -0
- package/dist/utils/change-utils.d.ts +62 -0
- package/dist/utils/change-utils.js +121 -0
- package/dist/utils/file-system.d.ts +36 -0
- package/dist/utils/file-system.js +281 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/interactive.d.ts +18 -0
- package/dist/utils/interactive.js +21 -0
- package/dist/utils/item-discovery.d.ts +4 -0
- package/dist/utils/item-discovery.js +72 -0
- package/dist/utils/match.d.ts +3 -0
- package/dist/utils/match.js +22 -0
- package/dist/utils/shell-detection.d.ts +20 -0
- package/dist/utils/shell-detection.js +41 -0
- package/dist/utils/task-progress.d.ts +8 -0
- package/dist/utils/task-progress.js +36 -0
- package/package.json +84 -0
- package/schemas/spec-driven/schema.yaml +148 -0
- package/schemas/spec-driven/templates/design.md +19 -0
- package/schemas/spec-driven/templates/proposal.md +23 -0
- package/schemas/spec-driven/templates/spec.md +8 -0
- package/schemas/spec-driven/templates/tasks.md +9 -0
- package/schemas/tdd/schema.yaml +213 -0
- package/schemas/tdd/templates/docs.md +15 -0
- package/schemas/tdd/templates/implementation.md +11 -0
- package/schemas/tdd/templates/spec.md +11 -0
- package/schemas/tdd/templates/test.md +11 -0
- package/scripts/postinstall.js +147 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import { FileSystemUtils } from '../../../utils/file-system.js';
|
|
5
|
+
/**
|
|
6
|
+
* Installer for Zsh completion scripts.
|
|
7
|
+
* Supports both Oh My Zsh and standard Zsh configurations.
|
|
8
|
+
*/
|
|
9
|
+
export class ZshInstaller {
|
|
10
|
+
homeDir;
|
|
11
|
+
/**
|
|
12
|
+
* Markers for .zshrc configuration management
|
|
13
|
+
*/
|
|
14
|
+
ZSHRC_MARKERS = {
|
|
15
|
+
start: '# OPENSPEC:START',
|
|
16
|
+
end: '# OPENSPEC:END',
|
|
17
|
+
};
|
|
18
|
+
constructor(homeDir = os.homedir()) {
|
|
19
|
+
this.homeDir = homeDir;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if Oh My Zsh is installed
|
|
23
|
+
*
|
|
24
|
+
* @returns true if Oh My Zsh is detected via $ZSH env var or directory exists
|
|
25
|
+
*/
|
|
26
|
+
async isOhMyZshInstalled() {
|
|
27
|
+
// First check for $ZSH environment variable (standard OMZ setup)
|
|
28
|
+
if (process.env.ZSH) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
// Fall back to checking for ~/.oh-my-zsh directory
|
|
32
|
+
const ohMyZshPath = path.join(this.homeDir, '.oh-my-zsh');
|
|
33
|
+
try {
|
|
34
|
+
const stat = await fs.stat(ohMyZshPath);
|
|
35
|
+
return stat.isDirectory();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the appropriate installation path for the completion script
|
|
43
|
+
*
|
|
44
|
+
* @returns Object with installation path and whether it's Oh My Zsh
|
|
45
|
+
*/
|
|
46
|
+
async getInstallationPath() {
|
|
47
|
+
const isOhMyZsh = await this.isOhMyZshInstalled();
|
|
48
|
+
if (isOhMyZsh) {
|
|
49
|
+
// Oh My Zsh custom completions directory
|
|
50
|
+
return {
|
|
51
|
+
path: path.join(this.homeDir, '.oh-my-zsh', 'custom', 'completions', '_openspec'),
|
|
52
|
+
isOhMyZsh: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Standard Zsh completions directory
|
|
57
|
+
return {
|
|
58
|
+
path: path.join(this.homeDir, '.zsh', 'completions', '_openspec'),
|
|
59
|
+
isOhMyZsh: false,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Backup an existing completion file if it exists
|
|
65
|
+
*
|
|
66
|
+
* @param targetPath - Path to the file to backup
|
|
67
|
+
* @returns Path to the backup file, or undefined if no backup was needed
|
|
68
|
+
*/
|
|
69
|
+
async backupExistingFile(targetPath) {
|
|
70
|
+
try {
|
|
71
|
+
await fs.access(targetPath);
|
|
72
|
+
// File exists, create a backup
|
|
73
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
74
|
+
const backupPath = `${targetPath}.backup-${timestamp}`;
|
|
75
|
+
await fs.copyFile(targetPath, backupPath);
|
|
76
|
+
return backupPath;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// File doesn't exist, no backup needed
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get the path to .zshrc file
|
|
85
|
+
*
|
|
86
|
+
* @returns Path to .zshrc
|
|
87
|
+
*/
|
|
88
|
+
getZshrcPath() {
|
|
89
|
+
return path.join(this.homeDir, '.zshrc');
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Generate .zshrc configuration content
|
|
93
|
+
*
|
|
94
|
+
* @param completionsDir - Directory containing completion scripts
|
|
95
|
+
* @returns Configuration content
|
|
96
|
+
*/
|
|
97
|
+
generateZshrcConfig(completionsDir) {
|
|
98
|
+
return [
|
|
99
|
+
'# OpenSpec shell completions configuration',
|
|
100
|
+
`fpath=("${completionsDir}" $fpath)`,
|
|
101
|
+
'autoload -Uz compinit',
|
|
102
|
+
'compinit',
|
|
103
|
+
].join('\n');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Configure .zshrc to enable completions
|
|
107
|
+
* Only applies to standard Zsh (not Oh My Zsh)
|
|
108
|
+
*
|
|
109
|
+
* @param completionsDir - Directory containing completion scripts
|
|
110
|
+
* @returns true if configured successfully, false otherwise
|
|
111
|
+
*/
|
|
112
|
+
async configureZshrc(completionsDir) {
|
|
113
|
+
// Check if auto-configuration is disabled
|
|
114
|
+
if (process.env.OPENSPEC_NO_AUTO_CONFIG === '1') {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const zshrcPath = this.getZshrcPath();
|
|
119
|
+
const config = this.generateZshrcConfig(completionsDir);
|
|
120
|
+
// Check write permissions
|
|
121
|
+
const canWrite = await FileSystemUtils.canWriteFile(zshrcPath);
|
|
122
|
+
if (!canWrite) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
// Use marker-based update
|
|
126
|
+
await FileSystemUtils.updateFileWithMarkers(zshrcPath, config, this.ZSHRC_MARKERS.start, this.ZSHRC_MARKERS.end);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
// Fail gracefully - don't break installation
|
|
131
|
+
console.debug(`Unable to configure .zshrc for completions: ${error.message}`);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Check if .zshrc has OpenSpec configuration markers
|
|
137
|
+
*
|
|
138
|
+
* @returns true if .zshrc exists and has markers
|
|
139
|
+
*/
|
|
140
|
+
async hasZshrcConfig() {
|
|
141
|
+
try {
|
|
142
|
+
const zshrcPath = this.getZshrcPath();
|
|
143
|
+
const content = await fs.readFile(zshrcPath, 'utf-8');
|
|
144
|
+
return content.includes(this.ZSHRC_MARKERS.start) && content.includes(this.ZSHRC_MARKERS.end);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if fpath configuration is needed for a given directory
|
|
152
|
+
* Used to verify if Oh My Zsh (or other) completions directory is already in fpath
|
|
153
|
+
*
|
|
154
|
+
* @param completionsDir - Directory to check for in fpath
|
|
155
|
+
* @returns true if configuration is needed, false if directory is already referenced
|
|
156
|
+
*/
|
|
157
|
+
async needsFpathConfig(completionsDir) {
|
|
158
|
+
try {
|
|
159
|
+
const zshrcPath = this.getZshrcPath();
|
|
160
|
+
const content = await fs.readFile(zshrcPath, 'utf-8');
|
|
161
|
+
// Check if fpath already includes this directory
|
|
162
|
+
return !content.includes(completionsDir);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
// If we can't read .zshrc, assume config is needed
|
|
166
|
+
console.debug(`Unable to read .zshrc to check fpath config: ${error instanceof Error ? error.message : String(error)}`);
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Remove .zshrc configuration
|
|
172
|
+
* Used during uninstallation
|
|
173
|
+
*
|
|
174
|
+
* @returns true if removed successfully, false otherwise
|
|
175
|
+
*/
|
|
176
|
+
async removeZshrcConfig() {
|
|
177
|
+
try {
|
|
178
|
+
const zshrcPath = this.getZshrcPath();
|
|
179
|
+
// Check if file exists
|
|
180
|
+
try {
|
|
181
|
+
await fs.access(zshrcPath);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// File doesn't exist, nothing to remove
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
// Read file content
|
|
188
|
+
const content = await fs.readFile(zshrcPath, 'utf-8');
|
|
189
|
+
// Check if markers exist
|
|
190
|
+
if (!content.includes(this.ZSHRC_MARKERS.start) || !content.includes(this.ZSHRC_MARKERS.end)) {
|
|
191
|
+
// Markers don't exist, nothing to remove
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
// Remove content between markers (including markers)
|
|
195
|
+
const lines = content.split('\n');
|
|
196
|
+
const startIndex = lines.findIndex((line) => line.trim() === this.ZSHRC_MARKERS.start);
|
|
197
|
+
const endIndex = lines.findIndex((line) => line.trim() === this.ZSHRC_MARKERS.end);
|
|
198
|
+
if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {
|
|
199
|
+
// Invalid marker placement
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
// Remove lines between markers (inclusive)
|
|
203
|
+
lines.splice(startIndex, endIndex - startIndex + 1);
|
|
204
|
+
// Remove trailing empty lines at the start if the markers were at the top
|
|
205
|
+
while (lines.length > 0 && lines[0].trim() === '') {
|
|
206
|
+
lines.shift();
|
|
207
|
+
}
|
|
208
|
+
// Write back
|
|
209
|
+
await fs.writeFile(zshrcPath, lines.join('\n'), 'utf-8');
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
// Fail gracefully
|
|
214
|
+
console.debug(`Unable to remove .zshrc configuration: ${error.message}`);
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Install the completion script
|
|
220
|
+
*
|
|
221
|
+
* @param completionScript - The completion script content to install
|
|
222
|
+
* @returns Installation result with status and instructions
|
|
223
|
+
*/
|
|
224
|
+
async install(completionScript) {
|
|
225
|
+
try {
|
|
226
|
+
const { path: targetPath, isOhMyZsh } = await this.getInstallationPath();
|
|
227
|
+
// Check if already installed with same content
|
|
228
|
+
let isUpdate = false;
|
|
229
|
+
try {
|
|
230
|
+
const existingContent = await fs.readFile(targetPath, 'utf-8');
|
|
231
|
+
if (existingContent === completionScript) {
|
|
232
|
+
// Already installed and up to date
|
|
233
|
+
return {
|
|
234
|
+
success: true,
|
|
235
|
+
installedPath: targetPath,
|
|
236
|
+
isOhMyZsh,
|
|
237
|
+
message: 'Completion script is already installed (up to date)',
|
|
238
|
+
instructions: [
|
|
239
|
+
'The completion script is already installed and up to date.',
|
|
240
|
+
'If completions are not working, try: exec zsh',
|
|
241
|
+
],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// File exists but content is different - this is an update
|
|
245
|
+
isUpdate = true;
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
// File doesn't exist or can't be read, proceed with installation
|
|
249
|
+
console.debug(`Unable to read existing completion file at ${targetPath}: ${error.message}`);
|
|
250
|
+
}
|
|
251
|
+
// Ensure the directory exists
|
|
252
|
+
const targetDir = path.dirname(targetPath);
|
|
253
|
+
await fs.mkdir(targetDir, { recursive: true });
|
|
254
|
+
// Backup existing file if updating
|
|
255
|
+
const backupPath = isUpdate ? await this.backupExistingFile(targetPath) : undefined;
|
|
256
|
+
// Write the completion script
|
|
257
|
+
await fs.writeFile(targetPath, completionScript, 'utf-8');
|
|
258
|
+
// Auto-configure .zshrc
|
|
259
|
+
let zshrcConfigured = false;
|
|
260
|
+
if (isOhMyZsh) {
|
|
261
|
+
// For Oh My Zsh, verify that custom/completions is in fpath
|
|
262
|
+
// If not, add it to .zshrc
|
|
263
|
+
const needsConfig = await this.needsFpathConfig(targetDir);
|
|
264
|
+
if (needsConfig) {
|
|
265
|
+
zshrcConfigured = await this.configureZshrc(targetDir);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// Standard Zsh always needs .zshrc configuration
|
|
270
|
+
zshrcConfigured = await this.configureZshrc(targetDir);
|
|
271
|
+
}
|
|
272
|
+
// Generate instructions (only if .zshrc wasn't auto-configured)
|
|
273
|
+
let instructions = zshrcConfigured ? undefined : this.generateInstructions(isOhMyZsh, targetPath);
|
|
274
|
+
// Add fpath guidance for Oh My Zsh installations
|
|
275
|
+
if (isOhMyZsh) {
|
|
276
|
+
const fpathGuidance = this.generateOhMyZshFpathGuidance(targetDir);
|
|
277
|
+
if (fpathGuidance) {
|
|
278
|
+
instructions = instructions ? [...instructions, '', ...fpathGuidance] : fpathGuidance;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Determine appropriate message based on update status
|
|
282
|
+
let message;
|
|
283
|
+
if (isUpdate) {
|
|
284
|
+
message = backupPath
|
|
285
|
+
? 'Completion script updated successfully (previous version backed up)'
|
|
286
|
+
: 'Completion script updated successfully';
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
message = isOhMyZsh
|
|
290
|
+
? 'Completion script installed successfully for Oh My Zsh'
|
|
291
|
+
: zshrcConfigured
|
|
292
|
+
? 'Completion script installed and .zshrc configured successfully'
|
|
293
|
+
: 'Completion script installed successfully for Zsh';
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
success: true,
|
|
297
|
+
installedPath: targetPath,
|
|
298
|
+
backupPath,
|
|
299
|
+
isOhMyZsh,
|
|
300
|
+
zshrcConfigured,
|
|
301
|
+
message,
|
|
302
|
+
instructions,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
return {
|
|
307
|
+
success: false,
|
|
308
|
+
isOhMyZsh: false,
|
|
309
|
+
message: `Failed to install completion script: ${error instanceof Error ? error.message : String(error)}`,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Generate Oh My Zsh fpath verification guidance
|
|
315
|
+
*
|
|
316
|
+
* @param completionsDir - Custom completions directory path
|
|
317
|
+
* @returns Array of guidance strings, or undefined if not needed
|
|
318
|
+
*/
|
|
319
|
+
generateOhMyZshFpathGuidance(completionsDir) {
|
|
320
|
+
return [
|
|
321
|
+
'Note: Oh My Zsh typically auto-loads completions from custom/completions.',
|
|
322
|
+
`Verify that ${completionsDir} is in your fpath by running:`,
|
|
323
|
+
' echo $fpath | grep "custom/completions"',
|
|
324
|
+
'',
|
|
325
|
+
'If not found, completions may not work. Restart your shell to ensure changes take effect.',
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Generate user instructions for enabling completions
|
|
330
|
+
*
|
|
331
|
+
* @param isOhMyZsh - Whether Oh My Zsh is being used
|
|
332
|
+
* @param installedPath - Path where the script was installed
|
|
333
|
+
* @returns Array of instruction strings
|
|
334
|
+
*/
|
|
335
|
+
generateInstructions(isOhMyZsh, installedPath) {
|
|
336
|
+
if (isOhMyZsh) {
|
|
337
|
+
return [
|
|
338
|
+
'Completion script installed to Oh My Zsh completions directory.',
|
|
339
|
+
'Restart your shell or run: exec zsh',
|
|
340
|
+
'Completions should activate automatically.',
|
|
341
|
+
];
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
const completionsDir = path.dirname(installedPath);
|
|
345
|
+
const zshrcPath = path.join(this.homeDir, '.zshrc');
|
|
346
|
+
return [
|
|
347
|
+
'Completion script installed to ~/.zsh/completions/',
|
|
348
|
+
'',
|
|
349
|
+
'To enable completions, add the following to your ~/.zshrc file:',
|
|
350
|
+
'',
|
|
351
|
+
` # Add completions directory to fpath`,
|
|
352
|
+
` fpath=(${completionsDir} $fpath)`,
|
|
353
|
+
'',
|
|
354
|
+
' # Initialize completion system',
|
|
355
|
+
' autoload -Uz compinit',
|
|
356
|
+
' compinit',
|
|
357
|
+
'',
|
|
358
|
+
'Then restart your shell or run: exec zsh',
|
|
359
|
+
'',
|
|
360
|
+
`Check if these lines already exist in ${zshrcPath} before adding.`,
|
|
361
|
+
];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Uninstall the completion script
|
|
366
|
+
*
|
|
367
|
+
* @returns true if uninstalled successfully, false otherwise
|
|
368
|
+
*/
|
|
369
|
+
async uninstall() {
|
|
370
|
+
try {
|
|
371
|
+
const { path: targetPath, isOhMyZsh } = await this.getInstallationPath();
|
|
372
|
+
// Try to remove completion script
|
|
373
|
+
let scriptRemoved = false;
|
|
374
|
+
try {
|
|
375
|
+
await fs.access(targetPath);
|
|
376
|
+
await fs.unlink(targetPath);
|
|
377
|
+
scriptRemoved = true;
|
|
378
|
+
}
|
|
379
|
+
catch {
|
|
380
|
+
// Script not installed
|
|
381
|
+
}
|
|
382
|
+
// Try to remove .zshrc configuration (only for standard Zsh)
|
|
383
|
+
let zshrcWasPresent = false;
|
|
384
|
+
let zshrcCleaned = false;
|
|
385
|
+
if (!isOhMyZsh) {
|
|
386
|
+
zshrcWasPresent = await this.hasZshrcConfig();
|
|
387
|
+
if (zshrcWasPresent) {
|
|
388
|
+
zshrcCleaned = await this.removeZshrcConfig();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (!scriptRemoved && !zshrcWasPresent) {
|
|
392
|
+
return {
|
|
393
|
+
success: false,
|
|
394
|
+
message: 'Completion script is not installed',
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
const messages = [];
|
|
398
|
+
if (scriptRemoved) {
|
|
399
|
+
messages.push(`Completion script removed from ${targetPath}`);
|
|
400
|
+
}
|
|
401
|
+
if (zshrcCleaned && !isOhMyZsh) {
|
|
402
|
+
messages.push('Removed OpenSpec configuration from ~/.zshrc');
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
success: true,
|
|
406
|
+
message: messages.join('. '),
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
return {
|
|
411
|
+
success: false,
|
|
412
|
+
message: `Failed to uninstall completion script: ${error instanceof Error ? error.message : String(error)}`,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Check if completion script is currently installed
|
|
418
|
+
*
|
|
419
|
+
* @returns true if the completion script exists
|
|
420
|
+
*/
|
|
421
|
+
async isInstalled() {
|
|
422
|
+
try {
|
|
423
|
+
const { path: targetPath } = await this.getInstallationPath();
|
|
424
|
+
await fs.access(targetPath);
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
catch {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Get information about the current installation
|
|
433
|
+
*
|
|
434
|
+
* @returns Installation status information
|
|
435
|
+
*/
|
|
436
|
+
async getInstallationInfo() {
|
|
437
|
+
const installed = await this.isInstalled();
|
|
438
|
+
if (!installed) {
|
|
439
|
+
return { installed: false };
|
|
440
|
+
}
|
|
441
|
+
const { path: targetPath, isOhMyZsh } = await this.getInstallationPath();
|
|
442
|
+
return {
|
|
443
|
+
installed: true,
|
|
444
|
+
path: targetPath,
|
|
445
|
+
isOhMyZsh,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
//# sourceMappingURL=zsh-installer.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for Bash completion scripts.
|
|
3
|
+
* These are Bash-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BASH_DYNAMIC_HELPERS = "# Dynamic completion helpers\n\n_openspec_complete_changes() {\n local changes\n changes=$(openspec __complete changes 2>/dev/null | cut -f1)\n COMPREPLY=($(compgen -W \"$changes\" -- \"$cur\"))\n}\n\n_openspec_complete_specs() {\n local specs\n specs=$(openspec __complete specs 2>/dev/null | cut -f1)\n COMPREPLY=($(compgen -W \"$specs\" -- \"$cur\"))\n}\n\n_openspec_complete_items() {\n local items\n items=$(openspec __complete changes 2>/dev/null | cut -f1; openspec __complete specs 2>/dev/null | cut -f1)\n COMPREPLY=($(compgen -W \"$items\" -- \"$cur\"))\n}";
|
|
6
|
+
//# sourceMappingURL=bash-templates.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for Bash completion scripts.
|
|
3
|
+
* These are Bash-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export const BASH_DYNAMIC_HELPERS = `# Dynamic completion helpers
|
|
6
|
+
|
|
7
|
+
_openspec_complete_changes() {
|
|
8
|
+
local changes
|
|
9
|
+
changes=$(openspec __complete changes 2>/dev/null | cut -f1)
|
|
10
|
+
COMPREPLY=($(compgen -W "$changes" -- "$cur"))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_openspec_complete_specs() {
|
|
14
|
+
local specs
|
|
15
|
+
specs=$(openspec __complete specs 2>/dev/null | cut -f1)
|
|
16
|
+
COMPREPLY=($(compgen -W "$specs" -- "$cur"))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_openspec_complete_items() {
|
|
20
|
+
local items
|
|
21
|
+
items=$(openspec __complete changes 2>/dev/null | cut -f1; openspec __complete specs 2>/dev/null | cut -f1)
|
|
22
|
+
COMPREPLY=($(compgen -W "$items" -- "$cur"))
|
|
23
|
+
}`;
|
|
24
|
+
//# sourceMappingURL=bash-templates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for Fish completion scripts.
|
|
3
|
+
* These are Fish-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FISH_STATIC_HELPERS = "# Helper function to check if a subcommand is present\nfunction __fish_openspec_using_subcommand\n set -l cmd (commandline -opc)\n set -e cmd[1]\n for i in $argv\n if contains -- $i $cmd\n return 0\n end\n end\n return 1\nend\n\nfunction __fish_openspec_no_subcommand\n set -l cmd (commandline -opc)\n test (count $cmd) -eq 1\nend";
|
|
6
|
+
export declare const FISH_DYNAMIC_HELPERS = "# Dynamic completion helpers\n\nfunction __fish_openspec_changes\n openspec __complete changes 2>/dev/null | while read -l id desc\n printf '%s\\t%s\\n' \"$id\" \"$desc\"\n end\nend\n\nfunction __fish_openspec_specs\n openspec __complete specs 2>/dev/null | while read -l id desc\n printf '%s\\t%s\\n' \"$id\" \"$desc\"\n end\nend\n\nfunction __fish_openspec_items\n __fish_openspec_changes\n __fish_openspec_specs\nend";
|
|
7
|
+
//# sourceMappingURL=fish-templates.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for Fish completion scripts.
|
|
3
|
+
* These are Fish-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export const FISH_STATIC_HELPERS = `# Helper function to check if a subcommand is present
|
|
6
|
+
function __fish_openspec_using_subcommand
|
|
7
|
+
set -l cmd (commandline -opc)
|
|
8
|
+
set -e cmd[1]
|
|
9
|
+
for i in $argv
|
|
10
|
+
if contains -- $i $cmd
|
|
11
|
+
return 0
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
return 1
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
function __fish_openspec_no_subcommand
|
|
18
|
+
set -l cmd (commandline -opc)
|
|
19
|
+
test (count $cmd) -eq 1
|
|
20
|
+
end`;
|
|
21
|
+
export const FISH_DYNAMIC_HELPERS = `# Dynamic completion helpers
|
|
22
|
+
|
|
23
|
+
function __fish_openspec_changes
|
|
24
|
+
openspec __complete changes 2>/dev/null | while read -l id desc
|
|
25
|
+
printf '%s\\t%s\\n' "$id" "$desc"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
function __fish_openspec_specs
|
|
30
|
+
openspec __complete specs 2>/dev/null | while read -l id desc
|
|
31
|
+
printf '%s\\t%s\\n' "$id" "$desc"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
function __fish_openspec_items
|
|
36
|
+
__fish_openspec_changes
|
|
37
|
+
__fish_openspec_specs
|
|
38
|
+
end`;
|
|
39
|
+
//# sourceMappingURL=fish-templates.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for PowerShell completion scripts.
|
|
3
|
+
* These are PowerShell-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export declare const POWERSHELL_DYNAMIC_HELPERS = "# Dynamic completion helpers\n\nfunction Get-OpenSpecChanges {\n $output = openspec __complete changes 2>$null\n if ($output) {\n $output | ForEach-Object {\n ($_ -split \"\\t\")[0]\n }\n }\n}\n\nfunction Get-OpenSpecSpecs {\n $output = openspec __complete specs 2>$null\n if ($output) {\n $output | ForEach-Object {\n ($_ -split \"\\t\")[0]\n }\n }\n}\n";
|
|
6
|
+
//# sourceMappingURL=powershell-templates.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for PowerShell completion scripts.
|
|
3
|
+
* These are PowerShell-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export const POWERSHELL_DYNAMIC_HELPERS = `# Dynamic completion helpers
|
|
6
|
+
|
|
7
|
+
function Get-OpenSpecChanges {
|
|
8
|
+
$output = openspec __complete changes 2>$null
|
|
9
|
+
if ($output) {
|
|
10
|
+
$output | ForEach-Object {
|
|
11
|
+
($_ -split "\\t")[0]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Get-OpenSpecSpecs {
|
|
17
|
+
$output = openspec __complete specs 2>$null
|
|
18
|
+
if ($output) {
|
|
19
|
+
$output | ForEach-Object {
|
|
20
|
+
($_ -split "\\t")[0]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
//# sourceMappingURL=powershell-templates.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for Zsh completion scripts.
|
|
3
|
+
* These are Zsh-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ZSH_DYNAMIC_HELPERS = "# Dynamic completion helpers\n\n# Use openspec __complete to get available changes\n_openspec_complete_changes() {\n local -a changes\n while IFS=$'\\t' read -r id desc; do\n changes+=(\"$id:$desc\")\n done < <(openspec __complete changes 2>/dev/null)\n _describe \"change\" changes\n}\n\n# Use openspec __complete to get available specs\n_openspec_complete_specs() {\n local -a specs\n while IFS=$'\\t' read -r id desc; do\n specs+=(\"$id:$desc\")\n done < <(openspec __complete specs 2>/dev/null)\n _describe \"spec\" specs\n}\n\n# Get both changes and specs\n_openspec_complete_items() {\n local -a items\n while IFS=$'\\t' read -r id desc; do\n items+=(\"$id:$desc\")\n done < <(openspec __complete changes 2>/dev/null)\n while IFS=$'\\t' read -r id desc; do\n items+=(\"$id:$desc\")\n done < <(openspec __complete specs 2>/dev/null)\n _describe \"item\" items\n}";
|
|
6
|
+
//# sourceMappingURL=zsh-templates.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static template strings for Zsh completion scripts.
|
|
3
|
+
* These are Zsh-specific helper functions that never change.
|
|
4
|
+
*/
|
|
5
|
+
export const ZSH_DYNAMIC_HELPERS = `# Dynamic completion helpers
|
|
6
|
+
|
|
7
|
+
# Use openspec __complete to get available changes
|
|
8
|
+
_openspec_complete_changes() {
|
|
9
|
+
local -a changes
|
|
10
|
+
while IFS=$'\\t' read -r id desc; do
|
|
11
|
+
changes+=("$id:$desc")
|
|
12
|
+
done < <(openspec __complete changes 2>/dev/null)
|
|
13
|
+
_describe "change" changes
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# Use openspec __complete to get available specs
|
|
17
|
+
_openspec_complete_specs() {
|
|
18
|
+
local -a specs
|
|
19
|
+
while IFS=$'\\t' read -r id desc; do
|
|
20
|
+
specs+=("$id:$desc")
|
|
21
|
+
done < <(openspec __complete specs 2>/dev/null)
|
|
22
|
+
_describe "spec" specs
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Get both changes and specs
|
|
26
|
+
_openspec_complete_items() {
|
|
27
|
+
local -a items
|
|
28
|
+
while IFS=$'\\t' read -r id desc; do
|
|
29
|
+
items+=("$id:$desc")
|
|
30
|
+
done < <(openspec __complete changes 2>/dev/null)
|
|
31
|
+
while IFS=$'\\t' read -r id desc; do
|
|
32
|
+
items+=("$id:$desc")
|
|
33
|
+
done < <(openspec __complete specs 2>/dev/null)
|
|
34
|
+
_describe "item" items
|
|
35
|
+
}`;
|
|
36
|
+
//# sourceMappingURL=zsh-templates.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { SupportedShell } from '../../utils/shell-detection.js';
|
|
2
|
+
/**
|
|
3
|
+
* Definition of a command-line flag/option
|
|
4
|
+
*/
|
|
5
|
+
export interface FlagDefinition {
|
|
6
|
+
/**
|
|
7
|
+
* Flag name without dashes (e.g., "json", "strict", "no-interactive")
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Short flag name without dash (e.g., "y" for "-y")
|
|
12
|
+
*/
|
|
13
|
+
short?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Human-readable description of what the flag does
|
|
16
|
+
*/
|
|
17
|
+
description: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the flag takes an argument value
|
|
20
|
+
*/
|
|
21
|
+
takesValue?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Possible values for the flag (for completion suggestions)
|
|
24
|
+
*/
|
|
25
|
+
values?: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Definition of a CLI command
|
|
29
|
+
*/
|
|
30
|
+
export interface CommandDefinition {
|
|
31
|
+
/**
|
|
32
|
+
* Command name (e.g., "init", "validate", "show")
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* Human-readable description of the command
|
|
37
|
+
*/
|
|
38
|
+
description: string;
|
|
39
|
+
/**
|
|
40
|
+
* Flags/options supported by this command
|
|
41
|
+
*/
|
|
42
|
+
flags: FlagDefinition[];
|
|
43
|
+
/**
|
|
44
|
+
* Subcommands (e.g., "change show", "spec validate")
|
|
45
|
+
*/
|
|
46
|
+
subcommands?: CommandDefinition[];
|
|
47
|
+
/**
|
|
48
|
+
* Whether this command accepts a positional argument (e.g., item name, path)
|
|
49
|
+
*/
|
|
50
|
+
acceptsPositional?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Type of positional argument for dynamic completion
|
|
53
|
+
* - 'change-id': Complete with active change IDs
|
|
54
|
+
* - 'spec-id': Complete with spec IDs
|
|
55
|
+
* - 'change-or-spec-id': Complete with both changes and specs
|
|
56
|
+
* - 'path': Complete with file paths
|
|
57
|
+
* - 'shell': Complete with supported shell names
|
|
58
|
+
* - 'schema-name': Complete with available schema names
|
|
59
|
+
* - undefined: No specific completion
|
|
60
|
+
*/
|
|
61
|
+
positionalType?: 'change-id' | 'spec-id' | 'change-or-spec-id' | 'path' | 'shell' | 'schema-name';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Interface for shell-specific completion script generators
|
|
65
|
+
*/
|
|
66
|
+
export interface CompletionGenerator {
|
|
67
|
+
/**
|
|
68
|
+
* The shell type this generator targets
|
|
69
|
+
*/
|
|
70
|
+
readonly shell: SupportedShell;
|
|
71
|
+
/**
|
|
72
|
+
* Generate the completion script content
|
|
73
|
+
*
|
|
74
|
+
* @param commands - Command definitions to generate completions for
|
|
75
|
+
* @returns The shell-specific completion script as a string
|
|
76
|
+
*/
|
|
77
|
+
generate(commands: CommandDefinition[]): string;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|