MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getShellCompletions

Function getShellCompletions

src/utils/bash/shellCompletion.ts:221–259  ·  view source on GitHub ↗
(
  input: string,
  cursorOffset: number,
  abortSignal: AbortSignal,
)

Source from the content-addressed store, hash-verified

219 * Supports bash and zsh shells (matches Shell.ts execution support)
220 */
221export 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}

Callers 1

generateBashSuggestionsFunction · 0.85

Calls 4

getShellTypeFunction · 0.85
parseInputContextFunction · 0.85
getCompletionsForShellFunction · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected