Extract ~600 lines of pure DSL logic from pen-mcp/tools/batch-design.ts into a sibling batch-design-dsl.ts that does not import document-manager (node:fs) or hooks (server-injected). `handleBatchDesign` becomes a thin server-side wrapper that opens/saves the .op file around the pure executor. Backward-compat: pen-mcp barrel + batch-design.ts both re-export `runBatchDesignDsl` so existing callers keep working. apps/web dispatcher changes: - `applyBatchDesignDsl` now runs `runBatchDesignDsl` DIRECTLY in the browser against useDocumentStore.getState().document (structuredClone + apply via applyExternalDocument). - HTTP `/api/mcp/exec-tool` fallback fires only when the in-browser executor throws (rare — caller error or future regression). - Removes per-tag HTTP latency on the common batch_design path. - ctx.defaultParentId is intentionally NOT applied here: the DSL is the AI's verbatim instruction set and rewriting `null` parents would change author intent. Element-tool calls still honor it. Image search (`G()` op) is swapped from `getSyncUrl`-based absolute URL (server) to an injectable `ImageSearchFetcher` callback. Server wrapper keeps the old behavior; browser path omits the fetcher so `src` stays empty for the apps/web image pipeline (scanAndFillImages) to enrich later. Tests: - New browser-safety gate `batch-design-dsl-browser-safe.test.ts`: walks the transitive import graph from batch-design-dsl.ts and fails if any reachable file imports node:fs / node:os / node:path / document-manager / hooks. 5 checks including a negative control on batch-design.ts (wrapper) to confirm the split is meaningful. - Dispatcher tests updated to match new behavior: happy path does NOT hit fetch; malformed DSL returns `status=failed` with per-op error surfaced (via pure executor's `errors[]`), not an opaque HTTP 500. - Total: 3028 → 3033 passing. |
||
|---|---|---|
| .. | ||
| agent-native@e1f90cab96 | ||
| pen-acp | ||
| pen-ai-skills | ||
| pen-core | ||
| pen-engine | ||
| pen-figma | ||
| pen-mcp | ||
| pen-react | ||
| pen-renderer | ||
| pen-sdk | ||
| pen-types | ||
| CLAUDE.md | ||