multiclaw 0.5.0 → 0.5.1

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.
@@ -1 +1,30 @@
1
+ /** Which package manager owns the copy of multiclaw that is currently running. */
2
+ export type Installer = "npm" | "pnpm" | "bun" | "yarn" | "unknown";
3
+ /** Walk up from `start` to the package.json that declares this package. */
4
+ export declare function findPackageRoot(start: string): string | undefined;
5
+ /** Read the installed version straight from disk (no module cache to go stale). */
6
+ export declare function readInstalledVersion(pkgRoot: string): string | undefined;
7
+ /**
8
+ * Identify the installer from the on-disk location of the running package.
9
+ *
10
+ * This is the whole point of the command: `npm install -g` writes to npm's
11
+ * prefix, which is not necessarily where the binary on PATH came from. A user
12
+ * with a pnpm global install used to get a silent no-op upgrade — npm installed
13
+ * a fresh copy somewhere else while `multiclaw --version` kept reporting the
14
+ * pnpm one. Upgrading must therefore target the manager that owns this copy.
15
+ */
16
+ export declare function detectInstaller(pkgRoot: string): Installer;
17
+ type Exec = (command: string, mode: "capture" | "inherit") => string;
18
+ export interface UpgradeContext {
19
+ pkgRoot: string;
20
+ currentVersion: string;
21
+ installer: Installer;
22
+ /** Re-read after installing: the on-disk copy is what `--version` reports. */
23
+ readVersion: (pkgRoot: string) => string | undefined;
24
+ exec: Exec;
25
+ }
26
+ /** Resolve the running install. `undefined` means it is not an installed copy. */
27
+ export declare function createUpgradeContext(): UpgradeContext | undefined;
28
+ export declare function runUpgrade(ctx: UpgradeContext): Promise<void>;
1
29
  export declare function upgradeCommand(): Promise<void>;
30
+ export {};
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { readFileSync as readFileSync2 } from "fs";
5
- import { dirname as dirname3, join as join4 } from "path";
6
- import { fileURLToPath } from "url";
4
+ import { readFileSync as readFileSync3 } from "fs";
5
+ import { dirname as dirname4, join as join5 } from "path";
6
+ import { fileURLToPath as fileURLToPath2 } from "url";
7
7
  import { Command } from "commander";
8
8
 
9
9
  // src/commands/doctor.ts
@@ -716,12 +716,12 @@ var FileLogWriter = class {
716
716
  this.streams.clear();
717
717
  return Promise.all(
718
718
  streams.map(
719
- (s) => new Promise((resolve4) => {
719
+ (s) => new Promise((resolve5) => {
720
720
  if (s.destroyed || s.writableEnded) {
721
- resolve4();
721
+ resolve5();
722
722
  return;
723
723
  }
724
- s.end(() => resolve4());
724
+ s.end(() => resolve5());
725
725
  })
726
726
  )
727
727
  ).then(() => void 0);
@@ -919,40 +919,132 @@ async function tuiCommand(options) {
919
919
 
920
920
  // src/commands/upgrade.ts
921
921
  import { execSync } from "child_process";
922
- import { createRequire as createRequire2 } from "module";
923
- var require2 = createRequire2(import.meta.url);
924
- async function upgradeCommand() {
925
- const { version: currentVersion } = require2("../package.json");
926
- console.log(`Current version: v${currentVersion}`);
922
+ import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
923
+ import { dirname as dirname3, join as join4, resolve as resolve4 } from "path";
924
+ import { fileURLToPath } from "url";
925
+ var PACKAGE_NAME = "multiclaw";
926
+ var RED2 = "\x1B[31m";
927
+ var GREEN2 = "\x1B[32m";
928
+ var RESET2 = "\x1B[0m";
929
+ function readManifest(dir) {
930
+ const manifest = join4(dir, "package.json");
931
+ if (!existsSync5(manifest)) return void 0;
932
+ try {
933
+ return JSON.parse(readFileSync2(manifest, "utf8"));
934
+ } catch {
935
+ return void 0;
936
+ }
937
+ }
938
+ function findPackageRoot(start) {
939
+ let dir = resolve4(start);
940
+ for (; ; ) {
941
+ if (readManifest(dir)?.name === PACKAGE_NAME) return dir;
942
+ const parent = dirname3(dir);
943
+ if (parent === dir) return void 0;
944
+ dir = parent;
945
+ }
946
+ }
947
+ function readInstalledVersion(pkgRoot) {
948
+ return readManifest(pkgRoot)?.version;
949
+ }
950
+ function detectInstaller(pkgRoot) {
951
+ const path6 = pkgRoot.replaceAll("\\", "/");
952
+ if (path6.includes("/pnpm/global/") || path6.includes("/.pnpm/")) return "pnpm";
953
+ if (path6.includes("/install/global/") || path6.includes("/.bun/")) return "bun";
954
+ if (path6.includes("/yarn/global/")) return "yarn";
955
+ if (path6.includes("/node_modules/")) return "npm";
956
+ return "unknown";
957
+ }
958
+ var COMMANDS = {
959
+ npm: { latest: "npm show multiclaw version", install: "npm install -g multiclaw@latest" },
960
+ pnpm: { latest: "pnpm view multiclaw version", install: "pnpm add -g multiclaw@latest" },
961
+ bun: void 0,
962
+ yarn: void 0,
963
+ unknown: void 0
964
+ };
965
+ var MANUAL = {
966
+ npm: "npm install -g multiclaw@latest",
967
+ pnpm: "pnpm add -g multiclaw@latest",
968
+ bun: "bun add -g multiclaw@latest",
969
+ yarn: "yarn global add multiclaw@latest",
970
+ unknown: "npm install -g multiclaw@latest"
971
+ };
972
+ function createUpgradeContext() {
973
+ const pkgRoot = findPackageRoot(dirname3(fileURLToPath(import.meta.url)));
974
+ if (!pkgRoot) return void 0;
975
+ const currentVersion = readInstalledVersion(pkgRoot);
976
+ if (!currentVersion) return void 0;
977
+ return {
978
+ pkgRoot,
979
+ currentVersion,
980
+ installer: detectInstaller(pkgRoot),
981
+ readVersion: readInstalledVersion,
982
+ exec: (command, mode) => {
983
+ if (mode === "inherit") {
984
+ execSync(command, { stdio: "inherit" });
985
+ return "";
986
+ }
987
+ return execSync(command, { encoding: "utf8" });
988
+ }
989
+ };
990
+ }
991
+ async function runUpgrade(ctx) {
992
+ const { pkgRoot, currentVersion, installer, exec, readVersion } = ctx;
993
+ console.log(`Current version: v${currentVersion} (${installer} install)`);
994
+ const commands = COMMANDS[installer];
995
+ if (!commands) {
996
+ const reason = installer === "unknown" ? `this copy is not a global install (${pkgRoot})` : `the ${installer} install at ${pkgRoot} cannot be upgraded automatically`;
997
+ console.error(`${RED2}Error: ${reason}. Run it manually: ${MANUAL[installer]}${RESET2}`);
998
+ process.exit(1);
999
+ return;
1000
+ }
927
1001
  console.log("Checking for updates...");
928
1002
  let latestVersion;
929
1003
  try {
930
- latestVersion = execSync("npm show multiclaw version", { encoding: "utf8" }).trim();
1004
+ latestVersion = exec(commands.latest, "capture").trim();
931
1005
  } catch {
932
- console.error("\x1B[31mError: Failed to fetch latest version from npm registry\x1B[0m");
1006
+ console.error(`${RED2}Error: Failed to fetch latest version from npm registry${RESET2}`);
933
1007
  process.exit(1);
934
1008
  return;
935
1009
  }
936
1010
  if (latestVersion === currentVersion) {
937
- console.log(`\x1B[32m\u2713\x1B[0m Already on the latest version (v${currentVersion})`);
1011
+ console.log(`${GREEN2}\u2713${RESET2} Already on the latest version (v${currentVersion})`);
938
1012
  return;
939
1013
  }
940
1014
  console.log(`Upgrading multiclaw v${currentVersion} \u2192 v${latestVersion}...`);
941
1015
  try {
942
- execSync("npm install -g multiclaw@latest", { stdio: "inherit" });
943
- console.log(`\x1B[32m\u2713\x1B[0m Successfully upgraded to v${latestVersion}`);
1016
+ exec(commands.install, "inherit");
944
1017
  } catch {
1018
+ console.error(`${RED2}Error: Upgrade failed. Try running manually: ${commands.install}${RESET2}`);
1019
+ process.exit(1);
1020
+ return;
1021
+ }
1022
+ const installedVersion = readVersion(pkgRoot);
1023
+ if (installedVersion !== latestVersion) {
945
1024
  console.error(
946
- "\x1B[31mError: Upgrade failed. Try running manually: npm install -g multiclaw@latest\x1B[0m"
1025
+ `${RED2}Error: ${commands.install} finished, but ${pkgRoot} still reports v${installedVersion ?? "unknown"}. Check for a second multiclaw install, then retry.${RESET2}`
947
1026
  );
948
1027
  process.exit(1);
1028
+ return;
1029
+ }
1030
+ console.log(`${GREEN2}\u2713${RESET2} Successfully upgraded to v${latestVersion} (${pkgRoot})`);
1031
+ }
1032
+ async function upgradeCommand() {
1033
+ const ctx = createUpgradeContext();
1034
+ if (!ctx) {
1035
+ console.error(
1036
+ `${RED2}Error: could not locate the multiclaw package this process is running from.${RESET2}`
1037
+ );
1038
+ process.exit(1);
1039
+ return;
949
1040
  }
1041
+ await runUpgrade(ctx);
950
1042
  }
951
1043
 
952
1044
  // src/index.ts
953
- var __filename2 = fileURLToPath(import.meta.url);
954
- var __dirname2 = dirname3(__filename2);
955
- var pkg = JSON.parse(readFileSync2(join4(__dirname2, "../package.json"), "utf-8"));
1045
+ var __filename2 = fileURLToPath2(import.meta.url);
1046
+ var __dirname2 = dirname4(__filename2);
1047
+ var pkg = JSON.parse(readFileSync3(join5(__dirname2, "../package.json"), "utf-8"));
956
1048
  var program = new Command();
957
1049
  program.name("multiclaw").description("Multi-agent orchestration CLI").version(pkg.version, "-v, --version", "Display version number").action((options) => tuiCommand(options));
958
1050
  program.command("init").description("Scaffold a config file (interactive)").action(() => initCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multiclaw",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "multiclaw": "dist/index.js"
@@ -30,8 +30,8 @@
30
30
  "@agentclientprotocol/claude-agent-acp": "^0.93.0",
31
31
  "@agentclientprotocol/codex-acp": "^2.2.2",
32
32
  "@inquirer/prompts": "^8.7.3",
33
- "@multiclawcli/core": "0.5.0",
34
- "@multiclawcli/dashboard": "0.5.0",
33
+ "@multiclawcli/core": "0.5.1",
34
+ "@multiclawcli/dashboard": "0.5.1",
35
35
  "commander": "^15.0.0",
36
36
  "jiti": "^2.7.0"
37
37
  },