Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d4f299e
docs(contract): add the optional fcite.call method and fcite.addon pe…
nodemode-ai Nov 27, 2026
48133cc
feat(contract): schema accepts fcite.addon, services and three produc…
nodemode-ai Nov 27, 2026
6834c59
feat(contract): host bridge routes fcite.call with per-service checks
nodemode-ai Nov 27, 2026
80e049b
feat(sdk): typed fcite.call client for family services
nodemode-ai Nov 27, 2026
db63dad
feat(contract): python host checks services and calls formcite on loo…
nodemode-ai Nov 27, 2026
a720e44
feat(contract): formpkg checks fcite.addon and its services
nodemode-ai Nov 27, 2026
fbd8cf4
feat(sim): simulated formcite service and older host for fcite.call
nodemode-ai Nov 27, 2026
3de74c3
feat(contract): hello example asks formcite for a search
nodemode-ai Nov 27, 2026
fab630a
feat(preview): consent dialog shows the per-service fcite.addon line
nodemode-ai Nov 27, 2026
3dab4ef
docs(manual): describe fcite.call in preview
nodemode-ai Nov 27, 2026
2254f91
docs(frontend): log how preview simulates fcite.call
nodemode-ai Nov 27, 2026
affacd2
chore(release): 0.12.0
nodemode-ai Nov 27, 2026
f0ab066
fix(host): read the service port file before the default port
nodemode-ai Nov 28, 2026
6e73037
docs(contract): say what an older host does with fcite.addon
nodemode-ai Nov 28, 2026
efe988f
docs(contract): describe how a host finds the service port
nodemode-ai Nov 28, 2026
400fd7e
docs(manual): say preview simulates formcite and how a host reaches it
nodemode-ai Nov 28, 2026
2710623
docs(backend): log the service port file and older host findings
nodemode-ai Nov 28, 2026
e00480b
chore(release): 0.12.1
nodemode-ai Nov 28, 2026
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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# 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.

- **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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</p>

<p align="center">
<img alt="version 0.11.0" src="https://img.shields.io/badge/version-0.11.0-4f6bff?style=flat-square">
<img alt="version 0.12.1" src="https://img.shields.io/badge/version-0.12.1-4f6bff?style=flat-square">
<img alt="Python FastAPI engine" src="https://img.shields.io/badge/Python-FastAPI%20engine-3776ab?style=flat-square&logo=python&logoColor=white">
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-interface-3178c6?style=flat-square">
<img alt="Tauri 2" src="https://img.shields.io/badge/Tauri-2-24C8DB?style=flat-square">
Expand Down
6 changes: 6 additions & 0 deletions backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion backend/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.0"
__version__ = "0.12.1"
35 changes: 32 additions & 3 deletions contract/CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down Expand Up @@ -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.
Expand All @@ -162,15 +166,40 @@ 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, 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`.
- 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

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.

Expand Down Expand Up @@ -205,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.
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.
5 changes: 3 additions & 2 deletions contract/examples/hello/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" }],
Expand Down
4 changes: 4 additions & 0 deletions contract/examples/hello/ui/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }));
1 change: 1 addition & 0 deletions contract/examples/hello/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>Hello</h1>
<dt>App</dt><dd id="app">&nbsp;</dd>
<dt>Extension</dt><dd id="ext">&nbsp;</dd>
<dt>Document</dt><dd id="doc">&nbsp;</dd>
<dt>FormCite</dt><dd id="cite">&nbsp;</dd>
</dl>
<button id="ping" type="button">Notify</button>
</main>
Expand Down
Loading
Loading