From 4eea909f28c43341d45f1e8a9089a9dba9b99e97 Mon Sep 17 00:00:00 2001 From: jacob314 Date: Wed, 25 Feb 2026 09:26:38 -0800 Subject: [PATCH] fix(cli): add Windows shell built-in commands to autocomplete list On Windows, many common commands like `dir`, `copy`, `del`, etc., are internal to `cmd.exe` and do not exist as separate executables on the disk. This updates `scanPathExecutables` to explicitly include these built-ins when running on Windows, ensuring a consistent autocomplete experience for Windows users. --- .../src/ui/hooks/useShellCompletion.test.ts | 4 ++ .../cli/src/ui/hooks/useShellCompletion.ts | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/packages/cli/src/ui/hooks/useShellCompletion.test.ts b/packages/cli/src/ui/hooks/useShellCompletion.test.ts index 93f7187c0e..dbfa955091 100644 --- a/packages/cli/src/ui/hooks/useShellCompletion.test.ts +++ b/packages/cli/src/ui/hooks/useShellCompletion.test.ts @@ -357,6 +357,10 @@ describe('useShellCompletion utilities', () => { // Very basic sanity check: common commands should be found if (process.platform !== 'win32') { expect(results).toContain('ls'); + } else { + expect(results).toContain('dir'); + expect(results).toContain('cls'); + expect(results).toContain('copy'); } }); diff --git a/packages/cli/src/ui/hooks/useShellCompletion.ts b/packages/cli/src/ui/hooks/useShellCompletion.ts index 41ae17105b..19442af280 100644 --- a/packages/cli/src/ui/hooks/useShellCompletion.ts +++ b/packages/cli/src/ui/hooks/useShellCompletion.ts @@ -182,6 +182,60 @@ export async function scanPathExecutables( const seen = new Set(); const executables: string[] = []; + // Add Windows shell built-ins + if (isWindows) { + const builtins = [ + 'assoc', + 'break', + 'call', + 'cd', + 'chcp', + 'chdir', + 'cls', + 'color', + 'copy', + 'date', + 'del', + 'dir', + 'echo', + 'endlocal', + 'erase', + 'exit', + 'for', + 'ftype', + 'goto', + 'if', + 'md', + 'mkdir', + 'mklink', + 'move', + 'path', + 'pause', + 'popd', + 'prompt', + 'pushd', + 'rd', + 'rem', + 'ren', + 'rename', + 'rmdir', + 'set', + 'setlocal', + 'shift', + 'start', + 'time', + 'title', + 'type', + 'ver', + 'verify', + 'vol', + ]; + for (const builtin of builtins) { + seen.add(builtin); + executables.push(builtin); + } + } + const dirResults = await Promise.all( dirs.map(async (dir) => { if (signal?.aborted) return [];