# Hatch > Notes you and your agents share. Plain Markdown files you own, sites you can publish from them, and packages to build your own apps on top. ## What Hatch does - **Your files, untouched.** Opening a note never changes it. Editing a block rewrites only that block. Inline HTML, math, footnotes and reference links are kept exactly as typed. - **Safe saves.** Edits from agents or other apps are merged in. A real conflict keeps both versions. Failed saves retry instead of disappearing. - **Obsidian compatible.** Wikilinks, embeds, callouts, tasks, tags, tables and frontmatter. - **Page icons and covers**, folder icons, editable tables, a slash menu, outline, backlinks and tags panels. - **Themes.** Seven built in, and a theme studio for making your own from three colours. Themes are small JSON files, and Hatch keeps them readable (WCAG AA) automatically. - **Images done right.** Images go next to the note in `Note.assets/`, not in your file tree. Drag a corner to resize (saved the Obsidian way, `|300`), double-click to see full size, and use the Attachments panel to spot and clean up unused files. - **Plugins.** Every built-in feature is a plugin on the same typed API community plugins use. Community plugins run in sandboxed frames. They can't reach the app, your keys or the network unless they ask, and they have to ask again if their code changes. - **Agents.** An MCP server lets agents search, read, create and append to notes. - **End-to-end encrypted sync** (optional per vault). Sign in to keep a vault the same on every device. When two devices edit the same note, both versions are kept. Notes deleted on another device go to `.trash/`. If an unusually large number of files disappear at once, Hatch waits for you before deleting them anywhere else. - **Shared vaults.** Invite people by email to a synced vault, each as someone who can view, edit or manage (invite and remove editors and viewers). They accept from their own account, then read and edit it on their devices, live when you both have a note open. A workspace's owners and admins manage its vaults. Encrypted vaults stay encrypted: you tell them the passphrase. **Folder access** gives someone, or everyone, a different role in one folder (edit, view or hidden), and a **guest** sees only the folders opened to them. The server enforces it on every file, history and live note, and a renamed folder keeps its rules. Plain vaults only: in an encrypted one anyone with the passphrase reads every file. Apps on Hatch read the same people and roles with `vaultTeam` from `@hatch/sync`. (`team.roleFor(path)`, `team.rules()`, `team.setRule(...)`). - **Graph view.** See the notes around the one you're reading, or the whole vault. The graph also comes as a keyboard-friendly list. - **Publish** a vault as a docs site, blog or portfolio. Download it as static files for any host, or host it on your Hatch server for anyone, anyone with the link, or only people you invite. Only the notes you pick leave the vault. Readers can subscribe by email (with a confirm step), and you can send a post to them, with a one-click unsubscribe in every email. Every page gets link previews, and with a public address, canonical links, structured data, a sitemap and robots rules. `noindex: true` in a note keeps it out of search. - **Math and diagrams.** `$math$` renders with KaTeX and ```` ```mermaid ```` blocks become diagrams. Both are edited as source and loaded only when a note uses them. - **Canvas.** Boards of cards, notes, images and links joined by arrows. They're saved as `.canvas` files (JSON Canvas), so they open in Obsidian too. - **Careers pages and boards.** Publish job posts as a careers site with an application form. Applications come into the vault as candidate notes with their resumes, and the server copy is deleted. Any folder opens as a board, with cards grouped by a property like `stage`, and moving a card updates the note. - **Roadmaps and forms.** Publish a roadmap from notes with a `status` property. Visitors upvote and suggest ideas, and vote counts come back into each note. Any note can hold a ```` ```form ```` block that becomes a form on the published site, and each response arrives in the vault as a private note. - **Collections.** Notes gathered by a rule, shown as a table, cards, a list, a board or a chart, with filters, formulas, sorting, grouping and summaries. Edit a note's properties right in the table. They're saved as Obsidian `.base` files, so Obsidian opens them too. See [bases](https://hatch-docs.pages.dev/using-hatch/collections-obsidian-bases/). - **Embeds.** `![[Note]]` and `![[Note#Heading]]` show that note in place, in the app and on published sites. Videos, maps and Figma files embed from a link, and load only when clicked. - **Components.** Charts, progress bars, tabs, buttons, a table of contents and forms, written as fenced blocks. Suggestions come up as you type, and problems are marked on their line. See [components](https://hatch-docs.pages.dev/using-hatch/components/). - **Templates.** Notes in a templates folder, filled in with `{{title}}`, `{{date}}` and `{{time}}`. Start a note from one, or insert one with `/template`. The folder setting is Obsidian's, so both apps share it. A collection's New button makes a note that already matches the view. The template gallery adds ready-made templates, collections (projects, reading list, contacts, habits, content) and pages. - **Live editing.** Open the same note on two devices and edit it together, with cursors. End-to-end encrypted when the vault is. See [live](https://hatch-docs.pages.dev/using-hatch/live-editing/). - **Opens at once.** The web app keeps your vault in the browser and opens it with no loading screen on later visits, even offline. - **Version history.** Every note keeps older versions on this device. Compare, copy or restore one from the History panel. No setup needed. See [history](https://hatch-docs.pages.dev/using-hatch/version-history/). - **Git backup.** Back up a vault to a private GitHub repo on a schedule, see how a note changed, and restore an older version. Its backups show in the same History panel. It's a backup, not sync. - **Agent sessions** (desktop). A board of the Claude Code, Codex and Grok sessions running on your computer, with the ones waiting on you first and a warning when two change the same files. Search every session, copy a hand-off for the next agent, and turn corrections you keep repeating into rules for all of them. Read only from folders you choose, secrets left out, encrypted. See sessions. - **Import** from Notion, Evernote, Apple Notes and OneNote (HTML), and Markdown folders. Links and images come along. - **Optional accounts.** Writing never needs an account. - **One codebase** for web, desktop (Electron) and mobile (Capacitor). --- # The chat Hatch has a chat panel in the right sidebar. It answers questions about your notes and proposes changes to them. This page says how it works, where your keys live, and what it can and can't do. ## Opening it - The chat icon in the side panel, `Mod-J`, or "Open chat" in the command palette. - On a phone it opens as a full screen sheet. - Settings are at Settings, AI (`/settings/ai`). ## What it can do - Read any note in the open vault. Hidden folders (`.hatch`, `.obsidian`) are left out. - Search notes, list a folder, and look up which notes link to a note. - Propose a change to a note, or a new note. ## What it can't do - Change a note on its own. Every change shows as a diff with Accept and Reject. Nothing is written before you accept. - Overwrite a note that changed after the change was proposed. The card says "This note changed since" and offers to run again. - Delete, move or rename notes (through an API key provider). - See your API keys. They are sent to the service as a request header, never as part of a message. ## Accepting a change - If the note is open, the change goes in as an edit in the editor. Undo takes it back, and it saves and syncs like typing. - If the note is not open, it is written through the vault. - The text from before is kept in History. The new text is kept too, marked "AI edit". - With several changes waiting, "Accept all" accepts each in turn. Each one is still checked against the note as it is now. ## Providers You pick the provider and the model at the top of the panel. ### Anthropic (API key) - Works on web, phone and desktop. - Requests go straight from your device to `api.anthropic.com`. There is no Hatch server in between. - Plain `fetch` with streaming. No SDK. - The model list comes from Anthropic once a key is saved. ### OpenAI-compatible (API key and address) - Works on web, phone and desktop. - Covers OpenAI, OpenRouter, Ollama, LM Studio and anything else that speaks Chat Completions. - Leave the address empty for OpenAI. For Ollama on your computer use `http://localhost:11434/v1`. It needs no key. - A local server has to allow requests from the page. For Ollama, set `OLLAMA_ORIGINS`. - The model list comes from the server's `/models`. If it has none, type the model's name. ### Agents on this computer (desktop only) - Hatch can talk to an agent you installed and signed in to yourself: Claude Code, Codex or Gemini CLI. - Hatch starts the agent as a child process in your vault folder and talks to it over the Agent Client Protocol (ACP). - Hatch never sees, stores or passes on your sign-in. It never offers a login. If the agent says it is signed out, run it in a terminal and sign in there (`claude`, `codex login`, `gemini`). - Settings, AI shows which agents were found, and the command to install one. Hatch shows the command as text. It never runs it. - The agent also gets Hatch's own MCP server, read-only, so it can search notes and read the component guide. Programs Hatch looks for: | Agent | Program | Install | | --- | --- | --- | | Claude Code | `claude-agent-acp` | `npm install -g @anthropic-ai/claude-code @agentclientprotocol/claude-agent-acp` | | Codex | `codex-acp` | `npm install -g @openai/codex @agentclientprotocol/codex-acp` | | Gemini CLI | `gemini --acp` | `npm install -g @google/gemini-cli` | The subscription credit note: using Claude Code from Hatch counts as programmatic use. It draws from your plan's monthly Agent SDK credit, billed at API rates. Settings, AI says this in one line. How an agent's changes reach you: - When the agent writes a file through Hatch (ACP `fs/write_text_file`), nothing is written. It becomes a proposed change with Accept and Reject, like any other. - When the agent asks permission to use one of its own tools, the request shows in the chat with "Allow once" and "Reject". If the request carries a file change, you see it as a diff first. - After you allow it, the agent writes the file itself, straight to disk. A tool you allowed does not go through Hatch, so there is no Accept step for it and Hatch can't stop it. - Hatch saves what you are typing before each message to an agent. When the agent reports a changed file, the open note takes the new text at once and History gets an "AI edit" version. If you typed in that note meanwhile, both texts are kept: yours in the note, the agent's next to it as a conflict copy. - An agent that asks for a file or a permission between messages gets an error at once, so it never hangs waiting. - A command the agent wants to run shows as the command text. Hatch can't turn what a command does into a diff. Reject it if you are not sure. - Hatch never picks "always allow" for you. It only offers once or reject. ## Ask AI on selected text - Select text in a note and press Ask AI, the first button of the toolbar over the selection. - Pick one of the asks (Improve writing, Fix spelling and grammar, Make shorter, Make simpler) or type your own, then Enter. - The new text shows under the field as it arrives. Nothing in the note changes until you press Replace or Insert below. Undo takes either back in one step. - Try again asks the same again. Discard or Escape closes it. Stop ends an answer still on its way. - It uses the provider and model picked in the chat. With an agent picked there, it uses a service you added a key for, because an agent edits files itself. With no key it says where to add one. - What goes along: the selected text, up to 600 characters on each side of it in the same block, the note's name and your ask. No tools, nothing else from the vault. - If the text changed while the answer was written (someone else typing), Replace says so instead of writing over it. - Turning AI chat off in Settings, Features takes the button away too. ## Where keys live - Never in the vault. Never synced. Never in a log. - Desktop: the system keychain, through Electron `safeStorage`. The file is in Hatch's own data folder. - Web and phone: this device's browser storage (IndexedDB). The key stays on this device. - Linux without a keychain (no GNOME Keyring or KWallet): Electron would fall back to a fixed password, which protects nothing. Hatch keeps the key in memory until you close it, and the settings page says so. - If the browser won't store anything, the key is kept until you close Hatch, and the settings page says so. - "Remove key" deletes it from the device. - A saved key is never shown again. Paste a new one to replace it. ## Where conversations live - On this device, in IndexedDB. Not in the vault, and not synced. - The last 30 per vault are kept. "Earlier chats" at the top of the panel lists them. - A conversation with an agent picked up after a restart starts a new agent session. Hatch passes along the earlier messages as text. ## What goes with a message - The open note, by default. Remove its chip to leave it out. - The text you selected in the note, when there is some. - Notes you add by typing `@`. - With an API key provider the text of these notes is sent along. An agent gets their paths and reads them itself. ## In the panel - **Thinking.** While the model thinks, a "Thinking" line shows what it is thinking about. It folds to "Thought for 6s" once it moves on. Open or close it yourself and it stays that way. Claude 4.6 and later (Haiku from 5) are asked for a summary of their thinking (adaptive thinking). The signed thinking goes back to Anthropic unchanged with the tool results, as the API requires. OpenAI-compatible servers that send `reasoning_content` or `reasoning`, and agents that share their thoughts, show the same way. - **Steps.** Two or more tool calls in a row fold into one line, like "Read 3 notes, searched twice". While they run, the line says what is happening now ("Reading Cabin"). Open it to see each step. A step that failed says why. - **Notes used.** Under an answer, "Used 3 notes" opens into links to the notes it read to answer. An agent's own reads count too. - **Copy, try again, edit.** Under each answer, copy it as Markdown. Under the last one, try again (the same message, with what went with it) or edit your message. Sending the edit replaces your message and the answer after it. Changes that were still waiting go with it. Accepted ones stay in their notes and in History. - **Scrolling.** The panel scrolls only when you ask it to. A new message starts near the top, with a little of the turn before it still showing, and the answer grows into the space below. Text that arrives out of view stays there, and "Jump to latest" takes you to it. Once you're at the end, the newest text stays in view. Selecting text holds it still. An earlier chat opens at your last message. - **Starter questions.** An empty chat offers a few questions you can ask with one press. With the open note going along they are about that note (summarize it, find related notes, turn it into slides). ## For developers - `packages/ai` is the core, with no UI in it. - `types.ts` has the message and stream event shapes and the `ChatProvider` interface. - `anthropic.ts` and `openai.ts` are the HTTP providers. `sse.ts` reads server-sent events. - `tools.ts` has the vault tools. `proposals.ts` holds proposed edits and the "changed since" check. - `runner.ts` loops model calls and tools. - `acp/node.ts` runs agents (Node only, exported as `@hatch/ai/node`). `acp/provider.ts` is the provider the app uses. `acp/protocol.ts` is what crosses the IPC bridge. - `packages/app/src/ai` is the panel, the settings page, key storage and saved conversations. - `apps/desktop/main/ai.ts` exposes agents and the keychain to the window. `apps/desktop/main/mcp.ts` is the bundled MCP server. - `store.applyProposal` is the one way a change you accepted in the chat is written. An agent's own tools, once allowed, write to disk directly. `ChatController.changedOnDisk` takes those in through `store.takeFromDisk`. - An answer is drawn with `remoteImages: 'link'`: a picture on another server becomes a plain link, so nothing in an answer is fetched without a click. Notes themselves still show remote pictures, which is why the app's content security policy keeps `https:` for images. - Tests: `packages/ai/src/*.test.ts`, `packages/app/src/ai/keys.test.ts` and `scripts/e2e-ai.py`. None of them call a real service. --- # Connect an agent Hatch ships an MCP server, so any agent that speaks MCP can search, read and write your notes. ## Set it up Add this to your MCP client config (Claude Desktop, Claude Code, Cursor): ```json { "mcpServers": { "hatch": { "command": "npx", "args": ["tsx", "/path/to/hatch/packages/mcp/src/cli.ts", "/path/to/your/vault"] } } } ``` Add `--read-only` to hide the write tools. ## Tools - Reading: `search_notes`, `read_note`, `list_notes`, `list_tags`, and `vault_guide`. The guide covers folders, tags, properties, templates, daily notes, and your filing rules. - Writing: `create_note` (from a template, with properties and tags), `append_to_note`, `add_to_section`, `replace_in_note`, `move_note` (updates links), and `add_to_daily_note`. To tell agents where things go, write the rules in `AGENTS.md` at the vault root or in `.hatch/AGENTS.md`. --- # Agent memory with the AI SDK `@hatchmd/ai-sdk` gives an agent built on Vercel's AI SDK a Hatch vault as its memory. The agent searches the vault before it answers and files what's worth keeping as Markdown notes. Your team reads and edits those notes in Hatch, Obsidian or any editor. When the agent and the people share the same files (a folder, or a vault synced to the bucket), the agent sees their edits on its next call. ```ts import { hatchTools } from '@hatchmd/ai-sdk' import { NodeFileSystem } from '@hatchmd/vault/node' import { stepCountIs, streamText } from 'ai' const hatch = await hatchTools({ fs: new NodeFileSystem('./vault') }) const result = streamText({ model: 'anthropic/claude-sonnet-5.5', instructions: hatch.instructions, tools: hatch.tools, stopWhen: stepCountIs(8), prompt: 'What did we decide about Acme’s renewal? Log today’s call too.', }) ``` ## The tools They're the same tools the MCP server gives Claude Code and Cursor (see [mcp.md](https://hatch-docs.pages.dev/using-hatch/connect-an-agent/)), so an agent you build files notes the way those do: | Tool | What it does | |---|---| | `vault_guide` | How this vault is laid out: folders, tags, properties, templates, daily notes and the owner's rules | | `search_notes`, `list_notes`, `query_notes`, `list_tags` | Find notes by text, folder, tag or property | | `read_note` | Read a note by path or name. Paths still work after a note is renamed or moved in Hatch | | `create_note`, `append_to_note`, `add_to_section`, `replace_in_note`, `add_to_daily_note`, `move_note` | Write. Edits are merged with whatever a person changed meanwhile | | `components`, `slides`, `site_look`, ... | Charts, slides and site styling, for agents that make pages | `hatch.instructions` tells the model how to use them. Pass it as `instructions` (with your own after it). ## Options | Option | | |---|---| | `fs` | Where the vault is. Any `FileSystem`: a folder (`NodeFileSystem`), memory (`MemoryFileSystem`), an object store (below) | | `name` | The vault's name in the instructions. Default "Vault" | | `readOnly` | Only the tools that read | | `only` | Keep only these tools, like `['search_notes', 'read_note']` | `hatch.vault` is the vault itself, for your own reads, and `hatch.close()` lets the tools go. ## A vault in an object store Serverless hosts have no lasting disk, so keep the vault in a bucket. Each note is one object. - **Cloudflare R2:** `r2FileSystem(env.VAULT, { prefix: 'acme' })` from `@hatchmd/ai-sdk/r2`, with the Worker's bucket binding. - **Anything else:** `objectStoreFileSystem(store)`, where `store` answers `list(prefix)`, `get(key)`, `put(key, bytes)` and `delete(keys)`. The Vercel template has one for Vercel Blob in about 30 lines. The tools read the bucket again before each call, but only notes that changed, so keep one `hatchTools` per warm instance rather than one per request. Opening the vault reads every note once, which counts against a Worker's subrequest limit: fine for hundreds of notes, too many for tens of thousands. An empty folder lasts only while the instance that made it runs, since a bucket only knows keys. ## Notes are input too Anything in the vault reaches the model, including instructions someone wrote into a note. The templates pass `only` so the agent can read and add, but not rewrite, move or delete notes. Widen that list only for agents that need it. ## Templates In `examples/agent-memory`: - `vercel`: a Vercel Function at `/api/chat`, with the vault in private Vercel Blob and the model through Vercel's AI Gateway. - `cloudflare`: a Worker at `/chat`, with the vault in R2, each conversation's turns in D1, and Anthropic's API. Both answer only callers that send `AGENT_TOKEN` as a Bearer token. To run Hatch itself (the app and the server) on your own machine with Coolify, see [deploy.md](https://hatch-docs.pages.dev/running-hatch/deploying-hatch/). --- # The file tree and tag colors ## Where new things go New notes, folders, canvases and collections go in the current folder. - Click a folder to make it current. It gets a thin outline. - Click a note and its folder becomes current. - Click the empty space under the tree to go back to the top of the vault. - Open a note any other way (search, a link) and its folder becomes current again. The logic is in `packages/app/src/treeFolder.ts`. `store.currentFolder()` reads it and `store.setCurrentFolder()` sets it. ## Making things - The + button at the top of the sidebar opens a menu: New note, New folder, New canvas, New collection. - Right-click a folder for the same four inside that folder. - Right-click a note for "New note next to this". - Right-click empty space for a note or folder at the top of the vault. - Shift+F10 or the Menu key opens the menu for the focused row. - Ctrl+N (Cmd+N on a Mac) makes a note in the current folder. A new item shows up with its name selected, ready to type over. Enter keeps the name, Escape leaves it as it is. After you name a new note, the caret is in the note. ## Folders - A folder is a real folder on disk, made with the platform's `mkdir`. So an empty folder is still there after a reload, and Obsidian sees it too. - The vault keeps the list of folders (`Vault.folders()`, `createFolder`, `move`, `removeFolder`). - A folder stays after its last note is deleted. - Sync sends files, not folders. An empty folder reaches your other devices once it has a note in it. ## Renaming, moving and deleting Notes, canvases, collections and folders all work the same way. A folder takes everything in it along. - **Rename**: F2 on the focused row, or Rename in its menu. - **Move**: drag a row onto a folder, onto a note (it lands next to that note) or onto the empty space under the tree (the top of the vault). Or pick "Move to folder" in the row's menu and choose a folder. A folder can't go into itself. - **A name that is taken** gets a free one ("Cabin 1"), the way a new note does. The toast says so. - **Delete**: Delete or Backspace on the focused row, or Delete in its menu. A folder with notes or files in it asks first and says how many go with it. An empty folder just goes. - **Undo**: the toast after a rename, a move or a delete has an Undo button for a few seconds. What follows a file to its new path: - Links to it. A link that still finds the same file is left alone, so `[[Cabin]]` by name survives a folder rename untouched. A link written as a path gets the new path: `[[Projects/Cabin]]`, `text`, `text`. Relative links inside a note that moved are fixed too. Headings and aliases are kept, and links inside code are not touched. - The open note is fixed in its editor, as an edit you can undo. It is never rewritten on disk behind the editor. - Saves of the open note wait while the files move, and go to the new path once they are there. You can keep typing during a move. - A note's `.assets` folder, its comments (`.hatch/comments/`) and its version history. - Canvas cards that show the file. - The open note, the address, Back and Forward, the current folder, folder icons, which folders are open in the tree, and the templates folder setting. Deleting a folder: - The folder is read from the disk first. A file another app or sync put there counts in the question, even when the tree showed the folder as empty, and is kept for Undo too. - An empty folder is only ever removed while it is empty on disk. If something turned up in it, nothing is deleted and the file shows in the tree. - Every note's last text is kept in History first (the Deleted notes list), so a note can come back later. That needs History to be on. - Comments are set aside in `.hatch/comments/.deleted/` and come back with the note. - Undo in the toast brings back the whole folder: notes, canvases, collections, empty folders and other files. Other files are kept for Undo up to 64 MB in all. Past that the toast says how many could not come back. How it is built: - `Vault.move(from, to)` moves a file or a folder. It asks the file system to rename the folder in one step (`FileSystem.movesFolders`: desktop, mobile, memory). The browser's file system can't do that, so there each file is moved (never over a file already at the new path) and the old folders removed only once they are empty (`FileSystem.removeDir`). The index is moved, not read again. - `Vault.syncFolder(path)` reads one folder from the disk again. Deleting a folder uses it before it asks. - `Vault.planLinkFixes(moves)` works out the link changes before anything moves, while every link can still be followed. - `moveWithLinks` in `packages/vault/src/moves.ts` puts the link fixes together with canvas cards and any `FileRewriter` a package adds. The MCP server's `move_note` uses it too. `folderRefsRewriter` in `packages/bases` follows a renamed or moved folder in collection filters (`file.inFolder("Old")`, `file.folder == "Old"`), in `.base` files and in ```` ```base ```` blocks. - `packages/app/src/fileMoves.ts` adds comments and deleting. `store.renameNote`, `store.renameFolder` and `store.moveTo` all go through one method, `relocateNow`. - `packages/app/src/treeDrag.ts` is the drag and drop. `components/MovePicker.tsx` is the folder picker. Limits to know about: - Sync sends a move as the old files going and new ones arriving. Other devices move the old copies to `.trash/` and download the new ones. The old folder is removed there once it is empty. A file that only moved is not counted as a suspicious mass delete, so a big folder moves without the "held deletions" question. A folder you delete in the app is not asked about twice either. - On another device, a note that moved shows up in History under Deleted notes at its old path, because History is kept per device. If that device had the note open, it switches to another note. - A collection whose folder name can't be changed where it is written (an odd YAML escape, say) is left as it was and counted in the "could not be updated" toast. Change it in the collection's filters. - Dragging needs a mouse. On a touch screen use "Move to folder". - There is no cut and paste for rows (Ctrl+X, Ctrl+V) yet. - Undo is offered in the toast only. It is not on Ctrl+Z. ## Tag colors - Every tag starts with one of the ten colors, picked from its name (`autoTagColor`, never gray). The same name gets the same color everywhere, from the first letter typed. - In a note a tag is text: a click puts the caret in it, so you can type. To open its menu ("Show notes with #tag", the ten colors and Default), rest the pointer on the tag and press the Color button that shows above it, or Cmd-click (Ctrl-click on Windows and Linux), or right-click. The menu key and Shift+F10 open it for the tag the caret is in. A tag in a note's properties or the Tags panel opens the menu with a click. - The colors are in the order Notion uses. Default is the theme's own tag color. - Anything that draws a tag writes `tagAttrs(name)` from `packages/app/src/tagColors.ts` (`data-tag` and `data-tagc`). The editor writes the same two attributes itself. - The ten colors are in `packages/theme/src/tag-colors.ts`. `tagPalette(theme)` tunes them to the theme in use, so the text reads on its chip (4.5:1) in light and dark. - Choices are saved in the vault at `.hatch/tags.json`, so they travel with your notes: ```json { "colors": { "work": "red", "reading": "teal", "inbox": "default" } } ``` - Tag names are stored in lower case. `#Work` and `#work` share a color. - Anything in the file that Hatch doesn't know is kept when it saves. - Anything that draws a tag sets `data-tag=""`: tags in a note, the tags property, the Tags panel. One stylesheet (`tagColorCss` in `packages/app/src/tagColors.ts`) maps those names to colors. Tag names are escaped, so an odd name can't break out of its rule. - Published sites don't use tag colors yet. Tags there keep the site theme's tag color. ## Tests - `packages/app/src/treeFolder.test.ts`, `packages/app/src/tagColors.test.ts` and the folder tests in `packages/vault/src/vault.test.ts`. - `packages/app/src/fileMoves.test.ts` covers renaming, moving and deleting folders with notes in them: links, canvases, comments and history. The sync side is in `apps/server/src/sync.test.ts`. - `scripts/e2e-tree.py` drives all of it in a browser. --- # Addresses and the Sites button ## What's open is in the address The path says what you're looking at. Copy it, bookmark it or reload, and you land in the same place. | Address | Opens | | --- | --- | | `/Projects/Cabin` | A note (`Projects/Cabin.md`) | | `/Projects/Cabin#open-questions` | A heading in that note | | `/Reading/Red-Rising` | `Reading/Red Rising.md`: spaces read as dashes | | `/Projects/Cabin-board.canvas` | A canvas. Other files keep their extension | | `/board/Candidates` | A folder shown as a board | | `/settings/appearance` | A settings page | | `/search?q=cabin` | Search, with the words filled in | | `/sessions/board` | Sessions (desktop) | | `/Projects/Cabin?panel=outline` | The note with the outline open (`outline:outline`) | | `/Projects/Cabin?panel=site` | One word for each built-in panel: `chat`, `site`, `git-history`. Another plugin's panel is `plugin:panel` unless both are the same word | | `/Projects/Cabin?chat=c1x2` | The note with a saved chat open | - Notes leave off `.md` and show spaces as dashes. That readable form is only used when it leads back to the same file: if `Red-Rising.md` exists too, `Red Rising.md` is written exactly, as `/Reading/Red%20Rising`. A link typed in any case still opens the note, and Hatch tidies the address. - A first part that's one of the app's own words (`settings`, `search`, `board`, `sessions`, `assets`...) goes after `/-/`, so a folder called "settings" is `/-/settings/...`. Boards and Sessions are kept apart from notes inside the app too, so a note called `board:x` is always a note. - A heading uses the same id as on a published site: the heading's text in lowercase with dashes. A repeated heading gets `-1`, `-2`. - The vault is not in the address. A link opens in the vault you have open. If the note isn't there, Hatch says so and leaves the vault ready to browse or search. If it turns up (sync, the disk still being read), it opens. - Renamed and moved notes keep their links. Every rename or move made in Hatch (by you or an agent through MCP) is remembered in `.hatch/moves.jsonl`, and an address for a file that isn't there follows it to where the file is now. The address then shows the new place. A file that has the old name again wins. Notes are never changed for this, so the vault stays plain Markdown. Sync joins the log from every device, and it keeps the newest 2,000 moves. See `docs/plans/rename-proof-urls.md` for why Hatch does this rather than put ids in addresses. - Old links (`#/note/Projects/Cabin.md`, `?panel=ai:chat`) still work. Hatch opens what they name and swaps in the new address. - Flags like `?e2e` and `?nosw` stay in the address as you move around. A feature's own state in the query (see `docs/url-state.md`) stays with its page. ### Where the address lives | Shell | Address | Links from outside | | --- | --- | --- | | Web | The real path. The server answers every path with the app (`deploy/Caddyfile`, and `apps/web/public/sw.js` offline) | Any link to the app | | Desktop | The hash of `hatch://app/index.html` | `hatch://open/Projects/Cabin` from a browser, another app or the terminal (`apps/desktop/main/links.ts`) | | Mobile | The hash | `hatch://open/...`, and the web app's own links when `VITE_HATCH_APP_URL` is set and the app is set up to take them (iOS associated domains, an Android intent filter) | The phone projects aren't in the repo, so after `cap add` the scheme has to be listed by hand: `CFBundleURLTypes` with `hatch` in the iOS `Info.plist`, and an intent filter for `hatch://open` in the Android manifest. https links also need an associated domain (iOS) and a verified app link (Android). Desktop takes `hatch://` links only when installed. A development run leaves them to the installed app (set `HATCH_DEV_LINKS=1` to try them). A Hatch started with `HATCH_VAULT` runs on its own window, as before; any other second launch hands its link to the running one. Deep links only ever show something. They can't write to the vault. Copy link (the note's menu) gives the link that opens what's on screen from anywhere it can: the page's address on the web, and `hatch://open/...` in the desktop and phone apps (the web app's address on a phone app built with `VITE_HATCH_APP_URL`). It keeps the open panel and leaves out test flags. Published sites follow moves too: a published note's old address answers with a `301` to its new one on Hatch hosting, and a redirect page (with `rel="canonical"`) on any other host. ## Back and Forward - The app's history is the browser's history. The browser's buttons, the app's buttons, the hotkeys and a mouse's side buttons all walk the same list. - Opening a note adds one entry. Typing, scrolling, moving to a heading and changing settings pages never add one. - Settings and search borrow the current entry. Closing them puts the note's address back. - A reload keeps the open note and the history behind it. - Renaming or moving a note updates its entries. So does renaming or moving a folder it is in, here or on another device before a reload. Back steps over a note that has been deleted. ## For people changing the code - `packages/app/src/routeAddress.ts` has `parseRoute` and `formatRoute` (pure, unit tested). Pass the vault's names to get readable addresses. Without them they're exact. - `packages/app/src/route.ts` has the `Router`. It writes through the shell's address adapter (`Platform.address`, from `@hatch/url-state`). - Features keep their own state in the query with `store.url` or the `useQueryState` hook (`docs/url-state.md`). Their history entries go through the router, so Back and Forward know them. - The store calls `router.sync()` whenever the open note or settings change, so new code only needs `store.open(path)`. Pass `{ heading }` to land on a heading and `{ push: false }` to replace the current entry. - `store.router.url()` gives the link to share (`Platform.shareLink` can change it for a shell). The move log is `vault.moveLog` (`packages/vault/src/moveLog.ts`): `moveWithLinks` records every move, `follow(path)` says where a path is now, and the MCP server and site builds use it too. `store.router.heading(id)` moves the address to a heading without adding an entry. - `state.back` and `state.forward` are kept by the router. Don't write to them. - `scripts/e2e-routes.py` checks all of the above in a browser. ## The Sites button The grid button at the top left of the sidebar lists your sites. While the sidebar is hidden it sits in the top bar, next to the sidebar button. - Each row shows the site's name, its kind and its address. - The site published from the open vault opens its settings (Settings, Publish). Rows under it go straight to its applications board or its subscribers. - A site published from another vault opens in the browser. To change it, open the vault it came from. - "New site" starts a site for the open vault. A vault publishes one site, so once it has one the list says how to start another. - Signed out, the list explains what a site is and offers to sign in. A site you set up without an account (to download) is still listed. Limits to know about: - The server doesn't store a site's kind. It lives in the vault's `.hatch/site.json`. Each device remembers the kinds of sites it has opened or published, and shows "Site" for the rest. - There is no page for managing a site on its own yet. Settings, Publish is that page for the open vault's site. --- # Collections (Obsidian Bases) In the app they're called collections. On disk they're Obsidian Bases (`.base` files), so both apps open them. In code they're still "bases". Hatch opens them as tables, cards, lists, boards, calendars and charts. Boards, calendars and charts are Hatch additions that Obsidian doesn't know about. A collection shows the notes that match its filters, with chosen properties as columns. ## Where the code is - `packages/yaml` reads and writes YAML. It refuses what it can't read correctly (anchors, tags, several documents) instead of guessing. - `packages/bases` has the expression language (`expr.ts`), values like dates and links (`values.ts`) and running a view (`base.ts`). - `packages/app/src/components/BasesView.tsx` is the screen. Its toolbar, views (table, cards, list, board, calendar, chart) and cells are in `components/bases/`. ## What works - Filters for the whole base and for each view, nested with `and`, `or` and `not`. - Formulas, property display names and column summaries. - Table, cards and list views. Sorting, grouping and a row limit. - Editing a note's property from its cell. The note changes, the base doesn't. - Dates and durations: `due < today() + "1w"`, `(now() - file.ctime).days`. - Editing the base as YAML, which is also how you fix a file Hatch can't read. ## Rules - The parsed YAML is the source of truth. Settings Hatch doesn't know are written back unchanged. Comments are lost when Hatch saves a change, as in Obsidian. - A file that isn't valid YAML is never saved over. It opens in the YAML editor with the reason. - A filter that doesn't parse shows no rows and says why. - Expressions have a work budget and size caps, so a formula can't freeze the app. ## Not yet - The map view. - Bases embedded in notes with a ```` ```base ```` block. - Property types from `.obsidian/types.json`. Dates written as text (`2026-05-01`) count as dates next to other dates and durations. ## New notes - **New** makes a note that shows up in the view: in the folder from `file.inFolder()`, with the values from simple `property == value` filters. - On a board, each column has its own **New**, which also sets that column's value. - On a calendar, each day has a **+** that makes a note with that date. ## Calendars - A calendar view places each note on the day in a date property. It's saved as a `date` key on the view (`date: note.due`). Without one it uses the property that holds dates most often. - Drag a note to another day, or focus it and press Alt with an arrow key (a day, or a week up and down). A time of day stays as it was. - Notes without a date are listed under the month, and can be dragged onto a day. - On a phone the month reads as a list of the days that have notes. - Dates are written bare (`due: 2026-12-05`), so Obsidian reads them as dates too. - A view can start new notes from a template. Pick it in Edit view, under "New notes start from". It's saved as a `template` key on the view. Obsidian keeps the key and ignores it. ## Inside a note - Write a ```` ```base ```` block in any note, the same way Obsidian does, or type `/collection`. - The block shows the collection. Its views switch, its table sorts, and **New** works, just like a `.base` file. - Sorting there is just for looking: it never rewrites the block. Use Edit YAML (the pencil) to change it for good. - `this` is the note the block is in, so `file.folder == this.file.folder` lists the notes next to it. - On a published site the block becomes a table of its first view. Only published notes are listed. - `![[Books.base]]` shows a collection file in a note. `![[Books.base#View]]` opens on that view. It's read-only there: open the collection to change it. Sites don't draw these yet. --- # Components Components are fenced code blocks with a name, like ```` ```chart ````. Hatch shows the result, and Obsidian or GitHub show the plain text, which still reads fine. ## Writing one - Type `/` and pick one (Chart, Progress bar, Tabs, Steps, Columns, Cards, Button, Table of contents, Post list, Form). You get a working example to edit. - Or type ```` ``` ```` at the start of a line. Block names come up as you type. - Click a component to edit its source. Click elsewhere to see the result. - Suggestions come up as you type keys and values. Press Ctrl+Space on an empty line to see them all. Enter or Tab picks one, Escape closes the list. - Problems get a wavy underline, and the reason is listed under the source. ## The blocks ### chart The same format as the Obsidian Charts plugin, so charts work in both apps. ````md ```chart type: bar labels: [Mon, Tue, Wed] series: - title: Pages read data: [12, 30, 8] ``` ```` - `type`: `bar`, `line` or `pie`. - `labels`: names along the bottom. - `series`: one `title` and `data` each. A pie chart uses the first series. - `title` and `beginAtZero` are optional. - Hover a chart to see each value, like the tooltip in most chart tools. This works on published sites too. A chart can count a collection instead of listing numbers: ````md ```chart type: bar collection: Books.base x: status y: pages aggregate: average ``` ```` - `collection` is the `.base` file to count. - `x` is the property to group by. `y` is the property to add up. Without `y`, it counts notes. - `aggregate` is how `y` is added up: `sum` (the default), `average`, `min`, `max` or `count`. - `view` picks one of the collection's views. Without `x`, the view's own chart settings are used. - The chart redraws as your notes change. On a published site it counts published notes only. ### progress ````md ```progress title: Chapters written value: 7 max: 12 ``` ```` - `value` is how much is done. `max` is the total (default 100). - `title` is shown above the bar. `label` still works, as an older name for it. ### tabs Each `tab: Name` line starts a tab. Everything under it is Markdown. ````md ```tabs tab: Mac Install with **brew**. tab: Linux Install with apt. ``` ```` A tab can hold a code block. Write the outer fence with four backticks so the inner one doesn't close it. When every tab holds only a code block, the tabs show as one code box with the names along its top, for the same command in several languages: `````md ````tabs tab: npm ```sh npm install hatch ``` tab: pnpm ```sh pnpm add hatch ``` ```` ````` ### steps Numbered steps for a guide. Each `step: Title` line starts one, and everything under it is Markdown. A step can hold code too (use four backticks on the outer fence, as for tabs). ````md ```steps step: Install the app Download it and open it. step: Make your first note Press **New note** and start typing. ``` ```` ### columns Content side by side: a picture next to text, or two paragraphs. Each `column:` line starts one, and everything under it is Markdown. `column: 2` makes a column twice as wide as a plain one. Up to 4 columns; on a phone they stack. Two pictures alone don't need this: written on one line, they already sit side by side. ````md ```columns column: 2 ![[porch.jpg]] column: The porch faces south, so it gets the afternoon sun. ``` ```` ### preview Shows Markdown or HTML the way it looks, in a frame, with its source folded under View code. For documenting what something looks like. Everything inside is Markdown, and a code block inside needs four backticks on the outer fence. ````md ```preview > [!tip] Previews > Readers see this as it looks, and its source under View code. ``` ```` ### demo A working page from your vault in a frame, like a built component example. The page and the files next to it (its scripts, styles and pictures) are published with the site, and its scripts run in a sandbox: they can't reach the site, its cookies or the reader's storage. The folder must hold only the built example: a folder with notes in it, or the vault's top, isn't published. In the app the block shows where the demo goes. The page gets `?theme=dark` when the reader's site is dark. A menu or popover that opens past the frame's bottom grows the frame while it's open. Build examples as classic scripts: module scripts need CORS in the sandbox, which only public sites on Hatch hosting send. | Key | What it does | | --- | --- | | `src` | An HTML page in your vault, like `"[[previews/button/index.html]]"`. Required | | `height` | How tall the frame is, in pixels, 80 to 1200. Default: 280 | | `title` | What screen readers call the demo. Default: Demo | ````md ```demo src: "[[previews/button/index.html]]" height: 240 ``` ```` ### files Folders and files as a tree. Write a list: a name ending in `/` is a folder, the items indented under it are inside it, `**name**` marks one to notice, and text after ` # ` is a note beside it. Folders open and close. ````md ```files - src/ - components/ - **button.tsx** # the one you add - app.tsx - package.json ``` ```` ### cards Linked cards in a grid, for pointing readers to the next pages. ````md ```cards cols: 2 items: - title: Quickstart text: Set up in five minutes. link: "[[Quickstart]]" - title: API reference text: Every endpoint. link: https://example.com/api ``` ```` - `items` lists the cards. Each has a `title`, and an optional `text` and `link` (a web address or a `[[note]]` in quotes). - `cols` is how many cards sit in a row on wide screens, 1 to 4 (default 2). Phones show one. - `look` set to `list` draws them as quiet rows instead of boxes: the title over its line, one under another. Good for a list of projects on a home page. ### posts Where a published blog or portfolio lists its posts, newest first. Put it in the home note to choose where the list goes: the page then leaves out the list it adds at the end. ````md ```posts title: Writing limit: 10 ``` ```` - `title` is shown above the list (none by default). - `limit` is how many posts to show (all by default). - In the editor it marks where the list will be. On any site that isn't a blog or portfolio it stays a note that says so. ### Code blocks with a file name Not a component, but handy in docs: put a file name after the language and it shows above the code. ````md ```js app.js console.log('hi') ``` ```` `title="app.js"` works too. ### button ````md ```button text: Read the guide link: "[[Welcome]]" style: secondary ``` ```` - `text` is what the button says. - `link` is a web address or a `[[note]]`. Put a `[[note]]` in quotes. - `style` is `primary` (the default) or `secondary`. ### toc Lists the note's headings. `depth` is the deepest level shown (default 3), and `title` replaces "Contents". ### form ````md ```form title: Get in touch folder: Leads fields: - Name* - Email (email)* - Topic (Sales | Support) - Message (long) button: Send thanks: Thanks. We'll reply within a day. ``` ```` - `folder` is where responses are saved. `fields` lists one field per line. - `title`, `button` and `thanks` are optional. - `align` places the form: `left` (the default), `center`, `right`, or `full` for the whole width of the text. - In a note, the form is a working preview: you can type and pick, but nothing is sent. - Field types and where responses go are in `forms.md`. ## Your own components You can add components of your own, like a carousel or a pull quote. They show up in the / menu next to the built-in ones, get the same suggestions and checks as you type, and work on published sites. - The quickest way: open Settings, then Your components, and pick Make one with the chat. Describe what you want ("Make a component that shows a quote with who said it"). The chat writes it, checks it, and shows it to you to accept. - Each component is one file, `.hatch/components/.yaml`. The file name is the block's name. Change the file and every note using it redraws. - Nothing ships pre-made. Ask the chat for what you want, for example "Make a carousel component for the pictures in Projects/Cabin.assets". It reads the guide, writes the file, checks it, and proposes it. Accept it, then type / and its name in any note. Ask it to put one in a note too. A carousel's arrows (or a swipe, or the arrow keys once it has focus) move one picture at a time. That scrolling is the one thing a component can do. ### What a component file holds ````yaml title: Pull quote description: A quote that stands out, with who said it. icon: ❝ keywords: quote citation testimonial keys: quote: type: text required: true doc: What they said by: type: text doc: Who said it example: | quote: Simple things should be simple. by: Alan Kay template: |
{{quote}}
{{#if by}}
{{by}}
{{/if}}
style: | .quote { margin: 0; padding: 16px 20px; border-left: 2px solid var(--h-border-strong); } blockquote { margin: 0; font-size: 1.15em; } figcaption { margin-top: 8px; color: var(--h-text-muted); font-size: var(--h-text-sm); } ```` - `keys` are what a block takes. Types: `text`, `number`, `boolean`, `enum` (with `values`, lowercase so they work as classes), `list`, `link`, `image` and `items` (a list of maps with their own `keys`). A key can be `required` and have a `default` of its own type. - Only these fields are read. A misspelled one (`descripton`, `styles`) is an error that names the field it meant. - `template` is HTML with holes: `{{key}}`, `{{#each key}}...{{/each}}` and `{{#if key}}...{{else}}...{{/if}}`. - `style` is CSS for the component only. Colors and fonts come from the theme (`var(--h-text)`, `var(--h-surface)` and the rest), so it matches every theme, light and dark. - Problems are listed in Settings with the lines around the bad one, numbered and marked (`packages/blocks/src/codeFrame.ts`, like Vite's error overlay), and a Fix with the chat button. The chat and MCP tools get the same lines as text. A block using a broken component says what's wrong instead of drawing. The chat and the MCP server won't save a component while anything is wrong, including design warnings like a picture without alt text, a button without a label, bold text above 500, or a transition over 300ms. ### What a component can't do Nothing in a component runs, so a component from someone else's vault is as safe as a note: - No scripts, event handlers, forms, frames, style attributes or `