@higrowth/cli 0.2.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +195 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1157,8 +1157,174 @@ function compareSkill(path, skill) {
1157
1157
  }
1158
1158
  }
1159
1159
 
1160
+ // src/commands/upgrade.ts
1161
+ var PKG_NAME = "@higrowth/cli";
1162
+ async function upgradeCommand() {
1163
+ process.stdout.write(
1164
+ `
1165
+ Upgrade ${PKG_NAME} to the latest version with whichever package
1166
+ manager you used to install it:
1167
+
1168
+ npm install -g ${PKG_NAME}@latest
1169
+ pnpm add -g ${PKG_NAME}@latest
1170
+ bun add -g ${PKG_NAME}@latest
1171
+ yarn global add ${PKG_NAME}@latest
1172
+
1173
+ Or, if you installed via the curl-piped flow:
1174
+
1175
+ curl -fsSL https://app.higrowth.ai/install.sh | sh
1176
+
1177
+ After upgrade, run \`higrowth -v\` to confirm.
1178
+ `
1179
+ );
1180
+ }
1181
+
1182
+ // src/lib/update-check.ts
1183
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
1184
+ import { dirname as dirname3, join as join3 } from "path";
1185
+ import { homedir as homedir3 } from "os";
1186
+ var PKG_NAME2 = "@higrowth/cli";
1187
+ var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
1188
+ var REQUEST_TIMEOUT_MS = 2e3;
1189
+ function cachePath() {
1190
+ return join3(homedir3(), ".config", "higrowth", "update-check.json");
1191
+ }
1192
+ function readCache() {
1193
+ const path = cachePath();
1194
+ if (!existsSync3(path)) return null;
1195
+ try {
1196
+ const raw = readFileSync3(path, "utf-8");
1197
+ const parsed = JSON.parse(raw);
1198
+ if (typeof parsed.latestVersion !== "string") return null;
1199
+ if (typeof parsed.fetchedAt !== "number") return null;
1200
+ return { latestVersion: parsed.latestVersion, fetchedAt: parsed.fetchedAt };
1201
+ } catch {
1202
+ return null;
1203
+ }
1204
+ }
1205
+ function writeCache(latestVersion) {
1206
+ const path = cachePath();
1207
+ try {
1208
+ mkdirSync3(dirname3(path), { recursive: true });
1209
+ writeFileSync3(
1210
+ path,
1211
+ JSON.stringify({ latestVersion, fetchedAt: Date.now() }, null, 2),
1212
+ "utf-8"
1213
+ );
1214
+ } catch {
1215
+ }
1216
+ }
1217
+ async function fetchLatestFromNpm() {
1218
+ const controller = new AbortController();
1219
+ const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
1220
+ try {
1221
+ const res = await fetch(`https://registry.npmjs.org/${PKG_NAME2}/latest`, {
1222
+ headers: { Accept: "application/json" },
1223
+ signal: controller.signal
1224
+ });
1225
+ if (!res.ok) return null;
1226
+ const body = await res.json();
1227
+ return body.version ?? null;
1228
+ } catch {
1229
+ return null;
1230
+ } finally {
1231
+ clearTimeout(timer);
1232
+ }
1233
+ }
1234
+ function compareVersions(a, b) {
1235
+ const parse = (v) => v.split("-")[0].split(".").map((s) => Number.parseInt(s, 10)).map((n2) => Number.isFinite(n2) ? n2 : 0);
1236
+ const aa = parse(a);
1237
+ const bb = parse(b);
1238
+ const n = Math.max(aa.length, bb.length);
1239
+ for (let i = 0; i < n; i++) {
1240
+ const ai = aa[i] ?? 0;
1241
+ const bi = bb[i] ?? 0;
1242
+ if (ai !== bi) return ai - bi;
1243
+ }
1244
+ return 0;
1245
+ }
1246
+ function shouldSkip() {
1247
+ if (process.env.HIGROWTH_NO_UPDATE_CHECK === "1") return true;
1248
+ if (process.env.CI) return true;
1249
+ if (!process.stdout.isTTY) return true;
1250
+ return false;
1251
+ }
1252
+ function beginUpdateCheck(currentVersion) {
1253
+ if (shouldSkip()) {
1254
+ return async () => {
1255
+ };
1256
+ }
1257
+ const cached = readCache();
1258
+ const fresh = cached && Date.now() - cached.fetchedAt < CHECK_INTERVAL_MS;
1259
+ const fetchPromise = fresh ? Promise.resolve(cached.latestVersion) : fetchLatestFromNpm().then((v) => {
1260
+ if (v) writeCache(v);
1261
+ return v;
1262
+ });
1263
+ return async () => {
1264
+ let latest;
1265
+ try {
1266
+ latest = await fetchPromise;
1267
+ } catch {
1268
+ return;
1269
+ }
1270
+ if (!latest) return;
1271
+ if (compareVersions(latest, currentVersion) <= 0) return;
1272
+ process.stderr.write(
1273
+ `
1274
+ \u2191 ${PKG_NAME2} ${latest} is available (you have ${currentVersion}).
1275
+ Upgrade: npm i -g ${PKG_NAME2}@latest
1276
+ (or bun add -g / pnpm add -g / yarn global add depending on how you installed.)
1277
+ Silence: set HIGROWTH_NO_UPDATE_CHECK=1
1278
+ `
1279
+ );
1280
+ };
1281
+ }
1282
+
1283
+ // package.json
1284
+ var package_default = {
1285
+ name: "@higrowth/cli",
1286
+ version: "0.3.0",
1287
+ description: "Higrowth CLI \u2014 log in via browser, install Claude Code / Codex skills, manage the MCP connection.",
1288
+ type: "module",
1289
+ license: "Apache-2.0",
1290
+ bin: {
1291
+ higrowth: "dist/index.js"
1292
+ },
1293
+ files: [
1294
+ "dist/",
1295
+ "README.md"
1296
+ ],
1297
+ scripts: {
1298
+ build: "tsup",
1299
+ dev: "tsup --watch",
1300
+ check: "tsc --noEmit"
1301
+ },
1302
+ engines: {
1303
+ node: ">=20"
1304
+ },
1305
+ publishConfig: {
1306
+ access: "public"
1307
+ },
1308
+ devDependencies: {
1309
+ "@types/iarna__toml": "^2.0.5",
1310
+ "@types/node": "^22.10.5",
1311
+ tsup: "^8.5.0",
1312
+ typescript: "^5.6.3"
1313
+ },
1314
+ keywords: ["higrowth", "seo", "aeo", "mcp", "claude-code", "agent"],
1315
+ homepage: "https://github.com/higrowth-ai/hg-engine",
1316
+ repository: {
1317
+ type: "git",
1318
+ url: "git+https://github.com/higrowth-ai/hg-engine.git",
1319
+ directory: "cli"
1320
+ },
1321
+ dependencies: {
1322
+ "@iarna/toml": "^2.2.5"
1323
+ }
1324
+ };
1325
+
1160
1326
  // src/index.ts
1161
- var VERSION = "0.1.1";
1327
+ var VERSION = package_default.version;
1162
1328
  var DEFAULT_HOST = "https://app.higrowth.ai";
1163
1329
  var USAGE = `higrowth \u2014 Connect your agent to a Higrowth workspace
1164
1330
 
@@ -1189,7 +1355,14 @@ COMMANDS
1189
1355
  skills update [--target TARGET]
1190
1356
  Re-install the bundled skill versions.
1191
1357
 
1192
- version
1358
+ upgrade
1359
+ Show the right command to upgrade @higrowth/cli to the latest
1360
+ published version, matched to your package manager (npm / pnpm /
1361
+ bun / yarn / curl-pipe). The CLI auto-checks for new versions on
1362
+ every invocation (cached 24h); set HIGROWTH_NO_UPDATE_CHECK=1 to
1363
+ silence the nudge.
1364
+
1365
+ version | --version | -v
1193
1366
  Print version + exit.
1194
1367
 
1195
1368
  FLAGS
@@ -1247,6 +1420,23 @@ function resolveTarget(raw) {
1247
1420
  }
1248
1421
  async function main() {
1249
1422
  const args = parseArgs(process.argv.slice(2));
1423
+ if (args.flags.version === true || args.flags.v === true) {
1424
+ process.stdout.write(`higrowth ${VERSION}
1425
+ `);
1426
+ return;
1427
+ }
1428
+ if (args.command === "" && (args.flags.help === true || args.flags.h === true)) {
1429
+ process.stdout.write(USAGE);
1430
+ return;
1431
+ }
1432
+ const showUpdateNotice = beginUpdateCheck(VERSION);
1433
+ try {
1434
+ await runCommand(args);
1435
+ } finally {
1436
+ await showUpdateNotice();
1437
+ }
1438
+ }
1439
+ async function runCommand(args) {
1250
1440
  const host = typeof args.flags.host === "string" ? args.flags.host : DEFAULT_HOST;
1251
1441
  const target = resolveTarget(args.flags.target);
1252
1442
  const device = args.flags.device === true;
@@ -1254,13 +1444,9 @@ async function main() {
1254
1444
  switch (args.command) {
1255
1445
  case "":
1256
1446
  case "help":
1257
- case "--help":
1258
- case "-h":
1259
1447
  process.stdout.write(USAGE);
1260
1448
  return;
1261
1449
  case "version":
1262
- case "--version":
1263
- case "-v":
1264
1450
  process.stdout.write(`higrowth ${VERSION}
1265
1451
  `);
1266
1452
  return;
@@ -1280,6 +1466,9 @@ async function main() {
1280
1466
  case "logout":
1281
1467
  await logoutCommand();
1282
1468
  return;
1469
+ case "upgrade":
1470
+ await upgradeCommand();
1471
+ return;
1283
1472
  case "skills":
1284
1473
  if (args.subcommand === "install" || args.subcommand === void 0) {
1285
1474
  await skillsInstallCommand({ target });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@higrowth/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Higrowth CLI — log in via browser, install Claude Code / Codex skills, manage the MCP connection.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",