longtable 0.1.30 → 0.1.31
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/longtable.mjs +9 -2
- package/package.json +1 -1
- package/src/claude.mjs +23 -4
package/bin/longtable.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { rmSync } from "node:fs";
|
|
|
15
15
|
import { join, resolve } from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
17
|
import { client, fetchConfig } from "../src/api.mjs";
|
|
18
|
-
import { claudeVersion, findClaude, tokenWorks } from "../src/claude.mjs";
|
|
18
|
+
import { claudeVersion, findClaude, installClaude, tokenWorks } from "../src/claude.mjs";
|
|
19
19
|
import { codexSignIn, codexSignedIn, codexVersion, findCodex } from "../src/codex.mjs";
|
|
20
20
|
import { disableAutostart, enableAutostart } from "../src/autostart.mjs";
|
|
21
21
|
import { forgetCopies, freshCopy, gitCanJoin, resolveSource } from "../src/repo.mjs";
|
|
@@ -40,8 +40,15 @@ async function connect() {
|
|
|
40
40
|
const ai = option("ai") || "claude";
|
|
41
41
|
if (!["claude", "codex"].includes(ai)) throw new Error("--ai is claude or codex.");
|
|
42
42
|
// Check the AI is here before the one-use code is spent.
|
|
43
|
-
|
|
43
|
+
let claude = ai === "claude" ? findClaude() : null;
|
|
44
44
|
const codex = ai === "codex" ? findCodex() : null;
|
|
45
|
+
// No Claude Code this connection can run: it is installed now with Anthropic's own installer, so connecting never
|
|
46
|
+
// stops on a step someone skipped. --no-install leaves it to the person.
|
|
47
|
+
if (ai === "claude" && !claude && !args.includes("--no-install")) {
|
|
48
|
+
say("Claude Code isn't on this computer yet, outside the Claude app. Installing it with Anthropic's installer (claude.ai/install), one moment.");
|
|
49
|
+
claude = installClaude();
|
|
50
|
+
if (claude) say("Claude Code is installed.");
|
|
51
|
+
}
|
|
45
52
|
if (ai === "claude" && !claude) throw new Error("Claude Code isn't installed on this computer. Install it from claude.com/claude-code, then press Connect again.");
|
|
46
53
|
if (ai === "codex" && !codex) throw new Error("Codex's command-line tool isn't installed on this computer. Install it with npm install -g @openai/codex, then press Connect again.");
|
|
47
54
|
|
package/package.json
CHANGED
package/src/claude.mjs
CHANGED
|
@@ -24,11 +24,19 @@ export function findClaude() {
|
|
|
24
24
|
const native = join(homedir(), ".local", "bin", exe);
|
|
25
25
|
if (existsSync(native)) return native;
|
|
26
26
|
if (isWindows) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
// The Claude app's own copy: where the app sees it, and where Windows really keeps it for a packaged app, which
|
|
28
|
+
// is what a connection started outside the app sees.
|
|
29
|
+
const roots = [join(process.env.APPDATA || "", "Claude", "claude-code")];
|
|
30
|
+
const packages = join(process.env.LOCALAPPDATA || "", "Packages");
|
|
31
|
+
try { for (const d of readdirSync(packages)) if (/^Claude_/i.test(d)) roots.push(join(packages, d, "LocalCache", "Roaming", "Claude", "claude-code")); } catch {}
|
|
32
|
+
for (const root of roots) {
|
|
33
|
+
if (!existsSync(root)) continue;
|
|
34
|
+
let versions = [];
|
|
35
|
+
try { versions = readdirSync(root).filter((v) => /^\d+\.\d+\.\d+$/.test(v)).sort(byVersionDesc); } catch {}
|
|
30
36
|
for (const v of versions) {
|
|
31
|
-
|
|
37
|
+
let builds = [];
|
|
38
|
+
try { builds = readdirSync(join(root, v)); } catch {}
|
|
39
|
+
for (const h of builds) {
|
|
32
40
|
const p = join(root, v, h, exe);
|
|
33
41
|
if (existsSync(p)) return p;
|
|
34
42
|
}
|
|
@@ -38,6 +46,17 @@ export function findClaude() {
|
|
|
38
46
|
return null;
|
|
39
47
|
}
|
|
40
48
|
|
|
49
|
+
// Claude Code from Anthropic's own installer, for a computer that has none the connection can run (only the
|
|
50
|
+
// Claude app's, kept to itself, or none at all). It is the documented way to install it; what it prints is shown.
|
|
51
|
+
export function installClaude() {
|
|
52
|
+
const cmd = isWindows
|
|
53
|
+
? ["powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "irm https://claude.ai/install.ps1 | iex"]]
|
|
54
|
+
: ["bash", ["-c", "curl -fsSL https://claude.ai/install.sh | bash"]];
|
|
55
|
+
const r = spawnSync(cmd[0], cmd[1], { stdio: "inherit", windowsHide: true, timeout: 10 * 60 * 1000 });
|
|
56
|
+
if (r.error) log(`installing Claude Code failed to start: ${r.error.message}`);
|
|
57
|
+
return findClaude();
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
// A clean environment: only what the operating system needs, plus the connection's own sign-in.
|
|
42
61
|
// Nothing from the parent process leaks in: no API keys, no settings from whatever started the connection.
|
|
43
62
|
// apiKey is only for the evals in CI, on the owner's own key; a person's connection always uses their own sign-in.
|