openpencil/crates
Kayshen-X 8b3bdcdfd5 feat(mcp): get_node surfaces fill_ref + stroke_ref from var_table
`NodeRecord` grew two fields so LLM clients can tell when a node's
colour follows a variable instead of a literal. Without this, the
client can only see the resolved hex — it doesn't know whether to
bump the variable (theme-wide ripple) or write a per-node override.

`crates/openpencil-shell-core/src/mcp/tools.rs`:

  - `NodeRecord { fill_ref: String, stroke_ref: String }`. Empty
    string when the node doesn't use a variable for that paint
    channel. Empty (not omitted) so clients can probe with a
    single `out.get("fill_ref") == Some(&"")` instead of having
    to handle the missing-key case as well.
  - `get_node_snapshot` + `walk_node` thread the document's
    `var_table` through the tree walk and look up
    `var_table.fill_refs[node.id]` + `var_table.stroke_refs[
    node.id]` per node. The lookup is O(log n) BTreeMap, so the
    full-document walk stays O(n log n) — fine for typical
    documents (≤ thousands of nodes); LLM call frequency is far
    below paint frequency anyway.
  - The `get_node` `call()` payload adds the two new keys
    alongside the existing kind / name / bounds / parent_id.

Test (1 added, 281 shell-core total, 33 mcp module total):
  - `get_node_surfaces_fill_and_stroke_refs` — installs
    `fill_refs[11] = "color-primary"` +
    `stroke_refs[11] = "color-accent"` on the sample doc, calls
    `get_node` with node_id=11, asserts the payload carries the
    variable names. A second call with node_id=12 (no ref
    mapping) asserts both fields are empty strings (not absent),
    pinning the API contract.

The MCP read-side now covers the full graph that paint-time `$ref`
substitution uses: list_variables → choose a variable;
list_pages → choose a page; get_document_info → counts;
get_selection → current focus; get_node(id) → kind, bounds,
parent, and which paint channels follow which variable.
2026-05-14 18:27:46 +08:00
..
anthropic-agent-sdk chore(crates): move vendored SDKs into workspace as forkable crates 2026-05-14 16:49:17 +08:00
copilot-sdk chore(crates): move vendored SDKs into workspace as forkable crates 2026-05-14 16:49:17 +08:00
openpencil-app feat(openpencil-app): skeleton crate (Stage F entry placeholder) 2026-05-03 22:05:00 +08:00
openpencil-desktop refactor(desktop): extract rotate-cursor builder into cursor_icon.rs 2026-05-14 17:38:16 +08:00
openpencil-shell-core feat(mcp): get_node surfaces fill_ref + stroke_ref from var_table 2026-05-14 18:27:46 +08:00
openpencil-shell-native fix(geometry): canvas_region shrinks for VariablesPanel too (codex BLOCK) 2026-05-14 17:57:55 +08:00
openpencil-shell-web feat(shell): export dialog + multi-format raster (PNG/JPEG/WEBP) + Property-panel preview 2026-05-14 14:02:52 +08:00
pen-codegen chore(workspace): cargo-deny 0.18 activation (Phase 1 Task 1.8 Step 6) 2026-05-03 23:05:00 +08:00
pen-core chore(workspace): cargo-deny 0.18 activation (Phase 1 Task 1.8 Step 6) 2026-05-03 23:05:00 +08:00
pen-engine chore(workspace): cargo-deny 0.18 activation (Phase 1 Task 1.8 Step 6) 2026-05-03 23:05:00 +08:00
pen-figma chore(workspace): cargo-deny 0.18 activation (Phase 1 Task 1.8 Step 6) 2026-05-03 23:05:00 +08:00
pen-types feat(pen-types): skeleton crate (bucket A) 2026-05-03 22:35:00 +08:00
wasm-libc-shim style(shell): cargo fmt --all (rustfmt-clean) 2026-05-10 18:47:33 +08:00
CLAUDE.md feat(shell): canonical .op loader + jian-core layout + visual fidelity pass 2026-05-14 09:26:08 +08:00