@fission-ai/openspec 0.17.2 → 0.19.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/README.md +52 -0
- package/dist/cli/index.js +39 -3
- package/dist/commands/artifact-workflow.d.ts +17 -0
- package/dist/commands/artifact-workflow.js +823 -0
- package/dist/commands/completion.js +42 -6
- package/dist/core/archive.d.ts +0 -5
- package/dist/core/archive.js +4 -257
- 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 +130 -0
- package/dist/core/artifact-graph/instruction-loader.js +173 -0
- package/dist/core/artifact-graph/resolver.d.ts +61 -0
- package/dist/core/artifact-graph/resolver.js +187 -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/completions/command-registry.js +7 -1
- package/dist/core/completions/factory.d.ts +15 -2
- package/dist/core/completions/factory.js +19 -1
- 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 +32 -0
- package/dist/core/completions/generators/powershell-generator.js +198 -0
- package/dist/core/completions/generators/zsh-generator.d.ts +0 -14
- package/dist/core/completions/generators/zsh-generator.js +55 -124
- 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 +1 -12
- 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/config.js +1 -0
- package/dist/core/configurators/slash/codebuddy.js +6 -9
- package/dist/core/configurators/slash/continue.d.ts +9 -0
- package/dist/core/configurators/slash/continue.js +46 -0
- package/dist/core/configurators/slash/registry.js +3 -0
- package/dist/core/converters/json-converter.js +2 -1
- package/dist/core/global-config.d.ts +10 -0
- package/dist/core/global-config.js +28 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/list.d.ts +6 -1
- package/dist/core/list.js +88 -6
- package/dist/core/specs-apply.d.ts +73 -0
- package/dist/core/specs-apply.js +384 -0
- package/dist/core/templates/skill-templates.d.ts +86 -0
- package/dist/core/templates/skill-templates.js +1934 -0
- package/dist/core/update.js +1 -1
- package/dist/core/validation/validator.js +2 -1
- package/dist/core/view.js +28 -8
- 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/utils/change-metadata.d.ts +47 -0
- package/dist/utils/change-metadata.js +130 -0
- package/dist/utils/change-utils.d.ts +51 -0
- package/dist/utils/change-utils.js +100 -0
- package/dist/utils/file-system.d.ts +11 -0
- package/dist/utils/file-system.js +50 -2
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +4 -1
- package/package.json +5 -1
- 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
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { POWERSHELL_DYNAMIC_HELPERS } from '../templates/powershell-templates.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates PowerShell completion scripts for the OpenSpec CLI.
|
|
4
|
+
* Uses Register-ArgumentCompleter for command completion.
|
|
5
|
+
*/
|
|
6
|
+
export class PowerShellGenerator {
|
|
7
|
+
shell = 'powershell';
|
|
8
|
+
/**
|
|
9
|
+
* Generate a PowerShell completion script
|
|
10
|
+
*
|
|
11
|
+
* @param commands - Command definitions to generate completions for
|
|
12
|
+
* @returns PowerShell completion script as a string
|
|
13
|
+
*/
|
|
14
|
+
generate(commands) {
|
|
15
|
+
// Build top-level commands using push() for loop clarity
|
|
16
|
+
const commandLines = [];
|
|
17
|
+
for (const cmd of commands) {
|
|
18
|
+
commandLines.push(` @{Name="${cmd.name}"; Description="${this.escapeDescription(cmd.description)}"},`);
|
|
19
|
+
}
|
|
20
|
+
const topLevelCommands = commandLines.join('\n');
|
|
21
|
+
// Build command cases using push() for loop clarity
|
|
22
|
+
const commandCaseLines = [];
|
|
23
|
+
for (const cmd of commands) {
|
|
24
|
+
commandCaseLines.push(` "${cmd.name}" {`);
|
|
25
|
+
commandCaseLines.push(...this.generateCommandCase(cmd, ' '));
|
|
26
|
+
commandCaseLines.push(' }');
|
|
27
|
+
}
|
|
28
|
+
const commandCases = commandCaseLines.join('\n');
|
|
29
|
+
// Dynamic completion helpers from template
|
|
30
|
+
const helpers = POWERSHELL_DYNAMIC_HELPERS;
|
|
31
|
+
// Assemble final script with template literal
|
|
32
|
+
return `# PowerShell completion script for OpenSpec CLI
|
|
33
|
+
# Auto-generated - do not edit manually
|
|
34
|
+
|
|
35
|
+
${helpers}
|
|
36
|
+
$openspecCompleter = {
|
|
37
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
38
|
+
|
|
39
|
+
$tokens = $commandAst.ToString() -split "\\s+"
|
|
40
|
+
$commandCount = ($tokens | Measure-Object).Count
|
|
41
|
+
|
|
42
|
+
# Top-level commands
|
|
43
|
+
if ($commandCount -eq 1 -or ($commandCount -eq 2 -and $wordToComplete)) {
|
|
44
|
+
$commands = @(
|
|
45
|
+
${topLevelCommands}
|
|
46
|
+
)
|
|
47
|
+
$commands | Where-Object { $_.Name -like "$wordToComplete*" } | ForEach-Object {
|
|
48
|
+
[System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, "ParameterValue", $_.Description)
|
|
49
|
+
}
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
$command = $tokens[1]
|
|
54
|
+
|
|
55
|
+
switch ($command) {
|
|
56
|
+
${commandCases}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Register-ArgumentCompleter -CommandName openspec -ScriptBlock $openspecCompleter
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Generate completion case for a command
|
|
65
|
+
*/
|
|
66
|
+
generateCommandCase(cmd, indent) {
|
|
67
|
+
const lines = [];
|
|
68
|
+
if (cmd.subcommands && cmd.subcommands.length > 0) {
|
|
69
|
+
// First, check if user is typing a flag for the parent command
|
|
70
|
+
if (cmd.flags.length > 0) {
|
|
71
|
+
lines.push(`${indent}if ($wordToComplete -like "-*") {`);
|
|
72
|
+
lines.push(`${indent} $flags = @(`);
|
|
73
|
+
for (const flag of cmd.flags) {
|
|
74
|
+
const longFlag = `--${flag.name}`;
|
|
75
|
+
const shortFlag = flag.short ? `-${flag.short}` : undefined;
|
|
76
|
+
if (shortFlag) {
|
|
77
|
+
lines.push(`${indent} @{Name="${longFlag}"; Description="${this.escapeDescription(flag.description)}"},`);
|
|
78
|
+
lines.push(`${indent} @{Name="${shortFlag}"; Description="${this.escapeDescription(flag.description)}"},`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
lines.push(`${indent} @{Name="${longFlag}"; Description="${this.escapeDescription(flag.description)}"},`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
lines.push(`${indent} )`);
|
|
85
|
+
lines.push(`${indent} $flags | Where-Object { $_.Name -like "$wordToComplete*" } | ForEach-Object {`);
|
|
86
|
+
lines.push(`${indent} [System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, "ParameterName", $_.Description)`);
|
|
87
|
+
lines.push(`${indent} }`);
|
|
88
|
+
lines.push(`${indent} return`);
|
|
89
|
+
lines.push(`${indent}}`);
|
|
90
|
+
lines.push('');
|
|
91
|
+
}
|
|
92
|
+
// Handle subcommands
|
|
93
|
+
lines.push(`${indent}if ($commandCount -eq 2 -or ($commandCount -eq 3 -and $wordToComplete)) {`);
|
|
94
|
+
lines.push(`${indent} $subcommands = @(`);
|
|
95
|
+
for (const subcmd of cmd.subcommands) {
|
|
96
|
+
lines.push(`${indent} @{Name="${subcmd.name}"; Description="${this.escapeDescription(subcmd.description)}"},`);
|
|
97
|
+
}
|
|
98
|
+
lines.push(`${indent} )`);
|
|
99
|
+
lines.push(`${indent} $subcommands | Where-Object { $_.Name -like "$wordToComplete*" } | ForEach-Object {`);
|
|
100
|
+
lines.push(`${indent} [System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, "ParameterValue", $_.Description)`);
|
|
101
|
+
lines.push(`${indent} }`);
|
|
102
|
+
lines.push(`${indent} return`);
|
|
103
|
+
lines.push(`${indent}}`);
|
|
104
|
+
lines.push('');
|
|
105
|
+
lines.push(`${indent}$subcommand = if ($commandCount -gt 2) { $tokens[2] } else { "" }`);
|
|
106
|
+
lines.push(`${indent}switch ($subcommand) {`);
|
|
107
|
+
for (const subcmd of cmd.subcommands) {
|
|
108
|
+
lines.push(`${indent} "${subcmd.name}" {`);
|
|
109
|
+
lines.push(...this.generateArgumentCompletion(subcmd, indent + ' '));
|
|
110
|
+
lines.push(`${indent} }`);
|
|
111
|
+
}
|
|
112
|
+
lines.push(`${indent}}`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// No subcommands
|
|
116
|
+
lines.push(...this.generateArgumentCompletion(cmd, indent));
|
|
117
|
+
}
|
|
118
|
+
return lines;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Generate argument completion (flags and positional)
|
|
122
|
+
*/
|
|
123
|
+
generateArgumentCompletion(cmd, indent) {
|
|
124
|
+
const lines = [];
|
|
125
|
+
// Flag completion
|
|
126
|
+
if (cmd.flags.length > 0) {
|
|
127
|
+
lines.push(`${indent}if ($wordToComplete -like "-*") {`);
|
|
128
|
+
lines.push(`${indent} $flags = @(`);
|
|
129
|
+
for (const flag of cmd.flags) {
|
|
130
|
+
const longFlag = `--${flag.name}`;
|
|
131
|
+
const shortFlag = flag.short ? `-${flag.short}` : undefined;
|
|
132
|
+
if (shortFlag) {
|
|
133
|
+
lines.push(`${indent} @{Name="${longFlag}"; Description="${this.escapeDescription(flag.description)}"},`);
|
|
134
|
+
lines.push(`${indent} @{Name="${shortFlag}"; Description="${this.escapeDescription(flag.description)}"},`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
lines.push(`${indent} @{Name="${longFlag}"; Description="${this.escapeDescription(flag.description)}"},`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
lines.push(`${indent} )`);
|
|
141
|
+
lines.push(`${indent} $flags | Where-Object { $_.Name -like "$wordToComplete*" } | ForEach-Object {`);
|
|
142
|
+
lines.push(`${indent} [System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, "ParameterName", $_.Description)`);
|
|
143
|
+
lines.push(`${indent} }`);
|
|
144
|
+
lines.push(`${indent} return`);
|
|
145
|
+
lines.push(`${indent}}`);
|
|
146
|
+
lines.push('');
|
|
147
|
+
}
|
|
148
|
+
// Positional completion
|
|
149
|
+
if (cmd.acceptsPositional) {
|
|
150
|
+
lines.push(...this.generatePositionalCompletion(cmd.positionalType, indent));
|
|
151
|
+
}
|
|
152
|
+
return lines;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Generate positional argument completion
|
|
156
|
+
*/
|
|
157
|
+
generatePositionalCompletion(positionalType, indent) {
|
|
158
|
+
const lines = [];
|
|
159
|
+
switch (positionalType) {
|
|
160
|
+
case 'change-id':
|
|
161
|
+
lines.push(`${indent}Get-OpenSpecChanges | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {`);
|
|
162
|
+
lines.push(`${indent} [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", "Change: $_")`);
|
|
163
|
+
lines.push(`${indent}}`);
|
|
164
|
+
break;
|
|
165
|
+
case 'spec-id':
|
|
166
|
+
lines.push(`${indent}Get-OpenSpecSpecs | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {`);
|
|
167
|
+
lines.push(`${indent} [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", "Spec: $_")`);
|
|
168
|
+
lines.push(`${indent}}`);
|
|
169
|
+
break;
|
|
170
|
+
case 'change-or-spec-id':
|
|
171
|
+
lines.push(`${indent}$items = @(Get-OpenSpecChanges) + @(Get-OpenSpecSpecs)`);
|
|
172
|
+
lines.push(`${indent}$items | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {`);
|
|
173
|
+
lines.push(`${indent} [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)`);
|
|
174
|
+
lines.push(`${indent}}`);
|
|
175
|
+
break;
|
|
176
|
+
case 'shell':
|
|
177
|
+
lines.push(`${indent}$shells = @("zsh", "bash", "fish", "powershell")`);
|
|
178
|
+
lines.push(`${indent}$shells | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {`);
|
|
179
|
+
lines.push(`${indent} [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", "Shell: $_")`);
|
|
180
|
+
lines.push(`${indent}}`);
|
|
181
|
+
break;
|
|
182
|
+
case 'path':
|
|
183
|
+
// PowerShell handles file path completion automatically
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
return lines;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Escape description text for PowerShell
|
|
190
|
+
*/
|
|
191
|
+
escapeDescription(description) {
|
|
192
|
+
return description
|
|
193
|
+
.replace(/`/g, '``') // Backticks (escape sequences)
|
|
194
|
+
.replace(/\$/g, '`$') // Dollar signs (prevents $())
|
|
195
|
+
.replace(/"/g, '""'); // Double quotes
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=powershell-generator.js.map
|
|
@@ -12,20 +12,6 @@ export declare class ZshGenerator implements CompletionGenerator {
|
|
|
12
12
|
* @returns Zsh completion script as a string
|
|
13
13
|
*/
|
|
14
14
|
generate(commands: CommandDefinition[]): string;
|
|
15
|
-
/**
|
|
16
|
-
* Generate a single completion function
|
|
17
|
-
*
|
|
18
|
-
* @param functionName - Name of the completion function
|
|
19
|
-
* @param varName - Name of the local array variable
|
|
20
|
-
* @param varLabel - Label for the completion items
|
|
21
|
-
* @param commandLines - Command line(s) to populate the array
|
|
22
|
-
* @param comment - Optional comment describing the function
|
|
23
|
-
*/
|
|
24
|
-
private generateCompletionFunction;
|
|
25
|
-
/**
|
|
26
|
-
* Generate dynamic completion helper functions for change and spec IDs
|
|
27
|
-
*/
|
|
28
|
-
private generateDynamicCompletionHelpers;
|
|
29
15
|
/**
|
|
30
16
|
* Generate completion function for a specific command
|
|
31
17
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ZSH_DYNAMIC_HELPERS } from '../templates/zsh-templates.js';
|
|
1
2
|
/**
|
|
2
3
|
* Generates Zsh completion scripts for the OpenSpec CLI.
|
|
3
4
|
* Follows Zsh completion system conventions using the _openspec function.
|
|
@@ -11,135 +12,65 @@ export class ZshGenerator {
|
|
|
11
12
|
* @returns Zsh completion script as a string
|
|
12
13
|
*/
|
|
13
14
|
generate(commands) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
script.push('#compdef openspec');
|
|
17
|
-
script.push('');
|
|
18
|
-
script.push('# Zsh completion script for OpenSpec CLI');
|
|
19
|
-
script.push('# Auto-generated - do not edit manually');
|
|
20
|
-
script.push('');
|
|
21
|
-
// Main completion function
|
|
22
|
-
script.push('_openspec() {');
|
|
23
|
-
script.push(' local context state line');
|
|
24
|
-
script.push(' typeset -A opt_args');
|
|
25
|
-
script.push('');
|
|
26
|
-
// Generate main command argument specification
|
|
27
|
-
script.push(' local -a commands');
|
|
28
|
-
script.push(' commands=(');
|
|
15
|
+
// Build command list using push() for loop clarity
|
|
16
|
+
const commandLines = [];
|
|
29
17
|
for (const cmd of commands) {
|
|
30
18
|
const escapedDesc = this.escapeDescription(cmd.description);
|
|
31
|
-
|
|
19
|
+
commandLines.push(` '${cmd.name}:${escapedDesc}'`);
|
|
32
20
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
script.push(' _arguments -C \\');
|
|
37
|
-
script.push(' "1: :->command" \\');
|
|
38
|
-
script.push(' "*::arg:->args"');
|
|
39
|
-
script.push('');
|
|
40
|
-
// Command dispatch logic
|
|
41
|
-
script.push(' case $state in');
|
|
42
|
-
script.push(' command)');
|
|
43
|
-
script.push(' _describe "openspec command" commands');
|
|
44
|
-
script.push(' ;;');
|
|
45
|
-
script.push(' args)');
|
|
46
|
-
script.push(' case $words[1] in');
|
|
47
|
-
// Generate completion for each command
|
|
21
|
+
const commandList = commandLines.join('\n');
|
|
22
|
+
// Build command cases using push() for loop clarity
|
|
23
|
+
const commandCaseLines = [];
|
|
48
24
|
for (const cmd of commands) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
commandCaseLines.push(` ${cmd.name})`);
|
|
26
|
+
commandCaseLines.push(` _openspec_${this.sanitizeFunctionName(cmd.name)}`);
|
|
27
|
+
commandCaseLines.push(' ;;');
|
|
52
28
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
script.push('}');
|
|
57
|
-
script.push('');
|
|
58
|
-
// Generate individual command completion functions
|
|
29
|
+
const commandCases = commandCaseLines.join('\n');
|
|
30
|
+
// Build command functions using push() for loop clarity
|
|
31
|
+
const commandFunctionLines = [];
|
|
59
32
|
for (const cmd of commands) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
script
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Generate dynamic completion helper functions for change and spec IDs
|
|
104
|
-
*/
|
|
105
|
-
generateDynamicCompletionHelpers() {
|
|
106
|
-
const lines = [];
|
|
107
|
-
lines.push('# Dynamic completion helpers');
|
|
108
|
-
lines.push('');
|
|
109
|
-
// Helper function for completing change IDs
|
|
110
|
-
lines.push('# Use openspec __complete to get available changes');
|
|
111
|
-
lines.push('_openspec_complete_changes() {');
|
|
112
|
-
lines.push(' local -a changes');
|
|
113
|
-
lines.push(' while IFS=$\'\\t\' read -r id desc; do');
|
|
114
|
-
lines.push(' changes+=("$id:$desc")');
|
|
115
|
-
lines.push(' done < <(openspec __complete changes 2>/dev/null)');
|
|
116
|
-
lines.push(' _describe "change" changes');
|
|
117
|
-
lines.push('}');
|
|
118
|
-
lines.push('');
|
|
119
|
-
// Helper function for completing spec IDs
|
|
120
|
-
lines.push('# Use openspec __complete to get available specs');
|
|
121
|
-
lines.push('_openspec_complete_specs() {');
|
|
122
|
-
lines.push(' local -a specs');
|
|
123
|
-
lines.push(' while IFS=$\'\\t\' read -r id desc; do');
|
|
124
|
-
lines.push(' specs+=("$id:$desc")');
|
|
125
|
-
lines.push(' done < <(openspec __complete specs 2>/dev/null)');
|
|
126
|
-
lines.push(' _describe "spec" specs');
|
|
127
|
-
lines.push('}');
|
|
128
|
-
lines.push('');
|
|
129
|
-
// Helper function for completing both changes and specs
|
|
130
|
-
lines.push('# Get both changes and specs');
|
|
131
|
-
lines.push('_openspec_complete_items() {');
|
|
132
|
-
lines.push(' local -a items');
|
|
133
|
-
lines.push(' while IFS=$\'\\t\' read -r id desc; do');
|
|
134
|
-
lines.push(' items+=("$id:$desc")');
|
|
135
|
-
lines.push(' done < <(openspec __complete changes 2>/dev/null)');
|
|
136
|
-
lines.push(' while IFS=$\'\\t\' read -r id desc; do');
|
|
137
|
-
lines.push(' items+=("$id:$desc")');
|
|
138
|
-
lines.push(' done < <(openspec __complete specs 2>/dev/null)');
|
|
139
|
-
lines.push(' _describe "item" items');
|
|
140
|
-
lines.push('}');
|
|
141
|
-
lines.push('');
|
|
142
|
-
return lines;
|
|
33
|
+
commandFunctionLines.push(...this.generateCommandFunction(cmd));
|
|
34
|
+
commandFunctionLines.push('');
|
|
35
|
+
}
|
|
36
|
+
const commandFunctions = commandFunctionLines.join('\n');
|
|
37
|
+
// Dynamic completion helpers from template
|
|
38
|
+
const helpers = ZSH_DYNAMIC_HELPERS;
|
|
39
|
+
// Assemble final script with template literal
|
|
40
|
+
return `#compdef openspec
|
|
41
|
+
|
|
42
|
+
# Zsh completion script for OpenSpec CLI
|
|
43
|
+
# Auto-generated - do not edit manually
|
|
44
|
+
|
|
45
|
+
_openspec() {
|
|
46
|
+
local context state line
|
|
47
|
+
typeset -A opt_args
|
|
48
|
+
|
|
49
|
+
local -a commands
|
|
50
|
+
commands=(
|
|
51
|
+
${commandList}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
_arguments -C \\
|
|
55
|
+
"1: :->command" \\
|
|
56
|
+
"*::arg:->args"
|
|
57
|
+
|
|
58
|
+
case $state in
|
|
59
|
+
command)
|
|
60
|
+
_describe "openspec command" commands
|
|
61
|
+
;;
|
|
62
|
+
args)
|
|
63
|
+
case $words[1] in
|
|
64
|
+
${commandCases}
|
|
65
|
+
esac
|
|
66
|
+
;;
|
|
67
|
+
esac
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
${commandFunctions}
|
|
71
|
+
${helpers}
|
|
72
|
+
compdef _openspec openspec
|
|
73
|
+
`;
|
|
143
74
|
}
|
|
144
75
|
/**
|
|
145
76
|
* Generate completion function for a specific command
|
|
@@ -284,7 +215,7 @@ export class ZshGenerator {
|
|
|
284
215
|
case 'path':
|
|
285
216
|
return "'*:path:_files'";
|
|
286
217
|
case 'shell':
|
|
287
|
-
return "'*:shell:(zsh)'";
|
|
218
|
+
return "'*:shell:(zsh bash fish powershell)'";
|
|
288
219
|
default:
|
|
289
220
|
return "'*: :_default'";
|
|
290
221
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { InstallationResult } from '../factory.js';
|
|
2
|
+
/**
|
|
3
|
+
* Installer for Bash completion scripts.
|
|
4
|
+
* Supports bash-completion package and standalone installations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BashInstaller {
|
|
7
|
+
private readonly homeDir;
|
|
8
|
+
/**
|
|
9
|
+
* Markers for .bashrc configuration management
|
|
10
|
+
*/
|
|
11
|
+
private readonly BASHRC_MARKERS;
|
|
12
|
+
constructor(homeDir?: string);
|
|
13
|
+
/**
|
|
14
|
+
* Check if bash-completion is installed
|
|
15
|
+
*
|
|
16
|
+
* @returns true if bash-completion directories exist
|
|
17
|
+
*/
|
|
18
|
+
isBashCompletionInstalled(): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the appropriate installation path for the completion script
|
|
21
|
+
*
|
|
22
|
+
* @returns Installation path
|
|
23
|
+
*/
|
|
24
|
+
getInstallationPath(): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Backup an existing completion file if it exists
|
|
27
|
+
*
|
|
28
|
+
* @param targetPath - Path to the file to backup
|
|
29
|
+
* @returns Path to the backup file, or undefined if no backup was needed
|
|
30
|
+
*/
|
|
31
|
+
backupExistingFile(targetPath: string): Promise<string | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the path to .bashrc file
|
|
34
|
+
*
|
|
35
|
+
* @returns Path to .bashrc
|
|
36
|
+
*/
|
|
37
|
+
private getBashrcPath;
|
|
38
|
+
/**
|
|
39
|
+
* Generate .bashrc configuration content
|
|
40
|
+
*
|
|
41
|
+
* @param completionsDir - Directory containing completion scripts
|
|
42
|
+
* @returns Configuration content
|
|
43
|
+
*/
|
|
44
|
+
private generateBashrcConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Configure .bashrc to enable completions
|
|
47
|
+
*
|
|
48
|
+
* @param completionsDir - Directory containing completion scripts
|
|
49
|
+
* @returns true if configured successfully, false otherwise
|
|
50
|
+
*/
|
|
51
|
+
configureBashrc(completionsDir: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Remove .bashrc configuration
|
|
54
|
+
* Used during uninstallation
|
|
55
|
+
*
|
|
56
|
+
* @returns true if removed successfully, false otherwise
|
|
57
|
+
*/
|
|
58
|
+
removeBashrcConfig(): Promise<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Install the completion script
|
|
61
|
+
*
|
|
62
|
+
* @param completionScript - The completion script content to install
|
|
63
|
+
* @returns Installation result with status and instructions
|
|
64
|
+
*/
|
|
65
|
+
install(completionScript: string): Promise<InstallationResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Generate user instructions for enabling completions
|
|
68
|
+
*
|
|
69
|
+
* @param installedPath - Path where the script was installed
|
|
70
|
+
* @returns Array of instruction strings
|
|
71
|
+
*/
|
|
72
|
+
private generateInstructions;
|
|
73
|
+
/**
|
|
74
|
+
* Uninstall the completion script
|
|
75
|
+
*
|
|
76
|
+
* @param options - Optional uninstall options
|
|
77
|
+
* @param options.yes - Skip confirmation prompt (handled by command layer)
|
|
78
|
+
* @returns Uninstallation result
|
|
79
|
+
*/
|
|
80
|
+
uninstall(options?: {
|
|
81
|
+
yes?: boolean;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
success: boolean;
|
|
84
|
+
message: string;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=bash-installer.d.ts.map
|