toolroll 0.9.120 → 0.9.123

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 (54) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +10 -23
  3. package/dist/agent-fence.js +57 -9
  4. package/dist/batch-checks.js +2 -2
  5. package/dist/builder.js +10 -7
  6. package/dist/central-recovery-stage.js +3 -3
  7. package/dist/codex-limits.js +2 -2
  8. package/dist/coding-provider.js +3 -3
  9. package/dist/contracts/console-api.js +1 -0
  10. package/dist/direct-chat-fence.js +9 -3
  11. package/dist/direct-chat.js +82 -10
  12. package/dist/first-run.js +1 -1
  13. package/dist/flexible-agents.js +16 -2
  14. package/dist/flexible-save.js +8 -8
  15. package/dist/flexible-session.js +2 -1
  16. package/dist/flexible-thread.js +5 -1
  17. package/dist/install-method.js +1 -3
  18. package/dist/invoke.js +11 -9
  19. package/dist/lead-tools.js +3 -2
  20. package/dist/live-terminal.js +24 -3
  21. package/dist/local-landing.js +48 -8
  22. package/dist/local-owner.js +1 -0
  23. package/dist/operate.js +40 -10
  24. package/dist/plan-limits-demand.js +32 -10
  25. package/dist/planner.js +2 -0
  26. package/dist/project-delete.js +1 -1
  27. package/dist/project-skills.js +105 -17
  28. package/dist/result-follow-ups.js +2 -2
  29. package/dist/scout.js +2 -1
  30. package/dist/serve.js +8 -1
  31. package/dist/server/direct-chat.js +1 -0
  32. package/dist/server/engine-api.js +6 -5
  33. package/dist/server/render-release.js +27 -15
  34. package/dist/server/route-table.js +2 -0
  35. package/dist/server/settings.js +151 -3
  36. package/dist/server/task-views.js +4 -3
  37. package/dist/server/tasks.js +11 -10
  38. package/dist/server/terminals.js +3 -1
  39. package/dist/skill-library-schema.js +70 -0
  40. package/dist/skill-library.js +693 -0
  41. package/dist/skill-local-sync.js +334 -0
  42. package/dist/skills-manifest.js +6 -3
  43. package/dist/skills-ui.js +122 -1
  44. package/dist/store.js +22 -4
  45. package/dist/surface.js +1 -1
  46. package/dist/task-status.js +2 -1
  47. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  48. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  49. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  50. package/dist/tui/linux-x64/toolroll-tui +0 -0
  51. package/dist/work-index.js +5 -2
  52. package/dist/work-summary.js +77 -1
  53. package/dist/workspace-ui.js +12 -6
  54. package/package.json +2 -1
@@ -122,6 +122,9 @@ import { applySavedKnowledge, changeKnowledge, knowledgeVersion, knowledgeView }
122
122
  import { changeLearning } from "../project-learning.js";
123
123
  import { listDecisions, recordDecision, retireDecision, searchMemory } from "../project-memory.js";
124
124
  import { changeSkills, githubSkill, importSkill, reviseSkillTest, skillsView, testSkill } from "../project-skills.js";
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";
127
+ import { skillLibrarySectionHtml } from "../skills-ui.js";
125
128
  import { signedIn } from "../oauth-run-token.js";
126
129
  import { addToolTo, catalogTool, localAppOf, removeToolFrom, setToolSecret, splitCommandLine, testToolOf, toolSecretStorage } from "../project-tools.js";
127
130
  import { liftAuthPause } from "../provider-auth.js";
@@ -315,17 +318,31 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
315
318
  if (chosen && !projects.includes(chosen))
316
319
  return refuse(response, who, 403, "That project is outside your access.", "/projects");
317
320
  const selector = projectPicker("/settings/skills", projects.map(repo => ({ repo, name: projectName(repo) })), chosen);
318
- let content = html `<p>Add a project to manage its skills.</p>`;
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>`;
319
336
  if (chosen) {
320
337
  try {
321
338
  const agent = resolvePhaseAgent(store, 'build', chosen, {});
322
- content = (skillsHtml(skillsView(store, chosen, who.name), who.via === 'cookie' ? who.session.csrf : '', who.role === 'approver', { 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' }));
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' }));
323
340
  }
324
341
  catch (error) {
325
342
  content = html `<p class="problem" role="alert">${error instanceof Error ? error.message : 'Skills are unavailable. Reload to retry.'}</p>`;
326
343
  }
327
344
  }
328
- return sendScreen(response, 200, screen('Skills', settingsSubPage("agents", "Skills", html `${url.searchParams.get('saved') === '1' ? html `<p role="status">Saved.</p>` : ''}${selector}${content}`), { chrome: chromeFor(chosen || project, 'settings'), functional: { script: skillsScript() } }));
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() } }));
329
346
  }
330
347
  async function toolsPage(ctx) {
331
348
  const { url, who, response, project } = ctx;
@@ -2686,6 +2703,7 @@ ${postForm("/settings/chat-approval/save", html `\
2686
2703
  "settings.skills-revise": skillsRevise,
2687
2704
  "settings.skills-import": skillsAct("import"),
2688
2705
  "settings.skills-change": skillsAct("change"),
2706
+ "settings.skills-library": skillsLibraryAct,
2689
2707
  "spend.budget": spendBudget,
2690
2708
  "settings.project-concurrency": projectConcurrency,
2691
2709
  "settings.project-live-view": projectLiveView,
@@ -3458,6 +3476,136 @@ ${postForm("/settings/chat-approval/save", html `\
3458
3476
  sendScreen(response, 200, screen(title, settingsSubPage("projects", title, body), { chrome: chromeFor(project, "projects") }));
3459
3477
  return null;
3460
3478
  }
3479
+ async function skillsLibraryAct(ctx) {
3480
+ const { response, posted } = ctx;
3481
+ const who = browserCaller(ctx.who);
3482
+ const body = readForm(posted, CONSOLE_FORMS.skillsLibrary);
3483
+ const repo = body.get("repo") ?? "";
3484
+ const backBase = repo ? `/settings/skills?repo=${encodeURIComponent(repo)}` : "/settings/skills";
3485
+ const backWith = (key, msg) => redirect(response, `${backBase}${backBase.includes("?") ? "&" : "?"}${key}=${encodeURIComponent(msg)}`);
3486
+ if (repo && (!visible(repo) || !consoleProjects().includes(repo))) {
3487
+ return refuse(response, who, 403, "That project is outside your access.", "/projects");
3488
+ }
3489
+ const action = body.get("action") ?? "";
3490
+ const now = clock();
3491
+ try {
3492
+ let said = "Saved.";
3493
+ if (action === "import-bundle") {
3494
+ const res = await importGithubSkillBundle(store, {
3495
+ url: body.get("url") ?? "",
3496
+ actor: who.name,
3497
+ autoUpdate: body.get("autoUpdate") === "1",
3498
+ }, now);
3499
+ said = `Imported ${res.importedCount} skill${res.importedCount === 1 ? "" : "s"} from ${res.bundle.owner}/${res.bundle.repoName} (${res.bundle.pinnedCommit.slice(0, 12)}).`;
3500
+ }
3501
+ else if (action === "import-skill") {
3502
+ const method = body.get("method") ?? "paste";
3503
+ let files, source;
3504
+ if (method === "paste") {
3505
+ files = [{ path: "SKILL.md", base64: Buffer.from(body.get("content") ?? "").toString("base64") }];
3506
+ source = "Global library (pasted SKILL.md)";
3507
+ }
3508
+ else if (method === "folder") {
3509
+ files = JSON.parse(body.get("files") ?? "[]");
3510
+ source = "Global library (uploaded folder)";
3511
+ }
3512
+ else if (method === "github") {
3513
+ const imported = await githubSkill(body.get("url") ?? "");
3514
+ files = imported.files;
3515
+ source = imported.source;
3516
+ }
3517
+ else {
3518
+ throw Error("Choose how to add the skill.");
3519
+ }
3520
+ const saved = importLibrarySkill(store, { actor: who.name, files, source, enable: true }, now);
3521
+ said = `Added ${saved.skill.name} to the global skill library.`;
3522
+ }
3523
+ else if (action === "enable-skill" || action === "disable-skill") {
3524
+ const revRaw = body.get("revision");
3525
+ const revision = revRaw !== null && revRaw !== "" ? Number(revRaw) : currentLibrary(store).revision;
3526
+ changeLibrarySkill(store, {
3527
+ actor: who.name,
3528
+ revision,
3529
+ action: action === "enable-skill" ? "enable" : "disable",
3530
+ sha: body.get("sha") ?? "",
3531
+ }, now);
3532
+ said = action === "enable-skill" ? "Skill enabled across all projects." : "Skill disabled globally.";
3533
+ }
3534
+ else if (action === "project-opt-out") {
3535
+ if (!repo)
3536
+ throw Error("Choose a project first.");
3537
+ const skillName = body.get("skill") ?? "*";
3538
+ const optOut = body.get("optedOut") === "1";
3539
+ setProjectSkillOptOut(store, { repo, skillName, optOut, actor: who.name }, now);
3540
+ said = skillName === "*"
3541
+ ? (optOut ? "This project opted out of the global skill library." : "Global skill library re-enabled for this project.")
3542
+ : (optOut ? `Opted this project out of ${skillName}.` : `Included ${skillName} in this project.`);
3543
+ }
3544
+ else if (action === "sweep-bundle") {
3545
+ const bundleId = body.get("bundle") ?? "";
3546
+ const results = await sweepSkillBundleUpdates(store, { actor: who.name, ...(bundleId ? { onlyBundleId: bundleId } : {}), force: true, now });
3547
+ const hit = results[0];
3548
+ if (!hit)
3549
+ said = "No matching bundle found.";
3550
+ else if (hit.status === "updated") {
3551
+ said = `Updated bundle to ${hit.commit?.slice(0, 12) ?? "latest"}.`;
3552
+ }
3553
+ else if (hit.status === "held") {
3554
+ said = `Held update (${hit.commit?.slice(0, 12) ?? "latest"}) for review: ${(hit.reasons ?? []).join(" ")}`;
3555
+ }
3556
+ else if (hit.status === "up-to-date" || hit.status === "skipped-recent") {
3557
+ said = "Bundle is already up to date.";
3558
+ }
3559
+ else {
3560
+ throw Error(hit.error ?? "Bundle update check failed.");
3561
+ }
3562
+ }
3563
+ else if (action === "apply-held") {
3564
+ const bundleId = body.get("bundle") ?? "";
3565
+ const results = await sweepSkillBundleUpdates(store, { actor: who.name, onlyBundleId: bundleId, allowSuspiciousForId: bundleId, force: true, now });
3566
+ const hit = results[0];
3567
+ if (hit?.status === "error")
3568
+ throw Error(hit.error ?? "Could not apply held update.");
3569
+ said = hit?.status === "updated" ? `Applied held update (${hit.commit?.slice(0, 12) ?? ""}).` : "No held update to apply.";
3570
+ }
3571
+ else if (action === "dismiss-held") {
3572
+ dismissHeldBundleUpdate(store, body.get("bundle") ?? "");
3573
+ said = "Dismissed held update.";
3574
+ }
3575
+ else if (action === "bundle-auto-update") {
3576
+ const autoUpdate = body.get("autoUpdate") === "1";
3577
+ setBundleAutoUpdate(store, body.get("bundle") ?? "", autoUpdate);
3578
+ said = autoUpdate ? "Daily automatic updates enabled." : "Daily automatic updates paused.";
3579
+ }
3580
+ else if (action === "rollback-bundle") {
3581
+ const rolled = rollbackSkillBundle(store, { id: body.get("bundle") ?? "", actor: who.name }, now);
3582
+ said = `Rolled back ${rolled.bundle.owner}/${rolled.bundle.repoName} to ${rolled.bundle.pinnedCommit.slice(0, 12)}.`;
3583
+ }
3584
+ else if (action === "local-sync") {
3585
+ const tool = body.get("tool") ?? "";
3586
+ if (!LOCAL_SKILL_TOOLS.includes(tool))
3587
+ throw Error("Unknown local tool.");
3588
+ const enabled = body.get("enabled") === "1";
3589
+ const lib = enabledLibrarySkills(store);
3590
+ const res = setLocalSkillSync(store, { tool: tool, enabled, actor: who.name, skills: lib.packages, libraryRevision: lib.revision }, now);
3591
+ 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.`;
3594
+ }
3595
+ else if (action === "local-sync-now") {
3596
+ const lib = enabledLibrarySkills(store);
3597
+ const synced = syncEnabledLocalTools(store, { actor: who.name, skills: lib.packages, libraryRevision: lib.revision }, now);
3598
+ said = synced.length ? "Local tool skill folders synced." : "No local tools have sync enabled.";
3599
+ }
3600
+ else {
3601
+ throw Error("Choose a supported skill library action.");
3602
+ }
3603
+ return backWith("said", said);
3604
+ }
3605
+ catch (error) {
3606
+ return backWith("problem", error instanceof Error ? error.message : "Could not update the skill library.");
3607
+ }
3608
+ }
3461
3609
  return { registrations, modelsView };
3462
3610
  }
3463
3611
  function savedLoginOf(store) {
@@ -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, 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,9 @@ 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
+ return { taskId: rootId, landed: standing?.words ?? null, canLand: person && complete && (record === null || record.undone), canUndo: person && record !== null && !record.undone && standing?.reverted !== true };
625
626
  }
626
627
  function failureOf(runs, assignment, readLog = true) {
627
628
  const last = latestFinishedAttempt(runs);
@@ -2812,12 +2812,13 @@ export function createTasksHandlers(runtime) {
2812
2812
  const ref = store.lookupRef(act.taskId);
2813
2813
  if (ref === null || !visible(ref.repo) || who.via !== "cookie")
2814
2814
  return refuse(response, who, 404, "no such task", "/");
2815
+ const shown = store.taskFamilyOf(act.taskId, null, true)?.current.id ?? act.taskId;
2815
2816
  if (ref.repo !== null && publishesThroughPullRequests(store, ref.repo))
2816
- return taskScreen(response, who, act.taskId, PULL_REQUESTS_INSTEAD, 409);
2817
+ return taskScreen(response, who, shown, PULL_REQUESTS_INSTEAD, 409);
2817
2818
  const local = who.authority === "local-owner";
2818
2819
  const principal = local ? null : leadPrincipal(who);
2819
2820
  if (!local && principal === null)
2820
- return taskScreen(response, who, act.taskId, "Your access changed. Sign in again.", 403);
2821
+ return taskScreen(response, who, shown, "Your access changed. Sign in again.", 403);
2821
2822
  const access = { repos: principal !== null ? principal.repos : store.knownRepos().filter(repo => store.accountCanAccess(who.name, repo)) };
2822
2823
  const undo = body.get("undo") === "1";
2823
2824
  const into = (body.get("into") ?? "").trim();
@@ -2826,28 +2827,28 @@ export function createTasksHandlers(runtime) {
2826
2827
  if (key === "") {
2827
2828
  const read = await readLanding(store, act.taskId, access, now, options);
2828
2829
  if (!read.ok)
2829
- return taskScreen(response, who, act.taskId, read.message, 409);
2830
+ return taskScreen(response, who, shown, read.message, 409);
2830
2831
  if (!("plan" in read)) {
2831
2832
  if (answersInPlace(ctx.request))
2832
2833
  return answerActInPlace(response, "done", `Already on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`, 200);
2833
- return redirect(response, taskHref(act.taskId));
2834
+ return redirect(response, taskHref(shown));
2834
2835
  }
2835
2836
  const plan = read.plan;
2836
2837
  if (answersInPlace(ctx.request))
2837
2838
  return respond(response, 200, "application/json; charset=utf-8", JSON.stringify({ outcome: "land-terms", key: plan.key, lines: landingWords(plan) }));
2838
2839
  const title = undo ? "Undo landing" : `Land on ${plan.branch}`;
2839
- return sendScreen(response, 200, screen(title, html `<h1>${title}</h1>${landingWords(plan).map(line => html `<p>${line}</p>`)}${postForm(`${taskHref(act.taskId)}/land`, html `${btn(undo ? "Undo it" : "Land it", { variant: "primary", type: "submit" })} ${btn("Cancel", { variant: "ghost", href: taskHref(act.taskId) })}`, { hidden: { key: plan.key, ...(into === "" ? {} : { into }), ...(undo ? { undo: "1" } : {}) } })}`, { chrome: chromeFor(ref.repo, "tasks") }));
2840
+ return sendScreen(response, 200, screen(title, html `<h1>${title}</h1>${landingWords(plan).map(line => html `<p>${line}</p>`)}${postForm(`${taskHref(act.taskId)}/land`, html `${btn(undo ? "Undo it" : "Land it", { variant: "primary", type: "submit" })} ${btn("Cancel", { variant: "ghost", href: taskHref(shown) })}`, { hidden: { key: plan.key, ...(into === "" ? {} : { into }), ...(undo ? { undo: "1" } : {}) } })}`, { chrome: chromeFor(ref.repo, "tasks") }));
2840
2841
  }
2841
2842
  const done = await land(store, act.taskId, { key, ...(into === "" ? {} : { into }), ...(undo ? { undo: true } : {}) }, principal !== null ? { kind: "person", who: principal } : { kind: "local" }, access, now, { root: evidenceRoot });
2842
2843
  if (!done.ok)
2843
- return taskScreen(response, who, act.taskId, done.message, done.reason === "authority" ? 403 : 409);
2844
+ return taskScreen(response, who, shown, done.message, done.reason === "authority" ? 403 : 409);
2844
2845
  if (done.handoff !== null) {
2845
2846
  const words = `Landing commit ${done.commit.slice(0, 7)} is ready. Your project folder has ${done.branch} checked out, so Toolroll didn't touch it. ${handoffWords(done.handoff, done.commit)}`;
2846
- return answersInPlace(ctx.request) ? answerActInPlace(response, "done", words, 200) : taskScreen(response, who, act.taskId, words, 200);
2847
+ return answersInPlace(ctx.request) ? answerActInPlace(response, "done", words, 200, done.handoff.command) : taskScreen(response, who, shown, words, 200);
2847
2848
  }
2848
2849
  if (answersInPlace(ctx.request))
2849
2850
  return answerActInPlace(response, "done", `${done.kind === "undo" ? "Undone" : "Landed"} on ${done.branch} (${done.commit.slice(0, 7)}).`, 200);
2850
- return redirect(response, taskHref(act.taskId));
2851
+ return redirect(response, taskHref(shown));
2851
2852
  }
2852
2853
  return { registrations, workListFor, showOrder, runListPane, peekFragment, taskMutation, queueRegionFor, ciFailingFor, completedRowFor, attemptRowFor, resultRowOf, reviewCockpitViewOf, decisionEvidence, runEvidence, sendArtifact, peekGuards, liveRunIds };
2853
2854
  }
@@ -3027,8 +3028,8 @@ export function localOwnerRetry(store, taskId, run, digest, now) {
3027
3028
  const done = retryAsLocalOwner(store, taskId, { run: Number(run), digest }, now);
3028
3029
  return done.ok ? { ok: true, replayed: done.replayed } : { ok: false, status: done.reason === "local-owner" || done.reason === "refused" || done.reason === "limit" ? 403 : 409, message: done.message };
3029
3030
  }
3030
- export function answerActInPlace(response, outcome, words, status) {
3031
- respond(response, status, "application/json; charset=utf-8", JSON.stringify({ outcome, words }));
3031
+ export function answerActInPlace(response, outcome, words, status, command = null) {
3032
+ respond(response, status, "application/json; charset=utf-8", JSON.stringify(command === null ? { outcome, words } : { outcome, words, command }));
3032
3033
  }
3033
3034
  function typedSteer(store, who, file, now, words, question = null) {
3034
3035
  return store.transact(() => {
@@ -14,6 +14,7 @@ import { SHELL_NO_COMMIT, SHELL_NO_RESULT, takeOverRevisionOf, takeOverRunsOf }
14
14
  import { failedAttemptSentence } from "../needs-you.js";
15
15
  import { checkEngineResponse } from "../contracts/engine-api.js";
16
16
  import { projectName, rowVisible } from "../project.js";
17
+ import { effectiveSkillsForRepo } from "../project-skills.js";
17
18
  import { transportOf } from "../public-access.js";
18
19
  import { agentSaidOf } from "../store.js";
19
20
  import { agentSetupOf } from "../agent-detect.js";
@@ -41,7 +42,8 @@ export function terminalHostFor(store, options) {
41
42
  return { host: null, problem: "This install has no terminal support (the optional @lydell/node-pty package didn't load). Reinstall Toolroll to add it." };
42
43
  const ledger = openTerminalLedger(store.raw());
43
44
  const buildWritable = () => [dirname(database), ...store.knownRepos()];
44
- return { host: new TerminalHost({ spawn, worktreeRoot: join(dirname(database), "live-worktrees"), buildWritable, ...(ledger === null ? {} : { ledger }) }), problem: null };
45
+ const skillsForRepo = (repo) => effectiveSkillsForRepo(store, repo);
46
+ return { host: new TerminalHost({ spawn, worktreeRoot: join(dirname(database), "live-worktrees"), buildWritable, skillsForRepo, ...(ledger === null ? {} : { ledger }) }), problem: null };
45
47
  }
46
48
  export function createTerminalHandlers(runtime, deps) {
47
49
  const { store, codingActorAllowed, codingProjectAllowed, liveCeiling } = runtime;
@@ -0,0 +1,70 @@
1
+ export const V186_SCHEMA = `
2
+ CREATE TABLE IF NOT EXISTS skill_library_change (
3
+ revision INTEGER PRIMARY KEY CHECK (revision >= 1),
4
+ actor TEXT NOT NULL,
5
+ at TEXT NOT NULL,
6
+ payload TEXT NOT NULL,
7
+ sha TEXT NOT NULL,
8
+ source TEXT NOT NULL DEFAULT 'manual' CHECK (source IN ('manual', 'bundle-import', 'auto-update', 'rollback'))
9
+ );
10
+ CREATE TRIGGER IF NOT EXISTS skill_library_change_no_update BEFORE UPDATE ON skill_library_change
11
+ BEGIN
12
+ SELECT RAISE(ABORT, 'Skill library history is immutable');
13
+ END;
14
+ CREATE TRIGGER IF NOT EXISTS skill_library_change_no_delete BEFORE DELETE ON skill_library_change
15
+ BEGIN
16
+ SELECT RAISE(ABORT, 'Skill library history is immutable');
17
+ END;
18
+ CREATE TABLE IF NOT EXISTS skill_project_opt_out (
19
+ repo TEXT NOT NULL,
20
+ skill_name TEXT NOT NULL,
21
+ actor TEXT NOT NULL,
22
+ at TEXT NOT NULL,
23
+ PRIMARY KEY (repo, skill_name)
24
+ );
25
+ CREATE TABLE IF NOT EXISTS skill_bundle (
26
+ id TEXT PRIMARY KEY,
27
+ repo_url TEXT NOT NULL,
28
+ owner TEXT NOT NULL,
29
+ repo_name TEXT NOT NULL,
30
+ branch TEXT NOT NULL,
31
+ subpath TEXT NOT NULL DEFAULT '',
32
+ pinned_commit TEXT NOT NULL CHECK (length(pinned_commit) = 40 AND pinned_commit NOT GLOB '*[^0-9a-f]*'),
33
+ previous_commit TEXT CHECK (previous_commit IS NULL OR (length(previous_commit) = 40 AND previous_commit NOT GLOB '*[^0-9a-f]*')),
34
+ previous_revision INTEGER,
35
+ skill_names_json TEXT NOT NULL,
36
+ auto_update INTEGER NOT NULL DEFAULT 1 CHECK (auto_update IN (0, 1)),
37
+ last_checked_at TEXT,
38
+ last_updated_at TEXT,
39
+ held_commit TEXT CHECK (held_commit IS NULL OR (length(held_commit) = 40 AND held_commit NOT GLOB '*[^0-9a-f]*')),
40
+ held_reason TEXT,
41
+ held_at TEXT,
42
+ actor TEXT NOT NULL,
43
+ created_at TEXT NOT NULL
44
+ );
45
+ CREATE TABLE IF NOT EXISTS skill_local_sync (
46
+ tool TEXT PRIMARY KEY CHECK (tool IN ('claude', 'codex', 'gemini')),
47
+ enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1)),
48
+ target_dir TEXT,
49
+ installed_json TEXT NOT NULL DEFAULT '{}',
50
+ synced_revision INTEGER NOT NULL DEFAULT 0,
51
+ synced_at TEXT,
52
+ updated_by TEXT NOT NULL,
53
+ updated_at TEXT NOT NULL
54
+ );
55
+ `;
56
+ export const V186_TABLES = Object.freeze([
57
+ "skill_library_change",
58
+ "skill_project_opt_out",
59
+ "skill_bundle",
60
+ "skill_local_sync",
61
+ ]);
62
+ export const V186_STEPS = Object.freeze(["skill-library"]);
63
+ export const V186_OBJECTS = Object.freeze([
64
+ ["table", "skill_library_change"],
65
+ ["trigger", "skill_library_change_no_update"],
66
+ ["trigger", "skill_library_change_no_delete"],
67
+ ["table", "skill_project_opt_out"],
68
+ ["table", "skill_bundle"],
69
+ ["table", "skill_local_sync"],
70
+ ]);