Source types
Every source has a type, and the type decides how it is fetched (SI-557, SI-556). The rest is shared by all types: scheduling and health (scheduler.md), the fetcher’s limits and its block on private addresses (feeds.md), storing items for every subscriber, filter rules and the AI pipeline (pipeline.md).
| Type | What it fetches | Added under Sources → Add a source |
|---|---|---|
rss |
An RSS, Atom, RDF or JSON Feed (feeds.md) | Feed or site |
youtube |
A YouTube channel’s or playlist’s feed (youtube.md) | Feed or site |
github |
A GitHub repository’s releases (below) | GitHub releases, or Feed or site with the repository’s address |
api |
A JSON API, read with a field mapping (below) | JSON API |
web |
A web page without a feed, read with a recipe of CSS selectors, or watched for changes (below) | Web page, or Follow the page itself when Feed or site finds no feed |
link |
Nothing: links added by hand (below) | One link |
GitHub releases
Follow a repository, and its latest release is a card in your stream. The release notes are the item’s text, so the summary stage summarizes them like an article. Code: feeds/github.ts.
- Adding:
owner/repoor any address inside the repository (github.com/sveltejs/kit, its releases page, a file) under GitHub releases. Pasting a repository’s address under Feed or site offers its releases too. Its.atomfeeds stay ordinary feeds. - One source per repository: the source URL is the repository’s page in lower case,
https://github.com/sveltejs/kit, since GitHub ignores case. The title is the repository’s own spelling,sveltejs/kit, taken from a release link. - Fetching:
GET https://api.github.com/repos/{owner}/{repo}/releases?per_page=10withAccept: application/vnd.github.html+json, which sends the notes already rendered as HTML (body_html). They are cleaned like feed content. The ETag makes an unchanged repository a304, which GitHub doesn’t count against the limit. - Which release: the newest published one. Drafts never show; pre-releases only when the source’s
config.prereleasesistrue(not in the app yet). - Only the latest keeps a card: one release is stored per fetch, and a new subscriber of a repository others follow gets only the latest one. When a new release arrives, the older ones leave every subscriber’s stream and the pipeline, unless the subscriber starred them. The item rows stay, so the posting history (the scheduler learns from it how often a repository releases) and starred releases are unchanged.
- The title is the repository’s name and the release’s name (“svelte 5.1.0”). A release name that already names the project (“@sveltejs/[email protected]”) stays as it is.
- Limits: without a token, GitHub allows 60 requests an hour per IP address. That’s enough for a few dozen repositories, since the scheduler fetches a repository that rarely releases rarely. With
GITHUB_TOKENset (deployment.md), it is 5,000 an hour. Any token works, a fine-grained one with no permissions too: it only reads public repositories. A403or429from the limit counts as a failed fetch and backs off like any other. - A repository that doesn’t exist fails with HTTP 404, and nothing is kept. One without releases yet follows fine and shows nothing until it has one.
JSON APIs
Any JSON API that answers a plain GET, read with a field mapping: where the list of items is in the answer, and which field of an item is the title, the link, the date… Code: feeds/json-api.ts, the paths in feeds/jsonpath.ts.
The mapping
Paths are in JSONPath. items is read from the whole answer; each field from one item.
| Field | Example | |
|---|---|---|
items |
$.data.posts |
The list. Missing or $: the answer itself is the list. A path with [*] gives its matches as the items: $.groups[*].posts[*] |
title |
$.title |
Plain text or HTML. A title or a link is needed |
url |
$.links.html |
Relative links are resolved against the API’s address |
date |
$.published_at |
Any date the feed parser reads (ISO 8601, RFC 822…), or a Unix time in seconds or milliseconds. Missing: the fetch time, in the API’s order |
id |
$.id |
Tells items apart across fetches. Missing: the link, else a hash of title, date and text |
summary, content |
$.excerpt, $.body_html |
HTML, or text, which becomes paragraphs |
author |
$.author.name |
|
image |
$.cover.url |
The supported JSONPath is a small, safe subset: $, names ($.a.b, the $. may be left out), quoted names ($['odd key']), indexes ([0], [-1] for the last), and wildcards ([*], .*). Filters, slices, recursive descent (..) and scripts are refused with a message: a mapping is user input that runs on the server.
A field’s value is used as text. Numbers become text; for a list, its first element counts; for an object, its name, url, href or value. So $.author works for both "author": "Jane" and "author": { "name": "Jane" }.
Preview, follow, fetch
Preview fetches the API and shows how many items the mapping finds and the first five, without keeping anything. Follow fetches it once like any new source: if the API fails, isn’t JSON, or items finds nothing in the answer, nothing is kept and the reason shows (“There is nothing at $.posts in the API’s answer.”). An empty list follows fine.
Items then go through the same normalizing as feed entries: cleaned HTML, canonical links without tracking parameters, excerpts, dates, the newest 200 per fetch, duplicates by id and by link. “Always load the full article” and share images work as for feeds.
One source per API and mapping
Sources are shared by URL. Two users who map one API differently need two sources, so the source URL is the API’s address plus a fragment that stands for the mapping: https://api.example.com/posts#hotaru-mapping=3f9c1e0a7b2d. The same address with the same mapping is one source; fragments never reach the API. The mapping is in the source’s config.mapping. The Sources page shows the address without the fragment.
Only public APIs: Hotaru sends no keys or headers of yours. An API that needs a key in the query string works, but the key is then part of the source’s address, visible to everyone who follows it.
Web pages
For sites without a feed: a blog’s index, a news page, a changelog. A recipe says how to read the page, and an AI model writes it once; every fetch after that only applies it, with no AI call. Code: feeds/web-page.ts, the AI part in services/web-recipes.ts.
The recipe
A recipe is CSS selectors, in one of two modes:
| Mode | Fields | |
|---|---|---|
list |
item, and title, url, date, summary, image, author |
The page lists posts. item selects each post; the fields are selectors inside one post |
page |
content |
The page has no list of posts (a price list, a changelog without links): it is watched for changes. content selects the part to watch; empty, the main text as a reader view finds it |
- A field ending in
@attributereads the attribute instead of the text:time@datetime,h2 a@href,img@src.@hrefalone reads the post element’s own attribute. - Defaults for a field that is left out: the link is the post’s first link (or the post itself, if it is a link), the title its first heading, else that link’s text, the date its first
<time>(itsdatetime, else its text). An image without an attribute readssrc,data-src,srcsetand the like. - A given selector is strict: a post whose
titleselector finds nothing is left out (a category tile, an ad between posts), and one whoseurlselector finds nothing has no link. Hotaru doesn’t guess then. - Dates are read like feed dates (feeds.md), and also “06.11.2026” (day first), “2026-11-16 00:00:00 +0000 UTC”, and dates without a time (“Nov 6, 2026”), which mean that day in UTC. A post without a date gets the fetch time, so posts the page lists before following all arrive at once; at most 50 per fetch.
- The selectors are user input that runs on the server: at most 300 characters each, and checked as CSS when the recipe is saved. They only select; nothing in a recipe runs code.
Making a recipe with AI
Make a recipe (POST /api/v1/sources/recipe) fetches the page and sends a simplified copy to a model (openai/gpt-6-luna, then anthropic/claude-haiku-5.5 if it fails): no scripts, styles or SVG, only the attributes selectors use (class, id, href, datetime, src, itemprop…), long texts cut, at most 60,000 characters (about 15,000 tokens); a longer page sends only its <main>. The model answers with a recipe in a JSON schema, told to prefer stable selectors over generated class names and :nth-child.
Hotaru then tries the recipe on the page. If it finds no posts or isn’t valid CSS, the model gets one more try, with what went wrong. If that fails too, the recipe is page: the page is watched for changes, and the answer’s note says so. Nothing is followed yet: the form shows the recipe and what it finds now, to edit, Preview again (POST /api/v1/sources/preview with recipe, free) and Follow.
A recipe costs one or two calls, an estimated $0.003 (not yet measured), paid by the user like every AI call (costs.md): stage web_recipe, Web page recipes under Settings → Costs. At most 30 calls per user in 24 hours. The page itself is fetched like a feed: through the host pool, never a private address, at most 5 MB.
Only the HTML the server sends is read. A page that builds its posts with JavaScript shows the model nothing to find; watching it, or following its API under JSON API, may work instead.
One source per page and recipe
Sources are shared by URL, and a recipe is part of a web page source’s identity (SI-572), as a mapping is a JSON API’s: the source URL is the page’s address plus a fragment that stands for the recipe, https://example.com/news/#hotaru-recipe=9b1c0e7d2a4f. The page’s own fragment is dropped, and fragments never reach the site. The recipe is in the source’s config.recipe, the watched text (config.snapshot) and the broken flag (config.recipeBroken) next to it. The Sources page shows the address without the fragment.
- The same page with the same recipe is one source, fetched once. A second account that follows it gets its latest items without a fetch, as for any shared source.
- Another recipe for the same page is another source, fetched on its own.
- Changing a recipe (Sources → Edit → Recipe, or
PUT /api/v1/subscriptions/{id}/recipe) changes it for you alone, and fetches the page with the new recipe at once. Code:setRecipe()inservices/follow.ts.- Nobody else follows the source, and no source has the new recipe yet (always the case with one account): the source takes the new recipe and its URL. Its items, history and schedule stay.
- Others follow it, or a source with the new recipe exists: your subscription moves to the source with the new recipe, made if missing. It keeps its id, name, tags and settings, and your filter and action rules that name the source name the new one. Your items come along as copies of your own in the new source (code:
services/carried.ts). A copy’s guid iscarried:<your id>:<guid>, which no fetch makes, so the source’s fetches still store the posts as its recipe reads them for everyone else. Copies are never given to another account (backfills and story research leave them out), don’t belong to a story, and go when you stop following. You don’t get a post you have as a copy a second time, by guid or by link. Your read, starred and saved state, keywords, research and checks move to the copy, and summaries are copied, so no paid AI stage runs again for a finished item; one still in the pipeline starts over. The new source’s latest items arrive as for a new follower. Others keep their recipe and their items. - You follow the page with the new recipe already, in another subscription:
422.
Web pages followed before SI-572 have the page alone as their URL; at start, Hotaru gives them the URL their recipe makes (upgradeWebSourceUrls()), so a new follower with the same recipe finds them.
Broken recipes
A layout change breaks a recipe quietly: the selectors find nothing. A fetch whose recipe finds no posts (or none with a title or link, or nothing at content) fails with the reason, like an unreachable site: the source’s health and the scheduler’s back-off follow (scheduler.md). It is also flagged: the source’s config.recipeBroken keeps the reason, the Sources page shows Recipe broken on its row, and its editor offers Make a new recipe. The next fetch that works clears the flag, and so does saving a new recipe: the fetch right after flags it again if the new one finds nothing too. A broken source’s fetch skips the ETag, so a page that hasn’t changed since doesn’t hide behind a 304.
Watching a page for changes
A page recipe keeps the watched text in the source’s config.snapshot (one line per block, at most 100,000 characters). Following stores the text as it is, without an item. Each fetch after compares the text: unchanged, nothing; changed, one item, “Pricing changed: Pro: $12”, with the lines Added and Removed (at most 60 of each), dated the fetch. The summary stage summarizes the change like an article. All changes link to the page, so they’re told apart by a hash of the text, not by link (urlsIdentifyItems: false), and never get the full article. A new recipe starts over without a change item.
Added links
Paste a URL under One link (or POST /api/v1/items), and the page becomes an item at the top of your stream that goes through the pipeline like any other: gate, summary, scores. Code: services/links.ts.
- The page is fetched once: its title (Open Graph, else
<title>), description, author, share image and, when Readability finds one, the article. The article is the text the AI stages read, so the extract stage doesn’t fetch the page again. A link that isn’t a web page (a PDF, an image) becomes an item named after its address. - Each user’s links are a source of their own, type
link, called “Added links” (rename it like any source). It is made on first use with Always show on, so the gate never filters out what you added on purpose. Its URL,hotaru:links/<user id>, is not an address: the scheduler never fetches it, and Refresh now isn’t offered. - A link added before isn’t added again, also when it differs only in tracking parameters or redirects to the same page. The answer says so (
created: false). - A page that fails (a 404, a private address) adds nothing.
- Pausing the source hides your added links; unsubscribing removes them, starred ones stay.
The plug-in interface
A type is a SourceTypeHandler in feeds/source-types.ts, registered in sourceTypes. refreshSource() does the shared work and asks the handler for the rest:
interface SourceTypeHandler { type: SourceType; // 'rss', 'github'… label: string; // "GitHub releases", for people polled?: boolean; // false: the scheduler never fetches it. Default true maxItemsPerFetch?: number; // default 200 backfillItems?: number; // a new subscriber of a shared source gets this many. Default 50 urlsIdentifyItems?: boolean; // false: items may share a link (a watched page's changes). Default true claims?(url: string): boolean; // a followed URL is this type's without asking fetch(source, context): Promise<FeedResult>; // required. Writes nothing; throws FeedFetchError prepare?(items, context): Promise<NewItem[]>; // lookups for new items only afterStore?(db, sourceId, { newItems }): void; // after a fetch that worked afterFailure?(db, sourceId, error): void; // after a fetch that failed}One fetch of a source, in order:
fetch(source, context)gets the source row (URL,config,etag,lastModified) and the context (the host pool, the dispatcher, a timeout, the clock, per-type options). It returns{ status: 'not_modified' }or{ status: 'ok', feed: { format, title, siteUrl, items }, etag, lastModified, permanentUrl, state }.stateis merged into the source’sconfigwith the fetch (json_patch, so a recipe saved meanwhile stays): what a type keeps between fetches, such as a watched page’s text. Items areNewItems; the easiest way to make them is to buildRawEntrys and pass them tonormalizeEntries()(parse.ts), which cleans, dates and deduplicates them like feed entries. Fetch throughfetchThroughPool(), which keeps to the per-host limits, blocks private addresses, and pauses a host after a429or503. A failure is aFeedFetchErrorwith a kind (http,timeout,parse,mapping…): the source’s health and the scheduler’s back-off follow from it, and the first fetch of a new source turns it into the message the user sees (apps/web/src/lib/server/sources.ts). ApermanentUrlmoves the source; leave it out when the address you fetched isn’t the source’s own (GitHub’s API).- Refresh keeps the newest
maxItemsPerFetchitems and drops those the source already has (by guid, and by link for links that only one entry has, unlessurlsIdentifyItemsis false). prepare(items, context)sees only the new ones, so a refetch costs nothing: YouTube looks up durations, feeds and APIs the full article and share images. It must not throw for a failed lookup; an item keeps what it has.- The items are stored for every subscriber, filter rules and rules run, and the pipeline picks them up.
afterStore(db, sourceId, { newItems })runs after. GitHub retires older releases there; web pages clear a broken recipe’s flag. A fetch that fails callsafterFailure(db, sourceId, error)instead, once the failure is recorded: web pages flag the recipe when it found nothing (mapping).
claims(url) lets a followed URL pick its type: YouTube channel feeds and GitHub repository pages. sourceTypeOf() asks every handler and falls back to rss. A type that needs more than a URL (a JSON API’s mapping) leaves it out and is chosen by the request instead (mapping or type in POST /api/v1/subscriptions, resolveSource() in services/follow.ts). Type-specific settings go in sources.config.
Adding a type
- Add its name to
SOURCE_TYPESindb/schema.tsand tosourceTypeinpackages/sdk/src/schemas.ts. The column is plain text: no migration. - Write the handler next to the others in
packages/core/src/feeds/, and register it insourceTypes. - If it needs more than an address to follow, extend
resolveSource()andsubscribeRequest. - Give it a label in
SOURCE_TYPE_LABELS(apps/web/src/lib/sources/types.ts) and, if it isn’t found by an address, a form in Add a source (AddSource.svelte). - Test it against a local server (
feeds/test-server.ts) withunrestrictedDispatcher(), asgithub.spec.tsdoes, and document it here.
API
| Request | |
|---|---|
POST /api/v1/sources/discover { url } |
A GitHub repository’s address gives its releases (type: 'github', format: 'github'). |
POST /api/v1/subscriptions { url, type: 'github', title?, tags? } |
Follows a repository’s releases; url may be owner/repo. Without type, a repository’s page does the same. |
POST /api/v1/sources/preview { url, mapping } |
What a JSON API with a mapping would bring: { url, itemCount, items, subscriptionId }, the first five items. 422 with the reason when it fails. Needs a subscribe token, like discovering feeds. |
POST /api/v1/sources/preview { url, recipe } |
The same for a web page with a recipe, with its title, and for a watched page the text it watches. |
POST /api/v1/sources/recipe { url } |
Makes a recipe with AI: { recipe, preview, note, costUsd, model }. Follows nothing. 402 over the AI budget, 403 (no_key) without the right to use AI (costs.md), 422 when the page fails or isn’t one, 429 after 30 calls in 24 hours, 503 without the pipeline. Needs a write token: it costs money. |
POST /api/v1/subscriptions { url, recipe, title?, tags? } |
Follows a web page with a recipe ({ mode: 'list', item, fields: { title?, url?, date?, summary?, image?, author? } } or { mode: 'page', content? }). |
PUT /api/v1/subscriptions/{id}/recipe { recipe } |
Gives a web page you follow a new recipe, for you alone (above), and fetches it: { subscription, refresh }. The subscription keeps its id; its sourceId and url may change. 404 for a subscription that isn’t yours or isn’t a web page, 422 for a recipe that won’t do or one you follow the page with already. |
POST /api/v1/subscriptions { url, mapping, title?, tags? } |
Follows a JSON API with a mapping ({ items?, fields: { title?, url?, date?, id?, summary?, content?, author?, image? } }). |
POST /api/v1/items { url } |
Adds a link by hand: 201 { itemId, title, created: true }, 200 with created: false when you added it before, 422 when the page fails. Needs a write token. |
The SDK has previewSource(), suggestRecipe(), setRecipe() and addLink(); subscribe() takes type, mapping and recipe. A subscription has recipe and recipeBroken (null for other types).