@integrity-labs/agt-cli 0.15.36 → 0.15.37

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/dist/bin/agt.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  success,
49
49
  table,
50
50
  warn
51
- } from "../chunk-TPR5XCFY.js";
51
+ } from "../chunk-XB7IGF3K.js";
52
52
 
53
53
  // src/bin/agt.ts
54
54
  import { join as join10 } from "path";
@@ -3732,7 +3732,7 @@ import { execFileSync, execSync } from "child_process";
3732
3732
  import { existsSync as existsSync5, realpathSync } from "fs";
3733
3733
  import chalk17 from "chalk";
3734
3734
  import ora15 from "ora";
3735
- var cliVersion = true ? "0.15.36" : "dev";
3735
+ var cliVersion = true ? "0.15.37" : "dev";
3736
3736
  async function fetchLatestVersion() {
3737
3737
  const host2 = getHost();
3738
3738
  if (!host2) return null;
@@ -4181,7 +4181,7 @@ function handleError(err) {
4181
4181
  }
4182
4182
 
4183
4183
  // src/bin/agt.ts
4184
- var cliVersion2 = true ? "0.15.36" : "dev";
4184
+ var cliVersion2 = true ? "0.15.37" : "dev";
4185
4185
  var program = new Command();
4186
4186
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
4187
4187
  program.hook("preAction", (thisCommand) => {
@@ -7347,4 +7347,4 @@ export {
7347
7347
  managerInstallCommand,
7348
7348
  managerUninstallCommand
7349
7349
  };
7350
- //# sourceMappingURL=chunk-TPR5XCFY.js.map
7350
+ //# sourceMappingURL=chunk-XB7IGF3K.js.map
@@ -22,7 +22,7 @@ import {
22
22
  resolveChannels,
23
23
  resolveDmTarget,
24
24
  wrapScheduledTaskPrompt
25
- } from "../chunk-TPR5XCFY.js";
25
+ } from "../chunk-XB7IGF3K.js";
26
26
  import {
27
27
  findTaskByTemplate,
28
28
  getProjectDir,
@@ -1435,7 +1435,7 @@ function clearAgentCaches(agentId, codeName) {
1435
1435
  var cachedFrameworkVersion = null;
1436
1436
  var lastVersionCheckAt = 0;
1437
1437
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
1438
- var agtCliVersion = true ? "0.15.36" : "dev";
1438
+ var agtCliVersion = true ? "0.15.37" : "dev";
1439
1439
  function resolveBrewPath(execFileSync2) {
1440
1440
  try {
1441
1441
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -1658,18 +1658,35 @@ var restartAfterUpgrade = false;
1658
1658
  var pendingUpgradeVersion = null;
1659
1659
  async function checkAndUpdateCli() {
1660
1660
  const cliPath = process.argv[1] ?? "";
1661
- const isHomebrew = cliPath.includes("/Cellar/") || cliPath.includes("/homebrew/");
1662
1661
  const isDevMode = cliPath.includes("/src/") || cliPath.includes("tsx");
1663
1662
  if (isDevMode) return;
1664
- if (!isHomebrew && !cliPath.includes("node_modules")) return;
1665
- const { homedir: homedir4 } = await import("os");
1663
+ let resolvedPath = cliPath;
1664
+ try {
1665
+ const { realpathSync } = await import("fs");
1666
+ resolvedPath = realpathSync(cliPath);
1667
+ } catch {
1668
+ }
1669
+ const isBrewFormula = /\/Cellar\/[^/]+\//.test(resolvedPath);
1670
+ const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
1671
+ if (!isBrewFormula && !isNpmGlobal) return;
1666
1672
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
1667
- const markerPath = join3(homedir4(), ".augmented", ".last-update-check");
1673
+ const markerPath = join3(homedir3(), ".augmented", ".last-update-check");
1668
1674
  try {
1669
1675
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
1670
1676
  if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) return;
1671
1677
  } catch {
1672
1678
  }
1679
+ if (isBrewFormula) {
1680
+ await checkAndUpdateCliViaBrew();
1681
+ } else {
1682
+ await checkAndUpdateCliViaNpm();
1683
+ }
1684
+ try {
1685
+ writeF(markerPath, String(Date.now()));
1686
+ } catch {
1687
+ }
1688
+ }
1689
+ async function checkAndUpdateCliViaBrew() {
1673
1690
  const { execFileSync: execFileSync2 } = await import("child_process");
1674
1691
  let brewPath;
1675
1692
  try {
@@ -1692,7 +1709,7 @@ async function checkAndUpdateCli() {
1692
1709
  if (agtOutdated) {
1693
1710
  const installed = agtOutdated.installed_versions?.[0] ?? "unknown";
1694
1711
  const latest = agtOutdated.current_version ?? "unknown";
1695
- log(`[self-update] agt CLI update available: ${installed} \u2192 ${latest}. Upgrading...`);
1712
+ log(`[self-update] agt CLI update available: ${installed} \u2192 ${latest}. Upgrading via brew...`);
1696
1713
  try {
1697
1714
  execFileSync2(brewPath, ["upgrade", "integrity-labs/tap/agt"], {
1698
1715
  timeout: 12e4,
@@ -1702,19 +1719,84 @@ async function checkAndUpdateCli() {
1702
1719
  restartAfterUpgrade = true;
1703
1720
  pendingUpgradeVersion = latest;
1704
1721
  } catch (err) {
1705
- log(`[self-update] Upgrade failed: ${err.message}`);
1722
+ log(`[self-update] brew upgrade failed: ${err.message}`);
1706
1723
  }
1707
1724
  } else if (!selfUpdateUpToDateLogged) {
1708
- log(`[self-update] agt CLI is up to date`);
1725
+ log(`[self-update] agt CLI is up to date (brew, ${agtCliVersion})`);
1709
1726
  selfUpdateUpToDateLogged = true;
1710
1727
  }
1711
1728
  } catch (err) {
1712
1729
  log(`[self-update] brew outdated failed: ${err.message}`);
1713
1730
  }
1731
+ }
1732
+ async function checkAndUpdateCliViaNpm() {
1733
+ const { execFileSync: execFileSync2 } = await import("child_process");
1734
+ if (agtCliVersion === "dev") return;
1735
+ let latest;
1714
1736
  try {
1715
- writeF(markerPath, String(Date.now()));
1716
- } catch {
1737
+ const res = await fetch(
1738
+ "https://registry.npmjs.org/@integrity-labs/agt-cli/latest",
1739
+ {
1740
+ signal: AbortSignal.timeout(1e4),
1741
+ headers: { Accept: "application/json" }
1742
+ }
1743
+ );
1744
+ if (!res.ok) {
1745
+ log(`[self-update] npm registry returned ${res.status}`);
1746
+ return;
1747
+ }
1748
+ const body = await res.json();
1749
+ if (!body.version) {
1750
+ log(`[self-update] npm registry response missing version field`);
1751
+ return;
1752
+ }
1753
+ latest = body.version;
1754
+ } catch (err) {
1755
+ log(`[self-update] npm registry fetch failed: ${err.message}`);
1756
+ return;
1757
+ }
1758
+ if (!isNewerSemver(agtCliVersion, latest)) {
1759
+ if (!selfUpdateUpToDateLogged) {
1760
+ log(`[self-update] agt CLI is up to date (npm, ${agtCliVersion})`);
1761
+ selfUpdateUpToDateLogged = true;
1762
+ }
1763
+ return;
1717
1764
  }
1765
+ log(`[self-update] agt CLI update available: ${agtCliVersion} \u2192 ${latest}. Upgrading via npm...`);
1766
+ const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
1767
+ const cmd = isRoot ? "npm" : "sudo";
1768
+ const args = isRoot ? [
1769
+ "install",
1770
+ "-g",
1771
+ `@integrity-labs/agt-cli@${latest}`,
1772
+ "--registry=https://registry.npmjs.org"
1773
+ ] : [
1774
+ "-n",
1775
+ "npm",
1776
+ "install",
1777
+ "-g",
1778
+ `@integrity-labs/agt-cli@${latest}`,
1779
+ "--registry=https://registry.npmjs.org"
1780
+ ];
1781
+ try {
1782
+ execFileSync2(cmd, args, { timeout: 18e4, stdio: "pipe" });
1783
+ log(`[self-update] agt CLI upgraded to ${latest}. Scheduling manager restart so the new binary takes effect.`);
1784
+ restartAfterUpgrade = true;
1785
+ pendingUpgradeVersion = latest;
1786
+ } catch (err) {
1787
+ log(`[self-update] npm upgrade failed: ${err.message}`);
1788
+ }
1789
+ }
1790
+ function isNewerSemver(local, remote) {
1791
+ const parse = (v) => v.replace(/^v/, "").split(".").map(Number);
1792
+ const l = parse(local);
1793
+ const r = parse(remote);
1794
+ for (let i = 0; i < 3; i++) {
1795
+ const lv = l[i] ?? 0;
1796
+ const rv = r[i] ?? 0;
1797
+ if (rv !== lv) return rv > lv;
1798
+ }
1799
+ return false;
1718
1800
  }
1719
1801
  async function checkClaudeAuth() {
1720
1802
  try {