#778: land the picture-probe and MCP cutovers (#6955, #6956) on main (#6960)

* #778: take craft-libs integration/wordcraft-778 at beeea924

Every craft-libs git dependency (workspace, ui-egui, wordcraft, wordcraft-web,
krilla patch) moves from 453b0da782 to beeea92451 (craft-libs main 0649a07aa
plus open PRs #2061-#2064). Cargo.lock: only craft-libs sources move, plus
windows-sys edge changes inside craft-libs crates; no crates.io versions change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* #778: docx stacking-order test follows the shared reader's one-more z

craft-libs 5f453efa9 (craft-docx: a relativeHeight of 0 stays the lowest
stacking order) reads Float::z as one more than the file's relativeHeight and
writes stored orders one less, so a file's 0 is no longer "none". The test
expected the old values; relative order and the round trip are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* #778: take craft-libs integration/wordcraft-778 at 24a15211

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* deps: pin craft-libs to the merged shared cutover prerequisites

* #778: pin craft-libs main at 93dac78c (with #2061-#2064)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* #778: picture probes use craft-image-codecs (DIB wrapping, JPEG budget, PNG/WebP) (#6955)

* #778: picture: wrap clipboard DIBs with craft-image-codecs' bmp_probe

probe_dib's local dib_to_bmp and dib_layout are replaced by
craft_image_codecs::bmp_probe::{dib_to_bmp, dib_layout}. The shared copies are
the same code; the only change is that they reserve their output fallibly. A
failed reservation in dib_to_bmp (the BMP's bytes can't be allocated) is
Refusal::TooLarge with the size the DIB header declares, the refusal a picture
too large to hold already gets; dib_layout leaves the DIB unchanged then.

The local dib_to_bmp name stays as a thin wrapper returning Result<_, Refusal>.
The old code is kept in the tests as an oracle: wrapping and layout are
byte-equal on thousands of crafted DIBs (core, info, V4, V5 headers, bit
fields, alpha with BI_RGB, every truncation), and probe_dib agrees.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* #778: picture: budget JPEG coefficients with craft-image-codecs

probe's JPEG held-coefficient estimate (jpeg_coefficients, frame_coefficients,
worst_coefficients) is replaced by craft_image_codecs::jpeg_worst_case_coefficients,
which returns the larger of that same estimate and the shared held_coefficients.
So the charge can only grow, never shrink.

It grows for: a SOF0/SOF1 8-bit first frame whose first scan has fewer
components than the frame (the decoder holds the coefficients until the other
scans); and a first-frame SOF2 with sampling factors above 4 (the old rule
clamped them to 4). A real baseline JPEG with all components in its first scan
is charged nothing, as before. With the 512 MiB budget, a 4:4:4 non-interleaved
baseline JPEG is now refused from about 59.6 Mpx instead of 67 Mpx; 4:2:0 and
4:2:2 stay under the RGBA8 conversion and are unchanged.

The old code is kept in the tests as an oracle: the new charge is never less
(crafted headers, every prefix, random damage), equal where the shared rule adds
nothing, and one test pins a case where it grows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* #778: picture: read PNG and WebP probes with craft-image-codecs

The local png_chunks header read is replaced by
craft_image_codecs::png_probe::pixel_model, and the VP8X alpha check in probe
by webp_probe::has_alpha (an error reads as no alpha, as non-RIFF input did).

PNG: for every valid colour type and bit depth, with and without tRNS and an
iCCP chunk, the size, bytes a pixel and alpha are what the old read gave
(PixelModel::bytes_per_pixel is channels * 2 for 16 bits, else channels, with a
palette as RGB and tRNS adding a channel to grey, RGB and palette). pixel_model
is stricter, so these are now refused (probe: Refusal::Broken, dimensions:
None) where the old read measured them: an invalid colour type and bit depth
pair, a zero or past-i32::MAX side, and more than 65,536 chunks before the
image data. None is a valid PNG.

WebP: a bare lossless (VP8L) picture whose header sets alpha_is_used now reports
alpha; the old rule only knew the VP8X flag.

The old PNG read and WebP rule are kept in the tests as oracles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* #778: picture tests follow craft-image-codecs' DIB fixes

The shared dib_to_bmp no longer adds 12 appended mask bytes to the pixel
offset of 52/56-byte BI_BITFIELDS headers, and dib_layout treats the bytes
after the header as a mask copy only when the payload is longer than the
pixel rows need. The differential test excludes exactly those inputs by
named predicate, asserts the new output for them, and stays byte-equal
elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* #778: dib_header_dims uses the shared fallible dib_to_bmp

Calls the shared probe directly so a failed allocation cannot recurse through the refusal wrapper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* #778: WordCraft's MCP stdio server runs on craft-mcp-server (#6956)

The JSON-RPC framing, bounded line reading, initialize, ping, tools/* and
resources/* now come from craft_mcp_server::Server; WordCraft keeps its tools,
resources, instructions and backends. The old server.rs stays as a test-only
oracle for a differential test. click/key schemas list every argument the app
accepts, since the shared check refuses unlisted ones.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
This commit is contained in:
authored and GitHub committed 2026-11-17 22:19:16 +01:00
1 parent c39b0e5755
commit dfd51a3cdc
10 files changed
+1374 -323

No files matched your search

+12 -1
View File
@@ -1,6 +1,6 @@
# MCP server
> **Last updated:** 2026-11-14 · 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-11-17 · 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.
WordCraft speaks the [Model Context Protocol](https://modelcontextprotocol.io) over stdio, so
Claude and other agents can write and edit documents.
@@ -36,6 +36,17 @@ On stdio, an invalid UTF-8 request line returns JSON-RPC parse error `-32700`. I
the backend, and the server continues with the next line instead of substituting characters
in text or paths.
The protocol core (framing, lifecycle, `tools/*`, `resources/*`) is the shared `craft-mcp-server`
crate; WordCraft supplies the tools, resources and instructions. What that means for a client:
- A request line over 1 MiB gets `-32600` "request too large" and the server keeps serving.
- A JSON-RPC batch holds at most 1000 messages; a larger one gets `-32600` "batch too large".
- A `tools/call` whose arguments do not match the tool's schema (a missing required argument, an
argument the tool does not list, or one of the wrong type) or that names an unknown tool returns
a tool result with `isError: true` naming the problem, not a JSON-RPC error.
- `resources/read` with no `uri` is `-32002` (unknown resource), like any unknown `uri`.
- `initialize` reports `listChanged: false` for tools and resources; `prompts/list` is empty.
## Scripts from the command line
`wordcraft-cli run --script job.json` (`--script -` reads standard input) runs the commands in a