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

Delete the dead exports scripts/unused-exports.ts finds, area by area #16800

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/16269-delete-the-dead-exports-scripts-unused-e → main 0 commits fork 1 thread · 1 unresolved

  • Merged. mason/16269-delete-the-dead-exports-scripts-unused-e was merged into main as 7f8d28a.

Review

Sign in to review this change.
36 files changed +2 −384
scripts/unused-exports-allow.json −53
@@ -6,20 +6,14 @@
66 "src/looks/archive.ts useLookStore",
77 "src/apps/contain.ts useTreeReader",
88 "src/apps/contain.ts watchTick",
9 "src/apps/dns_provider.ts EDITABLE_TYPES",
109 "src/apps/egress.ts resetEgressTotals",
1110 "src/apps/egress_refused.ts flushRefused",
12 "src/apps/manifest.ts declaresApp",
1311 "src/apps/migration_mode.ts migrationOrigin",
1412 "src/apps/relay_wait.ts clearRelayWaits",
1513 "src/apps/toolbar.ts TOOLBAR_PATH",
16 "src/arcade/host.ts arcadeOn",
17 "src/billing/orders.ts bySession",
18 "src/billing/orders.ts recentOrders",
1914 "src/billing/sync.ts setStripeFetch",
2015 "src/boards/live_hub.ts hubsOpen",
2116 "src/boards/model_fill.ts useModel",
22 "src/checks/deepsec_plan.ts sweepArgvs",
2317 "src/checks/doctor.ts isDoctorHold",
2418 "src/checks/order_dependent.ts orderDependent",
2519 "src/checks/lent_yield.ts setLoadSource",
@@ -29,43 +23,29 @@
2923 "src/checks/scans.ts scanSeconds",
3024 "src/checks/service.ts provideChecksForTest",
3125 "src/cloud/ovh_sign.ts resetOvhClock",
32 "src/contract/audit.ts identitiesOf",
3326 "src/core/accounts.ts edgeOnlyAccounts",
3427 "src/core/capacity.ts provideCpusForTest",
3528 "src/core/credit.ts clearCreditCache",
36 "src/core/device_grants.ts appIdOfSlug",
3729 "src/core/device_grants.ts grantedSlugs",
3830 "src/core/feed_chips.ts noChips",
39 "src/core/fence.ts heldIn",
40 "src/core/idempotency.ts clearInFlight",
4131 "src/core/idempotency.ts resetPruneClock",
42 "src/core/issue_teams.ts teamsAnswered",
4332 "src/core/issues.ts countIssues",
4433 "src/core/issues.ts issueRefKey",
4534 "src/core/issues.ts searchIssuesVisibleTo",
4635 "src/core/ledger_git.ts resetBatchClock",
47 "src/core/looks.ts isLookKind",
48 "src/core/meter.ts PLACEMENTS",
4936 "src/core/oidc.ts rotateKeys",
5037 "src/core/oidc.ts verifyIdToken",
5138 "src/core/parent_releases.ts refreshIdle",
5239 "src/core/pulls.ts mergeReadingsSettled",
5340 "src/core/pulls.ts mergedPullClosingScan",
54 "src/core/pulls.ts pullsForIssues",
5541 "src/core/roles.ts rolesTable",
5642 "src/core/route_timing.ts readTiming",
57 "src/core/sealed.ts sealedById",
5843 "src/core/search.ts grepCount",
5944 "src/core/search.ts grepRepo",
6045 "src/core/sessions.ts sessionUser",
6146 "src/core/signin-window.ts signinKeyCount",
62 "src/core/starts.ts startOfAccount",
63 "src/core/subscriptions.ts listAllGrants",
6447 "src/core/team-metrics.ts keptFigures",
65 "src/core/timers.ts pendingTimers",
6648 "src/core/transfer.ts transfersOf",
67 "src/core/usage.ts USAGE_BY",
68 "src/core/usage.ts USAGE_OUTCOMES",
6949 "src/core/v1_proof.ts useProof",
7050 "src/core/webhooks.ts deliveryBusy",
7151 "src/flow/stuck_pile.ts forgetStuckRepos",
@@ -73,31 +53,17 @@
7353 "src/crew/first_look.ts useLookModel",
7454 "src/crew/hot_history.ts forgetHeat",
7555 "src/crew/hot_history.ts sampleTimes",
76 "src/crew/models.ts modelLabel",
7756 "src/crew/sandbox_cause.ts skipReason",
78 "src/crew/week_read.ts forgetWeek",
79 "src/data/mask.ts isSecretColumn",
8057 "src/data/query.ts queriesRunning",
8158 "src/design/qr.ts QR_MAX_BYTES",
82 "src/display/items.ts itemsOfKeys",
83 "src/display/items.ts keepUnnamed",
84 "src/display/known.ts withoutDisplay",
85 "src/display/launch.ts coverUrl",
86 "src/display/launch.ts downloadUrl",
87 "src/display/launch.ts playUrl",
88 "src/display/launch.ts shotsUrl",
89 "src/display/selections.ts SHOWCASED",
90 "src/display/selections.ts displaySelections",
9159 "src/display/selections.ts selectionsHolding",
9260 "src/drop/store.ts streamingBytes",
9361 "src/efficiency/installs.ts resetInstalls",
94 "src/feed/chips.ts chipOfKind",
9562 "src/feed/likes.ts ledgerCount",
9663 "src/flow/alarm_drift.ts alarmDrift",
9764 "src/flow/alarm_drift.ts clearDriftCache",
9865 "src/flow/handovers.ts handoversSays",
9966 "src/flow/keeper.ts listAttempts",
100 "src/flow/kpi_words.ts trafficWords",
10167 "src/flow/lanes.ts useLanesReader",
10268 "src/flow/pages.ts usePagesReader",
10369 "src/flow/reach.ts NO_REACH",
@@ -108,8 +74,6 @@
10874 "src/git/diff-memory.ts mergeBaseCount",
10975 "src/git/local.ts aheadBehind",
11076 "src/git/local.ts isClean",
111 "src/git/local.ts isRepo",
112 "src/git/local.ts statusLetters",
11377 "src/git/merge.ts setMergeTreeAcceptsMergeBaseForTest",
11478 "src/git/path_listing.ts keptListings",
11579 "src/git/read.ts closeAllReaders",
@@ -119,9 +83,7 @@
11983 "src/http/crawl.ts crawlAgentCount",
12084 "src/http/crawl.ts pinCrawlLag",
12185 "src/http/crawl.ts setCrawlClock",
122 "src/http/mcp.ts toolNames",
12386 "src/http/mcp.ts toolRegistry",
124 "src/http/script_errors.ts SCRIPT_ERROR_PATH",
12587 "src/http/sse.ts resetSseDroppedCount",
12688 "src/http/sse.ts sseDroppedCount",
12789 "src/http/strangers.ts heldChanged",
@@ -139,7 +101,6 @@
139101 "src/kernel/log.ts clearErrors",
140102 "src/kernel/migrate.ts notAdditive",
141103 "src/kernel/result.ts andThen",
142 "src/kernel/result.ts trapAsync",
143104 "src/kernel/result.ts unwrapOr",
144105 "src/looks/main_looks.ts mainLook",
145106 "src/machines/shell.ts liveSessions",
@@ -148,14 +109,11 @@
148109 "src/origins/ahead.ts aheadBusy",
149110 "src/origins/git-mirror.ts mirrorOutboundForTest",
150111 "src/origins/git-mirror.ts provideMirrorOutboundForTest",
151 "src/origins/jobs.ts listJobs",
152112 "src/origins/jobs.ts resetJobs",
153113 "src/origins/oauth.ts pruneFlows",
154114 "src/origins/providers/index.ts forgetProviders",
155115 "src/origins/sync.ts syncsSettled",
156116 "src/packs/catalog.ts packNamed",
157 "src/perf/budgets.ts EXPLORE_READ_BUDGET",
158 "src/perf/page_budget_read.ts pageBudgetRows",
159117 "src/perf/views_store.ts pendingViews",
160118 "src/release/behind.ts readNewest",
161119 "src/release/landings.ts forgetLive",
@@ -189,18 +147,9 @@
189147 "src/tui/gallery.ts galleryFrame",
190148 "src/tui/local/common.ts localBusy",
191149 "src/tui/local/common.ts localIdle",
192 "src/tui/screens/common.ts COMMENT_MARK",
193150 "src/tui/screens/external.ts forgetEditor",
194 "src/tui/term/ansi.ts ERASE_LINE_RIGHT",
195 "src/tui/term/style.ts withAttr",
196 "src/tui/term/style.ts withBg",
197 "src/tui/term/style.ts withFg",
198 "src/tui/term/style.ts withoutAttr",
199151 "src/tui/term/terminal.ts diffScreens",
200 "src/tui/ui/editor.ts STATUS_BOLD",
201 "src/tui/ui/editor.ts expandLine",
202152 "src/tui/ui/icons.ts iconNames",
203 "src/tui/ui/image.ts clearImage",
204153 "src/web/chrome.ts stickyAction",
205154 "src/web/code_rows_pool.ts workersForTest",
206155 "src/web/diff-cache.ts clearDiffCache",
@@ -220,10 +169,8 @@
220169 "src/web/render/kinds.ts KNOWN_EXTENSIONS",
221170 "src/web/script_keys.ts SCRIPT_KEYS",
222171 "src/web/share_target.ts forgetShares",
223 "src/web/space_view.ts GLIDE_MS",
224172 "src/web/studio/home_cache.ts setHomeClock",
225173 "src/web/studio/home_last.ts forgetHome",
226174 "src/web/studio/review_evidence.ts rememberStat",
227 "src/web/studio/shelf.ts productionFactsForRepos",
228175 "src/web/sw.ts swSource"
229176 ]
src/apps/dns_provider.ts −1
@@ -7,7 +7,6 @@
77 */
88
99 export type EditableType = "A" | "AAAA" | "CNAME" | "TXT";
10 export const EDITABLE_TYPES: readonly EditableType[] = ["A", "AAAA", "CNAME", "TXT"];
1110
1211 export interface ZoneRecord {
1312 readonly type: EditableType;
src/apps/manifest.ts −7
@@ -646,13 +646,6 @@ export function parseCloud(
646646 return ok(out);
647647 }
648648
649 /** Whether `forge.json` declares an app at all, without validating it. */
650 export function declaresApp(forgeJson: string | undefined): boolean {
651 if (forgeJson === undefined) return false;
652 const parsed = parseJson(forgeJson, "forge.json");
653 return parsed.ok && parsed.value["app"] !== undefined;
654 }
655
656649 type Json = Record<string, unknown>;
657650
658651 const isObject = (value: unknown): value is Json =>
src/arcade/host.ts −5
@@ -58,11 +58,6 @@ export function arcadeUrl(runtime: AppsRuntime): string {
5858 return `${scheme}://${ARCADE_SLUG}${appHostSuffix(domain)}${port}`;
5959 }
6060
61 /** Whether the forge has an Arcade: apps run and a site admin's display is titled `arcade-builds`. */
62 export function arcadeOn(app: App): boolean {
63 return appsRuntime(app) !== undefined && arcadeRepoKnown(app) !== undefined;
64 }
65
6661 /** The Arcade's address when the forge has one. */
6762 export function arcadeHome(app: App): string | undefined {
6863 const runtime = appsRuntime(app);
src/billing/orders.ts −10
@@ -82,12 +82,6 @@ export function getOrder(db: Database, id: string): Order | undefined {
8282 return r ? fromRow(r) : undefined;
8383 }
8484
85 export function bySession(db: Database, sessionId: string): Order | undefined {
86 if (sessionId === "") return undefined;
87 const r = db.query<Row, [string]>("SELECT * FROM forge_order WHERE session_id = ?1").get(sessionId);
88 return r ? fromRow(r) : undefined;
89 }
90
9185 /** True when the ticket is the one the order was made with. */
9286 export function ticketFits(db: Database, id: string, ticket: string): boolean {
9387 const r = db.query<{ ticket_hash: string }, [string]>("SELECT ticket_hash FROM forge_order WHERE id = ?1").get(id);
@@ -183,10 +177,6 @@ export function failedOrders(db: Database): Order[] {
183177 return db.query<Row, []>("SELECT * FROM forge_order WHERE state = 'failed' ORDER BY updated_at DESC LIMIT 50").all().map(fromRow);
184178 }
185179
186 export function recentOrders(db: Database, limit = 20): Order[] {
187 return db.query<Row, [number]>("SELECT * FROM forge_order WHERE state != 'pending' ORDER BY updated_at DESC LIMIT ?1").all(limit).map(fromRow);
188 }
189
190180 /**
191181 * Orders whose forge is not up yet or is about to be made: paid, spawning or making, and pending
192182 * ones still within the checkout's validity. What the ceiling counts beside its pinned rows.
src/contract/audit.ts −5
@@ -78,11 +78,6 @@ export function standingOf(text: string | undefined): Standing {
7878 };
7979 }
8080
81 /** The identities of a sound standing: the floor, then the rest. */
82 export function identitiesOf(standing: Standing): readonly string[] {
83 return standing.kind === "sound" ? standing.identities : [];
84 }
85
8681 /**
8782 * The policy as a builder is briefed on it: one line per resource with the
8883 * least role each verb needs, or the problems when the contract does not
src/core/device_grants.ts −3
@@ -58,6 +58,3 @@ export const grantedSlugs = (db: Database, deviceId: number): string[] =>
5858
5959 export const allAppSlugs = (db: Database): string[] =>
6060 db.query<{ slug: string }, []>("SELECT slug FROM app ORDER BY slug").all().map((r) => r.slug);
61
62 export const appIdOfSlug = (db: Database, slug: string): string | undefined =>
63 db.query<{ id: string }, [string]>("SELECT id FROM app WHERE slug = ?1").get(slug)?.id;
src/core/idempotency.ts
Binary file not shown.
src/core/issue_teams.ts −4
@@ -94,10 +94,6 @@ export function teamVerdicts(
9494 });
9595 }
9696
97 /** Whether every named team has a current verdict on the head (vacuously true with no teams). */
98 export const teamsAnswered = (verdicts: readonly TeamVerdict[]): boolean =>
99 verdicts.every((v) => v.state !== undefined && !v.stale);
100
10197 /**
10298 * The named teams that still hold the pull: each has a crew reviewer on the
10399 * pull's repository and no current approval on its head. A stale approval,
src/core/looks.ts −2
@@ -11,8 +11,6 @@ import { id as newId } from "../kernel/id.ts";
1111 /** The three widths a page is pictured at. */
1212 export type LookKind = "phone" | "narrow" | "desktop" | "thumb";
1313 export const LOOK_KINDS: readonly LookKind[] = ["phone", "narrow", "desktop", "thumb"];
14 export const isLookKind = (value: string): value is LookKind =>
15 (LOOK_KINDS as readonly string[]).includes(value);
1614
1715 /**
1816 * The three sizes a picture is kept at, as a person holds them: a phone, a
src/core/meter.ts −1
@@ -27,7 +27,6 @@ import { defect } from "../kernel/error.ts";
2727
2828 /** Where an environment ran: hardware the operator owns, or a cloud's. */
2929 export type Placement = "owned" | "cloud";
30 export const PLACEMENTS: readonly Placement[] = ["owned", "cloud"];
3130
3231 /** How long one storage sample stands for, in milliseconds. */
3332 export const SAMPLE_SPAN_MS = 3_600_000;
src/core/pulls.ts −8
@@ -750,14 +750,6 @@ export function mergedPullCount(
750750 return row?.n ?? 0;
751751 }
752752
753 /** The pull rows for a page of issues, keyed by issue id. */
754 export function pullsForIssues(
755 db: Database,
756 issues: readonly Issue[],
757 ): Map<string, Pull> {
758 return new Map(joinMany(db, issues).map((pull) => [pull.id, pull]));
759 }
760
761753 /**
762754 * Which of these pull numbers have landed.
763755 *
src/core/sealed.ts −5
@@ -85,11 +85,6 @@ export function sealedRowById(
8585 return row ? { sealed: row.sealed === 1, authorId: row.author_id } : undefined;
8686 }
8787
88 /** Whether the issue `issueId` is sealed. */
89 export function sealedById(db: Database, issueId: string): boolean {
90 return sealedRowById(db, issueId)?.sealed === true;
91 }
92
9388 /** Issue `number` in `repoId` as `mayView` reads it. */
9489 export function sealedRowByNumber(
9590 db: Database,
src/core/subscriptions.ts −15
@@ -487,21 +487,6 @@ export function listGrants(db: Database, scopeId: string): Grant[] {
487487 }));
488488 }
489489
490 /** Every grant on this forge, for the page that says where each account goes. */
491 export function listAllGrants(db: Database): Grant[] {
492 return db
493 .query<{ scope_id: string; agent_id: string; subscription_id: string }, []>(
494 `SELECT scope_id, agent_id, subscription_id FROM subscription_grant
495 ORDER BY subscription_id, scope_id, agent_id`,
496 )
497 .all()
498 .map((r) => ({
499 scopeId: r.scope_id,
500 agentId: r.agent_id,
501 subscriptionId: r.subscription_id,
502 }));
503 }
504
505490 /**
506491 * The set of accounts one agent (or everyone) may use at a scope, replaced
507492 * whole. An empty set removes the grant, and the wider one applies again.
src/core/timers.ts −4
@@ -252,10 +252,6 @@ export function pendingOnce(db: Database, appId: string): number {
252252 return db.query<{ n: number }, [string]>("SELECT COUNT(*) AS n FROM timer WHERE app_id = ?1 AND kind = 'once' AND name = ''").get(appId)?.n ?? 0;
253253 }
254254
255 export function pendingTimers(db: Database, appId: string, limit = 100): Timer[] {
256 return db.query<Row, [string, number]>("SELECT * FROM timer WHERE app_id = ?1 AND kind = 'once' AND name = '' ORDER BY due_at LIMIT ?2").all(appId, limit).map(toTimer);
257 }
258
259255 export function setPaused(db: Database, id: number, paused: boolean, now: number): void {
260256 const t = getTimer(db, id);
261257 if (t === undefined) return;
src/core/usage.ts −13
@@ -23,12 +23,6 @@ import type { Database } from "bun:sqlite";
2323
2424 /** How a run ended, as far as spend is concerned. */
2525 export type UsageOutcome = "ok" | "failed" | "paused" | "running";
26 export const USAGE_OUTCOMES: readonly UsageOutcome[] = [
27 "ok",
28 "failed",
29 "paused",
30 "running",
31 ];
3226
3327 /**
3428 * What a run was for: `build` (an issue or a pull's feedback), `plan` (a
@@ -156,13 +150,6 @@ export function issueUsage(
156150
157151 /** What the ledger can be summed by. Each maps to one fixed column. */
158152 export type UsageBy = "subscription" | "repo" | "agent" | "issue" | "kind";
159 export const USAGE_BY: readonly UsageBy[] = [
160 "subscription",
161 "repo",
162 "agent",
163 "issue",
164 "kind",
165 ];
166153 const COLUMN: Readonly<Record<UsageBy, string>> = {
167154 subscription: "subscription_id",
168155 repo: "repo_id",
src/crew/models.ts −5
@@ -11,8 +11,3 @@ export const MODELS: readonly { id: string; label: string }[] = [
1111 { id: "sonnet", label: "Sonnet — capable and quick" },
1212 { id: "haiku", label: "Haiku — the quickest" },
1313 ];
14
15 /** The label for a model id, or the id itself when it is not on the list. */
16 export function modelLabel(id: string): string {
17 return MODELS.find((m) => m.id === id)?.label ?? id;
18 }
src/data/mask.ts −2
@@ -35,8 +35,6 @@ export const FORCE: Readonly<Record<string, readonly string[]>> = {
3535 ],
3636 };
3737
38 export const isSecretColumn = (column: string): boolean => SECRET.test(column);
39
4038 /** Whether `table.column` of a source shows only the mask. */
4139 export function masker(sourceId: string): (table: string, column: string) => boolean {
4240 const allow = new Set(ALLOW[sourceId] ?? []);
src/display/items.ts −27
@@ -131,13 +131,6 @@ export async function selectionKeys(app: App, config: DisplayConfig, viewer: Use
131131 return orderItems(found, config.order).map((i) => i.key);
132132 }
133133
134 /**
135 * Items for the given keys, in that order, as `viewer` may see them: what a
136 * display's page draws for builds that are not on it yet (its sidebar).
137 */
138 export const itemsOfKeys = (app: App, display: Repo, config: DisplayConfig, keys: readonly string[], viewer: User | undefined): Promise<DisplayItem[]> =>
139 chosenItems(app, display, config, keys, viewer);
140
141134 /** The chosen builds a viewer may see on the display, in the chosen order. */
142135 async function chosenItems(app: App, display: Repo, config: DisplayConfig, builds: readonly string[], viewer: User | undefined): Promise<DisplayItem[]> {
143136 const byRepo = new Map<string, { repo: Repo | undefined; pins: Map<string, BuildPin> }>();
@@ -214,23 +207,3 @@ export function orderItems<T extends { readonly key: string; readonly pin: Pick<
214207 .sort((a, b) => (a.pin.pinnedAt < b.pin.pinnedAt ? -1 : a.pin.pinnedAt > b.pin.pinnedAt ? 1 : a.key < b.key ? -1 : 1));
215208 return [...placed, ...rest];
216209 }
217
218 /**
219 * A person's new selection for a display, made whole: `named` is the list
220 * they gave, in their order, of builds they may name; every build already on
221 * the display from a repository they cannot read keeps its place, so a page
222 * that never showed its key cannot drop it.
223 */
224 export async function keepUnnamed(app: App, config: DisplayConfig, named: readonly string[], viewer: User | undefined): Promise<string[]> {
225 const current = await selectionKeys(app, config, "everyone");
226 const readable = (key: string): boolean => {
227 const [owner = "", name = ""] = key.slice(0, key.lastIndexOf(":")).split("/");
228 const repo = getRepo(app.db, owner, name);
229 return repo !== undefined && canRead(app.db, repo, viewer);
230 };
231 const out = named.filter(readable);
232 current.forEach((key, at) => {
233 if (!readable(key) && !out.includes(key)) out.splice(Math.min(at, out.length), 0, key);
234 });
235 return out;
236 }
src/display/known.ts −6
@@ -307,12 +307,6 @@ export async function warmDisplays(app: App): Promise<void> {
307307 });
308308 }
309309
310 /** Of `repos`, those with no `display.json` on their default branch. */
311 export async function withoutDisplay(app: App, repos: readonly Repo[]): Promise<Repo[]> {
312 const read = await inTurn(repos, (repo) => displayOf(app, repo));
313 return repos.filter((_, i) => read[i] === undefined);
314 }
315
316310 /** What a display is; the page and the terminal screen say it once, above the list. */
317311 export const DISPLAYS_SENTENCE = "A display is a showcase screen for a repository: its pinned demos, laid out as a shelf, grid or graph, to open full screen.";
318312 /** How to make one; the empty state of the page and of the terminal screen. */
src/display/launch.ts +1 −53
@@ -14,14 +14,9 @@
1414 */
1515
1616 import { createHmac, timingSafeEqual } from "node:crypto";
17 import type { App } from "../app.ts";
18 import { appsRuntime } from "../apps/runtime.ts";
19 import { arcadeUrl } from "../arcade/host.ts";
20 import { cartFile, shownFile } from "../arcade/shelf.ts";
21 import { canRead, type Repo } from "../core/repos.ts";
17 import type { Repo } from "../core/repos.ts";
2218 import type { BuildPin } from "../git/builds.ts";
2319 import { loadKey } from "../kernel/secret.ts";
24 import type { DisplayItem } from "./items.ts";
2520
2621 /** How long a grant to play a private page lasts. */
2722 export const CART_GRANT_MS = 60 * 60 * 1000;
@@ -45,53 +40,6 @@ export function verifyCart(dataDir: string, path: string, grant: string, now = D
4540 return a.length === b.length && timingSafeEqual(a, b);
4641 }
4742
48 /** The display origin, or undefined where no apps run. */
49 export function displayOrigin(app: App): string | undefined {
50 const runtime = appsRuntime(app);
51 return runtime === undefined ? undefined : arcadeUrl(runtime);
52 }
53
54 type Hidden = Pick<DisplayItem, "display" | "id">;
55
56 /** An item's own routes on the forge, under its display. */
57 export const shownBase = (item: Hidden): string => `/${item.display.ownerName}/${item.display.name}/display/demo/${item.id}`;
58
59 /** Where a captured demo plays, or undefined where no apps run or nothing is captured. */
60 export function playUrl(app: App, item: DisplayItem): string | undefined {
61 if (item.captured === undefined) return undefined;
62 if (item.open) return pinPlayUrl(app, item.repo, item.pin.oid, item.demo.page);
63 const origin = displayOrigin(app);
64 if (origin === undefined) return undefined;
65 const path = shownFile(item);
66 const plain = canRead(app.db, item.display, undefined);
67 return `${origin}/${path}${plain ? "" : `?g=${signCart(app.config.dataDir, path)}`}`;
68 }
69
70 /**
71 * Where a commit's captured page plays on the display origin, read through
72 * its own repository: plain when anyone may read it, else with a grant.
73 * The caller says it is captured (`captureState`).
74 */
75 export function pinPlayUrl(app: App, repo: Repo, oid: string, page: string): string | undefined {
76 const origin = displayOrigin(app);
77 if (origin === undefined) return undefined;
78 const path = cartFile(repo, oid, page);
79 return `${origin}/${path}${canRead(app.db, repo, undefined) ? "" : `?g=${signCart(app.config.dataDir, path)}`}`;
80 }
81
82 /** Where a captured demo downloads, on the forge. */
83 export const downloadUrl = (item: DisplayItem): string =>
84 item.open
85 ? `/${item.repo.ownerName}/${item.repo.name}/builds/${item.pin.oid}/download?page=${encodeURIComponent(item.demo.page)}`
86 : `${shownBase(item)}/download`;
87
8843 /** A pin's screenshots, on its repository. */
8944 export const repoShotsUrl = (repo: Pick<Repo, "ownerName" | "name">, pin: Pick<BuildPin, "label">): string =>
9045 `/${repo.ownerName}/${repo.name}/builds/${encodeURIComponent(pin.label)}/shots`;
91
92 /** A demo's screenshots, on the forge. */
93 export const shotsUrl = (item: DisplayItem): string => (item.open ? repoShotsUrl(item.repo, item.pin) : `${shownBase(item)}/shots`);
94
95 /** A demo's cover, or the picture of its captured page, on the forge. */
96 export const coverUrl = (item: DisplayItem): string =>
97 item.open ? `/${item.repo.ownerName}/${item.repo.name}/builds/${encodeURIComponent(item.pin.label)}/cover` : `${shownBase(item)}/cover`;
src/display/selections.ts −24
@@ -9,8 +9,6 @@
99 import type { App } from "../app.ts";
1010 import { canWrite, type Repo } from "../core/repos.ts";
1111 import type { User } from "../core/users.ts";
12 import { selectionKeys } from "./items.ts";
13 import { listedDisplays } from "./known.ts";
1412
1513 /** One display, as a selection of builds. */
1614 export interface DisplaySelection {
@@ -26,32 +24,10 @@ export interface DisplaySelection {
2624 readonly writes: boolean;
2725 }
2826
29 /** The id the Showcased selection goes by in a URL. */
30 export const SHOWCASED = "showcased";
31
3227 /** Whether `user` may change a display in `repo`: a person who writes it, never an agent. */
3328 export const writesDisplay = (app: App, repo: Repo, user: User | undefined): boolean =>
3429 user !== undefined && user.kind !== "agent" && canWrite(app.db, repo, user);
3530
36 /** Every display `viewer` reads whose file parses, as a selection, by title. */
37 export async function displaySelections(app: App, viewer: User | undefined): Promise<DisplaySelection[]> {
38 const listed = await listedDisplays(app, viewer);
39 const out: DisplaySelection[] = [];
40 for (const d of listed) {
41 if (!d.config.ok) continue;
42 const config = d.config.value;
43 out.push({
44 id: `${d.repo.ownerName}/${d.repo.name}`,
45 repo: d.repo,
46 title: config.title,
47 keys: await selectionKeys(app, config, viewer),
48 chosen: config.builds !== undefined,
49 writes: writesDisplay(app, d.repo, viewer),
50 });
51 }
52 return out.sort((a, b) => (a.title.toLowerCase() < b.title.toLowerCase() ? -1 : a.title.toLowerCase() > b.title.toLowerCase() ? 1 : a.id < b.id ? -1 : 1));
53 }
54
5531 /** The names of the selections a build is in: Showcased first, then each display. */
5632 export function selectionsHolding(key: string, showcased: boolean, displays: readonly DisplaySelection[]): string[] {
5733 return [...(showcased ? ["Showcased"] : []), ...displays.filter((d) => d.keys.includes(key)).map((d) => d.title)];
src/feed/chips.ts −2
@@ -18,8 +18,6 @@ const CHIP_OF: Partial<Record<FeedKind, KindChip>> = {
1818 release: "releases",
1919 };
2020
21 export const chipOfKind = (kind: FeedKind): KindChip | undefined => CHIP_OF[kind];
22
2321 /** Whether the viewer's chips switch this item off. */
2422 export function chipHides(
2523 chips: Chips,
src/flow/kpi_words.ts −16
@@ -177,22 +177,6 @@ export function trafficAttention(t: TrafficFigures): "deep" | "crawlers" | null
177177 return null;
178178 }
179179
180 /** The tile's words. */
181 export function trafficWords(t: TrafficTotals): { note: string; title: string; attn: boolean } {
182 const top = trafficTop(t);
183 if (top === null) return { note: "no requests in 15 min", title: KPI_COUNTS.traffic, attn: false };
184 const by = TRAFFIC_CLASSES.map((c) => `${TRAFFIC_WORDS[c]} ${share(t.classes[c].ms, t.ms)} (${t.classes[c].requests})`).join(", ");
185 const facts = `${by}. ${t.refused} refused, about ${t.addresses} ${t.addresses === 1 ? "address" : "addresses"}.`;
186 const wrong = trafficAttention(t);
187 if (wrong !== null)
188 return {
189 note: `of time: ${wrong === "deep" ? "anonymous deep" : "crawlers"}, too much`,
190 title: `Something is wrong: ${TRAFFIC_WORDS[wrong]} took most of the answering time, so everyone else waits. ${facts}`,
191 attn: true,
192 };
193 return { note: `of time: ${TRAFFIC_WORDS[top]}`, title: `Share of answering time over the last 15 minutes: ${facts}`, attn: false };
194 }
195
196180 /** Home's one line over /review: `3 waiting on you, oldest 2 days` (the largest sensible unit); null at zero, so the line is absent. */
197181 export function waitingWords(count: number, oldestAt: string | null, now: Date): string | null {
198182 if (count <= 0) return null;
src/git/local.ts −15
@@ -121,16 +121,6 @@ async function drain(
121121 return all;
122122 }
123123
124 /** `git rev-parse --show-toplevel`: the work-tree root, or an Err. */
125 export async function repoRoot(dir: string): Promise<LocalResult<string>> {
126 const out = await runLocal(["rev-parse", "--show-toplevel"], { cwd: dir });
127 return out.ok ? ok(out.value.trim()) : out;
128 }
129
130 export async function isRepo(dir: string): Promise<boolean> {
131 return (await repoRoot(dir)).ok;
132 }
133
134124 /** When the last fetch landed, from `.git/FETCH_HEAD`'s mtime, else null. */
135125 export async function lastFetch(dir: string): Promise<Date | null> {
136126 const file = Bun.file(`${dir}/.git/FETCH_HEAD`);
@@ -303,11 +293,6 @@ function entry(
303293 return { path, origPath, index, work, untracked, conflicted };
304294 }
305295
306 /** The two-letter summary a file row shows: "M.", ".M", "??", "UU". */
307 export function statusLetters(f: FileEntry): string {
308 return f.untracked ? "??" : `${f.index}${f.work}`;
309 }
310
311296 // ── diffs ────────────────────────────────────────────────────────────────
312297
313298 /**
src/http/script_errors.ts −1
@@ -23,7 +23,6 @@ import { clientBucket } from "./peer.ts";
2323 import type { RouteOf } from "./measure.ts";
2424 import { windowStart } from "./csp_report.ts";
2525
26 export const SCRIPT_ERROR_PATH = "/_script-error";
2726 export const SCRIPT_ERROR_MAX = BODY_CAPS.scriptError.bytes;
2827 export const MESSAGE_MAX = 120;
2928 const PATH_MAX = 200;
src/kernel/result.ts −10
@@ -29,16 +29,6 @@ export function trap<T>(fn: () => T): Result<T, unknown> {
2929 }
3030 }
3131
32 export async function trapAsync<T>(
33 fn: () => Promise<T>,
34 ): Promise<Result<T, unknown>> {
35 try {
36 return ok(await fn());
37 } catch (error) {
38 return err(error);
39 }
40 }
41
4232 export function map<T, U, E>(
4333 result: Result<T, E>,
4434 fn: (value: T) => U,
src/origins/jobs.ts −4
@@ -135,10 +135,6 @@ export function runningJob(
135135 return undefined;
136136 }
137137
138 /** Every job, newest first — what a "what is running?" view renders. */
139 export const listJobs = (): MirrorJob[] =>
140 [...jobs.values()].sort((a, b) => b.id.localeCompare(a.id));
141
142138 /**
143139 * Move a job on. A terminal job never moves again: a late stage report from
144140 * a job that already failed must not resurrect it as "importing issues".
src/perf/budgets.ts −6
@@ -69,9 +69,3 @@ export function gitBudgetFor(key: string): Budget {
6969 * largest paint at p95.
7070 */
7171 export const PAGE_BUDGET = { serverP95Ms: 150, paintP95Ms: 1000 } as const;
72
73 /**
74 * The ranked read behind /explore, /api/v1/explore and the MCP `explore` tool, as registered in
75 * BUDGETS.
76 */
77 export const EXPLORE_READ_BUDGET: Budget = budgetFor("/explore#read")!;
src/tui/screens/common.ts −1
@@ -1113,7 +1113,6 @@ export const VERDICT_MARKS = {
11131113 */
11141114 export const ISSUE_MARK = G.ring;
11151115 export const PULL_MARK = G.pull;
1116 export const COMMENT_MARK = G.comment;
11171116
11181117 /**
11191118 * A formatter for a whole list's counts, so the numbers line up as a column
src/tui/term/ansi.ts −1
@@ -21,7 +21,6 @@ export const ALT_LEAVE = "\x1b[?1049l";
2121 export const CURSOR_HIDE = "\x1b[?25l";
2222 export const CURSOR_SHOW = "\x1b[?25h";
2323 export const ERASE_ALL = "\x1b[2J";
24 export const ERASE_LINE_RIGHT = "\x1b[0K";
2524 export const WRAP_OFF = "\x1b[?7l";
2625 export const WRAP_ON = "\x1b[?7h";
2726 export const SGR_RESET = "\x1b[0m";
src/tui/term/style.ts −18
@@ -36,24 +36,6 @@ export function style(
3636 return { fg, bg, attr };
3737 }
3838
39 export function withFg(s: Style, fg: Color): Style {
40 return s.fg === fg ? s : { fg, bg: s.bg, attr: s.attr };
41 }
42
43 export function withBg(s: Style, bg: Color): Style {
44 return s.bg === bg ? s : { fg: s.fg, bg, attr: s.attr };
45 }
46
47 export function withAttr(s: Style, bits: number): Style {
48 const attr = s.attr | bits;
49 return attr === s.attr ? s : { fg: s.fg, bg: s.bg, attr };
50 }
51
52 export function withoutAttr(s: Style, bits: number): Style {
53 const attr = s.attr & ~bits;
54 return attr === s.attr ? s : { fg: s.fg, bg: s.bg, attr };
55 }
56
5739 export function sameStyle(a: Style, b: Style): boolean {
5840 return a.fg === b.fg && a.bg === b.bg && a.attr === b.attr;
5941 }
src/tui/ui/editor.ts +1 −22
@@ -36,7 +36,7 @@ import {
3636 } from "../../web/highlight.ts";
3737 import type { KeyEvent } from "../term/input.ts";
3838 import { G, type Rect, type Screen as Surface } from "../term/screen.ts";
39 import { style, BOLD } from "../term/style.ts";
39 import { style } from "../term/style.ts";
4040 import { clusters, displayWidth, truncate } from "../term/width.ts";
4141 import { tokColor, type Tokens } from "./theme.ts";
4242 import type { CursorPos } from "./widgets.ts";
@@ -93,24 +93,6 @@ export function colFromDisplay(line: string, want: number): number {
9393 return chars.length;
9494 }
9595
96 /** The line as the terminal will show it — tabs expanded in place. */
97 export function expandLine(line: string): string {
98 if (!line.includes("\t")) return line;
99 let out = "";
100 let width = 0;
101 for (const ch of clusters(line)) {
102 if (ch === "\t") {
103 const n = TAB - (width % TAB);
104 out += " ".repeat(n);
105 width += n;
106 } else {
107 out += ch;
108 width += displayWidth(ch);
109 }
110 }
111 return out;
112 }
113
11496 export interface EditorFile {
11597 readonly path: string;
11698 readonly eol: "\n" | "\r\n";
@@ -754,6 +736,3 @@ export class Editor {
754736 return truncate(this.status(), width);
755737 }
756738 }
757
758 /** Bold the file name in a status line the caller has already measured. */
759 export const STATUS_BOLD = BOLD;
src/tui/ui/image.ts −5
@@ -284,11 +284,6 @@ export function clearImages(caps: TermCapabilities): Uint8Array[] {
284284 return [];
285285 }
286286
287 /** Bytes that remove one placement by id. */
288 export function clearImage(id: number, caps: TermCapabilities): Uint8Array[] {
289 return caps.graphics === "kitty" ? [kittyDelete(id)] : [];
290 }
291
292287 // ---------------------------------------------------------------------------
293288 // The placeholder
294289 // ---------------------------------------------------------------------------
src/web/space_view.ts −3
@@ -9,9 +9,6 @@
99 * and the other functions here, by name.
1010 */
1111
12 /** A landing slides from "in review" to "landed" over this much time (4 h). */
13 export const GLIDE_MS = 4 * 3600000;
14
1512 export function clamp(v: number, lo: number, hi: number): number {
1613 return v < lo ? lo : v > hi ? hi : v;
1714 }
src/web/studio/shelf.ts −27
@@ -129,33 +129,6 @@ function factsOf(
129129 return out;
130130 }
131131
132 /**
133 * Production's own fact for every one of these repositories, in one batch:
134 * `runtime.status` is in-memory (no query), so the only reads are the app
135 * records, who may enter them, their domains and the run rows a fact points
136 * to — one each for the whole shelf, never one per row.
137 */
138 export function productionFactsForRepos(
139 ctx: Ctx,
140 repos: readonly Repo[],
141 ): Map<string, ProductionFact> {
142 if (appsRuntime(ctx.app) === undefined) return new Map();
143 const records = appsForRepos(
144 ctx.app.db,
145 repos.map((r) => r.id),
146 );
147 const enterable = enterableApps(
148 ctx.app.db,
149 repos.flatMap((repo) => {
150 const app = records.get(repo.id);
151 return app === undefined ? [] : [{ repo, app }];
152 }),
153 ctx.auth.user,
154 { named: false },
155 );
156 return factsOf(ctx, productionStatuses(ctx, repos, records, enterable));
157 }
158
159132 /** The row of a private app the viewer may not enter: its name, nothing it says. */
160133 function sealedRow(repo: Repo, user: User | undefined): Html {
161134 const mine = user !== undefined && repo.ownerId === user.id;

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs