Public: anyone can read this; the crew can change it.
Revert "The terminal's createForgeApp imports no screen: the root, palette, search and tell key load as the app starts" #17560
Closed 3d 17h ago
revert-17496 → main 1 commit
59 files
changed +1066
−1339
- CLAUDE.md
- scripts/dup-imports-allow.json
- src/tui/app/app.ts
- src/tui/forge.ts
- src/tui/forge_parts.ts
- test/apps-template-doors.test.ts
- test/bottleneck.test.ts
- test/deepsec-rate.test.ts
- test/design-theme.test.ts
- test/disk-intake.test.ts
- test/fetch-url.test.ts
- test/flow-pipeline.test.ts
- test/flow-report-doors.test.ts
- test/flow-throughput.test.ts
- test/flows-all.test.ts
- test/footing.test.ts
- test/keeper-writer-reads.test.ts
- test/loop-stall-by-route.test.ts
- test/packs-catalog.test.ts
- test/packs-hands.test.ts
- test/packs-mirror.test.ts
- test/palette-roster.test.ts
- test/plans-row.test.ts
- test/release-keeper-guest.test.ts
- test/resilience.test.ts
- test/search-docs.test.ts
- test/spawn-self-use.test.ts
- test/status-page.test.ts
- test/strangers.test.ts
- test/system-telemetry.test.ts
- test/talk-bring.test.ts
- test/tui-app-templates.test.ts
- test/tui-apps.test.ts
- test/tui-ask-data.test.ts
- test/tui-audit.test.ts
- test/tui-boards.test.ts
- test/tui-bring.test.ts
- test/tui-capacity.test.ts
- test/tui-changelog.test.ts
- test/tui-crawlers.test.ts
- test/tui-data.test.ts
- test/tui-devices.test.ts
- test/tui-forge-lazy.test.ts
- test/tui-home-pins.test.ts
- test/tui-migrate.test.ts
- test/tui-newapp.test.ts
- test/tui-newforge.test.ts
- test/tui-neworg.test.ts
- test/tui-passkeys.test.ts
- test/tui-pricing.test.ts
- test/tui-release-keeper.test.ts
- test/tui-releases.test.ts
- test/tui-runners.test.ts
- test/tui-sentinel.test.ts
- test/tui-startforge.test.ts
- test/tui-system.test.ts
- test/tui-terms.test.ts
- test/tui-trusted.test.ts
- test/tui-valves.test.ts
CLAUDE.md +2 −3
| @@ -216,9 +216,8 @@ src/ | ||
| 216 | 216 | channels (session only), keys, wire — zero deps, no forwarding |
| 217 | 217 | tui/ the terminal UI. term/ is the transport boundary (`Terminal`); |
| 218 | 218 | app/ is the loop (screen stack, keys, palette); ui/ is the widget |
| 219 | vocabulary; screens/* are adapters over actions/; forge.ts builds | |
| 220 | the app and imports no screen, forge_parts.ts (loaded as it | |
| 221 | starts) is the root + palette; ssh.ts is the front door (identity, git exec, | |
| 219 | vocabulary; screens/* are adapters over actions/; forge.ts is the | |
| 220 | root + palette; ssh.ts is the front door (identity, git exec, | |
| 222 | 221 | `serveForgeSsh`); main.ts is the stdio dev runner |
| 223 | 222 | apps/ a repository that runs (docs/APPS.md): manifest (forge.json, |
| 224 | 223 | fail-closed), checkout (a commit exported with read-tree + |
scripts/dup-imports-allow.json +1
src/tui/app/app.ts +6 −43
| @@ -10,7 +10,6 @@ | ||
| 10 | 10 | * owns an `AbortController` that `pop()` aborts. |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | import { AsyncLocalStorage } from "node:async_hooks"; | |
| 14 | 13 | import { chordOf, whichRows, whichStep, type Chord } from "./which.ts"; |
| 15 | 14 | import { defect } from "../../kernel/error.ts"; |
| 16 | 15 | import { oldKeys } from "../../web/keymap.ts"; |
| @@ -289,13 +288,9 @@ export interface AppOpts extends SessionOpts { | ||
| 289 | 288 | /** How long a toast stays up. @default 4000 */ |
| 290 | 289 | readonly toastMs?: number; |
| 291 | 290 | readonly root: (ctx: Ctx) => Screen; |
| 292 | /** | |
| 293 | * The palette's commands; undefined while they load (the palette offers the screen's own until | |
| 294 | * then). | |
| 295 | */ | |
| 296 | readonly commands?: (ctx: Ctx) => Command[] | undefined; | |
| 291 | readonly commands?: (ctx: Ctx) => Command[]; | |
| 297 | 292 | /** Turns the palette into the global search box. */ |
| 298 | readonly search?: (ctx: Ctx) => PaletteSearch | undefined; | |
| 293 | readonly search?: (ctx: Ctx) => PaletteSearch; | |
| 299 | 294 | /** |
| 300 | 295 | * Called whenever the theme settles on a new value — the picker closing or |
| 301 | 296 | * `ctx.setTheme`. The loop knows nothing about persistence; the host does. |
| @@ -312,12 +307,6 @@ export interface AppOpts extends SessionOpts { | ||
| 312 | 307 | * closed. Unset, only the terminal or a quit stops it. |
| 313 | 308 | */ |
| 314 | 309 | readonly until?: AbortSignal; |
| 315 | /** | |
| 316 | * What the app waits for before it takes a key: the host's parts (forge.ts loads its screens, | |
| 317 | * palette and search as the app starts). Keys typed before it settles are held and then played in | |
| 318 | * order; Ctrl+C still quits at once. | |
| 319 | */ | |
| 320 | readonly ready?: Promise<unknown>; | |
| 321 | 310 | } |
| 322 | 311 | |
| 323 | 312 | /** What the host does for the tell key, given the focused screen. */ |
| @@ -368,17 +357,9 @@ export class App { | ||
| 368 | 357 | private rawResize: ((cols: number, rows: number) => void) | null = null; |
| 369 | 358 | private paletteTimers: ReturnType<typeof setTimeout>[] = []; |
| 370 | 359 | private paletteAbort: AbortController | null = null; |
| 371 | private searchMade: PaletteSearch | undefined; | |
| 372 | /** The global search, made once it is there to make (`AppOptions.search`). */ | |
| 373 | private get search(): PaletteSearch | undefined { | |
| 374 | return (this.searchMade ??= this.opts.search?.(this.ctx)); | |
| 375 | } | |
| 360 | private search: PaletteSearch | undefined; | |
| 376 | 361 | readonly ctx: Ctx; |
| 377 | private commandsMade: Command[] | undefined; | |
| 378 | /** The palette's commands, made once they are there to make (`AppOptions.commands`). */ | |
| 379 | get commands(): Command[] { | |
| 380 | return (this.commandsMade ??= this.opts.commands?.(this.ctx)) ?? []; | |
| 381 | } | |
| 362 | readonly commands: Command[] = []; | |
| 382 | 363 | |
| 383 | 364 | private pending = 0; |
| 384 | 365 | |
| @@ -456,16 +437,8 @@ export class App { | ||
| 456 | 437 | this.iconSetting = opts.prefs?.icons ?? "auto"; |
| 457 | 438 | this.capabilities = this.readCapabilities(); |
| 458 | 439 | this.ctx = this.makeCtx(); |
| 459 | if (opts.ready !== undefined) { | |
| 460 | this.heldKeys = []; | |
| 461 | void this.ctx.track( | |
| 462 | opts.ready.finally(() => { | |
| 463 | const held = this.heldKeys ?? []; | |
| 464 | this.heldKeys = null; | |
| 465 | for (const { e, within } of held) within(() => this.onKey(e)); | |
| 466 | }), | |
| 467 | ); | |
| 468 | } | |
| 440 | this.commands = opts.commands?.(this.ctx) ?? []; | |
| 441 | this.search = opts.search?.(this.ctx); | |
| 469 | 442 | this.push(opts.root(this.ctx)); |
| 470 | 443 | } |
| 471 | 444 | |
| @@ -876,21 +849,11 @@ export class App { | ||
| 876 | 849 | return this.opts.tell?.keys(this.top().screen) ?? []; |
| 877 | 850 | } |
| 878 | 851 | |
| 879 | /** | |
| 880 | * Keys typed before `AppOpts.ready` settled, in order, each with the context it was typed in | |
| 881 | * (who is acting, `core/acting_via.ts`) to replay it within; null once it has. | |
| 882 | */ | |
| 883 | private heldKeys: { e: KeyEvent; within: <R>(fn: () => R) => R }[] | null = null; | |
| 884 | ||
| 885 | 852 | private onKey(e: KeyEvent): void { |
| 886 | 853 | this.invalidate(); |
| 887 | 854 | // Ctrl+C always quits, from any overlay and any screen; Ctrl+Z is |
| 888 | 855 | // swallowed (over SSH there is no process group to suspend into). |
| 889 | 856 | if (e.ctrl && e.key === "c") return this.stop(); |
| 890 | if (this.heldKeys !== null) { | |
| 891 | this.heldKeys.push({ e, within: AsyncLocalStorage.snapshot() }); | |
| 892 | return; | |
| 893 | } | |
| 894 | 857 | if (this.overlay !== "none") { |
| 895 | 858 | this.overlayKey(e); |
| 896 | 859 | return; |
src/tui/forge.ts +1006 −47
| @@ -1,56 +1,1029 @@ | ||
| 1 | 1 | /** |
| 2 | * The forge, as a terminal application: the one function that assembles an `App` for a given | |
| 3 | * identity. It imports no screen: the root, the palette, the search and the tell key are | |
| 4 | * `forge_parts.ts`, loaded as the app starts, so reaching `createForgeApp` reaches the loop and the | |
| 5 | * session, not every screen (`test/tui-forge-lazy.test.ts` holds that). | |
| 2 | * The forge, as a terminal application: the root screen, the command palette, | |
| 3 | * and the one function that assembles an `App` for a given identity. | |
| 6 | 4 | * |
| 7 | 5 | * Everything below this line is a client. It calls the same actions the JSON |
| 8 | 6 | * API calls and the same access helpers the web pages call, so there is no |
| 9 | 7 | * capability here that a token could not exercise, and no way for a session |
| 10 | 8 | * to see something the web would have hidden. |
| 11 | 9 | */ |
| 10 | ||
| 11 | import { queueTargetsFor } from "../flow/queue_targets.ts"; | |
| 12 | import { queueTargetLines } from "./screens/flow_targets.ts"; | |
| 13 | import { publicOrigin } from "../core/public_origin.ts"; | |
| 14 | import { nearPages } from "../web/near_pages.ts"; | |
| 12 | 15 | import type { App as Forge } from "../app.ts"; |
| 13 | import { actingVia } from "../core/acting_via.ts"; | |
| 14 | import { App, type Ctx, type Screen, type TellHook } from "./app/app.ts"; | |
| 15 | import type { Command, PaletteSearch } from "./app/palette.ts"; | |
| 16 | import { search } from "../actions/search.ts"; | |
| 17 | import { greppable } from "../core/search.ts"; | |
| 18 | import { guestCodeSearch } from "../http/strangers.ts"; | |
| 19 | import { canRead, getRepo, type Repo } from "../core/repos.ts"; | |
| 20 | import { nearRepos } from "../core/near_repos.ts"; | |
| 21 | import { sourceFor } from "../view/source.ts"; | |
| 22 | import { fleetCommand } from "./screens/fleet.ts"; | |
| 23 | import { dataCommand } from "./screens/data.ts"; | |
| 24 | import { packsCommand } from "./screens/packs.ts"; | |
| 25 | import { registryGalleryCommand } from "./screens/registry_gallery.ts"; | |
| 26 | import { placesCommand } from "./screens/places.ts"; | |
| 27 | import { crewNowCommand } from "./screens/crew_now.ts"; | |
| 28 | import { publicFeedCommand } from "./screens/publicfeed.ts"; | |
| 29 | import { statusCommand } from "./screens/status.ts"; | |
| 30 | import { templatesCommand } from "./screens/templates.ts"; | |
| 31 | import { needsCommands } from "./screens/needs.ts"; | |
| 32 | import { asksAdminCommands } from "./screens/asks_admin.ts"; | |
| 33 | import { shareReceiptsCommand, shareTellCommand } from "./screens/share_tell.ts"; | |
| 34 | import { sendChangeCommand } from "./screens/send_change.ts"; | |
| 35 | import { interruptedOutCommand } from "./screens/interrupted_out.ts"; | |
| 36 | import { getForgeCommand } from "./screens/getforge.ts"; | |
| 37 | import { startForgeCommand } from "./screens/startforge.ts"; | |
| 38 | import { pricingCommand } from "./screens/pricing.ts"; | |
| 39 | import { termsCommand } from "./screens/terms.ts"; | |
| 40 | import { forgeNameCommand } from "./screens/forgename.ts"; | |
| 41 | import { workCommand } from "./screens/work.ts"; | |
| 42 | import { shellsScreen } from "./screens/shells.ts"; | |
| 43 | import { forkTreeScreen } from "./screens/fork_tree.ts"; | |
| 44 | import { roadmapScreen } from "./screens/roadmap.ts"; | |
| 45 | import { spaceScreen } from "./screens/space.ts"; | |
| 46 | import { App, type Ctx, type Screen } from "./app/app.ts"; | |
| 47 | import type { Command, PaletteItem, PaletteSearch } from "./app/palette.ts"; | |
| 48 | import { G } from "./term/screen.ts"; | |
| 49 | import { fileIcon, icon, type IconName } from "./ui/icons.ts"; | |
| 16 | 50 | import type { SessionOpts, Terminal } from "./term/terminal.ts"; |
| 51 | import { actingVia } from "../core/acting_via.ts"; | |
| 17 | 52 | import { Session, type TuiIdentity } from "./session.ts"; |
| 53 | import { | |
| 54 | ISSUE_MARK, | |
| 55 | ORIGIN_MARK, | |
| 56 | PULL_MARK, | |
| 57 | errorText, | |
| 58 | promptScreen, | |
| 59 | blank, | |
| 60 | openOnWeb, | |
| 61 | runAsync, | |
| 62 | } from "./screens/common.ts"; | |
| 63 | import { chainScreen } from "./screens/chain.ts"; | |
| 64 | import { canSeeMemory } from "../boards/memory.ts"; | |
| 65 | import { cockpitScreen } from "./screens/cockpit.ts"; | |
| 66 | import { notesScreen } from "./screens/thoughtnotes.ts"; | |
| 67 | import { deciderScreen } from "./screens/decider.ts"; | |
| 68 | import { familyScreen, withForkCount } from "./screens/family.ts"; | |
| 69 | import { securityScreen } from "./screens/security_public.ts"; | |
| 70 | import { familyLines, familyView } from "../spawn/family.ts"; | |
| 71 | import { issueScreen } from "./screens/issue.ts"; | |
| 72 | import { pullScreen } from "./screens/pull.ts"; | |
| 73 | import { blobScreen } from "./screens/repo.ts"; | |
| 74 | import { dashboardScreen } from "./screens/dashboard.ts"; | |
| 75 | import { mayManageFlags } from "../core/flags.ts"; | |
| 76 | import { mayEditTrustedHosts } from "../origins/trusted-hosts.ts"; | |
| 77 | import { trustedHostsPrompt } from "./screens/trustedhosts.ts"; | |
| 78 | import { flagsScreen } from "./screens/flags.ts"; | |
| 79 | import { forgeUsageScreen } from "./screens/forge_usage.ts"; | |
| 80 | import { usageScreen } from "./screens/usage.ts"; | |
| 81 | import { canScreen } from "./screens/can.ts"; | |
| 82 | import { forkFlowsScreen } from "./screens/forkflows.ts"; | |
| 83 | import { modelScreen } from "./screens/model.ts"; | |
| 84 | import { notifyScreen } from "./screens/notify.ts"; | |
| 85 | import { talkBuildScreen } from "./screens/talk_build.ts"; | |
| 86 | import { talkChatsScreen } from "./screens/talk_chats.ts"; | |
| 87 | import { sshOn } from "../settings/ssh.ts"; | |
| 88 | import { sshKeysScreen } from "./screens/sshkeys.ts"; | |
| 89 | import { passkeysScreen } from "./screens/passkeys.ts"; | |
| 90 | import { confirmsScreen } from "./screens/confirms.ts"; | |
| 91 | import { receiptsScreen } from "./screens/receipts.ts"; | |
| 92 | import { mayTrust, trustedScreen } from "./screens/trusted.ts"; | |
| 93 | import { mayRunners, runnersScreen } from "./screens/runners.ts"; | |
| 94 | import { proposalTokensPrompt } from "./screens/proposal_tokens.ts"; | |
| 95 | import { signInsScreen } from "./screens/signins.ts"; | |
| 96 | import { oauthGrantsScreen } from "./screens/oauthgrants.ts"; | |
| 97 | import { originAppsScreen } from "./screens/originapps.ts"; | |
| 98 | import { addEntries } from "./screens/entries.ts"; | |
| 99 | import { capacityScreen, mayCapacity } from "./screens/capacity.ts"; | |
| 100 | import { crawlersScreen } from "./screens/crawlers.ts"; | |
| 101 | import { wrap } from "./term/width.ts"; | |
| 102 | import { flowReportFor } from "../flow/report.ts"; | |
| 103 | import { forgeCeiling } from "../flow/ceiling.ts"; | |
| 104 | import { flowLines, flowScreen } from "./screens/flow.ts"; | |
| 105 | import { laneTimeLines } from "./screens/lane_times.ts"; | |
| 106 | import { askUpdate, mayDrift } from "./screens/drift.ts"; | |
| 107 | import { readHandoverLists } from "../flow/handover_read.ts"; | |
| 108 | import { readDrifts } from "../flow/alarm_drift.ts"; | |
| 109 | import { readHeld } from "../flow/held.ts"; | |
| 110 | import { answerKeeper, readKeeper } from "../flow/keeper.ts"; | |
| 111 | import { beatLine, lastBeat } from "../keeper/beat.ts"; | |
| 112 | import { readVerified } from "../flow/verified.ts"; | |
| 113 | import { memoryScreen } from "./screens/system.ts"; | |
| 114 | import { noteRead, telemetryReader } from "../actions/telemetry.ts"; | |
| 115 | import { queuesFor, systemFor } from "../system/telemetry.ts"; | |
| 116 | import { flowGatesFor } from "../actions/runs.ts"; | |
| 117 | import { apiScreen } from "./screens/api.ts"; | |
| 118 | import { changelogScreen } from "./screens/changelog.ts"; | |
| 119 | import { docScreen, docsScreen, markdownScreen } from "./screens/docs.ts"; | |
| 120 | import { fetchPage, pageText } from "../core/web_page.ts"; | |
| 121 | import { anyDocEntry } from "../view/docs.ts"; | |
| 122 | import { keeperScreen } from "./screens/keeper.ts"; | |
| 123 | import { releasesScreen } from "./screens/releases.ts"; | |
| 124 | import { mayRead, mayReadKeeper } from "../release/gate.ts"; | |
| 125 | import { fileHoldsPrompt } from "./screens/fileholds.ts"; | |
| 126 | import { heldScreen } from "./screens/held.ts"; | |
| 127 | import { stalledScreen } from "./screens/stalled.ts"; | |
| 128 | import { issuesScreen, newIssueScreen } from "./screens/issues.ts"; | |
| 129 | import { limbsScreen } from "./screens/limbs.ts"; | |
| 130 | import { nextScreen } from "./screens/next.ts"; | |
| 131 | import { estimatesScreen } from "./screens/estimates.ts"; | |
| 132 | import { findingsScreen } from "./screens/findings.ts"; | |
| 133 | import { flowsScreen } from "./screens/flows.ts"; | |
| 134 | import { weekScreen } from "./screens/week.ts"; | |
| 135 | import { machinesScreen } from "./screens/machines.ts"; | |
| 136 | import { newPullScreen } from "./screens/newpull.ts"; | |
| 137 | import { newForgeScreen } from "./screens/newforge.ts"; | |
| 138 | import { newOrgScreen } from "./screens/neworg.ts"; | |
| 139 | import { migrateScreen } from "./screens/migrate.ts"; | |
| 140 | import { bringScreen } from "./screens/bring.ts"; | |
| 141 | import { bringWorkScreen } from "./screens/bringwork.ts"; | |
| 142 | import { proposeUpstreamScreen } from "./screens/proposeupstream.ts"; | |
| 143 | import { openNewApp, templateAppScreen } from "./screens/newapp.ts"; | |
| 144 | import { newRepoScreen } from "./screens/newrepo.ts"; | |
| 145 | import { repoScreen } from "./screens/repo.ts"; | |
| 146 | import { signInScreen } from "./screens/signin.ts"; | |
| 147 | import { tellHook } from "./screens/tell_here.ts"; | |
| 148 | import { local } from "./screens/where.ts"; | |
| 18 | 149 | |
| 19 | 150 | export { Session, type TuiIdentity }; |
| 20 | 151 | |
| 21 | type PartsModule = typeof import("./forge_parts.ts"); | |
| 22 | type Parts = ReturnType<PartsModule["forgeParts"]>; | |
| 152 | export function forgeRoot(session: Session): (ctx: Ctx) => Screen { | |
| 153 | return (ctx) => dashboardScreen(session, ctx); | |
| 154 | } | |
| 23 | 155 | |
| 24 | /** The parts module once this process has it: every app after the first is built at once. */ | |
| 25 | let partsModule: PartsModule | undefined; | |
| 156 | /** The repo-scoped palette verbs: a name to ask for, and what to do with it. */ | |
| 157 | const REPO_VERBS: readonly { | |
| 158 | id: string; | |
| 159 | title: string; | |
| 160 | /** The screen to push, or nothing when the verb hands over to the web. */ | |
| 161 | open: (f: Session, ctx: Ctx, repo: Repo) => Screen | undefined; | |
| 162 | }[] = [ | |
| 163 | { | |
| 164 | id: "repo", | |
| 165 | title: "Open a repository", | |
| 166 | open: (f, ctx, repo) => repoScreen(f, ctx, local(f, repo)), | |
| 167 | }, | |
| 168 | { | |
| 169 | id: "issues", | |
| 170 | title: "Issues in a repository", | |
| 171 | open: (f, ctx, repo) => issuesScreen(f, ctx, local(f, repo), "issue"), | |
| 172 | }, | |
| 173 | { | |
| 174 | // What the Later gate holds, as /held shows it: reading is the repository's own. | |
| 175 | id: "held", | |
| 176 | title: "Held by the Later gate", | |
| 177 | open: (f, ctx, repo) => heldScreen(f, ctx, repo), | |
| 178 | }, | |
| 179 | { | |
| 180 | // The ancestors, siblings and descendants of a repository the person may read. | |
| 181 | id: "fork-tree", | |
| 182 | title: "Fork tree of a repository", | |
| 183 | open: (f, ctx, repo) => forkTreeScreen(f, ctx, repo), | |
| 184 | }, | |
| 185 | { | |
| 186 | id: "roadmap", | |
| 187 | title: "Roadmap of a repository", | |
| 188 | open: (f, ctx, repo) => roadmapScreen(f, ctx, repo), | |
| 189 | }, | |
| 190 | { | |
| 191 | id: "space", | |
| 192 | title: "Space of a repository", | |
| 193 | open: (f, ctx, repo) => spaceScreen(f, ctx, repo), | |
| 194 | }, | |
| 195 | { | |
| 196 | id: "pulls", | |
| 197 | title: "Pull requests in a repository", | |
| 198 | open: (f, ctx, repo) => issuesScreen(f, ctx, local(f, repo), "pull"), | |
| 199 | }, | |
| 200 | { | |
| 201 | id: "milestones", | |
| 202 | title: "Milestones in a repository", | |
| 203 | open: (f, ctx, repo) => limbsScreen(f, ctx, repo), | |
| 204 | }, | |
| 205 | { | |
| 206 | // The owner's one ranked list the crew builds from (#8694). | |
| 207 | id: "next-up", | |
| 208 | title: "Next up in a repository", | |
| 209 | open: (f, ctx, repo) => nextScreen(f, ctx, repo), | |
| 210 | }, | |
| 211 | { | |
| 212 | // What is promised for each issue, the base rate to ask, and recording one (#11955). | |
| 213 | id: "estimates", | |
| 214 | title: "Estimates in a repository", | |
| 215 | open: (f, ctx, repo) => estimatesScreen(f, ctx, repo), | |
| 216 | }, | |
| 217 | { | |
| 218 | // The retrospective the forge wrote at the last weekly reset, and its proposals (#8704). | |
| 219 | id: "week", | |
| 220 | title: "The week in a repository", | |
| 221 | open: (f, ctx, repo) => weekScreen(f, ctx, repo), | |
| 222 | }, | |
| 223 | { | |
| 224 | // What flows in and out of a repository, and the radar's key for its admin (#9434). | |
| 225 | id: "flows", | |
| 226 | title: "Flows of a repository", | |
| 227 | open: (f, ctx, repo) => flowsScreen(f, ctx, repo), | |
| 228 | }, | |
| 229 | { | |
| 230 | // What code scanning found, and acceptance with a reason for a writer (#9593). | |
| 231 | id: "findings", | |
| 232 | title: "Findings in a repository", | |
| 233 | open: (f, ctx, repo) => findingsScreen(f, ctx, repo), | |
| 234 | }, | |
| 235 | { | |
| 236 | // Settings → Machines' other door: the machines and last shell sessions, writers only (#9471). | |
| 237 | id: "machines", | |
| 238 | title: "Machines of a repository", | |
| 239 | open: (f, ctx, repo) => machinesScreen(f, ctx, repo), | |
| 240 | }, | |
| 241 | { | |
| 242 | // What the crew's tokens bought on one app, as MCP `returns` with `repo` (#7271). | |
| 243 | id: "repo-usage", | |
| 244 | title: "Usage of a repository", | |
| 245 | open: (f, ctx, repo) => usageScreen(f, ctx, repo), | |
| 246 | }, | |
| 247 | { id: "new-issue", title: "New issue", open: newIssueScreen }, | |
| 248 | { id: "new-pull", title: "New pull request", open: newPullScreen }, | |
| 249 | { | |
| 250 | id: "settings", | |
| 251 | title: "Repository settings", | |
| 252 | // One settings page, the web's (#635): the terminal hands over its address. | |
| 253 | open: (f, ctx, repo) => { | |
| 254 | openOnWeb(f, ctx, `/${repo.ownerName}/${repo.name}/settings`, "Settings"); | |
| 255 | return undefined; | |
| 256 | }, | |
| 257 | }, | |
| 258 | ]; | |
| 26 | 259 | |
| 27 | 260 | /** |
| 28 | * The root screen until its module is in: it draws nothing and takes no key, and its load is the | |
| 29 | * module's arrival and then the real root's own load, so a settled app is the same as before. | |
| 261 | * The palette. Repo-scoped verbs ask for `owner/name` in a prompt and resolve | |
| 262 | * it through `getRepo` plus the screen's own access checks — a repo you | |
| 263 | * cannot read is reported as not found, exactly as it is everywhere else. | |
| 30 | 264 | */ |
| 31 | function rootWhenLoaded(parts: Promise<Parts>): (ctx: Ctx) => Screen { | |
| 265 | export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | |
| 32 | 266 | return (ctx) => { |
| 33 | let inner: Screen | undefined; | |
| 34 | return { | |
| 35 | get title() { | |
| 36 | return inner?.title ?? ""; | |
| 267 | const commands: Command[] = [ | |
| 268 | { | |
| 269 | id: "home", | |
| 270 | title: "Home", | |
| 271 | hint: "your repositories", | |
| 272 | run: () => ctx.push(dashboardScreen(session, ctx)), | |
| 37 | 273 | }, |
| 38 | get keys() { | |
| 39 | return inner?.keys ?? []; | |
| 274 | { | |
| 275 | // Browsing other people and forges is the web explorer's (#607): | |
| 276 | // the terminal hands over its address. | |
| 277 | id: "explore", | |
| 278 | title: "Explore", | |
| 279 | hint: "on the web", | |
| 280 | run: () => openOnWeb(session, ctx, "/explore", "The explorer"), | |
| 40 | 281 | }, |
| 41 | render: (area, s) => inner?.render(area, s), | |
| 42 | key: (e) => inner?.key(e) ?? false, | |
| 43 | paste: (text) => inner?.paste?.(text) ?? false, | |
| 44 | load: async (signal) => { | |
| 45 | inner = (await parts).root(ctx); | |
| 46 | await inner.load?.(signal); | |
| 282 | { | |
| 283 | // The same list as an Atom feed (#10967): the terminal hands over | |
| 284 | // the feed's address, to copy into a reader. | |
| 285 | id: "explore-feed", | |
| 286 | title: "Explore feed", | |
| 287 | hint: "Atom address", | |
| 288 | run: () => openOnWeb(session, ctx, "/explore.atom", "The explore feed"), | |
| 47 | 289 | }, |
| 48 | commands: () => inner?.commands?.() ?? [], | |
| 49 | here: () => inner?.here?.(), | |
| 50 | }; | |
| 290 | ...needsCommands(session, ctx), | |
| 291 | ...asksAdminCommands(session, ctx), | |
| 292 | packsCommand(session, ctx), | |
| 293 | registryGalleryCommand(session, ctx), | |
| 294 | ...(session.user ? [placesCommand(session, ctx)] : []), | |
| 295 | crewNowCommand(session, ctx), | |
| 296 | publicFeedCommand(session, ctx), | |
| 297 | statusCommand(session, ctx), | |
| 298 | templatesCommand(session, ctx), | |
| 299 | shareTellCommand(session, ctx), | |
| 300 | sendChangeCommand(ctx), | |
| 301 | interruptedOutCommand(session, ctx), | |
| 302 | getForgeCommand(session, ctx), | |
| 303 | ...startForgeCommand(session, ctx), | |
| 304 | pricingCommand(session, ctx), | |
| 305 | termsCommand(session, ctx), | |
| 306 | ...forgeNameCommand(session, ctx), | |
| 307 | ...dataCommand(session, ctx), | |
| 308 | fleetCommand(session, ctx), | |
| 309 | { | |
| 310 | // A person's or an org's page is the web's (#636): the terminal | |
| 311 | // hands over its address. | |
| 312 | id: "profile", | |
| 313 | title: "Open a profile", | |
| 314 | hint: "username or org", | |
| 315 | run: () => | |
| 316 | ctx.push( | |
| 317 | askFor(ctx, "Profile", "username", (name) => { | |
| 318 | openOnWeb(session, ctx, `/${encodeURIComponent(name)}`, "That profile"); | |
| 319 | return undefined; | |
| 320 | }), | |
| 321 | ), | |
| 322 | }, | |
| 323 | ]; | |
| 324 | ||
| 325 | for (const verb of REPO_VERBS) | |
| 326 | commands.push({ | |
| 327 | id: verb.id, | |
| 328 | title: verb.title, | |
| 329 | hint: "owner/name", | |
| 330 | run: () => | |
| 331 | ctx.push( | |
| 332 | askFor(ctx, verb.title, "owner/name", (spec) => { | |
| 333 | const [owner, name] = spec.split("/"); | |
| 334 | const repo = | |
| 335 | owner && name ? getRepo(session.db, owner, name) : undefined; | |
| 336 | // The palette is a client like any other: a repo you cannot | |
| 337 | // read is "not found", indistinguishable from a typo. Without | |
| 338 | // this check the palette would be a way around `canRead`. | |
| 339 | if (!repo || !canRead(session.db, repo, session.user)) { | |
| 340 | const near = owner && name ? nearRepos(session.db, session.user, owner, name) : []; | |
| 341 | const pages = nearPages(`/${spec}`, { | |
| 342 | signedIn: session.signedIn, | |
| 343 | admin: session.user?.isAdmin === true, | |
| 344 | }).map((p) => p.href); | |
| 345 | return near.length === 0 | |
| 346 | ? pages.length === 0 | |
| 347 | ? "not found — it does not exist, or is not visible to you" | |
| 348 | : `not found — pages like it, on the web: ${pages.join(", ")}` | |
| 349 | : `not found — did you mean ${near.map((r) => `${r.ownerName}/${r.name}`).join(", ")}?`; | |
| 350 | } | |
| 351 | // After the prompt has popped itself, or the pop takes the | |
| 352 | // screen just pushed instead (`later` in screens/common.ts). | |
| 353 | return Promise.resolve().then(() => { | |
| 354 | const next = verb.open(session, ctx, repo); | |
| 355 | if (next !== undefined) ctx.push(next); | |
| 356 | }); | |
| 357 | }), | |
| 358 | ), | |
| 359 | }); | |
| 360 | ||
| 361 | commands.push( | |
| 362 | session.signedIn | |
| 363 | ? { | |
| 364 | id: "new-repo", | |
| 365 | title: "New repository", | |
| 366 | run: () => ctx.push(newRepoScreen(session, ctx)), | |
| 367 | } | |
| 368 | : { | |
| 369 | id: "signin", | |
| 370 | title: "Sign in", | |
| 371 | run: () => | |
| 372 | ctx.push(signInScreen(session, ctx, () => ctx.invalidate())), | |
| 373 | }, | |
| 374 | ); | |
| 375 | // The owner's read-only mirrors, as the profile's "work (read-only)" draws them. | |
| 376 | if (session.user !== undefined && session.user.kind !== "agent") commands.push(workCommand(session, ctx)); | |
| 377 | // What this person's phone share sheet filed, as each receipt at /tell/share/:id shows it. | |
| 378 | if (session.user !== undefined && session.user.kind !== "agent") commands.push(shareReceiptsCommand(session, ctx)); | |
| 379 | // An app from a sentence, as /apps/new makes it: a person's, never an agent's. | |
| 380 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 381 | commands.push({ | |
| 382 | id: "new-app", | |
| 383 | title: "New app", | |
| 384 | hint: "say what it does in a sentence; the crew starts on it", | |
| 385 | run: () => openNewApp(session, ctx, blank("New app")), | |
| 386 | }); | |
| 387 | // The same from a template repository, as /apps/new?template= does. | |
| 388 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 389 | commands.push({ | |
| 390 | id: "new-app-template", | |
| 391 | title: "New app from a template", | |
| 392 | hint: "copy a repository you can read, as the starting files", | |
| 393 | run: () => ctx.push(templateAppScreen(session, ctx, blank("New app"))), | |
| 394 | }); | |
| 395 | // An app from another forge, as /bring does: a person's, never an agent's. | |
| 396 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 397 | commands.push({ | |
| 398 | id: "bring-app", | |
| 399 | title: "Bring an app", | |
| 400 | hint: "paste a link from another forge; it runs here", | |
| 401 | run: () => ctx.push(bringScreen(session, ctx, blank("Bring an app"))), | |
| 402 | }); | |
| 403 | // A repository kept elsewhere, to work on here, as Talk's `bring` does: a person's. | |
| 404 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 405 | commands.push({ | |
| 406 | id: "bring-work", | |
| 407 | title: "Work on a repository", | |
| 408 | hint: "from GitHub or another forge: your private copy here, the crew on it", | |
| 409 | run: () => ctx.push(bringWorkScreen(session, ctx, blank("Work on a repository"))), | |
| 410 | }); | |
| 411 | // A pull request at the origin from that copy, as Talk's `propose_upstream` does: a person's. | |
| 412 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 413 | commands.push({ | |
| 414 | id: "propose-upstream", | |
| 415 | title: "Propose upstream", | |
| 416 | hint: "your copy's branch as a pull request where the repository is kept", | |
| 417 | run: () => ctx.push(proposeUpstreamScreen(session, ctx, blank("Propose upstream"))), | |
| 418 | }); | |
| 419 | // An organization you own, as /organizations/new and MCP `org_create` make it: a person's, | |
| 420 | // never an agent's (#7260). | |
| 421 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 422 | commands.push({ | |
| 423 | id: "new-org", | |
| 424 | title: "New organization", | |
| 425 | hint: "an organization you own, for a client's apps", | |
| 426 | run: () => ctx.push(newOrgScreen(session, ctx)), | |
| 427 | }); | |
| 428 | if (session.signedIn) | |
| 429 | commands.push({ | |
| 430 | id: "migrate", | |
| 431 | title: "Migrate a repository", | |
| 432 | hint: "bring one in from an origin or a URL, pick its branch, put a crew on it", | |
| 433 | run: () => ctx.push(migrateScreen(session, ctx)), | |
| 434 | }); | |
| 435 | // A client's forge, as /forges/new makes it: any signed-in person's; the door decides the rest. | |
| 436 | if (session.signedIn) | |
| 437 | commands.push({ | |
| 438 | id: "new-forge", | |
| 439 | title: "New forge", | |
| 440 | hint: "spawn a client's forge and get its claim link", | |
| 441 | run: () => ctx.push(newForgeScreen(session, ctx)), | |
| 442 | }); | |
| 443 | // One screen, four keys: what happened, what needs you, the waves (#1152). | |
| 444 | if (session.signedIn) | |
| 445 | commands.push({ | |
| 446 | id: "cockpit", | |
| 447 | title: "Cockpit", | |
| 448 | hint: "what needs you, what happened, the waves under way", | |
| 449 | run: () => ctx.push(cockpitScreen(session, ctx)), | |
| 450 | }); | |
| 451 | // One box to write an idea in, each note with its live state; /notes' own door (#8696). | |
| 452 | if (session.signedIn) | |
| 453 | commands.push({ | |
| 454 | id: "thought-notes", | |
| 455 | title: "Notes", | |
| 456 | hint: "write an idea and watch it become shipped work", | |
| 457 | run: () => ctx.push(notesScreen(session, ctx)), | |
| 458 | }); | |
| 459 | if (session.signedIn) | |
| 460 | commands.push({ | |
| 461 | id: "decider", | |
| 462 | title: "Decider", | |
| 463 | hint: "what it closed, deferred and asked you about today", | |
| 464 | run: () => ctx.push(deciderScreen(session, ctx)), | |
| 465 | }); | |
| 466 | // The machine shells this person holds (#10544); an agent holds none. | |
| 467 | if (session.signedIn && session.user?.kind !== "agent") | |
| 468 | commands.push({ | |
| 469 | id: "shells", | |
| 470 | title: "Your shells", | |
| 471 | hint: "the machine shells you hold, live then ended", | |
| 472 | run: () => ctx.push(shellsScreen(session, ctx)), | |
| 473 | }); | |
| 474 | // Where a decision finds the owner; an agent is never offered it. | |
| 475 | if (session.signedIn && session.user?.kind !== "agent") | |
| 476 | commands.push({ | |
| 477 | id: "notify", | |
| 478 | title: "Phone notifications", | |
| 479 | hint: "where the crew reaches your phone; s sets, x turns off", | |
| 480 | run: () => ctx.push(notifyScreen(session, ctx)), | |
| 481 | }); | |
| 482 | // What the forge's agent asked first, waiting for the person's yes (#7650). | |
| 483 | if (session.signedIn && session.user?.kind !== "agent") | |
| 484 | commands.push({ | |
| 485 | id: "confirms", | |
| 486 | title: "Confirms", | |
| 487 | hint: "what the forge's agent asked to do; y does it once", | |
| 488 | run: () => ctx.push(confirmsScreen(session, ctx)), | |
| 489 | }); | |
| 490 | // What a confirmed action left that can still be undone (#12680): the page's Undo, from the | |
| 491 | // terminal. | |
| 492 | if (session.signedIn && session.user?.kind !== "agent") | |
| 493 | commands.push({ | |
| 494 | id: "receipts", | |
| 495 | title: "Receipts", | |
| 496 | hint: "what you confirmed in /talk; u undoes it once", | |
| 497 | run: () => ctx.push(receiptsScreen(session, ctx)), | |
| 498 | }); | |
| 499 | // Who folds in without a person's review, and the kill switch (#8937): a forge admin's. | |
| 500 | if (session.signedIn && mayTrust(session)) | |
| 501 | commands.push({ | |
| 502 | id: "trusted", | |
| 503 | title: "Trusted sources", | |
| 504 | hint: "who folds in without review; a trusts, x removes, s stops all, v reverts", | |
| 505 | run: () => ctx.push(trustedScreen(session, ctx)), | |
| 506 | }); | |
| 507 | // The machines that take the forge's checks, as Settings → Runners lists them (#15252): an | |
| 508 | // admin's. | |
| 509 | if (session.signedIn && mayRunners(session)) | |
| 510 | commands.push({ | |
| 511 | id: "runners", | |
| 512 | title: "Runners", | |
| 513 | hint: "the machines that take this forge's checks; x removes a hand-made one", | |
| 514 | run: () => ctx.push(runnersScreen(session, ctx)), | |
| 515 | }); | |
| 516 | // The forge's agent keeps many conversations, as /talk lists them (#8814). | |
| 517 | if (session.signedIn && session.user?.kind !== "agent") | |
| 518 | commands.push({ | |
| 519 | id: "conversations", | |
| 520 | title: "Conversations", | |
| 521 | hint: "your talks with the forge's agent; n starts one, r renames, x archives", | |
| 522 | run: () => ctx.push(talkChatsScreen(session, ctx)), | |
| 523 | }); | |
| 524 | // One prompt builds an app; each turn is a version to diff, restore and publish (#11010). | |
| 525 | if (session.signedIn && session.user?.kind !== "agent") | |
| 526 | commands.push({ | |
| 527 | id: "build-app", | |
| 528 | title: "Build an app", | |
| 529 | hint: "say what to build; versions, diff, restore and publish. n starts one", | |
| 530 | run: () => ctx.push(talkBuildScreen(session, ctx)), | |
| 531 | }); | |
| 532 | // A web page as the forge's agent reads it (`fetch_url`): the same Markdown, the same guard. | |
| 533 | if (session.signedIn) | |
| 534 | commands.push({ | |
| 535 | id: "fetch-page", | |
| 536 | title: "Read a web page", | |
| 537 | hint: "paste an https link; the page as Markdown, as Talk's agent reads it", | |
| 538 | run: () => | |
| 539 | ctx.push( | |
| 540 | askFor(ctx, "Read a web page", "An https link", (url) => { | |
| 541 | if (url === "") return "Paste a link."; | |
| 542 | return fetchPage(session.app.db, { url, who: session.user?.id ?? "" }).then((got) => { | |
| 543 | if (!got.ok) ctx.toast(got.error.message, "danger"); | |
| 544 | else ctx.push(markdownScreen(ctx, got.value.title || got.value.finalUrl, pageText(got.value))); | |
| 545 | }); | |
| 546 | }), | |
| 547 | ), | |
| 548 | }); | |
| 549 | // Only while the SSH switch is on (`settings/ssh.ts`); off, the keys are not a thing here. | |
| 550 | if (session.signedIn && sshOn(session.app.db)) | |
| 551 | commands.push({ | |
| 552 | id: "ssh-keys", | |
| 553 | title: "Computer keys", | |
| 554 | hint: "list, add and remove the keys that sign in as you", | |
| 555 | run: () => ctx.push(sshKeysScreen(session, ctx)), | |
| 556 | }); | |
| 557 | // /forks/flows, GET /api/v1/forks/flows and MCP `fork_flows`: one function, `forkFlows` | |
| 558 | // (#17056). | |
| 559 | if (session.signedIn) | |
| 560 | commands.push({ | |
| 561 | id: "fork-flows", | |
| 562 | title: "Fork flows", | |
| 563 | hint: "what I follow, what I offered, what my forks offered me", | |
| 564 | run: () => ctx.push(forkFlowsScreen(session, ctx)), | |
| 565 | }); | |
| 566 | // Settings › Passkeys and MCP `whoami_can kind: passkeys`, read only (#8044). | |
| 567 | if (session.signedIn && session.user?.kind !== "agent") | |
| 568 | commands.push({ | |
| 569 | id: "passkeys", | |
| 570 | title: "Passkeys", | |
| 571 | hint: "the passkeys that sign in as you", | |
| 572 | run: () => ctx.push(passkeysScreen(session, ctx)), | |
| 573 | }); | |
| 574 | if (session.signedIn) | |
| 575 | commands.push( | |
| 576 | { | |
| 577 | id: "account", | |
| 578 | title: "Account settings", | |
| 579 | run: () => openOnWeb(session, ctx, "/settings", "Account settings"), | |
| 580 | }, | |
| 581 | // Settings → Sessions and MCP `sessions`, in the terminal (#7237). | |
| 582 | { | |
| 583 | id: "signins", | |
| 584 | title: "Signed in", | |
| 585 | hint: "your browsers and tokens; d signs a browser out", | |
| 586 | run: () => ctx.push(signInsScreen(session, ctx)), | |
| 587 | }, | |
| 588 | // Settings › Connected agents: the OAuth grants you gave (#13308). | |
| 589 | { | |
| 590 | id: "oauth-grants", | |
| 591 | title: "Connected agents", | |
| 592 | hint: "the agents you let in through OAuth; x revokes one", | |
| 593 | run: () => ctx.push(oauthGrantsScreen(session, ctx)), | |
| 594 | }, | |
| 595 | // Settings → Connected accounts' OAuth apps and MCP `origin_apps` (#7291). | |
| 596 | { | |
| 597 | id: "origin-apps", | |
| 598 | title: "Connection apps", | |
| 599 | hint: "your OAuth apps for connecting accounts; a adds, d removes", | |
| 600 | run: () => ctx.push(originAppsScreen(session, ctx)), | |
| 601 | }, | |
| 602 | ); | |
| 603 | // The forge's RSS beside its JS heap, as /system gates it (#2151). | |
| 604 | if (canSeeMemory(session.user)) | |
| 605 | commands.push({ | |
| 606 | id: "system-memory", | |
| 607 | title: "System memory", | |
| 608 | hint: "RSS beside the JS heap, hourly for 24 h", | |
| 609 | run: () => ctx.push(memoryScreen(session, ctx)), | |
| 610 | }); | |
| 611 | // The pipeline's bottleneck and throughput, as /flow says them: a site admin's (#1554, #1786). | |
| 612 | const flowReader = telemetryReader(session.app, session.user); | |
| 613 | if (flowReader) | |
| 614 | commands.push({ | |
| 615 | id: "flow", | |
| 616 | title: "Flow", | |
| 617 | hint: "the pipeline's bottleneck and throughput", | |
| 618 | run: () => { | |
| 619 | if (session.user) noteRead(session.app, session.user, flowReader, "flow"); | |
| 620 | const keeper = readKeeper(session.db, flowReader.kind === "owner"); | |
| 621 | const user = session.user; | |
| 622 | const reportLines = ["", "Flow report:", ...flowReportFor(session.db, flowReader).lines.flatMap((l) => wrap(l, 58))]; | |
| 623 | ctx.push(flowScreen(ctx, flowLines( | |
| 624 | session.db, | |
| 625 | new Date(), | |
| 626 | systemFor(session.app, flowReader).duplicates, | |
| 627 | flowReader.kind === "agent" | |
| 628 | ? { | |
| 629 | queues: queuesFor(session.app, flowReader, new Date(), { batches: true }), | |
| 630 | gates: flowGatesFor(session.app, user), | |
| 631 | } | |
| 632 | : undefined, | |
| 633 | readHeld(session.app, flowReader.kind === "owner"), | |
| 634 | forgeCeiling(session.app.config), | |
| 635 | readVerified(session.app, flowReader.kind === "owner"), | |
| 636 | keeper, | |
| 637 | session.app.config.dataDir, | |
| 638 | flowReader.kind === "owner" ? beatLine(lastBeat(session.db), new Date()) : undefined, | |
| 639 | publicOrigin(session.app.config.url, `http://${session.app.config.host ?? "localhost"}:${session.app.config.port ?? 3000}`), | |
| 640 | ).concat(laneTimeLines(session.db, user), flowReader.kind === "owner" ? ["", ...queueTargetLines(queueTargetsFor(session.app)).flatMap((l) => wrap(l, 58))] : [], reportLines), keeper.ask && user ? { ask: keeper.ask, answer: () => answerKeeper(session.app, keeper.ask!.id, user.id) } : undefined, | |
| 641 | mayDrift(session) | |
| 642 | ? { read: async () => readHandoverLists(session.db, await readDrifts(session.app), Date.now()), update: (n) => askUpdate(session, n) } | |
| 643 | : undefined)); | |
| 644 | }, | |
| 645 | }); | |
| 646 | // The forge's capacity and guards, as MCP `capacity` gates them: a forge admin who is a person. | |
| 647 | if (mayCapacity(session)) | |
| 648 | commands.push({ | |
| 649 | id: "capacity", | |
| 650 | title: "Capacity", | |
| 651 | hint: "concurrency and guards, live; e changes a settable one", | |
| 652 | run: () => ctx.push(capacityScreen(session, ctx)), | |
| 653 | }); | |
| 654 | // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's | |
| 655 | // readers. | |
| 656 | if (mayCapacity(session)) | |
| 657 | commands.push({ | |
| 658 | id: "crawlers", | |
| 659 | title: "Crawlers", | |
| 660 | hint: "their share of answering time, and who was refused", | |
| 661 | run: () => ctx.push(crawlersScreen(session, ctx)), | |
| 662 | }); | |
| 663 | // The forge's API operations, as /api lists them; Enter runs a GET: for anyone. | |
| 664 | commands.push({ | |
| 665 | id: "api", | |
| 666 | title: "API", | |
| 667 | hint: "the forge's endpoints; run a GET", | |
| 668 | run: () => ctx.push(apiScreen(session, ctx)), | |
| 669 | }); | |
| 670 | // The forge's documentation, as /docs lists it: for anyone. | |
| 671 | commands.push({ | |
| 672 | id: "docs", | |
| 673 | title: "Docs", | |
| 674 | hint: "the forge's documentation; Enter reads one", | |
| 675 | run: () => ctx.push(docsScreen(ctx, sshOn(session.app.db))), | |
| 676 | }); | |
| 677 | // The last releases with their pulls, as /changelog shows them: for anyone. | |
| 678 | commands.push({ | |
| 679 | id: "changelog", | |
| 680 | title: "Changelog", | |
| 681 | hint: "the last 30 releases and their pulls", | |
| 682 | run: () => ctx.push(changelogScreen(session, ctx)), | |
| 683 | }); | |
| 684 | // The live release and the kept ones, as /releases gates them: a site admin or a reader of | |
| 685 | // FORGE_REPO. | |
| 686 | if (mayRead(session.app, session.user)) | |
| 687 | commands.push({ | |
| 688 | id: "releases", | |
| 689 | title: "Releases", | |
| 690 | hint: "the live release and the kept ones", | |
| 691 | run: () => ctx.push(releasesScreen(session, ctx)), | |
| 692 | }); | |
| 693 | // The release keeper's card (#7557), read by whoever reads GET /api/v1/keeper (#15515). | |
| 694 | if (mayReadKeeper(session.app, session.user)) | |
| 695 | commands.push({ | |
| 696 | id: "keeper", | |
| 697 | title: "Release keeper", | |
| 698 | hint: "what holds the next cut, and each release it cut with its probes", | |
| 699 | run: () => ctx.push(keeperScreen(session, ctx)), | |
| 700 | }); | |
| 701 | // Stalled flow steps the viewer can unblock, as the home's cards show them (#1807). | |
| 702 | if (session.signedIn) | |
| 703 | commands.push({ | |
| 704 | id: "stalled", | |
| 705 | title: "Stalled steps", | |
| 706 | hint: "pulls whose check is red or was never asked for; enter re-runs", | |
| 707 | run: () => ctx.push(stalledScreen(session, ctx)), | |
| 708 | }); | |
| 709 | // Hold new work on a file: the settings card's twin, admin-checked by the action itself. | |
| 710 | if (session.signedIn) | |
| 711 | commands.push({ | |
| 712 | id: "file-holds", | |
| 713 | title: "Held files", | |
| 714 | hint: "hold new work on a file, release it, or list the holds", | |
| 715 | run: () => ctx.push(fileHoldsPrompt(session, ctx, blank("Held files"))), | |
| 716 | }); | |
| 717 | // Settings → Flags, as the page has it: an admin who is not an agent (#1970). | |
| 718 | if (mayManageFlags(session.user)) | |
| 719 | commands.push({ | |
| 720 | id: "flags", | |
| 721 | title: "Flags", | |
| 722 | hint: "declared flags and their live values", | |
| 723 | run: () => ctx.push(flagsScreen(session, ctx)), | |
| 724 | }); | |
| 725 | // Settings → Connected accounts' trusted internal hosts: the same admin gate as the page. | |
| 726 | if (mayEditTrustedHosts(session.user)) | |
| 727 | commands.push({ | |
| 728 | id: "trusted-hosts", | |
| 729 | title: "Trusted hosts", | |
| 730 | hint: "internal hosts an origin may reach", | |
| 731 | run: () => ctx.push(trustedHostsPrompt(session, ctx, blank("Trusted hosts"))), | |
| 732 | }); | |
| 733 | // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's | |
| 734 | // gate, the same as Flags (#1565). | |
| 735 | if (session.user !== undefined) | |
| 736 | commands.push({ | |
| 737 | id: "usage", | |
| 738 | title: "Usage", | |
| 739 | hint: "the forge's spend and headroom; an admin also sees every route", | |
| 740 | run: () => ctx.push(usageScreen(session, ctx)), | |
| 741 | }); | |
| 742 | // What the forge spent across the apps you write, as GET /api/v1/usage and MCP `usage` answer. | |
| 743 | if (session.user !== undefined) | |
| 744 | commands.push({ | |
| 745 | id: "forge-spend", | |
| 746 | title: "Forge spend", | |
| 747 | hint: "today and the last 24 hours, headroom per subscription", | |
| 748 | run: () => ctx.push(forgeUsageScreen(session, ctx)), | |
| 749 | }); | |
| 750 | // Proposal tokens for a repository you write, as the API and MCP have them (#2148). | |
| 751 | if (session.user !== undefined) | |
| 752 | commands.push({ | |
| 753 | id: "proposal-tokens", | |
| 754 | title: "Proposal tokens", | |
| 755 | hint: "mint, list and revoke what a child proposes with", | |
| 756 | run: () => ctx.push(proposalTokensPrompt(session, ctx, blank("Proposal tokens"))), | |
| 757 | }); | |
| 758 | // Settings → Model: a person's own budget and subscription, as the page has them (#1145). | |
| 759 | if (session.user?.kind === "user") | |
| 760 | commands.push({ | |
| 761 | id: "model", | |
| 762 | title: "Model budget", | |
| 763 | hint: "what your crew may spend, and add your own subscription", | |
| 764 | run: () => ctx.push(modelScreen(session, ctx)), | |
| 765 | }); | |
| 766 | // The caller's own role and row of the roles table, as /settings and `whoami_can` have it | |
| 767 | // (#2304). | |
| 768 | if (session.user !== undefined) | |
| 769 | commands.push({ | |
| 770 | id: "can", | |
| 771 | title: "What I can do", | |
| 772 | hint: "your role and what it allows here", | |
| 773 | run: () => ctx.push(canScreen(session, ctx)), | |
| 774 | }); | |
| 775 | // Entries that live beside their screen, each at the place it names. | |
| 776 | addEntries(commands, session, ctx); | |
| 777 | // What /security says, for anyone (#13208). | |
| 778 | commands.push({ | |
| 779 | id: "security", | |
| 780 | title: "Security", | |
| 781 | hint: "what the forge enforces for everyone, and how to report a problem", | |
| 782 | run: () => ctx.push(securityScreen(ctx)), | |
| 783 | }); | |
| 784 | commands.push({ | |
| 785 | id: "family", | |
| 786 | title: "Family", | |
| 787 | hint: "the forge that sent this one, and the forges it sent", | |
| 788 | run: () => | |
| 789 | runAsync(ctx, async () => { | |
| 790 | const view = await familyView(session.app, session.user?.isAdmin === true); | |
| 791 | ctx.push(familyScreen(ctx, withForkCount(familyLines(view), view.children.length))); | |
| 792 | }), | |
| 793 | }); | |
| 794 | commands.push({ | |
| 795 | id: "chain", | |
| 796 | title: "Chain", | |
| 797 | hint: "the forges this forge's code descends from, root first", | |
| 798 | run: () => | |
| 799 | runAsync(ctx, async () => { | |
| 800 | ctx.push(await chainScreen(session.app, session.user, ctx)); | |
| 801 | }), | |
| 802 | }); | |
| 803 | commands.push({ | |
| 804 | id: "quit", | |
| 805 | title: "Quit", | |
| 806 | hint: "disconnect", | |
| 807 | run: () => ctx.quit(), | |
| 808 | }); | |
| 809 | return commands; | |
| 51 | 810 | }; |
| 52 | 811 | } |
| 53 | 812 | |
| 813 | /** | |
| 814 | * The palette's search half: one `search()` call, three sections. | |
| 815 | * | |
| 816 | * Everything the session can reach is in scope — the repos here, the repos | |
| 817 | * cached from every origin they have connected, conversations on both sides, | |
| 818 | * and the code itself through `git grep`. The action decides visibility once, | |
| 819 | * exactly as the web search page and the API do; nothing is filtered here, | |
| 820 | * because a row that reached this function was already allowed to. | |
| 821 | * | |
| 822 | * Enter on an origin repo opens the **live browse**, not a mirror: browse | |
| 823 | * first, mirror if you mean it (`view/source.ts`). A repo somebody else's | |
| 824 | * origin holds is `not_found` for you, and `sourceFor` is what says so. | |
| 825 | */ | |
| 826 | export function forgeSearch(session: Session): (ctx: Ctx) => PaletteSearch { | |
| 827 | return (ctx) => async (query, live, signal) => { | |
| 828 | // A guest is a stranger with a key: its search greps code under the same | |
| 829 | // limits as the page's and the API's (`http/strangers.ts`), counted | |
| 830 | // under its peer address. Refused, everything but the code is searched. | |
| 831 | // A one-letter query greps nothing (#11120), so it takes no slot either. | |
| 832 | const greps = session.user === undefined && greppable(query); | |
| 833 | const held = greps | |
| 834 | ? guestCodeSearch(session.app, session.identity.remoteAddress) | |
| 835 | : undefined; | |
| 836 | // `pulls: retry` narrows to pull requests, as `kind=pulls` does on the page. | |
| 837 | const pullsOnly = /^pulls:\s*/i.test(query); | |
| 838 | const q = pullsOnly ? query.replace(/^pulls:\s*/i, "") : query; | |
| 839 | let found; | |
| 840 | try { | |
| 841 | found = await search(session.app, session.user, { | |
| 842 | q, | |
| 843 | ...(pullsOnly ? { kind: "pulls" as const } : {}), | |
| 844 | limit: 8, | |
| 845 | live, | |
| 846 | withCode: held === undefined || held.allowed, | |
| 847 | }); | |
| 848 | } finally { | |
| 849 | if (held?.allowed) held.release(); | |
| 850 | } | |
| 851 | if (signal.aborted) return []; | |
| 852 | const items: PaletteItem[] = []; | |
| 853 | const set = ctx.icons; | |
| 854 | // The provenance grammar is the dot: filled means "here", hollow means | |
| 855 | // "somebody else's". A Nerd Font session gets the *noun* instead — a | |
| 856 | // repo, an issue, the file's own language mark — because with a real | |
| 857 | // glyph the kind is the more useful half and the section already says | |
| 858 | // where things came from. | |
| 859 | const mark = (nerd: IconName, plain: string): string => | |
| 860 | set === "nerd" ? icon(nerd, set) : plain; | |
| 861 | ||
| 862 | for (const hit of found.repos) { | |
| 863 | if (hit.source === "local") { | |
| 864 | items.push({ | |
| 865 | id: `repo:${hit.id}`, | |
| 866 | section: "Repos", | |
| 867 | mark: mark("repo", G.dot), | |
| 868 | title: `${hit.owner}/${hit.name}`, | |
| 869 | hint: countsHint(hit.openIssues, hit.openPulls, hit.description), | |
| 870 | run: () => { | |
| 871 | const repo = getRepo(session.db, hit.owner, hit.name); | |
| 872 | if (repo && canRead(session.db, repo, session.user)) | |
| 873 | ctx.push(repoScreen(session, ctx, local(session, repo))); | |
| 874 | }, | |
| 875 | }); | |
| 876 | continue; | |
| 877 | } | |
| 878 | const mirrored = | |
| 879 | hit.mirroredAs === null | |
| 880 | ? "" | |
| 881 | : ` · ${ORIGIN_MARK} mirrored as ${hit.mirroredAs.owner}/${hit.mirroredAs.name}`; | |
| 882 | items.push({ | |
| 883 | id: `origin:${hit.originId}:${hit.fullName}`, | |
| 884 | section: "Repos", | |
| 885 | // A hollow dot: this one is not here. The same grammar the where-strip | |
| 886 | // uses on every repo screen, so the mark means one thing everywhere. | |
| 887 | mark: mark("origin", G.ring), | |
| 888 | title: hit.fullName, | |
| 889 | hint: `${countsHint(hit.openIssues, hit.openPulls, hit.description)}${mirrored}`, | |
| 890 | run: () => { | |
| 891 | const opened = sourceFor(session.app, session.user, { | |
| 892 | originId: hit.originId, | |
| 893 | fullName: hit.fullName, | |
| 894 | }); | |
| 895 | if (!opened.ok) { | |
| 896 | ctx.toast(errorText(opened.error), "danger"); | |
| 897 | return; | |
| 898 | } | |
| 899 | ctx.push(repoScreen(session, ctx, opened.value)); | |
| 900 | }, | |
| 901 | }); | |
| 902 | } | |
| 903 | ||
| 904 | for (const hit of found.issues) { | |
| 905 | const where = | |
| 906 | hit.source === "local" | |
| 907 | ? `${hit.repo.owner}/${hit.repo.name}` | |
| 908 | : hit.fullName; | |
| 909 | items.push({ | |
| 910 | id: `issue:${where}#${hit.number}`, | |
| 911 | section: "Issues & pulls", | |
| 912 | mark: | |
| 913 | hit.kind === "pull" | |
| 914 | ? mark("pull", hit.source === "local" ? G.dot : G.ring) | |
| 915 | : mark("issue", hit.source === "local" ? G.dot : G.ring), | |
| 916 | title: `${where}#${hit.number} ${hit.title}`, | |
| 917 | hint: `${hit.kind} · ${hit.state}`, | |
| 918 | run: () => { | |
| 919 | if (hit.source !== "local") { | |
| 920 | const opened = sourceFor(session.app, session.user, { | |
| 921 | originId: hit.originId, | |
| 922 | fullName: hit.fullName, | |
| 923 | }); | |
| 924 | if (!opened.ok) { | |
| 925 | ctx.toast(errorText(opened.error), "danger"); | |
| 926 | return; | |
| 927 | } | |
| 928 | ctx.push(issuesScreen(session, ctx, opened.value, hit.kind)); | |
| 929 | return; | |
| 930 | } | |
| 931 | const repo = getRepo(session.db, hit.repo.owner, hit.repo.name); | |
| 932 | if (!repo || !canRead(session.db, repo, session.user)) return; | |
| 933 | const src = local(session, repo); | |
| 934 | ctx.push( | |
| 935 | hit.kind === "pull" | |
| 936 | ? pullScreen(session, ctx, src, hit.number) | |
| 937 | : issueScreen(session, ctx, src, hit.number), | |
| 938 | ); | |
| 939 | }, | |
| 940 | }); | |
| 941 | } | |
| 942 | ||
| 943 | // Guides: public, from the index /docs reads; Enter reads the guide. | |
| 944 | for (const hit of found.docs) { | |
| 945 | const entry = anyDocEntry(hit.path.replace(/^\/docs\//, "")); | |
| 946 | if (entry === undefined) continue; | |
| 947 | items.push({ | |
| 948 | id: `doc:${entry.name}`, | |
| 949 | section: "Guides", | |
| 950 | mark: mark("file", G.dot), | |
| 951 | title: hit.title, | |
| 952 | hint: hit.snippet.slice(0, 60), | |
| 953 | run: () => ctx.push(docScreen(ctx, entry, sshOn(session.app.db))), | |
| 954 | }); | |
| 955 | } | |
| 956 | ||
| 957 | for (const hit of found.code) { | |
| 958 | const where = `${hit.repo.owner}/${hit.repo.name}`; | |
| 959 | items.push({ | |
| 960 | id: `code:${where}:${hit.path}:${hit.line}`, | |
| 961 | section: "Code", | |
| 962 | mark: set === "nerd" ? fileIcon(hit.path, set) : G.dot, | |
| 963 | title: `${hit.path}:${hit.line}`, | |
| 964 | hint: `${where} · ${hit.text.trim().slice(0, 60)}`, | |
| 965 | run: () => { | |
| 966 | const repo = getRepo(session.db, hit.repo.owner, hit.repo.name); | |
| 967 | if (!repo || !canRead(session.db, repo, session.user)) return; | |
| 968 | ctx.push( | |
| 969 | blobScreen( | |
| 970 | session, | |
| 971 | ctx, | |
| 972 | local(session, repo), | |
| 973 | repo.defaultBranch, | |
| 974 | hit.path, | |
| 975 | ), | |
| 976 | ); | |
| 977 | }, | |
| 978 | }); | |
| 979 | } | |
| 980 | if (held !== undefined && !held.allowed) | |
| 981 | items.push({ | |
| 982 | id: "code:not-searched", | |
| 983 | section: "Code", | |
| 984 | mark: G.ring, | |
| 985 | title: "Code was not searched", | |
| 986 | hint: `${held.why}; retry in ${held.retryAfter}s`, | |
| 987 | run: () => ctx.toast("Sign in to search code without waiting.", "secondary"), | |
| 988 | }); | |
| 989 | if (found.codeSkipped) | |
| 990 | items.push({ | |
| 991 | id: "code:skipped", | |
| 992 | section: "Code", | |
| 993 | mark: G.ring, | |
| 994 | title: "Some code was not searched", | |
| 995 | hint: "the forge is busy grepping; try again shortly", | |
| 996 | run: () => ctx.toast("Code search is busy; try again shortly.", "secondary"), | |
| 997 | }); | |
| 998 | return items; | |
| 999 | }; | |
| 1000 | } | |
| 1001 | ||
| 1002 | /** `12 issues · 3 pulls · description` — whatever of it there is. */ | |
| 1003 | function countsHint( | |
| 1004 | issues: number, | |
| 1005 | pulls: number, | |
| 1006 | description: string, | |
| 1007 | ): string { | |
| 1008 | return [ | |
| 1009 | issues > 0 ? `${ISSUE_MARK} ${issues}` : "", | |
| 1010 | pulls > 0 ? `${PULL_MARK} ${pulls}` : "", | |
| 1011 | description, | |
| 1012 | ] | |
| 1013 | .filter((p) => p !== "") | |
| 1014 | .join(" "); | |
| 1015 | } | |
| 1016 | ||
| 1017 | /** A prompt with no parent to draw behind it — the palette closed already. */ | |
| 1018 | function askFor( | |
| 1019 | ctx: Ctx, | |
| 1020 | title: string, | |
| 1021 | label: string, | |
| 1022 | onSubmit: (value: string) => string | undefined | Promise<void>, | |
| 1023 | ): Screen { | |
| 1024 | return promptScreen(ctx, blank(title), { title, label, onSubmit }); | |
| 1025 | } | |
| 1026 | ||
| 54 | 1027 | export interface ForgeAppOptions extends SessionOpts { |
| 55 | 1028 | readonly terminal: Terminal; |
| 56 | 1029 | /** How long a toast stays up; a test that reads one after a settle makes it long. */ |
| @@ -76,31 +1049,17 @@ export function createForgeApp( | ||
| 76 | 1049 | return typeof v === "function" ? (v as (...a: unknown[]) => unknown).bind(t) : v; |
| 77 | 1050 | }, |
| 78 | 1051 | }); |
| 79 | // The screens, the palette, the search and the tell key arrive with their module, once per | |
| 80 | // process; until then the palette and the search wait, and the tell key is not offered. | |
| 81 | let loaded: Parts | undefined = partsModule?.forgeParts(session); | |
| 82 | const parts = | |
| 83 | loaded === undefined | |
| 84 | ? import("./forge_parts.ts").then((m) => (loaded = (partsModule = m).forgeParts(session))) | |
| 85 | : undefined; | |
| 86 | const tell: TellHook = { | |
| 87 | keys: (screen) => loaded?.tell.keys(screen) ?? [], | |
| 88 | key: (screen, ctx, e) => loaded?.tell.key(screen, ctx, e) ?? false, | |
| 89 | }; | |
| 90 | 1052 | const app = new App({ |
| 91 | 1053 | ...options, |
| 92 | 1054 | terminal, |
| 93 | 1055 | theme: session.theme(), |
| 94 | 1056 | prefs: session.terminalPrefs(), |
| 95 | root: loaded?.root ?? rootWhenLoaded(parts!), | |
| 96 | commands: (ctx): Command[] | undefined => loaded?.commands(ctx), | |
| 97 | search: (ctx): PaletteSearch | undefined => loaded?.search(ctx), | |
| 1057 | root: forgeRoot(session), | |
| 1058 | commands: forgeCommands(session), | |
| 1059 | search: forgeSearch(session), | |
| 98 | 1060 | onTheme: (name) => session.saveTheme(name), |
| 99 | 1061 | onPrefs: (prefs) => session.savePrefs(prefs), |
| 100 | tell, | |
| 101 | // Keys typed before the parts arrive wait for them: a palette opened at once finds its | |
| 102 | // commands. | |
| 103 | ...(parts === undefined ? {} : { ready: parts }), | |
| 1062 | tell: tellHook(session), | |
| 104 | 1063 | // Its screens read the forge's database: the forge closing stops the loop first (#16446). |
| 105 | 1064 | until: forge.closing.signal, |
| 106 | 1065 | }); |
src/tui/forge_parts.ts deleted −1028
| @@ -1,1028 +0,0 @@ | ||
| 1 | /** | |
| 2 | * The forge's terminal, its parts: the root screen, the command palette, the global search and the | |
| 3 | * tell key. `forge.ts` loads this module when an app starts (so a test or a session that reaches | |
| 4 | * `createForgeApp` does not reach every screen at import), and a test of a command imports it. | |
| 5 | * | |
| 6 | * Everything below this line is a client. It calls the same actions the JSON | |
| 7 | * API calls and the same access helpers the web pages call, so there is no | |
| 8 | * capability here that a token could not exercise, and no way for a session | |
| 9 | * to see something the web would have hidden. | |
| 10 | */ | |
| 11 | ||
| 12 | import { queueTargetsFor } from "../flow/queue_targets.ts"; | |
| 13 | import { queueTargetLines } from "./screens/flow_targets.ts"; | |
| 14 | import { publicOrigin } from "../core/public_origin.ts"; | |
| 15 | import { nearPages } from "../web/near_pages.ts"; | |
| 16 | import { search } from "../actions/search.ts"; | |
| 17 | import { greppable } from "../core/search.ts"; | |
| 18 | import { guestCodeSearch } from "../http/strangers.ts"; | |
| 19 | import { canRead, getRepo, type Repo } from "../core/repos.ts"; | |
| 20 | import { nearRepos } from "../core/near_repos.ts"; | |
| 21 | import { sourceFor } from "../view/source.ts"; | |
| 22 | import { fleetCommand } from "./screens/fleet.ts"; | |
| 23 | import { dataCommand } from "./screens/data.ts"; | |
| 24 | import { packsCommand } from "./screens/packs.ts"; | |
| 25 | import { registryGalleryCommand } from "./screens/registry_gallery.ts"; | |
| 26 | import { placesCommand } from "./screens/places.ts"; | |
| 27 | import { crewNowCommand } from "./screens/crew_now.ts"; | |
| 28 | import { publicFeedCommand } from "./screens/publicfeed.ts"; | |
| 29 | import { statusCommand } from "./screens/status.ts"; | |
| 30 | import { templatesCommand } from "./screens/templates.ts"; | |
| 31 | import { needsCommands } from "./screens/needs.ts"; | |
| 32 | import { asksAdminCommands } from "./screens/asks_admin.ts"; | |
| 33 | import { shareReceiptsCommand, shareTellCommand } from "./screens/share_tell.ts"; | |
| 34 | import { sendChangeCommand } from "./screens/send_change.ts"; | |
| 35 | import { interruptedOutCommand } from "./screens/interrupted_out.ts"; | |
| 36 | import { getForgeCommand } from "./screens/getforge.ts"; | |
| 37 | import { startForgeCommand } from "./screens/startforge.ts"; | |
| 38 | import { pricingCommand } from "./screens/pricing.ts"; | |
| 39 | import { termsCommand } from "./screens/terms.ts"; | |
| 40 | import { forgeNameCommand } from "./screens/forgename.ts"; | |
| 41 | import { workCommand } from "./screens/work.ts"; | |
| 42 | import { shellsScreen } from "./screens/shells.ts"; | |
| 43 | import { forkTreeScreen } from "./screens/fork_tree.ts"; | |
| 44 | import { roadmapScreen } from "./screens/roadmap.ts"; | |
| 45 | import { spaceScreen } from "./screens/space.ts"; | |
| 46 | import type { Ctx, Screen } from "./app/app.ts"; | |
| 47 | import type { Command, PaletteItem, PaletteSearch } from "./app/palette.ts"; | |
| 48 | import { G } from "./term/screen.ts"; | |
| 49 | import { fileIcon, icon, type IconName } from "./ui/icons.ts"; | |
| 50 | import type { Session } from "./session.ts"; | |
| 51 | import { | |
| 52 | ISSUE_MARK, | |
| 53 | ORIGIN_MARK, | |
| 54 | PULL_MARK, | |
| 55 | errorText, | |
| 56 | promptScreen, | |
| 57 | blank, | |
| 58 | openOnWeb, | |
| 59 | runAsync, | |
| 60 | } from "./screens/common.ts"; | |
| 61 | import { chainScreen } from "./screens/chain.ts"; | |
| 62 | import { canSeeMemory } from "../boards/memory.ts"; | |
| 63 | import { cockpitScreen } from "./screens/cockpit.ts"; | |
| 64 | import { notesScreen } from "./screens/thoughtnotes.ts"; | |
| 65 | import { deciderScreen } from "./screens/decider.ts"; | |
| 66 | import { familyScreen, withForkCount } from "./screens/family.ts"; | |
| 67 | import { securityScreen } from "./screens/security_public.ts"; | |
| 68 | import { familyLines, familyView } from "../spawn/family.ts"; | |
| 69 | import { issueScreen } from "./screens/issue.ts"; | |
| 70 | import { pullScreen } from "./screens/pull.ts"; | |
| 71 | import { blobScreen, repoScreen } from "./screens/repo.ts"; | |
| 72 | import { dashboardScreen } from "./screens/dashboard.ts"; | |
| 73 | import { mayManageFlags } from "../core/flags.ts"; | |
| 74 | import { mayEditTrustedHosts } from "../origins/trusted-hosts.ts"; | |
| 75 | import { trustedHostsPrompt } from "./screens/trustedhosts.ts"; | |
| 76 | import { flagsScreen } from "./screens/flags.ts"; | |
| 77 | import { forgeUsageScreen } from "./screens/forge_usage.ts"; | |
| 78 | import { usageScreen } from "./screens/usage.ts"; | |
| 79 | import { canScreen } from "./screens/can.ts"; | |
| 80 | import { forkFlowsScreen } from "./screens/forkflows.ts"; | |
| 81 | import { modelScreen } from "./screens/model.ts"; | |
| 82 | import { notifyScreen } from "./screens/notify.ts"; | |
| 83 | import { talkBuildScreen } from "./screens/talk_build.ts"; | |
| 84 | import { talkChatsScreen } from "./screens/talk_chats.ts"; | |
| 85 | import { sshOn } from "../settings/ssh.ts"; | |
| 86 | import { sshKeysScreen } from "./screens/sshkeys.ts"; | |
| 87 | import { passkeysScreen } from "./screens/passkeys.ts"; | |
| 88 | import { confirmsScreen } from "./screens/confirms.ts"; | |
| 89 | import { receiptsScreen } from "./screens/receipts.ts"; | |
| 90 | import { mayTrust, trustedScreen } from "./screens/trusted.ts"; | |
| 91 | import { mayRunners, runnersScreen } from "./screens/runners.ts"; | |
| 92 | import { proposalTokensPrompt } from "./screens/proposal_tokens.ts"; | |
| 93 | import { signInsScreen } from "./screens/signins.ts"; | |
| 94 | import { oauthGrantsScreen } from "./screens/oauthgrants.ts"; | |
| 95 | import { originAppsScreen } from "./screens/originapps.ts"; | |
| 96 | import { addEntries } from "./screens/entries.ts"; | |
| 97 | import { capacityScreen, mayCapacity } from "./screens/capacity.ts"; | |
| 98 | import { crawlersScreen } from "./screens/crawlers.ts"; | |
| 99 | import { wrap } from "./term/width.ts"; | |
| 100 | import { flowReportFor } from "../flow/report.ts"; | |
| 101 | import { forgeCeiling } from "../flow/ceiling.ts"; | |
| 102 | import { flowLines, flowScreen } from "./screens/flow.ts"; | |
| 103 | import { laneTimeLines } from "./screens/lane_times.ts"; | |
| 104 | import { askUpdate, mayDrift } from "./screens/drift.ts"; | |
| 105 | import { readHandoverLists } from "../flow/handover_read.ts"; | |
| 106 | import { readDrifts } from "../flow/alarm_drift.ts"; | |
| 107 | import { readHeld } from "../flow/held.ts"; | |
| 108 | import { answerKeeper, readKeeper } from "../flow/keeper.ts"; | |
| 109 | import { beatLine, lastBeat } from "../keeper/beat.ts"; | |
| 110 | import { readVerified } from "../flow/verified.ts"; | |
| 111 | import { memoryScreen } from "./screens/system.ts"; | |
| 112 | import { noteRead, telemetryReader } from "../actions/telemetry.ts"; | |
| 113 | import { queuesFor, systemFor } from "../system/telemetry.ts"; | |
| 114 | import { flowGatesFor } from "../actions/runs.ts"; | |
| 115 | import { apiScreen } from "./screens/api.ts"; | |
| 116 | import { changelogScreen } from "./screens/changelog.ts"; | |
| 117 | import { docScreen, docsScreen, markdownScreen } from "./screens/docs.ts"; | |
| 118 | import { fetchPage, pageText } from "../core/web_page.ts"; | |
| 119 | import { anyDocEntry } from "../view/docs.ts"; | |
| 120 | import { keeperScreen } from "./screens/keeper.ts"; | |
| 121 | import { releasesScreen } from "./screens/releases.ts"; | |
| 122 | import { mayRead, mayReadKeeper } from "../release/gate.ts"; | |
| 123 | import { fileHoldsPrompt } from "./screens/fileholds.ts"; | |
| 124 | import { heldScreen } from "./screens/held.ts"; | |
| 125 | import { stalledScreen } from "./screens/stalled.ts"; | |
| 126 | import { issuesScreen, newIssueScreen } from "./screens/issues.ts"; | |
| 127 | import { limbsScreen } from "./screens/limbs.ts"; | |
| 128 | import { nextScreen } from "./screens/next.ts"; | |
| 129 | import { estimatesScreen } from "./screens/estimates.ts"; | |
| 130 | import { findingsScreen } from "./screens/findings.ts"; | |
| 131 | import { flowsScreen } from "./screens/flows.ts"; | |
| 132 | import { weekScreen } from "./screens/week.ts"; | |
| 133 | import { machinesScreen } from "./screens/machines.ts"; | |
| 134 | import { newPullScreen } from "./screens/newpull.ts"; | |
| 135 | import { newForgeScreen } from "./screens/newforge.ts"; | |
| 136 | import { newOrgScreen } from "./screens/neworg.ts"; | |
| 137 | import { migrateScreen } from "./screens/migrate.ts"; | |
| 138 | import { bringScreen } from "./screens/bring.ts"; | |
| 139 | import { bringWorkScreen } from "./screens/bringwork.ts"; | |
| 140 | import { proposeUpstreamScreen } from "./screens/proposeupstream.ts"; | |
| 141 | import { openNewApp, templateAppScreen } from "./screens/newapp.ts"; | |
| 142 | import { newRepoScreen } from "./screens/newrepo.ts"; | |
| 143 | import { signInScreen } from "./screens/signin.ts"; | |
| 144 | import { tellHook } from "./screens/tell_here.ts"; | |
| 145 | import { local } from "./screens/where.ts"; | |
| 146 | ||
| 147 | ||
| 148 | export function forgeRoot(session: Session): (ctx: Ctx) => Screen { | |
| 149 | return (ctx) => dashboardScreen(session, ctx); | |
| 150 | } | |
| 151 | ||
| 152 | /** The repo-scoped palette verbs: a name to ask for, and what to do with it. */ | |
| 153 | const REPO_VERBS: readonly { | |
| 154 | id: string; | |
| 155 | title: string; | |
| 156 | /** The screen to push, or nothing when the verb hands over to the web. */ | |
| 157 | open: (f: Session, ctx: Ctx, repo: Repo) => Screen | undefined; | |
| 158 | }[] = [ | |
| 159 | { | |
| 160 | id: "repo", | |
| 161 | title: "Open a repository", | |
| 162 | open: (f, ctx, repo) => repoScreen(f, ctx, local(f, repo)), | |
| 163 | }, | |
| 164 | { | |
| 165 | id: "issues", | |
| 166 | title: "Issues in a repository", | |
| 167 | open: (f, ctx, repo) => issuesScreen(f, ctx, local(f, repo), "issue"), | |
| 168 | }, | |
| 169 | { | |
| 170 | // What the Later gate holds, as /held shows it: reading is the repository's own. | |
| 171 | id: "held", | |
| 172 | title: "Held by the Later gate", | |
| 173 | open: (f, ctx, repo) => heldScreen(f, ctx, repo), | |
| 174 | }, | |
| 175 | { | |
| 176 | // The ancestors, siblings and descendants of a repository the person may read. | |
| 177 | id: "fork-tree", | |
| 178 | title: "Fork tree of a repository", | |
| 179 | open: (f, ctx, repo) => forkTreeScreen(f, ctx, repo), | |
| 180 | }, | |
| 181 | { | |
| 182 | id: "roadmap", | |
| 183 | title: "Roadmap of a repository", | |
| 184 | open: (f, ctx, repo) => roadmapScreen(f, ctx, repo), | |
| 185 | }, | |
| 186 | { | |
| 187 | id: "space", | |
| 188 | title: "Space of a repository", | |
| 189 | open: (f, ctx, repo) => spaceScreen(f, ctx, repo), | |
| 190 | }, | |
| 191 | { | |
| 192 | id: "pulls", | |
| 193 | title: "Pull requests in a repository", | |
| 194 | open: (f, ctx, repo) => issuesScreen(f, ctx, local(f, repo), "pull"), | |
| 195 | }, | |
| 196 | { | |
| 197 | id: "milestones", | |
| 198 | title: "Milestones in a repository", | |
| 199 | open: (f, ctx, repo) => limbsScreen(f, ctx, repo), | |
| 200 | }, | |
| 201 | { | |
| 202 | // The owner's one ranked list the crew builds from (#8694). | |
| 203 | id: "next-up", | |
| 204 | title: "Next up in a repository", | |
| 205 | open: (f, ctx, repo) => nextScreen(f, ctx, repo), | |
| 206 | }, | |
| 207 | { | |
| 208 | // What is promised for each issue, the base rate to ask, and recording one (#11955). | |
| 209 | id: "estimates", | |
| 210 | title: "Estimates in a repository", | |
| 211 | open: (f, ctx, repo) => estimatesScreen(f, ctx, repo), | |
| 212 | }, | |
| 213 | { | |
| 214 | // The retrospective the forge wrote at the last weekly reset, and its proposals (#8704). | |
| 215 | id: "week", | |
| 216 | title: "The week in a repository", | |
| 217 | open: (f, ctx, repo) => weekScreen(f, ctx, repo), | |
| 218 | }, | |
| 219 | { | |
| 220 | // What flows in and out of a repository, and the radar's key for its admin (#9434). | |
| 221 | id: "flows", | |
| 222 | title: "Flows of a repository", | |
| 223 | open: (f, ctx, repo) => flowsScreen(f, ctx, repo), | |
| 224 | }, | |
| 225 | { | |
| 226 | // What code scanning found, and acceptance with a reason for a writer (#9593). | |
| 227 | id: "findings", | |
| 228 | title: "Findings in a repository", | |
| 229 | open: (f, ctx, repo) => findingsScreen(f, ctx, repo), | |
| 230 | }, | |
| 231 | { | |
| 232 | // Settings → Machines' other door: the machines and last shell sessions, writers only (#9471). | |
| 233 | id: "machines", | |
| 234 | title: "Machines of a repository", | |
| 235 | open: (f, ctx, repo) => machinesScreen(f, ctx, repo), | |
| 236 | }, | |
| 237 | { | |
| 238 | // What the crew's tokens bought on one app, as MCP `returns` with `repo` (#7271). | |
| 239 | id: "repo-usage", | |
| 240 | title: "Usage of a repository", | |
| 241 | open: (f, ctx, repo) => usageScreen(f, ctx, repo), | |
| 242 | }, | |
| 243 | { id: "new-issue", title: "New issue", open: newIssueScreen }, | |
| 244 | { id: "new-pull", title: "New pull request", open: newPullScreen }, | |
| 245 | { | |
| 246 | id: "settings", | |
| 247 | title: "Repository settings", | |
| 248 | // One settings page, the web's (#635): the terminal hands over its address. | |
| 249 | open: (f, ctx, repo) => { | |
| 250 | openOnWeb(f, ctx, `/${repo.ownerName}/${repo.name}/settings`, "Settings"); | |
| 251 | return undefined; | |
| 252 | }, | |
| 253 | }, | |
| 254 | ]; | |
| 255 | ||
| 256 | /** | |
| 257 | * The palette. Repo-scoped verbs ask for `owner/name` in a prompt and resolve | |
| 258 | * it through `getRepo` plus the screen's own access checks — a repo you | |
| 259 | * cannot read is reported as not found, exactly as it is everywhere else. | |
| 260 | */ | |
| 261 | export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | |
| 262 | return (ctx) => { | |
| 263 | const commands: Command[] = [ | |
| 264 | { | |
| 265 | id: "home", | |
| 266 | title: "Home", | |
| 267 | hint: "your repositories", | |
| 268 | run: () => ctx.push(dashboardScreen(session, ctx)), | |
| 269 | }, | |
| 270 | { | |
| 271 | // Browsing other people and forges is the web explorer's (#607): | |
| 272 | // the terminal hands over its address. | |
| 273 | id: "explore", | |
| 274 | title: "Explore", | |
| 275 | hint: "on the web", | |
| 276 | run: () => openOnWeb(session, ctx, "/explore", "The explorer"), | |
| 277 | }, | |
| 278 | { | |
| 279 | // The same list as an Atom feed (#10967): the terminal hands over | |
| 280 | // the feed's address, to copy into a reader. | |
| 281 | id: "explore-feed", | |
| 282 | title: "Explore feed", | |
| 283 | hint: "Atom address", | |
| 284 | run: () => openOnWeb(session, ctx, "/explore.atom", "The explore feed"), | |
| 285 | }, | |
| 286 | ...needsCommands(session, ctx), | |
| 287 | ...asksAdminCommands(session, ctx), | |
| 288 | packsCommand(session, ctx), | |
| 289 | registryGalleryCommand(session, ctx), | |
| 290 | ...(session.user ? [placesCommand(session, ctx)] : []), | |
| 291 | crewNowCommand(session, ctx), | |
| 292 | publicFeedCommand(session, ctx), | |
| 293 | statusCommand(session, ctx), | |
| 294 | templatesCommand(session, ctx), | |
| 295 | shareTellCommand(session, ctx), | |
| 296 | sendChangeCommand(ctx), | |
| 297 | interruptedOutCommand(session, ctx), | |
| 298 | getForgeCommand(session, ctx), | |
| 299 | ...startForgeCommand(session, ctx), | |
| 300 | pricingCommand(session, ctx), | |
| 301 | termsCommand(session, ctx), | |
| 302 | ...forgeNameCommand(session, ctx), | |
| 303 | ...dataCommand(session, ctx), | |
| 304 | fleetCommand(session, ctx), | |
| 305 | { | |
| 306 | // A person's or an org's page is the web's (#636): the terminal | |
| 307 | // hands over its address. | |
| 308 | id: "profile", | |
| 309 | title: "Open a profile", | |
| 310 | hint: "username or org", | |
| 311 | run: () => | |
| 312 | ctx.push( | |
| 313 | askFor(ctx, "Profile", "username", (name) => { | |
| 314 | openOnWeb(session, ctx, `/${encodeURIComponent(name)}`, "That profile"); | |
| 315 | return undefined; | |
| 316 | }), | |
| 317 | ), | |
| 318 | }, | |
| 319 | ]; | |
| 320 | ||
| 321 | for (const verb of REPO_VERBS) | |
| 322 | commands.push({ | |
| 323 | id: verb.id, | |
| 324 | title: verb.title, | |
| 325 | hint: "owner/name", | |
| 326 | run: () => | |
| 327 | ctx.push( | |
| 328 | askFor(ctx, verb.title, "owner/name", (spec) => { | |
| 329 | const [owner, name] = spec.split("/"); | |
| 330 | const repo = | |
| 331 | owner && name ? getRepo(session.db, owner, name) : undefined; | |
| 332 | // The palette is a client like any other: a repo you cannot | |
| 333 | // read is "not found", indistinguishable from a typo. Without | |
| 334 | // this check the palette would be a way around `canRead`. | |
| 335 | if (!repo || !canRead(session.db, repo, session.user)) { | |
| 336 | const near = owner && name ? nearRepos(session.db, session.user, owner, name) : []; | |
| 337 | const pages = nearPages(`/${spec}`, { | |
| 338 | signedIn: session.signedIn, | |
| 339 | admin: session.user?.isAdmin === true, | |
| 340 | }).map((p) => p.href); | |
| 341 | return near.length === 0 | |
| 342 | ? pages.length === 0 | |
| 343 | ? "not found — it does not exist, or is not visible to you" | |
| 344 | : `not found — pages like it, on the web: ${pages.join(", ")}` | |
| 345 | : `not found — did you mean ${near.map((r) => `${r.ownerName}/${r.name}`).join(", ")}?`; | |
| 346 | } | |
| 347 | // After the prompt has popped itself, or the pop takes the | |
| 348 | // screen just pushed instead (`later` in screens/common.ts). | |
| 349 | return Promise.resolve().then(() => { | |
| 350 | const next = verb.open(session, ctx, repo); | |
| 351 | if (next !== undefined) ctx.push(next); | |
| 352 | }); | |
| 353 | }), | |
| 354 | ), | |
| 355 | }); | |
| 356 | ||
| 357 | commands.push( | |
| 358 | session.signedIn | |
| 359 | ? { | |
| 360 | id: "new-repo", | |
| 361 | title: "New repository", | |
| 362 | run: () => ctx.push(newRepoScreen(session, ctx)), | |
| 363 | } | |
| 364 | : { | |
| 365 | id: "signin", | |
| 366 | title: "Sign in", | |
| 367 | run: () => | |
| 368 | ctx.push(signInScreen(session, ctx, () => ctx.invalidate())), | |
| 369 | }, | |
| 370 | ); | |
| 371 | // The owner's read-only mirrors, as the profile's "work (read-only)" draws them. | |
| 372 | if (session.user !== undefined && session.user.kind !== "agent") commands.push(workCommand(session, ctx)); | |
| 373 | // What this person's phone share sheet filed, as each receipt at /tell/share/:id shows it. | |
| 374 | if (session.user !== undefined && session.user.kind !== "agent") commands.push(shareReceiptsCommand(session, ctx)); | |
| 375 | // An app from a sentence, as /apps/new makes it: a person's, never an agent's. | |
| 376 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 377 | commands.push({ | |
| 378 | id: "new-app", | |
| 379 | title: "New app", | |
| 380 | hint: "say what it does in a sentence; the crew starts on it", | |
| 381 | run: () => openNewApp(session, ctx, blank("New app")), | |
| 382 | }); | |
| 383 | // The same from a template repository, as /apps/new?template= does. | |
| 384 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 385 | commands.push({ | |
| 386 | id: "new-app-template", | |
| 387 | title: "New app from a template", | |
| 388 | hint: "copy a repository you can read, as the starting files", | |
| 389 | run: () => ctx.push(templateAppScreen(session, ctx, blank("New app"))), | |
| 390 | }); | |
| 391 | // An app from another forge, as /bring does: a person's, never an agent's. | |
| 392 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 393 | commands.push({ | |
| 394 | id: "bring-app", | |
| 395 | title: "Bring an app", | |
| 396 | hint: "paste a link from another forge; it runs here", | |
| 397 | run: () => ctx.push(bringScreen(session, ctx, blank("Bring an app"))), | |
| 398 | }); | |
| 399 | // A repository kept elsewhere, to work on here, as Talk's `bring` does: a person's. | |
| 400 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 401 | commands.push({ | |
| 402 | id: "bring-work", | |
| 403 | title: "Work on a repository", | |
| 404 | hint: "from GitHub or another forge: your private copy here, the crew on it", | |
| 405 | run: () => ctx.push(bringWorkScreen(session, ctx, blank("Work on a repository"))), | |
| 406 | }); | |
| 407 | // A pull request at the origin from that copy, as Talk's `propose_upstream` does: a person's. | |
| 408 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 409 | commands.push({ | |
| 410 | id: "propose-upstream", | |
| 411 | title: "Propose upstream", | |
| 412 | hint: "your copy's branch as a pull request where the repository is kept", | |
| 413 | run: () => ctx.push(proposeUpstreamScreen(session, ctx, blank("Propose upstream"))), | |
| 414 | }); | |
| 415 | // An organization you own, as /organizations/new and MCP `org_create` make it: a person's, | |
| 416 | // never an agent's (#7260). | |
| 417 | if (session.user !== undefined && session.user.kind !== "agent") | |
| 418 | commands.push({ | |
| 419 | id: "new-org", | |
| 420 | title: "New organization", | |
| 421 | hint: "an organization you own, for a client's apps", | |
| 422 | run: () => ctx.push(newOrgScreen(session, ctx)), | |
| 423 | }); | |
| 424 | if (session.signedIn) | |
| 425 | commands.push({ | |
| 426 | id: "migrate", | |
| 427 | title: "Migrate a repository", | |
| 428 | hint: "bring one in from an origin or a URL, pick its branch, put a crew on it", | |
| 429 | run: () => ctx.push(migrateScreen(session, ctx)), | |
| 430 | }); | |
| 431 | // A client's forge, as /forges/new makes it: any signed-in person's; the door decides the rest. | |
| 432 | if (session.signedIn) | |
| 433 | commands.push({ | |
| 434 | id: "new-forge", | |
| 435 | title: "New forge", | |
| 436 | hint: "spawn a client's forge and get its claim link", | |
| 437 | run: () => ctx.push(newForgeScreen(session, ctx)), | |
| 438 | }); | |
| 439 | // One screen, four keys: what happened, what needs you, the waves (#1152). | |
| 440 | if (session.signedIn) | |
| 441 | commands.push({ | |
| 442 | id: "cockpit", | |
| 443 | title: "Cockpit", | |
| 444 | hint: "what needs you, what happened, the waves under way", | |
| 445 | run: () => ctx.push(cockpitScreen(session, ctx)), | |
| 446 | }); | |
| 447 | // One box to write an idea in, each note with its live state; /notes' own door (#8696). | |
| 448 | if (session.signedIn) | |
| 449 | commands.push({ | |
| 450 | id: "thought-notes", | |
| 451 | title: "Notes", | |
| 452 | hint: "write an idea and watch it become shipped work", | |
| 453 | run: () => ctx.push(notesScreen(session, ctx)), | |
| 454 | }); | |
| 455 | if (session.signedIn) | |
| 456 | commands.push({ | |
| 457 | id: "decider", | |
| 458 | title: "Decider", | |
| 459 | hint: "what it closed, deferred and asked you about today", | |
| 460 | run: () => ctx.push(deciderScreen(session, ctx)), | |
| 461 | }); | |
| 462 | // The machine shells this person holds (#10544); an agent holds none. | |
| 463 | if (session.signedIn && session.user?.kind !== "agent") | |
| 464 | commands.push({ | |
| 465 | id: "shells", | |
| 466 | title: "Your shells", | |
| 467 | hint: "the machine shells you hold, live then ended", | |
| 468 | run: () => ctx.push(shellsScreen(session, ctx)), | |
| 469 | }); | |
| 470 | // Where a decision finds the owner; an agent is never offered it. | |
| 471 | if (session.signedIn && session.user?.kind !== "agent") | |
| 472 | commands.push({ | |
| 473 | id: "notify", | |
| 474 | title: "Phone notifications", | |
| 475 | hint: "where the crew reaches your phone; s sets, x turns off", | |
| 476 | run: () => ctx.push(notifyScreen(session, ctx)), | |
| 477 | }); | |
| 478 | // What the forge's agent asked first, waiting for the person's yes (#7650). | |
| 479 | if (session.signedIn && session.user?.kind !== "agent") | |
| 480 | commands.push({ | |
| 481 | id: "confirms", | |
| 482 | title: "Confirms", | |
| 483 | hint: "what the forge's agent asked to do; y does it once", | |
| 484 | run: () => ctx.push(confirmsScreen(session, ctx)), | |
| 485 | }); | |
| 486 | // What a confirmed action left that can still be undone (#12680): the page's Undo, from the | |
| 487 | // terminal. | |
| 488 | if (session.signedIn && session.user?.kind !== "agent") | |
| 489 | commands.push({ | |
| 490 | id: "receipts", | |
| 491 | title: "Receipts", | |
| 492 | hint: "what you confirmed in /talk; u undoes it once", | |
| 493 | run: () => ctx.push(receiptsScreen(session, ctx)), | |
| 494 | }); | |
| 495 | // Who folds in without a person's review, and the kill switch (#8937): a forge admin's. | |
| 496 | if (session.signedIn && mayTrust(session)) | |
| 497 | commands.push({ | |
| 498 | id: "trusted", | |
| 499 | title: "Trusted sources", | |
| 500 | hint: "who folds in without review; a trusts, x removes, s stops all, v reverts", | |
| 501 | run: () => ctx.push(trustedScreen(session, ctx)), | |
| 502 | }); | |
| 503 | // The machines that take the forge's checks, as Settings → Runners lists them (#15252): an | |
| 504 | // admin's. | |
| 505 | if (session.signedIn && mayRunners(session)) | |
| 506 | commands.push({ | |
| 507 | id: "runners", | |
| 508 | title: "Runners", | |
| 509 | hint: "the machines that take this forge's checks; x removes a hand-made one", | |
| 510 | run: () => ctx.push(runnersScreen(session, ctx)), | |
| 511 | }); | |
| 512 | // The forge's agent keeps many conversations, as /talk lists them (#8814). | |
| 513 | if (session.signedIn && session.user?.kind !== "agent") | |
| 514 | commands.push({ | |
| 515 | id: "conversations", | |
| 516 | title: "Conversations", | |
| 517 | hint: "your talks with the forge's agent; n starts one, r renames, x archives", | |
| 518 | run: () => ctx.push(talkChatsScreen(session, ctx)), | |
| 519 | }); | |
| 520 | // One prompt builds an app; each turn is a version to diff, restore and publish (#11010). | |
| 521 | if (session.signedIn && session.user?.kind !== "agent") | |
| 522 | commands.push({ | |
| 523 | id: "build-app", | |
| 524 | title: "Build an app", | |
| 525 | hint: "say what to build; versions, diff, restore and publish. n starts one", | |
| 526 | run: () => ctx.push(talkBuildScreen(session, ctx)), | |
| 527 | }); | |
| 528 | // A web page as the forge's agent reads it (`fetch_url`): the same Markdown, the same guard. | |
| 529 | if (session.signedIn) | |
| 530 | commands.push({ | |
| 531 | id: "fetch-page", | |
| 532 | title: "Read a web page", | |
| 533 | hint: "paste an https link; the page as Markdown, as Talk's agent reads it", | |
| 534 | run: () => | |
| 535 | ctx.push( | |
| 536 | askFor(ctx, "Read a web page", "An https link", (url) => { | |
| 537 | if (url === "") return "Paste a link."; | |
| 538 | return fetchPage(session.app.db, { url, who: session.user?.id ?? "" }).then((got) => { | |
| 539 | if (!got.ok) ctx.toast(got.error.message, "danger"); | |
| 540 | else ctx.push(markdownScreen(ctx, got.value.title || got.value.finalUrl, pageText(got.value))); | |
| 541 | }); | |
| 542 | }), | |
| 543 | ), | |
| 544 | }); | |
| 545 | // Only while the SSH switch is on (`settings/ssh.ts`); off, the keys are not a thing here. | |
| 546 | if (session.signedIn && sshOn(session.app.db)) | |
| 547 | commands.push({ | |
| 548 | id: "ssh-keys", | |
| 549 | title: "Computer keys", | |
| 550 | hint: "list, add and remove the keys that sign in as you", | |
| 551 | run: () => ctx.push(sshKeysScreen(session, ctx)), | |
| 552 | }); | |
| 553 | // /forks/flows, GET /api/v1/forks/flows and MCP `fork_flows`: one function, `forkFlows` | |
| 554 | // (#17056). | |
| 555 | if (session.signedIn) | |
| 556 | commands.push({ | |
| 557 | id: "fork-flows", | |
| 558 | title: "Fork flows", | |
| 559 | hint: "what I follow, what I offered, what my forks offered me", | |
| 560 | run: () => ctx.push(forkFlowsScreen(session, ctx)), | |
| 561 | }); | |
| 562 | // Settings › Passkeys and MCP `whoami_can kind: passkeys`, read only (#8044). | |
| 563 | if (session.signedIn && session.user?.kind !== "agent") | |
| 564 | commands.push({ | |
| 565 | id: "passkeys", | |
| 566 | title: "Passkeys", | |
| 567 | hint: "the passkeys that sign in as you", | |
| 568 | run: () => ctx.push(passkeysScreen(session, ctx)), | |
| 569 | }); | |
| 570 | if (session.signedIn) | |
| 571 | commands.push( | |
| 572 | { | |
| 573 | id: "account", | |
| 574 | title: "Account settings", | |
| 575 | run: () => openOnWeb(session, ctx, "/settings", "Account settings"), | |
| 576 | }, | |
| 577 | // Settings → Sessions and MCP `sessions`, in the terminal (#7237). | |
| 578 | { | |
| 579 | id: "signins", | |
| 580 | title: "Signed in", | |
| 581 | hint: "your browsers and tokens; d signs a browser out", | |
| 582 | run: () => ctx.push(signInsScreen(session, ctx)), | |
| 583 | }, | |
| 584 | // Settings › Connected agents: the OAuth grants you gave (#13308). | |
| 585 | { | |
| 586 | id: "oauth-grants", | |
| 587 | title: "Connected agents", | |
| 588 | hint: "the agents you let in through OAuth; x revokes one", | |
| 589 | run: () => ctx.push(oauthGrantsScreen(session, ctx)), | |
| 590 | }, | |
| 591 | // Settings → Connected accounts' OAuth apps and MCP `origin_apps` (#7291). | |
| 592 | { | |
| 593 | id: "origin-apps", | |
| 594 | title: "Connection apps", | |
| 595 | hint: "your OAuth apps for connecting accounts; a adds, d removes", | |
| 596 | run: () => ctx.push(originAppsScreen(session, ctx)), | |
| 597 | }, | |
| 598 | ); | |
| 599 | // The forge's RSS beside its JS heap, as /system gates it (#2151). | |
| 600 | if (canSeeMemory(session.user)) | |
| 601 | commands.push({ | |
| 602 | id: "system-memory", | |
| 603 | title: "System memory", | |
| 604 | hint: "RSS beside the JS heap, hourly for 24 h", | |
| 605 | run: () => ctx.push(memoryScreen(session, ctx)), | |
| 606 | }); | |
| 607 | // The pipeline's bottleneck and throughput, as /flow says them: a site admin's (#1554, #1786). | |
| 608 | const flowReader = telemetryReader(session.app, session.user); | |
| 609 | if (flowReader) | |
| 610 | commands.push({ | |
| 611 | id: "flow", | |
| 612 | title: "Flow", | |
| 613 | hint: "the pipeline's bottleneck and throughput", | |
| 614 | run: () => { | |
| 615 | if (session.user) noteRead(session.app, session.user, flowReader, "flow"); | |
| 616 | const keeper = readKeeper(session.db, flowReader.kind === "owner"); | |
| 617 | const user = session.user; | |
| 618 | const reportLines = ["", "Flow report:", ...flowReportFor(session.db, flowReader).lines.flatMap((l) => wrap(l, 58))]; | |
| 619 | ctx.push(flowScreen(ctx, flowLines( | |
| 620 | session.db, | |
| 621 | new Date(), | |
| 622 | systemFor(session.app, flowReader).duplicates, | |
| 623 | flowReader.kind === "agent" | |
| 624 | ? { | |
| 625 | queues: queuesFor(session.app, flowReader, new Date(), { batches: true }), | |
| 626 | gates: flowGatesFor(session.app, user), | |
| 627 | } | |
| 628 | : undefined, | |
| 629 | readHeld(session.app, flowReader.kind === "owner"), | |
| 630 | forgeCeiling(session.app.config), | |
| 631 | readVerified(session.app, flowReader.kind === "owner"), | |
| 632 | keeper, | |
| 633 | session.app.config.dataDir, | |
| 634 | flowReader.kind === "owner" ? beatLine(lastBeat(session.db), new Date()) : undefined, | |
| 635 | publicOrigin(session.app.config.url, `http://${session.app.config.host ?? "localhost"}:${session.app.config.port ?? 3000}`), | |
| 636 | ).concat(laneTimeLines(session.db, user), flowReader.kind === "owner" ? ["", ...queueTargetLines(queueTargetsFor(session.app)).flatMap((l) => wrap(l, 58))] : [], reportLines), keeper.ask && user ? { ask: keeper.ask, answer: () => answerKeeper(session.app, keeper.ask!.id, user.id) } : undefined, | |
| 637 | mayDrift(session) | |
| 638 | ? { read: async () => readHandoverLists(session.db, await readDrifts(session.app), Date.now()), update: (n) => askUpdate(session, n) } | |
| 639 | : undefined)); | |
| 640 | }, | |
| 641 | }); | |
| 642 | // The forge's capacity and guards, as MCP `capacity` gates them: a forge admin who is a person. | |
| 643 | if (mayCapacity(session)) | |
| 644 | commands.push({ | |
| 645 | id: "capacity", | |
| 646 | title: "Capacity", | |
| 647 | hint: "concurrency and guards, live; e changes a settable one", | |
| 648 | run: () => ctx.push(capacityScreen(session, ctx)), | |
| 649 | }); | |
| 650 | // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's | |
| 651 | // readers. | |
| 652 | if (mayCapacity(session)) | |
| 653 | commands.push({ | |
| 654 | id: "crawlers", | |
| 655 | title: "Crawlers", | |
| 656 | hint: "their share of answering time, and who was refused", | |
| 657 | run: () => ctx.push(crawlersScreen(session, ctx)), | |
| 658 | }); | |
| 659 | // The forge's API operations, as /api lists them; Enter runs a GET: for anyone. | |
| 660 | commands.push({ | |
| 661 | id: "api", | |
| 662 | title: "API", | |
| 663 | hint: "the forge's endpoints; run a GET", | |
| 664 | run: () => ctx.push(apiScreen(session, ctx)), | |
| 665 | }); | |
| 666 | // The forge's documentation, as /docs lists it: for anyone. | |
| 667 | commands.push({ | |
| 668 | id: "docs", | |
| 669 | title: "Docs", | |
| 670 | hint: "the forge's documentation; Enter reads one", | |
| 671 | run: () => ctx.push(docsScreen(ctx, sshOn(session.app.db))), | |
| 672 | }); | |
| 673 | // The last releases with their pulls, as /changelog shows them: for anyone. | |
| 674 | commands.push({ | |
| 675 | id: "changelog", | |
| 676 | title: "Changelog", | |
| 677 | hint: "the last 30 releases and their pulls", | |
| 678 | run: () => ctx.push(changelogScreen(session, ctx)), | |
| 679 | }); | |
| 680 | // The live release and the kept ones, as /releases gates them: a site admin or a reader of | |
| 681 | // FORGE_REPO. | |
| 682 | if (mayRead(session.app, session.user)) | |
| 683 | commands.push({ | |
| 684 | id: "releases", | |
| 685 | title: "Releases", | |
| 686 | hint: "the live release and the kept ones", | |
| 687 | run: () => ctx.push(releasesScreen(session, ctx)), | |
| 688 | }); | |
| 689 | // The release keeper's card (#7557), read by whoever reads GET /api/v1/keeper (#15515). | |
| 690 | if (mayReadKeeper(session.app, session.user)) | |
| 691 | commands.push({ | |
| 692 | id: "keeper", | |
| 693 | title: "Release keeper", | |
| 694 | hint: "what holds the next cut, and each release it cut with its probes", | |
| 695 | run: () => ctx.push(keeperScreen(session, ctx)), | |
| 696 | }); | |
| 697 | // Stalled flow steps the viewer can unblock, as the home's cards show them (#1807). | |
| 698 | if (session.signedIn) | |
| 699 | commands.push({ | |
| 700 | id: "stalled", | |
| 701 | title: "Stalled steps", | |
| 702 | hint: "pulls whose check is red or was never asked for; enter re-runs", | |
| 703 | run: () => ctx.push(stalledScreen(session, ctx)), | |
| 704 | }); | |
| 705 | // Hold new work on a file: the settings card's twin, admin-checked by the action itself. | |
| 706 | if (session.signedIn) | |
| 707 | commands.push({ | |
| 708 | id: "file-holds", | |
| 709 | title: "Held files", | |
| 710 | hint: "hold new work on a file, release it, or list the holds", | |
| 711 | run: () => ctx.push(fileHoldsPrompt(session, ctx, blank("Held files"))), | |
| 712 | }); | |
| 713 | // Settings → Flags, as the page has it: an admin who is not an agent (#1970). | |
| 714 | if (mayManageFlags(session.user)) | |
| 715 | commands.push({ | |
| 716 | id: "flags", | |
| 717 | title: "Flags", | |
| 718 | hint: "declared flags and their live values", | |
| 719 | run: () => ctx.push(flagsScreen(session, ctx)), | |
| 720 | }); | |
| 721 | // Settings → Connected accounts' trusted internal hosts: the same admin gate as the page. | |
| 722 | if (mayEditTrustedHosts(session.user)) | |
| 723 | commands.push({ | |
| 724 | id: "trusted-hosts", | |
| 725 | title: "Trusted hosts", | |
| 726 | hint: "internal hosts an origin may reach", | |
| 727 | run: () => ctx.push(trustedHostsPrompt(session, ctx, blank("Trusted hosts"))), | |
| 728 | }); | |
| 729 | // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's | |
| 730 | // gate, the same as Flags (#1565). | |
| 731 | if (session.user !== undefined) | |
| 732 | commands.push({ | |
| 733 | id: "usage", | |
| 734 | title: "Usage", | |
| 735 | hint: "the forge's spend and headroom; an admin also sees every route", | |
| 736 | run: () => ctx.push(usageScreen(session, ctx)), | |
| 737 | }); | |
| 738 | // What the forge spent across the apps you write, as GET /api/v1/usage and MCP `usage` answer. | |
| 739 | if (session.user !== undefined) | |
| 740 | commands.push({ | |
| 741 | id: "forge-spend", | |
| 742 | title: "Forge spend", | |
| 743 | hint: "today and the last 24 hours, headroom per subscription", | |
| 744 | run: () => ctx.push(forgeUsageScreen(session, ctx)), | |
| 745 | }); | |
| 746 | // Proposal tokens for a repository you write, as the API and MCP have them (#2148). | |
| 747 | if (session.user !== undefined) | |
| 748 | commands.push({ | |
| 749 | id: "proposal-tokens", | |
| 750 | title: "Proposal tokens", | |
| 751 | hint: "mint, list and revoke what a child proposes with", | |
| 752 | run: () => ctx.push(proposalTokensPrompt(session, ctx, blank("Proposal tokens"))), | |
| 753 | }); | |
| 754 | // Settings → Model: a person's own budget and subscription, as the page has them (#1145). | |
| 755 | if (session.user?.kind === "user") | |
| 756 | commands.push({ | |
| 757 | id: "model", | |
| 758 | title: "Model budget", | |
| 759 | hint: "what your crew may spend, and add your own subscription", | |
| 760 | run: () => ctx.push(modelScreen(session, ctx)), | |
| 761 | }); | |
| 762 | // The caller's own role and row of the roles table, as /settings and `whoami_can` have it | |
| 763 | // (#2304). | |
| 764 | if (session.user !== undefined) | |
| 765 | commands.push({ | |
| 766 | id: "can", | |
| 767 | title: "What I can do", | |
| 768 | hint: "your role and what it allows here", | |
| 769 | run: () => ctx.push(canScreen(session, ctx)), | |
| 770 | }); | |
| 771 | // Entries that live beside their screen, each at the place it names. | |
| 772 | addEntries(commands, session, ctx); | |
| 773 | // What /security says, for anyone (#13208). | |
| 774 | commands.push({ | |
| 775 | id: "security", | |
| 776 | title: "Security", | |
| 777 | hint: "what the forge enforces for everyone, and how to report a problem", | |
| 778 | run: () => ctx.push(securityScreen(ctx)), | |
| 779 | }); | |
| 780 | commands.push({ | |
| 781 | id: "family", | |
| 782 | title: "Family", | |
| 783 | hint: "the forge that sent this one, and the forges it sent", | |
| 784 | run: () => | |
| 785 | runAsync(ctx, async () => { | |
| 786 | const view = await familyView(session.app, session.user?.isAdmin === true); | |
| 787 | ctx.push(familyScreen(ctx, withForkCount(familyLines(view), view.children.length))); | |
| 788 | }), | |
| 789 | }); | |
| 790 | commands.push({ | |
| 791 | id: "chain", | |
| 792 | title: "Chain", | |
| 793 | hint: "the forges this forge's code descends from, root first", | |
| 794 | run: () => | |
| 795 | runAsync(ctx, async () => { | |
| 796 | ctx.push(await chainScreen(session.app, session.user, ctx)); | |
| 797 | }), | |
| 798 | }); | |
| 799 | commands.push({ | |
| 800 | id: "quit", | |
| 801 | title: "Quit", | |
| 802 | hint: "disconnect", | |
| 803 | run: () => ctx.quit(), | |
| 804 | }); | |
| 805 | return commands; | |
| 806 | }; | |
| 807 | } | |
| 808 | ||
| 809 | /** | |
| 810 | * The palette's search half: one `search()` call, three sections. | |
| 811 | * | |
| 812 | * Everything the session can reach is in scope — the repos here, the repos | |
| 813 | * cached from every origin they have connected, conversations on both sides, | |
| 814 | * and the code itself through `git grep`. The action decides visibility once, | |
| 815 | * exactly as the web search page and the API do; nothing is filtered here, | |
| 816 | * because a row that reached this function was already allowed to. | |
| 817 | * | |
| 818 | * Enter on an origin repo opens the **live browse**, not a mirror: browse | |
| 819 | * first, mirror if you mean it (`view/source.ts`). A repo somebody else's | |
| 820 | * origin holds is `not_found` for you, and `sourceFor` is what says so. | |
| 821 | */ | |
| 822 | export function forgeSearch(session: Session): (ctx: Ctx) => PaletteSearch { | |
| 823 | return (ctx) => async (query, live, signal) => { | |
| 824 | // A guest is a stranger with a key: its search greps code under the same | |
| 825 | // limits as the page's and the API's (`http/strangers.ts`), counted | |
| 826 | // under its peer address. Refused, everything but the code is searched. | |
| 827 | // A one-letter query greps nothing (#11120), so it takes no slot either. | |
| 828 | const greps = session.user === undefined && greppable(query); | |
| 829 | const held = greps | |
| 830 | ? guestCodeSearch(session.app, session.identity.remoteAddress) | |
| 831 | : undefined; | |
| 832 | // `pulls: retry` narrows to pull requests, as `kind=pulls` does on the page. | |
| 833 | const pullsOnly = /^pulls:\s*/i.test(query); | |
| 834 | const q = pullsOnly ? query.replace(/^pulls:\s*/i, "") : query; | |
| 835 | let found; | |
| 836 | try { | |
| 837 | found = await search(session.app, session.user, { | |
| 838 | q, | |
| 839 | ...(pullsOnly ? { kind: "pulls" as const } : {}), | |
| 840 | limit: 8, | |
| 841 | live, | |
| 842 | withCode: held === undefined || held.allowed, | |
| 843 | }); | |
| 844 | } finally { | |
| 845 | if (held?.allowed) held.release(); | |
| 846 | } | |
| 847 | if (signal.aborted) return []; | |
| 848 | const items: PaletteItem[] = []; | |
| 849 | const set = ctx.icons; | |
| 850 | // The provenance grammar is the dot: filled means "here", hollow means | |
| 851 | // "somebody else's". A Nerd Font session gets the *noun* instead — a | |
| 852 | // repo, an issue, the file's own language mark — because with a real | |
| 853 | // glyph the kind is the more useful half and the section already says | |
| 854 | // where things came from. | |
| 855 | const mark = (nerd: IconName, plain: string): string => | |
| 856 | set === "nerd" ? icon(nerd, set) : plain; | |
| 857 | ||
| 858 | for (const hit of found.repos) { | |
| 859 | if (hit.source === "local") { | |
| 860 | items.push({ | |
| 861 | id: `repo:${hit.id}`, | |
| 862 | section: "Repos", | |
| 863 | mark: mark("repo", G.dot), | |
| 864 | title: `${hit.owner}/${hit.name}`, | |
| 865 | hint: countsHint(hit.openIssues, hit.openPulls, hit.description), | |
| 866 | run: () => { | |
| 867 | const repo = getRepo(session.db, hit.owner, hit.name); | |
| 868 | if (repo && canRead(session.db, repo, session.user)) | |
| 869 | ctx.push(repoScreen(session, ctx, local(session, repo))); | |
| 870 | }, | |
| 871 | }); | |
| 872 | continue; | |
| 873 | } | |
| 874 | const mirrored = | |
| 875 | hit.mirroredAs === null | |
| 876 | ? "" | |
| 877 | : ` · ${ORIGIN_MARK} mirrored as ${hit.mirroredAs.owner}/${hit.mirroredAs.name}`; | |
| 878 | items.push({ | |
| 879 | id: `origin:${hit.originId}:${hit.fullName}`, | |
| 880 | section: "Repos", | |
| 881 | // A hollow dot: this one is not here. The same grammar the where-strip | |
| 882 | // uses on every repo screen, so the mark means one thing everywhere. | |
| 883 | mark: mark("origin", G.ring), | |
| 884 | title: hit.fullName, | |
| 885 | hint: `${countsHint(hit.openIssues, hit.openPulls, hit.description)}${mirrored}`, | |
| 886 | run: () => { | |
| 887 | const opened = sourceFor(session.app, session.user, { | |
| 888 | originId: hit.originId, | |
| 889 | fullName: hit.fullName, | |
| 890 | }); | |
| 891 | if (!opened.ok) { | |
| 892 | ctx.toast(errorText(opened.error), "danger"); | |
| 893 | return; | |
| 894 | } | |
| 895 | ctx.push(repoScreen(session, ctx, opened.value)); | |
| 896 | }, | |
| 897 | }); | |
| 898 | } | |
| 899 | ||
| 900 | for (const hit of found.issues) { | |
| 901 | const where = | |
| 902 | hit.source === "local" | |
| 903 | ? `${hit.repo.owner}/${hit.repo.name}` | |
| 904 | : hit.fullName; | |
| 905 | items.push({ | |
| 906 | id: `issue:${where}#${hit.number}`, | |
| 907 | section: "Issues & pulls", | |
| 908 | mark: | |
| 909 | hit.kind === "pull" | |
| 910 | ? mark("pull", hit.source === "local" ? G.dot : G.ring) | |
| 911 | : mark("issue", hit.source === "local" ? G.dot : G.ring), | |
| 912 | title: `${where}#${hit.number} ${hit.title}`, | |
| 913 | hint: `${hit.kind} · ${hit.state}`, | |
| 914 | run: () => { | |
| 915 | if (hit.source !== "local") { | |
| 916 | const opened = sourceFor(session.app, session.user, { | |
| 917 | originId: hit.originId, | |
| 918 | fullName: hit.fullName, | |
| 919 | }); | |
| 920 | if (!opened.ok) { | |
| 921 | ctx.toast(errorText(opened.error), "danger"); | |
| 922 | return; | |
| 923 | } | |
| 924 | ctx.push(issuesScreen(session, ctx, opened.value, hit.kind)); | |
| 925 | return; | |
| 926 | } | |
| 927 | const repo = getRepo(session.db, hit.repo.owner, hit.repo.name); | |
| 928 | if (!repo || !canRead(session.db, repo, session.user)) return; | |
| 929 | const src = local(session, repo); | |
| 930 | ctx.push( | |
| 931 | hit.kind === "pull" | |
| 932 | ? pullScreen(session, ctx, src, hit.number) | |
| 933 | : issueScreen(session, ctx, src, hit.number), | |
| 934 | ); | |
| 935 | }, | |
| 936 | }); | |
| 937 | } | |
| 938 | ||
| 939 | // Guides: public, from the index /docs reads; Enter reads the guide. | |
| 940 | for (const hit of found.docs) { | |
| 941 | const entry = anyDocEntry(hit.path.replace(/^\/docs\//, "")); | |
| 942 | if (entry === undefined) continue; | |
| 943 | items.push({ | |
| 944 | id: `doc:${entry.name}`, | |
| 945 | section: "Guides", | |
| 946 | mark: mark("file", G.dot), | |
| 947 | title: hit.title, | |
| 948 | hint: hit.snippet.slice(0, 60), | |
| 949 | run: () => ctx.push(docScreen(ctx, entry, sshOn(session.app.db))), | |
| 950 | }); | |
| 951 | } | |
| 952 | ||
| 953 | for (const hit of found.code) { | |
| 954 | const where = `${hit.repo.owner}/${hit.repo.name}`; | |
| 955 | items.push({ | |
| 956 | id: `code:${where}:${hit.path}:${hit.line}`, | |
| 957 | section: "Code", | |
| 958 | mark: set === "nerd" ? fileIcon(hit.path, set) : G.dot, | |
| 959 | title: `${hit.path}:${hit.line}`, | |
| 960 | hint: `${where} · ${hit.text.trim().slice(0, 60)}`, | |
| 961 | run: () => { | |
| 962 | const repo = getRepo(session.db, hit.repo.owner, hit.repo.name); | |
| 963 | if (!repo || !canRead(session.db, repo, session.user)) return; | |
| 964 | ctx.push( | |
| 965 | blobScreen( | |
| 966 | session, | |
| 967 | ctx, | |
| 968 | local(session, repo), | |
| 969 | repo.defaultBranch, | |
| 970 | hit.path, | |
| 971 | ), | |
| 972 | ); | |
| 973 | }, | |
| 974 | }); | |
| 975 | } | |
| 976 | if (held !== undefined && !held.allowed) | |
| 977 | items.push({ | |
| 978 | id: "code:not-searched", | |
| 979 | section: "Code", | |
| 980 | mark: G.ring, | |
| 981 | title: "Code was not searched", | |
| 982 | hint: `${held.why}; retry in ${held.retryAfter}s`, | |
| 983 | run: () => ctx.toast("Sign in to search code without waiting.", "secondary"), | |
| 984 | }); | |
| 985 | if (found.codeSkipped) | |
| 986 | items.push({ | |
| 987 | id: "code:skipped", | |
| 988 | section: "Code", | |
| 989 | mark: G.ring, | |
| 990 | title: "Some code was not searched", | |
| 991 | hint: "the forge is busy grepping; try again shortly", | |
| 992 | run: () => ctx.toast("Code search is busy; try again shortly.", "secondary"), | |
| 993 | }); | |
| 994 | return items; | |
| 995 | }; | |
| 996 | } | |
| 997 | ||
| 998 | /** `12 issues · 3 pulls · description` — whatever of it there is. */ | |
| 999 | function countsHint( | |
| 1000 | issues: number, | |
| 1001 | pulls: number, | |
| 1002 | description: string, | |
| 1003 | ): string { | |
| 1004 | return [ | |
| 1005 | issues > 0 ? `${ISSUE_MARK} ${issues}` : "", | |
| 1006 | pulls > 0 ? `${PULL_MARK} ${pulls}` : "", | |
| 1007 | description, | |
| 1008 | ] | |
| 1009 | .filter((p) => p !== "") | |
| 1010 | .join(" "); | |
| 1011 | } | |
| 1012 | ||
| 1013 | /** A prompt with no parent to draw behind it — the palette closed already. */ | |
| 1014 | function askFor( | |
| 1015 | ctx: Ctx, | |
| 1016 | title: string, | |
| 1017 | label: string, | |
| 1018 | onSubmit: (value: string) => string | undefined | Promise<void>, | |
| 1019 | ): Screen { | |
| 1020 | return promptScreen(ctx, blank(title), { title, label, onSubmit }); | |
| 1021 | } | |
| 1022 | ||
| 1023 | /** | |
| 1024 | * What `createForgeApp` loads: the root, the palette, the search and the tell key, for one session. | |
| 1025 | */ | |
| 1026 | export function forgeParts(session: Session) { | |
| 1027 | return { root: forgeRoot(session), commands: forgeCommands(session), search: forgeSearch(session), tell: tellHook(session) }; | |
| 1028 | } |
test/apps-template-doors.test.ts +1 −2
| @@ -16,8 +16,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 16 | 16 | import { getRepo } from "../src/core/repos.ts"; |
| 17 | 17 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; |
| 18 | 18 | import { serve, type Servers } from "../src/http/server.ts"; |
| 19 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 20 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 19 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 21 | 20 | import { blank } from "../src/tui/screens/common.ts"; |
| 22 | 21 | import { templateAppScreen } from "../src/tui/screens/newapp.ts"; |
| 23 | 22 | import { deriveAppName } from "../src/web/pages/apps-name.ts"; |
test/bottleneck.test.ts +1 −2
| @@ -7,8 +7,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 7 | 7 | import { createToken } from "../src/core/tokens.ts"; |
| 8 | 8 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 9 | 9 | import { serve, type Servers } from "../src/http/server.ts"; |
| 10 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 11 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 10 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 12 | 11 | import { bottleneckLines } from "../src/tui/screens/bottleneck.ts"; |
| 13 | 12 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 14 | 13 | import type { User } from "../src/core/users.ts"; |
test/deepsec-rate.test.ts +1 −2
| @@ -19,8 +19,7 @@ import { deepsecRateSection } from "../src/web/pages/system.ts"; | ||
| 19 | 19 | import { deepsecRateLines, entry as systemEntry } from "../src/tui/screens/system.ts"; |
| 20 | 20 | import { createToken } from "../src/core/tokens.ts"; |
| 21 | 21 | import { serve } from "../src/http/server.ts"; |
| 22 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 23 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 22 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 24 | 23 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 25 | 24 | import { settleApp } from "./helpers/tui.ts"; |
| 26 | 25 |
test/design-theme.test.ts +1 −2
| @@ -23,8 +23,7 @@ import { | ||
| 23 | 23 | validateTokens, |
| 24 | 24 | } from "../src/web/studio/design.ts"; |
| 25 | 25 | import { serve, type Servers } from "../src/http/server.ts"; |
| 26 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 27 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 26 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 28 | 27 | import { designLines, designScreen, FIELDS, withField } from "../src/tui/screens/design.ts"; |
| 29 | 28 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 30 | 29 | import { adminCookie } from "./helpers/admin.ts"; |
test/disk-intake.test.ts +1 −2
| @@ -8,8 +8,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 8 | 8 | import { createToken } from "../src/core/tokens.ts"; |
| 9 | 9 | import { createUser, type User } from "../src/core/users.ts"; |
| 10 | 10 | import { serve, type Servers } from "../src/http/server.ts"; |
| 11 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 12 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 11 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 13 | 12 | import { diskLines } from "../src/tui/screens/disks.ts"; |
| 14 | 13 | import { diskSummary } from "../src/machines/disk_readings.ts"; |
| 15 | 14 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
test/fetch-url.test.ts +1 −2
| @@ -36,8 +36,7 @@ import { | ||
| 36 | 36 | import type { OutboundOptions } from "../src/kernel/outbound.ts"; |
| 37 | 37 | import { forgetOwnHost, localFor, setOwnHost } from "../src/kernel/own_host.ts"; |
| 38 | 38 | import { serve, type Servers } from "../src/http/server.ts"; |
| 39 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 40 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 39 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 41 | 40 | import { docScreen } from "../src/tui/screens/docs.ts"; |
| 42 | 41 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 43 | 42 | import { docEntry } from "../src/view/docs.ts"; |
test/flow-pipeline.test.ts +1 −2
| @@ -26,8 +26,7 @@ import { bottleneck, readPipeline, span, verdict } from "../src/flow/pipeline.ts | ||
| 26 | 26 | import { shellJs } from "../src/web/client.ts"; |
| 27 | 27 | import { serve, type Servers } from "../src/http/server.ts"; |
| 28 | 28 | import type { Ctx, Screen } from "../src/tui/app/app.ts"; |
| 29 | import { Session } from "../src/tui/forge.ts"; | |
| 30 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 29 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 31 | 30 | import { flowLines } from "../src/tui/screens/flow.ts"; |
| 32 | 31 | |
| 33 | 32 | const HOUR = 3_600_000; |
test/flow-report-doors.test.ts +1 −2
| @@ -12,8 +12,7 @@ import { setTelemetryGrant } from "../src/actions/telemetry.ts"; | ||
| 12 | 12 | import { createToken } from "../src/core/tokens.ts"; |
| 13 | 13 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; |
| 14 | 14 | import { serve, type Servers } from "../src/http/server.ts"; |
| 15 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 16 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 17 | 16 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 18 | 17 | import { flowReportFor } from "../src/flow/report.ts"; |
| 19 | 18 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
test/flow-throughput.test.ts +1 −2
| @@ -23,8 +23,7 @@ import { createToken } from "../src/core/tokens.ts"; | ||
| 23 | 23 | import { median, readThroughput, stageOf, throughputSays } from "../src/flow/throughput.ts"; |
| 24 | 24 | import { serve, type Servers } from "../src/http/server.ts"; |
| 25 | 25 | import type { Ctx, Screen } from "../src/tui/app/app.ts"; |
| 26 | import { Session } from "../src/tui/forge.ts"; | |
| 27 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 26 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 28 | 27 | import { flowLines } from "../src/tui/screens/flow.ts"; |
| 29 | 28 | |
| 30 | 29 | const HOUR = 3_600_000; |
test/flows-all.test.ts +1 −1
| @@ -136,7 +136,7 @@ test("the terminal gives an admin person every line and nobody else anything", a | ||
| 136 | 136 | expect(flowLines(new Session(app, identity(await get("bob"))), undefined, false, NOW)).toEqual([]); |
| 137 | 137 | expect(flowLines(new Session(app, identity(undefined)), undefined, false, NOW)).toEqual([]); |
| 138 | 138 | const { app: tui, session } = createForgeApp(app, identity(await get("alice")), { terminal: headlessTerminal(80, 24), exitHooks: false }); |
| 139 | const { forgeCommands } = await import("../src/tui/forge_parts.ts"); | |
| 139 | const { forgeCommands } = await import("../src/tui/forge.ts"); | |
| 140 | 140 | expect(forgeCommands(session)(tui.ctx).map((c) => c.id)).toContain("flows-all"); |
| 141 | 141 | tui.stop?.(); |
| 142 | 142 | }); |
test/footing.test.ts +1 −2
| @@ -28,8 +28,7 @@ import { | ||
| 28 | 28 | } from "../src/system/footing.ts"; |
| 29 | 29 | import { footingSection } from "../src/web/pages/system.ts"; |
| 30 | 30 | import { getUserByName, type User } from "../src/core/users.ts"; |
| 31 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 32 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 31 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 33 | 32 | import { footingLines, footingScreen } from "../src/tui/screens/footing.ts"; |
| 34 | 33 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 35 | 34 | import { settleApp } from "./helpers/tui.ts"; |
test/keeper-writer-reads.test.ts +1 −2
| @@ -17,8 +17,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 17 | 17 | import { serve, type Servers } from "../src/http/server.ts"; |
| 18 | 18 | import { recordBeat } from "../src/keeper/beat.ts"; |
| 19 | 19 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 20 | import { Session } from "../src/tui/forge.ts"; | |
| 21 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 20 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 22 | 21 | import { readKeeper } from "../src/tui/screens/keeper.ts"; |
| 23 | 22 | import { promote } from "./helpers/members.ts"; |
| 24 | 23 |
test/loop-stall-by-route.test.ts +1 −2
| @@ -17,8 +17,7 @@ import { createLoopWatch, HOUR_MS, NO_REQUEST } from "../src/perf/loop.ts"; | ||
| 17 | 17 | import { createAgent } from "../src/actions/crew.ts"; |
| 18 | 18 | import type { User } from "../src/core/users.ts"; |
| 19 | 19 | import { stallSection } from "../src/web/pages/system.ts"; |
| 20 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 21 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 20 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 22 | 21 | import { lagLines, stallLines, stallsScreen } from "../src/tui/screens/loopstalls.ts"; |
| 23 | 22 | import { settleApp } from "./helpers/tui.ts"; |
| 24 | 23 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
test/packs-catalog.test.ts +1 −2
| @@ -16,8 +16,7 @@ import { tool } from "../src/http/mcp/tools/repo_settings.ts"; | ||
| 16 | 16 | import { catalog, refreshCatalog, refreshCatalogQuietly } from "../src/packs/catalog.ts"; |
| 17 | 17 | import { markedRepos, saveMarkedRepos } from "../src/packs/marked.ts"; |
| 18 | 18 | import { setPackRepos } from "../src/packs/set.ts"; |
| 19 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 20 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 19 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 21 | 20 | import { packReposScreen } from "../src/tui/screens/packrepos.ts"; |
| 22 | 21 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 23 | 22 | import { fetchPack } from "../scripts/pack.ts"; |
test/packs-hands.test.ts +1 −2
| @@ -16,8 +16,7 @@ import { parsePack } from "../src/packs/pack.ts"; | ||
| 16 | 16 | import { packNamed } from "../src/packs/catalog.ts"; |
| 17 | 17 | import { fixturePacks, seedPacks } from "./helpers/packs.ts"; |
| 18 | 18 | import { deployCommands } from "../src/packs/words.ts"; |
| 19 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 20 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 19 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 21 | 20 | import { packLines, packsScreen } from "../src/tui/screens/packs.ts"; |
| 22 | 21 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 23 | 22 | import { cloneEnv, cloneUrl, deployOrg, pushEnv, realHands } from "../scripts/pack.ts"; |
test/packs-mirror.test.ts +1 −2
| @@ -19,8 +19,7 @@ import { repoDir } from "../src/git/repos.ts"; | ||
| 19 | 19 | import { serve, type Servers } from "../src/http/server.ts"; |
| 20 | 20 | import type { SshSession } from "../src/ssh/channels.ts"; |
| 21 | 21 | import { serveGitCommand } from "../src/tui/ssh.ts"; |
| 22 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 23 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 22 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 24 | 23 | import { mirrorPacksScreen } from "../src/tui/screens/mirrorpacks.ts"; |
| 25 | 24 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 26 | 25 | import { seedPacks } from "./helpers/packs.ts"; |
test/palette-roster.test.ts +1 −2
| @@ -5,8 +5,7 @@ import { join } from "node:path"; | ||
| 5 | 5 | import { createApp, type App } from "../src/app.ts"; |
| 6 | 6 | import { setSsh } from "../src/settings/ssh.ts"; |
| 7 | 7 | import { createUser, type User } from "../src/core/users.ts"; |
| 8 | import { Session } from "../src/tui/forge.ts"; | |
| 9 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 8 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 10 | 9 | import { quietLogs } from "./helpers/globals.ts"; |
| 11 | 10 | |
| 12 | 11 | quietLogs(); |
test/plans-row.test.ts +1 −2
| @@ -19,8 +19,7 @@ import { sizeWords } from "../src/settings/billing.ts"; | ||
| 19 | 19 | import { SIGNUP_DEFAULT } from "../src/settings/signup.ts"; |
| 20 | 20 | import { plansRow } from "../src/web/plans_row.ts"; |
| 21 | 21 | import { getForgeLines } from "../src/tui/screens/getforge.ts"; |
| 22 | import { Session } from "../src/tui/forge.ts"; | |
| 23 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 22 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 24 | 23 | |
| 25 | 24 | const FREE = DEFAULT_PLANS.find((p) => p.priceUsd === 0)!; |
| 26 | 25 | const SMALL = DEFAULT_PLANS.find((p) => p.key === "small")!; |
test/release-keeper-guest.test.ts +1 −2
| @@ -7,8 +7,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 7 | 7 | import { serve } from "../src/http/server.ts"; |
| 8 | 8 | import { tick } from "../src/keeper/keeper.ts"; |
| 9 | 9 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 10 | import { Session } from "../src/tui/forge.ts"; | |
| 11 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 10 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 12 | 11 | import { readKeeper } from "../src/tui/screens/keeper.ts"; |
| 13 | 12 | import { quietLogs } from "./helpers/globals.ts"; |
| 14 | 13 | import { keeperForge } from "./helpers/keeper.ts"; |
test/resilience.test.ts +1 −2
| @@ -12,8 +12,7 @@ import { fileResults, keepForgeGate, keepGate, readGate } from "../src/checks/ga | ||
| 12 | 12 | import { parseThreats, readThreats, standing } from "../src/core/threats.ts"; |
| 13 | 13 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 14 | 14 | import type { Ctx, Screen } from "../src/tui/app/app.ts"; |
| 15 | import { Session } from "../src/tui/forge.ts"; | |
| 16 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 17 | 16 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 18 | 17 | import { dirStore, type Store } from "../src/blob/store.ts"; |
| 19 | 18 | import { createForgeApp } from "../src/tui/forge.ts"; |
test/search-docs.test.ts +1 −1
| @@ -10,7 +10,7 @@ import { search } from "../src/actions/search.ts"; | ||
| 10 | 10 | import { guideTitleMatches } from "../src/web/pages/search.ts"; |
| 11 | 11 | import { serve, type Servers } from "../src/http/server.ts"; |
| 12 | 12 | import { searchDocs } from "../src/view/docs.ts"; |
| 13 | import { forgeSearch } from "../src/tui/forge_parts.ts"; | |
| 13 | import { forgeSearch } from "../src/tui/forge.ts"; | |
| 14 | 14 | import { Session } from "../src/tui/session.ts"; |
| 15 | 15 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 16 | 16 |
test/spawn-self-use.test.ts +1 −2
| @@ -28,8 +28,7 @@ import { childLines, selfLines } from "../src/tui/screens/system.ts"; | ||
| 28 | 28 | import { childrenSection, selfHelp, selfSection } from "../src/web/pages/system.ts"; |
| 29 | 29 | import { quietLogs } from "./helpers/globals.ts"; |
| 30 | 30 | import { settleApp } from "./helpers/tui.ts"; |
| 31 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 32 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 31 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 33 | 32 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 34 | 33 | import { getUserByName } from "../src/core/users.ts"; |
| 35 | 34 |
test/status-page.test.ts +1 −2
| @@ -8,8 +8,7 @@ import { ownProbeHeaders } from "../src/kernel/probe.ts"; | ||
| 8 | 8 | import { asOfWords, rowWords, statusJson, statusOf, statusReuse, statusWords, type StatusInput } from "../src/core/status_words.ts"; |
| 9 | 9 | import { MIRROR_STALE_MS, mirrorNeed } from "../src/snapshot/mirror.ts"; |
| 10 | 10 | import { statusBuilds } from "../src/web/pages/status.ts"; |
| 11 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 12 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 11 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 13 | 12 | import { statusLines } from "../src/tui/screens/status.ts"; |
| 14 | 13 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 15 | 14 | import { recordBoot } from "../src/kernel/boots.ts"; |
test/strangers.test.ts +1 −1
| @@ -29,7 +29,7 @@ import { | ||
| 29 | 29 | } from "../src/http/strangers.ts"; |
| 30 | 30 | import { Fresh } from "../src/kernel/fresh.ts"; |
| 31 | 31 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 32 | import { forgeSearch } from "../src/tui/forge_parts.ts"; | |
| 32 | import { forgeSearch } from "../src/tui/forge.ts"; | |
| 33 | 33 | import { Session } from "../src/tui/session.ts"; |
| 34 | 34 | import { seedAdmin } from "./helpers/admin.ts"; |
| 35 | 35 | import { gitClientEnv } from "./helpers/git-client.ts"; |
test/system-telemetry.test.ts +1 −2
| @@ -22,8 +22,7 @@ import { serve, type Servers } from "../src/http/server.ts"; | ||
| 22 | 22 | import { parseCores, parseNet, testFiles } from "../src/system/proc.ts"; |
| 23 | 23 | import { createLive, live, useLive } from "../src/system/live.ts"; |
| 24 | 24 | import type { Ctx, Screen } from "../src/tui/app/app.ts"; |
| 25 | import { Session } from "../src/tui/forge.ts"; | |
| 26 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 25 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 27 | 26 | import { systemLines } from "../src/tui/screens/system.ts"; |
| 28 | 27 | import { flowLines } from "../src/tui/screens/flow.ts"; |
| 29 | 28 | import { hasGrant, logRead } from "../src/core/telemetry.ts"; |
test/talk-bring.test.ts +1 −2
| @@ -35,8 +35,7 @@ import type { Ctx } from "../src/http/context.ts"; | ||
| 35 | 35 | import { serve, type Servers } from "../src/http/server.ts"; |
| 36 | 36 | import { settled } from "../src/origins/jobs.ts"; |
| 37 | 37 | import { syncsSettled } from "../src/origins/sync.ts"; |
| 38 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 39 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 38 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 40 | 39 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 41 | 40 | import { promote } from "./helpers/members.ts"; |
| 42 | 41 | import { settleApp } from "./helpers/tui.ts"; |
test/tui-app-templates.test.ts +1 −2
| @@ -16,8 +16,7 @@ import { offeredNotes } from "../src/core/forge_templates.ts"; | ||
| 16 | 16 | import { offeredTemplates } from "../src/core/app_templates.ts"; |
| 17 | 17 | import { getRepo, listReposOwnedBy } from "../src/core/repos.ts"; |
| 18 | 18 | import { createUser, type User } from "../src/core/users.ts"; |
| 19 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 20 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 19 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 21 | 20 | import { blank } from "../src/tui/screens/common.ts"; |
| 22 | 21 | import { appTemplatesScreen } from "../src/tui/screens/app_templates.ts"; |
| 23 | 22 | import { newAppScreen } from "../src/tui/screens/newapp.ts"; |
test/tui-apps.test.ts +1 −2
| @@ -42,8 +42,7 @@ import { serve, type Servers } from "../src/http/server.ts"; | ||
| 42 | 42 | import { quietLogs } from "./helpers/globals.ts"; |
| 43 | 43 | import { appendRunLog } from "../src/runs/log.ts"; |
| 44 | 44 | import type { App, Screen } from "../src/tui/app/app.ts"; |
| 45 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 46 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 45 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 47 | 46 | import { issueScreen } from "../src/tui/screens/issue.ts"; |
| 48 | 47 | import { pullScreen } from "../src/tui/screens/pull.ts"; |
| 49 | 48 | import { local } from "../src/tui/screens/where.ts"; |
test/tui-ask-data.test.ts +1 −2
| @@ -5,8 +5,7 @@ import { tmpdir } from "node:os"; | ||
| 5 | 5 | import { join } from "node:path"; |
| 6 | 6 | import { createApp, type App } from "../src/app.ts"; |
| 7 | 7 | import { createUser, type User } from "../src/core/users.ts"; |
| 8 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 9 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 8 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 10 | 9 | import { exploreRows, resultLines } from "../src/tui/screens/ask_data.ts"; |
| 11 | 10 | import { entry } from "../src/tui/screens/ask_data.ts"; |
| 12 | 11 | import { readParams } from "../src/boards/params.ts"; |
test/tui-audit.test.ts +1 −2
| @@ -13,8 +13,7 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | ||
| 13 | 13 | import { createApp, type App } from "../src/app.ts"; |
| 14 | 14 | import { createUser, type User } from "../src/core/users.ts"; |
| 15 | 15 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 16 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 17 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 16 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 18 | 17 | import { auditedFor, auditRows, doorLines } from "../src/tui/screens/audit.ts"; |
| 19 | 18 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 20 | 19 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-boards.test.ts +1 −2
| @@ -12,8 +12,7 @@ import { deleteBoard, listAllBoards, writeBoard } from "../src/actions/boards.ts | ||
| 12 | 12 | import { createAgent } from "../src/actions/crew.ts"; |
| 13 | 13 | import { createApp, type App } from "../src/app.ts"; |
| 14 | 14 | import { createUser, type User } from "../src/core/users.ts"; |
| 15 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 16 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 17 | 16 | import { dashboardScreen } from "../src/tui/screens/dashboard.ts"; |
| 18 | 17 | import { boardRows, boardsScreen, dataLine, refusal, stepWords } from "../src/tui/screens/boards.ts"; |
| 19 | 18 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
test/tui-bring.test.ts +1 −2
| @@ -5,8 +5,7 @@ import { tmpdir } from "node:os"; | ||
| 5 | 5 | import { join } from "node:path"; |
| 6 | 6 | import { createApp, type App } from "../src/app.ts"; |
| 7 | 7 | import { createUser, type User } from "../src/core/users.ts"; |
| 8 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 9 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 8 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 10 | 9 | import { bringWords } from "../src/actions/bring.ts"; |
| 11 | 10 | import { bringScreen } from "../src/tui/screens/bring.ts"; |
| 12 | 11 | import { bringWorkScreen } from "../src/tui/screens/bringwork.ts"; |
test/tui-capacity.test.ts +1 −2
| @@ -13,8 +13,7 @@ import { listEvents } from "../src/core/events.ts"; | ||
| 13 | 13 | import { changeCapacity } from "../src/actions/capacity.ts"; |
| 14 | 14 | import { CAPACITY_KEYS, capacityChanges, capacityDefault, capacityValue } from "../src/core/capacity.ts"; |
| 15 | 15 | import { createUser, type User } from "../src/core/users.ts"; |
| 16 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 17 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 16 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 18 | 17 | import { capacityScreen } from "../src/tui/screens/capacity.ts"; |
| 19 | 18 | import { EGRESS_REPORTED } from "../src/system/egress_line.ts"; |
| 20 | 19 | import { handover } from "../src/release/swap.ts"; |
test/tui-changelog.test.ts +1 −2
| @@ -10,8 +10,7 @@ import { openPull } from "../src/actions/pulls.ts"; | ||
| 10 | 10 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 11 | 11 | import { createApp, type App } from "../src/app.ts"; |
| 12 | 12 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 13 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 14 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 13 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 15 | 14 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 16 | 15 | import { groupByChapter } from "../src/release/chapter_groups.ts"; |
| 17 | 16 | import { chapterLines, changelogLines, changelogRows, changelogScreen, creditWords, pullLines } from "../src/tui/screens/changelog.ts"; |
test/tui-crawlers.test.ts +1 −2
| @@ -7,8 +7,7 @@ import { join } from "node:path"; | ||
| 7 | 7 | import { createApp, type App } from "../src/app.ts"; |
| 8 | 8 | import { createUser, type User } from "../src/core/users.ts"; |
| 9 | 9 | import { pinCrawlLag, setCrawlClock, takeCrawl } from "../src/http/crawl.ts"; |
| 10 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 11 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 10 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 12 | 11 | import { crawlersScreen } from "../src/tui/screens/crawlers.ts"; |
| 13 | 12 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 14 | 13 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-data.test.ts +1 −1
| @@ -12,7 +12,7 @@ import { rememberSpec } from "../src/apps/api_spec.ts"; | ||
| 12 | 12 | import { createApp as createAppRecord } from "../src/core/apps.ts"; |
| 13 | 13 | import { createRepo } from "../src/core/repos.ts"; |
| 14 | 14 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 15 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { forgeCommands } from "../src/tui/forge.ts"; | |
| 16 | 16 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 17 | 17 | import { dataScreen, FILTER_MAX, SQL_MAX, typing } from "../src/tui/screens/data.ts"; |
| 18 | 18 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
test/tui-devices.test.ts +1 −2
| @@ -10,8 +10,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 10 | 10 | import { declareDevice, listDevices } from "../src/core/devices.ts"; |
| 11 | 11 | import { grantedSlugs } from "../src/core/device_grants.ts"; |
| 12 | 12 | import { createUser, type User } from "../src/core/users.ts"; |
| 13 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 14 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 13 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 15 | 14 | import { devicesScreen } from "../src/tui/screens/devices.ts"; |
| 16 | 15 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 17 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-forge-lazy.test.ts deleted −116
| @@ -1,116 +0,0 @@ | ||
| 1 | /** | |
| 2 | * The terminal's screens load when an app starts, not when `createForgeApp` is imported | |
| 3 | * (src/tui/forge.ts): its static import closure reaches the loop and the session, never a screen | |
| 4 | * or `forge_parts.ts`. A test of one screen that builds an app then pays for the screens it opens, | |
| 5 | * not for all of them. Until the parts arrive the app holds keys (`AppOpts.ready`); once a process | |
| 6 | * has them, every later app is built at once. | |
| 7 | */ | |
| 8 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 9 | import { existsSync, readFileSync, statSync } from "node:fs"; | |
| 10 | import { dirname, join, relative } from "node:path"; | |
| 11 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 12 | import { tmpdir } from "node:os"; | |
| 13 | import { createApp, type App as Forge } from "../src/app.ts"; | |
| 14 | import { actingVia, personActing } from "../src/core/acting_via.ts"; | |
| 15 | import { createUser, type User } from "../src/core/users.ts"; | |
| 16 | import { App } from "../src/tui/app/app.ts"; | |
| 17 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 18 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; | |
| 19 | import { quietLogs } from "./helpers/globals.ts"; | |
| 20 | import { settleApp } from "./helpers/tui.ts"; | |
| 21 | ||
| 22 | quietLogs(); | |
| 23 | const ROOT = join(import.meta.dir, ".."); | |
| 24 | /** | |
| 25 | * The screens' shared parts (lists, prompts, words), which the loop itself draws with: not a | |
| 26 | * screen. | |
| 27 | */ | |
| 28 | const SHARED = "src/tui/screens/common.ts"; | |
| 29 | ||
| 30 | /** Every file a module reaches by a value import (not `import type`, not a dynamic `import()`). */ | |
| 31 | function closure(file: string): Set<string> { | |
| 32 | const seen = new Set<string>([file]); | |
| 33 | const todo = [file]; | |
| 34 | const re = /^\s*(?:import|export)\s+(?!type\b)(?:[^"';]*?\sfrom\s+)?["'](\.[^"']+)["']/gm; | |
| 35 | while (todo.length > 0) { | |
| 36 | const at = todo.pop()!; | |
| 37 | for (const m of readFileSync(at, "utf8").matchAll(re)) { | |
| 38 | if (/^\s*import\s*\{\s*(?:type\s+\w+\s*,?\s*)+\}\s*from/.test(m[0])) continue; | |
| 39 | const p = join(dirname(at), m[1]!); | |
| 40 | if (!existsSync(p) || !statSync(p).isFile() || seen.has(p)) continue; | |
| 41 | seen.add(p); | |
| 42 | todo.push(p); | |
| 43 | } | |
| 44 | } | |
| 45 | return seen; | |
| 46 | } | |
| 47 | ||
| 48 | let dir: string; | |
| 49 | let forge: Forge; | |
| 50 | let alice: User; | |
| 51 | ||
| 52 | beforeAll(async () => { | |
| 53 | dir = await mkdtemp(join(tmpdir(), "forge-tui-lazy-")); | |
| 54 | forge = createApp({ dataDir: dir, port: 0 }); | |
| 55 | const made = await createUser(forge.db, { | |
| 56 | origin: "seed", | |
| 57 | trusted: true, | |
| 58 | username: "alice", | |
| 59 | email: "[email protected]", | |
| 60 | password: "a-good-passphrase", | |
| 61 | adminIfFirst: true, | |
| 62 | }); | |
| 63 | if (!made.ok) throw new Error(made.error); | |
| 64 | alice = made.value; | |
| 65 | }); | |
| 66 | ||
| 67 | afterAll(async () => { | |
| 68 | forge.close(); | |
| 69 | await rm(dir, { recursive: true, force: true }); | |
| 70 | }); | |
| 71 | ||
| 72 | function boot() { | |
| 73 | const terminal = headlessTerminal(120, 30); | |
| 74 | const { app } = createForgeApp(forge, { sshUsername: "alice", remoteAddress: "127.0.0.1", user: alice }, { terminal, exitHooks: false }); | |
| 75 | app.start(); | |
| 76 | return { app, terminal }; | |
| 77 | } | |
| 78 | ||
| 79 | test("forge.ts reaches no screen and not the parts module by a static import", () => { | |
| 80 | const reached = [...closure(join(ROOT, "src/tui/forge.ts"))].map((p) => relative(ROOT, p)); | |
| 81 | expect( | |
| 82 | reached.filter( | |
| 83 | (p) => (p.startsWith("src/tui/screens/") && p !== SHARED) || p.startsWith("src/tui/local/") || p === "src/tui/forge_parts.ts", | |
| 84 | ), | |
| 85 | ).toEqual([]); | |
| 86 | }); | |
| 87 | ||
| 88 | test("a key typed before the app is ready waits for it, then runs in order and as its person", async () => { | |
| 89 | let ready!: () => void; | |
| 90 | const terminal = headlessTerminal(80, 24); | |
| 91 | const seen: [string, boolean][] = []; | |
| 92 | const app = new App({ | |
| 93 | terminal, | |
| 94 | theme: "dark", | |
| 95 | ready: new Promise<void>((resolve) => (ready = resolve)), | |
| 96 | root: () => ({ title: "root", keys: [], render() {}, key: (e) => (seen.push([e.key, personActing(alice)]), true) }), | |
| 97 | }); | |
| 98 | app.start(); | |
| 99 | actingVia({ userId: alice.id, door: "ssh" }, () => terminal.feed("ab")); | |
| 100 | expect(seen).toEqual([]); | |
| 101 | ready(); | |
| 102 | await settleApp(app); | |
| 103 | expect(seen).toEqual([["a", true], ["b", true]]); | |
| 104 | expect(personActing(alice)).toBe(false); | |
| 105 | app.stop(); | |
| 106 | }); | |
| 107 | ||
| 108 | test("once the parts are in, an app draws its root at once, with the palette and the tell key there", async () => { | |
| 109 | await settleApp(boot().app); | |
| 110 | const { app } = boot(); | |
| 111 | expect(app.screen.toText()).toContain("alice"); | |
| 112 | expect(app.commands.map((c) => c.id)).toEqual(expect.arrayContaining(["home", "explore", "conversations"])); | |
| 113 | await settleApp(app); | |
| 114 | expect(app.screen.toText()).toContain("alice"); | |
| 115 | app.stop(); | |
| 116 | }); |
test/tui-home-pins.test.ts +1 −2
| @@ -16,8 +16,7 @@ import { listPins } from "../src/boards/pins.ts"; | ||
| 16 | 16 | import { eventAudience } from "../src/core/event_audience.ts"; |
| 17 | 17 | import type { ForgeEvent } from "../src/core/events.ts"; |
| 18 | 18 | import { createUser, type User } from "../src/core/users.ts"; |
| 19 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 20 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 19 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 21 | 20 | import { homePinsScreen } from "../src/tui/screens/home_pins.ts"; |
| 22 | 21 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 23 | 22 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-migrate.test.ts +1 −2
| @@ -20,8 +20,7 @@ import { repoDir } from "../src/git/repos.ts"; | ||
| 20 | 20 | import { runGitCapture } from "../src/git/env.ts"; |
| 21 | 21 | import { serve, type Servers } from "../src/http/server.ts"; |
| 22 | 22 | import { forgetProviders } from "../src/origins/providers/index.ts"; |
| 23 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 24 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 23 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 25 | 24 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 26 | 25 | import { newFakeState, serveFakeForge, type FakeForge } from "./fake-origin.ts"; |
| 27 | 26 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-newapp.test.ts +1 −2
| @@ -12,8 +12,7 @@ import { createOrg } from "../src/actions/orgs.ts"; | ||
| 12 | 12 | import { getOrg } from "../src/core/orgs.ts"; |
| 13 | 13 | import { getRepo, listReposOwnedBy } from "../src/core/repos.ts"; |
| 14 | 14 | import { createUser, type User } from "../src/core/users.ts"; |
| 15 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 16 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 17 | 16 | import { blank } from "../src/tui/screens/common.ts"; |
| 18 | 17 | import { newAppScreen } from "../src/tui/screens/newapp.ts"; |
| 19 | 18 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
test/tui-newforge.test.ts +1 −2
| @@ -13,8 +13,7 @@ import { getRepo } from "../src/core/repos.ts"; | ||
| 13 | 13 | import { createUser, type User } from "../src/core/users.ts"; |
| 14 | 14 | import { usePlacement, useProbe } from "../src/spawn/door.ts"; |
| 15 | 15 | import { hostedPlacement } from "../src/spawn/placement.ts"; |
| 16 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 17 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 16 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 18 | 17 | import { newForgeScreen } from "../src/tui/screens/newforge.ts"; |
| 19 | 18 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 20 | 19 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-neworg.test.ts +1 −2
| @@ -12,8 +12,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 12 | 12 | import { getOrg } from "../src/core/orgs.ts"; |
| 13 | 13 | import { createUser, type User } from "../src/core/users.ts"; |
| 14 | 14 | import { tool as orgCreate } from "../src/http/mcp/tools/org_create.ts"; |
| 15 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 16 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 17 | 16 | import { newOrgScreen } from "../src/tui/screens/neworg.ts"; |
| 18 | 17 | import { newOrgSubmit } from "../src/web/pages/org.ts"; |
| 19 | 18 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
test/tui-passkeys.test.ts +1 −2
| @@ -11,8 +11,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 11 | 11 | import type { Credential } from "../src/auth/webauthn.ts"; |
| 12 | 12 | import { addPasskey, notePasskeyUsed } from "../src/core/passkeys.ts"; |
| 13 | 13 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; |
| 14 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 15 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 14 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 16 | 15 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 17 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| 18 | 17 | import { settleApp } from "./helpers/tui.ts"; |
test/tui-pricing.test.ts +1 −2
| @@ -19,8 +19,7 @@ import { setStrangerLimits, strangerLimits } from "../src/http/strangers.ts"; | ||
| 19 | 19 | import { err, ok } from "../src/kernel/result.ts"; |
| 20 | 20 | import { FREE, getPlans, setPlans } from "../src/settings/plans.ts"; |
| 21 | 21 | import { usePlacement, useProbe } from "../src/spawn/door.ts"; |
| 22 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 23 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 22 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 24 | 23 | import { pricingScreen } from "../src/tui/screens/pricing.ts"; |
| 25 | 24 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 26 | 25 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-release-keeper.test.ts +1 −2
| @@ -6,8 +6,7 @@ | ||
| 6 | 6 | import { describe, expect, test } from "bun:test"; |
| 7 | 7 | import { tick } from "../src/keeper/keeper.ts"; |
| 8 | 8 | import type { User } from "../src/core/users.ts"; |
| 9 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 10 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 9 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 11 | 10 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 12 | 11 | import { noteKeeperAtBoot } from "../src/keeper/at_boot.ts"; |
| 13 | 12 | import { holdLine, keeperScreen, readKeeper } from "../src/tui/screens/keeper.ts"; |
test/tui-releases.test.ts +1 −2
| @@ -16,8 +16,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 16 | 16 | import { releaseDir } from "../src/release/checkout.ts"; |
| 17 | 17 | import { mayRead, mayRollBack } from "../src/release/gate.ts"; |
| 18 | 18 | import { recordRelease } from "../src/release/record.ts"; |
| 19 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 20 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 19 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 21 | 20 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 22 | 21 | import { journeyText, readReleases, releasesScreen } from "../src/tui/screens/releases.ts"; |
| 23 | 22 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
test/tui-runners.test.ts −2
| @@ -37,8 +37,6 @@ async function drive(user: User, keys: readonly string[] = []) { | ||
| 37 | 37 | const terminal = headlessTerminal(120, 30); |
| 38 | 38 | const { app: tui, session } = createForgeApp(app, identity(user), { terminal, exitHooks: false }); |
| 39 | 39 | tui.start(); |
| 40 | // The palette arrives with the screens' module (forge.ts): settle first. | |
| 41 | await settleApp(tui); | |
| 42 | 40 | const offered = tui.commands.some((c) => c.id === "runners"); |
| 43 | 41 | tui.ctx.push(runnersScreen(session, tui.ctx)); |
| 44 | 42 | await settleApp(tui); |
test/tui-sentinel.test.ts +1 −2
| @@ -12,8 +12,7 @@ import { createRepo } from "../src/actions/repos.ts"; | ||
| 12 | 12 | import { createUser, type User } from "../src/core/users.ts"; |
| 13 | 13 | import { clearErrors, createLog } from "../src/kernel/log.ts"; |
| 14 | 14 | import { hunt } from "../src/crew/sentinel.ts"; |
| 15 | import { Session } from "../src/tui/forge.ts"; | |
| 16 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 17 | 16 | import type { Ctx } from "../src/tui/app/app.ts"; |
| 18 | 17 | |
| 19 | 18 | let dataDir: string; |
test/tui-startforge.test.ts +1 −2
| @@ -11,8 +11,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 11 | 11 | import { createUser, type User } from "../src/core/users.ts"; |
| 12 | 12 | import { usePlacement, useProbe } from "../src/spawn/door.ts"; |
| 13 | 13 | import { hostedPlacement } from "../src/spawn/placement.ts"; |
| 14 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 15 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 14 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 16 | 15 | import { startForgeScreen } from "../src/tui/screens/startforge.ts"; |
| 17 | 16 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 18 | 17 | import { START_REFUSALS } from "../src/web/start_refusal.ts"; |
test/tui-system.test.ts +1 −2
| @@ -12,8 +12,7 @@ import { readHealth } from "../src/actions/health.ts"; | ||
| 12 | 12 | import { createApp, type App } from "../src/app.ts"; |
| 13 | 13 | import { recordMemory } from "../src/boards/memory.ts"; |
| 14 | 14 | import { createUser, type User } from "../src/core/users.ts"; |
| 15 | import { createForgeApp, Session } from "../src/tui/forge.ts"; | |
| 16 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 15 | import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts"; | |
| 17 | 16 | import { setTelemetryGrant } from "../src/actions/telemetry.ts"; |
| 18 | 17 | import { hasGrant } from "../src/core/telemetry.ts"; |
| 19 | 18 | import { countRead, resetTelemetryReads } from "../src/system/telemetry_reads.ts"; |
test/tui-terms.test.ts +1 −2
| @@ -5,8 +5,7 @@ import { tmpdir } from "node:os"; | ||
| 5 | 5 | import { join } from "node:path"; |
| 6 | 6 | import { createApp } from "../src/app.ts"; |
| 7 | 7 | import { termRows } from "../src/billing/terms_words.ts"; |
| 8 | import { createForgeApp, type TuiIdentity } from "../src/tui/forge.ts"; | |
| 9 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 8 | import { createForgeApp, forgeCommands, type TuiIdentity } from "../src/tui/forge.ts"; | |
| 10 | 9 | import { termsScreen } from "../src/tui/screens/terms.ts"; |
| 11 | 10 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 12 | 11 | import { quietLogs } from "./helpers/globals.ts"; |
test/tui-trusted.test.ts −2
| @@ -38,8 +38,6 @@ async function drive(user: User, keys: readonly string[] = []) { | ||
| 38 | 38 | const terminal = headlessTerminal(120, 30); |
| 39 | 39 | const { app: tui, session } = createForgeApp(app, identity(user), { terminal, exitHooks: false }); |
| 40 | 40 | tui.start(); |
| 41 | // The palette arrives with the screens' module (forge.ts): settle first. | |
| 42 | await settleApp(tui); | |
| 43 | 41 | const offered = tui.commands.some((c) => c.id === "trusted"); |
| 44 | 42 | tui.ctx.push(trustedScreen(session, tui.ctx)); |
| 45 | 43 | await settleApp(tui); |
test/tui-valves.test.ts +1 −2
| @@ -10,8 +10,7 @@ import { audienceFilter } from "../src/core/event_audience.ts"; | ||
| 10 | 10 | import { listEvents } from "../src/core/events.ts"; |
| 11 | 11 | import { createUser, type User } from "../src/core/users.ts"; |
| 12 | 12 | import { readLevels } from "../src/flow/valve_store.ts"; |
| 13 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 14 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 13 | import { createForgeApp, forgeCommands } from "../src/tui/forge.ts"; | |
| 15 | 14 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 16 | 15 | import { quietLogs } from "./helpers/globals.ts"; |
| 17 | 16 | import { settleApp, settleUntil } from "./helpers/tui.ts"; |
new above
offline