Skip to content

fix: Windows cross-platform support in CLI#281

Open
mperkins0155 wants to merge 2 commits into
TinyAGI:mainfrom
mperkins0155:fix/windows-cross-platform
Open

fix: Windows cross-platform support in CLI#281
mperkins0155 wants to merge 2 commits into
TinyAGI:mainfrom
mperkins0155:fix/windows-cross-platform

Conversation

@mperkins0155

Copy link
Copy Markdown

What

Fixes three Windows-only bugs that prevented the tinyagi CLI from running on native Windows (non-WSL).

1. Doubled drive letter → MODULE_NOT_FOUND

new URL('.', import.meta.url).pathname returns /C:/Users/... on Windows. Passing that to path.resolve makes Node treat the leading / as the current drive root and prepend it, producing C:\C:\Users\...:

Error: Cannot find module 'C:\C:\Users\...\packages\cli\dist\version.js'

Fixed by using fileURLToPath() (correct on all platforms) in:

  • packages/cli/bin/tinyagi.mjs (REPO_ROOT)
  • packages/cli/lib/defaults.mjs (SCRIPT_DIR)

2. False "Missing prerequisites: node, npm"

commandExists() ran the POSIX shell builtin command -v via cmd.exe, which has no such command, so every check failed even with Node/npm installed. Now uses where on win32, command -v elsewhere (packages/cli/src/install.ts).

Testing

Verified on Windows 11, Node v25:

  • npm run build — clean
  • tinyagi version / install (detects existing build) / agent list / provider list / status
  • daemon start/stop — API server on localhost:3777, SQLite queue + heartbeat, clean shutdown

No behavior change on macOS/Linux (fileURLToPath and the command -v branch are unchanged there).

Three Windows-only bugs prevented the CLI from running on native Windows
(non-WSL):

1. Doubled drive letter (`C:\C:\Users\...` -> MODULE_NOT_FOUND).
   `new URL('.', import.meta.url).pathname` yields `/C:/...` on Windows,
   and `path.resolve` then prepends the cwd drive. Use `fileURLToPath()`
   instead, which is correct on all platforms.
   - packages/cli/bin/tinyagi.mjs (REPO_ROOT)
   - packages/cli/lib/defaults.mjs (SCRIPT_DIR)

2. "Missing prerequisites: node, npm" even when both are installed.
   `commandExists()` ran the POSIX builtin `command -v` through cmd.exe,
   which has no such command. Use `where` on win32, `command -v` elsewhere.
   - packages/cli/src/install.ts

Verified on Windows 11 / Node 25: build, install detection, agent/provider
list, and daemon start/stop (API on :3777) all work.
Copilot AI review requested due to automatic review settings June 16, 2026 05:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Improves cross-platform (notably Windows) compatibility for the CLI by updating command detection and making import.meta.url path resolution reliable on Windows.

Changes:

  • Update commandExists to use where on Windows and command -v elsewhere
  • Use fileURLToPath(import.meta.url) when deriving repo/script directories to avoid Windows URL pathname issues

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/cli/src/install.ts Switches command probing logic to be Windows-aware (where vs command -v)
packages/cli/lib/defaults.mjs Fixes SCRIPT_DIR calculation using fileURLToPath for Windows-safe paths
packages/cli/bin/tinyagi.mjs Fixes REPO_ROOT calculation using fileURLToPath for Windows-safe paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +31
const probe = process.platform === 'win32'
? `where ${cmd}`
: `command -v ${cmd}`;
try {
execSync(`command -v ${cmd}`, { stdio: 'ignore' });
execSync(probe, { stdio: 'ignore' });
`tinyagi office` failed with `spawn npm ENOENT` on Windows because npm
resolves to npm.cmd, which child_process.spawn can't find without a shell.
Pass shell:true on win32 so the office dashboard launches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants