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/dist/operate.js CHANGED
@@ -367,7 +367,7 @@ export const OPERATE_HELP = `toolroll — operating the queue
367
367
  toolroll task complete <id> mark the current result complete (--digest for JSON/agents);
368
368
  [--pull-request] --pull-request also opens its pull request
369
369
  toolroll task land <id> put accepted work on the project's own branch (no pull requests): shows what lands
370
- where, then --yes --key <key> lands it as one commit; --undo reverts it
370
+ where, then --yes --key <preview-key> lands it as one commit; --undo reverts it
371
371
  toolroll task merge <id> --as <you> --token <t>
372
372
  merge the task's pull request once checks pass
373
373
  [--anyway] merge without waiting for the full check
@@ -7730,7 +7730,7 @@ function taskAction(action, rest, flags, context) {
7730
7730
  return fail(context.write, context.json, "task", "usage", `unknown \`task ${action ?? ""}\` — try ${TASK_ACTIONS.join(", ")}`, EXIT.usage);
7731
7731
  }
7732
7732
  }
7733
- async function addTask(positional, flags, context) {
7733
+ async function addTask(positional, flags, context, fromNew = false) {
7734
7734
  const { store, write, json, now } = context;
7735
7735
  const title = positional.join(" ").trim();
7736
7736
  if (title === "")
@@ -7838,7 +7838,7 @@ async function addTask(positional, flags, context) {
7838
7838
  }
7839
7839
  }
7840
7840
  const next = filedRef !== null && filedRef.repo !== null && filedRef.plan === null && !flags.has("report")
7841
- ? "Next: run `toolroll`, select it and press p to ask for a plan. To build without a plan, file it with `toolroll task new` instead." : null;
7841
+ ? `Next: run \`toolroll\`, select it and press p to ask for a plan.${fromNew ? "" : " To build without a plan, file it with `toolroll task new` instead."}` : null;
7842
7842
  return succeed(write, json, "task add", {
7843
7843
  task: outcome.task,
7844
7844
  ...(replaces === undefined ? {} : { replaces }),
@@ -7887,16 +7887,17 @@ async function runTaskChecks(positional, flags, context) {
7887
7887
  const state = done?.state ?? "waiting";
7888
7888
  const words = `${CHECK_LEVEL_WORDS[asked.level]} checks`;
7889
7889
  const payload = { task: taskId, run: result.runId, head: result.head, request: asked.request, level: asked.level, state, exitCode: done?.exitCode ?? null };
7890
+ const complete = assignmentOf(store, taskId, clock(), { principal: "operator", repos: null, includeUnplaced: true }, context.evidenceRoot)?.state === "complete";
7890
7891
  if (state === "failed") {
7891
7892
  if (json) {
7892
7893
  write(envelopeJson({ ok: false, command: "task checks", reason: "checks-failed", ...payload }));
7893
7894
  return EXIT.failed;
7894
7895
  }
7895
- write(`${words} failed on ${result.head.slice(0, 7)}${done?.exitCode == null ? "" : ` (exit ${done.exitCode})`}. The result shows the failure.`);
7896
+ write(`${words} failed on ${result.head.slice(0, 7)}${done?.exitCode == null ? "" : ` (exit ${done.exitCode})`}. ${complete ? "It stays Complete; it can't land until they pass on its exact commit." : "The result shows the failure."}`);
7896
7897
  return EXIT.failed;
7897
7898
  }
7898
7899
  return succeed(write, json, "task checks", payload, () => [
7899
- state === "passed" ? `${words} passed on ${result.head.slice(0, 7)}. The result's status is upgraded.`
7900
+ state === "passed" ? `${words} passed on ${result.head.slice(0, 7)}.${complete ? " It stays Complete." : ""}`
7900
7901
  : state === "running" ? `${words} are already running on ${result.head.slice(0, 7)}.`
7901
7902
  : state === "not-run" ? `${words} didn't run: ${done?.note ?? "see the result's log"}`
7902
7903
  : `${words} are queued on ${result.head.slice(0, 7)}.`,
@@ -8208,7 +8209,7 @@ function showTask(positional, context) {
8208
8209
  ...(detail.hold === null ? [] : [` held: ${detail.hold.reason}`]),
8209
8210
  ...detail.steering.slice(-5).map(one => ` note #${one.id} to the agent: ${one.words}`),
8210
8211
  ...(detail.claim === null ? [] : [` claimed by ${detail.claim.runner} until ${detail.claim.expiresAt}`]),
8211
- ...(detail.dispatch === null ? [] : [` dispatch: ${detail.dispatch.detail.startsWith(detail.dispatch.summary) ? detail.dispatch.detail : `${detail.dispatch.summary} — ${detail.dispatch.detail}`}`]),
8212
+ ...(detail.dispatch === null || shared?.headline === "Complete" ? [] : [` dispatch: ${detail.dispatch.detail.startsWith(detail.dispatch.summary) ? detail.dispatch.detail : `${detail.dispatch.summary} — ${detail.dispatch.detail}`}`]),
8212
8213
  ...(detail.control.kind === "none"
8213
8214
  ? []
8214
8215
  : detail.control.kind === "stop"
@@ -12056,7 +12057,7 @@ async function newTaskCommand(positional, flags, context) {
12056
12057
  return fail(write, json, command, "person-only", "Only a person starts a build this way. File it with `task add`.", EXIT.refused);
12057
12058
  if (local === null && (json || !personAtTerminal(context)))
12058
12059
  return fail(write, json, command, "person-only", "`task new` asks a person at a terminal. Use `task add` from a script or an agent.", EXIT.refused);
12059
- const { name, token } = credentialsFrom(flags, context);
12060
+ let { name, token } = credentialsFrom(flags, context);
12060
12061
  const passwordFree = token !== undefined && (local !== null || sessionStandsIn(store));
12061
12062
  const facts = { passwordless: local === null && passwordFree, localOwner: local !== null, freshAt: null, returnTo: "/" };
12062
12063
  const buildNow = (preview, digest) => fastStartBuild(store, { preview, digest, actor: name ?? "", via: local === null ? "cli" : "terminal-ui", password: facts,
@@ -12078,6 +12079,29 @@ async function newTaskCommand(positional, flags, context) {
12078
12079
  if (words === "" || repo === undefined)
12079
12080
  return fail(write, json, command, "usage", "`toolroll task new \"<what should change>\" --repo <project>`", EXIT.usage);
12080
12081
  const placed = canonicalProject(repo) ?? resolve(repo);
12082
+ if (local === null && (flags.has("token") || (!facts.passwordless && !passwordFreeOwner(store)))) {
12083
+ let given = flags.has("token") ? token : undefined;
12084
+ if (given === undefined) {
12085
+ const usual = name === undefined ? soloOperatorOf(store) : null;
12086
+ if (name === undefined) {
12087
+ const answered = await (context.easySeams?.ask ?? ask)(usual === null ? "username: " : `username [${usual}]: `);
12088
+ name = answered === "" && usual !== null ? usual : answered;
12089
+ }
12090
+ given = await (context.easySeams?.askHidden ?? askHidden)("password: ");
12091
+ }
12092
+ else if (name === undefined)
12093
+ name = soloOperatorOf(store) ?? undefined;
12094
+ if (name === undefined || name === "" || given === "") {
12095
+ write("Nothing was filed.");
12096
+ return EXIT.refused;
12097
+ }
12098
+ const person = name;
12099
+ const proved = verifyApproverByPassword(store, person, given, store.knownRepos().filter(one => store.accountCanAccess(person, one)));
12100
+ if (!proved.ok)
12101
+ return fail(write, json, command, "unauthenticated", "That username and password didn't work. Nothing was filed.", EXIT.refused);
12102
+ token = given;
12103
+ facts.freshAt = clock().getTime();
12104
+ }
12081
12105
  const prepared = name === undefined || token === undefined ? { eligible: false, reason: "password" }
12082
12106
  : await prepareFastStart(store, { actor: name, repo: placed, title: words, via: local === null ? "cli" : "terminal-ui", password: facts }, clock());
12083
12107
  const terms = prepared.eligible ? fastTermsLines(store, prepared.scope, placed) : [];
@@ -12088,7 +12112,7 @@ async function newTaskCommand(positional, flags, context) {
12088
12112
  }
12089
12113
  if (!prepared.eligible) {
12090
12114
  write(`${fastRefusalWords(prepared.reason)} Filing it for a plan.`);
12091
- return addTask([words], flags, context);
12115
+ return addTask([words], flags, context, true);
12092
12116
  }
12093
12117
  write("Build approves exactly this:");
12094
12118
  write("");
@@ -12803,7 +12827,9 @@ async function projectFlexibleCommand(positional, flags, context) {
12803
12827
  return refused("Only a person changes a project's thread terms, never the lead, a token or a chat app.");
12804
12828
  const acting = await askCredentials(flags, context);
12805
12829
  if (acting === null)
12806
- return refused(`${action === "enable" ? "Turning on interactive agent threads needs your password" : "This needs your sign-in"}: pass --as and --token.`);
12830
+ return refused(action === "enable"
12831
+ ? "Turning on interactive agent threads needs your Toolroll password: run it again with `--as <your name>` and type the password when asked (`--token` is that password, only for scripts: it stays in shell history). Or turn them on in the browser, on the project's page in Settings."
12832
+ : "This needs your sign-in: run it again with `--as <your name>` and type your Toolroll password when asked.");
12807
12833
  if (action === "enable") {
12808
12834
  if (!flexibleAvailable(store))
12809
12835
  return fail(write, json, command, "not-available", FLEXIBLE_UNAVAILABLE, EXIT.refused);
@@ -13196,7 +13222,8 @@ async function threadCommand(positional, flags, context) {
13196
13222
  return fail(write, json, command, done.reason, done.message, EXIT.refused);
13197
13223
  if (done.stopPending)
13198
13224
  await stopFlexibleThreadsEverywhere(store, { reason: "its owner ended the thread", thread, clock });
13199
- return succeed(write, json, command, { thread, already: done.already }, () => [done.already ? "This thread had already ended." : "Ended. You can still ship its work for a week; then its copy is tidied."]);
13225
+ const keeps = flexibleShipNeedsFor(store, thread) === null ? "ship its work, or save it as a branch," : `save its work as a branch (\`toolroll thread save ${thread.slice(0, 8)}\`)`;
13226
+ return succeed(write, json, command, { thread, already: done.already }, () => [done.already ? "This thread had already ended." : `Ended. You can still ${keeps} for a week; then its copy is tidied.`]);
13200
13227
  }
13201
13228
  if (verb === "save") {
13202
13229
  const saved = await saveFlexibleBranch(store, { thread, by: { name: who.name, generation: account.generation }, now: clock(), prove: proveNow });
@@ -13397,7 +13424,7 @@ async function landTaskCommand(positional, flags, context) {
13397
13424
  return fail(write, json, command, "usage", `--${key} is not a ${command} option.`, EXIT.usage);
13398
13425
  const id = positional[0] === undefined ? undefined : resolveTaskId(store, positional[0]);
13399
13426
  if (id === undefined || positional.length !== 1)
13400
- return fail(write, json, command, "usage", "Use `toolroll task land <id>` to see what landing does, then `--yes --key <key>` to land it.", EXIT.usage);
13427
+ return fail(write, json, command, "usage", "Use `toolroll task land <id>` to see what landing does, then `--yes --key <preview-key>` to land it.", EXIT.usage);
13401
13428
  const into = text(flags, "into"), undo = flags.get("undo") === true, yes = flags.get("yes") === true, key = text(flags, "key");
13402
13429
  if (flags.has("into") && into === undefined)
13403
13430
  return fail(write, json, command, "usage", "--into needs a branch name.", EXIT.usage);
@@ -13418,6 +13445,8 @@ async function landTaskCommand(positional, flags, context) {
13418
13445
  if (!("plan" in read))
13419
13446
  return succeed(write, json, command, { landed: read.landed }, () => [`${id} · Landed on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`]);
13420
13447
  const plan = read.plan;
13448
+ if (local === null && passwordFreeOwner(store))
13449
+ return succeed(write, json, command, { plan }, () => [...landingWords(plan), LAND_NEEDS_PASSWORD]);
13421
13450
  return succeed(write, json, command, { plan }, () => [...landingWords(plan),
13422
13451
  `To ${undo ? "undo it" : "land it"}: toolroll task land ${id}${into === undefined ? "" : ` --into ${into}`}${undo ? " --undo" : ""} --yes --key ${plan.key}${local === null ? " --as <you>" : ""}`,
13423
13452
  ...(local === null ? ["That asks for your Toolroll password."] : [])]);
@@ -13427,6 +13456,8 @@ async function landTaskCommand(positional, flags, context) {
13427
13456
  let authority;
13428
13457
  if (local !== null)
13429
13458
  authority = { kind: "local" };
13459
+ else if (passwordFreeOwner(store))
13460
+ return fail(write, json, command, "unauthenticated", LAND_NEEDS_PASSWORD, EXIT.refused);
13430
13461
  else {
13431
13462
  const acting = await askCredentials(flags, context);
13432
13463
  const ref = store.lookupRef(id);
@@ -13475,3 +13506,4 @@ function verifyRepoOf(store, raw) {
13475
13506
  }
13476
13507
  return absolute;
13477
13508
  }
13509
+ const LAND_NEEDS_PASSWORD = "Land it from the workbench (B) or the task page in the browser; from a shell it needs a Toolroll password (`toolroll password set`).";
@@ -17,8 +17,16 @@ export function setPasswordless(store, on, by, now) {
17
17
  if (setting.on === on && (on || setting.at !== null))
18
18
  return { changed: false };
19
19
  store.recordAction({ at: now.toISOString(), actor: by, repo: null, taskId: null, runId: null, action: PASSWORDLESS_ACTION, outcome: on ? "on" : "off", source: "policy",
20
- detail: on ? "Passwordless on: approvals need no password" : "Passwordless off: step-ups ask for the password again" });
20
+ detail: on ? "Passwordless on: most browser approvals need no password" : "Passwordless off: step-ups ask for the password again" });
21
21
  store.bumpWake();
22
22
  return { changed: true };
23
23
  }
24
- export const PASSWORDLESS_TRADE = "Anyone holding a signed-in browser — an unlocked laptop, a phone, a stolen session — can then do everything you can without a second check. Signing in, session limits (12 hours idle, 7 days), signing out and ending sessions remain your protection. Creating or widening a way in (passwords, sign-in methods, API tokens, connected apps, people, workers, chat pairing, webhook secrets), or widening what a project's builds and checks reach (its network, where builds write, its home folder and its check access), still asks for your password.";
24
+ export const PASSWORDLESS_TRADE = "Anyone holding a signed-in browser — an unlocked laptop, a phone, a stolen session — can then do everything you can without a second check, except what still asks below. Signing in, session limits (12 hours idle, 7 days), signing out and ending sessions remain your protection.";
25
+ export const PASSWORDLESS_STILL_ASKS = Object.freeze([
26
+ "Signing in, and anything that adds or widens a way in: passwords, sign-in methods, API tokens, connected apps, people, workers, chat pairing and webhook secrets.",
27
+ "Widening what a project’s builds and checks reach: its network, where builds write, its home folder and its check commands.",
28
+ "Turning on interactive agent threads and saving the Claude sign-in they use.",
29
+ "Saving or shipping a Direct Chat’s work, and shipping a thread’s, except in Local mode on a laptop install, where this computer’s own browser and workbench don’t ask.",
30
+ "A toolroll command run in a shell without this computer’s remembered login.",
31
+ ]);
32
+ export const PASSWORDLESS_OTHERS = "Solo stands in the same way while you are the only person on this install. Local mode lets this computer’s browser file tasks, approve plans and add projects with no password at all. Without either, a password you just typed skips standard approvals on this computer for 15 minutes.";
@@ -1,5 +1,14 @@
1
+ import { realCustodyIO } from "./flexible-custody.js";
2
+ function processesNow() {
3
+ let table;
4
+ return (pid, start) => {
5
+ if (table === undefined)
6
+ table = realCustodyIO(() => null).table();
7
+ return table?.some(row => row.pid === pid && !row.zombie && row.start === start) ?? false;
8
+ };
9
+ }
10
+ const PROCESS_ROWS_AT_MOST = 500;
1
11
  export const PLAN_LIMITS_VIEW_WINDOW_MS = 10 * 60_000;
2
- const QUEUED_RECENTLY_MS = 60 * 60_000;
3
12
  const RUNNING_AT_MOST_MS = 6 * 3_600_000;
4
13
  const viewedAt = new WeakMap();
5
14
  const listeners = new WeakMap();
@@ -26,20 +35,33 @@ function any(store, sql, ...values) {
26
35
  return false;
27
36
  }
28
37
  }
29
- export function agentWorkActive(store, now) {
30
- const queuedSince = new Date(now.getTime() - QUEUED_RECENTLY_MS).toISOString();
38
+ function processesOf(store, sql, ...values) {
39
+ try {
40
+ return store.handle.prepare(sql).all(...values).flatMap(row => typeof row["pid"] === "number" && typeof row["start"] === "string" && row["start"] !== ""
41
+ ? [{ pid: row["pid"], start: row["start"] }] : []);
42
+ }
43
+ catch {
44
+ return [];
45
+ }
46
+ }
47
+ export function agentWorkActive(store, now, alive = processesNow()) {
48
+ const at = now.toISOString();
31
49
  const runningSince = new Date(now.getTime() - RUNNING_AT_MOST_MS).toISOString();
32
- return any(store, "SELECT 1 FROM task WHERE state = 'running' OR (state = 'queued' AND updated_at > ?) LIMIT 1", queuedSince)
33
- || any(store, "SELECT 1 FROM run WHERE outcome IS NULL AND started_at > ? LIMIT 1", runningSince)
34
- || any(store, "SELECT 1 FROM thread_turn WHERE status IN ('admitted', 'running') AND admitted_at > ? LIMIT 1", runningSince)
35
- || any(store, "SELECT 1 FROM direct_chat_turn WHERE status = 'running' AND created_at > ? LIMIT 1", runningSince)
36
- || any(store, "SELECT 1 FROM lead_queue WHERE status IN ('queued', 'running') LIMIT 1");
50
+ const living = (rows) => rows.some(one => alive(one.pid, one.start));
51
+ return any(store, `SELECT 1 FROM run r JOIN claim c ON c.lease_id = r.lease_id WHERE r.outcome IS NULL AND r.started_at > ?
52
+ AND c.released_at IS NULL AND c.expires_at > ? LIMIT 1`, runningSince, at)
53
+ || any(store, `SELECT 1 FROM lead_queue q JOIN mate_turn m ON m.id = q.turn_id WHERE q.status = 'running' AND q.claimed_at > ?
54
+ AND m.state = 'running' AND m.deadline_at > ? LIMIT 1`, runningSince, at)
55
+ || living(processesOf(store, `SELECT l.leader_pid AS pid, l.leader_start AS start FROM thread_turn t JOIN flexible_thread_launch l ON l.turn = t.id
56
+ WHERE t.status = 'running' AND t.started_at > ? AND l.state = 'live' LIMIT ${PROCESS_ROWS_AT_MOST}`, runningSince))
57
+ || living(processesOf(store, `SELECT pid, start_identity AS start FROM direct_chat_turn WHERE status = 'running' AND created_at > ?
58
+ LIMIT ${PROCESS_ROWS_AT_MOST}`, runningSince));
37
59
  }
38
- export function planLimitsWanted(store, now) {
60
+ export function planLimitsWanted(store, now, alive) {
39
61
  const viewed = viewedAt.get(store);
40
62
  if (viewed !== undefined && now.getTime() - viewed >= 0 && now.getTime() - viewed < PLAN_LIMITS_VIEW_WINDOW_MS)
41
63
  return true;
42
- return agentWorkActive(store, now);
64
+ return agentWorkActive(store, now, alive);
43
65
  }
44
66
  export function directChatRunning(store, provider, now) {
45
67
  const since = new Date(now.getTime() - RUNNING_AT_MOST_MS).toISOString();
@@ -604,8 +604,8 @@ export function testSkill(store, args, now = new Date()) {
604
604
  ? `Test ${skill.name}`
605
605
  : `Revise test: ${skill.name}`,
606
606
  repo: args.repo,
607
- goal: `Test skill ${skill.name} version ${skill.sha} with this sample request:\n${sample}${feedback ? `\nFeedback from test run #${args.sourceRun}:\n${feedback}` : ""}\nRead the supplied SKILL.md, perform the parts allowed in a read-only report task, and report the actual output, files read, and missing tools or permissions. Do not claim a successful test for steps you could not perform.`,
608
- outOfScope: "No repository changes, deployments, messages to other people, external writes, dependency installation or permission changes. Report any skill steps that require these actions.",
607
+ goal: `Test skill ${skill.name} version ${skill.sha} with this sample request:\n${sample}${feedback ? `\nFeedback from test run #${args.sourceRun}:\n${feedback}` : ""}\nRead the supplied SKILL.md, perform the parts a report task allows (reading the project; a report that changes a file fails, and nothing it wrote is kept), and report the actual output, files read, and missing tools or permissions. Do not claim a successful test for steps you could not perform.`,
608
+ outOfScope: "Nothing it changes in the project is kept (a report that changes a file fails). No deployments, messages to other people, external writes, dependency installation or permission changes. Report any skill steps that require these actions.",
609
609
  acceptance: [
610
610
  {
611
611
  id: "skill-result",
@@ -10,6 +10,7 @@ import { cancelDirectChatShip, executeDirectChatShip, listDirectChatShips, previ
10
10
  import { soloNow } from "../install-mode.js";
11
11
  import { backgroundInstalled } from "../laptop-background.js";
12
12
  import { localOwnerStandsNow } from "../local-owner.js";
13
+ import { gitCommand, UNSAFE_FOLDER } from "../local-landing.js";
13
14
  import { projectName, rowVisible } from "../project.js";
14
15
  import { handlersOf } from "./handler-registry.js";
15
16
  import { redirect, respond } from "./http.js";
@@ -597,12 +598,21 @@ export function createDirectChatHandlers(runtime, deps) {
597
598
  const changes = diff.changedFiles.length === 0 ? html `<p class="k-note">No changes in its copy of the project.</p>`
598
599
  : html `<p class="k-note">${diff.changedFiles.length} ${diff.changedFiles.length === 1 ? "file" : "files"} changed in its own copy of the project, as of its last turn${running ? " (it's still working)" : ""}.</p><ul>${diff.changedFiles.map(file => html `<li class="k-mono">${file}</li>`)}</ul>${shownDiff === "" ? "" : html `<details><summary>The changes</summary><pre class="k-mono" data-direct-chat-diff>${shownDiff}</pre></details>`}`;
599
600
  const ships = listDirectChatShips(store, thread.id);
600
- const shipped = ships.length === 0 ? "" : html `<ul>${ships.map(one => html `<li>${one.mode === "keep-branch" ? "Saved as branch" : "Shipped"} <span class="k-mono">${one.branch}</span> · ${one.state}${one.taskId === null ? "" : html ` · <a class="k-link" href="/t/${encodeURIComponent(one.taskId)}">Open task</a>`}</li>`)}</ul>`;
601
+ const bringIn = (one) => {
602
+ if (one.mode !== "keep-branch" || one.state !== "kept" || !/^[0-9a-f]{40}$/.test(one.candidateSha))
603
+ return "";
604
+ const command = gitCommand(one.repo, ["merge", "--ff-only", one.candidateSha]);
605
+ return command === null ? html `<br><span class="k-note">${UNSAFE_FOLDER(`git merge --ff-only ${one.candidateSha}`)}</span>`
606
+ : html `<br>To bring it in: <code class="k-mono" data-direct-chat-merge>${command}</code>`;
607
+ };
608
+ const shipped = ships.length === 0 ? "" : html `<ul>${ships.map(one => html `<li>${one.mode === "keep-branch" ? "Saved as branch" : "Shipped"} <span class="k-mono">${one.branch}</span> · ${one.state}${one.taskId === null ? "" : html ` · <a class="k-link" href="/t/${encodeURIComponent(one.taskId)}">Open task</a>`}${bringIn(one)}</li>`)}</ul>`;
609
+ const again = ctx.url.searchParams.get("review") === "again" && !running && diff.changedFiles.length > 0
610
+ ? html `<p class="k-note" data-direct-chat-review-again>That Ship review isn't kept after you leave it. Press Review Ship to see it again.</p>` : "";
601
611
  const shipAct = running || diff.changedFiles.length === 0 ? "" : postForm(`/direct-chats/${thread.id}/ship-review`, btn("Review Ship", { variant: "primary", type: "submit" }));
602
612
  const reply = thread.isLegacy ? html `<p class="k-note" data-direct-chat-read-only>Imported from an earlier version: read only. Start a new Direct Chat to go on.</p>`
603
613
  : running ? html `<p class="k-note">It's working on your last message. Reply when it finishes.</p>`
604
614
  : postForm(`/direct-chats/${thread.id}/reply`, html `${field({ id: "direct-chat-reply", label: "Reply", control: textarea({ id: "direct-chat-reply", name: "prompt", rows: 3, attrs: { required: true, maxlength: "20000" } }) })}${btn("Send", { variant: "primary", type: "submit" })}`, { hidden: { request: randomBytes(16).toString("hex") } });
605
- const body = html `<h1>${thread.title || "Direct Chat"}</h1><p class="k-note">${thread.project} · ${thread.provider}${thread.modelId ? ` · ${thread.modelId}` : ""}${running ? " · Working" : ""}</p>${turnHtml}${reply}<h2>Changes</h2>${changes}<h2>Ship</h2>${shipped}${shipAct === "" && ships.length === 0 ? html `<p class="k-note">${running ? "Ship opens when it finishes." : "Nothing to ship yet."}</p>` : shipAct}<p><a class="k-link" href="/direct-chats">All Direct Chats</a></p>`;
615
+ const body = html `<h1>${thread.title || "Direct Chat"}</h1><p class="k-note">${thread.project} · ${thread.provider}${thread.modelId ? ` · ${thread.modelId}` : ""}${running ? " · Working" : ""}</p>${turnHtml}${reply}<h2>Changes</h2>${changes}<h2>Ship</h2>${again}${shipped}${shipAct === "" && ships.length === 0 ? html `<p class="k-note">${running ? "Ship opens when it finishes." : "Nothing to ship yet."}</p>` : shipAct}<p><a class="k-link" href="/direct-chats">All Direct Chats</a></p>`;
606
616
  return runtime.sendScreen(ctx.response, 200, screen(thread.title || "Direct Chat", body, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
607
617
  }
608
618
  async function pageReply(ctx) {
@@ -634,10 +644,24 @@ export function createDirectChatHandlers(runtime, deps) {
634
644
  return pageRefusal(ctx, res.status, res.error);
635
645
  const preview = res.preview;
636
646
  const local = gate.who.authority === "local-owner";
637
- const facts = html `<ul><li>${preview.mode === "keep-branch" ? "Saved as branch" : "Shipped from branch"} <span class="k-mono">${preview.branch}</span></li><li>${preview.changedFiles.length} ${preview.changedFiles.length === 1 ? "file" : "files"}: ${preview.changedFiles.slice(0, 20).join(", ")}${preview.changedFiles.length > 20 ? "…" : ""}</li><li>${preview.checkCommand === null ? "No check command" : html `Check: <span class="k-mono">${preview.checkCommand}</span>`}</li><li>${preview.mergeSummary}</li>${preview.autoMergeReason === null ? "" : html `<li>${preview.autoMergeReason}</li>`}</ul>`;
647
+ const facts = html `<ul><li>${preview.mode === "keep-branch" ? "Save the branch" : "Ship from branch"} <span class="k-mono">${preview.branch}</span></li><li>${preview.changedFiles.length} ${preview.changedFiles.length === 1 ? "file" : "files"}: ${preview.changedFiles.slice(0, 20).join(", ")}${preview.changedFiles.length > 20 ? "…" : ""}</li><li>${preview.checkCommand === null ? "No check command" : html `Check: <span class="k-mono">${preview.checkCommand}</span>`}</li><li>${preview.mergeSummary}</li>${preview.autoMergeReason === null ? "" : html `<li>${preview.autoMergeReason}</li>`}</ul>`;
638
648
  const form = postForm(`/direct-chats/${threadId}/ship`, html `${local ? "" : html `<label>Password<input type="password" name="password" autocomplete="current-password" required></label>`}${btn(preview.mode === "keep-branch" ? "Save the branch" : "Ship it", { variant: "primary", type: "submit" })} ${btn("Cancel", { variant: "ghost", href: `/direct-chats/${threadId}` })}`, { hidden: { mode: preview.mode, termsDigest: preview.termsDigest, title: preview.title, goal: preview.goal } });
639
649
  return runtime.sendScreen(ctx.response, 200, screen("Ship", html `<h1>Ship ${preview.title}</h1>${facts}${form}`, { chrome: runtime.chromeFor(thread.repo, "tasks") }));
640
650
  }
651
+ async function pageShipReviewAgain(ctx) {
652
+ const gate = admit(ctx, null);
653
+ if (!gate.ok)
654
+ return pageRefusal(ctx, gate.status, gate.error);
655
+ const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
656
+ return redirect(ctx.response, `/direct-chats/${threadId}?review=again`);
657
+ }
658
+ async function pageShipDone(ctx) {
659
+ const gate = admit(ctx, null);
660
+ if (!gate.ok)
661
+ return pageRefusal(ctx, gate.status, gate.error);
662
+ const threadId = PAGE_PATH.exec(ctx.url.pathname)?.[1] ?? "";
663
+ return redirect(ctx.response, `/direct-chats/${threadId}`);
664
+ }
641
665
  async function pageShip(ctx) {
642
666
  const gate = admit(ctx, "direct-chat-ship");
643
667
  if (!gate.ok)
@@ -667,6 +691,8 @@ export function createDirectChatHandlers(runtime, deps) {
667
691
  "direct-chat.page": pageDetail,
668
692
  "direct-chat.page-ship-review": pageShipReview,
669
693
  "direct-chat.page-ship": pageShip,
694
+ "direct-chat.page-ship-review-again": pageShipReviewAgain,
695
+ "direct-chat.page-ship-done": pageShipDone,
670
696
  "direct-chat.page-reply": pageReply,
671
697
  "direct-chat.list": list,
672
698
  "direct-chat.detail": detail,
@@ -11,7 +11,7 @@ import { laptopShipProblem } from "../flexible-laptop.js";
11
11
  import { threadsStatusNote, tidyFlexibleSignIns } from "../flexible-sign-in.js";
12
12
  import { FLEXIBLE_UNAVAILABLE } from "../flexible.js";
13
13
  import { saveFlexibleBranch } from "../flexible-save.js";
14
- import { admitFlexibleThreadOwner, answerFlexibleRequest, cancelFlexibleThreadShip, closeFlexibleSessions, closeFlexibleThread, continueFlexibleThread, flexibleThreadShipTerms, latestFlexibleShip, sendBackFlexibleThread, shipFlexibleThread, tidyEndedFlexibleThreads, flexibleThreadChangeOf, flexibleThreadEdited, flexibleThreadLiveOf, flexibleThreadsOf, FLEXIBLE_WAIT_MS, flexibleThreadsExist, flexibleWorkOpen, openFlexibleSessions, recoverFlexibleHolders, startFlexibleThread, settleFlexibleStops, tickFlexibleSessions, waitFlexibleThreadChange, flexibleThreadChanges, flexibleThreadTipOf } from "../flexible-session.js";
14
+ import { admitFlexibleThreadOwner, answerFlexibleRequest, cancelFlexibleThreadShip, closeFlexibleSessions, closeFlexibleThread, continueFlexibleThread, flexibleShipNeedsFor, flexibleThreadShipTerms, latestFlexibleShip, sendBackFlexibleThread, shipFlexibleThread, tidyEndedFlexibleThreads, flexibleThreadChangeOf, flexibleThreadEdited, flexibleThreadLiveOf, flexibleThreadsOf, FLEXIBLE_WAIT_MS, flexibleThreadsExist, flexibleWorkOpen, openFlexibleSessions, recoverFlexibleHolders, startFlexibleThread, settleFlexibleStops, tickFlexibleSessions, waitFlexibleThreadChange, flexibleThreadChanges, flexibleThreadTipOf } from "../flexible-session.js";
15
15
  import { createFlexibleLauncher } from "../flexible-launcher.js";
16
16
  import { FLEXIBLE_NEXT_WORDS, flexibleReadiness, flexibleStartCard } from "../flexible-start.js";
17
17
  import { summaryLines } from "../approval-summary.js";
@@ -171,7 +171,7 @@ export function createEngineHandlers(runtime) {
171
171
  const admitted = admitFlexibleThreadOwner(store, sessions, { thread, viewer: { name: who.name }, canAccess: repo => store.accountCanAccess(who.name, repo) });
172
172
  return admitted.ok ? admitted.repo : null;
173
173
  };
174
- const acted = (response, status, outcome, words, next) => json(response, status, next === undefined ? { outcome, words } : { outcome, words, next });
174
+ const acted = (response, status, outcome, words, next, command = null) => json(response, status, { outcome, words, ...(next === undefined ? {} : { next }), ...(command === null ? {} : { command }) });
175
175
  async function liveThread(ctx) {
176
176
  const { url, who, request, response } = ctx;
177
177
  if (who.via !== "cookie")
@@ -577,7 +577,8 @@ export function createEngineHandlers(runtime) {
577
577
  if (!done.ok)
578
578
  return acted(response, 409, "refused", done.message);
579
579
  const words = act === "end"
580
- ? done.already ? "This thread had already ended." : done.stopPending ? "Ended. Stopping its agent…" : "Ended. You can still ship its work."
580
+ ? done.already ? "This thread had already ended." : done.stopPending ? "Ended. Stopping its agent…"
581
+ : flexibleShipNeedsFor(store, id) === null ? "Ended. You can still ship its work, or save it as a branch." : "Ended. You can still save its work as a branch (S on the thread)."
581
582
  : done.stopPending ? "Stopping its agent…" : "Stopped. Reply to go on.";
582
583
  return acted(response, 200, "done", words);
583
584
  };
@@ -594,7 +595,7 @@ export function createEngineHandlers(runtime) {
594
595
  const by = { name: who.name, generation: who.session.generation };
595
596
  const shown = await flexibleThreadShipTerms(store, { thread: id, by });
596
597
  if (!shown.ok)
597
- return acted(response, 409, "refused", shown.message);
598
+ return acted(response, 409, "refused", shown.message, undefined, shown.reason === "no-check" || shown.reason === "no-publishing" ? `toolroll thread save ${id.slice(0, 8)}` : null);
598
599
  const laptop = who.authority === "local-owner" && who.session.localGeneration !== null
599
600
  && laptopShipProblem(store, { owner: who.name, localGeneration: who.session.localGeneration }) === null;
600
601
  const command = `toolroll thread ship ${id} --key ${shown.summary.key}`;
@@ -677,7 +678,7 @@ export function createEngineHandlers(runtime) {
677
678
  const saved = await saveFlexibleBranch(store, { thread: id, by: { name: who.name, generation: who.session.generation }, now: new Date(), prove: held });
678
679
  if (!saved.ok)
679
680
  return acted(response, 409, "refused", saved.message);
680
- return acted(response, 200, "done", `${saved.already ? `Already saved as ${saved.branch}.` : `Saved as ${saved.branch} (commit ${saved.candidate.slice(0, 12)}).`} ${saved.next}`);
681
+ return acted(response, 200, "done", `${saved.already ? `Already saved as ${saved.branch}.` : `Saved as ${saved.branch} (commit ${saved.candidate.slice(0, 12)}).`} ${saved.next}`, undefined, saved.command);
681
682
  }
682
683
  async function leadChat(ctx) {
683
684
  const { url, who, request, response, now } = ctx;
@@ -2345,6 +2345,11 @@ export function landingCardHtml(landing, csrf) {
2345
2345
  const act = csrf === "" ? "" : landing.canLand
2346
2346
  ? postForm(`${taskHref(landing.taskId)}/land`, btn("Land it", { type: "submit" }))
2347
2347
  : landing.canUndo ? postForm(`${taskHref(landing.taskId)}/land`, btn("Undo landing", { variant: "ghost", type: "submit" }), { hidden: { undo: "1" } }) : "";
2348
+ const kept = landing.landed === null ? landing.kept ?? null : null;
2349
+ if (kept !== null) {
2350
+ const how = kept.command === null ? html `<p>${kept.words}</p>` : html `<p>To bring it in: <code class="k-mono" data-land-command>${kept.command}</code></p>`;
2351
+ return html `<section class="card" id="land" data-landing="kept"><strong>Landing commit ${kept.commit.slice(0, 7)} is ready</strong><p class="meta">Your project folder has ${kept.branch} checked out, so Toolroll didn't touch it.</p>${how}</section>`;
2352
+ }
2348
2353
  const title = landing.landed !== null && !landing.canLand ? landing.landed : "Not on your branch yet";
2349
2354
  const meta = landing.canLand ? "You see where it lands before anything moves." : "";
2350
2355
  return html `<section class="card" id="land" data-landing="${landing.landed === null ? "no" : "yes"}"><strong>${title}</strong>${meta === "" ? "" : html `<p class="meta">${meta}</p>`}${act}</section>`;
@@ -282,6 +282,8 @@ get("tasks", "direct-chat.list", "/engine/direct-chats", DIRECT_CHAT);
282
282
  get("tasks", "direct-chat.detail", `^\\/engine\\/direct-chats\\/${TERMINAL}$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}` });
283
283
  get("tasks", "direct-chat.page-list", "/direct-chats", DIRECT_CHAT);
284
284
  get("tasks", "direct-chat.page", `^\\/direct-chats\\/${TERMINAL}$`, { ...DIRECT_CHAT, sample: `/direct-chats/${"a".repeat(32)}` });
285
+ get("tasks", "direct-chat.page-ship-review-again", `^\\/direct-chats\\/${TERMINAL}\\/ship-review$`, { ...DIRECT_CHAT, sample: `/direct-chats/${"a".repeat(32)}/ship-review` });
286
+ get("tasks", "direct-chat.page-ship-done", `^\\/direct-chats\\/${TERMINAL}\\/ship$`, { ...DIRECT_CHAT, sample: `/direct-chats/${"a".repeat(32)}/ship` });
285
287
  get("tasks", "direct-chat.artifact", `^\\/engine\\/direct-chats\\/${TERMINAL}\\/artifacts\\/${TERMINAL}$`, { ...DIRECT_CHAT, sample: `/engine/direct-chats/${"a".repeat(32)}/artifacts/${"b".repeat(32)}` });
286
288
  get("pages", "projects.browse", "/projects/browse", free);
287
289
  get("pages", "projects.pick", "/projects/pick", { ...free, callers: ["cookie"], project: "none", ...approver("Sign in as an approver to add projects.", "/projects") });
@@ -353,6 +355,7 @@ get("tasks", "task.diff", `^\\/t\\/${TASK}\\/diff$`, { project: "task", limited:
353
355
  get("tasks", "task.result", `^\\/t\\/${TASK}\\/result$`, { project: "task", limited: "resource", ...free, sample: "/t/one/result" });
354
356
  get("tasks", "task.approval", `^\\/t\\/${TASK}\\/approval$`, { project: "task", limited: "resource", callers: ["cookie"], ...free, sample: "/t/one/approval" });
355
357
  get("tasks", "task.release", `^\\/t\\/${TASK}\\/release$`, { project: "task", limited: "resource", ...free, sample: "/t/one/release" });
358
+ get("tasks", "task.land-again", `^\\/t\\/${TASK}\\/land$`, { project: "task", limited: "resource", ...free, sample: "/t/one/land" });
356
359
  get("tasks", "release.locate", `^\\/approve\\/${ID}$`, { project: "task-ref", limited: "resource", ...free, sample: "/approve/1" });
357
360
  get("pages", "ledger.export", "/ledger/export", { limited: "unscoped", ...free });
358
361
  get("tasks", "runs", "/runs", { limited: "collection", ...free });
@@ -170,7 +170,7 @@ function yourPasswordSection(deps) {
170
170
  ? [formRow("Forgot it?", "On the computer running Toolroll, run this to choose a new one:", html ``, "wide"), codeLine("toolroll password reset")]
171
171
  : [formRow("Where it is", "Your first password is saved on the computer running Toolroll. Toolroll never shows it in a browser. To read it, run this there:", html ``, "wide"), codeLine(`cat ${saved}`)];
172
172
  })(),
173
- summary.passwordless === null ? "" : formRow("Passwordless", "Sign in once; most approvals then need no password.", btn(`${summary.passwordless ? "On" : "Off"} · Change`, { sm: true, href: "/settings/passwordless" }), "inline"),
173
+ summary.passwordless === null ? "" : formRow("Passwordless", "Sign in once; most approvals then need no password. Settings → Passwordless lists what still asks.", btn(`${summary.passwordless ? "On" : "Off"} · Change`, { sm: true, href: "/settings/passwordless" }), "inline"),
174
174
  ]),
175
175
  }),
176
176
  };
@@ -1,4 +1,4 @@
1
- import { PASSWORDLESS_TRADE, passwordlessSetting, setPasswordless } from "../passwordless.js";
1
+ import { PASSWORDLESS_OTHERS, PASSWORDLESS_STILL_ASKS, PASSWORDLESS_TRADE, passwordlessSetting, setPasswordless } from "../passwordless.js";
2
2
  import { approveNetworkRequest } from "../agent-network-request.js";
3
3
  import { declareJustMe, installModeNow, sessionStandsIn, soloNow, TEAM_FACT_WORDS } from "../install-mode.js";
4
4
  import { ACP_AGENTS, isKeyedProvider } from "../acp-agents.js";
@@ -121,9 +121,9 @@ import { deleteProject, holdingsWords, PROJECT_RECOVERY_DELETE_MESSAGE } from ".
121
121
  import { applySavedKnowledge, changeKnowledge, knowledgeVersion, knowledgeView } from "../project-knowledge.js";
122
122
  import { changeLearning } from "../project-learning.js";
123
123
  import { listDecisions, recordDecision, retireDecision, searchMemory } from "../project-memory.js";
124
- import { changeSkills, githubSkill, importSkill, reviseSkillTest, skillsView, testSkill } from "../project-skills.js";
124
+ import { changeSkills, effectiveSkillsForRepo, githubSkill, importSkill, reviseSkillTest, skillsView, testSkill } from "../project-skills.js";
125
125
  import { changeLibrarySkill, currentLibrary, dismissHeldBundleUpdate, enabledLibrarySkills, importGithubSkillBundle, importLibrarySkill, rollbackSkillBundle, setBundleAutoUpdate, setProjectSkillOptOut, skillLibraryView, sweepSkillBundleUpdates } from "../skill-library.js";
126
- import { LOCAL_SKILL_TOOLS, setLocalSkillSync, syncEnabledLocalTools } from "../skill-local-sync.js";
126
+ import { LOCAL_SKILL_TOOLS, LOCAL_TOOL_LABELS, setLocalSkillSync, syncEnabledLocalTools } from "../skill-local-sync.js";
127
127
  import { skillLibrarySectionHtml } from "../skills-ui.js";
128
128
  import { signedIn } from "../oauth-run-token.js";
129
129
  import { addToolTo, catalogTool, localAppOf, removeToolFrom, setToolSecret, splitCommandLine, testToolOf, toolSecretStorage } from "../project-tools.js";
@@ -317,32 +317,7 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
317
317
  const chosen = url.searchParams.get("repo") ?? project ?? projects[0] ?? "";
318
318
  if (chosen && !projects.includes(chosen))
319
319
  return refuse(response, who, 403, "That project is outside your access.", "/projects");
320
- const selector = projectPicker("/settings/skills", projects.map(repo => ({ repo, name: projectName(repo) })), chosen);
321
- const canManage = who.role === "approver";
322
- const csrf = who.via === "cookie" ? who.session.csrf : "";
323
- let globalContent = html ``;
324
- try {
325
- const libView = skillLibraryView(store, { repo: chosen || null });
326
- globalContent = skillLibrarySectionHtml(libView, libView.localSync, csrf, canManage, {
327
- repo: chosen,
328
- said: url.searchParams.get("said"),
329
- error: url.searchParams.get("problem"),
330
- });
331
- }
332
- catch (error) {
333
- globalContent = html `<p class="problem" role="alert">${error instanceof Error ? error.message : "Global skill library is unavailable."}</p>`;
334
- }
335
- let content = html `<p>Add a project to manage project-specific skills.</p>`;
336
- if (chosen) {
337
- try {
338
- const agent = resolvePhaseAgent(store, 'build', chosen, {});
339
- content = (skillsHtml(skillsView(store, chosen, who.name), csrf, canManage, { focus: url.searchParams.get('skill') ?? '', agent: agent.ok ? `Report agent: ${agent.spec.provider} · ${agent.spec.model ?? 'default'}. Change it on the test task before approval` : 'Choose a report agent on the test task before approval' }));
340
- }
341
- catch (error) {
342
- content = html `<p class="problem" role="alert">${error instanceof Error ? error.message : 'Skills are unavailable. Reload to retry.'}</p>`;
343
- }
344
- }
345
- return sendScreen(response, 200, screen('Skills', settingsSubPage("agents", "Skills", html `${url.searchParams.get('saved') === '1' ? html `<p role="status">Saved.</p>` : ''}${globalContent}${selector}${content}`), { chrome: chromeFor(chosen || project, 'settings'), functional: { script: skillsScript() } }));
320
+ return skillsScreen(ctx, chosen, { said: url.searchParams.get("said"), problem: url.searchParams.get("problem") }, 200);
346
321
  }
347
322
  async function toolsPage(ctx) {
348
323
  const { url, who, response, project } = ctx;
@@ -573,7 +548,7 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
573
548
  const setting = passwordlessSetting(store);
574
549
  const said = url.searchParams.get("said"), problem = url.searchParams.get("problem");
575
550
  const since = setting.at === null ? null : `${setting.on ? "on" : "off"} since ${new Date(setting.at).toLocaleString("en-US", { dateStyle: "medium", timeStyle: "short" })}, by ${setting.setBy ?? "someone"}`;
576
- return sendScreen(response, 200, screen("Passwordless", passwordlessHtml({ on: sessionStandsIn(store), since, trade: PASSWORDLESS_TRADE, said, problem }), { chrome: chromeFor(project, "settings") }));
551
+ return sendScreen(response, 200, screen("Passwordless", passwordlessHtml({ on: sessionStandsIn(store), since, trade: PASSWORDLESS_TRADE, stillAsks: PASSWORDLESS_STILL_ASKS, others: PASSWORDLESS_OTHERS, said, problem }), { chrome: chromeFor(project, "settings") }));
577
552
  }
578
553
  async function passwordlessSave(ctx) {
579
554
  const { response, now, posted } = ctx;
@@ -3589,8 +3564,8 @@ ${postForm("/settings/chat-approval/save", html `\
3589
3564
  const lib = enabledLibrarySkills(store);
3590
3565
  const res = setLocalSkillSync(store, { tool: tool, enabled, actor: who.name, skills: lib.packages, libraryRevision: lib.revision }, now);
3591
3566
  said = enabled && res
3592
- ? `Synced ${res.written.length} skill${res.written.length === 1 ? "" : "s"} to ${tool}${res.skippedForeign.length ? ` (left ${res.skippedForeign.length} of your own skills untouched)` : ""}.`
3593
- : `Turned off local sync for ${tool} and removed Toolroll-managed skills.`;
3567
+ ? `Synced ${res.written.length} skill${res.written.length === 1 ? "" : "s"} to ${LOCAL_TOOL_LABELS[tool]}${res.skippedForeign.length ? ` (left ${res.skippedForeign.length} of your own skills untouched)` : ""}.`
3568
+ : `Turned off local sync for ${LOCAL_TOOL_LABELS[tool]} and removed Toolroll-managed skills.`;
3594
3569
  }
3595
3570
  else if (action === "local-sync-now") {
3596
3571
  const lib = enabledLibrarySkills(store);
@@ -3603,8 +3578,55 @@ ${postForm("/settings/chat-approval/save", html `\
3603
3578
  return backWith("said", said);
3604
3579
  }
3605
3580
  catch (error) {
3606
- return backWith("problem", error instanceof Error ? error.message : "Could not update the skill library.");
3581
+ const why = error instanceof Error ? error.message : "Could not update the skill library.";
3582
+ if (action === "import-bundle")
3583
+ return skillsScreen(ctx, repo, { problem: `${why.replace(/\.?$/, ".")} Nothing was imported.`, bundleUrl: (body.get("url") ?? "").slice(0, 2000) }, 409);
3584
+ return backWith("problem", why);
3585
+ }
3586
+ }
3587
+ function skillsScreen(ctx, chosen, extra, status) {
3588
+ const { url, who, response, project } = ctx;
3589
+ const projects = consoleProjects();
3590
+ const selector = projectPicker("/settings/skills", projects.map(repo => ({ repo, name: projectName(repo) })), chosen, { evenOne: true });
3591
+ const canManage = who.role === "approver";
3592
+ const csrf = who.via === "cookie" ? who.session.csrf : "";
3593
+ let view = null, viewProblem = null;
3594
+ if (chosen) {
3595
+ try {
3596
+ view = skillsView(store, chosen, who.name);
3597
+ }
3598
+ catch (error) {
3599
+ viewProblem = error instanceof Error ? error.message : "Skills are unavailable. Reload to retry.";
3600
+ }
3601
+ }
3602
+ let globalContent = html ``;
3603
+ try {
3604
+ const libView = skillLibraryView(store, { repo: chosen || null });
3605
+ globalContent = skillLibrarySectionHtml(libView, libView.localSync, csrf, canManage, {
3606
+ repo: chosen,
3607
+ said: extra.said ?? null,
3608
+ error: extra.problem ?? null,
3609
+ ...(view === null ? {} : { projectSelection: view.selection }),
3610
+ ...(extra.bundleUrl === undefined ? {} : { bundleUrl: extra.bundleUrl }),
3611
+ });
3612
+ }
3613
+ catch (error) {
3614
+ globalContent = html `<p class="problem" role="alert">${error instanceof Error ? error.message : "Global skill library is unavailable."}</p>`;
3615
+ }
3616
+ let content = html `<p>Add a project to manage project-specific skills.</p>`;
3617
+ if (viewProblem !== null)
3618
+ content = html `<p class="problem" role="alert">${viewProblem}</p>`;
3619
+ else if (view !== null) {
3620
+ try {
3621
+ const agent = resolvePhaseAgent(store, 'build', chosen, {});
3622
+ content = (skillsHtml(view, csrf, canManage, { focus: url.searchParams.get('skill') ?? '', effective: effectiveSkillsForRepo(store, chosen).packages, agent: agent.ok ? `Report agent: ${agent.spec.provider} · ${agent.spec.model ?? 'default'}. Change it on the test task before approval` : 'Choose a report agent on the test task before approval' }));
3623
+ }
3624
+ catch (error) {
3625
+ content = html `<p class="problem" role="alert">${error instanceof Error ? error.message : 'Skills are unavailable. Reload to retry.'}</p>`;
3626
+ }
3607
3627
  }
3628
+ const title = chosen ? `Skills for ${projectName(chosen)}` : "Skills";
3629
+ return sendScreen(response, status, screen('Skills', settingsSubPage("agents", title, html `${url.searchParams.get('saved') === '1' ? html `<p role="status">Saved.</p>` : ''}${selector}${globalContent}${content}`), { chrome: chromeFor(chosen || project, 'settings'), functional: { script: skillsScript() } }));
3608
3630
  }
3609
3631
  return { registrations, modelsView };
3610
3632
  }
@@ -1,5 +1,5 @@
1
1
  import { localOwnerRefusal } from "../local-owner.js";
2
- import { broughtInOnBranch, landedWords, landingOf, publishesThroughPullRequests, recognisedOnBranch } from "../local-landing.js";
2
+ import { broughtInOnBranch, keptHandoffOf, landedStanding, landingOf, publishesThroughPullRequests, recognisedOnBranch } from "../local-landing.js";
3
3
  import { requestContext } from "./request-context.js";
4
4
  import { heldFindingCount } from "../findings.js";
5
5
  import { familyInWebReach } from "../findings.js";
@@ -620,8 +620,11 @@ export function createTaskViews(runtime) {
620
620
  const person = who.via === "cookie" && who.role === "approver";
621
621
  const onBranch = record === null || record.undone ? recognisedOnBranch(runtime.store, repo, rootId, complete ? assignment?.receipt?.head ?? null : null, baseGit) : null;
622
622
  if (onBranch !== null)
623
- return { taskId: rootId, landed: onBranch, canLand: false, canUndo: person && broughtInOnBranch(runtime.store, repo, rootId, baseGit) };
624
- return { taskId: rootId, landed: landedWords(runtime.store, rootId), canLand: person && complete && (record === null || record.undone), canUndo: person && record !== null && !record.undone };
623
+ return { taskId: rootId, landed: onBranch.words, canLand: false, canUndo: person && !onBranch.reverted && broughtInOnBranch(runtime.store, repo, rootId, baseGit) };
624
+ const standing = landedStanding(runtime.store, rootId, baseGit);
625
+ const kept = complete && (record === null || record.undone) ? keptHandoffOf(runtime.store, repo, rootId, assignment?.receipt?.head ?? null) : null;
626
+ return { taskId: rootId, landed: standing?.words ?? null, canLand: person && complete && (record === null || record.undone), canUndo: person && record !== null && !record.undone && standing?.reverted !== true,
627
+ ...(kept === null ? {} : { kept }) };
625
628
  }
626
629
  function failureOf(runs, assignment, readLog = true) {
627
630
  const last = latestFinishedAttempt(runs);