mirror of
https://github.com/storytold/wordcraft.git
synced 2026-12-05 04:07:03 -06:00
Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f627faed0 | ||
|
|
8cc1912dc0 | ||
|
|
0eda97fe8c | ||
|
|
db301eb1ba | ||
|
|
ab05f3f6d4 | ||
|
|
440243e3d7 | ||
|
|
18369a756e | ||
|
|
e8b2c87781 | ||
|
|
bf556a1cd6 | ||
|
|
0bcb856280 | ||
|
|
c555672b56 | ||
|
|
c1a23c6a1f | ||
|
|
a4ad65c372 | ||
|
|
04a3c76c10 | ||
|
|
fbe41cca76 | ||
|
|
553f0058ee | ||
|
|
f086af023f | ||
|
|
f9ff36d67c | ||
|
|
ce2b01e005 | ||
|
|
0739eb7379 | ||
|
|
17fecc43ec | ||
|
|
1a7b691293 | ||
|
|
a6e831e8ca | ||
|
|
187a36e16c | ||
|
|
903edaffc7 | ||
|
|
3e3975d3a0 | ||
|
|
e31df586db | ||
|
|
865fcf21eb | ||
|
|
a18747a686 | ||
|
|
bbe04de28d |
@@ -73,7 +73,7 @@ WordCraft is a Rust word processor targeting Microsoft Word parity, for macOS, W
|
||||
- `unsafe`: none; the workspace forbids it. Typing behaviour is pinned by `crates/engine/src/tests/typing.rs` and described in `docs/typing-parity.md`.
|
||||
- Attribution: `ATTRIBUTION.md`, a row per asset file, checked by `cargo xtask assets`. Icons are our own SVG set in `crates/ui-egui/icons/` (draw new icons there); sample content is in `crates/engine/src/sample.rs` and `cmd/design.rs`.
|
||||
- Fonts and language data come from other repositories as optional build inputs: craft-fonts through `CRAFT_FONTS_DIR`, and craft-i18n's `language-data/` through `CRAFT_I18N_DIR` (pinned by `craft-i18n.rev`; CI checks it out). Without craft-i18n the app builds with fallback spelling and no pattern hyphenation, so proofing tests need it. Proprietary font requests use installed fonts or the open substitutes in `crates/fonts/src/word.rs`. Layout tests use the fixed fonts in `assets/fonts/` ([docs/testing.md](docs/testing.md)).
|
||||
- Run: `cargo run --release -p wordcraft -- --sample --control 7981` starts the app with a sample document and the control channel. It takes JSON lines on `127.0.0.1:7981`: authenticate once per connection with the token from `~/.config/wordcraft/control-key.local-7981` (macOS: `~/Library/Application Support/WordCraft/`), `{"id":1,"method":"auth","params":{"token":"…"}}`, then send requests without a token; methods are in `crates/ui-egui/src/control.rs`, docs in `docs/control-protocol.md` (Token). Headless screenshots: `cargo run --release -p wordcraft-ui-egui --example ui_shot -- script.jsonl`. CLI: `wordcraft-cli convert|run|commands|parity`. MCP: `wordcraft-cli mcp --automation-read-root DIR --automation-write-root DIR` (both required; `--connect` is refused until the app confines its control channel, #3695), see `docs/mcp.md`.
|
||||
- Run: `cargo run --release -p wordcraft -- --sample --control 7981` starts the app with a sample document and the control channel. It takes JSON lines on `127.0.0.1:7981`: authenticate once per connection with the token from `~/.config/wordcraft/control-key.local-7981` (macOS: `~/Library/Application Support/WordCraft/`), `{"id":1,"method":"auth","params":{"token":"…"}}`, then send requests without a token; methods are in `crates/ui-egui/src/control.rs`, docs in `docs/control-protocol.md` (Token). Headless screenshots: `cargo run --release -p wordcraft-ui-egui --example ui_shot -- script.jsonl`. CLI: `wordcraft-cli convert|run|commands|parity`. MCP: plain `wordcraft-cli mcp` reaches the open window while ArtCraft Launcher › Settings › AI agents is on (`crates/ui-egui/src/agents.rs`, `crates/mcp/src/live.rs`); `--headless`, or the switch off, needs `--automation-read-root DIR --automation-write-root DIR`; see `docs/mcp.md`.
|
||||
- Headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): `cargo xtask parity` marks a catalog feature `headless: yes` only when its command is in the engine registry that `wordcraft-cli` and the MCP server load (never a `ui.*` id). A missing feature takes its `no`/`partial` value and `reach:` (`window`, `os` or `engine-gap`) from `HEADLESS` in `crates/engine/src/catalog.rs`, or reads `unknown`. When a command lands, delete its mark; `headless_marks_are_current` fails on a stale one.
|
||||
- Notes and progress: `plan/` is an optional gitignored notebook. Committed: `ROADMAP.md` (progress log), `docs/gaps.md`, `docs/roadmap.md`, `docs/target-app-parity.md`, `docs/architecture.md` and the parity checklists.
|
||||
- Contributor credits: `docs/contributors.md`.
|
||||
|
||||
Generated
+123
-96
@@ -1173,7 +1173,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-automation",
|
||||
"craft-behavior",
|
||||
@@ -1211,10 +1211,20 @@ dependencies = [
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-ai-agents"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-ai-integrations?rev=d94a3593adcff504eaaad9e5aee4c84fd2f07a72#d94a3593adcff504eaaad9e5aee4c84fd2f07a72"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-appkit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"objc2 0.6.5",
|
||||
@@ -1226,7 +1236,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-atomic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"rustix 1.1.6",
|
||||
]
|
||||
@@ -1234,7 +1244,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-automation"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1259,11 +1269,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-behavior"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"bitflags 2.13.2",
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
"craft-keymap",
|
||||
"craft-theme",
|
||||
"craft-tracked",
|
||||
@@ -1277,7 +1288,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-browse"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-docpath",
|
||||
@@ -1295,12 +1306,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cfb"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
|
||||
[[package]]
|
||||
name = "craft-cloud-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
@@ -1308,7 +1319,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cms"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"md-5",
|
||||
"rayon",
|
||||
@@ -1317,12 +1328,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-codepage"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
|
||||
[[package]]
|
||||
name = "craft-color"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1330,7 +1341,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-color-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-cms",
|
||||
@@ -1350,10 +1361,15 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-ai-agents",
|
||||
"craft-atomic",
|
||||
"craft-control-protocol",
|
||||
"craft-flags",
|
||||
"craft-platform",
|
||||
"dirs",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -1361,7 +1377,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control-protocol"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"serde_json",
|
||||
@@ -1371,7 +1387,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dds"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
@@ -1379,7 +1395,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dialogs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"craft-appkit",
|
||||
@@ -1405,7 +1421,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-doc-binary"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-cfb",
|
||||
@@ -1422,7 +1438,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docpath"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1430,7 +1446,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docx"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"chrono",
|
||||
@@ -1450,7 +1466,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-draw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1469,7 +1485,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-drawingml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-xml",
|
||||
@@ -1478,10 +1494,20 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-flags"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"dirs",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-flow"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-wordmodel",
|
||||
"image",
|
||||
@@ -1491,7 +1517,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-catalog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"fontique",
|
||||
"harfrust 0.13.3",
|
||||
@@ -1506,7 +1532,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-manager"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -1525,7 +1551,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-os-windows"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"windows-registry",
|
||||
"windows-sys 0.61.2",
|
||||
@@ -1534,7 +1560,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"cap-primitives",
|
||||
"craft-atomic",
|
||||
@@ -1557,7 +1583,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-subset"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"brotli 9.1.3",
|
||||
"harfbuzz-subset-sys",
|
||||
@@ -1570,7 +1596,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-fonts-build"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-font-subset",
|
||||
]
|
||||
@@ -1578,7 +1604,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-gpu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"egui-wgpu",
|
||||
"log",
|
||||
@@ -1590,7 +1616,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-i18n",
|
||||
@@ -1603,7 +1629,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-html"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"craft-flow",
|
||||
@@ -1616,7 +1642,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-i18n"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"brotli 9.1.3",
|
||||
"brotli-decompressor 6.3.1",
|
||||
@@ -1646,7 +1672,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-image-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-dds",
|
||||
"craft-jpeg",
|
||||
@@ -1673,7 +1699,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-imaging"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1691,7 +1717,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1699,7 +1725,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-keymap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
@@ -1714,7 +1740,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-latex"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-flow",
|
||||
"craft-math",
|
||||
@@ -1725,7 +1751,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-markdown"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-flow",
|
||||
"craft-html",
|
||||
@@ -1735,7 +1761,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-math"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-xml",
|
||||
"roxmltree",
|
||||
@@ -1745,7 +1771,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-mcp-server"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
@@ -1753,7 +1779,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-menu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1771,7 +1797,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metadata"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"brotli-decompressor 6.3.1",
|
||||
"chrono",
|
||||
@@ -1783,7 +1809,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metafile"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"image",
|
||||
@@ -1794,7 +1820,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-mime"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"chardetng",
|
||||
"chrono",
|
||||
@@ -1805,7 +1831,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-nightly"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"uds_windows",
|
||||
"winsafe",
|
||||
@@ -1814,7 +1840,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-odf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64 0.23.1",
|
||||
@@ -1840,7 +1866,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ods"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-odf",
|
||||
"craft-sheet",
|
||||
@@ -1851,7 +1877,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-offcrypto"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64 0.23.1",
|
||||
@@ -1868,7 +1894,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-opc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-xml",
|
||||
"craft-zip",
|
||||
@@ -1879,7 +1905,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pages"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -1895,7 +1921,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"krilla",
|
||||
"serde",
|
||||
@@ -1905,7 +1931,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-platform"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"async-channel",
|
||||
@@ -1943,7 +1969,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1967,7 +1993,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-proof"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"log",
|
||||
"miniz_oxide 0.9.1",
|
||||
@@ -1978,7 +2004,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-quit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"dispatch2",
|
||||
"egui",
|
||||
@@ -1991,7 +2017,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-review"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -2010,7 +2036,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-rtf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"craft-flow",
|
||||
@@ -2023,7 +2049,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-settings"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-host",
|
||||
@@ -2040,17 +2066,17 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-sheet"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
|
||||
[[package]]
|
||||
name = "craft-ssip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
|
||||
[[package]]
|
||||
name = "craft-svg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-xml",
|
||||
"flate2",
|
||||
@@ -2067,7 +2093,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-table"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2079,7 +2105,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-text"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2103,7 +2129,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-tracked",
|
||||
@@ -2118,7 +2144,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
@@ -2133,7 +2159,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tiff"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2143,7 +2169,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-time"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2152,7 +2178,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-timeline"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2167,12 +2193,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tracked"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-cloud-ui",
|
||||
"craft-ui-canvas",
|
||||
@@ -2186,7 +2212,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-canvas"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -2203,7 +2229,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-contract"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"craft-behavior",
|
||||
@@ -2241,7 +2267,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2252,7 +2278,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-panels"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2270,7 +2296,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-patterns"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2291,7 +2317,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-shell"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2312,7 +2338,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-test-kit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2323,7 +2349,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-widgets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2342,7 +2368,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-update"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
@@ -2374,7 +2400,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-web-api"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde_json",
|
||||
@@ -2385,7 +2411,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-web-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-platform",
|
||||
@@ -2397,7 +2423,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-win32"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"winsafe",
|
||||
]
|
||||
@@ -2405,7 +2431,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-window"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-appkit",
|
||||
"craft-atomic",
|
||||
@@ -2437,7 +2463,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-wordmodel"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-math",
|
||||
@@ -2451,7 +2477,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xls"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-cfb",
|
||||
"craft-sheet",
|
||||
@@ -2464,7 +2490,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xlsx"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"craft-drawingml",
|
||||
"craft-opc",
|
||||
@@ -2476,7 +2502,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
@@ -2486,7 +2512,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
@@ -3879,7 +3905,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
|
||||
[[package]]
|
||||
name = "hayro-cmap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"brotli 8.0.4",
|
||||
"hayro-postscript",
|
||||
@@ -3888,7 +3914,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
@@ -3906,7 +3932,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"hayro-ccitt",
|
||||
@@ -3924,12 +3950,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-postscript"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
@@ -4658,7 +4684,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "krilla"
|
||||
version = "0.8.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bumpalo",
|
||||
@@ -4797,7 +4823,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
|
||||
[[package]]
|
||||
name = "linesweeper"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"kurbo",
|
||||
@@ -9346,6 +9372,7 @@ dependencies = [
|
||||
"craft",
|
||||
"craft-mcp-server",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wordcraft-control-key",
|
||||
"wordcraft-doc",
|
||||
@@ -10067,4 +10094,4 @@ source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f
|
||||
[[patch.unused]]
|
||||
name = "hayro"
|
||||
version = "0.7.1"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
|
||||
|
||||
+39
-39
@@ -37,22 +37,22 @@ wordcraft-pdf = { path = "crates/pdf" }
|
||||
# reads the ca-valencia pack), #589 (French elision suggestions first), #497 (flag-based
|
||||
# compounding), #496 (review follow-ups, en-AU) and the merged #482–#490/#495 stack; the font
|
||||
# store's `language-pack` kind is #486 (CP4.1).
|
||||
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
wordcraft-engine = { path = "crates/engine" }
|
||||
wordcraft-mcp = { path = "crates/mcp" }
|
||||
wordcraft-zotero = { path = "crates/zotero" }
|
||||
wordcraft-control-key = { path = "crates/control-key" }
|
||||
wordcraft-ui-egui = { path = "crates/ui-egui" }
|
||||
wordcraft-validate = { path = "crates/validate" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", default-features = false }
|
||||
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", default-features = false }
|
||||
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
|
||||
# foundation
|
||||
kurbo = { version = "0.13", features = ["serde"] }
|
||||
@@ -85,28 +85,28 @@ wuff = "0.2.9"
|
||||
brotli-decompressor = "5"
|
||||
vello_cpu = "0.2"
|
||||
image = { version = "0.25", default-features = false }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", default-features = false, features = ["write"] }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", default-features = false, features = ["write"] }
|
||||
|
||||
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["doc"] }
|
||||
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["text"] }
|
||||
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["flow"] }
|
||||
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["detect"] }
|
||||
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
|
||||
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["doc"] }
|
||||
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["text"] }
|
||||
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["flow"] }
|
||||
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["detect"] }
|
||||
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
|
||||
# zlib streams (compressed metafile pictures in `.doc` drawings); already in the lock as a dependency of other crates.
|
||||
miniz_oxide = "0.9"
|
||||
cfb = "0.15"
|
||||
@@ -174,14 +174,14 @@ debug = 0
|
||||
# The framework's patches, which Cargo does not carry over to dependents: its vendored crates from craft-libs,
|
||||
# and the egui and winit forks it builds with.
|
||||
[patch.crates-io]
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
|
||||
|
||||
@@ -205,13 +205,17 @@ Web: `cd apps/wordcraft-web && trunk serve`, then open <http://127.0.0.1:8771/?s
|
||||
|
||||
WordCraft was designed to be driven by people *and* by AI agents.
|
||||
|
||||
With ArtCraft Launcher › Settings › AI agents on, AI apps reach the open WordCraft window through
|
||||
the launcher's one `ArtCraft` entry: tool calls act in the window, and files go to the agent folder
|
||||
(`Documents/ArtCraft/Agents/WordCraft`, or the folders in File › Options › Agents). Without the
|
||||
launcher:
|
||||
|
||||
```sh
|
||||
# headless documents; the agent reads only inside the first folder and writes only inside the second
|
||||
claude mcp add wordcraft -- wordcraft-cli mcp --automation-read-root DIR --automation-write-root DIR
|
||||
```
|
||||
|
||||
Both roots are required. Bridging an agent to the running app (`mcp --connect`) is refused until
|
||||
the app confines its control channel to the same roots (#3695).
|
||||
A headless server needs both roots.
|
||||
|
||||
Tools include `list_commands`, `execute`, `batch`, `type_text`, `select_text`, `inspect_document`,
|
||||
`render_page` and `save_document`. Agents
|
||||
|
||||
+164
-38
@@ -54,16 +54,25 @@ USAGE:
|
||||
wordcraft-cli commands [--json] list every command
|
||||
wordcraft-cli parity [--markdown] feature-catalog parity
|
||||
wordcraft-cli validate <file> [--json] structural integrity check (exit 0 pass, 1 fail, 2 incomplete, 3 usage/IO)
|
||||
wordcraft-cli mcp --automation-read-root DIR --automation-write-root DIR [--author NAME]
|
||||
MCP server on stdio, with a headless session.
|
||||
Both roots are required: the agent's commands read
|
||||
files (open, insert text or picture, mail-merge data,
|
||||
templates…) only inside the read root and write them
|
||||
(save, export, merge output…) only inside the write
|
||||
root, links followed; the same folder may be both.
|
||||
--connect HOST:PORT (bridge to the running app) is
|
||||
refused until the app confines its control channel
|
||||
(#3695, #5819).
|
||||
wordcraft-cli mcp [--automation-read-root DIR --automation-write-root DIR] [--headless]
|
||||
[--when-closed launch|headless|error] [--author NAME]
|
||||
MCP server on stdio. While AI agents are on in
|
||||
ArtCraft Launcher › Settings › AI agents, each tool
|
||||
call goes to the open WordCraft window, working in
|
||||
its agent folder (File › Options › Agents); while
|
||||
WordCraft is closed, --when-closed or that page's
|
||||
choice decides: open it, work without a window, or
|
||||
ask to open it. Otherwise, and with --headless, a
|
||||
headless session, which needs both roots: the
|
||||
agent's commands read files (open, insert text or
|
||||
picture, mail-merge data, templates…) only inside
|
||||
the read root and write them (save, export, merge
|
||||
output…) only inside the write root, links followed;
|
||||
the same folder may be both. Given with AI agents
|
||||
on, the roots replace the agent folder for headless
|
||||
work. --author names the author of a headless
|
||||
session's tracked changes and comments.
|
||||
--connect HOST:PORT is deprecated and ignored.
|
||||
wordcraft-cli zotero <command> <file> [--cmd 'id={json}' …] [--save OUT] [--trace] [--port P]
|
||||
run a Zotero command on a document (Zotero must be
|
||||
running): addEditCitation, addEditBibliography,
|
||||
@@ -261,6 +270,17 @@ fn find_option_arg<'a>(args: &'a [String], name: &str) -> OptionArg<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// `mcp --author NAME`: absent is the default author; a flag without a name, or given twice, is a
|
||||
/// usage error, never an unnamed session or the next option taken as the name.
|
||||
fn mcp_author(args: &[String]) -> Result<Option<String>, String> {
|
||||
match find_option_arg(args, "--author") {
|
||||
OptionArg::Absent => Ok(None),
|
||||
OptionArg::Duplicate => Err("mcp: duplicate --author option".into()),
|
||||
OptionArg::MissingValue => Err("mcp: --author requires a name".into()),
|
||||
OptionArg::Value(name) => Ok(Some(name.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_page_arg(command: &str, args: &[String]) -> Result<Option<u64>, String> {
|
||||
match find_option_arg(args, "--page") {
|
||||
OptionArg::Absent => Ok(None),
|
||||
@@ -376,13 +396,86 @@ const VALIDATE_OPTIONS: &[OptionSpec] = &[OptionSpec { name: "--json", takes_val
|
||||
const MCP_NEEDS_ROOTS: &str = "mcp: give both --automation-read-root DIR and --automation-write-root DIR: an agent's \
|
||||
commands may read only inside the read root and write only inside the write root (the same folder may be both)";
|
||||
|
||||
/// Why `mcp --connect` is refused: the running app would not confine the agent's file access.
|
||||
// lean: refused outright; allow it once the app confines its control channel and reports both roots.
|
||||
const MCP_CONNECT_REFUSED: &str = "mcp: --connect is refused for now: the desktop app does not confine its control \
|
||||
channel to automation roots yet (storytold/wordcraft#3695, #5819). Use the headless server: wordcraft-cli mcp \
|
||||
--automation-read-root DIR --automation-write-root DIR";
|
||||
/// Why `mcp` won't start while the suite's AI-MCP flag is on but the launcher's switch keeps agents
|
||||
/// out of the window: without roots it would have no folders to work in.
|
||||
const MCP_NEEDS_ROOTS_OR_AGENTS: &str = "mcp: give both --automation-read-root DIR and --automation-write-root DIR, or \
|
||||
turn on AI agents in ArtCraft Launcher › Settings › AI agents to work in WordCraft's open window and its agent folder";
|
||||
|
||||
const MCP_OPTIONS: &[OptionSpec] = &[OptionSpec { name: "--connect", takes_value: true }, OptionSpec { name: "--author", takes_value: true }];
|
||||
/// `--connect HOST:PORT`, from before plain `mcp` found the window by itself: kept for one release,
|
||||
/// ignored with this note on stderr, then removed.
|
||||
const MCP_CONNECT_DEPRECATED: &str = "wordcraft-cli: --connect is deprecated and will be removed in the next release: \
|
||||
plain `wordcraft-cli mcp` finds the open WordCraft window by itself while AI agents are on in ArtCraft Launcher › \
|
||||
Settings › AI agents. The address given is not used.";
|
||||
|
||||
const MCP_OPTIONS: &[OptionSpec] = &[
|
||||
OptionSpec { name: "--headless", takes_value: false },
|
||||
OptionSpec { name: "--when-closed", takes_value: true },
|
||||
OptionSpec { name: "--author", takes_value: true },
|
||||
];
|
||||
|
||||
/// Takes the deprecated `--connect` out of `args`, with its value (written apart, unless it is
|
||||
/// another option, or as `--connect=…`): whether it was there.
|
||||
fn take_connect(args: &mut Vec<String>) -> bool {
|
||||
let mut found = false;
|
||||
let mut i = 0;
|
||||
while let Some(arg) = args.get(i) {
|
||||
if arg == "--connect" {
|
||||
found = true;
|
||||
let with_value = args.get(i + 1).is_some_and(|v| !v.starts_with("--"));
|
||||
args.drain(i..if with_value { i + 2 } else { i + 1 });
|
||||
} else if arg.starts_with("--connect=") {
|
||||
found = true;
|
||||
args.remove(i);
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
found
|
||||
}
|
||||
|
||||
/// The suite's AI-MCP flag and whether the ArtCraft Launcher's switch lets agents use WordCraft.
|
||||
#[cfg(not(test))]
|
||||
fn agents_state() -> (bool, bool) {
|
||||
let flag = wordcraft_mcp::live::mcp_flag();
|
||||
(flag, flag && wordcraft_mcp::live::agents_allowed_now())
|
||||
}
|
||||
|
||||
/// Unit tests run `mcp` as without the suite's flag, whatever this machine's flags say; the plan
|
||||
/// itself is tested for every combination (`mcp_plan`), and the binary's tests set the flag.
|
||||
#[cfg(test)]
|
||||
fn agents_state() -> (bool, bool) {
|
||||
(false, false)
|
||||
}
|
||||
|
||||
/// How `mcp` runs.
|
||||
#[derive(Debug)]
|
||||
enum McpPlan {
|
||||
/// A headless session confined to both roots.
|
||||
Headless(std::sync::Arc<wordcraft_engine::file_access::AutomationRoots>),
|
||||
/// The open window while agents may use it, otherwise a headless session in the given roots
|
||||
/// or the app's agent folder ([`wordcraft_mcp::Live`]).
|
||||
Live(Option<std::sync::Arc<wordcraft_engine::file_access::AutomationRoots>>),
|
||||
}
|
||||
|
||||
/// `mcp`'s plan. With `--headless`, or without the suite's AI-MCP flag (`flag`), a headless session
|
||||
/// that needs both roots (shared rule 18). With the flag, the live client when the launcher's
|
||||
/// switch lets agents in (`switch`) or both roots are given, so nothing it does is unconfined;
|
||||
/// otherwise a refusal.
|
||||
fn mcp_plan(
|
||||
roots: Option<std::sync::Arc<wordcraft_engine::file_access::AutomationRoots>>,
|
||||
headless: bool,
|
||||
flag: bool,
|
||||
switch: bool,
|
||||
) -> Result<McpPlan, &'static str> {
|
||||
let both = roots.clone().filter(|r| r.read_root().is_some() && r.write_root().is_some());
|
||||
if headless || !flag {
|
||||
return both.map(McpPlan::Headless).ok_or(MCP_NEEDS_ROOTS);
|
||||
}
|
||||
if switch || both.is_some() {
|
||||
return Ok(McpPlan::Live(roots));
|
||||
}
|
||||
Err(MCP_NEEDS_ROOTS_OR_AGENTS)
|
||||
}
|
||||
const ZOTERO_OPTIONS: &[OptionSpec] = &[
|
||||
OptionSpec { name: "--cmd", takes_value: true },
|
||||
OptionSpec { name: "--save", takes_value: true },
|
||||
@@ -754,28 +847,7 @@ fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
|
||||
}
|
||||
}
|
||||
"validate" => run_validate(file.as_deref(), &rest),
|
||||
"mcp" => {
|
||||
let (roots, rest) = automation_roots("mcp", &rest)?;
|
||||
// Refused with or without a value, before the option check, so `--connect=…` gets this refusal rather than
|
||||
// "unknown option": a bare trailing `--connect` must not slip past either.
|
||||
if rest.iter().any(|a| a == "--connect" || a.starts_with("--connect=")) {
|
||||
return Err(MCP_CONNECT_REFUSED.into());
|
||||
}
|
||||
validate_options("mcp", &rest, MCP_OPTIONS)?;
|
||||
// Shared rule 18 (#7124): an agent entry point never runs unconfined.
|
||||
let Some(roots) = roots.filter(|r| r.read_root().is_some() && r.write_root().is_some()) else {
|
||||
return Err(MCP_NEEDS_ROOTS.into());
|
||||
};
|
||||
// Every thread of this process, not only the server's: nothing reaches past the roots.
|
||||
wordcraft_engine::file_access::confine_process(roots.clone());
|
||||
let show = |root: Option<&std::path::Path>| root.map_or_else(|| "none".to_string(), |r| r.display().to_string());
|
||||
eprintln!("wordcraft-cli: files confined: read root {}, write root {}", show(roots.read_root()), show(roots.write_root()));
|
||||
let backend: Box<dyn wordcraft_mcp::Backend> = Box::new(headless_mcp(roots, arg_value(&rest, "--author").as_deref())?);
|
||||
let mut server = wordcraft_mcp::Server::new(backend);
|
||||
let stdin = std::io::stdin();
|
||||
// A client that closes our stdout has hung up: `serve` returns BrokenPipe and we end cleanly.
|
||||
Ok(server.serve(stdin.lock(), std::io::stdout())?)
|
||||
}
|
||||
"mcp" => run_mcp(&rest),
|
||||
"zotero" => {
|
||||
validate_options("zotero", &rest, ZOTERO_OPTIONS)?;
|
||||
let paths = positionals(&rest, ZOTERO_OPTIONS);
|
||||
@@ -825,6 +897,60 @@ fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
|
||||
}
|
||||
}
|
||||
|
||||
/// `wordcraft-cli mcp`: serves MCP on stdin and stdout, headless or through the open window.
|
||||
fn run_mcp(rest: &[String]) -> Result<(), Failure> {
|
||||
let (roots, mut rest) = automation_roots("mcp", rest)?;
|
||||
// Taken out before the option check, with or without a value, so it never reads as unknown.
|
||||
if take_connect(&mut rest) {
|
||||
eprintln!("{MCP_CONNECT_DEPRECATED}");
|
||||
}
|
||||
validate_options("mcp", &rest, MCP_OPTIONS)?;
|
||||
let when_closed = match (rest.iter().any(|a| a == "--when-closed"), arg_value(&rest, "--when-closed")) {
|
||||
(false, _) => None,
|
||||
(true, value) => {
|
||||
Some(value.as_deref().and_then(wordcraft_mcp::live::WhenAppClosed::parse).ok_or("mcp: --when-closed takes launch, headless or error")?)
|
||||
}
|
||||
};
|
||||
let author = mcp_author(&rest)?;
|
||||
let (flag, switch) = agents_state();
|
||||
let show = |root: Option<&std::path::Path>| root.map_or_else(|| "none".to_string(), |r| r.display().to_string());
|
||||
let backend: Box<dyn wordcraft_mcp::Backend> = match mcp_plan(roots, rest.iter().any(|a| a == "--headless"), flag, switch)? {
|
||||
McpPlan::Headless(roots) => {
|
||||
// Shared rule 18 (#7124): an agent entry point never runs unconfined. Every thread of this process,
|
||||
// not only the server's: nothing reaches past the roots.
|
||||
wordcraft_engine::file_access::confine_process(roots.clone());
|
||||
eprintln!("wordcraft-cli: files confined: read root {}, write root {}", show(roots.read_root()), show(roots.write_root()));
|
||||
Box::new(headless_mcp(roots, author.as_deref())?)
|
||||
}
|
||||
McpPlan::Live(roots) => {
|
||||
let mut config = wordcraft_mcp::LiveConfig::installed()
|
||||
.ok_or("mcp: can't find WordCraft's settings folder (no home folder; set WORDCRAFT_PROFILE_DIR)")?;
|
||||
if let Some(roots) = &roots {
|
||||
config.read_root = roots.read_root().map(std::path::Path::to_path_buf);
|
||||
config.write_root = roots.write_root().map(std::path::Path::to_path_buf);
|
||||
// Both roots given: every headless session works in them, so the whole process is confined to
|
||||
// them. Calls to the window run in the app, inside its agent folders.
|
||||
if config.read_root.is_some() && config.write_root.is_some() {
|
||||
wordcraft_engine::file_access::confine_process(roots.clone());
|
||||
}
|
||||
}
|
||||
config.when_closed = when_closed;
|
||||
config.author = author;
|
||||
config.launch = std::env::current_exe().ok().and_then(|exe| wordcraft_mcp::live::launcher(&exe));
|
||||
eprintln!(
|
||||
"wordcraft-cli: tool calls go to the open WordCraft window while AI agents are on in ArtCraft Launcher, otherwise to a headless session (read root {}, write root {}; none: WordCraft's agent folder)",
|
||||
show(config.read_root.as_deref()),
|
||||
show(config.write_root.as_deref())
|
||||
);
|
||||
Box::new(wordcraft_mcp::Live::new(config))
|
||||
}
|
||||
};
|
||||
let mut server = wordcraft_mcp::Server::new(backend);
|
||||
let stdin = std::io::stdin();
|
||||
// A client that closes our stdout has hung up: `serve` returns BrokenPipe and we end cleanly.
|
||||
Ok(server.serve(stdin.lock(), std::io::stdout())?)
|
||||
}
|
||||
|
||||
/// At most 400 characters of `s`, for traces.
|
||||
fn clip(s: &str) -> String {
|
||||
match s.char_indices().nth(400) {
|
||||
|
||||
@@ -38,7 +38,7 @@ fn validators_accept_only_the_documented_options() {
|
||||
assert!(validate_options("run", &args(&["--cmd", "text.insert={}", "--cmd", "edit.undo", "--print"]), RUN_OPTIONS).is_ok());
|
||||
assert!(validate_options("commands", &args(&["--json"]), COMMANDS_OPTIONS).is_ok());
|
||||
assert!(validate_options("parity", &args(&["--markdown"]), PARITY_OPTIONS).is_ok());
|
||||
assert!(validate_options("mcp", &args(&["--connect", "127.0.0.1:9000"]), MCP_OPTIONS).is_ok());
|
||||
assert!(validate_options("mcp", &args(&["--headless", "--when-closed", "launch"]), MCP_OPTIONS).is_ok());
|
||||
assert!(validate_options("render", &args(&["in.docx", "out.png", "--page"]), RENDER_OPTIONS).is_ok());
|
||||
assert!(
|
||||
validate_options(
|
||||
@@ -326,18 +326,32 @@ fn every_agent_entry_point_refuses_to_start_without_both_roots() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The desktop app doesn't confine its control channel to roots yet (#3695, #5819), so the bridge
|
||||
/// to it is refused, with roots or without, before anything connects.
|
||||
/// `mcp`'s plan never runs anything unconfined (shared rule 18): headless needs both roots, and
|
||||
/// with the suite's AI-MCP flag the live client runs without them only while the launcher's switch
|
||||
/// lets agents into the window, which confines them to its agent folder.
|
||||
#[test]
|
||||
fn mcp_connect_is_refused_until_the_app_confines_its_control_channel() {
|
||||
let dir = std::env::temp_dir().to_string_lossy().into_owned();
|
||||
for line in [
|
||||
args(&["mcp", "--connect", "127.0.0.1:9"]),
|
||||
args(&["mcp", "--connect", "127.0.0.1:9", "--author", "Claude"]),
|
||||
args(&["mcp", "--connect", "127.0.0.1:9", "--automation-read-root", &dir, "--automation-write-root", &dir]),
|
||||
] {
|
||||
let e = run(&line).unwrap_err().to_string();
|
||||
assert!(e.contains("--connect") && e.contains("#3695") && e.contains("#5819"), "{line:?}: {e}");
|
||||
fn mcp_never_plans_an_unconfined_session() {
|
||||
let scratch = Scratch::new("mcp-plan");
|
||||
let root = |read: bool, write: bool| {
|
||||
let (r, w) = (read.then_some(scratch.0.as_path()), write.then_some(scratch.0.as_path()));
|
||||
wordcraft_engine::file_access::AutomationRoots::new(r, w).unwrap()
|
||||
};
|
||||
let both = || root(true, true);
|
||||
// --headless, or no flag: both roots or nothing.
|
||||
for (headless, flag, switch) in [(true, true, true), (true, false, false), (false, false, true), (false, false, false)] {
|
||||
assert!(matches!(mcp_plan(both(), headless, flag, switch), Ok(McpPlan::Headless(_))));
|
||||
for partial in [None, root(true, false), root(false, true)] {
|
||||
assert_eq!(mcp_plan(partial, headless, flag, switch).unwrap_err(), MCP_NEEDS_ROOTS);
|
||||
}
|
||||
}
|
||||
// The flag and the switch: the window, with or without roots.
|
||||
for roots in [None, root(true, false), both()] {
|
||||
assert!(matches!(mcp_plan(roots, false, true, true), Ok(McpPlan::Live(_))));
|
||||
}
|
||||
// The flag without the switch: only with both roots, which confine its headless sessions.
|
||||
assert!(matches!(mcp_plan(both(), false, true, false), Ok(McpPlan::Live(Some(_)))));
|
||||
for partial in [None, root(true, false), root(false, true)] {
|
||||
assert_eq!(mcp_plan(partial, false, true, false).unwrap_err(), MCP_NEEDS_ROOTS_OR_AGENTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,19 +366,38 @@ fn mcp_headless_session_takes_the_author_flag() {
|
||||
assert_eq!(unnamed.session.author, wordcraft_mcp::Headless::default().session.author, "no flag keeps the default author");
|
||||
}
|
||||
|
||||
/// `--connect` is refused whether or not it has a value, written apart or as `--connect=…`, even with both roots valid.
|
||||
/// `mcp --author` without a name is refused, also when another option follows it, instead of
|
||||
/// starting with the default author or that option as the name.
|
||||
#[test]
|
||||
fn mcp_connect_is_refused_without_a_value_too() {
|
||||
let scratch = Scratch::new("connect-bare");
|
||||
let dir = scratch.0.to_string_lossy().into_owned();
|
||||
let roots = ["--automation-read-root", &dir, "--automation-write-root", &dir];
|
||||
for tail in [vec!["--connect"], vec!["--connect", "--author", "Claude"], vec!["--connect=127.0.0.1:9"], vec!["--connect="]] {
|
||||
let line = args(&[&["mcp"][..], &roots, &tail].concat());
|
||||
let e = run(&line).unwrap_err().to_string();
|
||||
assert!(e.contains("--connect") && e.contains("#3695") && e.contains("#5819"), "{line:?}: {e}");
|
||||
fn mcp_author_needs_a_name() {
|
||||
assert_eq!(mcp_author(&args(&["--headless", "--author", "Claude"])), Ok(Some("Claude".to_string())));
|
||||
assert_eq!(mcp_author(&args(&["--headless"])), Ok(None));
|
||||
for given in [vec!["--author"], vec!["--author", "--headless"], vec!["--author", "A", "--author", "B"]] {
|
||||
assert!(mcp_author(&args(&given)).is_err(), "{given:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The deprecated `--connect` is taken out with its value, whether it has one, written apart or as
|
||||
/// `--connect=…`, and leaves the other options as they were.
|
||||
#[test]
|
||||
fn mcp_connect_is_taken_out_with_its_value() {
|
||||
for (given, left) in [
|
||||
(vec!["--connect", "127.0.0.1:9", "--author", "Claude"], vec!["--author", "Claude"]),
|
||||
(vec!["--connect"], vec![]),
|
||||
(vec!["--connect", "--author", "Claude"], vec!["--author", "Claude"]),
|
||||
(vec!["--headless", "--connect=127.0.0.1:9"], vec!["--headless"]),
|
||||
(vec!["--connect=", "--connect", "x"], vec![]),
|
||||
] {
|
||||
let mut rest = args(&given);
|
||||
assert!(take_connect(&mut rest), "{given:?}");
|
||||
assert_eq!(rest, args(&left), "{given:?}");
|
||||
assert!(validate_options("mcp", &rest, MCP_OPTIONS).is_ok());
|
||||
}
|
||||
let mut rest = args(&["--author", "Claude"]);
|
||||
assert!(!take_connect(&mut rest));
|
||||
assert_eq!(rest, args(&["--author", "Claude"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_rejects_missing_or_invalid_page_and_scale() {
|
||||
// Missing operands
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
//! Shared rule 18 (#7124): `wordcraft-cli mcp` refuses to start without both
|
||||
//! `--automation-read-root` and `--automation-write-root`, refuses `--connect` while the desktop
|
||||
//! app doesn't confine its control channel (#3695, #5819), and with both roots refuses files
|
||||
//! outside them, through the real binary.
|
||||
//! `--automation-read-root` and `--automation-write-root` unless the ArtCraft Launcher's switch
|
||||
//! lets agents into WordCraft's window (which confines them to its agent folder), takes the
|
||||
//! deprecated `--connect` with a note, and with both roots refuses files outside them, through the
|
||||
//! real binary. Each run gets its own suite flags, launcher folder and settings folder, so this
|
||||
//! machine's own never count.
|
||||
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -48,11 +50,17 @@ fn s(p: &Path) -> String {
|
||||
p.to_string_lossy().into_owned()
|
||||
}
|
||||
|
||||
/// Run `wordcraft-cli mcp <args>`, send `lines` on stdin, then hang up.
|
||||
/// Run `wordcraft-cli mcp <args>` without the suite's AI-MCP flag, send `lines` on stdin, then hang up.
|
||||
fn mcp(args: &[String], lines: &[Value]) -> Output {
|
||||
mcp_with(args, lines, &[("CRAFT_FLAGS", "-AI-MCP".into())])
|
||||
}
|
||||
|
||||
/// [`mcp`] with these environment variables.
|
||||
fn mcp_with(args: &[String], lines: &[Value], env: &[(&str, std::ffi::OsString)]) -> Output {
|
||||
let mut child = Command::new(env!("CARGO_BIN_EXE_wordcraft-cli"))
|
||||
.arg("mcp")
|
||||
.args(args)
|
||||
.envs(env.iter().map(|(k, v)| (*k, v)))
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
@@ -99,17 +107,60 @@ fn mcp_refuses_to_start_without_both_roots() {
|
||||
assert!(reply.get("error").is_none(), "{reply}");
|
||||
}
|
||||
|
||||
/// `--connect` is kept for one release: it says it is deprecated and is otherwise ignored, so a
|
||||
/// client configuration that still has it keeps working, and it opens no way around the roots.
|
||||
#[test]
|
||||
fn mcp_connect_is_refused_until_the_app_confines_its_control_channel() {
|
||||
fn mcp_connect_is_a_deprecated_alias_of_plain_mcp() {
|
||||
let folders = Folders::new("connect");
|
||||
let base = folders.0.clone();
|
||||
let (read, write) = (s(&base.join("in")), s(&base.join("out")));
|
||||
let why = ["--connect", "#3695", "#5819"];
|
||||
refused_at_start(&["--connect".into(), "127.0.0.1:9".into()], &why);
|
||||
refused_at_start(
|
||||
let out = mcp(
|
||||
&["--connect".into(), "127.0.0.1:9".into(), "--automation-read-root".into(), read, "--automation-write-root".into(), write],
|
||||
&why,
|
||||
&[serde_json::from_str(PING).unwrap()],
|
||||
);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(out.status.success(), "stderr: {stderr}");
|
||||
assert!(stderr.contains("--connect is deprecated"), "{stderr}");
|
||||
let reply: Value = serde_json::from_slice(out.stdout.split(|b| *b == b'\n').next().unwrap()).unwrap();
|
||||
assert_eq!(reply["id"], 1, "{reply}");
|
||||
refused_at_start(&["--connect".into(), "127.0.0.1:9".into()], &["--connect is deprecated", "--automation-read-root"]);
|
||||
}
|
||||
|
||||
/// With the suite's AI-MCP flag: while the launcher's switch keeps agents out, `mcp` still needs
|
||||
/// both roots and says how to let agents in; once the launcher's list names WordCraft, plain `mcp`
|
||||
/// starts without roots and follows the closed-app choice (here: ask to open WordCraft).
|
||||
#[test]
|
||||
fn with_the_flag_the_launcher_switch_lets_plain_mcp_start() {
|
||||
let folders = Folders::new("switch");
|
||||
let base = folders.0.clone();
|
||||
let launcher = base.join("launcher");
|
||||
let settings = base.join("settings");
|
||||
std::fs::create_dir_all(&launcher).unwrap();
|
||||
std::fs::create_dir_all(&settings).unwrap();
|
||||
std::fs::write(settings.join("config.toml"), "schema_version = 1\n[integrations]\nwhenAppClosed = \"error\"\n").unwrap();
|
||||
let env = [
|
||||
("CRAFT_FLAGS", std::ffi::OsString::from("AI-MCP")),
|
||||
("CRAFT_MCP_DIR", launcher.clone().into_os_string()),
|
||||
("WORDCRAFT_PROFILE_DIR", settings.into_os_string()),
|
||||
];
|
||||
let ping: Value = serde_json::from_str(PING).unwrap();
|
||||
let off = mcp_with(&[], std::slice::from_ref(&ping), &env);
|
||||
let stderr = String::from_utf8_lossy(&off.stderr);
|
||||
assert!(!off.status.success() && off.stdout.is_empty(), "started with the switch off: {stderr}");
|
||||
assert!(stderr.contains("ArtCraft Launcher") && stderr.contains("--automation-read-root"), "{stderr}");
|
||||
|
||||
let cli = s(Path::new(env!("CARGO_BIN_EXE_wordcraft-cli")));
|
||||
let list = json!({"version": 1, "apps": [{"id": "wordcraft", "name": "WordCraft", "command": cli, "args": ["mcp"]}]});
|
||||
std::fs::write(launcher.join("apps.json"), list.to_string()).unwrap();
|
||||
let on = mcp_with(&[], &[ping, tool(2, "list_documents", json!({}))], &env);
|
||||
let stderr = String::from_utf8_lossy(&on.stderr);
|
||||
assert!(on.status.success(), "stderr: {stderr}");
|
||||
let replies: Vec<Value> =
|
||||
String::from_utf8_lossy(&on.stdout).lines().filter(|l| !l.trim().is_empty()).map(|l| serde_json::from_str(l).unwrap()).collect();
|
||||
assert!(replies.iter().any(|r| r["id"] == 1 && r.get("error").is_none()), "{replies:?}");
|
||||
let call = replies.iter().find(|r| r["id"] == 2).expect("the tool call is answered");
|
||||
assert_eq!(call["result"]["isError"], true, "{call}");
|
||||
assert!(call.to_string().contains("isn't running"), "the closed-app choice answers: {call}");
|
||||
}
|
||||
|
||||
/// `tools/call` request `id` for `name` with `arguments`.
|
||||
|
||||
@@ -36,6 +36,7 @@ craft = { workspace = true, features = [
|
||||
"ui-app",
|
||||
"dialogs",
|
||||
"automation",
|
||||
"automation-agents",
|
||||
"gpu-startup",
|
||||
"print",
|
||||
"settings",
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
//! A connection authenticates once with the token (`docs/control-protocol.md`, Token). When no
|
||||
//! token or token file is supplied, the app generates a token and writes it to
|
||||
//! `<settings>/control-key.<instance>` (mode 0600) after the port is bound, and removes the file
|
||||
//! when the window closes.
|
||||
//! when the window closes. The server itself goes to the agent link for the run
|
||||
//! (`AgentLink::from_launch`), so File › Options › Agents says the launch options manage it.
|
||||
|
||||
use std::net::TcpListener;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -25,11 +26,28 @@ pub struct Control {
|
||||
}
|
||||
|
||||
impl Control {
|
||||
/// The server, for the agent link to keep for the whole run (`AgentLink::from_launch`), and the
|
||||
/// token file this run wrote, which the app removes when the window closes.
|
||||
pub fn split(self) -> (Listening, TokenFile) {
|
||||
(self.listening, TokenFile(self.created))
|
||||
}
|
||||
|
||||
/// Stop accepting connections and remove the token file this run wrote, if any.
|
||||
#[cfg(test)]
|
||||
pub fn shut_down(self) {
|
||||
let Self { listening, created } = self;
|
||||
let (listening, file) = self.split();
|
||||
drop(listening);
|
||||
remove(created.as_deref());
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/// The default token file a run wrote, if any; a token file the user supplied is never removed.
|
||||
pub struct TokenFile(Option<PathBuf>);
|
||||
|
||||
impl TokenFile {
|
||||
/// Removes the file this run wrote.
|
||||
pub fn remove(self) {
|
||||
remove(self.0.as_deref());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+38
-10
@@ -67,8 +67,8 @@ struct App {
|
||||
settings: SharedSettings<Prefs>,
|
||||
/// The print spool, a handle on the one in the app's services: jobs being sent finish first.
|
||||
spool: Spool,
|
||||
/// The control server, when `--control` started one; it removes the token file it made.
|
||||
control: Option<control_server::Control>,
|
||||
/// The token file `--control` wrote, removed at exit; its server runs in the agent link.
|
||||
control: Option<control_server::TokenFile>,
|
||||
/// The app binary's last step as the app leaves, run once at the end of `finish` (a Nightly
|
||||
/// quit ends the process inside AppKit's terminate, after eframe's `on_exit`).
|
||||
exit: Option<Box<dyn FnOnce()>>,
|
||||
@@ -118,8 +118,8 @@ impl App {
|
||||
if let Err(e) = self.settings.lock().flush() {
|
||||
log::warn!("preferences: {e}");
|
||||
}
|
||||
if let Some(control) = self.control.take() {
|
||||
control.shut_down();
|
||||
if let Some(file) = self.control.take() {
|
||||
file.remove();
|
||||
}
|
||||
if !launch_profile::current().is_nightly() {
|
||||
self.app.start_pending_update();
|
||||
@@ -858,13 +858,41 @@ fn main() -> eframe::Result {
|
||||
log::warn!("local recovery unavailable: {e}");
|
||||
}
|
||||
}
|
||||
// Agents in the open window: while the ArtCraft Launcher's switch (Settings › AI agents)
|
||||
// names WordCraft, the agent link serves them and publishes where, so `wordcraft-cli mcp`
|
||||
// finds the window. `--control` runs its own server for the whole run instead. Allow
|
||||
// Agent Control off (File › Options › Agents) refuses both. A Nightly window serves none.
|
||||
let mut control_server = None;
|
||||
if !nightly
|
||||
&& let Some(port) = control.port
|
||||
&& let Some((rx, started)) = control_server::start(&control, port, WindowHost::of(&ctx), wordcraft_control_key::settings_dir().as_deref())
|
||||
{
|
||||
app = app.with_control(ControlChannel::new(rx));
|
||||
control_server = Some(started);
|
||||
if !nightly {
|
||||
let settings_dir = wordcraft_control_key::settings_dir();
|
||||
// A file a crashed launch left behind names a port nothing serves; before this
|
||||
// launch's own listener, so it doesn't keep it.
|
||||
if let Some(dir) = &settings_dir {
|
||||
craft::automation::agents::remove_stale_connection(dir);
|
||||
}
|
||||
let allow = settings.lock().get().integrations.allow_agent_control;
|
||||
let launched = match control.port {
|
||||
Some(port) if !allow => {
|
||||
complain(format_args!("File › Options › Agents › Allow Agent Control is off: not listening on port {port}"));
|
||||
None
|
||||
}
|
||||
Some(port) => control_server::start(&control, port, WindowHost::of(&ctx), settings_dir.as_deref()),
|
||||
None => None,
|
||||
};
|
||||
let link = match launched {
|
||||
Some((rx, started)) => {
|
||||
app = app.with_control(ControlChannel::new(rx));
|
||||
let (listening, token_file) = started.split();
|
||||
control_server = Some(token_file);
|
||||
craft::automation::agents::AgentLink::from_launch(listening)
|
||||
}
|
||||
None => craft::automation::agents::AgentLink::new(settings_dir, format!("WordCraft {}", env!("CARGO_PKG_VERSION"))),
|
||||
};
|
||||
let switch = craft::automation::agents::AgentSwitch::watch(wordcraft_ui_egui::agents::LAUNCHER_APP_ID, {
|
||||
let ctx = ctx.clone();
|
||||
move || ctx.request_repaint()
|
||||
});
|
||||
app = app.with_agents(wordcraft_ui_egui::agents::Agents::new(link, switch));
|
||||
}
|
||||
// Nothing to open (no files, no sample, no control channel driving the editor): start
|
||||
// on File › Home, as Word does (#766), unless the Start screen option is off. Files
|
||||
|
||||
@@ -76,6 +76,12 @@ impl AutomationRoots {
|
||||
Ok(Some(Arc::new(Self { read, write })))
|
||||
}
|
||||
|
||||
/// Roots that grant no access at all: what an agent gets when its folders can't be used, so it
|
||||
/// is refused rather than left unconfined.
|
||||
pub fn none() -> Arc<Self> {
|
||||
Arc::new(Self { read: None, write: None })
|
||||
}
|
||||
|
||||
/// The read root, absolute with its links followed.
|
||||
pub fn read_root(&self) -> Option<&Path> {
|
||||
self.read.as_ref().map(|r| r.shown.as_path())
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::{DocLayout, Page, Placed};
|
||||
|
||||
/// Caret geometry on a page: a bar from (`x`, `top`) to (`x + width`, `top + height`). It is
|
||||
/// upright (`width` 0) except in turned text (a table cell's text direction), where it lies
|
||||
/// across the page (`height` 0).
|
||||
/// across the page (`height` 0), and `turn` is the direction its line reads in.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Caret {
|
||||
pub page: usize,
|
||||
@@ -20,6 +20,7 @@ pub struct Caret {
|
||||
pub top: f32,
|
||||
pub height: f32,
|
||||
pub width: f32,
|
||||
pub turn: TextDirection,
|
||||
}
|
||||
|
||||
/// An equation as [`DocLayout::equation_box`] finds it, in page coordinates: its left edge
|
||||
@@ -757,7 +758,7 @@ impl DocLayout {
|
||||
let base = top + (l.baseline - l.top);
|
||||
let ctop = (base - asc).max(top);
|
||||
let r = crate::turn_rect(*turn, *x, *y, Rect::new(cx, ctop, 0.0, (base + desc - ctop).max(4.0)));
|
||||
return Some(Caret { page: pi, x: r.x, top: r.y, height: r.h, width: r.w });
|
||||
return Some(Caret { page: pi, x: r.x, top: r.y, height: r.h, width: r.w, turn: *turn });
|
||||
}
|
||||
None
|
||||
}
|
||||
@@ -765,18 +766,15 @@ impl DocLayout {
|
||||
/// The style run text typed at `pos` would take (the character's before it, or at the start
|
||||
/// of a paragraph the first character's) and the baseline it sits on, on the page: `pos`'s
|
||||
/// line's, raised or lowered by the run's shift (superscript, `w:position`). An input method's
|
||||
/// composition is drawn with them, as Word draws it in the text's own font and size. `None` in
|
||||
/// turned text, whose lines aren't horizontal.
|
||||
/// composition is drawn with them, as Word draws it in the text's own font and size. In turned
|
||||
/// text the baseline is meaningless (the lines aren't horizontal); use the run only.
|
||||
pub fn typing_style(&self, pos: &Pos, page_hint: usize) -> Option<(StyleRun, f32)> {
|
||||
for (_, it) in self.pieces(pos.story, &pos.path, page_hint) {
|
||||
let Placed::Lines { para, l0, l1, y, turn, .. } = it else { continue };
|
||||
let Placed::Lines { para, l0, l1, y, .. } = it else { continue };
|
||||
let li = para.line_of(pos.off);
|
||||
if li < *l0 || li >= *l1 {
|
||||
continue;
|
||||
}
|
||||
if *turn != TextDirection::Horizontal {
|
||||
return None;
|
||||
}
|
||||
let first = para.lines.get(*l0)?;
|
||||
let line = para.lines.get(li)?;
|
||||
let at = |off: usize| para.clusters.iter().find(|c| c.start <= off && off < c.end).and_then(|c| para.styles.get(c.style as usize));
|
||||
|
||||
@@ -28,6 +28,18 @@ pub struct RowLayout {
|
||||
pub edge: f32,
|
||||
/// The row's cells: the items each one owns and where its content ends.
|
||||
pub cells: Vec<CellPart>,
|
||||
/// What a vertical merge running over a page break adds to this row.
|
||||
pub merge: MergeEdges,
|
||||
}
|
||||
|
||||
/// Items of a row for vertical merges crossing a page break (#8872). Rows are laid out before
|
||||
/// they meet a page, so these are placed only when the row starts or ends one.
|
||||
#[derive(Default)]
|
||||
pub struct MergeEdges {
|
||||
/// When the row is the first on a page: the continuing merge's fill and top border.
|
||||
pub top: Vec<Placed>,
|
||||
/// When the row is the last on a page: the closing bottom border of a merge running on.
|
||||
pub end: Vec<Placed>,
|
||||
}
|
||||
|
||||
/// A cell of a [`RowLayout`].
|
||||
@@ -899,6 +911,16 @@ fn grow_vertical_merges(rows: &[Vec<CellBox>], heights: &mut [f32]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Remember the fill (or none) each restart cell gives its merge's continuation.
|
||||
fn note_restart_fills(merge_fill: &mut std::collections::HashMap<usize, Rgb>, cells: &[CellBox]) {
|
||||
for c in cells.iter().filter(|c| c.vmerge == VMerge::Restart) {
|
||||
match c.fill {
|
||||
Some(f) => merge_fill.insert(c.g, f),
|
||||
None => merge_fill.remove(&c.g),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
struct TableRows<'a> {
|
||||
story: StoryRef,
|
||||
table: &'a Table,
|
||||
@@ -938,13 +960,17 @@ fn finish_table_rows(ctx: &mut Ctx, input: TableRows<'_>) -> TableLayout {
|
||||
.collect();
|
||||
// Second pass: place cells with their row height, fills and borders.
|
||||
let mut out = Vec::with_capacity(rows.len());
|
||||
let mut merge_fill: std::collections::HashMap<usize, Rgb> = std::collections::HashMap::new();
|
||||
for (ri, cells) in rows.into_iter().enumerate() {
|
||||
if only.is_some_and(|(row, _)| row != ri) {
|
||||
// The restart fills of earlier rows still shade the continuation of a merge.
|
||||
note_restart_fills(&mut merge_fill, &cells);
|
||||
continue;
|
||||
}
|
||||
let rh = heights.get(ri).copied().unwrap_or(0.0);
|
||||
let exact = t.rows.get(ri).is_some_and(|r| r.props.height_rule == HeightRule::Exact && r.props.height.is_some_and(|h| h > 0.0));
|
||||
let mut items = Vec::new();
|
||||
let mut merge = MergeEdges::default();
|
||||
let mut parts = Vec::with_capacity(cells.len());
|
||||
for (ci, c) in cells.into_iter().enumerate() {
|
||||
let first = items.len();
|
||||
@@ -1049,6 +1075,29 @@ fn finish_table_rows(ctx: &mut Ctx, input: TableRows<'_>) -> TableLayout {
|
||||
if last_of_merge && let Some(e) = b.bottom.filter(Border::is_visible) {
|
||||
items.push(Placed::Rule { x0: hx0, y0: y1, x1: hx1, y1, border: e });
|
||||
}
|
||||
if c.vmerge == VMerge::Restart {
|
||||
match c.fill {
|
||||
Some(f) => merge_fill.insert(c.g, f),
|
||||
None => merge_fill.remove(&c.g),
|
||||
};
|
||||
}
|
||||
if !last_of_merge && let Some(e) = b.bottom.filter(Border::is_visible) {
|
||||
merge.end.push(Placed::Rule { x0: hx0, y0: y1, x1: hx1, y1, border: e });
|
||||
}
|
||||
if c.vmerge == VMerge::Continue {
|
||||
let mut left = rh;
|
||||
let mut k = ri + 1;
|
||||
while cont.get(k).is_some_and(|v| v.contains(&c.g)) {
|
||||
left += heights.get(k).copied().unwrap_or(0.0);
|
||||
k += 1;
|
||||
}
|
||||
if let Some(color) = merge_fill.get(&c.g) {
|
||||
merge.top.push(Placed::Fill { rect: Rect::new(c.x, 0.0, c.w, left), color: *color });
|
||||
}
|
||||
if let Some(e) = b.top.filter(Border::is_visible) {
|
||||
merge.top.push(Placed::Rule { x0: hx0, y0, x1: hx1, y1: y0, border: e });
|
||||
}
|
||||
}
|
||||
if let Some(e) = b.left.filter(Border::is_visible) {
|
||||
items.push(Placed::Rule { x0, y0, x1: x0, y1, border: e });
|
||||
}
|
||||
@@ -1075,6 +1124,7 @@ fn finish_table_rows(ctx: &mut Ctx, input: TableRows<'_>) -> TableLayout {
|
||||
bottom: bottoms.get(ri).copied().unwrap_or(0.0),
|
||||
edge: edges.get(ri).copied().unwrap_or(0.0),
|
||||
cells: parts,
|
||||
merge,
|
||||
});
|
||||
}
|
||||
TableLayout { x, width: total, rows: out }
|
||||
@@ -1374,11 +1424,52 @@ fn split_row_with(row: &RowLayout, cut: f32, whole_cells: bool) -> Option<(RowLa
|
||||
}
|
||||
// The part left on the page is placed and never split again.
|
||||
Some((
|
||||
RowLayout { height: cut, items: a, bottom: row.bottom, edge: 0.0, cells: Vec::new() },
|
||||
RowLayout { height, items: b, bottom: row.bottom, edge: row.edge, cells: parts },
|
||||
RowLayout {
|
||||
height: cut,
|
||||
items: a,
|
||||
bottom: row.bottom,
|
||||
edge: 0.0,
|
||||
cells: Vec::new(),
|
||||
merge: MergeEdges { top: row.merge.top.clone(), end: at_y(&row.merge.end, cut) },
|
||||
},
|
||||
RowLayout {
|
||||
height,
|
||||
items: b,
|
||||
bottom: row.bottom,
|
||||
edge: row.edge,
|
||||
cells: parts,
|
||||
merge: MergeEdges { top: shorter(&row.merge.top, row.height - height), end: at_y(&row.merge.end, height) },
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
/// Horizontal rules of a merge's edge moved to `y`.
|
||||
fn at_y(items: &[Placed], y: f32) -> Vec<Placed> {
|
||||
items
|
||||
.iter()
|
||||
.map(
|
||||
|it| {
|
||||
if let Placed::Rule { x0, x1, border, .. } = it {
|
||||
Placed::Rule { x0: *x0, y0: y, x1: *x1, y1: y, border: *border }
|
||||
} else {
|
||||
it.clone()
|
||||
}
|
||||
},
|
||||
)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The fills of a merge's top edge for a continuation `by` points shorter than its row.
|
||||
fn shorter(items: &[Placed], by: f32) -> Vec<Placed> {
|
||||
items
|
||||
.iter()
|
||||
.map(|it| match it {
|
||||
Placed::Fill { rect, color } => Placed::Fill { rect: Rect::new(rect.x, rect.y, rect.w, (rect.h - by).max(0.0)), color: *color },
|
||||
other => other.clone(),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
type CellItems<'a> = Vec<std::borrow::Cow<'a, [Placed]>>;
|
||||
|
||||
/// The items of each cell of a row being split, with each cell's content end, and the cells
|
||||
|
||||
@@ -247,18 +247,70 @@ pub(crate) fn place_table(ctx: &mut Ctx, pb: &mut PageBuilder, t: &wordcraft_doc
|
||||
}
|
||||
}
|
||||
let repeated_height: f32 = header_rows.iter().filter_map(|i| tl.rows.get(*i)).map(|r| r.height).sum();
|
||||
let place = |pb: &mut PageBuilder, row: &table::RowLayout| {
|
||||
// The page of the last body row placed, and the closing borders of its merges that run on
|
||||
// (drawn if the next row starts a new page).
|
||||
let last_page = std::cell::Cell::new((0u32, usize::MAX));
|
||||
// Where the items of this table's rows on the page and column start; none before a row is placed.
|
||||
let page_from = std::cell::Cell::new(None::<usize>);
|
||||
let pending_end: std::cell::RefCell<Vec<Placed>> = std::cell::RefCell::new(Vec::new());
|
||||
let place = |pb: &mut PageBuilder, row: &table::RowLayout, body: bool| {
|
||||
let (x, y) = (pb.col_x() + tl.x, pb.y);
|
||||
let limit = pb.bottom.max(y + row.height);
|
||||
// A merged cell runs over the pages of its rows: on each its area is the rows there.
|
||||
let starts_page = body && last_page.get() != (pb.number, pb.col);
|
||||
if body {
|
||||
last_page.set((pb.number, pb.col));
|
||||
*pending_end.borrow_mut() = row
|
||||
.merge
|
||||
.end
|
||||
.iter()
|
||||
.map(|it| {
|
||||
let mut it = it.clone();
|
||||
it.translate(x, y);
|
||||
it
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
if let Some(pg) = pb.page() {
|
||||
for it in &row.items {
|
||||
if starts_page {
|
||||
page_from.set(Some(pg.items.len()));
|
||||
}
|
||||
// The continuing fill goes under the row's items (their borders), its top rules over them.
|
||||
let top = if starts_page { row.merge.top.as_slice() } else { &[] };
|
||||
let (fills, rules) = (top.iter().filter(|i| matches!(i, Placed::Fill { .. })), top.iter().filter(|i| !matches!(i, Placed::Fill { .. })));
|
||||
for it in fills.chain(&row.items).chain(rules) {
|
||||
let mut it = it.clone();
|
||||
it.translate(x, y);
|
||||
// The area ends at this page's bottom, #8872.
|
||||
if let Placed::Fill { rect, .. } | Placed::Clip { rect, .. } | Placed::Cell { rect, .. } = &mut it
|
||||
&& rect.bottom() > limit
|
||||
{
|
||||
rect.h = (limit - rect.y).max(0.0);
|
||||
}
|
||||
pg.items.push(it);
|
||||
}
|
||||
}
|
||||
pb.y += row.height;
|
||||
pb.content_bottom = pb.content_bottom.max(pb.y);
|
||||
};
|
||||
// The page ends here: close the merges running on to the next one.
|
||||
let close_merges = |pb: &mut PageBuilder| {
|
||||
let end = std::mem::take(&mut *pending_end.borrow_mut());
|
||||
let bottom = pb.y;
|
||||
if let Some(pg) = pb.page() {
|
||||
// The merged cells' areas end with the last row on the page.
|
||||
for it in pg.items.iter_mut().skip(page_from.get().unwrap_or(usize::MAX)) {
|
||||
if let Placed::Fill { rect, .. } | Placed::Clip { rect, .. } | Placed::Cell { rect, .. } = it
|
||||
&& rect.y < bottom
|
||||
&& rect.bottom() > bottom
|
||||
{
|
||||
rect.h = bottom - rect.y;
|
||||
}
|
||||
}
|
||||
pg.items.extend(end);
|
||||
}
|
||||
page_from.set(None);
|
||||
};
|
||||
// Measured in Word: an at-least row's minimum height is reserved, not split. Where less room
|
||||
// than that is left on a page that already holds something, the row starts the next page
|
||||
// whole; a row taller than a page then splits from the top of that page.
|
||||
@@ -350,7 +402,7 @@ pub(crate) fn place_table(ctx: &mut Ctx, pb: &mut PageBuilder, t: &wordcraft_doc
|
||||
};
|
||||
match split {
|
||||
Some((a, b)) => {
|
||||
place(pb, &a);
|
||||
place(pb, &a, true);
|
||||
table_notes(ctx, pb, &a.items);
|
||||
rest = Some(b);
|
||||
}
|
||||
@@ -359,18 +411,19 @@ pub(crate) fn place_table(ctx: &mut Ctx, pb: &mut PageBuilder, t: &wordcraft_doc
|
||||
None if pb.at_top() || fresh => break,
|
||||
None => {}
|
||||
}
|
||||
close_merges(pb);
|
||||
pb.advance(block, body_top);
|
||||
// Repeat header rows, up to the layout's cap.
|
||||
if ri >= header_rows.len() && ctx.header_repeats.saturating_add(header_cost) <= header_cap {
|
||||
ctx.header_repeats = ctx.header_repeats.saturating_add(header_cost);
|
||||
for h in header_rows.iter().filter_map(|hr| tl.rows.get(*hr)) {
|
||||
place(pb, h);
|
||||
place(pb, h, false);
|
||||
}
|
||||
}
|
||||
fresh = true;
|
||||
}
|
||||
let last = rest.as_ref().or(aligned.as_ref()).unwrap_or(row);
|
||||
place(pb, last);
|
||||
place(pb, last, true);
|
||||
table_notes(ctx, pb, &last.items);
|
||||
}
|
||||
// Its own space below (ODT).
|
||||
|
||||
@@ -3407,6 +3407,59 @@ fn a_vertical_merge_lays_out_as_one_cell() {
|
||||
assert_eq!((hit.2, hit.3), (0, 0));
|
||||
}
|
||||
|
||||
/// #8872: a merge running over a page break ends at the page's bottom; the rest is the
|
||||
/// continuation rows' own.
|
||||
#[test]
|
||||
fn a_vertical_merge_across_a_page_break_stays_inside_the_page() {
|
||||
crate::test_fonts();
|
||||
use wordcraft_doc::props::{HeightRule, VMerge};
|
||||
let mut d = Document::new();
|
||||
let mut t = Table::new(40, 2, 468.0);
|
||||
for (i, row) in t.rows.iter_mut().enumerate() {
|
||||
row.props.height = Some(40.0);
|
||||
row.props.height_rule = HeightRule::Exact;
|
||||
row.cells[0].props.vmerge = match i {
|
||||
14 => VMerge::Restart,
|
||||
15..=18 => VMerge::Continue,
|
||||
_ => VMerge::None,
|
||||
};
|
||||
}
|
||||
t.rows[14].cells[0].props.shading = Some(wordcraft_doc::props::Rgb(200, 0, 0));
|
||||
let line = Some(wordcraft_doc::props::Border::single(1.0));
|
||||
t.props.borders = Some(wordcraft_doc::props::Borders { top: line, left: line, bottom: line, right: line, between: line, inside_v: line });
|
||||
d.insert_block(StoryRef::Body, &Path::top(0), wordcraft_doc::Block::Table(t)).unwrap();
|
||||
let l = lay(&d);
|
||||
let body = l.pages[0].body;
|
||||
// The merge closes at the end of its first page, and goes on with its fill on the next.
|
||||
let mut cell0 = None;
|
||||
let mut closes = false;
|
||||
for item in &l.pages[0].items {
|
||||
match item {
|
||||
Placed::Cell { rect, row: 14, cell: 0, .. } => cell0 = Some(*rect),
|
||||
Placed::Rule { x0, x1, y0, y1, .. } if y0 == y1 => {
|
||||
closes |= cell0.is_some_and(|r| *x0 <= r.x + 1.0 && *x1 >= r.x + r.w - 1.0 && *y0 >= r.bottom() - 0.01)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
assert!(closes, "a border closes the merged cell on its first page");
|
||||
let next = l.pages[1].items.iter().find_map(|i| match i {
|
||||
Placed::Fill { rect, .. } if rect.x < cell0.unwrap().x + 1.0 => Some(*rect),
|
||||
_ => None,
|
||||
});
|
||||
assert!(next.is_some_and(|r| r.y <= l.pages[1].body.y + 0.01 && r.h > 40.0), "the fill goes on at the top of the next page: {next:?}");
|
||||
let mut spanning = false;
|
||||
for item in &l.pages[0].items {
|
||||
if let Placed::Cell { rect, row: 14, cell: 0, .. } = item {
|
||||
spanning = rect.h > 40.0 * 1.5;
|
||||
}
|
||||
if let Placed::Cell { rect, .. } | Placed::Fill { rect, .. } = item {
|
||||
assert!(rect.bottom() <= body.bottom() + 0.01, "{rect:?} past the page's content area {body:?}");
|
||||
}
|
||||
}
|
||||
assert!(spanning, "the merge still spans the rows left on the page");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_vertical_merge_aligns_its_text_with_the_first_page() {
|
||||
crate::test_fonts();
|
||||
@@ -6472,6 +6525,7 @@ fn split_row_rejects_a_hostile_cut() {
|
||||
items: vec![line(0.0), line(150.0)],
|
||||
bottom,
|
||||
cells: vec![CellPart { top: 2.0, items: 0..2, end: Some(170.0), align: None }],
|
||||
merge: Default::default(),
|
||||
};
|
||||
for cut in [f32::NAN, f32::INFINITY, f32::NEG_INFINITY, 0.0, -1.0, 200.0] {
|
||||
assert!(split_row(&row(200.0, 4.0), cut).is_none(), "{cut}");
|
||||
@@ -11977,6 +12031,7 @@ fn a_split_row_moves_shading_below_the_cut_with_it() {
|
||||
items: vec![line_row(0.0), line_row(150.0), fill(0.0, 200.0), fill(150.0, 50.0)],
|
||||
bottom: 0.0,
|
||||
cells: vec![CellPart { top: 2.0, items: 0..4, end: None, align: None }],
|
||||
merge: Default::default(),
|
||||
};
|
||||
let (a, b) = split_row(&row, 100.0).expect("splits");
|
||||
let fills = |r: &RowLayout| {
|
||||
@@ -16302,6 +16357,7 @@ fn split_cell_moves_image_frame() {
|
||||
edge: 0.0,
|
||||
items: vec![kept, image, frame],
|
||||
cells: vec![CellPart { top, items: 0..3, end: Some(170.0), align: None }],
|
||||
merge: Default::default(),
|
||||
};
|
||||
let (first, rest) = split_row(&row, 100.0).unwrap();
|
||||
assert_eq!(first.items.len(), 1);
|
||||
|
||||
@@ -20,4 +20,7 @@ log = { workspace = true }
|
||||
# lookup, which do not build for wasm32.
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
wordcraft-control-key = { workspace = true }
|
||||
craft = { workspace = true, features = ["automation"] }
|
||||
# The control channel's client, and agents in the open window (`live`): the shared live client,
|
||||
# the agent folders and the app's saved agent settings, read as its settings store reads them.
|
||||
craft = { workspace = true, features = ["automation", "automation-agents", "control", "settings"] }
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -16,4 +16,9 @@ pub trait Backend {
|
||||
fn has_ui(&self) -> bool;
|
||||
/// Short human description ("headless", "connected to 127.0.0.1:7981").
|
||||
fn describe(&self) -> String;
|
||||
/// The `agent_folders` tool's answer: `read_folder` and `write_folder`, each a path or `null`
|
||||
/// (`craft::control::agents::folders_answer`).
|
||||
fn agent_folders(&mut self) -> Result<Value, String> {
|
||||
Err("this session has no agent folders".into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,9 @@ pub struct Remote {
|
||||
/// The connection leads to the app's 127.0.0.1: the control token may be sent.
|
||||
send_key: bool,
|
||||
find_token: TokenFinder,
|
||||
/// Sign in with the challenge handshake: the app proves it holds the token before anything
|
||||
/// derived from it is sent ([`Remote::window`]).
|
||||
challenge: bool,
|
||||
}
|
||||
|
||||
impl Remote {
|
||||
@@ -145,7 +148,7 @@ impl Remote {
|
||||
}
|
||||
|
||||
fn connect_with(addr: &str, find_token: TokenFinder) -> std::io::Result<Self> {
|
||||
let mut r = Self { addr: addr.to_string(), client: None, connected: false, send_key: false, find_token };
|
||||
let mut r = Self { addr: addr.to_string(), client: None, connected: false, send_key: false, find_token, challenge: false };
|
||||
r.reconnect().map_err(|c| std::io::Error::other(r.connect_error(c, false)))?;
|
||||
if let Some(w) = r.key_warning() {
|
||||
log::warn!("{w}");
|
||||
@@ -156,7 +159,16 @@ impl Remote {
|
||||
/// A remote that connects on first use: the app may start after the MCP server, and a
|
||||
/// server that exits at once reads as failed for the client's whole session (#4078).
|
||||
pub fn lazy(addr: &str) -> Self {
|
||||
Self { addr: addr.to_string(), client: None, connected: false, send_key: false, find_token: Box::new(find_token) }
|
||||
Self { addr: addr.to_string(), client: None, connected: false, send_key: false, find_token: Box::new(find_token), challenge: false }
|
||||
}
|
||||
|
||||
/// The open window the agent link published (`craft::automation::agents::Window`): its
|
||||
/// loopback address and the token from its token file. It connects on first use and signs in
|
||||
/// with the challenge handshake, so a program that took the port of an app that quit learns
|
||||
/// nothing derived from the token.
|
||||
pub fn window(addr: &str, token: String) -> Self {
|
||||
let find_token: TokenFinder = Box::new(move |_| Ok(Token { value: token.clone(), from_file: false }));
|
||||
Self { addr: addr.to_string(), client: None, connected: false, send_key: false, find_token, challenge: true }
|
||||
}
|
||||
|
||||
/// The address the app is reached at, as given.
|
||||
@@ -205,7 +217,9 @@ impl Remote {
|
||||
let mut refused_before = false;
|
||||
loop {
|
||||
let token = (self.find_token)(&self.addr)?;
|
||||
match ControlClient::connect(sa, &token.value) {
|
||||
let signed_in =
|
||||
if self.challenge { ControlClient::connect_challenged(sa, &token.value) } else { ControlClient::connect(sa, &token.value) };
|
||||
match signed_in {
|
||||
Ok(client) => return Ok(client),
|
||||
Err(ConnectError::Refused(_)) if token.from_file && !refused_before => refused_before = true,
|
||||
Err(ConnectError::Refused(e)) => return Err(Connect::Refused(e)),
|
||||
|
||||
+21
-5
@@ -1,17 +1,22 @@
|
||||
//! WordCraft's MCP server (Model Context Protocol, JSON-RPC 2.0 over stdio).
|
||||
//!
|
||||
//! Two backends: [`Headless`] runs an in-process editing session (no window); [`backend::Remote`]
|
||||
//! talks to a running WordCraft app through its control channel (`wordcraft --control PORT`), so
|
||||
//! agents can also click, type and screenshot the real UI.
|
||||
//! Two backends: [`Headless`] runs an in-process editing session (no window); [`Live`] sends each
|
||||
//! tool call to the open WordCraft window while the ArtCraft Launcher's switch lets agents use it
|
||||
//! (through [`backend::Remote`], the app's control channel), so agents can also click, type and
|
||||
//! screenshot the real UI, and otherwise to a headless session.
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
pub mod backend;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub mod live;
|
||||
pub mod server;
|
||||
pub mod tools;
|
||||
|
||||
pub use backend::Backend;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use backend::Remote;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use live::{Live, LiveConfig};
|
||||
pub use server::Server;
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -21,8 +26,7 @@ use wordcraft_engine::Session;
|
||||
use wordcraft_engine::file_access::{self, AutomationRoots};
|
||||
|
||||
/// Methods that need the desktop app.
|
||||
pub const NEEDS_APP: &str =
|
||||
"needs the desktop app; `wordcraft-cli mcp --connect` is refused until the app confines its control channel to automation roots (#3695)";
|
||||
pub const NEEDS_APP: &str = "needs the open WordCraft window: turn on AI agents in ArtCraft Launcher › Settings › AI agents, open WordCraft, and use plain `wordcraft-cli mcp` (without --headless)";
|
||||
|
||||
/// An in-process session.
|
||||
pub struct Headless {
|
||||
@@ -38,6 +42,11 @@ impl Headless {
|
||||
self
|
||||
}
|
||||
|
||||
/// The folders the session's commands are confined to, if any.
|
||||
pub fn automation_roots(&self) -> Option<&Arc<AutomationRoots>> {
|
||||
self.roots.as_ref()
|
||||
}
|
||||
|
||||
/// Answer `method`; a document method addressed to another open document (`doc`) runs on
|
||||
/// that document, and the active one stays active.
|
||||
fn answer(&mut self, method: &str, mut params: Value) -> Result<Value, String> {
|
||||
@@ -111,6 +120,13 @@ impl Backend for Headless {
|
||||
fn describe(&self) -> String {
|
||||
"headless session (no window)".into()
|
||||
}
|
||||
fn agent_folders(&mut self) -> Result<Value, String> {
|
||||
let shown = |p: Option<&std::path::Path>| p.map(|p| p.to_string_lossy().into_owned());
|
||||
let roots = self.roots.as_deref();
|
||||
Ok(
|
||||
json!({"read_folder": shown(roots.and_then(AutomationRoots::read_root)), "write_folder": shown(roots.and_then(AutomationRoots::write_root))}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
//! Plain `wordcraft-cli mcp`: each tool call goes to the open WordCraft window while the person
|
||||
//! lets agents use it (the ArtCraft Launcher's switch), found through the connection file its
|
||||
//! agent link publishes, and otherwise to a session without a window. The file is read again
|
||||
//! before every call, so the app may start, quit or move to another port while the MCP client
|
||||
//! stays connected, and the client's configuration holds no port and no token.
|
||||
//!
|
||||
//! While agents may use the app but it is closed, the closed-app choice of File › Options › Agents
|
||||
//! (or `--when-closed`) decides: start WordCraft and wait for it, work without a window in the
|
||||
//! agent folders, or answer with an error that asks to open it. A session that went headless stays
|
||||
//! headless, so documents don't move under the agent.
|
||||
//!
|
||||
//! The lookup is the framework's, shared by every Craft app (`craft::automation::agents::Live`);
|
||||
//! this module supplies WordCraft's parts: its saved agent settings, its window client
|
||||
//! ([`Remote::window`], with the challenge handshake) and its headless session ([`Headless`],
|
||||
//! always confined to folders).
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex, PoisonError};
|
||||
use std::time::Duration;
|
||||
|
||||
use craft::automation::agents::{self, AgentSettings, Consent, HeadlessFolders, LaunchFn, Route, Window};
|
||||
use craft::settings::{Location, OpenOptions, Settings, SettingsStore};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use wordcraft_engine::file_access::AutomationRoots;
|
||||
|
||||
use crate::Headless;
|
||||
use crate::backend::{Backend, Remote};
|
||||
|
||||
pub use craft::automation::agents::WhenAppClosed;
|
||||
|
||||
/// The id the ArtCraft Launcher's app list names WordCraft by (its catalog id).
|
||||
pub const LAUNCHER_APP_ID: &str = "wordcraft";
|
||||
/// The app's name in messages and in its default agent folder.
|
||||
pub const APP_NAME: &str = "WordCraft";
|
||||
/// The desktop app's file name beside the CLI (without `.exe`).
|
||||
const APP_EXE: &str = "wordcraft";
|
||||
|
||||
/// The part of the app's saved settings `mcp` reads: File › Options › Agents, the `integrations`
|
||||
/// section of `config.toml`, read as the app's settings store reads it.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
struct AgentPrefs {
|
||||
integrations: AgentSettings,
|
||||
}
|
||||
|
||||
impl Settings for AgentPrefs {
|
||||
const APP_ID: &'static str = "wordcraft";
|
||||
const SCHEMA_VERSION: u32 = 1;
|
||||
}
|
||||
|
||||
/// The agent settings saved in the settings folder `dir`; the defaults when nothing is saved or
|
||||
/// the file can't be read (a value that doesn't fit resets only itself, as in the app). The CLI
|
||||
/// never fails over the app's settings.
|
||||
pub fn read_agent_settings(dir: &Path) -> AgentSettings {
|
||||
SettingsStore::<AgentPrefs>::read(&OpenOptions::new(Location::Dir(dir.to_path_buf()))).0.integrations
|
||||
}
|
||||
|
||||
/// The suite's `AI-MCP` flag (`ArtCraft/flags.toml` or `CRAFT_FLAGS`): without it the launcher's
|
||||
/// switch means nothing and `mcp` is headless, as before the switch.
|
||||
pub fn mcp_flag() -> bool {
|
||||
agents::mcp_flag()
|
||||
}
|
||||
|
||||
/// Whether the person lets agents use the open window now: the suite's `AI-MCP` flag and the
|
||||
/// launcher's switch. WordCraft had no consent of its own before the switch.
|
||||
pub fn agents_allowed_now() -> bool {
|
||||
agents::agents_allowed(agents::mcp_flag(), agents::launcher_allows(LAUNCHER_APP_ID), false)
|
||||
}
|
||||
|
||||
/// What `mcp` needs to find the window, and to work without one.
|
||||
pub struct LiveConfig {
|
||||
/// The app's settings folder: connection file, token file and settings.
|
||||
pub config_dir: PathBuf,
|
||||
/// Overrides the closed-app choice (`--when-closed`).
|
||||
pub when_closed: Option<WhenAppClosed>,
|
||||
/// The folders a headless session uses (`--automation-read-root`, `--automation-write-root`);
|
||||
/// while agents may use the app they replace its agent folders.
|
||||
pub read_root: Option<PathBuf>,
|
||||
pub write_root: Option<PathBuf>,
|
||||
/// The author of a headless session's tracked changes and comments (`--author`).
|
||||
pub author: Option<String>,
|
||||
/// Starts the app; `None` when this install can't ([`launcher`]).
|
||||
pub launch: Option<LaunchFn>,
|
||||
pub launch_timeout: Duration,
|
||||
/// Whether the person lets agents use the app now ([`agents_allowed_now`]); tests replace it.
|
||||
pub allowed: fn() -> bool,
|
||||
/// The folder agents use when the person chose none: `Documents/ArtCraft/Agents/WordCraft`;
|
||||
/// tests replace it.
|
||||
pub default_folder: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl LiveConfig {
|
||||
/// The app with its settings in `config_dir`, as it is installed.
|
||||
pub fn new(config_dir: PathBuf) -> Self {
|
||||
Self {
|
||||
config_dir,
|
||||
when_closed: None,
|
||||
read_root: None,
|
||||
write_root: None,
|
||||
author: None,
|
||||
launch: None,
|
||||
launch_timeout: agents::LAUNCH_TIMEOUT,
|
||||
allowed: agents_allowed_now,
|
||||
default_folder: craft::control::agents::default_folder(APP_NAME),
|
||||
}
|
||||
}
|
||||
|
||||
/// [`Self::new`] for the app's own settings folder (`WORDCRAFT_PROFILE_DIR`, otherwise the
|
||||
/// platform's); `None` without one (no home folder).
|
||||
pub fn installed() -> Option<Self> {
|
||||
wordcraft_control_key::settings_dir().map(Self::new)
|
||||
}
|
||||
}
|
||||
|
||||
type Shared = agents::Live<Arc<Mutex<Remote>>, Arc<Mutex<Headless>>>;
|
||||
|
||||
/// The backend of plain `mcp`; see the module docs.
|
||||
pub struct Live {
|
||||
shared: Shared,
|
||||
config_dir: PathBuf,
|
||||
default_folder: Option<PathBuf>,
|
||||
/// What `agent_folders` needs to tell where the next call will work before any call ran.
|
||||
when_closed: Option<WhenAppClosed>,
|
||||
read_root: Option<PathBuf>,
|
||||
write_root: Option<PathBuf>,
|
||||
allowed: fn() -> bool,
|
||||
}
|
||||
|
||||
/// A headless session confined to `folders`: never one without folders (rule 18).
|
||||
fn headless(folders: &HeadlessFolders, author: Option<&str>) -> Result<Arc<Mutex<Headless>>, String> {
|
||||
let read = folders.read.first().map(PathBuf::as_path);
|
||||
let roots = AutomationRoots::new(read, folders.write.as_deref())?.ok_or_else(|| {
|
||||
format!(
|
||||
"no folders to work in: give --automation-read-root DIR and --automation-write-root DIR, or turn on AI agents in ArtCraft Launcher › Settings › AI agents to use {APP_NAME}'s agent folder"
|
||||
)
|
||||
})?;
|
||||
let mut session = Headless::default().with_automation_roots(Some(roots));
|
||||
if let Some(name) = author {
|
||||
session.session.run("file.setAuthor", &serde_json::json!({"name": name})).map_err(|e| format!("--author: {e}"))?;
|
||||
}
|
||||
Ok(Arc::new(Mutex::new(session)))
|
||||
}
|
||||
|
||||
impl Live {
|
||||
pub fn new(cfg: LiveConfig) -> Self {
|
||||
let LiveConfig { config_dir, when_closed, read_root, write_root, author, launch, launch_timeout, allowed, default_folder } = cfg;
|
||||
let consent = move |dir: &Path| Consent::new(allowed(), read_agent_settings(dir));
|
||||
let connect = |w: &Window| Ok(Arc::new(Mutex::new(Remote::window(&w.addr(), w.token.clone()))));
|
||||
let make_headless = move |folders: &HeadlessFolders| headless(folders, author.as_deref());
|
||||
let mut shared = agents::LiveConfig::new(APP_NAME, config_dir.clone(), consent, connect, make_headless);
|
||||
shared.when_closed = when_closed;
|
||||
shared.read_roots = read_root.clone().into_iter().collect();
|
||||
shared.write_root = write_root.clone();
|
||||
shared.launch = launch;
|
||||
shared.launch_timeout = launch_timeout;
|
||||
shared.default_folder = default_folder.clone();
|
||||
Self { shared: agents::Live::new(shared), config_dir, default_folder, when_closed, read_root, write_root, allowed }
|
||||
}
|
||||
}
|
||||
|
||||
impl Backend for Live {
|
||||
fn call(&mut self, method: &str, params: Value) -> Result<Value, String> {
|
||||
match self.shared.resolve()? {
|
||||
Route::Window(window) => window.lock().unwrap_or_else(PoisonError::into_inner).call(method, params),
|
||||
Route::Headless(session) => session.lock().unwrap_or_else(PoisonError::into_inner).call(method, params),
|
||||
}
|
||||
}
|
||||
|
||||
fn has_ui(&self) -> bool {
|
||||
matches!(self.shared.current(), Some(Route::Window(_)))
|
||||
}
|
||||
|
||||
fn describe(&self) -> String {
|
||||
match self.shared.current() {
|
||||
Some(Route::Window(window)) => window.lock().unwrap_or_else(PoisonError::into_inner).describe(),
|
||||
Some(Route::Headless(_)) => "headless session (no window)".into(),
|
||||
None => {
|
||||
format!("the open {APP_NAME} window while AI agents are on in ArtCraft Launcher › Settings › AI agents, otherwise a headless session")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A headless session's own folders; the window's when calls go to it: its saved agent folders,
|
||||
/// the default agent folder for an empty one, as the app's agent link opens them. Before the
|
||||
/// first call, the folders the next call will work in, found as `Live` would without starting
|
||||
/// anything: the window's while one accepts agents or the app would be opened or asked for,
|
||||
/// otherwise those of the headless session it would make (the folders given to `mcp` win).
|
||||
fn agent_folders(&mut self) -> Result<Value, String> {
|
||||
let answer = |folders: &craft::control::agents::AgentFolders| Ok(craft::control::agents::folders_answer(folders));
|
||||
match self.shared.current() {
|
||||
Some(Route::Headless(session)) => return session.lock().unwrap_or_else(PoisonError::into_inner).agent_folders(),
|
||||
Some(Route::Window(_)) => return answer(&read_agent_settings(&self.config_dir).folders_with(self.default_folder.as_deref())),
|
||||
None => {}
|
||||
}
|
||||
let settings = read_agent_settings(&self.config_dir);
|
||||
let window = matches!(agents::find_window(&self.config_dir, APP_NAME), Ok(Some(_)));
|
||||
let allowed = (self.allowed)() && settings.allow_agent_control;
|
||||
let headless = !window && (!allowed || self.when_closed.unwrap_or(settings.when_app_closed) == WhenAppClosed::Headless);
|
||||
if !headless {
|
||||
return answer(&settings.folders_with(self.default_folder.as_deref()));
|
||||
}
|
||||
let (read, write) = (self.read_root.clone(), self.write_root.clone());
|
||||
if !allowed {
|
||||
let mut folders = craft::control::agents::AgentFolders::default();
|
||||
(folders.read, folders.write) = (read, write);
|
||||
return answer(&folders);
|
||||
}
|
||||
// Only looked up (and the default made) when the command leaves a direction open, as `Live` does.
|
||||
let mut folders = if read.is_some() && write.is_some() { Default::default() } else { settings.folders_with(self.default_folder.as_deref()) };
|
||||
folders.read = read.or(folders.read);
|
||||
folders.write = write.or(folders.write);
|
||||
answer(&folders)
|
||||
}
|
||||
}
|
||||
|
||||
/// How to start the desktop app that ships beside the CLI at `cli` (detached, with no standard
|
||||
/// streams: the CLI's carry the MCP protocol, and the app must outlive the MCP client).
|
||||
pub fn launcher(cli: &Path) -> Option<LaunchFn> {
|
||||
agents::launcher(cli, APP_EXE)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "live/tests.rs"]
|
||||
mod tests;
|
||||
@@ -0,0 +1,206 @@
|
||||
//! Plain `wordcraft-cli mcp` (`live.rs`): calls reach the open window through its connection file
|
||||
//! with the challenge handshake, and otherwise run headless, never unconfined. The lookup itself
|
||||
//! (closed-app choice, launch, stale files) has its own tests in craft-control.
|
||||
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
||||
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::net::TcpListener;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc;
|
||||
use std::time::Duration;
|
||||
|
||||
use craft::automation::agents::{Connection, TOKEN_FILE, write_connection};
|
||||
use craft::automation::security::{AuthStep, CHALLENGE_METHOD, ServerHandshake};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::*;
|
||||
|
||||
const TOKEN: &str = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
|
||||
|
||||
/// A fresh folder, removed when dropped.
|
||||
struct Folder(PathBuf);
|
||||
|
||||
impl Folder {
|
||||
fn new(tag: &str) -> Self {
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
static N: AtomicUsize = AtomicUsize::new(0);
|
||||
let dir = std::env::temp_dir().join(format!("wordcraft-live-{tag}-{}-{}", std::process::id(), N.fetch_add(1, Ordering::Relaxed)));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
Self(dir)
|
||||
}
|
||||
|
||||
fn sub(&self, name: &str) -> PathBuf {
|
||||
let dir = self.0.join(name);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
dir
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Folder {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
/// A config for the settings folder `dir`, the person letting agents in or not, an agent folder in
|
||||
/// `dir`, and nothing to start.
|
||||
fn config(dir: &Folder, allowed: fn() -> bool) -> LiveConfig {
|
||||
let mut cfg = LiveConfig::new(dir.sub("settings"));
|
||||
cfg.allowed = allowed;
|
||||
cfg.default_folder = Some(dir.0.join("Agents").join("WordCraft"));
|
||||
cfg.when_closed = Some(WhenAppClosed::Error);
|
||||
cfg
|
||||
}
|
||||
|
||||
/// The window's control server as the app's agent link runs it: the shared handshake with `TOKEN`
|
||||
/// on loopback, its connection file in `settings` and the token in an owner-only file. Answers
|
||||
/// every request with its method; sends the first frame of each connection on `first`.
|
||||
fn serve_window(settings: &std::path::Path) -> mpsc::Receiver<Value> {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
let token_file = settings.join(TOKEN_FILE);
|
||||
std::fs::write(&token_file, TOKEN).unwrap();
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
std::fs::set_permissions(&token_file, std::fs::Permissions::from_mode(0o600)).unwrap();
|
||||
}
|
||||
write_connection(settings, &Connection::new(port, token_file, "WordCraft test")).unwrap();
|
||||
let (first, frames) = mpsc::channel();
|
||||
std::thread::spawn(move || {
|
||||
for stream in listener.incoming() {
|
||||
let Ok(stream) = stream else { return };
|
||||
let first = first.clone();
|
||||
std::thread::spawn(move || {
|
||||
let mut reader = BufReader::new(stream.try_clone().unwrap());
|
||||
let mut out = stream;
|
||||
let mut handshake = ServerHandshake::new();
|
||||
let mut authenticated = false;
|
||||
let mut line = String::new();
|
||||
while reader.read_line(&mut line).is_ok_and(|n| n > 0) {
|
||||
let request: Value = serde_json::from_str(&line).unwrap_or(Value::Null);
|
||||
let reply = if authenticated {
|
||||
json!({"id": request["id"], "ok": true, "result": {"window": request["method"]}})
|
||||
} else {
|
||||
if request["id"] == json!(0) || request["method"] == "auth" && request["id"] == json!(1) {
|
||||
let _ = first.send(request.clone());
|
||||
}
|
||||
let (reply, step) = handshake.reply(&line, TOKEN);
|
||||
authenticated = step == AuthStep::Authenticated;
|
||||
if step == AuthStep::Rejected {
|
||||
let _ = out.write_all(format!("{reply}\n").as_bytes());
|
||||
return;
|
||||
}
|
||||
reply
|
||||
};
|
||||
let _ = out.write_all(format!("{reply}\n").as_bytes());
|
||||
line.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
frames
|
||||
}
|
||||
|
||||
/// While agents may use the app and its window publishes a connection, calls go to the window,
|
||||
/// signed in with the challenge handshake: the token never crosses the wire.
|
||||
#[test]
|
||||
fn a_call_reaches_the_open_window_with_the_challenge_handshake() {
|
||||
let dir = Folder::new("window");
|
||||
let cfg = config(&dir, || true);
|
||||
let frames = serve_window(&cfg.config_dir);
|
||||
let mut live = Live::new(cfg);
|
||||
let reply = live.call("document.inspect", json!({})).unwrap();
|
||||
assert_eq!(reply["window"], "document.inspect");
|
||||
assert!(live.has_ui());
|
||||
let challenge = frames.recv_timeout(Duration::from_secs(10)).unwrap();
|
||||
assert_eq!(challenge["method"], CHALLENGE_METHOD, "the first frame is the challenge");
|
||||
let proof = frames.recv_timeout(Duration::from_secs(10)).unwrap();
|
||||
assert!(proof["params"].get("token").is_none() && !proof.to_string().contains(TOKEN), "{proof}");
|
||||
}
|
||||
|
||||
/// Without the launcher's switch (the app then publishes no window) a call runs headless in the
|
||||
/// folders given to the command; with no folders at all it is refused rather than run unconfined.
|
||||
#[test]
|
||||
fn without_the_switch_calls_run_headless_and_never_unconfined() {
|
||||
let dir = Folder::new("off");
|
||||
let mut live = Live::new(config(&dir, || false));
|
||||
let refused = live.call("document.inspect", json!({})).unwrap_err();
|
||||
assert!(refused.contains("--automation-read-root"), "{refused}");
|
||||
|
||||
let work = dir.sub("work");
|
||||
let mut cfg = config(&dir, || false);
|
||||
cfg.read_root = Some(work.clone());
|
||||
cfg.write_root = Some(work.clone());
|
||||
let mut live = Live::new(cfg);
|
||||
assert!(live.call("document.inspect", json!({})).is_ok());
|
||||
assert!(!live.has_ui(), "headless, not the window");
|
||||
let outside = dir.0.join("outside.docx");
|
||||
assert!(live.call("engine.execute", json!({"command": "file.save", "params": {"path": outside}})).is_err());
|
||||
assert!(!outside.exists());
|
||||
let folders = live.agent_folders().unwrap();
|
||||
assert!(folders["write_folder"].as_str().is_some_and(|f| f.ends_with("work")), "{folders}");
|
||||
}
|
||||
|
||||
/// With agents allowed and the app closed, "work without a window" uses the agent folder: files go
|
||||
/// there and nowhere else.
|
||||
#[test]
|
||||
fn a_closed_app_works_without_a_window_in_the_agent_folder() {
|
||||
let dir = Folder::new("closed");
|
||||
let mut cfg = config(&dir, || true);
|
||||
cfg.when_closed = Some(WhenAppClosed::Headless);
|
||||
let agent_folder = cfg.default_folder.clone().unwrap();
|
||||
let mut live = Live::new(cfg);
|
||||
let inside = agent_folder.join("made.docx");
|
||||
live.call("engine.execute", json!({"command": "file.save", "params": {"path": inside}})).unwrap();
|
||||
assert!(inside.is_file());
|
||||
let outside = dir.0.join("outside.docx");
|
||||
assert!(live.call("engine.execute", json!({"command": "file.save", "params": {"path": outside}})).is_err());
|
||||
assert!(!outside.exists());
|
||||
}
|
||||
|
||||
/// The agent settings come from the app's `config.toml` as its store reads them: a value that
|
||||
/// doesn't fit resets only itself, and a missing or broken file gives the defaults.
|
||||
#[test]
|
||||
fn the_agent_settings_come_from_the_apps_config_file() {
|
||||
let dir = Folder::new("prefs");
|
||||
let settings = dir.sub("settings");
|
||||
assert_eq!(read_agent_settings(&settings), AgentSettings::default());
|
||||
std::fs::write(settings.join("config.toml"), "not toml [").unwrap();
|
||||
assert_eq!(read_agent_settings(&settings), AgentSettings::default());
|
||||
std::fs::write(
|
||||
settings.join("config.toml"),
|
||||
"schema_version = 1\ntab = \"home\"\n[integrations]\nwhenAppClosed = \"headless\"\nreadRoot = \"/in\"\ncontrolPort = \"x\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
let read = read_agent_settings(&settings);
|
||||
assert_eq!(read.when_app_closed, WhenAppClosed::Headless);
|
||||
assert_eq!(read.read_folder(), Some(PathBuf::from("/in")));
|
||||
assert_eq!(read.control_port, AgentSettings::default().control_port, "the bad port alone takes its default");
|
||||
|
||||
// The window's folders, as `agent_folders` reports them before any call: the saved ones, the
|
||||
// default agent folder for an empty one.
|
||||
let mut live = Live::new(config(&dir, || true));
|
||||
let folders = live.agent_folders().unwrap();
|
||||
assert_eq!(folders["read_folder"], json!("/in"));
|
||||
assert!(folders["write_folder"].as_str().is_some_and(|f| f.ends_with("WordCraft")), "{folders}");
|
||||
}
|
||||
|
||||
/// Before the first call, `agent_folders` names the folders the next call will work in: with the
|
||||
/// app closed and "work without a window", the folders given to `mcp` win over the agent folder.
|
||||
#[test]
|
||||
fn agent_folders_before_the_first_call_follow_the_given_roots() {
|
||||
let dir = Folder::new("folders-first");
|
||||
let work = dir.sub("work");
|
||||
let mut cfg = config(&dir, || true);
|
||||
cfg.when_closed = Some(WhenAppClosed::Headless);
|
||||
cfg.read_root = Some(work.clone());
|
||||
cfg.write_root = Some(work.clone());
|
||||
let mut live = Live::new(cfg);
|
||||
let before = live.agent_folders().unwrap();
|
||||
live.call("document.inspect", json!({})).unwrap();
|
||||
let after = live.agent_folders().unwrap();
|
||||
assert!(before["write_folder"].as_str().is_some_and(|f| f.ends_with("work")), "{before}");
|
||||
assert!(after["write_folder"].as_str().is_some_and(|f| f.ends_with("work")), "{after}");
|
||||
}
|
||||
@@ -406,11 +406,12 @@ fn every_documented_call_passes_the_argument_check() {
|
||||
("click", json!({"x": 1, "y": 2, "count": 2, "button": "right", "shift": true, "alt": true, "cmd": true, "ctrl": true, "command": true})),
|
||||
("key", json!({"key": "B", "shift": true, "alt": true, "cmd": true, "ctrl": true, "command": true})),
|
||||
("ui_inspect", json!({})),
|
||||
("agent_folders", json!({})),
|
||||
] {
|
||||
assert_eq!(check_arguments(defs, name, &args), Ok(()), "{name}");
|
||||
}
|
||||
// Every tool is covered above.
|
||||
assert_eq!(defs.len(), 18);
|
||||
assert_eq!(defs.len(), 19);
|
||||
}
|
||||
|
||||
/// Hostile and random input never panics or breaks the stream: every reply is one JSON line.
|
||||
|
||||
+40
-2
@@ -4,9 +4,10 @@ use serde_json::{Value, json};
|
||||
|
||||
use crate::backend::Backend;
|
||||
|
||||
/// An image tool result from a reply carrying base64 PNG in `png`.
|
||||
/// An image tool result from a reply carrying base64 PNG in `png` (the engine's renders) or
|
||||
/// `base64` (the window's `ui.screenshot`, the framework's capture reply).
|
||||
fn png_result(v: &Value, info: &Value) -> ToolResult {
|
||||
match v.get("png").and_then(Value::as_str) {
|
||||
match v.get("png").or_else(|| v.get("base64")).and_then(Value::as_str) {
|
||||
Some(png) if !png.is_empty() => ToolResult::image(png.to_string(), info),
|
||||
_ => ToolResult::error("the reply carried no picture"),
|
||||
}
|
||||
@@ -64,6 +65,21 @@ fn tool(name: &str, title: &str, desc: &str, schema: Value, ro: bool) -> Value {
|
||||
|
||||
/// Every MCP tool with its title, description, input schema and annotations (`tools/list`).
|
||||
pub fn tool_definitions() -> Value {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
return listed_tools();
|
||||
// Where agents put and find files: the suite's tool, the same in every Craft app.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
use craft::control::agents::{FOLDERS_TOOL, FOLDERS_TOOL_DESCRIPTION};
|
||||
let mut tools = listed_tools();
|
||||
if let Some(list) = tools.as_array_mut() {
|
||||
list.push(tool(FOLDERS_TOOL, "Agent folders", FOLDERS_TOOL_DESCRIPTION, obj(json!({}), &[]), true));
|
||||
}
|
||||
tools
|
||||
}
|
||||
}
|
||||
|
||||
fn listed_tools() -> Value {
|
||||
json!([
|
||||
tool(
|
||||
"list_commands",
|
||||
@@ -349,6 +365,7 @@ pub fn call_tool(b: &mut dyn Backend, name: &str, a: &Value) -> ToolResult {
|
||||
"click" => wrap(b.call("ui.click", a.clone())),
|
||||
"key" => wrap(b.call("ui.key", a.clone())),
|
||||
"ui_inspect" => wrap(b.call("ui.inspect", json!({}))),
|
||||
"agent_folders" => wrap(b.agent_folders()),
|
||||
other => ToolResult::error(format!("unknown tool `{other}`")),
|
||||
}
|
||||
}
|
||||
@@ -416,6 +433,27 @@ mod tests {
|
||||
assert!(b.seen.take().expect("called").1.get("doc").is_none());
|
||||
}
|
||||
|
||||
/// The window's screenshot reply carries the picture as `base64`; the tool returns it as an image.
|
||||
#[test]
|
||||
fn a_window_screenshot_reply_is_an_image() {
|
||||
struct Window;
|
||||
impl Backend for Window {
|
||||
fn call(&mut self, _: &str, _: Value) -> Result<Value, String> {
|
||||
Ok(json!({"base64": "iVBORw0KGgo=", "mime": "image/png", "width": 2, "height": 1}))
|
||||
}
|
||||
fn has_ui(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn describe(&self) -> String {
|
||||
"window".into()
|
||||
}
|
||||
}
|
||||
let r = call_tool(&mut Window, "screenshot", &json!({}));
|
||||
assert!(!r.is_error, "{r:?}");
|
||||
assert_eq!(r.content[0]["type"], "image");
|
||||
assert_eq!(r.content[0]["data"], "iVBORw0KGgo=");
|
||||
}
|
||||
|
||||
/// The password has to be in the schema, or a client has no way to know it can be sent.
|
||||
#[test]
|
||||
fn the_schema_advertises_the_password_as_optional() {
|
||||
|
||||
@@ -12,12 +12,12 @@ workspace = true
|
||||
# The craft libraries through their one facade (`craft::ui`, `craft::i18n`, `craft::window`, `craft::update`, ...),
|
||||
# at the workspace's one craft-libs pin.
|
||||
craft = { workspace = true, features = [
|
||||
"ui", "automation", "codepage", "keymap", "platform", "quit", "settings",
|
||||
"ui", "automation", "automation-agents", "codepage", "keymap", "platform", "quit", "settings",
|
||||
"color", "color-ui", "control", "draw", "font-manager", "gpu", "menu", "pages", "print", "review", "table", "text",
|
||||
"text-find", "web-api", "web-host", "window",
|
||||
] }
|
||||
craft-html = { workspace = true }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
|
||||
wordcraft-geom = { workspace = true, features = ["image"] }
|
||||
wordcraft-doc = { workspace = true }
|
||||
wordcraft-fonts = { workspace = true }
|
||||
@@ -77,7 +77,7 @@ craft-ui-test-kit = { workspace = true }
|
||||
craft = { workspace = true, features = ["ui-testing"] }
|
||||
|
||||
[build-dependencies]
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", features = ["subset"] }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", features = ["subset"] }
|
||||
serde_json = { workspace = true }
|
||||
toml = "1"
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
//! Agents in the open window, as in every Craft app: while the ArtCraft Launcher's switch
|
||||
//! (Settings › AI agents › Let AI agents use Craft apps) names WordCraft, the agent link serves the
|
||||
//! control channel on loopback with a token and publishes where in the settings folder, so
|
||||
//! `wordcraft-cli mcp` finds the window by itself. Turning the switch off stops it, with no
|
||||
//! restart. The link, the switch and the Agents page are the framework's
|
||||
//! (`craft::automation::agents`, `craft::automation::ui::agents`); WordCraft supplies the folders
|
||||
//! agent requests are confined to ([`Agents::roots`]) and the settings they come from
|
||||
//! ([`crate::prefs::Prefs::integrations`]), which only the person changes, in File › Options ›
|
||||
//! Agents.
|
||||
//!
|
||||
//! What agents do in the window reads and writes only inside those folders
|
||||
//! (`wordcraft_engine::file_access`): their requests, the screenshots they save, and the frames
|
||||
//! that play the input they send (a Ctrl+S an agent sends must not save outside them). The
|
||||
//! person's own work in the window is not confined. A server the launch options started
|
||||
//! (`--control`) is not the agent link's and stays as it was.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::automation::agents::{AgentLink, AgentLinkStatus, AgentSettings, AgentSwitch, LinkProblem};
|
||||
use craft::automation::control::ControlChannel;
|
||||
use craft::automation::ui::agents::AgentsPage;
|
||||
use craft::ui::patterns::preferences::SettingsDraft;
|
||||
use craft::ui::runtime::windows::WindowHost;
|
||||
use wordcraft_engine::file_access::AutomationRoots;
|
||||
|
||||
use crate::{WordApp, i18n};
|
||||
|
||||
/// The id the ArtCraft Launcher's app list names WordCraft by (its catalog id).
|
||||
pub const LAUNCHER_APP_ID: &str = "wordcraft";
|
||||
/// WordCraft's name in its default agent folder, `Documents/ArtCraft/Agents/WordCraft`.
|
||||
pub const AGENT_APP_NAME: &str = "WordCraft";
|
||||
/// The settings section and Options page the agent settings live in.
|
||||
pub const PAGE: &str = "integrations";
|
||||
|
||||
/// The agent link, the launcher's switch and the folders agent requests are confined to.
|
||||
pub struct Agents {
|
||||
link: AgentLink,
|
||||
switch: AgentSwitch,
|
||||
/// The folder agents use when the person chose none ([`craft::control::agents::default_folder`]).
|
||||
default_folder: Option<PathBuf>,
|
||||
/// While the agent link serves: what its requests may read and write. Never `None` then.
|
||||
roots: Option<Arc<AutomationRoots>>,
|
||||
}
|
||||
|
||||
impl Agents {
|
||||
/// Agents through `link` while `switch` lets them in. A link the launch options started
|
||||
/// (`AgentLink::from_launch`) keeps serving whatever the switch says.
|
||||
pub fn new(link: AgentLink, switch: AgentSwitch) -> Self {
|
||||
Self { link, switch, default_folder: craft::control::agents::default_folder(AGENT_APP_NAME), roots: None }
|
||||
}
|
||||
|
||||
/// `folder` replaces the default agent folder, so a test doesn't touch the person's Documents.
|
||||
#[doc(hidden)]
|
||||
#[must_use]
|
||||
pub fn with_default_folder(mut self, folder: Option<PathBuf>) -> Self {
|
||||
self.default_folder = folder;
|
||||
self
|
||||
}
|
||||
|
||||
/// Where the link stands: its port, whether the launch options run it, what went wrong.
|
||||
pub fn status(&self) -> &AgentLinkStatus {
|
||||
self.link.status()
|
||||
}
|
||||
|
||||
/// The launcher's switch.
|
||||
pub fn switch(&self) -> &AgentSwitch {
|
||||
&self.switch
|
||||
}
|
||||
|
||||
/// What the agent link's requests may read and write, while it serves.
|
||||
pub fn roots(&self) -> Option<&Arc<AutomationRoots>> {
|
||||
self.roots.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
/// The roots for agents with `settings`: their folders, the default agent folder for an empty one
|
||||
/// ([`AgentSettings::folders_with`]). Folders that can't be used grant nothing, with the reason,
|
||||
/// so agents are refused rather than left unconfined.
|
||||
fn roots_for(settings: &AgentSettings, default: Option<&Path>) -> (Arc<AutomationRoots>, Option<String>) {
|
||||
let folders = settings.folders_with(default);
|
||||
match AutomationRoots::new(folders.read.as_deref(), folders.write.as_deref()) {
|
||||
Ok(Some(roots)) => (roots, None),
|
||||
Ok(None) => (AutomationRoots::none(), Some(tl!("Agents can't open or save files: there is no agent folder. Choose one below.").to_string())),
|
||||
Err(error) => (AutomationRoots::none(), Some(i18n::fmt(tl!("Agents can't open or save files: {error}"), &[("error", &error)]))),
|
||||
}
|
||||
}
|
||||
|
||||
impl WordApp {
|
||||
/// Lets agents into this window through `agents` ([`crate::agents`]).
|
||||
#[must_use]
|
||||
pub fn with_agents(mut self, agents: Agents) -> Self {
|
||||
self.agents = Some(agents);
|
||||
self
|
||||
}
|
||||
|
||||
/// Brings the agent link in line with the launcher's switch and the agent settings: it starts,
|
||||
/// moves or stops its control server, and does nothing while neither changed. WordCraft had no
|
||||
/// consent of its own before the switch, so without the suite's `AI-MCP` flag agents stay out
|
||||
/// (only `--control` serves then).
|
||||
pub(crate) fn sync_agents(&mut self, ctx: &egui::Context) {
|
||||
let Some(agents) = self.agents.as_mut() else { return };
|
||||
let allowed = agents.switch.allows(false);
|
||||
let update = agents.link.sync(allowed.then_some(&self.ui.integrations), &WindowHost::of(ctx));
|
||||
if update.stopped {
|
||||
self.control = None;
|
||||
}
|
||||
if let Some(requests) = update.requests {
|
||||
self.control = Some(ControlChannel::new(requests));
|
||||
}
|
||||
if !update.changed {
|
||||
return;
|
||||
}
|
||||
agents.roots = None;
|
||||
if agents.link.status().port.is_some() && !agents.link.status().launch_flags {
|
||||
let (roots, problem) = roots_for(&self.ui.integrations, agents.default_folder.as_deref());
|
||||
agents.roots = Some(roots);
|
||||
if let Some(problem) = problem {
|
||||
agents.link.note(LinkProblem::App(problem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What the agent link's requests may read and write; `None` without the link (the launch
|
||||
/// options' server is not confined).
|
||||
pub(crate) fn agent_roots(&self) -> Option<Arc<AutomationRoots>> {
|
||||
self.agents.as_ref().and_then(|agents| agents.roots.clone())
|
||||
}
|
||||
|
||||
/// The roots for this frame: the agent link's while the frame plays input it sent. A click or a
|
||||
/// key from the channel acts for the agent, not the person; a click of the person's in the same
|
||||
/// frame is confined too, which errs the safe way.
|
||||
pub(crate) fn frame_roots(&self, ctx: &egui::Context) -> Option<Arc<AutomationRoots>> {
|
||||
self.agent_roots().filter(|_| !WindowHost::of(ctx).injected_idle())
|
||||
}
|
||||
|
||||
/// The link's state for `ui.inspect`: `port`, `launchFlags`, `error`, the suite's `AI-MCP` flag
|
||||
/// (`mcpFlag`) and the launcher's switch (`launcher`).
|
||||
pub(crate) fn agent_link_json(&self) -> serde_json::Value {
|
||||
let Some(agents) = &self.agents else { return serde_json::Value::Null };
|
||||
let mut v = serde_json::json!(agents.link.status());
|
||||
if let Some(m) = v.as_object_mut() {
|
||||
m.insert("mcpFlag".into(), agents.switch.mcp_flag().into());
|
||||
m.insert("launcher".into(), agents.switch.launcher().into());
|
||||
}
|
||||
v
|
||||
}
|
||||
}
|
||||
|
||||
/// File › Options › Agents: the framework's Agents page over the agent settings. A change applies
|
||||
/// at once, as every other Options row does, and the agent link follows on the next frame. The
|
||||
/// page writes the settings directly, not through a command: agents must not widen their own
|
||||
/// folders.
|
||||
pub(crate) fn page(app: &mut WordApp, ui: &mut egui::Ui) -> bool {
|
||||
let status = app.agents.as_ref().map(|agents| agents.link.status().clone()).unwrap_or_default();
|
||||
let mcp_flag = app.agents.as_ref().is_some_and(|agents| agents.switch.mcp_flag());
|
||||
let mut draft = SettingsDraft::default();
|
||||
if draft.replace(&serde_json::json!({ PAGE: app.ui.integrations })).is_err() {
|
||||
return false;
|
||||
}
|
||||
let out = AgentsPage::new(PAGE, &mut draft, &status).mcp_flag(mcp_flag).show(ui);
|
||||
if !out.changed {
|
||||
return false;
|
||||
}
|
||||
match draft.get::<AgentSettings>(PAGE) {
|
||||
Some(settings) => {
|
||||
app.ui.integrations = settings;
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "agents/tests.rs"]
|
||||
mod tests;
|
||||
@@ -0,0 +1,172 @@
|
||||
//! Agents in the open window (`agents.rs`): the agent link follows the launcher's switch, and what
|
||||
//! agents do reads and writes only inside their folders. The link, the switch and the Agents page
|
||||
//! have their own tests in craft-automation.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
use craft::automation::agents::{AgentLink, AgentSwitch, CONNECTION_FILE, find_window};
|
||||
use craft::automation::client::ControlClient;
|
||||
use craft::automation::control::{ControlRequest, Reply};
|
||||
use serde_json::json;
|
||||
|
||||
use super::Agents;
|
||||
use crate::{Services, WordApp, control};
|
||||
|
||||
/// A fresh folder, removed when dropped.
|
||||
struct Folder(PathBuf);
|
||||
|
||||
impl Folder {
|
||||
fn new(tag: &str) -> Self {
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
static N: AtomicUsize = AtomicUsize::new(0);
|
||||
let dir = std::env::temp_dir().join(format!("wordcraft-agents-{tag}-{}-{}", std::process::id(), N.fetch_add(1, Ordering::Relaxed)));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
Self(dir)
|
||||
}
|
||||
|
||||
fn settings(&self) -> PathBuf {
|
||||
self.0.join("settings")
|
||||
}
|
||||
|
||||
fn agent_folder(&self) -> PathBuf {
|
||||
self.0.join("Agents").join("WordCraft")
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Folder {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
/// An app whose agent link keeps its files in `dir`'s settings folder and whose default agent
|
||||
/// folder is in `dir`, with `switch` as the launcher's switch.
|
||||
fn linked(dir: &Folder, switch: AgentSwitch) -> WordApp {
|
||||
let link = AgentLink::new(Some(dir.settings()), "WordCraft test");
|
||||
let agents = Agents::new(link, switch).with_default_folder(Some(dir.agent_folder()));
|
||||
let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Services::default()).with_agents(agents);
|
||||
app.fonts_frames = 2;
|
||||
app
|
||||
}
|
||||
|
||||
fn port(app: &WordApp) -> Option<u16> {
|
||||
app.agents.as_ref().and_then(|agents| agents.status().port)
|
||||
}
|
||||
|
||||
fn set_switch(app: &mut WordApp, switch: AgentSwitch) {
|
||||
if let Some(agents) = app.agents.as_mut() {
|
||||
agents.switch = switch;
|
||||
}
|
||||
}
|
||||
|
||||
/// With the AI-MCP flag the launcher's switch alone starts the agent link and publishes where it
|
||||
/// listens; turning it off there stops it and removes the file, with no restart.
|
||||
#[test]
|
||||
fn the_launcher_switch_starts_and_stops_the_agent_link() {
|
||||
let dir = Folder::new("switch");
|
||||
let ctx = crate::test_harness::context();
|
||||
let mut app = linked(&dir, AgentSwitch::fixed(true, false));
|
||||
app.sync_agents(&ctx);
|
||||
assert!(port(&app).is_none() && app.control.is_none(), "off in the launcher: nothing listens");
|
||||
assert!(!dir.settings().join(CONNECTION_FILE).exists());
|
||||
|
||||
set_switch(&mut app, AgentSwitch::fixed(true, true));
|
||||
app.sync_agents(&ctx);
|
||||
let on = port(&app);
|
||||
assert!(on.is_some() && app.control.is_some(), "on in the launcher: the link serves");
|
||||
assert!(dir.settings().join(CONNECTION_FILE).is_file(), "and says where");
|
||||
let roots = app.agent_roots().expect("agent requests are confined");
|
||||
assert!(roots.write_root().is_some_and(|root| root.ends_with("WordCraft")), "to the agent folder");
|
||||
app.sync_agents(&ctx);
|
||||
assert_eq!(port(&app), on, "no change, no restart");
|
||||
assert_eq!(app.agent_link_json()["port"], json!(on));
|
||||
|
||||
set_switch(&mut app, AgentSwitch::fixed(true, false));
|
||||
app.sync_agents(&ctx);
|
||||
assert!(port(&app).is_none() && app.control.is_none() && app.agent_roots().is_none(), "off again: it stops");
|
||||
assert!(!dir.settings().join(CONNECTION_FILE).exists(), "and the file goes");
|
||||
}
|
||||
|
||||
/// Without the AI-MCP flag the launcher's list means nothing, and WordCraft had no consent of its
|
||||
/// own before the switch: agents stay out.
|
||||
#[test]
|
||||
fn without_the_flag_agents_stay_out() {
|
||||
let dir = Folder::new("flag");
|
||||
let ctx = crate::test_harness::context();
|
||||
let mut app = linked(&dir, AgentSwitch::fixed(false, true));
|
||||
app.sync_agents(&ctx);
|
||||
assert!(port(&app).is_none() && app.control.is_none());
|
||||
}
|
||||
|
||||
/// End to end over the agent link's port, token file and challenge handshake: an agent's save goes
|
||||
/// into the agent folder and is refused outside it.
|
||||
#[test]
|
||||
fn an_agent_saves_inside_its_folder_and_is_refused_outside() {
|
||||
let dir = Folder::new("save");
|
||||
let ctx = crate::test_harness::context();
|
||||
let mut app = linked(&dir, AgentSwitch::fixed(true, true));
|
||||
app.sync_agents(&ctx);
|
||||
let window = find_window(&dir.settings(), "WordCraft").unwrap().expect("the window accepts agents");
|
||||
let addr = window.addr().parse().unwrap();
|
||||
let token = window.token.clone();
|
||||
let inside = dir.agent_folder().join("inside.docx");
|
||||
let outside = dir.0.join("outside.docx");
|
||||
let (to_inside, to_outside) = (inside.clone(), outside.clone());
|
||||
let agent = std::thread::spawn(move || {
|
||||
let mut client = ControlClient::connect_challenged(addr, &token).unwrap();
|
||||
let save = |client: &mut ControlClient, path: &Path| client.call("engine.execute", json!({"command": "file.save", "params": {"path": path}}));
|
||||
(save(&mut client, &to_inside), save(&mut client, &to_outside))
|
||||
});
|
||||
while !agent.is_finished() {
|
||||
app.control_logic(&ctx);
|
||||
std::thread::sleep(Duration::from_millis(5));
|
||||
}
|
||||
let (saved, refused) = agent.join().unwrap();
|
||||
assert!(saved.is_ok(), "{saved:?}");
|
||||
assert!(inside.is_file());
|
||||
assert!(refused.is_err_and(|e| e.contains("outside")), "refused outside the agent folder");
|
||||
assert!(!outside.exists());
|
||||
}
|
||||
|
||||
/// A key an agent sends acts for the agent: its Ctrl+S doesn't save a document outside the agent
|
||||
/// folder. The person's own save of the same document does.
|
||||
#[test]
|
||||
fn an_agents_shortcut_saves_only_inside_its_folder() {
|
||||
let dir = Folder::new("keys");
|
||||
let outside = dir.0.join("person.docx");
|
||||
let mut app = linked(&dir, AgentSwitch::fixed(true, true));
|
||||
app.run("document.setText", json!({"text": "Seed"})).unwrap();
|
||||
app.session.path = Some(outside.clone());
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, a: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::logic(&ctx, a);
|
||||
a.ui(ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
let frames = |h: &mut egui_kittest::Harness<'_, WordApp>, n: usize| {
|
||||
for _ in 0..n {
|
||||
let ctx = h.ctx.clone();
|
||||
craft::ui::shell::embed::before_input(&ctx, |out| h.state_mut().frame_input(out));
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
frames(&mut h, 6);
|
||||
assert!(h.state().agent_roots().is_some(), "the agent link serves");
|
||||
let ctx = h.ctx.clone();
|
||||
h.state_mut().canvas.focus_page(&ctx);
|
||||
frames(&mut h, 4);
|
||||
let (req, _reply) = ControlRequest::new("ui.key", json!({"key": "S", "command": true}));
|
||||
let queued = control::handle(h.state_mut(), &ctx, &req);
|
||||
if let Reply::Done(v) = &queued {
|
||||
panic!("the key is queued, not answered: {v}");
|
||||
}
|
||||
frames(&mut h, 8);
|
||||
assert!(!outside.exists(), "the agent's Ctrl+S saved nothing outside its folder");
|
||||
|
||||
h.state_mut().run("file.save", json!({})).unwrap();
|
||||
assert!(outside.is_file(), "the person's own save writes it");
|
||||
}
|
||||
@@ -118,6 +118,9 @@ impl WordApp {
|
||||
font_notices: false,
|
||||
packs_rt: Default::default(),
|
||||
control: None,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
agents: None,
|
||||
pass_roots: None,
|
||||
capture_token: 0,
|
||||
native_scale: 1.0,
|
||||
software_drawing: false,
|
||||
@@ -263,7 +266,10 @@ impl WordApp {
|
||||
/// (a late paste, the control channel) is in `logic`.
|
||||
pub fn frame_input(&mut self, out: FrameOutput) -> FrameInput {
|
||||
if let Some(ctx) = self.ctx.clone() {
|
||||
self.run_fired(&ctx, &out);
|
||||
// The commands the last pass's keys fired act for whoever pressed them: an agent's
|
||||
// run inside its folders, as that pass did.
|
||||
let roots = self.pass_roots.take();
|
||||
wordcraft_engine::file_access::confine(roots.as_ref(), || self.run_fired(&ctx, &out));
|
||||
self.canvas.take_focus_after_pass(&ctx);
|
||||
// The zoom is context-wide but the display scale is per window: read it from the active
|
||||
// document window. The windowless root has no window, so it reports none (#8853).
|
||||
@@ -333,8 +339,16 @@ impl WordApp {
|
||||
self.print_feedback();
|
||||
}
|
||||
|
||||
/// Per-frame logic before layout: background work, the control channel, file results.
|
||||
/// Per-frame logic before layout: background work, the control channel, file results. A frame
|
||||
/// that plays input an agent sent runs inside the agent's folders ([`crate::agents`]).
|
||||
pub fn logic(&mut self, ctx: &egui::Context) {
|
||||
let roots = self.frame_roots(ctx);
|
||||
self.pass_roots = roots.clone();
|
||||
wordcraft_engine::file_access::confine(roots.as_ref(), || self.frame_logic(ctx));
|
||||
}
|
||||
|
||||
/// [`WordApp::logic`] inside the frame's roots, if any.
|
||||
fn frame_logic(&mut self, ctx: &egui::Context) {
|
||||
let lang = i18n::Lang::from_pref(&self.ui.language);
|
||||
if self.ctx.is_none() {
|
||||
theme::set_dark_text_curve(ctx);
|
||||
@@ -380,6 +394,8 @@ impl WordApp {
|
||||
self.chrome.search = false;
|
||||
}
|
||||
self.pump_close_prompt();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
self.sync_agents(ctx);
|
||||
self.control_logic(ctx);
|
||||
self.watch_fonts(ctx);
|
||||
// A script, an agent or a later result may have made another document the active one.
|
||||
@@ -427,7 +443,15 @@ impl WordApp {
|
||||
|
||||
/// Lay out the windows: on the desktop each open document's in its own native window
|
||||
/// ([`windows`]), on the web the one window.
|
||||
/// A frame that plays input an agent sent runs inside the agent's folders ([`crate::agents`]).
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
let roots = self.frame_roots(ui.ctx()).or_else(|| self.pass_roots.clone());
|
||||
self.pass_roots = roots.clone();
|
||||
wordcraft_engine::file_access::confine(roots.as_ref(), || self.frame_ui(ui));
|
||||
}
|
||||
|
||||
/// [`WordApp::ui`] inside the frame's roots, if any.
|
||||
fn frame_ui(&mut self, ui: &mut egui::Ui) {
|
||||
if self.windows.native() {
|
||||
self.windows_ui(ui);
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,7 @@ use craft::automation::control::ControlChannel;
|
||||
use craft::automation::screenshot::DocumentId;
|
||||
use craft::ui::runtime::motion::now;
|
||||
use craft::ui::runtime::windows::WindowHost;
|
||||
use wordcraft_engine::file_access::confine;
|
||||
|
||||
use super::WordApp;
|
||||
use crate::control;
|
||||
@@ -19,8 +20,14 @@ impl WordApp {
|
||||
}
|
||||
|
||||
/// The control channel's logic phase: finishes captures and input waiters, then, once the
|
||||
/// fonts are warm, runs the queued requests and answers them.
|
||||
/// fonts are warm, runs the queued requests and answers them. The agent link's requests, and
|
||||
/// the screenshots they save, read and write only inside the agent's folders.
|
||||
pub(crate) fn control_logic(&mut self, ctx: &egui::Context) {
|
||||
let roots = self.agent_roots();
|
||||
confine(roots.as_ref(), || self.control_logic_in(ctx));
|
||||
}
|
||||
|
||||
fn control_logic_in(&mut self, ctx: &egui::Context) {
|
||||
let Some(mut channel) = self.control.take() else { return };
|
||||
let host = WindowHost::of(ctx);
|
||||
let document = self.capture_document();
|
||||
@@ -51,6 +58,11 @@ impl WordApp {
|
||||
if ctx.will_discard() {
|
||||
return;
|
||||
}
|
||||
let roots = self.agent_roots();
|
||||
confine(roots.as_ref(), || self.control_ui_in(ctx));
|
||||
}
|
||||
|
||||
fn control_ui_in(&mut self, ctx: &egui::Context) {
|
||||
let Some(mut channel) = self.control.take() else { return };
|
||||
let host = WindowHost::of(ctx);
|
||||
let document = self.capture_document();
|
||||
@@ -60,3 +72,15 @@ impl WordApp {
|
||||
self.control = Some(channel);
|
||||
}
|
||||
}
|
||||
|
||||
/// The web build has no agent link: nothing is confined.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
impl WordApp {
|
||||
pub(crate) fn agent_roots(&self) -> Option<std::sync::Arc<wordcraft_engine::file_access::AutomationRoots>> {
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn frame_roots(&self, _: &egui::Context) -> Option<std::sync::Arc<wordcraft_engine::file_access::AutomationRoots>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,6 +664,9 @@ fn navigation_options(animations: bool) -> NavigationOptions {
|
||||
// Browsers report three lines per notch where native platforms report one.
|
||||
options.wheel_line = if cfg!(target_arch = "wasm32") { crate::scroll::NOTCH_PX / 3.0 } else { crate::scroll::NOTCH_PX };
|
||||
options.eased_wheel = animations;
|
||||
// macOS, Windows and the web send their own touchpad momentum; elsewhere (Wayland, X11) the lift ends the scroll
|
||||
// and the app glides on (#8855).
|
||||
options.touchpad_glide = !cfg!(any(target_os = "macos", target_os = "ios", target_os = "windows", target_arch = "wasm32"));
|
||||
options
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ use craft::ui::primitives::{FaceRun, PaintShape, StrokeWidth, TextRun};
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::style::{ComponentStyle, DataColor, StyleColor, StyleCx};
|
||||
use egui::{Color32, Pos2, Rect, Response, Ui, pos2, vec2};
|
||||
use wordcraft_doc::props::TextDirection;
|
||||
use wordcraft_layout::DocLayout;
|
||||
|
||||
use super::cursor::{caret_color_at, preedit_cursor_chars};
|
||||
@@ -39,8 +40,13 @@ struct Placement {
|
||||
/// The selection is collapsed, so a caret is drawn.
|
||||
collapsed: bool,
|
||||
/// The face, size and baseline on screen text typed at the caret takes, which a composition is drawn in. `None`
|
||||
/// in an equation, in turned text and without a style run.
|
||||
/// in an equation and without a style run. In turned text the baseline is unused.
|
||||
typing: Option<TypingFace>,
|
||||
/// The direction the caret's line reads in; turned text has a composition running down or up the page.
|
||||
turn: TextDirection,
|
||||
/// Turned text: the caret's top on screen, where the composition starts, and the line's width across the page.
|
||||
y0: f32,
|
||||
across: f32,
|
||||
}
|
||||
|
||||
/// The face text typed at the caret asks for, its size and its baseline on screen (`DocLayout::typing_style`).
|
||||
@@ -76,6 +82,9 @@ fn place(app: &WordApp, doc: &DocLayout, pages: &[PlacedPage]) -> Option<Placeme
|
||||
in_equation: true,
|
||||
collapsed: true,
|
||||
typing: None,
|
||||
turn: TextDirection::Horizontal,
|
||||
y0,
|
||||
across: 0.0,
|
||||
});
|
||||
}
|
||||
let sel = preview_sel(app).unwrap_or(&app.session.sel);
|
||||
@@ -105,15 +114,17 @@ fn place(app: &WordApp, doc: &DocLayout, pages: &[PlacedPage]) -> Option<Placeme
|
||||
} else {
|
||||
[pos2(x.round() + 0.5, y0), pos2(x.round() + 0.5, y1)]
|
||||
};
|
||||
// Word draws a composition in the font and size of the text it goes into; not in turned text, whose lines aren't
|
||||
// horizontal.
|
||||
let typing = if c.width > 0.0 {
|
||||
None
|
||||
} else {
|
||||
doc.typing_style(&sel.focus, app.session.page_hint)
|
||||
.filter(|(run, base)| run.size.is_finite() && run.size > 0.0 && base.is_finite())
|
||||
.map(|(run, base)| TypingFace { face: run.requested_face, size: run.size * scale, baseline: pr.rect.min.y + base * scale })
|
||||
};
|
||||
// Word draws a composition in the font and size of the text it goes into, along the line (turned text: down or up
|
||||
// the page).
|
||||
let turned = c.width > 0.0;
|
||||
let typing = doc
|
||||
.typing_style(&sel.focus, app.session.page_hint)
|
||||
.filter(|(run, base)| run.size.is_finite() && run.size > 0.0 && (turned || base.is_finite()))
|
||||
.map(|(run, base)| TypingFace {
|
||||
face: run.requested_face,
|
||||
size: run.size * scale,
|
||||
baseline: if turned { 0.0 } else { pr.rect.min.y + base * scale },
|
||||
});
|
||||
Some(Placement {
|
||||
bar,
|
||||
page: c.page,
|
||||
@@ -124,6 +135,9 @@ fn place(app: &WordApp, doc: &DocLayout, pages: &[PlacedPage]) -> Option<Placeme
|
||||
in_equation: false,
|
||||
collapsed: sel.is_collapsed(),
|
||||
typing,
|
||||
turn: c.turn,
|
||||
y0,
|
||||
across: c.width * scale,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -204,6 +218,9 @@ pub(crate) fn paint_caret(app: &mut WordApp, ui: &mut Ui, pass: &ToolPass, body:
|
||||
cursor,
|
||||
color: ink(app),
|
||||
typing: pl.typing,
|
||||
turn: pl.turn,
|
||||
y0: pl.y0,
|
||||
across: pl.across,
|
||||
});
|
||||
} else {
|
||||
let look = step(app, request(pl.bar, shown));
|
||||
@@ -224,8 +241,8 @@ pub(crate) fn paint_caret(app: &mut WordApp, ui: &mut Ui, pass: &ToolPass, body:
|
||||
// them an empty rect that clips their strokes away.
|
||||
let out = CaretMarks::new(tl!("Text cursor").to_string(), bars, composition).show_at(ui, pass.rect);
|
||||
// The candidate window sits at the input method's cursor inside the composition, as production placed it.
|
||||
if let Some(x) = out.composition_caret {
|
||||
report = Rect::from_min_max(pos2(x, report.min.y), pos2(x + 1.0, report.max.y));
|
||||
if let Some(r) = out.composition_caret {
|
||||
report = if pl.turn.is_turned() { r } else { Rect::from_min_max(pos2(r.min.x, report.min.y), pos2(r.min.x + 1.0, report.max.y)) };
|
||||
}
|
||||
}
|
||||
// Reported after the marks, which lay the composition out: this pass's final caret for the input method.
|
||||
@@ -245,6 +262,11 @@ struct Composition {
|
||||
color: Color32,
|
||||
/// The face, size and baseline it is drawn in; without them, the interface font from the caret's bottom.
|
||||
typing: Option<TypingFace>,
|
||||
/// The line's direction; turned, the composition's characters stack upright down or up from `y0`, in a column
|
||||
/// `across` wide starting at `left`.
|
||||
turn: TextDirection,
|
||||
y0: f32,
|
||||
across: f32,
|
||||
}
|
||||
|
||||
/// The style of the caret marks: the composition's ink.
|
||||
@@ -265,8 +287,9 @@ pub(crate) struct CaretMarks {
|
||||
common: Common,
|
||||
bars: Vec<(Bar, Color32)>,
|
||||
composition: Option<Composition>,
|
||||
/// Where the paint put the caret inside the composition (screen x), measured from the laid-out text.
|
||||
composition_caret: Option<f32>,
|
||||
/// Where the paint put the caret inside the composition (a bar in screen points; turned text: the rect the
|
||||
/// composition fills), measured from the laid-out text.
|
||||
composition_caret: Option<Rect>,
|
||||
}
|
||||
|
||||
impl CaretMarks {
|
||||
@@ -279,7 +302,7 @@ impl CaretMarks {
|
||||
/// What the marks report: the caret's place inside the composition they drew, for the candidate window.
|
||||
pub(crate) struct CaretMarksOutput {
|
||||
response: Response,
|
||||
composition_caret: Option<f32>,
|
||||
composition_caret: Option<Rect>,
|
||||
}
|
||||
|
||||
impl Outcome for CaretMarksOutput {
|
||||
@@ -330,6 +353,12 @@ impl Component for CaretMarks {
|
||||
}
|
||||
let Some(c) = &self.composition else { return };
|
||||
let color = DataColor::new(c.color);
|
||||
if c.turn.is_turned()
|
||||
&& let Some(t) = &c.typing
|
||||
{
|
||||
self.composition_caret = Some(paint_turned(&draw, c, t, color));
|
||||
return;
|
||||
}
|
||||
let (layout, top, bottom) = match &c.typing {
|
||||
// In the text's own face and size, its first baseline on the line's, as typed text would sit. Characters the
|
||||
// face lacks (CJK in a Latin font) come from the interface fonts; a size past the font atlas is capped.
|
||||
@@ -350,7 +379,7 @@ impl Component for CaretMarks {
|
||||
draw.stroke(&PaintShape::Path(underline), StrokeWidth::Thin, color);
|
||||
let x = (c.left + layout.char_x(c.cursor)).round() + 0.5;
|
||||
draw.stroke(&PaintShape::Path(vec![pos2(x, top), pos2(x, bottom)]), StrokeWidth::Medium, color);
|
||||
self.composition_caret = Some(x);
|
||||
self.composition_caret = Some(Rect::from_min_max(pos2(x, top), pos2(x, bottom)));
|
||||
}
|
||||
|
||||
fn access(&self, access: &mut Access, _: &Cx<'_, Self>) {
|
||||
@@ -361,3 +390,27 @@ impl Component for CaretMarks {
|
||||
CaretMarksOutput { response: cx.response.clone(), composition_caret: self.composition_caret }
|
||||
}
|
||||
}
|
||||
|
||||
/// A composition in turned text: its characters upright, each in a cell of the run's size, stacked from the caret down
|
||||
/// the page (`Down`) or up it (`Up`) in a column across the line, with the underline along the column's left edge and
|
||||
/// the input method's cursor across it. Returns the rect the composition fills, which the candidate window avoids.
|
||||
fn paint_turned(draw: &craft::ui::primitives::Draw<'_>, c: &Composition, t: &TypingFace, color: DataColor) -> Rect {
|
||||
let key = face_key(t.face);
|
||||
let sign = if c.turn == TextDirection::Up { -1.0 } else { 1.0 };
|
||||
// The cell's edge `i` characters from the start.
|
||||
let edge = |i: usize| c.y0 + sign * t.size * i as f32;
|
||||
let n = c.text.chars().count();
|
||||
for (i, ch) in c.text.chars().enumerate() {
|
||||
let mut buf = [0; 4];
|
||||
let s: &str = ch.encode_utf8(&mut buf);
|
||||
// Centred in the column as an em-wide ideograph; the baseline sits at 0.86 em in the cell, where its body lies.
|
||||
let top = edge(i).min(edge(i + 1));
|
||||
let at = pos2(c.left + (c.across - t.size) / 2.0, top + 0.86 * t.size);
|
||||
draw.face_run(at, &FaceRun::new(s, &key, t.size, color), || face_bytes(t.face));
|
||||
}
|
||||
let end = edge(n);
|
||||
draw.stroke(&PaintShape::Path(vec![pos2(c.left, c.y0), pos2(c.left, end)]), StrokeWidth::Thin, color);
|
||||
let at = edge(c.cursor.min(n)).round() + 0.5;
|
||||
draw.stroke(&PaintShape::Path(vec![pos2(c.left, at), pos2(c.left + c.across, at)]), StrokeWidth::Medium, color);
|
||||
Rect::from_two_pos(pos2(c.left, c.y0), pos2(c.left + c.across, end))
|
||||
}
|
||||
|
||||
@@ -2965,3 +2965,26 @@ fn mouse_wheel_notch_scrolls_document_line_distance_and_accelerates_on_flick() {
|
||||
let flicked = h.state().canvas.view.offset.1 - flick_start;
|
||||
assert!(flicked > 5.0 * eased_notch, "a rapid 5-notch flick ({flicked}) should accelerate past 5 single notches ({})", 5.0 * eased_notch);
|
||||
}
|
||||
|
||||
/// In vertical text the composition runs down the line, upright and at the text's size, and the candidate window
|
||||
/// reports the column it fills, not a horizontal strip (#8980).
|
||||
#[test]
|
||||
fn a_composition_in_vertical_text_runs_down_the_line() {
|
||||
let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
app.run("document.setText", json!({"text": "Hello"})).unwrap();
|
||||
app.run("layout.textDirection", json!({"value": "tbRl"})).unwrap();
|
||||
app.run("caret.docEnd", json!({})).unwrap();
|
||||
let mut h = composing_harness(app);
|
||||
kana_test_glyphs(&h.ctx);
|
||||
h.event(egui::Event::Ime(egui::ImeEvent::Preedit { text: "にほん".into(), active_range_chars: None }));
|
||||
for _ in 0..4 {
|
||||
h.app_frame();
|
||||
}
|
||||
let kana: Vec<_> = ["に", "ほ", "ん"].iter().filter_map(|k| drawn_composition(&h, k)).collect();
|
||||
assert_eq!(kana.len(), 3, "each kana is drawn on its own");
|
||||
let at = |i: usize| kana[i].pos;
|
||||
assert!(at(0).y < at(1).y && at(1).y < at(2).y, "the kana stack down the page");
|
||||
assert!((at(0).x - at(2).x).abs() < 1.0, "in one column");
|
||||
let ime = h.output().platform_output.ime.clone().expect("the canvas places the candidate window").cursor_rect;
|
||||
assert!(ime.height() > ime.width(), "the candidate window sits by the column: {ime:?}");
|
||||
}
|
||||
|
||||
@@ -9,10 +9,11 @@ use craft::theme::ControlSize;
|
||||
use craft::theme::variant::Variant;
|
||||
use craft::ui::bars::{Bar, BarKind};
|
||||
use craft::ui::buttons::{Button, ButtonOutput, IconButton, ToggleButton};
|
||||
use craft::ui::contract::{Bind, BodyCx, Gap, Props as _, Show as _, ShowContainer as _, TooltipSpec, Trigger};
|
||||
use craft::ui::contract::{AfterInk, Bind, BodyCx, Gap, Props as _, Show as _, ShowContainer as _, TooltipSpec, Trigger};
|
||||
use craft::ui::display::{Divider, Text};
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::runtime::env::with_env;
|
||||
use craft::ui::value_drag::{Slider, SliderScale};
|
||||
use egui::Ui;
|
||||
use serde_json::json;
|
||||
@@ -45,7 +46,16 @@ pub(crate) fn show(ui: &mut Ui, _cx: &mut BodyCx<'_>, app: &mut WordApp) {
|
||||
})
|
||||
.show(ui, |ui, _| {
|
||||
if let Ok(mut a) = app.try_borrow_mut() {
|
||||
page.set(Some(readouts(&mut a, ui)));
|
||||
// The readouts are secondary text, as v0.19.1 drew them (#8811): craft's ghost button takes the muted ink
|
||||
// where it passes text contrast.
|
||||
let rect = with_env(
|
||||
ui,
|
||||
|o| {
|
||||
o.values.set(AfterInk::Muted);
|
||||
},
|
||||
|ui| readouts(&mut a, ui),
|
||||
);
|
||||
page.set(Some(rect));
|
||||
}
|
||||
});
|
||||
if let (Some(page), Some(group), Ok(mut a)) = (page.get(), group.get(), app.try_borrow_mut()) {
|
||||
|
||||
@@ -70,9 +70,21 @@ pub fn inspect(app: &mut WordApp, ctx: &egui::Context) -> Value {
|
||||
"document": app.session.document_id(),
|
||||
"documents": app.session.documents(),
|
||||
"perf": {"frameMs": app.frame_ms, "layoutMs": app.session.layout().ms},
|
||||
"agentLink": agent_link(app),
|
||||
})
|
||||
}
|
||||
|
||||
/// The agent link for `ui.inspect` ([`crate::agents`]); `null` without one.
|
||||
fn agent_link(app: &WordApp) -> Value {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
return app.agent_link_json();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
let _ = app;
|
||||
Value::Null
|
||||
}
|
||||
}
|
||||
|
||||
/// Programmatic calls never open the Save prompt, so closing unsaved work must be explicit:
|
||||
/// save first, or pass `"force": true` (only a real boolean true counts) to discard it (#1268).
|
||||
pub(crate) fn close_refused(app: &WordApp, id: &str, params: &Value) -> Option<&'static str> {
|
||||
|
||||
@@ -90,6 +90,10 @@ pub(crate) enum AfterSave {
|
||||
pub(crate) struct PendingDialog {
|
||||
id: PickId,
|
||||
after: AfterPick,
|
||||
/// The folders in force when it opened: an agent's, when its input or request asked
|
||||
/// ([`crate::agents`]). Its answer arrives on a later frame and is handled inside them, so a
|
||||
/// path an agent typed into the fallback chooser can't reach outside them.
|
||||
roots: Option<std::sync::Arc<wordcraft_engine::file_access::AutomationRoots>>,
|
||||
}
|
||||
|
||||
/// How asking for a file went.
|
||||
@@ -125,7 +129,7 @@ impl WordApp {
|
||||
}
|
||||
let fallback = req.fallback || self.fallback_chooser;
|
||||
let id = self.host.files().pick(req.fallback(fallback));
|
||||
self.file_dialog = Some(PendingDialog { id, after });
|
||||
self.file_dialog = Some(PendingDialog { id, after, roots: wordcraft_engine::file_access::current() });
|
||||
// A service that answered at once is handled right away.
|
||||
self.poll_file_dialog().map_or(Asked::Pending, Asked::Done)
|
||||
}
|
||||
@@ -139,6 +143,12 @@ impl WordApp {
|
||||
if matches!(d.after, AfterPick::Recipients) {
|
||||
self.recipient_list_pending = false;
|
||||
}
|
||||
let roots = d.roots.clone();
|
||||
wordcraft_engine::file_access::confine(roots.as_ref(), || self.finish_dialog(d, picked))
|
||||
}
|
||||
|
||||
/// Finishes what the dialog `d` was for with its answer `picked`.
|
||||
fn finish_dialog(&mut self, d: PendingDialog, picked: Picked) -> Option<Result<Value, String>> {
|
||||
match picked {
|
||||
Picked::Cancelled => Some(self.finish_pick(d.after, None)),
|
||||
Picked::Unavailable(cause) => {
|
||||
|
||||
@@ -1007,6 +1007,33 @@ fn entries_expose_names_selection_and_picking() {
|
||||
assert_eq!(answer, Some(DialogResult::Ok(Answer::Paths(vec![PathBuf::from("/d/chapter.docx")]))));
|
||||
}
|
||||
|
||||
/// A Save As opened inside an agent's folders (its request, or a frame playing its input) keeps
|
||||
/// them for its answer, which arrives on a later frame with nothing in force: a path outside them
|
||||
/// is refused, one inside is saved.
|
||||
#[test]
|
||||
fn a_dialog_an_agent_opened_keeps_its_folders_for_the_answer() {
|
||||
use wordcraft_engine::file_access::{AutomationRoots, confine};
|
||||
let dir = scratch("agent-dialog");
|
||||
let inside = dir.join("agents");
|
||||
std::fs::create_dir_all(&inside).unwrap();
|
||||
let roots = AutomationRoots::new(Some(&inside), Some(&inside)).unwrap();
|
||||
let (mut a, files) = async_app();
|
||||
a.run("text.insert", json!({"text": UNSAVED})).unwrap();
|
||||
let outside = dir.join("outside.docx");
|
||||
confine(roots.as_ref(), || a.save_as_dialog());
|
||||
assert!(a.file_dialog_open(), "Save As asks for a file");
|
||||
answer(&files, Some(&outside.to_string_lossy()));
|
||||
let refused = a.poll_file_dialog().unwrap();
|
||||
assert_eq!(refused.unwrap()["saved"], false, "refused outside the agent's folder");
|
||||
assert!(!outside.exists());
|
||||
|
||||
let kept = inside.join("kept.docx");
|
||||
confine(roots.as_ref(), || a.save_as_dialog());
|
||||
answer(&files, Some(&kept.to_string_lossy()));
|
||||
assert!(a.poll_file_dialog().unwrap().is_ok());
|
||||
assert!(kept.is_file(), "saved inside it");
|
||||
}
|
||||
|
||||
/// #6131: File › Export to DOCX, ODT or RTF writes a copy. It ran a plain Save As, which made
|
||||
/// the copy the document's file and cleared its unsaved changes, so the next Save updated the
|
||||
/// copy and the original kept its old text.
|
||||
|
||||
@@ -103,6 +103,8 @@ pub use dialogs::dialogs_ribbon;
|
||||
pub use dialogs::dialogs_smart_art;
|
||||
pub use file_dialogs::open_filters;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub mod agents;
|
||||
mod announce;
|
||||
mod app;
|
||||
mod services;
|
||||
@@ -455,6 +457,13 @@ pub struct WordApp {
|
||||
pub(crate) packs_rt: language_packs::Runtime,
|
||||
/// The control channel's requests and replies, once a host started it.
|
||||
pub(crate) control: Option<craft::automation::control::ControlChannel>,
|
||||
/// Agents in the open window: the agent link, the launcher's switch and the folders agent
|
||||
/// requests are confined to ([`agents`]); `None` in a window without them (tests, the web).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) agents: Option<agents::Agents>,
|
||||
/// The agent's folders while this pass plays input an agent sent ([`WordApp::logic`]); the
|
||||
/// commands its keys fired run inside them at the next `frame_input`.
|
||||
pub(crate) pass_roots: Option<std::sync::Arc<wordcraft_engine::file_access::AutomationRoots>>,
|
||||
/// The last screenshot token handed out; tokens start at 1.
|
||||
pub(crate) capture_token: u64,
|
||||
/// The Navigation pane's search box takes the keyboard on its next frame (Ctrl+F, #712).
|
||||
|
||||
@@ -744,11 +744,19 @@ impl PreferencesModel for OptionsModel<'_> {
|
||||
}
|
||||
|
||||
fn custom_page(&mut self, ui: &mut Ui, page: &str) -> bool {
|
||||
if page == "agents" {
|
||||
if page != "agents" {
|
||||
return false;
|
||||
}
|
||||
// The launcher's switch, the link's state, the port, the agent folders and the closed-app
|
||||
// choice: the framework's Agents page, as in every Craft app.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
return crate::agents::page(self.app, ui);
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
Text::new(tl!("Every command is available to scripts and AI agents: run `wordcraft-cli mcp` for an MCP server, or start the app with `--control <port>` for the JSON control channel."))
|
||||
.show(ui);
|
||||
false
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn reset_page(&mut self, page: &str) {
|
||||
|
||||
@@ -167,6 +167,10 @@ pub struct Prefs {
|
||||
/// How far a touchpad swipe the system reports in points (Wayland, macOS) scrolls (#6146).
|
||||
#[serde(default, alias = "touchpadScrollSpeed")]
|
||||
pub touchpad_scroll_speed: ScrollSpeed,
|
||||
/// File › Options › Agents: the port agents connect on, the folders they may open from and save
|
||||
/// to, and what `wordcraft-cli mcp` does while the app is closed ([`crate::agents`]). Saved as
|
||||
/// the `integrations` section, which `wordcraft-cli mcp` reads too. Agents can't change it.
|
||||
pub integrations: craft::automation::agents::AgentSettings,
|
||||
}
|
||||
|
||||
impl Default for Prefs {
|
||||
@@ -228,6 +232,7 @@ impl Default for Prefs {
|
||||
font_download_notice: true,
|
||||
scroll_speed: ScrollSpeed::default(),
|
||||
touchpad_scroll_speed: ScrollSpeed::default(),
|
||||
integrations: craft::automation::agents::AgentSettings::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,30 @@ impl ThumbSource<usize> for SheetSource<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
outline_sheet(&mut image);
|
||||
ThumbRender::Ready(image)
|
||||
}
|
||||
}
|
||||
|
||||
/// A one-pixel grey edge on the sheet. The pane's well is as white as the paper, so without it the sheet's
|
||||
/// own shape is invisible and a portrait page looks like a landscape sheet with the page off to one side (#9111).
|
||||
fn outline_sheet(image: &mut ColorImage) {
|
||||
// lean: fixed grey, not a theme token: the sheet is paper, white in every theme; a token needs a craft-libs pane overlay.
|
||||
const EDGE: Color32 = Color32::from_gray(150);
|
||||
let [w, h] = image.size;
|
||||
if w == 0 || h == 0 {
|
||||
return;
|
||||
}
|
||||
for x in 0..w {
|
||||
image.pixels[x] = EDGE;
|
||||
image.pixels[(h - 1) * w + x] = EDGE;
|
||||
}
|
||||
for y in 0..h {
|
||||
image.pixels[y * w] = EDGE;
|
||||
image.pixels[y * w + w - 1] = EDGE;
|
||||
}
|
||||
}
|
||||
|
||||
/// The preview (#1156): the sheet fills the pane, a bar below pages through the sheets and zooms; zoomed in,
|
||||
/// the sheet pans.
|
||||
pub(super) fn show(app: &mut WordApp, ui: &mut Ui, lay: &Arc<DocLayout>) {
|
||||
|
||||
@@ -164,6 +164,9 @@ impl WordApp {
|
||||
packs_rt: _,
|
||||
// The control channel's screenshots and input go to the active window, whichever it is.
|
||||
control: _,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
agents: _,
|
||||
pass_roots: _,
|
||||
capture_token: _,
|
||||
fallback_chooser: _,
|
||||
// The current command's origin, set and cleared around it.
|
||||
@@ -253,6 +256,7 @@ impl WordApp {
|
||||
status_count: _,
|
||||
scroll_speed: _,
|
||||
touchpad_scroll_speed: _,
|
||||
integrations: _,
|
||||
nav_pane: _,
|
||||
show_discord: _,
|
||||
author: _,
|
||||
|
||||
+42
-13
@@ -1,10 +1,12 @@
|
||||
# Control protocol
|
||||
|
||||
> **Last updated:** 2026-11-26 · The methods as the control channel answers them since the craft framework port (#7101): `ui.type`, `ui.click` with `hold`, `ui.release`, the `command` modifier, wheel units `points` and `lines`, the screenshot reply's `base64`, the methods the table was missing, and an idle connection closing after 30 s. Earlier: `wordcraft-cli mcp --connect` is refused for now (#7124); the token section describes the bridge for when it returns. Earlier: The control channel authenticates once per connection with a token (`auth`), replacing the per-request key. Earlier: Correct the force-close request envelope and document the optional command search parameter; command behavior unchanged. #6146: scroll speed preferences (`ui.scrollSpeed`, `ui.touchpadScrollSpeed`); #6159: refuse ui.screenshot on secondary document windows and support root window selection with view.switchWindows.
|
||||
> **Last updated:** 2026-12-02 · The agent link: while ArtCraft Launcher › Settings › AI agents is on, the window serves this channel for agents on its own, confined to the agent folders, and `wordcraft-cli mcp` finds it through `agent-connection.json` (#8415); `--connect` is deprecated. Earlier: The methods as the control channel answers them since the craft framework port (#7101): `ui.type`, `ui.click` with `hold`, `ui.release`, the `command` modifier, wheel units `points` and `lines`, the screenshot reply's `base64`, the methods the table was missing, and an idle connection closing after 30 s. Earlier: `wordcraft-cli mcp --connect` was refused (#7124). Earlier: The control channel authenticates once per connection with a token (`auth`), replacing the per-request key. Earlier: Correct the force-close request envelope and document the optional command search parameter; command behavior unchanged. #6146: scroll speed preferences (`ui.scrollSpeed`, `ui.touchpadScrollSpeed`); #6159: refuse ui.screenshot on secondary document windows and support root window selection with view.switchWindows.
|
||||
|
||||
Start the app with a control port: `wordcraft --control 7981` (or `WORDCRAFT_CONTROL_PORT=7981`).
|
||||
A missing or invalid port after `--control` (not 1–65535) prints an error and exits with status 2.
|
||||
It listens on `127.0.0.1` only. Authenticate once per connection with the window's token (see
|
||||
File › Options › Agents › Allow Agent Control off refuses it (the app says so and runs without
|
||||
it). It listens on `127.0.0.1` only. For agents the window serves the same channel by itself:
|
||||
see [The agent link](#the-agent-link). Authenticate once per connection with the window's token (see
|
||||
[Token](#token)), then send one JSON object per line; each gets one reply line:
|
||||
|
||||
```json
|
||||
@@ -52,16 +54,43 @@ exit.
|
||||
sends. After that, a connection idle for 30 s is closed.
|
||||
- At most 16 connections are served at once; the next one gets `connection limit reached`.
|
||||
|
||||
`wordcraft-cli mcp --connect` is refused for now, until the app confines this channel to automation
|
||||
roots (#3695, #5819; see [docs/mcp.md](mcp.md)). When it returns, it takes the token from
|
||||
`WORDCRAFT_CONTROL_TOKEN`, or else from the
|
||||
token file for the port it connects to, and reads it again on every new connection (the app may
|
||||
have restarted). It sends the token only to the app's own address, `127.0.0.1` (`localhost`
|
||||
connects there too, never to `::1`): another loopback address such as `::1` or `127.0.0.2` is not
|
||||
where the app listens, so whoever listens there gets no token (#3699). For
|
||||
any other host it sends nothing and says why: to drive an app on
|
||||
another machine, forward its port to `127.0.0.1` (for example `ssh -L 7981:127.0.0.1:7981 host`)
|
||||
and set `WORDCRAFT_CONTROL_TOKEN` to that app's token.
|
||||
A channel started with `--control` is not confined to folders (#3695, #5819): it is for scripts and
|
||||
tests you run yourself. `wordcraft-cli mcp` doesn't use it.
|
||||
|
||||
## The agent link
|
||||
|
||||
While ArtCraft Launcher › Settings › AI agents › *Let AI agents use Craft apps* is on (and the
|
||||
suite's `AI-MCP` flag), the window serves this channel for agents without `--control`, and stops
|
||||
when the switch goes off, with no restart. File › Options › Agents shows where it stands; its
|
||||
Control Port is 0 (any free port) unless set there. Its token stays in `<settings>/agent-control.token`
|
||||
(owner-only, kept across launches; a file others could read is replaced with a new token), and the
|
||||
window publishes where it listens in `<settings>/agent-connection.json`:
|
||||
|
||||
```json
|
||||
{"version": 1, "pid": 4242, "port": 51234, "tokenFile": "…/agent-control.token", "app": "WordCraft <version>"}
|
||||
```
|
||||
|
||||
The file holds no secret. A crashed window can leave it behind; the next launch removes it when
|
||||
nothing listens on its port. `wordcraft-cli mcp` reads it before every tool call and signs in
|
||||
with the challenge handshake, so a program that took the port of a window that quit learns nothing
|
||||
derived from the token:
|
||||
|
||||
```json
|
||||
{"id": 0, "method": "auth.challenge", "params": {"clientNonce": "<64 hex>"}}
|
||||
{"id": 0, "ok": true, "result": {"serverNonce": "<64 hex>", "serverProof": "<64 hex>"}}
|
||||
{"id": 1, "method": "auth", "params": {"proof": "<64 hex>"}}
|
||||
{"id": 1, "ok": true, "result": {"authenticated": true}}
|
||||
```
|
||||
|
||||
The client checks `serverProof` before it sends its own `proof`; both are HMAC-SHA256 over the
|
||||
two nonces, keyed by the token (`craft::automation::security`).
|
||||
|
||||
Everything that comes through the agent link reads and writes files only in the agent folders
|
||||
(`Documents/ArtCraft/Agents/WordCraft` unless File › Options › Agents names others): the requests,
|
||||
the screenshots they save, and the frames that play the clicks and keys an agent sends, with the
|
||||
commands those keys fire. What the person does in the window is not confined. `ui.inspect`
|
||||
reports the link as `agentLink`: `port`, `launchFlags` (a `--control` server runs instead),
|
||||
`error`, `mcpFlag` and `launcher` (the switch names WordCraft).
|
||||
|
||||
## Delivery and startup failures
|
||||
|
||||
@@ -69,7 +98,7 @@ If the accept thread cannot start, startup reports that the control server is of
|
||||
its newly written token file; it does not report a listening server.
|
||||
|
||||
A client that encounters a write error or a lost reply must treat delivery as unknown once it
|
||||
has attempted to send. The MCP bridge does not replay mutations in this case, or image exports
|
||||
has attempted to send. `wordcraft-cli mcp` does not replay mutations in this case, or image exports
|
||||
with a string `path`; see [delivery failures](mcp.md#delivery-failures).
|
||||
|
||||
A request that times out while still queued is cancelled and cannot run later. If execution
|
||||
|
||||
@@ -345,7 +345,7 @@ The front-of-text opt-out is retained from the earlier implementation; this patc
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-11 | trivial | A line goes beside a floating picture or shape when the gap between the column edge and its wrap area is at least 18pt (square, tight and through; was 20pt), and beside a tight or through one at least 9pt before Word 2013 layout (compatibility mode 14 and below), as measured in Word; floating tables keep 20pt. A tight-wrapped cover whose empty paragraphs fit in a 19.15pt gap is one page again, not three (#6316, `layout::tests::text_goes_beside_a_float_in_an_18pt_gap`, `layout::tests::tight_wrap_needs_only_9pt_beside_it_before_word_2013_layout`) |
|
||||
| 2026-12-04 | trivial | An autofit table with a point width differing from its `tblGrid` total takes its column widths from complete rows of positive point-width cells (no `gridBefore`/`gridAfter`, spans included) when their column edges agree and their total matches the table's width within 0.5 pt; fixed tables, percentage tables and disagreeing rows keep the existing behaviour (#6525, `layout::table::tests::rows_outrank_grid_total`, `layout::tests::ordinary_table_takes_row_widths`) |
|
||||
| 2026-12-04 | trivial | An autofit table with a point width differing from its `tblGrid` total takes its column widths from complete rows of positive point-width cells (no `gridBefore`/`gridAfter`, spans included) when their column edges agree and their total matches the table's width within 0.5 pt; fixed tables, percentage tables and disagreeing rows keep the existing behaviour (#6525, `layout::table::width_tests::rows_outrank_grid_total`, `layout::tests::ordinary_table_takes_row_widths`) |
|
||||
| 2026-11-19 | trivial | Small Caps draws a space (U+0020) and an ideographic space (U+3000) at the small-caps size, and sets that size at 80% rounded to the half point, as Word does, so Small Caps lines break where Word breaks them (#7062); a Small Caps line of lowercase letters is as tall as without Small Caps (#7063) |
|
||||
| 2026-12-03 | trivial | Text frames (`w:framePr`) in a table cell float beside the cell's text only when `v_anchor == "text"`; frames with another vertical anchor (such as `"page"` or `"margin"`) flow inline in the cell instead of offsetting against the cell box and pushing the row onto a new page (#6523; `layout::tests::a_page_anchored_frame_in_a_cell_stays_in_the_cell`, `layout::tests::a_text_frame_in_a_cell_floats_beside_the_text`; synthetic tests cover `"page"` and `"text"`, `"margin"` and non-`"text"` values follow the same `cell_frame` predicate in `boxes::layout_box`; no new native Word comparison) |
|
||||
| 2026-12-04 | trivial | Clarified the 2026-12-03 turned-cell-text entry (#6528, #6529): the 648 pt `TURNED_MAX` cap applies only to the first-pass fallback for non-`At least` rows, overflowing wrapped lines, or non-exact text-box rows, while the second pass runs for every turned cell—recomputing from the final row or span height (capped to the starting page's remaining room for a page-split vertical merge), clamping to `TURNED_LIMIT` (1584 pt), and re-laying out whenever that length changed (#8976) |
|
||||
|
||||
+54
-28
@@ -1,37 +1,62 @@
|
||||
# MCP server
|
||||
|
||||
> **Last updated:** 2026-11-20 · `wordcraft-cli mcp` starts only with both `--automation-read-root` and `--automation-write-root`, and `--connect` is refused until the desktop app confines its control channel (#7124, shared rule 18). Earlier: The bridge authenticates once per connection with the control token (`WORDCRAFT_CONTROL_TOKEN` or the app's token file). Earlier: The protocol core is the shared `craft-mcp-server` crate (#778); `click` and `key` list every argument they accept. Earlier: Keep the complete `type_text` description in one tool-table row; behavior wording unchanged. Delivery review fixes for #2596: unknown outcomes are not replayed, including image exports to a path; invalid UTF-8 returns a parse error without stopping later requests.
|
||||
> **Last updated:** 2026-12-02 · Agents in the open window: while ArtCraft Launcher › Settings › AI agents is on, plain `wordcraft-cli mcp` sends each tool call to the open WordCraft window, confined to its agent folder, and `agent_folders` says where that is; `--connect` is deprecated (#8415). Earlier: `wordcraft-cli mcp` starts only with both `--automation-read-root` and `--automation-write-root` (#7124, shared rule 18). Earlier: The protocol core is the shared `craft-mcp-server` crate (#778); `click` and `key` list every argument they accept. Delivery review fixes for #2596: unknown outcomes are not replayed, including image exports to a path; invalid UTF-8 returns a parse error without stopping later requests.
|
||||
|
||||
WordCraft speaks the [Model Context Protocol](https://modelcontextprotocol.io) over stdio, so
|
||||
Claude and other agents can write and edit documents.
|
||||
|
||||
## With the ArtCraft Launcher
|
||||
|
||||
Turn on **ArtCraft Launcher › Settings › AI agents › Let AI agents use Craft apps**. The launcher
|
||||
adds one `ArtCraft` entry to your AI apps (Claude Desktop, Claude Code, Cursor, LM Studio), which
|
||||
reaches every Craft app installed; WordCraft writes no MCP client configuration itself. While the
|
||||
switch is on:
|
||||
|
||||
- The open WordCraft window takes agents. Its agent link listens on loopback (127.0.0.1) with a
|
||||
token kept in an owner-only file in the settings folder (`agent-control.token`), and publishes
|
||||
where in `agent-connection.json` there. Turning the switch off stops it and removes the file,
|
||||
with no restart. File › Options › Agents shows where it stands.
|
||||
- `wordcraft-cli mcp` (what the launcher starts) reads that file before every tool call, so
|
||||
WordCraft may open, close or change port while the AI app stays connected. It signs in with the
|
||||
challenge handshake: the window proves it holds the token before anything derived from the token
|
||||
is sent ([Token](control-protocol.md#token)). Calls then act in the window: the person sees the
|
||||
document change, and `screenshot`, `click`, `key` and `ui_inspect` work.
|
||||
- What agents do in the window reads and writes only in the **agent folders**: by default
|
||||
`Documents/ArtCraft/Agents/WordCraft` (made when first used), or the folders chosen in File ›
|
||||
Options › Agents. That covers their commands, the screenshots they save, and the keys and clicks
|
||||
they send: an agent's Ctrl+S on a document saved elsewhere is refused, the person's own is not.
|
||||
The `agent_folders` tool tells an agent where they are. Agents can't change these settings.
|
||||
- While WordCraft is closed, File › Options › Agents › *When WordCraft is closed* decides what a
|
||||
tool call does: **Open WordCraft** (the default; it starts the app and waits up to 45 s for it),
|
||||
**Work without a window** (a headless session in the agent folders), or **Ask to open WordCraft**
|
||||
(the call fails and says so). `--when-closed launch|headless|error` overrides it for one server.
|
||||
A session that went headless stays headless, so documents don't move under the agent.
|
||||
|
||||
Without the suite's `AI-MCP` flag (`ArtCraft/flags.toml`) the launcher's switch means nothing and
|
||||
`mcp` works as below. A WordCraft Nightly window takes no agents.
|
||||
|
||||
## Headless
|
||||
|
||||
```sh
|
||||
wordcraft-cli mcp --automation-read-root /work/project --automation-write-root /work/project/out
|
||||
```
|
||||
|
||||
Claude Code: `claude mcp add wordcraft -- wordcraft-cli mcp --automation-read-root /work/project --automation-write-root /work/project/out`.
|
||||
With `--headless`, or while the launcher's switch is off, the server runs a headless session (no
|
||||
window) and starts only with both roots: see [Confining file access](#confining-file-access).
|
||||
Without them it stops with an error naming the two flags (shared rule 18, #7124). With the switch
|
||||
on, roots given to `mcp` replace the agent folders for its headless sessions.
|
||||
|
||||
The server runs a headless session (no window) and starts only with both roots: see
|
||||
[Confining file access](#confining-file-access). Without them it stops with an error naming the
|
||||
two flags (shared rule 18, #7124).
|
||||
`--connect HOST:PORT` is deprecated and will be removed in the next release: plain `mcp` finds the
|
||||
open window by itself. Until then `--connect` prints a note on standard error and is otherwise
|
||||
ignored. `wordcraft --control PORT` still starts a control channel for scripts and tests
|
||||
([control protocol](control-protocol.md)); `mcp` doesn't use it, and it is not confined.
|
||||
|
||||
**`--connect` is refused for now.** `wordcraft-cli mcp --connect HOST:PORT` bridged an agent to the
|
||||
running app (`wordcraft --control 7981`), with clicks, keys and screenshots. The app doesn't
|
||||
confine its control channel to automation roots yet, so the bridge would give the agent every file
|
||||
the user can reach; it stops with an error pointing to #3695 and #5819. Once the app confines the
|
||||
channel, connected mode will be allowed when the app has both roots set. The rest of this page
|
||||
describes the connected mode as it will work then.
|
||||
|
||||
With `--connect`, the bridge authenticates once per connection with the app's control token, which
|
||||
it reads from `WORDCRAFT_CONTROL_TOKEN` or from the token file the app writes at start. It sends
|
||||
the token only to 127.0.0.1 and `localhost`; see [Token](control-protocol.md#token). The bridge serves even when the app
|
||||
isn't open yet: tool calls return "not reachable … will retry on each call" and succeed once the
|
||||
app's port opens (#4078), so a client that starts before WordCraft doesn't lose the server for
|
||||
its whole session.
|
||||
The window client's calls are tried again once when nothing was sent yet or the call only reads;
|
||||
a mutation whose outcome is unknown is never sent again (see below).
|
||||
|
||||
## Delivery failures
|
||||
|
||||
The connected bridge retries a request once if no write was attempted (for example, a failed
|
||||
The window client retries a request once if no write was attempted (for example, a failed
|
||||
connection). Once sending starts, a write or flush failure can mean the app already received
|
||||
the complete JSON body, even if its newline was not delivered. A lost reply has the same
|
||||
uncertainty. Mutations then return an `outcome unknown` error and are never automatically
|
||||
@@ -121,8 +146,8 @@ config works across the suite) keep the agent to the folders you give it:
|
||||
the name it is given, so that name must be inside the write root as well as what it leads to:
|
||||
a link outside the root pointing in is refused (#3735).
|
||||
- Read and write access are separate. Give the same folder twice for both; a root left out grants
|
||||
none of its access at the engine level. `wordcraft-cli mcp` needs both flags and refuses to start
|
||||
with one or neither.
|
||||
none of its access at the engine level. A headless `wordcraft-cli mcp` needs both flags and
|
||||
refuses to start with one or neither.
|
||||
- A path is made absolute against the server's working directory, then its links are followed: a
|
||||
file (or folder) link that leads out of a root is outside it. For a file that doesn't exist yet,
|
||||
its nearest existing folder's links are followed and the rest must be plain names, so `..` below a
|
||||
@@ -136,9 +161,9 @@ config works across the suite) keep the agent to the folders you give it:
|
||||
- The roots must be existing folders; a missing one stops the server with an error. Each flag is
|
||||
given once (`--flag <dir>` or `--flag=<dir>`).
|
||||
|
||||
The flags confine the headless server. WordCraft's desktop app has no equivalent flags yet, so a
|
||||
running app (`wordcraft --control`) is not confined, and `--connect` is refused, with the flags or
|
||||
without (#3695, #5819).
|
||||
The flags confine the headless server. In the open window the agent folders confine agents the
|
||||
same way ([With the ArtCraft Launcher](#with-the-artcraft-launcher)). A control channel started
|
||||
with `wordcraft --control` has no such flags yet and is not confined (#3695, #5819).
|
||||
|
||||
What the roots do not cover: commands that take no path (`text.insert`, `execute` of anything that
|
||||
works on the open document) can still read and change that document, and `get_text` and
|
||||
@@ -159,14 +184,14 @@ the suite's font store (see [installing languages](spelling-dictionaries.md#lang
|
||||
| Command | Params | Returns |
|
||||
|---|---|---|
|
||||
| `proof.packs` | `{"refresh"?: bool}` (fetch the pinned index again) | `{"packs": [{"locale", "name", "size", "licence", "class", "source" (upstream), "archive", "spelling", "hyphenation", "installed"}], "languages": [{"tags", "pack", "installed", "size", "proofing" (built_in, installed, own_dictionary, system_dictionary, install, grammar_built_in, not_available), "default"}] (Options › Language › Your languages), "installed": [...], "installing": [{"locale", "done", "total"}], "refreshing", "errors": {locale: message}, "network", "available"}` |
|
||||
| `proof.installPack` | `{"locale": "nl"}` | `{"locale", "name", "licence", "installed": true}` (`"already": true` when it was); with `--connect`, `{"locale", "started": true}` |
|
||||
| `proof.installPack` | `{"locale": "nl"}` | `{"locale", "name", "licence", "installed": true}` (`"already": true` when it was); in the open window, `{"locale", "started": true}` |
|
||||
| `proof.removePack` | `{"locale": "nl"}` | `{"locale", "installed": false}` |
|
||||
|
||||
None opens anything. Downloading is the font store's single consent setting: an agent can install
|
||||
only while the person has turned it on in the app (File › Options › Language: Install or Add a
|
||||
language…), and can never turn it on itself; otherwise `proof.installPack` fails with
|
||||
*downloading is turned off*. `refresh` likewise needs it on. Every archive is checked against the
|
||||
sha256 in the pinned index before it is unpacked. With `--connect` the commands act on the running
|
||||
sha256 in the pinned index before it is unpacked. In the open window the commands act on the
|
||||
app's packs, and an install or a `refresh` runs in the background so the window keeps working: the
|
||||
command returns `"started": true` at once, and `proof.packs` shows it under `installing` (or
|
||||
`refreshing`), then under `installed`, or its failure under `errors`. A removal waits until that
|
||||
@@ -199,7 +224,8 @@ test source in File › Options › Language and on the bar's Install.
|
||||
| `get_text` / `inspect_document` | read the document back (verify without screenshots); a header or footer's `fields` mark those with `perPage` (PAGE, NUMPAGES, STYLEREF…), whose stored result isn't what every page shows (`render_page` shows that); `fieldsTruncated` means a part has more than the 200 listed; a field kept as a range (a TOC, a bibliography) gives at most 2000 characters of its result, with `resultTruncated` when it has more |
|
||||
| `render_page` | a page as PNG |
|
||||
| `parity` | feature coverage |
|
||||
| `screenshot`, `click`, `key`, `ui_inspect` | app only (`--connect`) |
|
||||
| `screenshot`, `click`, `key`, `ui_inspect` | the open window only |
|
||||
| `agent_folders` | where agents put files to open and find what they saved: `read_folder`, `write_folder` (a path or `null`) |
|
||||
|
||||
### Several documents
|
||||
|
||||
@@ -219,7 +245,7 @@ document: the tool works on that document and the active one stays active.
|
||||
An id that names no open document, or a value that isn't a whole number from 0 up, is a tool error.
|
||||
`execute` with `view.switchWindows {"id": n}` makes a document active, and `file.closeDocument
|
||||
{"id": n, "force"?: true}` closes one (unsaved changes need `force`); `file.close {"save"?: true, "force"?: true}` closes the shown
|
||||
document, and unsaved changes need `save` (write, then close) or `force`. Through `--connect`, `doc`
|
||||
document, and unsaved changes need `save` (write, then close) or `force`. In the open window, `doc`
|
||||
reaches the app's control channel (see [Open documents](control-protocol.md#open-documents)); the
|
||||
app's window keeps showing the document it showed. `screenshot`, `click` and `key` act on the
|
||||
window, so they work on the document on screen.
|
||||
|
||||
@@ -20,9 +20,12 @@ finish-args:
|
||||
# The shared updater inspects and updates this installation via flatpak-spawn --host.
|
||||
- --talk-name=org.freedesktop.Flatpak
|
||||
- --filesystem=xdg-data/ArtCraft/versions:ro
|
||||
# Display: Wayland first; X11 only when no Wayland compositor is running.
|
||||
# Display: Wayland, plus X11 always. The clipboard (arboard) needs the Wayland data-control
|
||||
# protocol, which KWin does not offer to apps; it then falls back to the X11 clipboard, which
|
||||
# XWayland bridges. With fallback-x11 the sandbox has no X11 under Wayland and paste fails
|
||||
# (#8969, #8868). Remove --socket=x11 once the clipboard uses wl_data_device.
|
||||
- --socket=wayland
|
||||
- --socket=fallback-x11
|
||||
- --socket=x11
|
||||
# X11 shared memory (MIT-SHM). Without it the X11 fallback is slow or fails.
|
||||
- --share=ipc
|
||||
# GPU access for the wgpu renderer (Vulkan, or GL as a fallback).
|
||||
|
||||
@@ -21,9 +21,12 @@ finish-args:
|
||||
# The shared updater inspects and updates this installation via flatpak-spawn --host.
|
||||
- --talk-name=org.freedesktop.Flatpak
|
||||
- --filesystem=xdg-data/ArtCraft/versions:ro
|
||||
# Display: Wayland first; X11 only when no Wayland compositor is running.
|
||||
# Display: Wayland, plus X11 always. The clipboard (arboard) needs the Wayland data-control
|
||||
# protocol, which KWin does not offer to apps; it then falls back to the X11 clipboard, which
|
||||
# XWayland bridges. With fallback-x11 the sandbox has no X11 under Wayland and paste fails
|
||||
# (#8969, #8868). Remove --socket=x11 once the clipboard uses wl_data_device.
|
||||
- --socket=wayland
|
||||
- --socket=fallback-x11
|
||||
- --socket=x11
|
||||
# X11 shared memory (MIT-SHM). Without it the X11 fallback is slow or fails.
|
||||
- --share=ipc
|
||||
# GPU access for the wgpu renderer (Vulkan, or GL as a fallback).
|
||||
|
||||
Reference in New Issue
Block a user