diff --git a/packages/cli/bin/tinyagi.mjs b/packages/cli/bin/tinyagi.mjs index 0c81fe4f..1d85364a 100755 --- a/packages/cli/bin/tinyagi.mjs +++ b/packages/cli/bin/tinyagi.mjs @@ -3,6 +3,7 @@ import { execSync, spawn } from 'child_process'; import fs from 'fs'; import path from 'path'; +import { fileURLToPath } from 'url'; // ── Constants ──────────────────────────────────────────────────────────────── @@ -21,7 +22,7 @@ function log(color, msg) { process.stdout.write(`${color}${msg}${NC}\n`); } -const REPO_ROOT = path.resolve(new URL('.', import.meta.url).pathname, '../../..'); +const REPO_ROOT = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '../../..'); const CLI_DIR = path.join(REPO_ROOT, 'packages/cli/dist'); // ── CLI Script Runner ──────────────────────────────────────────────────────── @@ -239,7 +240,7 @@ switch (command) { execSync(`cd "${officeDir}" && npm run build`, { stdio: 'inherit' }); } log(GREEN, 'Starting TinyOffice on http://localhost:3000'); - const child = spawn('npm', ['run', 'start'], { cwd: officeDir, stdio: 'inherit' }); + const child = spawn('npm', ['run', 'start'], { cwd: officeDir, stdio: 'inherit', shell: process.platform === 'win32' }); child.on('exit', (code) => process.exit(code || 0)); break; } diff --git a/packages/cli/lib/defaults.mjs b/packages/cli/lib/defaults.mjs index 575bc6df..2f75fd39 100644 --- a/packages/cli/lib/defaults.mjs +++ b/packages/cli/lib/defaults.mjs @@ -1,6 +1,7 @@ import fs from 'fs'; import path from 'path'; import os from 'os'; +import { fileURLToPath } from 'url'; const TINYAGI_HOME = process.env.TINYAGI_HOME || path.join(os.homedir(), '.tinyagi'); const SETTINGS_FILE = path.join(TINYAGI_HOME, 'settings.json'); @@ -40,7 +41,7 @@ function expandHome(p) { * Determine SCRIPT_DIR (repo root) — same logic as tinyagi.sh. * When running from packages/cli/lib/defaults.mjs, go up 3 levels. */ -const SCRIPT_DIR = path.resolve(new URL('.', import.meta.url).pathname, '../../..'); +const SCRIPT_DIR = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '../../..'); function copyDirSync(src, dest) { fs.mkdirSync(dest, { recursive: true }); diff --git a/packages/cli/src/install.ts b/packages/cli/src/install.ts index 6f707444..032a13d9 100644 --- a/packages/cli/src/install.ts +++ b/packages/cli/src/install.ts @@ -24,8 +24,11 @@ function log(color: string, msg: string): void { } function commandExists(cmd: string): boolean { + const probe = process.platform === 'win32' + ? `where ${cmd}` + : `command -v ${cmd}`; try { - execSync(`command -v ${cmd}`, { stdio: 'ignore' }); + execSync(probe, { stdio: 'ignore' }); return true; } catch { return false;