Public: anyone can read this; the crew can change it.

The terminal and the Apple app's API offer no captain #18353

opened this

Merged 2h 37m ago, live in production

scout/forge:scout/18319-the-terminal-and-the-apple-app-s-api-off → main 0 commits fork 3 threads · 3 unresolved

  • Merged. scout/18319-the-terminal-and-the-apple-app-s-api-off was merged into main as 9a9ebf0.

Review

Sign in to review this change.
14 files changed +153 −472
docs/features/keymap.md −1
@@ -60,7 +60,6 @@ The terminal reads the same tables (`src/tui/app/which.ts`):
6060 - marking is `v` (the dashboard, the Later gate's ticks), and the dashboard's feed link, which had `v`, is `Y`;
6161 - the crew and duty switches turn on `Enter`, which they already did;
6262 - a grants cell toggles on `Enter`;
63 - the captain's on/off is `o`;
6463 - the crew fallback turns on `Enter`.
6564
6665 The old Space says where it went until 2026-12-15, in the Space panel's title.
docs/features/talk-captain.md +4 −5
@@ -4,17 +4,16 @@ row: Talk runs the captain
44 ---
55 # Talk runs the captain (#11011)
66
7 The web has no Captain page and no conversation of that name (#18318; a stored one is retitled Check-ins when a routine next posts): rules, schedules and watches are edited in the terminal (below) and, for watches, through the MCP `talk_watch` tool. Routines and watches post into an ordinary conversation titled "Check-ins" (an existing person keeps the thread they already had). The "Last 24 h" cost line on each post and the Cost block are dropped: each watch still shows its own spend in the terminal.
7 The web has no Captain page and no conversation of that name (#18318; a stored one is retitled Check-ins when a routine next posts): the terminal has no screen for them either (#18319): watches are proposed through the MCP `talk_watch` tool, and nothing edits rules or schedules. Routines and watches post into an ordinary conversation titled "Check-ins" (an existing person keeps the thread they already had). The "Last 24 h" cost line on each post and the Cost block are dropped:

Non-blocking: the sentence ends at "are dropped: " with nothing after it. Finish it, or cut it after "Cost block are dropped."

88
99 Talk is where the forge's owner steers it. What the owner used to do in a Claude Code session runs here.
1010
1111 - **Instructions.** In Talk a message that asks for work is an instruction acted on at once, with the person's own powers through the MCP and within what their role allows: file issues, assign, steer, reopen parked pulls, merge, lend credit. How the agent answers (the answer first, depth when asked, results shown, how each thing is known) is in `docs/features/talk-voice.md`. Real money, DNS and a dark roll are held as a write with Do it and Not now buttons in the thread (`crew/conversation_brief.ts`, `crew/conversation_confirm.ts`).
12 - **Memory** (`core/talk_memory.ts`, edited in the terminal, palette › Check-ins). Short durable rules and decisions, up to 60 of 400 characters. Every Talk turn carries them in its system prompt (`memoryBrief`). The first visit offers the starting rules (never `rm`, tokens off argv, never dark without a go, ask first on money, DNS and a dark roll); delete them and they stay gone.
13 - **Routines** (`core/talk_routines.ts`, `crew/routines.ts`, `crew/routine_report.ts`). The hourly forge check-in, the friends watch and the morning paper, each with an editable schedule: every 15 to 1440 minutes, or daily at an hour (UTC). Each posts at most three lines into the owner's **Check-ins** conversation; only a report that says something new needs the owner reaches the phone (the notify URL, `crew/notify.ts`). The lines are computed, not written by a model, so a routine costs no spend. A forge that was down runs an owed routine once on waking. **Post now** (`p` in the terminal screen) runs one at once, and says so when there is nothing new.
12 - **Memory** (`core/talk_memory.ts`, read only now). Short durable rules and decisions already stored. Every Talk turn carries them in its system prompt (`memoryBrief`).
13 - **Routines** (`core/talk_routines.ts`, `crew/routines.ts`, `crew/routine_report.ts`). The hourly forge check-in, the friends watch and the morning paper, each with an editable schedule: every 15 to 1440 minutes, or daily at an hour (UTC). Each posts at most three lines into the owner's **Check-ins** conversation; only a report that says something new needs the owner reaches the phone (the notify URL, `crew/notify.ts`). The lines are computed, not written by a model, so a routine costs no spend. A forge that was down runs an owed routine once on waking.

Non-blocking: "each with an editable schedule" is no longer true. The terminal screen was the only editor, so say the schedules are fixed at what is stored.

1414 - **Said once** (`crew/routine_once.ts`, the `said` column of `talk_routine`). Each need has a key (a vitals cause, a red trunk's repository, `stuck` for every stuck run) and the routine keeps what it last said under it. The check-in and the friends watch post only what is new (`Needs you:`), worse (its measure, a number with a unit such as GiB, % or runs, moved the bad way by a tenth or more, with the old one: `Worse: The database is 5.1 GiB. (was 4.6)`; less free disk is worse, a smaller database is not, and words that change with no measure, a time say, are never worse) or cleared (`Cleared:`), what shipped and who joined since the last run; nothing new posts nothing. A need the crew can fix that still stands a day after it was first said is filed once as an issue on the forge's own repository (`FORGE_REPO`) with its evidence, and the thread says `Filed #N for the crew`. The issue stays open for the crew; the need is silent until it closes (said once again if it remains) or gets worse. A need whose control is a settings page is the admin's alone and never filed. "I've seen it" (or "got it", "noted") in the thread keeps every need said so far quiet until it gets worse.
15 - **Watches** (`core/talk_watch.ts`, `crew/watches.ts`, `http/mcp/tools/talk_watch.ts`, #16557). A fourth routine kind: a short brief the agent leaves itself and what it waits for, as data the forge reads without a model: a pull is green, landed or changed (`pull_green`, `pull_landed`, `pull_changed`), a run ended (`run_ended`), an issue gained a comment (`issue_comment`), a check on main turned green (`main_green`), a pull merged (`merge_since`). "Done" is stated up front (`pull trevato/forge#16532 landed`). Each look (every 5 minutes by default, on the routines' minute clock) is free: nothing changed means nothing happens and nothing is spent. A change starts one ordinary Talk turn as the owner through `talk()` in the Check-ins conversation, with the brief, the change and the memory, so the same limits apply (12 a minute, the account's budget, resting); a refused turn is tried again at the next look. A forge that was down looks once on waking, so it wakes once. The forge, not the agent, ends a watch: when its condition is met, at 7 days ("ran out"), or at its spend cap (default $2, at most $20; what its wake turns cost, found by the `[Watch <id>]` mark each starts with); each says so in one line in the thread. Safety: only the owner (a site admin who is a person) has one; at most 5 live; the agent may only propose one with the `talk_watch` tool, which is held for a Do it like money (`crew/conversation_confirm.ts`); a watch's own turn cannot start another (`wakeRunning`); a watch's turn has the owner's role at most and every write stays held as before. The owner lists, adds, pauses, deletes and ends them in the terminal screen only (`w` adds `pull_green owner/name#123: brief`, `p` pauses, `e` is Ends now, `d` deletes), each showing what it waits for, when it last looked, its wakes and what it has spent.
15 - **Watches** (`core/talk_watch.ts`, `crew/watches.ts`, `http/mcp/tools/talk_watch.ts`, #16557). A fourth routine kind: a short brief the agent leaves itself and what it waits for, as data the forge reads without a model: a pull is green, landed or changed (`pull_green`, `pull_landed`, `pull_changed`), a run ended (`run_ended`), an issue gained a comment (`issue_comment`), a check on main turned green (`main_green`), a pull merged (`merge_since`). "Done" is stated up front (`pull trevato/forge#16532 landed`). Each look (every 5 minutes by default, on the routines' minute clock) is free: nothing changed means nothing happens and nothing is spent. A change starts one ordinary Talk turn as the owner through `talk()` in the Check-ins conversation, with the brief, the change and the memory, so the same limits apply (12 a minute, the account's budget, resting); a refused turn is tried again at the next look. A forge that was down looks once on waking, so it wakes once. The forge, not the agent, ends a watch: when its condition is met, at 7 days ("ran out"), or at its spend cap (default $2, at most $20; what its wake turns cost, found by the `[Watch <id>]` mark each starts with); each says so in one line in the thread. Safety: only the owner (a site admin who is a person) has one; at most 5 live; the agent may only propose one with the `talk_watch` tool, which is held for a Do it like money (`crew/conversation_confirm.ts`); a watch's own turn cannot start another (`wakeRunning`); a watch's turn has the owner's role at most and every write stays held as before. The terminal has no screen for them: the agent proposes one with `talk_watch`, and the forge ends it.
1616 - **Resume, and picking up fresh.** A thread resumes its Claude session (#10457) until it is long: half the context window (`FRESH_CONTEXT_SHARE`) or 60 of the person's messages since the last fresh start (`FRESH_TURNS`, `crew/fresh_start.ts`). Then, between turns and only when nothing waits on the last one (no confirm held, no crew run it filed still queued or running), the next turn starts a fresh session from the forge's record and the memory; at 85% full it starts fresh whatever waits. The record keeps the person's words verbatim up to 2,000 characters each, the last six answers whole but for their sums and shares, and each older answer cut to its first sentence with a `refs:` tail of every #N, owner/name#N, address and run id it named; its head says figures in it were true when said. The plan rides whole. The thread says so in one line (`FRESH_LINE`): "Picked up fresh: earlier figures are history."
17 - **Terminal** (`tui/screens/captain.ts`, palette › Check-ins, owner only). The rules, then the three routines, in one list. `a` adds a rule; `enter` edits the rule or the routine's schedule under the cursor; `d` deletes a rule; `space` turns a routine on or off; `p` posts a routine now; `r` reads again. A schedule is typed as minutes, `45` for every 45 minutes (15 to 1440), or `at 7` (also `daily 7`) for daily at 07:00 UTC.
1817
1918 The check-in also names the releases cut since the last one and the pillars that merged work (`crew/routine_facts_story.ts`), in one line, since the last check-in (`lastAt`; the git changelog is cached by head oid, so this costs a `rev-parse` between releases); it never reaches the phone for that alone.
2019
docs/features/talk-voice.md +1 −1
@@ -98,7 +98,7 @@ choices
9898
9999 The sentences are `VOICE` in `src/crew/conversation_brief.ts`, part of every Talk brief:
100100
101 - Open with the answer in one or two sentences, then go as deep as the question deserves; detail the person did not ask for goes inside a fold. A rule of theirs about length (Settings, Captain) is read as a rule about the opening and about noise, not a limit on depth they ask for. No reply length is fixed.
101 - Open with the answer in one or two sentences, then go as deep as the question deserves; detail the person did not ask for goes inside a fold. A rule of theirs about length (Settings) is read as a rule about the opening and about noise, not a limit on depth they ask for. No reply length is fixed.
102102 - Brief and direct: say the thing, then stop, with no preamble, recap or closing summary. The same every time: the same ask gets the same kind of answer in the same order (what was done or found, what it means, what is next) and the same words for the same things. Invention goes where the work needs it (a name, a design, a way round a problem), said as a choice, never into the form of the answer.
103103 - Show a result with `::show cN` and say what to look at; never copy its rows into prose.
104104 - A small choice that can be undone is made, not asked: the sensible default, done, and one line saying what was picked and how to change it; a question only when the choices lead to work that is costly to redo or cannot be undone.
src/core/talk_memory.ts +4 −83
@@ -1,18 +1,13 @@
11 /**
22 * What the owner has told Talk to remember (#11011): short durable facts and
33 * decisions ("never rm", "tokens stay off argv", "the forge is never dark
4 * without my go"). Readable and editable in Settings, and loaded into every
5 * Talk session as the person's own standing rules (`memoryBrief`). Plain data
6 * in, plain data out: one table, `talk_memory`.
4 * without my go"), loaded into every Talk session as the person's own standing
5 * rules (`memoryBrief`). Plain data in, plain data out: one table, `talk_memory`.
6 * Nothing writes the table now that the terminal's check-ins screen is gone;
7 * rules already stored still hold.
78 */
89
910 import type { Database } from "bun:sqlite";
10 import { id } from "../kernel/id.ts";
11 import { err, ok, type Result } from "../kernel/result.ts";
12 import { getUserSetting, setUserSetting } from "./settings.ts";
13
14 export const MEMORY_TEXT_MAX = 400;
15 export const MEMORY_MAX = 60;
1611
1712 export interface Memory {
1813 readonly id: string;
@@ -20,27 +15,6 @@ export interface Memory {
2015 readonly createdAt: string;
2116 }
2217
23 export type MemoryError = "empty" | "too_long" | "too_many" | "not_found";
24
25 /** What the owner reads for each refusal, on the web page and in the terminal alike. */
26 export const MEMORY_WORDS: Readonly<Record<MemoryError, string>> = {
27 empty: "Say what to remember.",
28 too_long: `Keep a rule to ${MEMORY_TEXT_MAX} characters.`,
29 too_many: `You keep ${MEMORY_MAX} rules, the most; delete one first.`,
30 not_found: "That rule is gone.",
31 };
32
33 /** The rules this forge's owner has run on; offered once, then theirs to edit or delete. */
34 export const STARTING_RULES: readonly string[] = [
35 "Never run rm or any command that deletes; archive or move instead.",
36 "Tokens and secrets never go on a command line (argv); they travel in the environment or a header.",
37 "The forge is never dark (down, drained, rolled) without my explicit go.",
38 "Anything that moves real money, changes DNS or rolls a release asks me first.",
39 "Open with the answer in a line or two; push to my phone only when something needs me.",
40 ];
41
42 const clean = (text: string): string => text.replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, "").replace(/\s+/g, " ").trim();
43
4418 export function listMemory(db: Database, userId: string): Memory[] {
4519 return db
4620 .query<{ id: string; text: string; created_at: string }, [string]>("SELECT id, text, created_at FROM talk_memory WHERE user_id = ?1 ORDER BY created_at, rowid")
@@ -48,59 +22,6 @@ export function listMemory(db: Database, userId: string): Memory[] {
4822 .map((r) => ({ id: r.id, text: r.text, createdAt: r.created_at }));
4923 }
5024
51 const STARTER = /^start-(\d+)$/;
52
53 /** Offer the starting rules to a person who has never had any, once; deleting them all keeps them gone. Runs on the first write, never on a read. */
54 export function seedMemory(db: Database, userId: string, now = new Date()): void {
55 if (getUserSetting(db, userId, "talk_memory_seeded") !== undefined) return;
56 setUserSetting(db, userId, "talk_memory_seeded", "1");
57 if (listMemory(db, userId).length === 0) for (const rule of STARTING_RULES) insert(db, userId, rule, now);
58 }
59
60 /** What the person's rules are now: the stored ones, or the starting rules (ids `start-N`) until a first write keeps them. Pure read. */
61 export function rulesOf(db: Database, userId: string): Memory[] {
62 const kept = listMemory(db, userId);
63 if (kept.length > 0 || getUserSetting(db, userId, "talk_memory_seeded") !== undefined) return kept;
64 return STARTING_RULES.map((text, i) => ({ id: `start-${i}`, text, createdAt: "" }));
65 }
66
67 function insert(db: Database, userId: string, text: string, now: Date): Memory {
68 const row = { id: id(), text, createdAt: now.toISOString() };
69 db.query("INSERT INTO talk_memory (id, user_id, text, created_at, updated_at) VALUES (?1,?2,?3,?4,?4)").run(row.id, userId, text, row.createdAt);
70 return row;
71 }
72
73 /** A shown starting rule's id becomes the stored rule's, once the first write has kept them. */
74 function resolve(db: Database, userId: string, memoryId: string): string {
75 const n = STARTER.exec(memoryId)?.[1];
76 if (n === undefined) return memoryId;
77 return listMemory(db, userId)[Number(n)]?.id ?? memoryId;
78 }
79
80 export function addMemory(db: Database, userId: string, text: string, now = new Date()): Result<Memory, MemoryError> {
81 const t = clean(text);
82 if (t === "") return err("empty");
83 if (t.length > MEMORY_TEXT_MAX) return err("too_long");
84 seedMemory(db, userId, new Date(now.getTime() - 1));
85 if (listMemory(db, userId).length >= MEMORY_MAX) return err("too_many");
86 return ok(insert(db, userId, t, now));
87 }
88
89 export function editMemory(db: Database, userId: string, memoryId: string, text: string, now = new Date()): Result<true, MemoryError> {
90 const t = clean(text);
91 if (t === "") return err("empty");
92 if (t.length > MEMORY_TEXT_MAX) return err("too_long");
93 seedMemory(db, userId);
94 const r = db.query("UPDATE talk_memory SET text = ?3, updated_at = ?4 WHERE id = ?1 AND user_id = ?2").run(resolve(db, userId, memoryId), userId, t, now.toISOString());
95 return r.changes === 0 ? err("not_found") : ok(true);
96 }
97
98 export function removeMemory(db: Database, userId: string, memoryId: string): Result<true, "not_found"> {
99 seedMemory(db, userId);
100 const r = db.query("DELETE FROM talk_memory WHERE id = ?1 AND user_id = ?2").run(resolve(db, userId, memoryId), userId);
101 return r.changes === 0 ? err("not_found") : ok(true);
102 }
103
10425 /** The standing rules as a brief section; empty when the person keeps none. */
10526 export function memoryBrief(db: Database, userId: string): string {
10627 const all = listMemory(db, userId);
src/core/talk_routines.ts −19
@@ -7,7 +7,6 @@
77
88 import type { Database } from "bun:sqlite";
99 import { getConversation, listConversations, newConversation, renameConversation, type Conversation } from "./conversations.ts";
10 import { err, ok, type Result } from "../kernel/result.ts";
1110 import { lastSlot } from "../nightly/slots.ts";
1211
1312 export const ROUTINE_KINDS = ["checkin", "friends", "paper"] as const;
@@ -64,24 +63,6 @@ export function listRoutines(db: Database, userId: string): Routine[] {
6463 });
6564 }
6665
67 export type RoutineError = "not_a_routine" | "bad_every" | "bad_hour";
68
69 /** Change a schedule: `hour` (0 to 23) makes it daily at that UTC hour; null makes it every `everyMin` minutes. */
70 export function setRoutine(
71 db: Database,
72 userId: string,
73 kind: string,
74 change: { readonly enabled: boolean; readonly everyMin: number; readonly atHour: number | null },
75 ): Result<Routine, RoutineError> {
76 if (!(ROUTINE_KINDS as readonly string[]).includes(kind)) return err("not_a_routine");
77 if (!Number.isInteger(change.everyMin) || change.everyMin < EVERY_MIN || change.everyMin > EVERY_MAX) return err("bad_every");
78 if (change.atHour !== null && (!Number.isInteger(change.atHour) || change.atHour < 0 || change.atHour > 23)) return err("bad_hour");
79 db.query(
80 "INSERT INTO talk_routine (user_id, kind, enabled, every_min, at_hour) VALUES (?1,?2,?3,?4,?5) ON CONFLICT (user_id, kind) DO UPDATE SET enabled = ?3, every_min = ?4, at_hour = ?5",
81 ).run(userId, kind, change.enabled ? 1 : 0, change.everyMin, change.atHour);
82 return ok(listRoutines(db, userId).find((r) => r.kind === kind)!);
83 }
84
8566 /** Whether a routine is owed at `now`: never run, or its interval or its daily slot has passed since it last did. */
8667 export function due(r: Pick<Routine, "enabled" | "everyMin" | "atHour" | "lastAt">, now: number): boolean {
8768 if (!r.enabled) return false;
src/core/talk_watch.ts −8
@@ -258,15 +258,7 @@ export function createWatch(db: Database, user: User, input: NewWatch, now: Date
258258 return row === undefined ? err("too_many") : ok(row);
259259 }
260260
261 /** Pause or resume; false when it is not the person's or already ended. */
262 export function pauseWatch(db: Database, userId: string, watchId: string, paused: boolean): boolean {
263 return db.query("UPDATE talk_watch SET state = ?3 WHERE id = ?1 AND user_id = ?2 AND state IN ('live','paused')").run(watchId, userId, paused ? "paused" : "live").changes > 0;
264 }
265
266261 /** End a live or paused watch with one line saying how. */
267262 export function endWatch(db: Database, userId: string, watchId: string, state: Exclude<WatchState, "live" | "paused">, line: string, now: Date = new Date()): boolean {
268263 return db.query("UPDATE talk_watch SET state = ?3, ended_at = ?4, ended_line = ?5 WHERE id = ?1 AND user_id = ?2 AND state IN ('live','paused')").run(watchId, userId, state, now.toISOString(), line.slice(0, 200)).changes > 0;
269264 }
270
271 /** Take a watch off the list altogether. */
272 export const deleteWatch = (db: Database, userId: string, watchId: string): boolean => db.query("DELETE FROM talk_watch WHERE id = ?1 AND user_id = ?2").run(watchId, userId).changes > 0;
src/generated/screens.ts +122 −124
@@ -22,123 +22,122 @@ import * as s17 from "../tui/screens/buckets.ts";
2222 import * as s18 from "../tui/screens/budgets.ts";
2323 import * as s19 from "../tui/screens/bugs.ts";
2424 import * as s20 from "../tui/screens/bulk.ts";
25 import * as s21 from "../tui/screens/captain.ts";
26 import * as s22 from "../tui/screens/childcredit.ts";
27 import * as s23 from "../tui/screens/claim_link.ts";
28 import * as s24 from "../tui/screens/claim_start.ts";
29 import * as s25 from "../tui/screens/client_clouds.ts";
30 import * as s26 from "../tui/screens/cloud.ts";
31 import * as s27 from "../tui/screens/cloudcost.ts";
32 import * as s28 from "../tui/screens/cloudtree.ts";
33 import * as s29 from "../tui/screens/codes.ts";
34 import * as s30 from "../tui/screens/connections.ts";
35 import * as s31 from "../tui/screens/controls.ts";
36 import * as s32 from "../tui/screens/cores.ts";
37 import * as s33 from "../tui/screens/crewbudgets.ts";
38 import * as s34 from "../tui/screens/crewfallback.ts";
39 import * as s35 from "../tui/screens/crewhandover.ts";
40 import * as s36 from "../tui/screens/crewkey.ts";
41 import * as s37 from "../tui/screens/crewsplits.ts";
42 import * as s38 from "../tui/screens/crewtop.ts";
43 import * as s39 from "../tui/screens/dataset.ts";
44 import * as s40 from "../tui/screens/design.ts";
45 import * as s41 from "../tui/screens/design_gallery.ts";
46 import * as s42 from "../tui/screens/devices.ts";
47 import * as s43 from "../tui/screens/disks.ts";
48 import * as s44 from "../tui/screens/displays.ts";
49 import * as s45 from "../tui/screens/domains.ts";
50 import * as s46 from "../tui/screens/dotfiles.ts";
51 import * as s47 from "../tui/screens/drift.ts";
52 import * as s48 from "../tui/screens/dutybudgets.ts";
53 import * as s49 from "../tui/screens/dutyswitch.ts";
54 import * as s50 from "../tui/screens/economics.ts";
55 import * as s51 from "../tui/screens/edgeonly.ts";
56 import * as s52 from "../tui/screens/experiments.ts";
57 import * as s53 from "../tui/screens/featurefeed.ts";
58 import * as s54 from "../tui/screens/features.ts";
59 import * as s55 from "../tui/screens/featureswitch.ts";
60 import * as s56 from "../tui/screens/feed.ts";
61 import * as s57 from "../tui/screens/flowsall.ts";
62 import * as s58 from "../tui/screens/footing.ts";
63 import * as s59 from "../tui/screens/forgeready.ts";
64 import * as s60 from "../tui/screens/forges.ts";
65 import * as s61 from "../tui/screens/forgeview.ts";
66 import * as s62 from "../tui/screens/front.ts";
67 import * as s63 from "../tui/screens/frontms.ts";
68 import * as s64 from "../tui/screens/funnel.ts";
69 import * as s65 from "../tui/screens/games.ts";
70 import * as s66 from "../tui/screens/gifts.ts";
71 import * as s67 from "../tui/screens/health_voice.ts";
72 import * as s68 from "../tui/screens/home_pins.ts";
73 import * as s69 from "../tui/screens/hostreach.ts";
74 import * as s70 from "../tui/screens/infra.ts";
75 import * as s71 from "../tui/screens/inventory.ts";
76 import * as s72 from "../tui/screens/invites.ts";
77 import * as s73 from "../tui/screens/knobs.ts";
78 import * as s74 from "../tui/screens/lapsed.ts";
79 import * as s75 from "../tui/screens/limits.ts";
80 import * as s76 from "../tui/screens/loopstalls.ts";
81 import * as s77 from "../tui/screens/madefrom.ts";
82 import * as s78 from "../tui/screens/maintainruns.ts";
83 import * as s79 from "../tui/screens/maintenance.ts";
84 import * as s80 from "../tui/screens/maintenanceweek.ts";
85 import * as s81 from "../tui/screens/mergedbranches.ts";
86 import * as s82 from "../tui/screens/mirrorpacks.ts";
87 import * as s83 from "../tui/screens/model.ts";
88 import * as s84 from "../tui/screens/money.ts";
89 import * as s85 from "../tui/screens/newissue.ts";
90 import * as s86 from "../tui/screens/next.ts";
91 import * as s87 from "../tui/screens/nowlist.ts";
92 import * as s88 from "../tui/screens/offers.ts";
93 import * as s89 from "../tui/screens/offsite.ts";
94 import * as s90 from "../tui/screens/orggrants.ts";
95 import * as s91 from "../tui/screens/orgteams.ts";
96 import * as s92 from "../tui/screens/originahead.ts";
97 import * as s93 from "../tui/screens/owner.ts";
98 import * as s94 from "../tui/screens/packrepos.ts";
99 import * as s95 from "../tui/screens/payments.ts";
100 import * as s96 from "../tui/screens/people.ts";
101 import * as s97 from "../tui/screens/pinned.ts";
102 import * as s98 from "../tui/screens/planner.ts";
103 import * as s99 from "../tui/screens/planrow.ts";
104 import * as s100 from "../tui/screens/plans.ts";
105 import * as s101 from "../tui/screens/previewdirs.ts";
106 import * as s102 from "../tui/screens/profile.ts";
107 import * as s103 from "../tui/screens/quotas.ts";
108 import * as s104 from "../tui/screens/recoverykit.ts";
109 import * as s105 from "../tui/screens/refused.ts";
110 import * as s106 from "../tui/screens/registry_items.ts";
111 import * as s107 from "../tui/screens/repolist.ts";
112 import * as s108 from "../tui/screens/requests.ts";
113 import * as s109 from "../tui/screens/resilience.ts";
114 import * as s110 from "../tui/screens/returning.ts";
115 import * as s111 from "../tui/screens/returns.ts";
116 import * as s112 from "../tui/screens/scorecard.ts";
117 import * as s113 from "../tui/screens/scrapes.ts";
118 import * as s114 from "../tui/screens/secrets.ts";
119 import * as s115 from "../tui/screens/sentinel.ts";
120 import * as s116 from "../tui/screens/series.ts";
121 import * as s117 from "../tui/screens/ship_time.ts";
122 import * as s118 from "../tui/screens/slowpages.ts";
123 import * as s119 from "../tui/screens/sold.ts";
124 import * as s120 from "../tui/screens/spend.ts";
125 import * as s121 from "../tui/screens/stalepulls.ts";
126 import * as s122 from "../tui/screens/subscriptions.ts";
127 import * as s123 from "../tui/screens/system.ts";
128 import * as s124 from "../tui/screens/tab.ts";
129 import * as s125 from "../tui/screens/tabworks.ts";
130 import * as s126 from "../tui/screens/teams.ts";
131 import * as s127 from "../tui/screens/telemetry.ts";
132 import * as s128 from "../tui/screens/tell_undo.ts";
133 import * as s129 from "../tui/screens/traces.ts";
134 import * as s130 from "../tui/screens/traffic.ts";
135 import * as s131 from "../tui/screens/trafficview.ts";
136 import * as s132 from "../tui/screens/valves.ts";
137 import * as s133 from "../tui/screens/waiting.ts";
138 import * as s134 from "../tui/screens/waiting_for_me.ts";
139 import * as s135 from "../tui/screens/wayback.ts";
140 import * as s136 from "../tui/screens/weekcard.ts";
141 import * as s137 from "../tui/screens/whocan.ts";
25 import * as s21 from "../tui/screens/childcredit.ts";
26 import * as s22 from "../tui/screens/claim_link.ts";
27 import * as s23 from "../tui/screens/claim_start.ts";
28 import * as s24 from "../tui/screens/client_clouds.ts";
29 import * as s25 from "../tui/screens/cloud.ts";
30 import * as s26 from "../tui/screens/cloudcost.ts";
31 import * as s27 from "../tui/screens/cloudtree.ts";
32 import * as s28 from "../tui/screens/codes.ts";
33 import * as s29 from "../tui/screens/connections.ts";
34 import * as s30 from "../tui/screens/controls.ts";
35 import * as s31 from "../tui/screens/cores.ts";
36 import * as s32 from "../tui/screens/crewbudgets.ts";
37 import * as s33 from "../tui/screens/crewfallback.ts";
38 import * as s34 from "../tui/screens/crewhandover.ts";
39 import * as s35 from "../tui/screens/crewkey.ts";
40 import * as s36 from "../tui/screens/crewsplits.ts";
41 import * as s37 from "../tui/screens/crewtop.ts";
42 import * as s38 from "../tui/screens/dataset.ts";
43 import * as s39 from "../tui/screens/design.ts";
44 import * as s40 from "../tui/screens/design_gallery.ts";
45 import * as s41 from "../tui/screens/devices.ts";
46 import * as s42 from "../tui/screens/disks.ts";
47 import * as s43 from "../tui/screens/displays.ts";
48 import * as s44 from "../tui/screens/domains.ts";
49 import * as s45 from "../tui/screens/dotfiles.ts";
50 import * as s46 from "../tui/screens/drift.ts";
51 import * as s47 from "../tui/screens/dutybudgets.ts";
52 import * as s48 from "../tui/screens/dutyswitch.ts";
53 import * as s49 from "../tui/screens/economics.ts";
54 import * as s50 from "../tui/screens/edgeonly.ts";
55 import * as s51 from "../tui/screens/experiments.ts";
56 import * as s52 from "../tui/screens/featurefeed.ts";
57 import * as s53 from "../tui/screens/features.ts";
58 import * as s54 from "../tui/screens/featureswitch.ts";
59 import * as s55 from "../tui/screens/feed.ts";
60 import * as s56 from "../tui/screens/flowsall.ts";
61 import * as s57 from "../tui/screens/footing.ts";
62 import * as s58 from "../tui/screens/forgeready.ts";
63 import * as s59 from "../tui/screens/forges.ts";
64 import * as s60 from "../tui/screens/forgeview.ts";
65 import * as s61 from "../tui/screens/front.ts";
66 import * as s62 from "../tui/screens/frontms.ts";
67 import * as s63 from "../tui/screens/funnel.ts";
68 import * as s64 from "../tui/screens/games.ts";
69 import * as s65 from "../tui/screens/gifts.ts";
70 import * as s66 from "../tui/screens/health_voice.ts";
71 import * as s67 from "../tui/screens/home_pins.ts";
72 import * as s68 from "../tui/screens/hostreach.ts";
73 import * as s69 from "../tui/screens/infra.ts";
74 import * as s70 from "../tui/screens/inventory.ts";
75 import * as s71 from "../tui/screens/invites.ts";
76 import * as s72 from "../tui/screens/knobs.ts";
77 import * as s73 from "../tui/screens/lapsed.ts";
78 import * as s74 from "../tui/screens/limits.ts";
79 import * as s75 from "../tui/screens/loopstalls.ts";
80 import * as s76 from "../tui/screens/madefrom.ts";
81 import * as s77 from "../tui/screens/maintainruns.ts";
82 import * as s78 from "../tui/screens/maintenance.ts";
83 import * as s79 from "../tui/screens/maintenanceweek.ts";
84 import * as s80 from "../tui/screens/mergedbranches.ts";
85 import * as s81 from "../tui/screens/mirrorpacks.ts";
86 import * as s82 from "../tui/screens/model.ts";
87 import * as s83 from "../tui/screens/money.ts";
88 import * as s84 from "../tui/screens/newissue.ts";
89 import * as s85 from "../tui/screens/next.ts";
90 import * as s86 from "../tui/screens/nowlist.ts";
91 import * as s87 from "../tui/screens/offers.ts";
92 import * as s88 from "../tui/screens/offsite.ts";
93 import * as s89 from "../tui/screens/orggrants.ts";
94 import * as s90 from "../tui/screens/orgteams.ts";
95 import * as s91 from "../tui/screens/originahead.ts";
96 import * as s92 from "../tui/screens/owner.ts";
97 import * as s93 from "../tui/screens/packrepos.ts";
98 import * as s94 from "../tui/screens/payments.ts";
99 import * as s95 from "../tui/screens/people.ts";
100 import * as s96 from "../tui/screens/pinned.ts";
101 import * as s97 from "../tui/screens/planner.ts";
102 import * as s98 from "../tui/screens/planrow.ts";
103 import * as s99 from "../tui/screens/plans.ts";
104 import * as s100 from "../tui/screens/previewdirs.ts";
105 import * as s101 from "../tui/screens/profile.ts";
106 import * as s102 from "../tui/screens/quotas.ts";
107 import * as s103 from "../tui/screens/recoverykit.ts";
108 import * as s104 from "../tui/screens/refused.ts";
109 import * as s105 from "../tui/screens/registry_items.ts";
110 import * as s106 from "../tui/screens/repolist.ts";
111 import * as s107 from "../tui/screens/requests.ts";
112 import * as s108 from "../tui/screens/resilience.ts";
113 import * as s109 from "../tui/screens/returning.ts";
114 import * as s110 from "../tui/screens/returns.ts";
115 import * as s111 from "../tui/screens/scorecard.ts";
116 import * as s112 from "../tui/screens/scrapes.ts";
117 import * as s113 from "../tui/screens/secrets.ts";
118 import * as s114 from "../tui/screens/sentinel.ts";
119 import * as s115 from "../tui/screens/series.ts";
120 import * as s116 from "../tui/screens/ship_time.ts";
121 import * as s117 from "../tui/screens/slowpages.ts";
122 import * as s118 from "../tui/screens/sold.ts";
123 import * as s119 from "../tui/screens/spend.ts";
124 import * as s120 from "../tui/screens/stalepulls.ts";
125 import * as s121 from "../tui/screens/subscriptions.ts";
126 import * as s122 from "../tui/screens/system.ts";
127 import * as s123 from "../tui/screens/tab.ts";
128 import * as s124 from "../tui/screens/tabworks.ts";
129 import * as s125 from "../tui/screens/teams.ts";
130 import * as s126 from "../tui/screens/telemetry.ts";
131 import * as s127 from "../tui/screens/tell_undo.ts";
132 import * as s128 from "../tui/screens/traces.ts";
133 import * as s129 from "../tui/screens/traffic.ts";
134 import * as s130 from "../tui/screens/trafficview.ts";
135 import * as s131 from "../tui/screens/valves.ts";
136 import * as s132 from "../tui/screens/waiting.ts";
137 import * as s133 from "../tui/screens/waiting_for_me.ts";
138 import * as s134 from "../tui/screens/wayback.ts";
139 import * as s135 from "../tui/screens/weekcard.ts";
140 import * as s136 from "../tui/screens/whocan.ts";
142141
143142 /** Each screen file that declares palette entries: its module and the export names. */
144143 export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readonly string[]])[] = [
@@ -164,8 +163,8 @@ export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readon
164163 [s19, ["entry"]],
165164 [s20, ["entry"]],
166165 [s21, ["entry"]],
167 [s22, ["entry"]],
168 [s23, ["entry","recoveryEntry"]],
166 [s22, ["entry","recoveryEntry"]],
167 [s23, ["entry"]],
169168 [s24, ["entry"]],
170169 [s25, ["entry"]],
171170 [s26, ["entry"]],
@@ -224,11 +223,11 @@ export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readon
224223 [s79, ["entry"]],
225224 [s80, ["entry"]],
226225 [s81, ["entry"]],
227 [s82, ["entry"]],
228 [s83, ["modelGrantEntry","modelCeilingEntry"]],
226 [s82, ["modelGrantEntry","modelCeilingEntry"]],
227 [s83, ["entry"]],
229228 [s84, ["entry"]],
230 [s85, ["entry"]],
231 [s86, ["nextAllEntry"]],
229 [s85, ["nextAllEntry"]],
230 [s86, ["entry"]],
232231 [s87, ["entry"]],
233232 [s88, ["entry"]],
234233 [s89, ["entry"]],
@@ -279,5 +278,4 @@ export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readon
279278 [s134, ["entry"]],
280279 [s135, ["entry"]],
281280 [s136, ["entry"]],
282 [s137, ["entry"]],
283281 ];
src/tui/screens/captain.ts deleted −165
@@ -1,165 +0,0 @@
1 /**
2 * The check-ins screen in the terminal (#11011): the standing rules Talk
3 * remembers, the three routines with their schedules and the watches, from
4 * `talk_memory`, `talk_routines`, `talk_watch` and `runRoutine`. The web has no page for them.
5 * Owner only: a site admin who is a person.
6 *
7 * a add a rule enter edit d delete a rule
8 * space turn a routine on or off p post a routine now r read again
9 */
10
11 import { movedKey } from "./moved_key.ts";
12 import { runRoutine } from "../../crew/routines.ts";
13 import { keyOf } from "../../web/keymap.ts";
14 import { addMemory, editMemory, MEMORY_TEXT_MAX, MEMORY_WORDS, removeMemory, rulesOf, type Memory } from "../../core/talk_memory.ts";
15 import { EVERY_MAX, EVERY_MIN, listRoutines, ROUTINE_NAMES, setRoutine, type Routine } from "../../core/talk_routines.ts";
16 import { createWatch, deleteWatch, endWatch, listWatches, pauseWatch, waitsText, WATCH_KINDS, WATCH_WORDS, type Watch } from "../../core/talk_watch.ts";
17 import type { Ctx, Screen } from "../app/app.ts";
18 import { binding } from "../app/keys.ts";
19 import type { Session } from "../session.ts";
20 import { ListState, drawList, metaOf, promptScreen, runAsync, type ListRow } from "./common.ts";
21 import type { PaletteEntry } from "./entries.ts";
22
23 export const mayCaptain = (f: Session): boolean => f.user?.isAdmin === true && f.user.kind !== "agent";
24
25
26 /** "60" is every 60 minutes; "at 7" is daily at 07 UTC. */
27 export function parseSchedule(text: string): { everyMin: number; atHour: number | null } | undefined {
28 const t = text.trim().toLowerCase();
29 const every = /^(\d+)$/.exec(t);
30 if (every) return { everyMin: Number(every[1]), atHour: null };
31 const at = /^(?:at|daily)\s+(\d+)$/.exec(t);
32 if (at) return { everyMin: EVERY_MIN, atHour: Number(at[1]) };
33 return undefined;
34 }
35
36 export const scheduleText = (r: Pick<Routine, "everyMin" | "atHour">): string => (r.atHour === null ? String(r.everyMin) : `at ${r.atHour}`);
37
38 type Line = { kind: "rule"; rule: Memory } | { kind: "routine"; routine: Routine } | { kind: "watch"; watch: Watch };
39
40 /**
41 * "pull_green trevato/forge#16532: merge it once green" is a watch: its kind, its target, then the
42 * brief.
43 */
44 export function parseWatch(text: string): { kind: string; target: string; brief: string } | undefined {
45 const m = /^(\w+)\s+(\S+)\s*[:-]\s*(.+)$/s.exec(text.trim());
46 return m === null ? undefined : { kind: m[1]!, target: m[2]!, brief: m[3]! };
47 }
48
49 const watchMeta = (w: Watch): string =>
50 metaOf(w.state === "live" || w.state === "paused" ? w.state : w.endedLine, `looked ${w.lastLookAt === null ? "not yet" : w.lastLookAt.slice(0, 16).replace("T", " ")}`, `${w.wakes} wakes`, `$${w.spentUsd.toFixed(2)} of $${w.capUsd.toFixed(2)}`);
51
52 export function captainRows(lines: readonly Line[]): ListRow[] {
53 return lines.map((l) =>
54 l.kind === "rule"
55 ? { title: l.rule.text, meta: "rule" }
56 : l.kind === "watch"
57 ? { title: `Watch: ${waitsText(l.watch)}`, meta: watchMeta(l.watch) }
58 : { title: ROUTINE_NAMES[l.routine.kind], meta: metaOf(l.routine.enabled ? "on" : "off", l.routine.atHour === null ? `every ${l.routine.everyMin} min` : `daily ${String(l.routine.atHour).padStart(2, "0")}:00 UTC`, l.routine.lastAt === null ? "not yet" : l.routine.lastAt.slice(0, 16).replace("T", " ")) },
59 );
60 }
61
62 export function captainScreen(f: Session, ctx: Ctx): Screen {
63 const state = new ListState();
64 let lines: Line[] = [];
65 const read = async (): Promise<void> => {
66 const routines = listRoutines(f.app.db, f.user!.id);
67 lines = [...rulesOf(f.app.db, f.user!.id).map((rule): Line => ({ kind: "rule", rule })), ...routines.map((routine): Line => ({ kind: "routine", routine })), ...listWatches(f.app.db, f.user!.id).map((watch): Line => ({ kind: "watch", watch }))];
68 state.clamp(lines.length);
69 ctx.invalidate();
70 };
71 const refresh = (): void => void read();
72 const say = (error: string | undefined): string | undefined => {
73 refresh();
74 return error;
75 };
76 const screen: Screen = {
77 title: "Check-ins",
78 keys: [binding(["j", "k"], "move"), binding(["a"], "add a rule"), binding(["enter"], "edit"), binding(["d"], "delete"), binding(["o"], "on/off"), binding(["p"], "post now / pause a watch"), binding(["w"], "add a watch"), binding(["e"], "end a watch now"), binding([keyOf("reread")], "refresh"), binding(["esc", "q"], "close")],
79 load: read,
80 render(area, s) {
81 drawList(s, area, ctx.theme.c, state, captainRows(lines));
82 },
83 key(e) {
84 const at = lines[state.index];
85 if (e.key === "esc" || e.key === "q") ctx.pop();
86 else if (e.key === "w")
87 ctx.push(
88 promptScreen(ctx, screen, {
89 title: "Watch",
90 label: "kind target: brief",
91 hint: `Kinds: ${WATCH_KINDS.join(", ")}.`,
92 onSubmit: (v) => {
93 const w = parseWatch(v);
94 if (w === undefined) return "Type: kind target: what to do when it changes.";
95 const made = createWatch(f.app.db, f.user!, w);
96 return say(made.ok ? undefined : WATCH_WORDS[made.error]);
97 },
98 }),
99 );
100 else if (e.key === "e" && at?.kind === "watch") {
101 endWatch(f.app.db, f.user!.id, at.watch.id, "ended", "Ended by you.");
102 ctx.toast("Ended.", "success");
103 refresh();
104 } else if (e.key === "p" && at?.kind === "watch") {
105 pauseWatch(f.app.db, f.user!.id, at.watch.id, at.watch.state === "live");
106 refresh();
107 } else if (e.key === "d" && at?.kind === "watch") {
108 deleteWatch(f.app.db, f.user!.id, at.watch.id);
109 ctx.toast("Deleted.", "success");
110 refresh();
111 } else if (e.key === "a")
112 ctx.push(promptScreen(ctx, screen, { title: "Remember", label: "A rule or decision", hint: `Up to ${MEMORY_TEXT_MAX} characters.`, onSubmit: (v) => say(((r) => (r.ok ? undefined : MEMORY_WORDS[r.error]))(addMemory(f.app.db, f.user!.id, v))) }));
113 else if (e.key === "enter" && at?.kind === "rule") {
114 const rule = at.rule;
115 ctx.push(promptScreen(ctx, screen, { title: "Edit rule", label: "Rule", value: rule.text, onSubmit: (v) => say(((r) => (r.ok ? undefined : MEMORY_WORDS[r.error]))(editMemory(f.app.db, f.user!.id, rule.id, v))) }));
116 } else if (e.key === "enter" && at?.kind === "routine") {
117 const r = at.routine;
118 ctx.push(
119 promptScreen(ctx, screen, {
120 title: ROUTINE_NAMES[r.kind],
121 label: "Minutes, or \"at 7\" for daily at that UTC hour",
122 value: scheduleText(r),
123 hint: `Every ${EVERY_MIN} to ${EVERY_MAX} minutes.`,
124 onSubmit: (v) => {
125 const sched = parseSchedule(v);
126 if (sched === undefined) return "Type minutes, or at and an hour.";
127 const saved = setRoutine(f.app.db, f.user!.id, r.kind, { enabled: r.enabled, ...sched });
128 return say(saved.ok ? undefined : { not_a_routine: "That is not a routine.", bad_every: `Every must be ${EVERY_MIN} to ${EVERY_MAX} minutes.`, bad_hour: "The hour is 0 to 23." }[saved.error]);
129 },
130 }),
131 );
132 } else if (e.key === "d" && at?.kind === "rule") {
133 removeMemory(f.app.db, f.user!.id, at.rule.id);
134 ctx.toast("Forgotten.", "success");
135 refresh();
136 } else if (at?.kind === "routine" && movedKey(ctx, e, " ", "o turns it on or off now")) {
137 return true;
138 } else if (e.key === "o" && at?.kind === "routine") {
139 const r = at.routine;
140 setRoutine(f.app.db, f.user!.id, r.kind, { enabled: !r.enabled, everyMin: r.everyMin, atHour: r.atHour });
141 refresh();
142 } else if (e.key === "p" && at?.kind === "routine") {
143 const kind = at.routine.kind;
144 runAsync(ctx, async () => {
145 const posted = await runRoutine(f.app, f.user!, kind, new Date());
146 ctx.toast(posted.posted ? `${ROUTINE_NAMES[kind]} posted to your Check-ins conversation in Talk.` : `${ROUTINE_NAMES[kind]}: nothing new since the last post.`, "success");
147 await read();
148 });
149 } else if (e.key === keyOf("reread")) refresh();
150 else state.key(e, lines.length);
151 return true;
152 },
153 };
154 return screen;
155 }
156
157 export const entry: PaletteEntry = {
158 rank: 60,
159 id: "captain",
160 title: "Check-ins",
161 hint: "what Talk remembers, and the check-ins it posts for you",
162 after: ["drift"],
163 offered: mayCaptain,
164 run: (session, ctx) => ctx.push(captainScreen(session, ctx)),
165 };
test/mcp-size.test.ts +11
@@ -370,3 +370,14 @@ test("a guest's manifest names the role and lists only report and offer: a stric
370370 expect(member.result._meta?.role).toBeUndefined();
371371 expect(member.result.tools.map((t: any) => t.name)).toContain("tell");
372372 });
373
374 test("no tool the Apple app reads, nor any screen of the terminal, is the captain", async () => {
375 const { tools } = await walk();
376 const hit = tools.filter((t) => /captain/i.test(`${t.name} ${t.description ?? ""} ${JSON.stringify(t.inputSchema ?? {})}`)).map((t) => t.name);
377 expect(hit).toEqual([]);
378 const { SCREEN_MODULES } = await import("../src/generated/screens.ts");
379 const { ENTRIES } = await import("../src/tui/screens/entries.ts");
380 expect(SCREEN_MODULES.flatMap(([, names]) => names).length).toBeGreaterThan(0);
381 expect(ENTRIES.filter((e) => /captain/i.test(`${e.id} ${e.title} ${e.hint}`)).map((e) => e.id)).toEqual([]);
382 expect(await Bun.file(new URL("../src/tui/screens/captain.ts", import.meta.url)).exists()).toBe(false);
383 });
test/palette-roster.test.ts −1
@@ -137,7 +137,6 @@ test("a site-admin person is offered the whole roster", () => {
137137 ["now", "Now", "what check, review, land and live count, with the rows"],
138138 ["front-milestones", "Milestones", "the biggest open milestones: how far, what landed this week"],
139139 ["forge-view", "Forge view", "the forge's counts, and Foundry when it is installed"],
140 ["captain", "Check-ins", "what Talk remembers, and the check-ins it posts for you"],
141140 ["oauth-grants", "Connected agents", "the agents you let in through OAuth; x revokes one"],
142141 ["origin-apps", "Connection apps", "your OAuth apps for connecting accounts; a adds, d removes"],
143142 ["system-memory", "System memory", "RSS beside the JS heap, hourly for 24 h"],
test/talk-brief-voice.test.ts −2
@@ -5,7 +5,6 @@
55 * every reply to three lines and called every person the owner are gone.
66 */
77 import { describe, expect, test } from "bun:test";
8 import { STARTING_RULES } from "../src/core/talk_memory.ts";
98 import { shownLine, voiceParts } from "../src/core/talk_voice.ts";
109 import { VOICE, conversationBrief } from "../src/crew/conversation_brief.ts";
1110
@@ -61,7 +60,6 @@ describe("how the agent is told to answer", () => {
6160 expect(brief).toContain("<details><summary>");
6261 // No cap on every reply's length: the only line count is for the report after an action.
6362 expect(brief).not.toMatch(/(?:every|each|your) repl(?:y|ies)[^.]*three lines/i);
64 expect(STARTING_RULES.join(" ")).not.toContain("three lines");
6563 });
6664
6765 test("a person is not told they are the owner; their role bounds what is done", () => {
test/talk-captain-turn.test.ts +1 −2
@@ -10,7 +10,6 @@ import { tmpdir } from "node:os";
1010 import { join } from "node:path";
1111 import { createApp, type App } from "../src/app.ts";
1212 import { listTurns, openConversation } from "../src/core/conversations.ts";
13 import { addMemory } from "../src/core/talk_memory.ts";
1413 import { createUser, type User } from "../src/core/users.ts";
1514 import { configureConversation, conversationOptions, say } from "../src/crew/conversation.ts";
1615 import { FRESH_LINE } from "../src/crew/fresh_start.ts";
@@ -60,7 +59,7 @@ const ask = async (text: string) => {
6059 };
6160
6261 test("memory rides every turn; a full thread continues fresh, a roomy one resumes", async () => {
63 addMemory(app.db, owner.id, "Never run rm.");
62 app.db.query("INSERT INTO talk_memory (id, user_id, text, created_at, updated_at) VALUES (?1,?2,?3,?4,?4)").run("m-rm", owner.id, "Never run rm.", "2026-12-01T00:00:00Z");
6463 await ask("first");
6564 expect(readFileSync(join(dir, "call-0.args"), "utf8")).toContain("Never run rm.");
6665
test/talk-captain.test.ts +8 −54
@@ -12,8 +12,8 @@ import { createApp, type App } from "../src/app.ts";
1212 import { listConversations, listTurns, newConversation, renameConversation } from "../src/core/conversations.ts";
1313 import { createSession } from "../src/core/sessions.ts";
1414 import { createUser, type User } from "../src/core/users.ts";
15 import { addMemory, editMemory, listMemory, memoryBrief, removeMemory, rulesOf, seedMemory, STARTING_RULES } from "../src/core/talk_memory.ts";
16 import { due, listRoutines, ROUTINE_KINDS, routineThread, setRoutine } from "../src/core/talk_routines.ts";
15 import { listMemory, memoryBrief } from "../src/core/talk_memory.ts";
16 import { due, listRoutines, ROUTINE_KINDS, routineThread } from "../src/core/talk_routines.ts";
1717 import { compose, LINES_MAX, type Facts } from "../src/crew/routine_report.ts";
1818 import { releasesSince } from "../src/crew/routine_facts_story.ts";
1919 import { runDue, runRoutine } from "../src/crew/routines.ts";
@@ -29,7 +29,6 @@ let app: App;
2929 let servers: Servers;
3030 let owner: User;
3131 let other: User;
32 let third: User;
3332
3433 beforeAll(async () => {
3534 dir = await mkdtemp(join(tmpdir(), "forge-captain-"));
@@ -42,7 +41,6 @@ beforeAll(async () => {
4241 };
4342 owner = await mk("captainowner", true);
4443 other = await mk("buddy");
45 third = await mk("third");
4644 }, 30_000);
4745
4846 afterAll(async () => {
@@ -53,49 +51,22 @@ afterAll(async () => {
5351 const quiet: Facts = { health: [], redMain: [], needs: [], asks: 0, holds: {}, newPeople: [], waiting: 0, mergedToday: 0, openedToday: 0, releases: [], pillarsMoved: [] };
5452
5553 describe("memory", () => {
56 test("is the person's own, bounded, and in the brief", () => {
57 expect(addMemory(app.db, owner.id, " ").ok).toBe(false);
58 expect(addMemory(app.db, owner.id, "x".repeat(401))).toEqual({ ok: false, error: "too_long" });
59 const added = addMemory(app.db, owner.id, "Never rm\nanything.");
60 if (!added.ok) throw new Error("add");
61 expect(added.value.text).toBe("Never rm anything.");
62 // The first write keeps the starting rules beside it.
63 expect(memoryBrief(app.db, owner.id)).toContain(`${STARTING_RULES.length + 1}. Never rm anything.`);
54 test("stored rules are the person's own and in the brief", () => {
55 const put = (u: string, text: string) => app.db.query("INSERT INTO talk_memory (id, user_id, text, created_at, updated_at) VALUES (?1,?2,?3,?4,?4)").run(`m-${u}`, u, text, "2026-12-01T00:00:00Z");
56 put(owner.id, "Never rm anything.");
57 expect(memoryBrief(app.db, owner.id)).toContain("1. Never rm anything.");
58 expect(listMemory(app.db, owner.id).map((m) => m.text)).toEqual(["Never rm anything."]);
6459 expect(memoryBrief(app.db, other.id)).toBe("");
65 // Another person cannot edit or remove it.
66 expect(editMemory(app.db, other.id, added.value.id, "mine now")).toEqual({ ok: false, error: "not_found" });
67 expect(removeMemory(app.db, other.id, added.value.id)).toEqual({ ok: false, error: "not_found" });
68 expect(editMemory(app.db, owner.id, added.value.id, "Never rm, ever.").ok).toBe(true);
69 expect(listMemory(app.db, owner.id).at(-1)?.text).toBe("Never rm, ever.");
70 expect(removeMemory(app.db, owner.id, added.value.id).ok).toBe(true);
71 expect(memoryBrief(app.db, owner.id)).not.toContain("Never rm, ever.");
7260 });
7361
74 test("the starting rules are offered once and deleting them keeps them gone", () => {
75 seedMemory(app.db, other.id);
76 expect(listMemory(app.db, other.id).map((m) => m.text)).toEqual([...STARTING_RULES]);
77 for (const m of listMemory(app.db, other.id)) removeMemory(app.db, other.id, m.id);
78 seedMemory(app.db, other.id);
79 expect(listMemory(app.db, other.id)).toEqual([]);
80 });
81
82 test("reading writes nothing: rules and routines are shown from defaults until a write", () => {
62 test("reading writes nothing: routines are shown from defaults until a write", () => {
8363 const fresh = "reader-" + Date.now();
84 expect(rulesOf(app.db, fresh).map((m) => m.text)).toEqual([...STARTING_RULES]);
8564 expect(listRoutines(app.db, fresh).map((r) => r.kind)).toEqual([...ROUTINE_KINDS]);
8665 expect(listMemory(app.db, fresh)).toEqual([]);
8766 expect(app.db.query("SELECT COUNT(*) AS n FROM talk_routine WHERE user_id = ?1").get(fresh)).toEqual({ n: 0 });
8867 expect(app.db.query("SELECT COUNT(*) AS n FROM user_setting WHERE user_id = ?1").get(fresh)).toEqual({ n: 0 });
8968 });
9069
91 test("a shown starting rule can be deleted before anything is stored", () => {
92 const u = third.id;
93 const first = rulesOf(app.db, u)[0]!;
94 expect(first.id).toBe("start-0");
95 expect(removeMemory(app.db, u, first.id).ok).toBe(true);
96 expect(rulesOf(app.db, u).map((m) => m.text)).toEqual(STARTING_RULES.slice(1));
97 });
98
9970 test("the brief fences routine posts as untrusted", () => {
10071 const brief = conversationBrief([]);
10172 expect(brief).toContain("untrusted data");
@@ -123,13 +94,6 @@ describe("schedules", () => {
12394 expect(due(r, now)).toBe(false);
12495 expect(due({ ...r, lastAt: "2026-11-09T07:00:30Z" }, now)).toBe(true);
12596 });
126 test("a schedule is validated", () => {
127 expect(setRoutine(app.db, owner.id, "nope", { enabled: true, everyMin: 60, atHour: null })).toEqual({ ok: false, error: "not_a_routine" });
128 expect(setRoutine(app.db, owner.id, "checkin", { enabled: true, everyMin: 5, atHour: null })).toEqual({ ok: false, error: "bad_every" });
129 expect(setRoutine(app.db, owner.id, "checkin", { enabled: true, everyMin: 60, atHour: 24 })).toEqual({ ok: false, error: "bad_hour" });
130 const ok = setRoutine(app.db, owner.id, "checkin", { enabled: true, everyMin: 30, atHour: null });
131 expect(ok.ok && ok.value.everyMin).toBe(30);
132 });
13397 });
13498
13599 describe("what a routine says", () => {
@@ -242,14 +206,4 @@ describe("the web no longer has a Captain", () => {
242206 expect(routineThread(app.db, owner.id, old.id).title).toBe("Check-ins");
243207 expect(listConversations(app.db, owner.id).some((c) => c.title === "Captain")).toBe(false);
244208 });
245
246 test("the terminal reads a schedule as minutes or a daily UTC hour", async () => {
247 const { parseSchedule, scheduleText } = await import("../src/tui/screens/captain.ts");
248 expect(parseSchedule("45")).toEqual({ everyMin: 45, atHour: null });
249 expect(parseSchedule("at 7")).toEqual({ everyMin: 15, atHour: 7 });
250 expect(parseSchedule("daily 23")).toEqual({ everyMin: 15, atHour: 23 });
251 expect(parseSchedule("soon")).toBeUndefined();
252 expect(scheduleText({ everyMin: 60, atHour: null })).toBe("60");
253 expect(scheduleText({ everyMin: 60, atHour: 7 })).toBe("at 7");
254 });
255209 });
test/talk-watch.test.ts +2 −7
@@ -15,12 +15,11 @@ import { mintViaToken } from "../src/core/via_token.ts";
1515 import { createToken } from "../src/core/tokens.ts";
1616 import { addComment, createIssue } from "../src/core/issues.ts";
1717 import { createRun } from "../src/core/runs.ts";
18 import { createWatch, endWatch, listWatches, pauseWatch, WATCH_MAX } from "../src/core/talk_watch.ts";
18 import { createWatch, endWatch, listWatches, WATCH_MAX } from "../src/core/talk_watch.ts";
1919 import { createUser, type User } from "../src/core/users.ts";
2020 import { configureConversation } from "../src/crew/conversation.ts";
2121 import { ASKING } from "../src/crew/conversation_confirm.ts";
2222 import { lookDue, spentOn, wakeText } from "../src/crew/watches.ts";
23 import { parseWatch } from "../src/tui/screens/captain.ts";
2423 import { serve, type Servers } from "../src/http/server.ts";
2524 import { tool } from "../src/http/mcp/tools/talk_watch.ts";
2625 import { quietLogs } from "./helpers/globals.ts";
@@ -124,8 +123,6 @@ describe("a watch looks for free", () => {
124123 expect(listWatches(app.db, owner.id)[0]!.wakes).toBe(1);
125124 // The wake's turn is what the watch spent: found by the mark its prompt starts with.
126125 expect(spentOn(app, w)).toBeCloseTo(0.01, 5);
127 expect(parseWatch("pull_green trevato/forge#16532: merge it once green")).toEqual({ kind: "pull_green", target: "trevato/forge#16532", brief: "merge it once green" });
128 expect(parseWatch("nonsense")).toBeUndefined();
129126 });
130127
131128 test("a forge that was down for many ticks wakes once", async () => {
@@ -208,12 +205,10 @@ describe("the forge's limits end it, not the agent's word", () => {
208205 expect(createWatch(app.db, owner, { brief: "x", kind: "issue_comment", target: `${slug}#1`, done: "landed" })).toEqual({ ok: false, error: "bad_done" });
209206 });
210207
211 test("a paused watch is not looked at, and ending one frees its place", async () => {
208 test("ending a watch frees its place", async () => {
212209 clear();
213210 const w = mkWatch({ kind: "issue_comment", target: `${slug}#1` });
214211 addComment(app.db, { issueId: pullId, authorId: owner.id, body: "again" });
215 pauseWatch(app.db, owner.id, w.id, true);
216 expect(await looks(min(5))).toEqual([]);
217212 expect(endWatch(app.db, owner.id, w.id, "ended", "Ended by you.")).toBe(true);
218213 expect(listWatches(app.db, owner.id)[0]!.state).toBe("ended");
219214 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs