toolroll 0.9.107 → 0.9.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -3
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +27 -25
- package/dist/browser-shell.js +1 -1
- package/dist/cli-help.js +5 -0
- package/dist/contracts/cli.js +2 -0
- package/dist/contracts/console-api.js +1 -1
- package/dist/folder-look.js +65 -4
- package/dist/guides.js +3 -1
- package/dist/lead-cli.js +2 -1
- package/dist/live-bus.js +14 -1
- package/dist/login-secrets.js +43 -0
- package/dist/operate.js +167 -18
- package/dist/project-admission.js +60 -29
- package/dist/project.js +73 -0
- package/dist/repos.js +37 -0
- package/dist/route-hooks.js +1 -0
- package/dist/sample-project.js +167 -9
- package/dist/scope.js +17 -2
- package/dist/serve.js +15 -3
- package/dist/server/live.js +5 -2
- package/dist/server/login-help.js +67 -0
- package/dist/server/pages.js +180 -26
- package/dist/server/people-tokens.js +36 -24
- package/dist/server/render-people.js +14 -2
- package/dist/server/render-projects.js +58 -10
- package/dist/server/route-table.js +2 -1
- package/dist/server/settings.js +3 -0
- package/dist/server/welcome.js +29 -18
- package/dist/settings-groups-ui.js +10 -1
- package/dist/store.js +33 -0
- package/dist/surface.js +4 -1
- package/dist/task-outcome-cli.js +99 -4
- package/dist/tui-source.js +11 -3
- package/dist/tui.js +39 -39
- package/dist/welcome-facts.js +12 -5
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import { acts, approvalFactsNow, approvalTerms, approveForm, btn, chip, count, d
|
|
|
11
11
|
import {} from "./render-pages.js";
|
|
12
12
|
export function shortPathOf(path) {
|
|
13
13
|
const home = homedir();
|
|
14
|
-
return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
14
|
+
return path === home ? "~" : path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
15
15
|
}
|
|
16
16
|
export function projectHref(name, path, ambiguous, page = "") {
|
|
17
17
|
return `/projects/${encodeURIComponent(name)}${page === "" ? "" : `/${page}`}${ambiguous ? `?path=${encodeURIComponent(path)}` : ""}`;
|
|
@@ -29,6 +29,7 @@ const mono = (text) => html `<span class="k-mono">${text}</span>`;
|
|
|
29
29
|
const sentence = (text) => text === "" ? text : `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
|
|
30
30
|
const refused = (text) => /nothing (changed|was)/i.test(text) ? sentence(text) : `${sentence(text).replace(/[.\s]+$/, "")}. Nothing changed.`;
|
|
31
31
|
export function addWaysHtml(data) {
|
|
32
|
+
const local = data.local ?? { outside: false, pick: false, pathProblem: null, pathValue: "" };
|
|
32
33
|
const onboard = data.onboard;
|
|
33
34
|
const github = onboard === null
|
|
34
35
|
? null
|
|
@@ -46,15 +47,19 @@ export function addWaysHtml(data) {
|
|
|
46
47
|
onboard.roots.length === 1 ? note(html `Clones into ${mono(shortPathOf(onboard.roots[0] ?? ""))}.`) : "",
|
|
47
48
|
]), { attrs: { class: "k-sec" } }),
|
|
48
49
|
])}</section>`;
|
|
49
|
-
const
|
|
50
|
-
|
|
50
|
+
const thisComputer = html `<section class="k-sec" aria-labelledby="add-local"><h3 id="add-local">From this computer</h3>${joinHtml([
|
|
51
|
+
local.pathProblem === null ? "" : notice(refused(local.pathProblem)),
|
|
52
|
+
local.pick ? acts(btn("Browse…", { sm: true, href: "/projects/pick" }))
|
|
53
|
+
: data.browsable ? acts(btn("Choose a folder", { sm: true, href: "/projects/browse" })) : "",
|
|
51
54
|
postForm("/projects/open", joinHtml([
|
|
52
|
-
field({ id: "add-path", label: "Or enter an exact path",
|
|
53
|
-
|
|
55
|
+
field({ id: "add-path", label: "Or enter an exact path",
|
|
56
|
+
hint: local.outside ? "Add any git repository on this computer — outside your projects folder, Toolroll asks for your password." : "It must be a git repository.",
|
|
57
|
+
error: null,
|
|
58
|
+
control: input({ id: "add-path", name: "path", hint: true, error: local.pathProblem !== null, value: local.pathValue, attrs: { placeholder: "~/code/your-repo", autocomplete: "off", spellcheck: "false", autocapitalize: "none" } }) }),
|
|
54
59
|
acts(btn("Add and open", { sm: true, type: "submit", variant: "primary" })),
|
|
55
|
-
]), { attrs: { class: "k-sec" }, returnTo: data.returnTo }),
|
|
60
|
+
]), { attrs: { class: "k-sec" }, returnTo: data.returnTo, hidden: { via: "path" } }),
|
|
56
61
|
])}</section>`;
|
|
57
|
-
return html `<div class="k-sec">${github ?? ""}${
|
|
62
|
+
return html `<div class="k-sec">${github ?? ""}${thisComputer}</div>`;
|
|
58
63
|
}
|
|
59
64
|
export function cloneReviewHtml(onboard, problem) {
|
|
60
65
|
if (onboard === null || !onboard.enabled || onboard.record === null)
|
|
@@ -97,8 +102,10 @@ export function projectsPage(chrome, data) {
|
|
|
97
102
|
const review = cloneReviewHtml(data.onboard, data.problemAt === "clone" ? data.problem : null);
|
|
98
103
|
const reviewHasProblem = review !== null && data.problemAt === "clone";
|
|
99
104
|
const said = data.problemAt === "said" && data.problem !== null ? sentence(data.problem) : null;
|
|
100
|
-
const
|
|
101
|
-
const
|
|
105
|
+
const pathProblem = data.problemAt === "path" ? data.problem : null;
|
|
106
|
+
const topProblem = data.problem === null || said !== null || linkProblem !== null || pathProblem !== null || reviewHasProblem ? null : data.problemAt === "clone" ? sentence(data.problem) : refused(data.problem);
|
|
107
|
+
const addHtml = addWaysHtml({ browsable: data.browsable, onboard: data.onboard, returnTo: data.returnTo, linkProblem,
|
|
108
|
+
...(data.local === undefined ? {} : { local: { ...data.local, pathProblem } }) });
|
|
102
109
|
const rowHtml = (one) => row({
|
|
103
110
|
href: one.href, chip: one.status === null ? html `` : one.status === "needs" ? chip(waitingWords(one.waiting), "ask") : status(one.status), title: one.name, wait: one.status === "needs",
|
|
104
111
|
desc: mono(one.shortPath), meta: html `<span>${one.summary ?? "Not scanned"}</span>${one.open ? html `<span>Open now</span>` : ""}`,
|
|
@@ -118,7 +125,7 @@ export function projectsPage(chrome, data) {
|
|
|
118
125
|
], "\n");
|
|
119
126
|
return screen(title, body, { chrome, workspace: { view: {
|
|
120
127
|
kind: "projects", choosing, problem: topProblem, said, returnTo: data.returnTo, recent, available,
|
|
121
|
-
add: { html: htmlString(addHtml), review: review === null ? null : htmlString(review), openOnLoad: linkProblem !== null },
|
|
128
|
+
add: { html: htmlString(addHtml), review: review === null ? null : htmlString(review), openOnLoad: linkProblem !== null || pathProblem !== null },
|
|
122
129
|
} } });
|
|
123
130
|
}
|
|
124
131
|
function activityHtml(report) {
|
|
@@ -232,3 +239,44 @@ export const unknownProject = (name) => ({ title: `There is no project called ${
|
|
|
232
239
|
export function waitingWords(count) {
|
|
233
240
|
return `${count} waiting on you`;
|
|
234
241
|
}
|
|
242
|
+
export function folderPickerPage(chrome, view) {
|
|
243
|
+
const title = "Choose a repository";
|
|
244
|
+
const crumbs = view.at === null ? "" : html `<nav class="k-mono" aria-label="Folder">${joinHtml(view.at.crumbs.map(one => one.href === null
|
|
245
|
+
? html `<span aria-current="location">${one.label}</span>`
|
|
246
|
+
: html `<a class="k-link" href="${one.href}">${one.label}</a>`), html `<span aria-hidden="true"> / </span>`)}</nav>`;
|
|
247
|
+
const gits = view.entries.filter(one => one.git).length;
|
|
248
|
+
const list = view.lookProblem !== null ? notice(view.lookProblem)
|
|
249
|
+
: view.entries.length === 0 && view.chosen !== null ? ""
|
|
250
|
+
: view.entries.length === 0 ? empty({ title: "No repositories here.", text: view.at?.up ? "Go up one folder, or try a shortcut." : "Try a shortcut." })
|
|
251
|
+
: html `${gits === 0 ? note("No repositories here. Open a folder to look inside it.") : ""}${group("Folders", count(view.entries.length))}${view.entries.map(one => row({
|
|
252
|
+
href: one.href, chip: one.git ? chip(one.registered ? "Project" : "Git repository", "") : html ``, title: one.name,
|
|
253
|
+
desc: one.git ? (one.registered ? "Already added" : "Choose to add it") : "Folder",
|
|
254
|
+
}))}`;
|
|
255
|
+
const body = joinHtml([
|
|
256
|
+
phoneHeader(title, { back: view.back[0] }),
|
|
257
|
+
doc(docHeader({ back: view.back, title, meta: crumbs, same: true }), view.problem === null ? "" : notice(sentence(view.problem)), view.said === null ? "" : infoLine(sentence(view.said)), view.chosen ?? "", view.shortcuts.length === 0 && !view.at?.up ? "" : html `<nav class="k-acts" aria-label="Go to">${view.at?.up ? btn("Up one folder", { sm: true, lead: "back", href: view.at.up }) : ""}${view.shortcuts.map(one => btn(one.label, { sm: true, variant: "ghost", href: one.href }))}</nav>`, html `<div>${list}</div>`),
|
|
258
|
+
], "\n");
|
|
259
|
+
return screen(title, body, { chrome });
|
|
260
|
+
}
|
|
261
|
+
export const typedPasswordField = (id) => field({ id, label: "Your password",
|
|
262
|
+
control: html `<input class="k-input" id="${id}" type="password" name="password" data-so-typed autocomplete="current-password" required>` });
|
|
263
|
+
export function pickRepoChosen(data) {
|
|
264
|
+
const form = (label, extra = "") => postForm("/projects/open", joinHtml([extra, acts(btn(label, { type: "submit", variant: "primary" }))]), { returnTo: "/projects", hidden: { path: data.path, via: "path" } });
|
|
265
|
+
const text = data.refusal !== null ? sentence(data.refusal)
|
|
266
|
+
: data.state === "open" ? "Already a project here."
|
|
267
|
+
: data.state === "outside" ? "It’s outside your projects folder, so Toolroll asks for your password."
|
|
268
|
+
: data.state === "blocked" ? "It’s outside your projects folder. Only an approver signed in with a password can add it."
|
|
269
|
+
: "Adds it as a project.";
|
|
270
|
+
const acts_ = data.refusal !== null || data.state === "blocked" ? ""
|
|
271
|
+
: data.state === "open" ? form("Open") : data.state === "outside" ? form("Add and open", typedPasswordField("pick-password")) : form("Add and open");
|
|
272
|
+
return slots({ status: html `<h2>${data.name}</h2>`, text: html `${mono(shortPathOf(data.path))} · ${text}`, acts: acts_, terms: "", attrs: { "aria-label": `Add ${data.name}` } });
|
|
273
|
+
}
|
|
274
|
+
export function outsideAddPage(chrome, data) {
|
|
275
|
+
const title = "Add a project from outside your projects folder";
|
|
276
|
+
const back = ["/projects", "Projects"];
|
|
277
|
+
const body = joinHtml([
|
|
278
|
+
phoneHeader(title, { back: back[0] }),
|
|
279
|
+
doc(docHeader({ back, title, same: true }), pickRepoChosen({ name: data.name, path: data.path, state: "outside", refusal: null })),
|
|
280
|
+
], "\n");
|
|
281
|
+
return screen(title, body, { chrome });
|
|
282
|
+
}
|
|
@@ -198,6 +198,7 @@ get("tasks", "term.state", "/term/state", TERM);
|
|
|
198
198
|
get("tasks", "term.session", `^\\/term\\/${TERMINAL}$`, { ...TERM, sample: `/term/${"a".repeat(32)}` });
|
|
199
199
|
get("tasks", "term.socket", `^\\/term\\/${TERMINAL}\\/socket$`, { ...TERM, sample: `/term/${"a".repeat(32)}/socket` });
|
|
200
200
|
get("pages", "projects.browse", "/projects/browse", free);
|
|
201
|
+
get("pages", "projects.pick", "/projects/pick", { ...free, callers: ["cookie"], project: "none", ...approver("Sign in as an approver to add projects.", "/projects") });
|
|
201
202
|
get("pages", "projects.github", "/projects/github", { ...free, callers: ["cookie"], callerRefusal: { status: 403, type: "text/plain; charset=utf-8", body: "listing repositories feeds a browser session's act" },
|
|
202
203
|
...anyApprover("your login can watch — adding projects is an approver's act") });
|
|
203
204
|
get("pages", "projects.page", "/projects", { limited: "unscoped", ...free });
|
|
@@ -449,7 +450,7 @@ post("pages", "projects.github-list", "/projects/github", { callers: ["cookie"],
|
|
|
449
450
|
post("pages", "projects.select", "/projects/select", { project: "form-path", limited: "unscoped", viewer: true });
|
|
450
451
|
post("pages", "projects.map-refresh", "^\\/projects\\/[^/]+\\/map\\/refresh$", { project: "form", sample: "/projects/payments-api/map/refresh", ...approver("An approver asks for a check of main.", "/projects") });
|
|
451
452
|
post("pages", "projects.remove", "/projects/remove", { project: "form", ...operator("An instance operator removes projects.", "/settings/project") });
|
|
452
|
-
post("pages", "projects.open", "/projects/open", { project: "
|
|
453
|
+
post("pages", "projects.open", "/projects/open", { project: "none" });
|
|
453
454
|
post("tasks", "tasks.add", "/tasks/add", { project: "form", limited: "collection", bodyCap: LARGE_FORM });
|
|
454
455
|
post("tasks", "tasks.fast", "/tasks/fast", { callers: ["cookie"], project: "none", limited: "collection", ...approver("An approver starts builds.", "/tasks/new") });
|
|
455
456
|
post("tasks", "queue.move", "/queue/move");
|
package/dist/server/settings.js
CHANGED
|
@@ -39,6 +39,7 @@ import { handlersOf } from './handler-registry.js';
|
|
|
39
39
|
import { refuse, screen, when } from "./chrome.js";
|
|
40
40
|
import { requestContext } from "./request-context.js";
|
|
41
41
|
import { btn, empty, infoLine, settingsSection } from "./kit.js";
|
|
42
|
+
import { shortPathOf } from "./render-projects.js";
|
|
42
43
|
import { approvalGroup, projectPicker, GROUP_PATHS, groupTitle, modeCeremonyHtml, modePageHtml, passwordlessHtml, HUB_ANCHOR_SCRIPT, pushScriptOf, settingsGroupPage, settingsSubPage } from "../settings-groups-ui.js";
|
|
43
44
|
import { HANDOFF_STYLE, redirect, respond, safeReturn, sayTo, signInSpent, startedHere } from "./http.js";
|
|
44
45
|
import { html, htmlString, joinHtml, postForm, reauth } from "../html.js";
|
|
@@ -769,6 +770,8 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
|
|
|
769
770
|
return { owner: who.authority !== "full", passwordSet: store.accountOf(who.name)?.passwordSet === true, canTurnOff: who.authority === "full" && operator };
|
|
770
771
|
})(),
|
|
771
772
|
advanced: { on: requestContext.getStore()?.advanced !== false, canChange: who.via === "cookie" },
|
|
773
|
+
projectsFolder: restricted() || runtime.unscopedMode ? null
|
|
774
|
+
: { folders: runtime.ceiling.roots.map(path => ({ path, shown: shortPathOf(path) })) },
|
|
772
775
|
backup: lastBackup === null ? null : lastBackup.ok === false
|
|
773
776
|
? { failed: true, words: `Failed ${when(lastBackup.startedAt)}${lastBackup.error === null ? "" : `: ${lastBackup.error}`}` }
|
|
774
777
|
: { failed: false, words: lastBackup.finishedAt === null ? "Backing up now" : `Backed up ${when(lastBackup.finishedAt)}` },
|
package/dist/server/welcome.js
CHANGED
|
@@ -4,18 +4,20 @@ import { builderReadyFor, firstRunBuilderRepo } from "../dispatch.js";
|
|
|
4
4
|
import { firstTaskSuggestions, SAMPLE_FIRST_TASKS, SAMPLE_PROJECT_NAME, welcomeModel, withBuilderStep } from "../first-run.js";
|
|
5
5
|
import { html, joinHtml, postForm } from "../html.js";
|
|
6
6
|
import { START_BUILDER_HREF } from "../needs-you.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { addSampleProject } from "../sample-project.js";
|
|
8
|
+
import { resolveCeiling } from "../project.js";
|
|
9
|
+
import { readProjectRegistryNow } from "../repos.js";
|
|
10
10
|
import { refuse, screen } from "./chrome.js";
|
|
11
11
|
import { handlersOf } from "./handler-registry.js";
|
|
12
12
|
import { redirect } from "./http.js";
|
|
13
|
+
import { rereadBrowser } from "./live.js";
|
|
13
14
|
import { btn, chip, codeLine, dock, note, notice, pageHeader, settingsRecord } from "./kit.js";
|
|
14
15
|
export const SAMPLE_PROBLEMS = {
|
|
15
16
|
"no-root": "There's no project folder to put the sample in. Add a folder instead.",
|
|
16
17
|
exists: `A folder named ${SAMPLE_PROJECT_NAME} is already there and wasn't made here, so nothing was changed.`,
|
|
17
18
|
failed: "The sample project couldn't be made. Nothing was added. Try again, or add a folder instead.",
|
|
18
19
|
"not-added": "The sample project was made but couldn't be added. Try again, or add it from Projects.",
|
|
20
|
+
incomplete: "The sample project wasn't added, and its line in the project list couldn't be taken back. Remove it in Projects, then try again.",
|
|
19
21
|
};
|
|
20
22
|
const isSampleProblem = (value) => value !== null && Object.hasOwn(SAMPLE_PROBLEMS, value);
|
|
21
23
|
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
@@ -118,27 +120,36 @@ export function createWelcomeHandlers(runtime) {
|
|
|
118
120
|
return sendScreen(response, 200, welcomePage(chrome, model, { problem: isSampleProblem(asked) ? asked : null, canAdd: approver && !store.isDemo() }));
|
|
119
121
|
}
|
|
120
122
|
async function addSample(ctx) {
|
|
121
|
-
const { who, response, now, posted } = ctx;
|
|
123
|
+
const { who, response, now, posted, request } = ctx;
|
|
122
124
|
readForm(posted, CONSOLE_FORMS.welcomeSample);
|
|
123
125
|
if (who.via !== "cookie")
|
|
124
126
|
return refuse(response, who, 403, "adding a project is a browser session's act");
|
|
125
127
|
if (store.isDemo())
|
|
126
128
|
return refuse(response, who, 403, "the sandbox never makes projects");
|
|
127
129
|
const back = (problem) => redirect(response, `/welcome?sample=${problem}#welcome-project`);
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
130
|
+
const stands = () => { const again = rereadBrowser(runtime, request, who); return again !== null && again.role === "approver" && !store.isDemo(); };
|
|
131
|
+
const registryPath = options.registryPath ?? null;
|
|
132
|
+
const registryBacked = registryPath !== null && options.admittedRepos !== undefined;
|
|
133
|
+
const ceiling = (registry) => {
|
|
134
|
+
const live = liveCeiling();
|
|
135
|
+
if (!registryBacked)
|
|
136
|
+
return live;
|
|
137
|
+
const read = registry ?? readProjectRegistryNow(registryPath);
|
|
138
|
+
const current = "error" in read ? [] : resolveCeiling([], read.roots).ceiling.roots;
|
|
139
|
+
return { ...live, roots: live.roots.filter(root => current.includes(root)) };
|
|
140
|
+
};
|
|
141
|
+
const added = await addSampleProject({
|
|
142
|
+
store, registryFile: registryPath, ceiling, now, visible,
|
|
143
|
+
authority: { actor: { label: who.name, origin: "console" }, stands },
|
|
144
|
+
resolveFolder: identities.resolveNow, generation: () => identities.generation(),
|
|
145
|
+
});
|
|
146
|
+
if (!added.ok) {
|
|
147
|
+
if (added.reason === "refused")
|
|
148
|
+
return refuse(response, who, 403, "your access changed while the sample was being added");
|
|
149
|
+
return back(added.reason);
|
|
150
|
+
}
|
|
151
|
+
deletedRepos.delete(added.repo);
|
|
152
|
+
who.session.project = added.repo;
|
|
142
153
|
who.session.projectRevision++;
|
|
143
154
|
sessions.persist(who.session);
|
|
144
155
|
return redirect(response, "/welcome");
|
|
@@ -402,13 +402,22 @@ export function projectsGroup(facts, flags) {
|
|
|
402
402
|
]);
|
|
403
403
|
return settingsShell({
|
|
404
404
|
group: "projects", title: "Projects", lead: "Each project has its own network, writes, checks, pull requests and tools.", flags,
|
|
405
|
-
body: joinHtml([answered(facts),
|
|
405
|
+
body: joinHtml([answered(facts), projectsFolderSection(facts.projectsFolder ?? null),
|
|
406
406
|
facts.projects.length === 0
|
|
407
407
|
? settingsSection({ id: "projects", title: "Projects", body: note(html `No projects yet. <a class="k-link" href="/projects">Add one on Projects</a>.`) })
|
|
408
408
|
: settingsLinks("Projects", rows),
|
|
409
409
|
per]),
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
|
+
function projectsFolderSection(view) {
|
|
413
|
+
if (view === null || view.folders.length === 0)
|
|
414
|
+
return html ``;
|
|
415
|
+
return settingsSection({
|
|
416
|
+
id: "projects-folder", title: view.folders.length === 1 ? "Projects folder" : "Projects folders",
|
|
417
|
+
lead: "Toolroll can add any git repository inside it.",
|
|
418
|
+
body: joinHtml(view.folders.map(one => formRow("Folder", null, html `<span class="k-mono">${one.shown}</span>`, "inline"))),
|
|
419
|
+
});
|
|
420
|
+
}
|
|
412
421
|
export function accessGroup(facts, flags) {
|
|
413
422
|
const people = facts.people;
|
|
414
423
|
const links = [
|
package/dist/store.js
CHANGED
|
@@ -18660,3 +18660,36 @@ export const CONTAINMENT_NOTICE_FACT = "containment-notice-shown";
|
|
|
18660
18660
|
export function noticeDueOnce(store, key, now) {
|
|
18661
18661
|
return Number(store.handle.prepare("INSERT OR IGNORE INTO installation_fact (key, value, created_at) VALUES (?, 'yes', ?)").run(key, now.toISOString()).changes) === 1;
|
|
18662
18662
|
}
|
|
18663
|
+
export function passwordResetRefusal(store, name, passwordsOnlyForOperators) {
|
|
18664
|
+
const row = store.handle.prepare("SELECT credential_hash, password_set, revoked_at FROM approver WHERE name = ?").get(name);
|
|
18665
|
+
if (row === undefined)
|
|
18666
|
+
return "no-account";
|
|
18667
|
+
if (row["revoked_at"] !== null && row["revoked_at"] !== undefined)
|
|
18668
|
+
return "revoked";
|
|
18669
|
+
if (String(row["credential_hash"]).startsWith("sso-only$"))
|
|
18670
|
+
return "sso-only";
|
|
18671
|
+
if (Number(row["password_set"]) !== 1)
|
|
18672
|
+
return "no-password";
|
|
18673
|
+
if (passwordsOnlyForOperators && !store.isInstanceOperator(name))
|
|
18674
|
+
return "password-not-allowed";
|
|
18675
|
+
return null;
|
|
18676
|
+
}
|
|
18677
|
+
export function resetAccountPassword(store, name, credentialHash, expectedGeneration, passwordsOnlyForOperators, now) {
|
|
18678
|
+
return store.transact(() => {
|
|
18679
|
+
const refusal = passwordResetRefusal(store, name, passwordsOnlyForOperators);
|
|
18680
|
+
if (refusal !== null)
|
|
18681
|
+
return { ok: false, reason: refusal };
|
|
18682
|
+
const written = store.handle.prepare(`UPDATE approver SET credential_hash = ?, generation = generation + 1
|
|
18683
|
+
WHERE name = ? AND generation = ? AND password_set = 1 AND revoked_at IS NULL AND credential_hash NOT LIKE 'sso-only$%'`).run(credentialHash, name, expectedGeneration);
|
|
18684
|
+
if (Number(written.changes) !== 1)
|
|
18685
|
+
return { ok: false, reason: "changed" };
|
|
18686
|
+
store.revokeDerivedAuthority(name, "credential-rotation", now);
|
|
18687
|
+
const leadTokens = store.revokeLeadCredentials(name, name, now);
|
|
18688
|
+
store.recordAction({ at: now.toISOString(), actor: name, repo: null, taskId: null, runId: null, action: "password reset at this computer", outcome: "changed", source: "access",
|
|
18689
|
+
detail: `every session of ${name} ended (generation ${expectedGeneration + 1})${leadTokens > 0 ? `; ${leadTokens} lead token${leadTokens === 1 ? "" : "s"} ended` : ""}` });
|
|
18690
|
+
return { ok: true, generation: expectedGeneration + 1, leadTokens };
|
|
18691
|
+
});
|
|
18692
|
+
}
|
|
18693
|
+
export function projectRowKnown(store, path) {
|
|
18694
|
+
return store.handle.prepare("SELECT 1 FROM project WHERE path = ?").get(path) !== undefined;
|
|
18695
|
+
}
|
package/dist/surface.js
CHANGED
|
@@ -455,7 +455,9 @@ const GUIDE_ROWS = [
|
|
|
455
455
|
operator("stop", "stop this computer's Toolroll after its running work is saved: the background service (until the next login), or the `up` running in a terminal"),
|
|
456
456
|
operator("open", "open this computer's Toolroll at a terminal, signed in: the terminal UI, or the browser with --web (starts it first when it isn't running); never prints a sign-in link"),
|
|
457
457
|
{ ...operatorRead("welcome", "the three steps to a first result (agent, project, first task) as the console's welcome shows them; at a terminal it walks them one at a time"), flags: [jsonFlag, dbFlag] },
|
|
458
|
+
{ ...operator("welcome sample", "add the sample project (a tiny repository with one function and its test) in your projects folder, as this computer's password-free owner at a terminal: the console welcome's Try a sample project; takes no folder or name"), flags: [jsonFlag, dbFlag] },
|
|
458
459
|
operator("password set", "set this computer's first password, typed twice at your own terminal (never a flag, file or environment variable); every session signs in again and local mode stays on"),
|
|
460
|
+
operator("password reset", "reset a forgotten password at the computer running Toolroll, typed twice at your own terminal (the one approver, or --as <name>); every session of that account ends and a saved first password that no longer works is removed. Anyone who can run commands as you on this computer can do this, as they could read the saved file"),
|
|
459
461
|
{ ...operatorRead("doctor", "check that Toolroll's service holds no key, token or password a build could read; names what it finds and the steps to fix it, never a value, and changes nothing"), flags: [jsonFlag] },
|
|
460
462
|
];
|
|
461
463
|
const REMOTE_NO = [
|
|
@@ -466,7 +468,7 @@ const REMOTE_NO = [
|
|
|
466
468
|
"assignment show", "assignment updates", "assignment claim", "assignment check", "assignment brief", "assignment inbox", "assignment ack",
|
|
467
469
|
"claim", "heartbeat", "worker release", "reap", "tick", "build", "reconcile",
|
|
468
470
|
"runner register", "runner retire", "runner bind", "runner capacity", "coordinator mint", "coordinator revoke", "mcp", "outbox deliver", "peek",
|
|
469
|
-
"serve", "serve check-public", "watch", "up", "onboard", "daemon", "background on", "background off", "background show", "stop", "open", "welcome", "password set", "doctor", "bridge", "setup show", "setup clear",
|
|
471
|
+
"serve", "serve check-public", "watch", "up", "onboard", "daemon", "background on", "background off", "background show", "stop", "open", "welcome", "welcome sample", "password set", "password reset", "doctor", "bridge", "setup show", "setup clear",
|
|
470
472
|
"providers", "keys status", "keys set", "keys clear", "keys verify", "keys auth", "models check", "models update", "models watch",
|
|
471
473
|
"models results",
|
|
472
474
|
"models suggestions", "models accept", "models dismiss", "models turn-off", "models keep", "models try", "models stop",
|
|
@@ -538,6 +540,7 @@ const LOCAL_ALLOW = {
|
|
|
538
540
|
"task archive": "archive-task",
|
|
539
541
|
"task restore": "archive-task",
|
|
540
542
|
"repos add": "add-project",
|
|
543
|
+
"welcome sample": "add-project",
|
|
541
544
|
"models suggestions": "read",
|
|
542
545
|
"models turn-off": "routing-turn-off",
|
|
543
546
|
"models dismiss": "dismiss-suggestion",
|
package/dist/task-outcome-cli.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { assignmentOf, checkAssignmentAsOperator, completeAsLocalOwner } from './assignment.js';
|
|
3
|
-
import { currentLocalOwner, localModeOn } from './local-owner.js';
|
|
3
|
+
import { currentLocalOwner, localActNow, localModeOn, LOCAL_OWNER_LAPSED } from './local-owner.js';
|
|
4
4
|
import { validateNote } from './decision.js';
|
|
5
5
|
import { assignmentForCoordinator, coordinatorToken } from './assignment-adapters.js';
|
|
6
6
|
import { authenticateCoordinator } from './coordinator.js';
|
|
7
|
-
import { reproveApprover } from './principal.js';
|
|
8
|
-
import { authenticateApprover, machineActing, personProof } from './scope.js';
|
|
7
|
+
import { reproveApprover, verifyApproverStanding } from './principal.js';
|
|
8
|
+
import { authenticateApprover, localWorkEligible, machineActing, personProof } from './scope.js';
|
|
9
9
|
import { currentActor } from './actor.js';
|
|
10
10
|
import { requestResultChanges } from './result-actions.js';
|
|
11
11
|
import { commentSourceKey, revisionSourceOf } from './result-review.js';
|
|
12
12
|
import { envelopeJson } from './envelope.js';
|
|
13
13
|
import { completeAndOpenPullRequest, mergeAsPerson, MERGE_NEEDS_PERSON, newestPullRequestOf, publishingOf, pullRequestViewOf } from './pull-request-flow.js';
|
|
14
14
|
import { proveRunStopped } from './stop-proof.js';
|
|
15
|
+
import { familyChangedFiles } from './result-completion.js';
|
|
16
|
+
import { activeRemote } from './remote-run.js';
|
|
17
|
+
import { underAgent } from './prompt.js';
|
|
15
18
|
export async function runTaskOutcomeCommand(action, positional, flags, context) {
|
|
16
19
|
const command = context.command ?? `task ${action}`;
|
|
17
20
|
const emit = (result, lines) => {
|
|
@@ -34,10 +37,13 @@ export async function runTaskOutcomeCommand(action, positional, flags, context)
|
|
|
34
37
|
return fail('usage', 'Choose your lead\'s credential or your own sign-in, not both.');
|
|
35
38
|
if (credential.token !== null && pullRequest)
|
|
36
39
|
return fail('unauthenticated', 'Opening a pull request is an approver\'s act. Use your own sign-in (--as and --token), not your lead\'s credential.');
|
|
40
|
+
const key = action === 'complete' ? 'c' : 'b';
|
|
41
|
+
if (credential.token === null && passwordFreeShell(context.store))
|
|
42
|
+
return fail('local-owner', passwordFreeShellWords(key, shellCallerOf(context.json, context.caller)));
|
|
37
43
|
const operator = credential.token === null ? await context.operator() : null;
|
|
38
44
|
if (credential.token === null && operator === null) {
|
|
39
45
|
return fail('unauthenticated', passwordFreeOwner(context.store)
|
|
40
|
-
?
|
|
46
|
+
? passwordFreeShellWords(key, shellCallerOf(context.json, context.caller))
|
|
41
47
|
: 'Run this at a terminal to sign in when asked, or open `toolroll`. Your lead can use --token-file or --token-env with its own credential.');
|
|
42
48
|
}
|
|
43
49
|
const { store, now, evidenceRoot } = context;
|
|
@@ -228,6 +234,95 @@ export async function runLocalCompletion(positional, flags, context) {
|
|
|
228
234
|
...(assignment.readiness?.checksOff ? [] : [receipt.checks.detail]),
|
|
229
235
|
]);
|
|
230
236
|
}
|
|
237
|
+
export function reviseAsLocalOwner(store, taskId, input, now, evidenceRoot) {
|
|
238
|
+
const fail = (reason, message) => ({ ok: false, reason, message });
|
|
239
|
+
try {
|
|
240
|
+
return store.transact(() => {
|
|
241
|
+
const local = localActNow(store, 'request-revision');
|
|
242
|
+
if (local === null)
|
|
243
|
+
return fail('local-owner', LOCAL_OWNER_LAPSED);
|
|
244
|
+
const standing = verifyApproverStanding(store, local.account, local.accountGeneration, store.knownRepos().filter(repo => store.accountCanAccess(local.account, repo)));
|
|
245
|
+
if (!standing.ok)
|
|
246
|
+
return fail('local-owner', LOCAL_OWNER_LAPSED);
|
|
247
|
+
const who = standing.who, repos = who.repos;
|
|
248
|
+
const current = assignmentOf(store, taskId, now, { principal: 'operator', repos }, evidenceRoot);
|
|
249
|
+
if (current === null || !store.accountCanAccess(who.name, current.repo))
|
|
250
|
+
return fail('not-found', 'That task is unavailable in your projects.');
|
|
251
|
+
const run = store.getRun(input.runId);
|
|
252
|
+
const runTask = run === null ? null : store.externalIdFor(run.taskRef);
|
|
253
|
+
const family = runTask === null ? null : store.taskFamilyOf(runTask, repos, false);
|
|
254
|
+
if (run === null || runTask === null || family?.root.id !== current.rootId || run.outcome === null)
|
|
255
|
+
return fail('not-found', 'That finished result is unavailable for this task.');
|
|
256
|
+
const changed = familyChangedFiles(store, runTask, run.id, evidenceRoot, { missing: 'unknown' });
|
|
257
|
+
for (const one of new Set([taskId, runTask, current.rootId])) {
|
|
258
|
+
const eligible = localWorkEligible(store, who.name, one, { act: 'revise', changed });
|
|
259
|
+
if (!eligible.ok)
|
|
260
|
+
return fail('local-owner', `${eligible.message} ${store.accountOf(who.name)?.passwordSet === true ? 'Sign in with your password to do this.' : 'Set a password first: run `toolroll password set`.'}`);
|
|
261
|
+
}
|
|
262
|
+
const source = revisionSourceOf(store.getScope(runTask)?.digest ?? null);
|
|
263
|
+
const key = createHash('sha256').update(JSON.stringify([who.name, run.id, source, input.feedback])).digest('hex').slice(0, 32);
|
|
264
|
+
const previous = store.diffCommentBySourceKey(commentSourceKey(who.name, key));
|
|
265
|
+
if ((family.current.id !== runTask || (current.receipt !== null && current.receipt.runId !== run.id)) && previous?.consumedBy == null)
|
|
266
|
+
return fail('stale-result', 'A newer version is current. Read its result before sending it back.');
|
|
267
|
+
const revised = requestResultChanges(store, evidenceRoot, { run: run.id, source, actor: who.name, repos,
|
|
268
|
+
batch: '', note: input.feedback, path: '', line: '', request: key, allowMode: true,
|
|
269
|
+
origin: 'person' }, now);
|
|
270
|
+
if (!revised.ok)
|
|
271
|
+
return fail(revised.status === 400 ? 'usage' : 'stale-result', revised.message);
|
|
272
|
+
const scope = store.getScope(revised.id);
|
|
273
|
+
return { ok: true, id: revised.id, rootId: current.rootId, sourceRun: run.id, source, key,
|
|
274
|
+
approved: scope?.approvedDigest != null && scope.approvedDigest === scope.digest, planning: store.lookupRef(revised.id)?.plan === 'requested' };
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
if (error instanceof Error && error.message === LOCAL_OWNER_LAPSED)
|
|
279
|
+
return fail('local-owner', LOCAL_OWNER_LAPSED);
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export async function runLocalRevision(positional, flags, context) {
|
|
284
|
+
const command = 'task revise';
|
|
285
|
+
const emit = (result, lines) => {
|
|
286
|
+
context.write(context.json ? envelopeJson({ ...result, command }) : result.ok ? (lines ?? []).join('\n') : result.message ?? 'The action was refused.');
|
|
287
|
+
return result.ok ? 0 : result.reason === 'usage' ? 2 : 3;
|
|
288
|
+
};
|
|
289
|
+
const fail = (reason, message) => emit({ ok: false, reason, message });
|
|
290
|
+
const usage = 'Use task revise <task> --run <build> --feedback "requested change".';
|
|
291
|
+
const allowed = new Set(['json', 'db', 'run', 'feedback']);
|
|
292
|
+
for (const key of flags.keys())
|
|
293
|
+
if (!allowed.has(key))
|
|
294
|
+
return fail('usage', `--${key} is not a ${command} option here.`);
|
|
295
|
+
const task = positional[0];
|
|
296
|
+
if (positional.length !== 1 || !task || task.length > 64 || /[\x00-\x1f]/.test(task))
|
|
297
|
+
return fail('usage', usage);
|
|
298
|
+
const run = flags.get('run'), feedback = flags.get('feedback');
|
|
299
|
+
if (typeof run !== 'string' || !/^[1-9]\d{0,14}$/.test(run))
|
|
300
|
+
return fail('usage', `--run needs the exact build number of the result you read. ${usage}`);
|
|
301
|
+
if (typeof feedback !== 'string' || !feedback.trim())
|
|
302
|
+
return fail('usage', 'Describe the requested change with --feedback.');
|
|
303
|
+
const done = reviseAsLocalOwner(context.store, task, { runId: Number(run), feedback }, context.now, context.evidenceRoot);
|
|
304
|
+
if (!done.ok)
|
|
305
|
+
return emit(done);
|
|
306
|
+
const { ok: _ok, ...result } = done;
|
|
307
|
+
return emit({ ok: true, result }, [`${done.rootId} · Revision created`, `Execution: ${done.id}`,
|
|
308
|
+
done.approved ? 'Covered by your existing operating mode.' : done.planning ? 'Updating the plan with your notes; approve it when it is ready.' : 'The revision is waiting for approval.']);
|
|
309
|
+
}
|
|
310
|
+
export function shellCallerOf(json, seam) {
|
|
311
|
+
return seam?.() ?? { json, agent: underAgent(process.env), terminal: process.stdin.isTTY === true && process.stdout.isTTY === true };
|
|
312
|
+
}
|
|
313
|
+
export function passwordFreeShell(store) {
|
|
314
|
+
return currentLocalOwner() === null && activeRemote() === null && currentActor()?.lead !== true && passwordFreeOwner(store);
|
|
315
|
+
}
|
|
316
|
+
export function passwordFreeShellWords(key, caller) {
|
|
317
|
+
const fix = `Open \`toolroll\` in your own terminal and press ${key} on the task.`;
|
|
318
|
+
if (caller.agent)
|
|
319
|
+
return `Your coding agent can't do this for you. ${fix}`;
|
|
320
|
+
if (caller.json)
|
|
321
|
+
return `With --json nothing can ask you, and you haven't set a password. ${fix}`;
|
|
322
|
+
if (!caller.terminal)
|
|
323
|
+
return `This can't ask you when it runs piped or in the background, and you haven't set a password. ${fix}`;
|
|
324
|
+
return `You haven't set a password, so there's nothing to sign in with here. Open \`toolroll\` and press ${key} on the task.`;
|
|
325
|
+
}
|
|
231
326
|
export function passwordFreeOwner(store) {
|
|
232
327
|
try {
|
|
233
328
|
if (!localModeOn(store))
|
package/dist/tui-source.js
CHANGED
|
@@ -15,7 +15,7 @@ import { flakyCount } from "./flaky.js";
|
|
|
15
15
|
import { memoryWaiting } from "./lesson-notes.js";
|
|
16
16
|
import { homeGroupOf } from "./home-groups.js";
|
|
17
17
|
import { terminalText } from "./terminal-text.js";
|
|
18
|
-
import { welcomeHere, welcomeLines } from "./welcome-facts.js";
|
|
18
|
+
import { sampleOffered, welcomeHere, welcomeLines } from "./welcome-facts.js";
|
|
19
19
|
import { planSourceOf, retryPinsOf } from "./local-owner-acts.js";
|
|
20
20
|
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21
21
|
const words = (value, fallback = "") => typeof value === "string" ? value : fallback;
|
|
@@ -157,13 +157,17 @@ export function createTuiSource(options) {
|
|
|
157
157
|
done = "Stopping. Its work so far is kept.";
|
|
158
158
|
break;
|
|
159
159
|
case "revise":
|
|
160
|
-
argv = ["task", "revise", act.id, "--feedback", act.text];
|
|
160
|
+
argv = ["task", "revise", act.id, "--run", String(act.runId), "--feedback", act.text];
|
|
161
161
|
done = "Sent back with your note.";
|
|
162
162
|
break;
|
|
163
163
|
case "answer":
|
|
164
164
|
argv = ["decide", String(act.decision), "--choose", act.option];
|
|
165
165
|
done = "Answered.";
|
|
166
166
|
break;
|
|
167
|
+
case "sample":
|
|
168
|
+
argv = ["welcome", "sample"];
|
|
169
|
+
done = "Added the sample project. Press n to write a first task.";
|
|
170
|
+
break;
|
|
167
171
|
case "retry":
|
|
168
172
|
argv = ["task", "requeue", act.id, "--run", String(act.runId), "--digest", act.digest];
|
|
169
173
|
done = "Retrying. It starts next.";
|
|
@@ -174,8 +178,11 @@ export function createTuiSource(options) {
|
|
|
174
178
|
break;
|
|
175
179
|
}
|
|
176
180
|
const answer = await command(argv);
|
|
181
|
+
setupCache = null;
|
|
177
182
|
if (answer.ok !== true)
|
|
178
183
|
return refusalOf(answer);
|
|
184
|
+
if (act.kind === "sample")
|
|
185
|
+
return { ok: true, message: answer["added"] === false ? "The sample project is already added. Press n to write a first task." : done };
|
|
179
186
|
if (act.kind === "complete" && answer["replayed"] === true)
|
|
180
187
|
return { ok: true, message: "Already accepted. The task is done." };
|
|
181
188
|
if (act.kind === "plan" && answer["replayed"] === true)
|
|
@@ -230,7 +237,8 @@ export function createTuiSource(options) {
|
|
|
230
237
|
});
|
|
231
238
|
if (here === null)
|
|
232
239
|
return null;
|
|
233
|
-
const
|
|
240
|
+
const offered = sampleOffered(here.model, localModeOf(store)?.enabled === true, store.isDemo());
|
|
241
|
+
const value = here.model.left === 0 ? null : { left: here.model.left, lines: welcomeLines(here.model, offered ? "key" : null).map(line => terminalText(line)), sample: offered };
|
|
234
242
|
setupCache = { at: Date.now(), value };
|
|
235
243
|
return value;
|
|
236
244
|
},
|