codex-copilot-dx 0.4.1 → 0.4.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/README.md +5 -4
- package/bin/cli.mjs +9 -1
- package/package.json +1 -1
- package/src/version.mjs +57 -0
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.
|
|
31
|
-
3.
|
|
32
|
-
4. Configure
|
|
33
|
-
5.
|
|
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,8 +7,10 @@ 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();
|
|
12
14
|
|
|
13
15
|
if (process.argv[2] === "usage") {
|
|
14
16
|
await printUsageSummary();
|
|
@@ -16,10 +18,16 @@ if (process.argv[2] === "usage") {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
console.log(`
|
|
19
|
-
codex-copilot-dx
|
|
21
|
+
codex-copilot-dx v${LOCAL_VERSION}
|
|
20
22
|
Use Codex Desktop with GitHub Copilot
|
|
21
23
|
`);
|
|
22
24
|
|
|
25
|
+
checkForUpdate({ currentVersion: LOCAL_VERSION }).then(({ latestVersion, updateAvailable }) => {
|
|
26
|
+
if (!updateAvailable) return;
|
|
27
|
+
console.log(`\n ${status("warn", `Update available: ${LOCAL_VERSION} -> ${latestVersion}`)}`);
|
|
28
|
+
console.log(" npm install -g codex-copilot-dx@latest\n");
|
|
29
|
+
});
|
|
30
|
+
|
|
23
31
|
try {
|
|
24
32
|
// Ensure GitHub login, using device flow if no token exists.
|
|
25
33
|
await ensureAuth();
|
package/package.json
CHANGED
package/src/version.mjs
ADDED
|
@@ -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
|
+
}
|