@divergeai/cli 0.1.6 → 0.1.8

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 +39 -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.6" : "dev";
7390
+ var VERSION = true ? "0.1.8" : "dev";
7391
7391
  var USER_AGENT = `diverge/${VERSION}`;
7392
7392
 
7393
7393
  // src/http.ts
@@ -8041,7 +8041,8 @@ import fs4 from "node:fs";
8041
8041
  import path7 from "node:path";
8042
8042
  function findOnPath(name, env = process.env, platform = process.platform) {
8043
8043
  const dirs = (env.PATH ?? "").split(path7.delimiter).filter(Boolean);
8044
- const candidates = platform === "win32" ? [name, `${name}.cmd`, `${name}.exe`] : [name];
8044
+ const extensions = (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
8045
+ const candidates = platform === "win32" ? extensions.map((extension) => `${name}${extension.toLowerCase()}`) : [name];
8045
8046
  for (const dir of dirs) {
8046
8047
  for (const candidate of candidates) {
8047
8048
  const full = path7.join(dir, candidate);
@@ -8068,6 +8069,19 @@ function dshArgs(overlayPath, args) {
8068
8069
  const rest = args.includes("--profile") ? args : args.length === 0 ? ["--profile", "web"] : ["--profile", "headless", ...args];
8069
8070
  return ["--patch", overlayPath, ...rest];
8070
8071
  }
8072
+ function dshLaunch(binary, args, platform = process.platform, execPath = process.execPath) {
8073
+ if (platform !== "win32" || !/\.(cmd|bat)$/i.test(binary)) return { command: binary, args };
8074
+ const packageDir = path7.join(path7.dirname(binary), "node_modules", "@deepseek-ai", "dsh");
8075
+ let bin;
8076
+ try {
8077
+ bin = JSON.parse(fs4.readFileSync(path7.join(packageDir, "package.json"), "utf8")).bin;
8078
+ } catch {
8079
+ throw new CliError(`${binary} is not an npm shim for @deepseek-ai/dsh (no ${packageDir}); reinstall: npm install -g @deepseek-ai/dsh`);
8080
+ }
8081
+ const script = typeof bin === "string" ? bin : typeof bin === "object" && bin !== null ? bin.dsh : void 0;
8082
+ if (typeof script !== "string") throw new CliError(`${packageDir}/package.json declares no dsh entry; reinstall: npm install -g @deepseek-ai/dsh`);
8083
+ return { command: execPath, args: [path7.join(packageDir, script), ...args] };
8084
+ }
8071
8085
  async function keepTokenFresh(loop) {
8072
8086
  let written = null;
8073
8087
  while (loop.isRunning()) {
@@ -8086,12 +8100,21 @@ function runDsh(options) {
8086
8100
  writeDshToken(options.credentialsPath, options.initialToken);
8087
8101
  const env = {};
8088
8102
  for (const [key, value] of Object.entries(options.env)) if (key !== "DIVERGENT_TOKEN" && value !== void 0) env[key] = value;
8089
- const child = spawn2(options.binary, dshArgs(options.overlayPath, options.args), { env, stdio: "inherit" });
8103
+ const launch = dshLaunch(options.binary, dshArgs(options.overlayPath, options.args));
8104
+ const child = spawn2(launch.command, launch.args, { env, stdio: "inherit" });
8090
8105
  let exited = false;
8106
+ let wake = null;
8107
+ const finish = () => {
8108
+ exited = true;
8109
+ wake?.();
8110
+ };
8091
8111
  const done = new Promise((resolve, reject) => {
8092
- child.on("error", reject);
8112
+ child.on("error", (error) => {
8113
+ finish();
8114
+ reject(error);
8115
+ });
8093
8116
  child.on("exit", (code2, signal) => {
8094
- exited = true;
8117
+ finish();
8095
8118
  resolve(code2 ?? (signal ? 128 + 15 : 1));
8096
8119
  });
8097
8120
  });
@@ -8104,7 +8127,17 @@ function runDsh(options) {
8104
8127
  freshToken: options.freshToken,
8105
8128
  write: (token) => writeDshToken(options.credentialsPath, token),
8106
8129
  isRunning: () => !exited,
8107
- sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
8130
+ sleep: (ms) => new Promise((resolve) => {
8131
+ const timer = setTimeout(() => {
8132
+ wake = null;
8133
+ resolve();
8134
+ }, ms);
8135
+ wake = () => {
8136
+ clearTimeout(timer);
8137
+ wake = null;
8138
+ resolve();
8139
+ };
8140
+ })
8108
8141
  });
8109
8142
  return done.finally(async () => {
8110
8143
  process.off("SIGINT", ignore);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divergeai/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
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",