agent-limit 0.6.2 → 0.7.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/bin/cli.tsx +41 -0
  2. package/package.json +1 -1
package/bin/cli.tsx CHANGED
@@ -27,6 +27,46 @@ if (command === "usage") {
27
27
  } else if (command === "version" || command === "--version" || command === "-v") {
28
28
  const pkg = await import("../package.json");
29
29
  console.log(pkg.version);
30
+ } else if (command === "update") {
31
+ const pkg = await import("../package.json");
32
+ const currentVersion = pkg.version;
33
+
34
+ console.log(`Current version: ${currentVersion}`);
35
+ console.log("Checking for updates...");
36
+
37
+ try {
38
+ const response = await fetch("https://registry.npmjs.org/agent-limit/latest");
39
+ if (!response.ok) {
40
+ throw new Error(`Failed to fetch: ${response.status}`);
41
+ }
42
+ const data = await response.json() as { version: string };
43
+ const latestVersion = data.version;
44
+
45
+ if (latestVersion === currentVersion) {
46
+ console.log(`✓ You're on the latest version (${currentVersion})`);
47
+ } else {
48
+ console.log(`New version available: ${latestVersion}`);
49
+ console.log("\nUpdating...");
50
+
51
+ const proc = Bun.spawn(["npm", "install", "-g", "agent-limit@latest"], {
52
+ stdout: "inherit",
53
+ stderr: "inherit",
54
+ });
55
+
56
+ const exitCode = await proc.exited;
57
+
58
+ if (exitCode === 0) {
59
+ console.log(`\n✓ Updated to ${latestVersion}`);
60
+ } else {
61
+ console.error("\n✗ Update failed. Try running manually:");
62
+ console.error(" npm install -g agent-limit@latest");
63
+ process.exit(1);
64
+ }
65
+ }
66
+ } catch (error) {
67
+ console.error("Failed to check for updates:", error instanceof Error ? error.message : error);
68
+ process.exit(1);
69
+ }
30
70
  } else if (command === "help" || command === "--help" || command === "-h" || !command) {
31
71
  console.log(`
32
72
  agent-limit
@@ -41,6 +81,7 @@ Quick Start:
41
81
 
42
82
  CLI:
43
83
  agent-limit usage Show usage dashboard
84
+ agent-limit update Update to latest version
44
85
  agent-limit version Show version
45
86
  agent-limit help Show this help message
46
87
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-limit",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Terminal dashboard to monitor Claude Code, Codex, and other agent usage limits",
5
5
  "type": "module",
6
6
  "main": "src/index.tsx",