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 @@ -122,6 +122,8 @@ jobs:
run: |
venv/bin/pip install -r requirements-test.txt
venv/bin/python -m pytest tests -q
- name: Third-party notices cover what ships
run: backend/venv/bin/python setup/notices.py --check

window:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

FormDesign is licensed under the Apache License 2.0 (see `LICENSE`). It includes or depends on the following works.

This file is the human ledger: what each work is and why it is there. The full licence text of everything the app ships (the Python runtime and packages frozen into the engine, the JavaScript packages built into the window, the Rust crates in the desktop shell and the layout core, and the fonts, dictionary and colour profile) is in `THIRD-PARTY-NOTICES.txt`, generated by `setup/notices.py` and checked in CI with `setup/notices.py --check`. It ships beside the app and in the frozen engine, and Preferences > General > About FormDesign shows it.

## Included in this repository

| Work | License | Where |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,6 @@ Code owners are set in [`.github/CODEOWNERS`](.github/CODEOWNERS).

## License

FormDesign is licensed under the Apache License 2.0 ([`LICENSE`](LICENSE), SPDX `Apache-2.0`). Copyright 2026 NodeAgentc, Inc. Third-party notices: [`NOTICE.md`](NOTICE.md).
FormDesign is licensed under the Apache License 2.0 ([`LICENSE`](LICENSE), SPDX `Apache-2.0`). Copyright 2026 NodeAgentc, Inc. Third-party notices: [`NOTICE.md`](NOTICE.md) (what each work is and why) and [`THIRD-PARTY-NOTICES.txt`](THIRD-PARTY-NOTICES.txt) (the full licence texts, generated by `setup/notices.py`).

<sub>FormDesign names file formats by their extension and no other application. Product names a person may associate with those formats are the trademarks of their owners; FormDesign is not affiliated with or endorsed by any of them.</sub>
36,130 changes: 36,130 additions & 0 deletions THIRD-PARTY-NOTICES.txt

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ Last updated: 2026-11-20 · no engine change in 0.93.1 (the version string only)

---

## after v0.93.1 · the shared finder is 1.1.0; THIRD-PARTY-NOTICES.txt holds the full licence texts and the engine serves it (2026-11-29)

- refers-to: app/services/agent_lookup.py (FormVis 1.1.0, never edited here); app/services/agent_programs.py :: launch; app/services/pty.py :: Terminals.create; app/services/claude_chat.py :: _run; app/core/config.py :: NOTICES_NAME, notices_path; app/routers/system.py :: NOTICES_CAP, notices; ../setup/agents.py :: LOOKUP_HASHES; ../setup/notices.py, notices_render.py, notices_crates.py, notices_wheels.py, notices_assets.py; ../setup/freeze_backend, freeze_backend.bat; tests/test_agent_lookup_windows.py; tests/test_notices.py
- kind: fix
- logged: after v0.93.1, no version yet · 2026-11-29

**The finder.** `agent_lookup.py` is FormVis's 1.1.0 byte for byte (sha256 `313fcd40541199c920314516026a0b225aeb4915e9a5dc26bf51d1ba05f1da8e`), recorded in `LOOKUP_HASHES`. On Windows it reads a program name as Windows opens it (any letter case, trailing dots or spaces, a `::$DATA` stream name), follows npm, pnpm and bun shims to their runner and script, and starts everything else through `cmd.exe /c` only when no word holds a character the interpreter acts on. A refusal is now `CommandLineRefused`, an OSError, in place of `StartRefused`, a ValueError. So `agent_programs.launch` turns it into a `ProgramError` before a token is issued (a Codex, Cursor or Antigravity tab answers the sentence), `pty` catches the new name for the Claude Code tab, and Chat's `OSError` clause already covers it. macOS and Linux behave as before. The launcher tests moved from `tests/test_reported_fixes.py` to `tests/test_agent_lookup_windows.py`: FormVis's 1.1.0 tests, the Claude Code shim with typed text, node found on PATH, and the refused tab.

**The notices.** `setup/notices.py` writes `THIRD-PARTY-NOTICES.txt` at the repo root: the Python runtime's LICENSE.txt, every Python package the engine freezes (the closure of `requirements.txt` and the macOS twin for macOS, Linux and Windows, with the `uvicorn[standard]` extras, licence files from importlib.metadata), PyInstaller (only its bootloader ships), the window's production npm packages, the crates of the desktop shell and the layout core (the closure of each Cargo.lock; licence files from the cargo registry, or the SPDX id and repository when a crate ships none), the template font library, the core's fonts, the en_US dictionary and the ICC profile. Texts that repeat are printed once at the end. A package that ships only on another platform (pywinpty, pywin32-ctypes, SecretStorage and what it needs) comes from `--wheels FOLDER`, or is kept from the previous file. `--registry-only` reads the crates' manifests without running cargo. `--check` (CI, test job) fails when a pin, a shipped package, an npm package, a crate, a font or a data file has no notice, or a notice names something that no longer ships. The freeze adds the file at the bundle root, `notices_path()` reads it there when frozen and at the repo root otherwise, and `GET /api/notices` answers it as text (404 when absent, at most 16 MiB). The installers carry it beside `LICENSE` and `NOTICE.md`.

**Seen.** `setup/notices.py --check` passes; `tests/test_notices.py` and `tests/test_agent_lookup_windows.py` pass. Not run: Windows, a frozen engine, an installer.

---

## v0.93.1 · the Windows freeze stops when a sidecar cannot be copied into src-tauri\binaries (2026-11-20)

- refers-to: setup/freeze_backend.bat (the two `copy /y` lines)
Expand Down
6 changes: 6 additions & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
REPO_ROOT = BACKEND_DIR.parent
FROZEN = getattr(sys, "frozen", False)
BUNDLE_DIR = Path(getattr(sys, "_MEIPASS", APP_DIR))
NOTICES_NAME = "THIRD-PARTY-NOTICES.txt"


def notices_path() -> Path:
return (BUNDLE_DIR if FROZEN else REPO_ROOT) / NOTICES_NAME


HOST = os.environ.get("FORMDESIGN_HOST", "127.0.0.1")
PORT = int(os.environ.get("FORMDESIGN_PORT", "8196"))
Expand Down
14 changes: 14 additions & 0 deletions backend/app/routers/system.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import platform

from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import PlainTextResponse

from app import __version__
from app.core import config, window_key
from app.engine.core import core

router = APIRouter()
NOTICES_CAP = 16 * 1024 * 1024


@router.post("/window/key")
Expand All @@ -30,6 +32,18 @@ async def version():
return {"app": "formdesign", "version": __version__, "core": core.version, "coreRunning": core.alive()}


@router.get("/notices", response_class=PlainTextResponse)
async def notices():
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("/health")
async def health():
return {"ok": core.alive(), "core": core.version, "restarts": core.restarts}
Expand Down
133 changes: 89 additions & 44 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.2"
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,69 +359,114 @@ def _quote(word: str, fish: bool) -> str:
return "'" + word.replace("'", "'\"'\"'") + "'"


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


CMD_CONTROL = re.compile(r"[\x00-\x1f\x7f]")
CMD_SPECIAL = frozenset('&|<>^()!%"')
CMD_REFUSAL = ("cannot pass through the Windows command interpreter, which rereads it even inside quotes; "
"pass long or special text through standard input or a file if the tool supports it")
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 _shim_file(folder: Path, rel: str) -> Path:
return folder.joinpath(*[part for part in re.split(r"[\\/]", rel) if part])
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 shim_target(path: str, env: dict) -> list[str] | None:
"""What an npm .cmd shim runs, so it can be started without the command interpreter: node beside the shim (or on PATH)
with the script the shim names, or the .exe the shim names. None when the file is not a shim of either shape."""
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(path).read_text(encoding="utf-8", errors="replace")
text = Path(shim).read_text(encoding="utf-8", errors="replace")[:65536]
except OSError:
return None
folder = Path(path).parent
script = re.search(r'"%_prog%"\s+"%dp0%\\([^"%]+)"\s+%\*', text)
if script:
target = _shim_file(folder, script.group(1))
beside = folder / "node.exe"
node = str(beside) if beside.is_file() else shutil.which("node", path=env.get("PATH"))
return [node, str(target)] if node and target.is_file() else None
exe = re.search(r'^\s*"%dp0%\\([^"%]+\.exe)"\s+%\*\s*$', text, re.M | re.I)
if exe:
target = _shim_file(folder, exe.group(1))
return [str(target)] if target.is_file() else 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_word(word: str) -> str:
"""A word for a command line the interpreter will read: refused when it holds a character the interpreter or a
batch file's %* would act on, quoted or not, with spaces or without."""
if CMD_CONTROL.search(word):
raise StartRefused("this text has a line break or a control character and " + CMD_REFUSAL + ".")
found = sorted({ch for ch in word if ch in CMD_SPECIAL})
if found:
raise StartRefused("this text has " + " ".join(found) + " and " + CMD_REFUSAL + ".")
return word


def _cmd_line(words: list[str]) -> list[str]:
return [_cmd_word(w) for w in words]
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. A .cmd shim is resolved to the program it runs; any other
.cmd or .bat goes through the command interpreter, and any word holding a character it would act on is refused."""
(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):
if not words[0].lower().endswith((".cmd", ".bat")):
if not batch_file(words[0]):
return words
target = shim_target(words[0], env) if words[0].lower().endswith(".cmd") else None
if target:
return [*target, *words[1:]]
return [env.get("COMSPEC") or "cmd.exe", "/d", "/v:off", "/c", *_cmd_line(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
8 changes: 6 additions & 2 deletions backend/app/services/agent_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def launch(kind: str) -> tuple[list[str], dict[str, str], str, str]:
if found.state != "runs":
raise ProgramError(agent_lookup.sentence(found, spec["install"]))
exe = found.path
try:
argv = claude_code.wrap([exe])
except agent_lookup.CommandLineRefused as exc:
raise ProgramError(f"{spec['label']} cannot start: {exc}") from None
if kind == "antigravity":
token = claude_code.issue_for(kind)
try:
Expand All @@ -142,11 +146,11 @@ def launch(kind: str) -> tuple[list[str], dict[str, str], str, str]:
except (OSError, ValueError) as exc:
claude_code.revoke(token)
raise ProgramError(f"{spec['label']} cannot be connected to FormDesign: {exc}") from None
return claude_code.wrap([exe]), claude_code.child_env(exe) | {claude_code.TOKEN_VAR: token}, str(folder), token
return argv, claude_code.child_env(exe) | {claude_code.TOKEN_VAR: token}, str(folder), token
try:
folder = claude_code.workdir()
except claude_code.ClaudeError as exc:
raise ProgramError(str(exc).replace("Claude Code", spec["label"], 1)) from None
connect(kind, folder)
token = claude_code.issue_for(kind)
return claude_code.wrap([exe]), claude_code.child_env(exe) | {claude_code.TOKEN_VAR: token}, str(folder), token
return argv, claude_code.child_env(exe) | {claude_code.TOKEN_VAR: token}, str(folder), token
4 changes: 2 additions & 2 deletions backend/app/services/claude_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from app.core import config
from app.engine.core import core
from app.services import agent_lookup, claude_code
from app.services import claude_code

NOTE = (claude_code.NOTE + " You are answering in FormDesign's Claude Code panel, which shows Markdown to people who may never have used a terminal: "
"write short paragraphs, use **bold** for panel and setting names and a bulleted list when you changed several things, avoid tables and long code blocks, "
Expand Down Expand Up @@ -175,7 +175,7 @@ def drain() -> None:
per = (ev.get("modelUsage") or {}).get(usage["model"]) or {}
usage["window"] = int(per.get("contextWindow") or usage["window"] or 0)
proc.wait(timeout=30)
except (OSError, subprocess.SubprocessError, claude_code.ClaudeError, agent_lookup.StartRefused) as e:
except (OSError, subprocess.SubprocessError, claude_code.ClaudeError) as e:
reply["error"] = f"Claude Code could not run: {e}"
finally:
STATE["proc"] = None
Expand Down
2 changes: 1 addition & 1 deletion backend/app/services/pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async def create(self, preset: str, cols: int, rows: int, prompt: str | None = N
raise ValueError(str(exc)) from None
try:
argv = claude_code.argv(found["path"], mcp_file, prompt or claude_code.prefs().get("claudeFirstMessage") or None, resume)
except agent_lookup.StartRefused as exc:
except agent_lookup.CommandLineRefused as exc:
claude_code.revoke(token)
raise ValueError(str(exc)) from None
env = claude_code.child_env(found["path"])
Expand Down
Loading
Loading