diff --git a/.agents/skills/formchem-harness/EVALS.json b/.agents/skills/formchem-harness/EVALS.json
index e5060c3b..539c7426 100644
--- a/.agents/skills/formchem-harness/EVALS.json
+++ b/.agents/skills/formchem-harness/EVALS.json
@@ -1,6 +1,6 @@
{
"skill_name": "formchem-harness",
- "notes": "Run with the FormChem engine and window open (./formchem) and the formchem MCP server connected with the agent token, version 0.12.0. Expected behaviours are observable in the tool calls and the final answer. FormChem 0.12.0 has 77 tools: agents draw with draw_from_smiles, draw_from_molfile, draw_from_name and add_reaction, edit by id with get_atoms and the 14 edit tools, check with render, get_structure and validate, name with name_structure, predict NMR with predict_nmr and predict_spectrum, work on spectra with open_spectrum and the spectrum tools, work in 3D with build_3d, conformers_3d, minimise_3d, scan_dihedral, measure_3d, open_3d_structure, extract_ligand and export_3d, work with structure databases and the notebook with db_list, db_create, db_open, db_import, db_search, db_get_record, db_add_record, db_update_record, db_export, nb_add_entry and nb_search, keep the shared structure library with library_list, library_add and live_structure_object, draw biopolymers with draw_from_helm, run xtb and CREST (only when installed) with xtb_optimise and crest_conformers, and still reach the window's commands, reactions, analysis and extensions; several evals check that the agent draws with the tools and checks before it claims. Evals 13 and 14 need a drawn esterification scheme (acetic acid + ethanol, arrow, ethyl acetate + water); evals 15 to 18 need ibuprofen inserted with insert-smiles CC(C)Cc1ccc(cc1)[C@@H](C)C(=O)O; eval 20 needs an SD file at the path it names; eval 28 needs ethyl acetate drawn; eval 29 needs a JCAMP-DX 1H NMR file of ethanol at the path it names; eval 33 needs a PDB file with a protein chain and a benzamidine ligand (BEN) at the path it names; eval 34 needs butane drawn; evals 36 to 40 need an SD file of a few hundred structures, one of them with a broken connection table, at the path eval 36 names, and evals 37 to 40 the database eval 36 makes; eval 44 needs ethanol drawn and eval 45 butane, and both should be run once with xtb and CREST installed and once without them.",
+ "notes": "Run with the FormChem engine and window open (./formchem) and the formchem MCP server connected with the agent token, version 0.14.0. Expected behaviours are observable in the tool calls and the final answer. FormChem 0.14.0 has 104 tools (the 27 of 0.14.0 add pages, object boxes, agent undo, fuse_ring and attach_template, the scheme layout tools, standardise, balance_reaction, isotope_pattern, export_helm, predict_ir_bands, predict_ms_fragments, the abbreviation tools and the 3D surface, terms, rotation, repair, render and PDB tools); evals 48 to 52 need a drawing open with, in order, an esterification scheme with a conditions text, benzene, any structure, nothing, and a primary amine. Of the earlier tools: agents draw with draw_from_smiles, draw_from_molfile, draw_from_name and add_reaction, edit by id with get_atoms and the 14 edit tools, check with render, get_structure and validate, name with name_structure, predict NMR with predict_nmr and predict_spectrum, work on spectra with open_spectrum and the spectrum tools, work in 3D with build_3d, conformers_3d, minimise_3d, scan_dihedral, measure_3d, open_3d_structure, extract_ligand and export_3d, work with structure databases and the notebook with db_list, db_create, db_open, db_import, db_search, db_get_record, db_add_record, db_update_record, db_export, nb_add_entry and nb_search, keep the shared structure library with library_list, library_add and live_structure_object, draw biopolymers with draw_from_helm, run xtb and CREST (only when installed) with xtb_optimise and crest_conformers, and still reach the window's commands, reactions, analysis and extensions; several evals check that the agent draws with the tools and checks before it claims. Evals 13 and 14 need a drawn esterification scheme (acetic acid + ethanol, arrow, ethyl acetate + water); evals 15 to 18 need ibuprofen inserted with insert-smiles CC(C)Cc1ccc(cc1)[C@@H](C)C(=O)O; eval 20 needs an SD file at the path it names; eval 28 needs ethyl acetate drawn; eval 29 needs a JCAMP-DX 1H NMR file of ethanol at the path it names; eval 33 needs a PDB file with a protein chain and a benzamidine ligand (BEN) at the path it names; eval 34 needs butane drawn; evals 36 to 40 need an SD file of a few hundred structures, one of them with a broken connection table, at the path eval 36 names, and evals 37 to 40 the database eval 36 makes; eval 44 needs ethanol drawn and eval 45 butane, and both should be run once with xtb and CREST installed and once without them; eval 47 needs a database at /tmp/fc-eval/compounds.fcdb.",
"evals": [
{
"id": 1,
@@ -523,6 +523,83 @@
"When CREST runs, quotes the relative energies and populations with the program label and how many conformers were dropped for lost stereo",
"Offers conformers_3d with MMFF94 only as a clearly named alternative, after asking"
]
+ },
+ {
+ "id": 46,
+ "name": "show-demos",
+ "prompt": "I'm new to FormChem. Show me some examples I can start from.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_context, then run_command with id demos (Help > Demos)",
+ "Tells the person Home now shows five demos (aspirin, the two-step aspirin synthesis, the enantiomers, cholesterol in 3D, benzocaine with its 1H NMR) and that clicking one opens a new unsaved copy",
+ "Does not claim to have opened a demo itself, and does not redraw the demos with draw_from_smiles unasked"
+ ]
+ },
+ {
+ "id": 47,
+ "name": "open-database-file",
+ "prompt": "Open /tmp/fc-eval/compounds.fcdb in FormChem so I can look at it.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_context, then db_open with the path (or run_command open-recent with params path, which shows the database workspace)",
+ "Quotes the record count and title from the answer, and says the database workspace is showing in the window",
+ "Does not import the file into a new database or copy it"
+ ]
+ },
+ {
+ "id": 48,
+ "name": "space-the-scheme",
+ "prompt": "Tidy the reaction scheme in my FormChem drawing so the arrows fit their conditions, and put the conditions in a footnote.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_context, then perceive_reactions, then space_reaction (or fit_arrows_to_conditions) and conditions_as_footnotes, each one undo step",
+ "Checks the result with render or list_objects and quotes what the tools answered",
+ "Does not move objects one by one with move to imitate Space Reaction"
+ ]
+ },
+ {
+ "id": 49,
+ "name": "fuse-a-ring",
+ "prompt": "Fuse a cyclopentane onto the bond between atoms 3 and 4 of the benzene in my FormChem drawing.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_atoms to find the bond id, then fuse_ring {bond, size: 5} (or attach_template with that bond)",
+ "Checks the new formula with get_structure (C9H10, indane) and looks at render",
+ "Asks the person to open the window if the tool says no window answered, instead of drawing the ring atom by atom silently"
+ ]
+ },
+ {
+ "id": 50,
+ "name": "journal-figure-page",
+ "prompt": "Make my FormChem drawing a single-figure file with a footer that says the file name and page number.",
+ "files": [],
+ "expected_behavior": [
+ "Calls list_pages, then set_page with a footer using {file} and {page}, then fit_page_to_drawing",
+ "Quotes the page size the tool answers in points",
+ "Leaves exporting the picture to the person or a window command, and says which"
+ ]
+ },
+ {
+ "id": 51,
+ "name": "ir-and-ms-of-a-structure",
+ "prompt": "What IR bands and EI fragments would ethyl acetate show? Use FormChem.",
+ "files": [],
+ "expected_behavior": [
+ "Calls predict_ir_bands and predict_ms_fragments with the SMILES CCOC(C)=O or the drawn structure",
+ "Quotes the bands and ions with the method and calls them indicative predictions, not measured data",
+ "Changes nothing in the drawing"
+ ]
+ },
+ {
+ "id": 52,
+ "name": "boc-is-not-a-template",
+ "prompt": "Put a Boc template on the nitrogen of my amine in FormChem.",
+ "files": [],
+ "expected_behavior": [
+ "Recognises that the template library holds whole molecules only and that Boc is an abbreviation",
+ "Sets the label Boc on a new atom bonded to the nitrogen with the edit tools (or abbreviation_list to confirm the entry), then checks with get_structure",
+ "Does not invent a template id"
+ ]
}
],
"trigger_evals": [
@@ -608,6 +685,15 @@
{"query": "run CREST through formchem on the drawn macrocycle and keep 10 conformers", "should_trigger": true},
{"query": "install xtb with conda on my laptop", "should_trigger": false},
{"query": "convert a HELM string to SMILES with the Pistoia HELM toolkit in Java", "should_trigger": false},
- {"query": "add a new HELM monomer to formchem's helm_monomers.json data file", "should_trigger": false}
+ {"query": "add a new HELM monomer to formchem's helm_monomers.json data file", "should_trigger": false},
+ {"query": "show me the formchem demos so I have something to start from", "should_trigger": true},
+ {"query": "open this .fcdb database in FormChem and tell me how many compounds it holds", "should_trigger": true},
+ {"query": "add a sixth demo drawing to formchem's backend/app/data/demos", "should_trigger": false},
+ {"query": "space out the reaction in my formchem drawing and add footnotes", "should_trigger": true},
+ {"query": "add a second page with an A4 landscape layout to my FormChem drawing", "should_trigger": true},
+ {"query": "predict the IR bands of this structure in formchem", "should_trigger": true},
+ {"query": "fuse a ring onto this bond in FormChem", "should_trigger": true},
+ {"query": "fix Space Reaction's gap calculation in formchem's scheme.py", "should_trigger": false},
+ {"query": "explain what an EI McLafferty rearrangement is", "should_trigger": false}
]
}
diff --git a/.agents/skills/formchem-harness/SKILL.md b/.agents/skills/formchem-harness/SKILL.md
index 29ac1268..fcc03577 100644
--- a/.agents/skills/formchem-harness/SKILL.md
+++ b/.agents/skills/formchem-harness/SKILL.md
@@ -1,21 +1,21 @@
---
name: formchem-harness
-description: "Drives FormChem, the FormAI family's chemical structure drawing suite, through its MCP server. Use whenever the person wants an agent to work in FormChem: draw a structure or reaction from SMILES, a molfile, a chemical name or HELM, edit it atom by atom, check it with render, get_structure or validate, predict a 1H or 13C NMR spectrum, open a JCAMP-DX spectrum, build it in 3D, find conformers, run xtb or CREST, open a PDB file or extract a ligand, search a compound database by substructure or similarity, import an SD file, register a compound, add a notebook entry, put a structure in the shared library, convert files, run a menu command, or asks what FormChem can do, and FormChem is named or its tools (draw_from_smiles, build_3d, db_search, library_add, draw_from_helm, render, run_command and the rest) are available. Covers 127.0.0.1:8220, the agent token, approval and Stop. Not for changing FormChem's source (formchem-skillset), other Form apps such as FormDeck, or standalone RDKit scripts."
+description: "Drives FormChem, the FormAI structure drawing suite, through its MCP server. Use whenever the person wants an agent to work in FormChem: draw a structure or reaction from SMILES, a molfile, a chemical name or HELM, edit it atom by atom, fuse a ring onto a bond, space a reaction scheme, add pages, check it with render, get_structure or validate, predict NMR, IR bands or MS fragments, open a JCAMP-DX spectrum, build it in 3D, find conformers, run xtb or CREST, open a PDB file or extract a ligand, search a compound database by substructure or similarity, import an SD file, register a compound, add a notebook entry, put a structure in the shared library, convert files, run a menu command, show the demos, or asks what FormChem can do, and FormChem is named or its tools (draw_from_smiles, build_3d, db_search, render, run_command and the rest) are available. Covers 127.0.0.1:8220, the agent token, approval and Stop. Not for changing FormChem's source (formchem-skillset), other Form apps, or standalone RDKit scripts."
license: Apache-2.0
metadata:
author: nodemode-ai
- version: "0.12.0"
+ version: "0.14.0"
---
# FormChem harness
FormChem is a chemical structure drawing suite running on this computer. Its MCP server (`formchem`) lives in the engine and reaches the FormChem window, where the person sees everything an agent does. This pack is the method for using it well: draw with the tools, check what you drew, and hand back.
-## What exists today (0.12.0)
+## What exists today (0.14.0)
FormChem has drawings (`.fchem` documents kept by the engine with undo, autosave and versions), an RDKit chemistry service that computes SMILES, InChIKey, formula, masses, CIP labels and valence warnings after every change, and a 2D canvas the person draws on. Earlier versions added reactions and annotations (0.5.0), stereo, queries and analysis (0.6.0), formats, pictures, the clipboard, Standardise and the command line (0.7.0), the agent tools (0.8.0), names, NMR prediction and JCAMP-DX spectra (0.9.0), 3D: builds with the stereo checked, conformers, scans, measurements, PDB and mmCIF files and ligands (0.10.0), and structure databases with the lab notebook (0.11.0).
-0.12.0 adds the shared structure library every Form app reads, live structures (a picture with the drawing inside that sibling apps keep and send back for editing), HELM in and out, xtb and CREST run when the person installed them, keyboard and screen reader access, and element palettes. The MCP server has 77 tools; `references/tools.md` is generated from the server and lists all of them; the library and HELM tools are in `sub-skills/library-and-biopolymers` and the xtb tools in `sub-skills/three-d`.
+0.12.0 adds the shared structure library every Form app reads, live structures (a picture with the drawing inside that sibling apps keep and send back for editing), HELM in and out, xtb and CREST run when the person installed them, keyboard and screen reader access, and element palettes. 0.13.0 adds no tool: the desktop app opens files the system hands it (databases, PDB, mmCIF and JCAMP-DX included), names and HELM work in the desktop app, and Help > Demos (`run_command {id: "demos"}`) shows five prepared drawings on Home that the person opens as new copies. 0.14.0, the parity pass, adds 27 tools: pages and object boxes, undo of agent changes, ring fusion and templates by anchor, Space Reaction, arrows fitted to conditions and footnotes, typed Standardise, balance, isotope pattern and HELM output, predicted IR bands and MS fragments, the user abbreviation library, and 3D surfaces, energy terms, bond rotation, hydrogen repair, 3D pictures and PDB entries by id. The template library holds only starter structures and whole molecules (groups such as Boc are abbreviations). The MCP server has 104 tools; `references/tools.md` is generated from the server and lists all of them.
| Group | Tools |
| --- | --- |
@@ -32,10 +32,14 @@ FormChem has drawings (`.fchem` documents kept by the engine with undo, autosave
| xtb and CREST (0.12.0) | `xtb_optimise`, `crest_conformers` (only when the person installed the programs) |
| Window, extensions, handoff | `list_commands`, `run_command`, `extensions_list`, `extension_command`, `handoff` |
| Reactions (0.5.0) and analysis (0.6.0) | `perceive_reactions`, `map_reaction`, `export_reaction`, `reaction_stoichiometry`, `properties`, `check_structure`, `stereo`, `substructure` |
+| Pages and undo (0.14.0) | `list_pages`, `add_page`, `delete_page`, `set_page`, `fit_page_to_drawing`, `list_objects`; `undo_agent_changes` |
+| Gestures and schemes (0.14.0) | `fuse_ring`, `attach_template` (need the window); `space_reaction`, `fit_arrows_to_conditions`, `conditions_as_footnotes` |
+| Chemistry as tools (0.14.0) | `standardise`, `balance_reaction` (write only with `apply`), `isotope_pattern`, `export_helm`, `predict_ir_bands`, `predict_ms_fragments`; `abbreviation_list`, `abbreviation_define`, `abbreviation_remove` |
+| 3D (0.14.0) | `compute_surface`, `energy_terms_3d`, `rotate_bond_3d`, `repair_hydrogens_3d`, `render_3d` (needs the window), `fetch_pdb` |
Every change an agent makes is one transaction and one undo step, labelled with the tool in the person's Edit > Undo, and every change answers with the structure it now holds (ids, SMILES, InChIKey, formula, warnings) and a PNG of it. The person sees which agent is editing in the title bar, with a Stop button, and Window > Agent Activity lists every call with undo for the latest one.
-Every name and computed number carries its method and version (FormChem names 0.9.0, FormChem increments 0.9.0, `ETKDGv3+MMFF94 (rdkit 2025.09.3)`, similarity scores with their fingerprint, `xtb 6.7.1, GFN2-xTB, ALPB (Water)`); quote them with the value, and never present a prediction or a computed energy as measured. What still is not there: names the offline engine refuses (hydro prefixes, spiro and bridged rings; peptides go through HELM), a tool that links peaks to atoms (the window command does) or inserts a spectrum file into an existing drawing, typing amounts into the Stoichiometry panel, tools for 3D styles and surfaces (the window commands do), DFT or any quantum method beyond the person's own xtb, a tool that returns HELM text or describes a structure in words (window commands `copy-helm` and `a11y-describe` do), and database fields, saved queries, attachments or signing for agents (the window does them). The export and copy commands still hand their file to the person, not to the agent; use `convert` or `get_structure` for text you can read. Never draw by other means and present it as FormChem's work.
+Every name and computed number carries its method and version (FormChem names 0.9.0, FormChem increments 0.9.0, `ETKDGv3+MMFF94 (rdkit 2025.09.3)`, similarity scores with their fingerprint, `xtb 6.7.1, GFN2-xTB, ALPB (Water)`); quote them with the value, and never present a prediction or a computed energy as measured. What still is not there: names the offline engine refuses (hydro prefixes, spiro and bridged rings; peptides go through HELM), a tool that links peaks to atoms (the window command does) or inserts a spectrum file into an existing drawing, typing amounts into the Stoichiometry panel, tools for 3D styles (the window commands do), DFT or any quantum method beyond the person's own xtb, a tool that describes a structure in words (the window command `a11y-describe` does), tools of their own for brackets, tables and TLC plates and for journal styles (`run_command` reaches them), and database fields, saved queries, attachments or signing for agents (the window does them). The export and copy commands still hand their file to the person, not to the agent; use `convert` or `get_structure` for text you can read. Never draw by other means and present it as FormChem's work.
## Doctrine (applies to every route)
@@ -52,21 +56,22 @@ Every name and computed number carries its method and version (FormChem names 0.
```
formchem-harness/
SKILL.md this router and the doctrine
- references/tools.md 71 of the 77 tools and their arguments (generated by ./formchem agents sync)
+ references/tools.md all 104 tools and their arguments (generated by ./formchem agents sync)
+ references/failures.md every error the tools give, what it means, what to do
EVALS.json evaluation prompts and trigger tests for this pack
sub-skills/
session-and-connection/ connecting, the agent token, get_context, approval, Stop, connection errors
- drawing/ documents, draw_from_smiles, draw_from_molfile, add_reaction, placement, convert
+ drawing/ documents, pages, draw_from_smiles, draw_from_molfile, templates and fused rings, placement, convert
edit-by-id/ get_atoms and the 14 edit tools: atoms, bonds, charges, stereo, groups, arrows, text
visual-qa/ render, get_structure, validate and compute_properties to check your own work
names-and-spectra/ draw_from_name, name_structure, predict_nmr, predict_spectrum and the spectrum tools
- three-d/ build_3d, conformers, minimise, scans, measure, PDB files, ligands, 3D export, xtb and CREST
+ three-d/ build_3d, conformers, minimise, scans, measure, surfaces, terms, rotation, PDB by id, ligands, 3D export and pictures, xtb and CREST
databases/ the db_ and nb_ tools: import, search, register, export, notebook entries
library-and-biopolymers/ the shared structure library, live structure objects, draw_from_helm
handoff/ handoff states and notes, what the person sees, Agent Activity
window-commands/ the window's commands through run_command; references/command-catalogue.md
- reactions/ reaction schemes, the four reaction tools, Set Reaction Roles
- structure-analysis/ properties, the structure check, stereo, substructure and the chemistry commands
+ reactions/ reaction schemes, the reaction tools, Space Reaction and footnotes, balance, Set Reaction Roles
+ structure-analysis/ properties, the structure check, stereo, substructure, isotopes, IR and MS, abbreviations
extension-drawings/ reading and changing the drawing through a Form extension
```
@@ -84,9 +89,10 @@ Paths inside a SUB-SKILL.md resolve against that sub-skill's own folder. `refere
| Draw caffeine, draw "(2R)-butan-2-ol", what is this structure called, its IUPAC name | `names-and-spectra`, then `visual-qa` |
| Predict or simulate the 1H or 13C NMR, why is this proton at 4.1, put the predicted spectrum next to it | `names-and-spectra` |
| Open this .jdx file, pick the IR peaks, integrate the NMR, set this integral to 3, link a peak to atoms, export the spectrum | `names-and-spectra` |
-| The reaction in the drawing: steps, roles, atom mapping, reaction SMILES or RXN, balance, moles, yield | `reactions` |
-| cLogP, TPSA, Lipinski, the structure check, stereo groups, SMARTS hits, hydrogens, abbreviations, atom lists, R-groups | `structure-analysis` |
-| Export a picture or file for the person, print, the clipboard, Standardise, a template, the grid, the dark page, Preferences, any menu command | `window-commands` |
+| The reaction in the drawing: steps, roles, atom mapping, reaction SMILES or RXN, balance, moles, yield; space the scheme, fit the arrows, letter the steps with footnotes | `reactions` |
+| cLogP, TPSA, Lipinski, the structure check, stereo groups, SMARTS hits, hydrogens, abbreviations, atom lists, R-groups; the isotope pattern, IR bands, MS fragments; define an abbreviation | `structure-analysis` |
+| Add a page, page size or header, list objects with their boxes, fit the page to the drawing; fuse a ring onto a bond, attach a template; undo what the agent did since a step | `drawing` |
+| Export a picture or file for the person, print, the clipboard, Standardise, the grid, the dark page, a journal style, Preferences, Help > Demos, any menu command | `window-commands` |
| Run an extension's command, which extensions are installed, read the drawing through an extension | `extension-drawings` |
| Tell the person you are done, ask them something, clear your note | `handoff` |
| Make it 3D, its conformers or lowest-energy shape, minimise, a torsion scan, a bond length or angle in 3D, does the 3D keep the stereo | `three-d`, then `visual-qa` |
@@ -102,41 +108,7 @@ Paths inside a SUB-SKILL.md resolve against that sub-skill's own folder. `refere
## When something fails
-| What you see | Meaning | Do |
-| --- | --- | --- |
-| No FormChem tools at all | The MCP server is not connected in this client | Ask the person to run `./formchem agents install` in the FormChem folder, start FormChem with `./formchem`, then restart the client |
-| 401, or "needs the agent token" | An HTTP setup without the 0.8.0 token | Ask the person to run `./formchem agents install` again, or to add `Authorization: Bearer` and the output of `./formchem agents token` to the client's FormChem entry; stdio (`./formchem mcp`) needs nothing |
-| Connection refused | The engine is not running | Ask the person to run `./formchem` or open the app; the stdio entry starts the engine itself |
-| "did not allow agents" or "blocked agents" | The person answered Deny, or blocked agents in Preferences | Stop and tell the person what you wanted to do |
-| "The person stopped [agent]'s access" | The person pressed Stop | Stop working. Tell them what you were about to do; they can Allow again in Agent Activity |
-| "Several drawings are open and no window shows one" | No `doc` and no active drawing | Call `list_open_documents` and pass `doc` |
-| "Could not read the SMILES" or "the molfile" | The text does not parse; no drawing was left behind | Fix the text once, or ask the person |
-| An edit error naming an id | A stale or wrong atom, bond or object id | Call `get_atoms` once and use the ids it returns |
-| "already exists" from `save_document` or `convert` | Agent tools never write over a file | Choose a new path, or ask the person to save over it in the window |
-| "has unsaved changes" from `close_document` | Only the person may discard changes | `save_document` first, or ask the person |
-| "is not available right now" | A window command is off (nothing selected, nothing to undo, a later version) | Do not retry; tell the person the reason it gives |
-| "Could not read the name" | The offline engine refused it (spelling, an inverted index name, D- or L- outside the dictionary, an impossible locant); nothing was drawn | Fix an obvious spelling once; else write the SMILES, use `draw_from_smiles` and say so |
-| `confidence: medium` on a name | A locant was assumed or the name has two readings | Quote the note and say what was drawn; ask if it matters |
-| `names: []` with a reason | No dictionary entry and the namer cannot name it, or the round trip failed | Report the reason; do not invent a systematic name |
-| "is not a spectrum" or "has none" from a spectrum tool | Wrong id, or the drawing holds no spectrum | `open_spectrum` or `predict_spectrum` first; pass `object` from its answer |
-| Predicted links stale after an edit | The curve follows the structure, the marks do not | Ask the person for Refresh Predicted Spectrum, or `run_command {id: "nmr-refresh"}` with that spectrum selected |
-| "stereo changed: lost ..." from `build_3d` | The 3D structure is not the drawn isomer | Do not use the geometry; check the wedges (`stereo`, `get_atoms`) and report it |
-| `unspecified_stereo` or `uff_fallback` note on a build | Centres without wedges were built as one arbitrary isomer; or MMFF94 had no parameters and UFF ran | Pass the note on with the numbers |
-| "No 3D coordinates yet" or "has no conformer" | The structure was never built, or an edit dropped its conformers | `build_3d`, then retry |
-| "The structure changed while 3D was being computed" (409) | Someone edited the structure during the build | Retry once; if it repeats, the person is editing: ask them |
-| `extract_ligand` refuses, or answers "inferred from the geometry" | The object is not a PDB or mmCIF model; or the ligand is outside the template table | Pass the model's `o...` id from `open_3d_structure`; say the bond orders were inferred and show the SMILES |
-| "No database is open" or "Several databases are open" | No handle given | `db_list`, then `db_open {path}` or pass `db` |
-| `db_add_record` error listing duplicates | The structure is there by the database's stereo and salts rules | Show the matches; call again with the `on_duplicate` the person chooses |
-| "open read-only" or 423 on a write | Another FormChem or `./formchem db` holds the file | Report the reason; read and search only |
-| `failed` records in a `db_import` job | Bad records were skipped, the rest imported | Pass on each record number and reason |
-| xtb or CREST "was not found" from `xtb_optimise` or `crest_conformers` | The person has not installed it, or its path is wrong; FormChem never ships it | Tell the person where to get it (the answer says); do not retry |
-| "unpaired electrons" or parity refusal from an xtb tool | Charge and `uhf` cannot match the electron count | Fix `charge` or `uhf` once from the structure, or ask |
-| An xtb job "timeout" or "failed" with the last lines | The time limit stopped it, or the program failed | Pass on the last lines; offer a larger `limit` or GFN-FF |
-| `draw_from_helm` refused "at character N" | Unknown monomer, mixture, BLOB or a typo | Fix an obvious typo once; else inline SMILES for the monomer, or report |
-| "has no item" from a library tool | Wrong id, or the item was deleted | `library_list`, then use an id it returns |
-| `renderer: "engine"` in a picture | No window answered; the engine drew the structures only | Fine for checking structures; say arrows and text were not drawn, or ask the person to open the window |
-
-When a call keeps failing in a way this table does not explain, call the same tool once with the simplest arguments (`get_context`, then `draw_from_smiles {smiles: "C"}`). If that fails too, the problem is the server or the connection, not the plan: report it to the person with the error text.
+`references/failures.md` maps every error the tools give (connection and token, consent and Stop, ids, names, spectra, 3D builds, databases, xtb and CREST, HELM, the library, engine-drawn pictures) to what it means and the one thing to do. Read it when a call fails, do that once, then report. When nothing there explains the failure, call the same tool once with the simplest arguments (`get_context`, then `draw_from_smiles {smiles: "C"}`); if that fails too, the problem is the server or the connection: report it to the person with the error text.
## Done means
diff --git a/.agents/skills/formchem-harness/references/failures.md b/.agents/skills/formchem-harness/references/failures.md
new file mode 100644
index 00000000..cea9800b
--- /dev/null
+++ b/.agents/skills/formchem-harness/references/failures.md
@@ -0,0 +1,38 @@
+# When something fails
+
+What each FormChem error means and the one thing to do about it. Read the error first: every one names the next step. Do that once, then report.
+
+| What you see | Meaning | Do |
+| --- | --- | --- |
+| No FormChem tools at all | The MCP server is not connected in this client | Ask the person to run `./formchem agents install` in the FormChem folder, start FormChem with `./formchem`, then restart the client |
+| 401, or "needs the agent token" | An HTTP setup without the 0.8.0 token | Ask the person to run `./formchem agents install` again, or to add `Authorization: Bearer` and the output of `./formchem agents token` to the client's FormChem entry; stdio (`./formchem mcp`) needs nothing |
+| Connection refused | The engine is not running | Ask the person to run `./formchem` or open the app; the stdio entry starts the engine itself |
+| "did not allow agents" or "blocked agents" | The person answered Deny, or blocked agents in Preferences | Stop and tell the person what you wanted to do |
+| "The person stopped [agent]'s access" | The person pressed Stop | Stop working. Tell them what you were about to do; they can Allow again in Agent Activity |
+| "Several drawings are open and no window shows one" | No `doc` and no active drawing | Call `list_open_documents` and pass `doc` |
+| "Could not read the SMILES" or "the molfile" | The text does not parse; no drawing was left behind | Fix the text once, or ask the person |
+| An edit error naming an id | A stale or wrong atom, bond or object id | Call `get_atoms` once and use the ids it returns |
+| "already exists" from `save_document` or `convert` | Agent tools never write over a file | Choose a new path, or ask the person to save over it in the window |
+| "has unsaved changes" from `close_document` | Only the person may discard changes | `save_document` first, or ask the person |
+| "is not available right now" | A window command is off (nothing selected, nothing to undo, a later version) | Do not retry; tell the person the reason it gives |
+| "Could not read the name" | The offline engine refused it (spelling, an inverted index name, D- or L- outside the dictionary, an impossible locant); nothing was drawn | Fix an obvious spelling once; else write the SMILES, use `draw_from_smiles` and say so |
+| `confidence: medium` on a name | A locant was assumed or the name has two readings | Quote the note and say what was drawn; ask if it matters |
+| `names: []` with a reason | No dictionary entry and the namer cannot name it, or the round trip failed | Report the reason; do not invent a systematic name |
+| "is not a spectrum" or "has none" from a spectrum tool | Wrong id, or the drawing holds no spectrum | `open_spectrum` or `predict_spectrum` first; pass `object` from its answer |
+| Predicted links stale after an edit | The curve follows the structure, the marks do not | Ask the person for Refresh Predicted Spectrum, or `run_command {id: "nmr-refresh"}` with that spectrum selected |
+| "stereo changed: lost ..." from `build_3d` | The 3D structure is not the drawn isomer | Do not use the geometry; check the wedges (`stereo`, `get_atoms`) and report it |
+| `unspecified_stereo` or `uff_fallback` note on a build | Centres without wedges were built as one arbitrary isomer; or MMFF94 had no parameters and UFF ran | Pass the note on with the numbers |
+| "No 3D coordinates yet" or "has no conformer" | The structure was never built, or an edit dropped its conformers | `build_3d`, then retry |
+| "The structure changed while 3D was being computed" (409) | Someone edited the structure during the build | Retry once; if it repeats, the person is editing: ask them |
+| `extract_ligand` refuses, or answers "inferred from the geometry" | The object is not a PDB or mmCIF model; or the ligand is outside the template table | Pass the model's `o...` id from `open_3d_structure`; say the bond orders were inferred and show the SMILES |
+| "No database is open" or "Several databases are open" | No handle given | `db_list`, then `db_open {path}` or pass `db` |
+| `db_add_record` error listing duplicates | The structure is there by the database's stereo and salts rules | Show the matches; call again with the `on_duplicate` the person chooses |
+| "open read-only" or 423 on a write | Another FormChem or `./formchem db` holds the file | Report the reason; read and search only |
+| `failed` records in a `db_import` job | Bad records were skipped, the rest imported | Pass on each record number and reason |
+| xtb or CREST "was not found" from `xtb_optimise` or `crest_conformers` | The person has not installed it, or its path is wrong; FormChem never ships it | Tell the person where to get it (the answer says); do not retry |
+| "unpaired electrons" or parity refusal from an xtb tool | Charge and `uhf` cannot match the electron count | Fix `charge` or `uhf` once from the structure, or ask |
+| An xtb job "timeout" or "failed" with the last lines | The time limit stopped it, or the program failed | Pass on the last lines; offer a larger `limit` or GFN-FF |
+| `draw_from_helm` refused "at character N" | Unknown monomer, mixture, BLOB or a typo | Fix an obvious typo once; else inline SMILES for the monomer, or report |
+| "has no item" from a library tool | Wrong id, or the item was deleted | `library_list`, then use an id it returns |
+| `renderer: "engine"` in a picture | No window answered; the engine drew the structures only | Fine for checking structures; say arrows and text were not drawn, or ask the person to open the window |
+When a call keeps failing in a way this table does not explain, call the same tool once with the simplest arguments (`get_context`, then `draw_from_smiles {smiles: "C"}`). If that fails too, the problem is the server or the connection, not the plan: report it to the person with the error text.
diff --git a/.agents/skills/formchem-harness/references/tools.md b/.agents/skills/formchem-harness/references/tools.md
index 23466773..5c2ef621 100644
--- a/.agents/skills/formchem-harness/references/tools.md
+++ b/.agents/skills/formchem-harness/references/tools.md
@@ -1,6 +1,6 @@
# FormChem MCP tools
-Generated by `./formchem agents sync` from the TOOLS list in `backend/app/routers/mcp.py` and the agent modules in its AGENT_MODULES; edit the server, never this file. 77 tools. Names and arguments are case sensitive. A tool answers with text first, then `structuredContent` where it sends it; a tool that cannot act answers with `isError: true` and a sentence naming the next step.
+Generated by `./formchem agents sync` from the TOOLS list in `backend/app/routers/mcp.py` and the agent modules in its AGENT_MODULES; edit the server, never this file. 104 tools. Names and arguments are case sensitive. A tool answers with text first, then `structuredContent` where it sends it; a tool that cannot act answers with `isError: true` and a sentence naming the next step.
Read-only tools never ask the person. An approval-gated tool asks the person in the FormChem window the first time (Deny, Allow once, Always allow); agents started in FormChem's own Claude Code, Codex, Cursor or Antigravity tabs are never asked.
@@ -33,10 +33,17 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
- close_document
- list_commands
- run_command
+- fuse_ring
+- attach_template
- extensions_list
- extension_command
- handoff
- perceive_reactions
+- space_reaction
+- fit_arrows_to_conditions
+- conditions_as_footnotes
+- predict_ir_bands
+- predict_ms_fragments
- map_reaction
- export_reaction
- reaction_stoichiometry
@@ -84,6 +91,26 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
- draw_from_helm
- xtb_optimise
- crest_conformers
+- standardise
+- balance_reaction
+- isotope_pattern
+- export_helm
+- list_pages
+- add_page
+- delete_page
+- set_page
+- fit_page_to_drawing
+- list_objects
+- undo_agent_changes
+- abbreviation_list
+- abbreviation_define
+- abbreviation_remove
+- compute_surface
+- energy_terms_3d
+- rotate_bond_3d
+- repair_hydrogens_3d
+- render_3d
+- fetch_pdb
- Resource
| Tool | Kind |
@@ -114,10 +141,17 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
| `close_document` | approval-gated |
| `list_commands` | read-only |
| `run_command` | approval-gated |
+| `fuse_ring` | approval-gated |
+| `attach_template` | approval-gated |
| `extensions_list` | read-only |
| `extension_command` | approval-gated |
| `handoff` | approval-gated when it changes something |
| `perceive_reactions` | approval-gated |
+| `space_reaction` | approval-gated |
+| `fit_arrows_to_conditions` | approval-gated |
+| `conditions_as_footnotes` | approval-gated |
+| `predict_ir_bands` | read-only |
+| `predict_ms_fragments` | read-only |
| `map_reaction` | approval-gated |
| `export_reaction` | read-only |
| `reaction_stoichiometry` | read-only |
@@ -165,6 +199,26 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
| `draw_from_helm` | approval-gated when it changes something |
| `xtb_optimise` | approval-gated when it changes something |
| `crest_conformers` | approval-gated when it changes something |
+| `standardise` | approval-gated when it changes something |
+| `balance_reaction` | approval-gated when it changes something |
+| `isotope_pattern` | read-only |
+| `export_helm` | read-only |
+| `list_pages` | read-only |
+| `add_page` | approval-gated when it changes something |
+| `delete_page` | approval-gated when it changes something |
+| `set_page` | approval-gated when it changes something |
+| `fit_page_to_drawing` | approval-gated when it changes something |
+| `list_objects` | read-only |
+| `undo_agent_changes` | approval-gated when it changes something |
+| `abbreviation_list` | read-only |
+| `abbreviation_define` | approval-gated when it changes something |
+| `abbreviation_remove` | approval-gated when it changes something |
+| `compute_surface` | read-only |
+| `energy_terms_3d` | read-only |
+| `rotate_bond_3d` | approval-gated when it changes something |
+| `repair_hydrogens_3d` | approval-gated when it changes something |
+| `render_3d` | read-only |
+| `fetch_pdb` | approval-gated when it changes something |
## get_context
@@ -447,6 +501,28 @@ Runs one command in the open FormChem window, exactly as the person's click woul
| `params` | object | no | Parameters the command lists, if any |
| `confirm` | boolean | no | |
+## fuse_ring
+
+Fuses a ring onto a drawn bond in the active drawing, on the side with fewer atoms nearby, as one undo step (the window's fuse-ring command). Answers with the new atom ids. Needs the window.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `bond` | string | yes | Bond id, or fragment id/bond id, from get_atoms |
+| `size` | integer | no | Ring size 3 to 8 (default 6) |
+| `benzene` | boolean | no | A benzene ring with alternating double bonds |
+
+## attach_template
+
+Puts a template (ids from GET /api/templates, such as benzene or pyridine) into the active drawing as one undo step (the window's attach-template command): on atom it merges the template's least connected atom into that atom, on bond it fuses the template's first ring bond onto that bond, otherwise it is centred at x, y in points. Answers with the new atom ids. Needs the window.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `id` | string | yes | Template id |
+| `atom` | string | no | Atom id (or fragment/atom) to attach at |
+| `bond` | string | no | Bond id (or fragment/bond) to fuse onto |
+| `x` | number | no | |
+| `y` | number | no | |
+
## extensions_list
The Form extensions FormChem found (installed by FormPortal or run from a folder by form.ext): id, name, version, source, state (ready, needs-permission, refused with the reason) and the commands each contributes.
@@ -481,6 +557,59 @@ Works out the reaction steps of a drawing from where its structures sit around t
| `doc` | string | no | Drawing id from get_context; may be left out when one drawing is open |
| `page` | string | no | Page id; all pages when left out |
+## space_reaction
+
+Lays a perceived reaction scheme out in one row as one undo step: arrows horizontal, even gaps, plus signs between species, arrows stretched to their conditions; with wrap (a row width in points) the scheme continues on a new row, joined by a dogleg line or by repeating the last structure.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `page` | string | no | |
+| `reaction` | string | no | Reaction id; every reaction of the page when left out |
+| `wrap` | number | no | Row width in points, 72 to 20000 |
+| `wrap_mode` | dogleg or repeat | no | |
+| `stretch` | boolean | no | Stretch arrows to fit their conditions (default true) |
+
+## fit_arrows_to_conditions
+
+Lengthens reaction arrows so their agents and conditions fit above and below them, moving what follows along, as one undo step.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `page` | string | no | |
+| `step` | string | no | Step id; every step of the page when left out |
+
+## conditions_as_footnotes
+
+Letters each step of a reaction (a), (b) above its arrow and moves the condition texts into one footnote under the scheme, as one undo step.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `page` | string | no | |
+| `reaction` | string | no | Reaction id; the first reaction of the page when left out |
+
+## predict_ir_bands
+
+Predicted IR absorption bands (wavenumber ranges by functional group, textbook values, indicative) for smiles or a drawn structure.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+
+## predict_ms_fragments
+
+Predicted EI mass spectrum fragment ions (molecular ion, alpha cleavage, benzylic, McLafferty, common neutral losses; indicative) for smiles or a drawn structure.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+
## map_reaction
Maps the atoms of one reaction step (reactant atom to product atom numbers) and marks the bonds broken, formed or changed in order, as one undo step. mode discard (default) maps from scratch, keep keeps the numbers already drawn, alter may change them, clear removes the mapping.
@@ -1032,6 +1161,235 @@ Searches conformers of a structure with the CREST program (metadynamics with GFN
| `threads` | integer | no | Threads; default the Preferences setting |
| `limit` | number | no | Time limit in seconds (default 600 for xtb, 3600 for CREST, at most 604800) |
+## standardise
+
+Standardises structures with the same steps as the window's Structure > Standardise: cleanup (Clean up); normalise (Normalise functional groups); salts (Remove salts and solvents); largest (Keep the largest fragment); reionise (Reionise); neutralise (Neutralise); tautomer (Canonical tautomer); isotopes (Remove isotopes); stereo (Remove stereochemistry); strip_h (Remove explicit hydrogens). Without steps the default set runs (cleanup, normalise, salts, reionise, neutralise, strip_h); a step can be added or dropped with + or - ("default -strip_h +tautomer"). Give smiles to standardise text without a drawing (nothing changes anywhere), or doc with optional objects to standardise structures of a drawing: apply true writes the result as one undo step (atom ids kept where the atom survives), apply false (the default) only reports. Answers with the SMILES before and after, each step that changed something with what it did, and the method of every step.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | SMILES to standardise without a drawing |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `objects` | array of string | no | Fragment ids to standardise; default every structure of the drawing |
+| `steps` | any | no | Step names (cleanup, normalise, salts, largest, reionise, neutralise, tautomer, isotopes, stereo, strip_h), default, all, with + or - before a name; a list or one string |
+| `apply` | boolean | no | Write the standardised structures into the drawing as one undo step (default false) |
+
+## balance_reaction
+
+Balances a reaction with the same solver as the window's Balance Reaction: element and charge counts of each species, the one-dimensional null space of the element matrix scaled to the smallest whole numbers (at most 50). Give smiles, a reaction SMILES such as CCC.O=O>>O=C=O.O, to balance text without a drawing; or a drawing's reaction step (doc, reaction and step from perceive_reactions; left out when the drawing has one step) to check it, and apply true to write the coefficients the solver found, or the coefficients you give as {object id: n}, into the step as one undo step (they are drawn before each structure). When no coefficients balance the step the answer suggests co-products to add (water, HCl, CO2 and others) and nothing is written.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | Reaction SMILES reactants>agents>products (agents are not counted) |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `reaction` | string | no | Reaction id from perceive_reactions |
+| `step` | string | no | Step id from perceive_reactions |
+| `coefficients` | object | no | Object id to whole number 1 to 999, written instead of the solver's answer (apply true) |
+| `apply` | boolean | no | Write the coefficients into the step as one undo step (default false: only check) |
+
+## isotope_pattern
+
+The isotope pattern of a molecule, as the Analysis panel's mass spectrum shows it: every peak's neutral mass, m/z and abundance relative to the base peak (peaks within 0.01 Da merged, peaks under threshold percent dropped), the monoisotopic and average mass and the common adduct ions. Give a formula (C13H18O2, C6H5Br, SO4 2-), a SMILES, or a drawing's structures (doc with optional objects; isotopes drawn on atoms are kept). Labels and R-groups that have no element are left out and said so. Changes nothing.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `formula` | string | no | Molecular formula with an optional charge at the end, such as C8H10N4O2 or C6H5NH3+ |
+| `smiles` | string | no | SMILES of one structure (dots allowed) |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `objects` | array of string | no | Fragment ids; default every structure of the drawing |
+| `threshold` | number | no | Smallest peak kept, in percent of the base peak (0 to 100, default 0.1) |
+
+## export_helm
+
+Writes a peptide, nucleic acid or linker as HELM version 2 text, as Copy as HELM does: the structure is cut at amide and phosphodiester bonds, every piece is matched to FormChem's own monomer data (the 20 amino acids and D forms, [Aib], [Nle], [Orn], [Sar], [Hyp], [pE], caps [ac] and [am], sugars R and [dR], phosphate P, bases A, C, G, U and T), and the HELM written is read back and compared by InChIKey; only a HELM that reads back to the same structure is offered. Give smiles, a molfile, or a drawing's structure (doc and object). When a piece has no monomer the answer says which and no HELM is given. Changes nothing.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | SMILES of the biopolymer |
+| `molfile` | string | no | MDL molfile of the biopolymer |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `object` | string | no | Fragment id; may be left out when the drawing has one structure |
+
+## list_pages
+
+The pages of a drawing in order: number, id, name, size in points (or auto for an auto-grow canvas), orientation, margins, header, footer and how many top-level objects each holds.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+
+## add_page
+
+Adds an empty page to a drawing after page after (default the last), with that page's size, margins, header and footer unless given. One undo step labelled with the tool name.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `after` | integer | no | Page number to add after, 1 based; 0 adds a first page |
+| `paper` | a3 or a4 or a5 or legal or letter or tabloid | no | |
+| `orientation` | portrait or landscape | no | |
+
+## delete_page
+
+Deletes a page and every object on it as one undo step. A drawing keeps at least one page.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | yes | Page number, 1 based (default 1) |
+
+## set_page
+
+Changes a page's setup: size (width and height in points, 36 to 5000, or paper with orientation), auto (an auto-grow canvas that fits the drawing plus the margin), margins, header and footer (fields {page}, {pages}, {file}, {date}) and name. all applies the size, margins, header and footer to every page. Objects never move.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | no | Page number, 1 based (default 1) |
+| `width` | number | no | |
+| `height` | number | no | |
+| `paper` | a3 or a4 or a5 or legal or letter or tabloid | no | |
+| `orientation` | portrait or landscape | no | |
+| `auto` | boolean | no | |
+| `margins` | number | no | |
+| `header` | string | no | |
+| `footer` | string | no | |
+| `name` | string | no | |
+| `all` | boolean | no | |
+
+## fit_page_to_drawing
+
+Shrinks a page to its drawing plus the page margin and moves the drawing to the top left margin, for a single-figure journal file. Bounds are the engine's estimate (fragment atoms and labels, text, arrows, shapes).
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | no | Page number, 1 based (default 1) |
+
+## list_objects
+
+The objects on a page, top level first, with id, kind, name, parent group, hidden and locked flags and the bounding box in points (x, y, w, h, the engine's estimate). kind filters by object kind.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | no | Page number, 1 based (default 1) |
+| `kind` | string | no | Only objects of this kind (fragment, text, arrow, table, tlc ...) |
+
+## undo_agent_changes
+
+Takes back agent changes in a drawing: without step it lists the agent steps still on the undo stack (newest first, with how many steps going back to each costs and how many of those are the person's); with step it undoes every step back to before it. Every undone step can be redone.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `step` | string | no | Agent step id from the listing |
+
+## abbreviation_list
+
+The abbreviation library the canvas uses: every built-in and user entry (label, reversed label, SMILES with * at the attachment point, category, source), the path of the user library file and any errors in it. With label it answers for that one label, also reading it as a condensed formula such as CH2CH2OH, with the group formula.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `label` | string | no | The abbreviation as typed on an atom, for example Bnz or Lnk (a letter, then up to 15 letters, digits, ( ) * + or -) |
+| `filter` | string | no | Only labels or categories containing this text |
+
+## abbreviation_define
+
+Adds an abbreviation to the person's user library (abbreviations.json in FormChem's data folder). The canvas uses it at once. smiles has one * at the attachment atom, or [*:1], [*:2] for ordered attachment points. A label that is also an element symbol needs prefer true; an existing user label needs replace true.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `label` | string | yes | The abbreviation as typed on an atom, for example Bnz or Lnk (a letter, then up to 15 letters, digits, ( ) * + or -) |
+| `smiles` | string | yes | |
+| `reversed` | string | no | Label shown when drawn on the left, for example TsO for OTs |
+| `category` | user or alkyl or aryl or protecting group or silyl or sulfonyl or functional or amino acid residue or nucleobase or ligand | no | |
+| `prefer` | boolean | no | |
+| `replace` | boolean | no | |
+
+## abbreviation_remove
+
+Removes an abbreviation from the person's user library. Built-in entries cannot be removed.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `label` | string | yes | The abbreviation as typed on an atom, for example Bnz or Lnk (a letter, then up to 15 letters, digits, ( ) * + or -) |
+
+## compute_surface
+
+Surface areas (Ų) and enclosed volumes (ų) of a structure's stored conformer, every hydrogen included: van der Waals, solvent-accessible and solvent-excluded, with a probe radius (default 1.4 Å, water) or a named solvent, at low, medium or high resolution. Areas by Shrake-Rupley dots (the SES area from grid faces), volumes from grid points, RDKit van der Waals radii. Read only.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `probe` | number | no | Probe radius in Å, 0 to 5 |
+| `solvent` | water or methanol or ethanol or acetonitrile or acetone or thf or dichloromethane or dmso or chloroform or benzene or toluene or hexane | no | |
+| `resolution` | low or medium or high | no | |
+
+## energy_terms_3d
+
+The force-field energy of a stored conformer split into terms (MMFF94: bond stretch, angle bend, stretch-bend, out-of-plane, torsion, van der Waals, electrostatics) with the total in kcal/mol; UFF gives the total only. Read only.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `method` | MMFF94 or MMFF94s or UFF | no | Force field (default MMFF94) |
+
+## rotate_bond_3d
+
+Turns a bond of a stored conformer as one undo step: four atoms and value set that dihedral, two atoms and angle turn by that many degrees. The smaller side moves unless side is other. Ring bonds are refused. Answers with the new dihedral and the single-point energy.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `atoms` | array of string | yes | Two bonded atom ids, or four for a dihedral (hydrogens as a1:h0) |
+| `value` | number | no | Dihedral to set, -180 to 180 |
+| `angle` | number | no | Degrees to turn by |
+| `side` | smaller or other | no | |
+| `method` | MMFF94 or MMFF94s or UFF | no | Force field (default MMFF94) |
+
+## repair_hydrogens_3d
+
+Adds missing and removes extra hydrogens on a stored conformer from valence and charge without moving any heavy atom (only hydrogens are relaxed), as one undo step. Answers with the hydrogen count before and after and the heavy-atom RMSD.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `method` | MMFF94 or MMFF94s or UFF | no | Force field (default MMFF94) |
+
+## render_3d
+
+A PNG of a structure's 3D model, or of a 3D object opened from a PDB or mmCIF file, drawn by the FormChem window's 3D View at width x height (64 to 8192 pixels, one pass), with an optional display style, surface, atom labels and hydrogen bonds. Needs the window open and the structure built in 3D.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment or 3D object id |
+| `width` | integer | no | |
+| `height` | integer | no | |
+| `transparent` | boolean | no | |
+| `display` | wire or stick or ballstick or spacefill or cartoon | no | |
+| `surface` | none or vdw or sas or ses | no | |
+| `labels` | none or symbol or index or charge or cip or residue | no | |
+| `hbonds` | boolean | no | |
+
+## fetch_pdb
+
+Downloads an entry from RCSB PDB (files.rcsb.org) by its four-character identifier and opens it into a drawing as a 3D object, one undo step. Only the identifier leaves the computer, and only when the person agrees in the FormChem window.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `id` | string | yes | PDB identifier such as 1CRN |
+| `format` | cif or pdb | no | |
+
## Resource
`formchem://guide` (text/markdown): what exists in this version, the tools, asking the person and errors.
diff --git a/.agents/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md b/.agents/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md
index 1bbf2bce..2a077601 100644
--- a/.agents/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md
+++ b/.agents/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md
@@ -42,6 +42,13 @@ A reaction SMILES (`reactants>agents>products`, such as `CCO.CC(=O)O>[H+]>CC(=O)
`convert` and `batch_convert` ask the person only when they write outside the temporary folder.
+## Workflow 4: pages, templates and taking back your work (0.14.0)
+
+1. Pages: `list_pages` first; `add_page {paper, orientation}`, `set_page {page, header, footer, margins, auto}` (fields `{page}`, `{pages}`, `{file}`, `{date}`), `fit_page_to_drawing {page}` for a single-figure file, `delete_page {page}` (the last page is refused). Each is one undo step.
+2. Layout checks: `list_objects {page}` gives every object's box in points; use it to see that nothing overlaps before you `render`.
+3. Rings and templates on what is there: `fuse_ring {bond, size, benzene}` fuses onto a drawn bond on the emptier side; `attach_template {id, atom}` attaches, `{id, bond}` fuses, `{id, x, y}` places (ids from `GET /api/templates`, such as `pyridine`). Both run the window's own commands, so a window must be open, and both answer the new atom ids. The template library holds only starter structures and whole molecules; a group such as Boc is an abbreviation (`structure-analysis`).
+4. Taking back: `undo_agent_changes {}` lists your steps still on the undo stack and how many steps going back would undo, the person's included; `undo_agent_changes {step}` goes back to before one. Tell the person how many of their own steps it took with it.
+
## Rules
- **Which drawing.** `doc` when given; else the only open drawing; else the one the window shows; else the tool asks for `doc`. When the person has several open, say which one you drew in.
diff --git a/.agents/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md b/.agents/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md
index 5c87371a..8447b8af 100644
--- a/.agents/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md
+++ b/.agents/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md
@@ -27,12 +27,15 @@ Answer reaction questions from what FormChem computes, not from the agent's own
| Map atoms | `map_reaction {doc?, reaction?, step?, mode?}`: `discard` (default) maps from scratch, `keep` keeps drawn numbers, `alter` may change them, `clear` removes them; the answer gives map numbers and bonds broken and formed | yes, one undo step |
| The reaction as text | `export_reaction {doc?, reaction?, step?, format?}`: `smiles`, `rxn` (V2000) or `rxnv3000`, with map numbers | no |
| Amounts and yields | `reaction_stoichiometry {doc?, reaction?, step?}`: rows with mmol, equiv, mass, volume, the limiting reagent, the theoretical and percent yield, and the balance check | no |
-| Balance coefficients | `run_command {id: "balance-reaction"}` on the selected or first step; `check-reaction` opens the balance dialog for the person | yes, one undo step |
-| Insert a template | `run_command {id: "insert-template", params: {id: "[template id]"}}`; the ids come from the engine's `GET /api/templates` | yes, one undo step |
+| Balance coefficients | `balance_reaction {doc?, reaction?, step?}` previews the coefficients and co-product hints; with `apply: true` it writes them (drawn before each species); `check-reaction` opens the balance dialog for the person | only with `apply` |
+| Lay the scheme out (0.14.0) | `space_reaction {page?, reaction?, wrap?, wrap_mode?}`: one centre line, 14.4 pt between a structure and an arrow, 7.2 pt around a plus, arrows stretched to their conditions; `wrap` (points) starts a new row with a `dogleg` line or by `repeat`ing the structure | yes, one undo step |
+| Fit arrows (0.14.0) | `fit_arrows_to_conditions {page?, step?}`: each arrow to its widest condition plus 7.2 pt a side, moving what follows. `perceive_reactions` does not stretch; call this or `space_reaction` after it | yes, one undo step |
+| Footnotes (0.14.0) | `conditions_as_footnotes {page?, reaction?}`: letters the steps (a), (b) and moves their conditions into one footnote under the scheme; a second call changes nothing | yes, one undo step |
+| Insert a template | `attach_template {id, x?, y?}` (or on an atom or bond, see `drawing`); the ids come from the engine's `GET /api/templates`, whole molecules only | yes, one undo step |
| Paste a reaction | `paste-reaction` reads the person's clipboard; an agent cannot fill the clipboard, so it is the person's | yes |
| The grid on the page | `stoichiometry-grid` inserts or refreshes the grid for the selected or first step; `show-stoichiometry` opens the panel for the person | yes for the grid |
-`doc` may be left out when one drawing is open; `reaction` and `step` default to the first. The two changing tools ask the person the first time like any change.
+`doc` may be left out when one drawing is open; `reaction` and `step` default to the first. The changing tools ask the person the first time like any change. Map numbers by hand and reacting-centre marks are window commands (`set-atom-map-number {map}`, `reacting-formed` and the other `reacting-*` ids, through `run_command` on the selection); the arrow badge they feed is on screen only. Densities for 65 common liquids come from FormChem's table when the person leaves the density empty; say so when you quote a volume.
## Procedure
diff --git a/.agents/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md b/.agents/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md
index 0836ac92..49acef80 100644
--- a/.agents/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md
+++ b/.agents/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md
@@ -52,5 +52,5 @@ Agents started from FormChem's own Claude Code, Codex, Cursor or Antigravity tab
## Gate
- [ ] `get_context` was the first call.
-- [ ] The plan uses only the 77 tools (the 71 in the pack root's `references/tools.md`, the library and HELM tools in `library-and-biopolymers` and the xtb tools in `three-d`) and the commands and extensions they report.
+- [ ] The plan uses only the 77 tools (all listed in the pack root's `references/tools.md`; the library and HELM tools explained in `library-and-biopolymers` and the xtb tools in `three-d`) and the commands and extensions they report.
- [ ] No change was attempted after a refusal or a stop, and the agent token never appeared in a reply or a note.
diff --git a/.agents/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md b/.agents/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md
index 03da30fa..5c9b54d5 100644
--- a/.agents/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md
+++ b/.agents/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md
@@ -26,6 +26,19 @@ From 0.8.0 `compute_properties` and `validate` are the same answers as `properti
`doc` may be left out when one drawing is open (the four 0.6.0 tools need it when several are open); `object` left out means every fragment. `structuredContent` carries the same JSON as the engine's `/api/analysis` routes. The isotope pattern has no tool: it is in the person's Analysis panel (`show-analysis`).
+### More reading tools (0.14.0)
+
+| Goal | Call | What comes back |
+| --- | --- | --- |
+| Isotope pattern | `isotope_pattern {formula or smiles or doc, objects?, threshold?}` | every peak's neutral mass, m/z and abundance; a charge may follow a space (`SO4 2-`) |
+| IR bands | `predict_ir_bands {smiles or doc, object?}` | characteristic bands by functional group, textbook ranges, labelled indicative |
+| MS fragments | `predict_ms_fragments {smiles or doc, object?}` | indicative EI fragment ions with their neutral losses |
+| HELM text | `export_helm {smiles or molfile or doc, object?}` | HELM version 2, refused when it would not read back |
+| Abbreviations | `abbreviation_list {label?, filter?}`; `abbreviation_define {label, smiles}` (one `*`, or `[*:1]`, `[*:2]`), `abbreviation_remove {label}` (built-ins refused) | the library; the two writes change the person's own library file and ask first |
+| Standardise | `standardise {smiles or doc, objects?, steps?, apply?}` | what the window's Standardise would do; it writes only with `apply: true` |
+
+Molecular weights use the CIAAW 2024 table and properties add Veber and Ghose; quote the method the answer gives. Typed labels such as CH2CH2OH are chemistry now, and a molecular formula typed on an atom stays text with its own note. Plain SMILES of a query structure is refused (`query_smiles_refused`): use SMARTS or a V3000 molfile through `convert`.
+
## Chemistry commands (run_command)
They act on the person's selection, or on the page when nothing is selected; the agent selects only with `select-all` or by inserting. Check `list_commands {id}` for params and the off reason first.
@@ -46,7 +59,7 @@ They act on the person's selection, or on the page when nothing is selected; the
1. **Context.** `get_context`; name the drawing and pick fragment ids from the tool answers, never by guess.
2. **Read with the tool, not the command.** For values, issues, labels or matches call the analysis tool; the command opens a panel the agent cannot read.
3. **Quote with the method.** Report each value as the tool printed it, with its unit and method ("cLogP 3.07, Crippen.MolLogP; typical error 0.5 to 0.7 log units"). Never compute a property, a CIP label or a SMARTS match with your own chemistry and present it as FormChem's.
-4. **Stereo states matter.** An `undefined` centre has no label because nothing fixes it; say so instead of guessing R or S. Allene axial chirality and drawn atropisomers are not perceived in this version.
+4. **Stereo states matter.** An `undefined` centre has no label because nothing fixes it; say so instead of guessing R or S. From 0.14.0 atropisomers and allenes get M or P from their wedges, listed as axes; SMILES, InChI and V2000 drop the axis, and the answer's note says so.
5. **Change through commands, then read back.** After `assign-wedges`, a stereo group or `add-hydrogens`, call `stereo` or `check_structure` again and report what changed, with Undo as the way back.
6. **Hand off** with what changed or what the person should look at (`handoff`).
diff --git a/.agents/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md b/.agents/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md
index cb82ea98..34c94ecb 100644
--- a/.agents/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md
+++ b/.agents/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md
@@ -52,6 +52,16 @@ Tight-binding total energies are in hartree for one structure, charge and solven
2. **Call `extract_ligand {object?, ligand?}`** with a key or het code, or nothing for the primary ligand. The answer gives the new fragment id and its SMILES, and whether bond orders came "from the template table" (30 common ligands) or were "inferred from the geometry". Say which; an inferred ligand's SMILES needs the person's eye.
3. **Check it** like any structure (`visual-qa`): `get_structure` and `validate` on the new fragment.
+## Workflow 3b: surfaces, terms, rotation, repair and PDB by id (0.14.0)
+
+- `compute_surface {object, conformer?, probe?, solvent?, resolution?}`: van der Waals, solvent-accessible and solvent-excluded areas (Ų) and volumes (ų), every hydrogen included; the SES area is an estimate and the answer says so. Reads only.
+- `energy_terms_3d {object, conformer?, method?}`: MMFF94 split into stretch, bend, stretch-bend, out-of-plane, torsion, van der Waals and electrostatics, adding up to the total; UFF gives the total only. Reads only.
+- `rotate_bond_3d {object, atoms, value?, angle?, side?}`: four atoms and `value` set a dihedral, two atoms and `angle` turn a bond; the smaller side moves, and a ring bond answers "Cannot rotate a ring bond." with nothing changed. One undo step.
+- `repair_hydrogens_3d {object, conformer?}`: adds missing and removes extra hydrogens without moving a heavy atom. One undo step.
+- `render_3d {object, width?, height?, transparent?, display?, surface?, labels?, hbonds?}`: a PNG drawn by the window's 3D View (needs the window); use it to check a 3D answer by eye.
+- `fetch_pdb {id, format?}`: downloads an RCSB entry by its four-character id and opens it as a 3D object; the id leaves the machine, so it asks the person like any change. Prefer a file the person already has.
+- Dihedrals read with the IUPAC sign from 0.14.0; numbers from 0.13.0 or before had the opposite sign.
+
## Workflow 4: export and show
- `export_3d {object, format, conformer?, output?}`: MOL (the shown conformer), SDF (default; every conformer, with energy and method data fields), PDB or XYZ, every hydrogen included. Without `output` the text comes back; with an absolute `output` it writes a new file and never overwrites.
diff --git a/.agents/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md b/.agents/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md
index de8c9a18..62237c0f 100644
--- a/.agents/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md
+++ b/.agents/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md
@@ -32,6 +32,7 @@ Most canvas commands act on the canvas selection. The agent sets the selection t
| Show it in 3D, change the 3D style or surface, put a 3D view on the page, save a 3D picture | Build and measure with the 3D tools (`three-d`). Then `view-3d` (opens the 3D View on the selection), `style-wire`, `style-stick`, `style-ballstick`, `style-spacefill`, `style-cartoon`, `surface-none`, `surface-vdw`, `surface-sas`, `surface-ses`, `surface-esp` (on only while the 3D View is open), `insert-3d-view` (a 3D object beside the selected structure), `export-3d-png {transparent}` and `export-gltf` (saved for the person). `export-3d-file {format, all}` saves MOL, SDF, PDB or XYZ for the person; `export_3d` gives the agent the text |
| Show the database, a view of it, its dialogs, or the notebook to the person | Work with the database tools (`databases`). Then `show-databases`, `db-view-table`, `db-view-gallery`, `db-view-form`, `db-view-plot`, `db-view-notebook`, `db-search {text}`, `db-import {path}`, `db-export`, `database-fields`, `database-settings` (the person's dialogs); `nb-sign-entry` asks the person to sign and is never run in their place |
| Copy a live structure for another Form app, open a library item for editing, HELM text of a drawn peptide, show the Structure Library or the Structure Summary, change the element colours | Library and HELM tools first (`library-and-biopolymers`). Then `copy-live-structure`, `open-live-structure {id, from}`, `copy-helm`, `structure-library {tab}`, `a11y-describe`, `element-palette-high-contrast` and its two siblings |
+| Show me the demos, an example to start from | `run_command {id: "demos"}` (Help > Demos, 0.13.0): Home at its five demos (aspirin, the two-step aspirin synthesis, the enantiomers, cholesterol in 3D, benzocaine with its 1H NMR). The person clicks one to open a new unsaved copy; then the drawing tools reach it like any drawing (`list_open_documents`) |
| Stack or group objects | `bring-front`, `bring-forward`, `send-backward`, `send-back`, `group`, `ungroup` on the selection; off with "Select something on the canvas first" when nothing is selected |
| Anything about the reaction in the drawing | Load `reactions` |
| Undo the last change | `run_command {id: "undo"}`: one transaction, whoever made it |
diff --git a/.agents/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md b/.agents/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md
index 2ef1d85c..a1bdc1c7 100644
--- a/.agents/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md
+++ b/.agents/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md
@@ -1,6 +1,6 @@
# Commands that touch a drawing
-The window's command registry, as far as it concerns drawings, for FormChem 0.12.0 (the commands of 0.7.0, plus `agent-activity` from 0.8.0, which opens Window > Agent Activity for the person, plus the name, spectrum and NMR commands of 0.9.0, the 3D commands of 0.10.0, the database and notebook commands of 0.11.0, and the library, live structure, HELM, xtb and accessibility commands of 0.12.0). From 0.8.0 the agent's own tools draw, edit, read back, render and convert; this page covers what the window's commands add. This page is a map, not the authority: `list_commands` is. A command marked `off now` there is not available in the running build, whatever this page says, and a command that lists `params` there takes exactly those.
+The window's command registry, as far as it concerns drawings, for FormChem 0.13.0 (the commands of 0.7.0, plus `agent-activity` from 0.8.0, which opens Window > Agent Activity for the person, plus the name, spectrum and NMR commands of 0.9.0, the 3D commands of 0.10.0, the database and notebook commands of 0.11.0, the library, live structure, HELM, xtb and accessibility commands of 0.12.0, and Help > Demos of 0.13.0). From 0.8.0 the agent's own tools draw, edit, read back, render and convert; this page covers what the window's commands add. This page is a map, not the authority: `list_commands` is. A command marked `off now` there is not available in the running build, whatever this page says, and a command that lists `params` there takes exactly those.
## Contents
@@ -17,6 +17,8 @@ The window's command registry, as far as it concerns drawings, for FormChem 0.12
- Databases and the notebook
- Library, live structures, HELM, xtb and accessibility
- The canvas, the view and the grid
+- Help > Demos (0.13.0)
+- The parity pass (0.14.0)
- Registered but off until a later version
- What no command does yet
@@ -29,7 +31,7 @@ The window's command registry, as far as it concerns drawings, for FormChem 0.12
| Command | Params | What it does |
| --- | --- | --- |
| `new-document` | | creates an empty drawing and makes it active (Home closes) |
-| `open-recent` | `path` (absolute) | opens that file: a `.fchem` drawing, a chemistry file (molfile, SD, RXN, RD, SMILES, CXSMILES, SMARTS, InChI, CML, CDXML, CDX) imported into a new unsaved drawing with an import report for the person, or a picture FormChem exported with its drawing inside; without `path` it shows Home |
+| `open-recent` | `path` (absolute) | opens that file: a `.fchem` drawing, a chemistry file (molfile, SD, RXN, RD, SMILES, CXSMILES, SMARTS, InChI, CML, CDXML, CDX, PDB, mmCIF, JCAMP-DX) imported into a new unsaved drawing with an import report for the person, a picture FormChem exported with its drawing inside, or an `.fcdb` database in the database workspace; the same path the desktop app uses for files the system hands it; without `path` it shows Home |
| `open` | | shows the file chooser to the person; an agent cannot answer it |
| `save` | | saves the active drawing; a drawing with no file yet asks the person for a name in the browser window |
| `save-as`, `save-copy` | | ask the person where or under what name |
@@ -230,9 +232,31 @@ From 0.12.0. Adding to the library, the live structure object, drawing from HELM
| `toggle-analysis`, `analysis-panel` | shows or hides the Analysis panel (formula, masses, m/z, elemental analysis from the engine, for the selection or the whole page) |
| `tool-select`, `tool-bond`, `tool-chain`, `tool-ring`, `tool-atom`, `tool-text`, `tool-eraser`, `tool-hand`, `tool-zoom`, `tool:[id]` | pick a drawing tool for the person; they do not draw by themselves |
+## Help > Demos (0.13.0)
+
+| Command | Params | What it does |
+| --- | --- | --- |
+| `demos` | none | shows Home scrolled to its Demos with the first card focused: Aspirin, Aspirin in two steps (scheme, stoichiometry amounts, curved-arrow mechanism), Enantiomers (L- and D-alanine, (S)- and (R)-ibuprofen with R and S labels), Cholesterol in 3D (three conformers and a 3D view), Benzocaine with its 1H NMR. The person clicks a card to open a new unsaved copy; no command or tool opens one for the agent |
+
+## The parity pass (0.14.0)
+
+The catalogue has 422 commands. Check `list_commands {id}` for each one's params before running it; the rows below are the groups, and the commands act on the selection or the active page like the others.
+
+| Commands | Do |
+| --- | --- |
+| `new-page`, `duplicate-page`, `delete-page`, `move-page-left`, `move-page-right`, `move-page {to}`, `next-page`, `previous-page`, `go-to-page {page}`, `page-setup`, `fit-page-to-drawing` | pages; `page-setup` with params sets size, orientation, auto-grow, margins, header and footer without the dialog (the `*_page` tools do the same and answer) |
+| `document-style`, `apply-style-document {preset, discard_overrides?}`, `apply-style-selection`, `export-style`, `import-style` | journal styles: `apply-style-document {"preset": "large-screen"}` rescales every structure to the preset |
+| `object-style`, `set-colour`, `text-bold`, `text-italic`, `text-underline`, `text-subscript`, `text-superscript`, `text-plain`, `text-formula`, `text-align-*`, `text-line-spacing`, `label-position-*`, `renumber-compounds`, `insert-heat`, `insert-light`, `insert-arrow-equals` | object and text formatting on the selection, label position, compound renumbering, heat, light and arrow-equals captions above the selected arrow |
+| `space-reaction`, `space-reaction-repeat`, `fit-arrow-to-conditions`, `conditions-as-footnotes`, `set-atom-map-number {map, sequence?}`, `reacting-formed`, `reacting-broken`, `reacting-order`, `reacting-stereo`, `reacting-unchanged`, `reacting-none` | scheme layout and mapping by hand (the scheme tools answer the agent directly) |
+| `atom-properties`, `toggle-atom-numbers`, `periodic-table-tool`, `toggle-circled-charges`, `toggle-lone-pair-bars`, `define-abbreviation`, `abbreviation-library` | atom display and the abbreviation library; the dialogs belong to the person |
+| `rotate-90-left`, `rotate-by-angle {degrees}`, `flip-keeps-wedges`, `fixed-bond-length`, `smart-guides`, `snap-atoms-to-grid`, `group-integral`, `select-scheme`, `join-atoms`, `fuse-ring {bond, size}`, `attach-template {id, atom?, bond?}`, `toggle-select-tool` | transforms, switches and gestures; `fuse_ring` and `attach_template` tools answer with the new ids |
+| `insert-glassware {id}`, `edit-table-cell`, `table-add-row`, `table-add-column`, `table-auto-grow`, `tlc-add-lane`, `tlc-duplicate-lane`, `tlc-delete-lane`, `tlc-lane-label`, `tlc-show-rf`, `tlc-rf-values` | glassware drawings, tables and TLC plates |
+| `export-tiff`, `export-jpeg`, `export-webp`, `print` (now a dialog), `save-undo-history`, `undo-agent-changes` | pictures and print hand their file or dialog to the person; `undo_agent_changes` is the agent's own way back |
+| `open-pdb-id`, `repair-hydrogens-3d`, `cancel-conformers`, `rotate-bond-3d`, `energy-terms-3d`, `surface-metrics-3d`, `colour-3d`, `labels-3d`, `hbonds-3d`, `binding-site-3d`, `projection-3d`, `periodic-table`, `constants-units` | the 3D View and the reference windows, for the person; the 3D tools answer the agent |
+
## Registered but off until a later version
-`demos` (0.13.0). Every 0.7.0, 0.9.0 and 0.10.0 placeholder is now a working command (`insert-name`, `view-3d`, `build-3d`, `minimize-3d` and `conformers` among them). Running an off one returns "is not available right now: Arrives in [version]". Say so; do not retry.
+None at 0.13.0: `demos` was the last placeholder. Every 0.7.0, 0.9.0 and 0.10.0 placeholder is a working command (`insert-name`, `view-3d`, `build-3d`, `minimize-3d` and `conformers` among them). If a command still answers "is not available right now: Arrives in [version]", say so; do not retry.
## What no command does yet
diff --git a/.agents/skills/formchem-skillset/EVALS.json b/.agents/skills/formchem-skillset/EVALS.json
index 15b53e67..98e289d2 100644
--- a/.agents/skills/formchem-skillset/EVALS.json
+++ b/.agents/skills/formchem-skillset/EVALS.json
@@ -1,6 +1,6 @@
{
"skill_name": "formchem-skillset",
- "notes": "Run in a FormChem checkout at 0.12.0 with CLAUDE.md present; evals 32 to 36 need no fixtures, and eval 35 must not install xtb. Expected behaviours are observable in the files read, the edits made and the commits.",
+ "notes": "Run in a FormChem checkout at 0.14.0 with CLAUDE.md present; evals 32 to 44 need no fixtures, eval 38 must not build a bundle, and eval 35 must not install xtb. Expected behaviours are observable in the files read, the edits made and the commits.",
"evals": [
{
"id": 1,
@@ -405,6 +405,94 @@
"Checks under 4x CPU throttling with a MutationObserver that a switch adds or removes no node and changes only fills",
"Writes the reason in frontend/HASHOUT_LOG.md, not in a comment"
]
+ },
+ {
+ "id": 37,
+ "name": "data-file-in-app",
+ "prompt": "I added a solvent density table to FormChem's stoichiometry service. It works from source but the desktop app says the table is missing. Fix it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads desktop and finds the app/data rule: the file belongs under backend/app/data and is read relative to the services folder with Path(__file__).resolve().parents[...]",
+ "Moves the read to that form instead of adding a new --add-data line or reading from the working folder or the repository root",
+ "Does not run pyinstaller or tauri build unless the task says so, and states that the frozen check (the file found in a built app) was not run if it was not"
+ ]
+ },
+ {
+ "id": 38,
+ "name": "associate-file-type",
+ "prompt": "Make FormChem's desktop app show up in Open With for .xyz files.",
+ "files": [],
+ "expected_behavior": [
+ "Loads desktop and changes the five places together: OPENABLE in src-tauri/src/main.rs, OPEN_EXTENSIONS in frontend/src/app/documents.ts, bundle.fileAssociations, Info.plist and the Linux MIME package",
+ "Adds the type as Viewer with rank Alternate, not Editor, and checks first that the engine can open an .xyz file",
+ "Runs cargo check under the lock after the config change and records what was not built (macOS, Windows) in the HASHOUT log"
+ ]
+ },
+ {
+ "id": 39,
+ "name": "add-home-demo",
+ "prompt": "Add a sixth demo to FormChem's Home: caffeine with its predicted 13C NMR spectrum.",
+ "files": [],
+ "expected_behavior": [
+ "Loads desktop and adds a FormChem JSON document under backend/app/data/demos plus its row in demos.json, baked with a scratch engine script outside the repository",
+ "Checks model.validate on the document and that GET /api/demos lists six demos with no error, without changing ui/home-demos.ts or home.ts",
+ "Leaves the browser demos under demos/ and frontend/src alone"
+ ]
+ },
+ {
+ "id": 40,
+ "name": "add-protecting-group-template",
+ "prompt": "Add a Boc protecting group to FormChem's built-in template library so people can drop it on an amine.",
+ "files": [],
+ "expected_behavior": [
+ "Loads annotations and refuses to add a single part to backend/app/data/templates, citing the owner's whole-molecule rule",
+ "Points to the abbreviation library (Boc is already there, services/chem/abbrev_data.py or abbrev.py) and Define Abbreviation for a new group",
+ "Changes no template JSON file"
+ ]
+ },
+ {
+ "id": 41,
+ "name": "space-reaction-gap",
+ "prompt": "In FormChem, Space Reaction leaves a 20 pt gap before the product instead of 14.4. Find the cause.",
+ "files": [],
+ "expected_behavior": [
+ "Loads reactions and reads services/chem/scheme.py space_reaction and _Spacer, and whether the window sent its drawn boxes",
+ "Reproduces on a scratch engine through the space route and reports the gaps and centre line as numbers",
+ "Keeps one algorithm for the window and agents, and leaves arrows stretched only at Perceive, Space and Fit"
+ ]
+ },
+ {
+ "id": 42,
+ "name": "ir-band-for-nitrile",
+ "prompt": "The predicted IR tab in FormChem shows no band for benzonitrile's C#N. Add it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads names-and-spectra and clean-room, and edits backend/app/services/spectra/ir_bands.py with a SMARTS written for FormChem and a textbook range",
+ "Copies no spectral table, keeps the method name, and checks benzonitrile through /api/chem/ir-bands on a scratch engine",
+ "Adds a backend HASHOUT entry"
+ ]
+ },
+ {
+ "id": 43,
+ "name": "export-tiff-colour",
+ "prompt": "FormChem's TIFF export comes out with swapped red and blue. Fix it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads formats-and-export and works in frontend/src/app/picture-raster.ts, adding no encoder dependency",
+ "Reads the exported file back with an outside reader in a scratch folder and compares pixels with the PNG export",
+ "Keeps every picture going through picture.ts pictureFile"
+ ]
+ },
+ {
+ "id": 44,
+ "name": "journal-style-selection",
+ "prompt": "Apply Style to Selection in FormChem also changes the bond length of unselected structures. Fix it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads canvas and reads app/style-commands.ts applyStyleDraft, where selection scope writes style overrides on the touched objects only",
+ "Checks in the window that only the selected fragment rescales and that one Undo restores it",
+ "Does not change the document style for selection scope"
+ ]
}
],
"trigger_evals": [
@@ -472,6 +560,20 @@
{"query": "FormChem's xtb job leaves its process running after cancel, look at services/xtb/runner.py", "should_trigger": true},
{"query": "Copy as HELM refuses a stapled peptide in formchem, fix the writer cuts", "should_trigger": true},
{"query": "draw oxytocin from HELM in FormChem for me", "should_trigger": false},
- {"query": "make FormDeck read the formai structure library folder", "should_trigger": false}
+ {"query": "make FormDeck read the formai structure library folder", "should_trigger": false},
+ {"query": "names work from source but not in the formchem desktop app, is the data folder bundled by freeze_backend", "should_trigger": true},
+ {"query": "double-clicking a .fcdb file does not open formchem on linux, check the desktop entry and the MIME package", "should_trigger": true},
+ {"query": "add a demo drawing to formchem's Home under backend/app/data/demos", "should_trigger": true},
+ {"query": "rebuild the formchem reactions browser demo after changing the stoichiometry panel", "should_trigger": true},
+ {"query": "open the FormChem aspirin demo for me and add a methyl group", "should_trigger": false},
+ {"query": "register a custom file extension with my Electron app on Windows", "should_trigger": false},
+ {"query": "formchem's Space Reaction puts the plus sign in the wrong place, look at scheme.py", "should_trigger": true},
+ {"query": "add a template to formchem's built-in library under backend/app/data/templates", "should_trigger": true},
+ {"query": "the predicted IR tab in formchem misses a carbonyl band", "should_trigger": true},
+ {"query": "formchem page strip and Page Setup header fields render wrong", "should_trigger": true},
+ {"query": "Apply Style to Document in formchem does not rescale the second page", "should_trigger": true},
+ {"query": "formchem TIFF or PDF/A picture export is broken", "should_trigger": true},
+ {"query": "space this reaction scheme in my FormChem drawing for me", "should_trigger": false},
+ {"query": "which journal style should I use for my ACS paper figures", "should_trigger": false}
]
}
diff --git a/.agents/skills/formchem-skillset/SKILL.md b/.agents/skills/formchem-skillset/SKILL.md
index 79679f99..97397eae 100644
--- a/.agents/skills/formchem-skillset/SKILL.md
+++ b/.agents/skills/formchem-skillset/SKILL.md
@@ -1,17 +1,17 @@
---
name: formchem-skillset
-description: "Guides development of the FormChem codebase, the FormAI family's chemical structure drawing suite. Use whenever a task changes, fixes or explains FormChem code: the document format (FORMAT.md, model.ts, model.py, ops), the RDKit service (identifiers, the 2D layout, CIP, stereo groups, abbreviations, queries, properties), reactions, file formats, the clipboard, the command line, the SVG canvas, annotations, names, NMR prediction, JCAMP-DX spectra, 3D (conformers, force fields, PDB, xtb and CREST), the structure database and notebook (.fcdb, search, import, signing hashes), live structures and the shared library (LIVE_STRUCTURES.md, formai:// links, edit-live), keyboard access and palettes, HELM, the shell, menus, extensions, the MCP server and agent tools, the Tauri shell, or a release and its CHANGELOG. Trigger on FormChem or formchem with backend/app, frontend/src, src-tauri, FORMAT.md or port 8220. Not for using FormChem (formchem-harness), other Form apps such as FormDeck, or standalone RDKit scripts."
+description: "Guides development of the FormChem codebase, the FormAI drawing suite. Use whenever a task changes, fixes or explains FormChem code: the document format (FORMAT.md, model.ts, model.py), the RDKit service (identifiers, CIP, abbreviations, queries), reactions and Space Reaction, file formats, picture export, page setup, headers and print, the clipboard, the command line, the SVG canvas, journal styles and text formatting, annotations, the template library of whole molecules, names, NMR, IR and MS prediction tables, JCAMP-DX spectra, 3D, PDB, xtb and CREST, the structure database and notebook (.fcdb, search, entry signing hashes), live structures (LIVE_STRUCTURES.md, formai:// links, edit-live), keyboard access, HELM, the shell, menus, extensions, MCP agent tools, the desktop app, files it opens, demos, or a release CHANGELOG. Trigger on FormChem or formchem with backend/app, frontend/src, src-tauri, FORMAT.md or port 8220. Not for using FormChem (formchem-harness), other Form apps, or standalone RDKit scripts."
license: Apache-2.0
metadata:
author: nodemode-ai
- version: "0.12.0"
+ version: "0.14.0"
---
# FormChem skillset
Route every change to FormChem's code through this file. It maps the subsystems that exist today, states the laws that hold everywhere and names the specialist to load. FormChem is a Python 3.12 FastAPI engine (`backend/`, port 8220), a vanilla TypeScript and Vite window (`frontend/`, port 5220, no framework) that talks to the engine over REST and one WebSocket, and a Tauri 2 shell (`src-tauri/`) that runs the frozen engine from a folder inside the app on macOS and as a sidecar elsewhere.
-**Where FormChem is (0.12.0).** Through 0.11.0: the shell, format, store and RDKit service, canvas, reactions, analysis, formats, agent tools, names, NMR, spectra, 3D, databases and the notebook (`CHANGELOG.md`). 0.12.0 adds live structures and the shared library (`docs/LIVE_STRUCTURES.md`), accessibility, HELM, xtb and CREST by path and six MCP tools (77). Desktop builds and the manual (0.13.0) come later (`DEV_PLAN.md`); do not write them ahead.
+**Where FormChem is (0.14.0, all fourteen phases built).** Through 0.11.0: the shell, format, store and RDKit service, canvas, reactions, analysis, formats, agent tools, names, NMR, spectra, 3D, databases and the notebook (`CHANGELOG.md`). 0.12.0 adds live structures and the shared library, accessibility, HELM and xtb and CREST by path. 0.13.0 adds files from the system, the whole `backend/app/data` in the frozen engine, the demos, `docs/MANUAL.md` and `docs/PARITY.md`. 0.14.0, the parity pass, adds Space Reaction and footnotes, predicted spectra tables, the whole-molecule template library and the Template tool, pages, headers and the Print dialog, condensed labels and atom numbers, journal styles and text formatting, journal-ready pictures, 3D terms, surfaces and crystals, and 27 MCP tools (104). Every v1 row of `docs/PARITY.md` is Full or a written Decision: read a row's Decision before building against it.
## Subsystem map
@@ -38,47 +38,13 @@ Route every change to FormChem's code through this file. It maps the subsystems
| Terminal and agent dock | `frontend/src/dock/` (vendored), `frontend/src/dock-adapter.ts`, `backend/app/routers/terminal.py`, `services/terminal.py`, `services/claude_code.py`, `services/agent_programs.py`, `services/agent_lookup.py` (vendored) | `dock` |
| Form extensions (host API 1) | `frontend/src/extensions/`, `backend/app/routers/extensions.py`, `services/formext_host.py` (vendored), `docs/EXTENSIONS.md` | `extensions` |
| MCP server, agent tools, the call log, Agent Activity, the token, the catalogue, skills | `backend/app/routers/mcp.py`, `services/agent_*.py`, `core/agent_token.py`, `routers/agent_activity.py`, `routers/commands.py`, `frontend/src/app/agent-*.ts`, `ui/agent-*.ts`, `canvas/agent-marks.ts`, `setup/mcp_stdio.py`, `setup/agents.py`, `docs/AGENTS.md`, `.claude/skills` | `agents` |
-| Desktop app, the macOS engine folder and the sidecar | `src-tauri/` (`packaged.rs`, `tauri.macos.conf.json`), `formchem_engine.py`, `setup/freeze_backend`, `lib.sh`, `desktop_*`, `build_app` | `desktop` |
+| Desktop app, the engine folder and sidecar, bundled data, file types, document icons, system-open; the demos | `src-tauri/` (`linux/`, `windows/`, `Info.plist`), `formchem_engine.py`, `setup/freeze_backend`, `desktop_*`, `build_app`, `app/system-open.ts`, `services/demos.py`, `ui/home-demos.ts`, `demos/` | `desktop` |
| Versions, changelog, notices, CI, formcompiler | `.docs/BRANCHING.md`, `CHANGELOG.md`, `NOTICE.md`, `setup/notices.py`, `.github/workflows/` | `release` |
| Where any FormChem feature may come from | the owner's clean-room specifications | `clean-room` |
## Dependency graph
-```text
-frontend commands/registry.ts -> nothing (DOM free; the cli and workers may import it)
-engine/model.ts, engine/ops.ts -> nothing (pure, DOM free; the contract)
-chem/ -> engine/model.ts only (pure, no t(), no DOM)
-engine/client.ts, session.ts -> model, ops, client-api, io/api, io/live
-canvas/render -> canvas/types.ts, engine/model, engine/ops (own geom, valence, rings); table.ts
- also chem/stoich.ts; marks-layer.ts also canvas/marks-options.ts
-engine/analysis-api.ts -> io/api, model, ops; the only caller of /api/analysis
-canvas/tools -> canvas/types.ts, engine/model, engine/ops, canvas/geom.ts
-canvas/view.ts, ui/tool-rail -> canvas/types.ts, hit.ts, selection.ts, ui/dom, ui/icons, i18n
-io/ -> registry only for the catalogue mirror
-ui/, dock-adapter, extensions -> io, ui/dom, ui/icons, i18n
-app.ts -> everything; the composition root (wiring only)
-backend services/model.py, ops.py -> nothing (pure; the contract)
-services/store.py -> model, ops, package, history, importers, hub; chem.derive imported lazily
-services/chem/ -> rdkit, indigo, model (never the store or routers)
-backend routers -> core, services (hub, bridge, library, store, chem, terminal, formext_host)
-mcp.py -> commands, extensions, consent, claude_code, bridge, hub, agent_token; agent_* lazily
-services/agent_*.py -> store, bridge, chem (agent_edits pure); agent_log hooks AFTER_CHANGE
-app/picture.ts -> canvas/render (a fresh renderer off screen), never the live canvas view
-app/clip-*.ts, import-files -> engine/model, ops, the export and parse routes; one paste plan (clip-data.ts)
-services/chem/writers, stream -> formats, report, io, rdkit, indigo (never the store)
-services/batch.py, app/cli.py -> chem/stream, records, standardise, depict, props (never routers or the store)
-services/pictures/ -> fontTools and the bundled fonts only
-services/names, nmr, spectra -> rdkit, numpy, chem (never routers); nmr registers its hook in spectra.source.PREDICTORS
-services/three_d -> rdkit, numpy, chem (never routers); store.apply_now runs three_d.stale
-services/database, notebook -> sqlite3, rdkit, numpy, chem (never routers or the document store)
-services/helm, xtb, describe -> rdkit, chem (xtb also three_d); xtb starts programs only as separate processes
-canvas/a11y -> canvas view and render, ui/a11y-announcer; installed before mountCanvas
-ui/view3d-lib.ts -> 3dmol by dynamic import only (nothing 3D at startup)
-window-only abilities -> reach the engine as window tools over /api/live (bridge.window_call)
-desktop shell -> frozen engine (formchem_engine.py) -> serves frontend/dist
-```
-
-The window reaches the engine only through `frontend/src/io/api.ts` (REST with the window key) and `io/live.ts` (`/api/live`). The engine never imports frontend code. A document change travels one way: a tool or command commits a transaction through the document client, the engine validates and applies it, then broadcasts `tx` and later `derived` to every window, which patches its mirror and its SVG.
+The full module graph is `references/dependency-graph.md`: read it before importing across folders. The three rules that matter most: `engine/model.ts`, `engine/ops.ts`, `services/model.py` and `ops.py` import nothing (the contract); `services/chem/` and every engine package below it never import the store or routers; the window reaches the engine only through `io/api.ts` and `io/live.ts`, and a change travels one way, as a transaction the engine applies and broadcasts.
## Laws for every change
@@ -105,9 +71,13 @@ The window reaches the engine only through `frontend/src/io/api.ts` (REST with t
| SMILES, InChI, formula, masses, implicit hydrogens, valence errors, warnings, 2D clean-up or layout, a structure file reader or writer, the derived cache | `chemistry-engine` |
| How a bond, label or wedge renders, a drawing tool, a hover key, hit testing, selection, zoom, the tool rail, canvas context menus | `canvas` |
| An arrow, bracket, shape, table, TLC plate, orbital, picture or caption, its handles and tool; z-order, groups, templates | `annotations`, with `canvas` for the laws it builds on |
-| Reaction roles, atom mapping, balance, the stoichiometry panel or grid, reaction SMILES or RXN, a reaction route, command or MCP tool | `reactions`, with `chemistry-engine` for RDKit and `agents` for a tool |
+| A template entry, the Template tool, glassware; pages, the page strip, Page Setup, headers and footers; table cells, TLC spots, Object Style | `annotations` (the whole-molecule rule, pages and objects) |
+| A journal style, Document Style, style files, text formatting keys, label position, vertical labels, the allene dot, mitre joins; atom numbers, Atom or Bond Properties, the periodic table picker, a gesture | `canvas` |
+| Reaction roles, atom mapping, balance, the stoichiometry panel or grid, reaction SMILES or RXN, a reaction route, command or MCP tool; Space Reaction, stretching, footnotes, wrapping, reacting-centre marks, the density table | `reactions`, with `chemistry-engine` for RDKit and `agents` for a tool |
+| A condensed label, the abbreviation library or Define Abbreviation; CIAAW weights, adducts, isotope resolution, found values, axial chirality, polymer formulas | `stereo-and-queries` |
+| The predicted 1H, 13C, IR or MS tables, solvent peaks, DEPT, IR bands, EI fragments | `names-and-spectra` |
| A CIP label, stereo group, wedge, abbreviation, hydrogen, query atom or bond, SMARTS, R-group, property, check issue or isotope peak; an `/api/analysis` route or tool | `stereo-and-queries` (`chemistry-engine` for the converter, `agents` for a tool) |
-| A file that opens wrong or loses something, an export or import report, a new format, File > Import, picture export, the drawing inside a picture, saving in the desktop app, print | `formats-and-export`, with `chemistry-engine` for RDKit and `clean-room` for a new format |
+| A file that opens wrong or loses something, an export or import report, a new format, File > Import, picture export (TIFF, JPEG, WebP, one-bit, SVG outlines, PDF/A), the drawing inside a picture, saving in the desktop app, the Print dialog, FASTA, superatom Sgroups, CDXML styling | `formats-and-export`, with `chemistry-engine` for RDKit and `clean-room` for a new format |
| Copy, Cut, Paste, Copy As, Paste Special, Duplicate, a clipboard flavour on one platform | `clipboard`, with `formats-and-export` for the text formats and pictures |
| `./formchem convert`, `batch`, `descriptors`, `render`, the stream reader, per-record failures, Standardise | `command-line`, with `chemistry-engine` for RDKit |
| A name read wrong, a dictionary entry, a ring parent, OPSIN; a predicted shift, an increment, a predictor; a JCAMP-DX file, the spectrum plot, peaks, integrals, atom links, the Spectrum editor | `names-and-spectra` (`clean-room` first; `canvas` for the renderer, `document-format` for the spectrum object) |
@@ -123,7 +93,7 @@ The window reaches the engine only through `frontend/src/io/api.ts` (REST with t
| Terminal tabs, Claude Code, Codex, Cursor or Antigravity tabs, the consent dialog, chat | `dock` |
| The extensions pane, an extension API call, FormPortal or form.ext integration | `extensions` |
| An MCP tool, an edit builder, agent render or placement, the call log, Agent Activity, Stop, the token, `./formchem agents`, skills | `agents` |
-| Desktop build, `build_app`, a slow start, the macOS engine folder, sidecar, updater, Tauri commands, title bar overlay | `desktop` |
+| Desktop build, `build_app`, a slow start, the engine folder, sidecar, updater, title bar overlay; a data file missing in the app; a file type, icon or double-click that does not open; a demo | `desktop` |
| A release, version sites, CHANGELOG, NOTICE, CI | `release` |
| Any chemistry feature, a file format, a name for a command or panel | `clean-room` first |
| Use FormChem: draw or edit a structure with the agent tools, run a menu command, hand off in the window | Not this pack: `formchem-harness` |
@@ -134,6 +104,8 @@ The window reaches the engine only through `frontend/src/io/api.ts` (REST with t
formchem-skillset/
SKILL.md this router, the subsystem map and the laws in short
references/repo-laws.md each law with its reason and exact format
+ references/dependency-graph.md which module may import which
+ references/running.md the commands for running, checking and scratch engines
EVALS.json evaluation prompts and the trigger tests (should and should not load)
sub-skills/ engine, document-format, chemistry-engine, reactions, stereo-and-queries, formats-and-export,
clipboard, command-line, names-and-spectra, three-d, databases, family-integration, canvas, annotations,
@@ -153,19 +125,7 @@ Paths inside a SUB-SKILL.md resolve against that sub-skill's folder; `references
## Running it
-```text
-./formchem install backend venv (backend/venv) and frontend packages
-./formchem engine 127.0.0.1:8220 and Vite on 5220 together
-./formchem backend | frontend one side
-./formchem serve built frontend served by the engine (FORMCHEM_DIST)
-./formchem doctor toolchain, installs and ports
-./formchem convert IN OUT the conversion command line (also batch, descriptors, render; docs/CLI.md)
-./formchem agents sync --check tools reference, skills mirror and agents/manifest.json in step
-cd frontend && npx tsc --noEmit type-check
-backend/venv/bin/python -m compileall -q backend/app setup
-```
-
-Scratch engines: `FORMCHEM_PORT=[port] FORMCHEM_DATA_DIR=[scratch]/data venv/bin/python -m uvicorn app.main:app --port [port]` from `backend/`; never point a check at `~/formchem`, the person's data folder.
+`./formchem` starts the engine (8220) and Vite (5220); `references/running.md` has every command a change needs (install, serve, doctor, convert, `agents sync --check`, `counts --check`, the type-check) and how to run a scratch engine that never touches `~/formchem`.
## Done means
diff --git a/.agents/skills/formchem-skillset/references/dependency-graph.md b/.agents/skills/formchem-skillset/references/dependency-graph.md
new file mode 100644
index 00000000..dbb8fa31
--- /dev/null
+++ b/.agents/skills/formchem-skillset/references/dependency-graph.md
@@ -0,0 +1,42 @@
+# FormChem dependency graph
+
+Which module may import which. Read it before adding an import across folders; an arrow that is not here is a new dependency and needs a reason in the HASHOUT log.
+
+```text
+frontend commands/registry.ts -> nothing (DOM free; the cli and workers may import it)
+engine/model.ts, engine/ops.ts -> nothing (pure, DOM free; the contract)
+chem/ -> engine/model.ts only (pure, no t(), no DOM)
+engine/client.ts, session.ts -> model, ops, client-api, io/api, io/live
+canvas/render -> canvas/types.ts, engine/model, engine/ops (own geom, valence, rings); table.ts
+ also chem/stoich.ts; marks-layer.ts also canvas/marks-options.ts
+engine/analysis-api.ts -> io/api, model, ops; the only caller of /api/analysis
+canvas/tools -> canvas/types.ts, engine/model, engine/ops, canvas/geom.ts
+canvas/view.ts, ui/tool-rail -> canvas/types.ts, hit.ts, selection.ts, ui/dom, ui/icons, i18n
+io/ -> registry only for the catalogue mirror
+ui/, dock-adapter, extensions -> io, ui/dom, ui/icons, i18n
+app.ts -> everything; the composition root (wiring only)
+backend services/model.py, ops.py -> nothing (pure; the contract)
+services/store.py -> model, ops, package, history, importers, hub; chem.derive imported lazily
+services/chem/ -> rdkit, indigo, model (never the store or routers)
+backend routers -> core, services (hub, bridge, library, store, chem, terminal, formext_host)
+mcp.py -> commands, extensions, consent, claude_code, bridge, hub, agent_token; agent_* lazily
+services/agent_*.py -> store, bridge, chem (agent_edits pure); agent_log hooks AFTER_CHANGE
+app/picture.ts -> canvas/render (a fresh renderer off screen), never the live canvas view
+app/clip-*.ts, import-files -> engine/model, ops, the export and parse routes; one paste plan (clip-data.ts)
+services/chem/writers, stream -> formats, report, io, rdkit, indigo (never the store)
+services/batch.py, app/cli.py -> chem/stream, records, standardise, depict, props (never routers or the store)
+services/pictures/ -> fontTools and the bundled fonts only
+services/names, nmr, spectra -> rdkit, numpy, chem (never routers); nmr registers its hook in spectra.source.PREDICTORS
+services/three_d -> rdkit, numpy, chem (never routers); store.apply_now runs three_d.stale
+services/database, notebook -> sqlite3, rdkit, numpy, chem (never routers or the document store)
+services/helm, xtb, describe -> rdkit, chem (xtb also three_d); xtb starts programs only as separate processes
+services/demos.py -> model; store and hub lazily (never routers); its data only from data/demos relative to services
+canvas/a11y -> canvas view and render, ui/a11y-announcer; installed before mountCanvas
+ui/view3d-lib.ts -> 3dmol by dynamic import only (nothing 3D at startup)
+app/system-open.ts -> ui/dom only; app.ts passes it the open function
+demos/ -> frontend/src as is, through Vite shims (io/api.ts becomes an offline stand-in)
+window-only abilities -> reach the engine as window tools over /api/live (bridge.window_call)
+desktop shell -> frozen engine (formchem_engine.py) -> serves frontend/dist
+```
+
+The window reaches the engine only through `frontend/src/io/api.ts` (REST with the window key) and `io/live.ts` (`/api/live`). The engine never imports frontend code. A document change travels one way: a tool or command commits a transaction through the document client, the engine validates and applies it, then broadcasts `tx` and later `derived` to every window, which patches its mirror and its SVG.
diff --git a/.agents/skills/formchem-skillset/references/running.md b/.agents/skills/formchem-skillset/references/running.md
new file mode 100644
index 00000000..1220e12a
--- /dev/null
+++ b/.agents/skills/formchem-skillset/references/running.md
@@ -0,0 +1,20 @@
+# Running FormChem while developing it
+
+The commands a change needs, from the repository root.
+
+```text
+./formchem install backend venv (backend/venv) and frontend packages
+./formchem engine 127.0.0.1:8220 and Vite on 5220 together
+./formchem backend | frontend one side
+./formchem serve built frontend served by the engine (FORMCHEM_DIST)
+./formchem doctor toolchain, installs and ports
+./formchem convert IN OUT the conversion command line (also batch, descriptors, render; docs/CLI.md)
+./formchem agents sync --check tools reference, skills mirror and agents/manifest.json in step
+./formchem counts --check the README size line in step with the code
+cd frontend && npx tsc --noEmit type-check
+backend/venv/bin/python -m compileall -q backend/app setup
+```
+
+Scratch engines: `FORMCHEM_PORT=[port] FORMCHEM_DATA_DIR=[scratch]/data venv/bin/python -m uvicorn app.main:app --port [port]` from `backend/`; never point a check at `~/formchem`, the person's data folder.
+
+On a shared machine, run heavy steps (type-check, build, browser checks) one at a time under a shared lock, and start a server outside that lock so it does not inherit it: a server started inside the lock holds it until it stops.
diff --git a/.agents/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md
index 15017f09..b7acb08b 100644
--- a/.agents/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md
@@ -33,7 +33,9 @@ Give agents an honest tool surface that only describes what FormChem can do now,
## The tool surface (0.12.0)
-77 tools: the six of the shell (`get_context`, `list_commands`, `run_command`, `extensions_list`, `extension_command`, `handoff`); the reaction tools of 0.5.0 and the analysis tools of 0.6.0 (owned by `reactions` and `stereo-and-queries`); and the 28 of 0.8.0: `list_open_documents`, `new_document`, `open_document`, `save_document`, `close_document`, `draw_from_smiles`, `draw_from_molfile`, `render`, `get_structure`, `validate`, `compute_properties`, `convert`, `batch_convert`, `get_atoms` and the 14 edit tools `add_atom`, `add_bond`, `set_charge`, `set_atom`, `set_stereo`, `replace_substructure`, `delete`, `move`, `scale`, `align`, `clean_layout`, `add_arrow`, `add_text`, `add_reaction`; and the 10 of 0.9.0, whose services `names-and-spectra` owns: `draw_from_name` (through `_draw`), `name_structure` (the route's `name_mol`), `predict_nmr`, `predict_spectrum` (`nmr.document.spectrum_ops`), `open_spectrum`, `spectrum_data`, `spectrum_peaks`, `spectrum_pick_peaks`, `spectrum_integrate` (`spectra.peak_ops`, `integral_ops`) and `spectrum_export`; and the 8 of 0.10.0, whose services `three-d` owns: `build_3d`, `conformers_3d`, `minimise_3d`, `scan_dihedral`, `measure_3d`, `open_3d_structure` (`three_d.open_bytes`) and `extract_ligand` call the `routers/three_d.py` functions through `_three_d` with an `AgentCall` in the body, so the route's `commit` applies with origin `agent` and the agent's name, and `export_3d` calls `export.write` directly. The writing ones are in `MUTATING` (`scan_dihedral` only with `store`, `export_3d` only with an `output` outside the temporary folder, through `_mutating`); a tool never builds its own copy of a route's ops. And the 11 of 0.11.0, whose services `databases` owns, in agent modules rather than in `mcp.py`: `services/agent_db.py` (`db_list`, `db_create`, `db_open`, `db_import`, `db_search`, `db_get_record`, `db_add_record`, `db_update_record`, `db_export`) and `services/agent_notebook.py` (`nb_add_entry`, `nb_search`). Each module offers `TOOLS` in the `_tool` shape, frozen `NAMES`, `mutating(name, args)` and `async call(name, args, agent_name)`, which runs the database services on a worker thread and writes as `agent:[name]`; `mcp.py` walks `AGENT_MODULES` for the list, the gate and dispatch, so a new module adds one name there. They touch no drawing (except `nb_add_entry {doc}`, which reads one), so they answer with `_ok` text and `structuredContent`, not `write_result`. And the 6 of 0.12.0, in three more agent modules: `agent_library.py` (`library_list`, `library_add`, `live_structure_object`; `family-integration` owns the service), `agent_helm.py` (`draw_from_helm`, through `mcp._draw`; `chemistry-engine` owns `services/helm`) and `agent_xtb.py` (`xtb_optimise`, `crest_conformers`, through `_three_d` with the xtb job routes; `three-d` owns `services/xtb`). HELM and xtb build `mcp.Agent("", agent_name)` in `call` because `_draw`, `_apply` and `_three_d` read only the name. `setup/agents.py` reads `mcp.py`'s own `TOOLS` by AST, and each agent module's finished `TOOLS` by importing it with the backend venv's Python (`_module_tools`), so `references/tools.md` and `agents/manifest.json` hold all 77 tools.
+104 tools (27 from 0.14.0, listed after this paragraph): the six of the shell (`get_context`, `list_commands`, `run_command`, `extensions_list`, `extension_command`, `handoff`); the reaction tools of 0.5.0 and the analysis tools of 0.6.0 (owned by `reactions` and `stereo-and-queries`); and the 28 of 0.8.0: `list_open_documents`, `new_document`, `open_document`, `save_document`, `close_document`, `draw_from_smiles`, `draw_from_molfile`, `render`, `get_structure`, `validate`, `compute_properties`, `convert`, `batch_convert`, `get_atoms` and the 14 edit tools `add_atom`, `add_bond`, `set_charge`, `set_atom`, `set_stereo`, `replace_substructure`, `delete`, `move`, `scale`, `align`, `clean_layout`, `add_arrow`, `add_text`, `add_reaction`; and the 10 of 0.9.0, whose services `names-and-spectra` owns: `draw_from_name` (through `_draw`), `name_structure` (the route's `name_mol`), `predict_nmr`, `predict_spectrum` (`nmr.document.spectrum_ops`), `open_spectrum`, `spectrum_data`, `spectrum_peaks`, `spectrum_pick_peaks`, `spectrum_integrate` (`spectra.peak_ops`, `integral_ops`) and `spectrum_export`; and the 8 of 0.10.0, whose services `three-d` owns: `build_3d`, `conformers_3d`, `minimise_3d`, `scan_dihedral`, `measure_3d`, `open_3d_structure` (`three_d.open_bytes`) and `extract_ligand` call the `routers/three_d.py` functions through `_three_d` with an `AgentCall` in the body, so the route's `commit` applies with origin `agent` and the agent's name, and `export_3d` calls `export.write` directly. The writing ones are in `MUTATING` (`scan_dihedral` only with `store`, `export_3d` only with an `output` outside the temporary folder, through `_mutating`); a tool never builds its own copy of a route's ops. And the 11 of 0.11.0, whose services `databases` owns, in agent modules rather than in `mcp.py`: `services/agent_db.py` (`db_list`, `db_create`, `db_open`, `db_import`, `db_search`, `db_get_record`, `db_add_record`, `db_update_record`, `db_export`) and `services/agent_notebook.py` (`nb_add_entry`, `nb_search`). Each module offers `TOOLS` in the `_tool` shape, frozen `NAMES`, `mutating(name, args)` and `async call(name, args, agent_name)`, which runs the database services on a worker thread and writes as `agent:[name]`; `mcp.py` walks `AGENT_MODULES` for the list, the gate and dispatch, so a new module adds one name there. They touch no drawing (except `nb_add_entry {doc}`, which reads one), so they answer with `_ok` text and `structuredContent`, not `write_result`. And the 6 of 0.12.0, in three more agent modules: `agent_library.py` (`library_list`, `library_add`, `live_structure_object`; `family-integration` owns the service), `agent_helm.py` (`draw_from_helm`, through `mcp._draw`; `chemistry-engine` owns `services/helm`) and `agent_xtb.py` (`xtb_optimise`, `crest_conformers`, through `_three_d` with the xtb job routes; `three-d` owns `services/xtb`). HELM and xtb build `mcp.Agent("", agent_name)` in `call` because `_draw`, `_apply` and `_three_d` read only the name. `setup/agents.py` reads `mcp.py`'s own `TOOLS` by AST, and each agent module's finished `TOOLS` by importing it with the backend venv's Python (`_module_tools`), so `references/tools.md` and `agents/manifest.json` hold every tool.
+
+The 27 of 0.14.0. In `AGENT_MODULES`: `agent_pages.py` (`list_pages`, `add_page`, `delete_page`, `set_page`, `fit_page_to_drawing`, `list_objects`, `undo_agent_changes`, which mutates only with `step`), `agent_abbrev.py` (`abbreviation_list`, `abbreviation_define`, `abbreviation_remove`), `agent_standardise.py` and `agent_balance.py` (`standardise`, `balance_reaction`, mutating only with `apply`), `agent_isotopes.py` (`isotope_pattern`) and `agent_helm_out.py` (`export_helm`), and `services/three_d/agent.py`, imported as `agent_three_d` (`compute_surface`, `energy_terms_3d`, `rotate_bond_3d`, `repair_hydrogens_3d`, `render_3d` through the window tool `render3d`, `fetch_pdb`). In `mcp.py` itself: `fuse_ring` and `attach_template` run the window's commands through `commands.execute` (`_window_verb`) and need a window; `space_reaction`, `fit_arrows_to_conditions` and `conditions_as_footnotes` reuse `routers/reactions._space`, `scheme.stretch_ops` and `scheme.footnote_ops` under `_apply`; `predict_ir_bands` and `predict_ms_fragments` read SMILES or a drawn fragment (`_predicted`). `setup/agents.py` `tools_data` resolves module names through `mcp.py`'s from-imports, so an aliased import such as `agent_three_d` still syncs. Reasons: `backend/HASHOUT_LOG.md` 303, 318, 319, 328, 329.
## Laws of the agent tools
diff --git a/.agents/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md
index c4cd61bd..eacda968 100644
--- a/.agents/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md
@@ -38,8 +38,21 @@ Draw every non-chemistry object from the document alone, patch it like a bond, a
- **Captions follow their target.** With `target` and `offset` the caption is placed from the target's drawn box; `x`, `y` are a cache that `transform.ts` refreshes in the same transaction when the target moves, and moving the caption rewrites `offset`.
- **Z-order is per container.** Page order and a group's `children` move separately with `move` ops computed on a working copy; a group's members are in no page order and are removed with the group.
- **Templates and glassware are original data.** Nothing from another product's library (`clean-room`); fresh ids on every insert, fragments scaled to the drawing's bond length, shapes kept at size.
+- **The template library holds whole molecules only (the owner's rule, 0.14.0).** `data/templates/*.json` is starter molecule structures and whole real molecules, not single parts: no protecting group, linkage, bare skeleton or generic projection (groups belong in `services/chem/abbrev_data.py`, glassware in `data/templates/glassware/`, which `templates._files` never globs). Every entry carries its `inchikey`, checked against the compound's published record and against the key the engine builds (Haworth and Fischer drawings: the connectivity layer plus each substituent's side). Keep an existing id when the compound stays.
- **Media is two steps.** POST stores bytes and returns the record; the window's one transaction lists `media[id]` and adds the image; the package writes only listed ids.
+## Templates, pages and objects (0.14.0)
+
+| Path | Role |
+| --- | --- |
+| `services/templates.py` `glassware_catalogue`, `_catalogues`; `routers/templates.py` `/api/glassware` | one cached catalogue per kind; `ui/glassware-dialog.ts` reuses the template cards |
+| `canvas/tools/template.ts` `attachAtAtom`, `fuseOnBond`; `ui/template-dialog.ts` `armForCanvas` | the Template tool: anchors from the structure (the `*` atom or least connected atom; the first ring bond), mirrored to the emptier side, atoms within 0.25 bond lengths merged |
+| `app/documents.ts` page edits; `canvas/view.ts` `pageBox`, `placeFurniture`; `ui/page-strip.ts`, `page-setup-dialog.ts`, `page-furniture.ts`; `app/page-commands.ts`; `styles/pages.css` | pages as single transactions (duplicate through `extractClip` and `pastePlan` for fresh ids), auto-grow both ways, the keyed page strip with a 30 px inset, headers and footers as HTML on the paper and `furnitureSvg` for print |
+| `canvas/table-edit.ts`, `canvas/tools/tlc.ts`, `ui/object-style-dialog.ts`, `app/annotation-commands.ts` | cell editing with Tab and auto-grow in the text's own transaction; TLC drag, Alt duplicate, Shift resize, lane reorder and labels on the renderer's `tlcLayout`, `data.rf` on every edit; Object Style for stroke, fill, gradient, opacity, shadow, orbital fill and phase |
+| `services/agent_pages.py` | `list_pages`, `add_page`, `delete_page`, `set_page`, `fit_page_to_drawing`, `list_objects` |
+
+Gate additions: three pages after New and Duplicate with fresh ids and 0 strip rebuilds on page switches; auto-grow moves no atom; Tab past the last cell adds a row in one undo step; a TLC drag changes `data.rf`. PARITY Decisions to respect: no layers, no gel object, no pen tool, no linked images (A-2.6, A-2.3.9, A-7.4.1, A-2.3.11). Reasons: `frontend/HASHOUT_LOG.md` 311, 312, 333 to 338, `backend/HASHOUT_LOG.md` 288 to 290, 328.
+
## Procedure
1. For a drawing fault, build a scratch drawing outside the repo with one of each kind and open it in the built window served by the engine; watch it under 4x CPU throttling with a MutationObserver over `.fc-app`.
diff --git a/.agents/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md
index cd2b126c..132c19ed 100644
--- a/.agents/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md
@@ -47,6 +47,19 @@ Let the person draw at the speed of thought while the document stays the only tr
**The document is the state.** Selection and hover live in the view; everything else is read from `client.view` (the mirror with any preview applied). Implicit hydrogens and double bond sides come from local rules until `derived` for the current revision arrives (`chemistry-engine`).
+## Gestures, labels and styles (0.14.0)
+
+| Path | Role |
+| --- | --- |
+| `tools/build.ts` `BOND_KINDS`, `isFull`, `valenceRoom`, `isCrowded`, `RingSpec.shape`, `toggleKekule`, `ringThrough`; `tools/ring.ts` `circleRing`, `RING_DRAG_STEP`; `tools/bond.ts` `cycleOrder`; `tools/modes.ts` | quadruple, hollow, plain hashed and crossed bonds (no format change), clicks that stop at full valence with a hint, the crowded flag under 60 degrees, cyclopentadiene and chair rings, Mod+click circle, Shift+click Kekule, ring drag in 15 degree steps, double-click order cycling as one undo step, remembered Fixed Bond Length, Flip Keeps Wedges and Smart Guides |
+| `tools/select.ts` `drillTarget`, `parentSelection`, `integralIn`, `schemeSelection`, `rotateDraft`, `smartGuides`, `joinAtoms`, `NUDGE`; `canvas/a11y/controller.ts` | drill-down, Escape up, integral groups, triple-click, the Alt+click pivot, guides for non-chemical drags, Join Atoms (`Shift+Mod+J`, since the dock keeps `Mod+J`), nudges 1, Alt 10, Shift 0.1 pt after a pointer click |
+| `tools/hotkeys.ts` `setHoverPanels`, `onPendingElement`; `ui/atom-properties.ts`, `bond-properties.ts`, `periodic-grid.ts` `ELEMENT_TOOL_DEF`; `render/atom.ts` | hover `'`, `/`, `=` and Enter-with-nothing-hovered without importing a dialog; the pending element tip; atom numbers from `show_number` and `number` (the window writes `number` explicitly; the renderer passes no index) |
+| `app/style-commands.ts` `applyStyleDraft`, `parseStyleFile`; `ui/style-dialog.ts`, `colour-picker.ts` | journal styles applied to a document (each fragment rescaled about its own centre) or a selection (`style` overrides), `.fcstyle` files, the emphasis red |
+| `render/label.ts` `verticalSide`, `LabelModel.centred`; `render/bond.ts` `mitreHalves`, `wedgeCorner`; `render/text.ts`; `text-editor.ts` `openRuns`; `tools/label.ts` | vertical labels and the allene dot (style values), centred labels, butt caps with mitre kites capped at 2 x line width, cut wedge and bold ends, justified text, the normal override, the formatted editor for texts and captions (atom labels stay plain strings) |
+| `tools/draft.ts` `moveAtoms`, `BULK_MOVE`; `render/renderer.ts` `SWEEP_AT` | one atoms op for 8 or more moved atoms and one crossing sweep past 48 dirty bonds (a 2,083-atom nudge went from 12.3 s to 0.8 s) |
+
+Rules: a key added here goes into `references/hover-keys.md` and must not clash (Help > Keyboard Shortcuts lists conflicts, and the map is fixed by PARITY A-5.1.9); a new style value is a contract change in FORMAT.md, `model.ts` and `model.py` together. Reasons: `frontend/HASHOUT_LOG.md` 313 to 332 and 350.
+
## Adding a tool
1. Implement `Tool` in `canvas/tools/[name].ts` against `ToolContext` only; add a `ToolDef` to `TOOLS` with a canonical group (`select`, `bond`, `chain`, `ring`, `atom`, `text`, `eraser`, `hand`, `zoom`) and an icon the rail draws.
diff --git a/.agents/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md b/.agents/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md
index 83a0e1f7..1d59325f 100644
--- a/.agents/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md
+++ b/.agents/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md
@@ -40,6 +40,10 @@ Every hover key commits one transaction. Two-letter elements and charge keys car
| . | toggle a radical dot |
| : | add a lone pair (cycles 0 to 4) |
| Enter | type a label (opens the text editor at the atom) |
+| ' | show or hide the atom number: writes `show_number` and an explicit `number` (0.14.0) |
+| / | Atom Properties through the panel `setHoverPanels` registered (0.14.0) |
+| = | the abbreviation picker with a drawn preview; condensed labels read by the engine (0.14.0) |
+| Enter with nothing hovered | reopen the label box at the last atom a hover key touched, with the last label (0.14.0; type-checked, not driven) |
| Space | revert to implicit carbon |
| Delete, Backspace | delete the atom and its bonds |
@@ -60,14 +64,17 @@ Every hover key commits one transaction. Two-letter elements and charge keys car
| Shift+3 to Shift+8 | fuse a saturated ring of that size |
| Shift+B | fuse a benzene ring |
| Delete, Backspace | delete the bond and any bare carbon left alone |
+| / | Bond Properties (0.14.0) |
+
+While the first letter of a two-letter element waits, `onPendingElement` reports the reading and `PendingTip` (in `ui/atom-properties.ts`) shows it near the pointer. While an atom or bond is hovered the status bar says its keys act on it (`setHint`, written only on change).
## Tool keys (nothing hovered)
The rail registers one command per group (`tool-select` V, `tool-bond` B, `tool-chain` C, `tool-ring` R, `tool-atom` A, `tool-text` T, `tool-eraser` E, `tool-hand` H, `tool-zoom` Z), `tool-[group]-next` on Shift plus the group key to cycle inside a group, and `tool:[id]` for every tool with its own `keys` (L for the lasso). A group key picks the group's tool that has no key of its own, so V means select even after L picked the lasso. `ToolDef.keys` are tool-switch keys only; hover keys never go there.
-## Keys left free
+## Keys outside the map
-Atom `'` (atom numbers), `/` (properties panel) and `=` (abbreviation picker) return false today so the canvas can bind them when that UI lands.
+From 0.14.0 Help > Keyboard Shortcuts shows both hover tables and a Key conflicts section (command keys shared by two commands, and tool letters that are also hover keys). The map is fixed, not editable (PARITY A-5.1.9). `Mod+J` and `` Mod+` `` belong to the terminal dock (`dock-adapter.ts` `isDockChord`), arrows nudge the selection unless the keyboard cursor was placed by Tab or Focus Structure, and the browser keeps `Mod+N`, `Mod+W` and `Shift+Mod+J` in a tab. The full bound-key list is the wiki page Keyboard Shortcuts.
## Changing the map
diff --git a/.agents/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md
index 2006b054..194da692 100644
--- a/.agents/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md
@@ -1,6 +1,6 @@
---
name: desktop
-description: "FormChem's Tauri 2 desktop shell: tauri.conf.json and tauri.macos.conf.json, the Rust entry point and its modules (engine start from the macOS engine folder or the sidecar, packaged.rs, splash-to-window reveal, macOS traffic lights, the Windows job object, clipboard access), the frozen engine formchem-engine built with PyInstaller (a flattened one-folder on macOS, one file elsewhere), the Tauri CLI pin, the updater and the desktop scripts. Use when the desktop app is slow to open or will not start, the engine fails or keeps running, a frozen build misses a module or data folder, the title bar or traffic lights are wrong, the splash hangs, or a desktop build or updater setting changes."
+description: "FormChem's Tauri 2 desktop shell: tauri.conf.json and tauri.macos.conf.json, the Rust entry point and its modules (engine start from the macOS engine folder or the sidecar, packaged.rs, splash-to-window reveal, macOS traffic lights, the Windows job object, clipboard access), the frozen engine formchem-engine built with PyInstaller (a flattened one-folder on macOS, one file elsewhere), the Tauri CLI pin, the updater and the desktop scripts, the engine's bundled data folder (app/data), file associations and document icons, files the system hands the app (system-open.ts), and the demos (Home's demos under backend/app/data/demos, browser demos under demos/). Use when the desktop app is slow to open or will not start, the engine fails or keeps running, a frozen build misses a module or data file, a double-clicked file does not open, a file type or icon changes, a demo is added or rebuilt, the title bar or traffic lights are wrong, the splash hangs, or a desktop build or updater setting changes."
---
# Desktop
@@ -21,7 +21,15 @@ Wrap the same window and engine in a native app: a thin Rust shell that starts t
| `src-tauri/src/reveal.rs` | Splash to window: the page calls `app_ready` with its background colour once painted; the splash closes after `window.formchemSplashDone()` |
| `src-tauri/src/traffic_lights.rs` | macOS overlay title bar: traffic lights placed in the 38 px title row |
| `src-tauri/src/win_job.rs` | Windows job object so the engine dies with the app |
-| `src-tauri/Cargo.toml`, `Cargo.lock`, `capabilities/`, `Info.plist`, `entitlements.plist`, `flatpak/` | Crate, permissions, macOS plist and entitlements, Flatpak manifest and AppStream metainfo |
+| `src-tauri/Cargo.toml`, `Cargo.lock`, `capabilities/`, `entitlements.plist`, `flatpak/` | Crate, permissions, macOS entitlements, Flatpak manifest (installs the MIME package and document icons from the deb) and AppStream metainfo (`provides/mediatype`, release lines) |
+| `src-tauri/Info.plist` | Merged over Tauri's generated plist: `CFBundleDocumentTypes` with `CFBundleTypeIconFile`, `UTExportedTypeDeclarations` with `UTTypeIconFile` (0.13.0) |
+| `src-tauri/linux/formchem.desktop`, `ai.nodemode.formchem.xml` | Desktop entry template (`Exec=... %U`) and the shared-mime-info package, both installed by the deb and rpm (0.13.0) |
+| `src-tauri/windows/hooks.nsh`, `tauri.windows.conf.json` | NSIS post-install hook pointing FormChem Document and FormChem Database at their `.ico`; the Windows resources (0.13.0) |
+| `src-tauri/icons/documents/`, `assets/icon_src/build.py` | `.fchem` and `.fcdb` document icons (PNG 16 to 512, `.ico`, `.icns`), written by `document_icon` from the owner's masters (0.13.0) |
+| `frontend/src/app/system-open.ts` | `registerSystemOpen(open, shown)`: reads `?open=` once, defines `window.__formchemOpen`, opens paths in order through `docs.openPath`; Tauri only (0.13.0) |
+| `backend/app/services/demos.py`, `routers/demos.py`, `data/demos/` | Home's demos: the manifest, five drawings, previews drawn as SVG, `GET /api/demos`, `POST /api/demos/{id}/open` as a fresh unsaved copy (0.13.0) |
+| `frontend/src/ui/home-demos.ts` | `mountHomeDemos` (reserved slots keyed by id), `openDemo`; Help > Demos calls `home.showDemos()` (0.13.0) |
+| `demos/` (`shared/`, `drawing/`, `reactions/`, `3d/`) | Offline browser demos on the window's code, each with README, CREDITS and HASHOUT_LOG; `demos/tsconfig.json` type-checks them (0.13.0) |
| `backend/formchem_engine.py` | Frozen engine entry; `--selfcheck`; `MODULES` (fastapi, uvicorn, keyring, rdkit, indigo) |
| `setup/freeze_backend`, `setup/install_desktop`, `setup/desktop_dev`, `setup/desktop_build`, `setup/desktop_check`, `build_app` (each with a `.bat` twin) | Freeze, toolchain, dev run, build, checks |
| `setup/lib.sh` | `fc_engine_folder` (copy to `src-tauri/engine`, flatten, sign, `--selfcheck`), `fc_flatten_engine`, `fc_sign_engine`; shared by `freeze_backend` and `build_app` |
@@ -31,7 +39,8 @@ Wrap the same window and engine in a native app: a thin Rust shell that starts t
- The window is the same `frontend/dist`; desktop-only behaviour is detected (`inTauri()`), never forked into a second UI.
- macOS: overlay title bar with a hidden title; the pre-paint boot sets `has-overlay-titlebar` so the row never jumps from 44 to 38 px. Native menus unless Menus in Window is on.
- The engine is `formchem-engine` everywhere: the sidecar (plus the target triple in `src-tauri/binaries/`) on Linux and Windows, the program inside `src-tauri/engine` on macOS. RDKit and Indigo are collected whole and fontTools' submodules collected when freezing.
-- A frozen module or data folder must be added to `setup/freeze_backend`, its `.bat` twin and `build_app`'s own PyInstaller call, which runs separately: entries 98 and 117 of the backend log record two misses of this kind.
+- **Engine data lives under `backend/app/data/` and is read relative to the services folder** (`Path(__file__).resolve().parents[1] / "data"` from `services/`, `parents[2]` one level deeper). `build_app`, `setup/freeze_backend` and `freeze_backend.bat` bundle the whole folder at `app/data`, so a new data file ships with no setup change. Never read data from the working folder or the repository root (only `services/templates.py` keeps its older `templates` resource path): the 0.10.0 to 0.12.0 desktop apps carried only `data/templates`, so names knew no common names and every HELM call failed (backend entry 279).
+- A frozen module or a folder outside `backend/app/data` must still be added to `setup/freeze_backend`, its `.bat` twin and `build_app`'s own PyInstaller call, which runs separately: entries 98 and 117 of the backend log record two misses of this kind.
## The one-folder engine on macOS
@@ -50,7 +59,21 @@ A PyInstaller one-file engine unpacks everything (several hundred MB, over 400 l
`@tauri-apps/cli` is a pinned dev dependency in `frontend/package.json` (2.12.6). The rule: its major.minor equals the `tauri` crate's in `src-tauri/Cargo.lock` (2.12.7), and each `@tauri-apps/plugin-*` package shares major.minor with its `tauri-plugin-*` crate; bump them together in one change, with `package-lock.json`. Tauri refuses to build across minor versions. Until 0.6.0 package.json did not list the CLI, so `npm ci` installed no `tauri` binary and `./build_app` stopped with "the Tauri CLI did not install"; with the pin, the owner's `./build_app` on macOS arm64 (Python 3.14) built the app.
-`build_app` checks in order: the system (Xcode Command Line Tools, or WebKitGTK 4.1 on Linux), Python 3.12 or newer, Node 20.19 or newer, one Rust install matching the machine, `THIRD-PARTY-NOTICES.txt`, the engine and window packages (reinstalled when their lock or the toolchain changes), the Tauri CLI binary and the version rule above, then builds the window, freezes the engine with the window, the notices and `backend/app/data/templates` (`--add-data`, the same as `setup/freeze_backend`), runs the frozen engine's `--selfcheck` (on macOS through `fc_engine_folder` in a subshell that sources `setup/lib.sh`), and bundles. A data folder the engine reads when frozen must be added to both `build_app` and `setup/freeze_backend` (and its `.bat`), or the desktop app ships without it.
+`build_app` checks in order: the system (Xcode Command Line Tools, or WebKitGTK 4.1 on Linux), Python 3.12 or newer, Node 20.19 or newer, one Rust install matching the machine, `THIRD-PARTY-NOTICES.txt`, the engine and window packages (reinstalled when their lock or the toolchain changes), the Tauri CLI binary and the version rule above, then builds the window, freezes the engine with the window, the notices, `backend/app/data/templates` at `templates` and `backend/app/data` at `app/data` (`--add-data`, the same as `setup/freeze_backend`), runs the frozen engine's `--selfcheck` (on macOS through `fc_engine_folder` in a subshell that sources `setup/lib.sh`), and bundles. A data file under `backend/app/data` ships through `app/data`; anything else the frozen engine reads must be added to both `build_app` and `setup/freeze_backend` (and its `.bat`), or the desktop app ships without it.
+
+## Files from the system and file associations
+
+The shell turns launch arguments (Linux, Windows), `RunEvent::Opened` (macOS) and second launches (the single-instance plugin) into absolute paths with `system_paths` (relative paths join the working folder, `file://` becomes a path), keeps those whose extension is in `OPENABLE`, and passes them as `?open=` at launch or through `window.__formchemOpen` later. `registerSystemOpen` opens them one at a time through `docs.openPath`, the Open Recent path, so an `.fcdb` reaches the database workspace; `shown` (`dbws.hide`) runs after a drawing opens so it comes to the front. Before 0.13.0 no page code read either channel and nothing opened.
+
+- A type lives in five places, kept in step by hand: `OPENABLE` (`main.rs`), `OPEN_EXTENSIONS` (`app/documents.ts`), and when associated `bundle.fileAssociations`, `Info.plist` and the MIME package.
+- FormChem's own types (`.fchem`, `.fcdb`) are Editor with their own MIME type and exported UTI; every other type is Viewer, rank Alternate, so FormChem never takes it from its owner. Do not associate a type the engine cannot open (`.helm` is out); `.dx` and `.ent` open when handed over but are not associated.
+- Document icons per platform: macOS through `Info.plist` and the `.icns` resources; deb and rpm through hicolor `mimetypes` icons named `ai.nodemode.formchem.document` and `.database` (the app-id prefix is what Flatpak exports); NSIS through `hooks.nsh`. The MSI has no hook (app icon), and an AppImage cannot register types or icons at all.
+- The desktop entry keeps `%U`, not `%F`, so `formai://` links reach the deep link plugin.
+- `./formchem desktop check` fails early when a document icon, the MIME package or the desktop entry is missing; add any new bundled file there too.
+
+## Demos
+
+Two kinds, both new in 0.13.0. **In the app:** `backend/app/data/demos/demos.json` lists id, file, title, description and kind; each drawing is plain FormChem JSON that `model.validate` accepts, and opening one makes a copy with a fresh id, no path and not dirty, so the shipped file is never written. To add one, bake the drawing with the engine (a scratch script, outside the repository), add its manifest row, and check `GET /api/demos` lists it with no error; Home picks it up with no window change. **In the browser:** `demos/[name]/` builds with `cd frontend && npx vite build --config ../demos/[name]/vite.config.ts` (under the heavy lock); `demos/shared/vite-base.ts` swaps `io/api.ts` for `offline-api.ts`, drops locales and `/fonts/`, stubs Tauri and 3Dmol, and emits one IIFE so the page runs from `file://`. Never edit `frontend/src` to suit a demo; check from `file://` with the network blocked and keep each built folder under 6 MB.
## Gate
@@ -58,3 +81,5 @@ A PyInstaller one-file engine unpacks everything (several hundred MB, over 400 l
- [ ] The desktop dev run opens the window without a white flash and the engine answers `/api/health` on its port.
- [ ] Quitting the app ends the engine process on every platform touched.
- [ ] On macOS: `src-tauri/engine` has the program, no symbolic link and no `.framework`, and `otool -L` finds nothing linking `Python.framework`.
+- [ ] A new data file is under `backend/app/data` and read relative to the services folder; in a built app Structure from Name draws caffeine, HELM draws `PEPTIDE1{G.G}$$$$` and Home shows the five demos.
+- [ ] A changed file type is in all five places, and a file of that type opens at launch and when sent to the running app.
diff --git a/.agents/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md
index 89c75ae7..83d28b64 100644
--- a/.agents/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md
@@ -38,6 +38,9 @@ Move drawings in and out of FormChem without losing anything silently. Every rea
- **Indigo is a bridge, not a source.** CDXML and CDX go through Indigo's KET JSON; FormChem's code, names and samples come from public specifications only (`clean-room`). Do not test against files made by the commercial program unless the owner supplies them.
- **Freeze both paths.** fontTools loads table modules by tag, so `--collect-submodules fontTools` must be in `setup/freeze_backend`, its `.bat` twin and `build_app`'s own freeze. Without fontTools, `/api/pictures/capabilities` says `fonts: false` and PDF and EPS lose their text.
- **Documents read at most 1000 records**, File > Import 50 by default; batch work uses the stream reader (`command-line`).
+- **One picture path (0.14.0).** Every picture goes through `fe/app/picture.ts` `pictureFile`; TIFF (FormChem's own LZW writer), one-bit PNG and the JPEG density patch live in `picture-raster.ts`, so no encoder dependency is added. SVG, PNG, PDF and EPS keep the drawing; TIFF, JPEG, WebP and PDF/A-2b cannot (PDF/A-2 allows only PDF/A attachments). SVG outlines (`services/pictures/svgout.outline_text`) work on the SVG text itself, so the rest stays byte for byte; WebKit cannot encode WebP, so it is refused there. Export Picture starts from Preferences > Files every time and keeps its height for every format. Full-page pictures and print draw the page header and footer (`PictureOptions.furniture`).
+- **Print is a dialog (0.14.0).** `app/print.ts` `PrintDialog` and `printLayout`: paper, scale, tiling with 10 pt overlap up to 64 sheets, crop marks, a preview whose sheet nodes are reused, never rebuilt. One page at a time (PARITY A-13.4).
+- **Reading and round trips (0.14.0).** `io._decode` is the one text decoder (BOMs, BOM-less UTF-16, UTF-8, Windows-1252, Latin-1; never replacement marks); FASTA becomes HELM and then atoms (`io._read_fasta`, 300 residues, 20 records); abbreviations are written as SUP Sgroups and read back as labels only when the atoms canonicalise to the library entry; CDXML styling is added after Indigo by `cdxio._restyle` (fonts, sizes, faces, colours, atom and bond colours; binary CDX untouched). Copy adds a molfile flavour and `data-molfile` in the HTML (`clip-system.ts`). Reasons: `backend/HASHOUT_LOG.md` 320 to 324, `frontend/HASHOUT_LOG.md` 339 to 342.
## Adding a format
diff --git a/.agents/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md
index 44920167..adf0e49c 100644
--- a/.agents/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md
@@ -82,6 +82,10 @@ Change FormChem's names, NMR prediction and spectra without breaking the three p
Write it from the published rules, not from another reader. Report what you repair or skip through `issues.py` with a code, a line and a sentence; add a synthetic file that exercises it to the scratch corpus (outside the repo) and confirm every existing corpus file still reads identically, and that `export.py` output re-reads with an empty report.
+### The predicted spectra tables (0.14.0)
+
+`frontend/src/ui/analysis-spectra.ts` (its own `styles/analysis-spectra.css`) is the Analysis panel's 1H, 13C, IR and MS section, mounted by the NMR lines in `ui/analysis-panel.ts`: one four-column table patched by key through `patchList`, 22 px rows, the solvent select kept in place (hidden) on IR and MS so the section keeps its 376 px height; results cached per fragment content and mode (64 entries). 13C shows the DEPT-135 phase from the attached hydrogens. Solvent residual and water peaks come from Fulmer et al. (Organometallics 2010) as italic reference rows; the solvent never changes a predicted shift. `backend/app/services/spectra/ir_bands.py` (about 25 SMARTS groups with textbook ranges; a specific group suppresses a general one) and `ms_fragments.py` (alpha, C-X, benzylic, allylic, McLafferty, common losses; one ion per formula, labelled indicative) are FormChem's own rule tables, routed from `routers/reactions.py` (`/api/chem/ir-bands`, `/api/chem/ms-fragments`) and the MCP tools `predict_ir_bands` and `predict_ms_fragments`. A new band or rule is a textbook fact written in FormChem's own SMARTS, never a copied table, and keeps its method name. Gate additions: switching tabs and solvents adds no layout shift and only the changed rows; ethyl acetate gives the ester C=O band and its EI ions. Reasons: `backend/HASHOUT_LOG.md` 308, `frontend/HASHOUT_LOG.md` 345.
+
## Gate
- [ ] Every new or changed value still carries method and version, and refusals still refuse.
diff --git a/.agents/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md
index 361ff088..d685ca7d 100644
--- a/.agents/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md
@@ -32,6 +32,20 @@ Read `docs/FORMAT.md` (Reactions on a page, the table `stoich` rule, the derived
| `frontend/src/engine/reactions-api.ts`, `app/reaction-commands.ts` | the typed route client and the Reaction menu commands |
| `frontend/src/chem/reaction-roles.ts`, `ui/roles-dialog.ts` | Set Reaction Roles (0.6.0): `reactionRoleOps` moves changed ids between role lists, sets `explicit: true` and drops coefficients and `stoich` entries that no longer fit, in one transaction; `canTakeRole` (fragments, text, captions, groups, images, shapes, tables, never the arrow); the keyed roles dialog. Window-side, no engine route |
+### Scheme layout, marks and stoichiometry extras (0.14.0)
+
+| Path | Role |
+| --- | --- |
+| `chem/scheme.py` `space_reaction`, `stretch_ops`, `footnote_ops`, `_Spacer` | Space Reaction (equal gaps on the first arrow's centre line, wrap with `dogleg` or `repeat`), arrow stretch to the widest follower plus 2 x 7.2 pt moving everything past the head, step letters and the footnote text; `layout_steps` puts conditions at the arrow tail with `w` the arrow length |
+| `routers/reactions.py` `_space`, `/api/chem/densities`, `/ir-bands`, `/ms-fragments` | the space, stretch and footnote routes (window boxes in `boxes`, else `geometry.object_box`); stretch runs on perceive unless `stretch: false` |
+| `data/densities.json`, `chem/stoich.py` `density_lookup` | 65 neat liquids matched by InChIKey; used when no density or concentration is typed (`density_source`) |
+| `fe/canvas/tools/transform.ts` `arrowFollowers`, `keepConditionsCentred` | agents and conditions move with their arrow in the same draft; the end-handle drag in `select.ts` keeps them centred |
+| `fe/canvas/render/marks-reaction.ts`, `app/reaction-commands.ts` `setReactionMarkSource` | reacting-centre marks, coefficients over 1, the arrow badge (live canvas only, never in exports) |
+| `fe/ui/stoich-panel.ts` `stoichGrid` | the table density as placeholder, written with the amount; copy as TSV and save as CSV |
+| `routers/mcp.py` `t_space_reaction`, `t_fit_arrows_to_conditions`, `t_conditions_as_footnotes` | the agent tools over the same functions, one agent undo step each |
+
+Rules: stretching happens at Perceive, Space Reaction and Fit Arrows, never per keystroke (roles are recomputed only by Perceive), and MCP `perceive_reactions` does not stretch. Wrapped steps get `explicit: true`. A footnote sits at least 2 bond lengths under the shaft so a later Perceive never reads it as a condition, and an existing (a) label is reused. The window's grid maths reads only typed densities, so the panel writes the table value with the amount in one transaction. Reasons: `backend/HASHOUT_LOG.md` 304 to 307, `frontend/HASHOUT_LOG.md` 343, 344, 346. Gate additions: Space Reaction gaps 14.4, 14.4, 7.2, 7.2 with centres within 0.1 pt; a 30 pt arrow drag moves its condition 30 pt in one undo step; a second Space or footnote run writes nothing; 1.00 g benzoic acid gives 0.713 mL thionyl chloride with no density typed.
+
## Laws
- **One reading of stoichiometry.** The engine's `stoich.py` and the window's `chem/stoich.ts` follow the same precedence: `scale_mmol` is the reference when present, else the limiting reagent's typed amount over its equiv, else the first amount; typed amounts beat typed equivalents. Never add a third computation; the renderer's own copy was deleted for disagreeing. Only typed values are stored, and the window's write rules (mass, volume or equiv replaces the other two; scale and the limiting reagent's amount replace each other) keep the two readings equal.
diff --git a/.agents/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md b/.agents/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md
index cb3ba469..8a8b15cb 100644
--- a/.agents/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md
+++ b/.agents/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md
@@ -37,13 +37,15 @@ Keep the chemistry of 0.6.0 in one shape: the engine (RDKit) computes and propos
- **Chiral flag 0 reads absolute.** A deliberate deviation from the clean-room spec (most files write 0 for enantiomers); do not "fix" it without the owner.
- **Ids survive contract and expand.** Expansion-internal ids are not live document ids (`_ids_of`); expand restores them unless they clash.
- **Every property names its method.** A new property row has `method` (the RDKit call) and `note` (in words), and the window's `PROPERTY_ROWS` gets a reserved width.
-- **A fix is a command name.** A check issue names its repairing route in `fix`, never a transaction; add the code to `SEVERITY` (and `FIX` if repairable) and to the window's row text.
+- **A fix names its repair.** A check issue names its repairing route in `fix`, or, when the repair is a fixed edit of the issue's own atoms, carries the transaction the Check Structure dialog commits (`check.hypervalent_fix`, 0.14.0); add the code to `SEVERITY` (and `FIX` if repairable) and to the window's row text.
+- **Labels are read by the engine (0.14.0).** `abbrev.resolve` tries the library (221 entries, `abbrev_data.py`, residues with `[*:1]` and `[*:2]`) and then `services/chem/condensed.py` (CH2CH2OH, C(O)NHMe, reversed HOCH2; `empirical` keeps a molecular formula as text); `convert.to_mol` joins a label's bonds to its points in z then id order. User entries go through `abbrev.save_user` and `remove_user` (atomic) and the `/api/analysis/abbreviations` routes. Never let an unresolved alias change an element atom's chemistry.
+- **Analysis values name their table (0.14.0).** Weights come from `data/atomic_weights.json` (CIAAW 2024) through `mass.weight_table`, the year in the method; adducts are `isotopes.ADDUCTS` (seven); patterns prune at 0.01 percent and merge by `resolution`; `props.GHOSE` names Crippen as its stand-in; axial M and P come from the drawn wedge (`perceive.axes`, depth read from the fragment's bond, not RDKit's cleared direction); polymer formulas from `ids.bracket_formulas` reach derived `polymer`; plain SMILES of a query is refused (`ids.query_refusal`). Reasons: `backend/HASHOUT_LOG.md` 291 to 303.
- **Marks are keyed.** New marks are specs in `marks-stereo.ts` or `marks-query.ts`, cached per fragment by `ChemMarks`; explicit fills, no CSS colours; never rebuild the layer.
- **Agents read through tools, change through commands.** Analysis tools stay read-only and outside `MUTATING`; a changing chemistry command is a window command agents reach with `run_command`.
## Known gaps (do not paper over)
-Allene axial chirality and drawn atropisomers are not perceived; link nodes and variable attachment are not built; SMARTS import draws aromatic rings as single bonds (fix: order 1.5 when both ends are aromatic); Markush `count` is before dedup and if-then; Export SMARTS copies in the desktop shell until 0.7.0.
+Link nodes, variable attachment and haptic centroids are not built (PARITY decisions: each would be a new atom or bond kind in the file contract); CIP agrees with the published hard set for 91.6 percent of its labels (RDKit's labeller); axial M and P are not written to V3000 or CXSMILES; Expand Abbreviation takes the first point of a two-point label; SMARTS import draws aromatic rings as single bonds (fix: order 1.5 when both ends are aromatic); Markush `count` is before dedup and if-then; Export SMARTS copies in the desktop shell until 0.7.0.
## Gate
diff --git a/.claude/skills/formchem-harness/EVALS.json b/.claude/skills/formchem-harness/EVALS.json
index e5060c3b..539c7426 100644
--- a/.claude/skills/formchem-harness/EVALS.json
+++ b/.claude/skills/formchem-harness/EVALS.json
@@ -1,6 +1,6 @@
{
"skill_name": "formchem-harness",
- "notes": "Run with the FormChem engine and window open (./formchem) and the formchem MCP server connected with the agent token, version 0.12.0. Expected behaviours are observable in the tool calls and the final answer. FormChem 0.12.0 has 77 tools: agents draw with draw_from_smiles, draw_from_molfile, draw_from_name and add_reaction, edit by id with get_atoms and the 14 edit tools, check with render, get_structure and validate, name with name_structure, predict NMR with predict_nmr and predict_spectrum, work on spectra with open_spectrum and the spectrum tools, work in 3D with build_3d, conformers_3d, minimise_3d, scan_dihedral, measure_3d, open_3d_structure, extract_ligand and export_3d, work with structure databases and the notebook with db_list, db_create, db_open, db_import, db_search, db_get_record, db_add_record, db_update_record, db_export, nb_add_entry and nb_search, keep the shared structure library with library_list, library_add and live_structure_object, draw biopolymers with draw_from_helm, run xtb and CREST (only when installed) with xtb_optimise and crest_conformers, and still reach the window's commands, reactions, analysis and extensions; several evals check that the agent draws with the tools and checks before it claims. Evals 13 and 14 need a drawn esterification scheme (acetic acid + ethanol, arrow, ethyl acetate + water); evals 15 to 18 need ibuprofen inserted with insert-smiles CC(C)Cc1ccc(cc1)[C@@H](C)C(=O)O; eval 20 needs an SD file at the path it names; eval 28 needs ethyl acetate drawn; eval 29 needs a JCAMP-DX 1H NMR file of ethanol at the path it names; eval 33 needs a PDB file with a protein chain and a benzamidine ligand (BEN) at the path it names; eval 34 needs butane drawn; evals 36 to 40 need an SD file of a few hundred structures, one of them with a broken connection table, at the path eval 36 names, and evals 37 to 40 the database eval 36 makes; eval 44 needs ethanol drawn and eval 45 butane, and both should be run once with xtb and CREST installed and once without them.",
+ "notes": "Run with the FormChem engine and window open (./formchem) and the formchem MCP server connected with the agent token, version 0.14.0. Expected behaviours are observable in the tool calls and the final answer. FormChem 0.14.0 has 104 tools (the 27 of 0.14.0 add pages, object boxes, agent undo, fuse_ring and attach_template, the scheme layout tools, standardise, balance_reaction, isotope_pattern, export_helm, predict_ir_bands, predict_ms_fragments, the abbreviation tools and the 3D surface, terms, rotation, repair, render and PDB tools); evals 48 to 52 need a drawing open with, in order, an esterification scheme with a conditions text, benzene, any structure, nothing, and a primary amine. Of the earlier tools: agents draw with draw_from_smiles, draw_from_molfile, draw_from_name and add_reaction, edit by id with get_atoms and the 14 edit tools, check with render, get_structure and validate, name with name_structure, predict NMR with predict_nmr and predict_spectrum, work on spectra with open_spectrum and the spectrum tools, work in 3D with build_3d, conformers_3d, minimise_3d, scan_dihedral, measure_3d, open_3d_structure, extract_ligand and export_3d, work with structure databases and the notebook with db_list, db_create, db_open, db_import, db_search, db_get_record, db_add_record, db_update_record, db_export, nb_add_entry and nb_search, keep the shared structure library with library_list, library_add and live_structure_object, draw biopolymers with draw_from_helm, run xtb and CREST (only when installed) with xtb_optimise and crest_conformers, and still reach the window's commands, reactions, analysis and extensions; several evals check that the agent draws with the tools and checks before it claims. Evals 13 and 14 need a drawn esterification scheme (acetic acid + ethanol, arrow, ethyl acetate + water); evals 15 to 18 need ibuprofen inserted with insert-smiles CC(C)Cc1ccc(cc1)[C@@H](C)C(=O)O; eval 20 needs an SD file at the path it names; eval 28 needs ethyl acetate drawn; eval 29 needs a JCAMP-DX 1H NMR file of ethanol at the path it names; eval 33 needs a PDB file with a protein chain and a benzamidine ligand (BEN) at the path it names; eval 34 needs butane drawn; evals 36 to 40 need an SD file of a few hundred structures, one of them with a broken connection table, at the path eval 36 names, and evals 37 to 40 the database eval 36 makes; eval 44 needs ethanol drawn and eval 45 butane, and both should be run once with xtb and CREST installed and once without them; eval 47 needs a database at /tmp/fc-eval/compounds.fcdb.",
"evals": [
{
"id": 1,
@@ -523,6 +523,83 @@
"When CREST runs, quotes the relative energies and populations with the program label and how many conformers were dropped for lost stereo",
"Offers conformers_3d with MMFF94 only as a clearly named alternative, after asking"
]
+ },
+ {
+ "id": 46,
+ "name": "show-demos",
+ "prompt": "I'm new to FormChem. Show me some examples I can start from.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_context, then run_command with id demos (Help > Demos)",
+ "Tells the person Home now shows five demos (aspirin, the two-step aspirin synthesis, the enantiomers, cholesterol in 3D, benzocaine with its 1H NMR) and that clicking one opens a new unsaved copy",
+ "Does not claim to have opened a demo itself, and does not redraw the demos with draw_from_smiles unasked"
+ ]
+ },
+ {
+ "id": 47,
+ "name": "open-database-file",
+ "prompt": "Open /tmp/fc-eval/compounds.fcdb in FormChem so I can look at it.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_context, then db_open with the path (or run_command open-recent with params path, which shows the database workspace)",
+ "Quotes the record count and title from the answer, and says the database workspace is showing in the window",
+ "Does not import the file into a new database or copy it"
+ ]
+ },
+ {
+ "id": 48,
+ "name": "space-the-scheme",
+ "prompt": "Tidy the reaction scheme in my FormChem drawing so the arrows fit their conditions, and put the conditions in a footnote.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_context, then perceive_reactions, then space_reaction (or fit_arrows_to_conditions) and conditions_as_footnotes, each one undo step",
+ "Checks the result with render or list_objects and quotes what the tools answered",
+ "Does not move objects one by one with move to imitate Space Reaction"
+ ]
+ },
+ {
+ "id": 49,
+ "name": "fuse-a-ring",
+ "prompt": "Fuse a cyclopentane onto the bond between atoms 3 and 4 of the benzene in my FormChem drawing.",
+ "files": [],
+ "expected_behavior": [
+ "Calls get_atoms to find the bond id, then fuse_ring {bond, size: 5} (or attach_template with that bond)",
+ "Checks the new formula with get_structure (C9H10, indane) and looks at render",
+ "Asks the person to open the window if the tool says no window answered, instead of drawing the ring atom by atom silently"
+ ]
+ },
+ {
+ "id": 50,
+ "name": "journal-figure-page",
+ "prompt": "Make my FormChem drawing a single-figure file with a footer that says the file name and page number.",
+ "files": [],
+ "expected_behavior": [
+ "Calls list_pages, then set_page with a footer using {file} and {page}, then fit_page_to_drawing",
+ "Quotes the page size the tool answers in points",
+ "Leaves exporting the picture to the person or a window command, and says which"
+ ]
+ },
+ {
+ "id": 51,
+ "name": "ir-and-ms-of-a-structure",
+ "prompt": "What IR bands and EI fragments would ethyl acetate show? Use FormChem.",
+ "files": [],
+ "expected_behavior": [
+ "Calls predict_ir_bands and predict_ms_fragments with the SMILES CCOC(C)=O or the drawn structure",
+ "Quotes the bands and ions with the method and calls them indicative predictions, not measured data",
+ "Changes nothing in the drawing"
+ ]
+ },
+ {
+ "id": 52,
+ "name": "boc-is-not-a-template",
+ "prompt": "Put a Boc template on the nitrogen of my amine in FormChem.",
+ "files": [],
+ "expected_behavior": [
+ "Recognises that the template library holds whole molecules only and that Boc is an abbreviation",
+ "Sets the label Boc on a new atom bonded to the nitrogen with the edit tools (or abbreviation_list to confirm the entry), then checks with get_structure",
+ "Does not invent a template id"
+ ]
}
],
"trigger_evals": [
@@ -608,6 +685,15 @@
{"query": "run CREST through formchem on the drawn macrocycle and keep 10 conformers", "should_trigger": true},
{"query": "install xtb with conda on my laptop", "should_trigger": false},
{"query": "convert a HELM string to SMILES with the Pistoia HELM toolkit in Java", "should_trigger": false},
- {"query": "add a new HELM monomer to formchem's helm_monomers.json data file", "should_trigger": false}
+ {"query": "add a new HELM monomer to formchem's helm_monomers.json data file", "should_trigger": false},
+ {"query": "show me the formchem demos so I have something to start from", "should_trigger": true},
+ {"query": "open this .fcdb database in FormChem and tell me how many compounds it holds", "should_trigger": true},
+ {"query": "add a sixth demo drawing to formchem's backend/app/data/demos", "should_trigger": false},
+ {"query": "space out the reaction in my formchem drawing and add footnotes", "should_trigger": true},
+ {"query": "add a second page with an A4 landscape layout to my FormChem drawing", "should_trigger": true},
+ {"query": "predict the IR bands of this structure in formchem", "should_trigger": true},
+ {"query": "fuse a ring onto this bond in FormChem", "should_trigger": true},
+ {"query": "fix Space Reaction's gap calculation in formchem's scheme.py", "should_trigger": false},
+ {"query": "explain what an EI McLafferty rearrangement is", "should_trigger": false}
]
}
diff --git a/.claude/skills/formchem-harness/SKILL.md b/.claude/skills/formchem-harness/SKILL.md
index 29ac1268..fcc03577 100644
--- a/.claude/skills/formchem-harness/SKILL.md
+++ b/.claude/skills/formchem-harness/SKILL.md
@@ -1,21 +1,21 @@
---
name: formchem-harness
-description: "Drives FormChem, the FormAI family's chemical structure drawing suite, through its MCP server. Use whenever the person wants an agent to work in FormChem: draw a structure or reaction from SMILES, a molfile, a chemical name or HELM, edit it atom by atom, check it with render, get_structure or validate, predict a 1H or 13C NMR spectrum, open a JCAMP-DX spectrum, build it in 3D, find conformers, run xtb or CREST, open a PDB file or extract a ligand, search a compound database by substructure or similarity, import an SD file, register a compound, add a notebook entry, put a structure in the shared library, convert files, run a menu command, or asks what FormChem can do, and FormChem is named or its tools (draw_from_smiles, build_3d, db_search, library_add, draw_from_helm, render, run_command and the rest) are available. Covers 127.0.0.1:8220, the agent token, approval and Stop. Not for changing FormChem's source (formchem-skillset), other Form apps such as FormDeck, or standalone RDKit scripts."
+description: "Drives FormChem, the FormAI structure drawing suite, through its MCP server. Use whenever the person wants an agent to work in FormChem: draw a structure or reaction from SMILES, a molfile, a chemical name or HELM, edit it atom by atom, fuse a ring onto a bond, space a reaction scheme, add pages, check it with render, get_structure or validate, predict NMR, IR bands or MS fragments, open a JCAMP-DX spectrum, build it in 3D, find conformers, run xtb or CREST, open a PDB file or extract a ligand, search a compound database by substructure or similarity, import an SD file, register a compound, add a notebook entry, put a structure in the shared library, convert files, run a menu command, show the demos, or asks what FormChem can do, and FormChem is named or its tools (draw_from_smiles, build_3d, db_search, render, run_command and the rest) are available. Covers 127.0.0.1:8220, the agent token, approval and Stop. Not for changing FormChem's source (formchem-skillset), other Form apps, or standalone RDKit scripts."
license: Apache-2.0
metadata:
author: nodemode-ai
- version: "0.12.0"
+ version: "0.14.0"
---
# FormChem harness
FormChem is a chemical structure drawing suite running on this computer. Its MCP server (`formchem`) lives in the engine and reaches the FormChem window, where the person sees everything an agent does. This pack is the method for using it well: draw with the tools, check what you drew, and hand back.
-## What exists today (0.12.0)
+## What exists today (0.14.0)
FormChem has drawings (`.fchem` documents kept by the engine with undo, autosave and versions), an RDKit chemistry service that computes SMILES, InChIKey, formula, masses, CIP labels and valence warnings after every change, and a 2D canvas the person draws on. Earlier versions added reactions and annotations (0.5.0), stereo, queries and analysis (0.6.0), formats, pictures, the clipboard, Standardise and the command line (0.7.0), the agent tools (0.8.0), names, NMR prediction and JCAMP-DX spectra (0.9.0), 3D: builds with the stereo checked, conformers, scans, measurements, PDB and mmCIF files and ligands (0.10.0), and structure databases with the lab notebook (0.11.0).
-0.12.0 adds the shared structure library every Form app reads, live structures (a picture with the drawing inside that sibling apps keep and send back for editing), HELM in and out, xtb and CREST run when the person installed them, keyboard and screen reader access, and element palettes. The MCP server has 77 tools; `references/tools.md` is generated from the server and lists all of them; the library and HELM tools are in `sub-skills/library-and-biopolymers` and the xtb tools in `sub-skills/three-d`.
+0.12.0 adds the shared structure library every Form app reads, live structures (a picture with the drawing inside that sibling apps keep and send back for editing), HELM in and out, xtb and CREST run when the person installed them, keyboard and screen reader access, and element palettes. 0.13.0 adds no tool: the desktop app opens files the system hands it (databases, PDB, mmCIF and JCAMP-DX included), names and HELM work in the desktop app, and Help > Demos (`run_command {id: "demos"}`) shows five prepared drawings on Home that the person opens as new copies. 0.14.0, the parity pass, adds 27 tools: pages and object boxes, undo of agent changes, ring fusion and templates by anchor, Space Reaction, arrows fitted to conditions and footnotes, typed Standardise, balance, isotope pattern and HELM output, predicted IR bands and MS fragments, the user abbreviation library, and 3D surfaces, energy terms, bond rotation, hydrogen repair, 3D pictures and PDB entries by id. The template library holds only starter structures and whole molecules (groups such as Boc are abbreviations). The MCP server has 104 tools; `references/tools.md` is generated from the server and lists all of them.
| Group | Tools |
| --- | --- |
@@ -32,10 +32,14 @@ FormChem has drawings (`.fchem` documents kept by the engine with undo, autosave
| xtb and CREST (0.12.0) | `xtb_optimise`, `crest_conformers` (only when the person installed the programs) |
| Window, extensions, handoff | `list_commands`, `run_command`, `extensions_list`, `extension_command`, `handoff` |
| Reactions (0.5.0) and analysis (0.6.0) | `perceive_reactions`, `map_reaction`, `export_reaction`, `reaction_stoichiometry`, `properties`, `check_structure`, `stereo`, `substructure` |
+| Pages and undo (0.14.0) | `list_pages`, `add_page`, `delete_page`, `set_page`, `fit_page_to_drawing`, `list_objects`; `undo_agent_changes` |
+| Gestures and schemes (0.14.0) | `fuse_ring`, `attach_template` (need the window); `space_reaction`, `fit_arrows_to_conditions`, `conditions_as_footnotes` |
+| Chemistry as tools (0.14.0) | `standardise`, `balance_reaction` (write only with `apply`), `isotope_pattern`, `export_helm`, `predict_ir_bands`, `predict_ms_fragments`; `abbreviation_list`, `abbreviation_define`, `abbreviation_remove` |
+| 3D (0.14.0) | `compute_surface`, `energy_terms_3d`, `rotate_bond_3d`, `repair_hydrogens_3d`, `render_3d` (needs the window), `fetch_pdb` |
Every change an agent makes is one transaction and one undo step, labelled with the tool in the person's Edit > Undo, and every change answers with the structure it now holds (ids, SMILES, InChIKey, formula, warnings) and a PNG of it. The person sees which agent is editing in the title bar, with a Stop button, and Window > Agent Activity lists every call with undo for the latest one.
-Every name and computed number carries its method and version (FormChem names 0.9.0, FormChem increments 0.9.0, `ETKDGv3+MMFF94 (rdkit 2025.09.3)`, similarity scores with their fingerprint, `xtb 6.7.1, GFN2-xTB, ALPB (Water)`); quote them with the value, and never present a prediction or a computed energy as measured. What still is not there: names the offline engine refuses (hydro prefixes, spiro and bridged rings; peptides go through HELM), a tool that links peaks to atoms (the window command does) or inserts a spectrum file into an existing drawing, typing amounts into the Stoichiometry panel, tools for 3D styles and surfaces (the window commands do), DFT or any quantum method beyond the person's own xtb, a tool that returns HELM text or describes a structure in words (window commands `copy-helm` and `a11y-describe` do), and database fields, saved queries, attachments or signing for agents (the window does them). The export and copy commands still hand their file to the person, not to the agent; use `convert` or `get_structure` for text you can read. Never draw by other means and present it as FormChem's work.
+Every name and computed number carries its method and version (FormChem names 0.9.0, FormChem increments 0.9.0, `ETKDGv3+MMFF94 (rdkit 2025.09.3)`, similarity scores with their fingerprint, `xtb 6.7.1, GFN2-xTB, ALPB (Water)`); quote them with the value, and never present a prediction or a computed energy as measured. What still is not there: names the offline engine refuses (hydro prefixes, spiro and bridged rings; peptides go through HELM), a tool that links peaks to atoms (the window command does) or inserts a spectrum file into an existing drawing, typing amounts into the Stoichiometry panel, tools for 3D styles (the window commands do), DFT or any quantum method beyond the person's own xtb, a tool that describes a structure in words (the window command `a11y-describe` does), tools of their own for brackets, tables and TLC plates and for journal styles (`run_command` reaches them), and database fields, saved queries, attachments or signing for agents (the window does them). The export and copy commands still hand their file to the person, not to the agent; use `convert` or `get_structure` for text you can read. Never draw by other means and present it as FormChem's work.
## Doctrine (applies to every route)
@@ -52,21 +56,22 @@ Every name and computed number carries its method and version (FormChem names 0.
```
formchem-harness/
SKILL.md this router and the doctrine
- references/tools.md 71 of the 77 tools and their arguments (generated by ./formchem agents sync)
+ references/tools.md all 104 tools and their arguments (generated by ./formchem agents sync)
+ references/failures.md every error the tools give, what it means, what to do
EVALS.json evaluation prompts and trigger tests for this pack
sub-skills/
session-and-connection/ connecting, the agent token, get_context, approval, Stop, connection errors
- drawing/ documents, draw_from_smiles, draw_from_molfile, add_reaction, placement, convert
+ drawing/ documents, pages, draw_from_smiles, draw_from_molfile, templates and fused rings, placement, convert
edit-by-id/ get_atoms and the 14 edit tools: atoms, bonds, charges, stereo, groups, arrows, text
visual-qa/ render, get_structure, validate and compute_properties to check your own work
names-and-spectra/ draw_from_name, name_structure, predict_nmr, predict_spectrum and the spectrum tools
- three-d/ build_3d, conformers, minimise, scans, measure, PDB files, ligands, 3D export, xtb and CREST
+ three-d/ build_3d, conformers, minimise, scans, measure, surfaces, terms, rotation, PDB by id, ligands, 3D export and pictures, xtb and CREST
databases/ the db_ and nb_ tools: import, search, register, export, notebook entries
library-and-biopolymers/ the shared structure library, live structure objects, draw_from_helm
handoff/ handoff states and notes, what the person sees, Agent Activity
window-commands/ the window's commands through run_command; references/command-catalogue.md
- reactions/ reaction schemes, the four reaction tools, Set Reaction Roles
- structure-analysis/ properties, the structure check, stereo, substructure and the chemistry commands
+ reactions/ reaction schemes, the reaction tools, Space Reaction and footnotes, balance, Set Reaction Roles
+ structure-analysis/ properties, the structure check, stereo, substructure, isotopes, IR and MS, abbreviations
extension-drawings/ reading and changing the drawing through a Form extension
```
@@ -84,9 +89,10 @@ Paths inside a SUB-SKILL.md resolve against that sub-skill's own folder. `refere
| Draw caffeine, draw "(2R)-butan-2-ol", what is this structure called, its IUPAC name | `names-and-spectra`, then `visual-qa` |
| Predict or simulate the 1H or 13C NMR, why is this proton at 4.1, put the predicted spectrum next to it | `names-and-spectra` |
| Open this .jdx file, pick the IR peaks, integrate the NMR, set this integral to 3, link a peak to atoms, export the spectrum | `names-and-spectra` |
-| The reaction in the drawing: steps, roles, atom mapping, reaction SMILES or RXN, balance, moles, yield | `reactions` |
-| cLogP, TPSA, Lipinski, the structure check, stereo groups, SMARTS hits, hydrogens, abbreviations, atom lists, R-groups | `structure-analysis` |
-| Export a picture or file for the person, print, the clipboard, Standardise, a template, the grid, the dark page, Preferences, any menu command | `window-commands` |
+| The reaction in the drawing: steps, roles, atom mapping, reaction SMILES or RXN, balance, moles, yield; space the scheme, fit the arrows, letter the steps with footnotes | `reactions` |
+| cLogP, TPSA, Lipinski, the structure check, stereo groups, SMARTS hits, hydrogens, abbreviations, atom lists, R-groups; the isotope pattern, IR bands, MS fragments; define an abbreviation | `structure-analysis` |
+| Add a page, page size or header, list objects with their boxes, fit the page to the drawing; fuse a ring onto a bond, attach a template; undo what the agent did since a step | `drawing` |
+| Export a picture or file for the person, print, the clipboard, Standardise, the grid, the dark page, a journal style, Preferences, Help > Demos, any menu command | `window-commands` |
| Run an extension's command, which extensions are installed, read the drawing through an extension | `extension-drawings` |
| Tell the person you are done, ask them something, clear your note | `handoff` |
| Make it 3D, its conformers or lowest-energy shape, minimise, a torsion scan, a bond length or angle in 3D, does the 3D keep the stereo | `three-d`, then `visual-qa` |
@@ -102,41 +108,7 @@ Paths inside a SUB-SKILL.md resolve against that sub-skill's own folder. `refere
## When something fails
-| What you see | Meaning | Do |
-| --- | --- | --- |
-| No FormChem tools at all | The MCP server is not connected in this client | Ask the person to run `./formchem agents install` in the FormChem folder, start FormChem with `./formchem`, then restart the client |
-| 401, or "needs the agent token" | An HTTP setup without the 0.8.0 token | Ask the person to run `./formchem agents install` again, or to add `Authorization: Bearer` and the output of `./formchem agents token` to the client's FormChem entry; stdio (`./formchem mcp`) needs nothing |
-| Connection refused | The engine is not running | Ask the person to run `./formchem` or open the app; the stdio entry starts the engine itself |
-| "did not allow agents" or "blocked agents" | The person answered Deny, or blocked agents in Preferences | Stop and tell the person what you wanted to do |
-| "The person stopped [agent]'s access" | The person pressed Stop | Stop working. Tell them what you were about to do; they can Allow again in Agent Activity |
-| "Several drawings are open and no window shows one" | No `doc` and no active drawing | Call `list_open_documents` and pass `doc` |
-| "Could not read the SMILES" or "the molfile" | The text does not parse; no drawing was left behind | Fix the text once, or ask the person |
-| An edit error naming an id | A stale or wrong atom, bond or object id | Call `get_atoms` once and use the ids it returns |
-| "already exists" from `save_document` or `convert` | Agent tools never write over a file | Choose a new path, or ask the person to save over it in the window |
-| "has unsaved changes" from `close_document` | Only the person may discard changes | `save_document` first, or ask the person |
-| "is not available right now" | A window command is off (nothing selected, nothing to undo, a later version) | Do not retry; tell the person the reason it gives |
-| "Could not read the name" | The offline engine refused it (spelling, an inverted index name, D- or L- outside the dictionary, an impossible locant); nothing was drawn | Fix an obvious spelling once; else write the SMILES, use `draw_from_smiles` and say so |
-| `confidence: medium` on a name | A locant was assumed or the name has two readings | Quote the note and say what was drawn; ask if it matters |
-| `names: []` with a reason | No dictionary entry and the namer cannot name it, or the round trip failed | Report the reason; do not invent a systematic name |
-| "is not a spectrum" or "has none" from a spectrum tool | Wrong id, or the drawing holds no spectrum | `open_spectrum` or `predict_spectrum` first; pass `object` from its answer |
-| Predicted links stale after an edit | The curve follows the structure, the marks do not | Ask the person for Refresh Predicted Spectrum, or `run_command {id: "nmr-refresh"}` with that spectrum selected |
-| "stereo changed: lost ..." from `build_3d` | The 3D structure is not the drawn isomer | Do not use the geometry; check the wedges (`stereo`, `get_atoms`) and report it |
-| `unspecified_stereo` or `uff_fallback` note on a build | Centres without wedges were built as one arbitrary isomer; or MMFF94 had no parameters and UFF ran | Pass the note on with the numbers |
-| "No 3D coordinates yet" or "has no conformer" | The structure was never built, or an edit dropped its conformers | `build_3d`, then retry |
-| "The structure changed while 3D was being computed" (409) | Someone edited the structure during the build | Retry once; if it repeats, the person is editing: ask them |
-| `extract_ligand` refuses, or answers "inferred from the geometry" | The object is not a PDB or mmCIF model; or the ligand is outside the template table | Pass the model's `o...` id from `open_3d_structure`; say the bond orders were inferred and show the SMILES |
-| "No database is open" or "Several databases are open" | No handle given | `db_list`, then `db_open {path}` or pass `db` |
-| `db_add_record` error listing duplicates | The structure is there by the database's stereo and salts rules | Show the matches; call again with the `on_duplicate` the person chooses |
-| "open read-only" or 423 on a write | Another FormChem or `./formchem db` holds the file | Report the reason; read and search only |
-| `failed` records in a `db_import` job | Bad records were skipped, the rest imported | Pass on each record number and reason |
-| xtb or CREST "was not found" from `xtb_optimise` or `crest_conformers` | The person has not installed it, or its path is wrong; FormChem never ships it | Tell the person where to get it (the answer says); do not retry |
-| "unpaired electrons" or parity refusal from an xtb tool | Charge and `uhf` cannot match the electron count | Fix `charge` or `uhf` once from the structure, or ask |
-| An xtb job "timeout" or "failed" with the last lines | The time limit stopped it, or the program failed | Pass on the last lines; offer a larger `limit` or GFN-FF |
-| `draw_from_helm` refused "at character N" | Unknown monomer, mixture, BLOB or a typo | Fix an obvious typo once; else inline SMILES for the monomer, or report |
-| "has no item" from a library tool | Wrong id, or the item was deleted | `library_list`, then use an id it returns |
-| `renderer: "engine"` in a picture | No window answered; the engine drew the structures only | Fine for checking structures; say arrows and text were not drawn, or ask the person to open the window |
-
-When a call keeps failing in a way this table does not explain, call the same tool once with the simplest arguments (`get_context`, then `draw_from_smiles {smiles: "C"}`). If that fails too, the problem is the server or the connection, not the plan: report it to the person with the error text.
+`references/failures.md` maps every error the tools give (connection and token, consent and Stop, ids, names, spectra, 3D builds, databases, xtb and CREST, HELM, the library, engine-drawn pictures) to what it means and the one thing to do. Read it when a call fails, do that once, then report. When nothing there explains the failure, call the same tool once with the simplest arguments (`get_context`, then `draw_from_smiles {smiles: "C"}`); if that fails too, the problem is the server or the connection: report it to the person with the error text.
## Done means
diff --git a/.claude/skills/formchem-harness/references/failures.md b/.claude/skills/formchem-harness/references/failures.md
new file mode 100644
index 00000000..cea9800b
--- /dev/null
+++ b/.claude/skills/formchem-harness/references/failures.md
@@ -0,0 +1,38 @@
+# When something fails
+
+What each FormChem error means and the one thing to do about it. Read the error first: every one names the next step. Do that once, then report.
+
+| What you see | Meaning | Do |
+| --- | --- | --- |
+| No FormChem tools at all | The MCP server is not connected in this client | Ask the person to run `./formchem agents install` in the FormChem folder, start FormChem with `./formchem`, then restart the client |
+| 401, or "needs the agent token" | An HTTP setup without the 0.8.0 token | Ask the person to run `./formchem agents install` again, or to add `Authorization: Bearer` and the output of `./formchem agents token` to the client's FormChem entry; stdio (`./formchem mcp`) needs nothing |
+| Connection refused | The engine is not running | Ask the person to run `./formchem` or open the app; the stdio entry starts the engine itself |
+| "did not allow agents" or "blocked agents" | The person answered Deny, or blocked agents in Preferences | Stop and tell the person what you wanted to do |
+| "The person stopped [agent]'s access" | The person pressed Stop | Stop working. Tell them what you were about to do; they can Allow again in Agent Activity |
+| "Several drawings are open and no window shows one" | No `doc` and no active drawing | Call `list_open_documents` and pass `doc` |
+| "Could not read the SMILES" or "the molfile" | The text does not parse; no drawing was left behind | Fix the text once, or ask the person |
+| An edit error naming an id | A stale or wrong atom, bond or object id | Call `get_atoms` once and use the ids it returns |
+| "already exists" from `save_document` or `convert` | Agent tools never write over a file | Choose a new path, or ask the person to save over it in the window |
+| "has unsaved changes" from `close_document` | Only the person may discard changes | `save_document` first, or ask the person |
+| "is not available right now" | A window command is off (nothing selected, nothing to undo, a later version) | Do not retry; tell the person the reason it gives |
+| "Could not read the name" | The offline engine refused it (spelling, an inverted index name, D- or L- outside the dictionary, an impossible locant); nothing was drawn | Fix an obvious spelling once; else write the SMILES, use `draw_from_smiles` and say so |
+| `confidence: medium` on a name | A locant was assumed or the name has two readings | Quote the note and say what was drawn; ask if it matters |
+| `names: []` with a reason | No dictionary entry and the namer cannot name it, or the round trip failed | Report the reason; do not invent a systematic name |
+| "is not a spectrum" or "has none" from a spectrum tool | Wrong id, or the drawing holds no spectrum | `open_spectrum` or `predict_spectrum` first; pass `object` from its answer |
+| Predicted links stale after an edit | The curve follows the structure, the marks do not | Ask the person for Refresh Predicted Spectrum, or `run_command {id: "nmr-refresh"}` with that spectrum selected |
+| "stereo changed: lost ..." from `build_3d` | The 3D structure is not the drawn isomer | Do not use the geometry; check the wedges (`stereo`, `get_atoms`) and report it |
+| `unspecified_stereo` or `uff_fallback` note on a build | Centres without wedges were built as one arbitrary isomer; or MMFF94 had no parameters and UFF ran | Pass the note on with the numbers |
+| "No 3D coordinates yet" or "has no conformer" | The structure was never built, or an edit dropped its conformers | `build_3d`, then retry |
+| "The structure changed while 3D was being computed" (409) | Someone edited the structure during the build | Retry once; if it repeats, the person is editing: ask them |
+| `extract_ligand` refuses, or answers "inferred from the geometry" | The object is not a PDB or mmCIF model; or the ligand is outside the template table | Pass the model's `o...` id from `open_3d_structure`; say the bond orders were inferred and show the SMILES |
+| "No database is open" or "Several databases are open" | No handle given | `db_list`, then `db_open {path}` or pass `db` |
+| `db_add_record` error listing duplicates | The structure is there by the database's stereo and salts rules | Show the matches; call again with the `on_duplicate` the person chooses |
+| "open read-only" or 423 on a write | Another FormChem or `./formchem db` holds the file | Report the reason; read and search only |
+| `failed` records in a `db_import` job | Bad records were skipped, the rest imported | Pass on each record number and reason |
+| xtb or CREST "was not found" from `xtb_optimise` or `crest_conformers` | The person has not installed it, or its path is wrong; FormChem never ships it | Tell the person where to get it (the answer says); do not retry |
+| "unpaired electrons" or parity refusal from an xtb tool | Charge and `uhf` cannot match the electron count | Fix `charge` or `uhf` once from the structure, or ask |
+| An xtb job "timeout" or "failed" with the last lines | The time limit stopped it, or the program failed | Pass on the last lines; offer a larger `limit` or GFN-FF |
+| `draw_from_helm` refused "at character N" | Unknown monomer, mixture, BLOB or a typo | Fix an obvious typo once; else inline SMILES for the monomer, or report |
+| "has no item" from a library tool | Wrong id, or the item was deleted | `library_list`, then use an id it returns |
+| `renderer: "engine"` in a picture | No window answered; the engine drew the structures only | Fine for checking structures; say arrows and text were not drawn, or ask the person to open the window |
+When a call keeps failing in a way this table does not explain, call the same tool once with the simplest arguments (`get_context`, then `draw_from_smiles {smiles: "C"}`). If that fails too, the problem is the server or the connection, not the plan: report it to the person with the error text.
diff --git a/.claude/skills/formchem-harness/references/tools.md b/.claude/skills/formchem-harness/references/tools.md
index 23466773..5c2ef621 100644
--- a/.claude/skills/formchem-harness/references/tools.md
+++ b/.claude/skills/formchem-harness/references/tools.md
@@ -1,6 +1,6 @@
# FormChem MCP tools
-Generated by `./formchem agents sync` from the TOOLS list in `backend/app/routers/mcp.py` and the agent modules in its AGENT_MODULES; edit the server, never this file. 77 tools. Names and arguments are case sensitive. A tool answers with text first, then `structuredContent` where it sends it; a tool that cannot act answers with `isError: true` and a sentence naming the next step.
+Generated by `./formchem agents sync` from the TOOLS list in `backend/app/routers/mcp.py` and the agent modules in its AGENT_MODULES; edit the server, never this file. 104 tools. Names and arguments are case sensitive. A tool answers with text first, then `structuredContent` where it sends it; a tool that cannot act answers with `isError: true` and a sentence naming the next step.
Read-only tools never ask the person. An approval-gated tool asks the person in the FormChem window the first time (Deny, Allow once, Always allow); agents started in FormChem's own Claude Code, Codex, Cursor or Antigravity tabs are never asked.
@@ -33,10 +33,17 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
- close_document
- list_commands
- run_command
+- fuse_ring
+- attach_template
- extensions_list
- extension_command
- handoff
- perceive_reactions
+- space_reaction
+- fit_arrows_to_conditions
+- conditions_as_footnotes
+- predict_ir_bands
+- predict_ms_fragments
- map_reaction
- export_reaction
- reaction_stoichiometry
@@ -84,6 +91,26 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
- draw_from_helm
- xtb_optimise
- crest_conformers
+- standardise
+- balance_reaction
+- isotope_pattern
+- export_helm
+- list_pages
+- add_page
+- delete_page
+- set_page
+- fit_page_to_drawing
+- list_objects
+- undo_agent_changes
+- abbreviation_list
+- abbreviation_define
+- abbreviation_remove
+- compute_surface
+- energy_terms_3d
+- rotate_bond_3d
+- repair_hydrogens_3d
+- render_3d
+- fetch_pdb
- Resource
| Tool | Kind |
@@ -114,10 +141,17 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
| `close_document` | approval-gated |
| `list_commands` | read-only |
| `run_command` | approval-gated |
+| `fuse_ring` | approval-gated |
+| `attach_template` | approval-gated |
| `extensions_list` | read-only |
| `extension_command` | approval-gated |
| `handoff` | approval-gated when it changes something |
| `perceive_reactions` | approval-gated |
+| `space_reaction` | approval-gated |
+| `fit_arrows_to_conditions` | approval-gated |
+| `conditions_as_footnotes` | approval-gated |
+| `predict_ir_bands` | read-only |
+| `predict_ms_fragments` | read-only |
| `map_reaction` | approval-gated |
| `export_reaction` | read-only |
| `reaction_stoichiometry` | read-only |
@@ -165,6 +199,26 @@ Read-only tools never ask the person. An approval-gated tool asks the person in
| `draw_from_helm` | approval-gated when it changes something |
| `xtb_optimise` | approval-gated when it changes something |
| `crest_conformers` | approval-gated when it changes something |
+| `standardise` | approval-gated when it changes something |
+| `balance_reaction` | approval-gated when it changes something |
+| `isotope_pattern` | read-only |
+| `export_helm` | read-only |
+| `list_pages` | read-only |
+| `add_page` | approval-gated when it changes something |
+| `delete_page` | approval-gated when it changes something |
+| `set_page` | approval-gated when it changes something |
+| `fit_page_to_drawing` | approval-gated when it changes something |
+| `list_objects` | read-only |
+| `undo_agent_changes` | approval-gated when it changes something |
+| `abbreviation_list` | read-only |
+| `abbreviation_define` | approval-gated when it changes something |
+| `abbreviation_remove` | approval-gated when it changes something |
+| `compute_surface` | read-only |
+| `energy_terms_3d` | read-only |
+| `rotate_bond_3d` | approval-gated when it changes something |
+| `repair_hydrogens_3d` | approval-gated when it changes something |
+| `render_3d` | read-only |
+| `fetch_pdb` | approval-gated when it changes something |
## get_context
@@ -447,6 +501,28 @@ Runs one command in the open FormChem window, exactly as the person's click woul
| `params` | object | no | Parameters the command lists, if any |
| `confirm` | boolean | no | |
+## fuse_ring
+
+Fuses a ring onto a drawn bond in the active drawing, on the side with fewer atoms nearby, as one undo step (the window's fuse-ring command). Answers with the new atom ids. Needs the window.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `bond` | string | yes | Bond id, or fragment id/bond id, from get_atoms |
+| `size` | integer | no | Ring size 3 to 8 (default 6) |
+| `benzene` | boolean | no | A benzene ring with alternating double bonds |
+
+## attach_template
+
+Puts a template (ids from GET /api/templates, such as benzene or pyridine) into the active drawing as one undo step (the window's attach-template command): on atom it merges the template's least connected atom into that atom, on bond it fuses the template's first ring bond onto that bond, otherwise it is centred at x, y in points. Answers with the new atom ids. Needs the window.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `id` | string | yes | Template id |
+| `atom` | string | no | Atom id (or fragment/atom) to attach at |
+| `bond` | string | no | Bond id (or fragment/bond) to fuse onto |
+| `x` | number | no | |
+| `y` | number | no | |
+
## extensions_list
The Form extensions FormChem found (installed by FormPortal or run from a folder by form.ext): id, name, version, source, state (ready, needs-permission, refused with the reason) and the commands each contributes.
@@ -481,6 +557,59 @@ Works out the reaction steps of a drawing from where its structures sit around t
| `doc` | string | no | Drawing id from get_context; may be left out when one drawing is open |
| `page` | string | no | Page id; all pages when left out |
+## space_reaction
+
+Lays a perceived reaction scheme out in one row as one undo step: arrows horizontal, even gaps, plus signs between species, arrows stretched to their conditions; with wrap (a row width in points) the scheme continues on a new row, joined by a dogleg line or by repeating the last structure.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `page` | string | no | |
+| `reaction` | string | no | Reaction id; every reaction of the page when left out |
+| `wrap` | number | no | Row width in points, 72 to 20000 |
+| `wrap_mode` | dogleg or repeat | no | |
+| `stretch` | boolean | no | Stretch arrows to fit their conditions (default true) |
+
+## fit_arrows_to_conditions
+
+Lengthens reaction arrows so their agents and conditions fit above and below them, moving what follows along, as one undo step.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `page` | string | no | |
+| `step` | string | no | Step id; every step of the page when left out |
+
+## conditions_as_footnotes
+
+Letters each step of a reaction (a), (b) above its arrow and moves the condition texts into one footnote under the scheme, as one undo step.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `page` | string | no | |
+| `reaction` | string | no | Reaction id; the first reaction of the page when left out |
+
+## predict_ir_bands
+
+Predicted IR absorption bands (wavenumber ranges by functional group, textbook values, indicative) for smiles or a drawn structure.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+
+## predict_ms_fragments
+
+Predicted EI mass spectrum fragment ions (molecular ion, alpha cleavage, benzylic, McLafferty, common neutral losses; indicative) for smiles or a drawn structure.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+
## map_reaction
Maps the atoms of one reaction step (reactant atom to product atom numbers) and marks the bonds broken, formed or changed in order, as one undo step. mode discard (default) maps from scratch, keep keeps the numbers already drawn, alter may change them, clear removes the mapping.
@@ -1032,6 +1161,235 @@ Searches conformers of a structure with the CREST program (metadynamics with GFN
| `threads` | integer | no | Threads; default the Preferences setting |
| `limit` | number | no | Time limit in seconds (default 600 for xtb, 3600 for CREST, at most 604800) |
+## standardise
+
+Standardises structures with the same steps as the window's Structure > Standardise: cleanup (Clean up); normalise (Normalise functional groups); salts (Remove salts and solvents); largest (Keep the largest fragment); reionise (Reionise); neutralise (Neutralise); tautomer (Canonical tautomer); isotopes (Remove isotopes); stereo (Remove stereochemistry); strip_h (Remove explicit hydrogens). Without steps the default set runs (cleanup, normalise, salts, reionise, neutralise, strip_h); a step can be added or dropped with + or - ("default -strip_h +tautomer"). Give smiles to standardise text without a drawing (nothing changes anywhere), or doc with optional objects to standardise structures of a drawing: apply true writes the result as one undo step (atom ids kept where the atom survives), apply false (the default) only reports. Answers with the SMILES before and after, each step that changed something with what it did, and the method of every step.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | SMILES to standardise without a drawing |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `objects` | array of string | no | Fragment ids to standardise; default every structure of the drawing |
+| `steps` | any | no | Step names (cleanup, normalise, salts, largest, reionise, neutralise, tautomer, isotopes, stereo, strip_h), default, all, with + or - before a name; a list or one string |
+| `apply` | boolean | no | Write the standardised structures into the drawing as one undo step (default false) |
+
+## balance_reaction
+
+Balances a reaction with the same solver as the window's Balance Reaction: element and charge counts of each species, the one-dimensional null space of the element matrix scaled to the smallest whole numbers (at most 50). Give smiles, a reaction SMILES such as CCC.O=O>>O=C=O.O, to balance text without a drawing; or a drawing's reaction step (doc, reaction and step from perceive_reactions; left out when the drawing has one step) to check it, and apply true to write the coefficients the solver found, or the coefficients you give as {object id: n}, into the step as one undo step (they are drawn before each structure). When no coefficients balance the step the answer suggests co-products to add (water, HCl, CO2 and others) and nothing is written.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | Reaction SMILES reactants>agents>products (agents are not counted) |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `reaction` | string | no | Reaction id from perceive_reactions |
+| `step` | string | no | Step id from perceive_reactions |
+| `coefficients` | object | no | Object id to whole number 1 to 999, written instead of the solver's answer (apply true) |
+| `apply` | boolean | no | Write the coefficients into the step as one undo step (default false: only check) |
+
+## isotope_pattern
+
+The isotope pattern of a molecule, as the Analysis panel's mass spectrum shows it: every peak's neutral mass, m/z and abundance relative to the base peak (peaks within 0.01 Da merged, peaks under threshold percent dropped), the monoisotopic and average mass and the common adduct ions. Give a formula (C13H18O2, C6H5Br, SO4 2-), a SMILES, or a drawing's structures (doc with optional objects; isotopes drawn on atoms are kept). Labels and R-groups that have no element are left out and said so. Changes nothing.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `formula` | string | no | Molecular formula with an optional charge at the end, such as C8H10N4O2 or C6H5NH3+ |
+| `smiles` | string | no | SMILES of one structure (dots allowed) |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `objects` | array of string | no | Fragment ids; default every structure of the drawing |
+| `threshold` | number | no | Smallest peak kept, in percent of the base peak (0 to 100, default 0.1) |
+
+## export_helm
+
+Writes a peptide, nucleic acid or linker as HELM version 2 text, as Copy as HELM does: the structure is cut at amide and phosphodiester bonds, every piece is matched to FormChem's own monomer data (the 20 amino acids and D forms, [Aib], [Nle], [Orn], [Sar], [Hyp], [pE], caps [ac] and [am], sugars R and [dR], phosphate P, bases A, C, G, U and T), and the HELM written is read back and compared by InChIKey; only a HELM that reads back to the same structure is offered. Give smiles, a molfile, or a drawing's structure (doc and object). When a piece has no monomer the answer says which and no HELM is given. Changes nothing.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `smiles` | string | no | SMILES of the biopolymer |
+| `molfile` | string | no | MDL molfile of the biopolymer |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `object` | string | no | Fragment id; may be left out when the drawing has one structure |
+
+## list_pages
+
+The pages of a drawing in order: number, id, name, size in points (or auto for an auto-grow canvas), orientation, margins, header, footer and how many top-level objects each holds.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+
+## add_page
+
+Adds an empty page to a drawing after page after (default the last), with that page's size, margins, header and footer unless given. One undo step labelled with the tool name.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `after` | integer | no | Page number to add after, 1 based; 0 adds a first page |
+| `paper` | a3 or a4 or a5 or legal or letter or tabloid | no | |
+| `orientation` | portrait or landscape | no | |
+
+## delete_page
+
+Deletes a page and every object on it as one undo step. A drawing keeps at least one page.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | yes | Page number, 1 based (default 1) |
+
+## set_page
+
+Changes a page's setup: size (width and height in points, 36 to 5000, or paper with orientation), auto (an auto-grow canvas that fits the drawing plus the margin), margins, header and footer (fields {page}, {pages}, {file}, {date}) and name. all applies the size, margins, header and footer to every page. Objects never move.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | no | Page number, 1 based (default 1) |
+| `width` | number | no | |
+| `height` | number | no | |
+| `paper` | a3 or a4 or a5 or legal or letter or tabloid | no | |
+| `orientation` | portrait or landscape | no | |
+| `auto` | boolean | no | |
+| `margins` | number | no | |
+| `header` | string | no | |
+| `footer` | string | no | |
+| `name` | string | no | |
+| `all` | boolean | no | |
+
+## fit_page_to_drawing
+
+Shrinks a page to its drawing plus the page margin and moves the drawing to the top left margin, for a single-figure journal file. Bounds are the engine's estimate (fragment atoms and labels, text, arrows, shapes).
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | no | Page number, 1 based (default 1) |
+
+## list_objects
+
+The objects on a page, top level first, with id, kind, name, parent group, hidden and locked flags and the bounding box in points (x, y, w, h, the engine's estimate). kind filters by object kind.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `page` | integer | no | Page number, 1 based (default 1) |
+| `kind` | string | no | Only objects of this kind (fragment, text, arrow, table, tlc ...) |
+
+## undo_agent_changes
+
+Takes back agent changes in a drawing: without step it lists the agent steps still on the undo stack (newest first, with how many steps going back to each costs and how many of those are the person's); with step it undoes every step back to before it. Every undone step can be redone.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open |
+| `step` | string | no | Agent step id from the listing |
+
+## abbreviation_list
+
+The abbreviation library the canvas uses: every built-in and user entry (label, reversed label, SMILES with * at the attachment point, category, source), the path of the user library file and any errors in it. With label it answers for that one label, also reading it as a condensed formula such as CH2CH2OH, with the group formula.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `label` | string | no | The abbreviation as typed on an atom, for example Bnz or Lnk (a letter, then up to 15 letters, digits, ( ) * + or -) |
+| `filter` | string | no | Only labels or categories containing this text |
+
+## abbreviation_define
+
+Adds an abbreviation to the person's user library (abbreviations.json in FormChem's data folder). The canvas uses it at once. smiles has one * at the attachment atom, or [*:1], [*:2] for ordered attachment points. A label that is also an element symbol needs prefer true; an existing user label needs replace true.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `label` | string | yes | The abbreviation as typed on an atom, for example Bnz or Lnk (a letter, then up to 15 letters, digits, ( ) * + or -) |
+| `smiles` | string | yes | |
+| `reversed` | string | no | Label shown when drawn on the left, for example TsO for OTs |
+| `category` | user or alkyl or aryl or protecting group or silyl or sulfonyl or functional or amino acid residue or nucleobase or ligand | no | |
+| `prefer` | boolean | no | |
+| `replace` | boolean | no | |
+
+## abbreviation_remove
+
+Removes an abbreviation from the person's user library. Built-in entries cannot be removed.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `label` | string | yes | The abbreviation as typed on an atom, for example Bnz or Lnk (a letter, then up to 15 letters, digits, ( ) * + or -) |
+
+## compute_surface
+
+Surface areas (Ų) and enclosed volumes (ų) of a structure's stored conformer, every hydrogen included: van der Waals, solvent-accessible and solvent-excluded, with a probe radius (default 1.4 Å, water) or a named solvent, at low, medium or high resolution. Areas by Shrake-Rupley dots (the SES area from grid faces), volumes from grid points, RDKit van der Waals radii. Read only.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `probe` | number | no | Probe radius in Å, 0 to 5 |
+| `solvent` | water or methanol or ethanol or acetonitrile or acetone or thf or dichloromethane or dmso or chloroform or benzene or toluene or hexane | no | |
+| `resolution` | low or medium or high | no | |
+
+## energy_terms_3d
+
+The force-field energy of a stored conformer split into terms (MMFF94: bond stretch, angle bend, stretch-bend, out-of-plane, torsion, van der Waals, electrostatics) with the total in kcal/mol; UFF gives the total only. Read only.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `method` | MMFF94 or MMFF94s or UFF | no | Force field (default MMFF94) |
+
+## rotate_bond_3d
+
+Turns a bond of a stored conformer as one undo step: four atoms and value set that dihedral, two atoms and angle turn by that many degrees. The smaller side moves unless side is other. Ring bonds are refused. Answers with the new dihedral and the single-point energy.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `atoms` | array of string | yes | Two bonded atom ids, or four for a dihedral (hydrogens as a1:h0) |
+| `value` | number | no | Dihedral to set, -180 to 180 |
+| `angle` | number | no | Degrees to turn by |
+| `side` | smaller or other | no | |
+| `method` | MMFF94 or MMFF94s or UFF | no | Force field (default MMFF94) |
+
+## repair_hydrogens_3d
+
+Adds missing and removes extra hydrogens on a stored conformer from valence and charge without moving any heavy atom (only hydrogens are relaxed), as one undo step. Answers with the hydrogen count before and after and the heavy-atom RMSD.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment id (or a 3D object bound to one); may be left out when the drawing has one structure |
+| `conformer` | string | no | Conformer id (c...); default the shown one |
+| `method` | MMFF94 or MMFF94s or UFF | no | Force field (default MMFF94) |
+
+## render_3d
+
+A PNG of a structure's 3D model, or of a 3D object opened from a PDB or mmCIF file, drawn by the FormChem window's 3D View at width x height (64 to 8192 pixels, one pass), with an optional display style, surface, atom labels and hydrogen bonds. Needs the window open and the structure built in 3D.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `object` | string | no | Fragment or 3D object id |
+| `width` | integer | no | |
+| `height` | integer | no | |
+| `transparent` | boolean | no | |
+| `display` | wire or stick or ballstick or spacefill or cartoon | no | |
+| `surface` | none or vdw or sas or ses | no | |
+| `labels` | none or symbol or index or charge or cip or residue | no | |
+| `hbonds` | boolean | no | |
+
+## fetch_pdb
+
+Downloads an entry from RCSB PDB (files.rcsb.org) by its four-character identifier and opens it into a drawing as a 3D object, one undo step. Only the identifier leaves the computer, and only when the person agrees in the FormChem window.
+
+| Argument | Type | Required | Notes |
+| --- | --- | --- | --- |
+| `doc` | string | no | Drawing id from list_open_documents; may be left out when one drawing is open or the window shows one |
+| `id` | string | yes | PDB identifier such as 1CRN |
+| `format` | cif or pdb | no | |
+
## Resource
`formchem://guide` (text/markdown): what exists in this version, the tools, asking the person and errors.
diff --git a/.claude/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md b/.claude/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md
index 1bbf2bce..2a077601 100644
--- a/.claude/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md
+++ b/.claude/skills/formchem-harness/sub-skills/drawing/SUB-SKILL.md
@@ -42,6 +42,13 @@ A reaction SMILES (`reactants>agents>products`, such as `CCO.CC(=O)O>[H+]>CC(=O)
`convert` and `batch_convert` ask the person only when they write outside the temporary folder.
+## Workflow 4: pages, templates and taking back your work (0.14.0)
+
+1. Pages: `list_pages` first; `add_page {paper, orientation}`, `set_page {page, header, footer, margins, auto}` (fields `{page}`, `{pages}`, `{file}`, `{date}`), `fit_page_to_drawing {page}` for a single-figure file, `delete_page {page}` (the last page is refused). Each is one undo step.
+2. Layout checks: `list_objects {page}` gives every object's box in points; use it to see that nothing overlaps before you `render`.
+3. Rings and templates on what is there: `fuse_ring {bond, size, benzene}` fuses onto a drawn bond on the emptier side; `attach_template {id, atom}` attaches, `{id, bond}` fuses, `{id, x, y}` places (ids from `GET /api/templates`, such as `pyridine`). Both run the window's own commands, so a window must be open, and both answer the new atom ids. The template library holds only starter structures and whole molecules; a group such as Boc is an abbreviation (`structure-analysis`).
+4. Taking back: `undo_agent_changes {}` lists your steps still on the undo stack and how many steps going back would undo, the person's included; `undo_agent_changes {step}` goes back to before one. Tell the person how many of their own steps it took with it.
+
## Rules
- **Which drawing.** `doc` when given; else the only open drawing; else the one the window shows; else the tool asks for `doc`. When the person has several open, say which one you drew in.
diff --git a/.claude/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md b/.claude/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md
index 5c87371a..8447b8af 100644
--- a/.claude/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md
+++ b/.claude/skills/formchem-harness/sub-skills/reactions/SUB-SKILL.md
@@ -27,12 +27,15 @@ Answer reaction questions from what FormChem computes, not from the agent's own
| Map atoms | `map_reaction {doc?, reaction?, step?, mode?}`: `discard` (default) maps from scratch, `keep` keeps drawn numbers, `alter` may change them, `clear` removes them; the answer gives map numbers and bonds broken and formed | yes, one undo step |
| The reaction as text | `export_reaction {doc?, reaction?, step?, format?}`: `smiles`, `rxn` (V2000) or `rxnv3000`, with map numbers | no |
| Amounts and yields | `reaction_stoichiometry {doc?, reaction?, step?}`: rows with mmol, equiv, mass, volume, the limiting reagent, the theoretical and percent yield, and the balance check | no |
-| Balance coefficients | `run_command {id: "balance-reaction"}` on the selected or first step; `check-reaction` opens the balance dialog for the person | yes, one undo step |
-| Insert a template | `run_command {id: "insert-template", params: {id: "[template id]"}}`; the ids come from the engine's `GET /api/templates` | yes, one undo step |
+| Balance coefficients | `balance_reaction {doc?, reaction?, step?}` previews the coefficients and co-product hints; with `apply: true` it writes them (drawn before each species); `check-reaction` opens the balance dialog for the person | only with `apply` |
+| Lay the scheme out (0.14.0) | `space_reaction {page?, reaction?, wrap?, wrap_mode?}`: one centre line, 14.4 pt between a structure and an arrow, 7.2 pt around a plus, arrows stretched to their conditions; `wrap` (points) starts a new row with a `dogleg` line or by `repeat`ing the structure | yes, one undo step |
+| Fit arrows (0.14.0) | `fit_arrows_to_conditions {page?, step?}`: each arrow to its widest condition plus 7.2 pt a side, moving what follows. `perceive_reactions` does not stretch; call this or `space_reaction` after it | yes, one undo step |
+| Footnotes (0.14.0) | `conditions_as_footnotes {page?, reaction?}`: letters the steps (a), (b) and moves their conditions into one footnote under the scheme; a second call changes nothing | yes, one undo step |
+| Insert a template | `attach_template {id, x?, y?}` (or on an atom or bond, see `drawing`); the ids come from the engine's `GET /api/templates`, whole molecules only | yes, one undo step |
| Paste a reaction | `paste-reaction` reads the person's clipboard; an agent cannot fill the clipboard, so it is the person's | yes |
| The grid on the page | `stoichiometry-grid` inserts or refreshes the grid for the selected or first step; `show-stoichiometry` opens the panel for the person | yes for the grid |
-`doc` may be left out when one drawing is open; `reaction` and `step` default to the first. The two changing tools ask the person the first time like any change.
+`doc` may be left out when one drawing is open; `reaction` and `step` default to the first. The changing tools ask the person the first time like any change. Map numbers by hand and reacting-centre marks are window commands (`set-atom-map-number {map}`, `reacting-formed` and the other `reacting-*` ids, through `run_command` on the selection); the arrow badge they feed is on screen only. Densities for 65 common liquids come from FormChem's table when the person leaves the density empty; say so when you quote a volume.
## Procedure
diff --git a/.claude/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md b/.claude/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md
index 0836ac92..49acef80 100644
--- a/.claude/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md
+++ b/.claude/skills/formchem-harness/sub-skills/session-and-connection/SUB-SKILL.md
@@ -52,5 +52,5 @@ Agents started from FormChem's own Claude Code, Codex, Cursor or Antigravity tab
## Gate
- [ ] `get_context` was the first call.
-- [ ] The plan uses only the 77 tools (the 71 in the pack root's `references/tools.md`, the library and HELM tools in `library-and-biopolymers` and the xtb tools in `three-d`) and the commands and extensions they report.
+- [ ] The plan uses only the 77 tools (all listed in the pack root's `references/tools.md`; the library and HELM tools explained in `library-and-biopolymers` and the xtb tools in `three-d`) and the commands and extensions they report.
- [ ] No change was attempted after a refusal or a stop, and the agent token never appeared in a reply or a note.
diff --git a/.claude/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md b/.claude/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md
index 03da30fa..5c9b54d5 100644
--- a/.claude/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md
+++ b/.claude/skills/formchem-harness/sub-skills/structure-analysis/SUB-SKILL.md
@@ -26,6 +26,19 @@ From 0.8.0 `compute_properties` and `validate` are the same answers as `properti
`doc` may be left out when one drawing is open (the four 0.6.0 tools need it when several are open); `object` left out means every fragment. `structuredContent` carries the same JSON as the engine's `/api/analysis` routes. The isotope pattern has no tool: it is in the person's Analysis panel (`show-analysis`).
+### More reading tools (0.14.0)
+
+| Goal | Call | What comes back |
+| --- | --- | --- |
+| Isotope pattern | `isotope_pattern {formula or smiles or doc, objects?, threshold?}` | every peak's neutral mass, m/z and abundance; a charge may follow a space (`SO4 2-`) |
+| IR bands | `predict_ir_bands {smiles or doc, object?}` | characteristic bands by functional group, textbook ranges, labelled indicative |
+| MS fragments | `predict_ms_fragments {smiles or doc, object?}` | indicative EI fragment ions with their neutral losses |
+| HELM text | `export_helm {smiles or molfile or doc, object?}` | HELM version 2, refused when it would not read back |
+| Abbreviations | `abbreviation_list {label?, filter?}`; `abbreviation_define {label, smiles}` (one `*`, or `[*:1]`, `[*:2]`), `abbreviation_remove {label}` (built-ins refused) | the library; the two writes change the person's own library file and ask first |
+| Standardise | `standardise {smiles or doc, objects?, steps?, apply?}` | what the window's Standardise would do; it writes only with `apply: true` |
+
+Molecular weights use the CIAAW 2024 table and properties add Veber and Ghose; quote the method the answer gives. Typed labels such as CH2CH2OH are chemistry now, and a molecular formula typed on an atom stays text with its own note. Plain SMILES of a query structure is refused (`query_smiles_refused`): use SMARTS or a V3000 molfile through `convert`.
+
## Chemistry commands (run_command)
They act on the person's selection, or on the page when nothing is selected; the agent selects only with `select-all` or by inserting. Check `list_commands {id}` for params and the off reason first.
@@ -46,7 +59,7 @@ They act on the person's selection, or on the page when nothing is selected; the
1. **Context.** `get_context`; name the drawing and pick fragment ids from the tool answers, never by guess.
2. **Read with the tool, not the command.** For values, issues, labels or matches call the analysis tool; the command opens a panel the agent cannot read.
3. **Quote with the method.** Report each value as the tool printed it, with its unit and method ("cLogP 3.07, Crippen.MolLogP; typical error 0.5 to 0.7 log units"). Never compute a property, a CIP label or a SMARTS match with your own chemistry and present it as FormChem's.
-4. **Stereo states matter.** An `undefined` centre has no label because nothing fixes it; say so instead of guessing R or S. Allene axial chirality and drawn atropisomers are not perceived in this version.
+4. **Stereo states matter.** An `undefined` centre has no label because nothing fixes it; say so instead of guessing R or S. From 0.14.0 atropisomers and allenes get M or P from their wedges, listed as axes; SMILES, InChI and V2000 drop the axis, and the answer's note says so.
5. **Change through commands, then read back.** After `assign-wedges`, a stereo group or `add-hydrogens`, call `stereo` or `check_structure` again and report what changed, with Undo as the way back.
6. **Hand off** with what changed or what the person should look at (`handoff`).
diff --git a/.claude/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md b/.claude/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md
index cb82ea98..34c94ecb 100644
--- a/.claude/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md
+++ b/.claude/skills/formchem-harness/sub-skills/three-d/SUB-SKILL.md
@@ -52,6 +52,16 @@ Tight-binding total energies are in hartree for one structure, charge and solven
2. **Call `extract_ligand {object?, ligand?}`** with a key or het code, or nothing for the primary ligand. The answer gives the new fragment id and its SMILES, and whether bond orders came "from the template table" (30 common ligands) or were "inferred from the geometry". Say which; an inferred ligand's SMILES needs the person's eye.
3. **Check it** like any structure (`visual-qa`): `get_structure` and `validate` on the new fragment.
+## Workflow 3b: surfaces, terms, rotation, repair and PDB by id (0.14.0)
+
+- `compute_surface {object, conformer?, probe?, solvent?, resolution?}`: van der Waals, solvent-accessible and solvent-excluded areas (Ų) and volumes (ų), every hydrogen included; the SES area is an estimate and the answer says so. Reads only.
+- `energy_terms_3d {object, conformer?, method?}`: MMFF94 split into stretch, bend, stretch-bend, out-of-plane, torsion, van der Waals and electrostatics, adding up to the total; UFF gives the total only. Reads only.
+- `rotate_bond_3d {object, atoms, value?, angle?, side?}`: four atoms and `value` set a dihedral, two atoms and `angle` turn a bond; the smaller side moves, and a ring bond answers "Cannot rotate a ring bond." with nothing changed. One undo step.
+- `repair_hydrogens_3d {object, conformer?}`: adds missing and removes extra hydrogens without moving a heavy atom. One undo step.
+- `render_3d {object, width?, height?, transparent?, display?, surface?, labels?, hbonds?}`: a PNG drawn by the window's 3D View (needs the window); use it to check a 3D answer by eye.
+- `fetch_pdb {id, format?}`: downloads an RCSB entry by its four-character id and opens it as a 3D object; the id leaves the machine, so it asks the person like any change. Prefer a file the person already has.
+- Dihedrals read with the IUPAC sign from 0.14.0; numbers from 0.13.0 or before had the opposite sign.
+
## Workflow 4: export and show
- `export_3d {object, format, conformer?, output?}`: MOL (the shown conformer), SDF (default; every conformer, with energy and method data fields), PDB or XYZ, every hydrogen included. Without `output` the text comes back; with an absolute `output` it writes a new file and never overwrites.
diff --git a/.claude/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md b/.claude/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md
index de8c9a18..62237c0f 100644
--- a/.claude/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md
+++ b/.claude/skills/formchem-harness/sub-skills/window-commands/SUB-SKILL.md
@@ -32,6 +32,7 @@ Most canvas commands act on the canvas selection. The agent sets the selection t
| Show it in 3D, change the 3D style or surface, put a 3D view on the page, save a 3D picture | Build and measure with the 3D tools (`three-d`). Then `view-3d` (opens the 3D View on the selection), `style-wire`, `style-stick`, `style-ballstick`, `style-spacefill`, `style-cartoon`, `surface-none`, `surface-vdw`, `surface-sas`, `surface-ses`, `surface-esp` (on only while the 3D View is open), `insert-3d-view` (a 3D object beside the selected structure), `export-3d-png {transparent}` and `export-gltf` (saved for the person). `export-3d-file {format, all}` saves MOL, SDF, PDB or XYZ for the person; `export_3d` gives the agent the text |
| Show the database, a view of it, its dialogs, or the notebook to the person | Work with the database tools (`databases`). Then `show-databases`, `db-view-table`, `db-view-gallery`, `db-view-form`, `db-view-plot`, `db-view-notebook`, `db-search {text}`, `db-import {path}`, `db-export`, `database-fields`, `database-settings` (the person's dialogs); `nb-sign-entry` asks the person to sign and is never run in their place |
| Copy a live structure for another Form app, open a library item for editing, HELM text of a drawn peptide, show the Structure Library or the Structure Summary, change the element colours | Library and HELM tools first (`library-and-biopolymers`). Then `copy-live-structure`, `open-live-structure {id, from}`, `copy-helm`, `structure-library {tab}`, `a11y-describe`, `element-palette-high-contrast` and its two siblings |
+| Show me the demos, an example to start from | `run_command {id: "demos"}` (Help > Demos, 0.13.0): Home at its five demos (aspirin, the two-step aspirin synthesis, the enantiomers, cholesterol in 3D, benzocaine with its 1H NMR). The person clicks one to open a new unsaved copy; then the drawing tools reach it like any drawing (`list_open_documents`) |
| Stack or group objects | `bring-front`, `bring-forward`, `send-backward`, `send-back`, `group`, `ungroup` on the selection; off with "Select something on the canvas first" when nothing is selected |
| Anything about the reaction in the drawing | Load `reactions` |
| Undo the last change | `run_command {id: "undo"}`: one transaction, whoever made it |
diff --git a/.claude/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md b/.claude/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md
index 2ef1d85c..a1bdc1c7 100644
--- a/.claude/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md
+++ b/.claude/skills/formchem-harness/sub-skills/window-commands/references/command-catalogue.md
@@ -1,6 +1,6 @@
# Commands that touch a drawing
-The window's command registry, as far as it concerns drawings, for FormChem 0.12.0 (the commands of 0.7.0, plus `agent-activity` from 0.8.0, which opens Window > Agent Activity for the person, plus the name, spectrum and NMR commands of 0.9.0, the 3D commands of 0.10.0, the database and notebook commands of 0.11.0, and the library, live structure, HELM, xtb and accessibility commands of 0.12.0). From 0.8.0 the agent's own tools draw, edit, read back, render and convert; this page covers what the window's commands add. This page is a map, not the authority: `list_commands` is. A command marked `off now` there is not available in the running build, whatever this page says, and a command that lists `params` there takes exactly those.
+The window's command registry, as far as it concerns drawings, for FormChem 0.13.0 (the commands of 0.7.0, plus `agent-activity` from 0.8.0, which opens Window > Agent Activity for the person, plus the name, spectrum and NMR commands of 0.9.0, the 3D commands of 0.10.0, the database and notebook commands of 0.11.0, the library, live structure, HELM, xtb and accessibility commands of 0.12.0, and Help > Demos of 0.13.0). From 0.8.0 the agent's own tools draw, edit, read back, render and convert; this page covers what the window's commands add. This page is a map, not the authority: `list_commands` is. A command marked `off now` there is not available in the running build, whatever this page says, and a command that lists `params` there takes exactly those.
## Contents
@@ -17,6 +17,8 @@ The window's command registry, as far as it concerns drawings, for FormChem 0.12
- Databases and the notebook
- Library, live structures, HELM, xtb and accessibility
- The canvas, the view and the grid
+- Help > Demos (0.13.0)
+- The parity pass (0.14.0)
- Registered but off until a later version
- What no command does yet
@@ -29,7 +31,7 @@ The window's command registry, as far as it concerns drawings, for FormChem 0.12
| Command | Params | What it does |
| --- | --- | --- |
| `new-document` | | creates an empty drawing and makes it active (Home closes) |
-| `open-recent` | `path` (absolute) | opens that file: a `.fchem` drawing, a chemistry file (molfile, SD, RXN, RD, SMILES, CXSMILES, SMARTS, InChI, CML, CDXML, CDX) imported into a new unsaved drawing with an import report for the person, or a picture FormChem exported with its drawing inside; without `path` it shows Home |
+| `open-recent` | `path` (absolute) | opens that file: a `.fchem` drawing, a chemistry file (molfile, SD, RXN, RD, SMILES, CXSMILES, SMARTS, InChI, CML, CDXML, CDX, PDB, mmCIF, JCAMP-DX) imported into a new unsaved drawing with an import report for the person, a picture FormChem exported with its drawing inside, or an `.fcdb` database in the database workspace; the same path the desktop app uses for files the system hands it; without `path` it shows Home |
| `open` | | shows the file chooser to the person; an agent cannot answer it |
| `save` | | saves the active drawing; a drawing with no file yet asks the person for a name in the browser window |
| `save-as`, `save-copy` | | ask the person where or under what name |
@@ -230,9 +232,31 @@ From 0.12.0. Adding to the library, the live structure object, drawing from HELM
| `toggle-analysis`, `analysis-panel` | shows or hides the Analysis panel (formula, masses, m/z, elemental analysis from the engine, for the selection or the whole page) |
| `tool-select`, `tool-bond`, `tool-chain`, `tool-ring`, `tool-atom`, `tool-text`, `tool-eraser`, `tool-hand`, `tool-zoom`, `tool:[id]` | pick a drawing tool for the person; they do not draw by themselves |
+## Help > Demos (0.13.0)
+
+| Command | Params | What it does |
+| --- | --- | --- |
+| `demos` | none | shows Home scrolled to its Demos with the first card focused: Aspirin, Aspirin in two steps (scheme, stoichiometry amounts, curved-arrow mechanism), Enantiomers (L- and D-alanine, (S)- and (R)-ibuprofen with R and S labels), Cholesterol in 3D (three conformers and a 3D view), Benzocaine with its 1H NMR. The person clicks a card to open a new unsaved copy; no command or tool opens one for the agent |
+
+## The parity pass (0.14.0)
+
+The catalogue has 422 commands. Check `list_commands {id}` for each one's params before running it; the rows below are the groups, and the commands act on the selection or the active page like the others.
+
+| Commands | Do |
+| --- | --- |
+| `new-page`, `duplicate-page`, `delete-page`, `move-page-left`, `move-page-right`, `move-page {to}`, `next-page`, `previous-page`, `go-to-page {page}`, `page-setup`, `fit-page-to-drawing` | pages; `page-setup` with params sets size, orientation, auto-grow, margins, header and footer without the dialog (the `*_page` tools do the same and answer) |
+| `document-style`, `apply-style-document {preset, discard_overrides?}`, `apply-style-selection`, `export-style`, `import-style` | journal styles: `apply-style-document {"preset": "large-screen"}` rescales every structure to the preset |
+| `object-style`, `set-colour`, `text-bold`, `text-italic`, `text-underline`, `text-subscript`, `text-superscript`, `text-plain`, `text-formula`, `text-align-*`, `text-line-spacing`, `label-position-*`, `renumber-compounds`, `insert-heat`, `insert-light`, `insert-arrow-equals` | object and text formatting on the selection, label position, compound renumbering, heat, light and arrow-equals captions above the selected arrow |
+| `space-reaction`, `space-reaction-repeat`, `fit-arrow-to-conditions`, `conditions-as-footnotes`, `set-atom-map-number {map, sequence?}`, `reacting-formed`, `reacting-broken`, `reacting-order`, `reacting-stereo`, `reacting-unchanged`, `reacting-none` | scheme layout and mapping by hand (the scheme tools answer the agent directly) |
+| `atom-properties`, `toggle-atom-numbers`, `periodic-table-tool`, `toggle-circled-charges`, `toggle-lone-pair-bars`, `define-abbreviation`, `abbreviation-library` | atom display and the abbreviation library; the dialogs belong to the person |
+| `rotate-90-left`, `rotate-by-angle {degrees}`, `flip-keeps-wedges`, `fixed-bond-length`, `smart-guides`, `snap-atoms-to-grid`, `group-integral`, `select-scheme`, `join-atoms`, `fuse-ring {bond, size}`, `attach-template {id, atom?, bond?}`, `toggle-select-tool` | transforms, switches and gestures; `fuse_ring` and `attach_template` tools answer with the new ids |
+| `insert-glassware {id}`, `edit-table-cell`, `table-add-row`, `table-add-column`, `table-auto-grow`, `tlc-add-lane`, `tlc-duplicate-lane`, `tlc-delete-lane`, `tlc-lane-label`, `tlc-show-rf`, `tlc-rf-values` | glassware drawings, tables and TLC plates |
+| `export-tiff`, `export-jpeg`, `export-webp`, `print` (now a dialog), `save-undo-history`, `undo-agent-changes` | pictures and print hand their file or dialog to the person; `undo_agent_changes` is the agent's own way back |
+| `open-pdb-id`, `repair-hydrogens-3d`, `cancel-conformers`, `rotate-bond-3d`, `energy-terms-3d`, `surface-metrics-3d`, `colour-3d`, `labels-3d`, `hbonds-3d`, `binding-site-3d`, `projection-3d`, `periodic-table`, `constants-units` | the 3D View and the reference windows, for the person; the 3D tools answer the agent |
+
## Registered but off until a later version
-`demos` (0.13.0). Every 0.7.0, 0.9.0 and 0.10.0 placeholder is now a working command (`insert-name`, `view-3d`, `build-3d`, `minimize-3d` and `conformers` among them). Running an off one returns "is not available right now: Arrives in [version]". Say so; do not retry.
+None at 0.13.0: `demos` was the last placeholder. Every 0.7.0, 0.9.0 and 0.10.0 placeholder is a working command (`insert-name`, `view-3d`, `build-3d`, `minimize-3d` and `conformers` among them). If a command still answers "is not available right now: Arrives in [version]", say so; do not retry.
## What no command does yet
diff --git a/.claude/skills/formchem-skillset/EVALS.json b/.claude/skills/formchem-skillset/EVALS.json
index 15b53e67..98e289d2 100644
--- a/.claude/skills/formchem-skillset/EVALS.json
+++ b/.claude/skills/formchem-skillset/EVALS.json
@@ -1,6 +1,6 @@
{
"skill_name": "formchem-skillset",
- "notes": "Run in a FormChem checkout at 0.12.0 with CLAUDE.md present; evals 32 to 36 need no fixtures, and eval 35 must not install xtb. Expected behaviours are observable in the files read, the edits made and the commits.",
+ "notes": "Run in a FormChem checkout at 0.14.0 with CLAUDE.md present; evals 32 to 44 need no fixtures, eval 38 must not build a bundle, and eval 35 must not install xtb. Expected behaviours are observable in the files read, the edits made and the commits.",
"evals": [
{
"id": 1,
@@ -405,6 +405,94 @@
"Checks under 4x CPU throttling with a MutationObserver that a switch adds or removes no node and changes only fills",
"Writes the reason in frontend/HASHOUT_LOG.md, not in a comment"
]
+ },
+ {
+ "id": 37,
+ "name": "data-file-in-app",
+ "prompt": "I added a solvent density table to FormChem's stoichiometry service. It works from source but the desktop app says the table is missing. Fix it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads desktop and finds the app/data rule: the file belongs under backend/app/data and is read relative to the services folder with Path(__file__).resolve().parents[...]",
+ "Moves the read to that form instead of adding a new --add-data line or reading from the working folder or the repository root",
+ "Does not run pyinstaller or tauri build unless the task says so, and states that the frozen check (the file found in a built app) was not run if it was not"
+ ]
+ },
+ {
+ "id": 38,
+ "name": "associate-file-type",
+ "prompt": "Make FormChem's desktop app show up in Open With for .xyz files.",
+ "files": [],
+ "expected_behavior": [
+ "Loads desktop and changes the five places together: OPENABLE in src-tauri/src/main.rs, OPEN_EXTENSIONS in frontend/src/app/documents.ts, bundle.fileAssociations, Info.plist and the Linux MIME package",
+ "Adds the type as Viewer with rank Alternate, not Editor, and checks first that the engine can open an .xyz file",
+ "Runs cargo check under the lock after the config change and records what was not built (macOS, Windows) in the HASHOUT log"
+ ]
+ },
+ {
+ "id": 39,
+ "name": "add-home-demo",
+ "prompt": "Add a sixth demo to FormChem's Home: caffeine with its predicted 13C NMR spectrum.",
+ "files": [],
+ "expected_behavior": [
+ "Loads desktop and adds a FormChem JSON document under backend/app/data/demos plus its row in demos.json, baked with a scratch engine script outside the repository",
+ "Checks model.validate on the document and that GET /api/demos lists six demos with no error, without changing ui/home-demos.ts or home.ts",
+ "Leaves the browser demos under demos/ and frontend/src alone"
+ ]
+ },
+ {
+ "id": 40,
+ "name": "add-protecting-group-template",
+ "prompt": "Add a Boc protecting group to FormChem's built-in template library so people can drop it on an amine.",
+ "files": [],
+ "expected_behavior": [
+ "Loads annotations and refuses to add a single part to backend/app/data/templates, citing the owner's whole-molecule rule",
+ "Points to the abbreviation library (Boc is already there, services/chem/abbrev_data.py or abbrev.py) and Define Abbreviation for a new group",
+ "Changes no template JSON file"
+ ]
+ },
+ {
+ "id": 41,
+ "name": "space-reaction-gap",
+ "prompt": "In FormChem, Space Reaction leaves a 20 pt gap before the product instead of 14.4. Find the cause.",
+ "files": [],
+ "expected_behavior": [
+ "Loads reactions and reads services/chem/scheme.py space_reaction and _Spacer, and whether the window sent its drawn boxes",
+ "Reproduces on a scratch engine through the space route and reports the gaps and centre line as numbers",
+ "Keeps one algorithm for the window and agents, and leaves arrows stretched only at Perceive, Space and Fit"
+ ]
+ },
+ {
+ "id": 42,
+ "name": "ir-band-for-nitrile",
+ "prompt": "The predicted IR tab in FormChem shows no band for benzonitrile's C#N. Add it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads names-and-spectra and clean-room, and edits backend/app/services/spectra/ir_bands.py with a SMARTS written for FormChem and a textbook range",
+ "Copies no spectral table, keeps the method name, and checks benzonitrile through /api/chem/ir-bands on a scratch engine",
+ "Adds a backend HASHOUT entry"
+ ]
+ },
+ {
+ "id": 43,
+ "name": "export-tiff-colour",
+ "prompt": "FormChem's TIFF export comes out with swapped red and blue. Fix it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads formats-and-export and works in frontend/src/app/picture-raster.ts, adding no encoder dependency",
+ "Reads the exported file back with an outside reader in a scratch folder and compares pixels with the PNG export",
+ "Keeps every picture going through picture.ts pictureFile"
+ ]
+ },
+ {
+ "id": 44,
+ "name": "journal-style-selection",
+ "prompt": "Apply Style to Selection in FormChem also changes the bond length of unselected structures. Fix it.",
+ "files": [],
+ "expected_behavior": [
+ "Loads canvas and reads app/style-commands.ts applyStyleDraft, where selection scope writes style overrides on the touched objects only",
+ "Checks in the window that only the selected fragment rescales and that one Undo restores it",
+ "Does not change the document style for selection scope"
+ ]
}
],
"trigger_evals": [
@@ -472,6 +560,20 @@
{"query": "FormChem's xtb job leaves its process running after cancel, look at services/xtb/runner.py", "should_trigger": true},
{"query": "Copy as HELM refuses a stapled peptide in formchem, fix the writer cuts", "should_trigger": true},
{"query": "draw oxytocin from HELM in FormChem for me", "should_trigger": false},
- {"query": "make FormDeck read the formai structure library folder", "should_trigger": false}
+ {"query": "make FormDeck read the formai structure library folder", "should_trigger": false},
+ {"query": "names work from source but not in the formchem desktop app, is the data folder bundled by freeze_backend", "should_trigger": true},
+ {"query": "double-clicking a .fcdb file does not open formchem on linux, check the desktop entry and the MIME package", "should_trigger": true},
+ {"query": "add a demo drawing to formchem's Home under backend/app/data/demos", "should_trigger": true},
+ {"query": "rebuild the formchem reactions browser demo after changing the stoichiometry panel", "should_trigger": true},
+ {"query": "open the FormChem aspirin demo for me and add a methyl group", "should_trigger": false},
+ {"query": "register a custom file extension with my Electron app on Windows", "should_trigger": false},
+ {"query": "formchem's Space Reaction puts the plus sign in the wrong place, look at scheme.py", "should_trigger": true},
+ {"query": "add a template to formchem's built-in library under backend/app/data/templates", "should_trigger": true},
+ {"query": "the predicted IR tab in formchem misses a carbonyl band", "should_trigger": true},
+ {"query": "formchem page strip and Page Setup header fields render wrong", "should_trigger": true},
+ {"query": "Apply Style to Document in formchem does not rescale the second page", "should_trigger": true},
+ {"query": "formchem TIFF or PDF/A picture export is broken", "should_trigger": true},
+ {"query": "space this reaction scheme in my FormChem drawing for me", "should_trigger": false},
+ {"query": "which journal style should I use for my ACS paper figures", "should_trigger": false}
]
}
diff --git a/.claude/skills/formchem-skillset/SKILL.md b/.claude/skills/formchem-skillset/SKILL.md
index 79679f99..97397eae 100644
--- a/.claude/skills/formchem-skillset/SKILL.md
+++ b/.claude/skills/formchem-skillset/SKILL.md
@@ -1,17 +1,17 @@
---
name: formchem-skillset
-description: "Guides development of the FormChem codebase, the FormAI family's chemical structure drawing suite. Use whenever a task changes, fixes or explains FormChem code: the document format (FORMAT.md, model.ts, model.py, ops), the RDKit service (identifiers, the 2D layout, CIP, stereo groups, abbreviations, queries, properties), reactions, file formats, the clipboard, the command line, the SVG canvas, annotations, names, NMR prediction, JCAMP-DX spectra, 3D (conformers, force fields, PDB, xtb and CREST), the structure database and notebook (.fcdb, search, import, signing hashes), live structures and the shared library (LIVE_STRUCTURES.md, formai:// links, edit-live), keyboard access and palettes, HELM, the shell, menus, extensions, the MCP server and agent tools, the Tauri shell, or a release and its CHANGELOG. Trigger on FormChem or formchem with backend/app, frontend/src, src-tauri, FORMAT.md or port 8220. Not for using FormChem (formchem-harness), other Form apps such as FormDeck, or standalone RDKit scripts."
+description: "Guides development of the FormChem codebase, the FormAI drawing suite. Use whenever a task changes, fixes or explains FormChem code: the document format (FORMAT.md, model.ts, model.py), the RDKit service (identifiers, CIP, abbreviations, queries), reactions and Space Reaction, file formats, picture export, page setup, headers and print, the clipboard, the command line, the SVG canvas, journal styles and text formatting, annotations, the template library of whole molecules, names, NMR, IR and MS prediction tables, JCAMP-DX spectra, 3D, PDB, xtb and CREST, the structure database and notebook (.fcdb, search, entry signing hashes), live structures (LIVE_STRUCTURES.md, formai:// links, edit-live), keyboard access, HELM, the shell, menus, extensions, MCP agent tools, the desktop app, files it opens, demos, or a release CHANGELOG. Trigger on FormChem or formchem with backend/app, frontend/src, src-tauri, FORMAT.md or port 8220. Not for using FormChem (formchem-harness), other Form apps, or standalone RDKit scripts."
license: Apache-2.0
metadata:
author: nodemode-ai
- version: "0.12.0"
+ version: "0.14.0"
---
# FormChem skillset
Route every change to FormChem's code through this file. It maps the subsystems that exist today, states the laws that hold everywhere and names the specialist to load. FormChem is a Python 3.12 FastAPI engine (`backend/`, port 8220), a vanilla TypeScript and Vite window (`frontend/`, port 5220, no framework) that talks to the engine over REST and one WebSocket, and a Tauri 2 shell (`src-tauri/`) that runs the frozen engine from a folder inside the app on macOS and as a sidecar elsewhere.
-**Where FormChem is (0.12.0).** Through 0.11.0: the shell, format, store and RDKit service, canvas, reactions, analysis, formats, agent tools, names, NMR, spectra, 3D, databases and the notebook (`CHANGELOG.md`). 0.12.0 adds live structures and the shared library (`docs/LIVE_STRUCTURES.md`), accessibility, HELM, xtb and CREST by path and six MCP tools (77). Desktop builds and the manual (0.13.0) come later (`DEV_PLAN.md`); do not write them ahead.
+**Where FormChem is (0.14.0, all fourteen phases built).** Through 0.11.0: the shell, format, store and RDKit service, canvas, reactions, analysis, formats, agent tools, names, NMR, spectra, 3D, databases and the notebook (`CHANGELOG.md`). 0.12.0 adds live structures and the shared library, accessibility, HELM and xtb and CREST by path. 0.13.0 adds files from the system, the whole `backend/app/data` in the frozen engine, the demos, `docs/MANUAL.md` and `docs/PARITY.md`. 0.14.0, the parity pass, adds Space Reaction and footnotes, predicted spectra tables, the whole-molecule template library and the Template tool, pages, headers and the Print dialog, condensed labels and atom numbers, journal styles and text formatting, journal-ready pictures, 3D terms, surfaces and crystals, and 27 MCP tools (104). Every v1 row of `docs/PARITY.md` is Full or a written Decision: read a row's Decision before building against it.
## Subsystem map
@@ -38,47 +38,13 @@ Route every change to FormChem's code through this file. It maps the subsystems
| Terminal and agent dock | `frontend/src/dock/` (vendored), `frontend/src/dock-adapter.ts`, `backend/app/routers/terminal.py`, `services/terminal.py`, `services/claude_code.py`, `services/agent_programs.py`, `services/agent_lookup.py` (vendored) | `dock` |
| Form extensions (host API 1) | `frontend/src/extensions/`, `backend/app/routers/extensions.py`, `services/formext_host.py` (vendored), `docs/EXTENSIONS.md` | `extensions` |
| MCP server, agent tools, the call log, Agent Activity, the token, the catalogue, skills | `backend/app/routers/mcp.py`, `services/agent_*.py`, `core/agent_token.py`, `routers/agent_activity.py`, `routers/commands.py`, `frontend/src/app/agent-*.ts`, `ui/agent-*.ts`, `canvas/agent-marks.ts`, `setup/mcp_stdio.py`, `setup/agents.py`, `docs/AGENTS.md`, `.claude/skills` | `agents` |
-| Desktop app, the macOS engine folder and the sidecar | `src-tauri/` (`packaged.rs`, `tauri.macos.conf.json`), `formchem_engine.py`, `setup/freeze_backend`, `lib.sh`, `desktop_*`, `build_app` | `desktop` |
+| Desktop app, the engine folder and sidecar, bundled data, file types, document icons, system-open; the demos | `src-tauri/` (`linux/`, `windows/`, `Info.plist`), `formchem_engine.py`, `setup/freeze_backend`, `desktop_*`, `build_app`, `app/system-open.ts`, `services/demos.py`, `ui/home-demos.ts`, `demos/` | `desktop` |
| Versions, changelog, notices, CI, formcompiler | `.docs/BRANCHING.md`, `CHANGELOG.md`, `NOTICE.md`, `setup/notices.py`, `.github/workflows/` | `release` |
| Where any FormChem feature may come from | the owner's clean-room specifications | `clean-room` |
## Dependency graph
-```text
-frontend commands/registry.ts -> nothing (DOM free; the cli and workers may import it)
-engine/model.ts, engine/ops.ts -> nothing (pure, DOM free; the contract)
-chem/ -> engine/model.ts only (pure, no t(), no DOM)
-engine/client.ts, session.ts -> model, ops, client-api, io/api, io/live
-canvas/render -> canvas/types.ts, engine/model, engine/ops (own geom, valence, rings); table.ts
- also chem/stoich.ts; marks-layer.ts also canvas/marks-options.ts
-engine/analysis-api.ts -> io/api, model, ops; the only caller of /api/analysis
-canvas/tools -> canvas/types.ts, engine/model, engine/ops, canvas/geom.ts
-canvas/view.ts, ui/tool-rail -> canvas/types.ts, hit.ts, selection.ts, ui/dom, ui/icons, i18n
-io/ -> registry only for the catalogue mirror
-ui/, dock-adapter, extensions -> io, ui/dom, ui/icons, i18n
-app.ts -> everything; the composition root (wiring only)
-backend services/model.py, ops.py -> nothing (pure; the contract)
-services/store.py -> model, ops, package, history, importers, hub; chem.derive imported lazily
-services/chem/ -> rdkit, indigo, model (never the store or routers)
-backend routers -> core, services (hub, bridge, library, store, chem, terminal, formext_host)
-mcp.py -> commands, extensions, consent, claude_code, bridge, hub, agent_token; agent_* lazily
-services/agent_*.py -> store, bridge, chem (agent_edits pure); agent_log hooks AFTER_CHANGE
-app/picture.ts -> canvas/render (a fresh renderer off screen), never the live canvas view
-app/clip-*.ts, import-files -> engine/model, ops, the export and parse routes; one paste plan (clip-data.ts)
-services/chem/writers, stream -> formats, report, io, rdkit, indigo (never the store)
-services/batch.py, app/cli.py -> chem/stream, records, standardise, depict, props (never routers or the store)
-services/pictures/ -> fontTools and the bundled fonts only
-services/names, nmr, spectra -> rdkit, numpy, chem (never routers); nmr registers its hook in spectra.source.PREDICTORS
-services/three_d -> rdkit, numpy, chem (never routers); store.apply_now runs three_d.stale
-services/database, notebook -> sqlite3, rdkit, numpy, chem (never routers or the document store)
-services/helm, xtb, describe -> rdkit, chem (xtb also three_d); xtb starts programs only as separate processes
-canvas/a11y -> canvas view and render, ui/a11y-announcer; installed before mountCanvas
-ui/view3d-lib.ts -> 3dmol by dynamic import only (nothing 3D at startup)
-window-only abilities -> reach the engine as window tools over /api/live (bridge.window_call)
-desktop shell -> frozen engine (formchem_engine.py) -> serves frontend/dist
-```
-
-The window reaches the engine only through `frontend/src/io/api.ts` (REST with the window key) and `io/live.ts` (`/api/live`). The engine never imports frontend code. A document change travels one way: a tool or command commits a transaction through the document client, the engine validates and applies it, then broadcasts `tx` and later `derived` to every window, which patches its mirror and its SVG.
+The full module graph is `references/dependency-graph.md`: read it before importing across folders. The three rules that matter most: `engine/model.ts`, `engine/ops.ts`, `services/model.py` and `ops.py` import nothing (the contract); `services/chem/` and every engine package below it never import the store or routers; the window reaches the engine only through `io/api.ts` and `io/live.ts`, and a change travels one way, as a transaction the engine applies and broadcasts.
## Laws for every change
@@ -105,9 +71,13 @@ The window reaches the engine only through `frontend/src/io/api.ts` (REST with t
| SMILES, InChI, formula, masses, implicit hydrogens, valence errors, warnings, 2D clean-up or layout, a structure file reader or writer, the derived cache | `chemistry-engine` |
| How a bond, label or wedge renders, a drawing tool, a hover key, hit testing, selection, zoom, the tool rail, canvas context menus | `canvas` |
| An arrow, bracket, shape, table, TLC plate, orbital, picture or caption, its handles and tool; z-order, groups, templates | `annotations`, with `canvas` for the laws it builds on |
-| Reaction roles, atom mapping, balance, the stoichiometry panel or grid, reaction SMILES or RXN, a reaction route, command or MCP tool | `reactions`, with `chemistry-engine` for RDKit and `agents` for a tool |
+| A template entry, the Template tool, glassware; pages, the page strip, Page Setup, headers and footers; table cells, TLC spots, Object Style | `annotations` (the whole-molecule rule, pages and objects) |
+| A journal style, Document Style, style files, text formatting keys, label position, vertical labels, the allene dot, mitre joins; atom numbers, Atom or Bond Properties, the periodic table picker, a gesture | `canvas` |
+| Reaction roles, atom mapping, balance, the stoichiometry panel or grid, reaction SMILES or RXN, a reaction route, command or MCP tool; Space Reaction, stretching, footnotes, wrapping, reacting-centre marks, the density table | `reactions`, with `chemistry-engine` for RDKit and `agents` for a tool |
+| A condensed label, the abbreviation library or Define Abbreviation; CIAAW weights, adducts, isotope resolution, found values, axial chirality, polymer formulas | `stereo-and-queries` |
+| The predicted 1H, 13C, IR or MS tables, solvent peaks, DEPT, IR bands, EI fragments | `names-and-spectra` |
| A CIP label, stereo group, wedge, abbreviation, hydrogen, query atom or bond, SMARTS, R-group, property, check issue or isotope peak; an `/api/analysis` route or tool | `stereo-and-queries` (`chemistry-engine` for the converter, `agents` for a tool) |
-| A file that opens wrong or loses something, an export or import report, a new format, File > Import, picture export, the drawing inside a picture, saving in the desktop app, print | `formats-and-export`, with `chemistry-engine` for RDKit and `clean-room` for a new format |
+| A file that opens wrong or loses something, an export or import report, a new format, File > Import, picture export (TIFF, JPEG, WebP, one-bit, SVG outlines, PDF/A), the drawing inside a picture, saving in the desktop app, the Print dialog, FASTA, superatom Sgroups, CDXML styling | `formats-and-export`, with `chemistry-engine` for RDKit and `clean-room` for a new format |
| Copy, Cut, Paste, Copy As, Paste Special, Duplicate, a clipboard flavour on one platform | `clipboard`, with `formats-and-export` for the text formats and pictures |
| `./formchem convert`, `batch`, `descriptors`, `render`, the stream reader, per-record failures, Standardise | `command-line`, with `chemistry-engine` for RDKit |
| A name read wrong, a dictionary entry, a ring parent, OPSIN; a predicted shift, an increment, a predictor; a JCAMP-DX file, the spectrum plot, peaks, integrals, atom links, the Spectrum editor | `names-and-spectra` (`clean-room` first; `canvas` for the renderer, `document-format` for the spectrum object) |
@@ -123,7 +93,7 @@ The window reaches the engine only through `frontend/src/io/api.ts` (REST with t
| Terminal tabs, Claude Code, Codex, Cursor or Antigravity tabs, the consent dialog, chat | `dock` |
| The extensions pane, an extension API call, FormPortal or form.ext integration | `extensions` |
| An MCP tool, an edit builder, agent render or placement, the call log, Agent Activity, Stop, the token, `./formchem agents`, skills | `agents` |
-| Desktop build, `build_app`, a slow start, the macOS engine folder, sidecar, updater, Tauri commands, title bar overlay | `desktop` |
+| Desktop build, `build_app`, a slow start, the engine folder, sidecar, updater, title bar overlay; a data file missing in the app; a file type, icon or double-click that does not open; a demo | `desktop` |
| A release, version sites, CHANGELOG, NOTICE, CI | `release` |
| Any chemistry feature, a file format, a name for a command or panel | `clean-room` first |
| Use FormChem: draw or edit a structure with the agent tools, run a menu command, hand off in the window | Not this pack: `formchem-harness` |
@@ -134,6 +104,8 @@ The window reaches the engine only through `frontend/src/io/api.ts` (REST with t
formchem-skillset/
SKILL.md this router, the subsystem map and the laws in short
references/repo-laws.md each law with its reason and exact format
+ references/dependency-graph.md which module may import which
+ references/running.md the commands for running, checking and scratch engines
EVALS.json evaluation prompts and the trigger tests (should and should not load)
sub-skills/ engine, document-format, chemistry-engine, reactions, stereo-and-queries, formats-and-export,
clipboard, command-line, names-and-spectra, three-d, databases, family-integration, canvas, annotations,
@@ -153,19 +125,7 @@ Paths inside a SUB-SKILL.md resolve against that sub-skill's folder; `references
## Running it
-```text
-./formchem install backend venv (backend/venv) and frontend packages
-./formchem engine 127.0.0.1:8220 and Vite on 5220 together
-./formchem backend | frontend one side
-./formchem serve built frontend served by the engine (FORMCHEM_DIST)
-./formchem doctor toolchain, installs and ports
-./formchem convert IN OUT the conversion command line (also batch, descriptors, render; docs/CLI.md)
-./formchem agents sync --check tools reference, skills mirror and agents/manifest.json in step
-cd frontend && npx tsc --noEmit type-check
-backend/venv/bin/python -m compileall -q backend/app setup
-```
-
-Scratch engines: `FORMCHEM_PORT=[port] FORMCHEM_DATA_DIR=[scratch]/data venv/bin/python -m uvicorn app.main:app --port [port]` from `backend/`; never point a check at `~/formchem`, the person's data folder.
+`./formchem` starts the engine (8220) and Vite (5220); `references/running.md` has every command a change needs (install, serve, doctor, convert, `agents sync --check`, `counts --check`, the type-check) and how to run a scratch engine that never touches `~/formchem`.
## Done means
diff --git a/.claude/skills/formchem-skillset/references/dependency-graph.md b/.claude/skills/formchem-skillset/references/dependency-graph.md
new file mode 100644
index 00000000..dbb8fa31
--- /dev/null
+++ b/.claude/skills/formchem-skillset/references/dependency-graph.md
@@ -0,0 +1,42 @@
+# FormChem dependency graph
+
+Which module may import which. Read it before adding an import across folders; an arrow that is not here is a new dependency and needs a reason in the HASHOUT log.
+
+```text
+frontend commands/registry.ts -> nothing (DOM free; the cli and workers may import it)
+engine/model.ts, engine/ops.ts -> nothing (pure, DOM free; the contract)
+chem/ -> engine/model.ts only (pure, no t(), no DOM)
+engine/client.ts, session.ts -> model, ops, client-api, io/api, io/live
+canvas/render -> canvas/types.ts, engine/model, engine/ops (own geom, valence, rings); table.ts
+ also chem/stoich.ts; marks-layer.ts also canvas/marks-options.ts
+engine/analysis-api.ts -> io/api, model, ops; the only caller of /api/analysis
+canvas/tools -> canvas/types.ts, engine/model, engine/ops, canvas/geom.ts
+canvas/view.ts, ui/tool-rail -> canvas/types.ts, hit.ts, selection.ts, ui/dom, ui/icons, i18n
+io/ -> registry only for the catalogue mirror
+ui/, dock-adapter, extensions -> io, ui/dom, ui/icons, i18n
+app.ts -> everything; the composition root (wiring only)
+backend services/model.py, ops.py -> nothing (pure; the contract)
+services/store.py -> model, ops, package, history, importers, hub; chem.derive imported lazily
+services/chem/ -> rdkit, indigo, model (never the store or routers)
+backend routers -> core, services (hub, bridge, library, store, chem, terminal, formext_host)
+mcp.py -> commands, extensions, consent, claude_code, bridge, hub, agent_token; agent_* lazily
+services/agent_*.py -> store, bridge, chem (agent_edits pure); agent_log hooks AFTER_CHANGE
+app/picture.ts -> canvas/render (a fresh renderer off screen), never the live canvas view
+app/clip-*.ts, import-files -> engine/model, ops, the export and parse routes; one paste plan (clip-data.ts)
+services/chem/writers, stream -> formats, report, io, rdkit, indigo (never the store)
+services/batch.py, app/cli.py -> chem/stream, records, standardise, depict, props (never routers or the store)
+services/pictures/ -> fontTools and the bundled fonts only
+services/names, nmr, spectra -> rdkit, numpy, chem (never routers); nmr registers its hook in spectra.source.PREDICTORS
+services/three_d -> rdkit, numpy, chem (never routers); store.apply_now runs three_d.stale
+services/database, notebook -> sqlite3, rdkit, numpy, chem (never routers or the document store)
+services/helm, xtb, describe -> rdkit, chem (xtb also three_d); xtb starts programs only as separate processes
+services/demos.py -> model; store and hub lazily (never routers); its data only from data/demos relative to services
+canvas/a11y -> canvas view and render, ui/a11y-announcer; installed before mountCanvas
+ui/view3d-lib.ts -> 3dmol by dynamic import only (nothing 3D at startup)
+app/system-open.ts -> ui/dom only; app.ts passes it the open function
+demos/ -> frontend/src as is, through Vite shims (io/api.ts becomes an offline stand-in)
+window-only abilities -> reach the engine as window tools over /api/live (bridge.window_call)
+desktop shell -> frozen engine (formchem_engine.py) -> serves frontend/dist
+```
+
+The window reaches the engine only through `frontend/src/io/api.ts` (REST with the window key) and `io/live.ts` (`/api/live`). The engine never imports frontend code. A document change travels one way: a tool or command commits a transaction through the document client, the engine validates and applies it, then broadcasts `tx` and later `derived` to every window, which patches its mirror and its SVG.
diff --git a/.claude/skills/formchem-skillset/references/running.md b/.claude/skills/formchem-skillset/references/running.md
new file mode 100644
index 00000000..1220e12a
--- /dev/null
+++ b/.claude/skills/formchem-skillset/references/running.md
@@ -0,0 +1,20 @@
+# Running FormChem while developing it
+
+The commands a change needs, from the repository root.
+
+```text
+./formchem install backend venv (backend/venv) and frontend packages
+./formchem engine 127.0.0.1:8220 and Vite on 5220 together
+./formchem backend | frontend one side
+./formchem serve built frontend served by the engine (FORMCHEM_DIST)
+./formchem doctor toolchain, installs and ports
+./formchem convert IN OUT the conversion command line (also batch, descriptors, render; docs/CLI.md)
+./formchem agents sync --check tools reference, skills mirror and agents/manifest.json in step
+./formchem counts --check the README size line in step with the code
+cd frontend && npx tsc --noEmit type-check
+backend/venv/bin/python -m compileall -q backend/app setup
+```
+
+Scratch engines: `FORMCHEM_PORT=[port] FORMCHEM_DATA_DIR=[scratch]/data venv/bin/python -m uvicorn app.main:app --port [port]` from `backend/`; never point a check at `~/formchem`, the person's data folder.
+
+On a shared machine, run heavy steps (type-check, build, browser checks) one at a time under a shared lock, and start a server outside that lock so it does not inherit it: a server started inside the lock holds it until it stops.
diff --git a/.claude/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md
index 15017f09..b7acb08b 100644
--- a/.claude/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/agents/SUB-SKILL.md
@@ -33,7 +33,9 @@ Give agents an honest tool surface that only describes what FormChem can do now,
## The tool surface (0.12.0)
-77 tools: the six of the shell (`get_context`, `list_commands`, `run_command`, `extensions_list`, `extension_command`, `handoff`); the reaction tools of 0.5.0 and the analysis tools of 0.6.0 (owned by `reactions` and `stereo-and-queries`); and the 28 of 0.8.0: `list_open_documents`, `new_document`, `open_document`, `save_document`, `close_document`, `draw_from_smiles`, `draw_from_molfile`, `render`, `get_structure`, `validate`, `compute_properties`, `convert`, `batch_convert`, `get_atoms` and the 14 edit tools `add_atom`, `add_bond`, `set_charge`, `set_atom`, `set_stereo`, `replace_substructure`, `delete`, `move`, `scale`, `align`, `clean_layout`, `add_arrow`, `add_text`, `add_reaction`; and the 10 of 0.9.0, whose services `names-and-spectra` owns: `draw_from_name` (through `_draw`), `name_structure` (the route's `name_mol`), `predict_nmr`, `predict_spectrum` (`nmr.document.spectrum_ops`), `open_spectrum`, `spectrum_data`, `spectrum_peaks`, `spectrum_pick_peaks`, `spectrum_integrate` (`spectra.peak_ops`, `integral_ops`) and `spectrum_export`; and the 8 of 0.10.0, whose services `three-d` owns: `build_3d`, `conformers_3d`, `minimise_3d`, `scan_dihedral`, `measure_3d`, `open_3d_structure` (`three_d.open_bytes`) and `extract_ligand` call the `routers/three_d.py` functions through `_three_d` with an `AgentCall` in the body, so the route's `commit` applies with origin `agent` and the agent's name, and `export_3d` calls `export.write` directly. The writing ones are in `MUTATING` (`scan_dihedral` only with `store`, `export_3d` only with an `output` outside the temporary folder, through `_mutating`); a tool never builds its own copy of a route's ops. And the 11 of 0.11.0, whose services `databases` owns, in agent modules rather than in `mcp.py`: `services/agent_db.py` (`db_list`, `db_create`, `db_open`, `db_import`, `db_search`, `db_get_record`, `db_add_record`, `db_update_record`, `db_export`) and `services/agent_notebook.py` (`nb_add_entry`, `nb_search`). Each module offers `TOOLS` in the `_tool` shape, frozen `NAMES`, `mutating(name, args)` and `async call(name, args, agent_name)`, which runs the database services on a worker thread and writes as `agent:[name]`; `mcp.py` walks `AGENT_MODULES` for the list, the gate and dispatch, so a new module adds one name there. They touch no drawing (except `nb_add_entry {doc}`, which reads one), so they answer with `_ok` text and `structuredContent`, not `write_result`. And the 6 of 0.12.0, in three more agent modules: `agent_library.py` (`library_list`, `library_add`, `live_structure_object`; `family-integration` owns the service), `agent_helm.py` (`draw_from_helm`, through `mcp._draw`; `chemistry-engine` owns `services/helm`) and `agent_xtb.py` (`xtb_optimise`, `crest_conformers`, through `_three_d` with the xtb job routes; `three-d` owns `services/xtb`). HELM and xtb build `mcp.Agent("", agent_name)` in `call` because `_draw`, `_apply` and `_three_d` read only the name. `setup/agents.py` reads `mcp.py`'s own `TOOLS` by AST, and each agent module's finished `TOOLS` by importing it with the backend venv's Python (`_module_tools`), so `references/tools.md` and `agents/manifest.json` hold all 77 tools.
+104 tools (27 from 0.14.0, listed after this paragraph): the six of the shell (`get_context`, `list_commands`, `run_command`, `extensions_list`, `extension_command`, `handoff`); the reaction tools of 0.5.0 and the analysis tools of 0.6.0 (owned by `reactions` and `stereo-and-queries`); and the 28 of 0.8.0: `list_open_documents`, `new_document`, `open_document`, `save_document`, `close_document`, `draw_from_smiles`, `draw_from_molfile`, `render`, `get_structure`, `validate`, `compute_properties`, `convert`, `batch_convert`, `get_atoms` and the 14 edit tools `add_atom`, `add_bond`, `set_charge`, `set_atom`, `set_stereo`, `replace_substructure`, `delete`, `move`, `scale`, `align`, `clean_layout`, `add_arrow`, `add_text`, `add_reaction`; and the 10 of 0.9.0, whose services `names-and-spectra` owns: `draw_from_name` (through `_draw`), `name_structure` (the route's `name_mol`), `predict_nmr`, `predict_spectrum` (`nmr.document.spectrum_ops`), `open_spectrum`, `spectrum_data`, `spectrum_peaks`, `spectrum_pick_peaks`, `spectrum_integrate` (`spectra.peak_ops`, `integral_ops`) and `spectrum_export`; and the 8 of 0.10.0, whose services `three-d` owns: `build_3d`, `conformers_3d`, `minimise_3d`, `scan_dihedral`, `measure_3d`, `open_3d_structure` (`three_d.open_bytes`) and `extract_ligand` call the `routers/three_d.py` functions through `_three_d` with an `AgentCall` in the body, so the route's `commit` applies with origin `agent` and the agent's name, and `export_3d` calls `export.write` directly. The writing ones are in `MUTATING` (`scan_dihedral` only with `store`, `export_3d` only with an `output` outside the temporary folder, through `_mutating`); a tool never builds its own copy of a route's ops. And the 11 of 0.11.0, whose services `databases` owns, in agent modules rather than in `mcp.py`: `services/agent_db.py` (`db_list`, `db_create`, `db_open`, `db_import`, `db_search`, `db_get_record`, `db_add_record`, `db_update_record`, `db_export`) and `services/agent_notebook.py` (`nb_add_entry`, `nb_search`). Each module offers `TOOLS` in the `_tool` shape, frozen `NAMES`, `mutating(name, args)` and `async call(name, args, agent_name)`, which runs the database services on a worker thread and writes as `agent:[name]`; `mcp.py` walks `AGENT_MODULES` for the list, the gate and dispatch, so a new module adds one name there. They touch no drawing (except `nb_add_entry {doc}`, which reads one), so they answer with `_ok` text and `structuredContent`, not `write_result`. And the 6 of 0.12.0, in three more agent modules: `agent_library.py` (`library_list`, `library_add`, `live_structure_object`; `family-integration` owns the service), `agent_helm.py` (`draw_from_helm`, through `mcp._draw`; `chemistry-engine` owns `services/helm`) and `agent_xtb.py` (`xtb_optimise`, `crest_conformers`, through `_three_d` with the xtb job routes; `three-d` owns `services/xtb`). HELM and xtb build `mcp.Agent("", agent_name)` in `call` because `_draw`, `_apply` and `_three_d` read only the name. `setup/agents.py` reads `mcp.py`'s own `TOOLS` by AST, and each agent module's finished `TOOLS` by importing it with the backend venv's Python (`_module_tools`), so `references/tools.md` and `agents/manifest.json` hold every tool.
+
+The 27 of 0.14.0. In `AGENT_MODULES`: `agent_pages.py` (`list_pages`, `add_page`, `delete_page`, `set_page`, `fit_page_to_drawing`, `list_objects`, `undo_agent_changes`, which mutates only with `step`), `agent_abbrev.py` (`abbreviation_list`, `abbreviation_define`, `abbreviation_remove`), `agent_standardise.py` and `agent_balance.py` (`standardise`, `balance_reaction`, mutating only with `apply`), `agent_isotopes.py` (`isotope_pattern`) and `agent_helm_out.py` (`export_helm`), and `services/three_d/agent.py`, imported as `agent_three_d` (`compute_surface`, `energy_terms_3d`, `rotate_bond_3d`, `repair_hydrogens_3d`, `render_3d` through the window tool `render3d`, `fetch_pdb`). In `mcp.py` itself: `fuse_ring` and `attach_template` run the window's commands through `commands.execute` (`_window_verb`) and need a window; `space_reaction`, `fit_arrows_to_conditions` and `conditions_as_footnotes` reuse `routers/reactions._space`, `scheme.stretch_ops` and `scheme.footnote_ops` under `_apply`; `predict_ir_bands` and `predict_ms_fragments` read SMILES or a drawn fragment (`_predicted`). `setup/agents.py` `tools_data` resolves module names through `mcp.py`'s from-imports, so an aliased import such as `agent_three_d` still syncs. Reasons: `backend/HASHOUT_LOG.md` 303, 318, 319, 328, 329.
## Laws of the agent tools
diff --git a/.claude/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md
index c4cd61bd..eacda968 100644
--- a/.claude/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/annotations/SUB-SKILL.md
@@ -38,8 +38,21 @@ Draw every non-chemistry object from the document alone, patch it like a bond, a
- **Captions follow their target.** With `target` and `offset` the caption is placed from the target's drawn box; `x`, `y` are a cache that `transform.ts` refreshes in the same transaction when the target moves, and moving the caption rewrites `offset`.
- **Z-order is per container.** Page order and a group's `children` move separately with `move` ops computed on a working copy; a group's members are in no page order and are removed with the group.
- **Templates and glassware are original data.** Nothing from another product's library (`clean-room`); fresh ids on every insert, fragments scaled to the drawing's bond length, shapes kept at size.
+- **The template library holds whole molecules only (the owner's rule, 0.14.0).** `data/templates/*.json` is starter molecule structures and whole real molecules, not single parts: no protecting group, linkage, bare skeleton or generic projection (groups belong in `services/chem/abbrev_data.py`, glassware in `data/templates/glassware/`, which `templates._files` never globs). Every entry carries its `inchikey`, checked against the compound's published record and against the key the engine builds (Haworth and Fischer drawings: the connectivity layer plus each substituent's side). Keep an existing id when the compound stays.
- **Media is two steps.** POST stores bytes and returns the record; the window's one transaction lists `media[id]` and adds the image; the package writes only listed ids.
+## Templates, pages and objects (0.14.0)
+
+| Path | Role |
+| --- | --- |
+| `services/templates.py` `glassware_catalogue`, `_catalogues`; `routers/templates.py` `/api/glassware` | one cached catalogue per kind; `ui/glassware-dialog.ts` reuses the template cards |
+| `canvas/tools/template.ts` `attachAtAtom`, `fuseOnBond`; `ui/template-dialog.ts` `armForCanvas` | the Template tool: anchors from the structure (the `*` atom or least connected atom; the first ring bond), mirrored to the emptier side, atoms within 0.25 bond lengths merged |
+| `app/documents.ts` page edits; `canvas/view.ts` `pageBox`, `placeFurniture`; `ui/page-strip.ts`, `page-setup-dialog.ts`, `page-furniture.ts`; `app/page-commands.ts`; `styles/pages.css` | pages as single transactions (duplicate through `extractClip` and `pastePlan` for fresh ids), auto-grow both ways, the keyed page strip with a 30 px inset, headers and footers as HTML on the paper and `furnitureSvg` for print |
+| `canvas/table-edit.ts`, `canvas/tools/tlc.ts`, `ui/object-style-dialog.ts`, `app/annotation-commands.ts` | cell editing with Tab and auto-grow in the text's own transaction; TLC drag, Alt duplicate, Shift resize, lane reorder and labels on the renderer's `tlcLayout`, `data.rf` on every edit; Object Style for stroke, fill, gradient, opacity, shadow, orbital fill and phase |
+| `services/agent_pages.py` | `list_pages`, `add_page`, `delete_page`, `set_page`, `fit_page_to_drawing`, `list_objects` |
+
+Gate additions: three pages after New and Duplicate with fresh ids and 0 strip rebuilds on page switches; auto-grow moves no atom; Tab past the last cell adds a row in one undo step; a TLC drag changes `data.rf`. PARITY Decisions to respect: no layers, no gel object, no pen tool, no linked images (A-2.6, A-2.3.9, A-7.4.1, A-2.3.11). Reasons: `frontend/HASHOUT_LOG.md` 311, 312, 333 to 338, `backend/HASHOUT_LOG.md` 288 to 290, 328.
+
## Procedure
1. For a drawing fault, build a scratch drawing outside the repo with one of each kind and open it in the built window served by the engine; watch it under 4x CPU throttling with a MutationObserver over `.fc-app`.
diff --git a/.claude/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md
index cd2b126c..132c19ed 100644
--- a/.claude/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/canvas/SUB-SKILL.md
@@ -47,6 +47,19 @@ Let the person draw at the speed of thought while the document stays the only tr
**The document is the state.** Selection and hover live in the view; everything else is read from `client.view` (the mirror with any preview applied). Implicit hydrogens and double bond sides come from local rules until `derived` for the current revision arrives (`chemistry-engine`).
+## Gestures, labels and styles (0.14.0)
+
+| Path | Role |
+| --- | --- |
+| `tools/build.ts` `BOND_KINDS`, `isFull`, `valenceRoom`, `isCrowded`, `RingSpec.shape`, `toggleKekule`, `ringThrough`; `tools/ring.ts` `circleRing`, `RING_DRAG_STEP`; `tools/bond.ts` `cycleOrder`; `tools/modes.ts` | quadruple, hollow, plain hashed and crossed bonds (no format change), clicks that stop at full valence with a hint, the crowded flag under 60 degrees, cyclopentadiene and chair rings, Mod+click circle, Shift+click Kekule, ring drag in 15 degree steps, double-click order cycling as one undo step, remembered Fixed Bond Length, Flip Keeps Wedges and Smart Guides |
+| `tools/select.ts` `drillTarget`, `parentSelection`, `integralIn`, `schemeSelection`, `rotateDraft`, `smartGuides`, `joinAtoms`, `NUDGE`; `canvas/a11y/controller.ts` | drill-down, Escape up, integral groups, triple-click, the Alt+click pivot, guides for non-chemical drags, Join Atoms (`Shift+Mod+J`, since the dock keeps `Mod+J`), nudges 1, Alt 10, Shift 0.1 pt after a pointer click |
+| `tools/hotkeys.ts` `setHoverPanels`, `onPendingElement`; `ui/atom-properties.ts`, `bond-properties.ts`, `periodic-grid.ts` `ELEMENT_TOOL_DEF`; `render/atom.ts` | hover `'`, `/`, `=` and Enter-with-nothing-hovered without importing a dialog; the pending element tip; atom numbers from `show_number` and `number` (the window writes `number` explicitly; the renderer passes no index) |
+| `app/style-commands.ts` `applyStyleDraft`, `parseStyleFile`; `ui/style-dialog.ts`, `colour-picker.ts` | journal styles applied to a document (each fragment rescaled about its own centre) or a selection (`style` overrides), `.fcstyle` files, the emphasis red |
+| `render/label.ts` `verticalSide`, `LabelModel.centred`; `render/bond.ts` `mitreHalves`, `wedgeCorner`; `render/text.ts`; `text-editor.ts` `openRuns`; `tools/label.ts` | vertical labels and the allene dot (style values), centred labels, butt caps with mitre kites capped at 2 x line width, cut wedge and bold ends, justified text, the normal override, the formatted editor for texts and captions (atom labels stay plain strings) |
+| `tools/draft.ts` `moveAtoms`, `BULK_MOVE`; `render/renderer.ts` `SWEEP_AT` | one atoms op for 8 or more moved atoms and one crossing sweep past 48 dirty bonds (a 2,083-atom nudge went from 12.3 s to 0.8 s) |
+
+Rules: a key added here goes into `references/hover-keys.md` and must not clash (Help > Keyboard Shortcuts lists conflicts, and the map is fixed by PARITY A-5.1.9); a new style value is a contract change in FORMAT.md, `model.ts` and `model.py` together. Reasons: `frontend/HASHOUT_LOG.md` 313 to 332 and 350.
+
## Adding a tool
1. Implement `Tool` in `canvas/tools/[name].ts` against `ToolContext` only; add a `ToolDef` to `TOOLS` with a canonical group (`select`, `bond`, `chain`, `ring`, `atom`, `text`, `eraser`, `hand`, `zoom`) and an icon the rail draws.
diff --git a/.claude/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md b/.claude/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md
index 83a0e1f7..1d59325f 100644
--- a/.claude/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md
+++ b/.claude/skills/formchem-skillset/sub-skills/canvas/references/hover-keys.md
@@ -40,6 +40,10 @@ Every hover key commits one transaction. Two-letter elements and charge keys car
| . | toggle a radical dot |
| : | add a lone pair (cycles 0 to 4) |
| Enter | type a label (opens the text editor at the atom) |
+| ' | show or hide the atom number: writes `show_number` and an explicit `number` (0.14.0) |
+| / | Atom Properties through the panel `setHoverPanels` registered (0.14.0) |
+| = | the abbreviation picker with a drawn preview; condensed labels read by the engine (0.14.0) |
+| Enter with nothing hovered | reopen the label box at the last atom a hover key touched, with the last label (0.14.0; type-checked, not driven) |
| Space | revert to implicit carbon |
| Delete, Backspace | delete the atom and its bonds |
@@ -60,14 +64,17 @@ Every hover key commits one transaction. Two-letter elements and charge keys car
| Shift+3 to Shift+8 | fuse a saturated ring of that size |
| Shift+B | fuse a benzene ring |
| Delete, Backspace | delete the bond and any bare carbon left alone |
+| / | Bond Properties (0.14.0) |
+
+While the first letter of a two-letter element waits, `onPendingElement` reports the reading and `PendingTip` (in `ui/atom-properties.ts`) shows it near the pointer. While an atom or bond is hovered the status bar says its keys act on it (`setHint`, written only on change).
## Tool keys (nothing hovered)
The rail registers one command per group (`tool-select` V, `tool-bond` B, `tool-chain` C, `tool-ring` R, `tool-atom` A, `tool-text` T, `tool-eraser` E, `tool-hand` H, `tool-zoom` Z), `tool-[group]-next` on Shift plus the group key to cycle inside a group, and `tool:[id]` for every tool with its own `keys` (L for the lasso). A group key picks the group's tool that has no key of its own, so V means select even after L picked the lasso. `ToolDef.keys` are tool-switch keys only; hover keys never go there.
-## Keys left free
+## Keys outside the map
-Atom `'` (atom numbers), `/` (properties panel) and `=` (abbreviation picker) return false today so the canvas can bind them when that UI lands.
+From 0.14.0 Help > Keyboard Shortcuts shows both hover tables and a Key conflicts section (command keys shared by two commands, and tool letters that are also hover keys). The map is fixed, not editable (PARITY A-5.1.9). `Mod+J` and `` Mod+` `` belong to the terminal dock (`dock-adapter.ts` `isDockChord`), arrows nudge the selection unless the keyboard cursor was placed by Tab or Focus Structure, and the browser keeps `Mod+N`, `Mod+W` and `Shift+Mod+J` in a tab. The full bound-key list is the wiki page Keyboard Shortcuts.
## Changing the map
diff --git a/.claude/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md
index 2006b054..194da692 100644
--- a/.claude/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/desktop/SUB-SKILL.md
@@ -1,6 +1,6 @@
---
name: desktop
-description: "FormChem's Tauri 2 desktop shell: tauri.conf.json and tauri.macos.conf.json, the Rust entry point and its modules (engine start from the macOS engine folder or the sidecar, packaged.rs, splash-to-window reveal, macOS traffic lights, the Windows job object, clipboard access), the frozen engine formchem-engine built with PyInstaller (a flattened one-folder on macOS, one file elsewhere), the Tauri CLI pin, the updater and the desktop scripts. Use when the desktop app is slow to open or will not start, the engine fails or keeps running, a frozen build misses a module or data folder, the title bar or traffic lights are wrong, the splash hangs, or a desktop build or updater setting changes."
+description: "FormChem's Tauri 2 desktop shell: tauri.conf.json and tauri.macos.conf.json, the Rust entry point and its modules (engine start from the macOS engine folder or the sidecar, packaged.rs, splash-to-window reveal, macOS traffic lights, the Windows job object, clipboard access), the frozen engine formchem-engine built with PyInstaller (a flattened one-folder on macOS, one file elsewhere), the Tauri CLI pin, the updater and the desktop scripts, the engine's bundled data folder (app/data), file associations and document icons, files the system hands the app (system-open.ts), and the demos (Home's demos under backend/app/data/demos, browser demos under demos/). Use when the desktop app is slow to open or will not start, the engine fails or keeps running, a frozen build misses a module or data file, a double-clicked file does not open, a file type or icon changes, a demo is added or rebuilt, the title bar or traffic lights are wrong, the splash hangs, or a desktop build or updater setting changes."
---
# Desktop
@@ -21,7 +21,15 @@ Wrap the same window and engine in a native app: a thin Rust shell that starts t
| `src-tauri/src/reveal.rs` | Splash to window: the page calls `app_ready` with its background colour once painted; the splash closes after `window.formchemSplashDone()` |
| `src-tauri/src/traffic_lights.rs` | macOS overlay title bar: traffic lights placed in the 38 px title row |
| `src-tauri/src/win_job.rs` | Windows job object so the engine dies with the app |
-| `src-tauri/Cargo.toml`, `Cargo.lock`, `capabilities/`, `Info.plist`, `entitlements.plist`, `flatpak/` | Crate, permissions, macOS plist and entitlements, Flatpak manifest and AppStream metainfo |
+| `src-tauri/Cargo.toml`, `Cargo.lock`, `capabilities/`, `entitlements.plist`, `flatpak/` | Crate, permissions, macOS entitlements, Flatpak manifest (installs the MIME package and document icons from the deb) and AppStream metainfo (`provides/mediatype`, release lines) |
+| `src-tauri/Info.plist` | Merged over Tauri's generated plist: `CFBundleDocumentTypes` with `CFBundleTypeIconFile`, `UTExportedTypeDeclarations` with `UTTypeIconFile` (0.13.0) |
+| `src-tauri/linux/formchem.desktop`, `ai.nodemode.formchem.xml` | Desktop entry template (`Exec=... %U`) and the shared-mime-info package, both installed by the deb and rpm (0.13.0) |
+| `src-tauri/windows/hooks.nsh`, `tauri.windows.conf.json` | NSIS post-install hook pointing FormChem Document and FormChem Database at their `.ico`; the Windows resources (0.13.0) |
+| `src-tauri/icons/documents/`, `assets/icon_src/build.py` | `.fchem` and `.fcdb` document icons (PNG 16 to 512, `.ico`, `.icns`), written by `document_icon` from the owner's masters (0.13.0) |
+| `frontend/src/app/system-open.ts` | `registerSystemOpen(open, shown)`: reads `?open=` once, defines `window.__formchemOpen`, opens paths in order through `docs.openPath`; Tauri only (0.13.0) |
+| `backend/app/services/demos.py`, `routers/demos.py`, `data/demos/` | Home's demos: the manifest, five drawings, previews drawn as SVG, `GET /api/demos`, `POST /api/demos/{id}/open` as a fresh unsaved copy (0.13.0) |
+| `frontend/src/ui/home-demos.ts` | `mountHomeDemos` (reserved slots keyed by id), `openDemo`; Help > Demos calls `home.showDemos()` (0.13.0) |
+| `demos/` (`shared/`, `drawing/`, `reactions/`, `3d/`) | Offline browser demos on the window's code, each with README, CREDITS and HASHOUT_LOG; `demos/tsconfig.json` type-checks them (0.13.0) |
| `backend/formchem_engine.py` | Frozen engine entry; `--selfcheck`; `MODULES` (fastapi, uvicorn, keyring, rdkit, indigo) |
| `setup/freeze_backend`, `setup/install_desktop`, `setup/desktop_dev`, `setup/desktop_build`, `setup/desktop_check`, `build_app` (each with a `.bat` twin) | Freeze, toolchain, dev run, build, checks |
| `setup/lib.sh` | `fc_engine_folder` (copy to `src-tauri/engine`, flatten, sign, `--selfcheck`), `fc_flatten_engine`, `fc_sign_engine`; shared by `freeze_backend` and `build_app` |
@@ -31,7 +39,8 @@ Wrap the same window and engine in a native app: a thin Rust shell that starts t
- The window is the same `frontend/dist`; desktop-only behaviour is detected (`inTauri()`), never forked into a second UI.
- macOS: overlay title bar with a hidden title; the pre-paint boot sets `has-overlay-titlebar` so the row never jumps from 44 to 38 px. Native menus unless Menus in Window is on.
- The engine is `formchem-engine` everywhere: the sidecar (plus the target triple in `src-tauri/binaries/`) on Linux and Windows, the program inside `src-tauri/engine` on macOS. RDKit and Indigo are collected whole and fontTools' submodules collected when freezing.
-- A frozen module or data folder must be added to `setup/freeze_backend`, its `.bat` twin and `build_app`'s own PyInstaller call, which runs separately: entries 98 and 117 of the backend log record two misses of this kind.
+- **Engine data lives under `backend/app/data/` and is read relative to the services folder** (`Path(__file__).resolve().parents[1] / "data"` from `services/`, `parents[2]` one level deeper). `build_app`, `setup/freeze_backend` and `freeze_backend.bat` bundle the whole folder at `app/data`, so a new data file ships with no setup change. Never read data from the working folder or the repository root (only `services/templates.py` keeps its older `templates` resource path): the 0.10.0 to 0.12.0 desktop apps carried only `data/templates`, so names knew no common names and every HELM call failed (backend entry 279).
+- A frozen module or a folder outside `backend/app/data` must still be added to `setup/freeze_backend`, its `.bat` twin and `build_app`'s own PyInstaller call, which runs separately: entries 98 and 117 of the backend log record two misses of this kind.
## The one-folder engine on macOS
@@ -50,7 +59,21 @@ A PyInstaller one-file engine unpacks everything (several hundred MB, over 400 l
`@tauri-apps/cli` is a pinned dev dependency in `frontend/package.json` (2.12.6). The rule: its major.minor equals the `tauri` crate's in `src-tauri/Cargo.lock` (2.12.7), and each `@tauri-apps/plugin-*` package shares major.minor with its `tauri-plugin-*` crate; bump them together in one change, with `package-lock.json`. Tauri refuses to build across minor versions. Until 0.6.0 package.json did not list the CLI, so `npm ci` installed no `tauri` binary and `./build_app` stopped with "the Tauri CLI did not install"; with the pin, the owner's `./build_app` on macOS arm64 (Python 3.14) built the app.
-`build_app` checks in order: the system (Xcode Command Line Tools, or WebKitGTK 4.1 on Linux), Python 3.12 or newer, Node 20.19 or newer, one Rust install matching the machine, `THIRD-PARTY-NOTICES.txt`, the engine and window packages (reinstalled when their lock or the toolchain changes), the Tauri CLI binary and the version rule above, then builds the window, freezes the engine with the window, the notices and `backend/app/data/templates` (`--add-data`, the same as `setup/freeze_backend`), runs the frozen engine's `--selfcheck` (on macOS through `fc_engine_folder` in a subshell that sources `setup/lib.sh`), and bundles. A data folder the engine reads when frozen must be added to both `build_app` and `setup/freeze_backend` (and its `.bat`), or the desktop app ships without it.
+`build_app` checks in order: the system (Xcode Command Line Tools, or WebKitGTK 4.1 on Linux), Python 3.12 or newer, Node 20.19 or newer, one Rust install matching the machine, `THIRD-PARTY-NOTICES.txt`, the engine and window packages (reinstalled when their lock or the toolchain changes), the Tauri CLI binary and the version rule above, then builds the window, freezes the engine with the window, the notices, `backend/app/data/templates` at `templates` and `backend/app/data` at `app/data` (`--add-data`, the same as `setup/freeze_backend`), runs the frozen engine's `--selfcheck` (on macOS through `fc_engine_folder` in a subshell that sources `setup/lib.sh`), and bundles. A data file under `backend/app/data` ships through `app/data`; anything else the frozen engine reads must be added to both `build_app` and `setup/freeze_backend` (and its `.bat`), or the desktop app ships without it.
+
+## Files from the system and file associations
+
+The shell turns launch arguments (Linux, Windows), `RunEvent::Opened` (macOS) and second launches (the single-instance plugin) into absolute paths with `system_paths` (relative paths join the working folder, `file://` becomes a path), keeps those whose extension is in `OPENABLE`, and passes them as `?open=` at launch or through `window.__formchemOpen` later. `registerSystemOpen` opens them one at a time through `docs.openPath`, the Open Recent path, so an `.fcdb` reaches the database workspace; `shown` (`dbws.hide`) runs after a drawing opens so it comes to the front. Before 0.13.0 no page code read either channel and nothing opened.
+
+- A type lives in five places, kept in step by hand: `OPENABLE` (`main.rs`), `OPEN_EXTENSIONS` (`app/documents.ts`), and when associated `bundle.fileAssociations`, `Info.plist` and the MIME package.
+- FormChem's own types (`.fchem`, `.fcdb`) are Editor with their own MIME type and exported UTI; every other type is Viewer, rank Alternate, so FormChem never takes it from its owner. Do not associate a type the engine cannot open (`.helm` is out); `.dx` and `.ent` open when handed over but are not associated.
+- Document icons per platform: macOS through `Info.plist` and the `.icns` resources; deb and rpm through hicolor `mimetypes` icons named `ai.nodemode.formchem.document` and `.database` (the app-id prefix is what Flatpak exports); NSIS through `hooks.nsh`. The MSI has no hook (app icon), and an AppImage cannot register types or icons at all.
+- The desktop entry keeps `%U`, not `%F`, so `formai://` links reach the deep link plugin.
+- `./formchem desktop check` fails early when a document icon, the MIME package or the desktop entry is missing; add any new bundled file there too.
+
+## Demos
+
+Two kinds, both new in 0.13.0. **In the app:** `backend/app/data/demos/demos.json` lists id, file, title, description and kind; each drawing is plain FormChem JSON that `model.validate` accepts, and opening one makes a copy with a fresh id, no path and not dirty, so the shipped file is never written. To add one, bake the drawing with the engine (a scratch script, outside the repository), add its manifest row, and check `GET /api/demos` lists it with no error; Home picks it up with no window change. **In the browser:** `demos/[name]/` builds with `cd frontend && npx vite build --config ../demos/[name]/vite.config.ts` (under the heavy lock); `demos/shared/vite-base.ts` swaps `io/api.ts` for `offline-api.ts`, drops locales and `/fonts/`, stubs Tauri and 3Dmol, and emits one IIFE so the page runs from `file://`. Never edit `frontend/src` to suit a demo; check from `file://` with the network blocked and keep each built folder under 6 MB.
## Gate
@@ -58,3 +81,5 @@ A PyInstaller one-file engine unpacks everything (several hundred MB, over 400 l
- [ ] The desktop dev run opens the window without a white flash and the engine answers `/api/health` on its port.
- [ ] Quitting the app ends the engine process on every platform touched.
- [ ] On macOS: `src-tauri/engine` has the program, no symbolic link and no `.framework`, and `otool -L` finds nothing linking `Python.framework`.
+- [ ] A new data file is under `backend/app/data` and read relative to the services folder; in a built app Structure from Name draws caffeine, HELM draws `PEPTIDE1{G.G}$$$$` and Home shows the five demos.
+- [ ] A changed file type is in all five places, and a file of that type opens at launch and when sent to the running app.
diff --git a/.claude/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md
index 89c75ae7..83d28b64 100644
--- a/.claude/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/formats-and-export/SUB-SKILL.md
@@ -38,6 +38,9 @@ Move drawings in and out of FormChem without losing anything silently. Every rea
- **Indigo is a bridge, not a source.** CDXML and CDX go through Indigo's KET JSON; FormChem's code, names and samples come from public specifications only (`clean-room`). Do not test against files made by the commercial program unless the owner supplies them.
- **Freeze both paths.** fontTools loads table modules by tag, so `--collect-submodules fontTools` must be in `setup/freeze_backend`, its `.bat` twin and `build_app`'s own freeze. Without fontTools, `/api/pictures/capabilities` says `fonts: false` and PDF and EPS lose their text.
- **Documents read at most 1000 records**, File > Import 50 by default; batch work uses the stream reader (`command-line`).
+- **One picture path (0.14.0).** Every picture goes through `fe/app/picture.ts` `pictureFile`; TIFF (FormChem's own LZW writer), one-bit PNG and the JPEG density patch live in `picture-raster.ts`, so no encoder dependency is added. SVG, PNG, PDF and EPS keep the drawing; TIFF, JPEG, WebP and PDF/A-2b cannot (PDF/A-2 allows only PDF/A attachments). SVG outlines (`services/pictures/svgout.outline_text`) work on the SVG text itself, so the rest stays byte for byte; WebKit cannot encode WebP, so it is refused there. Export Picture starts from Preferences > Files every time and keeps its height for every format. Full-page pictures and print draw the page header and footer (`PictureOptions.furniture`).
+- **Print is a dialog (0.14.0).** `app/print.ts` `PrintDialog` and `printLayout`: paper, scale, tiling with 10 pt overlap up to 64 sheets, crop marks, a preview whose sheet nodes are reused, never rebuilt. One page at a time (PARITY A-13.4).
+- **Reading and round trips (0.14.0).** `io._decode` is the one text decoder (BOMs, BOM-less UTF-16, UTF-8, Windows-1252, Latin-1; never replacement marks); FASTA becomes HELM and then atoms (`io._read_fasta`, 300 residues, 20 records); abbreviations are written as SUP Sgroups and read back as labels only when the atoms canonicalise to the library entry; CDXML styling is added after Indigo by `cdxio._restyle` (fonts, sizes, faces, colours, atom and bond colours; binary CDX untouched). Copy adds a molfile flavour and `data-molfile` in the HTML (`clip-system.ts`). Reasons: `backend/HASHOUT_LOG.md` 320 to 324, `frontend/HASHOUT_LOG.md` 339 to 342.
## Adding a format
diff --git a/.claude/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md
index 44920167..adf0e49c 100644
--- a/.claude/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/names-and-spectra/SUB-SKILL.md
@@ -82,6 +82,10 @@ Change FormChem's names, NMR prediction and spectra without breaking the three p
Write it from the published rules, not from another reader. Report what you repair or skip through `issues.py` with a code, a line and a sentence; add a synthetic file that exercises it to the scratch corpus (outside the repo) and confirm every existing corpus file still reads identically, and that `export.py` output re-reads with an empty report.
+### The predicted spectra tables (0.14.0)
+
+`frontend/src/ui/analysis-spectra.ts` (its own `styles/analysis-spectra.css`) is the Analysis panel's 1H, 13C, IR and MS section, mounted by the NMR lines in `ui/analysis-panel.ts`: one four-column table patched by key through `patchList`, 22 px rows, the solvent select kept in place (hidden) on IR and MS so the section keeps its 376 px height; results cached per fragment content and mode (64 entries). 13C shows the DEPT-135 phase from the attached hydrogens. Solvent residual and water peaks come from Fulmer et al. (Organometallics 2010) as italic reference rows; the solvent never changes a predicted shift. `backend/app/services/spectra/ir_bands.py` (about 25 SMARTS groups with textbook ranges; a specific group suppresses a general one) and `ms_fragments.py` (alpha, C-X, benzylic, allylic, McLafferty, common losses; one ion per formula, labelled indicative) are FormChem's own rule tables, routed from `routers/reactions.py` (`/api/chem/ir-bands`, `/api/chem/ms-fragments`) and the MCP tools `predict_ir_bands` and `predict_ms_fragments`. A new band or rule is a textbook fact written in FormChem's own SMARTS, never a copied table, and keeps its method name. Gate additions: switching tabs and solvents adds no layout shift and only the changed rows; ethyl acetate gives the ester C=O band and its EI ions. Reasons: `backend/HASHOUT_LOG.md` 308, `frontend/HASHOUT_LOG.md` 345.
+
## Gate
- [ ] Every new or changed value still carries method and version, and refusals still refuse.
diff --git a/.claude/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md
index 361ff088..d685ca7d 100644
--- a/.claude/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/reactions/SUB-SKILL.md
@@ -32,6 +32,20 @@ Read `docs/FORMAT.md` (Reactions on a page, the table `stoich` rule, the derived
| `frontend/src/engine/reactions-api.ts`, `app/reaction-commands.ts` | the typed route client and the Reaction menu commands |
| `frontend/src/chem/reaction-roles.ts`, `ui/roles-dialog.ts` | Set Reaction Roles (0.6.0): `reactionRoleOps` moves changed ids between role lists, sets `explicit: true` and drops coefficients and `stoich` entries that no longer fit, in one transaction; `canTakeRole` (fragments, text, captions, groups, images, shapes, tables, never the arrow); the keyed roles dialog. Window-side, no engine route |
+### Scheme layout, marks and stoichiometry extras (0.14.0)
+
+| Path | Role |
+| --- | --- |
+| `chem/scheme.py` `space_reaction`, `stretch_ops`, `footnote_ops`, `_Spacer` | Space Reaction (equal gaps on the first arrow's centre line, wrap with `dogleg` or `repeat`), arrow stretch to the widest follower plus 2 x 7.2 pt moving everything past the head, step letters and the footnote text; `layout_steps` puts conditions at the arrow tail with `w` the arrow length |
+| `routers/reactions.py` `_space`, `/api/chem/densities`, `/ir-bands`, `/ms-fragments` | the space, stretch and footnote routes (window boxes in `boxes`, else `geometry.object_box`); stretch runs on perceive unless `stretch: false` |
+| `data/densities.json`, `chem/stoich.py` `density_lookup` | 65 neat liquids matched by InChIKey; used when no density or concentration is typed (`density_source`) |
+| `fe/canvas/tools/transform.ts` `arrowFollowers`, `keepConditionsCentred` | agents and conditions move with their arrow in the same draft; the end-handle drag in `select.ts` keeps them centred |
+| `fe/canvas/render/marks-reaction.ts`, `app/reaction-commands.ts` `setReactionMarkSource` | reacting-centre marks, coefficients over 1, the arrow badge (live canvas only, never in exports) |
+| `fe/ui/stoich-panel.ts` `stoichGrid` | the table density as placeholder, written with the amount; copy as TSV and save as CSV |
+| `routers/mcp.py` `t_space_reaction`, `t_fit_arrows_to_conditions`, `t_conditions_as_footnotes` | the agent tools over the same functions, one agent undo step each |
+
+Rules: stretching happens at Perceive, Space Reaction and Fit Arrows, never per keystroke (roles are recomputed only by Perceive), and MCP `perceive_reactions` does not stretch. Wrapped steps get `explicit: true`. A footnote sits at least 2 bond lengths under the shaft so a later Perceive never reads it as a condition, and an existing (a) label is reused. The window's grid maths reads only typed densities, so the panel writes the table value with the amount in one transaction. Reasons: `backend/HASHOUT_LOG.md` 304 to 307, `frontend/HASHOUT_LOG.md` 343, 344, 346. Gate additions: Space Reaction gaps 14.4, 14.4, 7.2, 7.2 with centres within 0.1 pt; a 30 pt arrow drag moves its condition 30 pt in one undo step; a second Space or footnote run writes nothing; 1.00 g benzoic acid gives 0.713 mL thionyl chloride with no density typed.
+
## Laws
- **One reading of stoichiometry.** The engine's `stoich.py` and the window's `chem/stoich.ts` follow the same precedence: `scale_mmol` is the reference when present, else the limiting reagent's typed amount over its equiv, else the first amount; typed amounts beat typed equivalents. Never add a third computation; the renderer's own copy was deleted for disagreeing. Only typed values are stored, and the window's write rules (mass, volume or equiv replaces the other two; scale and the limiting reagent's amount replace each other) keep the two readings equal.
diff --git a/.claude/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md b/.claude/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md
index cb3ba469..8a8b15cb 100644
--- a/.claude/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md
+++ b/.claude/skills/formchem-skillset/sub-skills/stereo-and-queries/SUB-SKILL.md
@@ -37,13 +37,15 @@ Keep the chemistry of 0.6.0 in one shape: the engine (RDKit) computes and propos
- **Chiral flag 0 reads absolute.** A deliberate deviation from the clean-room spec (most files write 0 for enantiomers); do not "fix" it without the owner.
- **Ids survive contract and expand.** Expansion-internal ids are not live document ids (`_ids_of`); expand restores them unless they clash.
- **Every property names its method.** A new property row has `method` (the RDKit call) and `note` (in words), and the window's `PROPERTY_ROWS` gets a reserved width.
-- **A fix is a command name.** A check issue names its repairing route in `fix`, never a transaction; add the code to `SEVERITY` (and `FIX` if repairable) and to the window's row text.
+- **A fix names its repair.** A check issue names its repairing route in `fix`, or, when the repair is a fixed edit of the issue's own atoms, carries the transaction the Check Structure dialog commits (`check.hypervalent_fix`, 0.14.0); add the code to `SEVERITY` (and `FIX` if repairable) and to the window's row text.
+- **Labels are read by the engine (0.14.0).** `abbrev.resolve` tries the library (221 entries, `abbrev_data.py`, residues with `[*:1]` and `[*:2]`) and then `services/chem/condensed.py` (CH2CH2OH, C(O)NHMe, reversed HOCH2; `empirical` keeps a molecular formula as text); `convert.to_mol` joins a label's bonds to its points in z then id order. User entries go through `abbrev.save_user` and `remove_user` (atomic) and the `/api/analysis/abbreviations` routes. Never let an unresolved alias change an element atom's chemistry.
+- **Analysis values name their table (0.14.0).** Weights come from `data/atomic_weights.json` (CIAAW 2024) through `mass.weight_table`, the year in the method; adducts are `isotopes.ADDUCTS` (seven); patterns prune at 0.01 percent and merge by `resolution`; `props.GHOSE` names Crippen as its stand-in; axial M and P come from the drawn wedge (`perceive.axes`, depth read from the fragment's bond, not RDKit's cleared direction); polymer formulas from `ids.bracket_formulas` reach derived `polymer`; plain SMILES of a query is refused (`ids.query_refusal`). Reasons: `backend/HASHOUT_LOG.md` 291 to 303.
- **Marks are keyed.** New marks are specs in `marks-stereo.ts` or `marks-query.ts`, cached per fragment by `ChemMarks`; explicit fills, no CSS colours; never rebuild the layer.
- **Agents read through tools, change through commands.** Analysis tools stay read-only and outside `MUTATING`; a changing chemistry command is a window command agents reach with `run_command`.
## Known gaps (do not paper over)
-Allene axial chirality and drawn atropisomers are not perceived; link nodes and variable attachment are not built; SMARTS import draws aromatic rings as single bonds (fix: order 1.5 when both ends are aromatic); Markush `count` is before dedup and if-then; Export SMARTS copies in the desktop shell until 0.7.0.
+Link nodes, variable attachment and haptic centroids are not built (PARITY decisions: each would be a new atom or bond kind in the file contract); CIP agrees with the published hard set for 91.6 percent of its labels (RDKit's labeller); axial M and P are not written to V3000 or CXSMILES; Expand Abbreviation takes the first point of a two-point label; SMARTS import draws aromatic rings as single bonds (fix: order 1.5 when both ends are aromatic); Markush `count` is before dedup and if-then; Export SMARTS copies in the desktop shell until 0.7.0.
## Gate
diff --git a/.docs/wiki/Agents.md b/.docs/wiki/Agents.md
index 005d9bf2..bac4f3cd 100644
--- a/.docs/wiki/Agents.md
+++ b/.docs/wiki/Agents.md
@@ -20,7 +20,7 @@ The full reference, with every tool's arguments and result shape and the recorde
## Tools
-77 tools. Reading never asks you; a tool that changes something asks you in the window the first time (Consent, below).
+104 tools (27 of them new in 0.14.0). Reading never asks you; a tool that changes something asks you in the window the first time (Consent, below).
| Group | Tools | Kind |
| --- | --- | --- |
@@ -43,6 +43,13 @@ The full reference, with every tool's arguments and result shape and the recorde
| Handoff | `handoff` | change with a state |
| Reactions (0.5.0) | `perceive_reactions`, `map_reaction` (change); `export_reaction`, `reaction_stoichiometry` (read) | |
| Analysis (0.6.0) | `properties`, `check_structure`, `stereo`, `substructure` | read |
+| Pages and objects (0.14.0) | `add_page`, `delete_page`, `set_page`, `fit_page_to_drawing` (change); `list_pages`, `list_objects` (read) | |
+| Agent undo (0.14.0) | `undo_agent_changes` | change only with `step` |
+| Drawing gestures (0.14.0) | `fuse_ring`, `attach_template` (need the window) | change |
+| Reaction layout (0.14.0) | `space_reaction`, `fit_arrows_to_conditions`, `conditions_as_footnotes` | change |
+| Chemistry as tools (0.14.0) | `standardise`, `balance_reaction` (change only with `apply`); `isotope_pattern`, `export_helm`, `predict_ir_bands`, `predict_ms_fragments` (read) | |
+| Abbreviations (0.14.0) | `abbreviation_define`, `abbreviation_remove` (change); `abbreviation_list` (read) | |
+| 3D (0.14.0) | `rotate_bond_3d`, `repair_hydrogens_3d`, `fetch_pdb` (change); `compute_surface`, `energy_terms_3d`, `render_3d` (read; `render_3d` needs the window) | |
| Tool | What it does |
| --- | --- |
@@ -103,6 +110,15 @@ The full reference, with every tool's arguments and result shape and the recorde
| `handoff {state?, note?}` | working, ready or question, with a note the person sees |
| `perceive_reactions`, `map_reaction`, `export_reaction`, `reaction_stoichiometry` | reaction steps, atom mapping, reaction SMILES and RXN, amounts and yields ([Reactions](Reactions)) |
| `properties`, `check_structure`, `stereo`, `substructure` | the 0.6.0 analysis tools ([Analysis](Analysis), [Stereo and Queries](Stereo-and-Queries)) |
+| `list_pages {doc?}`, `add_page {after?, paper?, orientation?}`, `delete_page {page}`, `set_page {page?, width?, height?, paper?, orientation?, auto?, margins?, header?, footer?, name?, all?}`, `fit_page_to_drawing {page?}` | pages, their setup and headers and footers ([Printing and pages](Printing-and-Pages)) |
+| `list_objects {doc?, page?, kind?}` | every object on a page with its bounding box in points, to check a layout |
+| `undo_agent_changes {doc?, step?}` | lists the agent steps on the undo stack; with `step`, goes back to before it (your steps in between included, counted), each an ordinary undo you can redo |
+| `fuse_ring {bond, size?, benzene?}`, `attach_template {id, atom?, bond?, x?, y?}` | the ring and Template tool gestures, through the window ([Templates](Templates)) |
+| `space_reaction {page?, reaction?, wrap?, wrap_mode?, stretch?}`, `fit_arrows_to_conditions {page?, step?}`, `conditions_as_footnotes {page?, reaction?}` | Space Reaction, arrows stretched to their conditions, step letters and footnotes ([Reactions](Reactions)) |
+| `standardise {smiles or doc, objects?, steps?, apply?}`, `balance_reaction {smiles or doc, reaction?, step?, coefficients?, apply?}` | Standardise and Balance Reaction; they preview unless `apply` is true |
+| `isotope_pattern {formula or smiles or doc}`, `export_helm {smiles or molfile or doc}`, `predict_ir_bands`, `predict_ms_fragments` | the isotope pattern, HELM text, IR bands and EI fragments |
+| `abbreviation_list {label?, filter?}`, `abbreviation_define {label, smiles, ...}`, `abbreviation_remove {label}` | the abbreviation library and your own entries |
+| `compute_surface`, `energy_terms_3d`, `rotate_bond_3d`, `repair_hydrogens_3d`, `render_3d`, `fetch_pdb {id}` | 3D surfaces and volumes, energy terms, bond rotation, hydrogen repair, a PNG of the 3D View, a PDB entry by id ([3D](3D)) |
## Drawing directly
@@ -177,4 +193,4 @@ Every tool call, from any transport or from the window's own chat, is logged by
## Skills
-`formchem-harness` (using FormChem: drawing with the tools, checking with render and get_structure, names, NMR prediction and spectra, 3D and xtb, databases and the notebook, the structure library and HELM, commands, reactions, analysis, handoff) and `formchem-skillset` (developing FormChem), in `.claude/skills` and mirrored to `.agents/skills`. The harness's `references/tools.md` is generated from the server and lists every argument of all 77 tools.
+`formchem-harness` (using FormChem: drawing with the tools, checking with render and get_structure, names, NMR prediction and spectra, 3D and xtb, databases and the notebook, the structure library and HELM, commands, reactions, analysis, handoff) and `formchem-skillset` (developing FormChem), in `.claude/skills` and mirrored to `.agents/skills`. The harness's `references/tools.md` is generated from the server and lists every argument of all 104 tools.
diff --git a/.docs/wiki/Analysis.md b/.docs/wiki/Analysis.md
index d05cd026..72176498 100644
--- a/.docs/wiki/Analysis.md
+++ b/.docs/wiki/Analysis.md
@@ -9,7 +9,7 @@ Open it with Analysis > Show Analysis. It follows the selection, or the whole pa
| Row | Method (the row's tooltip) |
| --- | --- |
| Formula | Hill order with charge, abbreviations expanded |
-| Molecular weight | standard atomic weights (CIAAW conventional values) |
+| Molecular weight | from 0.14.0 the CIAAW Standard Atomic Weights 2024 (conventional values for the interval elements), the table and its year named in the tooltip; glucose gives C 40.00, H 6.71, O 53.28, chloroform 119.369 |
| Exact mass | monoisotopic mass from the most abundant isotope of each element |
| m/z | from 0.7.0: [M+H]+ for a neutral molecule, the ion's own m/z for a charged one, from the isotope pattern (electron mass corrected) |
| Elemental analysis | mass percent of each element |
@@ -19,10 +19,17 @@ Open it with Analysis > Show Analysis. It follows the selection, or the whole pa
| H-bond donors, acceptors | Lipinski counting (N-H and O-H; N and O) |
| Rotatable bonds | non-ring single bonds between non-terminal heavy atoms |
| Lipinski rule of five | MW at most 500, cLogP at most 5, donors at most 5, acceptors at most 10; passes with at most one violation |
+| Veber, Ghose | from 0.14.0: Veber (rotatable bonds, TPSA) and Ghose 1999 qualifying ranges, with Crippen cLogP and MR standing in for ALOGP as the method says; aspirin and ibuprofen pass Ghose, caffeine fails (cLogP -1.03) |
+| InChIKey | from 0.14.0, with a note on InChI's limits (tautomers, metals, enhanced stereo) in its tooltip |
+| Polymer formula | from 0.14.0, for a structure with repeat-unit (SRU), copolymer or multiple-group brackets: end groups outside and the unit in parentheses, such as C2H6(C2H4)n, the unit mass "per repeat unit"; also in the status bar |
Hover a row to read its method. Values stay in place while new ones load, so the panel never jumps. For ibuprofen the panel reads C13H18O2, 206.28, 206.1307, cLogP 3.07, tPSA 37.30 and a Lipinski pass.
-Under the rows, the isotope pattern is drawn as sticks with the base peak in the accent colour; hover a stick for its mass and abundance. Below it are the monoisotopic mass and the m/z of [M+H]+, [M+Na]+ and [M-H]- (an ion shows its own m/z instead). The pattern is exact, merged at 0.01 Da and cut at 0.1 percent of the base peak: dichloromethane shows M+2 at about 64 percent of M, bromobenzene M+2 at about 97 percent.
+Under the rows, the isotope pattern is drawn as sticks with the base peak in the accent colour; hover a stick for its mass and abundance. Below it are the monoisotopic mass and the m/z of [M+H]+, [M+Na]+ and [M-H]-, and from 0.14.0 also [M+K]+, [M+NH4]+, [M+Cl]- and [M+HCOO]- (an ion shows its own m/z instead). From 0.14.0 the pattern is cut at 0.01 percent of the base peak and merged at unit resolution (peaks within 0.5 Da of a cluster), or at a resolving power from 100 to 10,000,000 through the engine route and agents: at R 200000 the M+1 of C20H30N10O splits into its 15N and 13C peaks. Dichloromethane shows M+2 at about 64 percent of M, bromobenzene M+2 at about 97 percent.
+
+**Elemental analysis: found** (0.14.0): under the name section, type the percentages you measured for each element; each shows its difference from the calculated value, marked when it is over 0.4 (the usual journal limit). The values stay with the formula while you work.
+
+**Predicted spectra** (0.14.0): a section with 1H, 13C, IR and MS tabs over one table that keeps its height. 1H and 13C list the predicted shifts in journal style (13C with its DEPT-135 phase) with a journal line to copy; the solvent choice (CDCl3, DMSO-d6 and others) adds that solvent's residual and water peaks as italic reference rows (Fulmer et al., Organometallics 2010) and does not change the predicted shifts. IR lists characteristic bands by functional group from FormChem's own table of textbook ranges (an ester shows C=O 1735 to 1750 and C-O 1000 to 1300). MS lists indicative EI fragment ions (alpha cleavage, benzylic, allylic, McLafferty and losses of water, CO, CO2, ammonia, HCl and methyl). Every table names its method; the IR and MS lists are rules, not a database.
Analysis > Copy Analysis (or the panel's Copy button) puts every value with its method, the peaks and the adducts on the clipboard as text. Analysis > Compute Properties opens the panel on the selection.
@@ -36,8 +43,8 @@ Structure > Check Structure opens a panel that stays open while you work. It lis
| Warnings | unusual charges, misplaced, ambiguous or conflicting wedges, a wedge between two centres, undefined double bonds, overlapping atoms, very short or long bonds, unknown labels or isotopes, aromatic bonds outside a ring, stereo groups on atoms that are not centres, R-group gaps |
| Notes | undefined stereocentres, wavy-bond centres, charge imbalance, query features, uncommon isotopes, crossing bonds, labels such as Ac or Pr that are also element symbols |
-Click a row to select its atoms and bonds on the canvas. Rows with Fix repair the problem as one undo step: wedge problems are redrawn by Assign Wedges, abbreviation problems expanded. Check Again runs the check once more and keeps the list in place. Metal cations in salts, such as Na+, are not valence errors. An atom with "ignore warnings" set drops the issues that concern only it.
+Click a row to select its atoms and bonds on the canvas. Rows with Fix repair the problem as one undo step: wedge problems are redrawn by Assign Wedges, abbreviation problems expanded, and from 0.14.0 a pentavalent nitrogen such as a nitro group drawn N(=O)=O is redrawn charge-separated. From 0.14.0 an atropisomer or allene wedge is not flagged as misplaced; a note says that SMILES, InChI and V2000 drop the axis, and a typed molecular formula on an atom gets its own note. Check Again runs the check once more and keeps the list in place. Metal cations in salts, such as Na+, are not valence errors. An atom with "ignore warnings" set drops the issues that concern only it.
## For agents
-The MCP tools `properties`, `check_structure`, `stereo` and `substructure` give agents the same numbers, issues, CIP labels and matches as JSON with atom and bond ids, without asking the person, because they only read. `properties` adds rings, aromatic rings, fraction Csp3, stereocentres, refined donor and acceptor counts, TPSA with S and P, and the Veber rules. See [Agents](Agents).
+The MCP tools `properties`, `check_structure`, `stereo` and `substructure` give agents the same numbers, issues, CIP labels and matches as JSON with atom and bond ids, without asking the person, because they only read. `properties` adds rings, aromatic rings, fraction Csp3, stereocentres, refined donor and acceptor counts, TPSA with S and P, the Veber rules and from 0.14.0 Ghose. From 0.14.0 `isotope_pattern`, `predict_ir_bands` and `predict_ms_fragments` read too, and the engine routes `/api/analysis/fragments`, `/inchi-enhanced` and `/aromaticity` give a fragmentation sketch, the non-standard InChI for AND and OR groups, and the simple and MDL aromaticity models, which the window does not show. See [Agents](Agents).
diff --git a/.docs/wiki/Annotations.md b/.docs/wiki/Annotations.md
index 43793657..5520ff7c 100644
--- a/.docs/wiki/Annotations.md
+++ b/.docs/wiki/Annotations.md
@@ -45,9 +45,7 @@ Align, distribute, flip and rotate work on objects as on structures. A click on
## Templates
-Insert > Template... opens the library: 206 original templates in nine categories (rings, polycycles, heterocycles, amino acids, sugars, nucleotides, protecting groups, reagents and solvents, glassware), with search by name and tag. Home shows the same library on Start and on its Templates page. A click inserts the template in the middle of the view as one undo step, at the drawing's bond length, and selects it; with no drawing open, a new one is made.
-
-Your own templates: put JSON files in `~/formchem/templates` (or `FORMCHEM_DATA_DIR/templates`) in the format of [`docs/TEMPLATES.md`](https://github.com/nodemode-dev/formchem/blob/main/docs/TEMPLATES.md); they show with the built-in ones.
+Insert > Template... opens the library of 260 whole molecules, and Insert > Glassware... the glassware drawings; both are described on the [Templates](Templates) page, with the Template tool that attaches a template to an atom or fuses it onto a bond.
## Find
@@ -59,4 +57,12 @@ View > Show Rulers shows rulers along the top and left edges of the canvas; they
## Not yet
-`Enter` does not finish a polyline. Templates cannot be fused onto an atom or a bond yet, and land in the middle of the view even if something is there. Bracket tilt for slanted bonds, table cell editing, dragging TLC spots and choosing an orbital's phase or fill come later.
+`Enter` does not finish a polyline, and there is no free-form pen tool. Brackets do not tilt for slanted bonds, and a bracket's connectivity and copolymer kinds have no control in the window.
+
+## From 0.14.0
+
+- **Tables**: click a cell with the Table tool, or use Edit Table Cell on its right-click menu, to type in it; `Tab` and `Shift+Tab` move between cells, and with Auto-Grow Table on the column widens and the row grows to fit, and `Tab` past the last cell (or `Enter` in the last column) adds a row, all in one undo step with the text. Add Table Row and Add Table Column are on the same menu. Stoichiometry tables are edited in the Stoichiometry panel instead.
+- **TLC plates**: drag a spot to move it (its Rf changes as you drag, across lanes too), `Alt`-drag to copy it, `Shift`-drag to resize it, and `Mod`-click or `Delete` over a spot to remove it; deleting a lane's last spot removes the lane when the plate has another. Drag a lane's origin tick to reorder lanes, and click under a lane to type its label. The plate's right-click menu adds, duplicates and deletes lanes and shows Rf values. The Rf values are kept with the plate for notebooks and agents.
+- **Object Style...** (Format menu, or the right-click menu of a shape, line or orbital) sets stroke, dash, colour, fill (solid or a linear gradient), opacity and shadow, and an orbital's fill (filled, hollow, shaded) and phase.
+- **Symbols**: Insert > Symbol adds Heat (Δ), Light (hν) and Arrow-Equals above the selected arrow.
+- **Selection**: a second click on a selected group selects inside it, `Escape` selects the group around it, a triple-click selects the outermost group or the reaction scheme, and Arrange > Integral Group makes a group that is always moved whole.
diff --git a/.docs/wiki/Architecture.md b/.docs/wiki/Architecture.md
index 80f6d973..53b2efc8 100644
--- a/.docs/wiki/Architecture.md
+++ b/.docs/wiki/Architecture.md
@@ -19,10 +19,11 @@ backend/ FastAPI engine: core/ (config, guard, window key, seal, agent token),
file_watch, describe, helm/ (HELM reader, writer, monomers), xtb/ (finding and running xtb and CREST), chem/ on RDKit and Indigo, names/ (the name engines), nmr/ (the increment predictor),
spectra/ (the JCAMP-DX reader and spectrum service), three_d/ (3D building, conformers, force fields, scans, PDB and mmCIF
readers, ligands, the stale-conformer rule), database/ (the .fcdb store, registration, fields, import, export, search, hit
- lists, the command line), notebook/ (entries, the content hash, schemes, export)), data/templates/, data/names/,
- data/helm_monomers.json
+ lists, the command line), notebook/ (entries, the content hash, schemes, export), demos (the demo catalogue and previews)),
+ data/templates/, data/names/, data/helm_monomers.json, data/demos/ (all of data/ ships in the frozen engine at app/data)
src-tauri/ the desktop shell; the frozen engine runs from a folder inside the app on macOS and as a sidecar elsewhere; the deep link
- plugin registers formai://
+ plugin registers formai://; linux/ (desktop entry, MIME package), windows/ (installer hook), icons/documents/
+demos/ offline browser demos (drawing, reactions, 3d) built from the window's code with an offline stand-in for the engine
```
## The engine owns the document
@@ -97,6 +98,15 @@ From 0.12.0 FormChem shares structures with the other Form apps and runs outside
- **HELM becomes atoms.** `services/helm/` reads HELM against FormChem's own monomer data and joins monomers into one RDKit molecule, which enters the drawing as an ordinary fragment through the template placement path, one transaction.
- **xtb and CREST run outside.** `services/xtb/` finds the programs the person installed, runs one job at a time as a separate process in its own folder, and writes the result back as one 3D transaction with the stale-conformer check, as the 0.10.0 3D routes do.
+## Desktop and demos
+
+From 0.13.0 the desktop shell hands files from the system to the window, and the engine ships its demo drawings. ([Desktop](Desktop))
+
+- **Files from the system take the Open path.** `src-tauri/src/main.rs` turns launch arguments, macOS open events and second launches into absolute paths and passes them to the window as `?open=` parameters or `window.__formchemOpen`; `frontend/src/app/system-open.ts` opens them one at a time through the same function as Open Recent, so an `.fcdb` reaches the database workspace and every other file becomes a drawing in the engine's store.
+- **Engine data is read relative to the services folder.** Each service finds its data from its own file's location (`Path(__file__).resolve().parents[...] / "data"`), and the frozen engine carries `backend/app/data` at `app/data`, so the same lookup works from source and in the app.
+- **Demos are copies.** `services/demos.py` lists `data/demos/demos.json`, validates each drawing, draws a small SVG preview itself (the engine has no renderer of its own for documents) and opens a demo as a new document with a fresh id and no path, so the shipped file is never written. Home's Demos section (`ui/home-demos.ts`) fills reserved cards from `GET /api/demos`.
+- **Browser demos stand alone.** `demos/` builds the window's canvas, tools and panels with Vite shims: `io/api.ts` becomes an offline stand-in and documents live in memory with the window's own op code, so each page opens from `file://` with no engine.
+
## Guarding the engine
The engine binds to 127.0.0.1. A local guard refuses requests whose Host or Origin is not local, and a window key made at each start lets only the FormChem window change settings, use the terminal dock or answer an agent's question. Saved agent choices are sealed with a key in the system keychain. From 0.8.0 the MCP endpoint also needs the agent token (`core/agent_token.py`, the file `agent-token` in the data folder), which the stdio relay and the agent configs send.
diff --git a/.docs/wiki/Desktop.md b/.docs/wiki/Desktop.md
index 799c4cbf..fa5d8d1e 100644
--- a/.docs/wiki/Desktop.md
+++ b/.docs/wiki/Desktop.md
@@ -4,12 +4,22 @@ The desktop app is a thin Tauri 2 shell around the same window, with the engine
| Source path | What lives there |
| --- | --- |
-| `src-tauri/src/main.rs` | Engine start, splash and reveal, single instance, the Windows job object that ends the engine with the app, the macOS overlay title bar with the traffic lights inset, clipboard access for the windows |
+| `src-tauri/src/main.rs` | Engine start, single instance, files handed over from the system, the windows (overlay title bar on macOS, clipboard access), the updater commands, printing, the `formai://` deep link, stopping the engine on exit |
+| `src-tauri/src/engine_start.rs` | The waits for the engine (90 s for its address, 10 s for the window key), the start-up failure sentences, the data folder and the engine log path |
+| `src-tauri/src/reveal.rs` | The splash: its rounded corners and the reveal of the main window once the page is ready |
+| `src-tauri/src/traffic_lights.rs` | The macOS overlay title bar with the traffic lights inset, kept in place on resize, focus and theme changes |
+| `src-tauri/src/win_job.rs` | The Windows job object that ends the engine with the app |
| `src-tauri/src/packaged.rs` | Finds the engine folder: `../Resources/engine/formchem-engine` in the app bundle, or `engine/formchem-engine` beside the program under `tauri dev`; without it the shell starts the sidecar |
-| `src-tauri/tauri.conf.json` | Identity `ai.nodemode.formchem`, windows, bundle targets, `externalBin`, the updater endpoint |
+| `src-tauri/tauri.conf.json` | Identity `ai.nodemode.formchem`, the splash window, bundle targets, `externalBin`, the file associations, the updater endpoint and the `formai` deep link scheme |
| `src-tauri/tauri.macos.conf.json` | macOS only: no `externalBin`, and the engine folder `src-tauri/engine` shipped as the resource `engine` |
+| `src-tauri/tauri.windows.conf.json` | Windows only: the notices and the two document `.ico` files as resources, and the NSIS installer hook |
+| `src-tauri/Info.plist` | macOS: the document types with their icons (`CFBundleDocumentTypes`) and FormChem's two exported types |
+| `src-tauri/linux/` | `formchem.desktop` (the desktop entry, `Exec` with `%U`) and `ai.nodemode.formchem.xml` (the MIME package), installed by the `.deb` and `.rpm` |
+| `src-tauri/windows/hooks.nsh` | Points the FormChem Document and FormChem Database classes at their document icons after the NSIS install |
+| `src-tauri/icons/documents/` | The `.fchem` and `.fcdb` document icons: PNG 16 to 512, `.ico` and `.icns`, made by `assets/icon_src/build.py` |
| `src-tauri/capabilities/` | Window permissions |
-| `src-tauri/flatpak/` | The Flatpak manifest and `ai.nodemode.formchem.metainfo.xml` |
+| `src-tauri/flatpak/` | The Flatpak manifest (it installs the MIME package and document icons from the deb) and `ai.nodemode.formchem.metainfo.xml` |
+| `frontend/src/app/system-open.ts` | The window's side of opening files: reads the files the shell hands over and opens them as File > Open does |
| `setup/freeze_backend` | PyInstaller build of `backend/formchem_engine.py`: on macOS a one-folder build copied to `src-tauri/engine`, flattened and checked; elsewhere a one-file sidecar named `formchem-engine-
-
+
@@ -21,7 +21,11 @@
- Features · Agents · Extensions · Under the hood · Run from source + Features · Gallery · Demos · Agents · Extensions · Under the hood · Run from source · Build it yourself +
+ +
+
Drawings.fchem documents kept by the engine, with undo per drawing (one step per gesture, command or agent call), autosave, Save, Save As, Save a Copy and Recent on Home. Files from other programs open as new drawings with a report of anything that changed on the way in, or File > Import adds them to the open drawing. |
- Canvas and toolsA tool rail with selection and lasso, ten bond kinds, chains, benzene and rings of 3 to 8, atom labels, text, eraser, hand and zoom. Structures render in the 1996 journal style with bundled Arimo, and the canvas patches only what changed. |
+ Canvas and toolsA tool rail with selection and lasso, fourteen bond kinds, chains, benzene, cyclopentadiene, rings of 3 to 8 and chairs, templates that attach to an atom or fuse onto a bond with a click, atom labels, text, eraser, hand and zoom. Structures render in the 1996 journal style with bundled Arimo, and the canvas patches only what changed. |
Hover keysPoint at an atom or a bond and press a key: elements and two-letter symbols, charges, radicals, chains of 1 to 9 carbons, rings, phenyl, bond orders, wedges, hashes and double-bond placement. Arrow keys and Enter draw without the mouse. |
|
Chemistry engineRDKit in the engine works out canonical SMILES, CXSMILES, InChI, InChIKey, formula and masses after each change, flags valence problems on the canvas, and powers Clean Up, Lay Out, Standardise and Check Structure. The 2D layout scores several candidates and swings crowded groups apart, so Taxol's labels no longer touch. |
- Analysis panelFormula, masses, m/z and elemental analysis, plus cLogP, TPSA, molar refractivity, donors, acceptors, rotatable bonds and the rule of five, each with its method, and the isotope pattern with adduct m/z. Copy Analysis takes it all as text. |
- Arrange and styleDuplicate, delete, flip, rotate, align and distribute the selection; Drawing preferences set the default style and its bond length, widths and label size; element colours, carbon labels and stereo labels on request. |
+ Analysis panelFormula, CIAAW 2024 masses, seven adducts and elemental analysis with your found values, plus cLogP, TPSA, molar refractivity, donors, acceptors, rotatable bonds, Lipinski, Veber and Ghose, each with its method, the isotope pattern, polymer formulas, and predicted 1H, 13C, IR and MS tables. Copy Analysis takes it all as text. |
+ Arrange and styleDuplicate, flip, rotate by any angle, align and distribute, smart guides and nested groups; journal styles applied to a drawing you already have or a selection, style files, per-character text formatting and an emphasis red. |
ReactionsPerceive Reactions reads reactants, products, reagents and conditions around each arrow, multi-step schemes included. Atom mapping with reacting bonds, balance checks with suggested coefficients, and reaction SMILES and RXN in and out. |
+ ReactionsPerceive Reactions reads each arrow's reactants, products, reagents and conditions; Space Reaction lines a scheme up and wraps it, conditions follow their arrow, arrows stretch to fit, and steps get footnotes. Atom mapping with reacting centres and a check badge on the arrow, balance with drawn coefficients, and reaction SMILES and RXN in and out. |
AnnotationsFifteen arrow types and anchored electron-pushing arrows, plus signs, brackets, shapes, lines, tables, TLC plates, orbitals, pictures and attached captions, with handles, stacking order and groups. |
- Stoichiometry and templatesA stoichiometry panel for moles, equivalents, the limiting reagent and yields, insertable as a table, and 206 original templates from rings to glassware. Find and rulers with guides. |
+ Stoichiometry and templatesA stoichiometry panel for moles, equivalents, the limiting reagent and yields, insertable as a table, with a density table and CSV export, and 260 whole molecules to start from, plus a glassware gallery. Several pages with headers and footers, Find and rulers with guides. |
StereochemistryCIP labels from the new rules (R, S, r, s, E, Z), enhanced stereo groups (abs, AND, OR) and the chiral flag, Assign Wedges, and abbreviations from a library of 106 that contract and expand without losing an atom. |
+ StereochemistryCIP labels from the new rules (R, S, r, s, E, Z), enhanced stereo groups (abs, AND, OR) and the chiral flag, Assign Wedges, M and P for atropisomers and allenes, and abbreviations from a library of 221 (with typed labels such as CH2CH2OH read as chemistry) that contract and expand without losing an atom. |
Queries and R-groupsAtom lists, generic atoms and query bonds drawn as tags, Find Substructure by selection or SMARTS, SMARTS and V3000 query molfiles, and R-group definitions with Markush enumeration. |
Structure checkA panel of errors, warnings and notes with a code each, from valence and charges to wedges, overlaps and R-group gaps. Click a row to select its atoms, or fix wedges and abbreviations in one step. |
|
Chemistry filesMolfile V2000 and V3000, SD, RXN, RD, SMILES, CXSMILES, reaction SMILES, SMARTS, InChI and InChIKey, CML, CDXML and CDX in and out, each export with a report of exactly what the format could not keep. |
- Pictures and printPNG up to 600 dpi, SVG with embedded font subsets, PDF and EPS, for the page, the selection or each structure, with the editable drawing kept inside so the picture opens again as the drawing. Print at real size. |
+ Pictures and printPNG up to 1200 dpi, TIFF, JPEG, WebP, one-bit line art, SVG with embedded fonts or outlines, PDF, PDF/A and EPS, with the editable drawing kept inside so the picture opens again as the drawing. Print with scale, tiling, crop marks and a preview. |
ClipboardCopy puts the drawing, SMILES and a picture on the clipboard at once; Copy As picks SMILES, CXSMILES, Molfile, InChI, InChIKey, SMARTS, SVG, PNG or CDXML; Paste reads all of them back, and Paste Special lets you choose. |
|
SpectraOpen IR, Raman, UV-Vis, MS and NMR spectra from JCAMP-DX files in every compression form, kept byte for byte in the drawing. The Spectrum editor zooms, picks peaks, integrates and switches transmittance and absorbance; peaks, integrals and multiplets link to atoms, and hovering one lights the other. |
||||
3D ViewBuild 3D from 2D keeps every wedge and double bond as drawn and checks each stereocentre from the 3D model (Taxol keeps 11 of 11). Wire, stick, ball and stick, space filling and cartoon; van der Waals, solvent surfaces and ESP; distances, angles and dihedrals; a 3D view placed on the page keeps its angle and style. PNG and glTF out. |
+ 3D ViewBuild 3D from 2D keeps every wedge and double bond as drawn and checks each stereocentre from the 3D model (Taxol keeps 11 of 11). Wire, stick, ball and stick, space filling and cartoon; van der Waals, solvent surfaces with areas and volumes, and ESP; colour schemes, labels and hydrogen bonds; live distances, angles and dihedrals and bond rotation; a live link from 2D; a 3D view placed on the page keeps its angle and style. PNG at any size, stereo pairs and glTF out. |
Conformers and energiesConformer searches within an energy window with Boltzmann populations, MMFF94, MMFF94s or UFF minimisation, and relaxed dihedral scans plotted with their barrier, each energy shown with its force field and version. Edit the structure and its conformers go in the same undo step. |
- Proteins and ligandsPDB and mmCIF files open as cartoon with the ligand in focus and waters hidden, the file kept byte for byte in the drawing. Extract Ligand turns a ligand into an editable structure with its coordinates; 3D SD files keep theirs. Export as MOL, SD, PDB or XYZ with every hydrogen. |
+ Proteins and ligandsPDB and mmCIF files, from disk or by PDB id, open as cartoon with the ligand in focus and waters hidden, with models, alternate locations, assemblies and the binding site; small-molecule CIF packs its cell. Extract Ligand turns a ligand into an editable structure with its coordinates; 3D SD files keep theirs. Export as MOL, SD, PDB or XYZ with every hydrogen. |
DatabasesStructure databases in one SQLite file (.fcdb) that any SQLite browser opens: your own fields (numbers with units, dates, choices, files, links and computed descriptors), Add to Database with duplicate rules for stereo and salts, and table, gallery, form and plot views that scroll 10,000 records without a stall. Import SD, RD, SMILES, CSV and TSV with a preview and a report of every bad record; export to SD, SMILES or CSV. |
@@ -87,17 +91,42 @@ FormChem draws structures and reactions: draw on the canvas with the mouse or th
xtb and CRESTGFN2-xTB or GFN-FF optimisations and single points with ALPB solvents, and CREST conformer searches, when you have installed the programs: energies in hartree and kcal/mol with the gap and the program's version. FormChem never ships or downloads them. |
|||
MCP server77 tools over HTTP (with an agent token) and stdio: agents open and save drawings, draw from SMILES, reaction SMILES, molfiles or names, build and edit atom by atom by id, read structures back as SMILES, InChIKey, molfiles and names, render what you see, validate, predict NMR, open spectra and pick their peaks, build 3D conformers, scan and measure them, open PDB files and extract ligands, create, import into, search and export databases, add and find notebook entries, keep the structure library, draw from HELM, run xtb and CREST, convert files as the command line does, and run every menu command. Agent Activity lists each call with undo and Stop. |
+ MCP server104 tools over HTTP (with an agent token) and stdio: agents open and save drawings, draw from SMILES, reaction SMILES, molfiles or names, build and edit atom by atom by id, read structures back as SMILES, InChIKey, molfiles and names, render what you see, validate, predict NMR, open spectra and pick their peaks, build 3D conformers, scan and measure them, open PDB files and extract ligands, create, import into, search and export databases, add and find notebook entries, keep the structure library, draw from HELM, run xtb and CREST, convert files as the command line does, and run every menu command. Agent Activity lists each call with undo and Stop. |
The family shellHome, Preferences, twelve menus with full keyboard use (those that do not fit fold into More menus), Find a Command, the terminal and agent dock, Help and updates, in 26 interface languages. |
Form extensionsExtensions installed by FormPortal run in a sandboxed frame from the Extensions menu and panel, and ask before they read or change a drawing. |
![]() Reactions and stoichiometry. A scheme read into roles, with amounts, equivalents and the yield worked out as you type. |
+ ![]() 3D View. Built from the drawing with every stereocentre kept, conformers with their energies, styles, surfaces and measurements. |
+
![]() Databases. One .fcdb file per database, 300 records imported from an SD file, searched by structure and shown as a gallery, table, form or plot. |
+ ![]() Lab notebook. An experiment entry with its scheme, the stoichiometry computed from it, the procedure, and signing with a SHA-256 hash. |
+
![]() Structure library. Favourites, recent structures, templates and live structures in a plain folder every Form app reads. |
+ ![]() Home. New drawings, files to open, recent drawings and the five demos, with the 260 whole-molecule templates, Databases, Trash and agent setup in the rail. |
+