ampcode-connector 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ampcode-connector",
3
- "version": "0.1.1",
4
- "description": "Proxy Amp CLI through local OAuth subscriptions (Claude Code, Codex, Gemini CLI, Antigravity)",
3
+ "version": "0.1.2",
4
+ "description": "Proxy AmpCode through local OAuth subscriptions (Claude Code, Codex, Gemini CLI, Antigravity)",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
package/src/index.ts CHANGED
@@ -42,6 +42,10 @@ async function main(): Promise<void> {
42
42
  const config = await loadConfig();
43
43
  setLogLevel(config.logLevel);
44
44
  startServer(config);
45
+
46
+ // Non-blocking update check — runs in background after server starts
47
+ const { checkForUpdates } = await import("./utils/update-check.ts");
48
+ checkForUpdates();
45
49
  }
46
50
 
47
51
  function usage(): void {
@@ -0,0 +1,46 @@
1
+ /** Check npm registry for newer versions on startup. */
2
+
3
+ import { s, line } from "../cli/ansi.ts";
4
+
5
+ const PACKAGE_NAME = "ampcode-connector";
6
+ const REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
7
+ const TIMEOUT_MS = 3_000;
8
+
9
+ function currentVersion(): string {
10
+ // Read from package.json at import time
11
+ const pkg = require("../../package.json");
12
+ return pkg.version;
13
+ }
14
+
15
+ async function fetchLatestVersion(): Promise<string | null> {
16
+ try {
17
+ const res = await fetch(REGISTRY_URL, {
18
+ signal: AbortSignal.timeout(TIMEOUT_MS),
19
+ });
20
+ if (!res.ok) return null;
21
+ const data = (await res.json()) as { version: string };
22
+ return data.version;
23
+ } catch {
24
+ return null;
25
+ }
26
+ }
27
+
28
+ function isNewer(latest: string, current: string): boolean {
29
+ const parse = (v: string) => v.split(".").map(Number);
30
+ const [la, lb, lc] = parse(latest);
31
+ const [ca, cb, cc] = parse(current);
32
+ return la > ca || (la === ca && lb > cb) || (la === ca && lb === cb && lc > cc);
33
+ }
34
+
35
+ /** Non-blocking update check — logs a notice if a newer version exists. */
36
+ export async function checkForUpdates(): Promise<void> {
37
+ const current = currentVersion();
38
+ const latest = await fetchLatestVersion();
39
+
40
+ if (!latest || !isNewer(latest, current)) return;
41
+
42
+ line();
43
+ line(`${s.yellow}⬆ Update available${s.reset} ${s.dim}${current}${s.reset} → ${s.green}${latest}${s.reset}`);
44
+ line(` Run ${s.cyan}bunx ampcode-connector@latest${s.reset} to update`);
45
+ line();
46
+ }