@cabane/companion 0.6.159 → 0.6.161

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.
@@ -1,14 +1,68 @@
1
1
  // src/bundled-binaries.ts
2
- import { realpathSync, statSync } from "fs";
2
+ import { realpathSync as realpathSync3, statSync } from "fs";
3
3
  import { createRequire } from "module";
4
+ import { dirname as dirname3, join as join4 } from "path";
5
+ import { fileURLToPath as fileURLToPath3 } from "url";
6
+
7
+ // src/cabane-command.ts
8
+ import { accessSync, constants, realpathSync as realpathSync2 } from "fs";
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
+
12
+ // src/install-kind.ts
13
+ import { realpathSync } from "fs";
4
14
  import { homedir } from "os";
5
15
  import { dirname, join, sep } from "path";
6
16
  import { fileURLToPath } from "url";
17
+ var INSTALL_SCRIPT_COMMAND = "curl -fsSL https://cabane.ai/install.sh | bash";
18
+ function companionInstall(execPath = process.execPath, home = homedir()) {
19
+ const real = (path) => {
20
+ try {
21
+ return realpathSync(path);
22
+ } catch {
23
+ return path;
24
+ }
25
+ };
26
+ const scriptNode = join(real(home), ".cabane", "node") + sep;
27
+ return real(execPath).startsWith(scriptNode) ? "script" : "npm";
28
+ }
29
+ function repairRoute(packageRoot = ownRoot(), install = companionInstall()) {
30
+ let root = packageRoot;
31
+ try {
32
+ root = realpathSync(packageRoot);
33
+ } catch {
34
+ }
35
+ return root.includes(`${sep}.cabane${sep}versions${sep}`) ? "managed" : install;
36
+ }
37
+ function ownRoot() {
38
+ return dirname(dirname(fileURLToPath(import.meta.url)));
39
+ }
40
+
41
+ // src/cli-entry.ts
42
+ import { existsSync } from "fs";
43
+ import { fileURLToPath as fileURLToPath2 } from "url";
44
+
45
+ // src/install-record.ts
46
+ import { existsSync as existsSync2, readFileSync } from "fs";
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";
52
+ import pc from "picocolors";
53
+
54
+ // src/cabane-command.ts
55
+ var VERSIONS_SEGMENT = `${sep2}.cabane${sep2}versions${sep2}`;
56
+ function cabane(rest) {
57
+ return `cabane ${rest}`;
58
+ }
59
+
60
+ // src/bundled-binaries.ts
7
61
  function nodeResolveSelf(specifier) {
8
- const here = fileURLToPath(import.meta.url);
62
+ const here = fileURLToPath3(import.meta.url);
9
63
  if (typeof import.meta.resolve === "function") {
10
64
  try {
11
- return fileURLToPath(import.meta.resolve(specifier));
65
+ return fileURLToPath3(import.meta.resolve(specifier));
12
66
  } catch {
13
67
  }
14
68
  }
@@ -19,17 +73,17 @@ function nodeResolveSelf(specifier) {
19
73
  return walkNodeModules(specifier, here);
20
74
  }
21
75
  function walkNodeModules(pkg, fromPath) {
22
- let dir = dirname(fromPath);
76
+ let dir = dirname3(fromPath);
23
77
  for (; ; ) {
24
- const manifest = join(dir, "node_modules", pkg, "package.json");
78
+ const manifest = join4(dir, "node_modules", pkg, "package.json");
25
79
  if (nodeIsFile(manifest)) {
26
80
  try {
27
- return realpathSync(manifest);
81
+ return realpathSync3(manifest);
28
82
  } catch {
29
83
  return manifest;
30
84
  }
31
85
  }
32
- const parent = dirname(dir);
86
+ const parent = dirname3(dir);
33
87
  if (parent === dir) return null;
34
88
  dir = parent;
35
89
  }
@@ -91,7 +145,7 @@ function resolveClaude(env) {
91
145
  const manifest = env.resolve(`${pkg}/package.json`, sdkEntry);
92
146
  if (!manifest) continue;
93
147
  sawPackage ??= pkg;
94
- const exe = join(dirname(manifest), env.platform === "win32" ? "claude.exe" : "claude");
148
+ const exe = join4(dirname3(manifest), env.platform === "win32" ? "claude.exe" : "claude");
95
149
  if (env.isFile(exe)) {
96
150
  return { ...base, packageName: pkg, status: "present", path: exe };
97
151
  }
@@ -142,13 +196,13 @@ function resolveCodex(env) {
142
196
  if (!cliManifest) return { ...base, status: "platform_package_missing", path: null };
143
197
  const platformManifest = env.resolve(`${pkg}/package.json`, cliManifest);
144
198
  if (!platformManifest) return { ...base, status: "platform_package_missing", path: null };
145
- const packageRoot = join(dirname(platformManifest), "vendor", triple);
199
+ const packageRoot = join4(dirname3(platformManifest), "vendor", triple);
146
200
  const exeName = env.platform === "win32" ? "codex.exe" : "codex";
147
- const current = join(packageRoot, "bin", exeName);
148
- if (env.isFile(current) && env.isFile(join(packageRoot, "codex-package.json"))) {
201
+ const current = join4(packageRoot, "bin", exeName);
202
+ if (env.isFile(current) && env.isFile(join4(packageRoot, "codex-package.json"))) {
149
203
  return { ...base, status: "present", path: current };
150
204
  }
151
- const legacy = join(packageRoot, "codex", exeName);
205
+ const legacy = join4(packageRoot, "codex", exeName);
152
206
  if (env.isFile(legacy)) return { ...base, status: "present", path: legacy };
153
207
  return { ...base, status: "executable_missing", path: null };
154
208
  }
@@ -179,24 +233,17 @@ var HARNESS_LABEL = {
179
233
  function missingNoun(status) {
180
234
  return status === "executable_missing" ? "executable" : "platform package";
181
235
  }
182
- var INSTALL_SCRIPT_COMMAND = "curl -fsSL https://cabane.ai/install.sh | bash";
183
- function companionInstall(execPath = process.execPath, home = homedir()) {
184
- const real = (path) => {
185
- try {
186
- return realpathSync(path);
187
- } catch {
188
- return path;
189
- }
190
- };
191
- const scriptNode = join(real(home), ".cabane", "node") + sep;
192
- return real(execPath).startsWith(scriptNode) ? "script" : "npm";
193
- }
194
- function repairCommands(install = companionInstall()) {
195
- return install === "script" ? [INSTALL_SCRIPT_COMMAND] : ["npm i -g @cabane/companion --include=optional"];
236
+ function repairCommands(route = repairRoute(), spell = cabane) {
237
+ if (route === "managed") return [spell("stop"), spell("update")];
238
+ if (route === "script") return [spell("stop"), INSTALL_SCRIPT_COMMAND];
239
+ return ["npm i -g @cabane/companion --include=optional"];
196
240
  }
197
- function repairAction(install = companionInstall()) {
198
- return `Reinstall with \`${repairCommands(install)[0]}\`.`;
241
+ function repairAction(route = repairRoute(), spell = cabane) {
242
+ const [first, ...rest] = repairCommands(route, spell);
243
+ if (rest.length === 0) return `Reinstall with \`${first}\`.`;
244
+ return `Run \`${first}\`, then \`${rest.join("`, then `")}\`. ${STOP_WARNING}`;
199
245
  }
246
+ var STOP_WARNING = "Stopping ends any turn in progress.";
200
247
  function installWarning(r) {
201
248
  return `warning: @cabane/companion is incomplete: its bundled ${HARNESS_LABEL[r.runtime]} ${missingNoun(r.status)} for ${r.platform}-${r.arch} is missing. ${repairAction()}`;
202
249
  }