mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
docs: tests and agents run mcp --headless
Plain `photocraft-cli mcp` now works in the open window while the ArtCraft Launcher's agents switch is on, and may start PhotoCraft, also on a developer's machine. AGENTS.md says scripts, tests and agent sessions pass `--headless` (and tests give the CLI their own settings, launcher and flags folders); the headless examples in docs/development.md, docs/mcp.md, docs/control-protocol.md, the book and the README use it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
7091f8f416
commit
fcbc0a69f8
6 files changed
+14
-7
No files matched your search
@@ -161,6 +161,8 @@ cargo xtask test-corpus # if you touched psd, io, codecs, compose, gpu, text
|
||||
|
||||
While iterating, run less and keep the full commands above as the final gate: `cargo test -p <crate> --lib --tests` skips the examples and doctests plain `cargo test` builds every time (ui-egui has 11 examples), and `cargo test -p <crate> --test <file>` runs one integration-test file. `cargo nextest run` runs tests in parallel across binaries; see `docs/development.md` › Faster test loops.
|
||||
|
||||
**MCP in tests and agent sessions: `photocraft-cli mcp --headless`.** Plain `photocraft-cli mcp` works in the open PhotoCraft window while the ArtCraft Launcher's agents switch is on, and then may start PhotoCraft on the developer's machine when it is closed. Scripts, tests and agents that want a session without a window pass `--headless` (or use `photocraft-cli serve`); a test that runs the CLI also gives it its own settings, launcher and flags folders (`PHOTOCRAFT_CONFIG_DIR`, `CRAFT_MCP_DIR`, `CRAFT_FLAGS_FILE`, as `crate::command()` in `apps/photocraft-cli/tests/it/main.rs` does). To drive the running app on purpose, use `--control` (`docs/development.md`).
|
||||
|
||||
**Test corpora.** Real-file corpora live in `corpus/` (gitignored, never committed), fetched at pinned commits and sha256-verified by `cargo xtask corpus --all`: our Photoshop- and GIMP-authored oracles from https://github.com/storytold/photocraft-corpus plus psd-tools, ag-psd and PngSuite from their upstreams. Pins: `xtask/src/corpus_pins.rs`. The corpus tests are opt-in (cargo feature `corpus`): plain `cargo test` skips them, and with the feature on a missing corpus fails ("run `cargo xtask corpus --all`"). `cargo xtask test-corpus` fetches and runs them all. CI always runs them (the `corpus` job, cached by pin). Never commit corpus files; new oracles go to photocraft-corpus (its `AGENTS.md`), then a pin bump here. Details: `docs/development.md` › Test corpora.
|
||||
|
||||
Commands must **never panic** on bad input (Rule 9): every `run` closure and the code it calls returns `Err`, not a panic, for any params or document state. New commands come with a graceful-failure test (empty/out-of-range/wrong-type params → `Err`, not a crash).
|
||||
|
||||
@@ -242,8 +242,10 @@ photocraft-cli batch --actions grade.json --in ./raw --out ./graded
|
||||
# Every subcommand explains itself
|
||||
photocraft-cli batch --help
|
||||
|
||||
# Let an agent drive it over MCP (headless, or bridged to the running app)
|
||||
# Let an agent drive it over MCP: the open window while agents are allowed, otherwise headless
|
||||
photocraft-cli mcp
|
||||
# Always without a window (scripts, tests)
|
||||
photocraft-cli mcp --headless
|
||||
```
|
||||
|
||||
To let Claude or another AI app drive the open PhotoCraft window without a terminal, turn on **ArtCraft Launcher › Settings › AI agents** and click **Add** next to the AI app (one entry for every Craft app). See [`docs/mcp.md`](docs/mcp.md). These settings are behind the Craft suite's `AI-MCP` feature flag: set `AI-MCP = true` in `ArtCraft/flags.toml`, or start PhotoCraft with `CRAFT_FLAGS=AI-MCP`.
|
||||
|
||||
@@ -11,10 +11,11 @@ The simplest setup needs no terminal: turn on ArtCraft Launcher › Settings ›
|
||||
For a source checkout, first [install the CLI on PATH and register the server](../../../docs/mcp.md#install-and-register).
|
||||
The installed binary survives `cargo clean`; a symlink into `target/release` does not.
|
||||
|
||||
Start the headless server with:
|
||||
Start the headless server with (without `--headless`, `mcp` works in the open PhotoCraft window
|
||||
while the ArtCraft Launcher's agents switch is on):
|
||||
|
||||
```sh
|
||||
photocraft-cli mcp --automation-read-root /work/project --automation-write-root /work/project
|
||||
photocraft-cli mcp --headless --automation-read-root /work/project --automation-write-root /work/project
|
||||
```
|
||||
|
||||
Bridge to a running desktop application with the same private token file used by the app:
|
||||
|
||||
@@ -415,7 +415,7 @@ magenta alignment lines. `ui.pointer` drives the same code, so agents get identi
|
||||
|
||||
`photocraft-automation` provides an MCP server built on the official Rust SDK (`rmcp`). It runs in one of two modes:
|
||||
|
||||
- **Headless** (`photocraft-cli mcp`): an in-process `photocraft_engine::Session`. There is no window. CPU composition is the default; `--gpu` or `PHOTOCRAFT_GPU=1` enables optional GPU rendering with automatic CPU fallback.
|
||||
- **Headless** (`photocraft-cli mcp --headless`, or plain `mcp` while agents may not use the app): an in-process `photocraft_engine::Session`. There is no window. CPU composition is the default; `--gpu` or `PHOTOCRAFT_GPU=1` enables optional GPU rendering with automatic CPU fallback.
|
||||
- **Bridge** (`photocraft-cli mcp --bridge 127.0.0.1:7878 --control-token-file <path>`): every tool is forwarded to a running `photocraft --control 7878 --control-token-file <path>` over this protocol, so agents see and drive the live app. Explicit `--gpu` / `--no-gpu` flags are rejected with a usage error because the desktop controls rendering; `PHOTOCRAFT_GPU` is ignored in bridge mode. `--bridge 7878` is short for `--bridge 127.0.0.1:7878`. With no `--bridge`, `PHOTOCRAFT_CONTROL_PORT` selects the bridge port (`127.0.0.1:<port>`), and the CLI says so on standard error; with neither (or the variable empty), the MCP runs headless. A value that is not a port is a usage error naming the variable. `--automation-read-root` or `--automation-write-root` with the variable set is a usage error, since the bridge would drop the roots.
|
||||
|
||||
- **The open window** (plain `photocraft-cli mcp`): the bridge, with the address and token read before every tool call from `agent-connection.json` in the app's settings folder, while the person lets agents use the app; otherwise headless, as above (`--headless` forces that). The app publishes that file while agents may connect (the ArtCraft Launcher's switch; without the `AI-MCP` flag a saved Control Port), not with `--control`, and removes it when the connection stops; a file left by a crash fails the connection probe and counts as no app. See [MCP conventions](mcp.md#connecting-the-desktop-app-no-terminal).
|
||||
|
||||
+1
-1
@@ -322,7 +322,7 @@ At startup the desktop lists recovery metadata, then decodes one document at a t
|
||||
|
||||
`photocraft-cli mcp` serves MCP on stdio using `crates/automation`, which is built on `rmcp`:
|
||||
|
||||
- **Headless:** `photocraft-cli mcp --automation-read-root <project> --automation-read-root <library> --automation-write-root <project>`. It drives an in-process engine session with ordered read directories and one write directory.
|
||||
- **Headless:** `photocraft-cli mcp --headless --automation-read-root <project> --automation-read-root <library> --automation-write-root <project>`. Use `--headless` in scripts, tests and agent sessions: without it `mcp` works in the open window while the ArtCraft Launcher's agents switch is on, and may start PhotoCraft (When PhotoCraft Is Closed defaults to starting it). It drives an in-process engine session with ordered read directories and one write directory.
|
||||
- **Live app:** start `photocraft --control 7878 --control-token-file <private-path> --automation-read-root <project> --automation-read-root <library> --automation-write-root <project>`, then run `photocraft-cli mcp --bridge 127.0.0.1:7878 --control-token-file <private-path>`. The desktop process owns the roots; root flags on the bridging CLI are a usage error. See `docs/control-protocol.md#mcp-bridge`.
|
||||
- **Live app, no flags:** with the `AI-MCP` flag, turn on ArtCraft Launcher › Settings › AI agents and add the MCP client there; plain `photocraft-cli mcp` then works in the open window. The app publishes its port and token file in `agent-connection.json` in the settings folder; `mcp` reads it on every call. Without a launcher, a scratch `CRAFT_MCP_DIR` with an `apps.json` naming `photocraft` (the format in storytold/craft-ai-integrations, crate `craft-ai-agents`) turns the switch on for a test. See [MCP conventions](mcp.md#connecting-the-desktop-app-no-terminal). Test it against a scratch settings folder with `PHOTOCRAFT_CONFIG_DIR`, which both the app and the CLI honour.
|
||||
|
||||
|
||||
+4
-2
@@ -106,10 +106,12 @@ not put the CLI on `PATH`.
|
||||
|
||||
## Start a session
|
||||
|
||||
PhotoCraft follows the same conventions as FilmCraft #28. Start a headless session:
|
||||
PhotoCraft follows the same conventions as FilmCraft #28. Start a headless session (`--headless`:
|
||||
without it, `mcp` works in the open PhotoCraft window while the ArtCraft Launcher's agents switch is
|
||||
on, and may start the app; scripts, tests and agents pass it):
|
||||
|
||||
```sh
|
||||
photocraft-cli mcp \
|
||||
photocraft-cli mcp --headless \
|
||||
--automation-read-root /work/project \
|
||||
--automation-read-root /library/reference \
|
||||
--automation-write-root /work/project
|
||||
|
||||
Reference in new issue
Block a user