@hive3/cli 0.3.0 → 0.5.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.
package/src/skill.js ADDED
@@ -0,0 +1,212 @@
1
+ // @ts-check
2
+
3
+ import { chmod, lstat, mkdir, mkdtemp, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ import { requiredFlagValue, writeLine } from "./shared.js";
9
+ import { commandUsage } from "./usage.js";
10
+
11
+ export const SKILL_NAME = "hive3";
12
+ const SKILL_SOURCE = new URL("../skills/hive3/", import.meta.url);
13
+
14
+ /**
15
+ * Skills directories verified against each agent's documentation (October 2026):
16
+ * - Claude Code: ~/.claude/skills/<name>/SKILL.md and .claude/skills/<name>/SKILL.md
17
+ * - Codex: $HOME/.agents/skills and $REPO/.agents/skills (~/.codex/skills is deprecated)
18
+ * - Cursor: ~/.cursor/skills and .cursor/skills
19
+ * @type {Record<string, { label: string, user: string[], project: string[], invoke: string }>}
20
+ */
21
+ const AGENTS = {
22
+ claude: { invoke: "/hive3", label: "Claude Code", project: [".claude", "skills"], user: [".claude", "skills"] },
23
+ codex: { invoke: "$hive3", label: "Codex", project: [".agents", "skills"], user: [".agents", "skills"] },
24
+ cursor: { invoke: "/hive3", label: "Cursor", project: [".cursor", "skills"], user: [".cursor", "skills"] },
25
+ };
26
+ const DEFAULT_AGENT = "claude";
27
+
28
+ export function skillUsage() {
29
+ return /** @type {string} */ (commandUsage("skill"));
30
+ }
31
+
32
+ /**
33
+ * @param {string[]} args
34
+ */
35
+ function parseTargetArgs(args) {
36
+ const options = { agent: undefined, dir: undefined, force: false, project: false };
37
+ for (let index = 0; index < args.length; index += 1) {
38
+ const flag = args[index];
39
+ if (flag === "--agent") {
40
+ index += 1;
41
+ options.agent = requiredFlagValue(flag, args[index]);
42
+ } else if (flag === "--dir") {
43
+ index += 1;
44
+ options.dir = requiredFlagValue(flag, args[index]);
45
+ } else if (flag === "--project") {
46
+ options.project = true;
47
+ } else if (flag === "--force") {
48
+ options.force = true;
49
+ } else {
50
+ throw new Error(`Unknown skill option: ${flag}`);
51
+ }
52
+ }
53
+ if (options.dir !== undefined && (options.agent !== undefined || options.project)) {
54
+ throw new Error("--dir cannot be combined with --agent or --project.");
55
+ }
56
+ return options;
57
+ }
58
+
59
+ /**
60
+ * Resolve the folder the skill is installed into (`<skills dir>/hive3`).
61
+ * @param {{ agent?: string, dir?: string, project: boolean }} options
62
+ * @param {{ cwd?: string, homeDir?: string }} deps
63
+ */
64
+ export function resolveSkillTarget(options, deps) {
65
+ const cwd = deps.cwd ?? process.cwd();
66
+ if (options.dir !== undefined) {
67
+ return { agent: undefined, target: path.join(path.resolve(cwd, options.dir), SKILL_NAME) };
68
+ }
69
+ const agent = options.agent ?? DEFAULT_AGENT;
70
+ const spec = Object.hasOwn(AGENTS, agent) ? AGENTS[agent] : undefined;
71
+ if (!spec) {
72
+ throw new Error(
73
+ `Unknown agent "${agent}". Supported: ${Object.keys(AGENTS).join(", ")}. For any other agent, use --dir <skills directory>.`,
74
+ );
75
+ }
76
+ const base = options.project ? cwd : (deps.homeDir ?? os.homedir());
77
+ return { agent, target: path.join(base, ...(options.project ? spec.project : spec.user), SKILL_NAME) };
78
+ }
79
+
80
+ /**
81
+ * @typedef {{ relative: string, executable: boolean, content: Buffer }} SkillFile
82
+ * @returns {Promise<SkillFile[]>}
83
+ */
84
+ async function readBundledSkill() {
85
+ const root = fileURLToPath(SKILL_SOURCE);
86
+ /** @type {SkillFile[]} */
87
+ const files = [];
88
+ /** @param {string} relative */
89
+ async function walk(relative) {
90
+ const directory = path.join(root, relative);
91
+ for (const entry of (await readdir(directory, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
92
+ const entryRelative = path.join(relative, entry.name);
93
+ const full = path.join(root, entryRelative);
94
+ const info = await lstat(full);
95
+ if (info.isDirectory()) await walk(entryRelative);
96
+ else if (info.isFile()) {
97
+ files.push({ content: await readFile(full), executable: (info.mode & 0o111) !== 0, relative: entryRelative });
98
+ } else {
99
+ throw new Error(`The bundled skill contains an unsupported entry: ${entryRelative}`);
100
+ }
101
+ }
102
+ }
103
+ await walk("");
104
+ if (!files.some((file) => file.relative === "SKILL.md")) throw new Error("The bundled Hive3 skill is missing SKILL.md.");
105
+ return files;
106
+ }
107
+
108
+ /**
109
+ * Whether `target` already holds exactly the bundled files (and nothing else).
110
+ * Throws if the target, or anything inside it, is a symlink.
111
+ * @param {string} target
112
+ * @param {SkillFile[]} files
113
+ */
114
+ async function existingState(target, files) {
115
+ const info = await lstat(target).catch((error) => {
116
+ if (error?.code === "ENOENT") return undefined;
117
+ throw error;
118
+ });
119
+ if (!info) return "absent";
120
+ if (info.isSymbolicLink()) {
121
+ throw new Error(`${target} is a symlink; remove it first. The CLI never writes through symlinks.`);
122
+ }
123
+ if (!info.isDirectory()) throw new Error(`${target} exists and is not a directory; remove it first.`);
124
+ const expected = new Map(files.map((file) => [file.relative, file]));
125
+ /** @param {string} relative */
126
+ async function compare(relative) {
127
+ for (const entry of await readdir(path.join(target, relative), { withFileTypes: true })) {
128
+ const entryRelative = path.join(relative, entry.name);
129
+ const full = path.join(target, entryRelative);
130
+ const entryInfo = await lstat(full);
131
+ if (entryInfo.isSymbolicLink()) {
132
+ throw new Error(`${full} is a symlink; remove it first. The CLI never writes through symlinks.`);
133
+ }
134
+ if (entryInfo.isDirectory()) {
135
+ if (!(await compare(entryRelative))) return false;
136
+ } else {
137
+ const file = expected.get(entryRelative);
138
+ if (!file || !entryInfo.isFile() || !file.content.equals(await readFile(full))) return false;
139
+ expected.delete(entryRelative);
140
+ }
141
+ }
142
+ return true;
143
+ }
144
+ return (await compare("")) && expected.size === 0 ? "same" : "different";
145
+ }
146
+
147
+ /**
148
+ * Stage a complete copy beside the target, then swap it in, so a failure never leaves a half-written skill.
149
+ * @param {string} target
150
+ * @param {SkillFile[]} files
151
+ * @param {boolean} replace
152
+ */
153
+ async function writeSkill(target, files, replace) {
154
+ const skillsDir = path.dirname(target);
155
+ await mkdir(skillsDir, { recursive: true });
156
+ const staging = await mkdtemp(path.join(skillsDir, `.${SKILL_NAME}-`));
157
+ try {
158
+ for (const file of files) {
159
+ const destination = path.join(staging, file.relative);
160
+ await mkdir(path.dirname(destination), { recursive: true });
161
+ await writeFile(destination, file.content, { flag: "wx" });
162
+ await chmod(destination, file.executable ? 0o755 : 0o644);
163
+ }
164
+ for (const directory of new Set(files.map((file) => path.dirname(path.join(staging, file.relative))))) {
165
+ await chmod(directory, 0o755);
166
+ }
167
+ await chmod(staging, 0o755);
168
+ if (replace) await rm(target, { force: true, recursive: true });
169
+ await rename(staging, target);
170
+ } catch (error) {
171
+ await rm(staging, { force: true, recursive: true });
172
+ throw error;
173
+ }
174
+ }
175
+
176
+ /**
177
+ * @param {string[]} args
178
+ * @param {{ cwd?: string, homeDir?: string, stdout: { write(chunk: string): unknown } }} deps
179
+ */
180
+ export async function runSkill(args, deps) {
181
+ const [action, ...rest] = args;
182
+ if (!action || action === "--help" || action === "-h" || action === "help") {
183
+ writeLine(deps.stdout, skillUsage());
184
+ return;
185
+ }
186
+ if (action === "show") {
187
+ if (rest.length > 0) throw new Error(`Unknown skill show option: ${rest[0]}`);
188
+ const skill = (await readBundledSkill()).find((file) => file.relative === "SKILL.md");
189
+ deps.stdout.write(skill?.content.toString("utf8") ?? "");
190
+ return;
191
+ }
192
+ if (action !== "install" && action !== "path") throw new Error(`Unknown skill action: ${action}`);
193
+ const options = parseTargetArgs(rest);
194
+ const { agent, target } = resolveSkillTarget(options, deps);
195
+ if (action === "path") {
196
+ writeLine(deps.stdout, target);
197
+ return;
198
+ }
199
+ const files = await readBundledSkill();
200
+ const state = await existingState(target, files);
201
+ if (state === "same") {
202
+ writeLine(deps.stdout, `The Hive3 skill is already installed and up to date at ${target}.`);
203
+ return;
204
+ }
205
+ if (state === "different" && !options.force) {
206
+ throw new Error(`A different skill already exists at ${target}. Re-run with --force to replace it.`);
207
+ }
208
+ await writeSkill(target, files, state === "different");
209
+ const spec = agent ? AGENTS[agent] : undefined;
210
+ writeLine(deps.stdout, `Installed the Hive3 skill at ${target}.`);
211
+ if (spec) writeLine(deps.stdout, `Restart ${spec.label} if it is running, then use ${spec.invoke} or just ask it to use Hive3.`);
212
+ }
@@ -0,0 +1,16 @@
1
+ // @ts-check
2
+
3
+ /** Connect management only. The API base already includes /api/v1. */
4
+ export function createStripeClient(client) {
5
+ return {
6
+ status(query) {
7
+ return client.request("GET", "/payments/stripe/status", { query });
8
+ },
9
+ operate(operation, query, confirm) {
10
+ return client.request("POST", `/payments/stripe/${operation}`, {
11
+ query,
12
+ body: confirm === undefined ? {} : { confirm },
13
+ });
14
+ },
15
+ };
16
+ }
@@ -0,0 +1,63 @@
1
+ // @ts-check
2
+
3
+ import { authenticatedClient, requiredFlagValue, writeJson, writeLine } from "./shared.js";
4
+ import { createStripeClient } from "./stripe-client.js";
5
+
6
+ export function stripeUsage() {
7
+ return `Stripe Connect (JSON output)
8
+ hive3 stripe status [--account <account-id-or-handle>]
9
+ hive3 stripe onboard [--account <account-id-or-handle>] --yes
10
+ hive3 stripe refresh [--account <account-id-or-handle>]
11
+ hive3 stripe dashboard [--account <account-id-or-handle>] --yes
12
+ hive3 stripe tax-setup [--account <account-id-or-handle>] --yes
13
+ hive3 stripe disconnect [--account <account-id-or-handle>] --yes --confirm <owner-account-id>
14
+
15
+ status requires payments:read; all other operations require payments:write.
16
+ Managed accounts also need communities:read/write and a current owner/admin role,
17
+ within the key's managed-account allowlist. Connect management is owner/admin only;
18
+ Team (staff) access never grants it.
19
+ onboard creates or resumes Hive3's Stripe Connect V2/Express browser onboarding.
20
+ The owner completes verification in a browser; unattended KYC is not supported.
21
+ tax-setup opens authenticated Hive3 tax settings; no client secret is returned.
22
+ Dashboard links grant account access: open privately, never share or persist them.
23
+ Disconnect ends renewing Stripe subscriptions at period end, deactivates Stripe
24
+ plans and removes Hive3's connection. It does not close the account at Stripe.
25
+ Once disconnect begins, new Stripe sales and renewal resumes are blocked.
26
+ If interrupted or rejected by Stripe, retry disconnect to finish safely.
27
+ Use status to obtain the canonical owner account ID for exact confirmation.`;
28
+ }
29
+
30
+ export async function runStripeCommand(args, deps) {
31
+ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
32
+ writeLine(deps.stdout, stripeUsage());
33
+ return;
34
+ }
35
+ const [command, ...flags] = args;
36
+ const operations = { onboard: "onboarding", refresh: "refresh", dashboard: "dashboard", "tax-setup": "tax-setup", disconnect: "disconnect" };
37
+ if (command !== "status" && !Object.hasOwn(operations, command)) throw new Error(`Unknown stripe command: ${command}`);
38
+ let account;
39
+ let yes = false;
40
+ let confirm;
41
+ const seen = new Set();
42
+ for (let index = 0; index < flags.length; index += 1) {
43
+ const flag = flags[index];
44
+ if (seen.has(flag)) throw new Error(`${flag} may only be given once`);
45
+ seen.add(flag);
46
+ if (flag === "--account") account = requiredFlagValue(flag, flags[++index]);
47
+ else if (flag === "--yes") yes = true;
48
+ else if (flag === "--confirm") confirm = requiredFlagValue(flag, flags[++index]);
49
+ else throw new Error(`Unknown stripe option: ${flag}`);
50
+ }
51
+ if (confirm !== undefined && command !== "disconnect") throw new Error("--confirm is only accepted for disconnect");
52
+ if (["onboard", "dashboard", "tax-setup", "disconnect"].includes(command) && !yes) {
53
+ throw new Error(`stripe ${command} requires --yes`);
54
+ }
55
+ if (command === "disconnect" && !confirm) throw new Error("--confirm must exactly match the owner account ID returned by stripe status");
56
+ const client = createStripeClient(await authenticatedClient(deps));
57
+ const query = { account };
58
+ if (command === "status") {
59
+ writeJson(deps.stdout, await client.status(query));
60
+ return;
61
+ }
62
+ writeJson(deps.stdout, await client.operate(operations[command], query, confirm));
63
+ }
@@ -0,0 +1,11 @@
1
+ // @ts-check
2
+
3
+ export function createTeamClient(client) {
4
+ return {
5
+ operations: () => client.request("GET", "/team/operations"),
6
+ execute: (operation, payload, options = {}) => client.request("POST", `/team/operations/${encodeURIComponent(operation)}`, {
7
+ body: { payload, ...(options.confirmed ? { confirmed: true } : {}), ...(options.confirmation !== undefined ? { confirmation: options.confirmation } : {}), ...(options.requestId ? { requestId: options.requestId } : {}) },
8
+ idempotencyKey: options.requestId,
9
+ }),
10
+ };
11
+ }
@@ -0,0 +1,84 @@
1
+ // @ts-check
2
+
3
+ import { randomUUID } from "node:crypto";
4
+ import path from "node:path";
5
+ import { authenticatedClient, readJsonObject, requiredFlagValue, writeJson, writeLine } from "./shared.js";
6
+ import { createTeamClient } from "./team-client.js";
7
+ import { runFeedbackCommand } from "./feedback-commands.js";
8
+
9
+ // Client preflight only; authoritative operation names, validators and permissions live on the server.
10
+ const READ_OPERATIONS = new Set([
11
+ "accounts.search", "accounts.get", "events.search", "accounts.suggest-handle", "accounts.check-handle", "accounts.list-processing", "accounts.handover-target",
12
+ "featured.list", "onboarding.list", "credentials.list", "credentials.summary", "credentials.platform-wallets", "invites.list", "invites.email-account-hint", "billing.list",
13
+ "worlds.list", "worlds.get", "worlds.calendar", "worlds.sharedBans", "worlds.capacity", "reports.summary", "reports.rows",
14
+ "referrals.summary", "referrals.listReferrals", "referrals.referrerDetail", "referrals.referrerAttributions", "referrals.referrerConversions", "referrals.conversionPayments", "referrals.conversionAdjustments",
15
+ "migration.summary", "migration.accounts", "migration.unowned", "migration.clusters", "migration.resolutions",
16
+ ]);
17
+ const EXACT_OPERATIONS = new Set(["featured.remove", "featured.remove-highlight", "onboarding.remove", "invites.remove", "billing.cancel", "credentials.withdraw-fees"]);
18
+
19
+ export function teamUsage() {
20
+ return `Usage:
21
+ hive3 team operations [domain]
22
+ hive3 team <domain> <action> [--file payload.json] [--yes] [--confirm <exact-text>] [--idempotency-key <key>]
23
+ hive3 team feedback <list|get|messages|reply|status> [options]
24
+
25
+ Team Tools require current staff access and team:read/team:write scopes.
26
+ Staff: run hive3 login again (Team Tools are added automatically for staff accounts).
27
+ Operations are a fixed server allowlist, never arbitrary Convex function names.
28
+ team operations returns each operation's argument schema, description and confirmation rule.
29
+ Read payloads default to {}; use --file for operation arguments, including sensitive data.
30
+ Changes require --yes; resource removal and fee collection also require exact --confirm text.
31
+ Ownership transfers and legacy login invitations stay in browser Team Tools.
32
+ A fresh request ID is generated for each confirmed command; pass --idempotency-key to replay safely.
33
+ No automatic retry repeats an external email, entry issuance or withdrawal attempt.
34
+ Account deletion, destructive merges and resolution retries are not available through the CLI or API.
35
+
36
+ Examples:
37
+ hive3 team operations accounts
38
+ hive3 team accounts get --file account.json
39
+ hive3 team accounts set-tier --file tier.json --yes
40
+ hive3 team accounts grant-time --file time.json --yes
41
+ hive3 team credentials platform-wallets
42
+ hive3 team feedback list --status open`;
43
+ }
44
+
45
+ function parseOptions(args) {
46
+ const parsed = { yes: false };
47
+ for (let index = 0; index < args.length; index++) {
48
+ const flag = args[index];
49
+ if (flag === "--yes") { parsed.yes = true; continue; }
50
+ if (!["--file", "--confirm", "--idempotency-key"].includes(flag)) throw new Error(`Unknown team option: ${flag}`);
51
+ const key = flag.slice(2);
52
+ if (parsed[key] !== undefined) throw new Error(`${flag} may only be given once`);
53
+ parsed[key] = requiredFlagValue(flag, args[++index]);
54
+ }
55
+ if (parsed.confirm !== undefined && !parsed.yes) throw new Error("--confirm also requires --yes");
56
+ if (parsed["idempotency-key"] !== undefined && (!parsed["idempotency-key"].trim() || parsed["idempotency-key"].length > 128)) throw new Error("--idempotency-key must contain 1–128 characters");
57
+ return parsed;
58
+ }
59
+
60
+ export async function runTeamCommand(args, deps) {
61
+ if (args.length === 0 || args.some(arg => arg === "--help" || arg === "-h")) {
62
+ writeLine(deps.stdout, teamUsage());
63
+ return 0;
64
+ }
65
+ if (args[0] === "feedback") return await runFeedbackCommand(["team", ...args.slice(1)], deps);
66
+ if (args[0] === "operations") {
67
+ if (args.length > 2 || args[1]?.startsWith("-")) throw new Error("Usage: hive3 team operations [domain]");
68
+ const client = createTeamClient(await authenticatedClient(deps));
69
+ const result = await client.operations();
70
+ writeJson(deps.stdout, args[1] ? { ...result, data: result.data.filter(operation => operation.name.startsWith(`${args[1]}.`)) } : result);
71
+ return 0;
72
+ }
73
+ const [domain, action, ...rest] = args;
74
+ if (!domain || !action || !/^[a-z][a-zA-Z0-9-]*$/.test(domain) || !/^[a-z][a-zA-Z0-9-]*$/.test(action)) throw new Error("Usage: hive3 team <domain> <action> [--file payload.json] [--yes]");
75
+ const options = parseOptions(rest);
76
+ const operation = `${domain}.${action}`;
77
+ if (!READ_OPERATIONS.has(operation) && !options.yes) throw new Error("Team changes require --yes. Use team operations to discover argument and confirmation requirements.");
78
+ if (EXACT_OPERATIONS.has(operation) && options.confirm === undefined) throw new Error("This Team operation requires --confirm <exact-text>. Read team operations for its confirmation rule.");
79
+ const payload = options.file ? await readJsonObject(path.resolve(deps.cwd, options.file)) : {};
80
+ const client = createTeamClient(await authenticatedClient(deps));
81
+ const result = await client.execute(operation, payload, { confirmed: options.yes, confirmation: options.confirm, requestId: options.yes ? options["idempotency-key"] ?? randomUUID() : undefined });
82
+ writeJson(deps.stdout, result);
83
+ return 0;
84
+ }
package/src/update.js CHANGED
@@ -5,7 +5,7 @@ import { readFileSync } from "node:fs";
5
5
  import { promises as fs } from "node:fs";
6
6
  import path from "node:path";
7
7
 
8
- import { configDirectory } from "./config.js";
8
+ import { configDirectory, writePrivateFile } from "./config.js";
9
9
 
10
10
  export const PACKAGE_NAME = "@hive3/cli";
11
11
  export const REGISTRY_LATEST_URL = "https://registry.npmjs.org/@hive3%2Fcli/latest";
@@ -97,11 +97,7 @@ async function loadUpdateCache(file) {
97
97
  }
98
98
 
99
99
  async function saveUpdateCache(file, cache) {
100
- const directory = path.dirname(file);
101
- await fs.mkdir(directory, { mode: 0o700, recursive: true });
102
- const temporaryFile = `${file}.${process.pid}.tmp`;
103
- await fs.writeFile(temporaryFile, `${JSON.stringify(cache)}\n`, { mode: 0o600 });
104
- await fs.rename(temporaryFile, file);
100
+ await writePrivateFile(path.dirname(file), path.basename(file), `${JSON.stringify(cache)}\n`);
105
101
  }
106
102
 
107
103
  export async function maybeNotifyUpdate(overrides = {}) {
@@ -143,18 +139,27 @@ export async function maybeNotifyUpdate(overrides = {}) {
143
139
  if (compareVersions(latestVersion, currentVersion) <= 0) return null;
144
140
 
145
141
  writeLine(stderr, `Hive CLI update available: ${currentVersion} → ${latestVersion}`);
146
- writeLine(stderr, "Run `hive update` to install it.");
142
+ writeLine(stderr, "Run `hive3 update` to install it.");
147
143
  return latestVersion;
148
144
  }
149
145
 
150
- export function installLatest(overrides = {}) {
146
+ /**
147
+ * Install the exact version the user was shown. The version is validated against a
148
+ * strict semver pattern, so the only variable argument can never carry shell syntax.
149
+ * Windows resolves `npm` through `npm.cmd`, which Node (CVE-2024-27980 fix) refuses to
150
+ * spawn without a shell; the arguments are fixed and validated there, so `shell: true`
151
+ * is safe on win32 only.
152
+ */
153
+ export function installVersion(version, overrides = {}) {
154
+ parseVersion(version);
151
155
  const spawnImpl = overrides.spawn ?? spawn;
152
- const command = (overrides.platform ?? process.platform) === "win32" ? "npm.cmd" : "npm";
156
+ const windows = (overrides.platform ?? process.platform) === "win32";
153
157
  return new Promise((resolve, reject) => {
154
- const child = spawnImpl(command, ["install", "--global", `${PACKAGE_NAME}@latest`], {
155
- shell: false,
156
- stdio: "inherit",
157
- });
158
+ const child = spawnImpl(
159
+ windows ? "npm.cmd" : "npm",
160
+ ["install", "--global", `${PACKAGE_NAME}@${version}`],
161
+ { shell: windows, stdio: "inherit" },
162
+ );
158
163
  child.once("error", reject);
159
164
  child.once("exit", (code, signal) => {
160
165
  if (code === 0) resolve(undefined);
@@ -163,13 +168,21 @@ export function installLatest(overrides = {}) {
163
168
  });
164
169
  }
165
170
 
171
+ export function updateUsage() {
172
+ return [
173
+ "Usage: hive3 update [--check]",
174
+ " --check Report the latest published version without installing it.",
175
+ "Installs exactly the version it reports (npm install --global @hive3/cli@<version>).",
176
+ ].join("\n");
177
+ }
178
+
166
179
  export async function runUpdateCommand(args, overrides = {}) {
167
180
  const stdout = overrides.stdout ?? process.stdout;
168
181
  if (args.length > 1 || (args.length === 1 && !["--check", "--help", "-h"].includes(args[0]))) {
169
182
  throw new Error(`Unknown update option: ${args[0] ?? ""}`.trim());
170
183
  }
171
184
  if (args[0] === "--help" || args[0] === "-h") {
172
- writeLine(stdout, "Usage: hive update [--check]");
185
+ writeLine(stdout, updateUsage());
173
186
  return;
174
187
  }
175
188
 
@@ -189,11 +202,11 @@ export async function runUpdateCommand(args, overrides = {}) {
189
202
 
190
203
  if (args[0] === "--check") {
191
204
  writeLine(stdout, `Hive CLI update available: ${currentVersion} → ${latestVersion}`);
192
- writeLine(stdout, "Run `hive update` to install it.");
205
+ writeLine(stdout, "Run `hive3 update` to install it.");
193
206
  return;
194
207
  }
195
208
 
196
209
  writeLine(stdout, `Updating Hive CLI ${currentVersion} → ${latestVersion}...`);
197
- await (overrides.install ?? installLatest)({ platform: overrides.platform, spawn: overrides.spawn });
198
- writeLine(stdout, `Hive CLI ${latestVersion} installed. Run \`hive --help\` to verify it.`);
210
+ await (overrides.install ?? installVersion)(latestVersion, { platform: overrides.platform, spawn: overrides.spawn });
211
+ writeLine(stdout, `Hive CLI ${latestVersion} installed. Run \`hive3 --help\` to verify it.`);
199
212
  }