From 7702c983059b51beb97f309b42c0894cae7077b4 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Sat, 5 Dec 2026 13:46:06 -0500 Subject: [PATCH 001/160] feat(commands): reserve the guide and live link groups The command groups guide (the paged agent guide embedded in the engine) and link (live links from modelling tools) are reserved as empty modules chained into the catalogue, so the agents phase's builders own their files by path. cargo check -p fsh-commands passes. --- native/crates/fsh-commands/src/ext/guide.rs | 12 ++++++++++++ native/crates/fsh-commands/src/ext/link.rs | 12 ++++++++++++ native/crates/fsh-commands/src/ext/mod.rs | 12 +++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 native/crates/fsh-commands/src/ext/guide.rs create mode 100644 native/crates/fsh-commands/src/ext/link.rs diff --git a/native/crates/fsh-commands/src/ext/guide.rs b/native/crates/fsh-commands/src/ext/guide.rs new file mode 100644 index 00000000..b6714991 --- /dev/null +++ b/native/crates/fsh-commands/src/ext/guide.rs @@ -0,0 +1,12 @@ +//! The agent guide: paged help for agents and scripts, embedded in the engine (0.13.0). + +use super::ExtCommand; +use crate::engine::{Engine, State}; +use crate::error::Result; +use serde_json::Value; + +pub(super) static COMMANDS: &[ExtCommand] = &[]; + +pub(super) fn dispatch(_engine: &Engine, _st: &mut State, _name: &str, _args: &Value) -> Option> { + None +} diff --git a/native/crates/fsh-commands/src/ext/link.rs b/native/crates/fsh-commands/src/ext/link.rs new file mode 100644 index 00000000..d103440b --- /dev/null +++ b/native/crates/fsh-commands/src/ext/link.rs @@ -0,0 +1,12 @@ +//! Live links: modelling tools keep a group of parts in step with their own scene (0.13.0). + +use super::ExtCommand; +use crate::engine::{Engine, State}; +use crate::error::Result; +use serde_json::Value; + +pub(super) static COMMANDS: &[ExtCommand] = &[]; + +pub(super) fn dispatch(_engine: &Engine, _st: &mut State, _name: &str, _args: &Value) -> Option> { + None +} diff --git a/native/crates/fsh-commands/src/ext/mod.rs b/native/crates/fsh-commands/src/ext/mod.rs index bd245edd..f4cb9ada 100644 --- a/native/crates/fsh-commands/src/ext/mod.rs +++ b/native/crates/fsh-commands/src/ext/mod.rs @@ -13,11 +13,13 @@ pub(crate) mod configurator; pub(crate) mod denoise; mod exchange; mod graph; +mod guide; mod handoff; mod image; pub(crate) mod import; mod library; pub(crate) mod lighting; +mod link; mod materials; mod matimport; pub(crate) mod measure; @@ -68,6 +70,8 @@ pub(crate) fn commands() -> impl Iterator { .chain(web::COMMANDS.iter()) .chain(spin::COMMANDS.iter()) .chain(matimport::COMMANDS.iter()) + .chain(guide::COMMANDS.iter()) + .chain(link::COMMANDS.iter()) } /// Answers `name` when one of the groups owns it. @@ -141,5 +145,11 @@ pub(crate) fn dispatch(engine: &Engine, st: &mut State, name: &str, args: &Value if let Some(r) = spin::dispatch(engine, st, name, args) { return Some(r); } - matimport::dispatch(engine, st, name, args) + if let Some(r) = matimport::dispatch(engine, st, name, args) { + return Some(r); + } + if let Some(r) = guide::dispatch(engine, st, name, args) { + return Some(r); + } + link::dispatch(engine, st, name, args) } From 16b9bd96f4112613a2ef5d2deb5f89d18be7e3e4 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Sat, 5 Dec 2026 13:51:50 -0500 Subject: [PATCH 002/160] feat(service): reserve the scripting channel and the plugin host The packages app.scripting (the loopback scripting channel for scripts, plugins and live links) and app.plugins (the plugin host) each give an empty router and a lifespan, included in the service, so their builders own them by path. import app.main passes. --- backend/app/main.py | 6 ++++-- backend/app/plugins/__init__.py | 12 ++++++++++++ backend/app/scripting/__init__.py | 12 ++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 backend/app/plugins/__init__.py create mode 100644 backend/app/scripting/__init__.py diff --git a/backend/app/main.py b/backend/app/main.py index f777d521..712bf705 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -8,7 +8,7 @@ from fastapi.responses import FileResponse, JSONResponse from starlette.concurrency import run_in_threadpool -from app import __version__, engine_routes, notices, projects, settings, window_key +from app import __version__, engine_routes, notices, plugins, projects, scripting, settings, window_key from app.agent import agent_programs, consent from app.agent import config as agent_config from app.agent import router as agent_router @@ -30,7 +30,7 @@ @asynccontextmanager async def lifespan(app): - async with agent_router.lifespan(app): + async with agent_router.lifespan(app), scripting.lifespan(app), plugins.lifespan(app): try: yield finally: @@ -54,6 +54,8 @@ async def lifespan(app): app.include_router(output.router) app.include_router(video.router) app.include_router(exchange.router) +app.include_router(scripting.router) +app.include_router(plugins.router) @app.middleware("http") diff --git a/backend/app/plugins/__init__.py b/backend/app/plugins/__init__.py new file mode 100644 index 00000000..276bbf99 --- /dev/null +++ b/backend/app/plugins/__init__.py @@ -0,0 +1,12 @@ +"""Plugins: folders with a manifest, run by a Python host process each (0.13.0).""" + +from contextlib import asynccontextmanager + +from fastapi import APIRouter + +router = APIRouter() + + +@asynccontextmanager +async def lifespan(_app): + yield diff --git a/backend/app/scripting/__init__.py b/backend/app/scripting/__init__.py new file mode 100644 index 00000000..e6e2a3eb --- /dev/null +++ b/backend/app/scripting/__init__.py @@ -0,0 +1,12 @@ +"""The local scripting channel: a loopback JSON-lines socket for scripts, plugins and live links (0.13.0).""" + +from contextlib import asynccontextmanager + +from fastapi import APIRouter + +router = APIRouter() + + +@asynccontextmanager +async def lifespan(_app): + yield From 7c376650c6274ca6b5b2cb1f25a5158e103aface Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Sat, 5 Dec 2026 13:51:50 -0500 Subject: [PATCH 003/160] feat(setup): reserve the script command and the agents sync parts ./formshot script (setup/script and setup/script.py, also in formshot.bat) is reserved for the Python client, python/formshot is its package, and ./formshot agents sync and check now call two parts of their own, agents_guide (the guide's pages in the rendering skill) and agents_python (the Python client's command reference), which change nothing yet. ./formshot agents check stays clean. --- formshot | 2 ++ formshot.bat | 4 ++++ python/formshot/__init__.py | 1 + setup/agents.py | 9 ++++++++- setup/agents_guide.py | 7 +++++++ setup/agents_python.py | 7 +++++++ setup/script | 4 ++++ setup/script.py | 6 ++++++ 8 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 python/formshot/__init__.py create mode 100644 setup/agents_guide.py create mode 100644 setup/agents_python.py create mode 100755 setup/script create mode 100644 setup/script.py diff --git a/formshot b/formshot index 4f474c26..d38ce4fb 100755 --- a/formshot +++ b/formshot @@ -25,6 +25,7 @@ usage: ./formshot [command] [options] cad [fetch|status] download and verify the STEP and IGES reader (OpenCASCADE worker), or show whether it is installed oidn [fetch|status] download and verify Intel Open Image Denoise (the optional denoiser), or show whether it is installed mcp formshot over MCP's stdio transport, bridged to the running service's /mcp + script FILE [args] run a Python script against FormShot's scripting channel i18n extract|check collect the English interface strings, or check each language table against strings.json agents sync|check|install [--dry-run] write agents/manifest.json and the skill's tool reference (sync), validate the kit (check), or register formshot with Claude Code, Codex, Cursor and Antigravity (install) @@ -68,6 +69,7 @@ case "$cmd" in esac ;; app) exec ./build_app "$@" ;; mcp) exec python3 -I mcp/server.py "$@" ;; + script) FSH_CWD="${OLDPWD:-$PWD}" exec setup/script "$@" ;; i18n) exec python3 -I setup/i18n.py "$@" ;; agents) exec python3 -I setup/agents.py "$@" ;; notices) diff --git a/formshot.bat b/formshot.bat index b18db75a..329be635 100644 --- a/formshot.bat +++ b/formshot.bat @@ -21,6 +21,7 @@ if /i "%CMD%"=="desktop" goto desktop if /i "%CMD%"=="app" goto app if /i "%CMD%"=="doctor" goto doctor if /i "%CMD%"=="mcp" goto mcp +if /i "%CMD%"=="script" goto script if /i "%CMD%"=="cad" goto cad if /i "%CMD%"=="i18n" goto i18n if /i "%CMD%"=="agents" goto agents @@ -249,6 +250,9 @@ exit /b %FAIL% :mcp python -I mcp\server.py %2 %3 %4 %5 %6 %7 %8 %9 exit /b %errorlevel% +:script +python -I setup\script.py %2 %3 %4 %5 %6 %7 %8 %9 +exit /b %errorlevel% :cad set "PY=python" if exist backend\venv\Scripts\python.exe set "PY=backend\venv\Scripts\python.exe" diff --git a/python/formshot/__init__.py b/python/formshot/__init__.py new file mode 100644 index 00000000..a8fe5ea1 --- /dev/null +++ b/python/formshot/__init__.py @@ -0,0 +1 @@ +"""FormShot from Python: a standard-library client for the local scripting channel (0.13.0).""" diff --git a/setup/agents.py b/setup/agents.py index 94a94679..6a7d2401 100755 --- a/setup/agents.py +++ b/setup/agents.py @@ -10,6 +10,12 @@ from pathlib import Path ROOT = Path(__file__).resolve().parent.parent +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +import agents_guide # noqa: E402 +import agents_python # noqa: E402 + +EXTRAS = (agents_guide, agents_python) SKILL_NAME = "formshot-rendering" SKILL = ROOT / ".claude" / "skills" / SKILL_NAME MIRROR = ROOT / ".agents" / "skills" / SKILL_NAME @@ -157,6 +163,7 @@ def files_under(base: Path) -> dict: def sync(check: bool) -> int: cat = catalogue() + extra = [part.sync(ROOT, cat, check) for part in EXTRAS] manifest = manifest_text(cat) stale = not MANIFEST.exists() or MANIFEST.read_text(encoding="utf-8") != manifest if not SKILL.is_dir(): @@ -173,7 +180,7 @@ def sync(check: bool) -> int: say("the rendering skill's tool reference has drifted; run ./formshot agents sync" if drift else "tool reference up to date") if stale: say("agents/manifest.json is not what the engine's commands and the skills folder say; run ./formshot agents sync") - return 1 if drift or stale else 0 + return 1 if drift or stale or any(extra) else 0 wrote = [] if SKILL.is_dir(): REFERENCE.parent.mkdir(parents=True, exist_ok=True) diff --git a/setup/agents_guide.py b/setup/agents_guide.py new file mode 100644 index 00000000..cd633266 --- /dev/null +++ b/setup/agents_guide.py @@ -0,0 +1,7 @@ +"""The agent guide's pages in the rendering skill, kept in step by ./formshot agents sync (0.13.0).""" + +from pathlib import Path + + +def sync(root: Path, cat: dict, check: bool) -> bool: + return False diff --git a/setup/agents_python.py b/setup/agents_python.py new file mode 100644 index 00000000..5c75a721 --- /dev/null +++ b/setup/agents_python.py @@ -0,0 +1,7 @@ +"""The Python client's command reference, kept in step by ./formshot agents sync (0.13.0).""" + +from pathlib import Path + + +def sync(root: Path, cat: dict, check: bool) -> bool: + return False diff --git a/setup/script b/setup/script new file mode 100755 index 00000000..a7733ec6 --- /dev/null +++ b/setup/script @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e +source "$(dirname "$0")/lib.sh" +exec python3 -I "$FSH_ROOT/setup/script.py" "$@" diff --git a/setup/script.py b/setup/script.py new file mode 100644 index 00000000..caa7381e --- /dev/null +++ b/setup/script.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +import sys + +if __name__ == "__main__": + print("[formshot] script: the scripting channel arrives in 0.13.0", file=sys.stderr) + sys.exit(2) From f52ddfee862dd9535e4a682bc31588d33779ba9d Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Sat, 5 Dec 2026 13:51:50 -0500 Subject: [PATCH 004/160] feat(ui): reserve the console and plugins modules Empty entry modules for the script console and the plugins window join the fixed module list, so their builders own them by path. tsc --noEmit passes. --- frontend/src/modules.ts | 4 ++++ frontend/src/ui/console/index.ts | 5 +++++ frontend/src/ui/plugins/index.ts | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 frontend/src/ui/console/index.ts create mode 100644 frontend/src/ui/plugins/index.ts diff --git a/frontend/src/modules.ts b/frontend/src/modules.ts index 0a3bb5f1..31d45da6 100644 --- a/frontend/src/modules.ts +++ b/frontend/src/modules.ts @@ -13,6 +13,8 @@ import { mount as shortcuts } from './ui/shortcuts/index'; import { mount as workspaces } from './ui/workspaces/index'; import { mount as present } from './ui/present/index'; import { mount as exchange } from './ui/exchange/index'; +import { mount as scriptConsole } from './ui/console/index'; +import { mount as plugins } from './ui/plugins/index'; export const MODULES: readonly ShellModule[] = [ { id: 'workspace', mount: workspace }, @@ -29,4 +31,6 @@ export const MODULES: readonly ShellModule[] = [ { id: 'workspaces', mount: workspaces }, { id: 'present', mount: present }, { id: 'exchange', mount: exchange }, + { id: 'console', mount: scriptConsole }, + { id: 'plugins', mount: plugins }, ]; diff --git a/frontend/src/ui/console/index.ts b/frontend/src/ui/console/index.ts new file mode 100644 index 00000000..1f68b1db --- /dev/null +++ b/frontend/src/ui/console/index.ts @@ -0,0 +1,5 @@ +import type { ModuleContext } from '../../shell/app-shell'; + +export function mount(_ctx: ModuleContext): void { + return; +} diff --git a/frontend/src/ui/plugins/index.ts b/frontend/src/ui/plugins/index.ts new file mode 100644 index 00000000..1f68b1db --- /dev/null +++ b/frontend/src/ui/plugins/index.ts @@ -0,0 +1,5 @@ +import type { ModuleContext } from '../../shell/app-shell'; + +export function mount(_ctx: ModuleContext): void { + return; +} From 03d546627de482de873d5dc1f65cba4702027af1 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Sat, 5 Dec 2026 14:07:43 -0500 Subject: [PATCH 005/160] feat(service): headless consent and the folders agents may use A service started with FORMSHOT_HEADLESS=1 serves no window files and says headless: true in /api/health. With no window to ask, consent follows the new setting agents.headless (allow by default, or refuse, which keeps reads only). In a headless service every file an outside command reads or writes must lie in the projects folder, the agent output folder (/.formshot/agent-output, 0700), the temporary folder, the material library or FORMSHOT_AGENT_PATHS, and renders and exports sent without a target land in the agent output folder. consent.outside is the one gate for outside engine commands and /api/agent uses it; a window-attached service keeps its rules. The settings agents.headless, agents.mcp_profile and scripting.enabled are validated in settings.json. Ran against the base13 release engine on port 8341: refusals for files outside, relative paths, escaping links and OpenColorIO configs, the default targets for render.still, export.model and render.queue_add, the refuse setting, and window mode unchanged including a prompt released with once. --- backend/HASHOUT_LOG.md | 22 ++++++ backend/app/agent/consent.py | 21 ++++- backend/app/agent/paths.py | 146 +++++++++++++++++++++++++++++++++++ backend/app/main.py | 22 +++--- backend/app/settings.py | 30 +++++++ 5 files changed, 230 insertions(+), 11 deletions(-) create mode 100644 backend/app/agent/paths.py diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md index cf06de0a..ea924230 100644 --- a/backend/HASHOUT_LOG.md +++ b/backend/HASHOUT_LOG.md @@ -38,6 +38,7 @@ backend/ app/routers/exchange.py /api/exchange/exports (service export folders, download as file or ZIP, delete), /materials (material uploads) app/agent/ agent bus: config, events, commands, router, terminal, cmd_terminal, claude_code, agent_programs, cmd_agents, cmd_chat, cmd_prefs (with preferences files), external, consent, agent_lookup + app/agent/paths.py headless flag, /.formshot and agent-output, the folders agents may use, default output targets ``` ## Contents @@ -52,6 +53,7 @@ backend/ - [Verification](#verification) - [Preferences files](#preferences-files) - [Exchange routes](#exchange-routes) +- [Headless service](#headless-service) ## Layout and names @@ -279,3 +281,23 @@ The model upload refuses `.mtlx` and `.zip` as a main file and has no main for a - kind: verification - logged: v0.12.0 · 2026-12-04 `MESH_SUFFIXES` and `MESH_WORDS` gained `.3dm` and `.ifc` (the USD suffixes were already there), which the import upload and folder scan read. `python -m py_compile` on both files and `import app.main` clean. Against the service on 127.0.0.1:8331 with curl: create, delete and the material upload answer 403 without the window key; a download without key or ticket 403, with a ticket 200 (the file, `model/obj`), with the key 200; a folder as ZIP held `site/index.html` and `site/images/a.jpg`, the whole export held the file and the folder; `../../x` 400, a link to /etc inside the folder 400, a dot-named staging file 404, an unknown path 404; a material upload of two nested maps 200 with `set/...` names, a `.txt` 400, a name climbing out 400; no temporary ZIP was left after the downloads. The browser window then exported every model format, a web configurator and a spin viewer through these routes and downloaded them (see `frontend/HASHOUT_LOG.md`, Exchange in the window). Not run: Windows paths, a download interrupted halfway. + +## Headless service + +### app/agent/paths.py, app/main.py · a service without its window +- refers-to: app/agent/paths.py :: headless, home, formshot_dir, output_dir, allowed, library, refusal, prepare, FILE_DEFAULTS, FOLDER_DEFAULTS; app/main.py :: health, frontend_files, agent +- kind: decision +- logged: v0.13.0 · 2026-12-05 +`FORMSHOT_HEADLESS=1` (or `FSH_HEADLESS`, through `config.env`) makes the service headless: `/api/health` answers `headless: true` and `frontend_files` answers 404 for every path, so no window can be served from it. `paths.headless()` is the one test, so the scripting channel's discovery file and the MCP endpoint read the same flag. `` is `FORMSHOT_HOME` else the user's home (contract A's rule), and `output_dir()` makes `/.formshot/agent-output` with mode 0700 and resets the mode of both folders on every call, since a folder made earlier by another part may have been made 0755. The allowed folders are the projects folder, the output folder, `tempfile.gettempdir()`, `FORMSHOT_AGENT_PATHS` split on `os.pathsep`, and the library folders: built-in studio presets are applied by file path (`studio.apply {preset: "/studios/x.json"}`, the path `studio.list` gives), so without the library an agent could not apply a studio at all. Those folders come from the engine's own `studio.list` (`library` and the parent of `user_folder`), asked once and kept, because only the engine knows where it found its library (`FORMSHOT_LIBRARY`, beside the program, or above it). Every candidate and every checked path goes through `os.path.realpath`, so a link inside an allowed folder that points out of it is refused. The keys checked were found by walking every catalogue schema at 0.12.0: `path`, `folder`, `out`, `project` and `preset` string values at any depth, `config` under `ocio`, and the config part of `ocio:` tone map strings; nothing else names a file. Relative paths are refused rather than resolved, because the engine resolves some against the document's folder (`light.ies_info`, `studio.capture`), which the service does not know; `fshot:` project members pass. `prepare` fills a missing target of the writing commands into the output folder with a time stamp and a free suffix, using `format` as the extension when it is a plain word; folder renders share the output folder (their names come from the job's template), while frame sequences, web pages and spin viewers get a fresh folder each since they write many files. + +### app/agent/consent.py, app/settings.py · consent when no window can ask +- refers-to: app/agent/consent.py :: permit, outside, HEADLESS_REFUSED; app/settings.py :: HEADLESS, MCP_PROFILE, SCRIPTING, read, clean, headless_choice, mcp_profile, scripting_enabled; app/main.py :: agent +- kind: decision +- logged: v0.13.0 · 2026-12-05 +The three settings of contract B are flat keys with a dot in `settings.json` (`agents.headless`, `agents.mcp_profile`, `scripting.enabled`), because `agents` is already the consent choice string and cannot hold an object; `read()` fills their defaults (allow, standard, true) and `clean()` refuses other values with 400 so a bad Preferences row cannot store one. `permit` keeps its order: `blocked` refuses, `allowed` passes, and only then does a headless service answer from `agents.headless` (allow passes, refuse gives `HEADLESS_REFUSED`) where a window service would look for a live window; so a window-attached service behaves exactly as before. `outside(agent, name, args, tab)` is the whole gate for engine commands from outside: `blocked` first, then in a headless service `paths.prepare` and `paths.refusal` for every command, read-only ones too (a read can leak a file), then read-only commands and tab tokens pass and the rest go to `permit`. It returns the arguments to dispatch with the refusal, so a filled-in render target reaches the engine. `/api/agent` now calls it for engine targets; the window target keeps its old branch (blocked, then a prompt unless a tab token). `routers/mcp.py` belongs to the MCP tools work; its `call_tool` still calls `permit` directly, which gives the headless consent but not the folder rule until it calls `outside` instead. + +### Headless service · what ran +- refers-to: app/agent/paths.py; app/agent/consent.py; app/settings.py; app/main.py +- kind: verification +- logged: v0.13.0 · 2026-12-05 +With the base13 release engine, `HOME` and the data folder under the run folder, on 127.0.0.1:8341 (curl to `/api/agent`): headless health answered `headless: true` and `GET /` 404; `file.open` of a GLB in /tmp ran; the same file in a scratch folder, a relative path, `import.probe /etc/passwd` (read-only), a link in /tmp pointing at the scratch folder, `render.still` with an `ocio:/etc/config.ocio` tone map, `image.set` with an `ocio.config` outside and `studio.apply` with a preset outside were each refused with the sentence naming the folders; `studio.apply` of the built-in `dark-hero.json` by path ran; `render.still`, `export.model {format: obj}` and `render.queue_add` without targets wrote `render-