@shogo-ai/cli 1.4.1 → 1.9.0

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.
@@ -116,7 +116,22 @@ var PlatformPackageManager = class {
116
116
  return;
117
117
  } catch (err) {
118
118
  const wrapped = wrapWindowsNpmError(err);
119
- if (!wrapped) throw err;
119
+ if (wrapped) {
120
+ } else if (isNpmEresolveError(err)) {
121
+ console.warn(
122
+ "[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
123
+ );
124
+ nodeExecSync("npm.cmd install --loglevel=error --legacy-peer-deps", {
125
+ cwd,
126
+ timeout,
127
+ stdio,
128
+ env,
129
+ shell: "cmd.exe"
130
+ });
131
+ return;
132
+ } else {
133
+ throw err;
134
+ }
120
135
  }
121
136
  }
122
137
  this.installSyncBunCopyfile(cwd, opts);
@@ -189,9 +204,8 @@ var PlatformPackageManager = class {
189
204
  const timeout = opts?.timeout ?? DEFAULT_INSTALL_TIMEOUT;
190
205
  const env = this.spawnEnv(opts?.env);
191
206
  const cmd = "npm.cmd";
192
- const args = ["install", "--loglevel=error"];
193
- return new Promise((resolve, reject) => {
194
- const proc = spawn(cmd, args, {
207
+ const runOnce = (extraArgs) => new Promise((resolvePromise, rejectPromise) => {
208
+ const proc = spawn(cmd, ["install", "--loglevel=error", ...extraArgs], {
195
209
  cwd,
196
210
  stdio: "pipe",
197
211
  env,
@@ -199,7 +213,7 @@ var PlatformPackageManager = class {
199
213
  });
200
214
  const timer = setTimeout(() => {
201
215
  proc.kill();
202
- reject(new Error(`${cmd} install timed out after ${timeout / 1e3}s`));
216
+ rejectPromise(new Error(`${cmd} install timed out after ${timeout / 1e3}s`));
203
217
  }, timeout);
204
218
  let stderr = "";
205
219
  proc.stderr?.on("data", (d) => {
@@ -207,19 +221,34 @@ var PlatformPackageManager = class {
207
221
  });
208
222
  proc.on("exit", (code) => {
209
223
  clearTimeout(timer);
210
- if (code === 0) return resolve();
211
- if (/not recognized as an internal or external command/i.test(stderr)) {
212
- return reject(new NodeMissingError());
213
- }
214
- reject(new Error(`${cmd} install exited with code ${code}
215
- ${stderr}`));
224
+ resolvePromise({ code, stderr });
216
225
  });
217
226
  proc.on("error", (err) => {
218
227
  clearTimeout(timer);
219
- if (err.code === "ENOENT") return reject(new NodeMissingError());
220
- reject(err);
228
+ if (err.code === "ENOENT") return rejectPromise(new NodeMissingError());
229
+ rejectPromise(err);
221
230
  });
222
231
  });
232
+ return (async () => {
233
+ const first = await runOnce([]);
234
+ if (first.code === 0) return;
235
+ if (/not recognized as an internal or external command/i.test(first.stderr)) {
236
+ throw new NodeMissingError();
237
+ }
238
+ if (isEresolveStderr(first.stderr)) {
239
+ console.warn(
240
+ "[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
241
+ );
242
+ const second = await runOnce(["--legacy-peer-deps"]);
243
+ if (second.code === 0) return;
244
+ throw new Error(
245
+ `${cmd} install --legacy-peer-deps exited with code ${second.code}
246
+ ${second.stderr}`
247
+ );
248
+ }
249
+ throw new Error(`${cmd} install exited with code ${first.code}
250
+ ${first.stderr}`);
251
+ })();
223
252
  }
224
253
  installAsyncBunCopyfile(cwd, opts) {
225
254
  console.warn(
@@ -413,6 +442,15 @@ ${err?.message ?? ""}`;
413
442
  if (err?.code === "ENOENT") return new NodeMissingError();
414
443
  return null;
415
444
  }
445
+ function isEresolveStderr(stderr) {
446
+ return /ERESOLVE/i.test(stderr);
447
+ }
448
+ function isNpmEresolveError(err) {
449
+ const blob = `${err?.stderr?.toString?.() ?? ""}
450
+ ${err?.stdout?.toString?.() ?? ""}
451
+ ${err?.message ?? ""}`;
452
+ return isEresolveStderr(blob);
453
+ }
416
454
  var pkg = new PlatformPackageManager();
417
455
 
418
456
  export {
@@ -422,6 +460,7 @@ export {
422
460
  _resetUnixNodeCache,
423
461
  resolveBinInvocation,
424
462
  PlatformPackageManager,
463
+ isEresolveStderr,
425
464
  pkg
426
465
  };
427
- //# sourceMappingURL=chunk-UB4RE2UC.js.map
466
+ //# sourceMappingURL=chunk-L635SMF7.js.map
package/dist/index.cjs CHANGED
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  PlatformPackageManager: () => PlatformPackageManager,
26
26
  _resetUnixNodeCache: () => _resetUnixNodeCache,
27
27
  buildSyncPayload: () => buildSyncPayload,
28
+ isEresolveStderr: () => isEresolveStderr,
28
29
  isNodeAvailableOnUnix: () => isNodeAvailableOnUnix,
29
30
  isNodeAvailableOnWindows: () => isNodeAvailableOnWindows,
30
31
  normalizeToolEntry: () => normalizeToolEntry,
@@ -372,7 +373,22 @@ var PlatformPackageManager = class {
372
373
  return;
373
374
  } catch (err) {
374
375
  const wrapped = wrapWindowsNpmError(err);
375
- if (!wrapped) throw err;
376
+ if (wrapped) {
377
+ } else if (isNpmEresolveError(err)) {
378
+ console.warn(
379
+ "[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
380
+ );
381
+ (0, import_node_child_process.execSync)("npm.cmd install --loglevel=error --legacy-peer-deps", {
382
+ cwd,
383
+ timeout,
384
+ stdio,
385
+ env,
386
+ shell: "cmd.exe"
387
+ });
388
+ return;
389
+ } else {
390
+ throw err;
391
+ }
376
392
  }
377
393
  }
378
394
  this.installSyncBunCopyfile(cwd, opts);
@@ -445,9 +461,8 @@ var PlatformPackageManager = class {
445
461
  const timeout = opts?.timeout ?? DEFAULT_INSTALL_TIMEOUT;
446
462
  const env = this.spawnEnv(opts?.env);
447
463
  const cmd = "npm.cmd";
448
- const args = ["install", "--loglevel=error"];
449
- return new Promise((resolve, reject) => {
450
- const proc = (0, import_node_child_process.spawn)(cmd, args, {
464
+ const runOnce = (extraArgs) => new Promise((resolvePromise, rejectPromise) => {
465
+ const proc = (0, import_node_child_process.spawn)(cmd, ["install", "--loglevel=error", ...extraArgs], {
451
466
  cwd,
452
467
  stdio: "pipe",
453
468
  env,
@@ -455,7 +470,7 @@ var PlatformPackageManager = class {
455
470
  });
456
471
  const timer = setTimeout(() => {
457
472
  proc.kill();
458
- reject(new Error(`${cmd} install timed out after ${timeout / 1e3}s`));
473
+ rejectPromise(new Error(`${cmd} install timed out after ${timeout / 1e3}s`));
459
474
  }, timeout);
460
475
  let stderr = "";
461
476
  proc.stderr?.on("data", (d) => {
@@ -463,19 +478,34 @@ var PlatformPackageManager = class {
463
478
  });
464
479
  proc.on("exit", (code) => {
465
480
  clearTimeout(timer);
466
- if (code === 0) return resolve();
467
- if (/not recognized as an internal or external command/i.test(stderr)) {
468
- return reject(new NodeMissingError());
469
- }
470
- reject(new Error(`${cmd} install exited with code ${code}
471
- ${stderr}`));
481
+ resolvePromise({ code, stderr });
472
482
  });
473
483
  proc.on("error", (err) => {
474
484
  clearTimeout(timer);
475
- if (err.code === "ENOENT") return reject(new NodeMissingError());
476
- reject(err);
485
+ if (err.code === "ENOENT") return rejectPromise(new NodeMissingError());
486
+ rejectPromise(err);
477
487
  });
478
488
  });
489
+ return (async () => {
490
+ const first = await runOnce([]);
491
+ if (first.code === 0) return;
492
+ if (/not recognized as an internal or external command/i.test(first.stderr)) {
493
+ throw new NodeMissingError();
494
+ }
495
+ if (isEresolveStderr(first.stderr)) {
496
+ console.warn(
497
+ "[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
498
+ );
499
+ const second = await runOnce(["--legacy-peer-deps"]);
500
+ if (second.code === 0) return;
501
+ throw new Error(
502
+ `${cmd} install --legacy-peer-deps exited with code ${second.code}
503
+ ${second.stderr}`
504
+ );
505
+ }
506
+ throw new Error(`${cmd} install exited with code ${first.code}
507
+ ${first.stderr}`);
508
+ })();
479
509
  }
480
510
  installAsyncBunCopyfile(cwd, opts) {
481
511
  console.warn(
@@ -669,6 +699,15 @@ ${err?.message ?? ""}`;
669
699
  if (err?.code === "ENOENT") return new NodeMissingError();
670
700
  return null;
671
701
  }
702
+ function isEresolveStderr(stderr) {
703
+ return /ERESOLVE/i.test(stderr);
704
+ }
705
+ function isNpmEresolveError(err) {
706
+ const blob = `${err?.stderr?.toString?.() ?? ""}
707
+ ${err?.stdout?.toString?.() ?? ""}
708
+ ${err?.message ?? ""}`;
709
+ return isEresolveStderr(blob);
710
+ }
672
711
  var pkg = new PlatformPackageManager();
673
712
  // Annotate the CommonJS export names for ESM import in node:
674
713
  0 && (module.exports = {
@@ -677,6 +716,7 @@ var pkg = new PlatformPackageManager();
677
716
  PlatformPackageManager,
678
717
  _resetUnixNodeCache,
679
718
  buildSyncPayload,
719
+ isEresolveStderr,
680
720
  isNodeAvailableOnUnix,
681
721
  isNodeAvailableOnWindows,
682
722
  normalizeToolEntry,
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { AGENT_NAME_PATTERN, AgentManifestEntry, AgentToolEntry, AgentsManifest, BuildSyncPayloadOptions, DeployAuth, RunDeployOptions, RunDeployResult, SyncPayload, ToolDescriptor, ValidatedManifest, ValidationIssue, buildSyncPayload, normalizeToolEntry, runDeploy, validateManifest } from './deploy.cjs';
2
- export { NodeMissingError, PkgExecOptions, PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation } from './pkg.cjs';
2
+ export { NodeMissingError, PkgExecOptions, PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isEresolveStderr, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation } from './pkg.cjs';
3
3
  import 'node:child_process';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { AGENT_NAME_PATTERN, AgentManifestEntry, AgentToolEntry, AgentsManifest, BuildSyncPayloadOptions, DeployAuth, RunDeployOptions, RunDeployResult, SyncPayload, ToolDescriptor, ValidatedManifest, ValidationIssue, buildSyncPayload, normalizeToolEntry, runDeploy, validateManifest } from './deploy.js';
2
- export { NodeMissingError, PkgExecOptions, PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation } from './pkg.js';
2
+ export { NodeMissingError, PkgExecOptions, PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isEresolveStderr, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation } from './pkg.js';
3
3
  import 'node:child_process';
package/dist/index.js CHANGED
@@ -9,17 +9,19 @@ import {
9
9
  NodeMissingError,
10
10
  PlatformPackageManager,
11
11
  _resetUnixNodeCache,
12
+ isEresolveStderr,
12
13
  isNodeAvailableOnUnix,
13
14
  isNodeAvailableOnWindows,
14
15
  pkg,
15
16
  resolveBinInvocation
16
- } from "./chunk-UB4RE2UC.js";
17
+ } from "./chunk-L635SMF7.js";
17
18
  export {
18
19
  AGENT_NAME_PATTERN,
19
20
  NodeMissingError,
20
21
  PlatformPackageManager,
21
22
  _resetUnixNodeCache,
22
23
  buildSyncPayload,
24
+ isEresolveStderr,
23
25
  isNodeAvailableOnUnix,
24
26
  isNodeAvailableOnWindows,
25
27
  normalizeToolEntry,
package/dist/pkg.cjs CHANGED
@@ -23,6 +23,7 @@ __export(pkg_exports, {
23
23
  NodeMissingError: () => NodeMissingError,
24
24
  PlatformPackageManager: () => PlatformPackageManager,
25
25
  _resetUnixNodeCache: () => _resetUnixNodeCache,
26
+ isEresolveStderr: () => isEresolveStderr,
26
27
  isNodeAvailableOnUnix: () => isNodeAvailableOnUnix,
27
28
  isNodeAvailableOnWindows: () => isNodeAvailableOnWindows,
28
29
  pkg: () => pkg,
@@ -146,7 +147,22 @@ var PlatformPackageManager = class {
146
147
  return;
147
148
  } catch (err) {
148
149
  const wrapped = wrapWindowsNpmError(err);
149
- if (!wrapped) throw err;
150
+ if (wrapped) {
151
+ } else if (isNpmEresolveError(err)) {
152
+ console.warn(
153
+ "[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
154
+ );
155
+ (0, import_node_child_process.execSync)("npm.cmd install --loglevel=error --legacy-peer-deps", {
156
+ cwd,
157
+ timeout,
158
+ stdio,
159
+ env,
160
+ shell: "cmd.exe"
161
+ });
162
+ return;
163
+ } else {
164
+ throw err;
165
+ }
150
166
  }
151
167
  }
152
168
  this.installSyncBunCopyfile(cwd, opts);
@@ -219,9 +235,8 @@ var PlatformPackageManager = class {
219
235
  const timeout = opts?.timeout ?? DEFAULT_INSTALL_TIMEOUT;
220
236
  const env = this.spawnEnv(opts?.env);
221
237
  const cmd = "npm.cmd";
222
- const args = ["install", "--loglevel=error"];
223
- return new Promise((resolve, reject) => {
224
- const proc = (0, import_node_child_process.spawn)(cmd, args, {
238
+ const runOnce = (extraArgs) => new Promise((resolvePromise, rejectPromise) => {
239
+ const proc = (0, import_node_child_process.spawn)(cmd, ["install", "--loglevel=error", ...extraArgs], {
225
240
  cwd,
226
241
  stdio: "pipe",
227
242
  env,
@@ -229,7 +244,7 @@ var PlatformPackageManager = class {
229
244
  });
230
245
  const timer = setTimeout(() => {
231
246
  proc.kill();
232
- reject(new Error(`${cmd} install timed out after ${timeout / 1e3}s`));
247
+ rejectPromise(new Error(`${cmd} install timed out after ${timeout / 1e3}s`));
233
248
  }, timeout);
234
249
  let stderr = "";
235
250
  proc.stderr?.on("data", (d) => {
@@ -237,19 +252,34 @@ var PlatformPackageManager = class {
237
252
  });
238
253
  proc.on("exit", (code) => {
239
254
  clearTimeout(timer);
240
- if (code === 0) return resolve();
241
- if (/not recognized as an internal or external command/i.test(stderr)) {
242
- return reject(new NodeMissingError());
243
- }
244
- reject(new Error(`${cmd} install exited with code ${code}
245
- ${stderr}`));
255
+ resolvePromise({ code, stderr });
246
256
  });
247
257
  proc.on("error", (err) => {
248
258
  clearTimeout(timer);
249
- if (err.code === "ENOENT") return reject(new NodeMissingError());
250
- reject(err);
259
+ if (err.code === "ENOENT") return rejectPromise(new NodeMissingError());
260
+ rejectPromise(err);
251
261
  });
252
262
  });
263
+ return (async () => {
264
+ const first = await runOnce([]);
265
+ if (first.code === 0) return;
266
+ if (/not recognized as an internal or external command/i.test(first.stderr)) {
267
+ throw new NodeMissingError();
268
+ }
269
+ if (isEresolveStderr(first.stderr)) {
270
+ console.warn(
271
+ "[platform-pkg] npm install hit ERESOLVE \u2014 retrying with --legacy-peer-deps."
272
+ );
273
+ const second = await runOnce(["--legacy-peer-deps"]);
274
+ if (second.code === 0) return;
275
+ throw new Error(
276
+ `${cmd} install --legacy-peer-deps exited with code ${second.code}
277
+ ${second.stderr}`
278
+ );
279
+ }
280
+ throw new Error(`${cmd} install exited with code ${first.code}
281
+ ${first.stderr}`);
282
+ })();
253
283
  }
254
284
  installAsyncBunCopyfile(cwd, opts) {
255
285
  console.warn(
@@ -443,12 +473,22 @@ ${err?.message ?? ""}`;
443
473
  if (err?.code === "ENOENT") return new NodeMissingError();
444
474
  return null;
445
475
  }
476
+ function isEresolveStderr(stderr) {
477
+ return /ERESOLVE/i.test(stderr);
478
+ }
479
+ function isNpmEresolveError(err) {
480
+ const blob = `${err?.stderr?.toString?.() ?? ""}
481
+ ${err?.stdout?.toString?.() ?? ""}
482
+ ${err?.message ?? ""}`;
483
+ return isEresolveStderr(blob);
484
+ }
446
485
  var pkg = new PlatformPackageManager();
447
486
  // Annotate the CommonJS export names for ESM import in node:
448
487
  0 && (module.exports = {
449
488
  NodeMissingError,
450
489
  PlatformPackageManager,
451
490
  _resetUnixNodeCache,
491
+ isEresolveStderr,
452
492
  isNodeAvailableOnUnix,
453
493
  isNodeAvailableOnWindows,
454
494
  pkg,
package/dist/pkg.d.cts CHANGED
@@ -133,7 +133,15 @@ declare class PlatformPackageManager {
133
133
  acceptDataLoss?: boolean;
134
134
  }): Promise<void>;
135
135
  }
136
+ /**
137
+ * True if `npm install` produced an ERESOLVE peer-dependency failure.
138
+ *
139
+ * Exported for tests. npm prints `npm error code ERESOLVE` (npm 10+) or
140
+ * `npm ERR! code ERESOLVE` (older). Match both with a loose regex to stay
141
+ * forward-compatible.
142
+ */
143
+ declare function isEresolveStderr(stderr: string): boolean;
136
144
  /** Singleton — most consumers just need one. */
137
145
  declare const pkg: PlatformPackageManager;
138
146
 
139
- export { NodeMissingError, type PkgExecOptions, type PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation };
147
+ export { NodeMissingError, type PkgExecOptions, type PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isEresolveStderr, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation };
package/dist/pkg.d.ts CHANGED
@@ -133,7 +133,15 @@ declare class PlatformPackageManager {
133
133
  acceptDataLoss?: boolean;
134
134
  }): Promise<void>;
135
135
  }
136
+ /**
137
+ * True if `npm install` produced an ERESOLVE peer-dependency failure.
138
+ *
139
+ * Exported for tests. npm prints `npm error code ERESOLVE` (npm 10+) or
140
+ * `npm ERR! code ERESOLVE` (older). Match both with a loose regex to stay
141
+ * forward-compatible.
142
+ */
143
+ declare function isEresolveStderr(stderr: string): boolean;
136
144
  /** Singleton — most consumers just need one. */
137
145
  declare const pkg: PlatformPackageManager;
138
146
 
139
- export { NodeMissingError, type PkgExecOptions, type PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation };
147
+ export { NodeMissingError, type PkgExecOptions, type PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isEresolveStderr, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation };
package/dist/pkg.js CHANGED
@@ -2,15 +2,17 @@ import {
2
2
  NodeMissingError,
3
3
  PlatformPackageManager,
4
4
  _resetUnixNodeCache,
5
+ isEresolveStderr,
5
6
  isNodeAvailableOnUnix,
6
7
  isNodeAvailableOnWindows,
7
8
  pkg,
8
9
  resolveBinInvocation
9
- } from "./chunk-UB4RE2UC.js";
10
+ } from "./chunk-L635SMF7.js";
10
11
  export {
11
12
  NodeMissingError,
12
13
  PlatformPackageManager,
13
14
  _resetUnixNodeCache,
15
+ isEresolveStderr,
14
16
  isNodeAvailableOnUnix,
15
17
  isNodeAvailableOnWindows,
16
18
  pkg,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shogo-ai/cli",
3
- "version": "1.4.1",
3
+ "version": "1.9.0",
4
4
  "description": "Shogo CLI helpers — deploy/manifest validation and packager for Shogo agents.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,7 +35,7 @@
35
35
  "build": "tsup",
36
36
  "dev": "tsup --watch",
37
37
  "typecheck": "tsc --noEmit",
38
- "test": "bun --no-env-file test src/"
38
+ "test": "bun --no-env-file --conditions=development test src/"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^25.5.0",