toolroll 0.9.117 → 0.9.119

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +14 -14
  3. package/dist/agent-fence.js +54 -6
  4. package/dist/assignment.js +40 -29
  5. package/dist/browser/workspace.css +1 -1
  6. package/dist/browser/workspace.js +32 -31
  7. package/dist/builder.js +295 -237
  8. package/dist/central-recovery-stage.js +3 -3
  9. package/dist/check-failure.js +2 -2
  10. package/dist/check-levels.js +3 -0
  11. package/dist/check-report.js +58 -7
  12. package/dist/coding-context.js +16 -2
  13. package/dist/coding-provider.js +7 -3
  14. package/dist/coding-workspace.js +5 -5
  15. package/dist/contracts/console-api.js +4 -1
  16. package/dist/contracts/engine-api.js +1 -0
  17. package/dist/contracts/release-check.js +7 -4
  18. package/dist/contracts/release-terms.js +11 -2
  19. package/dist/contracts/verification-receipt.js +1 -1
  20. package/dist/deploy-gate.js +7 -1
  21. package/dist/direct-chat.js +3 -3
  22. package/dist/easy-start.js +8 -6
  23. package/dist/engine-reads.js +72 -0
  24. package/dist/flexible-conversation-schema.js +24 -0
  25. package/dist/flexible-conversation.js +162 -0
  26. package/dist/flexible-custody.js +3 -0
  27. package/dist/flexible-import.js +51 -0
  28. package/dist/flexible-session.js +84 -11
  29. package/dist/install-mode.js +1 -1
  30. package/dist/invoke.js +18 -6
  31. package/dist/local-landing.js +500 -0
  32. package/dist/local-owner.js +1 -0
  33. package/dist/operate.js +143 -22
  34. package/dist/passwordless.js +1 -1
  35. package/dist/planner.js +6 -1
  36. package/dist/project-delete.js +1 -0
  37. package/dist/project-skills.js +28 -13
  38. package/dist/rehearsal.js +27 -0
  39. package/dist/release-adapters.js +170 -2
  40. package/dist/release-approval.js +11 -8
  41. package/dist/release-card.js +7 -2
  42. package/dist/release-carry.js +1 -1
  43. package/dist/release-cli.js +115 -14
  44. package/dist/release-main-proof.js +49 -0
  45. package/dist/release-main.js +110 -0
  46. package/dist/release-recheck.js +10 -3
  47. package/dist/release.js +221 -33
  48. package/dist/reply-shape.js +6 -1
  49. package/dist/result-actions.js +7 -1
  50. package/dist/result-follow-ups.js +8 -4
  51. package/dist/scout.js +6 -2
  52. package/dist/serve.js +31 -14
  53. package/dist/server/direct-chat.js +88 -3
  54. package/dist/server/engine-api.js +43 -5
  55. package/dist/server/render-results.js +3 -1
  56. package/dist/server/render-tasks.js +10 -1
  57. package/dist/server/route-table.js +9 -0
  58. package/dist/server/settings.js +31 -7
  59. package/dist/server/task-views.js +15 -0
  60. package/dist/server/tasks.js +63 -3
  61. package/dist/settings-groups-ui.js +2 -2
  62. package/dist/skills-manifest.js +57 -0
  63. package/dist/store.js +29 -4
  64. package/dist/surface.js +9 -1
  65. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  66. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  67. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  68. package/dist/tui/linux-x64/toolroll-tui +0 -0
  69. package/dist/verification-evidence.js +17 -6
  70. package/dist/workspace-ui.js +1 -1
  71. package/package.json +3 -2
  72. package/scripts/release-proof.mjs +240 -0
package/dist/operate.js CHANGED
@@ -126,6 +126,7 @@ import { isWritesMode, writesWords } from "./writes-mode.js";
126
126
  import { linuxFenceAvailable, macosFenceAvailable } from "./agent-fence.js";
127
127
  import { parseMachLookup, parseReadDeny, readDenyWords } from "./project-sandbox.js";
128
128
  import { LOCAL_POLICY } from "./surface.js";
129
+ import { land, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "./local-landing.js";
129
130
  import { asLocalOwner, currentLocalOwner, localActNow, LOCAL_MODE_CONFINES, localModeOn, localOwnerRefusal, localOwnerRequested } from "./local-owner.js";
130
131
  import { CHECK_ACCESS_WARNINGS, checkAccessRunsAs, checkAccessWords, isCheckAccess, signInHostsMissing, signInsUnavailableWords, widerThan } from "./check-access.js";
131
132
  import { CLI_PASSWORD_SOURCE, withPasswordSource } from "./sign-in-guard.js";
@@ -720,7 +721,7 @@ export const TASK_ACTIONS = [
720
721
  "add", "new", "keep", "list", "show", "wait", "state", "block", "unblock", "next", "steer", "pause", "continue", "assign",
721
722
  "reopen", "scope", "approve", "hold", "unhold", "require", "requeue", "regate", "plan",
722
723
  "review", "accept", "repair", "route", "stop", "resume", "complete", "revise", "merge", "ask",
723
- "checks", "add-tests", "archive", "restore", "tidy", "ship", "ready", "handover", "before-after", "failing-first",
724
+ "checks", "add-tests", "archive", "restore", "tidy", "ship", "ready", "handover", "before-after", "failing-first", "land",
724
725
  ];
725
726
  export const PUBLISH_ACTIONS = ["setup", "grant", "revoke", "status", "unblock", "rearm", "merge", "refire"];
726
727
  export const CONFIG_ACTIONS = ["show", "set", "clear"];
@@ -737,6 +738,7 @@ export const OPERATE_VALUE_FLAGS = new Set([
737
738
  "for", "tick-every", "bridge-every", "reconcile-every", "incarnation",
738
739
  "say", "ceiling-usd", "cap-usd",
739
740
  "incident",
741
+ "into",
740
742
  "case", "k", "world", "deny", "abandon",
741
743
  "token-file", "bin", "poll", "github", "remote", "head-prefix", "password",
742
744
  "not-requester", "protect", "protect-paths",
@@ -769,6 +771,8 @@ export const OPERATE_BOOLEAN_FLAGS = new Set([
769
771
  "preview",
770
772
  "diagnostic", "keep",
771
773
  "no-carry",
774
+ "from-main", "full-check",
775
+ "rehearsal",
772
776
  "json", "yes", "all", "brief", "local", "history", "latest-watch", "dry-run", "file",
773
777
  "clear", "follow", "ready", "all-tasks", "inbound-only", "help", "undo", "anyone", "allow-dispatch", "allow-merge", "merge-delete-branch",
774
778
  "no-open", "single-process", "laptop", "web", "remove", "no-verify", "no-follow", "end", "report", "off", "tmux",
@@ -3438,14 +3442,17 @@ async function decideCommand(positional, flags, context) {
3438
3442
  "The task returns to the ready set; the next tick resumes it with your answer in hand.",
3439
3443
  ]);
3440
3444
  }
3441
- async function startConsole(options) {
3445
+ export async function startConsole(options) {
3442
3446
  const { context } = options;
3443
- noticeGitIncidents(context.store, context.clock);
3447
+ const rehearsal = options.rehearsal === true;
3448
+ if (!rehearsal)
3449
+ noticeGitIncidents(context.store, context.clock);
3444
3450
  const identities = projectIdentities(context.folderLook);
3445
3451
  const server = createDecisionServer({
3446
3452
  identities,
3447
3453
  store: context.store,
3448
- backgroundChecks: true,
3454
+ backgroundChecks: !rehearsal,
3455
+ ...(rehearsal ? { rehearsal: true } : {}),
3449
3456
  ...(context.desktopIdentity === undefined ? {} : { desktopIdentity: context.desktopIdentity }),
3450
3457
  ...(context.additionalProjectRepos === undefined || options.currentRepos === undefined ? {} : { additionalProjectRepos: options.currentRepos }),
3451
3458
  evidenceRoot: context.evidenceRoot,
@@ -3455,7 +3462,7 @@ async function startConsole(options) {
3455
3462
  ...(options.localRunner === undefined ? {} : { localRunner: options.localRunner }),
3456
3463
  poolRoot: options.poolRoot,
3457
3464
  ...(options.allowedHosts === undefined ? {} : { allowedHosts: options.allowedHosts }),
3458
- tailnetNames: context.tailnetNames ?? (() => readTailnetNames()),
3465
+ tailnetNames: rehearsal ? (async () => []) : context.tailnetNames ?? (() => readTailnetNames()),
3459
3466
  leadByDefault: true,
3460
3467
  ...(options.setupCode === undefined ? {} : { setupCode: options.setupCode }),
3461
3468
  ...(options.repos === undefined ? {} : { repos: options.repos }),
@@ -3477,6 +3484,11 @@ async function startConsole(options) {
3477
3484
  }).catch(error => {
3478
3485
  throw new Error(`could not listen on ${options.host}:${options.port} — ${describe(error)}`);
3479
3486
  });
3487
+ const bound = server.address();
3488
+ const port = typeof bound === "object" && bound !== null ? bound.port : options.port;
3489
+ const shown = options.host === "0.0.0.0" || options.host === "::" ? "localhost" : options.host;
3490
+ if (rehearsal)
3491
+ return { server, port, url: `http://${shown}:${port}/` };
3480
3492
  consoleIdentitiesInBackground(identities, [...options.repos ?? [], ...options.projectRoots ?? [], ...context.store.listProjects().map(one => one.path), ...context.store.knownRepos()]);
3481
3493
  const stopMonitoring = startMonitoring({
3482
3494
  store: context.store, settings: () => readMonitoring(dirname(context.databaseFile)),
@@ -3494,18 +3506,19 @@ async function startConsole(options) {
3494
3506
  ];
3495
3507
  server.on("close", () => { for (const stop of besideConsole)
3496
3508
  stop(); });
3497
- const bound = server.address();
3498
- const port = typeof bound === "object" && bound !== null ? bound.port : options.port;
3499
- const shown = options.host === "0.0.0.0" || options.host === "::" ? "localhost" : options.host;
3500
3509
  return { server, port, url: `http://${shown}:${port}/` };
3501
3510
  }
3502
3511
  async function serveCommand(flags, context) {
3503
3512
  const { store, write, json } = context;
3504
3513
  const portGiven = text(flags, "port");
3505
3514
  const port = Number(portGiven ?? 4180);
3506
- if (portGiven !== undefined && (!Number.isInteger(port) || port < 1 || port >= 65536))
3515
+ const rehearsal = flags.get("rehearsal") === true;
3516
+ if (portGiven !== undefined && (!Number.isInteger(port) || port < (rehearsal ? 0 : 1) || port >= 65536))
3507
3517
  return fail(write, json, "serve", "usage", "--port is a whole number under 65536", EXIT.usage);
3508
3518
  const host = text(flags, "host") ?? "127.0.0.1";
3519
+ if (rehearsal && (host !== "127.0.0.1" || ["allow-host", "public-url", "runner", "editor", "repo", "project-root"].some(one => flags.has(one)))) {
3520
+ return fail(write, json, "serve", "usage", "--rehearsal serves 127.0.0.1 only, with no --allow-host, --public-url, --runner, --editor, --repo or --project-root", EXIT.usage);
3521
+ }
3509
3522
  const allow = text(flags, "allow-host");
3510
3523
  const repoFlag = text(flags, "repo");
3511
3524
  const rootFlag = text(flags, "project-root");
@@ -3522,6 +3535,7 @@ async function serveCommand(flags, context) {
3522
3535
  context,
3523
3536
  host,
3524
3537
  port,
3538
+ ...(rehearsal ? { rehearsal: true } : {}),
3525
3539
  ...(setupCode === undefined ? {} : { setupCode }),
3526
3540
  ...(localRunner === undefined ? {} : { localRunner }),
3527
3541
  ...(publicUrl === undefined ? {} : { publicUrl }),
@@ -4651,10 +4665,17 @@ async function verifyCommand(positional, flags, context) {
4651
4665
  const { store, write, json } = context;
4652
4666
  const clock = context.clock ?? (() => new Date());
4653
4667
  const action = positional[0] ?? "show";
4654
- const repo = text(flags, "repo");
4668
+ const raw = text(flags, "repo");
4669
+ if (raw !== undefined && activeRemote() !== null && !isAbsolute(raw))
4670
+ return fail(write, json, `verify ${action}`, "usage", "name the project's full path: --repo <path>", EXIT.usage);
4671
+ const repo = raw === undefined ? undefined : verifyRepoOf(store, raw);
4672
+ const legacy = raw !== undefined && raw !== repo && !isAbsolute(raw) && store.liveVerifyCommand(raw) !== null ? raw : null;
4673
+ const legacyNote = legacy === null ? [] : [`An older check command saved under the name "${legacy}" applies to no project. Set the command for ${repo} again; \`toolroll verify clear --repo ${legacy}\` removes the old one.`];
4655
4674
  if (action === "show") {
4656
4675
  if (repo === undefined)
4657
4676
  return fail(write, json, "verify show", "usage", "which repo? --repo <path>", EXIT.usage);
4677
+ for (const line of json ? [] : legacyNote)
4678
+ write(line);
4658
4679
  const live = store.liveVerifyCommand(repo);
4659
4680
  const quick = liveQuickCommand(store, repo);
4660
4681
  const level = projectCheckLevel(store, repo);
@@ -4705,7 +4726,9 @@ async function verifyCommand(positional, flags, context) {
4705
4726
  if (acting === null || !verified?.ok)
4706
4727
  return refuseApprover(context, `verify ${action}`, verified, "an approved verification command runs unattended after every future build — changing it takes `--as <you> --token <t>`", repo);
4707
4728
  if (action === "clear") {
4708
- const cleared = store.clearVerifyCommand(grantKey, acting.name, clock());
4729
+ if (legacy !== null && !quickClear)
4730
+ store.clearVerifyCommand(legacy, acting.name, clock());
4731
+ const cleared = store.clearVerifyCommand(grantKey, acting.name, clock()) || (legacy !== null && !quickClear);
4709
4732
  if (quickClear)
4710
4733
  return succeed(write, json, "verify clear", { repo, cleared, level: "quick" }, () => [
4711
4734
  cleared ? `Cleared the quick command — Quick builds of ${repo} run the full check now.` : `No quick command was set for ${repo}.`,
@@ -7694,6 +7717,8 @@ function taskAction(action, rest, flags, context) {
7694
7717
  return reviewTaskCommand(rest, flags, context);
7695
7718
  case "accept":
7696
7719
  return acceptTaskProof(rest, flags, context);
7720
+ case "land":
7721
+ return landTaskCommand(rest, flags, context);
7697
7722
  case "repair":
7698
7723
  return repairTaskCommand(rest, flags, context);
7699
7724
  case "route":
@@ -8081,7 +8106,7 @@ function listTasks(flags, context) {
8081
8106
  }
8082
8107
  function showTask(positional, context) {
8083
8108
  const { store, write, json, now } = context;
8084
- const id = positional[0];
8109
+ const id = positional[0] === undefined ? undefined : resolveTaskId(store, positional[0]);
8085
8110
  if (id === undefined)
8086
8111
  return fail(write, json, "task show", "usage", "which task?", EXIT.usage);
8087
8112
  const task = store.getTask(id);
@@ -8753,6 +8778,11 @@ async function scopeTask(positional, flags, context) {
8753
8778
  let releaseTerms;
8754
8779
  let releaseCheck;
8755
8780
  let releaseNote = null;
8781
+ const fromMain = flags.get("from-main") === true;
8782
+ if ((fromMain || flags.get("full-check") === true) && releaseGiven === undefined)
8783
+ return fail(write, json, "task scope", "usage", "--from-main and --full-check go with --release <version>:<pull request>:<branch>", EXIT.usage);
8784
+ if (flags.get("full-check") === true && !fromMain)
8785
+ return fail(write, json, "task scope", "usage", "--full-check goes with --from-main", EXIT.usage);
8756
8786
  if (releaseGiven !== undefined) {
8757
8787
  const spec = /^(\d+\.\d+\.\d+):([1-9][0-9]*):([A-Za-z0-9._/-]+)$/.exec(releaseGiven);
8758
8788
  if (spec === null || candidateGiven === undefined)
@@ -8760,6 +8790,16 @@ async function scopeTask(positional, flags, context) {
8760
8790
  const repo = store.lookupRef(id)?.repo ?? null;
8761
8791
  if (repo === null)
8762
8792
  return fail(write, json, "task scope", "usage", "a release scope's task has to be placed in its project first", EXIT.usage);
8793
+ if (fromMain) {
8794
+ const purpose = releaseCheckPurposeFor(store, { repo, version: spec[1], pr: Number(spec[2]), branch: spec[3], candidate: candidateGiven, main: { check: flags.get("full-check") === true ? "full" : "deploy" } });
8795
+ if (!purpose.ok)
8796
+ return fail(write, json, "task scope", "refused", `This release from main can't be filed: ${purpose.why}.`, EXIT.refused);
8797
+ releaseCheck = purpose.purpose;
8798
+ }
8799
+ }
8800
+ if (releaseGiven !== undefined && candidateGiven !== undefined && !fromMain) {
8801
+ const spec = /^(\d+\.\d+\.\d+):([1-9][0-9]*):([A-Za-z0-9._/-]+)$/.exec(releaseGiven);
8802
+ const repo = store.lookupRef(id).repo;
8763
8803
  const made = releaseTermsFor(store, { repo, version: spec[1], pr: Number(spec[2]), branch: spec[3], candidate: candidateGiven, now, noCarry: flags.get("no-carry") === true });
8764
8804
  if (made.ok)
8765
8805
  releaseTerms = made.terms;
@@ -9238,6 +9278,8 @@ async function askCredentials(flags, context) {
9238
9278
  const local = currentLocalOwner();
9239
9279
  if (local !== null)
9240
9280
  return { name: local.account, token: "" };
9281
+ if (name === undefined && token !== undefined && activeRemote() === null)
9282
+ name = soloOperatorOf(context.store) ?? undefined;
9241
9283
  if ((name === undefined || token === undefined) && interactive() && !context.json) {
9242
9284
  const usual = name === undefined ? soloOperatorOf(context.store) : null;
9243
9285
  if (name === undefined) {
@@ -11863,7 +11905,7 @@ async function releaseApproveCommand(positional, flags, context) {
11863
11905
  const repo = repoFlag === undefined ? null : resolve(repoFlag);
11864
11906
  const stateDir = dirname(context.databaseFile);
11865
11907
  const { journals, unreadable } = waitingJournals(stateDir, name => journalFile(stateDir, name));
11866
- const named = branch === undefined ? journals : journals.filter(one => one.branch === branch);
11908
+ const named = branch === undefined ? journals : journals.filter(one => one.branch === branch || (/^\d+\.\d+\.\d+$/.test(branch) && one.version === branch && one.file.endsWith(`/from-main/${branch}.json`)));
11867
11909
  if (branch !== undefined && named.length === 0 && unreadable.includes(basename(journalFile(stateDir, branch)))) {
11868
11910
  return fail(write, json, command, "unreadable", `${branch}'s release journal can't be read as one; nothing was approved. Run \`toolroll release ${branch}\` again.`, EXIT.refused);
11869
11911
  }
@@ -12742,11 +12784,11 @@ async function projectFlexibleCommand(positional, flags, context) {
12742
12784
  if (standing.state === "secure")
12743
12785
  return { data: { state: "secure" }, lines: [`${repo}: Secure. Work is planned and approved before it starts.`] };
12744
12786
  if (standing.state === "unreadable")
12745
- return { data: { state: "unreadable" }, lines: [`${repo}: its Flexible terms can't be read, so they allow nothing. Turn Flexible off, then on again.`] };
12787
+ return { data: { state: "unreadable" }, lines: [`${repo}: its thread terms can't be read, so they allow nothing. Turn interactive agent threads off for it, then on again.`] };
12746
12788
  const data = { state: standing.state, digest: standing.digest, terms: standing.terms, signedBy: standing.signedBy, signedAt: standing.signedAt, ...(standing.state === "lapsed" ? { lapse: standing.reason } : {}) };
12747
12789
  if (standing.state === "lapsed")
12748
12790
  return { data, lines: [`${repo}: Flexible terms no longer count. ${FLEXIBLE_LAPSE_WORDS[standing.reason]} Turn it on again to sign new terms.`] };
12749
- return { data, lines: [`${repo}: Flexible, turned on by ${standing.signedBy}.`, ...termsLines(standing.terms, standing.digest)] };
12791
+ return { data, lines: [`${repo}: interactive agent threads are on, turned on by ${standing.signedBy}.`, ...termsLines(standing.terms, standing.digest)] };
12750
12792
  };
12751
12793
  if (action === "show") {
12752
12794
  const now = shown(flexibleStanding(store, repo));
@@ -12754,16 +12796,16 @@ async function projectFlexibleCommand(positional, flags, context) {
12754
12796
  }
12755
12797
  const refused = (message) => fail(write, json, command, "person-only", message, EXIT.refused);
12756
12798
  if (machineActing() || process.env["TOOLROLL_LEAD_TOKEN"] !== undefined || process.env["TOOLROLL_REMOTE_TOKEN"] !== undefined)
12757
- return refused("Only a person changes a project's Flexible terms, never the lead, a token or a chat app.");
12799
+ return refused("Only a person changes a project's thread terms, never the lead, a token or a chat app.");
12758
12800
  const acting = await askCredentials(flags, context);
12759
12801
  if (acting === null)
12760
- return refused(`${action === "enable" ? "Turning on Flexible needs your password" : "This needs your sign-in"}: pass --as and --token.`);
12802
+ return refused(`${action === "enable" ? "Turning on interactive agent threads needs your password" : "This needs your sign-in"}: pass --as and --token.`);
12761
12803
  if (action === "enable") {
12762
12804
  if (!flexibleAvailable(store))
12763
12805
  return fail(write, json, command, "not-available", FLEXIBLE_UNAVAILABLE, EXIT.refused);
12764
12806
  const proved = credentialApprover(store, acting.name, acting.token, repo);
12765
12807
  if (!proved.ok)
12766
- return refused("Only an approver of this project, with their password typed now, turns on Flexible.");
12808
+ return refused("Only an approver of this project, with their password typed now, turns on interactive agent threads.");
12767
12809
  const choice = { ...(max === undefined ? {} : { max }), ...(chosenDefault === undefined ? {} : { default: chosenDefault }) };
12768
12810
  const proposed = proposedFlexibleTerms(store, repo, acting.name, choice);
12769
12811
  if (!proposed.ok)
@@ -12773,18 +12815,18 @@ async function projectFlexibleCommand(positional, flags, context) {
12773
12815
  if (!interactive() || json)
12774
12816
  return fail(write, json, command, "review-terms", [...termsLines(proposed.terms, proposed.digest), `Read these terms, then run again with --digest ${proposed.digest} to agree to them. Nothing changed.`].join("\n"), EXIT.refused, { digest: proposed.digest, terms: proposed.terms });
12775
12817
  write(termsLines(proposed.terms, proposed.digest).join("\n"));
12776
- if (!(await confirm("Turn on Flexible with these terms? [y/N] ")))
12818
+ if (!(await confirm("Turn on interactive agent threads in this project with these terms?")))
12777
12819
  return fail(write, json, command, "declined", "Nothing changed.", EXIT.refused);
12778
12820
  digest = proposed.digest;
12779
12821
  }
12780
12822
  const done = enableFlexible(store, { repo, by: acting.name, proof: proved.method, choice, shownDigest: digest, now: context.clock() });
12781
12823
  if (!done.ok)
12782
12824
  return fail(write, json, command, done.reason, done.message, EXIT.refused);
12783
- return succeed(write, json, command, { repo, flexible: shown(flexibleStanding(store, repo)).data, replaced: done.replaced }, () => [`${repo} is Flexible.`, ...termsLines(done.terms, done.digest)]);
12825
+ return succeed(write, json, command, { repo, flexible: shown(flexibleStanding(store, repo)).data, replaced: done.replaced }, () => [`Interactive agent threads are on in ${repo} (terms ${done.digest}). Start one with T in the terminal workbench.`]);
12784
12826
  }
12785
12827
  const proved = authenticateApprover(store, acting.name, acting.token, repo);
12786
12828
  if (!proved.ok || !personProof(proved.method))
12787
- return refused("Only an approver of this project, signed in as a person, changes its Flexible terms.");
12829
+ return refused("Only an approver of this project, signed in as a person, changes its thread terms.");
12788
12830
  if (action === "lower") {
12789
12831
  if (max === undefined)
12790
12832
  return fail(write, json, command, "usage", "Name the highest level with --max supervised, auto or full.", EXIT.usage);
@@ -12796,7 +12838,7 @@ async function projectFlexibleCommand(positional, flags, context) {
12796
12838
  const done = turnFlexibleOff(store, { repo, by: acting.name, now: context.clock() });
12797
12839
  if (!done.ok)
12798
12840
  return fail(write, json, command, done.reason, done.message, EXIT.refused);
12799
- return succeed(write, json, command, { repo, changed: done.changed, flexible: { state: "secure" } }, () => [done.changed ? `${repo} is Secure again. No new Flexible threads start.` : `${repo} is already Secure.`]);
12841
+ return succeed(write, json, command, { repo, changed: done.changed, flexible: { state: "secure" } }, () => [done.changed ? `Interactive agent threads are off in ${repo}. No new ones start.` : `Interactive agent threads are already off in ${repo}.`]);
12800
12842
  }
12801
12843
  async function taskSizingConfig(action, value, repoGiven, flags, context) {
12802
12844
  const { store, write, json, clock } = context;
@@ -13336,3 +13378,82 @@ async function requestCommand(positional, flags, context) {
13336
13378
  }
13337
13379
  return fail(context.write, context.json, "request", "usage", "Use `toolroll request [list [--all]|show <id>|wait <id>|decline <id>|clear]`.", EXIT.usage);
13338
13380
  }
13381
+ async function landTaskCommand(positional, flags, context) {
13382
+ const { store, write, json, now } = context;
13383
+ const command = "task land";
13384
+ const allowed = new Set(["json", "db", "into", "undo", "yes", "key", "as", "token", "token-file", "token-env"]);
13385
+ for (const key of flags.keys())
13386
+ if (!allowed.has(key))
13387
+ return fail(write, json, command, "usage", `--${key} is not a ${command} option.`, EXIT.usage);
13388
+ const id = positional[0] === undefined ? undefined : resolveTaskId(store, positional[0]);
13389
+ if (id === undefined || positional.length !== 1)
13390
+ 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);
13391
+ const into = text(flags, "into"), undo = flags.get("undo") === true, yes = flags.get("yes") === true, key = text(flags, "key");
13392
+ if (flags.has("into") && into === undefined)
13393
+ return fail(write, json, command, "usage", "--into needs a branch name.", EXIT.usage);
13394
+ if (undo && into !== undefined)
13395
+ return fail(write, json, command, "usage", "--undo lands on the branch the work landed on; it takes no --into.", EXIT.usage);
13396
+ const landRepo = store.lookupRef(id)?.repo ?? null;
13397
+ if (landRepo !== null && publishesThroughPullRequests(store, landRepo))
13398
+ return fail(write, json, command, "pull-requests", PULL_REQUESTS_INSTEAD, EXIT.refused);
13399
+ const local = currentLocalOwner();
13400
+ const localRepos = local === null ? null : store.knownRepos().filter(repo => store.accountCanAccess(local.account, repo));
13401
+ const options = { root: context.evidenceRoot, ...(into === undefined ? {} : { into }), ...(undo ? { undo: true } : {}) };
13402
+ if (!yes) {
13403
+ if (key !== undefined)
13404
+ return fail(write, json, command, "usage", "--key goes with --yes.", EXIT.usage);
13405
+ const read = await readLanding(store, id, { repos: localRepos }, now, options);
13406
+ if (!read.ok)
13407
+ return fail(write, json, command, read.reason, read.message, EXIT.refused);
13408
+ if (!("plan" in read))
13409
+ return succeed(write, json, command, { landed: read.landed }, () => [`${id} · Landed on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`]);
13410
+ const plan = read.plan;
13411
+ return succeed(write, json, command, { plan }, () => [...landingWords(plan),
13412
+ `To ${undo ? "undo it" : "land it"}: toolroll task land ${id}${into === undefined ? "" : ` --into ${into}`}${undo ? " --undo" : ""} --yes --key ${plan.key}`]);
13413
+ }
13414
+ if (key === undefined || !/^[0-9a-f]{16}$/.test(key))
13415
+ return fail(write, json, command, "usage", "--yes needs the --key `toolroll task land` showed you, so what lands is what you read.", EXIT.usage);
13416
+ let authority;
13417
+ if (local !== null)
13418
+ authority = { kind: "local" };
13419
+ else {
13420
+ const acting = await askCredentials(flags, context);
13421
+ const ref = store.lookupRef(id);
13422
+ const repos = store.knownRepos().filter(repo => acting !== null && store.accountCanAccess(acting.name, repo));
13423
+ const proved = acting === null || ref === null ? null : verifyApproverByPassword(store, acting.name, acting.token, repos);
13424
+ if (proved === null || !proved.ok)
13425
+ return fail(write, json, command, "unauthenticated", "Landing work is a person's act: it takes `--as <you>` and your password.", EXIT.refused);
13426
+ authority = { kind: "person", who: proved.who };
13427
+ }
13428
+ const access = { repos: authority.kind === "person" ? authority.who.repos : localRepos };
13429
+ const result = await land(store, id, { key, ...(into === undefined ? {} : { into }), ...(undo ? { undo: true } : {}) }, authority, access, now, { root: context.evidenceRoot });
13430
+ if (!result.ok)
13431
+ return fail(write, json, command, result.reason, result.message, EXIT.refused);
13432
+ return succeed(write, json, command, { landing: result }, () => [
13433
+ `${id} · ${result.replayed ? "Already " : ""}${result.kind === "undo" ? "Undone" : "Landed"} on ${result.branch} (${result.commit.slice(0, 7)})${result.mode === "ref" ? "; no folder had it open" : ""}.`,
13434
+ ...(result.warning === null ? [] : [result.warning])
13435
+ ]);
13436
+ }
13437
+ function resolveTaskId(store, typed) {
13438
+ if (store.getTask(typed) !== null || typed.startsWith("task-"))
13439
+ return typed;
13440
+ return store.getTask(`task-${typed}`) !== null ? `task-${typed}` : typed;
13441
+ }
13442
+ function verifyRepoOf(store, raw) {
13443
+ const absolute = isAbsolute(raw) ? raw : resolve(process.cwd(), raw);
13444
+ let real;
13445
+ try {
13446
+ real = realpathSync(absolute);
13447
+ }
13448
+ catch {
13449
+ return absolute;
13450
+ }
13451
+ for (const known of new Set([...store.listProjects().map(one => one.path), ...store.knownRepos()])) {
13452
+ try {
13453
+ if (known === absolute || realpathSync(known) === real)
13454
+ return known;
13455
+ }
13456
+ catch { }
13457
+ }
13458
+ return absolute;
13459
+ }
@@ -17,7 +17,7 @@ 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: signing in is the only password" : "Passwordless off: step-ups ask for the password again" });
20
+ detail: on ? "Passwordless on: approvals need no password" : "Passwordless off: step-ups ask for the password again" });
21
21
  store.bumpWake();
22
22
  return { changed: true };
23
23
  }
package/dist/planner.js CHANGED
@@ -472,8 +472,11 @@ export async function plan(store, request) {
472
472
  }
473
473
  const clock = request.clock ?? (() => now);
474
474
  let projectSkillContext;
475
+ let projectSkills;
475
476
  try {
476
- projectSkillContext = skillsContext(store, root, request.runId);
477
+ let manifest;
478
+ ({ text: projectSkillContext, manifest } = skillsContext(store, root, request.runId));
479
+ projectSkills = { root, manifest };
477
480
  }
478
481
  catch (error) {
479
482
  return { ok: false, kind: "failure", reason: "skills-unavailable", message: `Project skills could not be loaded: ${error instanceof Error ? error.message : String(error)}` };
@@ -633,6 +636,7 @@ export async function plan(store, request) {
633
636
  cwd: worktree,
634
637
  idleTimeoutMs: timeoutMs,
635
638
  omitEnv: AGENT_ENV_DENYLIST,
639
+ skills: projectSkills,
636
640
  ...(agent === undefined ? {} : { runner: agent }),
637
641
  ...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
638
642
  clock,
@@ -778,6 +782,7 @@ export async function plan(store, request) {
778
782
  cwd: worktree,
779
783
  timeoutMs: STRUCTURED_REPAIR_TIMEOUT_MS,
780
784
  omitEnv: AGENT_ENV_DENYLIST,
785
+ skills: projectSkills,
781
786
  ...(agent === undefined ? {} : { runner: agent }),
782
787
  ...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
783
788
  clock,
@@ -311,6 +311,7 @@ function deleteRows(store, repo, d, now) {
311
311
  del("thread_relay_pending", flexibleThreads, repo);
312
312
  del("flexible_relay_grant", flexibleThreads, repo);
313
313
  del("thread_turn", flexibleThreads, repo);
314
+ del("flexible_turn_said", flexibleThreads, repo);
314
315
  del("flexible_thread_launch", flexibleThreads, repo);
315
316
  del("flexible_thread_level", flexibleThreads, repo);
316
317
  del("flexible_thread", "repo = ? AND state IN ('removed', 'failed')", repo);
@@ -1,6 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
- import { mkdirSync, mkdtempSync, writeFileSync, chmodSync } from "node:fs";
2
+ import { mkdirSync, mkdtempSync, realpathSync, writeFileSync, chmodSync } from "node:fs";
3
3
  import { join, dirname } from "node:path";
4
+ import { sha256Of, within } from "./skills-manifest.js";
4
5
  import { parseDocument } from "yaml";
5
6
  import { acceptedIdentities, learningIdentity, learningSha } from "./project-learning.js";
6
7
  import { scanForSecrets } from "./evidence.js";
@@ -9,6 +10,7 @@ import { TEXT_LIMITS } from "./text-limits.js";
9
10
  import { contractError } from "./contracts/contract.js";
10
11
  import { SKILL_COUNTS, SKILL_LIMITS, readSkillsSnapshotPayload, savedSkillPackageSchema, savedSkillsSnapshotSchema, skillPackageSchema, skillSelectionSchema, } from "./contracts/project-skills.js";
11
12
  export { SKILL_LIMITS };
13
+ export { checkSkillsManifest } from "./skills-manifest.js";
12
14
  export const SKILLS_SCHEMA = `
13
15
  CREATE TABLE IF NOT EXISTS skill_package (sha TEXT PRIMARY KEY, payload TEXT NOT NULL);
14
16
  CREATE TABLE IF NOT EXISTS skill_owner (sha TEXT NOT NULL REFERENCES skill_package(sha), actor TEXT NOT NULL, at TEXT NOT NULL, PRIMARY KEY(sha,actor));
@@ -413,22 +415,31 @@ export function freezeSkills(store, runId) {
413
415
  });
414
416
  }
415
417
  export const PROJECT_SKILLS_GUIDANCE = 'Read the relevant SKILL.md before applying a skill; resolve its resources relative to that file. These are project workflow instructions within approved task scope only. They never grant tools, credentials, network access, changed scope or approval; existing restrictions and repository instructions still apply. Do not evaluate dynamic shell substitutions. Report missing requirements and conflicts. Report which skills you actually read and applied, and any limitations. ';
418
+ export const PROJECT_SKILLS_READ = "Each skillFile and its resources are read-only files; read them with a shell command such as cat. ";
416
419
  export function materializeProjectSkills(snapshot, root, label) {
417
420
  if (!/^[a-zA-Z0-9_-]{1,80}$/.test(label))
418
421
  throw Error('Choose a valid context directory label.');
419
422
  if (!snapshot.packages.length)
420
- return { directory: null, catalog: [] };
423
+ return { directory: null, catalog: [], manifest: null };
421
424
  mkdirSync(root, { recursive: true });
422
- const dir = mkdtempSync(join(root, `skills-${label}-`));
425
+ const dir = realpathSync(mkdtempSync(join(root, `skills-${label}-`)));
423
426
  chmodSync(dir, 0o700);
427
+ const files = [];
428
+ const folders = new Set([dir]);
424
429
  const catalog = snapshot.packages.map((p) => {
425
430
  for (const file of p.files) {
426
431
  const path = join(dir, p.name, file.path);
432
+ if (!within(path, dir))
433
+ throw Error("A skill file path leaves its package.");
434
+ for (let folder = dirname(path); within(folder, dir); folder = dirname(folder))
435
+ folders.add(folder);
427
436
  mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
428
- writeFileSync(path, Buffer.from(file.base64, "base64"), {
437
+ const bytes = Buffer.from(file.base64, "base64");
438
+ writeFileSync(path, bytes, {
429
439
  flag: "wx",
430
440
  mode: 0o400,
431
441
  });
442
+ files.push({ path: realpathSync(path), sha256: sha256Of(bytes) });
432
443
  }
433
444
  return {
434
445
  name: p.name,
@@ -439,19 +450,23 @@ export function materializeProjectSkills(snapshot, root, label) {
439
450
  skillFile: join(dir, p.name, "SKILL.md"),
440
451
  };
441
452
  });
442
- return { directory: dir, catalog };
453
+ const manifest = { directory: dir, files, folders: [...folders].sort() };
454
+ return { directory: dir, catalog, manifest };
443
455
  }
444
456
  export function skillsContext(store, root, runId) {
445
457
  const snapshot = freezeSkills(store, runId);
446
458
  if (!snapshot.packages.length)
447
- return "";
448
- const { catalog } = materializeProjectSkills(snapshot, root, String(runId));
449
- return ("\nProject skills supplied for this run. " + PROJECT_SKILLS_GUIDANCE +
450
- (snapshot.test
451
- ? "This is a skill test: read and apply the named skill to the approved sample, then report the observed result. "
452
- : "") +
453
- JSON.stringify(catalog) +
454
- "\n");
459
+ return { text: "", manifest: null };
460
+ const { catalog, manifest } = materializeProjectSkills(snapshot, root, String(runId));
461
+ return {
462
+ text: "\nProject skills supplied for this run. " + PROJECT_SKILLS_GUIDANCE + PROJECT_SKILLS_READ +
463
+ (snapshot.test
464
+ ? "This is a skill test: read and apply the named skill to the approved sample, then report the observed result. "
465
+ : "") +
466
+ JSON.stringify(catalog) +
467
+ "\n",
468
+ manifest,
469
+ };
455
470
  }
456
471
  export function testSkill(store, args, now = new Date()) {
457
472
  const view = skillsView(store, args.repo, args.actor);
@@ -0,0 +1,27 @@
1
+ let depth = 0;
2
+ let realKill = null;
3
+ export function inRehearsal() { return depth > 0; }
4
+ export const REHEARSAL_SIGNAL_REFUSED = "a rehearsal never signals a process: every pid in its database copy belongs to the real computer";
5
+ export function enterRehearsal() {
6
+ if (depth === 0) {
7
+ realKill = process.kill.bind(process);
8
+ const real = realKill;
9
+ process.kill = ((pid, signal) => {
10
+ if ((signal === 0 || signal === "0") || pid === process.pid)
11
+ return real(pid, signal);
12
+ throw Object.assign(new Error(`${REHEARSAL_SIGNAL_REFUSED} (pid ${pid}, ${String(signal ?? "SIGTERM")})`), { code: "EPERM" });
13
+ });
14
+ }
15
+ depth += 1;
16
+ let left = false;
17
+ return () => {
18
+ if (left)
19
+ return;
20
+ left = true;
21
+ depth -= 1;
22
+ if (depth === 0 && realKill !== null) {
23
+ process.kill = realKill;
24
+ realKill = null;
25
+ }
26
+ };
27
+ }