longtable 0.1.7 → 0.1.8
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/package.json +1 -1
- package/src/repo.mjs +20 -0
- package/src/run.mjs +8 -1
package/package.json
CHANGED
package/src/repo.mjs
CHANGED
|
@@ -149,6 +149,26 @@ export function changedSoFar(tableId, work) {
|
|
|
149
149
|
return { files, gone, text, unread };
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
// Make the place for a copy: its branch, pushed with one empty commit of its own on top of the latest default branch,
|
|
153
|
+
// so the hosting sees something new and puts it up. If the branch is already there, it is left as it is.
|
|
154
|
+
export function openBranch(tableId, branch) {
|
|
155
|
+
safeBranch(branch);
|
|
156
|
+
const G = join(home, "copies", tableId, ".git");
|
|
157
|
+
try {
|
|
158
|
+
git(["--git-dir", G, "ls-remote", "--exit-code", "origin", `refs/heads/${branch}`]);
|
|
159
|
+
git(["--git-dir", G, "fetch", "--quiet", "--depth", "1", "--no-tags", "origin", `refs/heads/${branch}`]);
|
|
160
|
+
return git(["--git-dir", G, "rev-parse", "FETCH_HEAD"]);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
if (e.status !== 2) throw new Error("this computer could not reach the project's repository");
|
|
163
|
+
}
|
|
164
|
+
const head = git(["--git-dir", G, "rev-parse", "HEAD"]);
|
|
165
|
+
const tree = git(["--git-dir", G, "rev-parse", `${head}^{tree}`]);
|
|
166
|
+
const who = { ...quiet, GIT_AUTHOR_NAME: "Longtable", GIT_AUTHOR_EMAIL: "longtable@users.noreply.github.com", GIT_COMMITTER_NAME: "Longtable", GIT_COMMITTER_EMAIL: "longtable@users.noreply.github.com" };
|
|
167
|
+
const commit = git(["--git-dir", G, "commit-tree", tree, "-p", head, "-m", "A copy of its own"], who);
|
|
168
|
+
git(["--git-dir", G, "push", "--quiet", "origin", `${commit}:refs/heads/${branch}`]);
|
|
169
|
+
return commit;
|
|
170
|
+
}
|
|
171
|
+
|
|
152
172
|
// One commit of a sandbox, as a patch the team's AI can read to see what the client ended up with.
|
|
153
173
|
export function patchOf(tableId, branch, commit) {
|
|
154
174
|
safeBranch(branch);
|
package/src/run.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { client } from "./api.mjs";
|
|
|
10
10
|
import { ask, findClaude } from "./claude.mjs";
|
|
11
11
|
import { askCodex, codexLimits, findCodex } from "./codex.mjs";
|
|
12
12
|
import { packCode } from "./pack.mjs";
|
|
13
|
-
import { changedSoFar, freshCopy, landWork, openWork, patchOf, workBranch } from "./repo.mjs";
|
|
13
|
+
import { changedSoFar, freshCopy, landWork, openBranch, openWork, patchOf, workBranch } from "./repo.mjs";
|
|
14
14
|
import { hideSecrets, home, loadSecret, log, readConfig } from "./store.mjs";
|
|
15
15
|
|
|
16
16
|
const SOURCES = {
|
|
@@ -453,6 +453,13 @@ async function workSandbox(rpc, seat, engines, job) {
|
|
|
453
453
|
if (!engines.claude) throw new Error("Claude Code is not on this computer");
|
|
454
454
|
if (!seat.source) throw new Error("this connection has no code to work on");
|
|
455
455
|
freshCopy(seat.table_id, seat.source);
|
|
456
|
+
if (job.probe) {
|
|
457
|
+
// Only making the place for a copy: no AI is asked anything.
|
|
458
|
+
const commit = openBranch(seat.table_id, job.branch);
|
|
459
|
+
await rpc("runner_finish", { token: seat.token, job: job.job_id, answer: "", info: { commit } });
|
|
460
|
+
log(`sandbox job ${job.job_id}: made ${job.branch}`);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
456
463
|
const opened = openWork(seat.table_id, job.branch, "work", { refresh: true });
|
|
457
464
|
let note = "";
|
|
458
465
|
let told = 0;
|