@just-every/code 0.2.41 → 0.2.43
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/bin/coder.js +32 -0
- package/package.json +6 -6
- package/postinstall.js +32 -25
package/bin/coder.js
CHANGED
|
@@ -10,6 +10,10 @@ const __dirname = path.dirname(__filename);
|
|
|
10
10
|
|
|
11
11
|
const { platform, arch } = process;
|
|
12
12
|
|
|
13
|
+
// Important: Never delegate to another system's `code` binary (e.g., VS Code).
|
|
14
|
+
// When users run via `npx @just-every/code`, we must always execute our
|
|
15
|
+
// packaged native binary by absolute path to avoid PATH collisions.
|
|
16
|
+
|
|
13
17
|
const isWSL = () => {
|
|
14
18
|
if (platform !== "linux") return false;
|
|
15
19
|
try {
|
|
@@ -78,6 +82,7 @@ if (!existsSync(binaryPath)) {
|
|
|
78
82
|
|
|
79
83
|
// Check if binary exists and try to fix permissions if needed
|
|
80
84
|
import { existsSync, chmodSync, statSync, openSync, readSync, closeSync } from "fs";
|
|
85
|
+
import { spawnSync } from "child_process";
|
|
81
86
|
if (existsSync(binaryPath)) {
|
|
82
87
|
try {
|
|
83
88
|
// Ensure binary is executable on Unix-like systems
|
|
@@ -148,6 +153,33 @@ if (!validation.ok) {
|
|
|
148
153
|
process.exit(1);
|
|
149
154
|
}
|
|
150
155
|
|
|
156
|
+
// If running under npx/npm, emit a concise notice about which binary path is used
|
|
157
|
+
try {
|
|
158
|
+
const ua = process.env.npm_config_user_agent || "";
|
|
159
|
+
const isNpx = ua.includes("npx");
|
|
160
|
+
if (isNpx && process.stderr && process.stderr.isTTY) {
|
|
161
|
+
// Best-effort discovery of another 'code' on PATH for user clarity
|
|
162
|
+
let otherCode = "";
|
|
163
|
+
try {
|
|
164
|
+
const cmd = process.platform === "win32" ? "where code" : "command -v code || which code || true";
|
|
165
|
+
const out = spawnSync(process.platform === "win32" ? "cmd" : "bash", [
|
|
166
|
+
process.platform === "win32" ? "/c" : "-lc",
|
|
167
|
+
cmd,
|
|
168
|
+
], { encoding: "utf8" });
|
|
169
|
+
const line = (out.stdout || "").split(/\r?\n/).map((s) => s.trim()).filter(Boolean)[0];
|
|
170
|
+
if (line && !line.includes("@just-every/code")) {
|
|
171
|
+
otherCode = line;
|
|
172
|
+
}
|
|
173
|
+
} catch {}
|
|
174
|
+
if (otherCode) {
|
|
175
|
+
console.error(`@just-every/code: running bundled binary -> ${binaryPath}`);
|
|
176
|
+
console.error(`Note: a different 'code' exists at ${otherCode}; not delegating.`);
|
|
177
|
+
} else {
|
|
178
|
+
console.error(`@just-every/code: running bundled binary -> ${binaryPath}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
} catch {}
|
|
182
|
+
|
|
151
183
|
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
152
184
|
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
153
185
|
// executing. This allows us to forward those signals to the child process
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@just-every/code",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43",
|
|
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.
|
|
39
|
-
"@just-every/code-darwin-x64": "0.2.
|
|
40
|
-
"@just-every/code-linux-x64-musl": "0.2.
|
|
41
|
-
"@just-every/code-linux-arm64-musl": "0.2.
|
|
42
|
-
"@just-every/code-win32-x64": "0.2.
|
|
38
|
+
"@just-every/code-darwin-arm64": "0.2.43",
|
|
39
|
+
"@just-every/code-darwin-x64": "0.2.43",
|
|
40
|
+
"@just-every/code-linux-x64-musl": "0.2.43",
|
|
41
|
+
"@just-every/code-linux-arm64-musl": "0.2.43",
|
|
42
|
+
"@just-every/code-win32-x64": "0.2.43"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/postinstall.js
CHANGED
|
@@ -364,20 +364,32 @@ async function main() {
|
|
|
364
364
|
|
|
365
365
|
const ourShim = join(globalBin || '', isWindows ? 'code.cmd' : 'code');
|
|
366
366
|
|
|
367
|
-
// Resolve
|
|
368
|
-
|
|
367
|
+
// Resolve all 'code' candidates on PATH (so we detect collisions even if
|
|
368
|
+
// our npm global bin currently appears first).
|
|
369
|
+
const resolveAllOnPath = () => {
|
|
369
370
|
try {
|
|
370
371
|
if (isWindows) {
|
|
371
|
-
const out = execSync(
|
|
372
|
-
return out
|
|
373
|
-
}
|
|
374
|
-
|
|
372
|
+
const out = execSync('where code', { stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
373
|
+
return out.split(/\r?\n/).map(s => s.trim()).filter(Boolean);
|
|
374
|
+
}
|
|
375
|
+
// Prefer 'which -a' if available; fall back to 'command -v'
|
|
376
|
+
let out = '';
|
|
377
|
+
try {
|
|
378
|
+
out = execSync('bash -lc "which -a code 2>/dev/null"', { stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
379
|
+
} catch {
|
|
380
|
+
try {
|
|
381
|
+
out = execSync('command -v code || true', { stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
382
|
+
} catch { out = ''; }
|
|
375
383
|
}
|
|
376
|
-
|
|
384
|
+
return out.split(/\r?\n/).map(s => s.trim()).filter(Boolean);
|
|
385
|
+
} catch {
|
|
386
|
+
return [];
|
|
387
|
+
}
|
|
377
388
|
};
|
|
378
389
|
|
|
379
|
-
const
|
|
380
|
-
const
|
|
390
|
+
const candidates = resolveAllOnPath();
|
|
391
|
+
const others = candidates.filter(p => p && ourShim && p !== ourShim);
|
|
392
|
+
const collision = others.length > 0;
|
|
381
393
|
|
|
382
394
|
const ensureWrapper = (name, args) => {
|
|
383
395
|
if (!globalBin) return;
|
|
@@ -402,26 +414,22 @@ async function main() {
|
|
|
402
414
|
ensureWrapper('code-exec', 'exec');
|
|
403
415
|
|
|
404
416
|
if (collision) {
|
|
405
|
-
console.log('⚠ Detected
|
|
417
|
+
console.log('⚠ Detected existing `code` on PATH:');
|
|
418
|
+
for (const p of others) console.log(` - ${p}`);
|
|
406
419
|
if (globalBin) {
|
|
407
|
-
//
|
|
420
|
+
// Remove our global `code` shim to avoid shadowing editors like VS Code
|
|
408
421
|
try {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
writeFileSync(coderShim, content);
|
|
413
|
-
} else {
|
|
414
|
-
const content = `#!/bin/sh\nexec "$(dirname \"$0\")/code" "$@"\n`;
|
|
415
|
-
writeFileSync(coderShim, content);
|
|
416
|
-
chmodSync(coderShim, 0o755);
|
|
422
|
+
if (existsSync(ourShim)) {
|
|
423
|
+
unlinkSync(ourShim);
|
|
424
|
+
console.log(`✓ Skipped global 'code' shim (removed ${ourShim})`);
|
|
417
425
|
}
|
|
418
|
-
console.log(`✓ Created fallback command \`coder\` -> our \`code\``);
|
|
419
426
|
} catch (e) {
|
|
420
|
-
console.log(`⚠
|
|
427
|
+
console.log(`⚠ Could not remove npm shim '${ourShim}': ${e.message}`);
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
// Offer to create a 'vscode' alias that points to the existing system VS Code
|
|
424
|
-
|
|
431
|
+
const primaryOther = others[0];
|
|
432
|
+
if (isTTY && primaryOther) {
|
|
425
433
|
const prompt = (msg) => {
|
|
426
434
|
process.stdout.write(msg);
|
|
427
435
|
try {
|
|
@@ -436,10 +444,10 @@ async function main() {
|
|
|
436
444
|
try {
|
|
437
445
|
const vscodeShim = join(globalBin, isWindows ? 'vscode.cmd' : 'vscode');
|
|
438
446
|
if (isWindows) {
|
|
439
|
-
const content = `@echo off\r\n"${
|
|
447
|
+
const content = `@echo off\r\n"${primaryOther}" %*\r\n`;
|
|
440
448
|
writeFileSync(vscodeShim, content);
|
|
441
449
|
} else {
|
|
442
|
-
const content = `#!/bin/sh\nexec "${
|
|
450
|
+
const content = `#!/bin/sh\nexec "${primaryOther}" "$@"\n`;
|
|
443
451
|
writeFileSync(vscodeShim, content);
|
|
444
452
|
chmodSync(vscodeShim, 0o755);
|
|
445
453
|
}
|
|
@@ -451,7 +459,6 @@ async function main() {
|
|
|
451
459
|
console.log('Skipping creation of `vscode` alias.');
|
|
452
460
|
}
|
|
453
461
|
}
|
|
454
|
-
|
|
455
462
|
console.log('→ Use `coder` to run this tool, and `vscode` (if created) for your editor.');
|
|
456
463
|
} else {
|
|
457
464
|
console.log('Note: could not determine npm global bin; skipping alias creation.');
|