( input: string, cursorOffset: number, abortSignal: AbortSignal, )
| 219 | * Supports bash and zsh shells (matches Shell.ts execution support) |
| 220 | */ |
| 221 | export async function getShellCompletions( |
| 222 | input: string, |
| 223 | cursorOffset: number, |
| 224 | abortSignal: AbortSignal, |
| 225 | ): Promise<SuggestionItem[]> { |
| 226 | const shellType = getShellType() |
| 227 | |
| 228 | // Only support bash/zsh (matches Shell.ts execution support) |
| 229 | if (shellType !== 'bash' && shellType !== 'zsh') { |
| 230 | return [] |
| 231 | } |
| 232 | |
| 233 | try { |
| 234 | const { prefix, completionType } = parseInputContext(input, cursorOffset) |
| 235 | |
| 236 | if (!prefix) { |
| 237 | return [] |
| 238 | } |
| 239 | |
| 240 | const completions = await getCompletionsForShell( |
| 241 | shellType, |
| 242 | prefix, |
| 243 | completionType, |
| 244 | abortSignal, |
| 245 | ) |
| 246 | |
| 247 | // Add inputSnapshot to all suggestions so we can detect when input changes |
| 248 | return completions.map(suggestion => ({ |
| 249 | ...suggestion, |
| 250 | metadata: { |
| 251 | ...(suggestion.metadata as { completionType: ShellCompletionType }), |
| 252 | inputSnapshot: input, |
| 253 | }, |
| 254 | })) |
| 255 | } catch (error) { |
| 256 | logForDebugging(`Shell completion failed: ${error}`) |
| 257 | return [] // Silent fail |
| 258 | } |
| 259 | } |
no test coverage detected