From d4f299ee576b8adb2cbd3a70b69377196b5e7531 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:30:28 -0500
Subject: [PATCH 01/18] docs(contract): add the optional fcite.call method and
fcite.addon permission
The contract gains family services through the host, with loopback only for cataloged services, and three product ids.
---
contract/CONTRACT.md | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/contract/CONTRACT.md b/contract/CONTRACT.md
index b82a25d..4fab017 100644
--- a/contract/CONTRACT.md
+++ b/contract/CONTRACT.md
@@ -23,8 +23,11 @@ The product ids are the ids in formai.studio's `catalog/products.json`:
| `formtray` | FormTray | formtray |
| `formskills` | FormSkills | formskills |
| `formportal` | FormPortal | formportal |
+| `formtxt` | FormTxt | formtxt |
+| `formcel` | FormCel | formcel |
+| `formcite` | FormCite | formcite |
-The `product` enum in both schemas lists these thirteen.
+The `product` enum in both schemas lists these sixteen.
## 2. The package (`.formpkg`)
@@ -136,6 +139,7 @@ JSON-RPC 2.0 over `postMessage`, each message an object with `"formext": 1` besi
| `files.open` | `{ accept: [".wav"], multiple?: false }` | `[{ name, type, size, data }]` with `data` base64, at most 200 MB in total; the person picks through the host's own dialog | `files-read` |
| `files.save` | `{ name, type, data }` with `data` base64 | `{ saved: true, name }`; the person picks the place through the host's own dialog. A host with no save dialog asks the person to confirm the name in its own dialog and saves into the downloads folder (`name (2).ext` when taken) | `files-write` |
| `net.fetch` | `{ url, method?, headers?, body? }` with an `https://` url | `{ status, headers, body }` with `body` base64, at most 50 MB | `network` |
+| `fcite.call` | `{ service, method, params? }` | the service's answer, as JSON (section 6a). Optional: a host without it answers -32601 | `fcite.addon`, per service |
| `ext.done` | `{ result? }` | `null`, ends a headless command | none |
`document.apply` ops use the app's own command surface, the same one its palette, command line or MCP tools use, so an extension can never do what the app itself cannot.
@@ -162,15 +166,39 @@ JSON-RPC 2.0 over `postMessage`, each message an object with `"formext": 1` besi
| -32003 | not available in this app (for example `net.fetch` in an app that has no network) |
| -32004 | the app refused the operation (the message says why, in the app's words) |
+### 6a. Family services (`fcite.call`)
+
+An extension may ask a sibling Form app on the same computer for work through one optional method, `fcite.call { service, method, params }`. The services are those of the signed family catalog, and API 1's catalog has one:
+
+| Service | App | Method | Params | The host asks |
+|---|---|---|---|---|
+| `formcite` | FormCite | `search` | `{ q, limit?, offset? }` | `GET /api/cite/v1/search` |
+| | | `get` | `{ id, as? }` | `GET /api/cite/v1/items/{id}` |
+| | | `cite` | `{ ids, style, locale?, locators? }` | `POST /api/cite/v1/cite` |
+| | | `bibliography` | `{ ids, style, locale? }` | `POST /api/cite/v1/bibliography` |
+| | | `add` | `{ text, on_duplicate? }` (a DOI, ISBN, arXiv or PubMed id) | `POST /api/cite/v1/items/from-identifier` |
+| | | `import` | `{ text, format, on_duplicate? }` | `POST /api/cite/v1/import` |
+
+Rules:
+
+- The host makes the request, never the frame. The frame's `connect-src 'none'` stays as it is.
+- Only services in the signed family catalog, and only the methods each one declares above. Any other service or method is -32602.
+- Loopback only. The host reaches the service on `127.0.0.1` at the port the service's app writes in its data folder (FormCite: `engine.json`, 8330 by default), and nowhere else: never another host name or address, never through a proxy. This is the only loopback request API 1 lets a host make for an extension; `net.fetch` stays `https://` only.
+- The extension never sees a url or a token. The host pairs with the service as an app would (FormCite: `POST /api/cite/v1/pair` with the host's own product id and name, approved by the person in FormCite's Connections view) and keeps the token itself.
+- The package names the services it wants in `services` (for example `["formcite"]`) beside the `fcite.addon` permission. A call to a service the package did not name, or that the person did not allow, is -32001.
+- When the service's app is not running or not yet paired, the call is -32003 with a plain sentence ("FormCite is not running on this computer", "FormCite has not approved this app yet"). An answer from the service that is not a success is -32004 with the service's own `detail`.
+- An older host does not know the method and answers -32601; an extension shows its own words for that and keeps working.
+
## 7. Permissions and consent
-Permissions are those of `package.schema.json`: `document`, `files-read`, `files-write`, `network`, `models`, `native-code`. The first time an extension version is activated, the host shows its own consent dialog listing what the extension asks for, in plain words:
+Permissions are those of `package.schema.json`: `document`, `files-read`, `files-write`, `network`, `models`, `native-code`, `fcite.addon`. The first time an extension version is activated, the host shows its own consent dialog listing what the extension asks for, in plain words:
- `document`: read and change the open document
- `files-read`: open files you choose
- `files-write`: save files where you choose
- `network`: reach the internet
- `models`: use local models
+- `fcite.addon`: one line per service the package names, in the host's dialog with the same Allow and Not Now: "Let {Name} search, cite and add to your FormCite library?" for `formcite`. Allow is stored per service with the rest of the permission set; a service the person did not allow answers -32001.
The host asks before it creates the extension's frame (panel or headless), so the extension's first `host.hello` already carries the granted permissions; while the dialog is open no frame exists. The person chooses Allow or Not Now. Allow is stored per id, version and permission set, and a new version or a larger permission set asks again. Not Now is not stored: the next activation asks again. Every call needing a permission that is not granted fails with -32001, and the host never prompts mid-call.
@@ -205,4 +233,4 @@ A Rust or Go host ports `formext_host.py` line for line and keeps its messages.
## 10. Versions
-API 1 is this document. A host reports `api: "1"` in `host.hello`. Anything new is added to API 1 only when it is optional and an older host can answer -32601.
+API 1 is this document. A host reports `api: "1"` in `host.hello`. Anything new is added to API 1 only when it is optional and an older host can answer -32601. `fcite.call`, the `fcite.addon` permission and the `services` field are such an addition (form.ext 0.12.0): a package that does not ask for `fcite.addon` is unaffected.
From 48133ccaa1dafe30bf717f82ef6624e3a843c8f1 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:30:28 -0500
Subject: [PATCH 02/18] feat(contract): schema accepts fcite.addon, services
and three product ids
The package schema lists formtxt, formcel and formcite and the services field.
---
contract/schema/package.schema.json | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/contract/schema/package.schema.json b/contract/schema/package.schema.json
index 9aad89b..c2b049a 100644
--- a/contract/schema/package.schema.json
+++ b/contract/schema/package.schema.json
@@ -46,7 +46,10 @@
"formmcp",
"formtray",
"formskills",
- "formportal"
+ "formportal",
+ "formtxt",
+ "formcel",
+ "formcite"
]
},
"kind": {
@@ -78,6 +81,16 @@
"$ref": "#/$defs/permission"
}
},
+ "services": {
+ "type": "array",
+ "uniqueItems": true,
+ "maxItems": 8,
+ "items": {
+ "enum": [
+ "formcite"
+ ]
+ }
+ },
"payload": {
"type": "string",
"minLength": 1
@@ -189,7 +202,8 @@
"files-write",
"network",
"models",
- "native-code"
+ "native-code",
+ "fcite.addon"
]
},
"local": {
From 6834c59671eac85e6a45db52cfdb8bb7603e95c9 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:31:18 -0500
Subject: [PATCH 03/18] feat(contract): host bridge routes fcite.call with
per-service checks
The bridge knows the family service catalog, checks the fcite.addon permission and the services a package named, and answers -32601 when the host has no service handler.
---
contract/host/host-bridge.ts | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/contract/host/host-bridge.ts b/contract/host/host-bridge.ts
index 7073a61..5c27ad8 100644
--- a/contract/host/host-bridge.ts
+++ b/contract/host/host-bridge.ts
@@ -1,4 +1,8 @@
-export type Permission = 'document' | 'files-read' | 'files-write' | 'network' | 'models' | 'native-code';
+export type Permission = 'document' | 'files-read' | 'files-write' | 'network' | 'models' | 'native-code' | 'fcite.addon';
+
+export const SERVICES: Record = {
+ formcite: { app: 'FormCite', consent: 'Let {name} search, cite and add to your FormCite library?', methods: ['search', 'get', 'cite', 'bibliography', 'add', 'import'] },
+};
export type Source = 'catalogue' | 'sideload' | 'development';
export interface PanelDef {
@@ -19,6 +23,7 @@ export interface ExtensionRecord {
version: string;
source: Source;
permissions: Permission[];
+ services?: string[];
base: string;
entryUi: string;
panels: PanelDef[];
@@ -49,6 +54,7 @@ export interface HostHandlers {
openFiles?: (ext: ExtensionRecord, accept: string[], multiple: boolean) => Promise<{ name: string; type: string; size: number; data: string }[]>;
saveFile?: (ext: ExtensionRecord, name: string, type: string, data: string) => Promise<{ saved: boolean; name: string }>;
fetch?: (ext: ExtensionRecord, req: { url: string; method?: string; headers?: Record; body?: string }) => Promise<{ status: number; headers: Record; body: string }>;
+ service?: (ext: ExtensionRecord, service: string, method: string, params: Record) => Promise;
consent: (ext: ExtensionRecord) => Promise;
storage?: { get: (ext: ExtensionRecord, key: string) => unknown; set: (ext: ExtensionRecord, key: string, value: unknown) => void };
}
@@ -76,13 +82,15 @@ const NEEDS: Record = {
'files.open': 'files-read',
'files.save': 'files-write',
'net.fetch': 'network',
+ 'fcite.call': 'fcite.addon',
};
const STORAGE_CAP = 256 * 1024;
const GRANTS_KEY = 'formext.grants';
function grantKey(ext: ExtensionRecord) {
- return `${ext.id}@${ext.version}#${[...ext.permissions].sort().join(',')}`;
+ const services = ext.permissions.includes('fcite.addon') ? `+${[...(ext.services ?? [])].sort().join(',')}` : '';
+ return `${ext.id}@${ext.version}#${[...ext.permissions].sort().join(',')}${services}`;
}
function readGrants(): Record {
@@ -144,7 +152,7 @@ export interface MountOptions {
onRequest?: (method: string, phase: 'start' | 'end') => void;
}
-const PAUSING = new Set(['files.open', 'files.save', 'app.run', 'document.apply', 'net.fetch']);
+const PAUSING = new Set(['files.open', 'files.save', 'app.run', 'document.apply', 'net.fetch', 'fcite.call']);
const HEADLESS_IDLE_MS = 120_000;
export class ExtensionHost {
@@ -358,6 +366,15 @@ export class ExtensionHost {
if (!h.fetch) throw missing();
if (typeof params.url !== 'string' || !params.url.startsWith('https://')) throw new HostError(ERR.INVALID, 'only https:// addresses');
return h.fetch(ext, params);
+ case 'fcite.call': {
+ if (!h.service) throw new HostError(ERR.NOT_FOUND, 'fcite.call is not offered by this host');
+ const svc = SERVICES[String(params.service)];
+ if (!svc) throw new HostError(ERR.INVALID, `${String(params.service)} is not a family service`);
+ if (!svc.methods.includes(String(params.method))) throw new HostError(ERR.INVALID, `${svc.app} does not accept ${String(params.method)}`);
+ if (!(ext.services ?? []).includes(params.service)) throw new HostError(ERR.PERMISSION, `${ext.name} was not allowed to use ${svc.app}`);
+ const args = params.params && typeof params.params === 'object' && !Array.isArray(params.params) ? params.params : {};
+ return h.service(ext, params.service, params.method, args);
+ }
}
throw new HostError(ERR.NOT_FOUND, method);
}
@@ -370,8 +387,14 @@ export const PERMISSION_WORDS: Record = {
network: 'Reach the internet',
models: 'Use local models',
'native-code': 'Run native code',
+ 'fcite.addon': 'Use the Form apps it names on this computer',
};
+export function serviceConsent(ext: ExtensionRecord): string[] {
+ if (!ext.permissions.includes('fcite.addon')) return [];
+ return (ext.services ?? []).filter((s) => SERVICES[s]).map((s) => SERVICES[s].consent.replace('{name}', ext.name));
+}
+
export function themeTokens(names: string[] = ['--bg', '--panel', '--text', '--muted', '--accent', '--border', '--radius']): Record {
const style = getComputedStyle(document.documentElement);
const out: Record = {};
From 80e049b81f936309731c8ddfcf1c2b6e7de65b22 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:31:18 -0500
Subject: [PATCH 04/18] feat(sdk): typed fcite.call client for family services
Extensions call formext.fcite.call with typed params and results for each FormCite method.
---
contract/sdk/formext.ts | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/contract/sdk/formext.ts b/contract/sdk/formext.ts
index 0c93037..2522dd0 100644
--- a/contract/sdk/formext.ts
+++ b/contract/sdk/formext.ts
@@ -1,4 +1,4 @@
-export type Permission = 'document' | 'files-read' | 'files-write' | 'network' | 'models' | 'native-code';
+export type Permission = 'document' | 'files-read' | 'files-write' | 'network' | 'models' | 'native-code' | 'fcite.addon';
export interface Hello {
product: string;
@@ -36,7 +36,20 @@ export const ERR = { NOT_FOUND: -32601, INVALID: -32602, PERMISSION: -32001, CAN
type Pending = { resolve: (v: unknown) => void; reject: (e: unknown) => void; timer: number };
type Handler = (params: any) => unknown;
-const LONG = new Set(['files.open', 'files.save', 'app.run', 'document.apply', 'net.fetch']);
+const LONG = new Set(['files.open', 'files.save', 'app.run', 'document.apply', 'net.fetch', 'fcite.call']);
+
+export interface FormCiteMethods {
+ search: { params: { q: string; limit?: number; offset?: number }; result: { total?: number; items: { id: string; title?: string; [k: string]: unknown }[]; [k: string]: unknown } };
+ get: { params: { id: string; as?: string }; result: Record };
+ cite: { params: { ids: string[]; style: string; locale?: string; locators?: Record }; result: Record };
+ bibliography: { params: { ids: string[]; style: string; locale?: string }; result: Record };
+ add: { params: { text: string; on_duplicate?: string }; result: Record };
+ import: { params: { text: string; format: string; on_duplicate?: string }; result: Record };
+}
+
+export interface FamilyServices {
+ formcite: FormCiteMethods;
+}
export class FormExt {
private seq = 0;
@@ -148,6 +161,10 @@ export class FormExt {
fetch(url: string, init: { method?: string; headers?: Record; body?: string } = {}) {
return this.call<{ status: number; headers: Record; body: string }>('net.fetch', { url, ...init });
}
+ readonly fcite = {
+ call: (service: S, method: M, params: FamilyServices[S][M] extends { params: infer P } ? P : never) =>
+ this.call('fcite.call', { service, method, params }),
+ };
done(result?: unknown) {
return this.call('ext.done', result === undefined ? {} : { result });
}
From db63dad45af702af8a372eaaba4c1c0b7a5c161e Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:31:57 -0500
Subject: [PATCH 05/18] feat(contract): python host checks services and calls
formcite on loopback
The resolver accepts fcite.addon with cataloged services, and FamilyService pairs and calls a sibling app on 127.0.0.1 while holding the token itself.
---
contract/host/python/formext_host.py | 97 +++++++++++++++++++++++++++-
1 file changed, 96 insertions(+), 1 deletion(-)
diff --git a/contract/host/python/formext_host.py b/contract/host/python/formext_host.py
index a0f9cc1..8ac4dac 100644
--- a/contract/host/python/formext_host.py
+++ b/contract/host/python/formext_host.py
@@ -34,7 +34,94 @@
".cube": "text/plain; charset=utf-8",
".woff2": "font/woff2",
}
-PERMISSIONS = {"document", "files-read", "files-write", "network", "models", "native-code"}
+PERMISSIONS = {"document", "files-read", "files-write", "network", "models", "native-code", "fcite.addon"}
+SERVICES = {
+ "formcite": {
+ "app": "FormCite",
+ "port_file": "engine.json",
+ "port": 8330,
+ "prefix": "/api/cite/v1",
+ "methods": {
+ "search": ("GET", "/search", ("q", "limit", "offset")),
+ "get": ("GET", "/items/{id}", ("as",)),
+ "cite": ("POST", "/cite", None),
+ "bibliography": ("POST", "/bibliography", None),
+ "add": ("POST", "/items/from-identifier", None),
+ "import": ("POST", "/import", None),
+ },
+ },
+}
+
+
+class ServiceError(Exception):
+ def __init__(self, code: int, message: str):
+ super().__init__(message)
+ self.code = code
+
+
+class FamilyService:
+ def __init__(self, service: str, host: str, name: str, port: int | None = None, token: str = ""):
+ if service not in SERVICES:
+ raise ServiceError(-32602, f"{service} is not a family service")
+ self.spec = SERVICES[service]
+ self.host, self.name, self.token = host, name, token
+ self.port = int(port or self.spec["port"])
+
+ def _http(self, method: str, path: str, body: dict | None = None, headers: dict | None = None) -> tuple[int, dict]:
+ import http.client
+ conn = http.client.HTTPConnection("127.0.0.1", self.port, timeout=30)
+ data = json.dumps(body).encode() if body is not None else None
+ h = {"content-type": "application/json", **(headers or {})}
+ try:
+ conn.request(method, self.spec["prefix"] + path, body=data, headers=h)
+ res = conn.getresponse()
+ raw = res.read()
+ except OSError:
+ raise ServiceError(-32003, f"{self.spec['app']} is not running on this computer")
+ finally:
+ conn.close()
+ try:
+ return res.status, json.loads(raw or b"null")
+ except ValueError:
+ return res.status, {"detail": raw.decode("utf-8", "replace")[:200]}
+
+ def pair(self, scope: str = "read") -> dict:
+ status, out = self._http("POST", "/pair", {"host": self.host, "name": self.name, "scope": scope})
+ if status >= 400:
+ raise ServiceError(-32004, str(out.get("detail", status)))
+ return out
+
+ def collect(self, request_id: str, secret: str) -> str:
+ status, out = self._http("GET", f"/pair/{request_id}", headers={"X-FormCite-Pair-Secret": secret})
+ if status >= 400:
+ raise ServiceError(-32004, str(out.get("detail", status)))
+ if out.get("token"):
+ self.token = out["token"]
+ return str(out.get("status", ""))
+
+ def call(self, method: str, params: dict | None = None):
+ spec = self.spec["methods"].get(method)
+ if not spec:
+ raise ServiceError(-32602, f"{self.spec['app']} does not accept {method}")
+ if not self.token:
+ raise ServiceError(-32003, f"{self.spec['app']} has not approved this app yet")
+ verb, path, query = spec
+ params = dict(params or {})
+ if "{id}" in path:
+ from urllib.parse import quote
+ path = path.replace("{id}", quote(str(params.pop("id", "")), safe=""))
+ body = None
+ if verb == "GET":
+ from urllib.parse import urlencode
+ q = {k: params[k] for k in (query or ()) if params.get(k) is not None}
+ path += ("?" + urlencode(q)) if q else ""
+ else:
+ body = params
+ status, out = self._http(verb, path, body, {"authorization": f"Bearer {self.token}"})
+ if status >= 400:
+ detail = out.get("detail") if isinstance(out, dict) else None
+ raise ServiceError(-32004, str(detail or f"{self.spec['app']} answered {status}"))
+ return out
def portal_root() -> Path:
@@ -70,6 +157,7 @@ class Extension:
kind: str = ""
description: str = ""
permissions: list[str] = field(default_factory=list)
+ services: list[str] = field(default_factory=list)
entry_ui: str = ""
panels: list[dict] = field(default_factory=list)
commands: list[dict] = field(default_factory=list)
@@ -85,6 +173,7 @@ def public(self, base: str) -> dict:
"source": self.source,
"description": self.description,
"permissions": self.permissions,
+ "services": self.services,
"base": f"{base}/{self.id}/{self.version}/",
"entryUi": self.entry_ui,
"panels": self.panels,
@@ -138,6 +227,12 @@ def refuse(reason: str) -> Extension:
if not isinstance(perms, list) or any(p not in PERMISSIONS for p in perms):
return refuse("it asks for a permission that does not exist")
ext.permissions = list(dict.fromkeys(perms))
+ services = manifest.get("services") or []
+ if not isinstance(services, list) or any(s not in SERVICES for s in services):
+ return refuse("it asks for a family service that is not in the catalog")
+ if services and "fcite.addon" not in ext.permissions:
+ return refuse("it names family services without the fcite.addon permission")
+ ext.services = list(dict.fromkeys(services))
minimum = manifest.get("minimum_app")
if minimum and version_tuple(str(minimum)) > version_tuple(app_version):
return refuse(f"it needs {app_name} {minimum} or newer")
From a720e44681c3259fbcc00974c61e4bd60f77007c Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:31:57 -0500
Subject: [PATCH 06/18] feat(contract): formpkg checks fcite.addon and its
services
The checker accepts a package naming cataloged services with fcite.addon and refuses an unknown service id.
---
contract/tools/formpkg.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/contract/tools/formpkg.py b/contract/tools/formpkg.py
index 6dae77b..d1ffd74 100644
--- a/contract/tools/formpkg.py
+++ b/contract/tools/formpkg.py
@@ -8,9 +8,10 @@
import zipfile
from pathlib import Path
-PRODUCTS = ["formvis", "formcut", "formwav", "formpdf", "formdeck", "formlit", "formmd", "formencoder", "formvfx", "formmcp", "formtray", "formskills", "formportal"]
+PRODUCTS = ["formvis", "formcut", "formwav", "formpdf", "formdeck", "formlit", "formmd", "formencoder", "formvfx", "formmcp", "formtray", "formskills", "formportal", "formtxt", "formcel", "formcite"]
KINDS = ["effect-stack", "wgsl-kernel", "audio-chain", "caption-look", "lut", "timeline-template", "script-plugin", "action-set", "preset", "theme", "native-plugin"]
-PERMISSIONS = ["document", "files-read", "files-write", "network", "models", "native-code"]
+PERMISSIONS = ["document", "files-read", "files-write", "network", "models", "native-code", "fcite.addon"]
+SERVICES = ["formcite"]
TYPES = {".html", ".js", ".mjs", ".css", ".json", ".svg", ".png", ".webp", ".jpg", ".jpeg", ".gif", ".wasm", ".txt", ".md", ".wav", ".ogg", ".mp3", ".webm", ".mp4", ".cube", ".woff2"}
ID_RE = re.compile(r"^[a-z0-9][a-z0-9-]{1,63}\Z")
LOCAL_RE = re.compile(r"^[a-z0-9][a-z0-9-]{0,31}\Z")
@@ -65,6 +66,14 @@ def problems(folder: Path) -> tuple[list[str], dict]:
perms = m.get("permissions")
if not isinstance(perms, list) or any(p not in PERMISSIONS for p in perms) or len(set(perms or [])) != len(perms or []):
out.append(f"manifest.json: permissions must be unique values from {', '.join(PERMISSIONS)}")
+ services = m.get("services")
+ if services is not None:
+ if not isinstance(services, list) or any(s not in SERVICES for s in services) or len(set(services)) != len(services):
+ out.append(f"manifest.json: services must be unique values from {', '.join(SERVICES)}")
+ elif services and "fcite.addon" not in (perms if isinstance(perms, list) else []):
+ out.append("manifest.json: services needs the fcite.addon permission")
+ if isinstance(perms, list) and "fcite.addon" in perms and not services:
+ out.append("manifest.json: fcite.addon needs services, the family services the extension calls")
if m.get("api") != "1":
out.append('manifest.json: api must be "1" (every API 1 host refuses a package without it)')
contributes = m.get("contributes") or {}
From fbd8cf4d4f721f326ba6507abcb902284caca213 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:32:38 -0500
Subject: [PATCH 07/18] feat(sim): simulated formcite service and older host
for fcite.call
Preview answers fcite.call from a canned FormCite library, and answers -32601 when the older-host switch is set.
---
frontend/src/sim/host.ts | 2 ++
frontend/src/sim/services.ts | 53 ++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
create mode 100644 frontend/src/sim/services.ts
diff --git a/frontend/src/sim/host.ts b/frontend/src/sim/host.ts
index 4dd9932..41d744a 100644
--- a/frontend/src/sim/host.ts
+++ b/frontend/src/sim/host.ts
@@ -4,6 +4,7 @@ import type { AppSim, Json, SimEmit } from './types';
import type { SimFile } from './samples';
import { tokensFor } from './tokens';
import { clone } from './util';
+import { olderHost, simService } from './services';
export interface LogEntry {
id: number;
@@ -66,6 +67,7 @@ export class SimHost {
openFiles: offers.filesOpen ? (ext, accept, multiple) => ui.openFiles(ext, accept, multiple) : undefined,
saveFile: offers.filesSave ? (ext, name, type, data) => ui.saveFile(ext, name, type, data) : undefined,
fetch: offers.fetch ? (_ext, req) => ui.fetch(req) : undefined,
+ service: olderHost() ? undefined : (_ext, service, method, params) => simService(service, method, params),
});
this.wrapDispatch();
}
diff --git a/frontend/src/sim/services.ts b/frontend/src/sim/services.ts
new file mode 100644
index 0000000..0fad018
--- /dev/null
+++ b/frontend/src/sim/services.ts
@@ -0,0 +1,53 @@
+import { HostError, ERR } from '../../../contract/host/host-bridge';
+
+const LIBRARY = [
+ { id: 'itm_sim001', type: 'article-journal', title: 'Attention Is All You Need', author: 'Vaswani, Shazeer, Parmar', year: 2017, doi: '10.48550/arXiv.1706.03762' },
+ { id: 'itm_sim002', type: 'book', title: 'The Structure of Scientific Revolutions', author: 'Kuhn', year: 1962, isbn: '9780226458083' },
+ { id: 'itm_sim003', type: 'article-journal', title: 'A Mathematical Theory of Communication', author: 'Shannon', year: 1948, doi: '10.1002/j.1538-7305.1948.tb01338.x' },
+ { id: 'itm_sim004', type: 'article-journal', title: 'Deep Residual Learning for Image Recognition', author: 'He, Zhang, Ren, Sun', year: 2016, doi: '10.1109/CVPR.2016.90' },
+ { id: 'itm_sim005', type: 'book', title: 'Thinking, Fast and Slow', author: 'Kahneman', year: 2011, isbn: '9780374275631' },
+];
+
+export const OLDER_HOST_KEY = 'formext.sim.olderHost';
+
+export function olderHost(): boolean {
+ try {
+ return localStorage.getItem(OLDER_HOST_KEY) === '1';
+ } catch {
+ return false;
+ }
+}
+
+function cite(ids: unknown) {
+ const list = Array.isArray(ids) ? ids.map(String) : [];
+ const found = LIBRARY.filter((i) => list.includes(i.id));
+ if (!found.length) throw new HostError(ERR.REFUSED, 'None of these items are in the library.');
+ return found;
+}
+
+export async function simService(service: string, method: string, params: Record): Promise {
+ if (service !== 'formcite') throw new HostError(ERR.INVALID, `${service} is not a family service`);
+ switch (method) {
+ case 'search': {
+ const q = String(params.q ?? '').trim().toLowerCase();
+ if (!q) throw new HostError(ERR.REFUSED, 'q must not be empty');
+ const hits = LIBRARY.filter((i) => `${i.title} ${i.author} ${i.year}`.toLowerCase().includes(q));
+ const offset = Math.max(0, Number(params.offset ?? 0));
+ const limit = Math.max(1, Number(params.limit ?? 25));
+ return { query: q, total: hits.length, items: hits.slice(offset, offset + limit), simulated: true };
+ }
+ case 'get': {
+ const item = LIBRARY.find((i) => i.id === params.id);
+ if (!item) throw new HostError(ERR.REFUSED, 'There is no item with this id.');
+ return item;
+ }
+ case 'cite':
+ return { style: String(params.style ?? ''), text: `(${cite(params.ids).map((i) => `${i.author.split(',')[0]} ${i.year}`).join('; ')})`, simulated: true };
+ case 'bibliography':
+ return { style: String(params.style ?? ''), entries: cite(params.ids).map((i) => `${i.author} (${i.year}). ${i.title}.`), simulated: true };
+ case 'add':
+ case 'import':
+ return { added: [], skipped: [], simulated: true, detail: 'The simulated FormCite keeps its library unchanged.' };
+ }
+ throw new HostError(ERR.INVALID, `FormCite does not accept ${method}`);
+}
From 3de74c3f36eb628487540e7cb0f1a85351e1267e Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:32:38 -0500
Subject: [PATCH 08/18] feat(contract): hello example asks formcite for a
search
The hello panel calls fcite.call search and shows the titles, or the error code when it is refused.
---
contract/examples/hello/manifest.json | 5 +++--
contract/examples/hello/ui/hello.js | 4 ++++
contract/examples/hello/ui/index.html | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/contract/examples/hello/manifest.json b/contract/examples/hello/manifest.json
index 9755682..5bed814 100644
--- a/contract/examples/hello/manifest.json
+++ b/contract/examples/hello/manifest.json
@@ -9,9 +9,10 @@
"author": "nodemode",
"licence": "Apache-2.0",
"native": false,
- "permissions": ["document"],
+ "permissions": ["document", "fcite.addon"],
+ "services": ["formcite"],
"api": "1",
- "description": "The smallest working extension: a panel that shows what the host says about itself and the open document.",
+ "description": "The smallest working extension: a panel that shows what the host says about itself and the open document, and asks FormCite for a search.",
"entry": { "ui": "ui/index.html" },
"contributes": {
"panels": [{ "id": "main", "title": "Hello", "location": "dock" }],
diff --git a/contract/examples/hello/ui/hello.js b/contract/examples/hello/ui/hello.js
index 093ce45..dfebe09 100644
--- a/contract/examples/hello/ui/hello.js
+++ b/contract/examples/hello/ui/hello.js
@@ -41,4 +41,8 @@ call('document.read', {}).then(
(doc) => (document.getElementById('doc').textContent = JSON.stringify(doc).slice(0, 160)),
(err) => (document.getElementById('doc').textContent = err.message),
);
+call('fcite.call', { service: 'formcite', method: 'search', params: { q: 'learning', limit: 3 } }).then(
+ (res) => (document.getElementById('cite').textContent = `${res.total ?? res.items.length} found: ${res.items.map((i) => i.title).join('; ') || 'nothing yet'}`),
+ (err) => (document.getElementById('cite').textContent = err.code === -32601 ? `-32601: this app cannot reach FormCite yet` : `${err.code}: ${err.message}`),
+);
document.getElementById('ping').addEventListener('click', () => call('ui.notify', { message: 'Hello from an extension', level: 'info' }));
diff --git a/contract/examples/hello/ui/index.html b/contract/examples/hello/ui/index.html
index a5e70be..06549bd 100644
--- a/contract/examples/hello/ui/index.html
+++ b/contract/examples/hello/ui/index.html
@@ -12,6 +12,7 @@
Hello
App
Extension
Document
+
FormCite
From fab630af320da3c213b0c9a58b96cad09341a784 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:38:57 -0500
Subject: [PATCH 09/18] feat(preview): consent dialog shows the per-service
fcite.addon line
The simulated host lists each named service with its own consent sentence and names fcite.call for the permission.
---
frontend/src/panes/preview/index.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/frontend/src/panes/preview/index.ts b/frontend/src/panes/preview/index.ts
index 9334b56..0184e12 100644
--- a/frontend/src/panes/preview/index.ts
+++ b/frontend/src/panes/preview/index.ts
@@ -3,7 +3,7 @@ import { icon, esc, appIcon, HOSTS, productName, storage, theme, chooseProject,
import type { PaneDef, ShellContext, ProjectRef } from '../../shell';
import { SimHost, simFor, sampleFile, accepts } from '../../sim';
import type { AppSim, SimFile } from '../../sim';
-import { HostError, ERR, PERMISSION_WORDS } from '../../../../contract/host/host-bridge';
+import { HostError, ERR, PERMISSION_WORDS, serviceConsent } from '../../../../contract/host/host-bridge';
import type { ExtensionRecord, Permission } from '../../../../contract/host/host-bridge';
import { sizeText, b64ToBytes } from '../../sim/util';
import { MessageLog, pretty, short } from './log';
@@ -27,7 +27,7 @@ const TABS: { id: Tab; label: string; icon: string }[] = [
{ id: 'document', label: 'Document', icon: 'file' },
{ id: 'permissions', label: 'Permissions', icon: 'shield' },
];
-const METHODS: Record = { document: 'document.read, document.apply, app.commands, app.run', 'files-read': 'files.open', 'files-write': 'files.save', network: 'net.fetch', models: 'nothing extra in API 1', 'native-code': 'refused by API 1 hosts' };
+const METHODS: Record = { document: 'document.read, document.apply, app.commands, app.run', 'files-read': 'files.open', 'files-write': 'files.save', network: 'net.fetch', models: 'nothing extra in API 1', 'native-code': 'refused by API 1 hosts', 'fcite.addon': 'fcite.call, for the services it names' };
function mount(el: HTMLElement, ctx: ShellContext): () => void {
el.innerHTML = `
@@ -243,7 +243,7 @@ function mount(el: HTMLElement, ctx: ShellContext): () => void {
function consent(rec: ExtensionRecord): Promise {
return dialog((box, done) => {
- box.innerHTML = `
${esc(rec.name)} would like to
${rec.permissions.map((p) => `
${icon('check', 14)}${esc(PERMISSION_WORDS[p as Permission] ?? p)}
`).join('')}
${esc(sim?.app ?? '')} asks once for version ${esc(rec.version)}. This is the simulated host's consent dialog; the extension's frame is not created until you choose.
`;
+ box.innerHTML = `
${esc(rec.name)} would like to
${rec.permissions.filter((p) => p !== 'fcite.addon').map((p) => `
${icon('check', 14)}${esc(PERMISSION_WORDS[p as Permission] ?? p)}
`).join('')}${serviceConsent(rec).map((line) => `
${icon('check', 14)}${esc(line)}
`).join('')}
${esc(sim?.app ?? '')} asks once for version ${esc(rec.version)}. This is the simulated host's consent dialog; the extension's frame is not created until you choose.
`;
box.querySelector('[data-v="yes"]')?.focus();
box.addEventListener('click', (ev) => {
const v = (ev.target as HTMLElement).closest('[data-v]')?.dataset.v;
From 3dab4ef6fb0d1839315265dd253531f19223ebb2 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:39:50 -0500
Subject: [PATCH 10/18] docs(manual): describe fcite.call in preview
The manual says how Preview answers family service calls, the denied path and the older host.
---
docs/MANUAL.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/MANUAL.md b/docs/MANUAL.md
index fff697e..f36b6e7 100644
--- a/docs/MANUAL.md
+++ b/docs/MANUAL.md
@@ -125,6 +125,7 @@ Preview runs the extension in a simulated host for its app, with the contract's
- **Inject**: Send `ext.activate` again, Send `ext.event` (the app's own events, with real-looking data), Send `ext.theme` (and the Light toggle), Close panels (`ext.deactivate`).
- **Permissions and consent**: the consent dialog appears the first time, as in the app (Allow or Not Now). Allow now and Forget consent change it at any time; turning a declared permission off runs the extension as if the manifest did not ask for it, so you can see your `-32001` handling.
- **Files and network**: `files.open` offers sample files for the app or a file from this computer; `files.save` shows the save dialog and downloads the file; `net.fetch` goes out through the engine to public `https://` addresses only.
+- **Family services**: `fcite.call { service, method, params }` (permission `fcite.addon`, with `services` in the manifest) answers from a simulated FormCite with a small canned library; turn `fcite.addon` off under Declared permissions to see -32001, and set `formext.sim.olderHost` to `1` in the window's local storage and reload to see an older host answer -32601.
- **The log**: every message both ways (extension to host, host to extension), with its time, method, params, result or error; Errors shows only failures; Copy puts the log on the clipboard as JSON.
Reload on save (on by default) reloads the extension whenever a project file is saved. Commands: Preview: Reload the extension, Preview: Undo the last simulated step.
From 2254f91e5eb057d99de9a5d96a10326be5d9f41d Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:39:58 -0500
Subject: [PATCH 11/18] docs(frontend): log how preview simulates fcite.call
The frontend log records the simulated service, the older host switch and the denied path.
---
frontend/HASHOUT_LOG.md | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/frontend/HASHOUT_LOG.md b/frontend/HASHOUT_LOG.md
index 6b194b8..11ffcbf 100644
--- a/frontend/HASHOUT_LOG.md
+++ b/frontend/HASHOUT_LOG.md
@@ -226,3 +226,11 @@ The engine asks the window before an outside agent or the command line changes a
A broken seal (the stored choice was edited outside form.ext) shows "The saved agent permission was changed outside form.ext, so it is back to Ask." in two places: a `hidden` paragraph inside the consent dialog, set before the dialog opens, and a settings note row with `when: 'agentAccessReset'`, set in `sync()` before the settings sheet is shown. Settings gains the Outside agents select (`agent_access`: Ask, Allowed, Blocked).
Checked in headless Chrome (1440 by 900, 4x CPU throttle, cache off) against Vite and a running engine: three loads, one bootstrap request in all, a write from the page succeeds after each; `/mcp` `new` answered with Allow once (ran), Deny (refused) and Always allow (ran; the choice became `allowed`); the dialog element was the same node every time and the box of `.fx-main` was the same before, during and after; no console errors. After a hand edit of `settings.json`, the sentence shows in the dialog and in Settings, and the select reads Ask.
+
+## Family services in Preview {#fcite-call}
+
+- refers-to: src/sim/services.ts · src/sim/host.ts · src/panes/preview/index.ts · ../contract/host/host-bridge.ts
+- kind: decision
+- logged: unreleased
+
+`fcite.call` reaches the simulated host through the bridge's optional `service` handler. `sim/services.ts` answers `formcite` methods from five canned items and never changes them; `add` and `import` answer an empty result marked `simulated`. The older host is the same SimHost built without a `service` handler, chosen by the `formext.sim.olderHost` local storage key read once when the host is made, so the bridge answers -32601 exactly as an API 1 host without the method. The denied path needs nothing new: turning `fcite.addon` off under Declared permissions drops it from the record and the bridge answers -32001. The consent dialog lists each named service with its own sentence from `serviceConsent` in place of the generic `fcite.addon` words. Checked in headless Chrome at 1400 by 900 with the hello example: search answered "1 found: Deep Residual Learning for Image Recognition", the denied run -32001, the older host -32601.
From affacd2a9f92845bb054b3a5aef54c5092d344be Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Fri, 27 Nov 2026 16:41:39 -0500
Subject: [PATCH 12/18] chore(release): 0.12.0
Moves every version site to 0.12.0 and adds the changelog section for the fcite.call contract addition.
---
CHANGELOG.md | 12 ++++++++++++
README.md | 2 +-
backend/app/__init__.py | 2 +-
frontend/package-lock.json | 4 ++--
frontend/package.json | 2 +-
frontend/src/demo/engine/router.ts | 2 +-
frontend/src/shell/version.ts | 2 +-
src-tauri/Cargo.lock | 2 +-
src-tauri/Cargo.toml | 2 +-
src-tauri/tauri.conf.json | 2 +-
10 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03936b6..b41d47d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,17 @@
# Changelog
+## v0.12.0 · 2026-11-27
+
+An extension can ask FormCite for sources through the host app.
+
+- **New optional contract call:** `fcite.call { service, method, params? }`, under the new permission `fcite.addon`. A package names the services it wants in a new `services` field, and the person is asked once per service: "Let {Name} search, cite and add to your FormCite library?". The one service in the catalog is `formcite`, with `search`, `get`, `cite`, `bibliography`, `add` and `import`.
+- **Who makes the request:** the host app, never the extension's frame. The host may reach `127.0.0.1` for a cataloged service only; the extension never sees an address or a token, and `net.fetch` stays https only.
+- **Answers a caller can rely on:** `-32001` when the permission or the service was not granted, `-32601` from a host that predates the call, `-32602` for an unknown service or method, `-32003` when FormCite is not running or has not approved the app, `-32004` with FormCite's own reason when it refuses.
+- **Product ids:** `formtxt`, `formcel` and `formcite` are accepted in a manifest.
+- **Preview:** carries a simulated FormCite, and the `hello` example searches it. Setting the local storage key `formext.sim.olderHost` to `1` makes Preview behave as an older host.
+- Checked here, on Linux, in a built copy: `hello` showed one found title when allowed, `-32001` with the permission turned off, and `-32601` as an older host. `formpkg.py validate` accepted `hello` and refused an unknown service id.
+- Not run for this version: `./formext test`, so it is not known whether an existing case needs the new schema values. A real, approved FormCite search through the Python host stopped at the pairing step, which needs a person to approve it in FormCite. The browser demo in `demo/` was not rebuilt. The desktop shell was not compiled. The kit in `contract/` has not been copied to the other Form apps or the registry.
+
## v0.11.0 · 2026-11-23
form.ext has a full test suite.
diff --git a/README.md b/README.md
index 9b4290d..9af202c 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@
-
+
diff --git a/backend/app/__init__.py b/backend/app/__init__.py
index ae6db5f..ea370a8 100644
--- a/backend/app/__init__.py
+++ b/backend/app/__init__.py
@@ -1 +1 @@
-__version__ = "0.11.0"
+__version__ = "0.12.0"
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index f5a624a..a27b8cd 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "formext",
- "version": "0.11.0",
+ "version": "0.12.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "formext",
- "version": "0.11.0",
+ "version": "0.12.0",
"license": "GPL-3.0-only",
"dependencies": {
"@codemirror/autocomplete": "6.20.4",
diff --git a/frontend/package.json b/frontend/package.json
index d49817f..92535c3 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "formext",
"private": true,
- "version": "0.11.0",
+ "version": "0.12.0",
"description": "form.ext: the Form family's extension studio",
"license": "GPL-3.0-only",
"type": "module",
diff --git a/frontend/src/demo/engine/router.ts b/frontend/src/demo/engine/router.ts
index e791b31..8770e8e 100644
--- a/frontend/src/demo/engine/router.ts
+++ b/frontend/src/demo/engine/router.ts
@@ -76,7 +76,7 @@ function decodeFiles(rawFiles: Json): Record {
return out;
}
-on('GET', '/api/health', () => ({ ok: true, app: 'formext', version: '0.11.0 in this page', api: '1', pid: 0, python: null, frozen: false, home: DATA, contract: 'bundled', uptime: Math.round(performance.now() / 100) / 10, live_clients: 0, routers: ['health', 'settings', 'projects', 'live', 'library', 'package', 'preview', 'publish', 'runapp', 'templates', 'validate'], router_errors: {}, frontend: 'demo', demo: true }));
+on('GET', '/api/health', () => ({ ok: true, app: 'formext', version: '0.12.0 in this page', api: '1', pid: 0, python: null, frozen: false, home: DATA, contract: 'bundled', uptime: Math.round(performance.now() / 100) / 10, live_clients: 0, routers: ['health', 'settings', 'projects', 'live', 'library', 'package', 'preview', 'publish', 'runapp', 'templates', 'validate'], router_errors: {}, frontend: 'demo', demo: true }));
on('GET', '/api/settings', () => ({ ...settings.get(), home: DATA }));
on('PUT', '/api/settings', (_m, r) => {
const patch = { ...json(r) };
diff --git a/frontend/src/shell/version.ts b/frontend/src/shell/version.ts
index 526f948..458af1f 100644
--- a/frontend/src/shell/version.ts
+++ b/frontend/src/shell/version.ts
@@ -1 +1 @@
-export const VERSION = '0.11.0';
+export const VERSION = '0.12.0';
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index a6726c3..e440eaf 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -1077,7 +1077,7 @@ dependencies = [
[[package]]
name = "formext"
-version = "0.11.0"
+version = "0.12.0"
dependencies = [
"objc2",
"objc2-app-kit",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index edad32c..af7a662 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "formext"
-version = "0.11.0"
+version = "0.12.0"
description = "form.ext desktop shell"
authors = ["NodeAgentc, Inc."]
license = "GPL-3.0-only"
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 2d34144..9006c56 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -2,7 +2,7 @@
"$schema": "https://schema.tauri.app/config/2",
"productName": "form.ext",
"mainBinaryName": "formext",
- "version": "0.11.0",
+ "version": "0.12.0",
"identifier": "ai.nodemode.formext",
"build": {
"frontendDist": "../frontend/dist",
From f0ab0661999169f4991557b537a0d08da89927fa Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Sat, 28 Nov 2026 00:06:29 -0500
Subject: [PATCH 13/18] fix(host): read the service port file before the
default port
FamilyService now reads engine.json from the service's data folder when no port is given, and falls back to the catalog port when the file is missing or unreadable.
---
contract/host/python/formext_host.py | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/contract/host/python/formext_host.py b/contract/host/python/formext_host.py
index 8ac4dac..922216f 100644
--- a/contract/host/python/formext_host.py
+++ b/contract/host/python/formext_host.py
@@ -39,6 +39,8 @@
"formcite": {
"app": "FormCite",
"port_file": "engine.json",
+ "data_env": "FORMCITE_DATA_DIR",
+ "data_dir": "~/FormCite",
"port": 8330,
"prefix": "/api/cite/v1",
"methods": {
@@ -65,7 +67,18 @@ def __init__(self, service: str, host: str, name: str, port: int | None = None,
raise ServiceError(-32602, f"{service} is not a family service")
self.spec = SERVICES[service]
self.host, self.name, self.token = host, name, token
- self.port = int(port or self.spec["port"])
+ self.port = int(port or self.discover() or self.spec["port"])
+
+ def discover(self) -> int | None:
+ raw = os.environ.get(self.spec["data_env"], "").strip()
+ for folder in [Path(raw).expanduser()] * bool(raw) + [Path(self.spec["data_dir"]).expanduser()]:
+ try:
+ found = json.loads((folder / self.spec["port_file"]).read_text("utf-8")).get("port")
+ except (OSError, ValueError, AttributeError):
+ continue
+ if type(found) is int and 0 < found < 65536:
+ return found
+ return None
def _http(self, method: str, path: str, body: dict | None = None, headers: dict | None = None) -> tuple[int, dict]:
import http.client
From 6e73037924f3b7cacc0d20e5d1b03c98421738ab Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Sat, 28 Nov 2026 00:06:29 -0500
Subject: [PATCH 14/18] docs(contract): say what an older host does with
fcite.addon
An older host's package check refuses a package that asks for fcite.addon before its bridge can answer -32601, and API 1 has no optional permission, so the contract now says to ship two builds to load on both.
---
contract/CONTRACT.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/contract/CONTRACT.md b/contract/CONTRACT.md
index 4fab017..c2570e1 100644
--- a/contract/CONTRACT.md
+++ b/contract/CONTRACT.md
@@ -187,7 +187,8 @@ Rules:
- The extension never sees a url or a token. The host pairs with the service as an app would (FormCite: `POST /api/cite/v1/pair` with the host's own product id and name, approved by the person in FormCite's Connections view) and keeps the token itself.
- The package names the services it wants in `services` (for example `["formcite"]`) beside the `fcite.addon` permission. A call to a service the package did not name, or that the person did not allow, is -32001.
- When the service's app is not running or not yet paired, the call is -32003 with a plain sentence ("FormCite is not running on this computer", "FormCite has not approved this app yet"). An answer from the service that is not a success is -32004 with the service's own `detail`.
-- An older host does not know the method and answers -32601; an extension shows its own words for that and keeps working.
+- An older host (form.ext 0.11.0 and before) does two things, and they come in this order. Its package check (`check` in `formext_host.py`, and every port of it) refuses any package whose `permissions` names `fcite.addon`, with the reason "it asks for a permission that does not exist": such a package is never loaded there, so it never reaches the bridge. Its bridge does not know `fcite.call` and answers -32601; only a package that does not ask for `fcite.addon` can see that answer.
+- API 1 has no way to mark a permission optional: `permissions` is one list, and 0.11.0 refuses any name it does not know, while it ignores fields it does not know (such as `services`). An extension that must load on both ships two builds of the package: one that asks for `fcite.addon` and names `services`, for hosts from 0.12.0, and one without either, for older hosts. The code can be the same in both: it calls `fcite.call` and, on -32601 (older host) or -32001 (not allowed), shows its own words and keeps working.
## 7. Permissions and consent
@@ -233,4 +234,4 @@ A Rust or Go host ports `formext_host.py` line for line and keeps its messages.
## 10. Versions
-API 1 is this document. A host reports `api: "1"` in `host.hello`. Anything new is added to API 1 only when it is optional and an older host can answer -32601. `fcite.call`, the `fcite.addon` permission and the `services` field are such an addition (form.ext 0.12.0): a package that does not ask for `fcite.addon` is unaffected.
+API 1 is this document. A host reports `api: "1"` in `host.hello`. Anything new is added to API 1 only when it is optional and an older host can answer -32601. `fcite.call`, the `fcite.addon` permission and the `services` field are such an addition (form.ext 0.12.0): a package that does not ask for `fcite.addon` is unaffected, and one that does is refused by an older host's package check (section 6a), so it loads only on hosts from 0.12.0.
From efe988f04692b9224b2a6a16b4c193d340d2bc63 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Sat, 28 Nov 2026 00:06:29 -0500
Subject: [PATCH 15/18] docs(contract): describe how a host finds the service
port
The contract now names engine.json, its data folder and the order explicit port, port file, catalog default, matching FamilyService.
---
contract/CONTRACT.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contract/CONTRACT.md b/contract/CONTRACT.md
index c2570e1..c30000d 100644
--- a/contract/CONTRACT.md
+++ b/contract/CONTRACT.md
@@ -183,7 +183,7 @@ Rules:
- The host makes the request, never the frame. The frame's `connect-src 'none'` stays as it is.
- Only services in the signed family catalog, and only the methods each one declares above. Any other service or method is -32602.
-- Loopback only. The host reaches the service on `127.0.0.1` at the port the service's app writes in its data folder (FormCite: `engine.json`, 8330 by default), and nowhere else: never another host name or address, never through a proxy. This is the only loopback request API 1 lets a host make for an extension; `net.fetch` stays `https://` only.
+- Loopback only. The host reaches the service on `127.0.0.1` at the port the service's app writes in its data folder, and nowhere else. FormCite's desktop app takes a new port on every launch and writes it as the integer `port` in `engine.json` in its data folder (`FORMCITE_DATA_DIR`, else `~/FormCite`). The host uses, in order: a port it was given explicitly; the `port` in that file, read from the environment's folder and then the default folder, when it is an integer from 1 to 65535; the catalog's default port (FormCite 8330). A missing or unreadable file is not an error, and the file is read when the host builds its service client. The request goes to that port only: never another host name or address, never through a proxy. This is the only loopback request API 1 lets a host make for an extension; `net.fetch` stays `https://` only.
- The extension never sees a url or a token. The host pairs with the service as an app would (FormCite: `POST /api/cite/v1/pair` with the host's own product id and name, approved by the person in FormCite's Connections view) and keeps the token itself.
- The package names the services it wants in `services` (for example `["formcite"]`) beside the `fcite.addon` permission. A call to a service the package did not name, or that the person did not allow, is -32001.
- When the service's app is not running or not yet paired, the call is -32003 with a plain sentence ("FormCite is not running on this computer", "FormCite has not approved this app yet"). An answer from the service that is not a success is -32004 with the service's own `detail`.
From 400fd7e764f7de61920173d813f73a9bee4de7cb Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Sat, 28 Nov 2026 00:06:29 -0500
Subject: [PATCH 16/18] docs(manual): say preview simulates formcite and how a
host reaches it
The manual now says Preview answers from a simulated library, what a real older host does with fcite.addon, and how a host pairs with a real FormCite through FamilyService.
---
docs/MANUAL.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/MANUAL.md b/docs/MANUAL.md
index f36b6e7..3d196cb 100644
--- a/docs/MANUAL.md
+++ b/docs/MANUAL.md
@@ -125,7 +125,7 @@ Preview runs the extension in a simulated host for its app, with the contract's
- **Inject**: Send `ext.activate` again, Send `ext.event` (the app's own events, with real-looking data), Send `ext.theme` (and the Light toggle), Close panels (`ext.deactivate`).
- **Permissions and consent**: the consent dialog appears the first time, as in the app (Allow or Not Now). Allow now and Forget consent change it at any time; turning a declared permission off runs the extension as if the manifest did not ask for it, so you can see your `-32001` handling.
- **Files and network**: `files.open` offers sample files for the app or a file from this computer; `files.save` shows the save dialog and downloads the file; `net.fetch` goes out through the engine to public `https://` addresses only.
-- **Family services**: `fcite.call { service, method, params }` (permission `fcite.addon`, with `services` in the manifest) answers from a simulated FormCite with a small canned library; turn `fcite.addon` off under Declared permissions to see -32001, and set `formext.sim.olderHost` to `1` in the window's local storage and reload to see an older host answer -32601.
+- **Family services**: `fcite.call { service, method, params }` (permission `fcite.addon`, with `services` in the manifest) answers from a simulated FormCite with a small canned library; turn `fcite.addon` off under Declared permissions to see -32001, and set `formext.sim.olderHost` to `1` in the window's local storage and reload to see an older host answer -32601. That shows the older bridge only: a real 0.11.0 host refuses a package that asks for `fcite.addon` at its package check and never loads it, so a package that must load there ships a second build without `fcite.addon` and `services` (Contract, section 6a). Preview always answers from the simulated library and cannot be pointed at a real FormCite. A real host reaches FormCite through the Python host's `FamilyService("formcite", host, name)` in `contract/host/python/formext_host.py`, which finds the port in FormCite's `engine.json` (data folder `FORMCITE_DATA_DIR`, else `~/FormCite`) and falls back to 8330. The host first asks the person in its own dialog "Let {Name} search, cite and add to your FormCite library?"; on Allow it calls `pair()`, the person approves the request in FormCite's Connections view, and `collect(request_id, secret)` stores the token, after which `call(method, params)` answers with FormCite's real library.
- **The log**: every message both ways (extension to host, host to extension), with its time, method, params, result or error; Errors shows only failures; Copy puts the log on the clipboard as JSON.
Reload on save (on by default) reloads the extension whenever a project file is saved. Commands: Preview: Reload the extension, Preview: Undo the last simulated step.
From 271062385d12b38a0d8496abd8ebd362b4b73dc3 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Sat, 28 Nov 2026 00:06:29 -0500
Subject: [PATCH 17/18] docs(backend): log the service port file and older host
findings
Records why FamilyService reads engine.json and why a package asking for fcite.addon needs a second build for 0.11.0 hosts, with what was run.
---
backend/HASHOUT_LOG.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md
index 223a7f5..cd1a2f1 100644
--- a/backend/HASHOUT_LOG.md
+++ b/backend/HASHOUT_LOG.md
@@ -343,3 +343,9 @@ The file `tab_config` writes for a Claude Code tab and for a Chat run (`AgentTok
### Check lint scanner {#lint-scanner}
`scan_js` gives two copies of a script, both the same length as the source so offsets stay lines and columns: `code` with comments blanked, and `bare` with string, template text and regular-expression contents blanked too (quotes kept, `${...}` expressions kept as code). The code rules (`fetch`, `eval`, storage, dialogs, the SDK calls) run on `bare`, so a word inside a string is never a call; an `import` counts only where `bare` still has the keyword and it is not a property (`x.import(`). A match that is followed by a parameter list and `{` is a definition, not a call (the bundled SDK's `fetch(t,n={}){...}` method). Method strings count as uses unless they are the first argument of `this.call(` or `this.on(` (the SDK's own wrappers) or items of an array made only of method strings (the SDK's long-timeout set). With these rules every first-party package (the registry's packages) checks with no problem, the minified ones included, and FX3's bad fixture gives exactly the problems it gave before. The demo's `engine/validate.ts` has the same scanner.
+
+## Family service port and older hosts {#family-port}
+
+- refers-to: contract/host/python/formext_host.py; contract/CONTRACT.md; docs/MANUAL.md
+- `FamilyService` took `port or 8330` and never read the `port_file` its own `SERVICES` row names, so it could not find a desktop FormCite, which takes a new port on every launch. The catalog row now carries `data_env` (`FORMCITE_DATA_DIR`) and `data_dir` (`~/FormCite`); `discover()` reads `engine.json` from the environment's folder, then the default folder, and takes `port` only when it is an int from 1 to 65535 (`type(...) is int`, so `true` and `"8963"` do not count). An explicit `port` wins, a missing or unreadable file falls through to the catalog port. Proved on a private FormCite engine (port 8963, its own data folder): no port given found 8963 and paired; an absent folder, a string port and broken JSON each gave 8330.
+- A 0.11.0 `check` refuses a package that names `fcite.addon` ("it asks for a permission that does not exist") and ignores the unknown `services` field, so the hello example never loads there and never sees -32601. API 1 has no optional permission, and the 0.12.0 check was left as it was; the contract tells an author to ship a second build without `fcite.addon` and `services`. Run against both checks: with `fcite.addon`, 0.11.0 refused and 0.12.0 was ready; without it, both were ready.
From e00480ba320ce048296e4a4bbfac294b98ce6671 Mon Sep 17 00:00:00 2001
From: nodemode-ai
Date: Sat, 28 Nov 2026 00:06:29 -0500
Subject: [PATCH 18/18] chore(release): 0.12.1
Every version site moves to 0.12.1 and the changelog gets its section.
---
CHANGELOG.md | 10 ++++++++++
README.md | 2 +-
backend/app/__init__.py | 2 +-
frontend/package-lock.json | 4 ++--
frontend/package.json | 2 +-
frontend/src/demo/engine/router.ts | 2 +-
frontend/src/shell/version.ts | 2 +-
src-tauri/Cargo.lock | 2 +-
src-tauri/Cargo.toml | 2 +-
src-tauri/tauri.conf.json | 2 +-
10 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b41d47d..bdb5a43 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog
+## v0.12.1 · 2026-11-27
+
+A host now finds a running FormCite by itself, and the contract says plainly what an older host does.
+
+- **Fixed:** the Python host looked for FormCite only on port 8330. FormCite's desktop app takes a new port each time it opens and writes it to `engine.json` in its data folder. `FamilyService` now uses, in order, the port it is given, the port in that file (`FORMCITE_DATA_DIR`, else `~/FormCite`), then 8330. A missing or unreadable file is skipped.
+- **Changed, contract section 6a:** a 0.11.0 host refuses a package that asks for `fcite.addon`, so that package never reaches the bridge and never sees `-32601`. Only a package that does not ask for it sees `-32601` from an older bridge. API 1 cannot mark a permission optional, so an author who needs both hosts ships two builds.
+- **Manual:** Preview always answers `fcite.call` from a simulated library. The manual now says how a real host reaches a real FormCite: the consent sentence, `pair()`, the approval in FormCite's Connections view, `collect()`, then `call()`.
+- Checked here, on Linux: joined to a real FormCite 0.13.9 engine through the host bridge and `FamilyService`, the `hello` example showed one found title after the host's consent and the approval in FormCite; `-32001` with the permission off; `-32601` from the 0.11.0 bridge; `-32004` after access was removed in FormCite and `-32003` after a pairing was denied. `FamilyService` found an engine on port 8963 from `engine.json` with no port given, and fell back to 8330 when the file was missing, broken or held a port that was not a whole number.
+- Not run for this version: `./formext test`; form.ext's own window; anything on macOS or Windows.
+
## v0.12.0 · 2026-11-27
An extension can ask FormCite for sources through the host app.
diff --git a/README.md b/README.md
index 9af202c..3cdcc15 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@