* fix(app): record MCP and CLI structural edits as undo steps The automation bridge ran non-atomic tools, render, and eval without an undo entry, so Edit > Undo could not revert layers an MCP client or the CLI created, deleted, or rearranged. Snapshot the page around these edits as the AI chat does, and skip the entry when nothing changed so read-only scripts leave the history alone. * feat(app): activate documents, undo, redo, and change settings over automation Add activate_document, undo, redo, get_settings, and update_settings to the app's automation bridge. Settings cover appearance, snapping, canvas rendering, recovery, and chat preferences, validated with Valibot and applied through their owning stores; credentials, models, MCP connections, storage, and tool access stay out of reach. * feat(mcp): expose document activation, history, and settings tools * feat(cli): manage documents, history, settings, and tools in the running app Turn documents into a command group (list, open, new, save, close, activate), add undo, redo, and settings get/set, and add tool list/describe/call so every MCP tool runs from the shell, against the running app or headlessly on a file. * docs: document app control from the CLI and MCP * fix: never prompt in the app from automation closes and saves close_file opened the app's Save changes dialog, which an agent cannot answer: the call timed out and the dialog stayed open. It now fails on unsaved changes unless the caller passes unsaved "save" or "discard" (CLI --save or --discard). save_file and new_document no longer open a Save dialog for a document that was never saved, report a failed save as an error, and leave the document untouched when the path is refused. * docs: describe non-interactive close and save * fix: address review findings in app automation Keep a document's source when a save to a new path fails, report vector-edit undo and redo no-ops as unapplied, echo only the applied patch from update_settings so writing cannot read settings, reject tool call --write/--output without a file, and stop settings get from following inherited keys. * fix(app): record render undo on the page that receives the layers A render into a parent on another page was snapshotted against the target page, so undo left the new layers in place. Snapshot the page that contains the parent instead, and document that eval edits made after switching pages stay outside the undo step. * feat(app): limit automation undo to its own steps and expose design check settings The undo history is shared with the person in the editor, so an agent's undo could revert the user's last edit. Automation undo and redo now act only on steps made through the bridge, and only while they are newest; otherwise they fail and leave the history alone. Vector edit mode's session history is off limits entirely. Settings automation also covers the design check preferences that landed on master.
4.9 KiB
| title | description |
|---|---|
| Просмотр документов | Дерево объектов, поиск по имени и типу и просмотр свойств из терминала. |
Просмотр документов
CLI позволяет изучать документы дизайна без запуска редактора. Те же команды работают с открытым настольным приложением, если не указывать файл.
::: tip Установка
npm install -g @open-pencil/cli
# или
bun add -g @open-pencil/cli
:::
Общие сведения
Количество страниц и объектов, используемые шрифты и размер файла:
openpencil info design.fig
Дерево объектов
openpencil tree design.fig
Поиск объектов
По типу:
openpencil find design.fig --type TEXT
По имени:
openpencil find design.fig --name "Button"
Параметры можно использовать одновременно.
Запросы XPath
Селекторы XPath находят объекты по типу, атрибутам и положению в дереве:
openpencil query design.fig "//FRAME"
По типу
openpencil query design.fig "//TEXT" # Все текстовые объекты
openpencil query design.fig "//COMPONENT" # Все компоненты
openpencil query design.fig "//INSTANCE" # Все экземпляры
По атрибутам
openpencil query design.fig "//FRAME[@width < 300]" # Фреймы уже 300 пикселей
openpencil query design.fig "//*[@cornerRadius > 0]" # Объекты со скруглёнными углами
openpencil query design.fig "//*[@visible = false]" # Скрытые объекты
openpencil query design.fig "//TEXT[@fontSize >= 24]" # Крупный текст
openpencil query design.fig "//*[@opacity < 1]" # Объекты с неполной прозрачностью
По имени и содержимому
openpencil query design.fig "//TEXT[contains(@name, 'Button')]"
openpencil query design.fig "//TEXT[contains(@text, 'Hello')]"
По иерархии
openpencil query design.fig "//SECTION//TEXT" # Текст внутри секций
openpencil query design.fig "//FRAME/TEXT" # Непосредственные текстовые потомки фреймов
openpencil query design.fig "//COMPONENT_SET//INSTANCE" # Экземпляры внутри наборов компонентов
Доступные атрибуты
name, width, height, x, y, visible, opacity, cornerRadius, fontSize, fontFamily, fontWeight, layoutMode, itemSpacing, paddingTop, paddingRight, paddingBottom, paddingLeft, strokeWeight, rotation, locked, blendMode, text, lineHeight, letterSpacing
Свойства объекта
openpencil node design.fig --id 1:23
Страницы и переменные
openpencil pages design.fig
openpencil variables design.fig
Работа с открытым приложением
Если настольное приложение запущено, не указывайте путь к файлу. CLI подключится по RPC к открытому документу:
openpencil documents list
openpencil tree
openpencil tree --document-id tab-123 --page-id 0:1
openpencil eval --document-id tab-123 --page-id 0:1 -c "..."
Для автоматизированных процессов сначала вызовите openpencil documents list --json, а затем явно передавайте --document-id и --page-id, не полагаясь на видимую активную вкладку или страницу. Как открывать, сохранять, переключать и закрывать документы, отменять изменения, менять настройки и вызывать любые инструменты редактора, описано в Controlling the App.
Проверка качества
Проверка имён, компоновки, структуры и доступности:
openpencil lint design.fig
openpencil lint design.pen --preset strict
openpencil lint design.fig --rule color-contrast
openpencil lint design.fig --list-rules
Добавьте --json, если результат будет обрабатывать другая программа.
Вывод JSON
Все команды поддерживают --json. Результат можно передать jq, проверке CI или другой программе:
openpencil tree design.fig --json | jq '.[] | .name'