mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 09:20:03 +01:00
* fix(check): the on-demand loop check signs in on the box, and is red when it cannot ask The first run of loki-loop-check.yml (2026-11-12, run 43188095136) printed "down: loki e2e could not mint a session on the box" two seconds in, and the job was green. Three things were wrong: - The deploy ships the runner a fixed list of scripts and nothing under scripts/test, so on the box there was no test to run and no token script. The workflow now carries the check's own files with it. - The check minted an Auth.js session cookie. Sign-in moved to AccountKit on 2026-11-01, where that cookie is no session. It now signs in the way a runner does: scripts/test/mint-check-token.ts mints an agent token for the operator that expires in two hours, the check uses it as a bearer and removes it on exit. The cookie mint stays as the fallback. - A check that could not sign in exited 0. With the verdict asked for, it exits 1, and it says why (long strings masked). scripts/test/loop-check-signs-in.ts pins all of it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): what production showed after the first fix, and why the check could not sign in Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(check): the loop check prints Loki's own reason for a task that does not start Its first full run on the live site (2026-11-12, run 43191224470) ended "still queued (Queued) after 35 min" and then guessed at the builder's sign-in. The run route already answers the track's sentence for an open run (detail), and the chat's reply says where the task went: the check prints both, right after the dispatch and again when it gives up. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): the first full check on the live site, 4 of 5 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): why the probe did not start, in Loki's own words Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(chat): an address to Loki is not the loki project; the loop check reaches the project it was sent to A project named in a message outranks the selected project, on purpose (lib/loki-fleet-commands). The assistant is called Loki and so is one of the projects, so "Loki, add a dark mode toggle" typed with orangecat selected was sent to the loki project. Found through the loop check on the live site (2026-11-12, run 43198552471): asked for project orangecat, it came back "Sent loki to the cloud runner", because its marker was "[loki-e2e]". Three runs in a row had waited behind the loki project's open run while reporting on a project the probe never reached. - project-mention: withoutAddressTo removes an address to the assistant before matching: the name at the start followed by punctuation, after a greeting, "@loki", or set off by a comma at the end. "Loki's sidebar", "in loki" and a bare "Loki fix the header" still name the project. - loki-loop-e2e: the marker is "[e2e-probe]" and names no project, and the check fails at once when Loki dispatched to another project than the one it asked for. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): the probe had been going to the loki project; the routing fix Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(queue): a run that has gone silent gives its project to the waiting message A project's shared session takes one message at a time: the claim gate holds the next one until the run ahead has closed. A run closes when its agent reports. An agent that ended its turn without reporting still has a process at its prompt, and the reaper shelters a run with a live process for up to MAX_RUN_HOURS, so the next message could wait twelve hours behind a session that was doing nothing. On the live site (2026-11-12) messages sent through Loki's chat read "This project is still on an earlier task" and were still queued 25 to 35 minutes later. - lib/orchestration/quiet-lane: the rule, pure. The runner beats while the terminal prints and while the agent waits at a sign-in or an approval. No beat for 20 minutes (twice the window after which every surface says Stalled), not waiting for a person, no command outstanding, and still so 90 seconds after it was first seen: release. The second look covers a runner that could not beat for a while and whose first request back is the claim. - db/queries/quiet-lane: reads those facts for the run at the head of each lane a message waits in, through olderOpenRunSql, and closes it with the reaper's own verdict (partial with the handoff note, else timeout with the sentence), ended at its last beat. No escalation. - claimNextPendingCommand calls it before the gate, so the message is claimed in the request that closed the run. - The waiting sentence carries the bound. A working agent prints, so its beat is seconds old at any age and it keeps its lane. Nothing is closed when nobody is waiting. scripts/test/quiet-lane.ts, and five scenarios in scripts/test/lane-and-reaper.ts against a real Postgres (13 of 13 locally). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(runs): a pull request that cannot merge is said in the thread, with the message that repairs it The fleet's sweep merges a green pull request and leaves a red or conflicted one waiting. A task sent from the chat that ended at such a pull request read "done, it merges on its own" until somebody opened GitHub. - feedback/fix-shipping: PrBlocker, prBlockerFor (a conflict when GitHub says mergeable: false, else the names of the checks that failed; cancelled and still-running are not failures), prBlockerNews (once per commit and reason). - feedback/fix-shipping-refresh: readBlockers on the refresh input; only then are the head commit's check runs and statuses read. - run-follow-notify: the fifteen-minute follower asks, and on news writes one line into the thread the task came from and sends one push. The line ends with the message to send ("<project>: fix the failing checks on <pull request> and push to the same branch."): a message naming a project is a task for it. - Loki does not send the repair itself: no agent run nobody asked for (lib/auto-dispatch). scripts/test/run-follow-notify.ts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): the 11:17 rehearsal failed on a slow box: sign-up 504, 96% memory, a 503 window Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): bots do not answer on the live site (502, 11:39 UTC); OrangeCat #1672; #1678 green Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(queue): only a run whose runner has reported output can be read as having stopped A runner from before the beat existed reports nothing while its agent works. Silence since delivery would have closed such a run after twenty minutes and typed the waiting message into a working session. A run that has never beaten now keeps its lane; one that truly never printed is the reaper's, which closes it as never started from the runner's own unverified ack. scripts/test/quiet-lane.ts, and a sixth scenario in scripts/test/lane-and-reaper.ts (14 of 14 locally). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(ops): the box usage report prints the builder's memory budget and finishes on a slow box On 2026-11-12 the box had 0.6 GiB available and no swap left, and the report was cancelled at its 20-minute limit inside the first du. Each disk walk now gets a minute. A new section prints what the runner unit holds, whether it has a memory ceiling, and which cgroup the sandboxes' processes are in: sandbox.ts relies on the unit's MemoryMax to bound sealed sessions. Read-only, names and sizes only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): what holds the box's memory, measured; the builder has no ceiling Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(queue): an idle run is closed before the next task starts; the runner's six-hour stop and a turn answered in seconds are read correctly Three faults in the idle rule (#1680), found by an independent review and shown failing first in scripts/test/lane-and-reaper.ts against main (13 passed, 4 failed; 17 of 17 after): - An idle run stopped holding its project but stayed open until the hourly reaper. The next task went into the same session, and its ready handoff closes every delivered open run of the project, so the idle run was recorded as done with the other run's summary. The claim now closes the idle run first, with the reaper's own function and sentence, and only when a task is waiting in that project (db/queries/idle-run-close). - The runner stops beating six hours into a run. Half an hour later the run read as idle while it printed, and the next prompt went into a working session. A last working beat at that horizon is not read as silence (RUN_PROGRESS_HORIZON_SECONDS). - A turn that ended before the runner began reporting on it never had a working beat, read as unknown and held its project for up to twelve hours. Every beat stamps lastBeatAt; a run the runner reports on that has printed no work since delivery is idle after the same half hour. A run with no beat of any size keeps its lane, as before. scripts/test/idle-run-release.ts, scripts/test/lane-and-reaper.ts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(ops): the box usage report can be asked for memory alone The disk walks took the whole 20 minutes twice on 2026-11-12, on a box that was swapping, when only the memory was wanted. what=memory stops after the memory sections. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * feat(ops): the builder can be given a memory ceiling, read and set from the Sealed builds workflow Measured on the box, 2026-11-12 12:19 UTC: loki-box-runner.service held 6.3 GiB with MemoryHigh and MemoryMax at infinity, every sandbox process is in that unit's cgroup, the box had no swap left, and the kernel had stopped 30 processes for memory since boot: the gateway 15 times, a live site 3 times, a sandbox 3 times. Every site unit has a 1G ceiling; the builder had none, though sandbox.ts relies on the unit's MemoryMax to bound sealed sessions. sealed-builds-ctl.sh gains three modes, run from sealed-builds.yml: - memory: read. What the builder holds, what bounds it, what the box has left. - memory-set, runs="<GiB>": MemoryMax and MemoryHigh one below it, and the builder's processes are marked to give first when the whole box runs out. Refused when the ceiling is below what the builder holds now, because that stops sessions at once; "force" after the number sets it anyway. Nothing is restarted. - memory-clear: undo. Nothing is set by a deploy. It is a decision, applied by a person. scripts/hetzner/test-sealed-builds-memory.sh, in test:ops. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(runs, chat): the blocked pull request notice is said once and its repair reaches the right project; an address to Loki is set off, and is the project when nothing else is From the independent review of this branch, each finding confirmed by a second agent told to refute it. The notice: - It would have repeated every tick. "Already said" lived in the ledger, the ledger is rebuilt on every refresh, and the dispatch card's own refresh does not read blockers. It is kept beside the ledger now (payload.prBlockerSaid, per reason), written once the line is in the thread. - Its repair line named the pull request by link. The link carries the repository owner's name, and a project of that name won the match: the repair for loki went to Bitbaum. The line names the number, opens with "In <project>," and uses a verb the chat's own rule takes as a task, for a conflict as well. The test sends it through projectMentionedIn and looksLikeDispatchTask for four projects and both reasons. - action_required and stale count as failed: neither turns green by waiting. The address: - "ok loki is broken, fix its header", "loki-loop-check is red" and "run the tests on @loki" lost the project; "Loki - add a toggle" kept it. An address is the name set off from the sentence (a comma, a colon, any dash with space around it, "please", "can you"), at the start of any sentence. - "loki: fix the header" is read as an address, so a selected project gets the work; with nothing selected and no other project named, the name is the project (projectNamedByAddress, the last resort of both paths). scripts/test/run-follow-notify.ts, scripts/test/project-mention.ts (114). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(ops): the builder's ceiling is a ceiling only; docs(handoff): the box's memory, the review's findings, what is ready and not applied memory-set no longer sets MemoryHigh one below the ceiling: at the moment it is set the builder holds close to the ceiling, and a mark under what it holds would slow every session at once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): the box's memory now holds up OrangeCat merges: Browser smoke is red on main Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi --------- Co-authored-by: Claude <noreply@anthropic.com>
308 lines
12 KiB
TypeScript
308 lines
12 KiB
TypeScript
/**
|
|
* Regression coverage for the phone session of 2026-08-18.
|
|
*
|
|
* The operator typed, on /loki:
|
|
*
|
|
* "I want you to tell me what is left to do with Orange Cat for it to work
|
|
* properly."
|
|
*
|
|
* and got "Which project should I run that on?" over a grid of nine project
|
|
* chips — none of them the project they had just named. Two independent bugs
|
|
* had to line up to produce that, and both are covered here:
|
|
*
|
|
* 1. Project matching was `text.includes(name)` on the raw slug, so the
|
|
* registered `orangecat` never matched the typed "Orange Cat".
|
|
* 2. looksLikeDispatchTask treated any sentence over 16 characters containing
|
|
* " for "/" on "/" in " as work to dispatch. "for it to work" qualified, so
|
|
* a question was routed to an agent instead of being answered.
|
|
*
|
|
* Run: npx tsx scripts/test/project-mention.ts (or npm run test:unit)
|
|
*/
|
|
import { readFileSync } from "node:fs";
|
|
import { resolveFleetCommandProjectKey } from "@/lib/loki-fleet-commands";
|
|
import {
|
|
projectShownInScreenshot,
|
|
projectMentionedIn,
|
|
projectNamedByAddress,
|
|
resolveProjectFromContext,
|
|
textMentionsProject,
|
|
withoutAddressTo,
|
|
unknownProjectMention,
|
|
} from "@/lib/project-mention";
|
|
import { looksLikeDispatchTask } from "@/lib/command-resolve";
|
|
|
|
let passed = 0;
|
|
function check(label: string, condition: boolean): void {
|
|
if (!condition) throw new Error(`FAILED: ${label}`);
|
|
passed += 1;
|
|
console.log(` ✓ ${label}`);
|
|
}
|
|
function eq<T>(actual: T, expected: T, label: string): void {
|
|
check(`${label} (got ${JSON.stringify(actual)})`, Object.is(actual, expected));
|
|
}
|
|
|
|
// The fleet as it stood on the day, in the order the picker rendered it.
|
|
const FLEET = [
|
|
"Bitbaum",
|
|
"BiasLens",
|
|
"Zeitkastli",
|
|
"Prime tower",
|
|
"lifeops",
|
|
"aoz-begleitung",
|
|
"botsmann",
|
|
"datacat",
|
|
"loki",
|
|
"orangecat",
|
|
];
|
|
|
|
console.log("project-mention — spacing/case tolerance");
|
|
eq(
|
|
projectMentionedIn("what is left to do with Orange Cat", FLEET),
|
|
"orangecat",
|
|
"the reported case",
|
|
);
|
|
eq(projectMentionedIn("push orangecat please", FLEET), "orangecat", "exact slug still matches");
|
|
eq(projectMentionedIn("check OrangeCat's build", FLEET), "orangecat", "camel case");
|
|
eq(projectMentionedIn("look at orange-cat", FLEET), "orangecat", "hyphenated");
|
|
eq(
|
|
projectMentionedIn("the AOZ Begleitung rebuild", FLEET),
|
|
"aoz-begleitung",
|
|
"slug with a hyphen, typed with a space",
|
|
);
|
|
eq(
|
|
projectMentionedIn("deploy prime tower", FLEET),
|
|
"Prime tower",
|
|
"registered name keeps its own casing in the answer",
|
|
);
|
|
|
|
console.log("\nproject-mention — no invented matches");
|
|
eq(projectMentionedIn("nothing relevant here", FLEET), null, "unrelated prose matches nothing");
|
|
check(
|
|
"a project name is not found inside a longer word",
|
|
!textMentionsProject("going somewhere", "go"),
|
|
);
|
|
check("partial token runs do not match", !textMentionsProject("orange", "orangecat"));
|
|
eq(
|
|
projectMentionedIn("compare aoz to the aoz-begleitung plan", ["aoz", "aoz-begleitung"]),
|
|
"aoz-begleitung",
|
|
"the longer, more specific name wins",
|
|
);
|
|
|
|
console.log("\nproject-mention — selection outranks prose");
|
|
eq(
|
|
resolveProjectFromContext("work on Orange Cat", "datacat", FLEET),
|
|
"datacat",
|
|
"an explicit pick wins",
|
|
);
|
|
eq(
|
|
resolveProjectFromContext("work on Orange Cat", undefined, FLEET),
|
|
"orangecat",
|
|
"falls back to the name in the text",
|
|
);
|
|
|
|
console.log("\nproject-mention — a fast path follows the project you name");
|
|
eq(
|
|
resolveFleetCommandProjectKey("write the business plan for Orange Cat", "loki", FLEET),
|
|
"orangecat",
|
|
"named in the message beats the selection the last answer left behind",
|
|
);
|
|
eq(
|
|
resolveFleetCommandProjectKey("write the business plan", "loki", FLEET),
|
|
"loki",
|
|
"no name: the selection",
|
|
);
|
|
eq(resolveFleetCommandProjectKey("write the business plan", undefined, FLEET), null, "neither");
|
|
|
|
console.log("\nproject-mention — naming something we don't have");
|
|
const noOrangeCat = FLEET.filter((p) => p !== "orangecat");
|
|
eq(
|
|
unknownProjectMention("what is left to do with Orange Cat for it to work", noOrangeCat),
|
|
"Orange Cat",
|
|
"reports the operator's own words back",
|
|
);
|
|
eq(
|
|
unknownProjectMention("code review for “Red Dog”", noOrangeCat),
|
|
"Red Dog",
|
|
"a quoted phrase counts as a name",
|
|
);
|
|
eq(
|
|
unknownProjectMention("what is left to do with Orange Cat", FLEET),
|
|
null,
|
|
"silent when the project IS registered",
|
|
);
|
|
eq(unknownProjectMention("fix the tests", FLEET), null, "silent on ordinary prose");
|
|
eq(unknownProjectMention("remind me on Monday", FLEET), null, "a weekday is not a project");
|
|
|
|
console.log("\ncommand-resolve — asking is not dispatching");
|
|
check(
|
|
"the reported sentence is a question, not work",
|
|
!looksLikeDispatchTask(
|
|
"I want you to tell me what is left to do with Orange Cat for it to work properly.",
|
|
),
|
|
);
|
|
check("tell me …", !looksLikeDispatchTask("tell me how the deploy pipeline works for loki"));
|
|
check(
|
|
"can you explain …",
|
|
!looksLikeDispatchTask("Can you explain what changed in datacat on Friday"),
|
|
);
|
|
check(
|
|
"give me a rundown …",
|
|
!looksLikeDispatchTask("give me a rundown of what is blocked on botsmann"),
|
|
);
|
|
check(
|
|
"I need to know …",
|
|
!looksLikeDispatchTask("I need to know whether the migration ran in lifeops"),
|
|
);
|
|
check(
|
|
"a pronoun-led sentence is not an instruction",
|
|
!looksLikeDispatchTask("we should probably think about the pricing page in a while"),
|
|
);
|
|
check(
|
|
"a capability question is a question, even without its question mark",
|
|
!looksLikeDispatchTask("Are you able to work on improving Loki in this field."),
|
|
);
|
|
check(
|
|
"is it possible …",
|
|
!looksLikeDispatchTask("is it possible to run the deploy on lifeops from here"),
|
|
);
|
|
check("do you know …", !looksLikeDispatchTask("do you know what is running on the cloud builder"));
|
|
|
|
console.log("\ncommand-resolve — work is still work");
|
|
check("imperative with a verb", looksLikeDispatchTask("fix the failing tests in loki"));
|
|
check("build handoff", looksLikeDispatchTask("ok let's build it"));
|
|
check("explicit implement", looksLikeDispatchTask("implement the invite flow for botsmann"));
|
|
check(
|
|
"verb-led with no keyword verb",
|
|
looksLikeDispatchTask("ship the parser rewrite for datacat"),
|
|
);
|
|
check(
|
|
"an action question still dispatches",
|
|
looksLikeDispatchTask("can you fix the failing types in lifeops?"),
|
|
);
|
|
|
|
console.log("\nproject-mention — a screenshot names the project it is of");
|
|
// 2026-10-12: "Fix this so it works properly" + a screenshot of Loki's Control
|
|
// page, sent with no project picked, could not be acted on.
|
|
const SITES = [
|
|
{ name: "loki", liveUrl: "https://loki.orangecat.ch" },
|
|
{ name: "orangecat", liveUrl: "https://orangecat.ch" },
|
|
{ name: "aoz", liveUrl: null },
|
|
{ name: "aoz-begleitung", liveUrl: "https://aoz.orangecat.ch" },
|
|
];
|
|
const analysis = (shown: string, body = "") =>
|
|
`\n\n--- Attached image analysis (s.png, via m) ---\nShown: ${shown}\n${body}`;
|
|
eq(
|
|
projectShownInScreenshot(analysis("Loki — the Control screen"), SITES),
|
|
"loki",
|
|
"the Shown line names the project",
|
|
);
|
|
eq(
|
|
projectShownInScreenshot(analysis("a web app at loki.orangecat.ch"), SITES),
|
|
"loki",
|
|
"a project's own host wins, even though it also contains 'orangecat'",
|
|
);
|
|
eq(
|
|
projectShownInScreenshot(analysis("unknown", "The page loads https://orangecat.ch/about"), SITES),
|
|
"orangecat",
|
|
"a host anywhere in the analysis counts",
|
|
);
|
|
eq(
|
|
projectShownInScreenshot(
|
|
analysis("Loki — Control", "Cards for orangecat, aoz-begleitung and substrata are stalled."),
|
|
SITES,
|
|
),
|
|
"loki",
|
|
"projects listed ON the screen do not compete with the app it is",
|
|
);
|
|
eq(
|
|
projectShownInScreenshot(analysis("Loki and OrangeCat side by side"), SITES),
|
|
null,
|
|
"two projects shown is a question, not a guess",
|
|
);
|
|
eq(
|
|
projectShownInScreenshot(analysis("the AOZ Begleitung portal"), SITES),
|
|
"aoz-begleitung",
|
|
"a name containing another project's name is still one project",
|
|
);
|
|
eq(projectShownInScreenshot(analysis("unknown"), SITES), null, "unknown stays unknown");
|
|
eq(projectShownInScreenshot("", SITES), null, "no analysis, no guess");
|
|
|
|
// ── An address to the assistant is not a mention of the loki project ────────
|
|
// The assistant is called Loki and so is a project, and a name in the text
|
|
// outranks the selected project. So "Loki, add a dark mode toggle" typed with
|
|
// orangecat selected was sent to the loki project (found 2026-11-12).
|
|
//
|
|
// The first rule for it was reviewed the same day and was wrong both ways:
|
|
// "ok loki is broken, fix its header" and "loki-loop-check is red" lost the
|
|
// project, and "Loki - add a toggle" (a hyphen where a dash was meant) kept
|
|
// it. An address is the name SET OFF from the sentence, and a name used only
|
|
// as an address is still the project when nothing else says where to go.
|
|
console.log("\nproject-mention — an address to the assistant");
|
|
{
|
|
const names = ["loki", "orangecat", "solon", "heidi", "Bitbaum"];
|
|
// [what was typed, with orangecat selected, with nothing selected]
|
|
const cases: Array<[string, string, string]> = [
|
|
// An address: the selected project gets the work; with none, loki does.
|
|
["Loki, add a dark mode toggle to the profile page", "orangecat", "loki"],
|
|
["Hey Loki, add a dark mode toggle", "orangecat", "loki"],
|
|
["Loki - add a dark mode toggle to the profile page", "orangecat", "loki"],
|
|
["Loki — the build is red, fix it", "orangecat", "loki"],
|
|
["loki: fix the header", "orangecat", "loki"],
|
|
["Loki please add a dark mode toggle to the profile page", "orangecat", "loki"],
|
|
["Loki can you add a dark mode toggle to the profile page?", "orangecat", "loki"],
|
|
["Fix the header.\nLoki, also the footer", "orangecat", "loki"],
|
|
["Great work. Loki, now the footer too", "orangecat", "loki"],
|
|
["Add a dark mode toggle, Loki, to the profile page", "orangecat", "loki"],
|
|
["Good morning Loki, add a dark mode toggle", "orangecat", "loki"],
|
|
["Fix the header on the profile page, Loki.", "orangecat", "loki"],
|
|
["Thanks Loki! Now do the footer.", "orangecat", "loki"],
|
|
["Great. Thanks Loki, now the footer too", "orangecat", "loki"],
|
|
["@loki add a toggle", "orangecat", "loki"],
|
|
// The project is meant, whatever is selected.
|
|
["ok loki is broken, fix its header", "loki", "loki"],
|
|
["Ok loki needs a new page", "loki", "loki"],
|
|
["please loki needs a new page", "loki", "loki"],
|
|
["Please, loki's header overlaps on a phone", "loki", "loki"],
|
|
["Hey Loki's sidebar is broken", "loki", "loki"],
|
|
["Ok, loki-loop-check is red again, fix it", "loki", "loki"],
|
|
["Dear loki maintainers: bump next", "loki", "loki"],
|
|
["hi loki repo needs a lockfile bump", "loki", "loki"],
|
|
["run the tests on @loki", "loki", "loki"],
|
|
["@loki/ui needs a new release", "loki", "loki"],
|
|
["Loki's sidebar is broken", "loki", "loki"],
|
|
["Loki fix the header", "loki", "loki"],
|
|
["Loki, fix loki's sidebar", "loki", "loki"],
|
|
["Hey Loki, the loki project has a red check", "loki", "loki"],
|
|
["in loki, add a test", "loki", "loki"],
|
|
// Another project is named: it wins, addressed or not.
|
|
["Loki, build the share card in solon", "solon", "solon"],
|
|
["Hey Loki, what is left to do on Orange Cat?", "orangecat", "orangecat"],
|
|
];
|
|
for (const [said, selected, none] of cases) {
|
|
eq(
|
|
resolveFleetCommandProjectKey(said, "orangecat", names),
|
|
selected,
|
|
`orangecat selected: "${said}"`,
|
|
);
|
|
eq(resolveFleetCommandProjectKey(said, undefined, names), none, `nothing selected: "${said}"`);
|
|
}
|
|
// The strict reading and the last resort are two functions, and exactly one
|
|
// of them answers for a text that names loki.
|
|
eq(projectMentionedIn("loki: fix the header", names), null, "an address is not a mention");
|
|
eq(projectNamedByAddress("loki: fix the header", names), "loki", "but it is the last resort");
|
|
eq(projectNamedByAddress("ok loki is broken", names), null, "a mention needs no last resort");
|
|
eq(projectNamedByAddress("add a dark mode toggle", names), null, "no name, no last resort");
|
|
// Only the assistant's own name is an address; another project's name is not.
|
|
eq(projectMentionedIn("Solon, add a quorum rule", names), "solon", "another name is a mention");
|
|
eq(withoutAddressTo("Hey Loki, fix it"), "fix it", "the address is taken out, the rest is left");
|
|
eq(withoutAddressTo("no address here"), "no address here", "text with no address is untouched");
|
|
// The model path picks the same way (command-resolve pickProjectKey).
|
|
const resolve = readFileSync("src/lib/command-resolve.ts", "utf8");
|
|
check(
|
|
"the model path has the same last resort",
|
|
/namedInText \?\?\s*selectedProject \?\?\s*namedByAddress \?\?/.test(resolve),
|
|
);
|
|
}
|
|
|
|
console.log(`\n${passed}/${passed} project-mention cases passed`);
|