@zeroxyz/cli 0.0.16 → 0.0.20

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/index.js +37 -24
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command as Command9 } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@zeroxyz/cli",
9
- version: "0.0.16",
9
+ version: "0.0.20",
10
10
  type: "module",
11
11
  bin: {
12
12
  zero: "dist/index.js",
@@ -22,7 +22,7 @@ var package_default = {
22
22
  },
23
23
  scripts: {
24
24
  build: "tsup src/index.ts --format esm --out-dir dist --clean",
25
- "build:binary": "tsup --config tsup.binary.ts && cp -r skills hooks dist/pkg/ && pkg dist/pkg/index.cjs --config pkg.json --targets node24-macos-arm64,node24-macos-x64,node24-linux-x64 --output dist/bin/zero",
25
+ "build:binary": "tsup --config tsup.binary.ts && cp -r skills hooks dist/pkg/ && pnpm exec pkg dist/pkg/index.cjs --config pkg.json --targets node24-macos-arm64,node24-macos-x64,node24-linux-x64 --output dist/bin/zero",
26
26
  prepublishOnly: "pnpm run build",
27
27
  dev: "tsx src/index.ts",
28
28
  cli: "ZERO_API_URL=http://localhost:1111 tsx src/index.ts",
@@ -480,32 +480,41 @@ var initCommand = (appContext) => new Command4("init").description("Initialize Z
480
480
  const home = homedir2();
481
481
  const zeroDir = join2(home, ".zero");
482
482
  const configPath = join2(zeroDir, "config.json");
483
- if (existsSync2(configPath) && !options.force) {
483
+ let walletCreated = false;
484
+ let walletAddress = null;
485
+ const walletExists = (() => {
486
+ if (!existsSync2(configPath)) return false;
484
487
  try {
485
- const existing2 = JSON.parse(readFileSync2(configPath, "utf8"));
486
- if (existing2.privateKey) {
487
- console.error(
488
- "Zero is already initialized. Use --force to overwrite."
489
- );
490
- process.exitCode = 1;
491
- return;
492
- }
488
+ const existing = JSON.parse(readFileSync2(configPath, "utf8"));
489
+ return !!existing.privateKey;
490
+ } catch {
491
+ return false;
492
+ }
493
+ })();
494
+ if (!walletExists || options.force) {
495
+ const privateKey = generatePrivateKey();
496
+ const account = privateKeyToAccount(privateKey);
497
+ mkdirSync2(zeroDir, { recursive: true });
498
+ const existing = existsSync2(configPath) ? JSON.parse(readFileSync2(configPath, "utf8")) : {};
499
+ writeFileSync2(
500
+ configPath,
501
+ JSON.stringify(
502
+ { ...existing, privateKey, lowBalanceWarning: 1 },
503
+ null,
504
+ 2
505
+ )
506
+ );
507
+ walletCreated = true;
508
+ walletAddress = account.address;
509
+ console.log(`Wallet address: ${account.address}`);
510
+ } else {
511
+ try {
512
+ const existing = JSON.parse(readFileSync2(configPath, "utf8"));
513
+ const account = privateKeyToAccount(existing.privateKey);
514
+ walletAddress = account.address;
493
515
  } catch {
494
516
  }
495
517
  }
496
- const privateKey = generatePrivateKey();
497
- const account = privateKeyToAccount(privateKey);
498
- mkdirSync2(zeroDir, { recursive: true });
499
- const existing = existsSync2(configPath) ? JSON.parse(readFileSync2(configPath, "utf8")) : {};
500
- writeFileSync2(
501
- configPath,
502
- JSON.stringify(
503
- { ...existing, privateKey, lowBalanceWarning: 1 },
504
- null,
505
- 2
506
- )
507
- );
508
- console.log(`Wallet address: ${account.address}`);
509
518
  const agentsDetected = [];
510
519
  const agentsWithSkills = [];
511
520
  let skillsError = null;
@@ -536,6 +545,10 @@ var initCommand = (appContext) => new Command4("init").description("Initialize Z
536
545
  'Zero is ready! Run `zero search` to find capabilities.\n\nTry:\n zero search "translate text to Spanish"\n zero search "generate an image"\n zero search "weather forecast"'
537
546
  );
538
547
  appContext.services.analyticsService.capture("wallet_initialized", {
548
+ // biome-ignore lint/style/useNamingConvention: snake_case for analytics
549
+ wallet_created: walletCreated,
550
+ // biome-ignore lint/style/useNamingConvention: snake_case for analytics
551
+ wallet_address: walletAddress,
539
552
  // biome-ignore lint/style/useNamingConvention: snake_case for analytics
540
553
  agents_detected: agentsDetected,
541
554
  // biome-ignore lint/style/useNamingConvention: snake_case for analytics
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeroxyz/cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "zero": "dist/index.js",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "scripts": {
18
18
  "build": "tsup src/index.ts --format esm --out-dir dist --clean",
19
- "build:binary": "tsup --config tsup.binary.ts && cp -r skills hooks dist/pkg/ && pkg dist/pkg/index.cjs --config pkg.json --targets node24-macos-arm64,node24-macos-x64,node24-linux-x64 --output dist/bin/zero",
19
+ "build:binary": "tsup --config tsup.binary.ts && cp -r skills hooks dist/pkg/ && pnpm exec pkg dist/pkg/index.cjs --config pkg.json --targets node24-macos-arm64,node24-macos-x64,node24-linux-x64 --output dist/bin/zero",
20
20
  "prepublishOnly": "pnpm run build",
21
21
  "dev": "tsx src/index.ts",
22
22
  "cli": "ZERO_API_URL=http://localhost:1111 tsx src/index.ts",