codex-copilot-dx 0.4.1 → 0.4.3

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/README.md CHANGED
@@ -27,10 +27,11 @@ npx codex-copilot-dx@latest
27
27
 
28
28
  On first run, it will:
29
29
  1. Authenticate with GitHub via device flow (if needed)
30
- 2. Start the adapter (port `2026`)
31
- 3. Configure Codex (`~/.codex/config.toml`) to use the adapter, including stale shell env base URLs if present
32
- 4. Configure Claude Code (`~/.claude/settings.json`) to use the adapter; it creates the file when missing, otherwise backs up `settings.json.bak` before updating the local API env keys
33
- 5. Launch Codex Desktop
30
+ 2. Print the local package version and warn when a newer npm release is available
31
+ 3. Start the adapter (port `2026`)
32
+ 4. Configure Codex (`~/.codex/config.toml`) to use the adapter, including stale shell env base URLs if present
33
+ 5. Configure Claude Code (`~/.claude/settings.json`) to use the adapter; it creates the file when missing, otherwise backs up `settings.json.bak` before updating the local API env keys
34
+ 6. Launch Codex Desktop
34
35
 
35
36
  Claude Code picks up the new `ANTHROPIC_BASE_URL` on its next launch.
36
37
 
package/bin/cli.mjs CHANGED
@@ -7,19 +7,33 @@ import { startAdapter } from "../src/adapter.mjs";
7
7
  import { refreshVSCodeVersion } from "../src/copilot.mjs";
8
8
  import { status } from "../src/status.mjs";
9
9
  import { printUsageSummary } from "../src/usage.mjs";
10
+ import { checkForUpdate, localPackageVersion } from "../src/version.mjs";
10
11
 
11
12
  const ADAPTER_PORT = parseInt(process.env.ADAPTER_PORT || "2026");
13
+ const LOCAL_VERSION = localPackageVersion();
14
+ const command = process.argv[2];
12
15
 
13
- if (process.argv[2] === "usage") {
16
+ if (command === "--version" || command === "-v" || command === "version") {
17
+ console.log(`codex-copilot-dx v${LOCAL_VERSION}`);
18
+ process.exit(0);
19
+ }
20
+
21
+ if (command === "usage") {
14
22
  await printUsageSummary();
15
23
  process.exit(0);
16
24
  }
17
25
 
18
26
  console.log(`
19
- codex-copilot-dx
27
+ codex-copilot-dx v${LOCAL_VERSION}
20
28
  Use Codex Desktop with GitHub Copilot
21
29
  `);
22
30
 
31
+ checkForUpdate({ currentVersion: LOCAL_VERSION }).then(({ latestVersion, updateAvailable }) => {
32
+ if (!updateAvailable) return;
33
+ console.log(`\n ${status("warn", `Update available: ${LOCAL_VERSION} -> ${latestVersion}`)}`);
34
+ console.log(" npm install -g codex-copilot-dx@latest\n");
35
+ });
36
+
23
37
  try {
24
38
  // Ensure GitHub login, using device flow if no token exists.
25
39
  await ensureAuth();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Use Codex Desktop app with your GitHub Copilot subscription",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,57 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const REGISTRY_LATEST_URL = "https://registry.npmjs.org/codex-copilot-dx/latest";
6
+
7
+ export function localPackageVersion() {
8
+ const here = path.dirname(fileURLToPath(import.meta.url));
9
+ const pkg = JSON.parse(fs.readFileSync(path.join(here, "..", "package.json"), "utf8"));
10
+ return pkg.version;
11
+ }
12
+
13
+ function parseVersion(version) {
14
+ return String(version || "")
15
+ .split(/[+-]/)[0]
16
+ .split(".")
17
+ .map((part) => Number.parseInt(part, 10) || 0);
18
+ }
19
+
20
+ export function isVersionGreater(a, b) {
21
+ const left = parseVersion(a);
22
+ const right = parseVersion(b);
23
+ const len = Math.max(left.length, right.length, 3);
24
+ for (let i = 0; i < len; i += 1) {
25
+ const diff = (left[i] || 0) - (right[i] || 0);
26
+ if (diff > 0) return true;
27
+ if (diff < 0) return false;
28
+ }
29
+ return false;
30
+ }
31
+
32
+ export async function fetchLatestVersion({ fetchImpl = fetch, timeoutMs = 2000 } = {}) {
33
+ const controller = new AbortController();
34
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
35
+ try {
36
+ const resp = await fetchImpl(REGISTRY_LATEST_URL, {
37
+ headers: { Accept: "application/json" },
38
+ signal: controller.signal,
39
+ });
40
+ if (!resp.ok) return null;
41
+ const data = await resp.json();
42
+ return typeof data.version === "string" ? data.version : null;
43
+ } catch {
44
+ return null;
45
+ } finally {
46
+ clearTimeout(timer);
47
+ }
48
+ }
49
+
50
+ export async function checkForUpdate({ currentVersion = localPackageVersion(), fetchImpl, timeoutMs } = {}) {
51
+ const latestVersion = await fetchLatestVersion({ fetchImpl, timeoutMs });
52
+ return {
53
+ currentVersion,
54
+ latestVersion,
55
+ updateAvailable: latestVersion ? isVersionGreater(latestVersion, currentVersion) : false,
56
+ };
57
+ }