cli4ai 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,10 @@
4
4
  import { spawn, spawnSync } from 'child_process';
5
5
  import { readFileSync, writeFileSync, existsSync, chmodSync, rmSync } from 'fs';
6
6
  import { resolve } from 'path';
7
+ import { platform } from 'os';
7
8
  import { stringify as stringifyYaml } from 'yaml';
8
9
  import { output, outputError, log } from '../lib/cli.js';
10
+ const isWindows = platform() === 'win32';
9
11
  import { ensureCli4aiHome, ensureLocalDir, ROUTINES_DIR, LOCAL_ROUTINES_DIR } from '../core/config.js';
10
12
  import { getGlobalRoutines, getLocalRoutines, resolveRoutine, validateRoutineName } from '../core/routines.js';
11
13
  import { loadRoutineDefinition, dryRunRoutine, runRoutine, RoutineParseError, RoutineValidationError, RoutineTemplateError } from '../core/routine-engine.js';
@@ -256,6 +258,7 @@ export async function routinesRunCommand(name, args, options) {
256
258
  const child = spawn('bash', [routine.path, ...args], {
257
259
  cwd: process.cwd(),
258
260
  stdio: isTTY ? 'inherit' : ['pipe', 'pipe', 'pipe'],
261
+ shell: isWindows,
259
262
  env: {
260
263
  ...process.env,
261
264
  ...varEnv,
@@ -12,7 +12,9 @@ import { spawn } from 'child_process';
12
12
  import { readFileSync, existsSync } from 'fs';
13
13
  import { resolve, dirname } from 'path';
14
14
  import { fileURLToPath } from 'url';
15
+ import { platform } from 'os';
15
16
  import { output, outputError, log } from '../lib/cli.js';
17
+ const isWindows = platform() === 'win32';
16
18
  import { isDaemonRunning, getDaemonPid, removeDaemonPid, loadSchedulerState, getRunHistory, Scheduler, SCHEDULER_LOG_FILE, SCHEDULER_PID_FILE } from '../core/scheduler.js';
17
19
  import { getScheduledRoutines } from '../core/routines.js';
18
20
  export async function schedulerStartCommand(options) {
@@ -55,6 +57,7 @@ export async function schedulerStartCommand(options) {
55
57
  const child = spawn('npx', ['tsx', daemonScript, '--project-dir', process.cwd()], {
56
58
  detached: true,
57
59
  stdio: 'ignore',
60
+ shell: isWindows,
58
61
  env: {
59
62
  ...process.env,
60
63
  CLI4AI_DAEMON: 'true'
@@ -2,7 +2,9 @@
2
2
  * cli4ai update - Update installed packages and cli4ai itself
3
3
  */
4
4
  import { spawn } from 'child_process';
5
+ import { platform } from 'os';
5
6
  import { log } from '../lib/cli.js';
7
+ const isWindows = platform() === 'win32';
6
8
  import { getNpmGlobalPackages, getGlobalPackages } from '../core/config.js';
7
9
  // ANSI colors
8
10
  const RESET = '\x1B[0m';
@@ -50,7 +52,8 @@ async function updateCli4aiPackage(packageName) {
50
52
  return new Promise((resolve) => {
51
53
  // Use cli4ai add -g to reinstall the package (same location as original install)
52
54
  const proc = spawn('cli4ai', ['add', '-g', packageName, '-y'], {
53
- stdio: 'pipe'
55
+ stdio: 'pipe',
56
+ shell: isWindows
54
57
  });
55
58
  proc.on('close', (code) => {
56
59
  resolve(code === 0);
@@ -66,7 +69,8 @@ async function updateCli4aiPackage(packageName) {
66
69
  async function updateNpmPackage(packageName) {
67
70
  return new Promise((resolve) => {
68
71
  const proc = spawn('npm', ['install', '-g', `${packageName}@latest`], {
69
- stdio: 'pipe'
72
+ stdio: 'pipe',
73
+ shell: isWindows
70
74
  });
71
75
  proc.on('close', (code) => {
72
76
  resolve(code === 0);
@@ -11,6 +11,8 @@ import { existsSync, readFileSync } from 'fs';
11
11
  import { createInterface } from 'readline';
12
12
  import { platform, homedir } from 'os';
13
13
  import { log } from '../lib/cli.js';
14
+ // Windows compatibility: need shell: true for npx/node commands
15
+ const isWindows = platform() === 'win32';
14
16
  import { findPackage } from './config.js';
15
17
  import { loadManifest } from './manifest.js';
16
18
  import { getSecret } from './secrets.js';
@@ -383,6 +385,7 @@ export async function executeTool(options) {
383
385
  const proc = spawn(execCmd, execArgs, {
384
386
  stdio: 'inherit',
385
387
  cwd: invocationDir,
388
+ shell: isWindows, // Required on Windows for npx/node
386
389
  env: {
387
390
  ...process.env,
388
391
  INIT_CWD: process.env.INIT_CWD ?? invocationDir,
@@ -413,6 +416,7 @@ export async function executeTool(options) {
413
416
  const proc = spawn(execCmd, execArgs, {
414
417
  stdio: ['pipe', 'pipe', 'pipe'],
415
418
  cwd: invocationDir,
419
+ shell: isWindows, // Required on Windows for npx/node
416
420
  env: {
417
421
  ...process.env,
418
422
  INIT_CWD: process.env.INIT_CWD ?? invocationDir,
@@ -3,7 +3,9 @@
3
3
  */
4
4
  import { readFileSync } from 'fs';
5
5
  import { spawn } from 'child_process';
6
+ import { platform } from 'os';
6
7
  import { parse as parseYaml } from 'yaml';
8
+ const isWindows = platform() === 'win32';
7
9
  import { executeTool, ExecuteToolError } from './execute.js';
8
10
  import { remoteRunTool, RemoteConnectionError, RemoteApiError } from './remote-client.js';
9
11
  import { getRemote } from './remotes.js';
@@ -367,6 +369,7 @@ async function runExecStep(step, ctx, invocationDir) {
367
369
  const child = spawn(cmd, args, {
368
370
  cwd: invocationDir,
369
371
  stdio: ['pipe', 'pipe', 'pipe'],
372
+ shell: isWindows,
370
373
  env: {
371
374
  ...process.env,
372
375
  ...(env ?? {})
@@ -2,6 +2,8 @@
2
2
  * MCP Adapter - Converts CLI tools to MCP tools
3
3
  */
4
4
  import { spawn } from 'child_process';
5
+ import { platform } from 'os';
6
+ const isWindows = platform() === 'win32';
5
7
  /**
6
8
  * Convert a CLI command definition to MCP tool format
7
9
  */
@@ -61,6 +63,7 @@ export async function executeTool(entryPath, runtime, command, args, argOrder) {
61
63
  : ['run', entryPath, ...cmdArgs];
62
64
  const proc = spawn(runtime, runtimeArgs, {
63
65
  stdio: ['pipe', 'pipe', 'pipe'],
66
+ shell: isWindows,
64
67
  env: { ...process.env }
65
68
  });
66
69
  let stdout = '';
@@ -12,7 +12,8 @@
12
12
  import { spawn } from 'child_process';
13
13
  import { resolve } from 'path';
14
14
  import { appendFileSync, existsSync, mkdirSync } from 'fs';
15
- import { homedir } from 'os';
15
+ import { homedir, platform } from 'os';
16
+ const isWindows = platform() === 'win32';
16
17
  import { manifestToMcpTools } from './adapter.js';
17
18
  import { getSecret } from '../core/secrets.js';
18
19
  import { loadConfig } from '../core/config.js';
@@ -241,6 +242,7 @@ export class McpServer {
241
242
  }
242
243
  const proc = spawn(cmd, cmdArgs, {
243
244
  stdio: ['pipe', 'pipe', 'pipe'],
245
+ shell: isWindows,
244
246
  env: { ...process.env, ...secretsEnv }
245
247
  });
246
248
  let stdout = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli4ai",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "The package manager for AI CLI tools - cli4ai.com",
5
5
  "type": "module",
6
6
  "bin": {