toolroll 0.9.122 → 0.9.125

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/CHANGELOG.md CHANGED
@@ -4,6 +4,54 @@ Each release opens with one line on its theme, then **New**, **Changed**, **Fixe
4
4
  the ones it has). Each item is at most two lines and says where to find it. Notes for maintainers (CI, the release
5
5
  tooling) go on the GitHub release, not here. Entries before 0.9.104 use the older format.
6
6
 
7
+ ## 0.9.125 — 2026-11-26
8
+
9
+ Everything in 0.9.124, which was tagged but never reached npm.
10
+
11
+ ## 0.9.124 — 2026-11-26
12
+
13
+ Thread commits stop carrying your computer's name, Skills is in Settings, and saving a Direct Chat tells you how to
14
+ bring it in.
15
+
16
+ ### Changed
17
+
18
+ - **Skills is in Settings → Agents and models** for everyone: "Skills for <project>", one status per skill, and an
19
+ import that can't reach GitHub says so and keeps the address you typed.
20
+ - **Saving a Direct Chat as a branch** shows the exact `git merge` to bring it in; the button is "Save the branch".
21
+ - **Turning threads on from the workbench** keeps the message you typed and gives a command that explains its options.
22
+ - **Settings → Passwordless** lists exactly which acts still ask for a password.
23
+
24
+ ### Fixed
25
+
26
+ - **Commits an agent makes in a thread or Direct Chat** use your project's git name and email (or a neutral Toolroll
27
+ one), never your computer's account or host name. Commits made before this keep theirs.
28
+ - **A thread's Diff** no longer offers Accept and Send back for a task; it offers Save as branch.
29
+ - **Reloading a page after Ship, Save or Land** shows what happened instead of "Not found", and never does it again.
30
+
31
+ ## 0.9.123 — 2026-11-26
32
+
33
+ Accepted work stays accepted, every command Toolroll gives you can be copied whole, and Toolroll stays quiet while
34
+ nothing runs.
35
+
36
+ ### Changed
37
+
38
+ - **Accepted work stays accepted** when its checks run again, in the task list, the browser and the workbench; a
39
+ failed re-check shows next to it and blocks Land with the reason.
40
+ - **Commands you need to run open in a sheet** in the workbench (Land, Save as branch, a Ship that can't open a pull
41
+ request): the whole command on its own line, and `c` copies it exactly.
42
+ - **Plan-limit checks run only while an agent is working** (or for ten minutes after you open Spend), never while
43
+ tasks just wait.
44
+ - **`toolroll task new` with a password set** asks for it, shows the terms, then builds; a wrong password files
45
+ nothing.
46
+ - **Landing from a shell on an install without a password** says to land from the workbench (B) or the task page.
47
+
48
+ ### Fixed
49
+
50
+ - **After you revert landed work yourself**, the task says "Landed on main (abc1234) · a later commit reverted it"
51
+ instead of "On main".
52
+ - **The page after Land** shows the task's current version; **ending a thread** offers Save as branch where Ship
53
+ can't work.
54
+
7
55
  ## 0.9.122 — 2026-11-26
8
56
 
9
57
  Share one pinned skill library across every project and agent, approve releases on one clear screen, and enjoy a cleaner Mac titlebar.
@@ -13,7 +13,6 @@ export const ADVANCED_PAGES = Object.freeze([
13
13
  { title: "Agents", href: "/agents", words: "Every agent at work now, and the computers that build" },
14
14
  { title: "Spend", href: "/spend", words: "What agent work cost, and monthly limits", operator: true },
15
15
  { title: "Subagents", href: "/settings/lead/subagents", words: "Helpers the lead looks after" },
16
- { title: "Skills", href: "/settings/skills", words: "Reusable instructions for agents" },
17
16
  { title: "Learning", href: "/settings/learning", words: "Lessons kept from finished work" },
18
17
  { title: "Operating mode", href: "/mode", words: "Let a project run for a while without asking" },
19
18
  { title: "Policy", href: "/settings/policy", words: "Limits no task can go past" },
@@ -366,7 +366,7 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
366
366
  state = { chat, repo };
367
367
  const chatTitle = String(row["title"] ?? "Direct Chat").slice(0, 60);
368
368
  title = `Ship "${chatTitle}"`;
369
- terms.push(`Direct Chat: ${chatTitle} (branch ${String(row["branch"] ?? "")})`, changedCount > 0 ? `Changes: ${changedCount} ${changedCount === 1 ? "file" : "files"} changed` : "Inspect current clone changes in the Ship preview.", mode === "keep-branch" ? "Mode: Keep branch on this Mac." : "Mode: Ship (runs project check before merging).", "Opens the Ship preview so you can review and confirm before anything is pushed or merged.");
369
+ terms.push(`Direct Chat: ${chatTitle} (branch ${String(row["branch"] ?? "")})`, changedCount > 0 ? `Changes: ${changedCount} ${changedCount === 1 ? "file" : "files"} changed` : "Inspect current clone changes in the Ship preview.", mode === "keep-branch" ? "Mode: Save the branch on this computer." : "Mode: Ship (runs project check before merging).", "Opens the Ship preview so you can review and confirm before anything is pushed or merged.");
370
370
  }
371
371
  else {
372
372
  const chat = text(input, "chat", 80);
@@ -136,14 +136,14 @@ export function scheduleLimitsLoop(store, seams, everyMs = 5 * 60_000) {
136
136
  if (stopped || busy)
137
137
  return;
138
138
  const now = clock();
139
- if (!planLimitsWanted(store, now))
139
+ if (!planLimitsWanted(store, now, seams.alive))
140
140
  return;
141
141
  if (viewed && now.getTime() - lastPass < VIEWED_PASS_GAP_MS)
142
142
  return;
143
143
  busy = true;
144
144
  lastPass = now.getTime();
145
145
  try {
146
- const stillWanted = () => !stopped && planLimitsWanted(store, clock());
146
+ const stillWanted = () => !stopped && planLimitsWanted(store, clock(), seams.alive);
147
147
  await codexLimitsPass(store, { signedIn: seams.signedIn, stopped: () => stopped, stillWanted, ...(seams.readCodex === undefined ? {} : { read: seams.readCodex }) });
148
148
  if (stillWanted()) {
149
149
  await refreshSubscriptions(store, store.databaseFile(), { skipCodex: true, now: clock(), stillWanted, ...(seams.readers === undefined ? {} : { readers: seams.readers }) });
@@ -7,6 +7,7 @@ import { promisify } from "node:util";
7
7
  import { run } from "./exec.js";
8
8
  import { ENV, ENV_ALLOWLIST } from "./remote-main.js";
9
9
  import { checkoutGit, refusal, TEARDOWN_FLAGS, viewedGitSync } from "./teardown-git.js";
10
+ import { DIRECT_CHAT_IDENTITY, identityFrom, identityValues } from "./git-identity.js";
10
11
  const execFileAsync = promisify(execFile);
11
12
  const EXTRA_DIRECT_CHAT_GIT_FLAGS = [
12
13
  ...TEARDOWN_FLAGS,
@@ -238,6 +239,23 @@ export function runTrustedCloneGit(binding, args, input, extraEnv) {
238
239
  stdio: [input === undefined ? "ignore" : "pipe", "pipe", "pipe"],
239
240
  });
240
241
  }
242
+ export function cloneCommitIdentity(binding) {
243
+ if (binding === null)
244
+ return DIRECT_CHAT_IDENTITY;
245
+ let listing = "";
246
+ try {
247
+ listing = runTrustedCloneGit(binding, ["config", "--local", "--list", "-z"]);
248
+ }
249
+ catch { }
250
+ const values = identityValues(listing);
251
+ return { name: values.name ?? DIRECT_CHAT_IDENTITY.name, email: values.email ?? DIRECT_CHAT_IDENTITY.email };
252
+ }
253
+ function writeCloneIdentity(realGitDir, realClone, identity) {
254
+ const cloneEnv = cleanGitEnv({ GIT_COMMON_DIR: realGitDir });
255
+ for (const [key, value] of [["user.name", identity.name], ["user.email", identity.email]]) {
256
+ execFileSync("git", [...EXTRA_DIRECT_CHAT_GIT_FLAGS, `--git-dir=${realGitDir}`, `--work-tree=${realClone}`, "config", "--local", key, value], { cwd: realClone, encoding: "utf8", env: cloneEnv, stdio: ["ignore", "pipe", "pipe"] });
257
+ }
258
+ }
241
259
  function pinCloneGitConfig(realGitDir) {
242
260
  const configPath = join(realGitDir, "config");
243
261
  try {
@@ -289,6 +307,7 @@ export function cloneIsolatedRepo(input) {
289
307
  catch {
290
308
  }
291
309
  execFileSync("git", [...EXTRA_DIRECT_CHAT_GIT_FLAGS, `--git-dir=${realGitDir}`, `--work-tree=${realClone}`, "checkout", "-b", input.branch, baseSha], { cwd: realClone, encoding: "utf8", env: cloneEnv, stdio: ["ignore", "pipe", "pipe"] });
310
+ writeCloneIdentity(realGitDir, realClone, identityFrom(runHardenedMainGit(["config", "--local", "--list", "-z"], input.repo), DIRECT_CHAT_IDENTITY));
292
311
  const configSha256 = pinCloneGitConfig(realGitDir);
293
312
  return { baseSha, gitDir: realGitDir, configSha256, mainDirtyFiles };
294
313
  }
@@ -331,6 +350,7 @@ export async function cloneIsolatedRepoAsync(input) {
331
350
  catch {
332
351
  }
333
352
  await execFileAsync("git", [...EXTRA_DIRECT_CHAT_GIT_FLAGS, `--git-dir=${realGitDir}`, `--work-tree=${realClone}`, "checkout", "-b", input.branch, baseSha], { cwd: realClone, encoding: "utf8", env: cloneEnv });
353
+ writeCloneIdentity(realGitDir, realClone, identityFrom(await runHardenedMainGitAsync(["config", "--local", "--list", "-z"], input.repo), DIRECT_CHAT_IDENTITY));
334
354
  const configSha256 = pinCloneGitConfig(realGitDir);
335
355
  return { baseSha, gitDir: realGitDir, configSha256, mainDirtyFiles };
336
356
  }
@@ -176,10 +176,10 @@ export function directChatShipReadiness(store, repo) {
176
176
  const canAutoMerge = github !== null && check !== null;
177
177
  let autoMergeReason = null;
178
178
  if (github === null) {
179
- autoMergeReason = "This project isn't connected to GitHub pull requests yet — use Keep branch instead.";
179
+ autoMergeReason = "This project isn't connected to GitHub pull requests yet, so Save the branch instead.";
180
180
  }
181
181
  else if (check === null) {
182
- autoMergeReason = "Set a project check command in Settings before auto-merging — or use Keep branch.";
182
+ autoMergeReason = "Set a project check command in Settings before auto-merging, or Save the branch.";
183
183
  }
184
184
  return {
185
185
  canAutoMerge,
@@ -243,10 +243,10 @@ function previewWithInspection(store, input) {
243
243
  const canAutoMerge = github !== null && check !== null;
244
244
  let autoMergeReason = null;
245
245
  if (github === null) {
246
- autoMergeReason = "This project isn't connected to GitHub pull requests yet — use Keep branch instead.";
246
+ autoMergeReason = "This project isn't connected to GitHub pull requests yet, so Save the branch instead.";
247
247
  }
248
248
  else if (check === null) {
249
- autoMergeReason = "Set a project check command in Settings before auto-merging — or use Keep branch.";
249
+ autoMergeReason = "Set a project check command in Settings before auto-merging, or Save the branch.";
250
250
  }
251
251
  const mode = input.mode ?? (canAutoMerge ? "ship" : "keep-branch");
252
252
  const nextSeq = Number(store.handle.prepare("SELECT COALESCE(MAX(seq), 0) + 1 AS n FROM direct_chat_ship WHERE thread_id = ?").get(input.threadId)["n"]);
@@ -328,7 +328,7 @@ export function executeDirectChatShip(store, input) {
328
328
  ok: false,
329
329
  status: 409,
330
330
  code: "auto_merge_unavailable",
331
- error: preview.autoMergeReason ?? "Auto-merge isn't available for this project; use Keep branch instead.",
331
+ error: preview.autoMergeReason ?? "Auto-merge isn't available for this project; Save the branch instead.",
332
332
  };
333
333
  }
334
334
  const thread = store.handle
@@ -11,10 +11,11 @@ import { defaultCustodyIO } from "./flexible-launch.js";
11
11
  import { plainAgentEnv } from "./agent-fence.js";
12
12
  import { directChatFence } from "./direct-chat-fence.js";
13
13
  import { confined } from "./exec.js";
14
+ import { identityEnv } from "./git-identity.js";
14
15
  import { cleanLiveText, HIDDEN_LINE, liveSecretHit } from "./live-records.js";
15
16
  import { projectName } from "./project.js";
16
17
  import { captureNewWorkspaceArtifacts, extractBase64ImagesFromLine, getDirectChatArtifact, listArtifactsForThread, saveDirectChatArtifact, snapshotWorkspaceImages, } from "./direct-chat-artifacts.js";
17
- import { assertManagedClonePath, assertTrustedCloneGit, cloneIsolatedRepoAsync, pinnedConfigBackupPath, repairCloneGitBinding, runTrustedCloneGit, } from "./direct-chat-git.js";
18
+ import { assertManagedClonePath, assertTrustedCloneGit, cloneCommitIdentity, cloneIsolatedRepoAsync, pinnedConfigBackupPath, repairCloneGitBinding, runTrustedCloneGit, } from "./direct-chat-git.js";
18
19
  import { applyMainDirtyPatch, cloneSafeNodeModulesAsync } from "./direct-chat-workspace.js";
19
20
  import { defaultContextWindowFor, normalizeDirectChatEffort, resolveAgyModelForEffort } from "./direct-chat-catalog.js";
20
21
  import { effectiveSkillsForRepo, materializeProjectSkills } from "./project-skills.js";
@@ -1352,7 +1353,7 @@ export class DirectChatHost {
1352
1353
  `).run(turnId, thread.id, nextSeq, input.requestId, trimmed, switchedFrom, logPath, stderrPath, this.bootId(), stamp);
1353
1354
  let launched;
1354
1355
  try {
1355
- const childEnv = buildSanitizedChildEnv(thread.provider);
1356
+ const childEnv = { ...buildSanitizedChildEnv(thread.provider), ...identityEnv(cloneCommitIdentity(bindingForTree)) };
1356
1357
  if (turnSkills.dir !== null)
1357
1358
  childEnv["TOOLROLL_SKILLS_DIR"] = turnSkills.dir;
1358
1359
  launched = this.spawnTurnFn({
package/dist/first-run.js CHANGED
@@ -166,7 +166,7 @@ export function taskRoad(read, approved, built, facts) {
166
166
  if (waitsAtReady)
167
167
  steps = steps.map(step => step.key === "ready" ? { ...step, state: "stuck" } : step);
168
168
  const at = steps.find(step => step.key === "checks");
169
- if (facts.report !== true && at !== undefined && at.state === "stuck") {
169
+ if (facts.report !== true && at !== undefined && at.state === "stuck" && !complete) {
170
170
  steps = steps.map(step => step.key === "ready" && step.state === "done" ? { ...step, state: "todo" } : step);
171
171
  }
172
172
  if (facts.report === true) {
@@ -5,6 +5,7 @@ import { flexibleImportRef, importFlexibleCandidate, projectMergeHint, projectTh
5
5
  import { branchHeld, nextSeq, turnRunning } from "./flexible-ship.js";
6
6
  import { flexibleThread, flexibleThreadBranch, withFlexibleThreadLock } from "./flexible-thread.js";
7
7
  import { machineActing } from "./scope.js";
8
+ import { gitCommand, UNSAFE_FOLDER } from "./local-landing.js";
8
9
  const WORDS = Object.freeze({
9
10
  "machine-proof": "Only a person can save a thread's work. Nothing was saved.",
10
11
  "thread-unknown": "There's no such thread.",
@@ -19,7 +20,6 @@ const WORDS = Object.freeze({
19
20
  });
20
21
  const refuse = (reason) => ({ ok: false, reason, message: WORDS[reason] });
21
22
  export const flexibleSaveDigestOf = (terms) => createHash("sha256").update(`standing-orders:flexible-save:${canonicalJson(terms)}`, "utf8").digest("hex").slice(0, 32);
22
- const shellWord = (text) => /^[A-Za-z0-9_./~+@%=:,-]+$/.test(text) ? text : `'${text.replace(/'/g, "'\\''")}'`;
23
23
  function saverStanding(store, thread, by) {
24
24
  if (thread.createdBy !== by.name)
25
25
  return refuse("not-owner");
@@ -33,13 +33,13 @@ function saverStanding(store, thread, by) {
33
33
  async function nextWords(store, thread, candidate, branch, runner) {
34
34
  const hint = await projectMergeHint(store, { thread, candidate, ...(runner === undefined ? {} : { runner }) });
35
35
  if (hint === null)
36
- return `To use it: merge ${branch} in your repository.`;
37
- const repo = shellWord(hint.repo);
36
+ return { next: `To use it: merge ${branch} in your repository.`, command: null };
37
+ const ff = gitCommand(hint.repo, ["merge", "--ff-only", branch]), merge = gitCommand(hint.repo, ["merge", branch]);
38
38
  if (hint.branch === null)
39
- return `To use it: check out the branch you want it on, then run \`git -C ${repo} merge --ff-only ${branch}\`.`;
39
+ return { next: `To use it: check out the branch you want it on, then ${ff === null ? UNSAFE_FOLDER(`git merge --ff-only ${branch}`) : `run \`${ff}\`.`}`, command: ff };
40
40
  if (hint.fastForward)
41
- return `To put it on ${hint.branch}: \`git -C ${repo} merge --ff-only ${branch}\`.`;
42
- return `${hint.branch} moved since the thread started, so it won't fast-forward. To merge it: \`git -C ${repo} merge ${branch}\`.`;
41
+ return { next: ff === null ? `To put it on ${hint.branch}: ${UNSAFE_FOLDER(`git merge --ff-only ${branch}`)}` : `To put it on ${hint.branch}: \`${ff}\`.`, command: ff };
42
+ return { next: `${hint.branch} moved since the thread started, so it won't fast-forward. ${merge === null ? UNSAFE_FOLDER(`git merge ${branch}`) : `To merge it: \`${merge}\`.`}`, command: merge };
43
43
  }
44
44
  export async function saveFlexibleBranch(store, input) {
45
45
  if (machineActing())
@@ -67,7 +67,7 @@ export async function saveFlexibleBranch(store, input) {
67
67
  return refuse("branch-gone");
68
68
  if (actual !== read.candidate)
69
69
  return refuse("branch-moved");
70
- return { ok: true, already: true, branch, candidate: read.candidate, seq: null, changedPaths: read.changedPaths, next: await nextWords(store, input.thread, read.candidate, branch, input.runner) };
70
+ return { ok: true, already: true, branch, candidate: read.candidate, seq: null, changedPaths: read.changedPaths, ...(await nextWords(store, input.thread, read.candidate, branch, input.runner)) };
71
71
  }
72
72
  const at = input.now.toISOString();
73
73
  const recorded = store.transact(() => {
@@ -105,7 +105,7 @@ export async function saveFlexibleBranch(store, input) {
105
105
  return imported;
106
106
  }
107
107
  store.transact(() => { store.handle.prepare("UPDATE flexible_ship SET state = 'imported', state_at = ? WHERE id = ? AND state = 'approved'").run(at, recorded.digest); });
108
- return { ok: true, already: false, branch, candidate: read.candidate, seq: recorded.seq, changedPaths: read.changedPaths, next: await nextWords(store, input.thread, read.candidate, branch, input.runner) };
108
+ return { ok: true, already: false, branch, candidate: read.candidate, seq: recorded.seq, changedPaths: read.changedPaths, ...(await nextWords(store, input.thread, read.candidate, branch, input.runner)) };
109
109
  });
110
110
  if (locked.ok === false && (locked.reason === "not-available" || locked.reason === "thread-unknown"))
111
111
  return refuse("thread-unknown");
@@ -15,6 +15,7 @@ import { processMayBeAlive } from "./process-liveness.js";
15
15
  import { startIdentityOf } from "./flexible-custody.js";
16
16
  import { defaultCustodyIO, holdLaunch, recordGateShut, recordLive, reserveLaunchOpen, recordNeverStarted, recordSpawning, settleLaunch, unsettledLaunch } from "./flexible-launch.js";
17
17
  import { readProjectRefs, saveRefSnapshot } from "./flexible-refs.js";
18
+ import { identityEnv, projectGitIdentity, THREAD_IDENTITY } from "./git-identity.js";
18
19
  import { projectRowKnown } from "./store.js";
19
20
  import { readProjectRegistryNow } from "./repos.js";
20
21
  import { poolRootOf } from "./worktree.js";
@@ -440,12 +441,13 @@ export function flexibleThreadFence(store, input) {
440
441
  ...(unread === undefined ? {} : { pool: unread }) };
441
442
  return { ok: true, launch: { ...made, fenceGrants: grants }, paths, thread };
442
443
  }
443
- export function flexibleThreadEnv(paths, proxy, base = process.env) {
444
+ export function flexibleThreadEnv(paths, proxy, base = process.env, identity = THREAD_IDENTITY) {
444
445
  return {
445
446
  ...plainAgentEnv(base),
446
447
  HOME: real(homedir()), TMPDIR: paths.tmp, ...buildCacheEnv(paths.cache),
447
448
  GIT_TERMINAL_PROMPT: "0", GIT_CONFIG_NOSYSTEM: "1",
448
449
  ...proxy,
450
+ ...identityEnv(identity),
449
451
  };
450
452
  }
451
453
  function outerEnv(env, platform) {
@@ -552,7 +554,17 @@ async function spawnLocked(store, input, file, args, platform, seams) {
552
554
  const terms = termsProblem(launch);
553
555
  if (terms !== null)
554
556
  return refuse("containment", terms);
555
- const base = flexibleThreadEnv(paths, input.proxyEnv);
557
+ let project;
558
+ try {
559
+ project = realpathSync(fenced.thread.repo);
560
+ }
561
+ catch {
562
+ return refuse("repository-unusable");
563
+ }
564
+ const identity = await projectGitIdentity(project, THREAD_IDENTITY);
565
+ if (!identity.ok)
566
+ return refuse("repository-unusable", identity.why);
567
+ const base = flexibleThreadEnv(paths, input.proxyEnv, process.env, identity.identity);
556
568
  const env = { ...Object.fromEntries(Object.entries(input.agentEnv ?? {}).filter(([name]) => !(name in base))), ...base };
557
569
  const probed = await probeContainment(launch, paths, env, platform);
558
570
  if (probed !== null)
@@ -0,0 +1,65 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { isAbsolute, join } from "node:path";
5
+ import { run } from "./exec.js";
6
+ import { hardenedGit, refusal } from "./teardown-git.js";
7
+ import { unsafeInCommand } from "./local-landing.js";
8
+ export const THREAD_IDENTITY = Object.freeze({ name: "Toolroll thread", email: "thread@toolroll.local" });
9
+ export const DIRECT_CHAT_IDENTITY = Object.freeze({ name: "Toolroll Direct Chat", email: "direct-chat@toolroll.local" });
10
+ const plain = (value) => {
11
+ if (value === undefined || unsafeInCommand(value) || /[<>]/.test(value))
12
+ return null;
13
+ const trimmed = value.trim();
14
+ return trimmed !== "" && trimmed.length <= 200 ? trimmed : null;
15
+ };
16
+ export function identityValues(listing) {
17
+ let name, email;
18
+ for (const entry of listing.split("\0")) {
19
+ const newline = entry.indexOf("\n");
20
+ if (newline < 0)
21
+ continue;
22
+ const key = entry.slice(0, newline).toLowerCase();
23
+ if (key === "user.name")
24
+ name = entry.slice(newline + 1);
25
+ else if (key === "user.email")
26
+ email = entry.slice(newline + 1);
27
+ }
28
+ return { name: plain(name), email: plain(email) };
29
+ }
30
+ function globalValues(home, env) {
31
+ const xdg = env["XDG_CONFIG_HOME"];
32
+ const files = [join(xdg !== undefined && isAbsolute(xdg) ? xdg : join(home, ".config"), "git", "config"), join(home, ".gitconfig")];
33
+ const found = { name: null, email: null };
34
+ for (const file of files) {
35
+ if (!existsSync(file))
36
+ continue;
37
+ const ran = spawnSync("git", ["config", "--file", file, "--no-includes", "--list", "-z"], {
38
+ cwd: "/", encoding: "utf8", timeout: 5_000, killSignal: "SIGKILL", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 1_048_576,
39
+ env: { PATH: process.env["PATH"] ?? "/usr/bin:/bin", HOME: "/nonexistent", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", LANG: "C" },
40
+ });
41
+ if (ran.status !== 0)
42
+ continue;
43
+ const values = identityValues(ran.stdout);
44
+ found.name = values.name ?? found.name;
45
+ found.email = values.email ?? found.email;
46
+ }
47
+ return found;
48
+ }
49
+ export function identityFrom(localListing, neutral, home = homedir(), env = process.env) {
50
+ const local = identityValues(localListing);
51
+ const global = local.name !== null && local.email !== null ? { name: null, email: null } : globalValues(home, env);
52
+ return { name: local.name ?? global.name ?? neutral.name, email: local.email ?? global.email ?? neutral.email };
53
+ }
54
+ export async function projectGitIdentity(repo, neutral, inner = run) {
55
+ const ran = await hardenedGit(inner, "read", { repo })("git", ["config", "--local", "--list", "-z"], { cwd: repo, timeoutMs: 60_000 });
56
+ const refused = refusal(ran);
57
+ if (refused !== null)
58
+ return { ok: false, why: refused };
59
+ if (ran.code !== 0)
60
+ return { ok: false, why: "its git config couldn't be read" };
61
+ return { ok: true, identity: identityFrom(ran.stdout, neutral) };
62
+ }
63
+ export function identityEnv(identity) {
64
+ return { GIT_AUTHOR_NAME: identity.name, GIT_AUTHOR_EMAIL: identity.email, GIT_COMMITTER_NAME: identity.name, GIT_COMMITTER_EMAIL: identity.email };
65
+ }
@@ -215,7 +215,7 @@ export async function readLanding(store, taskId, access, now, options) {
215
215
  const checks = receipt.checks.status === "passed" ? "passed" : !projectCheckSet(store, project.repo) && receipt.checks.status === "not-run" ? "none" : null;
216
216
  if (checks === null) {
217
217
  if (receipt.checks.status === "failed")
218
- return refuse("checks", later ? `Its checks failed when they ran again after you accepted it (${receipt.checks.detail}). It stays Complete; it can't land until they pass on its exact commit.`
218
+ return refuse("checks", later ? `Its checks failed when they ran again after you accepted it (${receipt.checks.detail.replace(/\.$/, "")}). It stays Complete; it can't land until they pass on its exact commit.`
219
219
  : "Its checks failed. Only work whose checks passed on its exact commit lands.");
220
220
  return refuse("checks", later ? "Its checks changed since you accepted it and haven't run on its exact commit since. Run checks (it stays Complete), then land it."
221
221
  : "Its checks haven't passed on its exact commit. Run checks, then land it.");
@@ -636,13 +636,14 @@ function oidOrThrow(oid) {
636
636
  throw new Error("not a commit id");
637
637
  return oid;
638
638
  }
639
- const UNSAFE_IN_COMMAND = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\u061c\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff]/;
639
+ const UNSAFE_IN_COMMAND = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\u061c\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/;
640
+ export const unsafeInCommand = (text) => UNSAFE_IN_COMMAND.test(text);
640
641
  export function gitCommand(folder, args) {
641
642
  if (UNSAFE_IN_COMMAND.test(folder))
642
643
  return null;
643
644
  return ["git", "-C", `'${folder.replace(/'/g, "'\\''")}'`, ...args].join(" ");
644
645
  }
645
- const UNSAFE_FOLDER = (what) => `Toolroll can't write a safe command for this folder's name; run ${what} in your project folder.`;
646
+ export const UNSAFE_FOLDER = (what) => `Toolroll can't write a safe command for this folder's name; run ${what} in your project folder.`;
646
647
  function handoffCommand(folder, commit) {
647
648
  return gitCommand(folder, ["merge", "--ff-only", oidOrThrow(commit)]);
648
649
  }
@@ -669,6 +670,15 @@ function handoffRows(store, repo, taskId) {
669
670
  export function handoffsOf(store, repo, taskId) {
670
671
  return handoffRows(store, repo, taskId).filter(one => one.settled);
671
672
  }
673
+ export function keptHandoffOf(store, repo, rootId, candidate) {
674
+ if (candidate === null || !OID.test(candidate))
675
+ return null;
676
+ const one = handoffsOf(store, repo, rootId).find(row => row.candidate === candidate);
677
+ if (one === undefined)
678
+ return null;
679
+ const command = handoffCommand(one.folder, one.commit);
680
+ return { commit: one.commit, branch: one.ref.replace(/^refs\/heads\//, ""), command, words: handoffWords({ command }, one.commit) };
681
+ }
672
682
  class Refused extends Error {
673
683
  result;
674
684
  constructor(result) {
@@ -735,12 +745,45 @@ async function revertCommit(git, plan, scratch) {
735
745
  await git(["worktree", "prune"]).catch(() => null);
736
746
  }
737
747
  }
738
- export function landedWords(store, rootId) {
748
+ export function landedWords(store, rootId, read) {
749
+ return landedStanding(store, rootId, read)?.words ?? null;
750
+ }
751
+ export function landedStanding(store, rootId, read) {
739
752
  const landed = landingOf(store, rootId);
740
753
  if (landed === null)
741
754
  return null;
742
- return landed.undone ? `Landed on ${landed.intent.ref.replace(/^refs\/heads\//, "")} (${short(landed.intent.commit)}), then undone.`
743
- : `Landed on ${landed.intent.ref.replace(/^refs\/heads\//, "")} (${short(landed.intent.commit)}).`;
755
+ const where = `Landed on ${landed.intent.ref.replace(/^refs\/heads\//, "")} (${short(landed.intent.commit)})`;
756
+ if (landed.undone)
757
+ return { words: `${where}, then undone.`, reverted: false };
758
+ const reverted = read !== undefined && revertedOnBranch(landed.intent.repo, landed.intent.ref, landed.intent, read);
759
+ return { words: reverted ? `${where} · a later commit reverted it` : `${where}.`, reverted };
760
+ }
761
+ export function revertedOnBranch(repo, ref, landing, read) {
762
+ if (!OID.test(landing.old) || !OID.test(landing.commit) || !ref.startsWith("refs/heads/"))
763
+ return false;
764
+ const parents = read(repo, ["rev-list", "--parents", "-n", "1", landing.commit])?.split(" ") ?? [];
765
+ if (parents.length !== 2 || parents[0] !== landing.commit || parents[1] !== landing.old)
766
+ return false;
767
+ const changes = (raw) => {
768
+ const lines = raw.split("\n").filter(line => line.startsWith(":"));
769
+ const keys = [];
770
+ for (const line of lines) {
771
+ const match = /^:(\d{6}) (\d{6}) ([0-9a-f]{40}|[0-9a-f]{64}) ([0-9a-f]{40}|[0-9a-f]{64}) [A-Z]\d*\t(.+)$/.exec(line);
772
+ if (match === null)
773
+ return null;
774
+ keys.push(`${match[1]} ${match[2]} ${match[3]} ${match[4]}\t${match[5]}`);
775
+ }
776
+ return keys.sort();
777
+ };
778
+ const own = read(repo, ["diff-tree", "-r", "--no-renames", "--no-abbrev", "--no-commit-id", "--no-ext-diff", "--no-textconv", landing.commit]);
779
+ const mine = own === null ? null : changes(own);
780
+ if (mine === null || mine.length === 0)
781
+ return false;
782
+ const inverse = mine.map(key => { const [modes, path] = key.split("\t"); const [m1, m2, s1, s2] = modes.split(" "); return `${m2} ${m1} ${s2} ${s1}\t${path}`; }).sort().join("\n");
783
+ const later = read(repo, ["log", "--no-show-signature", "--no-merges", "--ancestry-path", "-n", "50", "--format=%x01%H", "--raw", "--no-renames", "--no-abbrev", "--no-ext-diff", "--no-textconv", `${landing.commit}..${ref}`]);
784
+ if (later === null)
785
+ return false;
786
+ return later.split("\u0001").slice(1).some(entry => changes(entry.slice(entry.indexOf("\n") + 1))?.join("\n") === inverse);
744
787
  }
745
788
  export function recognisedOnBranch(store, repo, rootId, candidate, read) {
746
789
  if (candidate === null || !OID.test(candidate))
@@ -749,8 +792,14 @@ export function recognisedOnBranch(store, repo, rootId, candidate, read) {
749
792
  const ref = recorded ?? (() => { const head = read(repo, ["symbolic-ref", "-q", "HEAD"]); return head !== null && head.startsWith("refs/heads/") ? head : null; })();
750
793
  if (ref === null || !landableBranch(ref.slice("refs/heads/".length)))
751
794
  return null;
752
- const commits = [candidate, ...handoffsOf(store, repo, rootId).filter(one => one.candidate === candidate && one.ref === ref).map(one => one.commit)];
753
- return commits.some(commit => read(repo, ["merge-base", "--is-ancestor", commit, ref]) !== null) ? `On ${ref.slice("refs/heads/".length)}` : null;
795
+ const handed = handoffsOf(store, repo, rootId).filter(one => one.candidate === candidate && one.ref === ref);
796
+ const found = [{ commit: candidate, old: null }, ...handed.map(one => ({ commit: one.commit, old: one.old }))]
797
+ .find(one => read(repo, ["merge-base", "--is-ancestor", one.commit, ref]) !== null);
798
+ if (found === undefined)
799
+ return null;
800
+ const reverted = found.old !== null && revertedOnBranch(repo, ref, { old: found.old, commit: found.commit }, read);
801
+ const where = `Landed on ${ref.slice("refs/heads/".length)} (${short(found.commit)})`;
802
+ return { words: reverted ? `${where} · a later commit reverted it` : where, reverted };
754
803
  }
755
804
  export function broughtInOnBranch(store, repo, rootId, read) {
756
805
  const landed = landedCommits(store, rootId);