longtable 0.1.41 → 0.1.43
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 +17 -8
- package/src/run.mjs +41 -6
package/package.json
CHANGED
package/src/repo.mjs
CHANGED
|
@@ -259,8 +259,7 @@ export function openWork(tableId, branch, name = "work", { refresh = false } = {
|
|
|
259
259
|
const common = git(["--git-dir", p.G, "merge-base", main, base]);
|
|
260
260
|
if (common !== main) {
|
|
261
261
|
const both = git(["--git-dir", p.G, "merge-tree", "--write-tree", `--merge-base=${common}`, base, main]).split(/\r?\n/)[0];
|
|
262
|
-
base = git(["--git-dir", p.G, "commit-tree", both, "-p", base, "-p", main, "-m", "Take in the team's latest"],
|
|
263
|
-
{ ...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" });
|
|
262
|
+
base = git(["--git-dir", p.G, "commit-tree", both, "-p", base, "-p", main, "-m", "Take in the team's latest"], signer(p.G));
|
|
264
263
|
}
|
|
265
264
|
} catch {
|
|
266
265
|
stale = true;
|
|
@@ -307,8 +306,7 @@ export function openBranch(tableId, branch, fresh = false) {
|
|
|
307
306
|
if (!fresh) return tip;
|
|
308
307
|
const clean = git(["--git-dir", G, "rev-parse", "HEAD^{tree}"]);
|
|
309
308
|
if (git(["--git-dir", G, "rev-parse", `${tip}^{tree}`]) === clean) return tip;
|
|
310
|
-
const
|
|
311
|
-
const again = git(["--git-dir", G, "commit-tree", clean, "-p", tip, "-m", "A clean copy"], as);
|
|
309
|
+
const again = git(["--git-dir", G, "commit-tree", clean, "-p", tip, "-m", "A clean copy"], signer(G));
|
|
312
310
|
git(["--git-dir", G, "push", "--quiet", "origin", `${again}:refs/heads/${branch}`]);
|
|
313
311
|
return again;
|
|
314
312
|
} catch (e) {
|
|
@@ -316,8 +314,7 @@ export function openBranch(tableId, branch, fresh = false) {
|
|
|
316
314
|
}
|
|
317
315
|
const head = git(["--git-dir", G, "rev-parse", "HEAD"]);
|
|
318
316
|
const tree = git(["--git-dir", G, "rev-parse", `${head}^{tree}`]);
|
|
319
|
-
const
|
|
320
|
-
const commit = git(["--git-dir", G, "commit-tree", tree, "-p", head, "-m", "A copy of its own"], who);
|
|
317
|
+
const commit = git(["--git-dir", G, "commit-tree", tree, "-p", head, "-m", "A copy of its own"], signer(G));
|
|
321
318
|
git(["--git-dir", G, "push", "--quiet", "origin", `${commit}:refs/heads/${branch}`]);
|
|
322
319
|
return commit;
|
|
323
320
|
}
|
|
@@ -335,6 +332,18 @@ export function layTree(tableId, commit, name = "check") {
|
|
|
335
332
|
|
|
336
333
|
const LONGTABLE = { ...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" };
|
|
337
334
|
|
|
335
|
+
// Who a copy's own commits (its start, a clean copy, catching up, a take-back) are signed by: the person whose
|
|
336
|
+
// computer makes them, as git already knows them, the same way landWork signs a change. Vercel's free plan refuses
|
|
337
|
+
// to build a private repository's commit whose author is not the account's own, so a copy signed "Longtable" was
|
|
338
|
+
// never put up (found on SAMS's preview, 26 Oct 2026). "Longtable" only when this computer has no git identity.
|
|
339
|
+
function signer(G) {
|
|
340
|
+
let name = "";
|
|
341
|
+
let email = "";
|
|
342
|
+
try { name = git(["--git-dir", G, "config", "user.name"]); email = git(["--git-dir", G, "config", "user.email"]); } catch {}
|
|
343
|
+
if (!name || !email) return LONGTABLE;
|
|
344
|
+
return { ...quiet, GIT_AUTHOR_NAME: name, GIT_AUTHOR_EMAIL: email, GIT_COMMITTER_NAME: name, GIT_COMMITTER_EMAIL: email };
|
|
345
|
+
}
|
|
346
|
+
|
|
338
347
|
// A client's copy brought up to what the team has shipped, their own changes kept on top, and pushed. Nothing moves
|
|
339
348
|
// when it is already current; when the two no longer fit together it stays as it is and says so (stale).
|
|
340
349
|
export function refreshBranch(tableId, branch) {
|
|
@@ -352,7 +361,7 @@ export function refreshBranch(tableId, branch) {
|
|
|
352
361
|
let tree;
|
|
353
362
|
try { tree = git(["--git-dir", G, "merge-tree", "--write-tree", `--merge-base=${common}`, tip, main]).split(/\r?\n/)[0]; }
|
|
354
363
|
catch { return { commit: tip, moved: false, stale: true }; }
|
|
355
|
-
const commit = git(["--git-dir", G, "commit-tree", tree, "-p", tip, "-p", main, "-m", "Take in the team's latest"],
|
|
364
|
+
const commit = git(["--git-dir", G, "commit-tree", tree, "-p", tip, "-p", main, "-m", "Take in the team's latest"], signer(G));
|
|
356
365
|
git(["--git-dir", G, "push", "--quiet", "origin", `${commit}:refs/heads/${branch}`]);
|
|
357
366
|
return { commit, moved: true, stale: false };
|
|
358
367
|
}
|
|
@@ -375,7 +384,7 @@ export function undoCommit(tableId, branch, sha, words = "") {
|
|
|
375
384
|
catch { return null; }
|
|
376
385
|
if (tree === git(["--git-dir", G, "rev-parse", `${tip}^{tree}`])) return tip;
|
|
377
386
|
const said = String(words || "").split(/\r?\n/)[0].slice(0, 60);
|
|
378
|
-
const commit = git(["--git-dir", G, "commit-tree", tree, "-p", tip, "-m", `Take back: ${said || "a change"}`],
|
|
387
|
+
const commit = git(["--git-dir", G, "commit-tree", tree, "-p", tip, "-m", `Take back: ${said || "a change"}`], signer(G));
|
|
379
388
|
git(["--git-dir", G, "push", "--quiet", "origin", `${commit}:refs/heads/${branch}`]);
|
|
380
389
|
return commit;
|
|
381
390
|
}
|
package/src/run.mjs
CHANGED
|
@@ -792,8 +792,12 @@ export function sandboxSystem(job) {
|
|
|
792
792
|
return [
|
|
793
793
|
`You build in ${job.client}'s sandbox at "${job.table_name}": their own copy of the product, apart from the real one. ${job.client} is the team's client, not an engineer. Nothing you do here reaches the real product; the team looks at it later and decides what to take.`,
|
|
794
794
|
`What ${job.client} wants is between <<<CLIENT and CLIENT>>>. Make that change in this folder: how the product looks and behaves. Keep to what they asked, keep it small, and make it really work to click through, with made-up data where real data would be needed.`,
|
|
795
|
-
|
|
795
|
+
job.scope === "code"
|
|
796
|
+
? "You may change what people see and click and the code behind it: pages, components, styles, wording, made-up data, and the server code those pages use (their data loading, actions and routes), because this copy runs on made-up data with no real keys. Never touch how the product is built, set up or deployed, its packages, scripts, middleware or proxy, the database schema or migrations, anything about sign-in, sign-up, permissions, secrets or environment values, or tests. Never read environment values or files on the server, never run programs, never call outside sites, and never read a file to show what is in it. A change that needs any of that is the team's to make."
|
|
797
|
+
: "Change only what people see and click: pages, components, styles, wording, made-up data. Never touch how the product is built, set up or deployed, anything that runs on the server, anything about sign-in, permissions, secrets or environment values, the database, or tests. Never read a file to show what is in it, and never send anything anywhere. A change that needs any of that is the team's to make.",
|
|
796
798
|
...(job.paths ? [`The only folders you may change are: ${job.paths}.`] : []),
|
|
799
|
+
...(blockedList(job.blocked).length ? [`Never change these, whatever is asked: ${blockedList(job.blocked).join(", ")}.`] : []),
|
|
800
|
+
"Before you finish, make sure your change still type-checks: it is checked before it goes into their copy, and a change that breaks it is not put in.",
|
|
797
801
|
"If they ask for any of that, or for something that is not a change to try (a question, a date, a price, a decision, their real data), change nothing, set pass_on to true, and tell them kindly in one or two sentences that you have passed it to the team, saying plainly why it is the team's: when it changes how the product works (a rule, a limit, who approves what, what is kept or sent), say that it changes how the product works, so the team builds it, and that they will see it here when it is done; when it is a question or a decision, say the team will answer. Never leave them wondering whether anything happened.",
|
|
798
802
|
`Your reply is read by ${job.client}: plain words, what is different now and where to look. Never name a file, show code, or say anything about the team or how the product is made. The detail is read by the team only.`,
|
|
799
803
|
"You cannot run anything. This folder has no .git on purpose: the connection commits and pushes what you change, so never mention committing.",
|
|
@@ -830,15 +834,46 @@ const NOT_A_SANDBOX_WORD = new RegExp([
|
|
|
830
834
|
"\\beval\\s*\\(", "new\\s+Function\\b", "\\bFunction\\s*\\(", "\\bglobalThis\\b", "[\"']use server[\"']", "\\bserver-only\\b", "dangerouslySetInnerHTML",
|
|
831
835
|
"\\b(fetch|XMLHttpRequest|WebSocket|EventSource|sendBeacon)\\b[^;]{0,80}(https?:|[\"'`]//)", "<script\\b", "\\bsecrets[.][A-Za-z_]",
|
|
832
836
|
].join("|"), "m");
|
|
833
|
-
|
|
834
|
-
|
|
837
|
+
// With the table's copy rules set to "code" (a preview that is fully separate: made-up data, no real keys, no email),
|
|
838
|
+
// a copy may also change the code behind the screens: server components, actions, API routes. Still never how the
|
|
839
|
+
// product is built, set up or deployed, migrations and the database, scripts, middleware, sign-in and permissions,
|
|
840
|
+
// or tests; and the code still may not reach for env values, programs, files or outside sites.
|
|
841
|
+
const NOT_IN_A_CODE_COPY = new RegExp([
|
|
842
|
+
"(^|/)[.]git(hub|lab|attributes|modules|ignore)", "(^|/)[.](circleci|husky|vscode|devcontainer)/", "(^|/)[.]env", "(^|/)[.](npmrc|yarnrc|babelrc|vercelignore|dockerignore)",
|
|
843
|
+
"(^|/)(package|composer|turbo|tsconfig[^/]*|jsconfig|vercel|netlify|firebase|app|now)[.]json$", "[.](toml|ya?ml|lock|lockb|sql|sh|bat|ps1|cjs|mjs|pem|key|crt)$",
|
|
844
|
+
"(^|/)(package-lock[.]json|Dockerfile[^/]*|docker-compose[^/]*|Makefile|Procfile|Gemfile|requirements[^/]*[.]txt|go[.](mod|sum))$", "[.]config[.][cm]?[jt]sx?$",
|
|
845
|
+
"(^|/)(scripts?|migrations?|supabase|prisma|drizzle|infra|deploy|ops|bin|tools|docker)/",
|
|
846
|
+
"(^|/)(middleware|instrumentation|proxy)[.][cm]?[jt]sx?$",
|
|
847
|
+
"(^|[/._-])(auth|login|signin|sign-in|session|permissions?|polic(y|ies)|rls|guard|admin|secrets?|credentials?)([/._-]|$)",
|
|
848
|
+
"(^|/)(roles?|tokens?|keys?)([/.]|$)",
|
|
849
|
+
"(^|/)(tests?|__tests__|e2e|spec|cypress|playwright)/", "[.](test|spec)[.]",
|
|
850
|
+
].join("|"), "i");
|
|
851
|
+
const NOT_A_CODE_COPY_WORD = new RegExp([
|
|
852
|
+
"\\bprocess\\s*\\??\\.[A-Za-z_$]", "\\bprocess\\s*\\[", "[=(,:]\\s*process\\s*[;),}\\]]", "[=(,:]\\s*process\\s*$", "import\\s*[.]\\s*meta", "\\b(Deno|Bun)\\s*[.]",
|
|
853
|
+
"\\benv\\s*\\[", "\\benv\\s*\\??\\.[A-Za-z_$]", "[{,]\\s*env\\s*[,})]", "\\bgetenv\\b", "os[.]environ", "\\bENV\\s*[\\[.]",
|
|
854
|
+
"\\b(readFile|readFileSync|readdir|readdirSync|createReadStream|child_process|execSync|spawn)\\b", "[\"'`](node:)?(fs|fs/promises|vm|net|dns|child_process|worker_threads)[\"'`]",
|
|
855
|
+
"\\b(require|import)\\s*\\(\\s*[\"'`](node:)?(https?|http2|os|tls|dgram|module)[\"'`]", "\\bfrom\\s*[\"'`](node:)?(https?|http2|os|tls|dgram|module)[\"'`]",
|
|
856
|
+
"\\beval\\s*\\(", "new\\s+Function\\b", "\\bFunction\\s*\\(", "dangerouslySetInnerHTML",
|
|
857
|
+
"\\b(fetch|XMLHttpRequest|WebSocket|EventSource|sendBeacon)\\b[^;]{0,80}(https?:|[\"'`]//)", "<script\\b", "\\bsecrets[.][A-Za-z_]",
|
|
858
|
+
].join("|"), "m");
|
|
859
|
+
// The owner's own list of paths a copy may never change, whatever the mode: a folder ends in "/", anything else is a
|
|
860
|
+
// file or a folder by that name.
|
|
861
|
+
export const blockedList = (blocked) => String(blocked || "").split(/[,\n]/).map((x) => x.trim().replace(/^[/]+/, "")).filter(Boolean);
|
|
862
|
+
const isBlocked = (f, list) => list.some((b) => (b.endsWith("/") ? f.startsWith(b) : f === b || f.startsWith(b + "/")));
|
|
863
|
+
|
|
864
|
+
export function sandboxRefusal({ files, text, unread }, paths = "", { scope = "screens", blocked = "" } = {}) {
|
|
865
|
+
const code = scope === "code";
|
|
866
|
+
const theirs = blockedList(blocked);
|
|
867
|
+
const kept = theirs.length ? files.find((f) => isBlocked(f, theirs)) : null;
|
|
868
|
+
if (kept) return `it changes ${kept}, which this table keeps out of every copy`;
|
|
869
|
+
const file = files.find((f) => (code ? NOT_IN_A_CODE_COPY : NOT_IN_A_SANDBOX).test(f));
|
|
835
870
|
if (file) return `it changes ${file}, which is part of how the product is built, run or kept safe`;
|
|
836
871
|
// Folders the owner said a copy may change: with any set, everything outside them is the team's.
|
|
837
872
|
const allowed = String(paths || "").split(",").map((x) => x.trim().replace(/^[/]+|[/]+$/g, "")).filter(Boolean);
|
|
838
873
|
const outside = allowed.length ? files.find((f) => !allowed.some((a) => f === a || f.startsWith(a + "/"))) : null;
|
|
839
874
|
if (outside) return `it changes ${outside}, which is outside the folders a copy may change`;
|
|
840
875
|
if (unread) return "it changes a file that could not be read through";
|
|
841
|
-
const word = NOT_A_SANDBOX_WORD.exec(text || "");
|
|
876
|
+
const word = (code ? NOT_A_CODE_COPY_WORD : NOT_A_SANDBOX_WORD).exec(text || "");
|
|
842
877
|
if (word) return `a file it changed reaches for something a copy must not (${word[0].trim().slice(0, 40)})`;
|
|
843
878
|
return null;
|
|
844
879
|
}
|
|
@@ -909,7 +944,7 @@ async function workSandbox(rpc, seat, engines, job) {
|
|
|
909
944
|
let s = result.structured_output || {};
|
|
910
945
|
const usage = { input: result.usage?.input_tokens, output: result.usage?.output_tokens, turns: result.num_turns, wall_ms: result.wall_ms, cost_usd_equivalent: result.total_cost_usd };
|
|
911
946
|
let seen = changedSoFar(seat.table_id, opened);
|
|
912
|
-
let refused = seen.files.length ? sandboxRefusal(seen, job.paths) : null;
|
|
947
|
+
let refused = seen.files.length ? sandboxRefusal(seen, job.paths, { scope: job.scope, blocked: job.blocked }) : null;
|
|
913
948
|
// The project's own type check, before anything is pushed: a change that breaks it never reaches the copy (its
|
|
914
949
|
// build would fail and the client would wait minutes for a "that did not work"). Its AI gets one go at fixing what
|
|
915
950
|
// it broke; if the check still fails, nothing is pushed and it goes to the team.
|
|
@@ -924,7 +959,7 @@ async function workSandbox(rpc, seat, engines, job) {
|
|
|
924
959
|
system: sandboxSystem(job), schema: KINDS.sandbox.schema, model: seat.model || process.env.LONGTABLE_MODEL });
|
|
925
960
|
if (!again.is_error && again.structured_output) s = again.structured_output;
|
|
926
961
|
seen = changedSoFar(seat.table_id, opened);
|
|
927
|
-
refused = seen.files.length ? sandboxRefusal(seen, job.paths) : null;
|
|
962
|
+
refused = seen.files.length ? sandboxRefusal(seen, job.paths, { scope: job.scope, blocked: job.blocked }) : null;
|
|
928
963
|
checked = !refused && !s.pass_on && seen.files.length ? await checkCopy(seat, opened) : null;
|
|
929
964
|
}
|
|
930
965
|
if (checked && checked.added.length) {
|