openpencil/apps/cli/README.zh.md
Kayshen Xu b4d1d2a7bb
V0.5.1 (#77)
* fix(docker): support multi-platform builds and fix monorepo paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* perf(renderer): cache pre-rasterized paragraph images to avoid per-frame glyph rasterization   (#76)

* fix(canvas): stabilize frame label size during zoom

  Draw frame labels in screen-space after the viewport transform
  restore, converting scene coords manually. Previously fontSize=12/zoom
  fed into Math.ceil caused integer-boundary jumps that made labels
  flicker during zoom. Also skip shadow rendering while actively
  zooming for smoother performance.

* perf(renderer): cache pre-rasterized paragraph images to avoid per-frame glyph rasterization

   - Add paraImageCache (SkImage, 128 MB LRU limit) keyed on the same key as paraCache
   - Use drawImageRect instead of drawParagraph on cache hit, skipping per-frame glyph shaping and rasterization
   - Fall back to direct drawParagraph only when off-screen surface creation (MakeSurface) fails
   - Extract _dpr getter to deduplicate device-pixel-ratio resolution logic across draw paths
   - Evict oldest entries when cache exceeds byte limit; delete SkImage on eviction and dispose()

* feat(cli): introduce OpenPencil CLI for terminal control of the design tool

- Added a new CLI application under `apps/cli` to manage OpenPencil from the terminal.
- Implemented commands for app control (`start`, `stop`, `status`), document operations (`open`, `save`, `get`, `selection`), and design manipulation (`design`, `import`).
- Enhanced documentation with usage instructions and platform support details.
- Updated build scripts to include CLI compilation and publishing processes.
- Introduced a new GitHub Actions workflow for publishing the CLI to npm.
- Updated existing workflows to integrate CLI build steps and ensure proper versioning across packages.

* docs: update README files to include CLI tool details and multi-platform code export

- Added CLI section to README files in multiple languages, detailing commands for terminal control of the design tool.
- Included instructions for global installation and usage examples for the CLI.
- Expanded documentation on multi-platform code export capabilities from a single `.op` file to various frameworks.
- Updated CLAUDE.md to reference the new CLI documentation and its integration with the design tool.

* chore(bun.lock): update package dependencies to specific versions

- Removed workspace references for several packages in the bun.lock file.
- Updated dependencies for `@zseven-w/pen-core`, `@zseven-w/pen-types`, `@zseven-w/pen-codegen`, `@zseven-w/pen-figma`, and `@zseven-w/pen-renderer` to version `0.5.1-beta.1`.
- Ensured consistency in dependency management across the project.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: leinaldo <60176594+leinaldo@users.noreply.github.com>
2026-03-23 21:20:59 +08:00

3.9 KiB
Raw Blame History

@zseven-w/openpencil

English · 简体中文 · 繁體中文 · 日本語 · 한국어 · Français · Español · Deutsch · Português · Русский · हिन्दी · Türkçe · ไทย · Tiếng Việt · Bahasa Indonesia

OpenPencil 的命令行工具 — 从终端控制设计工具。

安装

npm install -g @zseven-w/openpencil

平台支持

CLI 会自动检测并启动各平台上的 OpenPencil 桌面应用:

平台 检测的安装路径
macOS /Applications/OpenPencil.app, ~/Applications/OpenPencil.app
Windows NSIS 用户级 (%LOCALAPPDATA%)、系统级 (%PROGRAMFILES%)、便携版
Linux /usr/bin, /usr/local/bin, ~/.local/bin, AppImage (~/Applications, ~/Downloads), Snap, Flatpak

用法

op <command> [options]

输入方式

接受 JSON 或 DSL 的参数支持三种传入方式:

op design '...'              # 内联字符串(适合小型内容)
op design @design.txt        # 从文件读取(推荐用于大型设计)
cat design.txt | op design - # 从标准输入读取(管道传入)

应用控制

op start [--desktop|--web]   # 启动 OpenPencil默认桌面版
op stop                      # 停止运行中的实例
op status                    # 检查运行状态

设计(批量 DSL

op design <dsl|@file|-> [--post-process] [--canvas-width N]
op design:skeleton <json|@file|->
op design:content <section-id> <json|@file|->
op design:refine --root-id <id>

文档操作

op open [file.op]            # 打开文件或连接到实时画布
op save <file.op>            # 保存当前文档
op get [--type X] [--name Y] [--id Z] [--depth N]
op selection                 # 获取当前画布选中项

节点操作

op insert <json> [--parent P] [--index N] [--post-process]
op update <id> <json> [--post-process]
op delete <id>
op move <id> --parent <P> [--index N]
op copy <id> [--parent P]
op replace <id> <json> [--post-process]

代码导出

op export <format> [--out file]
# 格式react, html, vue, svelte, flutter, swiftui, compose, rn, css

变量与主题

op vars                      # 获取变量
op vars:set <json>           # 设置变量
op themes                    # 获取主题
op themes:set <json>         # 设置主题
op theme:save <file.optheme> # 保存主题预设
op theme:load <file.optheme> # 加载主题预设
op theme:list [dir]          # 列出主题预设

页面

op page list                 # 列出页面
op page add [--name N]       # 添加页面
op page remove <id>          # 删除页面
op page rename <id> <name>   # 重命名页面
op page reorder <id> <index> # 调整页面顺序
op page duplicate <id>       # 复制页面

导入

op import:svg <file.svg>     # 导入 SVG 文件
op import:figma <file.fig>   # 导入 Figma .fig 文件

布局

op layout [--parent P] [--depth N]
op find-space [--direction right|bottom|left|top]

全局选项

--file <path>     目标 .op 文件(默认:实时画布)
--page <id>       目标页面 ID
--pretty          人类可读的 JSON 输出
--help            显示帮助
--version         显示版本

许可证

MIT