@just-every/code 0.2.40 → 0.2.42

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/coder.js +52 -0
  2. package/package.json +6 -6
package/bin/coder.js CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  import path from "path";
5
5
  import { fileURLToPath } from "url";
6
+ import { realpathSync, accessSync, constants } from "fs";
7
+ import { spawnSync } from "child_process";
6
8
 
7
9
  // __dirname equivalent in ESM
8
10
  const __filename = fileURLToPath(import.meta.url);
@@ -10,6 +12,56 @@ const __dirname = path.dirname(__filename);
10
12
 
11
13
  const { platform, arch } = process;
12
14
 
15
+ // If invoked as "code" and another "code" exists in PATH that is not
16
+ // this package's launcher, delegate to it (e.g., VS Code's CLI).
17
+ // This avoids hijacking users who already have VS Code installed.
18
+ const maybeDelegateToOtherCode = () => {
19
+ try {
20
+ const invoked = process.env._ || "";
21
+ const invokedBase = path.basename(invoked);
22
+ if (invokedBase !== "code") return false;
23
+
24
+ const ourScriptReal = realpathSync(process.argv[1]);
25
+
26
+ const which = spawnSync("bash", ["-lc", "which -a code 2>/dev/null"], {
27
+ encoding: "utf8",
28
+ stdio: ["ignore", "pipe", "ignore"],
29
+ });
30
+ if (which.status !== 0 || !which.stdout) return false;
31
+
32
+ const candidates = which.stdout
33
+ .split(/\r?\n/)
34
+ .map((s) => s.trim())
35
+ .filter(Boolean);
36
+
37
+ for (const c of candidates) {
38
+ // Skip the path that was used to invoke us
39
+ if (c === invoked) continue;
40
+ try {
41
+ const real = realpathSync(c);
42
+ // Skip if it resolves to our own script (same file inside our package)
43
+ if (real === ourScriptReal) continue;
44
+
45
+ // Ensure it's executable; if so, exec and mirror exit code
46
+ accessSync(c, constants.X_OK);
47
+ const run = spawnSync(c, process.argv.slice(2), {
48
+ stdio: "inherit",
49
+ });
50
+ // If it executed (even with non-zero), we consider delegation done.
51
+ const code = run.status == null ? 1 : run.status;
52
+ process.exit(code);
53
+ } catch {
54
+ // Try next candidate
55
+ }
56
+ }
57
+ } catch {
58
+ // Fall through to our own binary
59
+ }
60
+ return false;
61
+ };
62
+
63
+ maybeDelegateToOtherCode();
64
+
13
65
  const isWSL = () => {
14
66
  if (platform !== "linux") return false;
15
67
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-every/code",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lightweight coding agent that runs in your terminal - fork of OpenAI Codex",
6
6
  "bin": {
@@ -35,10 +35,10 @@
35
35
  "prettier": "^3.3.3"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@just-every/code-darwin-arm64": "0.2.40",
39
- "@just-every/code-darwin-x64": "0.2.40",
40
- "@just-every/code-linux-x64-musl": "0.2.40",
41
- "@just-every/code-linux-arm64-musl": "0.2.40",
42
- "@just-every/code-win32-x64": "0.2.40"
38
+ "@just-every/code-darwin-arm64": "0.2.42",
39
+ "@just-every/code-darwin-x64": "0.2.42",
40
+ "@just-every/code-linux-x64-musl": "0.2.42",
41
+ "@just-every/code-linux-arm64-musl": "0.2.42",
42
+ "@just-every/code-win32-x64": "0.2.42"
43
43
  }
44
44
  }