indesign-cli 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. indesign_cli-0.2.0/LICENSE +21 -0
  2. indesign_cli-0.2.0/MANIFEST.in +4 -0
  3. indesign_cli-0.2.0/PKG-INFO +267 -0
  4. indesign_cli-0.2.0/README.md +243 -0
  5. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/README.md +32 -0
  6. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/__init__.py +1 -0
  7. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/__main__.py +5 -0
  8. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/artifacts.py +57 -0
  9. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/catalog.py +405 -0
  10. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/domains.py +178 -0
  11. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/envelope.py +65 -0
  12. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/errors.py +30 -0
  13. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/health.py +46 -0
  14. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/hidden_backend.py +116 -0
  15. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/hidden_handler_schemas.py +223 -0
  16. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/mcp_backend.py +152 -0
  17. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/node_setup.py +35 -0
  18. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/paths.py +41 -0
  19. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/plugins/__init__.py +2 -0
  20. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/plugins/backend.py +90 -0
  21. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/plugins/discovery.py +69 -0
  22. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/plugins/host_actions.py +76 -0
  23. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/plugins/install.py +38 -0
  24. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/plugins/manifest.py +279 -0
  25. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/plugins/validate.py +181 -0
  26. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/router.py +217 -0
  27. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/runtime.py +59 -0
  28. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/scripts.py +44 -0
  29. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/core/session.py +68 -0
  30. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/indesign_cli.py +320 -0
  31. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/node/hidden_handler_bridge.mjs +111 -0
  32. indesign_cli-0.2.0/agent-harness/cli_anything/indesign/skills/SKILL.md +198 -0
  33. indesign_cli-0.2.0/agent-harness/indesign_cli.egg-info/PKG-INFO +267 -0
  34. indesign_cli-0.2.0/agent-harness/indesign_cli.egg-info/SOURCES.txt +76 -0
  35. indesign_cli-0.2.0/agent-harness/indesign_cli.egg-info/dependency_links.txt +1 -0
  36. indesign_cli-0.2.0/agent-harness/indesign_cli.egg-info/entry_points.txt +3 -0
  37. indesign_cli-0.2.0/agent-harness/indesign_cli.egg-info/top_level.txt +1 -0
  38. indesign_cli-0.2.0/package-lock.json +168 -0
  39. indesign_cli-0.2.0/package.json +45 -0
  40. indesign_cli-0.2.0/pyproject.toml +45 -0
  41. indesign_cli-0.2.0/setup.cfg +4 -0
  42. indesign_cli-0.2.0/setup.py +29 -0
  43. indesign_cli-0.2.0/src/advanced/index.js +76 -0
  44. indesign_cli-0.2.0/src/core/InDesignMCPServer.js +273 -0
  45. indesign_cli-0.2.0/src/core/scriptExecutor.js +271 -0
  46. indesign_cli-0.2.0/src/core/sessionManager.js +545 -0
  47. indesign_cli-0.2.0/src/handlers/advancedTemplateHandlers.js +1072 -0
  48. indesign_cli-0.2.0/src/handlers/bookHandlers.js +490 -0
  49. indesign_cli-0.2.0/src/handlers/documentHandlers.js +1472 -0
  50. indesign_cli-0.2.0/src/handlers/exportHandlers.js +208 -0
  51. indesign_cli-0.2.0/src/handlers/graphicsHandlers.js +605 -0
  52. indesign_cli-0.2.0/src/handlers/groupHandlers.js +358 -0
  53. indesign_cli-0.2.0/src/handlers/helpHandlers.js +347 -0
  54. indesign_cli-0.2.0/src/handlers/index.js +77 -0
  55. indesign_cli-0.2.0/src/handlers/layerHandlers.js +75 -0
  56. indesign_cli-0.2.0/src/handlers/masterSpreadHandlers.js +451 -0
  57. indesign_cli-0.2.0/src/handlers/pageHandlers.js +698 -0
  58. indesign_cli-0.2.0/src/handlers/pageItemHandlers.js +704 -0
  59. indesign_cli-0.2.0/src/handlers/presentationHandlers.js +220 -0
  60. indesign_cli-0.2.0/src/handlers/spreadHandlers.js +348 -0
  61. indesign_cli-0.2.0/src/handlers/styleHandlers.js +458 -0
  62. indesign_cli-0.2.0/src/handlers/textHandlers.js +431 -0
  63. indesign_cli-0.2.0/src/handlers/utilityHandlers.js +83 -0
  64. indesign_cli-0.2.0/src/index.js +17 -0
  65. indesign_cli-0.2.0/src/types/index.js +106 -0
  66. indesign_cli-0.2.0/src/types/toolDefinitionsAdvancedTemplates.js +144 -0
  67. indesign_cli-0.2.0/src/types/toolDefinitionsBook.js +224 -0
  68. indesign_cli-0.2.0/src/types/toolDefinitionsContent.js +353 -0
  69. indesign_cli-0.2.0/src/types/toolDefinitionsDocument.js +409 -0
  70. indesign_cli-0.2.0/src/types/toolDefinitionsExport.js +65 -0
  71. indesign_cli-0.2.0/src/types/toolDefinitionsLayer.js +40 -0
  72. indesign_cli-0.2.0/src/types/toolDefinitionsMasterSpread.js +160 -0
  73. indesign_cli-0.2.0/src/types/toolDefinitionsPage.js +271 -0
  74. indesign_cli-0.2.0/src/types/toolDefinitionsPageItemGroup.js +437 -0
  75. indesign_cli-0.2.0/src/types/toolDefinitionsPresentation.js +83 -0
  76. indesign_cli-0.2.0/src/types/toolDefinitionsSpread.js +158 -0
  77. indesign_cli-0.2.0/src/types/toolDefinitionsUtility.js +40 -0
  78. indesign_cli-0.2.0/src/utils/stringUtils.js +107 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 lucdesign
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include package.json
2
+ include package-lock.json
3
+ recursive-include src *
4
+ prune agent-harness/cli_anything/indesign/tests
@@ -0,0 +1,267 @@
1
+ Metadata-Version: 2.4
2
+ Name: indesign-cli
3
+ Version: 0.2.0
4
+ Summary: Agent-native CLI for Adobe InDesign automation
5
+ Author: Sa
6
+ Maintainer: indesign-cli maintainers
7
+ License-Expression: MIT
8
+ Project-URL: Repository, https://github.com/zhanglongxiao111/indesign-cli
9
+ Project-URL: Issues, https://github.com/zhanglongxiao111/indesign-cli/issues
10
+ Project-URL: Homepage, https://github.com/zhanglongxiao111/indesign-cli#readme
11
+ Keywords: indesign,cli,agent,automation,mcp,adobe
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Win32 (MS Windows)
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: JavaScript
18
+ Classifier: Topic :: Multimedia :: Graphics
19
+ Classifier: Topic :: Software Development :: Build Tools
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # 🎨 indesign-cli
26
+
27
+ **中文** | [English](./README.en.md)
28
+
29
+ 让 AI Agent 直接操作 Adobe InDesign 的命令行工具。
30
+
31
+ `indesign-cli` 把 InDesign 的自动化能力包装成 Agent 友好的 CLI:Agent 可以查询工具、执行 JSX 脚本、调用排版能力、验证导出文件,还可以把配套 Skill 安装到其他项目中。
32
+
33
+ 当前 CLI 可发现 **148 个可调用能力**,覆盖 InDesign 绝大部分常用自动化功能:文档、页面、跨页、母版、图层、文本、图片、基础图形、样式、导出、Book、Presentation、模板槽位、脚本执行和环境检查。
34
+
35
+ 如果你正在做 **AI 生成画册、建筑汇报、品牌手册、版式模板、HTML 转 InDesign** 这类项目,它可以让 Agent 不再靠“猜坐标”和“手搓脚本”工作,而是通过稳定的命令和结构化返回值操作真实 InDesign。
36
+
37
+ ## ✨ 这个项目解决什么问题?
38
+
39
+ Adobe InDesign 很强,但对 AI Agent 来说并不好用:
40
+
41
+ - 工具能力多,Agent 不知道该调用哪个。
42
+ - JSX 脚本可以执行,但调试、传参、返回值和错误处理都很散。
43
+ - MCP 工具很多,直接塞进上下文会占用大量 token。
44
+ - 真实导出物是否成功,不能只靠“命令没报错”判断。
45
+
46
+ `indesign-cli` 做的事情很简单:**把真实 InDesign 自动化能力变成 Agent 更容易使用的一组命令。**
47
+
48
+ 它的关键价值之一是 **省 token**:Agent 不需要一次性读取 148 个工具的完整描述,可以先看 `tool domains` 的摘要,再用 `tool search`、`tool list`、`tool schema` 按需加载当前任务需要的工具说明。
49
+
50
+ 它不是一个给人类手动排版的 CLI,也不是一个新的排版引擎。它更像是 AI 项目和 InDesign 之间的稳定桥梁。
51
+
52
+ ## 🚀 快速安装
53
+
54
+ ### 1. 准备环境
55
+
56
+ 你需要:
57
+
58
+ - Windows
59
+ - Adobe InDesign 桌面版:推荐 2024-2026;CLI 会尝试连接 2022-2026、CC 版本和通用 `InDesign.Application` COM 入口,实际可用版本取决于本机 COM 注册
60
+ - Node.js 18+
61
+ - Python 3.10+
62
+
63
+ InDesign 需要和命令行运行在同一个 Windows 用户会话中。
64
+
65
+ ### 2. 从 GitHub 安装
66
+
67
+ ```powershell
68
+ pip install "git+https://github.com/zhanglongxiao111/indesign-cli.git"
69
+ ```
70
+
71
+ ### 3. 安装 Node 依赖
72
+
73
+ ```powershell
74
+ indesign-cli server setup
75
+ ```
76
+
77
+ 这一步会安装 InDesign 自动化所需的 Node 依赖,包括 `winax`。
78
+
79
+ ### 4. 检查环境
80
+
81
+ ```powershell
82
+ indesign-cli --json --pretty server health
83
+ ```
84
+
85
+ 如果返回 `ok: true`,CLI 基础环境就绪。
86
+
87
+ ## 🧠 给其他项目安装 Agent Skill
88
+
89
+ 如果你希望某个项目里的 Agent 自动知道如何使用 `indesign-cli`,可以在任意位置运行:
90
+
91
+ ```powershell
92
+ indesign-cli skill install --target D:\AI\your-project
93
+ ```
94
+
95
+ 它会安装到:
96
+
97
+ ```text
98
+ D:\AI\your-project\.codex\skills\indesign-cli\SKILL.md
99
+ ```
100
+
101
+ 之后,该项目中的 Agent 会自动获得这套 InDesign CLI 使用说明。
102
+
103
+ ## 🧩 插件接入
104
+
105
+ `indesign-cli` 支持项目级插件,让上层项目把自己的高层能力接入统一工具目录。比如 HTML-to-InDesign 项目可以注册 `html` 域,Agent 再通过同一套 `tool list/schema/call` 使用它。
106
+
107
+ 本地插件接入示例:
108
+
109
+ ```powershell
110
+ indesign-cli plugin install D:\AI\html-indesign
111
+ indesign-cli plugin validate D:\AI\html-indesign
112
+ indesign-cli plugin doctor html-indesign
113
+ indesign-cli tool list --domain html
114
+ ```
115
+
116
+ 插件工具不会默认挤进 Agent 上下文。Agent 仍然先看 domain 摘要,再按需读取具体 schema。
117
+
118
+ ## 🛠️ 常用能力
119
+
120
+ ### 🔎 查询可用工具
121
+
122
+ ```powershell
123
+ indesign-cli tool domains
124
+ indesign-cli tool search --query "pdf"
125
+ indesign-cli tool list --domain template
126
+ indesign-cli tool schema template.populate_template_slots
127
+ ```
128
+
129
+ Agent 可以先查有哪些工具,再只读取需要的 schema,减少上下文浪费。
130
+
131
+ ### 🧰 能力覆盖
132
+
133
+ 当前 `indesign-cli` 可发现 **148 个可调用能力**,覆盖 InDesign 绝大部分常用自动化功能,以及大多数 Agent 自动化场景:
134
+
135
+ - 文档、页面、跨页、母版、图层
136
+ - 文本框、表格、图片、基础图形、页面对象
137
+ - 段落样式、字符样式、对象样式、色板
138
+ - PDF / IDML / 图片导出与产物验证
139
+ - Book、Presentation、模板槽位和高级模板填充
140
+ - JSX 脚本执行、session 线索、环境检查和 Skill 安装
141
+
142
+ 这些能力通过 CLI 分域查询,不会一次性占满 Agent 上下文。
143
+
144
+ ### 📜 执行 JSX 脚本
145
+
146
+ ```powershell
147
+ indesign-cli --json --pretty script run test\workspace\probe.jsx
148
+ ```
149
+
150
+ 适合测试真实 InDesign 行为、创建文档、检查对象、执行复杂排版逻辑。
151
+
152
+ 复杂构建或导出可能超过默认等待时间,可以显式加长脚本通道超时:
153
+
154
+ ```powershell
155
+ indesign-cli --json --pretty script run test\workspace\build.jsx --timeout 900
156
+ ```
157
+
158
+ 短脚本也可以从 stdin 输入:
159
+
160
+ ```powershell
161
+ Get-Content test\workspace\probe.jsx | indesign-cli --json --pretty script run --stdin
162
+ ```
163
+
164
+ ### 📦 验证导出物
165
+
166
+ ```powershell
167
+ indesign-cli export verify output\deck.pdf
168
+ ```
169
+
170
+ 用于确认 PDF、IDML 等文件真的生成成功,而不是只看命令是否结束。
171
+
172
+ ### 🧩 使用模板槽位
173
+
174
+ ```powershell
175
+ indesign-cli tool call template.list_template_blueprints --args args.json
176
+ indesign-cli tool call template.inspect_template_blueprint --args args.json
177
+ indesign-cli tool call template.create_page_with_template --args args.json
178
+ indesign-cli tool call template.populate_template_slots --args args.json
179
+ ```
180
+
181
+ 适合让 Agent 基于母版、脚本标签和槽位名生成稳定页面。
182
+
183
+ ### 📚 Book / Presentation 工具
184
+
185
+ `indesign-cli` 也包含 Book 和 Presentation 相关能力,例如:
186
+
187
+ - 创建和管理 InDesign Book
188
+ - 导出 Book
189
+ - 创建演示型文档
190
+ - 添加封面页、章节页、全幅图片页、图片网格页
191
+
192
+ 这些能力可以通过 `tool domains`、`tool list` 和 `tool schema` 查询。
193
+
194
+ ## 🧪 示例工作流
195
+
196
+ 一个典型 Agent 流程可能是:
197
+
198
+ ```powershell
199
+ indesign-cli --json --pretty server health
200
+ indesign-cli tool domains
201
+ indesign-cli tool search --query "template"
202
+ indesign-cli tool schema template.populate_template_slots
203
+ indesign-cli --json --pretty script run test\workspace\build.jsx
204
+ indesign-cli export verify output\presentation.pdf
205
+ ```
206
+
207
+ Agent 负责生成脚本和参数,`indesign-cli` 负责把它们安全地送进真实 InDesign,并返回结构化结果。
208
+
209
+ ## 💡 适合谁使用?
210
+
211
+ 适合:
212
+
213
+ - 想让 AI Agent 自动操作 InDesign 的开发者
214
+ - 正在做 HTML / JSON / 模板到 InDesign 的转换项目
215
+ - 需要自动生成设计汇报、画册、排版文档的团队
216
+ - 希望用脚本验证真实 InDesign 输出的 Agent 工作流
217
+
218
+ 不适合:
219
+
220
+ - 只想手动点按钮排版的普通 InDesign 用户
221
+ - 不安装 Adobe InDesign 的纯后端环境
222
+ - 希望用它替代浏览器、LaTeX 或其他排版引擎的场景
223
+
224
+ ## 🔧 本地开发
225
+
226
+ ```powershell
227
+ git clone https://github.com/zhanglongxiao111/indesign-cli.git
228
+ cd indesign-cli
229
+ pip install -e .
230
+ indesign-cli server setup
231
+ indesign-cli server health
232
+ ```
233
+
234
+ 运行测试:
235
+
236
+ ```powershell
237
+ python -m pytest agent-harness\cli_anything\indesign\tests\test_core.py -q
238
+ node scripts\validate_schemas.js
239
+ node scripts\check_duplicates.mjs
240
+ node tests\index.js --required
241
+ ```
242
+
243
+ ## 📁 项目结构
244
+
245
+ ```text
246
+ .
247
+ ├─ agent-harness/ # Python CLI、内置 Skill、CLI 测试
248
+ ├─ src/ # MCP Server、InDesign handler、JSX/COM 执行链路
249
+ ├─ scripts/ # 维护脚本和检查脚本
250
+ ├─ tests/ # 测试和真实 InDesign E2E
251
+ ├─ docs/ # 设计文档、计划、协作记录
252
+ ├─ pyproject.toml # pip 安装入口
253
+ └─ AGENTS.md # 项目级 Agent 协作规则
254
+ ```
255
+
256
+ ## 🗺️ 下一步方向
257
+
258
+ 项目后续会重点完善:
259
+
260
+ - 更稳定的 HTML / 语义模板到 InDesign 转换链路
261
+ - 更好用的模板槽位协议
262
+ - 更适合 Agent 的排版检查和导出验证
263
+ - 更完善的示例项目和真实 E2E 场景
264
+
265
+ ## 📄 License
266
+
267
+ MIT
@@ -0,0 +1,243 @@
1
+ # 🎨 indesign-cli
2
+
3
+ **中文** | [English](./README.en.md)
4
+
5
+ 让 AI Agent 直接操作 Adobe InDesign 的命令行工具。
6
+
7
+ `indesign-cli` 把 InDesign 的自动化能力包装成 Agent 友好的 CLI:Agent 可以查询工具、执行 JSX 脚本、调用排版能力、验证导出文件,还可以把配套 Skill 安装到其他项目中。
8
+
9
+ 当前 CLI 可发现 **148 个可调用能力**,覆盖 InDesign 绝大部分常用自动化功能:文档、页面、跨页、母版、图层、文本、图片、基础图形、样式、导出、Book、Presentation、模板槽位、脚本执行和环境检查。
10
+
11
+ 如果你正在做 **AI 生成画册、建筑汇报、品牌手册、版式模板、HTML 转 InDesign** 这类项目,它可以让 Agent 不再靠“猜坐标”和“手搓脚本”工作,而是通过稳定的命令和结构化返回值操作真实 InDesign。
12
+
13
+ ## ✨ 这个项目解决什么问题?
14
+
15
+ Adobe InDesign 很强,但对 AI Agent 来说并不好用:
16
+
17
+ - 工具能力多,Agent 不知道该调用哪个。
18
+ - JSX 脚本可以执行,但调试、传参、返回值和错误处理都很散。
19
+ - MCP 工具很多,直接塞进上下文会占用大量 token。
20
+ - 真实导出物是否成功,不能只靠“命令没报错”判断。
21
+
22
+ `indesign-cli` 做的事情很简单:**把真实 InDesign 自动化能力变成 Agent 更容易使用的一组命令。**
23
+
24
+ 它的关键价值之一是 **省 token**:Agent 不需要一次性读取 148 个工具的完整描述,可以先看 `tool domains` 的摘要,再用 `tool search`、`tool list`、`tool schema` 按需加载当前任务需要的工具说明。
25
+
26
+ 它不是一个给人类手动排版的 CLI,也不是一个新的排版引擎。它更像是 AI 项目和 InDesign 之间的稳定桥梁。
27
+
28
+ ## 🚀 快速安装
29
+
30
+ ### 1. 准备环境
31
+
32
+ 你需要:
33
+
34
+ - Windows
35
+ - Adobe InDesign 桌面版:推荐 2024-2026;CLI 会尝试连接 2022-2026、CC 版本和通用 `InDesign.Application` COM 入口,实际可用版本取决于本机 COM 注册
36
+ - Node.js 18+
37
+ - Python 3.10+
38
+
39
+ InDesign 需要和命令行运行在同一个 Windows 用户会话中。
40
+
41
+ ### 2. 从 GitHub 安装
42
+
43
+ ```powershell
44
+ pip install "git+https://github.com/zhanglongxiao111/indesign-cli.git"
45
+ ```
46
+
47
+ ### 3. 安装 Node 依赖
48
+
49
+ ```powershell
50
+ indesign-cli server setup
51
+ ```
52
+
53
+ 这一步会安装 InDesign 自动化所需的 Node 依赖,包括 `winax`。
54
+
55
+ ### 4. 检查环境
56
+
57
+ ```powershell
58
+ indesign-cli --json --pretty server health
59
+ ```
60
+
61
+ 如果返回 `ok: true`,CLI 基础环境就绪。
62
+
63
+ ## 🧠 给其他项目安装 Agent Skill
64
+
65
+ 如果你希望某个项目里的 Agent 自动知道如何使用 `indesign-cli`,可以在任意位置运行:
66
+
67
+ ```powershell
68
+ indesign-cli skill install --target D:\AI\your-project
69
+ ```
70
+
71
+ 它会安装到:
72
+
73
+ ```text
74
+ D:\AI\your-project\.codex\skills\indesign-cli\SKILL.md
75
+ ```
76
+
77
+ 之后,该项目中的 Agent 会自动获得这套 InDesign CLI 使用说明。
78
+
79
+ ## 🧩 插件接入
80
+
81
+ `indesign-cli` 支持项目级插件,让上层项目把自己的高层能力接入统一工具目录。比如 HTML-to-InDesign 项目可以注册 `html` 域,Agent 再通过同一套 `tool list/schema/call` 使用它。
82
+
83
+ 本地插件接入示例:
84
+
85
+ ```powershell
86
+ indesign-cli plugin install D:\AI\html-indesign
87
+ indesign-cli plugin validate D:\AI\html-indesign
88
+ indesign-cli plugin doctor html-indesign
89
+ indesign-cli tool list --domain html
90
+ ```
91
+
92
+ 插件工具不会默认挤进 Agent 上下文。Agent 仍然先看 domain 摘要,再按需读取具体 schema。
93
+
94
+ ## 🛠️ 常用能力
95
+
96
+ ### 🔎 查询可用工具
97
+
98
+ ```powershell
99
+ indesign-cli tool domains
100
+ indesign-cli tool search --query "pdf"
101
+ indesign-cli tool list --domain template
102
+ indesign-cli tool schema template.populate_template_slots
103
+ ```
104
+
105
+ Agent 可以先查有哪些工具,再只读取需要的 schema,减少上下文浪费。
106
+
107
+ ### 🧰 能力覆盖
108
+
109
+ 当前 `indesign-cli` 可发现 **148 个可调用能力**,覆盖 InDesign 绝大部分常用自动化功能,以及大多数 Agent 自动化场景:
110
+
111
+ - 文档、页面、跨页、母版、图层
112
+ - 文本框、表格、图片、基础图形、页面对象
113
+ - 段落样式、字符样式、对象样式、色板
114
+ - PDF / IDML / 图片导出与产物验证
115
+ - Book、Presentation、模板槽位和高级模板填充
116
+ - JSX 脚本执行、session 线索、环境检查和 Skill 安装
117
+
118
+ 这些能力通过 CLI 分域查询,不会一次性占满 Agent 上下文。
119
+
120
+ ### 📜 执行 JSX 脚本
121
+
122
+ ```powershell
123
+ indesign-cli --json --pretty script run test\workspace\probe.jsx
124
+ ```
125
+
126
+ 适合测试真实 InDesign 行为、创建文档、检查对象、执行复杂排版逻辑。
127
+
128
+ 复杂构建或导出可能超过默认等待时间,可以显式加长脚本通道超时:
129
+
130
+ ```powershell
131
+ indesign-cli --json --pretty script run test\workspace\build.jsx --timeout 900
132
+ ```
133
+
134
+ 短脚本也可以从 stdin 输入:
135
+
136
+ ```powershell
137
+ Get-Content test\workspace\probe.jsx | indesign-cli --json --pretty script run --stdin
138
+ ```
139
+
140
+ ### 📦 验证导出物
141
+
142
+ ```powershell
143
+ indesign-cli export verify output\deck.pdf
144
+ ```
145
+
146
+ 用于确认 PDF、IDML 等文件真的生成成功,而不是只看命令是否结束。
147
+
148
+ ### 🧩 使用模板槽位
149
+
150
+ ```powershell
151
+ indesign-cli tool call template.list_template_blueprints --args args.json
152
+ indesign-cli tool call template.inspect_template_blueprint --args args.json
153
+ indesign-cli tool call template.create_page_with_template --args args.json
154
+ indesign-cli tool call template.populate_template_slots --args args.json
155
+ ```
156
+
157
+ 适合让 Agent 基于母版、脚本标签和槽位名生成稳定页面。
158
+
159
+ ### 📚 Book / Presentation 工具
160
+
161
+ `indesign-cli` 也包含 Book 和 Presentation 相关能力,例如:
162
+
163
+ - 创建和管理 InDesign Book
164
+ - 导出 Book
165
+ - 创建演示型文档
166
+ - 添加封面页、章节页、全幅图片页、图片网格页
167
+
168
+ 这些能力可以通过 `tool domains`、`tool list` 和 `tool schema` 查询。
169
+
170
+ ## 🧪 示例工作流
171
+
172
+ 一个典型 Agent 流程可能是:
173
+
174
+ ```powershell
175
+ indesign-cli --json --pretty server health
176
+ indesign-cli tool domains
177
+ indesign-cli tool search --query "template"
178
+ indesign-cli tool schema template.populate_template_slots
179
+ indesign-cli --json --pretty script run test\workspace\build.jsx
180
+ indesign-cli export verify output\presentation.pdf
181
+ ```
182
+
183
+ Agent 负责生成脚本和参数,`indesign-cli` 负责把它们安全地送进真实 InDesign,并返回结构化结果。
184
+
185
+ ## 💡 适合谁使用?
186
+
187
+ 适合:
188
+
189
+ - 想让 AI Agent 自动操作 InDesign 的开发者
190
+ - 正在做 HTML / JSON / 模板到 InDesign 的转换项目
191
+ - 需要自动生成设计汇报、画册、排版文档的团队
192
+ - 希望用脚本验证真实 InDesign 输出的 Agent 工作流
193
+
194
+ 不适合:
195
+
196
+ - 只想手动点按钮排版的普通 InDesign 用户
197
+ - 不安装 Adobe InDesign 的纯后端环境
198
+ - 希望用它替代浏览器、LaTeX 或其他排版引擎的场景
199
+
200
+ ## 🔧 本地开发
201
+
202
+ ```powershell
203
+ git clone https://github.com/zhanglongxiao111/indesign-cli.git
204
+ cd indesign-cli
205
+ pip install -e .
206
+ indesign-cli server setup
207
+ indesign-cli server health
208
+ ```
209
+
210
+ 运行测试:
211
+
212
+ ```powershell
213
+ python -m pytest agent-harness\cli_anything\indesign\tests\test_core.py -q
214
+ node scripts\validate_schemas.js
215
+ node scripts\check_duplicates.mjs
216
+ node tests\index.js --required
217
+ ```
218
+
219
+ ## 📁 项目结构
220
+
221
+ ```text
222
+ .
223
+ ├─ agent-harness/ # Python CLI、内置 Skill、CLI 测试
224
+ ├─ src/ # MCP Server、InDesign handler、JSX/COM 执行链路
225
+ ├─ scripts/ # 维护脚本和检查脚本
226
+ ├─ tests/ # 测试和真实 InDesign E2E
227
+ ├─ docs/ # 设计文档、计划、协作记录
228
+ ├─ pyproject.toml # pip 安装入口
229
+ └─ AGENTS.md # 项目级 Agent 协作规则
230
+ ```
231
+
232
+ ## 🗺️ 下一步方向
233
+
234
+ 项目后续会重点完善:
235
+
236
+ - 更稳定的 HTML / 语义模板到 InDesign 转换链路
237
+ - 更好用的模板槽位协议
238
+ - 更适合 Agent 的排版检查和导出验证
239
+ - 更完善的示例项目和真实 E2E 场景
240
+
241
+ ## 📄 License
242
+
243
+ MIT
@@ -0,0 +1,32 @@
1
+ # indesign-cli
2
+
3
+ Agent 专用 InDesign CLI harness。
4
+
5
+ 常用命令:
6
+
7
+ ```powershell
8
+ indesign-cli --version
9
+ indesign-cli tool domains
10
+ indesign-cli tool list --domain template
11
+ indesign-cli tool schema template.run_jsx_file
12
+ indesign-cli tool call template.run_jsx_file --args args.json
13
+ indesign-cli script run scripts/check.jsx
14
+ indesign-cli script run --stdin
15
+ indesign-cli export verify output/result.pdf
16
+ indesign-cli server setup
17
+ indesign-cli server health
18
+ indesign-cli session show
19
+ indesign-cli skill install --target D:\AI\html-indesign
20
+ ```
21
+
22
+ `cli-anything-indesign` 仍可作为旧项目兼容别名使用。
23
+
24
+ `script run` 是 Agent 做真实 InDesign 验证的主入口:
25
+
26
+ - 文件模式保留 `$.fileName` 和相对 `#include` 行为。
27
+ - stdin 模式适合临时探针脚本,并支持中文输入。
28
+ - JSX 可以返回普通字符串,也可以返回 `JSON.stringify(...)` 的字符串。
29
+ - 返回 JSON 字符串时,CLI 输出会包含 `data.result_json`,避免调用方二次解析 `data.parsed.result`。
30
+ - 成功和失败都会记录到当前目录的 `.indesign-cli/session.json`。
31
+
32
+ 本 CLI 复用当前项目的 MCP server 和 ExtendScript/COM 执行链路,不重新实现 InDesign 自动化能力。
@@ -0,0 +1 @@
1
+ __version__ = "0.2.0"
@@ -0,0 +1,5 @@
1
+ from .indesign_cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ raise SystemExit(main())
@@ -0,0 +1,57 @@
1
+ from __future__ import annotations
2
+
3
+ import zipfile
4
+ from datetime import datetime
5
+ from pathlib import Path
6
+ import re
7
+ from typing import Any
8
+
9
+ from .errors import CliError
10
+ from .paths import scrub_path
11
+
12
+
13
+ def parse_timestamp(value: str) -> datetime:
14
+ normalized = value.strip()
15
+ if normalized.endswith("Z"):
16
+ normalized = normalized[:-1] + "+00:00"
17
+ normalized = re.sub(r"(\.\d{6})\d+([+-]\d{2}:\d{2})$", r"\1\2", normalized)
18
+ return datetime.fromisoformat(normalized)
19
+
20
+
21
+ def verify_artifact(path: Path, created_after: datetime | None = None, cwd: Path | None = None) -> dict[str, Any]:
22
+ path_info = scrub_path(str(path), cwd or Path.cwd())
23
+ if not path.exists():
24
+ raise CliError("Artifact not found", code="ARTIFACT_NOT_FOUND", details={"path": path_info})
25
+ stat = path.stat()
26
+ if stat.st_size <= 0:
27
+ raise CliError("Artifact is empty", code="ARTIFACT_EMPTY", details={"path": path_info})
28
+ if created_after and datetime.fromtimestamp(stat.st_mtime, created_after.tzinfo) < created_after:
29
+ raise CliError("Artifact is older than expected", code="ARTIFACT_TOO_OLD", details={"path": path_info})
30
+
31
+ suffix = path.suffix.lower()
32
+ if suffix == ".pdf":
33
+ with path.open("rb") as handle:
34
+ if handle.read(4) != b"%PDF":
35
+ raise CliError("PDF signature is invalid", code="ARTIFACT_SIGNATURE_INVALID")
36
+ return {
37
+ "path": path_info,
38
+ "kind": "pdf",
39
+ "size_bytes": stat.st_size,
40
+ "signature_ok": True,
41
+ "mtime": stat.st_mtime,
42
+ }
43
+ if suffix == ".idml":
44
+ try:
45
+ with zipfile.ZipFile(path) as archive:
46
+ if "designmap.xml" not in archive.namelist():
47
+ raise CliError("IDML designmap.xml missing", code="ARTIFACT_SIGNATURE_INVALID")
48
+ except zipfile.BadZipFile as exc:
49
+ raise CliError("IDML ZIP structure is invalid", code="ARTIFACT_SIGNATURE_INVALID") from exc
50
+ return {
51
+ "path": path_info,
52
+ "kind": "idml",
53
+ "size_bytes": stat.st_size,
54
+ "signature_ok": True,
55
+ "mtime": stat.st_mtime,
56
+ }
57
+ raise CliError(f"Unsupported artifact type: {suffix}", code="ARTIFACT_UNSUPPORTED")