Skip to content
Myr

Strip non-essential comments from the rest of the web's features

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by oscabriel · committed by oscabriel · parent 88206c4 · Browse files · 83 files+126 added−1922 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

83 files+126 added−1922 removed

  • other:+126 added−1922 removed

83 files+126 added−1922 removed

modified:apps/web/src/features/agents/catalog.ts-5 removed
modified:apps/web/src/features/agents/forward.ts-10 removed
modified:apps/web/src/features/agents/llms.ts+2 added-7 removed
modified:apps/web/src/features/agents/manifest.ts+2 added-10 removed
modified:apps/web/src/features/agents/reference.tsx+2 added-22 removed
1/**2 * The For agents page's reference sections, set like a man page: the3 * CLI's synopsis, the endpoints, the limits and the refusals. Every word4 * that is not a heading comes from `@repo/agent-kit` (`synopsis`,5 * `agentEndpoints`, `agentLimits`) or the refusal union itself, so the6 * page and `/agents.md` say the same. Mono only for what a terminal takes:7 * commands, addresses and tags.8 */1import type {2 Endpoint,3 Limit,4 SynopsisLine,
1 unmodified line
6import { groups } from "@repo/protocol/refusal";7import { Fragment } from "react";8import type { ReactNode } from "react";918/** A link in running text: the rule colour's underline, ink on hover. */10export const LINK =11 "decoration-rule underline underline-offset-[0.2em] hover:decoration-current";1222/** One section of the reference: its heading at Title size, in the sans, then its body. */13export const ReferenceSection = ({14 children,15 id,16 title,
10 unmodified lines
27 {children}28 </section>29);3041/**42 * A usage line that wraps only between its words, never inside a flag43 * (`[--json]` stays whole), so a phone reads it as typed.44 */31const Usage = ({ usage }: { readonly usage: string }) => (32 <code className="text-mono font-mono">33 {usage.split(" ").map((word, index) => (34 <Fragment key={index}>
3 unmodified lines
38 ))}39 </code>40);4156/** Every command as typed, each over what it does, set close like a man page's synopsis. */42export const Synopsis = ({43 lines,44}: {45 readonly lines: readonly SynopsisLine[];
7 unmodified lines
53 ))}54 </ul>55);5672/** Each address an agent reads, one line each, linked where a browser can open it. */57export const Endpoints = ({58 endpoints,59}: {60 readonly endpoints: readonly Endpoint[];
11 unmodified lines
72 className="border-rule flex min-w-0 flex-col gap-0.5 border-b py-2.5"73 key={url}74 >75 {readable ? (92 // A server's own text, not a page of the app.76 <a className={`${LINK} w-fit max-w-full`} href={url}>77 {address}78 </a>79 ) : (
5 unmodified lines
85 })}86 </ul>87);88106/** The limits, as a plain table. */89export const Limits = ({ limits }: { readonly limits: readonly Limit[] }) => (90 <table className="text-ui w-full max-w-[48rem] border-collapse text-left">91 <thead>92 <tr className="border-rule border-b">
18 unmodified lines
111 </table>112);113114/**133 * Where `/llms-full.txt` lists a refusal: a text fragment on its table row134 * (`` `Tag` | Group ``), which nothing else in the file reads. A dash ends135 * a fragment's word, so it is escaped as well.115 * A text fragment on the refusal's row in `/llms-full.txt` (`` `Tag` | Group116 * ``). A dash ends a fragment's word, so it is escaped as well.117 */118const rowOf = (tag: string, group: string) =>119 `/llms-full.txt#:~:text=${encodeURIComponent(`\`${tag}\` | ${group}`).replaceAll("-", "%2D")}`;120140/** Every refusal of the union, by group, each tag linked to its row. */121export const Refusals = () => (122 <>123 <p className="text-ui text-muted-foreground max-w-[70ch]">124 Each tag opens its row in{" "}
30 unmodified lines
modified:apps/web/src/features/agents/respond.ts-9 removed
modified:apps/web/src/features/agents/setup-page.tsx-20 removed
1/**2 * The For agents page: one reference, in the order a reader reaches for3 * it: the CLI's synopsis, the ways to connect, the endpoints, the limits4 * and the refusals. The inspector is its contents. Every snippet and every5 * line of reference is `@repo/agent-kit`'s (`agentSetup` and its6 * neighbours), so the page has no text of its own for any of them7 * (principle 4). A shell line is a `CommandLine`; JSON and text to paste8 * sit in a block with the same copy affordance. A view: the CLI's commands9 * and the two hosts' URLs in, markup out.10 */1import {2 agentEndpoints,3 agentLimits,4 agentSetup,
18 unmodified lines
23 Refusals,24 Synopsis,25} from "./reference.tsx";2637/** The reference's sections, in order: each one's anchor and heading. */27const SECTIONS = [28 { id: "synopsis", title: "Synopsis" },29 { id: "connect", title: "Connect" },30 { id: "endpoints", title: "Endpoints" },31 { id: "limits", title: "Limits" },32 { id: "refusals", title: "Refusals" },33] as const;3446/**47 * JSON or text to paste: whole, with a button that copies it. It keeps its48 * own lines and indentation and scrolls sideways where the screen is49 * narrower than a line, as code does everywhere on the web, rather than50 * wrapping a value under its key; the keyboard reaches it to scroll.51 */35const SnippetBlock = ({ snippet }: { readonly snippet: SetupSnippet }) => {36 const { copied, copy } = useCopy(snippet.text);3738 return (39 <div className="border-rule bg-surface flex max-w-full min-w-0 items-start gap-2 border py-1 pr-1 pl-3">40 <pre41 aria-label={snippet.label}42 className="text-mono leading-terminal min-w-0 flex-1 overflow-x-auto py-0.5 font-mono whitespace-pre"60 // A box that scrolls is a stop for Tab, so a keyboard can scroll it.43 // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- a scrolling region must take focus to be scrolled without a pointer (WCAG 2.1.1)44 tabIndex={0}45 >46 <code className="select-all">{snippet.text}</code>
24 unmodified lines
71 )}72 </figure>73);7493/** One way to connect: its name, the agent it is for, and what to copy. */75const Channel = ({ channel }: { readonly channel: SetupChannel }) => (76 <div className="border-rule flex min-w-0 flex-col gap-3 border-t pt-4">77 <h3 className="text-want font-semibold">{channel.title}</h3>78 <p className="max-w-[70ch]">{channel.useWhen}</p>
4 unmodified lines
83 </div>84 </div>85);86106/** The inspector: the sections, as anchors. */87const Contents = () => (88 <nav aria-label="Contents">89 <ul className="flex flex-col">90 {SECTIONS.map(({ id, title }) => (
48 unmodified lines
modified:apps/web/src/features/answer/answer-page.tsx+2 added-69 removed
1/**2 * An answer, read like a run of the gate: where it stands first, then the3 * stages it passed, the lanes (failed ones open, passed ones folded into a4 * line), the held-back checks as one line per area, and, once it landed,5 * the landing's credit and its commit. What was judged (head, base, merged6 * tree, patch id) is plumbing, so it sits last, in the inspector.7 *8 * - The outcome is the hero: the status line a step up, whose move it is,9 * and a refusal drawn whole by `RefusalView`, as `git push` printed it.10 * When the outcome changes while the page is open its word and mark11 * settle in, and a landing that happened then is stamped once.12 * - A stage the answer never needed (no decider took part, no held-back13 * checks judged it) reads not needed, never passed.14 * - With no answer judged yet, the page says who holds the ask, or gives15 * the command that claims it: never a dead end.16 *17 * Held-back checks show only what `HeldBackResult` carries: an area, how18 * many passed of how many, and the suite's root. A lane's log is named19 * only by the command that reads it. The head and the merged tree live in20 * the claim's fork, which the code browser never reads, so only the base21 * and the landing link their commit pages.22 */1import { Brand } from "@repo/brand";2import type {3 HeldBackResult,4 LaneOutcome,
44 unmodified lines
49 roundOf,50 roundsAsTheyStand,51} from "./subject.ts";5275/** How long a lane ran: "640 ms", "8.3 s", "2 min 5 s". */53export const durationText = (millis: number) => {54 if (millis < 1000) {55 return `${millis} ms`;56 }
6 unmodified lines
6364 return `${Math.floor(seconds / 60)} min ${seconds % 60} s`;65};6690/** Each lane result as a mark, a word and its role colour: the word first. */67const results = {68 blocked: { mark: "waiting", tone: "text-waiting", word: "blocked" },69 failed: { mark: "refused", tone: "text-refused", word: "failed" },70 flaked: { mark: "retry", tone: "text-waiting", word: "flaked" },
3 unmodified lines
74 LaneOutcome,75 { readonly mark: StateMark; readonly tone: string; readonly word: string }76>;77102/** The page's trail: the project, its asks, the ask, then this answer. */78export const answerCrumbs = (ask: Ask): readonly Crumb[] => [79 { label: ask.project, to: `/${ask.project}` },80 { label: "Asks", to: `/${ask.project}` },81 { label: ask.id, mono: true, to: askPath(ask.project, ask.id) },82 { label: "Answer" },83];84110/** What reads a lane's log, when the platform kept one. */85const LaneLog = ({86 lane,87 project,88}: {
14 unmodified lines
103 />104 );105};106133/** One lane: its mark, name and command, its result in a word, and how long it ran. */107const LaneRow = ({108 lane,109 project,110}: {
31 unmodified lines
142 </li>143 );144};145173/** "6 lanes passed in 41 s": the lanes run one after another, so their times add up. */146const passedLine = (lanes: readonly LaneResult[]) =>147 `${lanes.length} ${lanes.length === 1 ? "lane" : "lanes"} passed in ${durationText(148 lanes.reduce((total, { durationMs }) => total + durationMs, 0)149 )}`;150179/** The lanes the platform ran on the merged tree: what failed, open and first; what passed, in one line. */151export const Lanes = ({152 checking = false,153 lanes,154 project,155}: {156 readonly lanes: readonly LaneResult[];157 readonly project: Ask["project"];187 /** The gate is still at work on the answer: its lanes may yet run. */158 readonly checking?: boolean;159}) => {160 if (lanes.length === 0) {161 return (
43 unmodified lines
205 </div>206 );207};208239/** Held-back checks: one line per area, as the landing's trailer spells it, and nothing else. */209export const HeldBackBits = ({210 results: areas,211}: {212 readonly results: readonly HeldBackResult[];
21 unmodified lines
234 ))}235 </ul>236);237269/** A git id, short as git prints it, whole on hover. */238const Sha = ({ sha }: { readonly sha: string }) => (239 <code className="text-mono font-mono" title={sha}>240 {shortSha(sha)}241 </code>242);243276/** Content the inspector shows, left out of the facts drawn inline in main below the shell's width. */244export const InspectorOnly = ({245 children,246}: {247 readonly children: ReactNode;
2 unmodified lines
250 {children}251 </div>252);253287/**288 * Every push the gate checked, newest first, the one the page reads289 * selected: first in main, once there is more than one, so a verdict is290 * read against its round.291 */254const RoundsRegion = ({255 ask,256 current,257 now,
2 unmodified lines
260}: {261 readonly ask: AskId;262 readonly project: ProjectName;263 readonly rounds: readonly Round[];302 /** The head the page shows. */264 readonly current: CommitSha | undefined;265 readonly now: DateTime.Utc;266}) => {306 // The page reads the last round at its head.267 const read =268 current === undefined269 ? 0270 : rounds.findLastIndex(({ head }) => head === current) + 1;
25 unmodified lines
296 </Region>297 );298};299340/**341 * What a waiting answer's contributor needs, from its rounds: there is342 * nothing to run, and what another push would start.343 */300const waitingSentence = (round: ReturnType<typeof roundOf>) =>301 round === undefined302 ? "Nothing for you to run."303 : `Nothing for you to run. Pushing again starts round ${round.of + 1}; this verdict stays as round ${round.number}.`;304349/** What the hero says before any answer was judged: who holds the ask, or how to take it. */305const NoAnswerYet = ({306 ask,307 now,308 states,
31 unmodified lines
340 />341 );342 }343389 // What it waits on must land before anyone can claim it.344 const waiting = ask.blockedBy.filter(345 (blocker) => states.get(blocker)?.landed === undefined346 ).length;347
24 unmodified lines
372 />373 );374};375422/**423 * The outcome, a step up: settled in when it changes while the page is424 * open (never on the first paint), and stamped once on a live landing.425 */376const Hero = ({377 ask,378 now,379 stamp,
6 unmodified lines
386 readonly states: ReadonlyMap<AskId, AskProgress>;387 readonly verdict: Verdict | undefined;388}) => {389 const tag = verdict?.outcome._tag ?? "none";440 // Only an outcome that replaced another while the page was open settles in.390 const [shown, setShown] = useState(tag);391 const [changed, setChanged] = useState(false);392393 if (shown !== tag) {
28 unmodified lines
422 </section>423 );424};425477/** The answer's run: the gate, the lanes, the held-back checks, and the landing. */426const Run = ({427 holds,428 landing,429 now,
2 unmodified lines
432}: {433 readonly holds: ReturnType<typeof holdsOf>;434 readonly landing: LandingView | undefined;435 readonly now: DateTime.Utc;488 /** Which round the verdict is, of how many. */436 readonly round: ReturnType<typeof roundOf>;437 readonly verdict: Verdict;438}) => (439 <>
44 unmodified lines
484 )}485486 {landing === undefined ? null : (487 <Region id="answer-landing" title="Landing">541 {/* The landing told as a sentence before it is shown as a hash:542 the page's job is to credit the people. */}488 {/* The landing told as a sentence before it is shown as a hash. */}489 <p className="text-title flex min-w-0 flex-wrap items-baseline gap-x-2 font-normal">490 <span className="flex items-center gap-2 font-semibold">491 <StateMarkIcon mark="landed" />492 <span className="text-landed">Landed</span>
54 unmodified lines
547 </AppLink>548 </Region>549 )}550605 {/* Below the shell's width the inspector's facts sit above the run, so606 the plumbing comes here, last. */}551 {/* Below the shell's width the inspector's facts sit above the run, so the plumbing comes here, last. */}552 <div className="shell:hidden">553 <ProvenanceFacts entries={verdictProvenance(verdict, now)} />554 </div>555 </>556);557558export interface AnswerViewProps {614 /** The ask the answer is to: its want titles the page. */559 readonly ask: Ask;616 /** The verdict on the answer; none before one was judged. */560 readonly verdict: Verdict | undefined;618 /** The landing it made, once it landed. */561 readonly landing?: LandingView | undefined;562 readonly now: DateTime.Utc;621 /** Where each ask stands, from the project's events (`askStates`). */563 readonly states?: ReadonlyMap<AskId, AskProgress>;623 /** The family's parent, when the ask is a member of one. */564 readonly parent?: Ask | undefined;625 /** The head the address names, when it names an earlier answer. */565 readonly head?: CommitSha | undefined;627 /** It landed while the page was open: stamp the landing's mark, once. */566 readonly stamp?: boolean;629 /** Who is reading, to tell the claimant the claim is theirs. */567 readonly viewer?: Handle | undefined;568}569570const NONE: ReadonlyMap<AskId, AskProgress> = new Map();571635/** The answer's facts: its state, claim, family, territory and check, then what was judged. */572const AnswerFacts = ({573 ask,574 now,575 parent,
55 unmodified lines
631 </>632 );633};634699/** The line under the hero's title: the ask, the round, when it was judged, and the way to the latest answer. */635const AnswerMeta = ({636 ask,637 head,638 now,
91 unmodified lines
730 }731 />732 }733 status={799 // The answer's head reads title, then which answer this is, then800 // the outcome: a refusal drawn whole would bury a line after it.734 <div className="flex min-w-0 flex-col gap-4">735 <div className="text-ui text-muted-foreground">736 <AnswerMeta737 ask={ask}
43 unmodified lines
modified:apps/web/src/features/answer/reads.ts-38 removed
1/**2 * What the ask page and the answer page read on the server, before either3 * draws: the subject, then what is read beside it (the project's events,4 * the family's parent, the check's source, the landing). A read beside the5 * subject that fails leaves its part out; the subject's own refusal is the6 * page's 404 (`notFoundFor`). The routes call these from their server7 * functions only, so none of it reaches the browser's first load.8 */1import { Client } from "@repo/protocol/contracts";2import { Verdict } from "@repo/protocol/domain/answer";3import { Ask } from "@repo/protocol/domain/ask";4import { CheckSpec } from "@repo/protocol/domain/check";
13 unmodified lines
1819import { notFoundFor } from "../shared/refusals.ts";20import { keptEvents, readEvents, readParent } from "./subject.ts";2130/** An ask's address, not yet decoded. */22export interface AskAddress {23 readonly ask: string;24 readonly project: string;25}2636/** The address, decoded: names the platform could hold. */27const AskPath = Schema.Struct({ ask: AskId, project: ProjectName });2839/** The check's file, as the page carries it. */29const CheckRead = Schema.Struct({30 path: RepoPath,31 sha: BlobSha,32 text: Schema.String,33});3446/**47 * What the page's loader carries from the server, encoded: the ask and its48 * brief, the family's parent, the verdict on its latest answer, the49 * check's source, the events about them (and the last number of all the50 * project's), and when it was read.51 */35export const AskPageData = Schema.Struct({36 ask: Ask,37 brief: Schema.NonEmptyString,38 check: Schema.UndefinedOr(CheckRead),
5 unmodified lines
44});4546export type AskPageData = typeof AskPageData.Type;4765/** The check's source on main, when the check is a file that reads as text; none when it cannot be read. */48const readCheck = (ask: Ask) =>49 Effect.gen(function* () {50 if (!CheckSpec.guards.RedThenGreen(ask.check)) {51 return Option.none<typeof CheckRead.Type>();
12 unmodified lines
64 Effect.orElseSucceed(() => Option.none<typeof CheckRead.Type>())65 );66 });6786/**87 * The page's reads: the ask, the project's events and the latest verdict88 * at once, then the family's parent (if it is in one) and the check's89 * source; or a not-found carrying the platform's refusal (a 404).90 */68export const readAsk = (params: AskAddress) =>69 Effect.gen(function* () {70 const path = yield* Schema.decodeEffect(AskPath)(params).pipe(71 Effect.mapError(() => notFound())
33 unmodified lines
105 ),106 });107 });108132/** The page's address, not yet decoded: the path's names and `?head=`. */109export interface AnswerAddress {110 readonly ask: string;111 readonly head?: string | undefined;112 readonly project: string;113}114139/** The address, decoded: names the platform could hold, and a commit id. */115const AnswerPath = Schema.Struct({116 ask: AskId,117 head: Schema.optionalKey(CommitSha),118 project: ProjectName,119});120146/**147 * What the page's loader carries from the server, encoded: the ask, the148 * verdict and its landing, the family's parent, the events about them (and149 * the last number of all the project's), and when it was read.150 */121export const AnswerPageData = Schema.Struct({122 ...AnswerPath.fields,123 askRead: Ask,124 brief: Schema.NonEmptyString,
6 unmodified lines
131});132133export type AnswerPageData = typeof AnswerPageData.Type;134165/** The landing a verdict's answer made, when it landed. */135export const landedBy = (136 verdict: Verdict | undefined137): LandedSha | undefined =>138 verdict !== undefined && Outcome.isAnyOf(["Landed"])(verdict.outcome)139 ? verdict.outcome.sha140 : undefined;141173/** The landing at `sha`; none for no landing, or one the platform no longer finds. */142const readLanding = (project: ProjectName, sha: LandedSha | undefined) =>143 Effect.gen(function* () {144 if (sha === undefined) {145 return Option.none<LandingView>();
2 unmodified lines
148 const client = yield* Client;149150 return yield* client.landing({ project, sha }).pipe(151 Effect.map((found) => Option.some(found.landing)),184 // The verdict names a landing the platform no longer finds: show the verdict alone.152 Effect.catchTag("UnknownCommit", () => Effect.succeedNone)153 );154 });155189/**190 * The page's reads: the verdict, the ask and the project's events at191 * once, then the landing (if it landed) and the family's parent (if it is192 * in one); or a not-found carrying the refusal (a 404).193 */156export const readAnswer = ({ ask, head, project }: AnswerAddress) =>157 Effect.gen(function* () {158 const path = yield* Schema.decodeEffect(AnswerPath)(159 head === undefined ? { ask, project } : { ask, head, project }
34 unmodified lines
modified:apps/web/src/features/answer/subject.ts+4 added-38 removed
1/**2 * What an ask's page and its answer's page read beside their subject, and3 * the plain readings over it:4 *5 * - the project's events (`watch`, replayed from the first), kept to the6 * ones about the asks the page draws: the ask, what it waits on, and its7 * family. The fold over them (`askStates`) says who holds each ask, its8 * rounds and whether it landed, with no contract of its own;9 * - a family member's parent (`showAsk`), whose stored children count the10 * family, since a listing drops the ones that landed;11 * - what a verdict holds, so the gate's strip draws a stage the answer12 * never needed as not needed.13 *14 * A read beside the subject that fails leaves its part out; it never fails15 * the page.16 */1import { Client } from "@repo/protocol/contracts";2import type { Verdict } from "@repo/protocol/domain/answer";3import type { Ask } from "@repo/protocol/domain/ask";4import { ProjectEvent } from "@repo/protocol/domain/event";
5 unmodified lines
10import { lastSeq } from "../shared/ask-progress.ts";11import type { AskProgress, Round } from "../shared/ask-progress.ts";12import type { StageHolds } from "../shared/outcome.tsx";1330/** The ask an event is about: one, or none. */14const askOf = (event: ProjectEvent): readonly AskId[] =>15 ProjectEvent.match(event, {16 AskClosed: ({ ask }) => [ask],17 AskOpened: ({ ask }) => [ask.ask],
9 unmodified lines
27 Released: ({ ask }) => [ask],28 Warned: ({ ask }) => [ask],29 });3048/** The events about `asks`, in the order given. */31export const eventsAbout = (32 events: readonly ProjectEvent[],33 asks: ReadonlySet<AskId>34): readonly ProjectEvent[] =>35 events.filter((event) => askOf(event).some((about) => asks.has(about)));3655/**56 * The delete child among a family parent's stored children: the one named57 * for the parent, as the platform names it when it splits a migrate ask.58 */37/** The platform names a split's delete child after its parent. */38export const deleteChildOf = (parent: Ask): AskId | undefined =>39 parent.blockedBy.find((child) => child === `${parent.id}-delete`);4062/** The parent of the family `ask` is in: the one read for it, or the ask itself when it heads one. */41export const familyHead = (ask: Ask, parent: Ask | undefined) =>42 parent ?? (deleteChildOf(ask) === undefined ? undefined : ask);4366/** Every ask whose events the page needs: the ask, what it waits on, and its family. */44export const asksAround = (45 ask: Ask,46 parent: Ask | undefined47): ReadonlySet<AskId> =>
2 unmodified lines
50 ...ask.blockedBy,51 ...(parent === undefined ? [] : [parent.id, ...parent.blockedBy]),52 ]);5377/** The project's events from the first; none when they cannot be read. */54export const readEvents = (project: ProjectName) =>55 Effect.gen(function* () {56 const client = yield* Client;57
3 unmodified lines
6162 return events;63 });6489/** The parent ask of a family member; none for an ask in no family, or one the platform no longer finds. */65export const readParent = (ask: Ask) =>66 Effect.gen(function* () {67 if (ask.parent === undefined) {68 return Option.none<Ask>();
8 unmodified lines
77 Effect.orElseSucceed(() => Option.none<Ask>())78 );79 });80106/** What a page carries of the events: those about its asks, and the last number of all of them. */81export const keptEvents = (82 events: readonly ProjectEvent[],83 ask: Ask,84 parent: Ask | undefined
1 unmodified line
86 events: eventsAbout(events, asksAround(ask, parent)),87 lastSeq: lastSeq(events),88});89116/** Whether an outcome waited on a person: a decision, or a decider's finish. */90const waitedOnPerson = Outcome.isAnyOf(["AwaitingDecision", "AwaitingFinish"]);91119/**120 * What a verdict holds beyond its stage: whether a decider took part (the121 * landing's `Decided-by`, or a round of the same answer that waited on one)122 * and whether held-back checks judged it.123 */92export const holdsOf = (93 verdict: Verdict,94 landing: LandingView | undefined,95 rounds: readonly Round[]
5 unmodified lines
101 ),102 heldBack: verdict.heldBack.length > 0,103});104137/** Which round the answer at `head` is, of how many: the last round judged at that head. */105export const roundOf = (106 rounds: readonly Round[],107 head: CommitSha108): { readonly number: number; readonly of: number } | undefined => {
2 unmodified lines
111 return index === -1 ? undefined : { number: index + 1, of: rounds.length };112};113114/**148 * Each round with the last word on it: a round's own event says what the149 * gate said when it judged the push (often that it was still checking),150 * so the verdict on that head, and the landing that closed the ask, speak151 * for it once they came.115 * A round's own event says what the gate said when it judged the push (often116 * still checking), so the verdict on that head, and the landing that closed the117 * ask, speak for it once they came.118 */119export const roundsAsTheyStand = (120 progress: AskProgress | undefined,121 verdict: Verdict | undefined
22 unmodified lines
modified:apps/web/src/features/ask/ask-page.tsx-55 removed
1/**2 * An ask, as a person reads it: the want as the title, then where it3 * stands in one line (open to take, claimed by someone, refused at a4 * stage, landed), whose move that is and what runs next. Below, the brief,5 * the check (the spec: its source inline), and every answer judged so far,6 * one row each. The inspector holds the typed facts: its state, how to7 * take it or who holds it, its territory and check, its family, and its8 * project's posture.9 *10 * A family member says what it waits on in the family's terms ("waiting11 * for 4 of 6 children to land") and draws the family as a fan; once every12 * sibling has landed, the delete child reads open to take. Who holds an13 * ask and its rounds come from the project's events (`askStates`), with14 * no contract of their own.15 *16 * Agents read the same ask as Markdown (`markdown.ts`); the page shows the17 * brief exactly as they read it, and links the Markdown.18 */1import { Brand } from "@repo/brand";2import type { Verdict } from "@repo/protocol/domain/answer";3import type { Ask } from "@repo/protocol/domain/ask";4import { CheckSpec } from "@repo/protocol/domain/check";
38 unmodified lines
43import { When } from "../shared/time.tsx";44import { Region } from "./fields.tsx";45import { markdownPath } from "./markdown.ts";4665/** The check's file, as the page read it: enough to draw its source. */47export interface CheckSource {48 readonly path: string;68 /** The blob's id: the drawing's cache key. */49 readonly sha: string;50 readonly text: string;51}5253const LINK = "decoration-rule underline hover:decoration-current";5455const NONE: ReadonlyMap<AskId, AskProgress> = new Map();5677/** How many lines of the check show before the reader asks for the whole. */57const CHECK_LINES = 30;5880/** The page's trail: the project, its asks, then the ask. */59export const askCrumbs = (ask: Ask): readonly Crumb[] => [60 { label: ask.project, to: `/${ask.project}` },61 { label: "Asks", to: `/${ask.project}` },62 { label: ask.id, mono: true },63];6487/** The command that claims an ask, run in a clone of its project. */65export const claimCommand = (ask: Ask) =>66 `${Brand.cli} claim ${ask.id} --project ${ask.project}`;6791/** What judges an answer, by the check's kind, in words; its file linked when it has one. */68const CheckSummary = ({ ask }: { readonly ask: Ask }) =>69 CheckSpec.match(ask.check, {70 LintToZero: ({ rule, territory }) => (71 <>
39 unmodified lines
111 </>112 ),113 });114139/**140 * The check's source, drawn as the code browser draws a file: its first141 * thirty lines until the reader asks for the whole, the server's plain142 * lines first and the highlighted drawing in place of them.143 */115const CheckFile = ({ source }: { readonly source: CheckSource }) => {116 const [whole, setWhole] = useState(false);117 const lines = linesOf(source.text);118 const long = lines.length > CHECK_LINES;
11 unmodified lines
130 {lines.length} {lines.length === 1 ? "line" : "lines"}131 </span>132 </figcaption>133 <ClientFile163 // Each cut of the file is its own drawing.134 fallback={<NumberedLines text={shown} />}135 key={whole ? "whole" : "head"}136 path={source.path}137 sha={whole || !long ? source.sha : `${source.sha}:${CHECK_LINES}`}
42 unmodified lines
180 ))}181 </ul>182);183214/** The brief's sections, as prose; the want is the page's title. */184const Brief = ({ ask }: { readonly ask: Ask }) => {185 const { context, current, outOfScope, terms } = ask.brief;186187 const parts = [
27 unmodified lines
215 </Region>216 );217};218250/** Every answer judged, one row each, oldest first, each linking its verdict. */219const Answers = ({220 ask,221 now,222 rounds,
35 unmodified lines
258 </AppLink>259 </Region>260);261294/** The asks an ask outside a family still waits on, each linked. */262const WaitsOn = ({263 asks,264 project,265}: {
23 unmodified lines
289 </span>290 </p>291);292326/**327 * What a family's parent waits on, in the fan's terms: how many of its328 * children have yet to land, then the delete step; never a list of ids329 * (the fan draws each child).330 */293const FamilyWaits = ({294 finale,295 parent,296 project,
38 unmodified lines
335};336337export interface AskViewProps {338 readonly ask: Ask;377 /** The brief as the platform renders it for an agent, in Markdown. */339 readonly brief: string;340 readonly now: DateTime.Utc;380 /** Where the project is cloned from. */341 readonly platformUrl: string;382 /** Where each ask stands, from the project's events (`askStates`). */342 readonly states?: ReadonlyMap<AskId, AskProgress>;384 /** The family's parent, when the ask is a member of one. */343 readonly parent?: Ask | undefined;386 /** The verdict on its latest answer, to say at which stage a refusal came. */344 readonly verdict?: Verdict | undefined;388 /** The check's source, when it is a file the page could read. */345 readonly check?: CheckSource | undefined;390 /** The project's posture, once the list of projects has it. */346 readonly posture?: Posture | undefined;392 /** Who is reading, to tell the claimant the claim is theirs. */347 readonly viewer?: Handle | undefined;348}349396/** Where the ask stands, as its status line reads it. */350const subjectOf = (351 ask: Ask,352 states: ReadonlyMap<AskId, AskProgress>,353 verdict: Verdict | undefined,
10 unmodified lines
364 project: ask.project,365 };366 }367415 // A refusal says at which stage it came, which only the verdict holds.368 const lastRound = progress?.rounds.at(-1);369370 if (371 latest !== undefined &&
22 unmodified lines
394 takeable,395 };396};397446/** Where an ask stands for its page: what it still waits on, whether it can be taken, and its family. */398const standing = (399 ask: Ask,400 states: ReadonlyMap<AskId, AskProgress>,401 parent: Ask | undefined
13 unmodified lines
415 held: progress?.claimant !== undefined || ask.state === "claimed",416 progress,417 remaining,418 takeable: ask.state === "open" && remaining.length === 0,468 // A family member says what it waits on in the family's terms, and a469 // wait the latest outcome already names needs no second line.419 waitsOn:420 ask.parent === undefined &&421 remaining.length > 0 &&422 !(latest !== undefined && Outcome.isAnyOf(["WaitingOnParent"])(latest)),423 };424};425477/** The ask's facts: its state, how to take it or who holds it, its territory and check, its family, its project's posture. */426const AskFacts = ({427 ask,428 now,429 parent,
58 unmodified lines
488 </>489 );490};491544/** The line under the title: the kind, who asked (and mentors), and when it opened. */492const AskMeta = ({493 ask,494 now,495}: {
17 unmodified lines
513 ]}514 />515);516570/** The Markdown an agent reads, shown whole on demand, and its own address. */517const ForAgents = ({518 ask,519 brief,520}: {
80 unmodified lines
601 {waitsOn && family !== ask ? (602 <WaitsOn asks={remaining} project={ask.project} />603 ) : null}604 {family === undefined ? null : (659 // Below the shell's width the family sits under the head, as a fan.605 <div className="shell:hidden mt-4">606 <FamilyStrip607 expanded={false}608 parent={family}
32 unmodified lines
modified:apps/web/src/features/ask/fields.tsx-16 removed
1/**2 * Labelled values, in two forms:3 *4 * - `Definitions` and `Definition`: a definition list, each term in the5 * label's style over its value, side by side from the shell's width;6 * the form records and agents' pages use (the ledger, the env shape, the7 * policy, For agents).8 * - `Fields` and `Field`: the grid of ruled rows the pages not yet moved9 * still use; from `lg` two fields share a row.10 *11 * Values that are code (ids, paths, SHAs) wrap anywhere, so a phone never12 * scrolls sideways.13 */1import type { ReactNode } from "react";23export const Fields = ({4 children,
22 unmodified lines
27 <dd className="min-w-0 [overflow-wrap:anywhere]">{children}</dd>28 </div>29);3044/** A list of terms and their values: one ruled row each. */31export const Definitions = ({32 children,33 label,34}: {
4 unmodified lines
39 {children}40 </dl>41);4257/** One term over its value; beside it from the shell's width. */43export const Definition = ({44 children,45 term,46}: {
5 unmodified lines
52 <dd className="text-ui min-w-0 [overflow-wrap:anywhere]">{children}</dd>53 </div>54);5571/** A titled region of a page: a heading over its content, 32 px from the next. */56export const Region = ({57 children,58 id,59 title,
12 unmodified lines
modified:apps/web/src/features/ask/markdown.ts+3 added-43 removed
1/**2 * An ask as Markdown, for agents: a harness reads an ask with one plain3 * fetch, either with `Accept: text/markdown` on the ask's own URL or at the4 * same URL with `.md`. The request decides; no user-agent list does.5 *6 * The brief is the platform's: `showAsk` renders it once, and the web only7 * serves it, with the banner that names the web's indexes under its title. A refusal is8 * set the way `git push` printed it, from `@repo/protocol/render`9 * (AGENTS.md principle 3), then its next command.10 * Pure: a `Request` or an `Exit` in, a string or a `Response` out.11 */1import { indexBanner, underTitle } from "@repo/agent-kit/host-doc";2import { Brand } from "@repo/brand";3import type { Visibility } from "@repo/protocol/annotations";4import type { ProjectName } from "@repo/protocol/ids";
2 unmodified lines
7import { Array, Cause, Exit, Option, Schema } from "effect";89const MARKDOWN = "text/markdown; charset=utf-8";1022/** A contract's `Visibility`: a `public` one's answer may be cached for a minute, a `maintainers` one's never. */11export type ContractVisibility = ReturnType<typeof Visibility.defaultValue>;1225/** One range of an `Accept` header: `text/markdown;q=0.8`. */13interface MediaRange {14 readonly quality: number;15 readonly subtype: string;16 readonly type: string;17}1832/** A q-value as RFC 9110 writes it: 0 to 1, at most three decimals; anything else is no range. */19/** A q-value as RFC 9110 writes it: 0 to 1, at most three decimals. */20const QUALITY = /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/u;2122const rangesOf = (accept: string): readonly MediaRange[] =>23 accept.split(",").flatMap((entry) => {
9 unmodified lines
33 ? []34 : [{ quality: Number(quality), subtype, type }];35 });3650/** How closely `range` names `type/subtype`: 3 by name, 2 by `type/*`, 1 by `*\/*`, 0 not at all. */37const closeness = (range: MediaRange, type: string, subtype: string) => {38 if (range.type === type) {39 if (range.subtype === subtype) {40 return 3;
4 unmodified lines
4546 return range.type === "*" && range.subtype === "*" ? 1 : 0;47};4863/** The quality the closest range gives `type/subtype` (RFC 9110 §12.5.1), and how close it was. */49const preferenceFor = (50 ranges: readonly MediaRange[],51 type: string,52 subtype: string
11 unmodified lines
64 return best;65};6667/**83 * Whether the request asks for the ask as Markdown: it names `text/markdown`84 * itself, with a quality above zero and at least the quality it gives85 * `text/html`. A wildcard alone (`*\/*`, `text/*`, or no `Accept` at all)86 * gets the page, as a browser does.68 * A wildcard alone (`*\/*`, `text/*`, or no `Accept` at all) gets the page, as69 * a browser does.70 */71export const wantsMarkdown = (request: Request) => {72 const ranges = rangesOf(request.headers.get("accept") ?? "");73 const markdown = preferenceFor(ranges, "text", "markdown");
5 unmodified lines
79 markdown.quality >= html.quality80 );81};82100/** The longest run of backticks in `text`. */83const longestTicks = (text: string) =>84 Math.max(0, ...[...text.matchAll(/`+/gu)].map(([run]) => run.length));85104/** `text` as inline code, its delimiter longer than any backticks inside it. */86const inlineCode = (text: string) => {87 const ticks = longestTicks(text);88 const fence = "`".repeat(ticks + 1);8990 return ticks === 0 ? `${fence}${text}${fence}` : `${fence} ${text} ${fence}`;91};92112/**113 * Refusals as an agent reads them in Markdown: every refusal's `explain`114 * lines in one text block, verbatim (git's `remote:` lines, without the115 * prefix), then each distinct `next` command once, as its own paragraph.116 */93export const refusalsMarkdown = (94 refusals: Array.NonEmptyReadonlyArray<Refusal>95) => {96 const lines = explain(refusals);
19 unmodified lines
116 },117 status,118 });119144/** What a Markdown answer may be cached for, by its contract's visibility. */120const cacheFor = (visibility: ContractVisibility) =>121 visibility === "public" ? "public, max-age=60" : "private, no-store";122123const isRefusal = Schema.is(Refusal);124150/** What the web says when the platform gave neither the ask nor a refusal. */125const UNANSWERED = [126 "The platform did not answer, so the web cannot read this ask now. Ask again in a moment.",127 "",128].join("\n");129156/** Where the web's indexes are, for the banner under an ask's title. */130export interface AskIndex {131 readonly project: ProjectName;132 readonly webUrl: string;133}134162/**163 * How reading an ask ended, as the Markdown response: the brief (200,164 * cacheable as its contract's visibility allows), with the banner naming165 * `index`'s `llms.txt` files under its title; a refusal (404, its166 * Markdown, no banner); or no answer from the platform (502). Only a brief167 * is cached.168 */135export const askMarkdownResponse = <E>(136 result: Exit.Exit<{ readonly brief: string }, E>,137 visibility: ContractVisibility,138 index: AskIndex
12 unmodified lines
151 cacheFor(visibility)152 ),153 });154189/**190 * The answer to a path that can name no ask: a project's and an ask's names191 * are lowercase words joined by single dashes, so the platform is not asked.192 */155export const noAskAt = (path: string) =>156 markdown(157 [158 `No ask is at ${inlineCode(path)}: a project's and an ask's names are lowercase words joined by single dashes.`,
4 unmodified lines
163 404,164 "no-store"165 );166205/** Where an ask's Markdown lives: its page's URL with `.md`. */167export const markdownPath = (project: string, ask: string) =>168 `/${project}/asks/${ask}.md`;169209/** The `Link` header that names an ask page's Markdown as an alternate of it. */170export const markdownAlternate = (project: string, ask: string) =>171 `<${markdownPath(project, ask)}>; rel="alternate"; type="text/markdown"`;
modified:apps/web/src/features/ask/refused.tsx-20 removed
1/**2 * The page for an address that names no ask, or no answer: a 404 whose body3 * is the refusal the platform gave (`UnknownProject`, `UnknownAsk`), as4 * `git push` printed it, so a person reads what an agent reads in Markdown,5 * then the way onward: the project, when the address names one, and the6 * open asks. The refusals travel from the server in a not-found's data,7 * encoded as `Refusals`; `NoSuchAsk` decodes them where they arrive8 * (AGENTS.md principle 2).9 */1import { ProjectName } from "@repo/protocol/ids";2import { UnknownProject } from "@repo/protocol/refusal";3import type { Refusal } from "@repo/protocol/refusal";4import { Option, Schema } from "effect";
6 unmodified lines
11import { Refusals } from "../shared/refusals.ts";12import type { Crumb } from "../shared/shell/sections.ts";13import { Workspace } from "../shared/shell/workspace.tsx";1424/** What a 404 says when the address could name no ask, so no refusal came back. */15export const NAMES_ONLY =16 "Nothing is at this address: a project's and an ask's names are lowercase words joined by single dashes.";1718const LINK = "decoration-rule underline hover:decoration-current";1920const isUnknownProject = Schema.is(UnknownProject);2132/** Where to go from a page that names nothing: the project, then every open ask. */22const Onward = ({ project }: { readonly project: ProjectName | undefined }) => (23 <nav aria-label="Onward" className="text-ui flex flex-wrap gap-x-5 gap-y-1">24 {project === undefined ? null : (25 <AppLink className={LINK} to={projectPath(project)}>
12 unmodified lines
38 refusals,39 title,40}: {41 readonly nothing?: string;53 /** The project the address names, when it could be one. */42 readonly project?: ProjectName | undefined;43 readonly refusals: Array.NonEmptyReadonlyArray<Refusal> | undefined;44 readonly title: string;45}) => {58 // A project the platform says it lacks is no way onward.46 const known = refusals?.some(isUnknownProject) === true ? undefined : project;4761 // The trail goes as far as what exists: the project and its asks.48 const crumbs: readonly Crumb[] =49 known === undefined50 ? [{ label: "Asks", to: ASKS_PATH }, { label: title }]51 : [
17 unmodified lines
69const decodeRefusals = Schema.decodeUnknownOption(Refusals);7071const decodeProject = Schema.decodeUnknownOption(ProjectName);7287/**88 * A route's not-found page: the refusals its loader's not-found carried,89 * decoded; `nothing` when it carried none (the address could name no ask).90 * `project` is the address's own segment, linked only when a project could91 * have that name.92 */73export const NoSuchAsk = ({74 data,75 nothing = NAMES_ONLY,76 project,
12 unmodified lines
modified:apps/web/src/features/auth/session-slot.tsx+3 added-23 removed
1/**2 * The session, wherever the shell shows it (the rail's foot, the tablet's3 * top bar, the phone's More sheet): who is signed in, with sign-out, or a4 * link to sign in that comes back to this page. Signing in is only for5 * deciders (PRODUCT.md), so the slot stays quiet: the handle in ink, the6 * action in muted text.7 *8 * `SessionView` draws it from props; `SessionSlot` wires it to `whoAtom`9 * and the location. Sign-in is a server route, so its link is a plain10 * anchor that loads the document; the handle's page is the router's.11 */1import { useAtomValue } from "@effect/atom-react";2import type { Handle } from "@repo/protocol/ids";3import { useLocation } from "@tanstack/react-router";4import { Option } from "effect";
4 unmodified lines
9import { personPath } from "../shared/paths.ts";10import { whoAtom } from "./who.ts";1112/**24 * Where sign-in comes back to: the page the reader is on, without its25 * `#fragment`. The server never sees a fragment, so a link that carried one26 * would differ between the server's render and the browser's (`#L3`).13 * Without its `#fragment`: the server never sees one, so a link that carried it14 * would differ between the server's render and the browser's.15 */16export const hereOf = (location: {17 readonly pathname: string;18 readonly searchStr: string;19}) => `${location.pathname}${location.searchStr}`;2033/** Sign-in, coming back to `here` afterwards. */21export const signInHref = (here: string) =>22 `/auth/signin?${new URLSearchParams({ return: here }).toString()}`;2337/** The session's own action style: muted text, ink on hover. */24const ACTION =25 "text-muted-foreground hover:text-foreground text-ui inline-flex cursor-pointer items-center gap-1.5 no-underline transition-colors duration-150";2641/**42 * Where the slot sits: `rail` stacks the handle over its action in the43 * rail's foot and the More sheet; `bar` keeps both on the top bar's line.44 */27export type SessionLayout = "bar" | "rail";2829export const SessionView = ({30 handle,
22 unmodified lines
53 <p className="text-ui flex min-w-0 items-baseline gap-1">54 <span className="text-muted-foreground sr-only shrink-0">55 Signed in as56 </span>75 {/* A long handle is cut short for the line it shares; its title76 is whole. */}57 {/* A long handle is cut short; its title is whole. */}58 <AppLink59 className="decoration-rule hover:decoration-foreground max-w-[12rem] min-w-0 truncate font-medium underline-offset-4 hover:underline"60 title={signedIn}61 to={personPath(signedIn)}
26 unmodified lines
88 />89 );90};91111/** Whether someone is signed in, as far as this browser knows yet. */92export const useSignedIn = (): boolean => {93 const who = useAtomValue(whoAtom);9495 return AsyncResult.isSuccess(who) && Option.isSome(who.value);
1 unmodified line
modified:apps/web/src/features/auth/who.ts-12 removed
1/**2 * Who is signed in, as the browser learns it: the web's own `/auth/whoami`3 * (a same-origin server route that asks the platform with the session4 * cookie the page's JavaScript cannot read). It runs in the browser only:5 * on the server the slot renders as signed out, the page's first paint, and6 * the browser fills it in.7 *8 * Not a contract, so not an atom over `ContractsClient` (`src/surfaces.ts`):9 * the session is the web's, not the platform's.10 */1import { Handle } from "@repo/protocol/ids";2import { Effect, Option, Schema } from "effect";3import { FetchHttpClient, HttpClient, HttpClientResponse } from "effect/http";4import { Atom } from "effect/reactivity";516/** `/auth/whoami`'s answer: the handle signed in, or nothing. */6const Who = Schema.Struct({ handle: Schema.optionalKey(Handle) });719/** The handle signed in in this browser, once known; signed out on the server and on any failure. */8export const whoAtom = Atom.make(9 HttpClient.get("/auth/whoami").pipe(10 Effect.flatMap(HttpClientResponse.schemaBodyJson(Who)),11 Effect.map(({ handle }) => Option.fromUndefinedOr(handle)),
4 unmodified lines
modified:apps/web/src/features/decision/choices.tsx+2 added-22 removed
1/**2 * A decider's choices on one decision: one button per choice its subject3 * allows, each taken with one tap (there is no confirm and no undo, as the4 * platform has none), and under each, in a muted line, what the platform5 * then does. The default (what happens if nobody decides) is the outline6 * button, with the word "default" beside its name.7 *8 * Once taken, the record replaces the buttons: who chose what, when, the9 * note, and what it did, in the landed role only for a choice that made10 * something happen.11 */1import type { Choice, Decision } from "@repo/protocol/domain/decision";2import type { DateTime } from "effect";3import { Option } from "effect";4import { useId } from "react";
12 unmodified lines
17 takenWords,18 tookEffect,19} from "./subject.ts";2032/** Why a choice waits, and whether it waits on something that will come. */21export interface Held {22 readonly reason: string;23 readonly waiting: boolean;24}2538/** How the choices sit: two to a row (main, a phone's open row), or one under another (the inspector). */26export type ChoicesLayout = "grid" | "stack";2728const LAYOUTS = {29 grid: "grid grid-cols-2 gap-x-3 gap-y-3",
7 unmodified lines
37 layout = "grid",38 onChoose,39}: {40 readonly decision: Decision;54 /** A choice on its way: every button waits. */41 readonly busy: boolean;56 /** Why Accept waits, when it does (a proposal whose draft is not read yet). */42 readonly held?: Option.Option<Held>;43 readonly layout?: ChoicesLayout;44 readonly onChoose: (choice: Choice) => void;45}) => {
51 unmodified lines
97 </fieldset>98 );99};100116/** A choice taken, in one line: its word in its role, then what it did. */101export const TakenLine = ({102 choice,103 decision,104 stamp = false,105}: {106 readonly decision: Decision;107 readonly choice: Choice;124 /** Settle the mark once: the decider took it while the page was open. */108 readonly stamp?: boolean;109}) => {110 const effect = tookEffect(decision, choice);111
18 unmodified lines
130 </p>131 );132};133151/** The record of a taken decision: the line, then who, when and the note. */134export const DecisionRecord = ({135 decided,136 decision,137 now,
20 unmodified lines
158 )}159 </section>160);161180// Choices kept in sight while their decision is: on a phone, a bar fixed181// above the bottom bar (a bar that only stuck would stay below the screen182// while its decision starts low on the page), with main keeping room for183// it at its foot (`styles.css`); from a tablet's width, where they sit.162// Fixed, not sticky, on a phone: a bar that only stuck would stay below the163// screen while its decision starts low on the page.164export const stuckAboveBar = (node: ReactNode) => (165 <div166 className="border-rule bg-background tablet:static tablet:border-t-0 tablet:p-0 fixed inset-x-0 bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-[6] border-t px-4 py-2"167 data-choices-bar=""
4 unmodified lines
modified:apps/web/src/features/decision/decision-card.tsx+4 added-48 removed
1/**2 * One decision, as a decider takes it: when it expires and what happens if3 * nobody decides (the decision's own `default`), its evidence typed by its4 * subject, a note to keep with the choice, and the choices with what each5 * does. Once taken, the record replaces the choices. Today's inspector, a6 * phone's open row and the decision's own page each draw this one card.7 *8 * An `OpenProposal` holds Accept until its draft has been read, and while9 * the platform's agent is drafting it again: the draft is passed in, or10 * read from `showProposal` in the browser when it is not, so the server11 * never renders an Accept the browser might then hold.12 *13 * The subject's words follow GLOSSARY.md (ask, answer, landing, finish,14 * vouch). The default's word is the decision's `default` field as the15 * platform set it: the web keeps no table of defaults by subject.16 */1import type { Decide } from "@repo/protocol/contracts";2import { DecisionSubject } from "@repo/protocol/domain/decision";3import type { Choice, Decision } from "@repo/protocol/domain/decision";4import { DraftState } from "@repo/protocol/domain/proposal";
19 unmodified lines
24 describeDefault,25 describeSubject,26} from "./subject.ts";2744/** What a decider sends when they choose: the `decide` contract's payload, from its one schema. */28export type DecideInput = typeof Decide.payloadSchema.Type;2947/** Whether a decision opens a proposed ask. */30const opensAsk = DecisionSubject.isAnyOf(["OpenProposal"]);3150/** Whether a draft is still being written. */32const isDraftingNow = DraftState.isAnyOf(["Drafting"]);3353/**54 * Why Accept on a proposal waits, if it does: its draft not read yet, its55 * read failed, or the draft being written. Once read it may be accepted: a56 * ready draft, a want alone, or a failed round (which keeps an earlier57 * ready draft, or leaves the want alone).58 */34const acceptHeld = (read: DraftRead): Option.Option<Held> =>35 DraftRead.$match(read, {36 Read: ({ draft }) =>37 Option.exists(draft, isDraftingNow)
6 unmodified lines
44 : { reason: "Reading the draft…", waiting: true }45 ),46 });4773/** When it expires, and what happens if nobody decides. */48export const ExpiryLines = ({49 decision,50 now,51 soon,
27 unmodified lines
79 </p>80 </div>81);82109/** A note kept with the choice, behind a disclosure. */83const NoteField = ({84 note,85 onNote,86}: {
36 unmodified lines
123 readonly decision: Decision;124 readonly layout: ChoicesLayout;125}126154/** The choices on a proposal whose draft state was not passed: read from `showProposal`. */127/**128 * Read in the browser, so the server never renders an Accept the browser might129 * then hold.130 */131const ProposalChoices = ({132 proposal,133 ...props134}: ChoiceProps & { readonly proposal: ProposalId }) => {
9 unmodified lines
144 />145 );146};147172/**173 * What ends the card: the choices while the decision is open (a174 * proposal's held until its draft is read), the record once it is taken.175 */148const Ending = ({149 draft,150 now,151 stamp,
39 unmodified lines
191 />192 );193};194223/** How many files a finish's diff changes, when it carries one. */195export const finishFileCount = (decision: Decision): number | undefined =>196 Option.getOrUndefined(197 Option.map(patchOf(decision), (patch) => changedFiles(patch).length)198 );
14 unmodified lines
213}: {214 readonly decision: Decision;215 readonly now: DateTime.Utc;216 readonly onDecide: (input: DecideInput) => void;246 /** Whether it expires within the day (Today's `expiringSoon`). */217 readonly soon?: boolean;248 /** Whether a choice on it is on its way: its buttons wait. */218 readonly busy?: boolean;250 /** What a page shows after the evidence, before the note (a waiver's diff). */219 readonly children?: ReactNode;252 /**253 * Where the choices go: in place (the default), or handed to the page,254 * which puts them where they stay in sight (a phone's sticky bar).255 */220 readonly choices?: (node: ReactNode) => ReactNode;257 /** Whether it says when it expires and its default (off where the page says so already). */221 readonly expiry?: boolean;259 /** Whether a finish links to its own page, where its diff is (off on that page). */222 readonly finishLink?: boolean;223 readonly layout?: ChoicesLayout;262 /** Settle the record's mark once: the choice was taken while the page was open. */224 readonly stamp?: boolean;264 /**265 * For an `OpenProposal`, what has been read of the proposal's draft:266 * Accept waits until it is read, and while it is drafting. Read from267 * `showProposal` in the browser when not passed.268 */225 readonly draft?: DraftRead | undefined;226}) => {227 const [note, setNote] = useState("");228
46 unmodified lines
modified:apps/web/src/features/decision/decision-page.tsx-29 removed
1/**2 * One decision on its own page, every subject but a finish (which reads as3 * the code browser does, `features/finish/finish-view.tsx`). The title is4 * the subject in plain words; under it, when it expires, its default and5 * whose move it is. Main holds the evidence at the page's width (a6 * waiver's marker drawn at its line in the answer's diff, when the7 * decision carries the diff), a note, and the choices, each saying what8 * it does; on a phone the choices stay in a bar above the bottom bar.9 * The inspector holds the decision's own facts (its deciders, when it10 * opened and expires, its default), the ask or proposal it concerns, and,11 * for a posture change, the project's posture.12 *13 * Once taken, the record replaces the choices. Signed out, the page says14 * what a decision is and that its deciders take it on Today: no choices,15 * and nothing of its evidence.16 */1import { Brand } from "@repo/brand";2import type { Ask } from "@repo/protocol/domain/ask";3import { DecisionSubject } from "@repo/protocol/domain/decision";4import type { Decision } from "@repo/protocol/domain/decision";
33 unmodified lines
38const waives = DecisionSubject.isAnyOf(["Waiver"]);3940const finishes = DecisionSubject.isAnyOf(["Finish"]);4158/** No files: a decision that carries no diff. */42const NO_FILES: readonly PatchFile[] = [];4344const LINK = "decoration-rule underline hover:decoration-current";4563/** The trail to a decision: its project, Today, its id. */46const crumbsOf = (project: ProjectName, id: DecisionId) => [47 { label: project, to: `/${project}` },48 { label: "Today", to: "/today" },49 { label: id, mono: true },50];5170/** The decision's own facts: who decides it, when it opened and expires, its default. */52const DecisionFacts = ({53 decision,54 now,55 soon,
39 unmodified lines
95 </dl>96 </FactBlock>97);98118/** The ask a decision concerns: its want and its page. */99const AskFacts = ({ ask }: { readonly ask: Ask }) => (100 <FactBlock label="The ask">101 <p className="text-ui" data-said="">102 {ask.brief.want}
3 unmodified lines
106 </AppLink>107 </FactBlock>108);109130/** The proposal a decision would open: its want, who proposed it, its page. */110const ProposalFacts = ({ proposal }: { readonly proposal: Proposal }) => (111 <FactBlock label="The proposal">112 <p className="text-ui" data-said="">113 {proposal.want}
9 unmodified lines
123 </AppLink>124 </FactBlock>125);126148/** The waiver's marker drawn at its line, in the answer's diff of that file. */127export const WaiverDiff = ({128 decision,129 files,130}: {
27 unmodified lines
158 </section>159 );160};161184/** What a decision is, for a reader who does not decide it here. */162const ForAnyone = ({163 children,164 id,165 project,
22 unmodified lines
188export interface DecisionViewProps {189 readonly data: DecisionPageData;190 readonly onDecide: (input: DecideInput) => void;191 readonly busy?: boolean;215 /** The decision as the decider's choice left it, once taken here. */192 readonly taken?: Decision | undefined;217 /** The waiver's diff, parsed, when the decision carries one. */193 readonly files?: readonly PatchFile[];219 /** The page for a finish, when the decision is one (the route draws it whole). */194 readonly finish?: ReactNode;195 readonly here: string;222 /** What the reader's last choice came back with, when it failed: shown above the choices. */196 readonly failure?: ReactNode;197}198226/** A decision the reader may take, whole. */199const Found = ({200 busy,201 failure,202 files,
67 unmodified lines
270 </Workspace>271 );272};273302/** The page for a decision that cannot be shown whole, with why. */274const Apart = ({275 children,276 data,277}: {
72 unmodified lines
modified:apps/web/src/features/decision/evidence.tsx+3 added-32 removed
1import type { Evidence as Fact } from "@repo/protocol/domain/common";2// A decision's evidence, typed by what it is about: the commits a stray3// push moved between (each a link to its page), the proposal's draft and4// files, a ratchet's before and after, a waiver's marker at its line, a5// posture's from and to beside the ledger, the hosts a proxy may now reach,6// the item a stored value matched, the person a vouch admits, the answer a7// finish lands. Then whatever else the platform put on it, as label and8// value, the diff and the fork left to the finish.9//10// Every value that is code is mono; every link is the router's.2import { DecisionSubject } from "@repo/protocol/domain/decision";3import type { Decision } from "@repo/protocol/domain/decision";4import type { Posture } from "@repo/protocol/posture";5import { ArrowRight, FileDiff, FileText } from "lucide-react";
13 unmodified lines
1920const CODE = "text-mono font-mono [overflow-wrap:anywhere]";2122/**32 * Whether an evidence line holds a file: its label is a path (one word with33 * a slash or a dot, as the ask file under the config folder, or a check34 * at the root, `offset.test.ts`), where every other label is words.23 * A label that is a path: one word with a slash or a dot, where every other24 * label is words.25 */26const isFileFact = ({ label }: Fact) => /^\S*[./]\S*$/u.test(label);2728const opensAsk = DecisionSubject.isAnyOf(["OpenProposal"]);2940/** The files an `OpenProposal` decision holds, shown as code; none for any other subject. */30export const filesOf = (decision: Decision): readonly Fact[] =>31 opensAsk(decision.subject) ? decision.evidence.filter(isFileFact) : [];3244/** One fact: its label over (or beside) its value. */33const FactRow = ({34 children,35 label,36}: {37 readonly children: ReactNode;38 readonly label: string;39}) => (40 <div className="contents">53 {/* Sentence case, as every label on the page: the platform names some54 evidence in lower case ("answer"); the text stays the platform's. */}41 {/* Sentence case: the platform names some evidence in lower case. */}42 <dt className="text-label text-muted-foreground pt-0.5 first-letter:uppercase">43 {label}44 </dt>45 <dd className="text-ui mb-1.5 min-w-0 [overflow-wrap:anywhere] @lg:mb-0">
2 unmodified lines
48 </div>49);5051const FactList = ({ children }: { readonly children: ReactNode }) => (65 // Label beside value where the evidence has the width (main), label over66 // value where it has not (the inspector, a phone).52 <dl className="grid grid-cols-1 gap-x-4 gap-y-1.5 @lg:grid-cols-[minmax(7rem,auto)_1fr]">53 {children}54 </dl>55);5672/** A link to a page of the web, with its mark. */57const PageLink = ({58 children,59 icon: Icon,60 to,
10 unmodified lines
71 {children}72 </AppLink>73);7491/** A posture as a mark and its name, in its role. */75const PostureWord = ({ posture }: { readonly posture: Posture }) => (76 <span className="inline-flex items-center gap-1.5">77 <Mark look={POSTURE_MARKS[posture]} size="sm" />78 <code className={CODE}>{posture}</code>79 </span>80);8199/** From one value to another, the arrow hidden from a screen reader, which hears "to". */82const FromTo = ({83 from,84 to,85}: {
27 unmodified lines
113 {shortSha(sha)}114 </AppLink>115);116135/** The facts each subject carries in its own fields, typed. */117const SubjectFacts = ({ decision }: { readonly decision: Decision }) =>118 DecisionSubject.match(decision.subject, {119 Finish: ({ ask, head }) => (120 <FactList>
122 unmodified lines
243 </FactList>244 ),245 });246266/** A whole commit id in running evidence. */247const WHOLE_SHA = /\b[0-9a-f]{40}\b/u;248269/** `text` with each whole commit id cut to its first seven, whole in its title. */249const ShortShas = ({ text }: { readonly text: string }) =>250 text.split(/(?<sha>\b[0-9a-f]{40}\b)/u).map((part, index) =>251 WHOLE_SHA.test(part) ? (252 <code className={CODE} key={`${index}:${part}`} title={part}>
3 unmodified lines
256 part257 )258 );259281// The labels the subject's own facts already say (a waiver's escape, a282// ratchet's count), or the finish draws.260const SHOWN_ELSEWHERE: ReadonlySet<string> = new Set([261 PATCH_LABEL,262 FORK_LABEL,263 "escape",264 "ratchet",265]);266290/** The rest of what the platform put on the decision, as label and value. */267const OtherFacts = ({268 decision,269 files,270}: {
8 unmodified lines
279 <FactList>280 {facts.map(({ href, label, value }) => (281 <FactRow282 key={`${label}:${value}`}307 // Who pushed the answer, at which head: the subject's own row308 // is already the answer.283 label={label === "answer" ? "Pushed by" : label}284 >285 {href === undefined ? (286 <ShortShas text={value} />
7 unmodified lines
294 </FactList>295 );296};297324/** The way from a `Finish` decision to its answer's diff, with how many files it changes. */298export const FinishLink = ({299 decision,300 files,301}: {
8 unmodified lines
310 {files === undefined ? "" : ` (${files} ${files === 1 ? "file" : "files"})`}311 </PageLink>312);313341/** A decision's evidence: its subject's facts, the rest, and a proposal's files as code. */314export const DecisionEvidence = ({315 decision,316 heading = "h4",317}: {318 readonly decision: Decision;347 /** The heading level a proposal's file paths take. */319 readonly heading?: "h3" | "h4";320}) => {321 const files = filesOf(decision);322
15 unmodified lines
modified:apps/web/src/features/decision/read.ts+2 added-27 removed
1/**2 * What a decision's page reads, in a module with no view of its own: a3 * route's loader runs before its page's view loads, so the route reaches4 * these without carrying the page.5 *6 * The decision comes from the reader's Today in its project alone, read7 * with their own session: someone who decides nothing there gets why, and8 * no evidence. Beside it, what it concerns, each read on its own (one that9 * fails is left out): the ask, the proposal, the project's posture; for a10 * finish, the verdict on its head and, from the project's events, where11 * the answer's earlier rounds were refused and whether a newer head came.2 * Kept apart from the page's view: a route's loader runs before the view loads,3 * so the route reaches this without carrying the page.4 */5import { Client } from "@repo/protocol/contracts";6import { Verdict } from "@repo/protocol/domain/answer";7import { Ask } from "@repo/protocol/domain/ask";
10 unmodified lines
1819import { askStates } from "../shared/ask-progress.ts";20import { findDecision, readOfCause, TodayRead } from "../today/read.ts";2130/** A refusal from an answer's round that points at a line, as the page's loader sends it. */22export const Placed = Schema.Struct({23 line: Schema.Int,24 path: Schema.String,25 refusal: Refusal,26 round: Schema.Int,27});2838/** What the page read for its reader: the decision and what it concerns, or why there is none. */29export const DecisionRead = Schema.TaggedUnion({30 Found: {41 /** The ask it concerns, when it concerns one. */31 ask: Schema.optionalKey(Ask),32 decision: Decision,44 /** A head pushed to the answer after the one a finish names. */33 newerHead: Schema.optionalKey(CommitSha),46 /** Refusals from the answer's rounds that point at a line. */34 placed: Schema.Array(Placed),48 /** The project's posture, for a posture change. */35 posture: Schema.optionalKey(36 Schema.Struct({ label: Schema.String, posture: Posture })37 ),52 /** The proposal it would open, for an `OpenProposal`. */38 proposal: Schema.optionalKey(Proposal),39 soon: Schema.Boolean,55 /** The verdict on a finish's head. */40 verdict: Schema.optionalKey(Verdict),41 },42 NotOnToday: {},43 Refused: { refusal: Refusal },
4 unmodified lines
48export type DecisionRead = typeof DecisionRead.Type;4950export type FoundDecision = Extract<DecisionRead, { readonly _tag: "Found" }>;5168/** What a decision's loader sends: whose page, what it read, and when. */52export const DecisionPageData = Schema.Struct({53 decision: DecisionId,54 now: Schema.DateTimeUtcFromString,55 project: ProjectName,
1 unmodified line
57});5859export type DecisionPageData = typeof DecisionPageData.Type;6078/** The refusals among an outcome, when it refused. */61const refusalsOf = (outcome: Outcome): readonly Refusal[] =>62 Outcome.guards.Refused(outcome) ? outcome.refusals : [];6382/** Every refusal of an ask's rounds that points at a line, with the round it came from. */64const placedIn = (events: readonly ProjectEvent[], ask: AskId) =>65 (askStates(events).get(ask)?.rounds ?? []).flatMap(({ outcome }, index) =>66 refusalsOf(outcome).flatMap((refusal) =>67 refusal.at === undefined
8 unmodified lines
76 ]77 )78 );7999/** The head last pushed to `ask`, when it is not `head`. */80export const newerThan = (81 events: readonly ProjectEvent[],82 ask: AskId,83 head: CommitSha
2 unmodified lines
8687 return last === undefined || last === head ? undefined : last;88};89110/** The ask a subject concerns, when it concerns one. */90const askOf = DecisionSubject.match({91 Finish: ({ ask }) => Option.some(ask),92 OpenProposal: () => Option.none(),93 PostureChange: () => Option.none(),
4 unmodified lines
98 Vouch: () => Option.none(),99 Waiver: ({ ask }) => Option.some(ask),100});101123/** What a decision concerns, each read on its own: one that fails is left out. */102const concerning = (decision: Decision, soon: boolean) =>103 Effect.gen(function* () {104 const client = yield* Client;105 const { project, subject } = decision;
37 unmodified lines
143 Effect.orElseSucceed(() => Option.none())144 ),145 });146169 // A finish's rounds, from the project's events: where earlier rounds170 // were refused, and whether a newer head was pushed.147 const events = Option.isSome(finish)148 ? yield* Stream.runCollect(client.watch({ project, since: 0 })).pipe(149 Effect.map((all): readonly ProjectEvent[] => all),150 Effect.orElseSucceed((): readonly ProjectEvent[] => [])
33 unmodified lines
184 }),185 });186 });187212/** The decision for its page, and what it concerns, read with the reader's session. */188export const readDecision = (params: {189 readonly project: string;190 readonly decision: string;191}) =>
40 unmodified lines
modified:apps/web/src/features/decision/subject.ts+2 added-53 removed
1/**2 * What a decision is about and what each choice on it does, in words, with3 * no view of its own: Today's rows, the inspector, a decision's page and4 * its finish all say a subject the same way.5 *6 * - `describeSubject`: the subject as one plain sentence, the row's link.7 * - `allowedChoices`: the choices its deciders have, in its own words.8 * - `consequenceOf`: what the platform does once a choice is taken, one9 * line under each button, written from what the platform's code does for10 * that subject. Where a choice changes nothing anyone can see, the line11 * says so rather than promising something.12 *13 * Each table names every subject, so a new kind fails to compile until it14 * has its sentence, its choices and its lines.15 */1import { DecisionSubject } from "@repo/protocol/domain/decision";2import type { Choice, Decision } from "@repo/protocol/domain/decision";3import { DateTime, Match } from "effect";45const yesOrNo: readonly Choice[] = ["accept", "decline"];67/**23 * The choices a subject's deciders have: a stray push is adopted or24 * reverted, anything else accepted or declined. The platform reads `accept`25 * on a stray push as `adopt` too, but the page offers each subject its own26 * words only.8 * The platform reads `accept` on a stray push as `adopt` too, but the page9 * offers each subject its own words only.10 */11export const allowedChoices = DecisionSubject.match({12 Finish: () => yesOrNo,13 OpenProposal: () => yesOrNo,
7 unmodified lines
21});2223const short = (sha: string) => sha.slice(0, 7);2442/** A ref as people say it: `main` for `refs/heads/main`. */25export const refWords = (ref: string) => ref.replace(/^refs\/heads\//u, "");2645/** What a decision is about, in one plain sentence. */27export const describeSubject = DecisionSubject.match({28 Finish: ({ ask, head }) =>29 `Finish the passing answer to ${ask}, at ${short(head)}`,30 OpenProposal: ({ proposal }) => `Open the ask proposed in ${proposal}`,
11 unmodified lines
42 Waiver: ({ ask, at, marker, reason }) =>43 `Allow ${marker} at ${at.path}:${at.line} in the answer to ${ask}: ${reason}`,44});4565/** A subject's kind as a row's metadata names it. */46export const subjectKind = DecisionSubject.match({47 Finish: () => "finish",48 OpenProposal: () => "proposal",49 PostureChange: () => "posture change",
4 unmodified lines
54 Vouch: () => "vouch",55 Waiver: () => "waiver",56});5778/** What saying yes and saying no do, for one subject. */58interface Lines {59 readonly yes: string;60 readonly no: string;61}6284/** What the platform takes no step on: the choice is kept, and nothing else moves. */63const RECORDED =64 "Your choice is kept on the decision; the platform takes no other step on it.";6588/**89 * What each choice does, by subject, as the platform's code does it:90 *91 * - an accepted proposal opens its ask (its files land on main, decided by92 * the decider); a declined one closes;93 * - an accepted finish lands the answer at its head with the decider as94 * `Finished-by`; a declined one leaves it waiting;95 * - a waiver, a ratchet raise or a posture change holds an answer: yes lets96 * it go on with the decider as `Decided-by`, no refuses it with the97 * refusal the decision stood for;98 * - a stray push to main is adopted as a landing, or reverted by one, with99 * the decider as `Decided-by`; a push to another ref moves nothing;100 * - a vouch lands a line in the vouch file;101 * - a widened proxy or a stored value found in an answer is recorded, and102 * nothing else follows yet.103 */66const linesOf = (subject: DecisionSubject): Lines =>67 Match.value(subject).pipe(68 Match.tagsExhaustive({69 Finish: (): Lines => ({
34 unmodified lines
104 }),105 })106 );107146/** Whether a choice says yes, in any subject's words. */108const saysYes = {109 accept: true,110 adopt: true,111 decline: false,112 revert: false,113} as const satisfies Record<Choice, boolean>;114154/** What taking `choice` on `subject` does, in one line. */115export const consequenceOf = (116 subject: DecisionSubject,117 choice: Choice118): string => {
1 unmodified line
120121 return saysYes[choice] ? lines.yes : lines.no;122};123164/** Each choice as its button says it. */124export const choiceWords = {125 accept: "Accept",126 adopt: "Adopt",127 decline: "Decline",128 revert: "Revert",129} as const satisfies Record<Choice, string>;130172/** Each choice once taken. */131export const takenWords = {132 accept: "Accepted",133 adopt: "Adopted",134 decline: "Declined",135 revert: "Reverted",136} as const satisfies Record<Choice, string>;137180/**181 * Whether a taken choice made something happen: what lands, opens or is182 * put back is drawn in the landed role; a choice that leaves things as they183 * were is ink.184 */138export const tookEffect = (decision: Decision, choice: Choice): boolean =>139 saysYes[choice]140 ? consequenceOf(decision.subject, choice) !== RECORDED141 : DecisionSubject.guards.StrayPush(decision.subject) &&142 refWords(decision.subject.ref) === "main";143191/** An expiry as a decider reads it on any phone: weekday, date and time, in UTC. */144export const byWhen = (at: DateTime.Utc) =>145 `${DateTime.formatUtc(at, {146 day: "numeric",147 hour: "2-digit",
3 unmodified lines
151 month: "short",152 weekday: "short",153 })} UTC`;154203/** What happens when nobody decides in time: the decision's own default, and by when. */155export const describeDefault = (decision: Decision) =>156 `If nobody decides by ${byWhen(decision.expiresAt)}: ${decision.default}`;157207/** A decision's own page. */158export const decisionHref = (decision: Decision) =>159 `/${decision.project}/decisions/${decision.id}`;160211/** A decision's place in a Today that may hold several projects. */161export const decisionKey = ({ id, project }: Decision) => `${project}/${id}`;
modified:apps/web/src/features/docs/docs-view.tsx-10 removed
1/**2 * The docs on the web: the index, every page under Guides then Reference3 * with its summary, and one page, its Markdown under its title with the4 * pages listed in the inspector. Every word on them is `@repo/agent-kit`'s5 * (`docPages`); a view: pages in, markup out.6 */1import type { DocPage, DocPart } from "@repo/agent-kit/docs/index";23import { SiteMarkdown } from "../markdown/markdown.tsx";4import { AppLink } from "../shared/link.tsx";5import { docsPath } from "../shared/paths.ts";6import { Workspace } from "../shared/shell/workspace.tsx";7import { docsMarkdownPath } from "./head.ts";815/** Each part's heading, in the order the index shows them. */9const PARTS = [10 { part: "guide", title: "Guides" },11 { part: "reference", title: "Reference" },12] as const satisfies readonly { part: DocPart; title: string }[];1314const LINK =15 "decoration-rule hover:decoration-foreground underline underline-offset-4";1624/** Only the page itself is current. */17const EXACT = { exact: true, includeSearch: false } as const;1819export const DocsIndexView = ({20 pages,
25 unmodified lines
46 ))}47 </Workspace>48);4958/** The pages, for the inspector: the one being read is current. */50const Contents = ({ pages }: { readonly pages: readonly DocPage[] }) => (51 <nav aria-label="Docs">52 {PARTS.map(({ part, title }) => (53 <div className="mb-3" key={part}>
17 unmodified lines
71 ))}72 </nav>73);7484/** A page's Markdown past its title and summary, which the page head shows. */75const bodyOf = ({ markdown, summary, title }: DocPage) =>76 markdown.slice(`# ${title}\n\n${summary}\n\n`.length);7778export const DocsPageView = ({
27 unmodified lines
modified:apps/web/src/features/docs/head.ts+2 added-6 removed
1/**2 * What the docs' pages put in their head, in a module with no view of its3 * own: a route's `head` runs before its page's view loads, so the Markdown4 * renderer stays off every page's first load.2 * Kept apart from the view: a route's `head` runs before its page's view loads,3 * so the Markdown renderer stays off every page's first load.4 */5import type { DocEntry } from "@repo/agent-kit/docs/entries";67import { markdownAlternateLink } from "../front/markdown.ts";8import { pageHead } from "../shared/head.ts";9import { docsPath } from "../shared/paths.ts";1012/** Where a page's Markdown is. */11export const docsMarkdownPath = (slug: string) => `${docsPath(slug)}.md`;1215/** A page's head: its title, its summary, and its Markdown. */13export const docsHead = (page: DocEntry) => ({14 ...pageHead({ description: page.summary, title: page.title }),15 links: [markdownAlternateLink(docsMarkdownPath(page.slug))],16});1721/** The index's head. */18export const docsIndexHead = () =>19 pageHead({20 description: "Guides, and a reference read from the platform's schema.",21 title: "Docs",
1 unmodified line
modified:apps/web/src/features/env/env-page.tsx+2 added-43 removed
1/**2 * A project's env shape: every item its committed `.env.schema` declares,3 * parsed at the landed commit and never resolved (ADR 0009). The status4 * line counts the items and says who set the sensitive ones. Sensitive5 * items come first, each saying on its own line that it is sensitive and6 * who set its value and when (or that nobody has); then every item's type,7 * whether it is required, its `@proxy` hosts, tags, docs and description.8 * The inspector says where the schema was read and how a value is set.9 *10 * Never a value, and nothing that would take or show one: a value is set11 * only from a terminal (`setEnv` is RPC and CLI alone), so the page shows12 * that command line instead of a form. The placeholder unlanded code sees13 * is not shown either: it is not a value, but it reads like one.14 *15 * Props in, markup out: the route reads the env shape16 * (`src/client/env.ts`) and hands it here. (Lint keeps "shape" out of code17 * names, so the prop is the env schema's view: `schema`.)2 * Never a value, and nothing that would take or show one: `setEnv` is RPC and3 * CLI alone. Lint keeps "shape" out of code names, so the prop is `schema`.4 */5import { Brand } from "@repo/brand";6import type { EnvItem, EnvSchemaView } from "@repo/protocol/domain/env";7import type { ProjectName } from "@repo/protocol/ids";
12 unmodified lines
20import { AppLink } from "../shared/link.tsx";21import { Workspace } from "../shared/shell/workspace.tsx";22import { distanceInWords, When } from "../shared/time.tsx";2338/** Where varlock, whose `.env.schema` format this is, documents it. */24const VARLOCK = "https://varlock.dev";2526const LINK = "decoration-rule underline hover:decoration-current";27
5 unmodified lines
3334const plural = (count: number, one: string, many: string) =>35 `${count} ${count === 1 ? one : many}`;3652/**53 * When the env shape was read, at the latest: `now`, or the newest time a54 * value was set if that is later. The page keeps the `now` it was served55 * with while it reads the env shape again as values are set, and a value56 * that was set is never set in the future.57 */37const readAt = (schema: EnvSchemaView, now: DateTime.Utc) => {38 let latest = now;3940 for (const { value } of schema.items) {
4 unmodified lines
4546 return latest;47};4870/** The items, sensitive ones first; each kind in the schema's own order. */49const sensitiveFirst = (items: readonly EnvItem[]) => [50 ...items.filter(({ sensitive }) => sensitive),51 ...items.filter(({ sensitive }) => !sensitive),52];5376/** The newest value set among `items`, if any was. */54const newestSet = (items: readonly EnvItem[]) => {55 let newest: EnvItem["value"];5657 for (const { value } of items) {
8 unmodified lines
6667 return newest;68};6993/**94 * The sensitive items in words: "1 sensitive, set by ines-v 1 d ago",95 * "1 sensitive, not set", "3 sensitive: 2 set, latest by ines-v 1 d ago".96 */70const sensitiveWords = (items: readonly EnvItem[], now: DateTime.Utc) => {71 const sensitive = items.filter((item) => item.sensitive);72 const set = sensitive.filter(({ value }) => value !== undefined);73 const newest = newestSet(sensitive);
12 unmodified lines
86 ? `1 sensitive, set ${by}`87 : `${sensitive.length} sensitive: ${set.length} set, latest ${by}`;88};89117/** Whether `docs` is a web address, so a link to it can go nowhere else. */90const isWebAddress = (docs: string) => /^https?:\/\//iu.test(docs);9192const requiredWords = (required: EnvItem["required"]) => {93 if (required === "depends") {
2 unmodified lines
9697 return required ? "yes" : "no";98};99128/** The proxy's hosts, then what it is limited to: "sentry.io, only /api/**". */100const Proxy = ({101 proxy,102}: {103 readonly proxy: NonNullable<EnvItem["proxy"]>;
26 unmodified lines
130 ) : (131 <span className="[overflow-wrap:anywhere]">{docs}</span>132 );133163/** Who set a write-only value and when, or that nobody has; never the value. */134const Value = ({135 now,136 value,137}: {
8 unmodified lines
146 <When at={value.setAt} now={now} />147 </span>148 );149180/** The item's line: its key, then, for a sensitive one, the lock, the word and who set it. */150const ItemLine = ({151 item,152 now,153}: {
70 unmodified lines
224 </Definitions>225 </li>226);227259/** The caption that credits the format: "env shape: varlock's .env.schema format". */228const Caption = () => (229 <>230 env shape:{" "}231 <a className={LINK} href={VARLOCK} rel="noreferrer">
1 unmodified line
233 </a>234 </>235);236269/** One fact of where the schema was read, its label beside it. */237const Read = ({238 children,239 term,240}: {
7 unmodified lines
248 </dd>249 </div>250);251285/** How a decider sets a value: from a terminal, never here. */252const SetValueFacts = ({ project }: { readonly project: ProjectName }) => (253 <FactBlock label="Set a value">254 <p className="text-ui text-muted-foreground">255 A decider sets one from a terminal; nobody reads it back.
4 unmodified lines
260 />261 </FactBlock>262);263298/** The project's posture, once the list of projects has brought it. */264const PostureOf = ({265 posture,266 project,267}: {
53 unmodified lines
321 posture,322 schema,323}: {324 readonly now: DateTime.Utc;360 /** The project's posture, from the list of projects; it may come after the page. */325 readonly posture?: Posture | undefined;326 readonly schema: EnvSchemaView;327}) => {328 const { items } = schema;
23 unmodified lines
352 </Workspace>353 );354};355392/**393 * A project whose main has not landed yet: there is no landed394 * `.env.schema` to read, so there is no env shape, which is not the same as395 * no project.396 */356export const NothingLanded = ({357 project,358}: {359 readonly project: ProjectName;
8 unmodified lines
modified:apps/web/src/features/finish/annotation.tsx-11 removed
1/**2 * What a decider's diff marks under one of its lines: a refusal that3 * pointed there (in the rubric, its lines as `explain` printed them, the4 * round it came from), or a marker that waits on a decision (in ochre, the5 * marker and its reason). Compact, one block under the line, the same in6 * the server's plain diff and in the browser's drawing.7 */1import type { Refusal } from "@repo/protocol/refusal";2import { explain } from "@repo/protocol/render";3import { Hourglass, OctagonX, RotateCcw } from "lucide-react";412/** A refusal placed in a diff: its file and line, and the round it came from. */5export interface PlacedRefusal {6 readonly refusal: Refusal;7 readonly path: string;8 readonly line: number;17 /** The round it refused, counting from 1. */9 readonly round: number;10}1121/** A refusal under its line, as git printed it. */12export const RefusalNote = ({ placed }: { readonly placed: PlacedRefusal }) => {13 const [first = "", ...rest] = explain([placed.refusal]).filter(14 (line) => !line.startsWith(" at: ")15 );
31 unmodified lines
47 </div>48 );49};5061/** A marker that waits on a decider, under its line. */51export const MarkerNote = ({52 marker,53 reason,54}: {
18 unmodified lines
modified:apps/web/src/features/finish/files.ts-35 removed
1/**2 * The files a decision's diff changes, as its page draws them: parsed once3 * by the drawing's own parser (`@pierre/diffs`' `parsePatchFiles`), so the4 * server's plain text and the browser's drawing hold the same hunks; each5 * file's `+n −m`, its id for the read marks, and its part of the change.6 *7 * The order is a rule, never a model's: the ask's territory first, then8 * tests, then anything else, each part by path in the order a tree lists9 * them.10 *11 * A diff's lines are numbered from its hunk headers (a patch holds only12 * the hunks, not the whole files), so a refusal's `at` line finds the line13 * it names.14 *15 * No React and no DOM: the server's render and the browser's both read it.16 */1import { parsePatchFiles } from "@pierre/diffs";2import type { FileDiffMetadata } from "@pierre/diffs";3import type { ChangedFile } from "@repo/protocol/domain/code";4import { RepoPath } from "@repo/protocol/ids";
8 unmodified lines
13} from "../code/diff-model.ts";14import type { DrawnFile } from "../code/diff-model.ts";15import { fileBlocks, patchIdOf } from "./patch.ts";1633/** Which part of the change a file is in. */17export type Part = "territory" | "tests" | "other";1836/** A changed file as the finish page holds it. */19export interface PatchFile extends DrawnFile {20 readonly part: Part;39 /** This file's change, as an id: what a read mark is kept against. */21 readonly patchId: string;22}2324const STATUS = {
11 unmodified lines
36} as const satisfies Record<Part, number>;3738const decodePath = Schema.decodeUnknownOption(RepoPath);3959/** The part a path is in: the territory's, the tests', or the rest. */40export const partOf =41 (territory: readonly string[]) =>42 (path: string): Part => {43 if (isTestPath(path)) {
4 unmodified lines
48 ? "territory"49 : "other";50 };5172/** Whether a file's block holds no text lines to draw: git's binary notes. */52const isBinary = (block: string) =>53 /^(?:Binary files .* differ|GIT binary patch)$/mu.test(block);5476/**77 * The files `patch` changes, parsed and counted, territory first, then78 * tests, then the rest. `key` names the change, so the drawing caches each79 * file's highlighting once.80 */55export const patchFiles = (56 patch: string,57 territory: readonly string[],58 key: string
40 unmodified lines
99 treeOrder(a.file.path, b.file.path)100 );101};102129/** One numbered line of a patch, on its side. */103export interface PatchLine {104 readonly kind: "addition" | "context" | "deletion";132 /** Its number in the new file (context and additions) or the old one (deletions). */105 readonly number: number;106 readonly text: string;107}108137/** One row of a patch's unified view: a line, or the unchanged lines a hunk skips. */109export type PatchRow =110 | { readonly kind: "separator"; readonly lines: number }111 | PatchLine;112142/** A line as the diff stores it, without its line ending. */113const bare = (line: string | undefined) => (line ?? "").replace(/\r?\n$/u, "");114145/**146 * `diff` as unified rows, each line numbered from its hunk's header: a147 * context line and an addition by the new file, a deletion by the old.148 */115export const patchRows = (diff: FileDiffMetadata): readonly PatchRow[] => {116 const rows: PatchRow[] = [];117118 for (const hunk of diff.hunks) {
39 unmodified lines
158159 return rows;160};161196/** The new file's line numbers a diff draws: where an annotation at a line can sit. */162export const drawnLines = (diff: FileDiffMetadata): ReadonlySet<number> =>163 new Set(164 patchRows(diff).flatMap((row) =>165 row.kind === "addition" || row.kind === "context" ? [row.number] : []
2 unmodified lines
modified:apps/web/src/features/finish/finish-files-button.tsx+2 added-5 removed
1/**2 * The Files button on a finish's page below the shell's width, where the3 * rail is not drawn: it opens the changed files as a sheet from the left,4 * loaded on its first press. `import.meta.env.SSR` is `true` in the5 * Worker's build, so the Worker bundles none of the sheet.2 * `import.meta.env.SSR` is `true` in the Worker's build, so the Worker bundles3 * none of the sheet.4 */5import { FolderTree } from "lucide-react";6import { lazy, Suspense, useState } from "react";7
2 unmodified lines
10const Sheet = import.meta.env.SSR11 ? undefined12 : lazy(() => import("./finish-files-sheet.tsx"));1316/** The changed files below the shell's width: a Files button, and the list as a sheet, loaded on its first press. */14export const FinishFilesButton = () => {15 const [open, setOpen] = useState(false);1617 return (
20 unmodified lines
modified:apps/web/src/features/finish/finish-files-sheet.tsx-6 removed
1/**2 * A finish's changed files below the shell's width, as a sheet from the3 * left, loaded on the first press of Files (`finish-rail.tsx`). Choosing a4 * file moves the diff to it, and the sheet closes.5 */1import { Option } from "effect";23import { Sheet, SheetContent } from "../../components/ui/sheet.tsx";4import { FinishFiles, useFinish } from "./finish-rail-body.tsx";
12 unmodified lines
17 <SheetContent side="left" title="Changed files">18 <div19 className="flex h-full min-h-0 flex-col"20 onClick={(event) => {26 // A file chosen moves the diff to it: the sheet has done its work.21 if (22 event.target instanceof Element &&23 event.target.closest("a") !== null24 ) {
14 unmodified lines
modified:apps/web/src/features/finish/finish-files.tsx-11 removed
1/**2 * A finish's changed files as a list the rail (or, below the shell's3 * width, a sheet) holds: the ask's territory first, then tests, then the4 * rest, each a row with its change as a letter (A, M or D, in the diff's5 * tints), its path, its `+n −m`, whether this reader marked it read (a6 * muted check, the word for a screen reader) and whether a refusal pointed7 * into it (the refused cross). Choosing one scrolls the diff to it.8 */1import { Check, OctagonX } from "lucide-react";23import { diffAnchor } from "../code/paths.ts";4import { ChangeCounts } from "../code/plain-diff.tsx";
11 unmodified lines
16 territory: "In the territory",17 tests: "Tests",18} as const satisfies Record<Part, string>;1928/** A path as two parts: its name first, then its folder, muted, which gives way first. */20const PathWords = ({ path }: { readonly path: string }) => {21 const slash = path.lastIndexOf("/");2223 return (
15 unmodified lines
39 read,40 refused,41}: {42 readonly files: readonly PatchFile[];52 /** The page's own address, which each row adds its file's anchor to. */43 readonly href: string;44 readonly read: ReadonlySet<string>;45 readonly refused: ReadonlySet<string>;56 /** The file the diff stands at. */46 readonly current?: string | undefined;47}) => (48 <nav49 aria-label="Changed files"
75 unmodified lines
modified:apps/web/src/features/finish/finish-plain.tsx-16 removed
1/**2 * A decider's diff as plain text: what the server sends, and what a reader3 * sees until the browser has drawn the highlighted diff over it (or, on a4 * phone, the one file being read). It takes the code browser's measures5 * (a 44 px sticky file header, 13 px code on 20 px lines, the gutter, the6 * sign column, the diff's own tints), so the drawing arrives in place.7 *8 * Under a line it draws what the page puts there (a refusal that pointed9 * at it, a marker waiting on a decision); a note whose line the diff does10 * not show sits at the top of its file, saying which line it means.11 */1import { Option } from "effect";2import type { ReactNode } from "react";34import { diffAnchor } from "../code/paths.ts";
2 unmodified lines
7import type { PatchFile, PatchLine } from "./files.ts";8import { MarkRead } from "./mark-read.tsx";9import type { MarkedFile } from "./read-marks.ts";1022/** Something drawn under one line of one file. */11export interface LineNote {12 readonly path: string;13 readonly line: number;14 readonly node: ReactNode;
18 unmodified lines
3334const GUTTER =35 "border-background min-w-[calc(6ch+2px)] border-r-2 pr-[1ch] pl-[2ch] text-right tabular-nums select-none";3649/** The notes on one file: under a line it draws, and those it does not. */37const notesFor = (file: PatchFile, notes: readonly LineNote[]) => {38 const mine = notes.filter(({ path }) => path === file.file.path);3940 const shown = Option.match(file.diff, {
7 unmodified lines
48 elsewhere: mine.filter(({ line }) => !shown.has(line)),49 };50};5165/** One file's lines, with its notes under theirs. */52const Lines = ({53 file,54 notes,55}: {
69 unmodified lines
125 refused,126}: {127 readonly files: readonly PatchFile[];128 readonly notes: readonly LineNote[];143 /** The files this reader marked read; each header offers "Mark read" when given. */129 readonly read?: ReadonlySet<string> | undefined;130 readonly onMark?: ((file: MarkedFile, read: boolean) => void) | undefined;146 /** The files a refusal points into, marked in their headers. */131 readonly refused?: ReadonlySet<string> | undefined;132 readonly folded?: ReadonlySet<string> | undefined;133 readonly onFold?: ((path: string, folded: boolean) => void) | undefined;134}) => (
59 unmodified lines
modified:apps/web/src/features/finish/finish-rail-body.tsx-12 removed
1/**2 * A finish's changed files, for the rail (`finish-rail.tsx`, which loads3 * this in the browser) and, below the shell's width, a sheet behind a4 * Files button in the diff's toolbar: territory first, each with its5 * change, its counts, this reader's read mark and the refused cross.6 *7 * Both read the page's own loader data (its match), so the list and the8 * diff come from one read, and the read marks from one store.9 */1import { DecisionSubject } from "@repo/protocol/domain/decision";2import { useLocation, useMatch } from "@tanstack/react-router";3import { Option, Schema } from "effect";4import { useMemo } from "react";
6 unmodified lines
11import { marksKey, useReadMarks } from "./read-marks.ts";1213const decode = Schema.decodeUnknownOption(DecisionPageData);1424/** The finish on the page, its files in order; none for any other page. */15export const useFinish = () => {16 const data: unknown = useMatch({17 from: "/$owner/$project/decisions/$decision",18 select: (match) => match.loaderData,
31 unmodified lines
50};5152export type Finish = Option.Option.Value<ReturnType<typeof useFinish>>;5364/** The finish's files, with this reader's marks and the file the diff stands at. */54export const FinishFiles = ({ finish }: { readonly finish: Finish }) => {55 const marked = useMemo(56 () =>57 finish.files.map(({ file, patchId }) => ({ patchId, path: file.path })),
30 unmodified lines
88 </>89 );90};91103/** The finish's changed files, in the rail's slot. */92export const FinishRailFiles = () =>93 Option.match(useFinish(), {94 onNone: () => null,95 onSome: (found) => <FinishFiles finish={found} />,
4 unmodified lines
modified:apps/web/src/features/finish/finish-rail.tsx+2 added-9 removed
1/**2 * The rail of a decision's page. A route's `staticData` loads with every3 * page, so this module stays light: it tells a finish from any other4 * decision by the shape of the page's data alone, holds the way back to5 * Today and to who decides for any other, and for a finish loads its6 * changed files in the browser7 * (`finish-rail-body.tsx`), with the list's place held until they come.2 * A route's `staticData` loads with every page, so this module stays light and3 * loads a finish's files in the browser.4 */5import { ClientOnly, useMatch } from "@tanstack/react-router";6import { Option, Schema } from "effect";7import { lazy, Suspense } from "react";89import { AppLink } from "../shared/link.tsx";10import { RailSlot } from "../shared/shell/rail-slot.tsx";1116/** A finish's page data, by its shape: found, and about a finish. */12const FinishPageData = Schema.Struct({13 read: Schema.TaggedStruct("Found", {14 decision: Schema.Struct({15 subject: Schema.TaggedStruct("Finish", {}),
2 unmodified lines
18});1920const isFinishPage = Schema.decodeUnknownOption(FinishPageData);2127/** A row of the slot, as the rail draws its rows. */22const ROW =23 "text-ui text-foreground hover:bg-surface mx-2 flex h-8 min-w-0 items-center px-2 no-underline transition-colors duration-[120ms] focus-visible:outline-offset-[-2px]";2425const Body = import.meta.env.SSR26 ? undefined27 : lazy(() => import("./finish-rail-body.tsx"));2835/** The list's place: its count line's height, until the list is drawn. */29const Placeholder = () => (30 <div aria-hidden="true" className="border-rule h-10 shrink-0 border-b" />31);32
43 unmodified lines
modified:apps/web/src/features/finish/finish-view.tsx+1 added-50 removed
1/**2 * A `Finish` decision's page: the one page where a decider reads an3 * answer's diff, laid out as the code browser is. The changed files sit in4 * the rail (territory first, then tests, then the rest); the diff fills5 * main, file by file under sticky headers, each with a "Mark read" button,6 * and a refusal from an earlier round sits under the line it pointed at.7 * The want, the verdict, the choices and the three lines that finish it8 * from a clone sit in the inspector from 1440 px; below that, the choices9 * stay in a bar at the foot of the diff. On a phone the page reads the10 * want, the verdict and the choices first, then the diff one file at a11 * time.12 *13 * The read marks are this browser's alone (`read-marks.ts`). A head pushed14 * to the answer while the page is open says so above the diff, and the15 * diff stays as it was until the reader reloads it.16 *17 * What the page reads from the decision's evidence: `patch`, the answer's18 * unified diff, and `fork`, the name of the answer's fork19 * (`<key>--<ask>--<handle>`), where a finish fetches the head and pushes20 * its commits. Without a patch the page shows the lines and no diff;21 * without a fork it names the fork by the claim fork's pattern and leaves22 * the answerer's handle for the decider to fill in. The web never calls23 * `finish` itself.24 */1/** The web never calls `finish` itself. */2import { Brand } from "@repo/brand";3import type { Verdict } from "@repo/protocol/domain/answer";4import type { Ask } from "@repo/protocol/domain/ask";5import type { ChangedFile } from "@repo/protocol/domain/code";
40 unmodified lines
46export type { FinishDecision } from "./patch.ts";4748const LINK = "decoration-rule underline hover:decoration-current";4973/** Where the answer's head lives: its fork's git URL on the platform. */50const remoteOf = (decision: FinishDecision, platformUrl: string) =>51 Arr.findFirst(decision.evidence, ({ label }) => label === FORK_LABEL).pipe(52 Option.map(53 ({ href, value }) => href ?? `${platformUrl}/${value.trim()}.git`
3 unmodified lines
57 `${platformUrl}/${decision.project}--${decision.subject.ask}--<answerer>.git`58 )59 );6085/** The three lines that take the answer's head into a clone, put the decider's commits on it, and finish it. */61export const finishLines = (62 decision: FinishDecision,63 platformUrl: string,64 verdict: Verdict | undefined
17 unmodified lines
82 },83 ] as const;84};85111/** The three finish lines, numbered, each under what it does. */86const FinishLines = ({87 decision,88 platformUrl,89 verdict,
18 unmodified lines
108 </p>109 </FactBlock>110);111138/** What the ask wants, in one paragraph, and the way to it. */112const WantFacts = ({ ask }: { readonly ask: Ask }) => (113 <FactBlock label="The ask wants">114 <p className="text-want font-normal" data-said="">115 {ask.brief.want}
3 unmodified lines
119 </AppLink>120 </FactBlock>121);122150/** The verdict on the head: its line, and the gate's stages in a strip. */123const VerdictFacts = ({ verdict }: { readonly verdict: Verdict }) => (124 <FactBlock label={`Verdict at ${shortSha(verdict.head)}`}>125 <div className="flex flex-col gap-2" data-outcome={verdict.outcome._tag}>126 <StatusLine
17 unmodified lines
144 readonly now: DateTime.Utc;145 readonly onDecide: (input: DecideInput) => void;146 readonly busy?: boolean;147 readonly soon?: boolean;176 /** The diff's files, territory first (`patchFiles`); none without a patch. */148 readonly files: readonly PatchFile[];178 /** Refusals from the answer's rounds that point into its files. */149 readonly placed?: readonly PlacedRefusal[];180 /** The head last pushed to the answer, when it is not the one decided on. */150 readonly newerHead?: CommitSha | undefined;182 /** The files this reader marked read. */151 readonly read?: ReadonlySet<string>;152 readonly onMark?: (file: MarkedFile, read: boolean) => void;153 readonly split?: boolean;154 readonly onSplit?: (split: boolean) => void;155 readonly folded?: ReadonlySet<string> | undefined;156 readonly onFold?: (path: string, folded: boolean) => void;157 readonly onFoldAll?: (folded: boolean) => void;190 /** Draw the diff in the browser over the plain text (the page does; a test reads the plain text). */158 readonly draw?: boolean;192 /** The Files button, below the shell's width. */159 readonly filesButton?: ReactNode;194 /** Settle the record's mark: the choice was taken while the page was open. */160 readonly stamp?: boolean;196 /** What the reader's last choice came back with, when it failed. */161 readonly failure?: ReactNode;162}163164const NO_FILES: ReadonlySet<string> = new Set();165166const NO_REFUSALS: readonly PlacedRefusal[] = [];167204/** No whole files: a decision's diff comes parsed from its patch. */168const NO_CHANGED: readonly ChangedFile[] = [];169207/** A file's state in its header: a refusal pointed into it, or this reader read it. */170const slotOf = (171 path: string,172 header: ReactNode,173 refused: ReadonlySet<string>,
5 unmodified lines
179180 return read.has(path) ? { header, path, status: "read" } : { header, path };181};182221/** The refusals among `placed`, as notes under their lines. */183const refusalNotes = (placed: readonly PlacedRefusal[]): readonly LineNote[] =>184 placed.map((each) => ({185 line: each.line,186 node: <RefusalNote placed={each} />,187 path: each.path,188 }));189229/** A head pushed after the one the decision names: said above the diff, never swapped in. */190const NewerHead = ({ head }: { readonly head: CommitSha }) => (191 <output192 className={`border-rule bg-surface flex flex-wrap items-center gap-x-3 gap-y-2 border-b py-2 ${GUTTER}`}193 data-newer-head={head}
15 unmodified lines
209 </Button>210 </output>211);212253/**254 * The choices kept at the foot of the diff below 1440 px, where the255 * inspector is a sheet; once taken, the choice's record in their place.256 */213const DecisionBar = ({214 busy,215 decision,216 now,
42 unmodified lines
259 )}260 </section>261);262307/** A choice that came back failed: said where the reader looks next, and politely. */263const Failure = ({264 children,265 className = "",266}: {
4 unmodified lines
271 {children}272 </div>273);274320/** On a phone: the diff one file at a time, with the way to the next and the one before. */275const OneFileAtATime = ({276 files,277 notes,278 onMark,
66 unmodified lines
345 </section>346 );347};348395/** The diff from a tablet's width: plain from the server, drawn over in the browser, the choices at its foot. */349const WideDiff = ({350 busy,351 decision,352 draw,
93 unmodified lines
446 </div>447 );448};449497/** On a phone: the want, the verdict and the choices first, then the diff a file at a time. */450const PhoneFinish = ({451 ask,452 busy,453 decision,
67 unmodified lines
521 )}522 </div>523);524573/** The inspector's facts: the want, the verdict, the decision, the lines that finish it, the diff's stats. */525const FinishFacts = ({526 ask,527 busy,528 decision,
138 unmodified lines
modified:apps/web/src/features/finish/mark-read.tsx-6 removed
1/**2 * A changed file's "Mark read" button, in its header: the word in sight3 * (never an icon alone), pressed once read, and the file's path for a4 * screen reader. A mark is this reader's alone (`read-marks.ts`).5 */1import { Check } from "lucide-react";23import type { PatchFile } from "./files.ts";4import type { MarkedFile } from "./read-marks.ts";511/** A file's "Mark read" button: its word in sight, and what it marks for a screen reader. */6export const MarkRead = ({7 file,8 onMark,9 read,
24 unmodified lines
modified:apps/web/src/features/finish/patch.ts+4 added-29 removed
1/**2 * The answer's diff, where a `Finish` decision carries it: the evidence3 * entry labelled `patch`, a unified diff (`git diff <base> <head>`). No other4 * decision carries one (`Decision.evidence` holds no diff unless5 * the kind allows a finish), and the web never fetches one another way.6 */1import { DecisionSubject } from "@repo/protocol/domain/decision";2import type { Decision } from "@repo/protocol/domain/decision";3import { Array as Arr, Option } from "effect";411/** The evidence label a `Finish` decision's diff travels under. */5export const PATCH_LABEL = "patch";614/** The evidence label naming the answer's fork, the repo a finish fetches from and pushes to. */7export const FORK_LABEL = "fork";817/** A decision whose subject is a finish. */9export type FinishDecision = Decision & {10 readonly subject: Extract<DecisionSubject, { readonly _tag: "Finish" }>;11};1213const finishes = DecisionSubject.isAnyOf(["Finish"]);1424/** Whether a decision is a finish: the one subject whose page shows a diff. */15export const isFinishDecision = (16 decision: Decision17): decision is FinishDecision => finishes(decision.subject);1829/** The diff a `Finish` decision carries, if it carries one; never another subject's. */19export const patchOf = (decision: Decision): Option.Option<string> =>20 isFinishDecision(decision)21 ? Option.map(22 Arr.findFirst(decision.evidence, ({ label }) => label === PATCH_LABEL),23 ({ value }) => value24 ).pipe(Option.filter((patch) => patch.trim().length > 0))25 : Option.none();2638// git ends a `---`/`+++` line with a tab when its path holds a space, and39// `diff -u` puts its timestamp after one: the path stops at the tab.27// git ends a `---`/`+++` line with a tab when its path holds a space, and `diff28// -u` puts its timestamp after one: the path stops at the tab.29const NEW_FILE = /^\+\+\+ (?:b\/)?(?<path>[^\t]+)(?:\t.*)?$/u;3031const OLD_FILE = /^--- (?:a\/)?(?<path>[^\t]+)(?:\t.*)?$/u;3233const RENAMED = /^rename to (?<path>.+)$/u;3435const HEADER = /^diff --git a\/.+ b\/(?<path>.+)$/u;3648/** One file's block of a unified diff: the path it ends up at (or the path it leaves). */37const pathOf = (block: readonly string[]): Option.Option<string> => {38 const first = (pattern: RegExp) =>39 Arr.findFirst(block, (line) => pattern.test(line)).pipe(40 Option.flatMap((line) =>
13 unmodified lines
54 Option.orElse(() => first(HEADER))55 );56};5770/** The text of each file's block of a unified diff, by the path it ends up at. */58export const fileBlocks = (patch: string): ReadonlyMap<string, string> => {59 const lines = patch.split("\n");60 const gitHeaders = lines.some((line) => HEADER.test(line));61
20 unmodified lines
82 )83 );84};8599/**100 * The files a unified diff changes, in its order: each `diff --git` block's101 * new path (its old path when the file is deleted). A diff without git's102 * headers counts as one block per `---`/`+++` pair.103 */86export const changedFiles = (patch: string): readonly string[] => [87 ...fileBlocks(patch).keys(),88];8990/**109 * A short, stable id for one file's change: a polynomial hash over its110 * block of the diff, kept under a 32-bit prime. A new head that changes111 * the file changes its id, so whatever was kept against the old one no112 * longer matches.91 * A new head that changes the file changes its id, so a mark kept against the92 * old one no longer matches.93 */94export const patchIdOf = (text: string): string => {95 let hash = 7;96
5 unmodified lines
102};103104const waives = DecisionSubject.isAnyOf(["Waiver"]);105126/**127 * The answer's diff a `Waiver` decision carries, when it carries one under128 * the same `patch` label a finish uses: the page draws the marker's file129 * from it, with the marker at its line.130 */106export const waiverPatchOf = (decision: Decision): Option.Option<string> =>107 waives(decision.subject)108 ? Option.map(109 Arr.findFirst(decision.evidence, ({ label }) => label === PATCH_LABEL),
3 unmodified lines
modified:apps/web/src/features/finish/read-marks.ts+3 added-25 removed
1/**2 * Which of a finish's files its reader has marked read: kept in this3 * browser alone, never sent anywhere, and about files, never a person. A4 * mark is kept against the decision, the file and that file's change (its5 * patch id), and the whole set against the answer's head: a new head6 * pushed to the answer clears them, and a file whose change differs reads7 * unread.8 *9 * The browser's storage may be missing, full or refused (a private window);10 * every read and write is tried, and a refused one keeps nothing, so the11 * page works the same with no marks.12 *13 * The rail and the diff both show the marks; a change made in one is told14 * to the other with an event on the window.2 * Kept in this browser alone, never sent anywhere. Storage may be missing, full3 * or refused (a private window), so every read and write is tried and a refused4 * one keeps nothing.5 */6import { Option, Result, Schema } from "effect";7import { useCallback, useEffect, useState } from "react";819/** What one decision's marks are kept as. */9const Kept = Schema.Struct({10 head: Schema.String,11 read: Schema.Record(Schema.String, Schema.String),12});1314const decodeKept = Schema.decodeUnknownOption(Schema.fromJsonString(Kept));1527/** Where one decision's marks are kept. */16export const marksKey = (project: string, decision: string) =>17 `finish.read:${project}/${decision}`;1831/** The event a change to the marks is told by. */19const CHANGED = "finish-read-marks";2034/** A file and its change, as a mark is kept against it. */21export interface MarkedFile {22 readonly path: string;23 readonly patchId: string;24}2540/** The paths marked read, at `head`, whose change is still the one marked. */26export const readMarks = (27 storage: Storage | undefined,28 key: string,29 head: string,
16 unmodified lines
46 : new Set(),47 });48};4965/** Mark `file` read or unread at `head`; marks kept at another head are dropped. A refused write keeps nothing. */50export const writeMark = (51 storage: Storage | undefined,52 key: string,53 head: string,
17 unmodified lines
7172 Result.try(() => storage?.setItem(key, JSON.stringify({ head, read: next })));73};7491/** The browser's storage, when there is one this page may use. */75const browserStorage = (): Storage | undefined =>76 Result.getOrUndefined(Result.try(() => globalThis.localStorage));7795/**96 * The marks on `files` at `head`, read once the page runs (the server97 * draws none), and the way to set one. Every view of the same decision98 * hears a change made in another.99 */78export const useReadMarks = (79 key: string,80 head: string,81 files: readonly MarkedFile[],
27 unmodified lines
modified:apps/web/src/features/front/facts.tsx+1 added-30 removed
1/**2 * The facts a list of asks shows beside it: with nothing selected on the3 * front page, where to start and every project with its posture; with an4 * ask selected (the front page and a project's home alike), that ask's5 * state, how to take it, where it may change things, its family and its6 * project's posture, and the way to its page.7 *8 * Only what the list read is needed to draw them; what the full ask adds9 * (its territory's paths, its check, its mentor) fills in once the browser10 * has read it, in a block of the same size.11 */1import { installCommand } from "@repo/agent-kit/install";2import { Brand } from "@repo/brand";3import type { Ask, AskListing } from "@repo/protocol/domain/ask";4import type { ProjectListing } from "@repo/protocol/domain/front-page";
16 unmodified lines
21import { StatusLine } from "../shared/status-line.tsx";2223const LINK = "decoration-rule underline hover:decoration-current";2436/** One numbered step: what it does, then its command. */25export const Step = ({26 command,27 label,28}: {
5 unmodified lines
34 <CommandLine command={command} numbered />35 </div>36);3750/** A link onward, at a block's foot. */38export const Onward = ({39 children,40 to,41}: {
8 unmodified lines
50 <ArrowRight aria-hidden="true" className="size-3.5" strokeWidth={1.75} />51 </AppLink>52);5367/** Where an agent reads the same thing: a server route, so a plain link. */54/** A server route, so a plain link. */55export const ForAgents = ({ href }: { readonly href: string }) => (56 <p className="text-ui text-muted-foreground border-rule border-t pt-3 first:border-t-0">57 For agents:{" "}58 <a className={`text-foreground text-mono font-mono ${LINK}`} href={href}>
1 unmodified line
60 </a>61 </p>62);6377/** The three ways in from the front page: the CLI, the asks it lists, a claim. */64export const StartHere = ({ webUrl }: { readonly webUrl: string }) => (65 <FactBlock label="Take an ask">66 <Step command={installCommand(webUrl)} label="Install the command line" />67 <Step command={`${Brand.cli} front`} label="List every open ask" />
4 unmodified lines
72 <ForAgents href="/llms.txt" />73 </FactBlock>74);7590/** A count and its noun: "1 open ask", "7 open asks". */76export const plural = (count: number, one: string, many: string) =>77 `${count} ${count === 1 ? one : many}`;7894/**95 * Every project the platform lists, by its open asks; bars until the list96 * arrives. Each project's posture is its group header's to say, once.97 */79export const ProjectsFacts = ({80 projects,81}: {82 readonly projects: readonly ProjectListing[] | undefined;
23 unmodified lines
106 </ul>107 </FactBlock>108 );109129/** Who may take an ask, from what its listing says (the full ask adds the mentor). */110const whoMayTake = (111 listing: AskListing,112 project: ProjectName,113 full: Ask | undefined
8 unmodified lines
122 ? "Held for people, not agents"123 : `Anyone vouched in ${project}, or with a record in its area`;124};125146/** A family the selected ask belongs to, as the page knows it. */126export interface SelectedFamily {127 readonly parent: Ask;128 readonly finale: AskId;129 readonly states: ReadonlyMap<AskId, AskProgress>;130}131153/** The selected ask's project posture, in the platform's words. */132export interface SelectedPosture {133 readonly label: string;134 readonly posture: Posture;135}136159/**160 * The selected ask: its state, how to take it (the claim numbered first),161 * where it may change things and what judges it, its family, its project's162 * posture, and its page.163 */137export const SelectedAskFacts = ({138 family,139 full,140 listing,
4 unmodified lines
145 takeable,146}: {147 readonly listing: AskListing;148 readonly project: ProjectName;176 /** Whether the viewer may take it (the front page knows); open and unheld when not known. */149 readonly takeable: boolean;178 /** The full ask, once the browser has read it. */150 readonly full: Ask | undefined;151 readonly progress: AskProgress | undefined;152 readonly family: SelectedFamily | undefined;153 readonly posture: SelectedPosture | undefined;
74 unmodified lines
modified:apps/web/src/features/front/families.ts+3 added-25 removed
1// Which listed asks form a family, read from the names a migrate ask's split2// gives its members: the platform opens a child per module as3// `<parent>-<module>` and a delete child as `<parent>-delete`, and the4// parent waits on all of them. A listing names no parent (the full ask does,5// one read away), so a family is read from what the list holds: an ask that6// waits on an ask named after it is a family's parent, and its members are7// the listed asks it waits on, and its delete child.8//9// An ask that waits on another not named after it (one fix after another)10// is no family: it stays a row of its own that reads as waiting.1// A listing names no parent, so a family is read from names: a split opens2// `<parent>-<module>` children and a `<parent>-delete` child, and the parent3// waits on all of them.4import type { AskListing } from "@repo/protocol/domain/ask";5import { AskId } from "@repo/protocol/ids";614/** One family, as a list holds it. */7export interface ListedFamily {8 readonly parent: AskId;17 /** Its members the list holds, in the list's order: the children still open, and the delete child. */9 readonly members: readonly AskId[];19 /** The delete child, which waits on every other child. */10 readonly finale: AskId;11}1223/** The delete child a split gives `parent`. */13export const finaleOf = (parent: AskId): AskId =>14 AskId.make(`${parent}-delete`);1527/** Whether `parent` waits on an ask named after it, as a split names its members. */16const isParent = ({ ask, blockedBy }: AskListing) =>17 blockedBy.some((blocker) => blocker.startsWith(`${ask}-`));1831/** Every family among `listings`, each at its parent's place in the list. */19export const familiesIn = (20 listings: readonly AskListing[]21): readonly ListedFamily[] =>22 listings.flatMap((parent) => {
14 unmodified lines
37 },38 ];39 });4054/** A list's item: an ask of its own, or a family drawn as one row. */41export type Arranged<L extends AskListing = AskListing> =42 | { readonly kind: "ask"; readonly listing: L }43 | {44 readonly kind: "family";
1 unmodified line
46 readonly members: readonly L[];47 readonly finale: AskId;48 };4964/**65 * `listings` as a list draws them: each family at its parent's place, its66 * members taken out of the list (they are drawn under the parent's fan),67 * every other ask where it was.68 */50export const arrange = <L extends AskListing>(51 listings: readonly L[]52): readonly Arranged<L>[] => {53 const families = familiesIn(listings);
23 unmodified lines
77 ];78 });79};80100// The listings with each ask's blockers cut to those still listed: an ask101// that landed has left the list, and nothing waits on it any more (as the102// front page's entries name only what they still wait on).81export const stillWaiting = <L extends AskListing>(listings: readonly L[]) => {82 const listed = new Set(listings.map(({ ask }) => ask));8384 return listings.map((listing) => ({
4 unmodified lines
modified:apps/web/src/features/front/filter.ts+2 added-26 removed
1/**2 * The front page's filter, read from its address3 * (`?kind=bug&take=open&project=datekit`), in a module with no view of its4 * own: the route decodes its search with it before the page's view loads.5 */1import { Reserve } from "@repo/protocol/domain/ask";2import type { FrontPageEntry } from "@repo/protocol/domain/front-page";3import { KindName, ProjectName } from "@repo/protocol/ids";4import { Option, Schema } from "effect";56import { ASKS_PATH } from "../shared/paths.ts";713/** Asks the viewer may take now: the one value `?take=` has. */8export const Take = Schema.Literal("open");910export type Take = typeof Take.Type;1118/**19 * What the front page is narrowed to: one kind; asks open to take, or held20 * for someone; one project.21 */12export interface FrontFilter {13 readonly kind?: KindName;14 readonly reserved?: Reserve;15 readonly take?: Take;16 readonly project?: ProjectName;17}1829/** A filter as an address may write it: a key set to `undefined` is no filter. */19export type FrontFilterInput = {20 readonly [Key in keyof FrontFilter]?: FrontFilter[Key] | undefined;21};22
4 unmodified lines
27const decodeTake = Schema.decodeUnknownOption(Take);2829const decodeProject = Schema.decodeUnknownOption(ProjectName);3042/** `{ [key]: value }` when there is a value, and nothing when there is none. */31const present = <A, B>(value: A | undefined, field: (a: A) => B) =>32 Option.match(Option.fromUndefinedOr(value), {33 onNone: () => ({}),34 onSome: field,35 });3649/** `input` with every key left undefined dropped. */37export const compact = (input: FrontFilterInput): FrontFilter => ({38 ...present(input.kind, (kind) => ({ kind })),39 ...present(input.project, (project) => ({ project })),40 ...present(input.reserved, (reserved) => ({ reserved })),41 ...present(input.take, (take) => ({ take })),42});4344/**58 * The filter in an address's search: each value that decodes is kept, and59 * one that does not is dropped, so a stale or mistyped link shows the whole60 * list rather than an error.45 * A value that does not decode is dropped, so a stale or mistyped link shows46 * the whole list rather than an error.47 */48export const readFilter = (search: {49 readonly kind?: unknown;50 readonly project?: unknown;
6 unmodified lines
57 reserved: Option.getOrUndefined(decodeReserve(search.reserved)),58 take: Option.getOrUndefined(decodeTake(search.take)),59 });6075/** The front page's address for `filter`, in one key order. */61export const frontPath = (filter: FrontFilterInput) => {62 const search = new URLSearchParams(63 (["kind", "take", "reserved", "project"] as const).flatMap((key) => {64 const value = filter[key];
4 unmodified lines
6970 return search === "" ? ASKS_PATH : `${ASKS_PATH}?${search}`;71};7288/** Whether `entry` passes every part of `filter`. */73export const passes = (filter: FrontFilter) => (entry: FrontPageEntry) =>74 (filter.kind === undefined || entry.ask.kind === filter.kind) &&75 (filter.reserved === undefined || entry.ask.reserve === filter.reserved) &&76 (filter.take === undefined || entry.takeable) &&77 (filter.project === undefined || entry.project === filter.project);7895/**96 * The entries `filter` keeps, the ones the viewer may take first; each group97 * keeps the order given (the platform's: newest ask first).98 */79export const filterEntries = (80 entries: readonly FrontPageEntry[],81 filter: FrontFilter82): readonly FrontPageEntry[] => {
4 unmodified lines
87 ...shown.filter(({ takeable }) => !takeable),88 ];89};90111/**112 * How many entries `filter` would keep with `part` set as given and the113 * rest of the filter as it is: the count beside each filter option.114 */91export const countWith = (92 entries: readonly FrontPageEntry[],93 filter: FrontFilter,94 part: FrontFilterInput
1 unmodified line
modified:apps/web/src/features/front/front-page.tsx+2 added-38 removed
1/**2 * The front page: the open asks of every project, grouped by project, the3 * ones the viewer may take first; a family drawn as one row with its fan;4 * a toolbar that narrows the list by kind, by who may take an ask and by5 * project; and beside it, where to start, or the selected ask's facts.6 * Props in, markup out: the route reads the entries, the families' parents7 * and their projects' events on the server, the list of projects in the8 * browser (it may arrive after the rows, and moves none of them), and9 * hands them here.10 *11 * Each project's posture is said once, on its group's header, from the12 * list of projects; a row says only its own state. The filter is a link13 * (`/asks?kind=bug&take=open`), so a filtered list is an address to share.14 */1import { Brand } from "@repo/brand";2import { Reserve } from "@repo/protocol/domain/ask";3import type { Ask } from "@repo/protocol/domain/ask";4import type { ProjectEvent } from "@repo/protocol/domain/event";
28 unmodified lines
33import { countWith, filterEntries, frontPath } from "./filter.ts";34import type { FrontFilter, FrontFilterInput } from "./filter.ts";35import { EXPLAINER } from "./head.ts";3651/** The list's count, as the context bar says it: "10 open asks, 8 open to take". */37export const frontCount = (shown: readonly FrontPageEntry[]) =>38 `${plural(shown.length, "open ask", "open asks")}, ${39 shown.filter(({ takeable }) => takeable).length40 } open to take`;
1 unmodified line
42export interface FrontPageProps {43 readonly entries: readonly FrontPageEntry[];44 readonly filter: FrontFilter;45 readonly now: DateTime.Utc;61 /** Each family's parent as the platform stores it: its children, all of them. */46 readonly parents: readonly Ask[];63 /** The events of each project that holds a family on the page. */47 readonly events: ReadonlyMap<ProjectName, readonly ProjectEvent[]>;65 /** The children that landed while the page was open, by project. */48 readonly stampsOf?: (project: ProjectName) => ReadonlySet<AskId>;67 /** Every project with its posture; none until the list arrives. */49 readonly projects: readonly ProjectListing[] | undefined;50 readonly platformUrl: string;51 readonly webUrl: string;71 /** The selected ask in full, once the browser has read it. */52 readonly selectedAsk?: Ask | undefined;53}5475/** The entries of each project, in the order its first entry comes. */55const byProject = (shown: readonly FrontPageEntry[]) => {56 const groups = new Map<ProjectName, FrontPageEntry[]>();5758 for (const entry of shown) {
2 unmodified lines
6162 return [...groups];63};6486/** One option of a filter: its words and its count, the current one marked. */65const FilterOption = ({66 count,67 current,68 label,
18 unmodified lines
87 </AppLink>88 </li>89);90113/** A filter's options, under its name for a screen reader. */91const Segment = ({92 children,93 label,94}: {
4 unmodified lines
99 {children}100 </ul>101);102126/** The kinds on the page, and the one filtered to, each once, by name. */103const kindsOf = (entries: readonly FrontPageEntry[], filter: FrontFilter) =>104 [105 ...new Set([106 ...entries.map(({ ask }) => ask.kind),107 ...(filter.kind === undefined ? [] : [filter.kind]),108 ]),109 ].toSorted();110135/** The projects on the page, and the one filtered to, each once, by name. */111const projectsOf = (entries: readonly FrontPageEntry[], filter: FrontFilter) =>112 [113 ...new Set([114 ...entries.map(({ project }) => project),
6 unmodified lines
121 people: "Held for people",122} as const satisfies Record<Reserve, string>;123124/**150 * The projects as a menu: a disclosure of links, so it opens and narrows151 * with no script. A new address closes it (its key is the filter's152 * project).125 * A disclosure of links, so it works with no script. Its key is the filter's126 * project, so a new address closes it.127 */128const ProjectMenu = ({129 entries,130 filter,
35 unmodified lines
166 </ul>167 </details>168);169196/** The toolbar: kind; open to take or held for newcomers; project. */170const Toolbar = ({171 entries,172 filter,173}: {
62 unmodified lines
236 </>237 );238};239267/**268 * The front page with no open ask: with no project yet, the command that269 * brings one; with projects, the command that opens an ask.270 */240const NoAsks = ({241 projects,242}: {243 readonly projects: readonly ProjectListing[] | undefined;
9 unmodified lines
253 title="No open asks on any project. A decider opens one from an ask file."254 />255 );256288/** A project's group of rows, as the page reads it. */257interface Group {258 readonly project: ProjectName;259 readonly entries: readonly FrontPageEntry[];260 readonly items: readonly Arranged[];261 readonly states: ReadonlyMap<AskId, AskProgress>;262}263296/** The row ids in the order the page shows them: what `j` and `k` walk. */264const rowIds = (groups: readonly Group[]) =>265 groups.flatMap(({ items }) =>266 items.map((item) =>267 item.kind === "ask" ? item.listing.ask : item.parent.ask268 )269 );270304/** A project's group: its header (name, posture once, counts), then its rows. */271const ProjectGroup = ({272 group,273 listing,274 now,
51 unmodified lines
326 const parent = parents.find(327 (ask) => ask.project === project && ask.id === item.parent.ask328 );329364 // A parent the platform did not give in full: its members stay rows.330 if (parent === undefined) {331 return [332 row(item.parent),333 ...item.members.map((member) => row(member)),
20 unmodified lines
354 </RowGroup>355 );356};357393/** The selected entry's facts, with its family when it is a member. */358const Selected = ({359 entry,360 full,361 parents,
159 unmodified lines
modified:apps/web/src/features/front/head.ts+2 added-12 removed
1/**2 * What the list pages put in their head and their first lines, in a module3 * with no view of its own: a route's `head` runs with the route, before its4 * page's view loads, so a view's imports (the Markdown renderer) stay out of5 * every page's first load.2 * Kept apart from the views: a route's `head` runs before its page's view3 * loads, so the Markdown renderer stays out of every page's first load.4 */58/** What an ask is, and how one lands: the page's one sentence. */6export const EXPLAINER =7 "Each ask is one change a project wants, with a check that fails on its main today. Claim one, make the check pass, and push: the gate lands it.";812/** A block that is no paragraph of prose: a heading, a quote, a table, a list, a fence, HTML, an image. */9const NOT_PROSE = /^(?:#|>|\||[-*+]\s|\d+[.)]\s|```|~~~|<|!\[|\[!\[)/u;1015/** A paragraph's inline Markdown as plain words: links and code as their text, emphasis dropped. */11const plainWords = (text: string) =>12 text13 .replaceAll(/!\[[^\]]*\]\([^)]*\)/gu, "")14 .replaceAll(/\[(?<label>[^\]]*)\]\([^)]*\)/gu, "$<label>")
4 unmodified lines
19 )20 .replaceAll(/\s+/gu, " ")21 .trim();2228/**29 * A README's first sentence, as plain words: the first paragraph of prose30 * (past its title, badges, quotes, tables and lists), to its first full31 * stop. None when the README opens with no paragraph of prose.32 */23export const ledeOf = (text: string): string | undefined => {24 const paragraph = text25 .split(/\n\s*\n/u)26 .map((block) => block.trim())
12 unmodified lines
modified:apps/web/src/features/front/markdown.ts-10 removed
1/**2 * A list page that also answers agents: the same URL gives the page to a3 * browser and Markdown to a request that asks for it (`Accept:4 * text/markdown`), so the answer varies by `Accept`, and the page names its5 * Markdown as an alternate, in its head and in a `Link` header.6 */78/** `response`, marked as one of several answers to its URL, chosen by `Accept`. */1export const variedByAccept = (response: Response): Response => {2 const headers = new Headers(response.headers);34 headers.set("vary", "Accept");56 return new Response(response.body, { headers, status: response.status });7};817/** The `Link` header naming `href` as the page's Markdown. */9export const markdownLink = (href: string) =>10 `<${href}>; rel="alternate"; type="text/markdown"`;1121/** The head's link naming `href` as the page's Markdown. */12export const markdownAlternateLink = (href: string) => ({13 href,14 rel: "alternate",15 type: "text/markdown",
1 unmodified line
modified:apps/web/src/features/front/stamps.ts+2 added-25 removed
1/**2 * Which landings an open page stamps: a child of a family that lands while3 * the page is open settles with the stamp, once, and a landing the page's4 * first read already held never does.5 *6 * The first read the page settles on sets `mountSeq` (the highest event7 * number it held); each later read stamps the asks it shows landed that the8 * read before did not, closed by an event after `mountSeq`9 * (`stampsFrom`). Whether the stream or a poll brought the later read, a10 * landing stamps once: the stamped set only grows, so a mark keeps its11 * stamp through every later render rather than settling again.12 */1import type { ProjectEvent } from "@repo/protocol/domain/event";2import type { AskId } from "@repo/protocol/ids";3import { useState } from "react";45import { askStates, lastSeq, stampsFrom } from "../shared/ask-progress.ts";6import type { AskProgress } from "../shared/ask-progress.ts";720/** What a page remembers between reads of one project's events. */8export interface StampMemory {22 /** The highest event number of the first read. */9 readonly mountSeq: number;24 /** Where each ask stood in the read before. */10 readonly previous: ReadonlyMap<AskId, AskProgress>;26 /** Every ask stamped so far. */11 readonly stamped: ReadonlySet<AskId>;12}1330/** The page's memory after one more read of `events`; the first read stamps nothing. */14export const stampStep = (15 memory: StampMemory | undefined,16 events: readonly ProjectEvent[]17): StampMemory => {
14 unmodified lines
32 : new Set([...memory.stamped, ...fresh]),33 };34};3553/** Each project's memory after one more read of each project's events. */36const stepAll = (37 memory: ReadonlyMap<string, StampMemory>,38 reads: ReadonlyMap<string, readonly ProjectEvent[]>39): ReadonlyMap<string, StampMemory> =>
3 unmodified lines
43 stampStep(memory.get(project), events),44 ])45 );4665/**66 * The asks each project's page should stamp, from its events as the page67 * reads them (a new map each time a read changes). A project's first read68 * stamps nothing.69 */47export const useStamps = (48 reads: ReadonlyMap<string, readonly ProjectEvent[]>49): ((project: string) => ReadonlySet<AskId>) => {50 const [seen, setSeen] = useState(reads);51 const [memory, setMemory] = useState(() => stepAll(new Map(), reads));5276 // A new read: step the memory now, in this render, as React's guide to77 // state from the previous render does, so the stamp draws with the read.53 // Step the memory in this render, as React's guide to state from the previous54 // render does, so the stamp draws with the read.55 let current = memory;5657 if (reads !== seen) {58 current = stepAll(memory, reads);
6 unmodified lines
modified:apps/web/src/features/home/home-page.tsx-21 removed
1/**2 * A signed-in reader's own page: their work (each claim, its ask's want and3 * where its answer stands, with the command that runs next); the decisions4 * waiting for them when they decide somewhere; the open asks they may take;5 * and the way to their record. No score and no count of credit (DESIGN.md).6 * Signed out, it says what the page is and how to sign in. A view: what the7 * server read, and the instant, in; markup out.8 */1import { Brand } from "@repo/brand";2import type { Today } from "@repo/protocol/domain/decision";3import type { FrontPageEntry } from "@repo/protocol/domain/front-page";4import { Outcome } from "@repo/protocol/domain/outcome";
42 unmodified lines
47 WORK_SHOWN,48} from "./read.ts";49import type { Work } from "./read.ts";5059/** What the page is, said to a reader who is not signed in. */51const WHAT_HOME_IS =52 "Home is your own page: the asks you hold and where each answer stands, the decisions waiting for you, and the asks you may take next.";5363/** The decisions the page lists; the rest are on Today. */54const DECISIONS_SHOWN = 5;5556const LINK =57 "decoration-rule hover:decoration-foreground font-medium underline underline-offset-4";5869/** A block's empty state, under its header like its rows would be. */59const Empty = (props: Parameters<typeof EmptyState>[0]) => (60 <li className="pt-3">61 <EmptyState {...props} />62 </li>63);6476/**77 * What runs next on a claim: a refusal's own `next`, or, while the claim78 * runs with nothing refused, its local check before a push.79 */65const nextOf = ({ answer, claim }: Work) => {66 if (answer !== undefined) {67 return Outcome.guards.Refused(answer.outcome)68 ? {
172 unmodified lines
241 {children}242 </RowGroup>243);244260/** A decider's waiting decisions, or that none waits. */245const Waiting = ({ today }: { readonly today: Today }) => {246 const waiting = today.decisions.length + today.overflow;247248 return (
9 unmodified lines
258 </DecisionsGroup>259 );260};261278/** The decisions block: a decider's waiting decisions; nothing for anyone else. */262const DecisionsBlock = ({ decisions }: { readonly decisions: Decisions }) =>263 Decisions.match(decisions, {264 Decides: ({ today }) => <Waiting today={today} />,265 NotDecider: () => null,
24 unmodified lines
290 Every open ask291 </AppLink>292);293311/** The asks block's empty state: none to take, or none came. */294const NoAsks = ({ title }: { readonly title: string }) => (295 <Empty command={`${Brand.cli} front`} onward={EVERY_ASK} title={title} />296);297316/** The asks the reader may take, or why none shows. */298const AskList = ({ asks }: { readonly asks: Takeable }) =>299 Takeable.match(asks, {300 Listed: ({ asks: listed }) =>301 listed.length === 0 ? (
15 unmodified lines
317 <AskList asks={asks} />318 </RowGroup>319);320340/** Who is signed in, the way to their record, and the way to import a repo. */321const Record = ({ handle }: { readonly handle: Handle }) => (322 <>323 Signed in as <HandleLink handle={handle} />.{" "}324 <AppLink className={LINK} to={personPath(handle)}>
26 unmodified lines
351 </div>352 </Workspace>353);354375/** Signed out: what the page is, the way in, and the command. */355const SignedOut = () => (356 <Workspace crumbs={[{ label: "Home" }]} title="Home">357 <div className="flex max-w-[70ch] flex-col items-start gap-3">358 <p className="text-body">{WHAT_HOME_IS}</p>
27 unmodified lines
modified:apps/web/src/features/home/read.ts-42 removed
1/**2 * What `/home` reads, in a module with no view of its own: a route's loader3 * runs before its page's view loads.4 *5 * - `HomeRead`: the reader's work (each claim from `status`, its ask's want6 * and its latest answer), their Today when they decide somewhere, the7 * open asks they may take (`frontPage`, read as them), or why there is8 * none of it.9 * - `readHome`: that read, made with whatever `Client` the caller gives10 * (the server's, carrying the reader's own session).11 */1import { Client } from "@repo/protocol/contracts";2import { AnswerView } from "@repo/protocol/domain/answer";3import { ClaimView } from "@repo/protocol/domain/claim";4import { Today } from "@repo/protocol/domain/decision";
13 unmodified lines
18} from "effect";1920import { isSignedOut } from "../today/read.ts";2133/** The asks the page lists: the first few the reader may take; the rest are at `/asks`. */22const ASKS_SHOWN = 8;2336/** The claims the page lists, running first, then the newest; the rest are in `status`. */24export const WORK_SHOWN = 10;2539/** How many reads of one kind the page makes at once. */26const AT_ONCE = 4;2742/** One claim of the reader's, its ask's want, and its latest answer. */28export const Work = Schema.Struct({29 answer: Schema.optionalKey(AnswerView),30 claim: ClaimView,46 /** Absent when the ask did not come: the row names it by its id. */31 want: Schema.optionalKey(Schema.NonEmptyString),32});3334export type Work = typeof Work.Type;3552/** The decisions block: the reader's Today, or why there is none. */36export const Decisions = Schema.TaggedUnion({37 Decides: { today: Today },38 NotDecider: {},39 Unreachable: {},40});4142export type Decisions = typeof Decisions.Type;4361/** The asks block: the first the reader may take, or that the list did not come. */44export const Takeable = Schema.TaggedUnion({45 Listed: { asks: Schema.Array(FrontPageEntry) },46 Unreachable: {},47});4849export type Takeable = typeof Takeable.Type;5069/** What the page read for its reader: their work, or why there is none. */51export const HomeRead = Schema.TaggedUnion({52 Read: {53 asks: Takeable,54 decisions: Decisions,55 handle: Handle,75 /** Every claim the reader holds, of which `work` is the first `WORK_SHOWN`. */56 held: Schema.Int,77 /** How many of those are still running. */57 running: Schema.Int,58 work: Schema.Array(Work),59 },60 SignedOut: {},
1 unmodified line
62});6364export type HomeRead = typeof HomeRead.Type;6587/** What the loader sends: the read, and the instant it was made. */66export const HomePageData = Schema.Struct({67 now: Schema.DateTimeUtcFromString,68 read: HomeRead,69});7071export type HomePageData = typeof HomePageData.Type;7295/** A claim still running: its holder's to push to. */73export const isRunning = (claim: ClaimView) =>74 claim.state === "live" || claim.state === "warned";7576const openedOrder = Order.mapInput(77 DateTime.Order,78 (claim: ClaimView) => claim.openedAt79);80104/** Running claims first, then the newest. */81const workOrder: Order.Order<ClaimView> = Order.combine(82 Order.mapInput(Order.Boolean, (claim: ClaimView) => !isRunning(claim)),83 Order.flip(openedOrder)84);
4 unmodified lines
89);9091const isNotDecider = Schema.is(NotDecider);92117/** Where a claim's ask lives: one key per (project, ask). */93export const askKey = ({ ask, project }: ClaimView) => `${project}/${ask}`;94120/**121 * The asks whose id the reader's claims hold in more than one project.122 * `status` names an answer's ask but not its project, so those asks' answers123 * are read again one project at a time.124 */95const sharedAsks = (claims: readonly ClaimView[]) =>96 new Set(97 Object.entries(Arr.groupBy(claims, ({ ask }) => ask)).flatMap(98 ([ask, holding]) =>99 new Set(holding.map(({ project }) => project)).size > 1 ? [ask] : []100 )101 );102133/** The reader's answers in each of `projects`; a project that did not answer gives none. */103const answersIn = (projects: readonly ProjectName[]) =>104 Effect.gen(function* () {105 const client = yield* Client;106
9 unmodified lines
116 )117 );118 });119151/** Each shown claim's ask's want, by `askKey`; an ask that did not come is left out. */120const wantsOf = (claims: readonly ClaimView[]) =>121 Effect.gen(function* () {122 const client = yield* Client;123 const asks = Arr.dedupeWith(claims, (a, b) => askKey(a) === askKey(b));
10 unmodified lines
134 ).pipe(Effect.map((found) => found.flat()))135 );136 });137170/** The claims the page lists: running first, then the newest, the first `WORK_SHOWN`. */138const shownOf = (claims: readonly ClaimView[]) =>139 Arr.sort(claims, workOrder).slice(0, WORK_SHOWN);140174/**175 * The reader's first claims, each with its want and its latest answer. An176 * answer belongs to the newest claim on its ask in its project; an older177 * claim on the same ask shows its own state. An ask whose id the reader178 * holds in two projects takes its answers from `again`, read per project.179 */141export const pairWork = ({142 again,143 answers,144 claims,
5 unmodified lines
150 readonly wants: ReadonlyMap<string, string>;151}): readonly Work[] => {152 const shared = sharedAsks(claims);153193 /** The claim each (project, ask) gives its answer to: the newest, set last. */154 const newest = new Map(155 Arr.sort(claims, openedOrder).map(156 (claim) => [askKey(claim), claim] as const157 )
27 unmodified lines
185 }),186 }));187};188229/** `pairWork` over what the platform answers: the wants, and answers read again where needed. */189const workOf = (claims: readonly ClaimView[], answers: readonly AnswerView[]) =>190 Effect.gen(function* () {191 const shown = shownOf(claims);192 const shared = sharedAsks(claims);
14 unmodified lines
207208 return pairWork({ again, answers, claims, wants });209 });210252/** The reader's home, or why there is none, encoded for the page. */211export const readHome = Effect.gen(function* () {212 const client = yield* Client;213214 const [status, today, front] = yield* Effect.all(
51 unmodified lines
modified:apps/web/src/features/import/client-owner.tsx-12 removed
1/**2 * The owner select, drawn in the browser only. The server renders its3 * stand-in: the trigger as it will look, holding the choice in sight and4 * in the form (a hidden input), never a native `<select>`; after5 * hydration the browser loads the kit's select over it6 * (`owner-select.tsx`), whose trigger takes the same `TRIGGER`.7 * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic8 * import below is dead code there and the Worker bundles none of it.9 */1import type { Owner } from "@repo/protocol/ids";2import { ClientOnly } from "@tanstack/react-router";3import { ChevronDown } from "lucide-react";4import { lazy, Suspense } from "react";56export interface OwnerSelectProps {16 /** The owners to choose from, the default first. */7 readonly choices: readonly Owner[];8 readonly labelledBy: string;9 readonly describedBy: string;10 readonly onChange: (value: Owner) => void;11 readonly value: Owner | undefined;12}1324/** The trigger's size, the kit's select and the stand-in alike. */14export const TRIGGER =15 "tablet:text-ui tablet:h-9 h-11 w-full max-w-sm text-base";1617const SelectLater = import.meta.env.SSR18 ? undefined19 : lazy(() => import("./owner-select.tsx"));2032/** The select's place before it is drawn: its trigger, showing the choice. */21const StandIn = ({ describedBy, labelledBy, value }: OwnerSelectProps) => (22 <>23 <button24 aria-describedby={describedBy}
30 unmodified lines
modified:apps/web/src/features/import/import-form.tsx-38 removed
1/**2 * The import form: a signed-in person pastes a public repo's HTTPS URL,3 * may name a branch, picks the owner and the name, and presses Import. The4 * owner and the name follow the URL until the person changes them: the5 * URL's source namespace (`github.com/pallets`) when its host is one the6 * platform knows, else their handle; the URL's last segment as the name.7 * At a source namespace's address the owner is the address's, fixed.8 * Signed out, it says what would be imported and links to sign-in, coming9 * back to `here`. Props in, markup out: the route reads who is signed in,10 * sends the payload, and goes to the project once it is made.11 *12 * Nothing is imported until Import is pressed; nothing here asks a host13 * anything.14 */1import { Brand } from "@repo/brand";2import type {3 Handle,4 Owner,
19 unmodified lines
24 prefillFrom,25} from "./prefill.ts";26import type { ImportPayload } from "./prefill.ts";2742/** What the form starts with: a URL, and the owner and name it gives. */28export interface ImportPrefill {29 readonly url: string;30 readonly owner?: SourceNamespace | undefined;31 readonly name?: ShortName | undefined;32}3349/** Who is importing, and what became of the last press. */34export interface Importer {51 /** The handle signed in in this browser; none signed out. */35 readonly handle: Option.Option<Handle>;53 /** Whether the browser is still learning who is signed in. */36 readonly checking?: boolean | undefined;55 /** Whether an import is on its way: the button waits. */37 readonly busy?: boolean | undefined;57 /** Sends the payload; the route goes to the project once it is made. */38 readonly onImport?: ((payload: ImportPayload) => void) | undefined;59 /** What the last import came back with, when it was refused. */39 readonly refusal?: ReactNode | undefined;40}4142export interface ImportFormProps extends Importer {43 readonly prefill?: ImportPrefill | undefined;65 /** The owner the address fixes, at a source namespace's address. */44 readonly fixedOwner?: SourceNamespace | undefined;67 /** The page's own address, where sign-in comes back to. */45 readonly here: string;46}4771/** The import as a command, for a reader in a terminal. */48export const importCommand = (project = "<owner>/<name>", url = "<url>") =>49 `${Brand.cli} init --project ${project} --import ${url}`;5051const LINK = "decoration-rule font-medium underline hover:decoration-current";5277/** A field's label and the words under it. */53const LABEL = "text-ui font-medium";5455const HINT = "text-label text-muted-foreground font-normal";5682/**83 * A text field in mono: 16 px on a phone, so it does not zoom on focus, and84 * without ligatures, as code shows what was typed (`://` stays three).85 */57const MONO_FIELD =58 "tablet:h-9 tablet:text-mono h-11 font-mono text-base [font-feature-settings:'calt'_0,'liga'_0]";5989/** What Import says, by where the form stands: why it waits, or what it does. */60const IMPORT_WORDS = {61 busy: "Importing…",62 noName: "Name the project",63 noOwner: "No owner you may import under",
2 unmodified lines
66} as const;6768type FormState = keyof typeof IMPORT_WORDS;69100/** Where the form stands: importing, waiting on a field, or ready. */70const formState = ({71 branch,72 busy,73 owner,
79 unmodified lines
153 </section>154 );155};156188/** The owner, fixed by the address: in sight, and in the form. */157const FixedOwner = ({158 hintId,159 owner,160}: {
7 unmodified lines
168 <input name="owner" type="hidden" value={owner} />169 </>170);171204/** What the hint under Owner says, by what may be chosen. */172const ownerHint = (fixed: boolean, choices: readonly Owner[]) => {173 if (fixed) {174 return "The address names it: the project keeps its source's account.";175 }
2 unmodified lines
178 ? "The URL's own account, or your handle."179 : "Your handle: this URL's host is not one a project may be owned by.";180};181215/** Under Name: the project's address once the name is one, else what a name is. */182const NameHint = ({183 payload,184}: {185 readonly payload: Option.Option<ImportPayload>;
73 unmodified lines
259 onChange={(event) => {260 setUrl(event.target.value);261 }}262 placeholder="https://github.com/pallets/click"297 // At a source namespace's address the URL is the address's own.263 readOnly={busy || fixedOwner !== undefined}264 required265 spellCheck={false}266 type="url"
76 unmodified lines
343 {refusal}344345 <div className="flex flex-col gap-2">346 <Button382 // Waiting for a URL or a name, it says so at full strength, dashed383 // like any field still to fill, rather than sitting grey.347 className={`tablet:h-9 tablet:w-fit h-11 w-full min-w-28 px-4 ${state === "ready" || state === "busy" ? "" : "text-muted-foreground border-dashed disabled:opacity-100"}`}348 data-state={state}349 disabled={state !== "ready"}350 type="submit"
13 unmodified lines
364 </form>365 );366};367405/** The form, the way to sign in, or the wait while the browser learns who is signed in. */368export const ImportForm = ({369 busy,370 checking = false,371 fixedOwner,
27 unmodified lines
modified:apps/web/src/features/import/import-offer.tsx-13 removed
1/**2 * The import a source namespace's address offers when nobody has made the3 * project (`/github.com/pallets/click`): the form prefilled with the URL4 * the address rebuilds (read-only), the owner fixed to the namespace, and5 * the name; signed out, the way to sign in. It never imports on its own.6 * The route draws it in place of the not-found when `offerFor` names the7 * address's project. Props in, markup out.8 */1import {2 isSourceNamespace,3 ownerOf,4 ProjectName,
7 unmodified lines
12import { sourceUrlOf } from "./prefill.ts";1314const decodeProject = Schema.decodeUnknownOption(ProjectName);1524/**25 * The project an address that names none offers to import: its name, when26 * its owner is a source namespace; none for a person's address and for27 * one that names no possible project.28 */16export const offerFor = (name: string): Option.Option<ProjectName> =>17 Option.filter(decodeProject(name), (project) =>18 isSourceNamespace(ownerOf(project))19 );
30 unmodified lines
modified:apps/web/src/features/import/import-page.tsx-12 removed
1/**2 * `/import`: the import form under the page's head, and beside it what an3 * import does and the same import as a command. A URL in the address4 * (`?url=`) fills the form. Props in, markup out: the route reads who is5 * signed in, sends the payload and goes to the project once it is made.6 */1import { CommandLine } from "../shared/command.tsx";2import { FactBlock } from "../shared/facts.tsx";3import { Workspace } from "../shared/shell/workspace.tsx";4import { ImportForm, importCommand } from "./import-form.tsx";5import type { Importer } from "./import-form.tsx";613/** What an import does, and the same import from a terminal. */7export const ImportFacts = () => (8 <>9 <FactBlock label="What an import does">10 <ul className="text-ui flex list-disc flex-col gap-1.5 pl-4">
18 unmodified lines
29 url = "",30 here,31 ...importer32}: Importer & {40 /** The URL the address carries, to fill the form with. */33 readonly url?: string | undefined;42 /** The page's own address, where sign-in comes back to. */34 readonly here: string;35}) => (45 // Below the shell's width the form comes first, and what an import does46 // follows it, rather than standing between the reader and the form.36 <div className="contents [&_[data-facts=inline]]:hidden">37 <Workspace38 crumbs={[{ label: "Import a repo" }]}39 facts={<ImportFacts />}
3 unmodified lines
43 >44 <ImportForm45 {...importer}46 here={here}58 // The name follows the URL until the person types one.47 prefill={url === "" ? undefined : { url }}48 />49 <div className="shell:hidden border-rule flex flex-col border-t pt-4">50 <ImportFacts />
4 unmodified lines
modified:apps/web/src/features/import/owner-select.tsx-9 removed
1/**2 * The owner an import is made under, chosen with the kit's select: the3 * URL's source namespace first when its host is one the platform knows,4 * then the person's handle. Drawn in the browser only (`client-owner.tsx`):5 * Base UI's select and its positioning are the browser's to run, and the6 * Worker bundles none of them.7 */1import {2 Select,3 SelectContent,4 SelectItem,
13 unmodified lines
18 <Select19 items={choices.map((choice) => ({ label: choice, value: choice }))}20 name="owner"21 onValueChange={(chosen) => {29 // The select hands back one of its items' values: find it, an owner.22 const owner = choices.find((choice) => choice === chosen);2324 if (owner !== undefined) {25 onChange(owner);
17 unmodified lines
43 </SelectContent>44 </Select>45);4655// `React.lazy` takes a module's default export.47export default OwnerSelect;
modified:apps/web/src/features/import/prefill.ts-33 removed
1/**2 * What the import form reads from a pasted URL, and what it sends. Pure:3 * no view, no transport. The owner is the URL's source namespace4 * (`github.com/pallets`) when its host is one the platform knows; the name5 * is the URL's last segment, without `.git`, lowercased. Nothing here asks6 * a host anything: the platform clones the URL when Import is pressed.7 */1import type { InitProject } from "@repo/protocol/contracts";2import { ImportSource } from "@repo/protocol/domain/policy";3import {4 Owner,
3 unmodified lines
8} from "@repo/protocol/ids";9import type { Handle, ProjectName, SourceNamespace } from "@repo/protocol/ids";10import { Array, Option, Schema } from "effect";1119/** What `initProject` takes, from its one schema. */12export type ImportPayload = typeof InitProject.payloadSchema.Type;1322/** What a URL prefills: the owner its host gives, and the name it ends in. */14export interface Prefill {15 readonly owner: Option.Option<SourceNamespace>;16 readonly name: Option.Option<ShortName>;17}1828// `https://<host>/<path>`: the path's last non-empty segment is the repo's.19const HTTPS_URL = /^https:\/\/[^/?#\s]+\/(?<path>[^?#\s]+)$/u;2021const decodeShortName = Schema.decodeUnknownOption(ShortName);2223const decodeOwner = Schema.decodeUnknownOption(Owner);2425const decodeSource = Schema.decodeUnknownOption(ImportSource);2637/** The name a URL ends in, without `.git` and lowercased; none when it is no name. */27const nameIn = (url: string): Option.Option<ShortName> => {28 const path = HTTPS_URL.exec(url.trim())?.groups?.path ?? "";29 const last = path.split("/").findLast((segment) => segment !== "") ?? "";3031 return decodeShortName(last.replace(/\.git$/u, "").toLowerCase());32};3345/** The owner and the name `url` prefills. */34export const prefillFrom = (url: string): Prefill => ({35 name: nameIn(url),36 owner: sourceNamespaceOf(url.trim()),37});3851/** A source namespace as an owner: every one is (a host is never a reserved word). */39export const ownerOfNamespace = (40 namespace: SourceNamespace41): Option.Option<Owner> => decodeOwner(namespace);4256/** A handle as an owner, lowercased; none for one no owner can spell. */43export const ownerOfHandle = (handle: Handle): Option.Option<Owner> =>44 decodeOwner(handle.toLowerCase());4560/**61 * The owners a person may import `url` under: the URL's source namespace62 * first when its host is one the platform knows (the default then), and63 * their own handle.64 */46export const ownerChoices = (47 handle: Option.Option<Handle>,48 url: string49): readonly Owner[] =>
1 unmodified line
51 ...Option.toArray(Option.flatMap(prefillFrom(url).owner, ownerOfNamespace)),52 ...Option.toArray(Option.flatMap(handle, ownerOfHandle)),53 ]);5474/**75 * The URL a source namespace's project was imported from:76 * `github.com/pallets/click` is `https://github.com/pallets/click`.77 */55export const sourceUrlOf = (project: ProjectName) => `https://${project}`;5680/**81 * The source the form names, as `initProject` takes it: the URL and the82 * branch trimmed, the branch only when named. None for a URL the contract83 * would refuse (no public HTTPS URL).84 */57export const importSourceOf = (form: {58 readonly url: string;59 readonly branch: string;60}): Option.Option<ImportSource> => {
2 unmodified lines
6364 return decodeSource(branch === "" ? { url } : { branch, url });65};6695/**96 * The form's fields as `initProject`'s payload: its source, and the97 * project the owner and the name make. None when the contract would refuse98 * the name or the URL before the platform ever read it.99 */67export const importPayload = (form: {68 readonly url: string;69 readonly branch: string;70 readonly owner: Owner;
8 unmodified lines
modified:apps/web/src/features/import/use-importer.tsx-20 removed
1/**2 * The import form's wiring, for the two pages that draw it (`/import` and3 * a source namespace's address nobody has made): who is signed in, read in4 * the browser; `importAtom`, sent only when Import is pressed; the move to5 * the project once it is made; and a refusal, drawn as the platform gave6 * it, under the form.7 */1import { useAtom, useAtomValue } from "@effect/atom-react";2import { ownerOf } from "@repo/protocol/ids";3import type { ProjectName } from "@repo/protocol/ids";4import { useLocation, useNavigate, useRouter } from "@tanstack/react-router";
6 unmodified lines
11import { whoAtom } from "../auth/who.ts";12import { ProposalFailure } from "../proposal/failure.tsx";13import type { Importer } from "./import-form.tsx";1422/**23 * Where an import that made `made` goes from a page at `at`: nowhere when24 * it is the project this address names (its page reads it again), else to25 * the project's page.26 */15export const afterImport = (made: ProjectName, at?: ProjectName) =>16 made === at17 ? Option.none()18 : Option.some({19 params: { owner: ownerOf(made), project: made },20 to: "/$owner/$project" as const,21 });2235/**36 * Who is importing and what became of the last press. `at` is the project37 * this page's address names, if any: a project made there is read again38 * where it stands; any other is gone to.39 */23export const useImporter = (at?: ProjectName): Importer => {24 const navigate = useNavigate();25 const router = useRouter();26 const here = useLocation({ select: hereOf });27 const who = useAtomValue(whoAtom);28 const [imported, send] = useAtom(importAtom);46 // Set once this page sends: a project the atom still holds from an47 // earlier visit never moves the page.29 const [sent, setSent] = useState(false);30 const made = sent ? Option.getOrUndefined(importMade(imported)) : undefined;3132 useEffect(() => {
1 unmodified line
34 return;35 }3637 Option.match(afterImport(made, at), {57 // The loader read this address as no project: it reads it again.38 onNone: () => {39 void router.invalidate();40 },41 onSome: (to) => {
20 unmodified lines
modified:apps/web/src/features/landing/landing-page.tsx-24 removed
1/**2 * The landing: what the platform is, said once, and the way to the open3 * asks first. Its evidence is the screen `git push` prints when the gate4 * refuses, set as git sets it, not a picture of one. Every sentence on it is5 * the README's or the glossary's. A view: the platform's address, the web's6 * own and the projects in; markup out.7 */1import { installCommand } from "@repo/agent-kit/install";2import { Brand } from "@repo/brand";3import type { ReactNode } from "react";4
16 unmodified lines
21import { LandingProjects } from "./projects.ts";22import { pushTranscript } from "./transcript.ts";23import { LEDE, WHAT_IT_IS } from "./words.ts";2432/** A link in a plain row (the top, the foot): ink, underlined only on hover. */25const ROW_LINK = "no-underline hover:underline";2635/** The primary action: an ink button that is a link. */27const PRIMARY = buttonVariants({ className: "no-underline" });2838/** Where an agent's reference is. */29const AGENTS_PATH = "/agents";3041/** Text git prints or takes, inside a sentence. */31const Code = ({ children }: { readonly children: ReactNode }) => (32 <code className={ID}>{children}</code>33);3446/** The branch's name, as git takes it. */35const MAIN = "main";3649/** The lede, its one branch name set as git takes it. */37const Lede = () => {38 const [before, after] = LEDE.split(MAIN);3940 return (
4 unmodified lines
45 </>46 );47};4862/** One part of the page under its name, parted from the last by a hairline. */49const Part = ({50 children,51 id,52 title,
12 unmodified lines
65 {children}66 </section>67);6883/** A noun a contributor meets, and what GLOSSARY.md says it is. */69interface Noun {70 readonly noun: string;71 readonly means: ReactNode;72}7389/** The four nouns, in the glossary's words. */74const NOUNS: readonly Noun[] = [75 {76 means: (77 <>
19 unmodified lines
97 noun: "Refusal",98 },99];100117/** The core loop, in the README's six lines. */101const LOOP: readonly ReactNode[] = [102 <>103 A decider opens an ask; <Code>{`${Brand.cli} ask open`}</Code> lands it only104 once its check fails on <Code>main</Code> twice the same way, by an
17 unmodified lines
122 every person, or answers with a refusal.123 </>,124];125143/** One thing a platform can do that a setting cannot: the README's lead, and its words. */126interface Power {127 readonly lead: string;128 readonly says: ReactNode;129}130149/** What a platform can do that a setting on a code host cannot, in the README's words. */131const POWERS: readonly Power[] = [132 {133 lead: "Judge with checks the answer cannot touch.",134 says: (
34 unmodified lines
169 ),170 },171];172192/** The wordmark and the ways in, as a plain row. */173const Top = () => (174 <header className="border-rule flex flex-wrap items-center justify-between gap-x-6 gap-y-2 border-b py-4">175 <AppLink className="text-want font-semibold no-underline" to="/">176 {Brand.name}
14 unmodified lines
191 </nav>192 </header>193);194215/** A line of the screen, with the refusal's tag in the refused colour wherever git names it. */195const Printed = ({196 tag,197 text,198}: {
17 unmodified lines
216 </>217 );218};219241/** The push, and what git prints back when the gate refuses it. */220const Transcript = ({ platformUrl }: { readonly platformUrl: string }) => {221 const { command, lines, tag } = pushTranscript(platformUrl);222223 return (
22 unmodified lines
246 </figure>247 );248};249272/** The projects on the platform, each with its posture, or that the list did not come. */250const Projects = ({ projects }: { readonly projects: LandingProjects }) =>251 LandingProjects.match(projects, {252 Listed: ({ projects: listed }) => (253 <ul className="flex flex-col">
16 unmodified lines
270 ),271 Unreachable: () => <UnreachableNotice />,272 });273297/** The landing, as everyone reads it. */274export const LandingView = ({275 platformUrl,276 projects,277 webUrl,
100 unmodified lines
modified:apps/web/src/features/landing/projects.ts-7 removed
1/**2 * The landing's projects block: the eight that lead (the most open asks3 * first, a tie by name), or that the list did not come. The read that4 * fills it is `read.ts`'s.5 */1import { ProjectListing } from "@repo/protocol/domain/front-page";2import { Schema } from "effect";34import { leadingProjects, PROJECTS_SHOWN } from "../shared/project-order.ts";511/** The projects block: the ones that lead, or that the list did not come. */6export const LandingProjects = Schema.TaggedUnion({7 Listed: { projects: Schema.Array(ProjectListing) },8 Unreachable: {},9});1011export type LandingProjects = typeof LandingProjects.Type;1219/** The block from a list that came: the eight that lead. */13export const listedProjects = (14 projects: readonly ProjectListing[]15): LandingProjects =>16 LandingProjects.cases.Listed.make({
2 unmodified lines
modified:apps/web/src/features/landing/read.ts+2 added-9 removed
1/**2 * The landing's read on the server, as nobody, by the route's loader: the3 * platform's project list, so the page arrives with its projects for every4 * reader (a crawler and a reader with no script included) and the edge may5 * keep it. The list ignores the caller, so nobody's read is everyone's.2 * The list ignores the caller, so nobody's read is everyone's and the edge may3 * keep it.4 */5import { Client } from "@repo/protocol/contracts";6import { Effect } from "effect";78import { LandingProjects, listedProjects } from "./projects.ts";912/**13 * The first few projects, or, when the platform did not answer (a refusal,14 * or a call that died on the way), the block that says so. It never fails:15 * the page leads to the asks either way.16 */10export const readLandingProjects: Effect.Effect<11 LandingProjects,12 never,13 Client
10 unmodified lines
modified:apps/web/src/features/landing/transcript.ts+3 added-11 removed
1/**2 * The landing's evidence: the screen `git push` prints when an answer3 * strays outside its ask's territory, as the platform's gateway writes it.4 * The refusal's lines come from the one renderer (`explain`, `headline`),5 * so they cannot drift from what the gateway sends; git's own lines around6 * them (`To`, `! [remote rejected]`, `error:`) and the fork are the README's7 * screen, which `apps/platform/test/core-loop.test.ts` asserts from real8 * git.2 * The refusal's lines come from the one renderer, so they cannot drift from3 * what the gateway sends; git's own lines around them are what4 * `apps/platform/test/core-loop.test.ts` asserts from real git.5 */6import { RepoPath } from "@repo/protocol/ids";7import { OutOfScope } from "@repo/protocol/refusal";8import { explain, headline } from "@repo/protocol/render";914/** The fork the push goes to: datekit's `parse-iso`, claimed by alice. */10const FORK = "datekit--parse-iso--alice.git";1112const refusals = [13 new OutOfScope({ paths: [RepoPath.make("README.md")] }),14] as const;1521/** One line of the screen, and whether git printed it as the platform's (`remote:`). */16export interface TranscriptLine {17 readonly text: string;18 readonly remote: boolean;19}2027/** The push and what git prints back, against the platform at `platformUrl`. */21export const pushTranscript = (platformUrl: string) => {22 const remote = `${platformUrl.replace(/\/+$/u, "")}/${FORK}`;23 const tag = headline(refusals);2425 return {26 command: "git push",34 /** The refusal's tag, which the page sets in the refused colour. */27 tag,28 lines: [29 ...explain(refusals).map((text): TranscriptLine => ({30 remote: true,
14 unmodified lines
modified:apps/web/src/features/landing/words.ts+2 added-5 removed
1/**2 * The landing's two opening sentences, the README's, in a module of their3 * own: the route's `head` unfurls with the lede, and a route's head is4 * bundled with the route tree every page loads, so it must pull in no view.2 * A module of their own: a route's head is bundled with the route tree every3 * page loads, so it must pull in no view.4 */57/** The README's opening line: what the platform is. */6export const WHAT_IT_IS =7 "A Git platform for the boundary between a project and everyone else.";811/** The README's lede, the sentence the page unfurls with when its link is shared. */9export const LEDE =10 "Everything a project ships is public, its contribution process is typed code on main, and a push lands only by passing a typed gate.";
modified:apps/web/src/features/ledger/areas.ts-32 removed
1/**2 * What a ledger says about its sealed areas, folded from its entries, and3 * the one sentence its page opens on: the posture label, then each area's4 * count and authors ("Open with sealed evidence. export: 7 sealed checks5 * by 3 people."). A module with no view of its own.6 */1import { LedgerEntry } from "@repo/protocol/domain/visibility";2import type { Ledger } from "@repo/protocol/domain/visibility";3import type { AreaName, SuiteRoot } from "@repo/protocol/ids";4import type { DateTime } from "effect";5import { Option } from "effect";613/** An admission's evidence: when, how many green runs on main, how many known-bad trees it failed. */7export interface Admission {8 readonly at: DateTime.Utc;9 readonly knownBadCaught: number;10 readonly mainRuns: number;11}1220/** One sealed area, as its entries leave it. */13export interface AreaSummary {22 /** The admission of the area's current root; none when that root joined without one. */14 readonly admission: Option.Option<Admission>;15 readonly area: AreaName;25 /** How many people wrote the suite, as its latest commitment counts them. */16 readonly authors: Option.Option<number>;27 /** When any entry about the area was last recorded. */17 readonly changedAt: DateTime.Utc;29 /** How many sealed checks the area holds, as its latest count or commitment says. */18 readonly checks: number;31 /** The suite's salted root, as its latest commitment or admission names it. */19 readonly root: Option.Option<SuiteRoot>;20}2135/** What one entry says about an area, if it is about one. */22interface AreaFact {23 readonly admitted: Option.Option<Admission & { readonly suite: SuiteRoot }>;24 readonly area: AreaName;25 readonly at: DateTime.Utc;
1 unmodified line
27 readonly checks: Option.Option<number>;28 readonly root: Option.Option<SuiteRoot>;29}3045/** A fact that says nothing yet: each kind of entry fills in what it knows. */31const noFact: Omit<AreaFact, "area" | "at"> = {32 admitted: Option.none(),33 authors: Option.none(),34 checks: Option.none(),
29 unmodified lines
64 Released: () => [],65 ValueSet: () => [],66 });6783/** The ledger's entries in the order they were recorded. */68const recorded = (ledger: Ledger) =>69 ledger.entries.toSorted((one, other) => one.seq - other.seq);7087/** An area as its facts so far leave it: each later fact overrides what it says. */71interface Folded {72 readonly admissions: ReadonlyMap<SuiteRoot, Admission>;73 readonly area: AreaName;74 readonly authors: Option.Option<number>;
14 unmodified lines
89 checks: Option.orElse(fact.checks, () => before?.checks ?? Option.none()),90 root: Option.orElse(fact.root, () => before?.root ?? Option.none()),91});92110/**111 * Each sealed area's latest count, authors and root, when it last changed,112 * and the admission of its current root, folded from the entries in the113 * order they were recorded; areas by name.114 */93export const areaSummaries = (ledger: Ledger): readonly AreaSummary[] => {94 const areas = new Map<AreaName, Folded>();9596 for (const fact of recorded(ledger).flatMap(factsOf)) {
16 unmodified lines
113114export const plural = (count: number, one: string, many: string) =>115 `${count} ${count === 1 ? one : many}`;116139/** "export: 7 sealed checks by 3 people". */117export const areaHeadline = ({ area, authors, checks }: AreaSummary) =>118 `${area}: ${plural(checks, "sealed check", "sealed checks")}${Option.match(119 authors,120 {
1 unmodified line
122 onSome: (count) => ` by ${plural(count, "person", "people")}`,123 }124 )}`;125149/** The ledger's head sentence: what leads it, and the rest. */126export interface LedgerHead {127 readonly lead: string;128 readonly rest: string;129}130155/**156 * The ledger in one sentence, in two parts: its lead, the posture label,157 * and the rest, every sealed area's headline, or what it holds back when158 * no area is counted yet. A label that names the sealed areas ("Open with159 * sealed evidence · sealed checks in export, parser") leads with its160 * posture alone when the areas follow with their counts, so no area is161 * named twice; any other label leads whole.162 */131export const ledgerHead = (ledger: Ledger): LedgerHead => {132 const areas = areaSummaries(ledger);133134 if (areas.length > 0) {
19 unmodified lines
modified:apps/web/src/features/ledger/ledger-page.tsx+3 added-31 removed
1/**2 * A project's ledger, facts first. Its status line is one sentence: the3 * posture label the platform computed, then each sealed area's count and4 * authors ("Open with sealed evidence. export: 7 sealed checks by 35 * people."). Then each declared layer (its audience, holdings, disclosure,6 * reason and who reads and writes it), each sealed area folded from the7 * entries (its salted root, its admission record, when it last changed),8 * and the history: one typed line per entry, newest first. The inspector9 * holds the posture, what is held back, the CLI line and what each10 * disclosure means.11 *12 * Props in, markup out: the route reads the ledger (`src/client/ledger.ts`)13 * and hands it here. The ledger carries no path, no check name and no file14 * name, and nothing here adds one; the layer read log is maintainers' data15 * and never reaches the public ledger.2 * The ledger carries no path, no check name and no file name, and nothing here3 * adds one; the layer read log is maintainers' data and never reaches the4 * public ledger.5 */6import { Brand } from "@repo/brand";7import { LedgerEntry } from "@repo/protocol/domain/visibility";8import type { Layer, Ledger, Members } from "@repo/protocol/domain/visibility";
24 unmodified lines
33import { When } from "../shared/time.tsx";34import { areaHeadline, areaSummaries, ledgerHead, plural } from "./areas.ts";35import type { AreaSummary } from "./areas.ts";3648/** A day as a reader skims it: "Oct 11", in UTC. */37const dayOf = (at: DateTime.Utc) =>38 DateTime.formatUtc(at, { day: "numeric", locale: "en-US", month: "short" });3952/**53 * When the ledger was read, at the latest: `now`, or its newest entry's54 * time if that is later. The page keeps the `now` it was served with while55 * it reads the ledger again as entries arrive, and a recorded entry is never56 * in the future.57 */40const readAt = (ledger: Ledger, now: DateTime.Utc) => {41 let latest = now;4243 for (const entry of ledger.entries) {
2 unmodified lines
4647 return latest;48};4968/** The ledger's entries, newest first. */50const newestFirst = (ledger: Ledger) =>51 ledger.entries.toSorted((one, other) => other.seq - one.seq);5253const Code = ({ children }: { readonly children: ReactNode }) => (
1 unmodified line
55 {children}56 </code>57);5878/** The posture label leads, in its role; the areas follow in ink. */59const postureTone = {60 open: "text-foreground",61 openCore: "text-sealed",62 openOnSchedule: "text-sealed",63 openWithSealedEvidence: "text-sealed",64 sourceAvailable: "text-foreground",65} as const satisfies Record<Ledger["posture"], string>;6687/** The ledger's status line: its posture, then every sealed area, in one sentence. */67const HeadSentence = ({ ledger }: { readonly ledger: Ledger }) => {68 const { lead, rest } = ledgerHead(ledger);6970 return (
12 unmodified lines
83 </p>84 );85};86108/** Handles, each linked to their page, comma-separated. */87const Handles = ({ handles }: { readonly handles: readonly Handle[] }) =>88 handles.map((handle, index) => (89 <Fragment key={handle}>90 {index === 0 ? null : ", "}
45 unmodified lines
136 </Definitions>137 </li>138);139162/** "admitted Oct 11; passes main 3/3; catches 2 known-bad", or why there is none. */140const admissionWords = (summary: AreaSummary) =>141 Option.match(summary.admission, {142 onNone: () => "joined without admission runs",143 onSome: ({ at, knownBadCaught, mainRuns }) =>
40 unmodified lines
184 </Definitions>185 </li>186);187211/** Each kind of entry's word, and whether it is about something sealed. */188const kindOf = Match.type<LedgerEntry>().pipe(189 Match.tagsExhaustive({190 Admitted: () => ({ sealed: true, word: "Admitted" }),191 CommitmentPublished: () => ({ sealed: true, word: "Commitment changed" }),
4 unmodified lines
196 ValueSet: () => ({ sealed: true, word: "Value set" }),197 })198);199224/** One entry in words, as the ledger records it; its root, if it names one, is apart. */200const EntryWords = ({201 entry,202 project,203}: {
48 unmodified lines
252 ),253 })254 );255281/** The salted root an entry names, if it names one. */256const rootOf = (entry: LedgerEntry): Option.Option<string> =>257 LedgerEntry.match(entry, {258 Admitted: ({ suite }) => Option.some(suite),259 CommitmentPublished: ({ suite }) => Option.some(suite),
3 unmodified lines
263 Released: () => Option.none(),264 ValueSet: () => Option.none(),265 });266293/** One entry on one line: when, its kind's word, what it says, and its root. */267const EntryRow = ({268 entry,269 now,270 project,
53 unmodified lines
324 ))}325 </ol>326 );327355/** What each disclosure lets the public learn, one line each. */328const Disclosures = () => (329 <FactBlock label="What each disclosure shows">330 <ul className="flex flex-col gap-1.5">331 {Object.values(disclosureWords).map((words) => (
92 unmodified lines
modified:apps/web/src/features/markdown/markdown.tsx+4 added-48 removed
1/**2 * A Markdown file from a project's repo, rendered: a README on the3 * project and tree pages, a `.md` file on the blob page. Its links and4 * images resolve against `dir` at the commit `at`, so they stay inside the5 * project at that commit. The site's own Markdown (the docs) is drawn the6 * same way by `SiteMarkdown`, with nothing to resolve.7 *8 * react-markdown builds React elements (no `dangerouslySetInnerHTML`), so9 * the same component renders in the Worker and in the browser. What may10 * reach the page is decided by the plugin chain in `pipeline.ts`; this11 * file only draws the elements that come out of it.12 */1import type { CommitSha, ProjectName } from "@repo/protocol/ids";2import type { AnyRouter, RegisteredRouter } from "@tanstack/react-router";3import { Link, useRouter } from "@tanstack/react-router";4import type { ComponentProps, ReactNode } from "react";
3 unmodified lines
8import { literalPath } from "../shared/link.tsx";9import { rehypePluginsFor, remarkPlugins, sitePlugins } from "./pipeline.ts";1011export interface RepoMarkdownProps {24 /** The commit the file was read at; links and images point there. */12 readonly at: CommitSha;26 /** The file's directory, relative to the repo root; `""` is the root. */13 readonly dir: string;14 readonly project: ProjectName;29 /** The file's text. */15 readonly source: string;16}1718type AnchorProps = ComponentProps<"a"> & ExtraProps;1935/** A path on this origin (`/p/blob/…`), as `resolve.ts` leaves every in-project link. */20const isSameOrigin = (href: string) =>21 href.startsWith("/") && !href.startsWith("//") && !href.startsWith("/\\");2239/**40 * A link inside the project: a router `Link` when a router is there (the41 * app), so it opens without a full load; a plain link when none is (a42 * view rendered on its own, as the pages' tests render it).43 */23const ProjectLink = ({24 children,25 href,26 // The sanitizer never lets a `target` through.
7 unmodified lines
34 <a {...props} href={href}>35 {children}36 </a>37 ) : (59 // `href`, not `to`: the router parses a built href into path, query60 // and fragment, where `to` would keep `?raw=1#L3` inside the path. Its61 // `$` and braces escaped (`literalPath`): a file's name, never a param62 // the router fills from the page being read. A `string` target makes63 // `to` optional in the Link's props.38 // `href`, not `to`: the router parses a built href into path, query and39 // fragment, where `to` would keep `?raw=1#L3` inside the path.40 // `literalPath` escapes its `$` and braces, so a file's name is never a41 // param.42 <Link<RegisteredRouter, string, string> {...props} href={literalPath(href)}>43 {children}44 </Link>45 );46};4770/** `a`: in-project links through the router; links that leave go with no referrer and no endorsement. */48const Anchor = ({ children, href, node: _node, ...props }: AnchorProps) => {49 if (href !== undefined && isSameOrigin(href)) {50 return (51 <ProjectLink {...props} href={href}>
16 unmodified lines
68 </a>69 );70};7195/** `img`: loaded when scrolled to, decoded off the main thread, and sent with no referrer. */72const Image = ({73 alt,74 node: _node,75 ...props
8 unmodified lines
84);8586const components: Components = { a: Anchor, img: Image };87112/**113 * A README in the page's own type: body text at 16 px on a 70-character114 * measure, headings under the page's headline, code in the mono size on115 * the surface, links in ink. Colours come from the tokens116 * (`prose-tokens` in `styles.css`), so both schemes share these classes.117 */88const PROSE = [89 "prose prose-tokens text-body max-w-[70ch] min-w-0",120 // Headings on the scale: h1 and h2 at the title size, so the page's own121 // headline leads, the h1 ruled beneath; h3 and h4 at the want's size.90 "prose-headings:font-semibold prose-headings:tracking-[-0.01em]",91 "prose-h1:text-title prose-h1:mb-3 prose-h1:border-b prose-h1:border-rule prose-h1:pb-2",92 "prose-h2:text-title prose-h2:mt-8 prose-h2:mb-3",93 "prose-h3:text-want prose-h4:text-want",126 // Inline code: the mono face on a surface field, without backticks.94 "prose-code:before:content-none prose-code:after:content-none prose-code:font-normal",95 "[&_:not(pre)>code]:bg-surface [&_:not(pre)>code]:text-mono [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-px",129 // A code block: a field on the surface, ruled in a hairline.96 "prose-pre:bg-surface prose-pre:text-foreground prose-pre:border prose-pre:border-rule prose-pre:rounded-none",97 "prose-pre:text-mono prose-pre:leading-terminal prose-pre:px-4 prose-pre:py-3",132 // Links: ink, underlined in a hairline that darkens under the pointer.98 "prose-a:font-normal prose-a:decoration-input hover:prose-a:decoration-foreground",134 // Quotes as plain indented text, without the plugin's quotation marks.99 "prose-blockquote:font-normal prose-blockquote:not-italic",100 "[&_blockquote_p]:before:content-none [&_blockquote_p]:after:content-none",137 // Images inside the measure, set in the line as a README sets them.101 "prose-img:my-0 prose-img:inline-block prose-img:max-w-full",102 "prose-table:text-ui prose-th:font-semibold",103].join(" ");104
14 unmodified lines
119 </Markdown>120 </div>121);122160/**161 * The site's own Markdown (a page of the docs), in the README's type: its162 * links are the site's paths, through the router, and leave nothing to163 * resolve against a repo.164 */123export const SiteMarkdown = ({124 source,125}: {126 readonly source: string;
9 unmodified lines
136 </Markdown>137 </div>138);139182/** A README that is not Markdown (`README`, `README.txt`, `README.rst`): its text as written. */140export const RepoText = ({141 source,142}: {143 readonly source: string;
4 unmodified lines
148);149150const markdownExtension = /\.(?:markdown|md|mdown|mdwn|mkd|mkdn)$/iu;151195/** Whether a file renders as Markdown (`RepoMarkdown`) or as text (`RepoText`), by its name. */152export const isMarkdownPath = (path: string) => markdownExtension.test(path);
modified:apps/web/src/features/markdown/pipeline.ts+19 added-56 removed
1/**2 * The plugin chain that turns a project's Markdown into a safe tree, in3 * the one order that makes it safe (ADR 0019). It is the security property4 * of the README renderer, so it lives here alone and is tested whole5 * (`test/markdown.test.tsx`):6 *7 * 1. `remarkGfm`: tables, task lists, strikethrough, autolinks, footnotes;8 * 2. `rehypeRaw`: the README's own HTML (`<p align="center"><img …>`)9 * becomes elements, so everything after sees it;10 * 3. `rehypeRepoUrls`: relative links and media point into the project at11 * the SHA (`resolve.ts`), before the sanitizer judges them;12 * 4. `rehypeFootnoteIds`: the footnotes' ids and links lose the13 * `user-content-` remark-rehype gave them, since the sanitizer gives14 * every id that prefix next, and twice made `user-content-user-content-15 * fn-1` while the links named `user-content-fn-1`;16 * 5. `rehypeSanitize` with `schema`: GitHub's allow-list, the last gate on17 * what comes in (no script, no handler, no `javascript:` or `data:`18 * URL, no iframe, style or form; every `id` and `name` prefixed19 * `user-content-`, so a README cannot clobber the page's own globals);20 * 6. `rehypeSlug`: heading ids, after the sanitizer, so `#usage` finds21 * `## Usage` unprefixed;22 * 7. `rehypeFragmentLinks`: last, once every id is final, a `#x` link with23 * no `x` in the file points at `user-content-x` when that is there (a24 * footnote, a README's own `<a id>` or `<a name>`), as GitHub's page25 * script does. It only changes where a link inside the file points,26 * never an id.27 *28 * react-markdown's `defaultUrlTransform` stays on as a second net.2 * The order is the security property: 1. `remarkGfm`; 2. `rehypeRaw`, so3 * everything after sees the README's own HTML; 3. `rehypeRepoUrls`, before the4 * sanitizer judges the URLs; 4. `rehypeFootnoteIds`, dropping remark-rehype's5 * `user-content-` prefix, which the sanitizer adds next; 5. `rehypeSanitize`6 * with `schema`, the last gate (no script, handler, `javascript:` or `data:`7 * URL, iframe, style or form; every `id` and `name` prefixed, so a README8 * cannot clobber the page's globals); 6. `rehypeSlug`, after the sanitizer, so9 * `#usage` finds `## Usage` unprefixed; 7. `rehypeFragmentLinks`, last, once10 * every id is final. react-markdown's `defaultUrlTransform` stays on as a11 * second net.12 */13import { Predicate } from "effect";14import type { Element, Properties, Root } from "hast";15import type { Options } from "react-markdown";
6 unmodified lines
2223import { resolveRepoUrl } from "./resolve.ts";24import type { RepoUrlContext } from "./resolve.ts";2543/** A list of unified plugins, each with its options, as react-markdown takes them. */26export type PluggableList = NonNullable<Options["rehypePlugins"]>;2746/** Where a Markdown file was read: the project, the commit, and the file's directory (`""` is the root). */28export type MarkdownAt = Omit<RepoUrlContext, "kind">;2930/**50 * GitHub's allow-list (`hast-util-sanitize`'s `defaultSchema`), with a51 * code block's `language-…` class kept on `code`, and a `style` element52 * dropped with its CSS (the default drops only a `script` whole, so a53 * style's rules would show as text).31 * A code block's `language-…` class is kept, and a `style` element is dropped32 * with its CSS (the default drops only a `script` whole, so a style's rules33 * would show as text).34 */35export const schema: Schema = {36 ...defaultSchema,37 strip: [...(defaultSchema.strip ?? []), "style"],
5 unmodified lines
43 ],44 },45};4667/** Elements whose URL loads bytes into the page: they read the raw file. */47const media = new Set(["img", "source", "video"]);4870/** One `srcset` candidate (`url [descriptor]`), its URL resolved. */49const candidate = (value: string, at: RepoUrlContext) => {50 const [url = "", ...descriptor] = value.trim().split(/\s+/u);5152 return [resolveRepoUrl(url, at), ...descriptor].join(" ");53};5477/** Rewrite one URL property, when the element carries it as a string. */55const rewrite = (56 properties: Properties,57 key: "href" | "src" | "srcSet",58 to: (value: string) => string
18 unmodified lines
7778 const here = { ...at, kind: "media" } as const;7980 rewrite(node.properties, "src", (src) => resolveRepoUrl(src, here));104 // rehype-raw keeps `srcset` as written: one string, candidates split by commas.81 // rehype-raw keeps `srcset` as written: one string, candidates split by82 // commas.83 rewrite(node.properties, "srcSet", (srcSet) =>84 srcSet85 .split(",")86 .map((value) => candidate(value, here))87 .join(", ")88 );89};90113/**114 * A rehype plugin: every `a[href]` and every `img`, `video` and `source`115 * `src` (and `srcset`) resolved into the project at the SHA.116 */91export const rehypeRepoUrls = (at: MarkdownAt) => (tree: Root) => {92 visit(tree, "element", (node) => {93 resolveElement(node, at);94 });95};96123/** The prefix the sanitizer puts on every `id` and `name` (`hast-util-sanitize`'s default). */97const CLOBBER = schema.clobberPrefix ?? "user-content-";9899const unprefixed = (value: string, lead = "") =>100 value.startsWith(`${lead}${CLOBBER}`)101 ? `${lead}${value.slice(lead.length + CLOBBER.length)}`102 : value;103131/** Drop the prefix from one property, when the element carries it as a string. */104const unprefix = (properties: Properties, key: "href" | "id", lead = "") => {105 const value = properties[key];106107 if (Predicate.isString(value)) {
1 unmodified line
109 }110};111112/**141 * A rehype plugin: the footnotes remark-rehype made (a reference, a142 * footnote's item, a back-reference) lose the prefix it gave their ids and143 * links, so the sanitizer's prefix is their only one.113 * So the sanitizer's prefix is their only one; twice made114 * `user-content-user-content-fn-1`.115 */116export const rehypeFootnoteIds = () => (tree: Root) => {117 visit(tree, "element", (node, _index, parent) => {118 const { properties } = node;
21 unmodified lines
140 });141};142143/**173 * A rehype plugin, run last: a link to `#x` where the file has no `x` but174 * has `user-content-x` (the sanitizer's prefix) points there, so a175 * footnote and a README's own anchor jump. A target is an element's `id`176 * or an anchor's `name`, the two a browser scrolls to for a fragment.144 * As GitHub's page script does: a link to `#x` where the file has no `x` but145 * has `user-content-x` points there.146 */147export const rehypeFragmentLinks = () => (tree: Root) => {148 const ids = new Set<string>();149
29 unmodified lines
179};180181export const remarkPlugins: PluggableList = [remarkGfm];182214/** The rehype half of the chain for one file, in its fixed order. */183export const rehypePluginsFor = (at: MarkdownAt): PluggableList => [184 rehypeRaw,185 [rehypeRepoUrls, at],186 rehypeFootnoteIds,
1 unmodified line
188 rehypeSlug,189 rehypeFragmentLinks,190];191224/**225 * The rehype half of the chain for the site's own text (the docs): no raw226 * HTML and no repo to resolve links against, still sanitized, with heading227 * ids and fragment links as a README gets.228 */192export const sitePlugins: PluggableList = [193 [rehypeSanitize, schema],194 rehypeSlug,195 rehypeFragmentLinks,
1 unmodified line
modified:apps/web/src/features/markdown/resolve.ts+6 added-22 removed
1/**2 * Where a link or an image in a project's Markdown file points, inside the3 * web: the file was read at one commit, in one directory, so a relative4 * URL names a path in that commit's tree, as GitHub resolves a README's5 * links. The result always names the SHA, never `main`, so it reads the6 * same tree forever (and a raw image caches forever, ADR 0019).7 *8 * Pure, so the rules are table-tested on their own; `pipeline.ts` runs it9 * over the rendered tree before the sanitizer sees it.2 * The result always names the SHA, never `main`, so it reads the same tree3 * forever.4 */5import type { CommitSha, ProjectName } from "@repo/protocol/ids";613/** Where the file was read: the project, the commit, its directory, and what kind of URL this is. */7export interface RepoUrlContext {15 /** The file's directory, relative to the repo root; `""` is the root. */8 readonly dir: string;17 /** A link opens a page (`blob`, or `tree` for a folder); media loads the raw bytes. */9 readonly kind: "link" | "media";10 readonly project: ProjectName;11 readonly sha: CommitSha;12}1323/** A URL scheme (`https:`, `mailto:`, `javascript:` …): the URL leaves the repo, and the sanitizer judges it. */14/**15 * A URL scheme (`https:`, `mailto:`, `javascript:` …): the URL leaves the repo,16 * and the sanitizer judges it.17 */18const scheme = /^[a-z][a-z0-9+.-]*:/iu;1926/** A base no reader resolves against; only its path is kept. */20const base = "https://repo.invalid/";2122const edgeSlashes = /^\/+|\/+$/gu;2331/** Media reads raw bytes; a link opens a folder (`tree`) when its path ends in `/`, else a file (`blob`). */24const routeOf = (kind: RepoUrlContext["kind"], pathname: string) => {25 if (kind === "media") {26 return "raw";27 }
1 unmodified line
29 return pathname.endsWith("/") ? "tree" : "blob";30};3132/**41 * Resolve `url` against the file's directory at `sha`:42 *43 * - `#…`, `""`, `//host…` and anything with a scheme come back as written;44 * - `/x` starts at the repo root, anything else at `dir`; `..` stops at45 * the root (the URL parser clamps it), and a `?query` and `#hash` stay;46 * - a link becomes `/<project>/blob/<sha>/<path>`, or `/tree/` when it ends47 * in `/` (a folder); media becomes `/<project>/raw/<sha>/<path>`.48 *33 * Only the parsed path is kept, so a URL the parser reads as another host34 * (`/\host/x`) still lands inside the project.35 */36export const resolveRepoUrl = (url: string, at: RepoUrlContext): string => {
27 unmodified lines
modified:apps/web/src/features/people/person-page.tsx+2 added-23 removed
1/**2 * A person's page: their credit, read from the trailers on landed commits,3 * grouped by project and then by area, each area one sentence of the roles4 * they hold there ("Answered and asked in datekit/src"), linked to the5 * project's landings. Credit gates nothing and ranks no one (GLOSSARY.md6 * "Credit", "Record"): the read counts landings per role, and the page7 * draws none of those counts, orders by name, and adds nothing up.2 * Credit gates nothing and ranks no one: the page draws none of the read's3 * counts, orders by name, and adds nothing up.4 */5import { CreditRole } from "@repo/protocol/domain/credit";6import type { CreditSummary } from "@repo/protocol/domain/record";7import type { Handle, ProjectName } from "@repo/protocol/ids";
6 unmodified lines
14import { MetaCode, MetaLine, Row, RowGroup } from "../shared/row.tsx";15import { projectSections } from "../shared/shell/sections.ts";16import { Workspace } from "../shared/shell/workspace.tsx";1722/** One area of a project: each role a person holds there. */18export interface AreaCredit {19 readonly area: string;20 readonly roles: readonly CreditRole[];21}2228/** One project: the areas a person is credited in. */23export interface ProjectCredit {24 readonly areas: readonly AreaCredit[];25 readonly project: ProjectName;26}2734/** Each role as the sentence says it, in the past: the trailer names what they did. */28const ROLE_WORD = {29 "Advised-by": "advised",30 "Asked-by": "asked",31 "Decided-by": "decided",
2 unmodified lines
34 "Released-by": "released",35 "Signed-off-by": "answered",36} as const satisfies Record<CreditRole, string>;3745/**46 * The order a sentence names roles in: the answer first (it is the work47 * the landing is), then the trailers' own order.48 */38const SENTENCE_ORDER: readonly CreditRole[] = [39 "Signed-off-by",40 ...CreditRole.literals.filter((role) => role !== "Signed-off-by"),41];
1 unmodified line
43const bySentence = Order.mapInput(Order.Number, (role: CreditRole) =>44 SENTENCE_ORDER.indexOf(role)45);4658/** Words joined as a sentence lists them: `a`, `a and b`, `a, b and c`. */47const listed = (words: readonly string[]) =>48 words.length < 249 ? words.join("")50 : `${words.slice(0, -1).join(", ")} and ${words.at(-1) ?? ""}`;5164/** Where an area sits, in words: "the whole project" for its root. */52const whereOf = (project: string, area: string) =>53 area === "." || area === "" ? "the whole project" : `${project}/${area}`;5468/**69 * An area's roles as one sentence: "Answered and asked in datekit/src",70 * "Decided in the whole project".71 */55export const areaSentence = (56 project: string,57 area: string,58 roles: readonly CreditRole[]
6 unmodified lines
6566 return `${sentence.charAt(0).toUpperCase()}${sentence.slice(1)}`;67};6886/** `rows` grouped by `key`, the groups in the order their keys sort. */69const groupBy = <A,>(70 rows: readonly A[],71 key: (row: A) => string72): readonly Array.NonEmptyReadonlyArray<A>[] =>73 Object.entries(Array.groupBy(rows, key))74 .toSorted(([one], [other]) => one.localeCompare(other))75 .map(([, group]) => group);7695/** A person's credit by project, then by area (each by name), each area's roles once each. */77export const creditsByProject = (78 credits: readonly CreditSummary[]79): readonly ProjectCredit[] =>80 groupBy(credits, ({ project }) => project).map((inProject) => ({
8 unmodified lines
89 })),90 project: Array.headNonEmpty(inProject).project,91 }));92112/** The project's landings, where an area's credits are the trailers. */93const landingsOf = (project: ProjectName) =>94 projectSections(project).find(({ tab }) => tab === "landings")?.to ??95 projectPath(project);96
58 unmodified lines
155 </Workspace>156 );157};158179/** The page for an address whose last part cannot be a handle. */159export const NoSuchPersonView = () => (160 <PageShell title="No such person">161 <EmptyState162 onward={<AppLink to={ASKS_PATH}>Open asks</AppLink>}
4 unmodified lines
modified:apps/web/src/features/project/asks.tsx-15 removed
1/**2 * A project's open asks as rows: each ask its want first and its state at3 * the right, with its claim command when it is open; a family drawn as its4 * parent's row with the fan under it and its children listed, so a reader5 * sees how many of them landed and which wait.6 */1import type { Ask, AskListing } from "@repo/protocol/domain/ask";2import type { AskId, ProjectName } from "@repo/protocol/ids";3import type { DateTime } from "effect";4import type { ReactNode } from "react";
2 unmodified lines
7import type { AskProgress } from "../shared/ask-progress.ts";8import { FamilyStrip } from "../shared/family.tsx";9import { AskRow, RowList } from "../shared/row.tsx";1017/** Whether an ask is open to take as its listing says: nobody holds it, it waits on nothing, and it is held for nobody. */11export const openToTake = (listing: AskListing) =>12 !listing.claimed &&13 listing.blockedBy.length === 0 &&14 listing.reserve === undefined;1523/**24 * The asks a project counts as open: every one listed, but a family's25 * delete child while it waits on its siblings (it opens when they land).26 */16export const openAsks = (listings: readonly AskListing[]) => {17 const finales = new Set(18 arrange(listings).flatMap((item) =>19 item.kind === "family" ? [item.finale] : []
4 unmodified lines
24 ({ ask, blockedBy }) => !(finales.has(ask) && blockedBy.length > 0)25 );26};2739/** The project's asks, families as fans with their children listed. */28export const AskList = ({29 asks,30 now,31 onSelect,
5 unmodified lines
37}: {38 readonly asks: readonly AskListing[];39 readonly now: DateTime.Utc;40 readonly project: ProjectName;53 /** Each family's parent in full, which counts its children. */41 readonly parents: readonly Ask[];42 readonly states: ReadonlyMap<AskId, AskProgress>;43 readonly stamps: ReadonlySet<AskId>;44 readonly selected: string | undefined;
20 unmodified lines
65 }6667 const parent = parents.find(({ id }) => id === item.parent.ask);6882 // A parent the platform did not give in full: its members stay rows.69 if (parent === undefined) {70 return [71 row(item.parent),72 ...item.members.map((member) => row(member)),
20 unmodified lines
93 </RowList>94 );95};96111/** Row ids in the order `AskList` draws them: what `j` and `k` walk. */97export const askListIds = (asks: readonly AskListing[]) =>98 arrange(asks).map((item) =>99 item.kind === "ask" ? item.listing.ask : item.parent.ask100 );
modified:apps/web/src/features/project/landings.tsx+2 added-17 removed
1/**2 * A project's recent landings as one-line credits: what the landing did (the3 * ask it answered or opened), who is credited, in one sentence of roles,4 * and when. The full trailers are the landing's own, on its commit's page.5 */1import type { LandingView } from "@repo/protocol/domain/landing";2import { Option } from "effect";3import type { DateTime } from "effect";4
2 unmodified lines
7import { askPath } from "../shared/paths.ts";8import { When } from "../shared/time.tsx";9import { askOf } from "../why/rows.ts";1016/** How many landings the project's home shows. */11export const RECENT_SHOWN = 3;1213/**20 * A landing's subject line. The platform writes `Answer <ask>` on a landing21 * that answers an ask; `LandingView` carries no subject for the rest, so22 * those read by what they are: an ask's opening as `Open ask <ask>`, then a23 * decider's own landing and the first adoption.14 * `LandingView` carries a subject only for `Answer <ask>`, so the rest read by15 * what they are.16 */17export const landingSubject = (landing: LandingView) =>18 Option.match(askOf(landing), {19 onNone: () =>
1 unmodified line
21 onSome: ({ ask, kind }) =>22 kind === "opened" ? `Open ask ${ask}` : `Answer ${ask}`,23 });2433/**34 * The landings the project's home shows, newest first: the last three35 * answers once three have landed, so the landings that set the project up36 * (its first push, its openings) give way to the work people did; before37 * then, the last three of any kind.38 */25export const recentShown = (26 landings: readonly LandingView[]27): readonly LandingView[] => {28 const answers = landings.filter((landing) => landing.ask !== undefined);
41 unmodified lines
70 </li>71 );72};7388/** The landings given, each as one line of credit. */74export const LandingList = ({75 landings,76 now,77}: {
9 unmodified lines
modified:apps/web/src/features/project/posture-label.ts+3 added-11 removed
1/**2 * A posture in the words GLOSSARY.md gives it ("Posture"). The project list3 * and the front page carry only the literal; the fuller label the platform4 * computes from a project's visibility config ("Open · sealed checks in5 * parser") is the ledger's. Until a listing carries that6 * label, each posture reads as its own name, never as a claim about what is7 * sealed.2 * The project list carries only the literal; until it carries the platform's3 * full label, each posture reads as its own name, never as a claim about what4 * is sealed.5 */6import type { Posture } from "@repo/protocol/posture";78const labels = {
5 unmodified lines
14} as const satisfies Record<Posture, string>;1516export const postureLabel = (posture: Posture): string => labels[posture];1721/**22 * A posture in its short form: the one the rail and a project's head both23 * say, so a project reads the same in both places (the platform's full24 * label is its title).25 */18const words = {19 open: "Open",20 openCore: "Open core",21 openOnSchedule: "Open on schedule",
5 unmodified lines
modified:apps/web/src/features/project/project-nav.tsx-11 removed
1/**2 * A project's section row: Asks, Code, Landings, Refs, Policy, Ledger and3 * Env shape, one line under the page's head where the rail is not drawn4 * (below 1120 px; from there the rail lists them). The line scrolls5 * sideways inside itself and never wraps, so it never pushes the page6 * sideways. The page being read is marked `aria-current` and underlined in7 * ink; a page under none of them (a proposal) marks none.8 *9 * Its links are the router's (`AppLink`), so moving between sections never10 * reloads the page.11 */1import type { ProjectName } from "@repo/protocol/ids";2import type { ReactNode } from "react";34import { AppLink } from "../shared/link.tsx";
29 unmodified lines
modified:apps/web/src/features/project/project-page.tsx+5 added-65 removed
1/**2 * A project's home, which is its list of asks: its name, its posture and3 * when it last landed; its open asks, a family drawn as a fan with its4 * children listed; then its README. Beside them, how a change lands here:5 * the posture, the gate, who decides, what is held back, the commands that6 * take part, and the last landings; or the selected ask's facts, one Escape7 * from them. Props in, markup out: the route reads the asks, the ledger,8 * the events, the policy and the code on the server and keeps them live in9 * the browser, and hands them here.10 */1import { IMPORTED_NOTE } from "@repo/agent-kit/docs/imported-note";2import { Brand } from "@repo/brand";3import type { Ask, AskListing } from "@repo/protocol/domain/ask";4import type { FileView, TreeListing } from "@repo/protocol/domain/code";
38 unmodified lines
43import { postureLabel, postureWord } from "./posture-label.ts";44import { ProjectNav } from "./project-nav.tsx";45import { ReadmeSection } from "./readme-section.tsx";4657/** A project's code as its home reads it: the root folder at main, and its README. */47export interface ProjectCode {48 readonly readme?: FileView | undefined;49 readonly root: TreeListing;50}5163/** Who decides for which paths, as the project's policy says. */52export interface Deciders {53 readonly handles: readonly Handle[];54 readonly paths: Glob;55}5669/** One area a layer holds checks in, and how many. */57export interface HeldBackArea {58 readonly area: AreaName;72 /** How many sealed checks it holds. */59 readonly checks: number;60 readonly detail: string;61}6277/** An entry that says nothing about an area's count. */63const noCount = (): readonly (readonly [AreaName, number])[] => [];6480/**81 * What a project holds back, from its ledger: each sealed area and how many82 * checks it holds, as the latest count or commitment says.83 */65export const heldBackOf = (ledger: Ledger): readonly HeldBackArea[] => {66 const checks = new Map(67 ledger.entries68 .toSorted((a, b) => a.seq - b.seq)
21 unmodified lines
90 }));91};9293/**113 * The project as its home knows it: its name, its open asks, when it last114 * landed, and its posture once its own ledger has said it. Until then the115 * page says no posture, never one it was not told.94 * Until its own ledger has said it, the page says no posture, never one it was95 * not told.96 */97export type HomeListing = Omit<ProjectListing, "posture"> & {98 readonly posture?: Posture | undefined;99};100121/** The project for its home, from what was read: the posture only from its own ledger. */101export const homeListing = ({102 asks,103 ledger,104 project,
6 unmodified lines
111 posture: ledger?.posture,112 project,113});114136/** A posture known, in the platform's words. */115interface KnownPosture {116 readonly label: string;117 readonly posture: Posture;118}119120export interface ProjectViewProps {143 /** The open asks; none while they are read, and none when they could not be. */121 readonly asks: readonly AskListing[] | undefined;145 /** Whether the asks could not be read: the platform did not answer. */122 readonly unreachable?: boolean;147 /** The project's landings, newest first. */123 readonly landings: readonly LandingView[];149 /** The project: its posture (once its ledger is read), when it last landed, its open asks. */124 readonly listing: HomeListing;151 /** When it last landed, as its events say, over what the listing says. */125 readonly lastLanded?: DateTime.Utc | undefined;153 /** Its posture in the platform's words, from its own ledger. */126 readonly postureLabel?: string | undefined;155 /** What it holds back, from its ledger; none while it is read. */127 readonly heldBack?: readonly HeldBackArea[] | undefined;157 /** Who decides for which paths; none while the policy is read or when it has none. */128 readonly deciders?: readonly Deciders[] | undefined;159 /** Where it was imported from; none for a project that started empty, or while the policy is read. */129 readonly importedFrom?: ImportSource | undefined;130 readonly now: DateTime.Utc;131 readonly platformUrl: string;163 /** The root folder at main and its README, once read. */132 readonly code?: ProjectCode | undefined;165 /** Each family's parent in full, which counts its children. */133 readonly parents?: readonly Ask[];167 /** Where each ask stands, from the project's events. */134 readonly states?: ReadonlyMap<AskId, AskProgress>;169 /** The children that landed while the page was open. */135 readonly stamps?: ReadonlySet<AskId>;171 /** The selected ask in full, once the browser has read it. */136 readonly selectedAsk?: Ask | undefined;173 /** Whether someone is signed in, who may propose an ask. */137 readonly signedIn?: boolean;138}139177/** Who decides, one line per set of paths, at most three, then the policy. */140const WhoDecides = ({141 deciders,142 project,143}: {
29 unmodified lines
173 </FactBlock>174 );175};176215/** Where an imported project came from: its source, the branch adopted, and what a copy is. */177const ImportedFrom = ({ source }: { readonly source: ImportSource }) => (178 <FactBlock label="Imported from">179 <p className="text-ui">180 <a
15 unmodified lines
196 </p>197 </FactBlock>198);199239/** The four commands that take part, in the order a newcomer runs them. */200const TakePart = ({201 platformUrl,202 project,203}: {
20 unmodified lines
224 </FactBlock>225);226227/**268 * The last landings. Before the project's main first lands, the push that269 * lands it is its initializer's; after it, the replay may still hold no270 * landing event, since adopting main is not one: say so, never "nothing271 * landed".228 * Adopting main is not a landing event, so the replay may hold no landing:229 * never say "nothing landed".230 */231const RecentLandings = ({232 landedAt,233 landings,
33 unmodified lines
267268 return <FactBlock label="Recent landings">{shown}</FactBlock>;269};270313/** How a change lands here: the facts with nothing selected; the posture is the head's to say. */271const HowItLands = ({272 deciders,273 heldBack,274 importedFrom,
30 unmodified lines
305 <ForAgents href={`/${listing.project}/llms.txt`} />306 </>307);308352/**353 * How a change lands here, in one sentence built only from typed facts:354 * the gate, the paths deciders are set for, what is held back (the ledger355 * linked from it), and when it last landed. The one place the project's356 * own pages state it; the inspector carries the same as facts.357 */309const RuleSentence = ({310 deciders,311 heldBack,312 landedAt,
38 unmodified lines
351 </p>352 );353};354404/** The project line: its posture and its open asks; its README's first sentence; then its one rule sentence. */355const ProjectLine = ({356 count,357 lede,358 posture,
5 unmodified lines
364 readonly rule: ReactNode;365}) => (366 <div className="flex flex-col gap-3">367 <p className="text-ui text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-1">418 {/* The posture in the short form the rail says, the platform's own419 label its title; its dot after it, so a line never opens on one. */}368 {/* Its dot after it, so a line never opens on one. */}369 {posture === undefined ? null : (370 <span className="flex items-center gap-x-2">371 <PostureBadge372 label={postureWord(posture.posture)}
13 unmodified lines
386 {rule}387 </div>388);389441/** The asks' place on the page, as far as they have been read. */390const AsksSection = ({391 asks,392 now,393 onSelect,
57 unmodified lines
451 </section>452 );453};454507/** Whichever facts the inspector shows: how a change lands here, or the selected ask's. */455const PageFacts = ({456 landedAt,457 picked,458 posture,
44 unmodified lines
503 />504 );505};506560/** A list's count at the context bar's end: "7 open asks, 6 open to take". */507const countOf = (open: readonly AskListing[]) =>508 `${plural(open.length, "open ask", "open asks")}, ${509 open.filter(openToTake).length510 } open to take`;511566/** The page, with the selection the list keeps (or none, outside a router). */512const ProjectPanes = ({513 props,514 select,515 selected,
100 unmodified lines
616617 return <ProjectPanes props={props} select={select} selected={selected} />;618};619675/**676 * The project's home. Inside the router its list selects (`?ask=`) and `j`677 * and `k` walk it; a view rendered alone draws the same page with nothing678 * selected.679 */620export const ProjectView = (given: ProjectViewProps) => {621 const props = {622 ...given,623 asks: given.asks && stillWaiting(given.asks),
8 unmodified lines
modified:apps/web/src/features/project/readme-section.tsx-6 removed
1/**2 * A README (or any Markdown file) under its own name, rendered on the3 * project's prose: a project's home shows its root README below its asks,4 * and a folder or a Markdown file shows its own. Its first sentence is the5 * project's lede, under the project's name (`ledeOf`, `features/front/head.ts`).6 */1import type { FileView } from "@repo/protocol/domain/code";2import type { ProjectName } from "@repo/protocol/ids";34import { dirOf } from "../code/paths.ts";
31 unmodified lines
modified:apps/web/src/features/project/unknown-project.tsx-7 removed
1/**2 * The page for an address that names no project: the platform's own3 * refusal, `UnknownProject`, as `git` and the CLI would print it, then the4 * way onward. An address that cannot be a project's name at all says so in5 * a sentence.6 */1import { ProjectName } from "@repo/protocol/ids";2import { UnknownProject } from "@repo/protocol/refusal";3import { Option, Schema } from "effect";4
6 unmodified lines
11const decodeProject = Schema.decodeUnknownOption(ProjectName);1213const LINK = "decoration-rule underline hover:decoration-current";1421/** Where to go instead: every open ask. */15const Onward = () => (16 <div className="text-ui flex flex-wrap gap-x-4 gap-y-1">17 <AppLink className={LINK} to={ASKS_PATH}>18 Open asks
24 unmodified lines
modified:apps/web/src/features/project-people/people-view.tsx-44 removed
1/**2 * A project's policy (its section reads "Policy"; its address stays3 * `/$project/people`), as its config folder states it at the landed4 * commit: who decides which paths, the vouch rule and the vouch file's5 * lines, the caps, budget and timings, and whether landings disclose6 * agents. The layers are one line that links the ledger, where who reads7 * and writes each one is told. The head says which commit and which file8 * it is read from; the inspector says how to change any of it.9 *10 * Props in, markup out: the route reads `projectPolicy` and `ledger`11 * (`src/client/{policy,ledger}.ts`) and hands them here. With no policy at12 * the landed commit, the page says why (`unevaluated`: no config folder, or13 * one that did not evaluate), names the commit and says what makes it14 * evaluate; with no reason either, nothing has landed yet. The page is15 * read-only: the one way to change any of it is to land a change to the16 * config folder, and it says so with the commands.17 */1import { Brand } from "@repo/brand";2import type { PolicyPending, PublicPolicy } from "@repo/protocol/domain/policy";3import type { Ledger } from "@repo/protocol/domain/visibility";4import type { Handle, ProjectName } from "@repo/protocol/ids";
13 unmodified lines
18import { Workspace } from "../shared/shell/workspace.tsx";1920type Vouches = PublicPolicy["vouches"];2139/** The project's config file, `project.ts` in the config folder. */22const PROJECT_FILE = `${Brand.configDir}/project.ts`;2342/** The config folder as a reader writes it: `<configDir>/`. */24const CONFIG_DIR = `${Brand.configDir}/`;2526const HOUR_MS = 3_600_000;27
1 unmodified line
2930const plural = (count: number, one: string, many: string) =>31 `${count} ${count === 1 ? one : many}`;3252/** A claim timing as a reader says it: whole hours up to two days, then days. */33const spanOf = (ms: number) => {34 if (ms % HOUR_MS !== 0) {35 return plural(Math.round(ms / 60_000), "minute", "minutes");36 }
4 unmodified lines
41 ? plural(hours / 24, "day", "days")42 : plural(hours, "hour", "hours");43};4465/** What a vouch gates, in words. */45const vouchModes = {46 all: "For everything: claiming an ask, offering a sealed answer and proposing an ask all need a vouch.",47 bansOnly:48 "Bans only: nobody needs a vouch, but a denounced person still may not claim, push or propose.",
6 unmodified lines
55 {children}56 </code>57);5880/** A file or a commit in running text: mono, linked. */59const CodeLink = ({60 children,61 to,62}: {
4 unmodified lines
67 {children}68 </AppLink>69);7093/** Handles, each linked to their page, comma-separated. */71const Handles = ({ handles }: { readonly handles: readonly Handle[] }) =>72 handles.map((handle, index) => (73 <Fragment key={handle}>74 {index === 0 ? null : ", "}75 <HandleLink handle={handle} />76 </Fragment>77 ));78102/** "As of 71fda27, from <config folder>/project.ts", each linked; or the platform's defaults. */79const AsOf = ({80 policy,81 project,82}: {
17 unmodified lines
100 )}101 </>102);103128/** Who decides each path: the path in mono, then its deciders. */104const Deciders = ({105 deciders,106}: {107 readonly deciders: PublicPolicy["deciders"];
84 unmodified lines
192 </Region>193 );194};195221/** A number a reader compares: set in tabular figures. */196const Num = ({ children }: { readonly children: string }) => (197 <span className="tabular-nums">{children}</span>198);199
47 unmodified lines
247 </p>248 </Region>249);250277/** The layers' one line: each by name and disclosure, and a link to the ledger. */251const LayersLine = ({252 ledger,253 project,254}: {
33 unmodified lines
288 .289 </p>290 );291319/**320 * The layers in one line, under a heading of their own: each by name and321 * disclosure, held back, and the ledger, where who reads and writes each322 * one is told. Nothing else.323 */292const Layers = ({293 ledger,294 project,295}: {
4 unmodified lines
300 <LayersLine ledger={ledger} project={project} />301 </Region>302);303336/** The page over an evaluated policy: each of its sections. */304const Evaluated = ({305 ledger,306 policy,307 project,
15 unmodified lines
323 <Layers ledger={ledger} project={project} />324 </>325);326360/** The landed commit, short and linked: "The config at the landed commit <sha> has not been evaluated". */327const NotEvaluated = ({328 at,329 project,330}: {
6 unmodified lines
337 {" has not been evaluated"}338 </>339);340375/**376 * Why the config at the landed commit has not been evaluated, and what377 * makes it evaluate: a `project.ts` naming the test command, or a fix to378 * the folder that did not evaluate. Either way, it evaluates again at379 * every landing.380 */341const Pending = ({342 pending,343 project,344}: {
45 unmodified lines
390 </p>391 </div>392);393434/** One way to change the policy: what it does, then its command, a flag to a line. */394const Step = ({395 command,396 label,397}: {
5 unmodified lines
403 <CommandLine command={command} numbered />404 </div>405);406448/** `command`, then each flag with its value on a line of its own. */407const lines = (command: string, flags: readonly string[]) =>408 [command, ...flags].join(" \\\n ");409452/** How the policy changes: by a landing to the config folder, never here. */410const ChangeFacts = ({ project }: { readonly project: ProjectName }) => (411 <FactBlock label="How to change these">412 <p className="text-ui">413 {`Land a change to ${CONFIG_DIR}: open an ask for it, or, as a decider, land your own from a clone.`}
28 unmodified lines
442}: {443 readonly ledger: Ledger;444 readonly policy: Option.Option<PublicPolicy>;445 readonly project: ProjectName;489 /** Why there is no policy at the landed commit; none before the first landing. */446 readonly unevaluated: Option.Option<PolicyPending>;447}): ReactNode => (448 <Workspace449 facts={<ChangeFacts project={project} />}
22 unmodified lines
modified:apps/web/src/features/proposal/client-file.tsx+2 added-10 removed
1/**2 * A drafted file (the ask file or its check), drawn in the browser only.3 * The server renders the file's path as a heading and its text in a4 * `<pre>`; after hydration the browser loads `@pierre/diffs` and draws it5 * highlighted. `import.meta.env.SSR` is `true` in the Worker's build, so the6 * dynamic import below is dead code there and the Worker bundles none of it7 * (`bytes:check`), as `features/code/client-code.tsx` does.2 * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic import3 * below is dead code there and the Worker bundles none of it.4 */5import { ClientOnly } from "@tanstack/react-router";6import { lazy, Suspense } from "react";712// A type-only import is erased, so the server bundles nothing of it.8import type { DraftedFileProps } from "./drafted-file.tsx";910const DraftedFileLater = import.meta.env.SSR11 ? undefined12 : lazy(() => import("./drafted-file.tsx"));1319/** The file's text as the server and a reader without JavaScript see it. */14const Plain = ({ content }: { readonly content: string }) => (15 <pre className="border-rule bg-surface text-mono leading-code overflow-x-auto border px-3 py-2 font-mono">16 {content}17 </pre>18);1926/** One drafted file under its path: a heading, then the code. */20export const DraftedCode = ({21 content,22 heading: Heading = "h3",23 path,24}: DraftedFileProps & {32 /** The heading level the path takes in its page. */25 readonly heading?: "h3" | "h4";26}) => {27 const fallback = <Plain content={content} />;28
17 unmodified lines
modified:apps/web/src/features/proposal/drafted-file.tsx-10 removed
1/**2 * One drafted file, drawn by `@pierre/diffs`: the ask file or its check,3 * highlighted by Shiki's JavaScript engine (never its WASM one). Nothing is4 * selectable or anchored here: a page may hold several of these, and the5 * file's own page is the place for `#L` anchors.6 *7 * The library and Shiki's grammars are megabytes, so only the browser8 * loads this module (`client-file.tsx`); the Worker never bundles it.9 */1import { File } from "@pierre/diffs/react";2import type { FileOptions } from "@pierre/diffs/react";3import { useMemo } from "react";4
8 unmodified lines
13}1415const options: FileOptions<undefined, undefined> = {16 ...diffsOptions,26 // The page names the file in its own heading above the code.17 disableFileHeader: true,18 overflow: "scroll",19};20
17 unmodified lines
modified:apps/web/src/features/proposal/failure.tsx-10 removed
1/**2 * A call the propose, proposal or decision pages sent, failed. A session3 * that ended (or never began) asks the reader to sign in and come back to4 * the same address, so the form, the proposal or the decision is where5 * they left it; a refusal reads as the platform gave it, through6 * `RefusalView`; anything else is the platform not answering, in ink,7 * never as a refusal.8 */1import { Unauthenticated } from "@repo/protocol/principal";2import { Refusal } from "@repo/protocol/refusal";3import { Cause, Option, Schema } from "effect";4import { LogIn } from "lucide-react";
11 unmodified lines
16 doing,17 here,18}: {19 readonly cause: Cause.Cause<unknown>;28 /** What the reader was doing, as "Sign in to …" ends: `propose it`. */20 readonly doing: string;30 /** The page's own address (`hereOf`), where sign-in comes back to. */21 readonly here: string;22}) => {23 const error = Cause.findErrorOption(cause);24
28 unmodified lines
modified:apps/web/src/features/proposal/live-draft.ts-15 removed
1/**2 * Where a proposal's draft stands, read live for a view that is not handed3 * it: the decision card on Today holds Accept until the browser has read the4 * proposal's draft, and while the platform's agent drafts it again. The read5 * is `showProposal` (`client/proposal.ts`), which `ProposalDrafted`6 * refreshes; on the server, and until it answers, nothing is read yet.7 */1import { useAtomValue } from "@effect/atom-react";2import type { ShowProposal } from "@repo/protocol/contracts";3import type { DraftState } from "@repo/protocol/domain/proposal";4import type { ProjectName, ProposalId } from "@repo/protocol/ids";
1 unmodified line
6import { AsyncResult } from "effect/reactivity";78import { proposalAtom } from "../../client/proposal.ts";917/**18 * What the browser has read of a proposal's draft: nothing (`Unread`), yet19 * or because the read `failed`; or the draft it read, `None` for a20 * proposal no agent drafted (a want alone).21 */10export type DraftRead = Data.TaggedEnum<{11 Read: { readonly draft: Option.Option<DraftState> };12 Unread: { readonly failed: boolean };13}>;1427/** Constructors and guards for a draft read. */15export const DraftRead = Data.taggedEnum<DraftRead>();1630/** A draft read: `draft`, or none for a proposal no agent drafted. */17export const readDraft = (draft?: DraftState): DraftRead =>18 DraftRead.Read({ draft: Option.fromUndefinedOr(draft) });1934/** The draft a `showProposal` read holds: once it answered, or why there is none yet. */20export const draftReadOf = (21 result: AsyncResult.AsyncResult<22 typeof ShowProposal.successSchema.Type,23 unknown
11 unmodified lines
modified:apps/web/src/features/proposal/proposal-view.tsx+4 added-47 removed
1/**2 * One proposal, as its proposer and its deciders follow it. The title is3 * its want; under it, where the platform's draft stands in the outcome's4 * words: drafting (the checking role), ready and waiting for a decider (the5 * waiting role), or a failed round, drawn by `RefusalView` when the round6 * failed with a refusal the page can draw whole, else as an ink line. Then7 * the draft read as a guide, in the order it was made: the ask file (its8 * want, territory and kind as rows, its source behind a disclosure), the9 * check (its source), and red first (the run that failed twice the same10 * way, its assertion once).11 *12 * "Let the platform's agent draft it" (or "Draft again"), with a note for13 * the agent, is the proposer's or a decider's while the proposal is open14 * and not drafting; a decider also gets the way to the decision that would15 * open the ask. The inspector holds who proposed it, when it expires, the16 * decision, and the draft's round.17 *18 * Nothing here edits the drafted files: a member proposes again, or a19 * decider sends the draft back with a note.20 */1import { Brand } from "@repo/brand";2import type { ConfigFile } from "@repo/protocol/domain/common";3import { DraftState } from "@repo/protocol/domain/proposal";4import type { Proposal } from "@repo/protocol/domain/proposal";
19 unmodified lines
24import { When } from "../shared/time.tsx";25import { DraftedCode } from "./client-file.tsx";2627/**48 * How many attempts a draft round makes before it fails: the platform's49 * `DRAFT_ROUNDS` (`@repo/project/draft-runs`), which the web's production50 * code does not import; `test/proposal.test.tsx` holds the two equal.28 * The platform's `DRAFT_ROUNDS`, which the web's production code does not29 * import; `test/proposal.test.tsx` holds the two equal.30 */31export const DRAFT_ATTEMPTS = 3;3254/** The longest note `draftAsk` takes. */33const NOTE_LIMIT = 2000;3457/** Where a proposal stands in one word: its draft's while it is open, else its own. */35export const standing = (proposal: Proposal) =>36 proposal.state === "open" && proposal.draft !== undefined37 ? proposal.draft._tag38 : proposal.state;
1 unmodified line
40const draftingNow = DraftState.isAnyOf(["Drafting"]);4142const failedNow = DraftState.isAnyOf(["Failed"]);4367/** Whether the platform's agent is drafting the proposal's ask right now. */44export const isDrafting = (proposal: Proposal) =>45 proposal.draft !== undefined && draftingNow(proposal.draft);4671/** Every refusal of the union, to find one by the tag a failed draft kept. */47const refusalKinds = groups.flatMap(({ members }) => [...members]);4849/**75 * The refusal a failed round ended with, when its tag alone makes one: a76 * draft keeps only the tag, so a refusal that needs fields of its own77 * cannot be drawn whole, and is said in words instead.50 * A draft keeps only the tag, so a refusal that needs fields of its own cannot51 * be drawn whole.52 */53export const refusalOfTag = (tag: string): Option.Option<Refusal> =>54 Arr.findFirst(refusalKinds, (kind) => kind.identifier === tag).pipe(55 Option.flatMap((kind): Option.Option<Refusal> =>
2 unmodified lines
58 kind.makeOption({} as never)59 )60 );6188/** Whether a drafted file is the ask file: under the config folder, or named as one. */62const isAskFile = ({ path }: ConfigFile) =>63 path.startsWith(`${Brand.configDir}/`) || path.endsWith(".ask.ts");6492/** The draft's files in the order it made them: the ask file, the check, then what the check reads. */65const filesInOrder = (files: readonly ConfigFile[]) => {66 const askFile = files.find(isAskFile);67 const rest = files.filter((file) => file !== askFile);68 const checks = rest.filter(({ path }) => isTestPath(path));
1 unmodified line
7071 return { askFile, checks, others };72};73102/** The kind an ask file names (`kinds.fix`), when it names one plainly. */74const kindIn = (source: string) =>75 /\bkinds\.(?<kind>[A-Za-z]+)/u.exec(source)?.groups?.kind;7677const Step = ({
25 unmodified lines
103 <dd className="text-ui min-w-0 [overflow-wrap:anywhere]">{children}</dd>104 </div>105);106136/** The ask file: what it states, then its source behind a disclosure. */107const AskFileStep = ({108 file,109 proposal,110}: {
35 unmodified lines
146 </Step>147 );148};149180/** Red first: the run that failed twice the same way on main, its assertion once. */150const RedFirst = ({ draft }: { readonly draft: DraftState }) =>151 DraftState.match(draft, {152 Drafting: () => null,153 Failed: () => null,
15 unmodified lines
169 </Step>170 ),171 });172204/** A round that failed: the refusal whole when the page can draw it, else in words, in ink. */173const FailedRound = ({ draft }: { readonly draft: DraftState }) =>174 DraftState.match(draft, {175 Drafting: () => null,176 Failed: ({ attempts, model, refusal, round }) =>
24 unmodified lines
201 }),202 Ready: () => null,203 });204237/** "Draft again", with a note the agent reads. */205const Redraft = ({206 again,207 busy,208 onRedraft,
51 unmodified lines
260 </section>261 );262};263297/** The way to the open decision that would open the ask. */264const DecisionLink = ({265 decision,266 project,267}: {
9 unmodified lines
277 Decide it: {decision}278 </AppLink>279);280315/** The draft's round, in a line: its number and where it stands. */281const roundLine = (draft: DraftState) =>282 DraftState.match(draft, {283 Drafting: ({ round }) => `Round ${round}, drafting now`,284 Failed: ({ attempts, round }) =>
1 unmodified line
286 Ready: ({ attempts, round }) =>287 `Round ${round} ready after ${attempts} of ${DRAFT_ATTEMPTS} attempts`,288 });289325/** The inspector's facts: who proposed it, when it expires, its decision, the draft's round. */290const ProposalFacts = ({291 decision,292 now,293 project,
43 unmodified lines
337 )}338 </>339);340377/** Where the proposal stands, under its title: the status line, or a failed round; then what drafting means and its note. */341const ProposalStatus = ({ proposal }: { readonly proposal: Proposal }) => {342 const { draft } = proposal;343 const drafting = draft !== undefined && draftingNow(draft);344
28 unmodified lines
373 </div>374 );375};376414/** The draft as a guide, in the order it was made; a want alone says so. */377const DraftGuide = ({378 files,379 proposal,380}: {
47 unmodified lines
428 proposal,429}: {430 readonly project: ProjectName;431 readonly proposal: Proposal;470 /** The files the proposal holds (the ask file and its check), as `showProposal` read them. */432 readonly files: readonly ConfigFile[];472 /** The open decision on the proposal, when the reader's Today holds it. */433 readonly decision: Option.Option<DecisionId>;474 /** Whether the reader is its proposer or one of the project's deciders. */434 readonly mayRedraft: boolean;435 readonly onRedraft?: (note: string | undefined) => void;477 /** Whether a "Draft again" is on its way: the button waits. */436 readonly busy?: boolean;479 /** What the last "Draft again" came back with, when it was refused. */437 readonly children?: ReactNode;438 readonly now?: DateTime.Utc;439}): ReactNode => {440 const open = proposal.state === "open";
43 unmodified lines
modified:apps/web/src/features/propose/client-territory.tsx+2 added-8 removed
1/**2 * The territory select, drawn in the browser only. The server renders its3 * stand-in: the trigger as it will look, holding the choice in sight and4 * in the form (a hidden input), never a native `<select>`; after5 * hydration the browser loads the kit's select over it.6 * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic7 * import below is dead code there and the Worker bundles none of it.2 * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic import3 * below is dead code there and the Worker bundles none of it.4 */5import { ClientOnly } from "@tanstack/react-router";6import { ChevronDown } from "lucide-react";7import { lazy, Suspense } from "react";813// A type-only import is erased, so the server bundles nothing of it.9import type { TerritorySelectProps } from "./territory-select.tsx";1011const SelectLater = import.meta.env.SSR12 ? undefined13 : lazy(() => import("./territory-select.tsx"));1420/** The select's place before it is drawn: its trigger, showing the choice. */15const StandIn = ({ choices, labelledBy, value }: TerritorySelectProps) => (16 <>17 <button18 aria-labelledby={labelledBy}
29 unmodified lines
modified:apps/web/src/features/propose/propose-link.tsx+2 added-5 removed
1/**2 * The way to the propose form, for signed-in members only. Who is signed in3 * is the browser's to learn (`whoAtom`), after the first paint, so the4 * server renders no link and the browser adds it, as the header's session2 * Who is signed in is the browser's to learn, after the first paint, so the3 * server renders no link and the browser adds it.5 * slot does (`features/auth/session-slot.tsx`).4 */5import { useAtomValue } from "@effect/atom-react";6import type { ProjectName } from "@repo/protocol/ids";7import { Option } from "effect";
13 unmodified lines
21 Propose an ask22 </a>23);2427/** `ProposeLink` once the browser knows someone is signed in; nothing before or otherwise. */25export const SignedInProposeLink = ({26 project,27}: {28 readonly project: ProjectName;
4 unmodified lines
modified:apps/web/src/features/propose/propose-view.tsx+2 added-39 removed
1/**2 * The propose form: a signed-in member writes a want, may name the3 * territory it belongs to (one of the project's top folders), and lets the4 * platform's agent draft the ask file and its failing check from it,5 * checked by default. A line from the why page (`?about&line&at`) starts the6 * want with where it points. The inspector says what makes a good want and7 * gives the same proposal as a command. Props in, markup out: the route8 * reads who is signed in and the project's paths, sends the payload, and9 * goes to the proposal once it is made.10 *11 * Only the want, the territory and the draft box: the files are the12 * agent's to write, or a person's through `propose --files` in the CLI.13 * Propose waits until there is a want, and says so on itself.14 */1import { Brand } from "@repo/brand";2import type { ProposeAsk } from "@repo/protocol/contracts";3import type { CommitSha, ProjectName, RepoPath } from "@repo/protocol/ids";4import { Option } from "effect";
11 unmodified lines
16import { FactBlock } from "../shared/facts.tsx";17import { Workspace } from "../shared/shell/workspace.tsx";18import { ClientTerritorySelect } from "./client-territory.tsx";1934/** What `proposeAsk` takes, from its one schema. */20export type ProposePayload = typeof ProposeAsk.payloadSchema.Type;2137/** A line a why page points at: the file, the line and the commit it was read at. */22export interface About {23 readonly path: RepoPath;24 readonly line: number;25 readonly at: CommitSha;26}2728/**45 * The form's fields as `proposeAsk`'s payload: the want trimmed, the46 * territory when one is named, and `draft: true` only when the box is47 * checked (the contract takes no `draft: false`).29 * `draft: true` only when the box is checked: the contract takes no `draft:30 * false`.31 */32export const proposalPayload = (form: {33 readonly project: ProjectName;34 readonly want: string;
9 unmodified lines
4445 return form.draft ? { ...named, draft: true } : named;46};4765/** How a want about one line starts: `In \`src/format.ts\` line 12 at 4c2e6a8: `. */48export const wantAbout = ({ at, line, path }: About) =>49 `In \`${path}\` line ${line} at ${at.slice(0, 7)}: `;5069/**70 * The form's address for `project`, at the line a why page names when it71 * names one: where the project page links, and where sign-in comes back to.72 */51export const proposeFormPath = (52 project: ProjectName,53 about: Option.Option<About> = Option.none()54) =>
2 unmodified lines
57 onSome: ({ at, line, path }) =>58 `/${project}/proposals/new?${new URLSearchParams({ about: path, at, line: String(line) }).toString()}`,59 });6083/** The value the territory takes when the agent chooses it. */61const AGENT_CHOOSES = "";6286/** The territories the form offers: the agent's choice first, then each top folder. */63export const territoryChoices = (modules: readonly RepoPath[]) => [64 { label: "Let the agent choose", value: AGENT_CHOOSES },65 ...modules.map((module) => ({ label: module, value: module })),66];6792/** What Propose says: why it waits, or what it does. */68const proposeWords = (written: boolean, busy: boolean) => {69 if (!written) {70 return "Write the want first";71 }7273 return busy ? "Proposing" : "Propose";74};75101/** The proposal as a command, for a reader in a terminal. */76const PROPOSE_COMMAND = `${Brand.cli} propose --draft "<want>"`;7778const SignInFirst = ({79 about,
31 unmodified lines
111 <CommandLine command={PROPOSE_COMMAND} />112 </section>113);114141/** What makes a good want, and the same proposal from a terminal. */115const GoodWant = () => (116 <>117 <FactBlock label="A good want">118 <ul className="text-ui flex list-disc flex-col gap-1.5 pl-4">
110 unmodified lines
229230 {children}231232 <Button260 // Waiting for a want, it says so at full strength, dashed like any261 // field still to fill, rather than sitting grey.233 className={`tablet:h-9 tablet:w-fit h-11 w-full min-w-28 px-4 ${written ? "" : "text-muted-foreground border-dashed disabled:opacity-100"}`}234 data-written={written}235 disabled={busy || !written}236 type="submit"
5 unmodified lines
242 </form>243 );244};245275/** The form, the way to sign in, or the wait while the browser learns who is signed in. */246const ProposeBody = ({247 about,248 busy,249 checking,
46 unmodified lines
296 signedIn,297}: {298 readonly project: ProjectName;299 readonly signedIn: boolean;330 /** Whether the browser is still learning who is signed in. */300 readonly checking?: boolean;301 readonly about: Option.Option<About>;333 /** The project's top folders, each a territory to choose. */302 readonly modules: readonly RepoPath[];335 /** Sends the payload; the route goes to the proposal once it is made. */303 readonly onPropose?: (payload: ProposePayload) => void;337 /** Whether a proposal is on its way: the button waits. */304 readonly busy?: boolean;339 /** What the last proposal came back with, when it was refused. */305 readonly children?: ReactNode;306}): ReactNode => (342 // Below the shell's width the form comes first, and what makes a good343 // want follows it, rather than standing between the reader and the form.307 <div className="contents [&_[data-facts=inline]]:hidden">308 <Workspace309 crumbs={[310 { label: project, to: `/${project}` },
24 unmodified lines
modified:apps/web/src/features/propose/territory-select.tsx-9 removed
1/**2 * The territory a proposal names, chosen with the kit's select: the agent's3 * choice first, then each of the project's top folders in mono. Drawn in4 * the browser only (`client-territory.tsx`): Base UI's select, its5 * positioning and its scroll lock are the browser's to run, and the Worker6 * bundles none of them.7 */1import {2 Select,3 SelectContent,4 SelectItem,
1 unmodified line
6 SelectValue,7} from "../../components/ui/select.tsx";89export interface TerritorySelectProps {17 /** What the select offers, the agent's choice (`""`) first. */10 readonly choices: readonly {11 readonly label: string;12 readonly value: string;13 }[];
1 unmodified line
15 readonly onChange: (value: string) => void;16 readonly value: string;17}1827/** The trigger's look, shared with the server's stand-in for it. */19export const TRIGGER =20 "tablet:text-ui tablet:h-9 h-11 w-full max-w-xs text-base";2122export const TerritorySelect = ({
32 unmodified lines
modified:apps/web/src/features/today/read.ts+3 added-25 removed
1/**2 * What Today's page reads, in a module with no view of its own: a route's3 * loader runs before its page's view loads, so the route reaches these4 * without carrying the page.5 *6 * - `TodayRead`: the reader's Today, or why there is none (a refusal, no7 * session, no answer from the platform), as the loader sends it.8 * - `readToday`: that read, made with whatever `Client` the caller gives9 * (the server's, carrying the reader's own session).10 * - The order a decider takes decisions in: due within the day first, then11 * by expiry.12 */1import { Client } from "@repo/protocol/contracts";2import { Today } from "@repo/protocol/domain/decision";3import type { Decision } from "@repo/protocol/domain/decision";4import type { DecisionId, ProjectName } from "@repo/protocol/ids";
11 unmodified lines
16} from "effect";1718import { decisionKey } from "../decision/subject.ts";1932/** What the page read for its reader: their Today, or why there is none. */20export const TodayRead = Schema.TaggedUnion({21 Read: { today: Today },22 Refused: { refusal: Refusal },23 SignedOut: {},
1 unmodified line
25});2627export type TodayRead = typeof TodayRead.Type;2842/** What Today's loader sends: the read, and the instant it was made. */29export const TodayPageData = Schema.Struct({30 now: Schema.DateTimeUtcFromString,31 read: TodayRead,32});
3 unmodified lines
36const isRefusal = Schema.is(Refusal);3738const isUnauthenticated = Schema.is(Unauthenticated);3954/** Whether a read failed because its reader is not signed in. */40export const isSignedOut = (cause: Cause.Cause<unknown>) =>41 Option.exists(Cause.findErrorOption(cause), isUnauthenticated);4258/** A failed read of Today, as the page says it. */43export const readOfCause = (cause: Cause.Cause<unknown>): TodayRead => {44 const error = Cause.findErrorOption(cause);4546 if (Option.isSome(error) && isRefusal(error.value)) {
4 unmodified lines
51 ? TodayRead.cases.SignedOut.make({})52 : TodayRead.cases.Unreachable.make({});53};5471/** Soonest to expire first, then oldest, then by project and id: one order every time. */55export const expiryOrder: Order.Order<Decision> = Order.combineAll([56 Order.mapInput(DateTime.Order, ({ expiresAt }: Decision) => expiresAt),57 Order.mapInput(DateTime.Order, ({ openedAt }: Decision) => openedAt),58 Order.mapInput(Order.String, ({ project }: Decision) => project),59 Order.mapInput(Order.String, ({ id }: Decision) => id),60]);6162/**80 * The decisions `today.expiringSoon` names. Ids are minted per project, so a81 * Today across projects may hold two decisions with one id; where an id is82 * named `n` times, the `n` of its decisions that expire first are the ones83 * meant (a decision that expires within the day expires before any that84 * does not).63 * Ids are minted per project, so a Today across projects may hold two decisions64 * with one id; where an id is named `n` times, the `n` of its decisions that65 * expire first are the ones meant.66 */67export const expiringSoon = (today: Today): ReadonlySet<string> => {68 const named = Arr.groupBy(today.expiringSoon, (id) => id);69 const byExpiry = Arr.sort(today.decisions, expiryOrder);
7 unmodified lines
77 )78 );79};80100/** Today's decisions in the order a decider takes them: expiring soon first, then by expiry. */81export const orderDecisions = (today: Today): readonly Decision[] => {82 const soon = expiringSoon(today);8384 return Arr.sort(
7 unmodified lines
92 )93 );94};95116/** Where one decision stands on Today: listed (and whether it expires soon), or not there. */96export const findDecision = (97 today: Today,98 project: ProjectName,99 id: DecisionId
10 unmodified lines
110 }))111 );112};113135/** The reader's Today, or why there is none, encoded for the page. */114export const readToday = ({ project }: { readonly project?: ProjectName }) =>115 Effect.gen(function* () {116 const client = yield* Client;117
12 unmodified lines
modified:apps/web/src/features/today/today-page.tsx+1 added-52 removed
1/**2 * Today: a decider's day of decisions, not diffs, held to a budget said in3 * one sentence. The decisions sit in sections: those due within the day,4 * then the rest within the budget by expiry, then how many wait for5 * tomorrow (their ids are not in the read, so they have no rows). Below6 * them, the newcomers to welcome and a sample of landings that needed7 * nobody.8 *9 * Each row says its subject in plain words (the link to its page), its10 * project, kind and id, and when it expires over its default. From the11 * shell's width a row selects into the inspector, which holds the whole12 * decision: its evidence, a note, and its choices, each with what it does.13 * Below it a row opens in place, one at a time, its choices kept in sight14 * above the bottom bar while it is open.15 *16 * A choice taken leaves its row where it was, reading what it did; the17 * budget sentence moves with the next read. There is no toast.18 *19 * A failure reads as what it is: a refusal (`NotDecider` for a person who20 * decides nothing) through `RefusalView`, a missing sign-in as what Today21 * is and how to sign in, and an unreachable platform as that, never as an22 * empty day.23 */1import { Brand } from "@repo/brand";2import type { Decision, Today } from "@repo/protocol/domain/decision";3import type { LandingView } from "@repo/protocol/domain/landing";4import { Array as Arr, Option, Order } from "effect";
42 unmodified lines
47} from "./read.ts";4849const counted = (count: number) => (count === 0 ? "none" : String(count));5074/** The day's budget, in one sentence: decisions taken and left, and the finishes apart. */51export const budgetSentence = (budget: Today["budget"]) =>52 `Decisions: ${budget.used} taken, ${counted(Math.max(0, budget.total - budget.used))} left today. Finishes are counted apart: ${counted(budget.finishes)} taken.`;5378/** The budget for the context bar: what is left. */54const budgetShort = (budget: Today["budget"]) =>55 `${counted(Math.max(0, budget.total - budget.used))} left today`;5682/** What Today is, for someone it does not hold decisions for yet. */57const WHAT_TODAY_IS =58 "Today is a decider's page: the decisions you owe your projects each day, each with its evidence and a safe default if you leave it.";5986/** A decision on the page: listed, and whether it is due within the day. */60interface Listed {61 readonly decision: Decision;62 readonly soon: boolean;63}6492/** The choice a row's decision was taken with, when the decider took it here. */65const choiceOf = (decision: Decision) => decision.decided?.choice;6695/** Its expiry over its default, at the row's end; muted when it is not due within the day. */67const openState = (listed: Listed, now: DateTime.Utc) => ({68 mark: listed.soon ? ("waiting" as const) : ("notYet" as const),69 time: `default: ${listed.decision.default}`,70 word: distanceInWords(listed.decision.expiresAt, now),71});72102/** The way to open a row in place, below the shell's width. */73const OpenHere = ({74 decision,75 onToggle,76 open,
25 unmodified lines
102 readonly onSelect: ((key: string) => void) | undefined;103 readonly open: string | undefined;104 readonly onOpen: (key: string | undefined) => void;105 readonly selected: string | undefined;136 /** The decisions taken while the page was open, to stamp once. */106 readonly stamped: ReadonlySet<string>;107}108140/** One decision's row: its subject, where it stands, and (below the shell's width) the whole of it in place. */109const DecisionRow = ({110 listed,111 props,112}: {
96 unmodified lines
209210const plural = (count: number, one: string, many: string) =>211 `${count} ${count === 1 ? one : many}`;212245/** The decisions, due today then within the budget, each section only when it holds one. */213const DecisionSections = ({214 listed,215 props,216}: {
36 unmodified lines
253 </>254 );255};256290/** How many wait beyond the budget, as a sentence: their ids are not in the read. */257const Tomorrow = ({ overflow }: { readonly overflow: number }) =>258 overflow === 0 ? null : (259 <Section name="Waits for tomorrow">260 <li
62 unmodified lines
323 ))}324 </Section>325 );326361/** The decision the inspector holds, whole. */327const SelectedFacts = ({328 busy,329 listed,330 now,
40 unmodified lines
371 </FactBlock>372 </>373);374410/** Signed out: what Today is, the way in, and the command. */375const SignedOutNotice = ({ here }: { readonly here: string }) => (376 <div className="flex max-w-[70ch] flex-col items-start gap-3">377 <p className="text-body">{WHAT_TODAY_IS}</p>378 <p className="text-ui">
8 unmodified lines
387 <CommandLine command={`${Brand.cli} today`} />388 </div>389);390427/** What a choice that failed came back with: the refusal, or why there is none. */391const DecidedFailure = ({392 decided,393}: {394 readonly decided: AsyncResult.AsyncResult<unknown, unknown>;
11 unmodified lines
406 Unreachable: () => <UnreachableNotice />,407 });408};409447/** The page around a Today with no decisions to list: the reason, said whole. */410const Unlisted = ({ children }: { readonly children: ReactNode }) => (411 <Workspace crumbs={[{ label: "Today" }]} title="Today" variant="list">412 {children}413 </Workspace>414);415454/**455 * The decisions on the page: Today's, and any the decider took here that456 * the next read no longer lists, each where it was.457 */416const listedOf = (417 today: Today,418 taken: ReadonlyMap<string, Listed>419): readonly Listed[] => {
20 unmodified lines
440 )441 );442};443486/** `kept` with `decision`, taken, where it was listed. */444const withTaken = (445 kept: ReadonlyMap<string, Listed>,446 decision: Decision,447 soon: ReadonlySet<string>
5 unmodified lines
453 [key, { decision, soon: kept.get(key)?.soon ?? soon.has(key) }],454 ]);455};456500/** The decision a choice just came back with, when it was taken. */457const takenNow = (458 decided: AsyncResult.AsyncResult<{ readonly decision: Decision }, unknown>459): Option.Option<Decision> =>460 Option.filter(
23 unmodified lines
484 const [open, setOpen] = useState<string>();485 const soon = expiringSoon(today);486 const fresh = takenNow(decided);487532 // A choice taken stays on the page after the next read leaves it out:533 // kept as soon as it comes back, while this render draws it already.488 // A choice taken stays on the page after the next read leaves it out.489 if (490 Option.isSome(fresh) &&491 kept.get(decisionKey(fresh.value))?.decision.decided === undefined492 ) {
35 unmodified lines
528 onDecide,529 onOpen: setOpen,530 onSelect,531 open,577 // A row is drawn selected only when the address names it; with none578 // named the inspector holds the first, and no row looks chosen.532 selected,533 stamped,534 };535536 return (584 // Below the shell's width a row opens in place, so the inspector's585 // copy of the selected decision is not drawn in main as well.537 <div className="contents [&_[data-facts=inline]]:hidden">538 <Workspace539 count={budgetShort(today.budget)}540 crumbs={[{ label: "Today" }]}
52 unmodified lines
593}: {594 readonly read: TodayRead;595 readonly now: DateTime.Utc;596 readonly onDecide: (input: DecideInput) => void;646 /** The decider's last choice, as `decide` answered it. */597 readonly decided?: AsyncResult.AsyncResult<598 { readonly decision: Decision },599 unknown600 >;651 /** The decision the inspector holds (`project/id`); the first listed when none. */601 readonly selected?: string | undefined;602 readonly onSelect?: ((key: string) => void) | undefined;603}) =>604 TodayRead.match(read, {
28 unmodified lines