@divergeai/cli 0.1.5 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/diverge.mjs +44 -6
  2. package/package.json +1 -1
package/dist/diverge.mjs CHANGED
@@ -7387,7 +7387,7 @@ import path10 from "node:path";
7387
7387
  import { parseArgs } from "node:util";
7388
7388
 
7389
7389
  // src/version.ts
7390
- var VERSION = true ? "0.1.5" : "dev";
7390
+ var VERSION = true ? "0.1.7" : "dev";
7391
7391
  var USER_AGENT = `diverge/${VERSION}`;
7392
7392
 
7393
7393
  // src/http.ts
@@ -7441,7 +7441,13 @@ function openerCommand(url, env = process.env, platform = process.platform) {
7441
7441
  if (custom) return { command: custom, args: [url] };
7442
7442
  if (platform === "darwin") return { command: "open", args: [url] };
7443
7443
  if (platform === "win32") {
7444
- return { command: "cmd", args: ["/c", "start", '""', `"${url.replace(/&/g, "^&")}"`], windowsVerbatimArguments: true };
7444
+ const root = env.SYSTEMROOT || env.windir || "C:\\Windows";
7445
+ const script = `Start-Process -FilePath '${url.replace(/'/g, "''")}'`;
7446
+ return {
7447
+ command: `${root}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,
7448
+ args: ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")],
7449
+ windowsVerbatimArguments: true
7450
+ };
7445
7451
  }
7446
7452
  return { command: "xdg-open", args: [url] };
7447
7453
  }
@@ -8062,6 +8068,19 @@ function dshArgs(overlayPath, args) {
8062
8068
  const rest = args.includes("--profile") ? args : args.length === 0 ? ["--profile", "web"] : ["--profile", "headless", ...args];
8063
8069
  return ["--patch", overlayPath, ...rest];
8064
8070
  }
8071
+ function dshLaunch(binary, args, platform = process.platform, execPath = process.execPath) {
8072
+ if (platform !== "win32" || !/\.(cmd|bat)$/i.test(binary)) return { command: binary, args };
8073
+ const packageDir = path7.join(path7.dirname(binary), "node_modules", "@deepseek-ai", "dsh");
8074
+ let bin;
8075
+ try {
8076
+ bin = JSON.parse(fs4.readFileSync(path7.join(packageDir, "package.json"), "utf8")).bin;
8077
+ } catch {
8078
+ throw new CliError(`${binary} is not an npm shim for @deepseek-ai/dsh (no ${packageDir}); reinstall: npm install -g @deepseek-ai/dsh`);
8079
+ }
8080
+ const script = typeof bin === "string" ? bin : typeof bin === "object" && bin !== null ? bin.dsh : void 0;
8081
+ if (typeof script !== "string") throw new CliError(`${packageDir}/package.json declares no dsh entry; reinstall: npm install -g @deepseek-ai/dsh`);
8082
+ return { command: execPath, args: [path7.join(packageDir, script), ...args] };
8083
+ }
8065
8084
  async function keepTokenFresh(loop) {
8066
8085
  let written = null;
8067
8086
  while (loop.isRunning()) {
@@ -8080,12 +8099,21 @@ function runDsh(options) {
8080
8099
  writeDshToken(options.credentialsPath, options.initialToken);
8081
8100
  const env = {};
8082
8101
  for (const [key, value] of Object.entries(options.env)) if (key !== "DIVERGENT_TOKEN" && value !== void 0) env[key] = value;
8083
- const child = spawn2(options.binary, dshArgs(options.overlayPath, options.args), { env, stdio: "inherit" });
8102
+ const launch = dshLaunch(options.binary, dshArgs(options.overlayPath, options.args));
8103
+ const child = spawn2(launch.command, launch.args, { env, stdio: "inherit" });
8084
8104
  let exited = false;
8105
+ let wake = null;
8106
+ const finish = () => {
8107
+ exited = true;
8108
+ wake?.();
8109
+ };
8085
8110
  const done = new Promise((resolve, reject) => {
8086
- child.on("error", reject);
8111
+ child.on("error", (error) => {
8112
+ finish();
8113
+ reject(error);
8114
+ });
8087
8115
  child.on("exit", (code2, signal) => {
8088
- exited = true;
8116
+ finish();
8089
8117
  resolve(code2 ?? (signal ? 128 + 15 : 1));
8090
8118
  });
8091
8119
  });
@@ -8098,7 +8126,17 @@ function runDsh(options) {
8098
8126
  freshToken: options.freshToken,
8099
8127
  write: (token) => writeDshToken(options.credentialsPath, token),
8100
8128
  isRunning: () => !exited,
8101
- sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
8129
+ sleep: (ms) => new Promise((resolve) => {
8130
+ const timer = setTimeout(() => {
8131
+ wake = null;
8132
+ resolve();
8133
+ }, ms);
8134
+ wake = () => {
8135
+ clearTimeout(timer);
8136
+ wake = null;
8137
+ resolve();
8138
+ };
8139
+ })
8102
8140
  });
8103
8141
  return done.finally(async () => {
8104
8142
  process.off("SIGINT", ignore);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divergeai/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Divergent platform CLI: sign in, wire coding agents to the inference gateway, call platform tools",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",