Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
666d4e8
fix(window): tell the desktop shell when the window has painted, so i…
nodemode-ai Dec 3, 2026
0ad37ca
fix(desktop): show the main window after 6 s, not 20 s, if the page n…
nodemode-ai Dec 3, 2026
30a45a2
feat(agent): live stream, window command bridge, jobs and owner appro…
nodemode-ai Dec 3, 2026
bb02a7c
feat(cli): formledger cli mcp, an MCP server on stdio for Claude Code…
nodemode-ai Dec 3, 2026
8ecb5fe
feat(window): open pages refresh live when the books change elsewhere…
nodemode-ai Dec 3, 2026
659f82b
feat(window): every page action, menu item and preference is a typed …
nodemode-ai Dec 3, 2026
d08045e
fix(agent): plain refusals for agents, the reach of Always allow, and…
nodemode-ai Dec 3, 2026
51f717c
docs(agents): the MCP server, the window's commands, approval, compac…
nodemode-ai Dec 3, 2026
7f23326
feat(dock): each agent tab gets its own write token and Claude Code s…
nodemode-ai Dec 3, 2026
0ab4584
feat(account): an App tokens panel lists, makes and revokes the owner…
nodemode-ai Dec 3, 2026
f43b79d
docs(agents): the dock connects agents by itself, and Account makes a…
nodemode-ai Dec 3, 2026
0be2027
docs(hashout): the 0.16.0 roles' rationale for the engine, the window…
nodemode-ai Dec 3, 2026
eadce57
fix(agent): a read-only token runs only the window's read commands, s…
nodemode-ai Dec 3, 2026
22c4181
fix(window): invoke app_ready only after the page's first contentful …
nodemode-ai Dec 3, 2026
cfbf644
docs(hashout): correct the reveal timing numbers after the paint fix …
nodemode-ai Dec 3, 2026
a9c3acf
chore(release): 0.16.0 (0.16.0)
nodemode-ai Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/skills/formledger-harness/EVALS.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"files": [],
"expected_behavior": [
"Does not open source files or propose code changes",
"Says the repository is a scaffold and has no MCP server or agent tool yet, and does not invent app features or menu paths"
"Points to docs/ledger/agents.md and the formledger cli mcp server for using the app, and does not invent app features or menu paths"
]
}
],
Expand Down
5 changes: 3 additions & 2 deletions .claude/skills/formledger-harness/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FormLedger is a local-first business app that is the system of record for a smal

This pack is for agents who change the repository. It is not about using the app. `docs/BEHAVIOURS.md` is the specification: every phase's exit criterion traces to a behaviour there, and nothing outside the repo is a source of behaviour. Outside reference products are never opened or copied.

There is no MCP server or agent-facing tool yet; they are later phases. Do not add `.mcp.json` or describe agent tools until a phase builds them. `./formledger cli` is a client of the running server over HTTP with an app token (`FORMLEDGER_URL`, `FORMLEDGER_TOKEN`); it never opens the database, because one server process is the only writer.
Agents use the app through `./formledger cli mcp` (stdio MCP, in `internal/cli/mcp.go`), the `internal/agent` module (`/api/agent/*`: routes, call, window commands, jobs, approval; `/api/live`: the change stream) and the window's command registry, bridged by `web/src/ui/agent-bridge.ts`; `docs/ledger/agents.md` is the reference. A new window action must be a registered command with typed params (`web/src/engine/agent.ts` holds the page actions), and a new money-moving, destructive or people route must fall in an approval class in `internal/agent/call.go`. There is no `.mcp.json`, because the server needs the user's own app token. `./formledger cli` is a client of the running server over HTTP with an app token (`FORMLEDGER_URL`, `FORMLEDGER_TOKEN`); it never opens the database, because one server process is the only writer.

## Repo map

Expand All @@ -31,7 +31,8 @@ There is no MCP server or agent-facing tool yet; they are later phases. Do not a
| `internal/coa`, `internal/fiscal` | The chart of accounts with its starter chart; fiscal years, monthly periods and the period lock |
| `internal/journal`, `internal/posting` | Draft entries and the triggers that protect posted rows; post and cancel, each one transaction, with gapless numbers |
| `internal/reports` | Trial balance, general ledger, balances, period activity and the integrity check, all read-only SQL |
| `internal/cli` | `./formledger cli`, the HTTP client |
| `internal/cli` | `./formledger cli`, the HTTP client, and `cli mcp`, the agents' MCP server |
| `internal/agent` | The agents' engine side: `/api/live` change stream, `/api/agent/*` routes, call, window commands, jobs and the owner's approval |
| `docs/ledger/` | One page per ledger part, with routes and refusal codes |
| `internal/customers`, `internal/items`, `internal/taxrates` | The parties and the things sold; tax is basis points, computed half-up per line |
| `internal/series`, `internal/sales` | Gapless numbers for any document prefix; the sales document tables with their protecting triggers, drafts and server-side totals |
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FormLedger: a local-first business app that is the system of record for a small

`.claude/skills/formledger-harness/SKILL.md` holds the repo map, the commands, the ports, the rules of the build, the ledger invariants and the hand-back. Read it before changing anything. `docs/BEHAVIOURS.md` is the specification.

There is no MCP server, CLI for agents or agent-facing tool yet.
Agents that use FormLedger (not change it) connect with `./formledger cli mcp`, an MCP server on stdio that is a client of the running server with an app token. It reaches every engine route, every `formledger cli` command and every command of the open window, and the window shows their changes live. Posting, cancelling, allocating, amending, confirming, deleting, period locks, invitations and the app lock wait for the owner's approval in the window; sign-in, tokens and terminals are never reachable. `docs/ledger/agents.md` lists the tools. When you add a user action to the window, register it as a command with typed params in the engine's registry so agents get it too.

## Build and check

Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 0.16.0

FormLedger opens in about three seconds on a Mac instead of twenty or more, and Claude Code and the other agents can now do everything you can in it.

### Fixed
- **Slow open on macOS.** The desktop app keeps its window hidden until the page says it is ready, and the page had stopped saying so, so every launch waited out a 20 second safety timer behind the splash. The page now says so as soon as it has drawn, and the safety timer is 6 seconds. Windows and Linux were not affected.

### New
- **Agents can do everything you can.** Every page action is a typed command (invoices and other documents, payments, stock, master data, cash, reports, the dashboard, templates, the menus and Preferences), 115 in all, that Claude Code and the other agents can list and run. A new `formledger cli mcp` server gives agents the ledger's data and every engine route, going through the running engine so it stays the only writer.
- **Claude Code in the dock works with no setup.** Each agent tab gets its own access key, passed to it with the engine's address, and Claude Code is started with FormLedger's tools already connected. The key is listed under Account, App tokens, revoked when the tab closes, and cleaned up after a crash.
- **App tokens in Account:** see your keys, make one (shown once, with Copy) and revoke any of them.
- **The open page follows changes.** When an agent or the command line changes the books, the page you have open updates at once; a draft you are editing is kept, with a note.

### Changed
- **You approve the risky steps.** When an agent deletes, posts, cancels, allocates, amends or confirms, locks a period, invites someone, locks the app, signs out or quits, FormLedger asks you in the window first; with no window open the step is refused. Agents cannot sign in or create or revoke keys, and read-only keys stay read-only.

### Known issues
- The plain `formledger cli` run with your own token is not approval-gated; it is your scripted path. Only the agent tools are.
- Codex, Cursor and Antigravity tabs get a key and the engine's address, but not yet the agent tools set up for them.
- Part of a first launch on a Mac can be macOS checking the downloaded app; signing and notarisation are done when the app is built.

## 0.15.1

FormLedger's window now matches the other Form apps at the top right, in Preferences and around the macOS traffic lights.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A local-first business app that is the system of record for a small company. Go
- `embed.go` embeds `web/dist` into the binary. `src-tauri/` starts the server as the sidecar `binaries/formledger-server`.
- `docs/BEHAVIOURS.md` is the specification; every phase's exit criterion traces to it. Outside reference products are never opened or copied.
- `formledger`, `formledger_oc_install` and `build_app` at the root are the scripts the repo ships, not build output.
- There is no MCP server, CLI for agents or agent-facing tool yet, and so no `.mcp.json`. They are later phases.
- Agents reach the app through `./formledger cli mcp` (stdio MCP, a client of the server with an app token), the engine's `internal/agent` module (`/api/agent/*` and the `/api/live` stream) and the window's command registry. Every new user action is a registered command with typed params; money-moving, destructive and people actions stay behind the owner's approval. See `docs/ledger/agents.md`. There is no `.mcp.json`: the server needs the user's own app token.
- The planning documents (`DEV_PLAN.md`, `BUILD_NOTES.md`) live in a planning sidecar outside the repo.

## Skills
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := v0.15.1
VERSION := v0.16.0
GO_BUILD := CGO_ENABLED=0 go build -trimpath -ldflags "-s -w"

.PHONY: build web server check clean
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</p>

<p align="center">
<img alt="version v0.15.1" src="https://img.shields.io/badge/version-v0.15.1-eef0f4?style=flat-square">
<img alt="version v0.16.0" src="https://img.shields.io/badge/version-v0.16.0-eef0f4?style=flat-square">
<img alt="Go 1.26+" src="https://img.shields.io/badge/Go-1.26%2B-00ADD8?style=flat-square&logo=go&logoColor=white">
<img alt="TypeScript and Vite" src="https://img.shields.io/badge/TypeScript-Vite-3178c6?style=flat-square">
<img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-3a3a3a?style=flat-square">
Expand Down Expand Up @@ -124,7 +124,9 @@ The command line is a client of the running server; it never opens the database.

[`docs/ledger/cli.md`](docs/ledger/cli.md) walks from an empty company to a trial balance. What the app commits to do is listed in [`docs/BEHAVIOURS.md`](docs/BEHAVIOURS.md), and [`AGENTS.md`](AGENTS.md) is the guide for coding agents working on the repo.

From 0.15.0 the window also has an agent dock, opened from View, Agent Dock, the robot button at the top right or with Cmd or Ctrl plus J: a terminal panel beside the books with a shell tab and tabs for Claude Code, Codex, Cursor and, from 0.15.1, Antigravity when they are installed on your computer. Only the owner of the books can open it, and only from this computer. On Windows its terminals do not open yet. FormLedger has no MCP server yet; an agent drives the books through the command line above.
From 0.15.0 the window also has an agent dock, opened from View, Agent Dock, the robot button at the top right or with Cmd or Ctrl plus J: a terminal panel beside the books with a shell tab and tabs for Claude Code, Codex, Cursor and, from 0.15.1, Antigravity when they are installed on your computer. Only the owner of the books can open it, and only from this computer. On Windows its terminals do not open yet.

From 0.15.2 agents can do what you can do at the window. `./formledger cli mcp` is an MCP server for Claude Code, Codex, Cursor and others (`claude mcp add formledger -e FORMLEDGER_TOKEN=fl_... -- /path/to/formledger cli mcp`): it reads and writes the books over every engine route and the command line, and runs any of the window's commands, from opening a page to posting an invoice or changing a preference. Posting, cancelling, allocating, deleting, period locks and invitations wait for your yes in the window, sign-in and tokens stay with you, and whatever an agent changes shows in the open window at once. In the agent dock it needs no setup: each agent tab gets its own token, listed under Account, App tokens and withdrawn when the tab closes, and Claude Code starts with the server already connected. [`docs/ledger/agents.md`](docs/ledger/agents.md) lists the tools.

## Network

Expand Down
2 changes: 1 addition & 1 deletion cmd/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Living log of all comment content, explainers, rationale, TODOs, & removed (hashed-out) code for the entry point, `embed.go`, `internal/server`, `internal/static` and `internal/startup`. Source files stay comment-free per dev-rules `sub-skills/hashout-log/SUB-SKILL.md`; everything they would have said lives here, indexed. Read it first, then edit code surgically.

Current build version: v0.15.1
Current build version: v0.16.0
Last updated: 2026-11-26 (US Eastern) · skeleton port from form.md

---
Expand Down
73 changes: 73 additions & 0 deletions docs/ledger/agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Agents: MCP, the window bridge and the live stream

Claude Code, Codex, Cursor and other agents can do in FormLedger what a person can do at the window. They work as a client of the running server with an app token, so one server process stays the only writer and the token's role and scope decide what they may do. Money-moving, destructive and people actions wait for the owner's yes in the open window.

## Connect an agent

In the agent dock nothing needs setting up. Each agent tab (Claude Code, Codex, Cursor, Antigravity) gets its own write-scoped app token when it starts, named for example `Claude Code tab, FormLedger dock`, with `FORMLEDGER_TOKEN`, `FORMLEDGER_URL` and `FORMLEDGER_AGENT` in its environment, so `formledger cli` works in it at once. Claude Code also starts with the `formledger` MCP server in its `--mcp-config` and a short note saying it is there. The token is stored hashed, is listed under Account, App tokens, where the owner can revoke it, and is withdrawn when the tab closes; tokens left by a run that ended without closing its tabs are withdrawn when FormLedger next starts. Both show in the audit log as the FormLedger dock.

Outside the dock:

1. Under Account, App tokens, make an app token (read or write). It is shown once.
2. Add the MCP server to the agent. For Claude Code:

```
claude mcp add formledger -e FORMLEDGER_TOKEN=fl_... -- /path/to/formledger cli mcp
```

`FORMLEDGER_URL` points it at a server other than `http://127.0.0.1:8340`. Inside the agent dock's terminals the server's own address is already set (`FORMLEDGER_ENGINE_URL`), so only the token is needed. `FORMLEDGER_AGENT` names the agent in the approval dialog (default `MCP agent`).

## Tools

| Tool | Does |
| --- | --- |
| `ledger_overview` | The user and role behind the token, read-only or not, open windows, window commands |
| `ledger_routes` | Every engine route an agent may call, with the approval class of those that wait for the owner |
| `ledger_get` | GET one engine route, compact JSON |
| `ledger_call` | POST, PATCH, PUT or DELETE one engine route |
| `ledger_cli` | Any `formledger cli` command, for example `["invoice","post","SINV-0001"]`; its writes go through the same approval |
| `ledger_export` | One CSV export to a file on this computer, the same bytes as File, Export CSV |
| `ledger_print` | A document or statement as a PDF file on this computer, the same as Print |
| `app_commands` | The open window's commands: menus, buttons, page actions and Preferences, with argument names and approval class |
| `app_command` | One window command with its typed arguments |
| `app_run` | Run one window command, as if the person clicked it |
| `job_status` | Poll a job id answered by a slow call |

## The window's commands

Every action of the window is a command in one registry (`web/src/engine/commands.ts`) with typed parameters (type, required, enum, min, max). The palette, the menus, the keyboard and agents all run the same commands. Groups: Navigation (`view.open`, `view.current`, `go.*`, `nav.*`), File and New (`new.*`, `file.*`), View, Window and Edit (the menus), Preferences (`prefs.get`, `prefs.set`, `app.preferences`), Account and People (`account.lock`, `invites.*`, `session.logout`), Documents (`doc.*`), Payments (`payment.*`), Stock (`stockdoc.*`), Setup (`master.*`, `cash.*`), Reports (`report.*`, `dashboard.*`) and Templates (`template.*`).

`view.open { view, id, kind, status, template, from, to, asOf }` opens any page or one document, so an agent can show the person what it did.

## Approval

These wait for the owner in the window's Consent dialog (Deny, Allow once, Always allow), whether they come as an engine call, a cli command or a window command:

- posting, cancelling, allocating, amending, confirming, deleting;
- locking and unlocking periods;
- inviting people and withdrawing invitations, the app lock, signing out, closing or reloading the window.

Always allow covers that kind of action from that credential until FormLedger restarts. With no window open these are refused with `consent_needs_window`. Nothing in FormLedger sends mail or anything else off this computer.

Never reachable by agents: sign-in, set-up, unlock, invitation acceptance, claiming the books, app tokens and the dock's terminals. A read-only token stays read-only on every path: it may GET engine routes and run only the window's read commands (`view.current`, `prefs.get`, `cash.get`, `template.use`, the `*.get` and `*.list` commands, `payment.openInvoices`, `report.*` and `dashboard.*`). Every other window command is refused to it, including those that change only the window, such as `prefs.set`, the theme toggle and navigation (`view.open`, `go.*`, `nav.*`), because they change what the owner sees.

## Compact results and jobs

Lists longer than the limit (default 50, at most 500) are cut and their full length is reported under `truncated`. Binary output is not sent; `ledger_export` and `ledger_print` write files instead. A call that takes longer than its wait (default 15 s, at most 60) answers `{ job, state }`; poll it with `job_status`. States: `running`, `waiting_consent`, `done`, `failed`, `denied`.

## Live

`GET /api/live` is a server-sent event stream for the signed-in window. Every successful write publishes a `change` event (method, path, area, by `window`, `token` or `agent`, and the window id that made it). The open page refreshes in place; a document or payment with unsaved edits keeps them and says it changed. The same stream carries `consent` and `command` events to the window.

## Engine routes

| Route | Who | Does |
| --- | --- | --- |
| `GET /api/agent` | token or session | Overview |
| `GET /api/agent/routes` | token or session | Callable routes with approval classes |
| `POST /api/agent/call` | token or session | Run one route with the caller's credential, approval and compact answer |
| `GET /api/agent/commands`, `GET /api/agent/commands/{id}` | token or session | The window's catalogue |
| `POST /api/agent/commands/{id}` | token or session | Run a window command |
| `GET /api/agent/jobs/{id}` | token or session | Poll a job |
| `GET /api/live` | window session | The live stream |
| `POST /api/agent/window/catalogue`, `POST /api/agent/window/result`, `POST /api/agent/consent/{id}` | window session | The window's side of the bridge |
6 changes: 4 additions & 2 deletions docs/ledger/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ bin/formledger cli --help the compiled binary

| Setting | What it does |
|---|---|
| `FORMLEDGER_URL` | the server address, default `http://127.0.0.1:8340` |
| `FORMLEDGER_URL` | the server address; unset, `FORMLEDGER_ENGINE_URL` (set in the agent dock's terminals), else `http://127.0.0.1:8340` |
| `FORMLEDGER_TOKEN` | the app token, `fl_...` |
| `--token-file FILE` | read the token from a file instead (it wins over the variable) |
| `--table` | print a table instead of the server's JSON |

Every command prints JSON on stdout, or a table with `--table`. A problem prints one plain sentence on stderr: no token, a refused token, a read-only token asked to change something, a role that may not do the action, a server that does not answer, or a server that does not know the command yet. Exit codes: 0 done, 1 refused or failed, 2 wrong usage. `--help` works at every level (`formledger cli journal --help`, `formledger cli journal new --help`).

`formledger cli mcp` serves the same commands, every engine route and the open window's commands to Claude Code and other agents over MCP; see [agents.md](agents.md).

## Making the first app token

A token cannot be made from the command line. `POST /api/me/tokens` needs a signed-in browser session, and an app token may not make another one; `formledger cli token` only prints these steps.

The web app has no screen for app tokens yet, so for now a token is made with curl and a session cookie. The `fl_...` value is in the answer's `token` field and is shown once:
In the window, Account, App tokens makes one (name and scope; the `fl_...` value is shown once) and lists and revokes them. The agent dock makes one for each agent tab by itself. Without the window, a token is made with curl and a session cookie; the `fl_...` value is in the answer's `token` field and is shown once:

```
curl -c jar -H 'Content-Type: application/json' \
Expand Down
Loading
Loading