Compare commits

...

2 Commits

Author SHA1 Message Date
zhanghuanxu
cc4e3c3eef refactor(slides):create slide and edit ppt template 2026-07-03 12:54:40 +08:00
zhanghuanxu
92f72ab699 docs: update lark slides design ideas 2026-07-02 20:04:52 +08:00
16 changed files with 713 additions and 1184 deletions

View File

@@ -4,7 +4,7 @@ version: 1.0.0
description: "飞书幻灯片:创建和编辑幻灯片。创建演示文稿、读取幻灯片内容、管理幻灯片页面(创建、删除、读取、局部替换)。当用户需要创建或编辑幻灯片、读取或修改单个页面时使用。当用户给出 doubao.com 的 /slides/ URL/token 时,也应直接使用本 skill不要因为域名不是飞书而回退到 WebFetch路由依据是 URL 路径模式和 token而不是域名。不负责云文档内容编辑走 lark-doc、云文档里的独立画板对象走 lark-whiteboard注意 slide 内嵌的流程图/架构图仍属本 skill、上传或下载普通文件走 lark-drive。"
metadata:
requires:
bins: ["lark-cli"]
bins: [ "lark-cli" ]
cliHelp: "lark-cli slides --help"
---
@@ -12,198 +12,36 @@ metadata:
## Quick Reference
| 用户需求 | 优先动作 | 关键文档 / 命令 |
|----------|----------|-----------------|
| 新建 PPT | 先规划 `slide_plan.json`,再按复杂度选择一步或两步创建 | `planning-layer.md``visual-planning.md``asset-planning.md``slides +create` |
| 已有 PPT 大幅改写 | 多页整页重建用 `+replace-pages`,单页局部编辑用 `+replace-slide` | `xml_presentations.get``lark-slides-replace-pages.md``lark-slides-edit-workflows.md` |
| 编辑单个标题、文本块、图片或局部元素 | 优先块级替换/插入,不改页序 | `slides +replace-slide``lark-slides-replace-slide.md` |
| 读取或分析已有 PPT | 解析 slides/wiki token回读全文或单页 XML保存 `xml_presentation_id``slide_id``revision_id` | `xml_presentations.get``xml_presentation.slide.get` |
| 获取幻灯片页面截图 | 用 `slide_id` 或页号指定页面 | `slides +screenshot``lark-slides-screenshot.md` |
| 上传或使用图片 | 先上传为 `file_token`,禁止直接写 http(s) 外链 | `slides +media-upload`,或 `+create --slides``@./path` 占位符 |
| 在 slide 中绘制柱/条/折线/面积/雷达/饼等有数据序列的图表 | 使用原生 `<chart>` 元素 | `xml-schema-quick-ref.md` |
| 在 slide 中绘制流程图、时序图、架构图、散点图、漏斗图或装饰图案 | 必须先用 Read 工具读取参考文档,再生成 `<whiteboard>` 元素 | [`lark-slides-whiteboard.md`](references/lark-slides-whiteboard.md) |
| 使用语义图标 | 先检索 IconPark再写 `<icon iconType="...">` | `iconpark_tool.py search → resolve``iconpark.md` |
| 创建失败、空白页、3350001、布局异常 | 先回读状态,再按排障清单修复,不假设原操作原子成功 | `troubleshooting.md``validation-checklist.md` |
| 用户需求 | 指引 |
|----------|------|
| 读取 / 分析本地 PPTX 内容 | 文本用 `python -m markitdown presentation.pptx`;视觉总览用 `python3 scripts/thumbnail.py presentation.pptx`;原始 OOXML 用 `python3 scripts/office/unpack.py presentation.pptx unpacked/` |
| 从模板创建或编辑已有本地 PPTX | 先读 `lark-slides-pptx-template-workflows.md` |
| 从零新建飞书在线 PPT | 先读 `lark-slides-create-workflows.md` |
| 获取在线 slides 内容、读取 / 分析已有在线 PPT | XML 内容优先用 `slides +xml-get` 保存到文件;页面视觉内容用 `slides +screenshot`,详见 `lark-slides-screenshot.md` |
**CRITICAL — 开始前 MUST 先用 Read 工具读取 [`../lark-shared/SKILL.md`](../lark-shared/SKILL.md),认证、权限和全局参数均以 lark-shared 为准。**
## 读取 / 分析内容
**CRITICAL — 生成任何 XML 之前MUST 先用 Read 工具读取 [xml-schema-quick-ref.md](references/xml-schema-quick-ref.md),禁止凭记忆猜测 XML 结构。**
**CRITICAL — PPT 生成与模板编辑硬约束PPT 的尺寸是 960x540确保主体内容在页面边界内。多用生图辅助搜图必须要图文并茂。不要为了画出一个具象物体而堆叠 3 个以上仅用于拟形的 shape。生成背景图时必须在 prompt 中明确要求不要出现任何文字。用户指定 PPT 模板时,用 lark-drive 技能导入成 lark slides回读理解每页版式后直接在该 slides 上编辑,可以填改文字和图片、按需增删模板页,必须严格沿用原版式和字体,只改内容不做设计,完成后回读并微调,凝练文字或缩减字号消除文字溢出,调整 shape 顺序或位置避免文字遮挡。**
**CRITICAL — 新建演示文稿或大幅改写页面时MUST 先生成 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`,再生成 XML。先创建对应目录规划层规则和中间产物生命周期见 [planning-layer.md](references/planning-layer.md)。仅替换一个标题、插入一个块等小型已有页编辑可豁免。**
**CRITICAL — 新建演示文稿或大幅改写页面时,生成 XML 前 MUST 读取 [visual-planning.md](references/visual-planning.md),确保 `layout_type`、`visual_focus`、`text_density` 实际改变页面几何、主视觉和文本量。**
**CRITICAL — 新建演示文稿或大幅改写页面时,规划 `asset_need` MUST 遵循 [asset-planning.md](references/asset-planning.md):只做元数据规划,必须有 `fallback_if_missing`,不得要求真实搜索、下载或上传素材。**
**CRITICAL — 创建或大幅改写后MUST 按 [validation-checklist.md](references/validation-checklist.md) 做显式验证:回读全文 XML、核对页数和关键元素、检查空白/破损页、明显溢出、布局风险XML 语法和文本重叠静态检查优先使用 [`scripts/xml_text_overlap_lint.py`](scripts/xml_text_overlap_lint.py)。**
**CRITICAL — 创建前自检或失败排障时MUST 按 [troubleshooting.md](references/troubleshooting.md) 检查 XML 转义、结构、shell 截断、图片 token、3350001 和布局风险。**
**编辑已有幻灯片页面**:单个标题、文本块、图片或局部元素优先用 [`+replace-slide`](references/lark-slides-replace-slide.md)(块级替换/插入,不动页序);已有 Slides 的多页大改优先用 [`+replace-pages`](references/lark-slides-replace-pages.md) 在原 presentation 内批量重建页面,避免 `slides +create` 生成新链接。选择 action 和完整读-改-写流程见 [`lark-slides-edit-workflows.md`](references/lark-slides-edit-workflows.md)。
## 身份选择
飞书幻灯片通常是用户自己的内容资源。**默认应优先显式使用 `--as user`(用户身份)执行 slides 相关操作**,始终显式指定身份。
- **`--as user`(推荐)**:以当前登录用户身份创建、读取、管理演示文稿。执行前先完成用户授权:
### 在线 Slides
```bash
lark-cli auth login --domain slides
# 读取完整 XML 内容,优先保存到文件再分析
lark-cli slides +xml-get --as user --presentation slides_example_presentation_id --output presentation.xml --json
# 获取页面截图;必须指定 --slide-number 或 --slide-id多个页面可重复传 --slide-number
lark-cli slides +screenshot --as user --presentation slides_example_presentation_id --slide-number 1 --output-dir screenshots --json
```
- **`--as bot`**:仅在用户明确要求以应用身份操作,或需要让 bot 持有/创建资源时使用。使用 bot 身份时,要额外确认 bot 是否真的有目标演示文稿的访问权限
在线 Slides 的截图参数和页码语义详见 [`lark-slides-screenshot.md`](references/lark-slides-screenshot.md);需要继续编辑在线 Slides 时,按 `lark-slides-create-workflows.md` / `lark-slides-replace-workflows.md` 选择创建或替换流程
**执行规则**
## 编辑 PPTX 工作流
1. 创建、读取、增删 slide、按用户给出的链接继续编辑已有 PPT默认都先用 `--as user`
2. 如果出现权限不足,先检查当前是否误用了 bot 身份;不要默认回退到 bot。
3. 只有在用户明确要求"用应用身份 / bot 身份操作",或当前工作流就是 bot 创建资源后再做协作授权时,才切换到 `--as bot`
**完整流程先读 [`lark-slides-pptx-template-workflows.md`](references/lark-slides-pptx-template-workflows.md)。**
## 执行前必做
## 从零创建
> **重要**`references/slides_xml_schema_definition.xml` 是此 skill 唯一正确的 XML 协议来源;其他 md 仅是对它和 CLI schema 的摘要。
**完整流程先读 [`lark-slides-create-workflows.md`](references/lark-slides-create-workflows.md)。**
高频只读:
- [xml-schema-quick-ref.md](references/xml-schema-quick-ref.md)
- [planning-layer.md](references/planning-layer.md)(新建 / 大幅改写)
- [visual-planning.md](references/visual-planning.md)(新建 / 大幅改写)
- [asset-planning.md](references/asset-planning.md)(新建 / 大幅改写)
- [validation-checklist.md](references/validation-checklist.md)(创建 / 大幅改写后)
按需再读:
- 创建:[`lark-slides-create.md`](references/lark-slides-create.md)
- 编辑:[`lark-slides-edit-workflows.md`](references/lark-slides-edit-workflows.md)、[`lark-slides-replace-slide.md`](references/lark-slides-replace-slide.md)、[`lark-slides-replace-pages.md`](references/lark-slides-replace-pages.md)
- 截图:[`lark-slides-screenshot.md`](references/lark-slides-screenshot.md)
- 图片:[`lark-slides-media-upload.md`](references/lark-slides-media-upload.md)
- 流程图 / 时序图 / 架构图 / 装饰图案:[`lark-slides-whiteboard.md`](references/lark-slides-whiteboard.md)
- 图标:[`iconpark.md`](references/iconpark.md)、[`scripts/iconpark_tool.py`](scripts/iconpark_tool.py)
- 排障:[`troubleshooting.md`](references/troubleshooting.md)
- 完整协议:[`slides_xml_schema_definition.xml`](references/slides_xml_schema_definition.xml)
## Workflow
> **这是演示文稿,不是文档。** 每页 slide 是独立的视觉画面,信息密度要低,排版要留白。
### Design Ideas
不要生成无设计感的幻灯片。纯白背景 + 标题 + bullets 只能作为极简临时稿,不能作为正式交付。
开始写 XML 前,先在 `slide_plan.json` 里确定 deck 级视觉策略:
- **主题化配色**:配色必须服务本次主题、行业和受众,不要默认蓝色商务风。如果把同一套颜色换到另一个完全不同主题仍然成立,说明配色不够具体。
- **主次比例**:选择 1 个主色承担约 60-70% 视觉权重1-2 个辅助色承担结构和分区1 个强调色只用于关键数字、结论或行动点。不要让所有颜色权重相同。
- **背景一致性**:先确定全 deck 的背景策略,默认保持同一明暗基调和底色体系;只有分节、转场或强调页才有意改变背景,并必须通过相同主色、纹理、边栏或 motif 让变化看起来属于同一套设计。无论深浅,都要保证正文、图标和线条对比充足。
- **统一 motif**:选择一个可复用视觉母题贯穿全文,例如粗侧边栏、圆形图标底、半出血图片区、编号节点、卡片左上角色块或大号数字。不要每页换一套装饰语言。
每页至少要有一个视觉元素:图片、图标、图表、表格、流程、对比结构、大号数字、示意图或由 shape 组成的抽象视觉。文本框本身不算主视觉。
可优先考虑这些页面形态:
- **双栏结构**:左文右图或左图右文,视觉区域占 35-45% 宽度。
- **图标行**:图标在色块或圆形底中,右侧是短标题和一句解释。
- **2x2 / 2x3 网格**:适合能力、模块、风险、行动项,每格内容保持同等层级。
- **半出血视觉**:图片或抽象形状占据左/右半屏,文字覆盖或贴边排布。
- **大数字卡片**:关键指标用 60-72pt 数字,下面配 10-14pt 标签。
- **对比列**before/after、方案 A/B、问题/解法用左右并列,标题和基线严格对齐。
- **时间线/流程图**:步骤用节点和箭头表达,流程方向必须一眼可见。
字体和间距建议:
- 标题 36-44pt关键结论可更大正文 14-18pt注释 10-12pt。
- 正文默认左对齐;只在封面、结尾或大号数字场景中使用居中。
- 页面边距至少 40px内容块之间保持 24-40px 间距,并在同一 deck 内保持一致。
- 卡片内边距要真实留出空间,不要让文字贴边;对齐 shape 和文字时要考虑文本框 padding。
常见错误必须避免:
- 不要所有页面复用同一种标题 + 三 bullets 版式。
- 不要用低对比文字或低对比图标,例如浅灰字压在浅色背景上。
- 不要让装饰线穿过文字,或让页脚、来源、编号挤压主体内容。
- 不要把素材缺失表现为空白图片框;必须按 `fallback_if_missing` 生成 XML-native 视觉。
- 不要留下占位文案、示例公司名、示例日期或与用户主题无关的内容。
### 创建方式选择
| 场景 | 推荐方式 |
|------|----------|
| 简单 XML1-3 页、结构简单、几乎无复杂中文和特殊字符) | `slides +create --slides '[...]'` 一步创建 |
| 复杂 XML多页、含中文、大段文本、复杂布局、嵌套引号、特殊字符较多 | **两步创建**:先 `slides +create` 创建空白 PPT再用 `xml_presentation.slide create` 逐页添加 |
| 已有 PPT 继续追加或插入页面 | 使用 `xml_presentation.slide create`,必要时配合 `before_slide_id` |
> [!WARNING]
> `--slides '[...]'` 的风险点主要在 shell 参数传递,而不是单纯页数。即使只有 1 页,只要 XML 足够复杂,也建议使用两步创建法。
> [!IMPORTANT]
> `slides +create --slides` 底层会逐页创建,不是原子操作。中途失败时先记录 `xml_presentation_id`,回读确认当前状态,再继续修复或追加。
```text
Step 1: 需求澄清 & 读取知识
- 澄清主题、受众、页数、风格
- 读取 xml-schema-quick-ref.md新建 / 大幅改写时还要读取 planning-layer.md、visual-planning.md、asset-planning.md
Step 2: 生成大纲 → 用户确认 → 写入 slide_plan.json
- 生成结构化大纲供用户确认
- 新建 / 大幅改写必须先创建目录并写入 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`
- plan 字段、路径命名和 `asset_need` 结构按 planning-layer.md / asset-planning.md 执行
Step 3: 按 slide_plan.json 生成 XML → 创建
- 逐页消费 plankey_message 定主结论layout_type 定几何visual_focus 定主视觉text_density 定文本量
- 缺少真实素材时必须用 `fallback_if_missing` 生成 XML-native 兜底视觉;不要留空
- 创建方式按“创建方式选择”判断;图片、复杂 XML、转义和 3350001 排查按 lark-slides-create.md、media-upload.md、troubleshooting.md 执行
Step 4: 审查 & 交付
- 创建完成后,必须用 xml_presentations.get 读取全文 XML并按 validation-checklist.md 做显式验证记录,包括 XML 文本重叠检查
- 失败或部分成功按 troubleshooting.md 处理;局部问题优先用 `+replace-slide` 修正
- 没问题 → 交付:告知用户演示文稿 ID 和访问方式
```
### jq 命令模板(编辑已有 PPT 时使用)
新建 PPT 推荐用 `+create --slides`。以下 jq 模板适用于向已有演示文稿追加页面的场景,可以避免手动转义双引号:
```bash
# 追加到末尾
lark-cli slides xml_presentation.slide create \
--as user \
--params '{"xml_presentation_id":"YOUR_ID"}' \
--data "$(jq -n --arg content '<slide xmlns="http://www.larkoffice.com/sml/2.0">
<style><fill><fillColor color="BACKGROUND_COLOR"/></fill></style>
<data>
在这里放置 shape、line、table、chart、whiteboard 等元素
</data>
</slide>' '{slide:{content:$content}}')"
# 插到指定页之前before_slide_id 必须在 --data body 里,与 slide 同级
# ⚠️ 不要把 before_slide_id 写进 --params —— CLI 会当未知 query 参数静默下发,服务端忽略,新页跑到末尾
lark-cli slides xml_presentation.slide create \
--as user \
--params '{"xml_presentation_id":"YOUR_ID"}' \
--data "$(jq -n --arg content '<slide ...>...</slide>' --arg before 'TARGET_SLIDE_ID' \
'{slide:{content:$content}, before_slide_id:$before}')"
```
> 渐变色必须使用 `rgba()` 格式并带百分比停靠点,如 `linear-gradient(135deg,rgba(15,23,42,1) 0%,rgba(56,97,140,1) 100%)`。使用 `rgb()` 或省略停靠点会导致服务端回退为白色。
### 大纲模板
生成大纲时使用以下格式,交给用户确认:
```text
[PPT 标题] — [定位描述],面向 [目标受众]
页面结构N 页):
1. 封面页:[标题文案]
2. [页面主题][要点1]、[要点2]、[要点3]
3. [页面主题][要点描述]
...
N. 结尾页:[结尾文案]
风格:[配色方案][排版风格]
```
当没有本地 PPTX 模板 / 参考演示文稿,或目标是新建飞书 / Lark 在线 Slides 而不是本地 `.pptx` 文件时,使用该流程。
## 核心概念
@@ -240,35 +78,98 @@ Slides (演示文稿)
└── slide_id (页面唯一标识)
```
## Shortcuts 与 API
## 身份选择
Shortcut 是对常用操作的高级封装(`lark-cli slides +<verb> [flags]`)。有 Shortcut 的操作优先使用
飞书幻灯片通常是用户自己的内容资源。**默认应优先显式使用 `--as user`(用户身份)执行 slides 相关操作**,始终显式指定身份
| Shortcut | 说明 |
|----------|------|
| [`+create`](references/lark-slides-create.md) | 创建 PPT可选 `--slides` 一步添加页面,支持 `<img src="@./local.png">` 占位符自动上传) |
| [`+media-upload`](references/lark-slides-media-upload.md) | 上传本地图片到指定演示文稿,返回 `file_token`(用作 `<img src="...">`),最大 20 MB |
| [`+replace-slide`](references/lark-slides-replace-slide.md) | 对已有幻灯片页面进行块级替换/插入(`block_replace` / `block_insert`),自动注入 id 和 `<content/>`,不改变页序 |
| [`+replace-pages`](references/lark-slides-replace-pages.md) | 在原演示文稿内批量重建多个页面:先创建新页到旧页前,再删除旧页;适合已有 Slides 的多页大改,不新建链接 |
没有 Shortcut 覆盖时使用原生 API。高频资源`xml_presentations.get` 读取全文;`xml_presentation.slide.create/delete/get/replace` 管理单页。
- **`--as user`(推荐)**:以当前登录用户身份创建、读取、管理演示文稿。执行前先完成用户授权:
```bash
lark-cli schema slides.<resource>.<method> # 调用 API 前必须先查看参数结构
lark-cli slides <resource> <method> [flags] # 调用 API
lark-cli auth login --domain slides
```
> **重要**:使用原生 API 时,必须先运行 `schema` 查看 `--data` / `--params` 参数结构,不要猜测字段格式
- **`--as bot`**:仅在用户明确要求以应用身份操作,或需要让 bot 持有/创建资源时使用。使用 bot 身份时,要额外确认 bot 是否真的有目标演示文稿的访问权限
## 核心规则
**执行规则**
1. **先规划再写 XML**:新建演示文稿或大幅改写页面时,必须先写入 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`;风格和大纲只能作为规划输入,不能绕过规划层
2. **创建流程**:简单短 XML1-3 页、结构简单、特殊字符少)可用 `slides +create --slides '[...]'` 一步创建;复杂内容、含图片/中文大段文本/嵌套引号/较多特殊字符,或超过 10 页时,默认先 `slides +create` 创建空白 PPT再用 `xml_presentation.slide.create` 逐页添加
3. **`<slide>` 直接子元素只有 `<style>``<data>``<note>`**:文本和图形必须放在 `<data>`
4. **文本通过 `<content>` 表达**:必须用 `<content><p>...</p></content>`,不能把文字直接写在 shape 内
5. **保存关键 ID**:后续操作需要 `xml_presentation_id``slide_id``revision_id`
6. **删除谨慎**:删除操作不可逆,且至少保留一页幻灯片
7. **编辑已有页面优先原链接更新**:修改单个 shape/img 用 `+replace-slide``block_replace` / `block_insert`),不要整页重建;已有 Slides 的多页整页重建用 `+replace-pages`,不要用 `slides +create` 新建整份 PPT只有没有 shortcut 覆盖的特殊单页整页操作才手动 `slide.create` + `slide.delete`
8. **`<img src>` 只能用上传到飞书 drive 的 `file_token`,禁止使用 http(s) 外链 URL**:飞书 slides 渲染端不会代理外链图片,外链 src 在 PPT 里通常不显示或显示破图。流程必须是「先把图存到本地 → 用 `slides +media-upload` 上传或 `+create --slides``@./path` 占位符自动上传 → 拿 `file_token` 写进 `<img src>`」。如果用户给了网图链接,先 `curl`/下载到 CWD 内再走上传流程,不要直接把外链 URL 塞进 `src`。**图片最大 20 MB**slides upload API 不支持分片上传)。
1. 创建、读取、增删 slide、按用户给出的链接继续编辑已有 PPT默认都先用 `--as user`
2. 如果出现权限不足,先检查当前是否误用了 bot 身份;不要默认回退到 bot。
3. 只有在用户明确要求"用应用身份 / bot 身份操作",或当前工作流就是 bot 创建资源后再做协作授权时,才切换到 `--as bot`
> **注意**:如果 md 内容与 `slides_xml_schema_definition.xml` 或 `lark-cli schema slides.<resource>.<method>` 输出不一致,以后两者为准。
## 设计思路
### 内容先行
- 每页只服务一个核心观点。内容页标题应写成带判断的结论句,而不是主题标签;读者只看标题就能知道这一页要证明什么。
- 受众和交付方式决定密度:演讲型 deck 更适合少字、强节奏、分步呈现;自读型 deck 必须在没有讲解和点击的情况下完整可读。
- 并列观点要互不重叠、没有明显缺口,通常控制在 3-5 个,最多不要超过 7 个;排序只选一种逻辑:时间、结构或重要性。
- 封面、章节页、内容页、结尾页承担不同任务。章节页只做过渡,不承载多点论证;短 deck 不要机械加入 agenda、Q&A 或多个收尾页。
### 视觉系统
- 先根据主题、行业、受众和交付方式推导视觉方向,再确定配色、字体、图形语言和页面密度;不要让用户在一堆抽象风格词里做选择。
- 同一份 deck 要锁定一套视觉系统,并贯穿所有页面:主色、背景、正文颜色、强调色、标题处理、留白密度、图标/图形风格都要稳定。
- 配色要有角色分工:`primary` 承担品牌/结构,`background` 承担页面基底,`text_primary` / `text_body` 保证阅读,`accent` 只用于关键数字、结论或行动点。
- 不要默认蓝色商务风;如果一套配色换到完全不同主题仍然成立,说明它不够具体。
- 背景策略要克制:纯色、渐变或图片三选一作为主背景,不要叠多层全页色块。深色、发光或科技感页面,应使用平整深色背景 + 局部发光元素,而不是半透明大渐变把页面洗白。
- 所有文字、图标、线条和图表都必须与背景保持足够对比;弱化信息可以降低饱和度或透明度,但不能牺牲可读性。
### 字体与字号
- 标题字体可以有性格,正文字体必须清晰耐读;不要整份 deck 都默认 Arial。
- 中英文混排时,字体族先写英文/拉丁字体,再写中文/CJK 字体,最后写通用 fallback标题和正文各用一套稳定组合。
- 字体选择要匹配视觉系统的类别和处理方式:衬线、无衬线、圆体、等宽、粗窄标题、全大写等风格不要随意互换。
- 常用标题方向:`Playfair Display` / `EB Garamond` / `Lora` 适合编辑感和高级感;`Anton` / `Bebas Neue` / `Oswald` 适合强冲击标题;`DM Sans` / `Montserrat` / `Poppins` 适合现代产品和商业正文。
- 常用中文方向:`思源宋体` 适合长文和编辑感;`思源黑体` / `黑体` 适合中性现代;`寒蝉德黑体` 适合工业和科技;`寒蝉全圆体` / `资源圆体` 适合温暖亲和;书法类字体只用于少量标题。
| 元素 | 建议字号 |
|------|----------|
| 封面标题 | 40-56px纯标题页可到 64-96px |
| 内容页标题 | 28-40px |
| 副标题 / 分区标题 | 20-26px |
| 正文一级 | 16-20px |
| 正文二级 | 13-16px |
| 注释 / 来源 | 11-13px |
| Hero number | 80-140px |
不要为了填满空页面而盲目放大字体;页面显得空时,优先补充有意义的信息、调整构图或强化边缘对齐。
### 布局
- 先判断内容关系,再设计版式。比较、流程、时间线、循环、层级、矩阵、漏斗、整体-部分、因果等关系,应通过位置、对齐、分组、比例和流向直接表达。
- 版式本身要承载逻辑:比较用并列和基线对齐,流程用方向和连接,层级用尺度和嵌套,矩阵用坐标和象限,因果用箭头和阅读顺序。
- 每页都应围绕该页内容重新组织,不要从固定模板里盖章;同一 deck 可以复用视觉母题,但不要所有页面都是标题 + 三 bullets。
- 页面要留呼吸感。内容块之间保持稳定间距,卡片内边距要真实存在;文字不要贴边,也不要被装饰线、图片或页脚挤压。
- 正文默认左对齐;只有封面、章节页、结尾页、大号数字或少量仪式感页面适合居中。
### 视觉元素与图表
- 视觉元素必须承载意义或引导注意力,不做填空装饰。图片、图标、图表、表格、色块、连线都要解释内容关系、强调重点或改善阅读节奏。
- 每个内容页至少应有一个非纯文本视觉锚点:图片、图标、图表、表格、流程、对比结构、大号数字、示意图或抽象 shape 组合。
- 信息图、截图、图表等素材要保持原始比例;不要为了塞进版面强行裁切或拉伸。装饰性照片可以更自由,但仍要服务主题和构图。
- 有真实数据序列时,先写清图表要证明的 takeaway再选择图表类型一张图只表达一个核心结论。单个数字或两项简单对比优先用大号数字 callout不必硬画图。
- 饼图 / 环图只适合表达明确的整体构成;不确定时优先使用排序条形图。多系列数据要控制数量,必要时合并为 Other。
- 封面和结尾页的图片不要自带文字;文字应由 slide 渲染,避免图片中文字不可控、不可编辑或与语言风格冲突。
### 动效
- 动效服务节奏和注意力,不做炫技。只有在逐步解释、引导关键元素、展示流程 / 时间 / 变化时才使用。
- 演讲型 deck 可以用少量 build 控制听众视线;自读型、正式汇报型、董事会/咨询风格 deck 应尽量静态,最多使用统一的页面转场。
- 封面、章节页和结尾页默认静态。单页动效不超过 3 个 build且同页尽量只使用一种效果如果需要更多步骤优先拆页。
- 动效要让观众注意内容出现,而不是注意效果本身。优先使用淡入、出现、轻微上浮、擦入;避免旋转、弹跳、闪烁、远距离飞入等抢戏效果。
### 基于模板或已有 PPT 编辑
- 如果用户要求继续编辑、补页或修改已有 PPT默认保留原页面内容、结构、字体、配色和视觉资产只改用户要求的部分。
- 除非用户明确要求重做,不要擅自美化、重排、加封面、换背景或从零复刻。
- 如果用户把上传文件作为“参考风格”而不是“继续编辑原文件”,才可以抽取其视觉语言后重新创作。
### 避免事项
- 不要让版式先于内容;先判断这一页的逻辑关系,再决定几何结构。
- 不要创建纯文本页plain title + bullets 只能作为草稿,不是正式交付。
- 不要只设计一页,其余页面保持 plain视觉系统必须全篇贯彻或者全篇保持有意克制。
- 不要混用太多字体、字号、圆角、阴影和强调色;变化必须有层级意义。
- 不要使用低对比文字、低对比图标或难以阅读的背景图。
- 不要用图表承载多个结论,也不要因为有数字就机械画图。
- 不要在标题下方画装饰强调线作为默认设计手法;优先用留白、背景色块、尺度、分区和对齐建立层级。

View File

@@ -1,124 +0,0 @@
# Asset Planning
新建演示文稿或大幅改写页面时,在写入 `slide_plan.json` 前后都可以参考本文件。目标是让 agent 主动识别有价值的图、图标、图表、流程图、时序图、架构图、装饰图案、截图或示意图需求,同时保持 deck 在没有真实素材时也能完整执行。
本文件只定义轻量资产规划。不要把它理解成素材采集流程。
## Core Rules
- `asset_need` is metadata only. It can guide page design, but it must not require web search, local download, media upload, or external tools.
- Every planned asset must include a fallback visual plan so the slide can be generated with XML shapes, text, arrows, tables, simple charts, whiteboard diagrams, or placeholder regions.
- Asset needs must serve the page's `key_message` and `visual_focus`. Do not add decorative assets that do not clarify the page.
- Prefer a few high-value asset plans over one asset on every page. For a 6-page technical or business deck, plan assets on at least 3 pages when the content allows.
- If a real local asset already exists or the user provides one, it can be used through the normal media-upload workflow. Still keep `fallback_if_missing` in the plan.
- Do not leave blank image boxes in final XML. If the asset is missing, render the fallback visual.
## JSON Shape
Use an object for one planned asset, or an array when a page genuinely needs multiple assets. Keep each item compact.
```json
{
"asset_type": "architecture_diagram",
"purpose": "Show how API gateway, planner, XML generator, and Slides API interact.",
"suggested_query": "agent native slides runtime architecture diagram",
"fallback_if_missing": "Draw grouped boxes connected by arrows with short labels."
}
```
For a page without a meaningful asset need, use:
```json
{
"asset_type": "none",
"purpose": "No external or simulated asset needed; the page is text-led.",
"suggested_query": "",
"fallback_if_missing": "Use typography, spacing, and simple accent shapes only."
}
```
## Supported Asset Types
- `paper_figure`: figure from a paper or technical article.
- `architecture_diagram`: system components, data flow, dependency map, or model structure.
- `icon`: small semantic symbol for a concept, step, role, or status.
- `logo`: brand, product, team, or customer mark.
- `chart`: line, bar, pie, radar, area, or combo data visual. Note: `<chart>` does not support funnel or scatter — map those to `<whiteboard>` SVG at generation time.
- `infographic`: composed visual explanation, usually combining labels, numbers, and simple shapes.
- `screenshot`: product UI, terminal output, workflow state, or page capture.
- `flow_diagram`: process, sequence, decision tree, or mechanism diagram.
- `none`: explicitly no asset needed.
Do not invent new asset types unless the user asks for a special visual format. If a need is close to these types, choose the closest one and explain the detail in `purpose`.
## Planning Guidance
Match asset type to slide role:
- `architecture-diagram` layout usually pairs with `architecture_diagram` or `flow_diagram`.
- `process-flow` layout usually pairs with `flow_diagram`, `icon`, or `infographic`.
- `comparison` layout often works with `icon`, `chart`, or `infographic`.
- `timeline` layout often works with `icon`, `chart`, or shape-based milestone markers.
- `big-number` layout often works with `chart` or `infographic`, but only if it supports the metric.
- `image-left-text-right` and `image-right-text-left` can use `screenshot`, `paper_figure`, `logo`, or `infographic`; if missing, use a large placeholder diagram or stylized panel.
`suggested_query` is only a future lookup hint. Write it as a short phrase a human or later workflow could search, but do not execute the search unless the user separately requests real assets.
`fallback_if_missing` must be concrete enough to turn into XML, for example:
- "Draw a simplified attention matrix with 5 token labels, semi-transparent cells, and arrows to output token."
- "Use three grouped boxes with arrows from client to gateway to service; add small protocol labels."
- "Render a mini bar chart with 4 bars using shapes and value labels."
- "Use a bordered placeholder panel with product area labels, not an empty image."
Weak fallbacks to avoid:
- "Use a placeholder."
- "Find another image."
- "Leave blank if unavailable."
- "Use generic decoration."
## Examples
Transformer Self-Attention page:
```json
{
"asset_type": "paper_figure",
"purpose": "Explain token-to-token attention and why each output token mixes context.",
"suggested_query": "Transformer self attention attention matrix diagram",
"fallback_if_missing": "Draw a simplified attention matrix with token labels, colored weights, and arrows from input tokens to one highlighted output token."
}
```
System architecture page:
```json
{
"asset_type": "architecture_diagram",
"purpose": "Show the runtime path from user prompt to plan, XML generation, Slides API creation, and fetch verification.",
"suggested_query": "slides generation runtime architecture planner XML API verification",
"fallback_if_missing": "Draw four grouped boxes connected left-to-right with arrows; put verification as a return arrow from Slides API to agent."
}
```
Business comparison page:
```json
{
"asset_type": "infographic",
"purpose": "Make before/after differences scannable without dense bullet lists.",
"suggested_query": "before after product workflow comparison infographic",
"fallback_if_missing": "Use two side-by-side panels with matching icon circles and three parallel rows of concise labels."
}
```
## Plan To XML Contract
When generating XML:
1. If an asset exists and the workflow supports it, place it in the planned visual region.
2. If no asset exists, immediately render `fallback_if_missing` with XML-native shapes, text, lines, arrows, tables, whiteboard diagrams, or chart-like elements.
3. Size the fallback to satisfy `visual_focus`; it should be a real page element, not a tiny decoration.
4. Keep text-density limits. Do not compensate for missing assets by adding long bullet text.
5. After creation, fetch the presentation and verify asset pages are not blank and that each planned fallback is visible when no real asset was used.

View File

@@ -0,0 +1,155 @@
# 设计规则
这份规则用于生成或大幅改写演示文稿时做布局、组件、视觉层级和 XML 决策。它不是审美评论清单,而是生成前必须落到坐标、字号、颜色、组件和校验动作里的约束。
默认画布按 `960 x 540` 规划。模板可以覆盖具体坐标,但不能覆盖这些原则:页面要有清晰主视觉区域,文本要受密度约束,不同页型必须产生明显不同的几何结构。
## 生成前先定的事
- 先定页面角色:封面、章节页、观点页、证据页、数据页、对比页、流程页、时间线页、结论页。
- 先定一个主锚点:标题、关键数字、图表、截图、结论句或对比差异。主锚点必须是页面最大、最靠前或最高对比的区域。
- 先定结构令牌:外边距、标题区、主体区、栏宽、模块间距、组件内边距、圆角、线条粗细、色彩令牌和字体角色。
- 先定文本密度,再写文本。不要先塞满内容,再靠缩字号抢救。
- 先定组件类型。只有当内容确实是同级可比对象时才用卡片;只有当顺序有意义时才用流程或时间线。
## 核心规则
- `layout_type` 必须改变几何:不同页型的元素位置、区域大小、对齐方式和视觉节奏都要明显不同。
- `visual_focus` 必须成为最大或最高对比区域。它可以是图片、图表、指标、引语、表格或形状占位视觉。
- `text_density` 用来限制可见文本量:
- `low`:标题加一句短陈述,或 1-3 个标签。
- `medium`:标题加 2-4 条短要点,或若干带标签的信息区。
- `high`:使用表格、分栏、分组标签或注释。不要用一个长 bullet 框承载所有信息。
- 不要把整份演示文稿做成“标题加 bullet”。当页面数不少于 4 页且内容允许时,至少使用 4 种不同布局结构。
- 优先使用少量大对象,不要堆很多小文本框。
- 每页只允许 1 个主锚点。次级锚点必须解释、证明或补充主锚点,不能与它争抢注意力。
## 布局与间距
- 常规内容页使用 `60-80` px 外边距,除非有意使用全出血图片或封面式处理。
- 常规内容页标题区通常为 `y=36..90`,主体内容通常从 `y>=110` 开始。标题文本框要足够宽,避免意外换行。
- 非背景内容应尽量位于 `y=500` 以上,页脚除外。
- 优先把主体拆成 2-3 个大区域,而不是很多碎片。常见结构包括:左文右图、左图右文、上标题下模块、指标锚点加证据区。
- 同级模块必须共享 x/y、宽高、内边距和槽位顺序。不同尺寸只在差异本身就是信息时使用。
- 相关元素之间的距离应小于不相关元素之间的距离;主锚点周围留更大呼吸空间,次要信息可以更紧凑但必须对齐。
- 间距令牌要显式:`margin``titleGap``moduleGap``innerPadding`。重复模块用令牌生成坐标,不要手工逐个摆放。
## 背景与视觉母题一致性
- 为普通内容页选择一个默认背景,并精确复用。避免多个近似但不一致的背景色,除非它明确表示章节变化。
- 封面、强调页、结论页可以使用深色、图片主导或高对比背景,但仍必须共享整套文稿的主色、视觉母题、边缘处理、字体或几何语言。
- 如果封面使用左右或分区构图,背景或版式中必须看得出分区;为文字区和视觉区保留各自空间。
- 复用少量视觉装置:侧边栏、卡片圆角、节点样式、线条粗细、图标容器或页脚处理。
- 背景和视觉母题形状应先于内容元素插入,避免遮住文字、图片或图示。
## 视觉层级
- 用位置、大小、字重、留白和颜色共同建立层级,不要只靠颜色。
- 至少定义 3 个清晰文本层级:标题/主张、模块标题或标签、正文/注释。复杂页可增加指标和来源角色。
- 指标、结论或关键差异如果是页面主旨,必须放在专用区域中,不能埋在段落、图例或小卡片里。
- 颜色只用于确认已经由尺寸和位置建立的层级。到处使用强调色会让页面失去重点。
- 装饰不能成为第一视觉停点;分割线、网格线、卡片边框应低对比,除非它们表示选择、风险或状态。
## 字体与文本框
把字体当作角色系统,而不是逐个文本框随机调样式。推荐先定义这些角色:`deckTitle``slideTitle``sectionLabel``moduleTitle``body``caption``metric``source`
| 文本用途 | 常见字号 | 最小高度 |
|----------|----------|----------|
| 注释1 行 | 10-12 | 18 |
| 注释2 行 | 10-12 | 30 |
| 正文1 行 | 13-16 | 24 |
| 正文2 行 | 13-16 | 40 |
| 正文2 行,加粗 | 15-18 | 48 |
| 小标题1 行 | 24-32 | 42 |
| 大标题2 行 | 34-44 | 110 |
| 核心指标 | 64-110 | 110 |
补充规则:
- 同一角色在同一页和同一组组件中必须使用相同 `fontFamily``fontSize``fontWeight` 和颜色。
- 加粗文本、中文文本、中英混排、较大行距,或包含多个段落的文本块,都需要增加高度。
- 不要把较长中文句子或英文短语放进 `height=18``height=22` 的文本框。这类高度只适合短标签。
- 不要通过把正文缩到不可读来解决拥挤。优先缩短文案、拆分模块、扩大文本框或换成表格/卡片/图示结构。
- 页脚和来源说明通常只放一行短文本。如果需要更多内容,应放成页脚上方的正式注释块。
- 底部结论条承载一行强调文本时至少 `40` px 高,承载两行时至少 `54` px 高。
## 色彩
- 从中性底色、高对比正文色、低对比分割色、一个强调色开始。只有在表达正负、风险、阶段、类别等语义时才增加语义色。
- 普通内容页避免给每个模块不同填充色。模块填充用于分组,强调色用于标记重要项或当前项。
- 图表配色应克制:大多数系列保持柔和,只高亮支持页面结论的系列、行、列或单元格。
- 同一套演示文稿中强调色的含义要稳定。不要在一页表示推荐,下一页又表示风险。
- 长正文不要放在高饱和背景上。深色或图片背景必须保证标题和正文对比度。
## 页型规则
把这些高频页型当作几何承诺,而不是名称。
| `layout_type` | 几何承诺 | 文本限制 |
|---------------|----------|----------|
| `title-cover` | 一个主导性标题块,可配全出血背景、侧边大图、强调带或分区视觉区域。 | 只用 `low`:标题加副标题/背景句,不放 bullets。 |
| `section-opener` | 大章节编号、标签或标题成为主锚点,其他内容只做定位。 | 只放章节名、短引导句和必要元信息。 |
| `image-left-text-right` | 左侧视觉区占约 `35-45%` 宽度;密集截图或论文图可放大到 `50-65%`;右侧文本通常从 `x=420` 开始。 | 一个主标题加最多 4 条要点,或 2-3 张解读卡片/标注。 |
| `image-right-text-left` | 左侧文本区通常从 `x=60..90` 开始,宽 `400..460`;右侧视觉区占约 `35-45%` 宽度,并与主文本块对齐。 | 一个核心判断加 2-3 条支撑点;标注要短且结构平行。 |
| `two-column` | 主区域拆成两个均衡栏,例如 `x=60,width=400``x=500,width=400`;每栏都需要自己的标题或视觉锚点。 | `medium`:每栏 2-3 条短内容。`high`:使用分组行或小表格。 |
| `big-number` | 最大对象必须留给指标:字号常为 `64-110`,区域至少 `300 x 120`。 | `low``medium`;数字周围只放紧凑标签、图例或小卡片。 |
| `comparison` | 使用两个或三个对齐的面板、列、表格或小倍图;用一个明确线索突出推荐项或关键差异。 | 使用平行表述;避免长短不一的 bullet 列表。 |
| `cards` | 2-6 个同级模块共享宽高、内边距、标题位置和槽位顺序。 | 每张卡片只承载一个短观点,不放段落。 |
| `process` | 重复节点加连接线,形成单一路径;连接线在节点和标签下方。 | 步骤标签比描述更突出,描述短且平行。 |
| `timeline` | 里程碑沿时间轴排列;时间差重要时按时间比例,否则按序列均分。 | 日期/阶段标签优先,说明文字短。 |
| `data` | 结论区与证据区分离,指标或洞察先于图表细节。 | 图表标题写洞察,不只写指标名。 |
| `conclusion` | 使用一个主导性的结论句或行动号召,最多搭配 3 个下一步卡片、检查项或负责人/日期标签。 | 保持易记,不要堆总结。 |
## 组件规则
- **封面/章节页**:只保留标题组、主视觉和少量元信息。不要把封面做成执行摘要、仪表盘或多卡片汇总。
- **指标组件**:包含 value、unit、label、explanation、optional delta。数值是最大文本单位和限定词靠近数值但更小。
- **数据图表**:先给图表/表格留足边界,再放标注。优先用直接标签减少视线往返;网格线和坐标轴低对比。
- **对比组件**:被比较对象必须共享槽位顺序,例如 label、metric、visual、description、emphasis marker。只高亮一个推荐项、变化项或风险项。
- **卡片组件**:卡片只用于真实同级对象。标题长度和字号要平行,正文用一句话,推荐或选中卡片最多增加一个强调线索。
- **流程/时间线**:节点从数组或索引生成位置,连接线先画、节点后画、标签最后画。不要让连接线穿过文字。
- **截图/论文图/产品图**:真实素材必须足够大到可读;若过密,应裁切关键区域、做局部放大,或用原生形状重画核心信息。
## 截图与真实素材页面
- 根据页面角色决定放置方式,不按固定页码套模板。方法概览、证据页、对比页和失败分析页通常更适合放真实图片。
- 只有在图片以幻灯片尺寸展示仍可读时,才直接使用真实素材。如果图过密,应裁切关键区域、做局部放大,或用原生形状重画核心信息。
- 截图或真实图片通常应成为视觉焦点。不要把它缩成装饰性缩略图,同时在周围堆大量文字。
- 配少量解释性标注,告诉观众应该看哪里。
- 使用外部素材或论文图时,始终添加简短来源说明。
## XML / Slides 生成规则
- 先定义画布、边距、标题区、主体区、栏宽、间距、颜色、字体角色和组件 token再生成具体对象。
- 每个文本框必须先有语义角色,再分配坐标、字号、字重和颜色。
- 所有形状、文本、图片、图表都使用显式 `x/y/width/height`,不要依赖默认位置或自适应猜测。
- 重复组件必须从同一数据数组和同一几何函数生成,避免手写出微小不一致。
- z-order 顺序通常是:背景、分区形状、连接线、图片/图表/卡片、文本、标注/强调层。
- 颜色通过 `base``text``muted``accent``positive``negative``risk` 等 token 引用,不要在每个对象里临时硬编码。
- 生成后必须检查重叠、裁切、异常换行、标题意外换行、底部溢出、来源说明缺失和主锚点不清。
## 常见错误
- 页面没有主锚点,所有内容都像同级说明。
- 把视觉稿变成标题加长 bullet或者把研究材料原文直接塞进文本框。
- 用很多颜色和边框填满空白,却没有表达语义。
- 同级卡片尺寸、标题位置、槽位顺序不一致。
- 数据页只有图表没有结论,或结论离证据太远。
- 流程线穿过标签,时间线里程碑太多且描述过长。
- 字号层级过平,标题、标签、正文看起来差不多大。
- 为了装下文字持续缩字号,而不是删减、拆分或换结构。
## 证据来源
这些规则来自典型ppt案例的主题化提炼。核心跨文稿模式包括
- 顶部标题先锚定页面,再组织主体内容。
- 左右文本/视觉分区是最稳定的解释结构之一。
- 结构化文本页使用重复对齐模块,而不是自由散落文本框。
- 数据页通常用数字锚点配合图表或表格表达结论。
- 字体尺度分离标题、标签和正文。
- 中性底色配有限强调色比多色装饰更可靠。
- 封面和章节页使用更少文本对象和更强视觉框架。
- 多个同级对象应规范化为卡片或同构模块。
- 流程和时间线通过重复节点加克制连接线表达顺序。

View File

@@ -0,0 +1,266 @@
---
name: lark-slides
version: 1.0.0
description: "飞书幻灯片:创建和编辑幻灯片。创建演示文稿、读取幻灯片内容、管理幻灯片页面(创建、删除、读取、局部替换)。当用户需要创建或编辑幻灯片、读取或修改单个页面时使用。当用户给出 doubao.com 的 /slides/ URL/token 时,也应直接使用本 skill不要因为域名不是飞书而回退到 WebFetch路由依据是 URL 路径模式和 token而不是域名。不负责云文档内容编辑走 lark-doc、云文档里的独立画板对象走 lark-whiteboard注意 slide 内嵌的流程图/架构图仍属本 skill、上传或下载普通文件走 lark-drive。"
metadata:
requires:
bins: ["lark-cli"]
cliHelp: "lark-cli slides --help"
---
# slides (v1)
## Quick Reference
| 用户需求 | 优先动作 | 关键文档 / 命令 |
|-------------------------------------|----------|-----------------|
| 新建 PPT | 先确定叙事、页序和视觉策略,再按复杂度选择一步或两步创建 | `design-rules.md``slides +create` |
| 已有 PPT 大幅改写 | 多页整页重建用 `+replace-pages`,单页局部编辑用 `+replace-slide` | `xml_presentations.get``lark-slides-replace-pages.md``lark-slides-edit-workflows.md` |
| 编辑单个标题、文本块、图片或局部元素 | 优先块级替换/插入,不改页序 | `slides +replace-slide``lark-slides-replace-slide.md` |
| 读取或分析已有 PPT | 解析 slides/wiki token回读全文或单页 XML保存 `xml_presentation_id``slide_id``revision_id` | `xml_presentations.get``xml_presentation.slide.get` |
| 获取幻灯片页面截图 | 用 `slide_id` 或页号指定页面 | `slides +screenshot``lark-slides-screenshot.md` |
| 上传或使用图片 | 先上传为 `file_token`,禁止直接写 http(s) 外链 | `slides +media-upload`,或 `+create --slides``@./path` 占位符 |
| 在 slide 中绘制柱/条/折线/面积/雷达/饼等有数据序列的图表 | 使用原生 `<chart>` 元素 | `xml-schema-quick-ref.md` |
| 在 slide 中绘制流程图、时序图、架构图、散点图、漏斗图或装饰图案 | 必须先用 Read 工具读取参考文档,再生成 `<whiteboard>` 元素 | [`lark-slides-whiteboard.md`](references/lark-slides-whiteboard.md) |
| 使用语义图标 | 先检索 IconPark再写 `<icon iconType="...">` | `iconpark_tool.py search → resolve``iconpark.md` |
| 创建失败、空白页、3350001、布局异常 | 先回读状态,再按排障清单修复,不假设原操作原子成功 | `troubleshooting.md``validation-checklist.md` |
**CRITICAL — 开始前 MUST 先用 Read 工具读取 [`../lark-shared/SKILL.md`](../lark-shared/SKILL.md),认证、权限和全局参数均以 lark-shared 为准。**
**CRITICAL — 生成任何 XML 之前MUST 先用 Read 工具读取 [xml-schema-quick-ref.md](references/xml-schema-quick-ref.md),禁止凭记忆猜测 XML 结构。**
**CRITICAL — PPT 生成与模板编辑硬约束PPT 的尺寸是 960x540确保主体内容在页面边界内。多用生图辅助搜图必须要图文并茂。不要为了画出一个具象物体而堆叠 3 个以上仅用于拟形的 shape。生成背景图时必须在 prompt 中明确要求不要出现任何文字。用户指定 PPT 模板时,用 lark-drive 技能导入成 lark slides回读理解每页版式后直接在该 slides 上编辑,可以填改文字和图片、按需增删模板页,必须严格沿用原版式和字体,只改内容不做设计,完成后回读并微调,凝练文字或缩减字号消除文字溢出,调整 shape 顺序或位置避免文字遮挡。**
**CRITICAL — 创建或大幅改写后MUST 按 [validation-checklist.md](references/validation-checklist.md) 做显式验证:回读全文 XML、核对页数和关键元素、检查空白/破损页、明显溢出、布局风险XML 语法和文本重叠静态检查优先使用 [`scripts/xml_text_overlap_lint.py`](scripts/xml_text_overlap_lint.py)。**
**CRITICAL — 创建前自检或失败排障时MUST 按 [troubleshooting.md](references/troubleshooting.md) 检查 XML 转义、结构、shell 截断、图片 token、3350001 和布局风险。**
**编辑已有幻灯片页面**:单个标题、文本块、图片或局部元素优先用 [`+replace-slide`](references/lark-slides-replace-slide.md)(块级替换/插入,不动页序);已有 Slides 的多页大改优先用 [`+replace-pages`](references/lark-slides-replace-pages.md) 在原 presentation 内批量重建页面,避免 `slides +create` 生成新链接。选择 action 和完整读-改-写流程见 [`lark-slides-edit-workflows.md`](references/lark-slides-edit-workflows.md)。
## 身份选择
飞书幻灯片通常是用户自己的内容资源。**默认应优先显式使用 `--as user`(用户身份)执行 slides 相关操作**,始终显式指定身份。
- **`--as user`(推荐)**:以当前登录用户身份创建、读取、管理演示文稿。执行前先完成用户授权:
```bash
lark-cli auth login --domain slides
```
- **`--as bot`**:仅在用户明确要求以应用身份操作,或需要让 bot 持有/创建资源时使用。使用 bot 身份时,要额外确认 bot 是否真的有目标演示文稿的访问权限。
**执行规则**
1. 创建、读取、增删 slide、按用户给出的链接继续编辑已有 PPT默认都先用 `--as user`
2. 如果出现权限不足,先检查当前是否误用了 bot 身份;不要默认回退到 bot。
3. 只有在用户明确要求"用应用身份 / bot 身份操作",或当前工作流就是 bot 创建资源后再做协作授权时,才切换到 `--as bot`
## 执行前必做
> **重要**`references/slides_xml_schema_definition.xml` 是此 skill 唯一正确的 XML 协议来源;其他 md 仅是对它和 CLI schema 的摘要。
高频只读:
- [xml-schema-quick-ref.md](references/xml-schema-quick-ref.md)
- [design-rules.md](references/design-rules.md)(新建 / 大幅改写)
- [validation-checklist.md](references/validation-checklist.md)(创建 / 大幅改写后)
按需再读:
- 创建:[`lark-slides-create.md`](references/lark-slides-create.md)
- 编辑:[`lark-slides-edit-workflows.md`](references/lark-slides-edit-workflows.md)、[`lark-slides-replace-slide.md`](references/lark-slides-replace-slide.md)、[`lark-slides-replace-pages.md`](references/lark-slides-replace-pages.md)
- 截图:[`lark-slides-screenshot.md`](references/lark-slides-screenshot.md)
- 图片:[`lark-slides-media-upload.md`](references/lark-slides-media-upload.md)
- 流程图 / 时序图 / 架构图 / 装饰图案:[`lark-slides-whiteboard.md`](references/lark-slides-whiteboard.md)
- 图标:[`iconpark.md`](references/iconpark.md)、[`scripts/iconpark_tool.py`](scripts/iconpark_tool.py)
- 排障:[`troubleshooting.md`](references/troubleshooting.md)
- 完整协议:[`slides_xml_schema_definition.xml`](references/slides_xml_schema_definition.xml)
## Workflow
> **这是演示文稿,不是文档。** 每页 slide 是独立的视觉画面,信息密度要低,排版要留白。
### Design Ideas
不要生成无设计感的幻灯片。纯白背景 + 标题 + bullets 只能作为极简临时稿,不能作为正式交付。
开始写 XML 前,先确定 deck 级视觉策略:
- **主题化配色**:配色必须服务本次主题、行业和受众,不要默认蓝色商务风。如果把同一套颜色换到另一个完全不同主题仍然成立,说明配色不够具体。
- **主次比例**:选择 1 个主色承担约 60-70% 视觉权重1-2 个辅助色承担结构和分区1 个强调色只用于关键数字、结论或行动点。不要让所有颜色权重相同。
- **背景一致性**:先确定全 deck 的背景策略,默认保持同一明暗基调和底色体系;只有分节、转场或强调页才有意改变背景,并必须通过相同主色、纹理、边栏或 motif 让变化看起来属于同一套设计。无论深浅,都要保证正文、图标和线条对比充足。
- **统一 motif**:选择一个可复用视觉母题贯穿全文,例如粗侧边栏、圆形图标底、半出血图片区、编号节点、卡片左上角色块或大号数字。不要每页换一套装饰语言。
每页至少要有一个视觉元素:图片、图标、图表、表格、流程、对比结构、大号数字、示意图或由 shape 组成的抽象视觉。文本框本身不算主视觉。
可优先考虑这些页面形态:
- **双栏结构**:左文右图或左图右文,视觉区域占 35-45% 宽度。
- **图标行**:图标在色块或圆形底中,右侧是短标题和一句解释。
- **2x2 / 2x3 网格**:适合能力、模块、风险、行动项,每格内容保持同等层级。
- **半出血视觉**:图片或抽象形状占据左/右半屏,文字覆盖或贴边排布。
- **大数字卡片**:关键指标用 60-72pt 数字,下面配 10-14pt 标签。
- **对比列**before/after、方案 A/B、问题/解法用左右并列,标题和基线严格对齐。
- **时间线/流程图**:步骤用节点和箭头表达,流程方向必须一眼可见。
字体和间距建议:
- 标题 36-44pt关键结论可更大正文 14-18pt注释 10-12pt。
- 正文默认左对齐;只在封面、结尾或大号数字场景中使用居中。
- 页面边距至少 40px内容块之间保持 24-40px 间距,并在同一 deck 内保持一致。
- 卡片内边距要真实留出空间,不要让文字贴边;对齐 shape 和文字时要考虑文本框 padding。
常见错误必须避免:
- 不要所有页面复用同一种标题 + 三 bullets 版式。
- 不要用低对比文字或低对比图标,例如浅灰字压在浅色背景上。
- 不要让装饰线穿过文字,或让页脚、来源、编号挤压主体内容。
- 不要把素材缺失表现为空白图片框;必须用 XML-native 形状、图表、表格或 whiteboard 生成兜底视觉。
- 不要留下占位文案、示例公司名、示例日期或与用户主题无关的内容。
### 创建方式选择
| 场景 | 推荐方式 |
|------|----------|
| 简单 XML1-3 页、结构简单、几乎无复杂中文和特殊字符) | `slides +create --slides '[...]'` 一步创建 |
| 复杂 XML多页、含中文、大段文本、复杂布局、嵌套引号、特殊字符较多 | **两步创建**:先 `slides +create` 创建空白 PPT再用 `xml_presentation.slide create` 逐页添加 |
| 已有 PPT 继续追加或插入页面 | 使用 `xml_presentation.slide create`,必要时配合 `before_slide_id` |
> [!WARNING]
> `--slides '[...]'` 的风险点主要在 shell 参数传递,而不是单纯页数。即使只有 1 页,只要 XML 足够复杂,也建议使用两步创建法。
> [!IMPORTANT]
> `slides +create --slides` 底层会逐页创建,不是原子操作。中途失败时先记录 `xml_presentation_id`,回读确认当前状态,再继续修复或追加。
```text
Step 1: 需求澄清 & 读取知识
- 澄清主题、受众、页数、风格
- 读取 xml-schema-quick-ref.md新建 / 大幅改写时还要读取 design-rules.md
Step 2: 生成大纲 → 用户确认
- 生成结构化大纲供用户确认
- 新建 / 大幅改写必须先明确 deck 目标、受众、页序、视觉系统和每页关键消息
- 每页确定 `key_message`、`layout_type`、`visual_focus`、`text_density`;素材需求只作为设计意图
Step 3: 按已确认大纲生成 XML → 创建
- 逐页生成 XMLkey_message 定主结论layout_type 定几何visual_focus 定主视觉text_density 定文本量
- 缺少真实素材时必须用 XML-native 形状、图表、表格或 whiteboard 生成兜底视觉;不要留空
- 创建方式按“创建方式选择”判断;图片、复杂 XML、转义和 3350001 排查按 lark-slides-create.md、media-upload.md、troubleshooting.md 执行
Step 4: 审查 & 交付
- 创建完成后,必须用 xml_presentations.get 读取全文 XML并按 validation-checklist.md 做显式验证记录,包括 XML 文本重叠检查
- 失败或部分成功按 troubleshooting.md 处理;局部问题优先用 `+replace-slide` 修正
- 没问题 → 交付:告知用户演示文稿 ID 和访问方式
```
### jq 命令模板(编辑已有 PPT 时使用)
新建 PPT 推荐用 `+create --slides`。以下 jq 模板适用于向已有演示文稿追加页面的场景,可以避免手动转义双引号:
```bash
# 追加到末尾
lark-cli slides xml_presentation.slide create \
--as user \
--params '{"xml_presentation_id":"YOUR_ID"}' \
--data "$(jq -n --arg content '<slide xmlns="http://www.larkoffice.com/sml/2.0">
<style><fill><fillColor color="BACKGROUND_COLOR"/></fill></style>
<data>
在这里放置 shape、line、table、chart、whiteboard 等元素
</data>
</slide>' '{slide:{content:$content}}')"
# 插到指定页之前before_slide_id 必须在 --data body 里,与 slide 同级
# ⚠️ 不要把 before_slide_id 写进 --params —— CLI 会当未知 query 参数静默下发,服务端忽略,新页跑到末尾
lark-cli slides xml_presentation.slide create \
--as user \
--params '{"xml_presentation_id":"YOUR_ID"}' \
--data "$(jq -n --arg content '<slide ...>...</slide>' --arg before 'TARGET_SLIDE_ID' \
'{slide:{content:$content}, before_slide_id:$before}')"
```
> 渐变色必须使用 `rgba()` 格式并带百分比停靠点,如 `linear-gradient(135deg,rgba(15,23,42,1) 0%,rgba(56,97,140,1) 100%)`。使用 `rgb()` 或省略停靠点会导致服务端回退为白色。
### 大纲模板
生成大纲时使用以下格式,交给用户确认:
```text
[PPT 标题] — [定位描述],面向 [目标受众]
页面结构N 页):
1. 封面页:[标题文案]
2. [页面主题][要点1]、[要点2]、[要点3]
3. [页面主题][要点描述]
...
N. 结尾页:[结尾文案]
风格:[配色方案][排版风格]
```
## 核心概念
### URL 格式与 Token
| URL 格式 | 示例 | Token 类型 | 处理方式 |
|----------|------|-----------|----------|
| `/slides/` | `https://example.larkoffice.com/slides/xxxxxxxxxxxxx` | `xml_presentation_id` | URL 路径中的 token 直接作为 `xml_presentation_id` 使用 |
| `/wiki/` | `https://example.larkoffice.com/wiki/wikcnxxxxxxxxx` | `wiki_token` | ⚠️ **不能直接使用**,需要先查询获取真实的 `obj_token` |
> `+replace-slide` 和 `+media-upload` shortcut 会自动解析以上两种 URL直接调用原生 API 时仍需手动解析 wiki 链接。
### Wiki 链接特殊处理(关键!)
知识库链接(`/wiki/TOKEN`)不能直接当 `xml_presentation_id`。直接调用原生 API 前,先查询 wiki 节点,确认 `node.obj_type == "slides"`,再用 `node.obj_token` 作为真实 presentation ID。
```bash
lark-cli wiki spaces get_node --as user --params '{"token":"wiki_token"}'
```
Shortcut `+replace-slide``+media-upload` 会自动解析 `/wiki/` URL手动调用 `xml_presentations.*` / `xml_presentation.slide.*` 时才需要自己做这一步。
### 资源关系
```text
Wiki Space (知识空间)
└── Wiki Node (知识库节点, obj_type: slides)
└── obj_token → xml_presentation_id
Slides (演示文稿)
├── xml_presentation_id (演示文稿唯一标识)
├── revision_id (版本号)
└── Slide (幻灯片页面)
└── slide_id (页面唯一标识)
```
## Shortcuts 与 API
Shortcut 是对常用操作的高级封装(`lark-cli slides +<verb> [flags]`)。有 Shortcut 的操作优先使用。
| Shortcut | 说明 |
|----------|------|
| [`+create`](references/lark-slides-create.md) | 创建 PPT可选 `--slides` 一步添加页面,支持 `<img src="@./local.png">` 占位符自动上传) |
| [`+media-upload`](references/lark-slides-media-upload.md) | 上传本地图片到指定演示文稿,返回 `file_token`(用作 `<img src="...">`),最大 20 MB |
| [`+replace-slide`](references/lark-slides-replace-slide.md) | 对已有幻灯片页面进行块级替换/插入(`block_replace` / `block_insert`),自动注入 id 和 `<content/>`,不改变页序 |
| [`+replace-pages`](references/lark-slides-replace-pages.md) | 在原演示文稿内批量重建多个页面:先创建新页到旧页前,再删除旧页;适合已有 Slides 的多页大改,不新建链接 |
没有 Shortcut 覆盖时使用原生 API。高频资源`xml_presentations.get` 读取全文;`xml_presentation.slide.create/delete/get/replace` 管理单页。
```bash
lark-cli schema slides.<resource>.<method> # 调用 API 前必须先查看参数结构
lark-cli slides <resource> <method> [flags] # 调用 API
```
> **重要**:使用原生 API 时,必须先运行 `schema` 查看 `--data` / `--params` 参数结构,不要猜测字段格式。
## 核心规则
1. **先规划再写 XML**:新建演示文稿或大幅改写页面时,先确定 deck 目标、受众、页序、视觉系统和每页关键消息;不要从用户提示直接跳到 XML
2. **创建流程**:简单短 XML1-3 页、结构简单、特殊字符少)可用 `slides +create --slides '[...]'` 一步创建;复杂内容、含图片/中文大段文本/嵌套引号/较多特殊字符,或超过 10 页时,默认先 `slides +create` 创建空白 PPT再用 `xml_presentation.slide.create` 逐页添加
3. **`<slide>` 直接子元素只有 `<style>``<data>``<note>`**:文本和图形必须放在 `<data>`
4. **文本通过 `<content>` 表达**:必须用 `<content><p>...</p></content>`,不能把文字直接写在 shape 内
5. **保存关键 ID**:后续操作需要 `xml_presentation_id``slide_id``revision_id`
6. **删除谨慎**:删除操作不可逆,且至少保留一页幻灯片
7. **编辑已有页面优先原链接更新**:修改单个 shape/img 用 `+replace-slide``block_replace` / `block_insert`),不要整页重建;已有 Slides 的多页整页重建用 `+replace-pages`,不要用 `slides +create` 新建整份 PPT只有没有 shortcut 覆盖的特殊单页整页操作才手动 `slide.create` + `slide.delete`
8. **`<img src>` 只能用上传到飞书 drive 的 `file_token`,禁止使用 http(s) 外链 URL**:飞书 slides 渲染端不会代理外链图片,外链 src 在 PPT 里通常不显示或显示破图。流程必须是「先把图存到本地 → 用 `slides +media-upload` 上传或 `+create --slides``@./path` 占位符自动上传 → 拿 `file_token` 写进 `<img src>`」。如果用户给了网图链接,先 `curl`/下载到 CWD 内再走上传流程,不要直接把外链 URL 塞进 `src`。**图片最大 20 MB**slides upload API 不支持分片上传)。
> **注意**:如果 md 内容与 `slides_xml_schema_definition.xml` 或 `lark-cli schema slides.<resource>.<method>` 输出不一致,以后两者为准。

View File

@@ -0,0 +1,77 @@
# PPT Template Rewrite Principles
本页只约束“用户指定 PPT 模板、底稿、已有 PPTX/PDF/Slides并要求基于它二次创作”的场景。核心原则模板不是风格参考而是必须沿用的编辑底稿。
## Import First
用户指定 PPT 模板时,先使用 `lark-drive` 技能把模板导入成 Lark Slides。后续写入目标是导入后的 Slides不是新建一个脱离模板的 deck也不是先在本地重画 PPTX 再导入。
导入后必须回读 Slides 内容理解每页的真实版式、字体、层级、图片、图表、shape、表格和文本容器。回读结果是模板二创的事实来源。
## Read Before Editing
编辑任何 PPT 页面前,必须先阅读该页面。
如果当前上下文中没有该页内容,必须重新读取页面;这里的“当前上下文”不包含 System Prompt。不能只凭记忆、文件名、缩略图印象或模板整体风格判断来编辑具体页面。
阅读页面时至少判断:
- 该页原本承担的角色,例如封面、章节页、目录、流程、对比、数据、总结。
- 该页的主要版式结构,例如图文关系、箭头、时间线、节点、表格、图表、左右对照、背景图或产品图。
- 哪些文本框、shape 标签、表格单元格或图表标签承载内容。
- 原页面的字体、字号、颜色、对齐、层级和留白关系。
## Edit The Imported Slides Directly
理解页面后,直接在导入后的 Slides 上编辑。允许的操作包括:
- 填写、替换、凝练或删除文字。
- 替换或补充图片。
- 更新图表、表格、数字标签或节点标签里的内容。
- 按需复制、删除或重排模板页。
- 在源页面没有合适承载位置时,做局部、小范围新增元素。
新增元素只能补足内容缺口,不能成为新的主版式。页面主体仍应由模板原有版式承载。
## Preserve Design
模板二创必须严格沿用原版式和字体,只改内容,不做设计。
默认保留:
- 页面布局、视觉层级、留白和对齐关系。
- 原字体、字号体系、颜色、文本框位置和 shape 顺序。
- 背景图、图片、logo、图表、表格、装饰形状、线条、图标和页面结构。
- 模板中不同页型之间的差异。
不要把模板页改造成统一的通用卡片、白板、标题栏、三栏、2x2 卡片或大面积遮罩。不要把模板当作背景图后另起一套设计系统。
## Content Only
内容必须优先进入原页面已有的文本框、shape 标签、节点、表格单元格、图表标签或注释容器。
如果原容器空间不足,优先:
- 凝练文字。
- 降低字号但保持原字体体系。
- 拆分到页面已有的邻近容器。
- 使用模板已有的注释、标签或补充说明区域。
- 复制同页或同模板中的原生容器样式做局部补充。
不要为了容纳长文案而重画页面主体结构。不要用新增大卡片遮住原图表、箭头、图片、背景或关键 shape。
## Readback And Tune
完成编辑后必须回读结果,并逐页微调。
回读时重点检查:
- 文字是否溢出、截断、压线或超出容器。
- 文本是否遮挡图片、图表、shape、箭头、节点或其他文字。
- shape 顺序是否导致内容被覆盖或遮住。
- 新内容是否仍然落在模板原有版式中,而不是覆盖模板结构。
- 字体、字号、颜色、对齐和层级是否仍贴近原页。
发现文字溢出时,优先凝练文字或缩减字号。发现遮挡时,调整 shape 顺序、局部位置或复用原有空白区域解决。只有在这些方法都不能满足内容表达时,才做局部新增或删除。
模板二创的完成标准不是“生成了一套看起来统一的新 PPT”而是“原模板的版式、字体和视觉结构仍清晰存在内容已经被准确替换并且回读后没有溢出和遮挡”。

View File

@@ -237,4 +237,4 @@ lark-cli slides +replace-slide --as user \
- [xml_presentation.slide get](lark-slides-xml-presentation-slide-get.md) — 读原页拿 `block_id` / `revision_id`
- [xml_presentation.slide replace](lark-slides-xml-presentation-slide-replace.md) — 底层 replace API 参考
- [+media-upload](lark-slides-media-upload.md) — 上传图片拿 `file_token`
- [lark-slides-edit-workflows.md](lark-slides-edit-workflows.md) — 读-改-写闭环 + 决策树
- [lark-slides-edit-workflows.md](lark-slides-block-replace-workflows) — 读-改-写闭环 + 决策树

View File

@@ -67,7 +67,7 @@ lark-cli slides xml_presentation.slide create --as user --params '<json_params>'
</slide>
```
详细格式请参考 [xml-format-guide.md](xml-format-guide.md) 和 [xml-schema-quick-ref.md](xml-schema-quick-ref.md)。
详细格式请参考 [xml-schema-quick-ref.md](xml-schema-quick-ref.md)。
## 使用示例
@@ -216,5 +216,4 @@ done
- [slides +create](lark-slides-create.md) - 创建空白 PPT
- [xml_presentations get](lark-slides-xml-presentations-get.md) - 读取 PPT 内容
- [xml_presentation.slide delete](lark-slides-xml-presentation-slide-delete.md) - 删除幻灯片页面
- [xml-format-guide.md](xml-format-guide.md) - XML 格式详细规范
- [xml-schema-quick-ref.md](xml-schema-quick-ref.md) - Schema 快速参考
- [xml-schema-quick-ref.md](xml-schema-quick-ref.md) - XML 格式和 Schema 唯一 Markdown 入口

View File

@@ -107,4 +107,4 @@ lark-cli slides xml_presentation.slide get --as user --params '{
- [slides +replace-slide](lark-slides-replace-slide.md) — 块级替换 shortcut推荐
- [xml_presentation.slide replace](lark-slides-xml-presentation-slide-replace.md) — 底层 replace API 参考
- [xml_presentations get](lark-slides-xml-presentations-get.md) — 读整个 PPT
- [lark-slides-edit-workflows.md](lark-slides-edit-workflows.md) — 读-改-写闭环
- [lark-slides-edit-workflows.md](lark-slides-block-replace-workflows) — 读-改-写闭环

View File

@@ -184,4 +184,4 @@ lark-cli slides xml_presentation.slide replace --as user --params '{
- [slides +replace-slide](lark-slides-replace-slide.md) — 块级替换 shortcut推荐自动注入 id
- [xml_presentation.slide get](lark-slides-xml-presentation-slide-get.md) — 读原页拿 block short ID
- [slides +media-upload](lark-slides-media-upload.md) — 上传图片拿 file_token
- [lark-slides-edit-workflows.md](lark-slides-edit-workflows.md) — 读-改-写闭环 + 决策树
- [lark-slides-edit-workflows.md](lark-slides-block-replace-workflows) — 读-改-写闭环 + 决策树

View File

@@ -1,216 +0,0 @@
# Planning Layer
新建演示文稿或大幅改写页面时,必须先写 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`,再生成 XML。这个文件是 deck 的设计中间层,用来把叙事、页面角色、布局、视觉重点和文字密度固定下来,避免从用户提示直接跳到 XML。
小型已有页编辑可豁免,例如只替换一个标题、改一个数字、插入一个块、上传并插入一张图。只要任务会重排多页、生成新 deck、替换整页结构仍然需要规划层。
## Required Flow
1. 理解用户需求,必要时澄清主题、受众、页数、风格。
2. 选择唯一 plan 目录:`.lark-slides/plan/<deck-or-task-id>/`
3. 先创建目录:`mkdir -p .lark-slides/plan/<deck-or-task-id>`
4. 写入 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`
5. 读取 `xml-schema-quick-ref.md``visual-planning.md``asset-planning.md`
6. 按 plan、visual planning 和 asset planning 规则逐页生成 XML`layout_type``visual_focus``text_density` 转成具体页面几何和文本量约束,并把缺失素材转成可执行兜底视觉。
7. 创建 PPT 后用 `xml_presentations.get` 回读,核对页面数量、关键元素和 plan 到 XML 的对应关系。
## Plan Path
Use a separate plan directory per deck or task so multiple presentations in the same workspace cannot overwrite each other.
Recommended IDs:
- New deck before creation: title slug plus date/time, such as `q3-review-20260507-1805`.
- Existing PPT rewrite: the `xml_presentation_id`.
- Ambiguous or untitled task: short task slug plus date/time.
Rules:
- Do not reuse `.lark-slides/plan/slide_plan.json` as a shared path.
- Create the directory before writing the file.
- Reuse the same plan path for XML generation and post-create verification for that deck.
## Artifact Lifecycle
`.lark-slides/` is local agent state. It supports recovery, iteration, and later edits, but it should not be treated as source code or committed by default.
Keep:
- `.lark-slides/plan/<deck-or-task-id>/slide_plan.json` after successful creation or major rewrite. The plan is the editable design state for the deck.
- A small manifest when useful for follow-up work, such as `xml_presentation_id`, slide IDs, `revision_id`, plan path, and verification status.
Clean or avoid keeping:
- Transient XML payloads after successful creation and verification. Prefer `/tmp` for throwaway XML, or delete generated XML files after success.
- Stale XML drafts that no longer match the current presentation state.
Exception:
- If creation fails or partially succeeds, keep the relevant XML/debug payloads until recovery is complete. Record `xml_presentation_id` first, then fetch current state before retrying.
## JSON Shape
```json
{
"presentation_goal": "Explain the proposal and secure approval for the next phase.",
"audience": "Product and engineering leaders who know the domain but need a concise decision narrative.",
"theme_style": "Clean business style, light background, restrained blue accent, strong visual hierarchy.",
"visual_system": {
"background_strategy": "Content pages use one light base; cover and closing may use a related dark treatment with the same accent system.",
"motif": "A reusable left accent bar and consistent card/header treatments.",
"color_roles": {
"primary": "Used for the dominant structural motif and about 60-70% of visual weight.",
"secondary": "Used for grouped regions, comparison panels, or supporting categories.",
"accent": "Used only for key numbers, conclusions, or focus markers."
}
},
"typography_constraints": {
"title_max_lines": 2,
"body_max_lines_per_box": 2,
"footer_max_lines": 1,
"long_text_handling": "Shorten, split into multiple boxes, or move detail to speaker notes instead of shrinking into a tight box."
},
"verification_plan": {
"check_background_consistency": true,
"check_text_fit": true,
"check_visual_focus": true,
"check_asset_rendering": true
},
"slides": [
{
"page": 1,
"title": "Proposal Title",
"key_message": "The initiative is ready for a focused pilot.",
"layout_type": "title-cover",
"visual_focus": "Large title area with one concise supporting statement.",
"asset_need": {
"asset_type": "logo",
"purpose": "Signal product or team identity on the opening page.",
"suggested_query": "product logo",
"fallback_if_missing": "Use a small text badge and abstract shape motif instead of a real logo."
},
"text_density": "low",
"speaker_intent": "Frame the decision and establish the deck's point of view."
}
]
}
```
## Required Fields
Top-level fields:
- `presentation_goal`: what the whole deck is trying to achieve.
- `audience`: target readers or listeners and their assumed background.
- `theme_style`: visual tone, palette direction, and professional style.
- `visual_system`: deck-level visual rules that must stay stable across pages, including background strategy, recurring motif, and color roles.
- `typography_constraints`: deck-level limits for line count, text box density, and how to handle long text before XML generation.
- `verification_plan`: explicit checks to perform after creation or major edits; include background consistency, text fit, visual focus, and asset rendering when relevant.
- `slides`: ordered page plans.
Each slide must include:
- `page`: 1-based page number.
- `title`: slide title.
- `key_message`: the one idea this page must land.
- `layout_type`: planned page structure.
- `visual_focus`: dominant visual object or region.
- `asset_need`: planning-only structured asset metadata; no search, download, or upload required. Follow `asset-planning.md`.
- `text_density`: `low`, `medium`, or `high`.
- `speaker_intent`: why the speaker needs this page and how it advances the story.
## Layout Vocabulary
Use one of these `layout_type` values unless the user explicitly needs a custom structure:
- `title-cover`
- `section-divider`
- `two-column`
- `image-left-text-right`
- `image-right-text-left`
- `big-number`
- `timeline`
- `comparison`
- `architecture-diagram`
- `process-flow`
- `quote-highlight`
- `conclusion`
The value must affect XML geometry, not just appear as a label. For example, `timeline` should create a horizontal or vertical sequence, `comparison` should create distinct side-by-side regions, and `big-number` should reserve dominant space for a large metric.
## Text Density Rules
- `low`: title plus 1 short statement, or 1-3 very short labels.
- `medium`: title plus 2-4 concise bullets or labeled regions.
- `high`: allowed only when the user needs detail; use tables, columns, or grouped regions instead of a long bullet list.
Do not let all pages become title + bullet slides. For decks of 4 or more pages, aim for at least 4 different `layout_type` values when the content allows it.
Text density must be realistic for the planned geometry. If a page needs long titles, bilingual labels, paper figure captions, legal disclaimers, or dense technical wording, record how the text will be shortened, split, or moved to speaker notes. Do not rely on small font sizes or tight boxes to make text fit.
## Visual System Planning
Before generating XML, define a visual system that can survive the whole deck:
- `background_strategy`: specify the default background for normal content pages, and which page roles may intentionally differ. Do not let pages drift through near-identical but inconsistent background colors.
- `motif`: choose one or two reusable structural devices, such as a side bar, header rail, numbered node, card treatment, diagram lane, or section band. The motif should appear consistently enough that pages feel related.
- `color_roles`: assign primary, secondary, and accent roles. The same color must not mean unrelated things across pages.
- `cover_content_relationship`: if the cover uses a different dark or image-led treatment, state how it connects to content pages through shared colors, motifs, or geometry.
- `closing_relationship`: if the closing page mirrors the cover, state that explicitly so it looks intentional rather than like a new theme.
These are planning constraints, not decoration notes. They must affect coordinates, background fills, shape styles, and text placement in generated XML.
## Iterative Deck State
When continuing an existing deck, update the same plan path rather than creating a new disconnected plan. Keep the plan aligned with what has actually been created.
Recommended optional fields for long-running work:
- `deck_status`: current slide count, target slide count if known, and last verified revision or timestamp.
- `created_slides`: page number, slide id when known, and the page role.
- `assets_used`: source, local path when applicable, uploaded token when known, and which page uses it.
- `open_issues`: known layout, text fit, asset, or consistency risks that still need correction.
Do not hard-code a page number just because a previous deck used that pattern. Plan by page role and evidence need, such as "method overview pages should use a figure when the source has a readable figure" instead of binding screenshots, charts, or diagrams to a fixed page index. The plan should describe decision rules, not a rigid template sequence.
## Asset Planning
`asset_need` is metadata. It can describe a desired figure, diagram, chart, icon, logo, screenshot, or fallback shape-based visual, but it must not require web search, local download, or media upload.
Use an object for one planned asset, an array for multiple real needs, or `asset_type: "none"` when no asset is useful. Each planned asset must include:
- `asset_type`: one of `paper_figure`, `architecture_diagram`, `icon`, `logo`, `chart`, `infographic`, `screenshot`, `flow_diagram`, or `none`.
- `purpose`: why this asset helps the page's key message.
- `suggested_query`: short future lookup hint only; do not execute it unless separately requested.
- `fallback_if_missing`: concrete XML-native visual plan using shapes, labels, tables, whiteboard diagrams, or placeholder panels.
For detailed rules and examples, read `asset-planning.md`.
Good examples:
- `{"asset_type":"architecture_diagram","purpose":"Explain component relationships.","suggested_query":"service architecture diagram","fallback_if_missing":"Draw a component diagram with grouped boxes, connector arrows, and short labels."}`
- `{"asset_type":"logo","purpose":"Identify the customer context.","suggested_query":"customer logo","fallback_if_missing":"Use a text label in a small badge."}`
- `{"asset_type":"chart","purpose":"Show adoption trend.","suggested_query":"monthly adoption trend chart","fallback_if_missing":"Draw a simple trend line chart with axis labels and data points."}`
## XML Generation Contract
Before writing each slide XML, map the plan fields to concrete decisions:
- `key_message` determines the headline, dominant claim, or main takeaway.
- `layout_type` determines the coordinate structure and element types. Use `visual-planning.md` for concrete layout rules.
- `visual_focus` determines the largest visual region or emphasized object.
- `text_density` caps visible text volume.
- `asset_need` informs placeholder diagrams, icons, charts, screenshots, or shape-based fallback visuals only. Missing real assets must use `fallback_if_missing`, not blank regions.
After creating the PPT, fetch the presentation and verify:
- Page count matches the plan.
- Every page has the planned title and key message represented.
- At least several pages have visibly different XML layout structures.
- Planned `visual_focus` appears as a dominant visual region or object.
- Asset planning is proportional to the deck topic and length: technical, research, product, and analytical decks should include meaningful planned visuals where they clarify the story, and each planned asset has a visible fallback if no real asset was used.
- `text_density` is reflected in the amount of visible text.
- Pages are not crowded, and any planned `timeline`, `comparison`, or `architecture-diagram` page uses its matching visual structure.
- The actual backgrounds match `visual_system.background_strategy`; any dark, image-led, or emphasis page has an intentional relationship to the rest of the deck.
- Text boxes respect `typography_constraints`; long labels, captions, footer text, and conclusion bars are not squeezed into boxes that are too short for the intended line count.
- If real assets are used, the final XML contains renderable asset tokens or supported local placeholders for creation, not http URLs, stale local paths, or blank image boxes.

View File

@@ -0,0 +1,64 @@
# Slides Template Workflow
当用户提到"模板""套用模板""参考某种主题/风格/版式",或需求明显落在已有场景模板内(如工作汇报、产品介绍、商业计划书、培训、晋升汇报等),使用本文。
## 核心规则
- 必须先用 `scripts/template_tool.py search` 做模板检索,默认给出 2-3 个最匹配模板候选供用户选择。
- 锁定模板后用 `summarize` 获取主题和布局摘要。
- 只有需要具体布局骨架时才用 `extract` 裁切目标页型 XML。
- 不要直接读取完整模板 XML。
- 不要照搬模板占位文案、示例公司名、示例日期或与用户主题无关的原模板内容。
`scripts/template_tool.py` 需要 Python 3。`references/template-index.json` 是脚本缓存/轻量路由索引,不是默认给 agent 阅读的文档;`assets/templates/*.xml` 是机器资源,只应通过脚本摘要或裁切,不要全文读取。
模板细则见 [template-catalog.md](template-catalog.md)。主流程只记住:先 `search`,锁定后 `summarize`,需要骨架时才 `extract`
```bash
python3 skills/lark-slides/scripts/template_tool.py search --query "<用户需求原文>" --limit 3
python3 skills/lark-slides/scripts/template_tool.py summarize --template <template-id> --label <封面|目录|分节|内容|结尾>
python3 skills/lark-slides/scripts/template_tool.py extract --template <template-id> --label <页型> --out /tmp/template-slice.xml
```
## 生成流程
```text
Step 1: 需求澄清 & 读取知识
- 澄清主题、受众、页数、风格
- 读取 xml-schema-quick-ref.md新建 / 大幅改写时还要读取 design-rules.md
- 按本文检索模板并给出候选
Step 2: 生成大纲 -> 用户确认
- 生成结构化大纲供用户确认;如使用模板,标明基于哪个模板改写
- 新建 / 大幅改写必须先明确 deck 目标、受众、页序、视觉系统和每页关键消息
- 模板只提供风格和局部布局骨架,不要照搬无关占位内容
Step 3: 按已确认大纲生成 XML -> 创建
- 逐页生成 XMLkey_message 定主结论layout_type 定几何visual_focus 定主视觉text_density 定文本量
- 缺少真实素材时必须用 `fallback_if_missing` 生成 XML-native 兜底视觉;不要留空
- 创建方式按 SKILL.md 的"创建方式选择"判断;图片、复杂 XML、转义和 3350001 排查按 lark-slides-create.md、media-upload.md、troubleshooting.md 执行
Step 4: 审查 & 交付
- 创建完成后,必须用 xml_presentations.get 读取全文 XML并按 validation-checklist.md 做显式验证记录,包括 XML 文本重叠检查
- 失败或部分成功按 troubleshooting.md 处理;局部问题优先用 `+replace-slide` 修正
- 没问题 -> 交付:告知用户演示文稿 ID 和访问方式
```
## 大纲格式
生成大纲时使用以下格式,交给用户确认:
```text
[PPT 标题] - [定位描述],面向 [目标受众]
模板:[未使用模板 / <category>/<template>.xml推荐原因]
页面结构N 页):
1. 封面页:[标题文案]
2. [页面主题][要点1]、[要点2]、[要点3]
3. [页面主题][要点描述]
...
N. 结尾页:[结尾文案]
风格:[配色方案][排版风格]
```

View File

@@ -1,6 +1,6 @@
# Validation Checklist
创建或大幅改写演示文稿后必须做一次显式验证。目标是发现空白页、XML 损坏、内容截断、明显溢出、弱视觉层级和未验证输出。
创建或大幅改写演示文稿后,必须做一次显式验证如果只创建空白ppt则不用验证。目标是发现空白页、XML 损坏、内容截断、明显溢出、弱视觉层级和未验证输出。
小型已有页编辑也要做对应范围的验证:至少读取被改页面或全文 XML确认目标元素已更新且未破坏周边结构。
@@ -46,7 +46,7 @@ python3 skills/lark-slides/scripts/xml_text_overlap_lint.py --input <presentatio
## Page Count And Structure
- 实际页数必须等于用户要求或 `slide_plan.json` 的页数。
- 实际页数必须等于用户要求或已确认大纲的页数。
- 如果创建过程部分失败,先记录已创建的 `xml_presentation_id`,再回读确认哪些页已写入。
- 每页都应包含 `<data>`,且 `<data>` 内至少有一个非背景主体元素。
- 封面、章节页、总结页可以文字较少,但不能只有空背景。
@@ -54,7 +54,7 @@ python3 skills/lark-slides/scripts/xml_text_overlap_lint.py --input <presentatio
## Expected Elements
`slide_plan.json` 和用户要求逐页核对:
已确认大纲和用户要求逐页核对:
- 标题或主结论存在,并能对应 `key_message`
- `layout_type` 对应的主要结构已生成。

View File

@@ -1,254 +0,0 @@
# Visual Planning
新建演示文稿或大幅改写页面时,在 `slide_plan.json` 完成后、生成 XML 前读取本文件。目标是让 `layout_type``visual_focus``text_density` 变成实际页面几何,而不是只写在 plan 里。
默认画布按 `960 x 540` 规划。已有页面回读 XML 可以影响具体坐标,但不能覆盖这些原则:页面要有主视觉区域、文本要受密度约束、不同 `layout_type` 必须产生明显不同的坐标结构。
## Core Rules
- `layout_type` must change geometry: element positions, region sizes, alignment, and visual rhythm must differ across page types.
- `visual_focus` determines the largest or highest-contrast region. It can be an image, diagram, metric, quote, table, or shape-based placeholder.
- `text_density` caps visible text:
- `low`: title plus one short statement, or 1-3 labels.
- `medium`: title plus 2-4 concise bullets or labeled regions.
- `high`: use a table, columns, grouped labels, or annotations. Do not use one long bullet box.
- Do not create a deck where every content page is title plus bullets. For 4 or more pages, use at least 4 different layout structures when the content allows.
- Keep generous margins. Use `60-80` px outer margins on standard content pages unless a full-bleed image or cover treatment is intentional.
- Reserve vertical space for titles. A typical content title area is `y=36..90`; main content should usually start at `y>=110`.
- Avoid crowding the bottom edge. Keep non-background content above `y=500` unless it is a footer.
- Prefer fewer, larger objects over many small text boxes.
- Keep backgrounds consistent with the deck's `visual_system.background_strategy`. Normal content pages should use the same base background unless there is a clear page-role reason to change.
- Treat text fit as a layout constraint, not a cleanup step. If a text box is too small for the intended line count, shorten the text, split it, or allocate more space before creating XML.
## Background And Motif Consistency
Decks can vary page backgrounds, but variation must be intentional and legible:
- Pick one default background for ordinary content pages and reuse it exactly. Avoid near-identical drift such as several slightly different off-white values unless it encodes a clear section change.
- Cover, section divider, emphasis, and conclusion pages may use a dark, image-led, or high-contrast background. They must still share the deck's primary color, motif, edge treatment, typography, or geometry.
- If a cover uses a split composition, make the split visible in the background or layout. For example, reserve a darker text region and a related but distinct visual region instead of placing all elements on one flat field.
- Reuse a small number of visual devices: side bar, card radius, node style, line weight, icon container, or footer treatment. Do not introduce a new decorative language on each page.
- Insert background and motif shapes before content elements so they do not cover text, images, or diagrams.
## Text Fit Guardrails
Use these as conservative minimums on a 960 x 540 canvas. Increase height when using bold text, Chinese text, mixed Chinese/English, or line spacing above default.
| Text use | Typical font size | Minimum height |
|----------|-------------------|----------------|
| Caption, 1 line | 10-12 | 18 |
| Caption, 2 lines | 10-12 | 30 |
| Body, 1 line | 13-16 | 24 |
| Body, 2 lines | 13-16 | 40 |
| Body, 2 lines, bold | 15-18 | 48 |
| Headline, 1 line | 24-32 | 42 |
| Title, 2 lines | 34-44 | 110 |
Additional rules:
- Do not put long Chinese sentences or long English phrases into `height=18` or `height=22` boxes. Those heights are for short labels only.
- Footer/source text should usually be one short line. If it needs more, make it a real caption block above the footer area.
- Bottom conclusion bars should be at least `40` px tall for one emphasized line and at least `54` px tall for two lines.
- Diagram labels should be short enough to fit the shape. Prefer two short lines over one cramped long line.
- When a text block has more than one `<p>`, size the box for multiple lines explicitly. Do not assume the renderer will auto-expand.
- If a line contains mixed Chinese and English, budget more width than either language alone; mixed text wraps less predictably.
## Layout Types
### `title-cover`
Purpose: introduce the deck's point of view.
Geometry:
- Use one dominant title block, usually `x=70..120`, `y=150..250`, `width=700..820`.
- Add one subtitle or context line, not a bullet list.
- Optional visual focus can be a full-bleed background, large side image, accent band, or abstract shape motif.
- If the cover has a right-side diagram, screenshot, or motif cluster, use a split layout: keep the title/subtitle region within the left or central text region, and reserve a separate visual region so labels and connectors do not cross the title.
- For split covers, make the background reinforce the composition, such as a darker text side and a related visual panel. Avoid one flat field where title and diagram compete for attention.
- Keep source metadata to one short line where possible. If it wraps, shorten author lists or move details to notes.
- The main title should be controlled, normally one or two lines. Do not let it occupy both the text region and the visual region.
Text:
- `low` only unless the user explicitly asks for detail.
### `section-divider`
Purpose: reset rhythm and mark a new chapter.
Geometry:
- Use a large section number, chapter label, or single centered claim.
- Keep the page sparse. A divider is not a content page.
- Visual focus can be one oversized number, a vertical accent bar, or a full-width band.
Text:
- Title plus one phrase. No bullets.
### `two-column`
Purpose: compare two related ideas or pair explanation with evidence.
Geometry:
- Split main region into two balanced columns, for example left `x=60,width=400`, right `x=500,width=400`.
- Each column needs its own heading or visual anchor.
- Do not place one full-width bullet box under a normal title; that is not a two-column layout.
Text:
- `medium`: 2-3 short items per column.
- `high`: use grouped rows or mini table structure inside columns.
### `image-left-text-right`
Purpose: let a visual establish context, with text explaining implication.
Geometry:
- Left visual region should occupy roughly `35-45%` of slide width, often full height or tall crop.
- Right text region starts around `x=420` and should have a strong headline plus short support.
- If no real image is available, create a shape-based placeholder visual that matches `asset_need`.
- For dense screenshots, paper figures, or product captures with small labels, allocate a larger visual region when possible: often `50-65%` of slide width or at least `320` px height.
- Place screenshots in a deliberate frame or panel, and leave enough margin so axes, captions, and edge labels are not cropped by the slide boundary.
Text:
- Keep right-side text short. Avoid more than 4 bullets.
- For screenshot explanation pages, prefer 2-3 interpretation cards or callouts instead of a paragraph block.
### `image-right-text-left`
Purpose: lead with a message, then reinforce it with a visual.
Geometry:
- Left text region starts around `x=60..90`, width `400..460`.
- Right visual region occupies roughly `35-45%` of slide width.
- Align the image or placeholder with the main text block, not only with the title.
- For dense screenshots, paper figures, or product captures with small labels, increase the visual region and reduce text. A readable image is more valuable than a fully populated text column.
Text:
- Use one main claim and 2-3 supporting points.
- Keep callouts parallel and short. If a callout needs more than two lines, split it into a separate note or a new slide.
### `big-number`
Purpose: make one metric or fact memorable.
Geometry:
- Reserve the largest object for the metric: font size often `64-110`, region at least `300 x 120`.
- Pair the number with one explanation and optional 2-3 small supporting labels.
- Do not bury the number in a bullet list or small card.
Text:
- `low` or `medium`. If detail is needed, add small annotations around the metric.
- Supporting labels must not compete with the number. Use compact labels, legends, or mini-cards rather than long explanatory bars.
### `timeline`
Purpose: show sequence, roadmap, history, or phases.
Geometry:
- Create a horizontal or vertical spine with 3-6 milestones.
- Each milestone should have a dot/card/date label connected by a line or arrow.
- Title is separate from the sequence. The sequence is the visual focus.
Text:
- Each milestone gets a short label and optional one-line explanation.
- Do not use paragraph-length milestone descriptions.
### `comparison`
Purpose: make a choice, before/after, old/new, or option tradeoff clear.
Geometry:
- Use two or three distinct panels, columns, or a table-like structure.
- Headings must be visually aligned so differences are easy to scan.
- Use color, border, icon, or label treatment to highlight the preferred option or key difference.
Text:
- Use parallel wording across columns.
- Avoid uneven long bullet lists that destroy comparability.
### `architecture-diagram`
Purpose: explain components, dependencies, or system flow.
Implementation: prefer `<whiteboard>` (see `lark-slides-whiteboard.md`); use `<shape>` + `<line>` only as fallback.
Geometry:
- Main visual area should be a diagram, not prose.
- Use grouped boxes, lanes, arrows or lines, and short labels.
- Keep diagram labels concise. Put explanation in notes or a small side caption if needed.
Text:
- Prefer labels of 1-5 words.
- Use no more than one short explanatory text block.
- If a node label needs two lines, size the node and the text box for two lines. Do not let labels overlap connectors.
### `process-flow`
Purpose: show operational steps, workflow, or cause-effect path.
Implementation: prefer `<whiteboard>` (see `lark-slides-whiteboard.md`); use `<shape>` + `<line>` only as fallback.
Geometry:
- Use numbered steps connected by arrows or lines.
- 3-5 steps is ideal for one slide. If there are more, group them into phases.
- The flow direction must be visually obvious.
Text:
- Each step gets a verb-led label and one short descriptor at most.
- Step labels should be parallel in length and grammar. If one step needs a long explanation, move the explanation to a side note or speaker notes.
### `quote-highlight`
Purpose: emphasize a customer voice, principle, thesis, or decision statement.
Geometry:
- Quote or claim is the dominant text object.
- Use large type, generous whitespace, and optional attribution or context badge.
- Do not combine a quote-highlight page with a normal bullet section.
Text:
- One quote or statement, plus optional attribution. No bullets.
### `conclusion`
Purpose: close with decision, recommendation, or next action.
Geometry:
- Use one dominant closing statement or call to action.
- Add up to 3 next-step cards, checklist items, or owner/date labels.
- Visual focus should be the recommendation or action, not decorative filler.
Text:
- Keep the final page easy to remember. Avoid recap overload.
- Conclusion pages may mirror the cover background, but must clearly reuse the deck's motif or color roles so the ending feels intentional.
## Screenshot And Paper Figure Pages
When a page uses a real screenshot, chart, paper figure, or product capture:
- Choose screenshot placement based on page role, not a fixed slide number. Method overview, evidence, comparison, and failure-analysis pages are common candidates; title, agenda, and conclusion pages usually are not.
- Use the real asset only when it is readable at slide size. If the figure is too dense, crop to the relevant region, create a zoomed detail, or redraw the core message with native shapes.
- A screenshot should normally be the visual focus. Do not shrink it into a decorative thumbnail while surrounding it with dense text.
- Pair the image with a small number of interpretive annotations that tell the audience what to notice.
- Always include a short source caption when using external or paper-derived visuals.
- Verify the final XML contains a supported image token or creation-time local placeholder, not an unsupported external URL.
## Plan To XML Checklist
Before creating XML for each page, answer these checks:
1. Which region is the visual focus, and is it the largest or most prominent object?
2. Does the XML geometry match the `layout_type` description above?
3. Does `text_density` limit the number of paragraphs, bullets, labels, and text boxes?
4. Would this page still be recognizable if the `layout_type` label were removed from the plan?
5. Across the deck, do multiple pages use genuinely different structures?
6. Does the background follow the planned deck strategy, and are any deviations intentional?
7. Are all text boxes large enough for their intended font size and line count?
8. If the page uses a screenshot or paper figure, is it large enough to read and accompanied by concise interpretation?
After fetching the created presentation, verify:
- Use `timeline`, `comparison`, and `architecture-diagram` only when the content calls for them; do not force irrelevant page types.
- Any planned `timeline`, `comparison`, or `architecture-diagram` page uses the matching sequence, side-by-side comparison, or component-and-connection structure.
- Pages are not crowded and do not rely on long bullet boxes.
- Main claim, supporting detail, and visual focus have clear hierarchy.
- Static XML inspection should include text-fit risk: very short text boxes containing long text, multi-paragraph boxes with insufficient height, footer text that may wrap, and labels placed directly over connectors.
- Background and motif consistency should be checked across pages, not only within one slide.

View File

@@ -1,369 +0,0 @@
# XML 格式指南
本文档基于 [slides_xml_schema_definition.xml](slides_xml_schema_definition.xml) 整理,说明飞书 Slides XML SchemaSML 2.0)的核心结构和常用写法。
## 基本结构
```xml
<?xml version="1.0" encoding="UTF-8"?>
<presentation xmlns="http://www.larkoffice.com/sml/2.0" width="960" height="540">
<title>演示文稿标题</title>
<slide>
<style>
<fill>
<fillColor color="rgb(245, 245, 245)"/>
</fill>
</style>
<data>
<shape type="text" topLeftX="80" topLeftY="80" width="800" height="120">
<content textType="title">
<p>主标题</p>
</content>
</shape>
</data>
<note>
<content textType="body">
<p>这是演讲者备注。</p>
</content>
</note>
</slide>
</presentation>
```
## 根元素
### `<presentation>`
协议标准写法应带命名空间 `http://www.larkoffice.com/sml/2.0`;当前服务端实现可能兼容不带 `xmlns` 的输入,但不作为协议保证。
**属性:**
| 属性 | 类型 | 必需 | 说明 |
|------|------|------|------|
| `width` | positiveInteger | 是 | 演示文稿宽度,如 `960` |
| `height` | positiveInteger | 是 | 演示文稿高度,如 `540` |
| `id` | string | 否 | 演示文稿标识 |
**子元素:**
| 元素 | 必需 | 说明 |
|------|------|------|
| `<title>` | 否 | 演示文稿标题 |
| `<theme>` | 否 | 全局主题 |
| `<slide>` | 是 | 幻灯片页面,至少 1 页,最多 100 页 |
## 主题
### `<theme>`
`<theme>` 当前包含两部分:
- `<background>`:演示文稿级背景填充
- `<textStyles>`:主题文本样式集合
`<textStyles>` 下可选子元素:
- `<title>`
- `<headline>`
- `<sub-headline>`
- `<body>`
- `<caption>`
这些元素定义的是主题默认样式,不是页面结构。常用属性:
| 属性 | 说明 |
|------|------|
| `fontFamily` | 字体 |
| `fontSize` | 字号 |
| `fontColor` | 字体颜色 |
## 幻灯片元素
### `<slide>`
单张幻灯片的结构比较严格。
**属性:**
| 属性 | 类型 | 必需 | 说明 |
|------|------|------|------|
| `id` | string | 否 | 幻灯片标识 |
**直接子元素只有:**
| 元素 | 必需 | 说明 |
|------|------|------|
| `<style>` | 否 | 页面样式 |
| `<data>` | 否 | 页面元素容器 |
| `<note>` | 否 | 演讲者备注 |
这意味着 `<title>``<headline>``<body>``<caption>` 不能直接放在 `<slide>` 下。
## 文本内容模型
### `<content>`
实际页面文本通常通过 `<content>` 表达,常见位置有:
- `shape` 内部
- `table/td` 内部
- `note` 内部
**常用属性:**
| 属性 | 说明 |
|------|------|
| `textType` | `title` / `headline` / `sub-headline` / `body` / `caption` |
| `verticalAlign` | 垂直对齐 |
| `textAlign` | 水平对齐 |
| `lineSpacing` | 行间距 |
| `fontSize` | 字号 |
| `fontFamily` | 字体 |
| `color` | 字体颜色 |
| `bold` / `italic` / `underline` / `strikethrough` | 内容级样式 |
| `wrap` | 是否自动换行 |
**可包含的子元素:**
- `<p>`
- `<ul>`
- `<ol>`
### `<p>`
`<p>` 是段落元素,可混排纯文本和内联标签:
- `<br/>`
- `<strong>`
- `<em>`
- `<u>`
- `<span>`
- `<del>`
- `<a>`
- `<shadow>`
- `<outline>`
示例:
```xml
<content textType="body" textAlign="left">
<p>普通文本 <strong>加粗</strong> <em>斜体</em> <a href="https://example.com">链接</a></p>
<ul>
<li><p>列表项 1</p></li>
<li><p>列表项 2</p></li>
</ul>
</content>
```
## 常用页面元素
所有页面元素都放在 `<data>` 中。
### `<shape>`
`shape` 可表示普通形状,也可表示文本框。文本框推荐使用 `type="text"`
```xml
<shape type="text" topLeftX="80" topLeftY="80" width="800" height="120">
<content textType="title">
<p>主标题</p>
</content>
</shape>
```
```xml
<shape type="rect" topLeftX="700" topLeftY="120" width="180" height="120">
<fill>
<fillColor color="rgba(100, 149, 237, 0.25)"/>
</fill>
<border color="rgb(100, 149, 237)" width="2"/>
</shape>
```
**属性:**
| 属性 | 必需 | 说明 |
|------|------|------|
| `type` | 是 | 形状类型,`text` 表示文本框 |
| `topLeftX` | 是 | 左上角 X 坐标 |
| `topLeftY` | 是 | 左上角 Y 坐标 |
| `width` | 是 | 宽度 |
| `height` | 是 | 高度 |
| `rotation` | 否 | 旋转角度 |
| `flipX` / `flipY` | 否 | 翻转 |
| `alpha` | 否 | 透明度 |
**可选子元素:**
- `<fill>`
- `<border>`
- `<reflection>`
- `<shadow>`
- `<content>`
### `<line>`
```xml
<line startX="100" startY="200" endX="420" endY="200">
<border color="rgb(43, 47, 54)" width="2"/>
</line>
```
`line` 使用的是 `startX` / `startY` / `endX` / `endY`,不是 `x1` / `y1` / `x2` / `y2`
### `<img>`
```xml
<img src="file_token_or_url" topLeftX="100" topLeftY="220" width="320" height="180"/>
```
`img` 使用 `topLeftX` / `topLeftY`,不是 `x` / `y`
`src` 只接受两种值:
| `src` 形式 | 说明 |
|---|---|
| `file_token`(如 `boxcnXXXXXXXXXXXXXXXXXXXXXX` | 通过 `slides +media-upload` 上传后返回的 token |
| `@<本地路径>`(如 `@./assets/chart.png` | **仅在 `slides +create --slides` 中可用**CLI 会自动上传该文件并替换为 file_token |
> **禁止使用 http(s) 外链 URL**:飞书 slides 渲染端不会代理外链图片,`src="https://..."` 在 PPT 里通常显示破图。要用网图必须先 `curl`/下载到 CWD 内,再走上传流程拿 `file_token`。
本地图片的两种姿势:
- **新建带图 PPT**`+create --slides` 里直接写 `src="@./pic.png"`CLI 在创空白 PPT 后、加 slides 前自动上传并替换 token
- **给已有 PPT 加带图新页**:先 `slides +media-upload --file ./pic.png --presentation $PID` 拿 token再用 token 写进 `xml_presentation.slide create` 的 XML
### `<icon>`
```xml
<icon iconType="iconpark/Base/setting.svg" topLeftX="440" topLeftY="220" width="32" height="32"/>
```
### `<table>`
表格结构为:
- `<table>`
- `<colgroup>` / `<tr>`
- `<tr>` 内为 `<td>`
- `<td>` 内可放 `<content>`
### `<chart>`
图表元素必须至少包含:
- `<chartPlotArea>`
- `<chartData>`
同时还可以包含:
- `<chartTitle>`
- `<chartSubTitle>`
- `<chartStyle>`
- `<chartLegend>`
- `<chartTooltip>`
如果要写图表 XML建议直接以 XSD 为准,不要自行发明更简化的 chart DSL。
## 样式元素
### `<fill>`
```xml
<fill>
<fillColor color="rgb(100, 149, 237)"/>
</fill>
```
### `<border>`
```xml
<border color="rgb(0, 0, 0)" width="2" dashArray="solid"/>
```
### 颜色格式
```xml
<fillColor color="rgb(255, 0, 0)"/>
<fillColor color="rgba(255, 0, 0, 0.5)"/>
<fillColor color="linear-gradient(90deg, rgb(255,0,0) 0%, rgb(0,0,255) 100%)"/>
<fillColor color="radial-gradient(circle at 50% 50%, rgb(255,0,0) 0%, rgb(0,0,255) 100%)"/>
```
## 演讲者备注
### `<note>`
```xml
<note>
<content textType="body">
<p>这是演讲者备注内容。</p>
</content>
</note>
```
## 完整示例
```xml
<?xml version="1.0" encoding="UTF-8"?>
<presentation xmlns="http://www.larkoffice.com/sml/2.0" width="960" height="540">
<title>季度报告</title>
<theme>
<textStyles>
<title fontFamily="思源黑体" fontSize="54" fontColor="rgba(0, 0, 0, 1)"/>
<body fontFamily="思源黑体" fontSize="18" fontColor="rgba(43, 47, 54, 1)"/>
</textStyles>
</theme>
<slide>
<style>
<fill>
<fillColor color="rgb(245, 245, 245)"/>
</fill>
</style>
<data>
<shape type="text" topLeftX="80" topLeftY="72" width="760" height="100">
<content textType="title">
<p>2024 年第一季度报告</p>
</content>
</shape>
<shape type="text" topLeftX="80" topLeftY="200" width="520" height="180">
<content textType="body">
<p>核心指标</p>
<ul>
<li><p>用户增长:+25%</p></li>
<li><p>收入增长:+30%</p></li>
<li><p>市场份额15%</p></li>
</ul>
</content>
</shape>
<shape type="rect" topLeftX="660" topLeftY="180" width="180" height="140">
<fill>
<fillColor color="rgba(100, 149, 237, 0.25)"/>
</fill>
<border color="rgb(100, 149, 237)" width="2"/>
</shape>
</data>
<note>
<content textType="body">
<p>讲到增长率时补充样本范围。</p>
</content>
</note>
</slide>
</presentation>
```
## 最佳实践
1. 始终带上命名空间 `xmlns="http://www.larkoffice.com/sml/2.0"`
2.`shape type="text"` + `content` 表达页面文本
3.`topLeftX` / `topLeftY``startX` / `startY` 等 schema 中定义的属性名
4. 优先使用 `rgb` / `rgba` 颜色格式
5. 特殊字符按 XML 规则转义
6. 标准 16:9 页面建议使用 `width="960"``height="540"`
## 参考文档
- [xml-schema-quick-ref.md](xml-schema-quick-ref.md)
- [slides_xml_schema_definition.xml](slides_xml_schema_definition.xml)
- [examples.md](examples.md)
- [slides_demo.xml](slides_demo.xml)

View File

@@ -8,6 +8,8 @@
2. `<presentation>` 直接子元素只有 `<title>``<theme>``<slide>`
3. `<slide>` 直接子元素只有 `<style>``<data>``<note>`
4. 页面中的文本通常通过 `<content>` 表达,而不是把 `<title>``<body>` 直接挂在 `<slide>`
5. 文本中的特殊字符必须按 XML 规则转义,例如 `&` 写成 `&amp;``<` / `>` 写成 `&lt;` / `&gt;`
6. 标准 16:9 页面建议使用 `width="960"``height="540"`
## 最小可用示例
@@ -36,6 +38,8 @@
**子元素:** `<title>?`, `<theme>?`, `<slide>+`
`<slide>` 至少 1 页,最多 100 页。
## slide 元素
| 属性 | 必需 | 说明 |
@@ -54,6 +58,19 @@ XSD 中的 `title`、`headline`、`sub-headline`、`body`、`caption` 主要出
- `<theme><textStyles>...</textStyles></theme>` 中,作为主题文本样式
- `<content textType="...">` 中,作为内容的文本类型
`<theme>` 当前可包含:
- `<background>` - 演示文稿级背景填充
- `<textStyles>` - 主题文本样式集合
主题文本样式常用属性:
| 属性 | 说明 |
|------|------|
| `fontFamily` | 字体 |
| `fontSize` | 字号 |
| `fontColor` | 字体颜色 |
`textStyles` 的 schema 默认值如下:
| textType | 默认字号 |
@@ -71,12 +88,14 @@ XSD 中的 `title`、`headline`、`sub-headline`、`body`、`caption` 主要出
| 属性 | 说明 |
|------|------|
| `textType` | `title` / `headline` / `sub-headline` / `body` / `caption` |
| `verticalAlign` | 垂直对齐方式 |
| `textAlign` | 文本对齐方式 |
| `lineSpacing` | 行间距schema 默认 `multiple:1.5` |
| `fontSize` | 字号 |
| `fontFamily` | 字体 |
| `color` | 字体颜色 |
| `bold` / `italic` / `underline` / `strikethrough` | 文本样式 |
| `wrap` | 是否自动换行 |
`<content>` 的子元素只能是:
@@ -84,6 +103,8 @@ XSD 中的 `title`、`headline`、`sub-headline`、`body`、`caption` 主要出
- `<ul>`
- `<ol>`
`<p>` 可混排纯文本和内联标签:`<br/>``<strong>``<em>``<u>``<span>``<del>``<a>``<shadow>``<outline>`
### content 示例
```xml
@@ -117,6 +138,10 @@ XSD 中的 `title`、`headline`、`sub-headline`、`body`、`caption` 主要出
| `width` | 是 | 宽度 |
| `height` | 是 | 高度 |
| `rotation` | 否 | 旋转角度 |
| `flipX` / `flipY` | 否 | 翻转 |
| `alpha` | 否 | 透明度 |
可选子元素:`<fill>``<border>``<reflection>``<shadow>``<content>`
### line
@@ -126,12 +151,16 @@ XSD 中的 `title`、`headline`、`sub-headline`、`body`、`caption` 主要出
</line>
```
`line` 使用 `startX` / `startY` / `endX` / `endY`,不是 `x1` / `y1` / `x2` / `y2`
### img
```xml
<img src="file_token_or_url" topLeftX="80" topLeftY="120" width="320" height="180"/>
```
`img` 使用 `topLeftX` / `topLeftY`,不是 `x` / `y`
`src` 只支持:`slides +media-upload` 返回的 `file_token`,或 `@<本地路径>` 占位符(仅 `+create --slides` 自动上传并替换)。**禁止使用 http(s) 外链 URL**——飞书 slides 渲染端不会代理外链图,外链 src 在 PPT 里通常不显示。本地图片详见 [lark-slides-create.md](lark-slides-create.md#本地图片path-占位符) / [lark-slides-media-upload.md](lark-slides-media-upload.md)。
> **注意**`width`/`height` 是**裁剪后**的显示尺寸。比例和原图不一致时会自动裁剪(无法靠属性关闭),想避免裁剪就让 `width:height` 对齐原图比例。
@@ -144,6 +173,14 @@ XSD 中的 `title`、`headline`、`sub-headline`、`body`、`caption` 主要出
`iconType` 必须来自已验证的 IconPark 路径。需要语义图标时,先运行 `scripts/iconpark_tool.py search --query "<语义>"`,不要凭记忆拼路径。更多规则见 [iconpark.md](iconpark.md)。
### table
表格结构为 `<table>`,内部可包含 `<colgroup>` / `<tr>``<tr>` 内为 `<td>``<td>` 内可放 `<content>`
### chart
图表元素必须至少包含 `<chartPlotArea>``<chartData>`;还可包含 `<chartTitle>``<chartSubTitle>``<chartStyle>``<chartLegend>``<chartTooltip>`。复杂 chart XML 以 XSD 为准,不要自行发明简化 DSL。
### whiteboard
```xml
@@ -231,13 +268,6 @@ Mermaid 模式:内容用 `<![CDATA[...]]>` 包裹,避免 `[`、`>`、`-->`
</note>
```
## 详细参考
- [slides_xml_schema_definition.xml](slides_xml_schema_definition.xml)
- [xml-format-guide.md](xml-format-guide.md)
- [examples.md](examples.md)
- [slides_demo.xml](slides_demo.xml)
## Schema 版本信息
- **版本**: 2.0.0