Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
- name: Engine tests
working-directory: backend
run: python -m pytest tests -q -p no:cacheprovider
- name: Third-party notices cover what ships
run: python setup/notices.py --check
- name: Document engine tests
working-directory: frontend
run: |
Expand Down
4 changes: 2 additions & 2 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Third-party notices

formpath is licensed under the Apache License 2.0 (see `LICENSE`). It includes or depends on the following works.
formpath is licensed under the Apache License 2.0 (see `LICENSE`). It includes or depends on the following works. This file is the list, with the reason each one is there; `THIRD-PARTY-NOTICES.txt` holds the full licence text of everything the app ships (the Python packages frozen into the engine, the production npm packages built into the window, every Rust crate in the desktop shell and the third-party works kept in this repository). `setup/notices.py` writes it and `python3 setup/notices.py --check` fails in CI when something that ships has no notice there.

## Included in this repository

Expand Down Expand Up @@ -51,7 +51,7 @@ Tauri links these crates unedited (no `[patch]` and no vendored copy):
| webpki-root-certs | CDLA-Permissive-2.0 | root certificates for the updater's TLS |
| r-efi | MIT OR Apache-2.0 OR LGPL-2.1-or-later | used under MIT |

The Linux AppImage also carries the build machine's WebKitGTK, GTK and GLib (LGPL-2.1-or-later) as separate shared libraries. The installers carry this file and `LICENSE`.
The Linux AppImage also carries the build machine's WebKitGTK, GTK and GLib (LGPL-2.1-or-later) as separate shared libraries. The installers carry this file, `LICENSE` and `THIRD-PARTY-NOTICES.txt` (`bundle.resources`); `THIRD-PARTY-NOTICES.txt` is also frozen into the engine, which shows it under About formpath, Third-party notices.

## Build tools, not distributed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ In the window, Window > Terminal (or the Terminal button in the title bar) opens
- **Service:** a FastAPI engine for projects, fonts, file import and export, and the MCP endpoint at `/mcp`.
- **Desktop:** a Tauri 2 shell that starts the engine as a sidecar.
- **UI:** keyed DOM patching and a pre-paint theme boot, so changes do not flash or re-render.
- **Size:** about 62,900 lines of TypeScript, 2,400 of CSS, 8,200 of Python and 800 of Rust (product code, tests excluded; `./formpath counts --check` verifies it).
- **Size:** about 62,900 lines of TypeScript, 2,400 of CSS, 8,900 of Python and 800 of Rust (product code, tests excluded; `./formpath counts --check` verifies it).
- **Tested:** Vitest suites for `.fpth`, SVG, PDF, Pathfinder and type outlines, plus pytest suites for the engine guard, consent, MCP, versions and project files.

## Download
Expand Down
24,249 changes: 24,249 additions & 0 deletions THIRD-PARTY-NOTICES.txt

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,31 @@ Both launchers expanded `%*` or `%2` to `%9` inside a parenthesised block. `cmd`

Package copied every font the document uses and said nothing about licences. It now names the copied fonts whose `fsType` restricts embedding and asks the person to check that the licence also lets them pass the font on before they share the package. No font is ever dropped: a package without its fonts opens wrong on the next computer, and whether a licence allows passing the file on is the person's reading to make, not the app's.

### app/services/agent_lookup.py, claude_code.py, agent_programs.py, setup/claude_launch.py, setup/agents.py · the finder is version 1.1.0, one Windows starter
- refers-to: app/services/agent_lookup.py :: VERSION, plain_name, batch_file, shim_target, cmd_safe, CommandLineRefused, start_argv; app/services/claude_code.py :: via_cmd, _start, argv, _chat_argv, located; app/services/agent_programs.py :: _claude_signed_in, open_terminal; setup/claude_launch.py :: via_cmd, main; setup/agents.py :: LOOKUP_HASHES, _refused, install_claude; tests/test_windows_start.py
- kind: decision
- logged: v0.63.0 · 2026-11-29

The file was replaced whole by FormVis's 1.1.0, SHA-256 `313fcd40541199c920314516026a0b225aeb4915e9a5dc26bf51d1ba05f1da8e`, and `LOOKUP_HASHES` now holds only that version. The finder itself now does what `agent_shim.py` did on top of it: it reads a program name the way Windows opens it (any letter case, trailing dots or spaces, a `::$DATA` stream name), follows npm, pnpm and bun `.cmd` shims to their node or bun script or their `.exe` and starts that with the words as an argv list, and for any other batch file refuses a word cmd.exe would change with `CommandLineRefused`, an `OSError`. It is stricter than the shim was in one way: a program path with a space may not hold `@` or be followed by a word that has a space or is empty.

Removed: `app/services/agent_shim.py` (`npm_target`, `unshim`, `through_cmd`, `plain`, `cmd_safe`, `refusal`) and `claude_code._direct` and `_wrap`. The refusals before a version check in `claude_code.located`, `agent_programs._claude_signed_in`, `setup/claude_launch.py` and `setup/agents.py` are gone because `check` and `run` go through `start_argv`, which refuses before anything starts, and `check` turns the refusal into a broken finding with its sentence.

Kept, formpath's own: `claude_code._start` turns the refusal into `ValueError`, so the tab routes answer as before; a first message cmd would change is refused with the advice to use the Chat tab; Chat passes its message on standard input when the program still starts through cmd (`via_cmd`); the launcher hands such a program its server list as a file; setup says why it does not add the MCP server.

Tests changed, and why: `tests/test_windows_start.py` called `agent_shim`; it now holds the same cases against the finder, plus pnpm and bun shims, a shim whose runner changes between lines, the spaced-path rule, `plain_name`, and a check that never starts a changed batch path. Not run: Windows, a real npm, pnpm or bun install.

### app/core/config.py, app/routers/system.py, setup/notices.py · the full third-party licence texts ship and are checked
- refers-to: app/core/config.py :: NOTICES_NAME, notices_path; app/routers/system.py :: notices, NOTICES_CAP; formpath_engine.py :: selfcheck; setup/notices.py; setup/notices_crates.py; setup/notices_texts/; tests/test_notices.py
- kind: decision
- logged: v0.63.0 · 2026-11-29

NOTICE.md lists the components; it did not carry their licence texts. `THIRD-PARTY-NOTICES.txt` at the repository root now holds them, written by `setup/notices.py` on FormDAM's model: the Python runtime's LICENSE.txt; every distribution the engine can freeze on macOS, Linux or Windows (the requirements, the extras they name, such as `uvicorn[standard]`, and what those require, with each platform's markers), with the licence files from its installed metadata; the production npm packages from `frontend/package-lock.json`; every crate the desktop shell's Cargo.lock reaches, with the licence files from the cargo registry cache, or its SPDX licence and repository with a note when the crate ships none; and five third-party works kept in the tree (the Adobe CMap files, HarfBuzz inside harfbuzz.wasm, and the Lucide, Phosphor and Remix Icon icons), whose texts are in `setup/notices_texts/`. Identical texts are printed once and referred to by number. formpath downloads no binaries, so there is no binary section.

A package that ships on another system and is not installed here is read from a wheel: `--wheels DIR`. `NOTICES_CRATE_SRC` adds unpacked crate folders to the registry cache. `--check` reads only the file, the requirements and the lock files: it fails when a pinned requirement is listed at another version, when an installed distribution of the closure, a production npm package, a locked crate or a kept work has no section, or when a section names something that no longer ships. CI runs it in the test job.

The file is frozen into the engine (`setup/freeze_backend`, `.bat`) and carried by the installers (`bundle.resources`). `GET /api/notices` answers it as plain text, 404 when the build has none, and refuses a file over 16 MB; `--selfcheck` reports `notices_bundled`.

Seen: generated on macOS with the wheels of pywinpty, pywin32-ctypes, colorama, jeepney, secretstorage, cryptography, cffi and pycparser and the one crate missing from the cache unpacked beside it; 40 Python distributions, 10 npm packages, 5 kept works and 515 crates, none without a licence statement; `--check` passes. Not run: the check on Linux or Windows, a frozen engine, a built installer.
### app/routers/mcp.py, app/core/files.py · file writes ask each time, and an existing file needs replace
- refers-to: app/routers/mcp.py :: _REPLACE, EACH_TIME_ANSWERS, _writes_files, _consent_request, _ask_caller, _call, _taken, _keep_existing, _write, _run, mcp; app/core/files.py :: write_exclusive; frontend/src/io/api.ts :: asksEachTime, consentOffers; frontend/src/automation/agent-bridge.ts :: loop; frontend/src/dock-adapter.ts :: outsideAgents.arrive; tests/test_file_write_consent.py
- kind: decision
Expand Down
9 changes: 9 additions & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import sys
from pathlib import Path

from app import __version__
Expand All @@ -16,6 +17,7 @@
SESSION_TTL_SECONDS = 24 * 60 * 60
BACKEND_DIR = Path(__file__).resolve().parents[2]
REPO_DIR = BACKEND_DIR.parent
NOTICES_NAME = "THIRD-PARTY-NOTICES.txt"


def _load_env_file() -> None:
Expand Down Expand Up @@ -77,6 +79,13 @@ def dist_dir() -> Path | None:
return candidate if (candidate / "index.html").is_file() else None


def notices_path() -> Path:
"""THIRD-PARTY-NOTICES.txt: frozen into the engine beside the window files, or at the root of a checkout."""
if getattr(sys, "frozen", False):
return Path(getattr(sys, "_MEIPASS", "")) / NOTICES_NAME
return REPO_DIR / NOTICES_NAME


def is_desktop() -> bool:
return os.environ.get("FORMPATH_DESKTOP") == "1"

Expand Down
16 changes: 16 additions & 0 deletions backend/app/routers/system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import PlainTextResponse

from app.core import config, window_key

Expand Down Expand Up @@ -26,6 +27,21 @@ def health() -> dict:
return {"status": "ok"}


NOTICES_CAP = 16 * 1024 * 1024


@router.get("/notices", response_class=PlainTextResponse)
def notices() -> PlainTextResponse:
try:
with open(config.notices_path(), encoding="utf-8") as handle:
text = handle.read(NOTICES_CAP + 1)
except OSError:
raise HTTPException(404, "The third-party notices are not in this build") from None
if len(text) > NOTICES_CAP:
raise HTTPException(500, "The third-party notices file is larger than expected")
return PlainTextResponse(text, headers={"Cache-Control": "no-store"})


@router.get("/version")
def version() -> dict:
return {"name": config.APP_NAME, "version": config.VERSION}
Expand Down
107 changes: 104 additions & 3 deletions backend/app/services/agent_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from dataclasses import dataclass, field
from pathlib import Path

VERSION = "1.0.1"
VERSION = "1.1.0"
PROGRAMS: dict = {
"claude": {"title": "Claude Code", "names": ("claude",), "setting": "claudeBin",
"install": "curl -fsSL https://claude.ai/install.sh | bash", "install_windows": "irm https://claude.ai/install.ps1 | iex",
Expand Down Expand Up @@ -359,13 +359,114 @@ def _quote(word: str, fish: bool) -> str:
return "'" + word.replace("'", "'\"'\"'") + "'"


class CommandLineRefused(OSError):
"""A word the Windows command interpreter would not pass through to the program as it is."""


BATCH_ENDINGS = (".cmd", ".bat")
RUNNERS = ("node", "bun")
_STREAM = re.compile(r"(?:::\$data)?[ .]*$", re.I)
_DP0 = r'"%(?:~dp0|dp0%)\\?([^"%\r\n]+?\.{ext})"'
_RUNNER = r'(?:"%_prog%"|(node|bun)(?:\.exe)?|"%(?:~dp0|dp0%)\\?(node|bun)\.exe")'
_SHIM_SCRIPT = re.compile(r'(?:^|&)[ \t]*@?' + _RUNNER + r'[ \t]+' + _DP0.format(ext="(?:js|cjs|mjs)") + r'[ \t]+%\*[ \t\r]*$', re.I | re.M)
_SHIM_EXE = re.compile(r'(?:^|&)[ \t]*@?' + _DP0.format(ext="exe") + r'[ \t]+%\*[ \t\r]*$', re.I | re.M)
_SHIM_SETS = re.compile(r'\bset[ \t]+"?([A-Za-z_]\w*)=', re.I)
_SHIM_PROG = re.compile(r'\bset[ \t]+"?_prog=([^"\r\n]*)', re.I)
_PROG_VALUE = re.compile(r'(?:%(?:~dp0|dp0%)\\?)?(node|bun)(?:\.exe)?', re.I)
_SHIM_OWN_VARS = frozenset({"dp0", "_prog", "pathext", "node_path"})
_CMD_REFUSED = re.compile(r'[&|<>^()!%"\x00-\x1f\x7f]')
_CMD_QUOTED = re.compile(r'[ \t]')
REFUSAL = ("Windows starts this program through the command interpreter (cmd.exe), which would change or act on the text, so it "
"was not started. Pass long or special text through standard input or a file if the program supports it, or point "
"the setting at the program's .exe or node script so it starts without the command interpreter.")


def plain_name(path: str | os.PathLike) -> str:
"""The file name as Windows opens it: lower case, without trailing dots or spaces or a ::$DATA stream name."""
return _STREAM.sub("", Path(str(path)).name).lower()


def batch_file(path: str | os.PathLike) -> bool:
"""Whether Windows would start this file through the command interpreter (.cmd or .bat in any letter case)."""
return plain_name(path).endswith(BATCH_ENDINGS)


def _beside(folder: Path, rel: str) -> Path:
return folder.joinpath(*[part for part in rel.replace("\\", "/").split("/") if part])


def _runner(text: str, named: list[str]) -> str | None:
"""The one runner (node or bun) every script line of a shim uses, or None when they disagree or one is unknown."""
progs = _SHIM_PROG.findall(text)
stems = {word.lower() for word in named if word}
if any(not word for word in named):
for value in progs:
match = _PROG_VALUE.fullmatch(value.strip())
if not match:
return None
stems.add(match.group(1).lower())
return stems.pop() if len(stems) == 1 else None


def shim_target(shim: str, env: dict | None = None) -> list[str] | None:
"""The program an npm, pnpm or bun .cmd shim runs (its script with node or bun, or its .exe), so it can be started
without the command interpreter; None when the file is not such a shim (it sets anything of its own other than
NODE_PATH, or hands %* to anything else) or its target is missing. pnpm's NODE_PATH is not carried over: node finds a
package's own dependencies from the script's folder."""
env = os.environ if env is None else env
folder = Path(shim).parent
try:
text = Path(shim).read_text(encoding="utf-8", errors="replace")[:65536]
except OSError:
return None
if any(name.lower() not in _SHIM_OWN_VARS for name in _SHIM_SETS.findall(text)):
return None
lines = _SHIM_SCRIPT.findall(text)
scripts = [_beside(folder, rel) for _bare, _dp0, rel in lines]
exes = [_beside(folder, rel) for rel in _SHIM_EXE.findall(text)]
if scripts and not exes and len(set(scripts)) == 1 and scripts[0].is_file():
runner = _runner(text, [bare or dp0 for bare, dp0, _rel in lines])
if runner is None:
return None
beside = folder / f"{runner}.exe"
found = str(beside) if beside.is_file() else shutil.which(runner, path=env.get("PATH", ""))
return [found, str(scripts[0])] if found else None
if exes and not scripts and len(set(exes)) == 1 and plain_name(exes[0]) not in ("node.exe", "bun.exe") and exes[0].is_file():
return [str(exes[0])]
return None


def cmd_safe(words: list[str]) -> None:
"""Raises CommandLineRefused unless cmd.exe /c would pass every word, the program's path included, unchanged. No word
may hold & | < > ^ ( ) ! % " or a control character: quotes do not protect a word there, so no word is let through
because it is quoted or has no spaces. A program path that needs quotes (a space or tab) keeps them only when it is
the line's one quoted word and holds no @, so such a path may not be followed by a word that needs quotes."""
words = [str(word) for word in words]
for index, word in enumerate(words):
if _CMD_REFUSED.search(word):
what = "The path of this program" if index == 0 else "A word for this program"
raise CommandLineRefused(f"{what} has one of & | < > ^ ( ) ! % \" or a control character. {REFUSAL}")
program, rest = words[0], words[1:]
if _CMD_QUOTED.search(program) and ("@" in program or any(word == "" or _CMD_QUOTED.search(word) for word in rest)):
raise CommandLineRefused("The path of this program has a space, and the command interpreter would drop its quotes when an "
f"@ is in it or another word has a space or is empty. {REFUSAL}")


def start_argv(cmd: list, env: dict | None = None, platform: str | None = None) -> list[str]:
"""How a program is started, the same for a tab, Chat and a check: through the person's login shell on macOS and Linux
(exec, so the process is the program), directly on Windows with the command interpreter in front of a .cmd or .bat."""
(exec, so the process is the program), directly on Windows. An npm, pnpm or bun .cmd shim is started as the node or bun
script or the program it names, with the words as an argv list; any other .cmd or .bat (any letter case, trailing dots
or spaces) goes through the command interpreter, only with words it passes through unchanged."""
words = [str(c) for c in cmd]
env = os.environ if env is None else env
if windows(platform):
return [env.get("COMSPEC") or "cmd.exe", "/c", *words] if words[0].lower().endswith((".cmd", ".bat")) else words
if not batch_file(words[0]):
return words
direct = shim_target(words[0], env)
if direct and not batch_file(direct[0]):
return [*direct, *words[1:]]
cmd_safe(words)
return [env.get("COMSPEC") or "cmd.exe", "/c", *words]
shell = login_shell(env, platform)
fish = Path(shell).name == "fish"
return [shell, "-l", "-c", "exec " + " ".join(_quote(w, fish) for w in words)]
Expand Down
6 changes: 2 additions & 4 deletions backend/app/services/agent_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

from app.core import config
from app.services import agent_lookup, agent_shim, claude_code, terminal
from app.services import agent_lookup, claude_code, terminal

TOKEN_VAR = "FORMPATH_INAPP_TOKEN"
PROGRAMS = {
Expand All @@ -26,8 +26,6 @@ def find(kind: str) -> str | None:
def _claude_signed_in(path: str) -> bool | None:
if os.environ.get("ANTHROPIC_API_KEY") or os.environ.get("CLAUDE_CODE_OAUTH_TOKEN"):
return True
if agent_shim.refusal([path, "auth", "status"]):
return None
try:
out = agent_lookup.run([path, "auth", "status"], claude_code.child_env(path), claude_code.CHECK_WAIT)
data = json.loads(out.stdout)
Expand Down Expand Up @@ -144,7 +142,7 @@ def open_terminal(kind: str, cols: int = 100, rows: int = 30) -> dict:
try:
if own:
write_tab_entry(own, token)
session = terminal.open_session(folder, cols, rows, program["title"], claude_code._wrap([path] + (codex_args() if kind == "codex" else [])), env, kind, token)
session = terminal.open_session(folder, cols, rows, program["title"], claude_code._start([path] + (codex_args() if kind == "codex" else [])), env, kind, token)
except BaseException:
claude_code.revoke(token)
if own:
Expand Down
Loading
Loading