@cabane/companion 0.6.160 → 0.6.162
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/dist/cli.js +7138 -7459
- package/dist/launch.js +40 -54
- package/dist/pairing-config.js +70 -158
- package/dist/postinstall.js +17 -83
- package/dist/runtime.js +1902 -2138
- package/dist/static/app.js +5 -53
- package/package.json +2 -2
package/dist/postinstall.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// src/bundled-binaries.ts
|
|
2
2
|
import { realpathSync as realpathSync3, statSync } from "fs";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
|
-
import { dirname as dirname3, join as
|
|
4
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
5
5
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
6
6
|
|
|
7
7
|
// src/cabane-command.ts
|
|
8
8
|
import { accessSync, constants, realpathSync as realpathSync2 } from "fs";
|
|
9
|
-
import { homedir as
|
|
10
|
-
import { basename, delimiter, dirname as dirname2, join as
|
|
9
|
+
import { homedir as homedir4 } from "os";
|
|
10
|
+
import { basename as basename2, delimiter, dirname as dirname2, join as join3, sep as sep2 } from "path";
|
|
11
11
|
|
|
12
12
|
// src/install-kind.ts
|
|
13
13
|
import { realpathSync } from "fs";
|
|
@@ -41,86 +41,20 @@ function ownRoot() {
|
|
|
41
41
|
// src/cli-entry.ts
|
|
42
42
|
import { existsSync } from "fs";
|
|
43
43
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
44
|
-
var RELATIVE_CANDIDATES = ["./cli.js", "../dist/cli.js", "../cli.js"];
|
|
45
|
-
function companionCliEntry(deps = {}) {
|
|
46
|
-
const exists = deps.exists ?? existsSync;
|
|
47
|
-
const candidates = deps.candidates ?? RELATIVE_CANDIDATES.map((rel) => fileURLToPath2(new URL(rel, import.meta.url)));
|
|
48
|
-
for (const candidate of candidates) {
|
|
49
|
-
if (exists(candidate)) return candidate;
|
|
50
|
-
}
|
|
51
|
-
const argv1 = "argv1" in deps ? deps.argv1 : process.argv[1];
|
|
52
|
-
if (argv1 && exists(argv1)) return argv1;
|
|
53
|
-
return candidates[0] ?? "";
|
|
54
|
-
}
|
|
55
44
|
|
|
56
|
-
// src/
|
|
57
|
-
import {
|
|
45
|
+
// src/install-record.ts
|
|
46
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
58
47
|
import { homedir as homedir2 } from "os";
|
|
48
|
+
import { basename, join as join2 } from "path";
|
|
49
|
+
|
|
50
|
+
// src/term.ts
|
|
51
|
+
import { homedir as homedir3 } from "os";
|
|
59
52
|
import pc from "picocolors";
|
|
60
|
-
function tildePath(path, home = homedir2()) {
|
|
61
|
-
if (home && path.startsWith(home + "/")) return `~${path.slice(home.length)}`;
|
|
62
|
-
return path;
|
|
63
|
-
}
|
|
64
53
|
|
|
65
54
|
// src/cabane-command.ts
|
|
66
|
-
var INVOKED_COMMAND_ENV = "CABANE_INVOKED_COMMAND";
|
|
67
55
|
var VERSIONS_SEGMENT = `${sep2}.cabane${sep2}versions${sep2}`;
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
const home = deps.home ?? homedir3();
|
|
71
|
-
if (install === "script") return join2(home, ".cabane", "bin", "cabane");
|
|
72
|
-
const entry = deps.cliEntry ?? companionCliEntry();
|
|
73
|
-
const own = npmBinFor(entry);
|
|
74
|
-
if (own) return own;
|
|
75
|
-
if (!entry.includes(VERSIONS_SEGMENT)) return null;
|
|
76
|
-
const isExecutable = deps.isExecutable ?? executable;
|
|
77
|
-
const invoked = "invoked" in deps ? deps.invoked : process.env[INVOKED_COMMAND_ENV];
|
|
78
|
-
if (invoked && isExecutable(invoked)) return invoked;
|
|
79
|
-
const besideNode = join2(dirname2(dirname2(deps.execPath ?? process.execPath)), "bin", "cabane");
|
|
80
|
-
return isExecutable(besideNode) ? besideNode : null;
|
|
81
|
-
}
|
|
82
|
-
function npmBinFor(path) {
|
|
83
|
-
const marker = `${sep2}lib${sep2}node_modules${sep2}@cabane${sep2}companion${sep2}`;
|
|
84
|
-
const at = path.indexOf(marker);
|
|
85
|
-
if (at < 0) return null;
|
|
86
|
-
return join2(path.slice(0, at), "bin", "cabane");
|
|
87
|
-
}
|
|
88
|
-
function cabaneCommand(deps = {}) {
|
|
89
|
-
const own = installedCommandPath(deps);
|
|
90
|
-
if (!own) return "cabane";
|
|
91
|
-
const realpath = deps.realpath ?? safeRealpath;
|
|
92
|
-
const isExecutable = deps.isExecutable ?? executable;
|
|
93
|
-
const ownReal = realpath(own);
|
|
94
|
-
if (!ownReal) return "cabane";
|
|
95
|
-
const onPath = firstOnPath("cabane", "path" in deps ? deps.path : process.env.PATH, isExecutable);
|
|
96
|
-
if (onPath && realpath(onPath) === ownReal) return "cabane";
|
|
97
|
-
return tildePath(own, deps.home);
|
|
98
|
-
}
|
|
99
|
-
function cabane(rest, deps) {
|
|
100
|
-
return `${cabaneCommand(deps)} ${rest}`;
|
|
101
|
-
}
|
|
102
|
-
function firstOnPath(name, path, isExecutable = executable) {
|
|
103
|
-
for (const dir of (path ?? "").split(delimiter)) {
|
|
104
|
-
if (!dir) continue;
|
|
105
|
-
const candidate = join2(dir, name);
|
|
106
|
-
if (isExecutable(candidate)) return candidate;
|
|
107
|
-
}
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
function executable(path) {
|
|
111
|
-
try {
|
|
112
|
-
accessSync(path, constants.X_OK);
|
|
113
|
-
return true;
|
|
114
|
-
} catch {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function safeRealpath(path) {
|
|
119
|
-
try {
|
|
120
|
-
return realpathSync2(path);
|
|
121
|
-
} catch {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
56
|
+
function cabane(rest) {
|
|
57
|
+
return `cabane ${rest}`;
|
|
124
58
|
}
|
|
125
59
|
|
|
126
60
|
// src/bundled-binaries.ts
|
|
@@ -141,7 +75,7 @@ function nodeResolveSelf(specifier) {
|
|
|
141
75
|
function walkNodeModules(pkg, fromPath) {
|
|
142
76
|
let dir = dirname3(fromPath);
|
|
143
77
|
for (; ; ) {
|
|
144
|
-
const manifest =
|
|
78
|
+
const manifest = join4(dir, "node_modules", pkg, "package.json");
|
|
145
79
|
if (nodeIsFile(manifest)) {
|
|
146
80
|
try {
|
|
147
81
|
return realpathSync3(manifest);
|
|
@@ -211,7 +145,7 @@ function resolveClaude(env) {
|
|
|
211
145
|
const manifest = env.resolve(`${pkg}/package.json`, sdkEntry);
|
|
212
146
|
if (!manifest) continue;
|
|
213
147
|
sawPackage ??= pkg;
|
|
214
|
-
const exe =
|
|
148
|
+
const exe = join4(dirname3(manifest), env.platform === "win32" ? "claude.exe" : "claude");
|
|
215
149
|
if (env.isFile(exe)) {
|
|
216
150
|
return { ...base, packageName: pkg, status: "present", path: exe };
|
|
217
151
|
}
|
|
@@ -262,13 +196,13 @@ function resolveCodex(env) {
|
|
|
262
196
|
if (!cliManifest) return { ...base, status: "platform_package_missing", path: null };
|
|
263
197
|
const platformManifest = env.resolve(`${pkg}/package.json`, cliManifest);
|
|
264
198
|
if (!platformManifest) return { ...base, status: "platform_package_missing", path: null };
|
|
265
|
-
const packageRoot =
|
|
199
|
+
const packageRoot = join4(dirname3(platformManifest), "vendor", triple);
|
|
266
200
|
const exeName = env.platform === "win32" ? "codex.exe" : "codex";
|
|
267
|
-
const current =
|
|
268
|
-
if (env.isFile(current) && env.isFile(
|
|
201
|
+
const current = join4(packageRoot, "bin", exeName);
|
|
202
|
+
if (env.isFile(current) && env.isFile(join4(packageRoot, "codex-package.json"))) {
|
|
269
203
|
return { ...base, status: "present", path: current };
|
|
270
204
|
}
|
|
271
|
-
const legacy =
|
|
205
|
+
const legacy = join4(packageRoot, "codex", exeName);
|
|
272
206
|
if (env.isFile(legacy)) return { ...base, status: "present", path: legacy };
|
|
273
207
|
return { ...base, status: "executable_missing", path: null };
|
|
274
208
|
}
|