PSD Automator
Cross-platform PSD text automation for teams using both macOS and Windows.
Scope
- - Phase 1 + 2 only.
- Screenshot understanding is intentionally out of scope.
- Uses one task protocol and two execution engines:
- macOS: AppleScript (
osascript)
- Windows: Photoshop COM (PowerShell)
Task Protocol
Read references/task-schema.json before running.
Minimal required fields:
- - INLINECODE1
- INLINECODE2 (
layerName + newText) - INLINECODE5 or INLINECODE6
Key optional fields:
- -
workflow.sourceMode: inplace or INLINECODE9 - INLINECODE10 : PNG export (
mode=single or mode=layer_sets for sliced/block assets) - INLINECODE13 : zip name for sliced assets bundle
- INLINECODE14 :
auto / always / off (macOS Unicode path bridge) - INLINECODE18 : whether to bundle
layer_sets PNGs into one zip - INLINECODE20 : screenshot path for selecting most similar exported slice
Build and Refresh PSD Index
Create or refresh local cache:
CODEBLOCK0
Incremental refresh:
CODEBLOCK1
Run a Task
Dry-run first (recommended):
CODEBLOCK2
Execute:
CODEBLOCK3
Natural-language dispatch (through OpenClaw chat command, supports .psd and .psb):
CODEBLOCK4
DingTalk image handoff (required)
When replying in DingTalk and task execution is successful with PNG output, the final response MUST include this marker with an absolute path:
CODEBLOCK5
Rules:
- - Use absolute path only (for example
/Users/name/Desktop/xxx.png). - Do not use filename-only values.
- If
pngOutputPath (or first item in pngOutputPaths) is missing, clearly report failure and do not emit a fake marker. - For
mode=layer_sets, pngOutputPaths should contain all exported block images in the output folder. - When available, use
selectedPngPath as the single best-match image for screenshot workflows. - When available, send
bundleZipPath as file attachment: [DINGTALK_FILE]{"path":"<absolute_zip_path>","fileName":"<name>.zip","fileType":"zip"}[/DINGTALK_FILE]. - Keep normal human-readable summary, then append marker on a new line at the end.
OpenClaw Routing Pattern (Phase 2)
Use OpenClaw subagent routing guidance:
Core idea:
- 1. Main agent parses request.
- Resolve target machine + platform capabilities.
- Spawn/dispatch to target subagent.
- Subagent runs
run-task.js locally. - Return normalized result + audit log.
Safety Baseline
- - Always support
dryRun. - Keep style lock (
font and size) after text changes. - Disable Photoshop dialogs.
- Create
.bak backup before write. - Stop on ambiguous file matches (
E_FILE_AMBIGUOUS); never guess silently. - On layer-not-found, return
availableLayers + suggestedLayers. - Emit standardized error codes from references/error-codes.md.
PSD Automator
面向同时使用macOS和Windows团队的跨平台PSD文本自动化工具。
适用范围
- - 仅限第一阶段和第二阶段。
- 截图理解功能明确排除在外。
- 使用单一任务协议和两个执行引擎:
- macOS:AppleScript(osascript)
- Windows:Photoshop COM(PowerShell)
任务协议
运行前请阅读 references/task-schema.json。
必填字段:
- - taskId
- input.edits[](layerName + newText)
- input.exactPath 或 input.fileHint
关键可选字段:
- - workflow.sourceMode:inplace 或 copythenedit
- output.exports[]:PNG导出(mode=single 或 mode=layersets 用于切片/块资源)
- output.bundle.zipName:切片资源包的zip名称
- options.pathBridgeMode:auto / always / off(macOS Unicode路径桥接)
- options.bundleZip:是否将 layersets PNG打包成一个zip文件
- options.matchImagePath:用于选择最相似导出切片的截图路径
构建和刷新PSD索引
创建或刷新本地缓存:
bash
node skills/psd-automator/scripts/build-index.js \
--root /Projects/Design \
--root /Users/me/Desktop/assets \
--index ~/.openclaw/psd-index.json
增量刷新:
bash
node skills/psd-automator/scripts/build-index.js --incremental
运行任务
建议先进行试运行:
bash
node skills/psd-automator/scripts/run-task.js \
--task skills/psd-automator/examples/task.mac.json \
--dry-run
执行:
bash
node skills/psd-automator/scripts/run-task.js \
--task skills/psd-automator/examples/task.mac.json
自然语言调度(通过OpenClaw聊天命令,支持 .psd 和 .psb):
text
/psd design-mac-01 帮我找到20260225工位名牌.psd或20260225工位名牌.psb,把姓名改成琳琳,座右铭改成步履不前,稳步前进,保存成png放置在桌面 --dry-run
钉钉图片交接(必需)
在钉钉中回复且任务执行成功并输出PNG时,最终回复必须包含此标记及绝对路径:
text
[DINGTALKIMAGE]{path:pngpath>}[/DINGTALKIMAGE]
规则:
- - 仅使用绝对路径(例如 /Users/name/Desktop/xxx.png)。
- 不要使用仅文件名。
- 如果缺少 pngOutputPath(或 pngOutputPaths 中的第一项),请明确报告失败,不要发送虚假标记。
- 对于 mode=layersets,pngOutputPaths 应包含输出文件夹中的所有导出块图片。
- 当可用时,使用 selectedPngPath 作为截图工作流的最佳匹配图片。
- 当可用时,将 bundleZipPath 作为文件附件发送:[DINGTALKFILE]{path:zippath>,fileName:.zip,fileType:zip}[/DINGTALK_FILE]。
- 保留正常的人类可读摘要,然后在末尾新行追加标记。
OpenClaw路由模式(第二阶段)
使用OpenClaw子代理路由指南:
核心思路:
- 1. 主代理解析请求。
- 确定目标机器+平台能力。
- 生成/调度到目标子代理。
- 子代理本地运行 run-task.js。
- 返回标准化结果+审计日志。
安全基线
- - 始终支持 dryRun。
- 文本更改后保持样式锁定(font 和 size)。
- 禁用Photoshop对话框。
- 写入前创建 .bak 备份。
- 文件匹配不明确时停止(EFILEAMBIGUOUS);绝不静默猜测。
- 图层未找到时,返回 availableLayers + suggestedLayers。
- 从 references/error-codes.md 输出标准化错误代码。