@abuaboud/box 0.7.9 → 0.7.10
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/cbox.mjs +14 -2
- package/package.json +1 -1
package/dist/cbox.mjs
CHANGED
|
@@ -417,6 +417,7 @@ ${styleText3("yellow", "!")} Connect GitHub so Box can clone ${repo} and your bo
|
|
|
417
417
|
|
|
418
418
|
// src/local.ts
|
|
419
419
|
import { execFileSync as execFileSync3, spawn as spawn3 } from "node:child_process";
|
|
420
|
+
import { createHash } from "node:crypto";
|
|
420
421
|
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync5, renameSync, rmSync, statSync, watch, writeFileSync as writeFileSync4 } from "node:fs";
|
|
421
422
|
import { homedir as homedir4 } from "node:os";
|
|
422
423
|
import { basename, dirname, join as join5 } from "node:path";
|
|
@@ -781,6 +782,7 @@ async function openLocal({ name, env, here, branch, fresh = false }) {
|
|
|
781
782
|
api("/api/environments")
|
|
782
783
|
]).finally(() => stop());
|
|
783
784
|
const environment = envs.find((e) => e.name === env) ?? fail(`No environment named ${env}.`);
|
|
785
|
+
void sendSetup();
|
|
784
786
|
const folder = prepareFolder(name, env, here, got.mcp);
|
|
785
787
|
try {
|
|
786
788
|
writeFileSync4(join5(BOXES, "llms.txt"), await fetch(new URL("/llms.txt", load().server)).then((r) => r.ok ? r.text() : Promise.reject()));
|
|
@@ -802,6 +804,16 @@ async function openLocal({ name, env, here, branch, fresh = false }) {
|
|
|
802
804
|
ok(`Claude closed \xB7 repo synced \xB7 ${name} sleeps once it's quiet ${dim(`\xB7 come back with: box ${name}`)}`);
|
|
803
805
|
process.exit(code2);
|
|
804
806
|
}
|
|
807
|
+
async function sendSetup() {
|
|
808
|
+
const { tar, ...home2 } = localClaudeHome();
|
|
809
|
+
const buf = await tar;
|
|
810
|
+
const sha = buf && buf.length <= 30 << 20 ? createHash("sha256").update(buf).digest("hex") : void 0;
|
|
811
|
+
const put = (body) => api("/api/laptop-setup", { method: "PUT", body: JSON.stringify({ home: home2, sha, ...body }) });
|
|
812
|
+
try {
|
|
813
|
+
if ((await put({})).need && buf) await put({ tgz: buf.toString("base64") });
|
|
814
|
+
} catch {
|
|
815
|
+
}
|
|
816
|
+
}
|
|
805
817
|
var claude = (folder, args) => new Promise((done) => spawn3("claude", args, { cwd: folder, stdio: "inherit", env: { ...process.env, ...process.getuid?.() === 0 && { IS_SANDBOX: "1" } } }).on("error", () => fail("Claude Code is not installed on this laptop. npm i -g @anthropic-ai/claude-code, or use box --remote.")).on("close", (c) => done(c ?? 0)));
|
|
806
818
|
function trustFolder(folder) {
|
|
807
819
|
const file2 = join5(homedir4(), ".claude.json");
|
|
@@ -862,7 +874,7 @@ async function rm(name, opts = {}) {
|
|
|
862
874
|
}
|
|
863
875
|
|
|
864
876
|
// src/remote.ts
|
|
865
|
-
import { createHash } from "node:crypto";
|
|
877
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
866
878
|
import { styleText as styleText4 } from "node:util";
|
|
867
879
|
import { select as select3 } from "@inquirer/prompts";
|
|
868
880
|
import ssh22 from "ssh2";
|
|
@@ -985,7 +997,7 @@ async function newRemoteBox(env, branch, name, o) {
|
|
|
985
997
|
async function sendHome(name, tar) {
|
|
986
998
|
const buf = await tar;
|
|
987
999
|
if (!buf || buf.length > 30 << 20) return api(`/api/boxes/${name}/home`, { method: "POST", body: "{}" }).catch(() => void 0);
|
|
988
|
-
const sha =
|
|
1000
|
+
const sha = createHash2("sha256").update(buf).digest("hex");
|
|
989
1001
|
const post = (body) => api(`/api/boxes/${name}/home`, { method: "POST", body: JSON.stringify(body) });
|
|
990
1002
|
if ((await post({ sha }).catch(() => ({ need: false }))).need) await post({ sha, tgz: buf.toString("base64") }).catch(() => void 0);
|
|
991
1003
|
}
|
package/package.json
CHANGED