Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
29 changes: 25 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,31 @@ jobs:
for i in $(seq 1 30); do curl -sf "http://127.0.0.1:$FORMTOOLS_PORT/api/health" && break; sleep 1; done
curl -sf "http://127.0.0.1:$FORMTOOLS_PORT/api/health"
curl -sf "http://127.0.0.1:$FORMTOOLS_PORT/api/capabilities"
- name: Tests
run: |
pip install pytest httpx
python -m pytest -q tests

test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
cache: npm
cache-dependency-path: frontend/package-lock.json
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
cache: pip
cache-dependency-path: backend/requirements.txt
- run: npm ci
working-directory: frontend
- run: pip install -r backend/requirements.txt pytest httpx
- name: Interface logic (vitest)
run: npx vitest run
working-directory: frontend
- name: Engine (pytest)
run: python -m pytest -q -p no:cacheprovider tests
working-directory: backend

scripts:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

Rules for any coding agent (Claude Code, Codex, Cursor, Antigravity) working in this repository. `CLAUDE.md` is the full rule set; read it first.

- Stage: released (v0.13.0), built and bundled for macOS, Windows and Linux. `./formtools agents sync` mirrors `.claude/skills` into `.agents/skills`; `./formtools agents check` (also in CI) fails on drift. The plan of record is `DEV_PLAN.md` in the planning sidecar. Code changes route through `.claude/skills/formtools-harness`; using the app through MCP routes through `.claude/skills/formtools-driving`.
- Stage: released (v0.14.0), built and bundled for macOS, Windows and Linux. `./formtools agents sync` mirrors `.claude/skills` into `.agents/skills`; `./formtools agents check` (also in CI) fails on drift. The plan of record is `DEV_PLAN.md` in the planning sidecar. Code changes route through `.claude/skills/formtools-harness`; using the app through MCP routes through `.claude/skills/formtools-driving`.
- You are an outside agent to the running app. Tools that only read always work. Any other tool (including the ones behind `./formtools cli convert`, `resize` and `rename --apply`) is asked about in the formtools window (Deny, Allow once, Always allow) unless the person chose Allowed in Settings, Integration, Outside agents, and is refused under Blocked or when no window is open to ask. Only the window can change that choice: when a call is refused, tell the person what the refusal says and stop. `agents/manifest.json` lists every tool and which ones ask.
- Research lives in `docs/encyclopedia/` (start at `INDEX.md`). Paraphrase only; every page keeps its Sources list.
- Before adding a dependency, check `docs/encyclopedia/engines/engine-licensing-matrix.md` and add a `NOTICE.md` row in the same commit.
- Edits are surgical and hand-made. No emoji. No em dash in Markdown. Versions are `v*.*.*`.
- Tests are added when the owner asks; a change in behaviour updates its tests in the same pull request; every test follows the five rules in `docs/TESTING.md`. `./formtools test` runs them.
- Commits: author and committer `nodemode-ai <mackin@nodemode.ai>`, no attribution trailers of any kind.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.14.0 · 2026-11-23

formtools has a full test suite.

- `./formtools test` runs two layers: interface logic (vitest with happy-dom, `frontend/tests/unit`) and the engine (pytest against the real FastAPI app, `backend/tests`). `./formtools test unit` or `./formtools test engine` runs one. `docs/TESTING.md` says how to run them and what a test must do to be accepted.
- 1,244 new cases run the app and check what a user or a calling program would notice: archives read back by independent readers and equal to their source byte for byte, hashes against published vectors, picture edits against geometry, renames with nothing lost, duplicates, disk usage, hosts files, glTF read by the format's rules, the MCP surface against JSON-RPC 2.0 and agreeing with the HTTP routes, the command-line tools, and viewers, tool forms and dialogs mounted in a document. With the 90 cases that were already here, 1,334 pass.
- No app code changed. Where a test showed the app to be wrong, the test stays as a strict expected failure whose reason starts with `DEFECT:`. There are 2 such cases: the environment.d writer leaves `$` unescaped, so systemd expands it at login, where environment.d(5) says to write `$$`; and a copy job that fails because ffmpeg is missing leaves an empty reserved output file beside the source, where every other failed copy removes its output. `git grep -n "DEFECT:" backend/tests frontend/tests` lists them.
- CI runs the tests on every pull request in one job, `test`, on Linux.
- Not run for this version: the browser demo in `demo/` was not rebuilt, so its built script still says 0.13.0. Real ffmpeg, ffprobe and exiftool output was not run, only stand-in programs. The desktop shell has no tests. The tests did not run on macOS or Windows.

## 0.13.0 · 2026-11-20

The family's colour and layer names, all of them.
Expand Down
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The form* family's media and file utility belt: viewers, batch image tools, 3D v

## Stage

Released (v0.13.0), built and bundled for macOS, Windows and Linux: Phases 1 to 9 of the approved plan, with Phase 2b for formvis and the repository side of Phase 10. Run `./formtools agents sync` after changing a skill and `./formtools agents check` before committing. The plan of record (`DEV_PLAN.md`), `BUILD_NOTES.md` and the root `HASHOUT_LOG.md` ship in the planning sidecar zip; read them, then the in-tree logs (`frontend/`, `backend/`, `src-tauri/`, `setup/` `HASHOUT_LOG.md`), before changing anything. For changing the code route through `.claude/skills/formtools-harness`; for using the app through MCP, `.claude/skills/formtools-driving`.
Released (v0.14.0), built and bundled for macOS, Windows and Linux: Phases 1 to 9 of the approved plan, with Phase 2b for formvis and the repository side of Phase 10. Run `./formtools agents sync` after changing a skill and `./formtools agents check` before committing. The plan of record (`DEV_PLAN.md`), `BUILD_NOTES.md` and the root `HASHOUT_LOG.md` ship in the planning sidecar zip; read them, then the in-tree logs (`frontend/`, `backend/`, `src-tauri/`, `setup/` `HASHOUT_LOG.md`), before changing anything. For changing the code route through `.claude/skills/formtools-harness`; for using the app through MCP, `.claude/skills/formtools-driving`.

## Layout notes

Expand All @@ -22,6 +22,7 @@ Released (v0.13.0), built and bundled for macOS, Windows and Linux: Phases 1 to
- No emoji anywhere; no U+2014 em dash in Markdown (use the interpunct); near-zero comments, with context in the `HASHOUT_LOG.md` files.
- Versions are `v*.*.*` with dots.
- Vite `server.host` stays `false` with a pinned port.
- Tests are added when the owner asks; a change in behaviour updates its tests in the same pull request; every test follows the five rules in `docs/TESTING.md`. `./formtools test` runs them.

## Commits

Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ python -m compileall -q backend setup

CI also boots the engine and probes `/api/health` and `/api/capabilities`, runs
`bash -n` over the shell scripts, and fails on an em dash in tracked Markdown or an
emoji in any tracked text.
emoji in any tracked text. `./formtools test` runs the tests; `docs/TESTING.md` says
where they live and what a test must do to be accepted.

- Keep each pull request to one change.
- Write commit subjects the way the history does: `type(scope): plain sentence (X.Y.Z)`,
Expand Down
2 changes: 2 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Every dependency gets a row here with its name, version, licence and where it sh
| formvis `ffmpeg_fetch.py` and `ffmpeg_record.py`, ported to `backend/app/tools/media/fetch.py` and `record.py`, Copyright (C) 2026 NodeAgentc, Inc. | 1.98.7 | Apache-2.0 | engine |
| PyInstaller | 6.22.3 | GPL-2.0 with the bootloader exception | build tool only; the exception covers the frozen engine |
| TypeScript, Vite, @tauri-apps/cli | 7.0.2, 8.3.5, 2.12.4 | Apache-2.0, MIT, Apache-2.0 OR MIT | build tools only |
| vitest | 5.0.5 | MIT | test only, not shipped |
| happy-dom | 21.0.4 | MIT | test only, not shipped |
| The three demo folders (pictures, documents, 3D models, sounds and the Demo Pixel font) | generated | Apache-2.0, own work | made on the person's computer by `backend/app/tools/demos`; nothing is bundled in the app and no third-party picture or font is used. The browser demo pages (`demo/`, `demos/family/`, `demos/bench/`) carry the engine's recorded answers for these folders in `assets/recording.js`, made by `scripts/demo-record.py` |

## Trademarks
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version 0.13.0" src="https://img.shields.io/badge/version-0.13.0-eef0f4?style=flat-square">
<img alt="version 0.14.0" src="https://img.shields.io/badge/version-0.14.0-eef0f4?style=flat-square">
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-Vite-3178c6?style=flat-square&logo=typescript&logoColor=white">
<img alt="Python FastAPI engine" src="https://img.shields.io/badge/Python-FastAPI-009688?style=flat-square">
<img alt="macOS, Windows, Linux" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux-native-2f7bf5?style=flat-square">
Expand Down
2 changes: 1 addition & 1 deletion backend/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.13.0"
__version__ = "0.14.0"
Empty file.
19 changes: 19 additions & 0 deletions backend/tests/agents/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest


@pytest.fixture
def tab(client):
from .support import tab_token

with tab_token() as headers:
yield headers


@pytest.fixture
def no_catalogue(client):
from app.services import bridge

kept = bridge.catalogue()
bridge.mirror([])
yield
bridge.mirror(kept)
62 changes: 62 additions & 0 deletions backend/tests/agents/support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import json
from contextlib import contextmanager

ORDINARY = (-32700, -32600, -32601, -32602, -32603)


def rpc(client, method, params=None, request_id=1, headers=None):
message = {"jsonrpc": "2.0", "id": request_id, "method": method}
if params is not None:
message["params"] = params
return client.post("/mcp", json=message, headers=headers or {})


def well_formed(reply, request_id):
assert isinstance(reply, dict)
assert reply.get("jsonrpc") == "2.0"
assert reply.get("id") == request_id
assert ("result" in reply) != ("error" in reply)
if "error" in reply:
error = reply["error"]
assert isinstance(error["code"], int) and not isinstance(error["code"], bool)
assert isinstance(error["message"], str) and error["message"]
return reply


def tool_result(reply):
result = reply["result"]
assert isinstance(result["isError"], bool)
assert isinstance(result["content"], list) and result["content"]
for block in result["content"]:
assert block["type"] == "text"
assert isinstance(block["text"], str)
return result["isError"], result["content"][0]["text"]


def call(client, name, arguments=None, headers=None, request_id=7):
reply = rpc(client, "tools/call", {"name": name, "arguments": arguments if arguments is not None else {}}, request_id, headers).json()
return tool_result(well_formed(reply, request_id))


def is_sentence(text):
words = text.split()
return len(words) >= 3 and "Traceback" not in text and not text.startswith("the tool failed") and any(ch.isalpha() for ch in text)


@contextmanager
def tab_token():
from app.services import agents

token, _ = agents.issue(8240)
try:
yield {agents.INAPP_HEADER: token}
finally:
agents.revoke(token)


def listed_tools(client):
return rpc(client, "tools/list").json()["result"]["tools"]


def as_json(text):
return json.loads(text)
182 changes: 182 additions & 0 deletions backend/tests/agents/test_bridge_and_live.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import threading

import pytest


from .support import as_json, call

LOCAL = {"host": "127.0.0.1:80"}
CATALOGUE = [
{"id": "view.zoom-in", "label": "Zoom in", "group": "View", "description": "Make the picture larger", "keys": ["+"], "secret": "x"},
{"id": "view.zoom-out", "label": "Zoom out", "group": "View"},
{"id": "terminal-new", "label": "New terminal"},
{"label": "no id"},
"junk",
]


@pytest.fixture
def mirrored(client):
from app.services import bridge

kept = bridge.catalogue()
reply = client.post("/api/commands/catalogue", json={"commands": [c for c in CATALOGUE if isinstance(c, dict)]}).json()
yield reply
bridge.mirror(kept)


@pytest.fixture
def window(client):
from app.core import window_key

with client.websocket_connect("/api/live", headers=LOCAL) as ws:
ws.send_json({"t": "hello", "key": window_key.KEY})
deadline = threading.Event()
for _ in range(100):
if client.get("/api/mcp/status").json()["window"]:
break
deadline.wait(0.02)
yield ws


def run_in_background(client, tab, command, params=None):
box = {}

def work():
box["out"] = call(client, "run_command", {"id": command, **({"params": params} if params is not None else {})}, tab)

thread = threading.Thread(target=work)
thread.start()
return thread, box


def test_the_mirrored_catalogue_keeps_only_entries_with_an_id(mirrored):
assert mirrored == {"ok": True, "size": 3}


def test_list_commands_shows_window_commands_but_not_the_ones_only_a_person_runs(client, mirrored):
listing = as_json(call(client, "list_commands")[1])
ids = [c["id"] for c in listing["commands"]]
assert "view.zoom-in" in ids and "view.zoom-out" in ids
assert "terminal-new" not in ids
assert "hint" not in listing
zoom = next(c for c in listing["commands"] if c["id"] == "view.zoom-in")
assert zoom == {"id": "view.zoom-in", "title": "Zoom in", "description": "Make the picture larger"}


def test_describe_command_gives_the_window_command_its_group_and_keys_and_drops_unknown_fields(client, mirrored):
described = as_json(call(client, "describe_command", {"id": "view.zoom-in"})[1])
assert described["group"] == "View" and described["keys"] == ["+"]
assert "secret" not in described


def test_describe_command_will_not_describe_a_command_only_a_person_runs(client, mirrored):
failed, text = call(client, "describe_command", {"id": "terminal-new"})
assert failed is True and "list_commands" in text


@pytest.mark.parametrize("command", ["terminal-toggle", "terminal-new", "claude-code", "claude-chat"])
def test_run_command_refuses_a_command_only_a_person_runs_and_names_it(client, tab, window, command):
failed, text = call(client, "run_command", {"id": command}, tab)
assert failed is True
assert command in text and "person" in text


def test_run_command_refuses_an_id_the_window_does_not_have(client, tab, mirrored):
failed, text = call(client, "run_command", {"id": "view.fly"}, tab)
assert failed is True and "list_commands" in text


def test_run_command_with_no_window_says_to_open_formtools(client, tab, mirrored):
assert client.get("/api/mcp/status").json()["window"] is False
failed, text = call(client, "run_command", {"id": "view.zoom-in"}, tab)
assert failed is True
assert "No formtools window is open" in text


def test_the_status_says_a_window_is_connected_only_while_it_is(client):
from app.core import window_key

assert client.get("/api/mcp/status").json()["window"] is False
with client.websocket_connect("/api/live", headers=LOCAL) as ws:
ws.send_json({"t": "hello", "key": window_key.KEY})
seen = False
for _ in range(100):
seen = client.get("/api/mcp/status").json()["window"]
if seen:
break
threading.Event().wait(0.02)
assert seen is True
for _ in range(100):
if not client.get("/api/mcp/status").json()["window"]:
break
threading.Event().wait(0.02)
assert client.get("/api/mcp/status").json()["window"] is False


def test_a_socket_without_the_window_key_is_closed_and_never_counts_as_a_window(client):
from starlette.websockets import WebSocketDisconnect

with client.websocket_connect("/api/live", headers=LOCAL) as ws:
ws.send_json({"t": "hello", "key": "not-the-key"})
with pytest.raises(WebSocketDisconnect) as closed:
ws.receive_json()
assert closed.value.code == 4403
assert client.get("/api/mcp/status").json()["window"] is False


def test_run_command_reaches_the_window_with_its_params_and_returns_the_windows_answer(client, tab, window, mirrored):
thread, box = run_in_background(client, tab, "view.zoom-in", {"steps": 2})
event = window.receive_json()
assert event["t"] == "run" and event["command"] == "view.zoom-in" and event["params"] == {"steps": 2}
window.send_json({"t": "result", "id": event["id"], "ok": True, "result": {"zoom": 4}})
thread.join(5)
assert box["out"] == (False, '{"zoom": 4}')


def test_run_events_arrive_in_the_order_they_were_asked_each_with_its_own_id(client, tab, window, mirrored):
seen = []
for step in range(4):
thread, box = run_in_background(client, tab, "view.zoom-out", {"n": step})
event = window.receive_json()
seen.append(event)
window.send_json({"t": "result", "id": event["id"], "ok": True, "result": step * 10})
thread.join(5)
assert box["out"] == (False, str(step * 10))
assert [e["params"]["n"] for e in seen] == [0, 1, 2, 3]
assert len({e["id"] for e in seen}) == 4


def test_an_answer_for_another_id_is_ignored_and_the_right_one_completes_the_call(client, tab, window, mirrored):
thread, box = run_in_background(client, tab, "view.zoom-in")
event = window.receive_json()
window.send_json({"t": "result", "id": "r-not-this-one", "ok": True, "result": "wrong"})
window.send_json({"t": "result", "id": event["id"], "ok": True, "result": "right"})
thread.join(5)
assert box["out"] == (False, "right")


def test_a_command_the_window_fails_comes_back_as_a_tool_error_with_the_windows_words(client, tab, window, mirrored):
thread, box = run_in_background(client, tab, "view.zoom-in")
event = window.receive_json()
window.send_json({"t": "result", "id": event["id"], "ok": False, "error": "Open a picture first."})
thread.join(5)
assert box["out"] == (True, "Open a picture first.")


def test_params_that_are_not_an_object_reach_the_window_as_an_empty_object(client, tab, window, mirrored):
box = {}
thread = threading.Thread(target=lambda: box.update(out=call(client, "run_command", {"id": "view.zoom-in", "params": [1, 2]}, tab)))
thread.start()
event = window.receive_json()
assert event["params"] == {}
window.send_json({"t": "result", "id": event["id"], "ok": True, "result": None})
thread.join(5)
assert box["out"] == (False, "null")


def test_only_the_window_key_holder_can_replace_the_catalogue(bare, client, mirrored):
response = bare.post("/api/commands/catalogue", json={"commands": []})
assert response.status_code == 403
assert "window" in response.json()["error"]
assert "view.zoom-in" in [c["id"] for c in as_json(call(client, "list_commands")[1])["commands"]]
Loading
Loading