diff --git a/apps/site/scripts/reader-cafe-flags.ts b/apps/site/scripts/reader-cafe-flags.ts index 8da84a36..e36346dc 100644 --- a/apps/site/scripts/reader-cafe-flags.ts +++ b/apps/site/scripts/reader-cafe-flags.ts @@ -3,14 +3,13 @@ import { profileForNewsRow } from "@rat-stack/core/cafe-people"; import { sortCafeProjects } from "@rat-stack/core/contracts"; import { Effect, Option } from "effect"; -import { Model } from "../../web/src/client/cafe/model.ts"; -import type { CafeModel } from "../../web/src/client/cafe/model.ts"; import { allStarsCopy, directoryCopy, newsCopy, } from "../../web/src/features/cafe/copy.ts"; import { newsOrder } from "../../web/src/features/cafe/news-order.ts"; +import { CafePage } from "../../web/src/reader-cafe.ts"; import { cafeNewsPageItems } from "./cafe-pages.ts"; import { ReaderInputError } from "./reader-input-error.ts"; import { prepareReaderSiteInputs } from "./reader-site-inputs.ts"; @@ -26,7 +25,7 @@ export const readerCafeFlags = Effect.fn("readerCafeFlags")( path: "/news" | "/news/latest" | "/directory" | "/all-stars", heading: string, sourcePath: string, - cafe: CafeModel + cafe: typeof CafePage.Type ) { const descriptor = inputs.pages.find((entry) => entry.path === path); @@ -69,7 +68,7 @@ export const readerCafeFlags = Effect.fn("readerCafeFlags")( newsOrder[sort].href, sort === "rank" ? newsCopy.heading : newsOrder.newest.heading, ".brain/data/cafe/news.json", - Model.News({ + CafePage.cases.News.make({ items, profiles: items.flatMap((item) => Option.toArray( @@ -93,13 +92,13 @@ export const readerCafeFlags = Effect.fn("readerCafeFlags")( "/all-stars", allStarsCopy.heading, ".brain/data/cafe/people.json", - Model.AllStars({ people: people.people }) + CafePage.cases.AllStars.make({ people: people.people }) ), yield* page( "/directory", directoryCopy.heading, ".brain/data/cafe/projects.json", - Model.Directory({ + CafePage.cases.Directory.make({ projects: sortCafeProjects(data.projects, "updated"), selected: [], }) diff --git a/apps/web/effect-ui.ts b/apps/web/effect-ui.ts index 6a6a9545..e4a9ce2b 100644 --- a/apps/web/effect-ui.ts +++ b/apps/web/effect-ui.ts @@ -2,6 +2,7 @@ import { Schema } from "effect"; import type { Plugin } from "vite"; const entries = { + "all-stars-effect-ui": "src/client/all-stars-effect-ui/entry.ts", "directory-effect-ui": "src/client/directory-effect-ui/entry.ts", "news-effect-ui": "src/client/news-effect-ui/entry.ts", "reader-effect-ui": "src/client/reader-effect-ui/entry.ts", diff --git a/apps/web/reader-pages.ts b/apps/web/reader-pages.ts index ef0f0f66..c6f34c58 100644 --- a/apps/web/reader-pages.ts +++ b/apps/web/reader-pages.ts @@ -5,7 +5,7 @@ import { Effect, FileSystem, Schema } from "effect"; import type { Plugin } from "vite"; import { prepareReader } from "./scripts/reader-build.js"; -import { ReaderFlags } from "./src/client/reader/model.js"; +import { ReaderSource } from "./src/reader-cafe.js"; import { ReaderErrorTemplate } from "./src/server/reader-error-template.js"; const preparedPages = Effect.gen(function* preparedPages() { @@ -16,10 +16,10 @@ const preparedPages = Effect.gen(function* preparedPages() { ); const pages = yield* Schema.decodeEffect( - Schema.fromJsonString(Schema.Array(ReaderFlags)) + Schema.fromJsonString(Schema.Array(ReaderSource)) )(source); - const encodePage = Schema.encodeEffect(Schema.fromJsonString(ReaderFlags)); + const encodePage = Schema.encodeEffect(Schema.fromJsonString(ReaderSource)); const sources = yield* Effect.forEach((page: (typeof pages)[number]) => encodePage(page).pipe( diff --git a/apps/web/scripts/reader-build.ts b/apps/web/scripts/reader-build.ts index afc8058d..9d82ba5f 100644 --- a/apps/web/scripts/reader-build.ts +++ b/apps/web/scripts/reader-build.ts @@ -21,6 +21,7 @@ import { writeFileAtomically } from "../../site/scripts/write-file-atomically.ts import { ReaderFlags } from "../src/client/reader/model.ts"; import type { ReaderPageFlags } from "../src/client/reader/model.ts"; import { contentGenerationHeader } from "../src/content-generation-header.ts"; +import { ReaderSource } from "../src/reader-cafe.ts"; import { isReaderRoutePath, readerNoStoreRoutePaths, @@ -113,7 +114,7 @@ const readerPages = Effect.gen(function* readerPages() { const error = yield* readerErrorTemplate(origin); const decoded = yield* Effect.forEach((page: (typeof pages)[number]) => - Schema.decodeUnknownEffect(ReaderFlags)({ + Schema.decodeUnknownEffect(ReaderSource)({ ...page, page: { ...page.page, @@ -134,7 +135,7 @@ export const prepareReader = Effect.fn("reader.prepare")( const { error, pages } = yield* readerPages; const encoded = yield* Schema.encodeEffect( - Schema.fromJsonString(Schema.Array(ReaderFlags)) + Schema.fromJsonString(Schema.Array(ReaderSource)) )(pages); const encodedError = yield* Schema.encodeEffect( diff --git a/apps/web/src/client/all-stars-effect-ui/component.ts b/apps/web/src/client/all-stars-effect-ui/component.ts new file mode 100644 index 00000000..39295148 --- /dev/null +++ b/apps/web/src/client/all-stars-effect-ui/component.ts @@ -0,0 +1,16 @@ +import { Html } from "@effect/ui/html"; +import { Schema } from "effect"; + +import { view } from "../../features/all-stars-effect-ui/view.js"; +import { AllStarsProps } from "./model.js"; + +export const AllStarsPage = Html.component({ + name: "AllStarsPage", + props: AllStarsProps, + model: Schema.Null, + message: Schema.Never, +}).make({ + init: () => null, + update: ($) => $.model, + view: (h) => view(h, h.props.people), +}); diff --git a/apps/web/src/client/all-stars-effect-ui/entry.ts b/apps/web/src/client/all-stars-effect-ui/entry.ts new file mode 100644 index 00000000..05fd6fde --- /dev/null +++ b/apps/web/src/client/all-stars-effect-ui/entry.ts @@ -0,0 +1,11 @@ +import { Effect } from "effect"; + +import { installReaderTools } from "../web-mcp-boot.js"; +import { hydrateAllStars } from "./hydration.js"; + +import "../../../../site/src/rat.css"; +import "../reader.css"; + +installReaderTools(); + +Effect.runFork(hydrateAllStars(document)); diff --git a/apps/web/src/client/all-stars-effect-ui/hydration.ts b/apps/web/src/client/all-stars-effect-ui/hydration.ts new file mode 100644 index 00000000..b14b4f40 --- /dev/null +++ b/apps/web/src/client/all-stars-effect-ui/hydration.ts @@ -0,0 +1,53 @@ +import { HtmlHydrate } from "@effect/ui/html"; +import { Cause, Effect, Schema } from "effect"; + +import { AllStarsPage } from "./component.js"; +import { AllStarsHandoff, allStarsHandoffId, allStarsRootId } from "./model.js"; + +const decodeHandoff = Schema.decodeEffect( + Schema.fromJsonString(AllStarsHandoff) +); + +export const hydrateAllStars = (page: Document) => + Effect.suspend(() => { + const container = page.querySelector(`#${allStarsRootId}`); + const payload = page.querySelector(`#${allStarsHandoffId}`); + + if (container === null || payload === null) { + return Effect.void; + } + + return decodeHandoff(payload.textContent ?? "").pipe( + Effect.flatMap(({ props, state }) => + Effect.gen(function* adoptAllStars() { + const root = yield* HtmlHydrate.hydrateEffect( + AllStarsPage, + props, + container, + state + ); + + yield* root.adopted; + container.dataset.hydrated = "true"; + + return yield* Effect.never; + }) + ) + ); + }).pipe( + Effect.scoped, + Effect.tapCause((cause) => { + if (Cause.hasInterruptsOnly(cause)) { + return Effect.void; + } + + if (Cause.hasFails(cause)) { + return Effect.logError("All Stars hydration failed: invalid handoff"); + } + + return Effect.logError("All Stars hydration failed", cause); + }), + Effect.catchCause((cause) => + Cause.hasInterruptsOnly(cause) ? Effect.interrupt : Effect.void + ) + ); diff --git a/apps/web/src/client/all-stars-effect-ui/model.ts b/apps/web/src/client/all-stars-effect-ui/model.ts new file mode 100644 index 00000000..fb47191c --- /dev/null +++ b/apps/web/src/client/all-stars-effect-ui/model.ts @@ -0,0 +1,14 @@ +import { CafePersonSummary } from "@rat-stack/core/contracts"; +import { Schema } from "effect"; + +import { effectUiHandoff } from "../effect-ui-handoff.js"; + +export const AllStarsProps = Schema.Struct({ + people: Schema.Array(CafePersonSummary), +}); + +export const AllStarsHandoff = effectUiHandoff(AllStarsProps); + +export const allStarsRootId = "all-stars-effect-ui"; + +export const allStarsHandoffId = "all-stars-effect-ui-handoff"; diff --git a/apps/web/src/client/cafe/index.ts b/apps/web/src/client/cafe/index.ts deleted file mode 100644 index f387e3c4..00000000 --- a/apps/web/src/client/cafe/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export { Message } from "./message.js"; - -export type { CafeMessage } from "./message.js"; - -export { Model } from "./model.js"; - -export type { - AllStarsModel, - CafeModel, - DirectoryModel, - NewsModel, -} from "./model.js"; - -export { update } from "./update.js"; diff --git a/apps/web/src/client/cafe/message.ts b/apps/web/src/client/cafe/message.ts deleted file mode 100644 index 6f2aa9a3..00000000 --- a/apps/web/src/client/cafe/message.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { CafeLetter } from "@rat-stack/core/contracts"; -import { defineMessageUnion } from "foldkit/message"; - -export const Message = defineMessageUnion({ - ClearedStackLetters: {}, - ToggledStackLetter: { letter: CafeLetter }, -}); - -export type CafeMessage = typeof Message.Type; diff --git a/apps/web/src/client/cafe/model.ts b/apps/web/src/client/cafe/model.ts deleted file mode 100644 index 56ece838..00000000 --- a/apps/web/src/client/cafe/model.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { - CafeLetter, - CafeNewsItem, - CafeNewsSort, - CafePersonSummary, - CafeProject, - IsoDate, -} from "@rat-stack/core/contracts"; -import { Schema } from "effect"; -import { defineTaggedUnion } from "foldkit/schema"; - -export const NewsProfileLink = Schema.Struct({ - name: Schema.String, - route: Schema.String, - url: Schema.String, -}); - -export const Model = defineTaggedUnion({ - AllStars: { - people: Schema.Array(CafePersonSummary), - }, - Directory: { - projects: Schema.Array(CafeProject), - selected: Schema.Array(CafeLetter), - }, - News: { - items: Schema.Array(CafeNewsItem), - profiles: Schema.Array(NewsProfileLink), - rankedAt: IsoDate, - sort: CafeNewsSort, - }, -}); - -export type CafeModel = typeof Model.Type; - -export type DirectoryModel = typeof Model.Directory.Type; - -export type NewsModel = typeof Model.News.Type; - -export type AllStarsModel = typeof Model.AllStars.Type; diff --git a/apps/web/src/client/cafe/update.ts b/apps/web/src/client/cafe/update.ts deleted file mode 100644 index 09d08c29..00000000 --- a/apps/web/src/client/cafe/update.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { cafeLetters } from "@rat-stack/core/contracts"; -import type { CafeLetterValue } from "@rat-stack/core/contracts"; -import type { Update } from "foldkit"; -import { modifyFields } from "foldkit/struct"; - -import { Message } from "./message.js"; -import type { CafeMessage } from "./message.js"; -import { Model } from "./model.js"; -import type { CafeModel, DirectoryModel } from "./model.js"; - -type UpdateReturn = Update.Return; - -const toggleLetter = - (letter: CafeLetterValue) => - (selected: readonly CafeLetterValue[]): readonly CafeLetterValue[] => - cafeLetters.filter((candidate) => - candidate === letter - ? !selected.includes(candidate) - : selected.includes(candidate) - ); - -const updateDirectory = ( - model: CafeModel, - change: (directory: DirectoryModel) => DirectoryModel -): UpdateReturn => ({ - model: Model.match(model, { - AllStars: (allStars) => allStars, - Directory: change, - News: (news) => news, - }), -}); - -export const update = (model: CafeModel, message: CafeMessage): UpdateReturn => - Message.match(message, { - ClearedStackLetters: () => - updateDirectory(model, modifyFields({ selected: () => [] })), - ToggledStackLetter: ({ letter }) => - updateDirectory(model, modifyFields({ selected: toggleLetter(letter) })), - }); diff --git a/apps/web/src/client/news-effect-ui/model.ts b/apps/web/src/client/news-effect-ui/model.ts index 3890bb6a..e6390950 100644 --- a/apps/web/src/client/news-effect-ui/model.ts +++ b/apps/web/src/client/news-effect-ui/model.ts @@ -1,9 +1,14 @@ import { CafeNewsItem, CafeNewsSort } from "@rat-stack/core/contracts"; import { Schema } from "effect"; -import { NewsProfileLink } from "../cafe/model.js"; import { effectUiHandoff } from "../effect-ui-handoff.js"; +const NewsProfileLink = Schema.Struct({ + name: Schema.String, + route: Schema.String, + url: Schema.String, +}); + export const NewsProps = Schema.Struct({ items: Schema.Array(CafeNewsItem), profiles: Schema.Array(NewsProfileLink), diff --git a/apps/web/src/client/reader/message.ts b/apps/web/src/client/reader/message.ts index 24b14bf1..32e6a8e3 100644 --- a/apps/web/src/client/reader/message.ts +++ b/apps/web/src/client/reader/message.ts @@ -1,7 +1,6 @@ import { Schema } from "effect"; import { defineMessageUnion } from "foldkit/message"; -import { Message as CafeMessage } from "../cafe/message.js"; import { Message as DocsMessage } from "../docs/message.js"; import { Message as MotionDemoMessage } from "../motion/message.js"; import { Message as TubeMessage } from "../tube/message.js"; @@ -12,7 +11,6 @@ export const Message = defineMessageUnion({ CompletedDetectClipboard: { access: DetectedClipboardAccess }, CompletedWaitBeforeCopyReset: { id: Schema.String }, FailedCopyReaderText: { id: Schema.String }, - GotCafeMessage: { message: CafeMessage }, GotDocsMessage: { message: DocsMessage }, GotMotionMessage: { message: MotionDemoMessage }, GotTubeMessage: { message: TubeMessage }, diff --git a/apps/web/src/client/reader/model.ts b/apps/web/src/client/reader/model.ts index 2c40b66d..5ede7ecb 100644 --- a/apps/web/src/client/reader/model.ts +++ b/apps/web/src/client/reader/model.ts @@ -6,7 +6,6 @@ import { ReaderPageDescriptor, ReaderReferences, } from "../../page-descriptor.js"; -import { Model as CafeModel } from "../cafe/model.js"; import { Model as DocsModel } from "../docs/model.js"; import { Model as MotionDemoModel } from "../motion/model.js"; import { CopyPrompt } from "../reader-copy-prompt.js"; @@ -22,7 +21,6 @@ export const ReaderFlags = Schema.Struct({ blocks: Schema.Array(ReaderBlock), bodyNodes: Schema.OptionFromOptional(Schema.Array(ReaderNodeSchema)), breadcrumb: Schema.OptionFromOptional(ReaderBreadcrumb), - cafe: Schema.OptionFromOptional(CafeModel), codeFences: Schema.Array( Schema.Struct({ html: Schema.String, value: Schema.String }) ), diff --git a/apps/web/src/client/reader/update.ts b/apps/web/src/client/reader/update.ts index 80af11b9..ef8bb9cc 100644 --- a/apps/web/src/client/reader/update.ts +++ b/apps/web/src/client/reader/update.ts @@ -3,7 +3,6 @@ import { Update } from "foldkit"; import { modifyFields } from "foldkit/struct"; import { update as updateDocs } from "../../features/app.js"; -import * as Cafe from "../cafe/index.js"; import type { AppMessage as DocsMessage } from "../docs/message.js"; import type { AppModel as DocsModel } from "../docs/model.js"; import type { DocumentQueries } from "../docs/queries.js"; @@ -34,15 +33,6 @@ const copyablePrompt = (model: ReaderModel, id: string) => ? findCopyPrompt(model, id) : Option.none(); -const foldCafe = Update.foldChild({ - read: (model: ReaderModel) => model.cafe, - toParentMessage: (message: Cafe.CafeMessage) => - Message.GotCafeMessage({ message }), - update: Cafe.update, - write: (model: ReaderModel, cafe: Cafe.CafeModel) => - modifyFields(model, { cafe: () => Option.some(cafe) }), -}); - const foldDocs = Update.foldChild({ read: (model: ReaderModel) => model.docs, toParentMessage: (message: DocsMessage) => @@ -98,8 +88,6 @@ export const update = ( ? withCopyStatus(model, id, CopyStatus.Failed()) : model, }), - GotCafeMessage: ({ message: cafeMessage }) => - foldCafe(model, cafeMessage), GotDocsMessage: ({ message: docsMessage }) => foldDocs(model, docsMessage), GotMotionMessage: ({ message: motionMessage }) => diff --git a/apps/web/src/entry.server.ts b/apps/web/src/entry.server.ts index 738d4da1..108fdaed 100644 --- a/apps/web/src/entry.server.ts +++ b/apps/web/src/entry.server.ts @@ -7,20 +7,22 @@ import { ReaderErrorPage, readerErrorPath, } from "../../site/src/reader-error-page.js"; -import { findPage } from "./client/reader-pages.js"; -import type { ReaderPageFlags } from "./client/reader/model.js"; import { newsOrder } from "./features/cafe/news-order.js"; import { + allStarsRouter, directoryRouter, isWithinSection, loreRouter, } from "./features/site-route.js"; +import type { ReaderSourcePage } from "./reader-cafe.js"; import { isWorkerFirstReaderRoute } from "./reader-routes.js"; import { readerPrerenderOrigin } from "./server/prerender-origin.js"; import { EffectUiAssets } from "./server/reader-document.js"; import { readerSupportsEffectUi } from "./server/reader-effect-ui-props.js"; import { ReaderErrorTemplate } from "./server/reader-error-template.js"; +import { findPage } from "./server/reader-pages.js"; import { + renderAllStarsOrError, renderDirectoryOrError, renderNewsOrError, renderReaderApplication, @@ -32,12 +34,13 @@ import { websiteTelemetry, } from "./server/website-bindings.js"; -export { pagePaths as prerenderPaths } from "./client/reader-pages.js"; +export { pagePaths as prerenderPaths } from "./server/reader-pages.js"; export { renderDocument } from "./server/reader-document.js"; const effectUiAssets = Schema.decodeUnknownSync( Schema.Struct({ + "all-stars-effect-ui": EffectUiAssets, "directory-effect-ui": EffectUiAssets, "news-effect-ui": EffectUiAssets, "reader-effect-ui": EffectUiAssets, @@ -134,7 +137,7 @@ const renderErrorRoute = Effect.fn("reader.renderErrorRoute")( const renderErrorApplication = (error: typeof ReaderErrorPage.Type) => renderReaderError(errorTemplate, error); -const renderReaderHtml = (page: ReaderPageFlags) => { +const renderReaderHtml = (page: ReaderSourcePage) => { const { path, status } = page.page; if (path === newsOrder.rank.href || path === newsOrder.newest.href) { @@ -155,6 +158,15 @@ const renderReaderHtml = (page: ReaderPageFlags) => { ); } + if (path === allStarsRouter()) { + return renderAllStarsOrError( + page, + effectUiAssets["all-stars-effect-ui"], + () => import("./server/all-stars-effect-ui.js"), + renderErrorApplication + ); + } + if (isWithinSection(loreRouter(), path) && readerSupportsEffectUi(page)) { return Effect.tryPromise( () => import("./server/reader-effect-ui-page.js") diff --git a/apps/web/src/features/all-stars-effect-ui/view.ts b/apps/web/src/features/all-stars-effect-ui/view.ts new file mode 100644 index 00000000..2fb83577 --- /dev/null +++ b/apps/web/src/features/all-stars-effect-ui/view.ts @@ -0,0 +1,108 @@ +import type { Html } from "@effect/ui/html"; +import type { CafePersonSummary } from "@rat-stack/core/contracts"; +import * as stylex from "@stylexjs/stylex"; + +import { cafeStyles } from "../cafe/cafe.stylex.js"; +import { allStarsCopy, removalIssueUrl, removalPromise } from "../cafe/copy.js"; +import { allStarsFeedRouter } from "../site-route.js"; + +type AllStarsHtml = Html.H; + +type Person = typeof CafePersonSummary.Type; + +const toolNames = [ + "listPeople", + "readPerson", + "searchPeople", + "listChannels", + "peopleFor", +]; + +const externalLink = (h: AllStarsHtml, href: string, label: string) => + h.a.attrs({ href, rel: "noopener noreferrer" }).children(label); + +const repositories = (h: AllStarsHtml, { repos }: Person) => + repos.length === 0 + ? [] + : [ + h.p( + "Built: ", + ...repos.flatMap((repo, index) => [ + ...(index === 0 ? [] : [", "]), + externalLink(h, repo.source, repo.repo), + ` (${repo.stars} stars)`, + ]) + ), + ]; + +const cardView = (h: AllStarsHtml, person: Person) => + h.li + .key(person.id) + .class(stylex.props(cafeStyles.card).className ?? "") + .children( + h.img.class(stylex.props(cafeStyles.avatar).className ?? "").attrs({ + src: person.avatar, + alt: "", + width: "64", + height: "64", + loading: "lazy", + }), + h.div( + h.h3(h.a.attr("href", person.route).children(person.name)), + h.p(person.summary.text), + ...repositories(h, person), + h.p + .class(stylex.props(cafeStyles.meta).className ?? "") + .children( + externalLink(h, person.summary.source, "source"), + `, checked ${person.summary.verified}` + ) + ) + ); + +const sectionView = ( + h: AllStarsHtml, + heading: string, + people: readonly Person[] +) => + people.length === 0 + ? [] + : [ + h.h2(heading), + h.ul + .class(stylex.props(cafeStyles.cards).className ?? "") + .children(...people.map((person) => cardView(h, person))), + ]; + +export const view = (h: AllStarsHtml, people: readonly Person[]) => + h.div( + h.p(allStarsCopy.intro), + h.p(allStarsCopy.entryRule), + h.p( + "Agents can call ", + ...toolNames.flatMap((name, index) => [ + ...(index === 0 + ? [] + : [index === toolNames.length - 1 ? " and " : ", "]), + h.code(name), + ]), + " over MCP, HTTP or code mode. ", + h.a.attr("href", allStarsFeedRouter()).children(allStarsCopy.feedLabel), + "." + ), + ...sectionView( + h, + allStarsCopy.peopleHeading, + people.filter((person) => person.kind === "person") + ), + ...sectionView( + h, + allStarsCopy.channelsHeading, + people.filter((person) => person.kind === "channel") + ), + h.p( + "To be removed from this page, ", + h.a.attr("href", removalIssueUrl(null)).children("open an issue"), + ` in joelhooks/rat-stack. ${removalPromise}` + ) + ); diff --git a/apps/web/src/features/cafe/all-stars.ts b/apps/web/src/features/cafe/all-stars.ts deleted file mode 100644 index bcae9d2a..00000000 --- a/apps/web/src/features/cafe/all-stars.ts +++ /dev/null @@ -1,127 +0,0 @@ -import type { CafePersonSummary } from "@rat-stack/core/contracts"; -import * as stylex from "@stylexjs/stylex"; -import type { Html, HtmlBuilder } from "foldkit/html"; - -import type { CafeMessage } from "../../client/cafe/message.js"; -import type { AllStarsModel } from "../../client/cafe/model.js"; -import { allStarsFeedRouter } from "../site-route.js"; -import { cafeStyles } from "./cafe.stylex.js"; -import { allStarsCopy, removalIssueUrl, removalPromise } from "./copy.js"; - -const toolNames = [ - "listPeople", - "readPerson", - "searchPeople", - "listChannels", - "peopleFor", -] as const; - -const cardView = ( - h: HtmlBuilder, - person: typeof CafePersonSummary.Type -): Html => - h.li( - [h.Key(person.id), h.Class(stylex.props(cafeStyles.card).className ?? "")], - [ - h.img([ - h.Src(person.avatar), - h.Alt(""), - h.Width("64"), - h.Height("64"), - h.Loading("lazy"), - h.Class(stylex.props(cafeStyles.avatar).className ?? ""), - ]), - h.div( - [], - [ - h.h3([], [h.a([h.Href(person.route)], [person.name])]), - h.p([], [person.summary.text]), - ...(person.repos.length === 0 - ? [] - : [ - h.p( - [], - [ - "Built: ", - ...person.repos.flatMap((repo, index) => [ - ...(index === 0 ? [] : [", "]), - h.a( - [h.Href(repo.source), h.Rel("noopener noreferrer")], - [repo.repo] - ), - ` (${repo.stars} stars)`, - ]), - ] - ), - ]), - h.p( - [h.Class(stylex.props(cafeStyles.meta).className ?? "")], - [ - h.a( - [h.Href(person.summary.source), h.Rel("noopener noreferrer")], - ["source"] - ), - `, checked ${person.summary.verified}`, - ] - ), - ] - ), - ] - ); - -const sectionView = ( - h: HtmlBuilder, - heading: string, - people: readonly (typeof CafePersonSummary.Type)[] -): readonly Html[] => - people.length === 0 - ? [] - : [ - h.h2([], [heading]), - h.ul( - [h.Class(stylex.props(cafeStyles.cards).className ?? "")], - people.map((person) => cardView(h, person)) - ), - ]; - -export const view = (model: AllStarsModel, h: HtmlBuilder): Html => - h.div( - [], - [ - h.p([], [allStarsCopy.intro]), - h.p([], [allStarsCopy.entryRule]), - h.p( - [], - [ - "Agents can call ", - ...toolNames.flatMap((name, index) => [ - ...(index === 0 - ? [] - : [index === toolNames.length - 1 ? " and " : ", "]), - h.code([], [name]), - ]), - " over MCP, HTTP or code mode. ", - h.a([h.Href(allStarsFeedRouter())], [allStarsCopy.feedLabel]), - ".", - ] - ), - ...sectionView( - h, - allStarsCopy.peopleHeading, - model.people.filter((person) => person.kind === "person") - ), - ...sectionView( - h, - allStarsCopy.channelsHeading, - model.people.filter((person) => person.kind === "channel") - ), - h.p( - [], - [ - "To be removed from this page, ", - h.a([h.Href(removalIssueUrl(null))], ["open an issue"]), - ` in joelhooks/rat-stack. ${removalPromise}`, - ] - ), - ] - ); diff --git a/apps/web/src/features/cafe/directory.ts b/apps/web/src/features/cafe/directory.ts deleted file mode 100644 index d1313f25..00000000 --- a/apps/web/src/features/cafe/directory.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { Button } from "@foldkit/ui"; -import { - cafeDomain, - cafeLetterInitial, - cafeLetters, - filterCafeProjects, - verifiedLetters, -} from "@rat-stack/core/contracts"; -import type { - CafeLetterValue, - CafeProjectValue, -} from "@rat-stack/core/contracts"; -import * as stylex from "@stylexjs/stylex"; -import { Array } from "effect"; -import type { Html, HtmlBuilder } from "foldkit/html"; - -import { Message } from "../../client/cafe/message.js"; -import type { CafeMessage } from "../../client/cafe/message.js"; -import type { DirectoryModel } from "../../client/cafe/model.js"; -import { cafeStyles } from "./cafe.stylex.js"; -import { - cafeSubmissionPrompt, - directoryCopy, - letterNames, - projectCount, -} from "./copy.js"; -import { authorView } from "./news.js"; - -const badgeView = ( - h: HtmlBuilder, - project: CafeProjectValue, - letter: CafeLetterValue -): Html => - h.abbr( - [ - h.Key(letter), - h.Class(stylex.props(cafeStyles.badge).className ?? ""), - h.Title(`${letterNames[letter]}: ${project.stack[letter] ?? ""}`), - h.AriaLabel(`${letterNames[letter]}: ${project.stack[letter] ?? ""}`), - ], - [cafeLetterInitial[letter]] - ); - -const projectView = ( - h: HtmlBuilder, - project: CafeProjectValue -): Html => - h.li( - [ - h.Key(project.url), - h.Class(stylex.props(cafeStyles.item).className ?? ""), - ], - [ - h.article( - [], - [ - h.p( - [], - [ - h.a( - [h.Href(project.url), h.Rel("noopener noreferrer")], - [project.title] - ), - h.span( - [h.Class(stylex.props(cafeStyles.badges).className ?? "")], - verifiedLetters(project).map((letter) => - badgeView(h, project, letter) - ) - ), - ] - ), - h.p([], [project.summary]), - h.p( - [h.Class(stylex.props(cafeStyles.meta).className ?? "")], - [ - "by ", - authorView(h, project.author, cafeDomain(project.url)), - ` 路 updated ${project.date}`, - ...(project.stars === null ? [] : [` 路 ${project.stars} stars`]), - ] - ), - ] - ), - ] - ); - -const letterToggle = ( - h: HtmlBuilder, - selected: readonly CafeLetterValue[], - letter: CafeLetterValue -): Html => - Button.view( - { - onClick: Message.ToggledStackLetter({ letter }), - toView: ({ button }) => - h.button( - [ - ...button, - h.Key(letter), - h.AriaPressed(String(selected.includes(letter))), - h.Class( - stylex.props( - cafeStyles.badge, - selected.includes(letter) && cafeStyles.pressed - ).className ?? "" - ), - ], - [letterNames[letter]] - ), - }, - h - ); - -export const view = ( - model: DirectoryModel, - h: HtmlBuilder -): Html => { - const shown = filterCafeProjects(model.projects, model.selected); - - return h.div( - [], - [ - h.p([], [directoryCopy.intro]), - h.fieldset( - [h.Class(stylex.props(cafeStyles.filter).className ?? "")], - [ - h.legend([], [directoryCopy.filterLegend]), - ...cafeLetters.map((letter) => - letterToggle(h, model.selected, letter) - ), - ...Array.match(model.selected, { - onEmpty: () => [], - onNonEmpty: () => [ - Button.view( - { - onClick: Message.ClearedStackLetters(), - toView: ({ button }) => - h.button(button, [directoryCopy.clearLabel]), - }, - h - ), - ], - }), - ] - ), - h.p( - [h.Role("status"), h.AriaLive("polite")], - [projectCount(shown.length)] - ), - h.ul( - [h.Class(stylex.props(cafeStyles.list).className ?? "")], - shown.map((project) => projectView(h, project)) - ), - h.p([], [cafeSubmissionPrompt]), - ] - ); -}; diff --git a/apps/web/src/features/cafe/index.ts b/apps/web/src/features/cafe/index.ts deleted file mode 100644 index 48147cec..00000000 --- a/apps/web/src/features/cafe/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Submodel } from "foldkit"; -import type { Html } from "foldkit/html"; - -import type { CafeMessage } from "../../client/cafe/message.js"; -import { Model } from "../../client/cafe/model.js"; -import type { CafeModel } from "../../client/cafe/model.js"; -import * as AllStars from "./all-stars.js"; -import * as Directory from "./directory.js"; -import * as News from "./news.js"; - -export { - allStarsRouter, - directoryRouter, - newsFeedRouter, - newsRouter, -} from "../site-route.js"; - -export const view = Submodel.defineView((model, h) => - Model.match(model, { - AllStars: (allStars) => AllStars.view(allStars, h), - Directory: (directory) => Directory.view(directory, h), - News: (news) => News.view(news, h), - }) -); diff --git a/apps/web/src/features/cafe/news.ts b/apps/web/src/features/cafe/news.ts deleted file mode 100644 index 31a48603..00000000 --- a/apps/web/src/features/cafe/news.ts +++ /dev/null @@ -1,213 +0,0 @@ -import { - cafeDomain, - githubProfileUrl, - xProfileUrl, -} from "@rat-stack/core/contracts"; -import type { - CafeAuthor, - CafeNewsItemValue, - CafeReply, -} from "@rat-stack/core/contracts"; -import * as stylex from "@stylexjs/stylex"; -import { Array, Option } from "effect"; -import type { Html, HtmlBuilder } from "foldkit/html"; - -import type { CafeMessage } from "../../client/cafe/message.js"; -import type { NewsModel } from "../../client/cafe/model.js"; -import { newsFeedRouter } from "../site-route.js"; -import { cafeStyles } from "./cafe.stylex.js"; -import { - allStarsCopy, - cafeSubmissionPrompt, - newsCopy, - newsKindLabels, - shownReplies, - sortRules, - sortRulesLead, - sortSignals, - sortSignalsLead, - sortSources, - threadCounts, -} from "./copy.js"; -import { otherNewsOrder } from "./news-order.js"; - -const externalLink = ( - h: HtmlBuilder, - href: string, - label: string -): Html => h.a([h.Href(href), h.Rel("noopener noreferrer")], [label]); - -export const authorView = ( - h: HtmlBuilder, - author: typeof CafeAuthor.Type, - fallback: string -): Html => { - if (author.github !== null) { - return externalLink(h, githubProfileUrl(author.github), author.github); - } - - if (author.x !== null) { - return externalLink(h, xProfileUrl(author.x), `@${author.x}`); - } - - return h.span([], [fallback]); -}; - -const replyView = (h: HtmlBuilder, reply: typeof CafeReply.Type) => - h.li( - [h.Key(reply.url)], - [ - externalLink(h, xProfileUrl(reply.x), `@${reply.x}`), - `: ${reply.text} `, - externalLink(h, reply.url, `${reply.likes} likes`), - ] - ); - -const threadView = ( - h: HtmlBuilder, - item: CafeNewsItemValue -): Html[] => - item.kind === "thread" - ? [ - h.p( - [h.Class(stylex.props(cafeStyles.meta).className ?? "")], - [threadCounts(item.engagement.replies, item.engagement.participants)] - ), - h.details( - [h.Class(stylex.props(cafeStyles.replies).className ?? "")], - [ - h.summary([], [newsCopy.repliesLabel]), - h.ul( - [], - item.topReplies - .slice(0, shownReplies) - .map((reply) => replyView(h, reply)) - ), - ] - ), - ] - : []; - -const profileLinkView = ( - h: HtmlBuilder, - profiles: NewsModel["profiles"], - item: CafeNewsItemValue -): (Html | string)[] => - Option.match( - Array.findFirst(profiles, (profile) => profile.url === item.url), - { - onNone: (): (Html | string)[] => [], - onSome: (profile) => [ - " 路 ", - h.a( - [h.Href(profile.route), h.AriaLabel(`${profile.name} on all stars`)], - [allStarsCopy.profileLabel] - ), - ], - } - ); - -const itemView = ( - h: HtmlBuilder, - profiles: NewsModel["profiles"], - item: CafeNewsItemValue -): Html => - h.li( - [h.Key(item.url), h.Class(stylex.props(cafeStyles.item).className ?? "")], - [ - h.article( - [], - [ - h.p( - [], - [ - h.span( - [h.Class(stylex.props(cafeStyles.tag).className ?? "")], - [`[${newsKindLabels[item.kind]}]`] - ), - externalLink(h, item.url, item.title), - h.span( - [h.Class(stylex.props(cafeStyles.meta).className ?? "")], - [` (${cafeDomain(item.url)})`] - ), - ] - ), - ...Option.toArray(Option.fromNullishOr(item.summary)).map((summary) => - h.p([], [summary]) - ), - ...(item.interest === undefined - ? [] - : [ - h.p( - [h.Class(stylex.props(cafeStyles.meta).className ?? "")], - [item.interest.why] - ), - ]), - h.p( - [h.Class(stylex.props(cafeStyles.meta).className ?? "")], - [ - h.time([], [item.date]), - " by ", - authorView(h, item.author, cafeDomain(item.url)), - ...profileLinkView(h, profiles, item), - ] - ), - ...threadView(h, item), - ] - ), - ] - ); - -const sortSectionView = (h: HtmlBuilder): Html => - h.section( - [h.AriaLabelledBy("how-this-list-is-sorted")], - [ - h.h2([h.Id("how-this-list-is-sorted")], [newsCopy.sortHeading]), - h.p([], [sortSignalsLead]), - h.ul( - [], - sortSignals.map((signal) => h.li([], [signal])) - ), - h.p([], [sortRulesLead]), - h.ul( - [], - sortRules.map((rule) => h.li([], [rule])) - ), - h.p( - [], - [ - newsCopy.priorArtLead, - ...sortSources.flatMap((source, index) => [ - ...(index === 0 ? [] : [", "]), - externalLink(h, source.href, source.label), - ]), - ".", - ] - ), - ] - ); - -export const view = (model: NewsModel, h: HtmlBuilder): Html => { - const other = otherNewsOrder(model.sort); - - return h.div( - [], - [ - h.p([], [newsCopy.intro]), - h.p( - [], - [ - h.a([h.Href(other.href)], [other.label]), - " 路 ", - h.a([h.Href(newsFeedRouter())], [newsCopy.feedLabel]), - ] - ), - h.ol( - [h.Class(stylex.props(cafeStyles.list).className ?? "")], - model.items.map((item) => itemView(h, model.profiles, item)) - ), - ...(model.sort === "rank" ? [sortSectionView(h)] : []), - h.p([], [cafeSubmissionPrompt]), - ] - ); -}; diff --git a/apps/web/src/features/reader.ts b/apps/web/src/features/reader.ts index 52fab9e6..d5fdd970 100644 --- a/apps/web/src/features/reader.ts +++ b/apps/web/src/features/reader.ts @@ -13,7 +13,6 @@ import { } from "../client/reader/model.js"; import type { ReaderModel } from "../client/reader/model.js"; import { view as docsView } from "./app.js"; -import * as CafeView from "./cafe/index.js"; import * as MotionView from "./motion/index.js"; import { readerFooter, readerNewsCallout } from "./reader-chrome.js"; import { readerCopyIcon } from "./reader-copy-icon.js"; @@ -295,19 +294,7 @@ const bodyView = ( ) ), }), - ...(cafeSlot === undefined - ? Option.match(model.cafe, { - onNone: () => [], - onSome: (cafe) => [ - h.submodel({ - model: cafe, - slotId: "cafe", - toParentMessage: (message) => Message.GotCafeMessage({ message }), - view: CafeView.view, - }), - ], - }) - : [cafeSlot(h)]), + ...(cafeSlot === undefined ? [] : [cafeSlot(h)]), ...Option.match(model.docs, { onNone: () => [], onSome: (docs) => [ diff --git a/apps/web/src/reader-cafe.ts b/apps/web/src/reader-cafe.ts new file mode 100644 index 00000000..cc2c40b0 --- /dev/null +++ b/apps/web/src/reader-cafe.ts @@ -0,0 +1,19 @@ +import { IsoDate } from "@rat-stack/core/contracts"; +import { Schema } from "effect"; + +import { AllStarsProps } from "./client/all-stars-effect-ui/model.js"; +import { DirectoryProps } from "./client/directory-effect-ui/model.js"; +import { NewsProps } from "./client/news-effect-ui/model.js"; +import { ReaderFlags } from "./client/reader/model.js"; + +export const CafePage = Schema.TaggedUnion({ + AllStars: AllStarsProps.fields, + Directory: DirectoryProps.fields, + News: { ...NewsProps.fields, rankedAt: IsoDate }, +}); + +export const ReaderSource = ReaderFlags.pipe( + Schema.fieldsAssign({ cafe: Schema.OptionFromOptional(CafePage) }) +); + +export type ReaderSourcePage = typeof ReaderSource.Type; diff --git a/apps/web/src/server/all-stars-effect-ui.ts b/apps/web/src/server/all-stars-effect-ui.ts new file mode 100644 index 00000000..35f3661e --- /dev/null +++ b/apps/web/src/server/all-stars-effect-ui.ts @@ -0,0 +1,38 @@ +import { HtmlServer } from "@effect/ui/html"; +import { Effect, Schema } from "effect"; + +import { AllStarsPage } from "../client/all-stars-effect-ui/component.js"; +import { + AllStarsHandoff, + allStarsHandoffId, + allStarsRootId, +} from "../client/all-stars-effect-ui/model.js"; +import type { AllStarsProps } from "../client/all-stars-effect-ui/model.js"; +import type { ReaderPageFlags } from "../client/reader/model.js"; +import type { EffectUiAssets } from "./reader-document.js"; +import { renderEffectUiCafe } from "./reader-effect-ui.js"; + +export const renderAllStarsPage = Effect.fn("reader.renderAllStarsPage")( + function* renderAllStarsPage( + page: ReaderPageFlags, + { people }: typeof AllStarsProps.Type, + assets: typeof EffectUiAssets.Type + ) { + const props = { people }; + const rendered = yield* HtmlServer.renderToHtml(AllStarsPage, props); + + const handoff = yield* Schema.encodeEffect(AllStarsHandoff)({ + props, + state: rendered.state, + }); + + return yield* renderEffectUiCafe( + page, + allStarsRootId, + rendered.html, + allStarsHandoffId, + handoff, + assets + ); + } +); diff --git a/apps/web/src/server/reader-effect-ui-props.ts b/apps/web/src/server/reader-effect-ui-props.ts index 48208bae..3dbe6eea 100644 --- a/apps/web/src/server/reader-effect-ui-props.ts +++ b/apps/web/src/server/reader-effect-ui-props.ts @@ -6,7 +6,6 @@ import type { ReaderPageFlags } from "../client/reader/model.js"; export const readerSupportsEffectUi = (flags: ReaderPageFlags) => flags.blocks.length === 0 && - Option.isNone(flags.cafe) && Option.isNone(flags.docs) && Option.isNone(flags.motion) && Option.isNone(flags.tube); diff --git a/apps/web/src/client/reader-pages.ts b/apps/web/src/server/reader-pages.ts similarity index 87% rename from apps/web/src/client/reader-pages.ts rename to apps/web/src/server/reader-pages.ts index 1c033f16..3e6b5cdc 100644 --- a/apps/web/src/client/reader-pages.ts +++ b/apps/web/src/server/reader-pages.ts @@ -1,8 +1,8 @@ import { Effect, Option, Schema } from "effect"; import { readerPagePaths } from "virtual:reader-pages"; -import { ReaderFlags } from "./reader/model.js"; -import type { ReaderPageFlags } from "./reader/model.js"; +import { ReaderSource } from "../reader-cafe.js"; +import type { ReaderSourcePage } from "../reader-cafe.js"; export const pagePaths = Schema.decodeUnknownSync(Schema.Array(Schema.String))( readerPagePaths @@ -13,7 +13,7 @@ const decodeSources = Schema.decodeUnknownEffect( ); const decodePage = Schema.decodeUnknownEffect( - Schema.fromJsonString(ReaderFlags) + Schema.fromJsonString(ReaderSource) ); const importSources = () => import("virtual:reader-page-sources"); @@ -38,7 +38,7 @@ const loadSources = Effect.fn("reader.loadPageSources")( const knownPaths = new Set(pagePaths); -const decoded = new Map(); +const decoded = new Map(); export const findPage = Effect.fn("reader.findPage")(function* findPage( path: string diff --git a/apps/web/src/server/reader-render.ts b/apps/web/src/server/reader-render.ts index 1ee15134..376610ae 100644 --- a/apps/web/src/server/reader-render.ts +++ b/apps/web/src/server/reader-render.ts @@ -2,11 +2,13 @@ import { Cause, Effect, Option, Schema } from "effect"; import { renderToString } from "foldkit/experimental/server"; import type { ReaderErrorPage } from "../../../site/src/reader-error-page.js"; -import { Model as CafeModel } from "../client/cafe/model.js"; import { init } from "../client/reader/init.js"; import { ReaderFlags } from "../client/reader/model.js"; import type { ReaderPageFlags } from "../client/reader/model.js"; import { view } from "../features/reader.js"; +import { CafePage } from "../reader-cafe.js"; +import type { ReaderSourcePage } from "../reader-cafe.js"; +import type * as AllStarsRenderer from "./all-stars-effect-ui.js"; import type * as DirectoryRenderer from "./directory-effect-ui.js"; import type * as NewsRenderer from "./news-effect-ui.js"; import { withReaderHead } from "./reader-document.js"; @@ -42,7 +44,7 @@ type RenderError = ( const renderCafeOrError = ( page: ReaderPageFlags, - label: "News" | "Directory", + label: "News" | "Directory" | "All Stars", renderCafe: Effect.Effect[0], E>, renderError: RenderError ) => { @@ -79,7 +81,7 @@ const renderCafeOrError = ( export const renderNewsOrError = Effect.fn("reader.renderNewsOrError")( ( - page: ReaderPageFlags, + page: ReaderSourcePage, assets: typeof EffectUiAssets.Type, loadNews: () => Promise, renderError: RenderError @@ -88,7 +90,7 @@ export const renderNewsOrError = Effect.fn("reader.renderNewsOrError")( page, "News", Effect.gen(function* renderNews() { - const cafe = page.cafe.pipe(Option.filter(CafeModel.guards.News)); + const cafe = page.cafe.pipe(Option.filter(CafePage.guards.News)); if (Option.isNone(cafe)) { return yield* new MissingCafe({ path: page.page.path }); @@ -106,7 +108,7 @@ export const renderDirectoryOrError = Effect.fn( "reader.renderDirectoryOrError" )( ( - page: ReaderPageFlags, + page: ReaderSourcePage, assets: typeof EffectUiAssets.Type, loadDirectory: () => Promise, renderError: RenderError @@ -115,7 +117,7 @@ export const renderDirectoryOrError = Effect.fn( page, "Directory", Effect.gen(function* renderDirectory() { - const cafe = page.cafe.pipe(Option.filter(CafeModel.guards.Directory)); + const cafe = page.cafe.pipe(Option.filter(CafePage.guards.Directory)); if (Option.isNone(cafe)) { return yield* new MissingCafe({ path: page.page.path }); @@ -128,3 +130,28 @@ export const renderDirectoryOrError = Effect.fn( renderError ) ); + +export const renderAllStarsOrError = Effect.fn("reader.renderAllStarsOrError")( + ( + page: ReaderSourcePage, + assets: typeof EffectUiAssets.Type, + loadAllStars: () => Promise, + renderError: RenderError + ) => + renderCafeOrError( + page, + "All Stars", + Effect.gen(function* renderAllStars() { + const cafe = page.cafe.pipe(Option.filter(CafePage.guards.AllStars)); + + if (Option.isNone(cafe)) { + return yield* new MissingCafe({ path: page.page.path }); + } + + const { renderAllStarsPage } = yield* Effect.tryPromise(loadAllStars); + + return yield* renderAllStarsPage(page, cafe.value, assets); + }), + renderError + ) +); diff --git a/apps/web/test/all-stars-effect-ui.test.ts b/apps/web/test/all-stars-effect-ui.test.ts new file mode 100644 index 00000000..6c822c48 --- /dev/null +++ b/apps/web/test/all-stars-effect-ui.test.ts @@ -0,0 +1,138 @@ +import { NodeServices } from "@effect/platform-node"; +import { ssr } from "@effect/ui/html/testing"; +import { TestHost } from "@effect/ui/testing"; +import { expect, it } from "@effect/vitest"; +import { Effect, FileSystem, Option, Path, Schema } from "effect"; + +import { AllStarsPage } from "../src/client/all-stars-effect-ui/component.js"; +import { + AllStarsHandoff, + AllStarsProps, + allStarsHandoffId, + allStarsRootId, +} from "../src/client/all-stars-effect-ui/model.js"; +import { CafePage, ReaderSource } from "../src/reader-cafe.js"; +import { renderAllStarsPage } from "../src/server/all-stars-effect-ui.js"; +import { + renderDocument, + withReaderHead, +} from "../src/server/reader-document.js"; +import { cafeParity, parseCafeHtml } from "./cafe-parity.js"; +import fixture from "./fixtures/foldkit-all-stars-parity.json"; + +const cardSelector = "main ul > li:has(img)"; + +const assets = { + entryScript: "/assets/all-stars-effect-ui-test.js", + modulePreloads: [], + stylesheets: [], +}; + +const allStarsFlags = Effect.gen(function* allStarsFlags() { + const fs = yield* FileSystem.FileSystem; + const paths = yield* Path.Path; + + const source = yield* fs.readFileString( + paths.resolve(import.meta.dirname, "../dist/reader-pages.json") + ); + + const pages = yield* Schema.decodeEffect( + Schema.fromJsonString(Schema.Array(ReaderSource)) + )(source); + + const flags = yield* Effect.fromOption( + Option.fromNullishOr(pages.find((page) => page.page.path === "/all-stars")) + ); + + const cafe = yield* Effect.fromOption( + flags.cafe.pipe(Option.filter(CafePage.guards.AllStars)) + ); + + return { cafe, flags }; +}); + +it.live( + "All Stars keeps the captured Foldkit text, links, avatars and classes", + () => + Effect.gen(function* allStarsParity() { + const { flags } = yield* allStarsFlags; + + const props = yield* Schema.decodeUnknownEffect(AllStarsProps)({ + people: fixture.people, + }); + + const rendered = yield* renderAllStarsPage(flags, props, assets); + const html = renderDocument(withReaderHead(rendered, flags), assets); + + expect(cafeParity(parseCafeHtml(html), cardSelector)).toEqual( + fixture.legacy + ); + }).pipe(Effect.provide(NodeServices.layer)) +); + +it.layer(TestHost.layer())("All Stars with committed data", (test) => { + test.effect( + "the built route preserves profile order and adopts its keyed cards", + () => + Effect.gen(function* committedAllStars() { + const { cafe } = yield* allStarsFlags; + const fs = yield* FileSystem.FileSystem; + const paths = yield* Path.Path; + + const output = parseCafeHtml( + yield* fs.readFileString( + paths.resolve( + import.meta.dirname, + "../dist/client/all-stars/index.html" + ) + ) + ); + + const ordered = [ + ...cafe.people.filter(({ kind }) => kind === "person"), + ...cafe.people.filter(({ kind }) => kind === "channel"), + ]; + + const expected = ordered.map(({ avatar, name, route }) => ({ + avatar, + name, + route, + })); + + const cards = [...output.querySelectorAll(cardSelector)].map( + (card) => ({ + avatar: card.querySelector("img")?.getAttribute("src"), + name: card.querySelector("h3 a")?.textContent, + route: card.querySelector("h3 a")?.getAttribute("href"), + }) + ); + + expect(cards).toEqual(expected); + expect(cards.length).toBeGreaterThan(0); + expect( + output.querySelector('script[type="module"]')?.getAttribute("src") + ).toMatch(/^\/assets\/all-stars-effect-ui-[\w-]+\.js$/u); + expect( + output.querySelector("[data-foldkit-app], [data-foldkit-flags]") + ).toBeNull(); + expect(output.querySelector(`#${allStarsRootId}`)).not.toBeNull(); + + const payload = output.querySelector(`#${allStarsHandoffId}`); + expect(payload?.getAttribute("type")).toBe("application/json"); + + const { props } = yield* Schema.decodeEffect( + Schema.fromJsonString(AllStarsHandoff) + )(payload?.textContent ?? ""); + + expect(props).toEqual({ people: cafe.people }); + + const hydrated = yield* ssr(AllStarsPage, props); + expect(hydrated.adopted).toEqual(["/AllStarsPage"]); + expect( + [...hydrated.container.querySelectorAll("li:has(img) h3 a")].map( + (link) => link.getAttribute("href") + ) + ).toEqual(ordered.map(({ route }) => route)); + }).pipe(Effect.provide(NodeServices.layer)) + ); +}); diff --git a/apps/web/test/all-stars.seam.test.ts b/apps/web/test/all-stars.seam.test.ts index cfed1f8e..7ec85860 100644 --- a/apps/web/test/all-stars.seam.test.ts +++ b/apps/web/test/all-stars.seam.test.ts @@ -1,6 +1,6 @@ import { NodeServices } from "@effect/platform-node"; import { expect, it } from "@effect/vitest"; -import { Effect, Schema } from "effect"; +import { Effect, Option, Schema } from "effect"; import { renderToString } from "foldkit/experimental/server"; import { readerBodyFlags } from "../../site/scripts/reader-body-flags.ts"; @@ -9,6 +9,8 @@ import { prepareReaderSiteInputs } from "../../site/scripts/reader-site-inputs.t import { init } from "../src/client/reader/init.js"; import { ReaderFlags } from "../src/client/reader/model.js"; import { view } from "../src/features/reader.js"; +import { CafePage, ReaderSource } from "../src/reader-cafe.js"; +import { renderAllStarsPage } from "../src/server/all-stars-effect-ui.js"; const htmlText = (value: string) => value @@ -67,14 +69,19 @@ it.effect( return; } - const cards = yield* renderToString( - { Flags: ReaderFlags, init, view }, - { - flags: yield* Schema.decodeUnknownEffect(ReaderFlags)(index), - isHydratable: false, - } + const page = yield* Schema.decodeUnknownEffect(ReaderSource)(index); + + const cafe = yield* page.cafe.pipe( + Option.filter(CafePage.guards.AllStars), + Effect.fromOption ); + const cards = yield* renderAllStarsPage(page, cafe, { + entryScript: "/assets/all-stars-effect-ui-test.js", + modulePreloads: [], + stylesheets: [], + }); + for (const person of inputs.cafe.people) { expect(cards.html).toContain(`src="${person.avatar.path}"`); expect(cards.html).toContain(`href="/all-stars/${person.id}"`); diff --git a/apps/web/test/cafe-fixture.ts b/apps/web/test/cafe-fixture.ts index ccd0e29e..6caa5310 100644 --- a/apps/web/test/cafe-fixture.ts +++ b/apps/web/test/cafe-fixture.ts @@ -2,8 +2,6 @@ import { CafeProject, cafeLetters } from "@rat-stack/core/contracts"; import type { CafeLetterValue } from "@rat-stack/core/contracts"; import { Schema } from "effect"; -import { Model } from "../src/client/cafe/model.js"; - const evidenceFor = ( letters: readonly CafeLetterValue[], letter: CafeLetterValue @@ -42,7 +40,7 @@ export const edgeApp = cafeProject("edge-app", [ "effect", ]); -export const directoryHome = Model.Directory({ +export const directoryHome = { projects: [fullStack, effectOnly, edgeApp], selected: [], -}); +}; diff --git a/apps/web/test/cafe-parity.ts b/apps/web/test/cafe-parity.ts new file mode 100644 index 00000000..6eeac77e --- /dev/null +++ b/apps/web/test/cafe-parity.ts @@ -0,0 +1,45 @@ +export const parseCafeHtml = (html: string) => + new DOMParser().parseFromString(html, "text/html"); + +export const cafeText = (element: Element) => + (element.textContent ?? "").replaceAll(/\s+/gu, " ").trim(); + +export const cafeAttributes = ( + root: ParentNode, + selector: string, + attributes: readonly string[] +) => + [...root.querySelectorAll(selector)].map((element) => [ + element.localName, + ...attributes.flatMap((name) => { + const value = element.getAttribute(name); + + return value === null ? [] : [`${name}=${value}`]; + }), + ]); + +export const cafeParity = (document: Document, listSelector: string) => ({ + text: [...document.querySelectorAll("header, main, footer")].map(cafeText), + rows: [...document.querySelectorAll(listSelector)].map(cafeText), + attributes: cafeAttributes( + document, + "main :is([class], a, abbr, button, img, time, details, [role=status])", + [ + "class", + "href", + "rel", + "title", + "type", + "aria-label", + "aria-pressed", + "aria-live", + "src", + "alt", + "width", + "height", + "loading", + "datetime", + "open", + ] + ), +}); diff --git a/apps/web/test/cafe.scene.test.ts b/apps/web/test/cafe.scene.test.ts deleted file mode 100644 index 831ddd9b..00000000 --- a/apps/web/test/cafe.scene.test.ts +++ /dev/null @@ -1,152 +0,0 @@ -import { it } from "@effect/vitest"; -import { CafePersonSummary, CafeStory } from "@rat-stack/core/contracts"; -import { Schema } from "effect"; -import { click, expect, given, label, role, scene, text } from "foldkit/scene"; - -import { Model } from "../src/client/cafe/model.js"; -import { update } from "../src/client/cafe/update.js"; -import { view } from "../src/features/cafe/index.js"; -import { directoryHome, fullStack } from "./cafe-fixture.js"; - -it("CAFE pages show the short prompt instead of the agent filing instructions", () => { - for (const model of [ - directoryHome, - Model.News({ - items: [], - profiles: [], - rankedAt: fullStack.date, - sort: "rank", - }), - ]) { - scene( - { update, view }, - given(model), - expect( - text( - "Know a project or story about the stack? Ask your agent to suggest it." - ) - ).toExist(), - expect(text("Suggest a story or project through your agent")).toBeAbsent() - ); - } -}); - -it("pressing stack letters narrows the directory to projects with evidence for every pressed letter", () => { - scene( - { update, view }, - given(directoryHome), - expect(text("3 projects")).toExist(), - expect(role("button", { name: "Show all projects" })).toBeAbsent(), - click(role("button", { name: "Cloudflare" })), - expect(role("button", { name: "Cloudflare" })).toHaveAttr( - "aria-pressed", - "true" - ), - expect(text("2 projects")).toExist(), - expect(role("link", { name: "effect-only" })).toBeAbsent(), - expect(role("link", { name: "edge-app" })).toExist(), - click(role("button", { name: "Foldkit" })), - expect(text("1 project")).toExist(), - expect(role("link", { name: "edge-app" })).toBeAbsent(), - expect(role("link", { name: "full-stack" })).toExist(), - click(role("button", { name: "Show all projects" })), - expect(text("3 projects")).toExist(), - expect(role("button", { name: "Cloudflare" })).toHaveAttr( - "aria-pressed", - "false" - ), - expect(role("link", { name: "effect-only" })).toExist() - ); -}); - -it("badges name each verified letter and its evidence", () => { - scene( - { update, view }, - given(directoryHome), - expect(role("link", { name: "effect-only" })).toExist(), - expect(label("Effect: effect evidence in package.json")).toHaveText("E"), - expect(label("Foldkit: foldkit evidence in package.json")).toHaveText("F"), - expect(label("Foldkit: null")).toBeAbsent() - ); -}); - -const fact = { - source: "https://github.com/ada", - text: "Ada builds CAFE things.", - verified: "2026-11-02", -}; - -const ada = Schema.decodeSync(CafePersonSummary)({ - avatar: "/avatars/ada.png", - handles: [ - { - handle: "ada", - kind: "github", - url: "https://github.com/ada", - ...fact, - }, - ], - id: "ada", - kind: "person", - name: "Ada", - packages: [], - repos: [{ repo: "ada/engine", stars: 12, ...fact }], - route: "/all-stars/ada", - summary: fact, - topics: [], -}); - -it("the all stars index shows one card per person, and channels under their own heading", () => { - scene( - { update, view }, - given( - Model.AllStars({ - people: [ - ada, - Schema.decodeSync(CafePersonSummary)({ - ...Schema.encodeSync(CafePersonSummary)(ada), - id: "fold", - kind: "channel", - name: "Fold", - }), - ], - }) - ), - expect(role("link", { name: "Ada" })).toHaveAttr("href", "/all-stars/ada"), - expect(role("heading", { name: "People" })).toExist(), - expect(role("heading", { name: "Channels" })).toExist(), - expect(role("link", { name: "Fold" })).toExist(), - expect(text("Ada builds CAFE things.")).toExist(), - expect(role("link", { name: "ada/engine" })).toExist(), - expect(role("link", { name: "open an issue" })).toExist() - ); -}); - -it("a news row whose author has a profile links to it", () => { - const row = Schema.decodeSync(CafeStory)({ - author: { github: "ada", x: null }, - date: "2026-11-01", - kind: "post", - repo: null, - source: "https://example.com/source", - summary: "A row.", - title: "Ada's row", - url: "https://example.com/row", - }); - - scene( - { update, view }, - given( - Model.News({ - items: [row], - profiles: [{ name: "Ada", route: "/all-stars/ada", url: row.url }], - rankedAt: row.date, - sort: "rank", - }) - ), - expect(role("link", { name: "Ada on all stars" })).toHaveAttr( - "href", - "/all-stars/ada" - ) - ); -}); diff --git a/apps/web/test/cafe.story.test.ts b/apps/web/test/cafe.story.test.ts deleted file mode 100644 index 28bd7511..00000000 --- a/apps/web/test/cafe.story.test.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { expect, it } from "@effect/vitest"; -import { CafeLetter, cafeLetters } from "@rat-stack/core/contracts"; -import type { CafeLetterValue } from "@rat-stack/core/contracts"; -import { Schema } from "effect"; -import * as Arbitrary from "effect/Arbitrary"; -import { given, message, model, story } from "foldkit/story"; - -import { Message } from "../src/client/cafe/message.js"; -import { Model } from "../src/client/cafe/model.js"; -import { update } from "../src/client/cafe/update.js"; -import { directoryHome } from "./cafe-fixture.js"; - -const histories = Arbitrary.schema( - Schema.Array( - Schema.Union([ - Schema.Struct({ letter: CafeLetter, step: Schema.Literal("toggle") }), - Schema.Struct({ step: Schema.Literal("clear") }), - ]) - ).check(Schema.isMaxLength(40)) -); - -const expectedSelection = ( - history: typeof histories extends Arbitrary.Arbitrary ? A : never -): readonly CafeLetterValue[] => { - const chosen = new Set(); - - for (const step of history) { - if (step.step === "clear") { - chosen.clear(); - } else if (chosen.has(step.letter)) { - chosen.delete(step.letter); - } else { - chosen.add(step.letter); - } - } - - return cafeLetters.filter((letter) => chosen.has(letter)); -}; - -it.prop( - "directory filter histories select each toggled letter once, in C, A, F, E order", - { history: histories }, - ({ history }) => { - story( - update, - given(directoryHome), - ...history.map((step) => - message( - step.step === "clear" - ? Message.ClearedStackLetters() - : Message.ToggledStackLetter({ letter: step.letter }) - ) - ), - model((current) => { - expect(current).toStrictEqual( - Model.Directory({ - projects: directoryHome.projects, - selected: expectedSelection(history), - }) - ); - }) - ); - } -); - -it.prop( - "news pages ignore directory filter messages", - { history: histories }, - ({ history }) => { - const news = Model.News({ - items: [], - profiles: [], - rankedAt: Schema.decodeSync(Schema.String.pipe(Schema.brand("IsoDate")))( - "2026-10-08" - ), - sort: "rank", - }); - - story( - update, - given(news), - ...history.map((step) => - message( - step.step === "clear" - ? Message.ClearedStackLetters() - : Message.ToggledStackLetter({ letter: step.letter }) - ) - ), - model((current) => { - expect(current).toStrictEqual(news); - }) - ); - } -); diff --git a/apps/web/test/directory-effect-ui.test.ts b/apps/web/test/directory-effect-ui.test.ts index fc525452..f42ea3bc 100644 --- a/apps/web/test/directory-effect-ui.test.ts +++ b/apps/web/test/directory-effect-ui.test.ts @@ -9,9 +9,7 @@ import { filterCafeProjects, } from "@rat-stack/core/contracts"; import { Effect, FileSystem, Logger, Option, Path, Schema } from "effect"; -import { renderToString } from "foldkit/experimental/server"; -import { Model as CafeModel } from "../src/client/cafe/model.js"; import { DirectoryPage } from "../src/client/directory-effect-ui/component.js"; import { hydrateDirectory } from "../src/client/directory-effect-ui/hydration.js"; import { @@ -20,14 +18,12 @@ import { directoryHandoffId, directoryRootId, } from "../src/client/directory-effect-ui/model.js"; -import { init } from "../src/client/reader/init.js"; -import { ReaderFlags } from "../src/client/reader/model.js"; import { directoryCopy, letterNames, projectCount, } from "../src/features/cafe/copy.js"; -import { view } from "../src/features/reader.js"; +import { CafePage, ReaderSource } from "../src/reader-cafe.js"; import { renderDirectoryPage } from "../src/server/directory-effect-ui.js"; import { renderDocument, @@ -39,6 +35,8 @@ import { renderReaderError, } from "../src/server/reader-render.js"; import { cafeProject, directoryHome } from "./cafe-fixture.js"; +import { cafeParity } from "./cafe-parity.js"; +import legacyDirectory from "./fixtures/foldkit-directory-parity.json"; const directoryFlags = Effect.gen(function* directoryFlags() { const fs = yield* FileSystem.FileSystem; @@ -49,7 +47,7 @@ const directoryFlags = Effect.gen(function* directoryFlags() { ); const pages = yield* Schema.decodeEffect( - Schema.fromJsonString(Schema.Array(ReaderFlags)) + Schema.fromJsonString(Schema.Array(ReaderSource)) )(source); const flags = yield* Effect.fromOption( @@ -57,7 +55,7 @@ const directoryFlags = Effect.gen(function* directoryFlags() { ); const cafe = yield* Effect.fromOption( - flags.cafe.pipe(Option.filter(CafeModel.guards.Directory)) + flags.cafe.pipe(Option.filter(CafePage.guards.Directory)) ); return { cafe, flags }; @@ -66,46 +64,11 @@ const directoryFlags = Effect.gen(function* directoryFlags() { const parseMarkup = (html: string) => new DOMParser().parseFromString(html, "text/html"); -const text = (element: Element) => - (element.textContent ?? "").replaceAll(/\s+/gu, " ").trim(); - -const visibleText = (document: Document) => - [...document.querySelectorAll("header, main, footer")].map(text); - const projectLinks = (root: ParentNode) => [...root.querySelectorAll("li > article > p:first-child > a")].map((link) => link.getAttribute("href") ); -const links = (document: Document) => - [...document.querySelectorAll("a")].map((a) => - ["href", "rel", "target"].map((name) => a.getAttribute(name)) - ); - -const head = (document: Document) => - [ - ...document.head.querySelectorAll( - 'title, meta, link:not([rel="modulepreload"]), script:not([type="module"]):not([id])' - ), - ].map((tag) => tag.outerHTML); - -const stylesAndControls = (document: Document) => - [ - ...document.querySelectorAll( - "main :is([class], button, abbr, [role=status])" - ), - ].map((element) => [ - element.localName, - ...[ - "class", - "type", - "title", - "aria-label", - "aria-pressed", - "aria-live", - ].map((key) => element.getAttribute(key)), - ]); - const assets = { entryScript: "/assets/directory-effect-ui-test.js", modulePreloads: [], @@ -203,11 +166,36 @@ it.effect.prop( { arbitrary: { runs: 40 } } ); +it.live("directory text and styles match the captured Foldkit fixtures", () => + Effect.gen(function* directoryParity() { + const { flags } = yield* directoryFlags; + + const cases = [ + { expected: legacyDirectory.all, selected: [] }, + { + expected: legacyDirectory.alchemy, + selected: [CafeLetter.make("alchemy")], + }, + ]; + + for (const { expected, selected } of cases) { + const props = { ...directoryHome, selected }; + const rendered = yield* renderDirectoryPage(flags, props, assets); + + const html = renderDocument(withReaderHead(rendered, flags), assets); + + expect(cafeParity(parseMarkup(html), "main li:has(>article)")).toEqual( + expected + ); + } + }).pipe(Effect.provide(NodeServices.layer)) +); + it.live( - "committed data keeps Foldkit text and styles with and without a selected letter", + "the built Directory preserves the catalog order and explicit handoff", () => - Effect.gen(function* directoryParity() { - const { cafe, flags } = yield* directoryFlags; + Effect.gen(function* committedDirectory() { + const { cafe } = yield* directoryFlags; const fs = yield* FileSystem.FileSystem; const paths = yield* Path.Path; @@ -220,65 +208,24 @@ it.live( ) ); - expect(new Set(cafe.projects.map((project) => project.url)).size).toBe( - cafe.projects.length - ); - - const stylesheets = [ - ...output.head.querySelectorAll('link[rel="stylesheet"][href]'), - ].flatMap((tag) => - Option.toArray(Option.fromNullishOr(tag.getAttribute("href"))) - ); - - const documentAssets = { ...assets, stylesheets }; + const urls = cafe.projects.map(({ url }) => url); - for (const selected of [[], [CafeLetter.make("alchemy")]]) { - const filteredCafe = CafeModel.Directory({ ...cafe, selected }); - const page = { ...flags, cafe: Option.some(filteredCafe) }; + expect(new Set(urls).size).toBe(urls.length); + expect(projectLinks(output)).toEqual(urls); + expect( + output.querySelector("[data-foldkit-app], [data-foldkit-flags]") + ).toBeNull(); - const legacy = yield* renderToString( - { Flags: ReaderFlags, init, view }, - { flags: page, isHydratable: false } - ); - - const actual = - selected.length === 0 - ? output - : yield* renderDirectoryPage(page, filteredCafe, assets).pipe( - Effect.map((application) => - parseMarkup( - renderDocument( - withReaderHead(application, page), - documentAssets - ) - ) - ) - ); - - const expected = parseMarkup( - renderDocument(withReaderHead(legacy, page), documentAssets) - ); + const payload = output.querySelector(`#${directoryHandoffId}`); + expect(payload?.getAttribute("type")).toBe("application/json"); - expect(visibleText(actual)).toEqual(visibleText(expected)); - expect(stylesAndControls(actual)).toEqual(stylesAndControls(expected)); - expect(links(actual)).toEqual(links(expected)); - expect(head(actual)).toEqual(head(expected)); - expect( - actual.querySelector("[data-foldkit-app], [data-foldkit-flags]") - ).toBeNull(); - - const payload = actual.querySelector(`#${directoryHandoffId}`); - expect(payload?.getAttribute("type")).toBe("application/json"); - - const { props, state } = yield* Schema.decodeEffect( - Schema.fromJsonString(DirectoryHandoff) - )(payload?.textContent ?? ""); - - expect(props).toEqual({ projects: cafe.projects, selected }); - expect(state["/DirectoryPage"]).toEqual(selected); + const { props, state } = yield* Schema.decodeEffect( + Schema.fromJsonString(DirectoryHandoff) + )(payload?.textContent ?? ""); - expect(actual.querySelector(`#${directoryRootId}`)).not.toBeNull(); - } + expect(props).toEqual({ projects: cafe.projects, selected: [] }); + expect(state["/DirectoryPage"]).toEqual([]); + expect(output.querySelector(`#${directoryRootId}`)).not.toBeNull(); }).pipe(Effect.provide(NodeServices.layer)) ); diff --git a/apps/web/test/effect-ui-assets.test.ts b/apps/web/test/effect-ui-assets.test.ts index a72ce18e..819f3328 100644 --- a/apps/web/test/effect-ui-assets.test.ts +++ b/apps/web/test/effect-ui-assets.test.ts @@ -42,6 +42,8 @@ it("uses the static manifest graph and keeps first-seen stylesheet order", () => const assetModule = "virtual:reader-effect-ui-assets"; +const allStarsEntry = "src/client/all-stars-effect-ui/entry.ts"; + const directoryEntry = "src/client/directory-effect-ui/entry.ts"; const newsEntry = "src/client/news-effect-ui/entry.ts"; @@ -63,7 +65,7 @@ const fixture = (overrideManifest?: ManifestFixture): Plugin => ({ } if ( - [directoryEntry, newsEntry, readerEntry].some((entry) => + [allStarsEntry, directoryEntry, newsEntry, readerEntry].some((entry) => id.endsWith(entry) ) ) { @@ -132,11 +134,20 @@ it.effect("loads dev source URLs without a client build", () => server.ssrLoadModule(assetModule) ); - expect(module).toHaveProperty("default.reader-effect-ui", { - entryScript: `/${readerEntry}`, - modulePreloads: [], - stylesheets: [], - }); + const entries = { + "all-stars-effect-ui": allStarsEntry, + "directory-effect-ui": directoryEntry, + "news-effect-ui": newsEntry, + "reader-effect-ui": readerEntry, + }; + + for (const [name, entry] of Object.entries(entries)) { + expect(module).toHaveProperty(`default.${name}`, { + entryScript: `/${entry}`, + modulePreloads: [], + stylesheets: [], + }); + } }) ); @@ -154,7 +165,7 @@ it.effect( } const names = client.output.map(({ fileName }) => fileName); - expect(names).toHaveLength(3); + expect(names).toHaveLength(4); expect(names).not.toContain(".vite/manifest.json"); const server = yield* buildEnvironment(builder, "ssr"); @@ -196,12 +207,12 @@ it.effect( ); expect(entryFailure).toContain( - `Missing Effect UI client entry for ${directoryEntry}` + `Missing Effect UI client entry for ${allStarsEntry}` ); const missingChunk = yield* fixtureBuilder({ - [directoryEntry]: { - file: "assets/directory.js", + [allStarsEntry]: { + file: "assets/all-stars.js", imports: ["_missing.js"], isEntry: true, }, @@ -212,7 +223,7 @@ it.effect( ); expect(chunkFailure).toContain( - `Effect UI entry ${directoryEntry} imports missing manifest chunk _missing.js` + `Effect UI entry ${allStarsEntry} imports missing manifest chunk _missing.js` ); }) ); diff --git a/apps/web/test/fixtures/foldkit-all-stars-parity.json b/apps/web/test/fixtures/foldkit-all-stars-parity.json new file mode 100644 index 00000000..dcfb7569 --- /dev/null +++ b/apps/web/test/fixtures/foldkit-all-stars-parity.json @@ -0,0 +1,204 @@ +{ + "people": [ + { + "avatar": "/avatars/alchemy-run.png", + "handles": [ + { + "handle": "alchemy-run", + "kind": "github", + "url": "https://github.com/alchemy-run", + "source": "https://github.com/alchemy-run", + "verified": "2026-11-02" + }, + { + "handle": "alchemy_run", + "kind": "x", + "url": "https://x.com/alchemy_run", + "source": "https://github.com/alchemy-run", + "verified": "2026-11-02" + }, + { + "handle": "alchemy.run", + "kind": "site", + "url": "https://alchemy.run", + "source": "https://github.com/alchemy-run", + "verified": "2026-11-02" + } + ], + "id": "alchemy-run", + "kind": "channel", + "name": "Alchemy", + "packages": ["@effect/platform-node", "alchemy", "effect"], + "repos": [ + { + "repo": "alchemy-run/alchemy", + "stars": 1833, + "source": "https://github.com/alchemy-run/alchemy", + "verified": "2026-11-02" + } + ], + "route": "/all-stars/alchemy-run", + "summary": { + "text": "GitHub describes alchemy-run/alchemy as \"Infrastructure as Effects\".", + "source": "https://github.com/alchemy-run/alchemy", + "verified": "2026-11-02" + }, + "topics": ["alchemy"] + }, + { + "avatar": "/avatars/bjacobso.jpg", + "handles": [ + { + "handle": "bjacobso", + "kind": "github", + "url": "https://github.com/bjacobso", + "source": "https://github.com/bjacobso", + "verified": "2026-11-16" + }, + { + "handle": "bjacobso", + "kind": "x", + "url": "https://x.com/bjacobso", + "source": "https://github.com/bjacobso", + "verified": "2026-11-16" + } + ], + "id": "bjacobso", + "kind": "person", + "name": "Ben Jacobson", + "packages": ["effect"], + "repos": [ + { + "repo": "bjacobso/forma", + "stars": 6, + "source": "https://github.com/bjacobso/forma", + "verified": "2026-11-16" + } + ], + "route": "/all-stars/bjacobso", + "summary": { + "text": "Ben Jacobson's Forma is \"a typed, homoiconic Lisp for building domain-specific languages and portable artifacts\", built on Effect.", + "source": "https://github.com/bjacobso/forma/blob/main/package.json", + "verified": "2026-11-16" + }, + "topics": ["effect", "foldkit"] + }, + { + "avatar": "/avatars/rankincodes.jpg", + "handles": [ + { + "handle": "rankincodes", + "kind": "github", + "url": "https://github.com/rankincodes", + "source": "https://github.com/rankincodes", + "verified": "2026-11-04" + }, + { + "handle": "rankintweets", + "kind": "x", + "url": "https://x.com/rankintweets", + "source": "https://github.com/rankincodes", + "verified": "2026-11-16" + } + ], + "id": "rankincodes", + "kind": "person", + "name": "Adam Rankin", + "packages": [], + "repos": [], + "route": "/all-stars/rankincodes", + "summary": { + "text": "Adam Rankin is the leading contributor to effect-mq, an Effect v4 background-job library.", + "source": "https://github.com/TeamWarp/effect-mq/graphs/contributors", + "verified": "2026-11-04" + }, + "topics": ["effect"] + } + ], + "legacy": { + "text": [ + "馃悁 Rat Stackskillsloresystemsnewsall starsglossarysearchagent guide", + "For agents: start with the agent guide. Every page is Markdown by default; add Accept: text/html for HTML.source files / Ratstack all starsRatstack all starsPeople and channels with a /news row, contributions to pinned stack packages, code on the stack that rat-stack vendors or credits, or sourced public work on the stack. Every fact links to its source and the date we checked it.A person or channel enters through a /news row, contributions to a pinned stack package, code on the stack that rat-stack vendors or credits, or sourced public work built on or teaching the stack.Agents can call listPeople, readPerson, searchPeople, listChannels and peopleFor over MCP, HTTP or code mode. Atom feed.PeopleBen JacobsonBen Jacobson's Forma is \"a typed, homoiconic Lisp for building domain-specific languages and portable artifacts\", built on Effect.Built: bjacobso/forma (6 stars)source, checked 2026-11-16Adam RankinAdam Rankin is the leading contributor to effect-mq, an Effect v4 background-job library.source, checked 2026-11-04ChannelsAlchemyGitHub describes alchemy-run/alchemy as \"Infrastructure as Effects\".Built: alchemy-run/alchemy (1833 stars)source, checked 2026-11-02To be removed from this page, open an issue in joelhooks/rat-stack. A removal ships with the next site update.", + "Explorelearn modeglossarychange logpeersReferenceagent guideAPI docssourceMarkdown by default. HTML when you ask for it. Agents start here." + ], + "rows": [ + "Ben JacobsonBen Jacobson's Forma is \"a typed, homoiconic Lisp for building domain-specific languages and portable artifacts\", built on Effect.Built: bjacobso/forma (6 stars)source, checked 2026-11-16", + "Adam RankinAdam Rankin is the leading contributor to effect-mq, an Effect v4 background-job library.source, checked 2026-11-04", + "AlchemyGitHub describes alchemy-run/alchemy as \"Infrastructure as Effects\".Built: alchemy-run/alchemy (1833 stars)source, checked 2026-11-02" + ], + "attributes": [ + ["p", "class=agent-pointer visually-hidden"], + ["a", "href=https://ratstack.sh/llms.txt"], + ["nav", "class=breadcrumb", "aria-label=Breadcrumb"], + ["a", "href=/"], + ["a", "href=/all-stars.xml"], + ["ul", "class=xrvj5dj x1vjsyax xe8uvvx x1ghz6dp x1717udv"], + ["li", "class=x1cy8zhl x78zum5 x1vjsyax x17xev97"], + [ + "img", + "class=x12oqio5 x1lliihq x2lah0s x1sh0tsm xekueh", + "src=/avatars/bjacobso.jpg", + "alt=", + "width=64", + "height=64", + "loading=lazy" + ], + ["a", "href=/all-stars/bjacobso"], + [ + "a", + "href=https://github.com/bjacobso/forma", + "rel=noopener noreferrer" + ], + ["p", "class=xraqfvc x1s8wshw"], + [ + "a", + "href=https://github.com/bjacobso/forma/blob/main/package.json", + "rel=noopener noreferrer" + ], + ["li", "class=x1cy8zhl x78zum5 x1vjsyax x17xev97"], + [ + "img", + "class=x12oqio5 x1lliihq x2lah0s x1sh0tsm xekueh", + "src=/avatars/rankincodes.jpg", + "alt=", + "width=64", + "height=64", + "loading=lazy" + ], + ["a", "href=/all-stars/rankincodes"], + ["p", "class=xraqfvc x1s8wshw"], + [ + "a", + "href=https://github.com/TeamWarp/effect-mq/graphs/contributors", + "rel=noopener noreferrer" + ], + ["ul", "class=xrvj5dj x1vjsyax xe8uvvx x1ghz6dp x1717udv"], + ["li", "class=x1cy8zhl x78zum5 x1vjsyax x17xev97"], + [ + "img", + "class=x12oqio5 x1lliihq x2lah0s x1sh0tsm xekueh", + "src=/avatars/alchemy-run.png", + "alt=", + "width=64", + "height=64", + "loading=lazy" + ], + ["a", "href=/all-stars/alchemy-run"], + [ + "a", + "href=https://github.com/alchemy-run/alchemy", + "rel=noopener noreferrer" + ], + ["p", "class=xraqfvc x1s8wshw"], + [ + "a", + "href=https://github.com/alchemy-run/alchemy", + "rel=noopener noreferrer" + ], + [ + "a", + "href=https://github.com/joelhooks/rat-stack/issues/new?title=Remove%20an%20all%20stars%20profile" + ] + ] + } +} diff --git a/apps/web/test/fixtures/foldkit-directory-parity.json b/apps/web/test/fixtures/foldkit-directory-parity.json new file mode 100644 index 00000000..2923bf13 --- /dev/null +++ b/apps/web/test/fixtures/foldkit-directory-parity.json @@ -0,0 +1,219 @@ +{ + "all": { + "text": [ + "馃悁 Rat Stackskillsloresystemsnewsall starsglossarysearchagent guide", + "For agents: start with the agent guide. Every page is Markdown by default; add Accept: text/html for HTML.source files / Ratstack directoryRatstack directoryProjects built with Cloudflare, Alchemy, Foldkit and Effect. A letter badge appears only when the repository shows evidence for it.Show projects that useCloudflareAlchemyFoldkitEffect3 projectsfull-stackCAFEfull-stack summary.by ada 路 updated 2026-10-01effect-onlyEeffect-only summary.by ada 路 updated 2026-10-01edge-appCAEedge-app summary.by ada 路 updated 2026-10-01Know a project or story about the stack? Ask your agent to suggest it.", + "Explorelearn modeglossarychange logpeersReferenceagent guideAPI docssourceMarkdown by default. HTML when you ask for it. Agents start here." + ], + "rows": [ + "full-stackCAFEfull-stack summary.by ada 路 updated 2026-10-01", + "effect-onlyEeffect-only summary.by ada 路 updated 2026-10-01", + "edge-appCAEedge-app summary.by ada 路 updated 2026-10-01" + ], + "attributes": [ + ["p", "class=agent-pointer visually-hidden"], + ["a", "href=https://ratstack.sh/llms.txt"], + ["nav", "class=breadcrumb", "aria-label=Breadcrumb"], + ["a", "href=/"], + ["fieldset", "class=x78zum5 x1a02dak x1xlarca x1ghz6dp x1717udv"], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "type=button", + "aria-pressed=false" + ], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "type=button", + "aria-pressed=false" + ], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "type=button", + "aria-pressed=false" + ], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "type=button", + "aria-pressed=false" + ], + ["p", "aria-live=polite"], + ["ul", "class=x1bkqx2q"], + ["li", "class=x1sfq807"], + [ + "a", + "href=https://github.com/ada/full-stack", + "rel=noopener noreferrer" + ], + ["span", "class=x3nfvp2 x1xlarca xr8tzk0"], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Cloudflare: cloudflare evidence in package.json", + "aria-label=Cloudflare: cloudflare evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Alchemy: alchemy evidence in package.json", + "aria-label=Alchemy: alchemy evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Foldkit: foldkit evidence in package.json", + "aria-label=Foldkit: foldkit evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Effect: effect evidence in package.json", + "aria-label=Effect: effect evidence in package.json" + ], + ["p", "class=xraqfvc x1s8wshw"], + ["a", "href=https://github.com/ada", "rel=noopener noreferrer"], + ["li", "class=x1sfq807"], + [ + "a", + "href=https://github.com/ada/effect-only", + "rel=noopener noreferrer" + ], + ["span", "class=x3nfvp2 x1xlarca xr8tzk0"], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Effect: effect evidence in package.json", + "aria-label=Effect: effect evidence in package.json" + ], + ["p", "class=xraqfvc x1s8wshw"], + ["a", "href=https://github.com/ada", "rel=noopener noreferrer"], + ["li", "class=x1sfq807"], + ["a", "href=https://github.com/ada/edge-app", "rel=noopener noreferrer"], + ["span", "class=x3nfvp2 x1xlarca xr8tzk0"], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Cloudflare: cloudflare evidence in package.json", + "aria-label=Cloudflare: cloudflare evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Alchemy: alchemy evidence in package.json", + "aria-label=Alchemy: alchemy evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Effect: effect evidence in package.json", + "aria-label=Effect: effect evidence in package.json" + ], + ["p", "class=xraqfvc x1s8wshw"], + ["a", "href=https://github.com/ada", "rel=noopener noreferrer"] + ] + }, + "alchemy": { + "text": [ + "馃悁 Rat Stackskillsloresystemsnewsall starsglossarysearchagent guide", + "For agents: start with the agent guide. Every page is Markdown by default; add Accept: text/html for HTML.source files / Ratstack directoryRatstack directoryProjects built with Cloudflare, Alchemy, Foldkit and Effect. A letter badge appears only when the repository shows evidence for it.Show projects that useCloudflareAlchemyFoldkitEffectShow all projects2 projectsfull-stackCAFEfull-stack summary.by ada 路 updated 2026-10-01edge-appCAEedge-app summary.by ada 路 updated 2026-10-01Know a project or story about the stack? Ask your agent to suggest it.", + "Explorelearn modeglossarychange logpeersReferenceagent guideAPI docssourceMarkdown by default. HTML when you ask for it. Agents start here." + ], + "rows": [ + "full-stackCAFEfull-stack summary.by ada 路 updated 2026-10-01", + "edge-appCAEedge-app summary.by ada 路 updated 2026-10-01" + ], + "attributes": [ + ["p", "class=agent-pointer visually-hidden"], + ["a", "href=https://ratstack.sh/llms.txt"], + ["nav", "class=breadcrumb", "aria-label=Breadcrumb"], + ["a", "href=/"], + ["fieldset", "class=x78zum5 x1a02dak x1xlarca x1ghz6dp x1717udv"], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "type=button", + "aria-pressed=false" + ], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg x1fiepzm x1wzia90", + "type=button", + "aria-pressed=true" + ], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "type=button", + "aria-pressed=false" + ], + [ + "button", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "type=button", + "aria-pressed=false" + ], + ["button", "type=button"], + ["p", "aria-live=polite"], + ["ul", "class=x1bkqx2q"], + ["li", "class=x1sfq807"], + [ + "a", + "href=https://github.com/ada/full-stack", + "rel=noopener noreferrer" + ], + ["span", "class=x3nfvp2 x1xlarca xr8tzk0"], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Cloudflare: cloudflare evidence in package.json", + "aria-label=Cloudflare: cloudflare evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Alchemy: alchemy evidence in package.json", + "aria-label=Alchemy: alchemy evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Foldkit: foldkit evidence in package.json", + "aria-label=Foldkit: foldkit evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Effect: effect evidence in package.json", + "aria-label=Effect: effect evidence in package.json" + ], + ["p", "class=xraqfvc x1s8wshw"], + ["a", "href=https://github.com/ada", "rel=noopener noreferrer"], + ["li", "class=x1sfq807"], + ["a", "href=https://github.com/ada/edge-app", "rel=noopener noreferrer"], + ["span", "class=x3nfvp2 x1xlarca xr8tzk0"], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Cloudflare: cloudflare evidence in package.json", + "aria-label=Cloudflare: cloudflare evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Alchemy: alchemy evidence in package.json", + "aria-label=Alchemy: alchemy evidence in package.json" + ], + [ + "abbr", + "class=x12oqio5 x1rg5ohu x1xlr1w8 x1u7k74 x1et6avd xhpiq8o x2b8uid x1hl2dhg", + "title=Effect: effect evidence in package.json", + "aria-label=Effect: effect evidence in package.json" + ], + ["p", "class=xraqfvc x1s8wshw"], + ["a", "href=https://github.com/ada", "rel=noopener noreferrer"] + ] + } +} diff --git a/apps/web/test/fixtures/foldkit-news-parity.json b/apps/web/test/fixtures/foldkit-news-parity.json new file mode 100644 index 00000000..34000691 --- /dev/null +++ b/apps/web/test/fixtures/foldkit-news-parity.json @@ -0,0 +1,113 @@ +{ + "rank": { + "text": [ + "馃悁 Rat Stackskillsloresystemsnewsall starsglossarysearchagent guide", + "For agents: start with the agent guide. Every page is Markdown by default; add Accept: text/html for HTML.source files / News fixtureNews fixtureNews from people who build with Cloudflare, Alchemy, Foldkit and Effect. The ratstack desk agent picks and checks entries from public sources each day.Latest first 路 Atom feed[post]Title 42