Phase 2 plan: assets as a library
Phase 2 makes assets a searchable library of files in R2, plus a record of where each file is used, so any image or video can fill any role and an agent can find files by what they show. What changes in goatboat and the site, with before and after examples.
This continues Projects, media and schema: the plan, which stays as it was when phase 1 was planned.
Phase 1: done
Finished on December 4, 2026:
- Migration: projects have
parent_idandstage;kindis gone. Content lostcontent_hash,formatandcomponent_key. - goatboat: parent and stage in ops, the MCP and the owner UI;
readmeis no longer a default section;SCHEMA.mdandschema.dbmlare deleted; the display name is GoatBoat CMS. - Data: jaygriff.com holds v4 and v3, Gems holds Games, every public project has a stage,
wipis gone andnextjsmerged intonext-js. - Site: project pages with stage, links and subproject cards; the notes list shows a project with its subprojects.
Left over, on purpose: CPU Ladder and Resume (both private) have no stage, and older projects keep their readme sections.
Phase 2: the goals
Any file can fill any role: a thumbnail, a hero, a hover preview, a gallery, inline in an article. And an agent can find any file by what it shows, so adding pictures to the site is "put them in R2 with a description", and an agent picks them out later, twenty at a time if needed.
What's wrong today
Each row in assets mixes two things: a file (url, kind, size, alt) and one place it appears (whose it is, in what role, in what order). So:
- A file used in two places is two rows, with its url, size and alt copied into each. 8 urls are stored two or three times.
- A file that isn't used anywhere can't have a row, so there's no list of what's in R2 and nothing to search.
- 49 rows have no alt text and 35 have no size.
- Only one hero per page or project, and nothing for hover videos.
The design: files, and where they're used
assets asset_uses
(one row per file in R2) (one row per place a file appears)
+-------------------------+ +------------------------------+
| id |<----| asset_id |
| url (unique) | | content_id or project_id |
| kind | | role |
| width, height, duration | | sort_order |
| focus_x, focus_y | | alt, caption (overrides) |
| alt (default) | +------------------------------+
| description |
| context |
| project, tags |
| poster_id -> assets |
| created_at |
+-------------------------+Naming: the library keeps the name assets. It's the word the domain (assets.jaygriff.com), the MCP tools and the instructions already use, it covers SVG logos and artifact HTML ("media" doesn't really), and it works in the singular. files was ruled out because content rows already have a file column. Today's assets table is really a table of uses, so the migration renames it out of the way first.
assets: the library
A file with no uses is normal: it's in the library, waiting to be found. Files are findable as soon as they're added; descriptions can be corrected later. Sizes live here because a file at a url never changes, the site needs them while rendering, and search filters on them.
Tweaks describe the picture, not the style. Where its subject sits is a fact about the file, so it's stored as a point, not as a CSS value like center: a slot can change shape (16:10 cards today, square tiles or a wide hero later), and a point keeps working in any of them. Other tweaks follow the same rule if they're ever needed (a background colour behind a transparent PNG, say), and a use only gets an override column once a real case needs one.
asset_uses: where a file appears
A use says "this file fills this role on this page or project".
Caption and alt sit on the use because the same screenshot can mean different things in different places. Demo videos are gallery items for now; they get a spot of their own on the project page only if that's wanted later.
Images inside an article body are not uses. They stay plain markdown urls. When the site renders a page, it looks those urls up in the library for size and alt, so nothing has to be recorded or kept in sync when a body changes. If "where is this file used?" ever matters, it can be built later by scanning bodies once.
Adding files: assets:add
Two steps, linked by a small list file. The command can't take a paragraph of description per file, so the text goes in a list first.
1. The agent writes the list. Jay hands over files, or says "add my new screenshots" (the drop folder). The agent opens and looks at each one, then writes a list in scratch/, one entry per file:
[
{
"file": "/Users/jay/Pictures/site/Screenshot 2026-12-05 at 10.41.22.png",
"description": "goatboat proposal page: an update to /notes/assets-plan, with the description field's old and new text highlighted in a diff",
"alt": "A goatboat proposal showing a page's description changing, old text struck through and new text highlighted",
"context": "Taken while designing the series feature, to show how a plan changed between versions",
"project": "goatboat",
"tags": ["screenshot", "proposals"],
"focus": [0.5, 0.4]
}
]A video gets a look at a few frames. focus is optional: it's set when a picture has one clear subject, and a busy screenshot leaves it out. When it's a close call, the agent asks Cloudflare for the cropped version and looks at it before saving.
2. The script reads the list.
npm run assets:add -- scratch/assets/2026-12-05.jsonFor each entry it names the file by content (img/<first 16 hex of sha256>.<ext>), skipping the upload if R2 already has it; measures it; for a video, grabs a still frame and adds it as its poster; uploads the original bytes with the immutable cache header (screenshots stay lossless PNG); and saves the row with the list's text, findable right away. Then it prints each url, its size and a markdown line ready to paste.
The list means a file is never saved without its text, and it stays in scratch/ as a record of what each batch added. --dry-run shows what the script would do. A description or focus is fixed later with update_asset, directly, since the library is a private working index. Video steps need ffmpeg on the Mac. A later pass with an AI API can fill in descriptions in bulk by writing the same kind of list; there's no backfill of existing R2 files now.
Finding files: find_media
One MCP tool. Text search over description, context and tags, using SQLite's built-in full-text search (FTS5, which Turso supports), ranked by relevance. Filters: project, kind, since, minimum width, unused only. With no text it lists the newest first, for "the screenshots I just took". Each result has the url, size, alt and description, so an agent can rule out a file too small for a slot, and can download a small copy through Cloudflare to look at it before using it.
No embeddings (semantic search) for now: at a few hundred files, text search plus an agent trying a few phrasings is enough. They can be added later without changing anything else.
Writing descriptions: what it is (screenshot, photo, diagram, logo), what app or page it shows, the words visible in it, and why it was taken if known. Use the names Jay would search for: "proposal page", not "a web interface with a form". This goes into goatboat's instructions.
What changes on the site: before and after
The API hands over roles, not a list to search
Today every page gets assets as a flat list, and each component searches it. The same search for an artifact's file is written out five times (the arcade, games, the artifacts page, the games aside and the content page), and fallbacks like "the hero, else the thumbnail" are written by hand where they're needed:
// before
const src = item.assets.find((a) => a.kind === "html" && a.role === "hero")?.url;
const image =
item.assets.find((a) => a.kind === "image" && a.role === "hero") ??
item.assets.find((a) => a.kind === "image" && a.role === "thumbnail");After, goatboat sorts uses by role and applies the fallbacks once, so every component reads the same shape. The file's facts and the use's overrides arrive already merged:
// after
const src = item.assets.hero[0]?.url; // an artifact's html file
const image = item.assets.thumbnail; // already falls back to the hero, then a poster// the shape
assets: {
thumbnail: Asset | null;
preview: Asset | null;
hero: Asset[]; // one, or a carousel
logo: { svg: Asset | null; png: Asset | null };
gallery: Asset[];
}Sizes are always there
Today a missing size is guessed, and the guess sets the box the image loads into, so a wrong guess makes the page jump:
// before
width={project.thumbnail.width ?? 1280}
height={project.thumbnail.height ?? 800}After, every file is measured when it's added, so width and height are always numbers. And slots with a set shape (cards, thumbnails, gallery tiles) don't need the file's size at all: the box has a CSS aspect-ratio, and the image fills it with next/image's fill and object-fit. Only article images take their shape from the file.
Crops stop being a hard-coded list
Project cards crop thumbnails to 16:10 from the top, which suits screenshots: their header stays in view. Three projects' pictures have their subject in the middle instead, so their slugs are hard-coded to crop from the centre:
// before (project-entry.tsx, and object-top / object-center in its module)
export const CENTERED = new Set(["jaygriff-v2", "jaygriff-v3", "goatboat"]);
<Image ... data-centered={CENTERED.has(project.slug)} />After, each file can say where its subject is, and every slot that crops keeps that point in view. A new picture that needs it gets a focus point in the library, not a code change:
// after: the point reaches CSS as a custom property
const { focusX, focusY } = picture;
<Image ... style={focusX == null ? undefined : { "--focus": `${focusX * 100}% ${focusY * 100}%` }} />/* the slot's default (the top) unless the file says otherwise */
.image { object-position: var(--focus, top); }Slots that crop on Cloudflare's side pass the same point as its gravity option, so both kinds of crop agree.
Decided: a focus point is a per-picture value, and a CSS module, compiled at build time, can't know one; it has to reach CSS through the element's style. The site's rules now allow exactly that: style may set CSS custom properties to pass a runtime value to the module, which does the styling with var(). Six components already did this (a measured width, a game card's palette from data), so the rule caught up with the code. Fixed sets of states still use data- attributes.
Article images get sizes and alt text
Today an image in markdown renders as a bare <img>: no size, so the text jumps when it loads, and no alt unless it was typed into the markdown:
// before (MarkdownRenderer)
img: ({ src, alt }) => <img src={src} alt={alt ?? ""} className={styles.image} />After, the page comes with its R2 images looked up in the library, and the renderer uses next/image with the real size, Cloudflare's resizing, and the library's alt text when the markdown has none:
// after
img: ({ src, alt }) => {
const file = images[src]; // from the API: width, height, alt
return file
? <Image src={src} alt={alt || file.alt || ""} width={file.width} height={file.height} sizes="..." />
: <img src={src} alt={alt ?? ""} />; // other hosts, unchanged
}New things the site can show
- Hover preview: a thumbnail with a
previewplays it, muted and looping, while hovered; it loads only on hover. Touch screens show the still. - Video hero: a hero of kind
videorenders as<video>with its poster, instead of an image. - Carousel hero: more than one hero renders as a carousel.
- Logos anywhere: any component can show a project's logo, falling back to its Lucide icon.
- Image posts: a gallery with each picture's caption, under the post's own description.
Icons and links
- Icons: a Lucide icon is a name, not a file.
projects.iconstays as text in kebab-case. An uploaded logo is an asset used aslogo. - Videos:
projects.video_urlgoes; a video is an asset with a use. - Links:
app_href,repo_urlanddemo_urlare links, not assets. Decide: keep the columns, or replace them with alinkslist of{ label, url }. My pick: the list, once a project needs a third kind of link.
Build order
- The library. New
asset_filestable (renamed toassetsin step 2, sinceassetsis still in use) with full-text search,assets:add,find_media, and the description guidance. Adds only; nothing that exists changes, and the site doesn't change. - Uses replace the old table. One migration: old rows become library files plus uses, duplicate urls merged, existing alt and sizes kept;
video_urldropped. goatboat's asset ops and MCP tools take an asset and a role. The site switches to the role-sortedassetsshape. Safety as in phase 1: copy the database, check row counts and foreign keys, open old proposals against the copy, deploy the site's reading change together with goatboat. - Article images. The page's R2 images come with it, and the renderer uses their sizes and alt. Site only.
- The new looks, each its own small change: focus points in place of
CENTERED(the three files get theirs then), hover previews, video heroes, carousels, logos in more places, and slots that ask Cloudflare to crop to the slot's exact shape around the focus point.
Left for later
An AI API pass to fill in descriptions; embeddings if text search runs out; the project links list. From the schema audit: project rows stored twice as content (finding 5), the unfiled project (6), notes as a type (9), and its open questions: games at scale, dates on projects, featured projects, tag pages, private vs unlisted, page history, scheduled publishing. Also a separate idea: series, so a plan like this one and the page it continues can sit together as parts of one thing.
Related
- Projects, media and schema: the planTwo phases to approve. Phase 1: subprojects and stage for projects, plus the schema audit's content cleanup. Phase 2: media as files and their uses, so any image or video can fill any role. What changes in the database, goatboat and the site, and what Jay needs to decide.
- Schema audit, November 2026A review of goatboat's database on 30 November 2026: what the schema says, what the rows actually hold, and the migration I'd run.
- Issue tracker: planIssues become their own type with a small tracker around them: /issues pages in the notes chrome, a sidebar grouped by area, four states, a priority, and commits that close them.
- Architectural Blueprint: Single-File "Code-as-Data" CMSA web-first content layer that treats fully interactive React components as flat text strings in a database, bypassing heavy bundlers while enabling rapid AI-assisted development.