Skip to content

Commit 65aff94

Browse files
committed
feat(slides): improve slide planning and validation guidance
refactor(slides): rename slide layout lint scope Change-Id: I1b0e42b6508ec2c5f6ae6dc0d1b7ac23c5bbe2e3 feat(slides): improve lark slides skill guidance Change-Id: I49563da4ca623a89f5391f36ceb8f5a31417e321 feat(slides): strengthen lark slides planning guidance Change-Id: If49330e1f9b779bc76a919565ed61a31c255f508 feat(slides): remove lark slides layout lint rules Change-Id: I64f1fc3b33d05c069c9ef58e61d00aa57ac18ecd refactor(slides): streamline skill guidance Change-Id: I3b39faaab7dcac52fac1572590fc5d8934428da5 feat(slides): add slides asset planning guidance Change-Id: I37303043f7704e4ba484552158390a4e24bf9c42 feat(slides): add visual planning guidance Change-Id: Idee7c392d41ff02124313d572c547d0a086d9c35 feat(slides): add lark slides planning layer Change-Id: I3f0765aa53656070d9ba9b388dade19355e7bc6f
1 parent b612dde commit 65aff94

10 files changed

Lines changed: 1065 additions & 434 deletions

skills/lark-slides/SKILL.md

Lines changed: 101 additions & 330 deletions
Large diffs are not rendered by default.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Asset Planning
2+
3+
新建演示文稿或大幅改写页面时,在写入 `slide_plan.json` 前后都可以参考本文件。目标是让 agent 主动识别有价值的图、图标、图表、截图或示意图需求,同时保持 deck 在没有真实素材时也能完整执行。
4+
5+
本文件只定义轻量资产规划。不要把它理解成素材采集流程。
6+
7+
## Core Rules
8+
9+
- `asset_need` is metadata only. It can guide page design, but it must not require web search, local download, media upload, or external tools.
10+
- Every planned asset must include a fallback visual plan so the slide can be generated with XML shapes, text, arrows, tables, simple charts, or placeholder regions.
11+
- Asset needs must serve the page's `key_message` and `visual_focus`. Do not add decorative assets that do not clarify the page.
12+
- 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.
13+
- 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.
14+
- Do not leave blank image boxes in final XML. If the asset is missing, render the fallback visual.
15+
16+
## JSON Shape
17+
18+
Use an object for one planned asset, or an array when a page genuinely needs multiple assets. Keep each item compact.
19+
20+
```json
21+
{
22+
"asset_type": "architecture_diagram",
23+
"purpose": "Show how API gateway, planner, XML generator, and Slides API interact.",
24+
"suggested_query": "agent native slides runtime architecture diagram",
25+
"fallback_if_missing": "Draw grouped boxes and arrows with XML shapes; use labels instead of an image."
26+
}
27+
```
28+
29+
For a page without a meaningful asset need, use:
30+
31+
```json
32+
{
33+
"asset_type": "none",
34+
"purpose": "No external or simulated asset needed; the page is text-led.",
35+
"suggested_query": "",
36+
"fallback_if_missing": "Use typography, spacing, and simple accent shapes only."
37+
}
38+
```
39+
40+
## Supported Asset Types
41+
42+
- `paper_figure`: figure from a paper or technical article.
43+
- `architecture_diagram`: system components, data flow, dependency map, or model structure.
44+
- `icon`: small semantic symbol for a concept, step, role, or status.
45+
- `logo`: brand, product, team, or customer mark.
46+
- `chart`: line, bar, pie, funnel, scatter, or chart-like data visual.
47+
- `infographic`: composed visual explanation, usually combining labels, numbers, and simple shapes.
48+
- `screenshot`: product UI, terminal output, workflow state, or page capture.
49+
- `flow_diagram`: process, sequence, decision tree, or mechanism diagram.
50+
- `none`: explicitly no asset needed.
51+
52+
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`.
53+
54+
## Planning Guidance
55+
56+
Match asset type to slide role:
57+
58+
- `architecture-diagram` layout usually pairs with `architecture_diagram` or `flow_diagram`.
59+
- `process-flow` layout usually pairs with `flow_diagram`, `icon`, or `infographic`.
60+
- `comparison` layout often works with `icon`, `chart`, or `infographic`.
61+
- `timeline` layout often works with `icon`, `chart`, or shape-based milestone markers.
62+
- `big-number` layout often works with `chart` or `infographic`, but only if it supports the metric.
63+
- `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.
64+
65+
`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.
66+
67+
`fallback_if_missing` must be concrete enough to turn into XML, for example:
68+
69+
- "Draw a simplified attention matrix with 5 token labels, semi-transparent cells, and arrows to output token."
70+
- "Use three grouped boxes with arrows from client to gateway to service; add small protocol labels."
71+
- "Render a mini bar chart with 4 bars using shapes and value labels."
72+
- "Use a bordered placeholder panel with product area labels, not an empty image."
73+
74+
Weak fallbacks to avoid:
75+
76+
- "Use a placeholder."
77+
- "Find another image."
78+
- "Leave blank if unavailable."
79+
- "Use generic decoration."
80+
81+
## Examples
82+
83+
Transformer Self-Attention page:
84+
85+
```json
86+
{
87+
"asset_type": "paper_figure",
88+
"purpose": "Explain token-to-token attention and why each output token mixes context.",
89+
"suggested_query": "Transformer self attention attention matrix diagram",
90+
"fallback_if_missing": "Draw a simplified attention matrix with token labels, colored weights, and arrows from input tokens to one highlighted output token."
91+
}
92+
```
93+
94+
System architecture page:
95+
96+
```json
97+
{
98+
"asset_type": "architecture_diagram",
99+
"purpose": "Show the runtime path from user prompt to plan, XML generation, Slides API creation, and fetch verification.",
100+
"suggested_query": "slides generation runtime architecture planner XML API verification",
101+
"fallback_if_missing": "Draw four grouped boxes connected left-to-right with arrows; put verification as a return arrow from Slides API to agent."
102+
}
103+
```
104+
105+
Business comparison page:
106+
107+
```json
108+
{
109+
"asset_type": "infographic",
110+
"purpose": "Make before/after differences scannable without dense bullet lists.",
111+
"suggested_query": "before after product workflow comparison infographic",
112+
"fallback_if_missing": "Use two side-by-side panels with matching icon circles and three parallel rows of concise labels."
113+
}
114+
```
115+
116+
## Plan To XML Contract
117+
118+
When generating XML:
119+
120+
1. If an asset exists and the workflow supports it, place it in the planned visual region.
121+
2. If no asset exists, immediately render `fallback_if_missing` with XML-native shapes, text, lines, arrows, tables, or chart-like elements.
122+
3. Size the fallback to satisfy `visual_focus`; it should be a real page element, not a tiny decoration.
123+
4. Keep text-density limits. Do not compensate for missing assets by adding long bullet text.
124+
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.

skills/lark-slides/references/lark-slides-xml-presentation-slide-create.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ lark-cli slides xml_presentation.slide create --as user \
178178
| 400 | XML 格式错误 | 检查 `slide.content` 是否是完整 `<slide>` 元素 |
179179
| 400 | 请求体结构错误 | 检查是否按 `slide.content``before_slide_id` 包装 |
180180
| 403 | 权限不足 | 检查是否拥有 `slides:presentation:update``slides:presentation:write_only` scope |
181-
| 3350001 | XML 非 well-formed 或服务端参数校验失败 | 优先检查未转义字符:文本 `Q&A -> Q&amp;A`,文本 `<` / `>` 写成 `&lt;` / `&gt;`,属性 URL `a=1&b=2 -> a=1&amp;b=2`;创建前运行 `python3 skills/lark-slides/scripts/layout_lint.py --input <file>` 获取行列和上下文 |
181+
| 3350001 | XML 非 well-formed 或服务端参数校验失败 | 优先检查未转义字符:文本 `Q&A -> Q&amp;A`,文本 `<` / `>` 写成 `&lt;` / `&gt;`,属性 URL `a=1&b=2 -> a=1&amp;b=2` |
182182

183183
## 注意事项
184184

@@ -188,8 +188,7 @@ lark-cli slides xml_presentation.slide create --as user \
188188
4. **fill / border 写法**: 颜色填充使用 `<fill><fillColor color="..."/></fill>`,边框常用 `<border color="..." width="2"/>`
189189
5. **插入位置**: 通过 `before_slide_id` 指定插入目标,而不是用 `position`
190190
6. **JSON 转义**: 如果直接内联 XML,需要正确转义双引号
191-
7. **本地预检**: 创建前运行 `layout_lint.py --input <file>`;它检查 XML well-formed 和布局风险,不等价于完整 XSD schema 校验
192-
8. **建议**: 先使用 `xml_presentations.get` 获取现有结构,再添加新页面
191+
7. **建议**: 先使用 `xml_presentations.get` 获取现有结构,再添加新页面
193192

194193
## 批量添加建议
195194

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# Planning Layer
2+
3+
新建演示文稿或大幅改写页面时,必须先写 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`,再生成 XML。这个文件是 deck 的设计中间层,用来把叙事、页面角色、布局、视觉重点和文字密度固定下来,避免从用户提示直接跳到 XML。
4+
5+
小型已有页编辑可豁免,例如只替换一个标题、改一个数字、插入一个块、上传并插入一张图。只要任务会重排多页、生成新 deck、替换整页结构,仍然需要规划层。
6+
7+
## Required Flow
8+
9+
1. 理解用户需求,必要时澄清主题、受众、页数、风格。
10+
2. 如果适合模板,先用 `template_tool.py search` 检索,锁定模板后用 `summarize` 获取主题和页型信息。
11+
3. 选择唯一 plan 目录:`.lark-slides/plan/<deck-or-task-id>/`
12+
4. 先创建目录:`mkdir -p .lark-slides/plan/<deck-or-task-id>`
13+
5. 写入 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`
14+
6. 读取 `xml-schema-quick-ref.md``visual-planning.md``asset-planning.md`
15+
7. 按 plan、visual planning 和 asset planning 规则逐页生成 XML,把 `layout_type``visual_focus``text_density` 转成具体页面几何和文本量约束,并把缺失素材转成可执行兜底视觉。
16+
8. 创建 PPT 后用 `xml_presentations.get` 回读,核对页面数量、关键元素和 plan 到 XML 的对应关系。
17+
18+
模板不能代替 plan。模板搜索和摘要只能影响 `theme_style`、页面流、布局选择和局部布局骨架;最终仍必须有 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`
19+
20+
## Plan Path
21+
22+
Use a separate plan directory per deck or task so multiple presentations in the same workspace cannot overwrite each other.
23+
24+
Recommended IDs:
25+
26+
- New deck before creation: title slug plus date/time, such as `q3-review-20260507-1805`.
27+
- Existing PPT rewrite: the `xml_presentation_id`.
28+
- Ambiguous or untitled task: short task slug plus date/time.
29+
30+
Rules:
31+
32+
- Do not reuse `.lark-slides/plan/slide_plan.json` as a shared path.
33+
- Create the directory before writing the file.
34+
- Reuse the same plan path for XML generation and post-create verification for that deck.
35+
36+
## JSON Shape
37+
38+
```json
39+
{
40+
"presentation_goal": "Explain the proposal and secure approval for the next phase.",
41+
"audience": "Product and engineering leaders who know the domain but need a concise decision narrative.",
42+
"theme_style": "Clean business style, light background, restrained blue accent, strong visual hierarchy.",
43+
"visual_system": {
44+
"background_strategy": "Content pages use one light base; cover and closing may use a related dark treatment with the same accent system.",
45+
"motif": "A reusable left accent bar and consistent card/header treatments.",
46+
"color_roles": {
47+
"primary": "Used for the dominant structural motif and about 60-70% of visual weight.",
48+
"secondary": "Used for grouped regions, comparison panels, or supporting categories.",
49+
"accent": "Used only for key numbers, conclusions, or focus markers."
50+
}
51+
},
52+
"typography_constraints": {
53+
"title_max_lines": 2,
54+
"body_max_lines_per_box": 2,
55+
"footer_max_lines": 1,
56+
"long_text_handling": "Shorten, split into multiple boxes, or move detail to speaker notes instead of shrinking into a tight box."
57+
},
58+
"verification_plan": {
59+
"check_background_consistency": true,
60+
"check_text_fit": true,
61+
"check_visual_focus": true,
62+
"check_asset_rendering": true
63+
},
64+
"slides": [
65+
{
66+
"page": 1,
67+
"title": "Proposal Title",
68+
"key_message": "The initiative is ready for a focused pilot.",
69+
"layout_type": "title-cover",
70+
"visual_focus": "Large title area with one concise supporting statement.",
71+
"asset_need": {
72+
"asset_type": "logo",
73+
"purpose": "Signal product or team identity on the opening page.",
74+
"suggested_query": "product logo",
75+
"fallback_if_missing": "Use a small text badge and abstract shape motif instead of a real logo."
76+
},
77+
"text_density": "low",
78+
"speaker_intent": "Frame the decision and establish the deck's point of view."
79+
}
80+
]
81+
}
82+
```
83+
84+
## Required Fields
85+
86+
Top-level fields:
87+
88+
- `presentation_goal`: what the whole deck is trying to achieve.
89+
- `audience`: target readers or listeners and their assumed background.
90+
- `theme_style`: visual tone, palette direction, and professional style.
91+
- `visual_system`: deck-level visual rules that must stay stable across pages, including background strategy, recurring motif, and color roles.
92+
- `typography_constraints`: deck-level limits for line count, text box density, and how to handle long text before XML generation.
93+
- `verification_plan`: explicit checks to perform after creation or major edits; include background consistency, text fit, visual focus, and asset rendering when relevant.
94+
- `slides`: ordered page plans.
95+
96+
Each slide must include:
97+
98+
- `page`: 1-based page number.
99+
- `title`: slide title.
100+
- `key_message`: the one idea this page must land.
101+
- `layout_type`: planned page structure.
102+
- `visual_focus`: dominant visual object or region.
103+
- `asset_need`: planning-only structured asset metadata; no search, download, or upload required. Follow `asset-planning.md`.
104+
- `text_density`: `low`, `medium`, or `high`.
105+
- `speaker_intent`: why the speaker needs this page and how it advances the story.
106+
107+
## Layout Vocabulary
108+
109+
Use one of these `layout_type` values unless the user explicitly needs a custom structure:
110+
111+
- `title-cover`
112+
- `section-divider`
113+
- `two-column`
114+
- `image-left-text-right`
115+
- `image-right-text-left`
116+
- `big-number`
117+
- `timeline`
118+
- `comparison`
119+
- `architecture-diagram`
120+
- `process-flow`
121+
- `quote-highlight`
122+
- `conclusion`
123+
124+
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.
125+
126+
## Text Density Rules
127+
128+
- `low`: title plus 1 short statement, or 1-3 very short labels.
129+
- `medium`: title plus 2-4 concise bullets or labeled regions.
130+
- `high`: allowed only when the user needs detail; use tables, columns, or grouped regions instead of a long bullet list.
131+
132+
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.
133+
134+
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.
135+
136+
## Visual System Planning
137+
138+
Before generating XML, define a visual system that can survive the whole deck:
139+
140+
- `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.
141+
- `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.
142+
- `color_roles`: assign primary, secondary, and accent roles. The same color must not mean unrelated things across pages.
143+
- `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.
144+
- `closing_relationship`: if the closing page mirrors the cover, state that explicitly so it looks intentional rather than like a new theme.
145+
146+
These are planning constraints, not decoration notes. They must affect coordinates, background fills, shape styles, and text placement in generated XML.
147+
148+
## Iterative Deck State
149+
150+
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.
151+
152+
Recommended optional fields for long-running work:
153+
154+
- `deck_status`: current slide count, target slide count if known, and last verified revision or timestamp.
155+
- `created_slides`: page number, slide id when known, and the page role.
156+
- `assets_used`: source, local path when applicable, uploaded token when known, and which page uses it.
157+
- `open_issues`: known layout, text fit, asset, or consistency risks that still need correction.
158+
159+
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.
160+
161+
## Asset Planning
162+
163+
`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.
164+
165+
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:
166+
167+
- `asset_type`: one of `paper_figure`, `architecture_diagram`, `icon`, `logo`, `chart`, `infographic`, `screenshot`, `flow_diagram`, or `none`.
168+
- `purpose`: why this asset helps the page's key message.
169+
- `suggested_query`: short future lookup hint only; do not execute it unless separately requested.
170+
- `fallback_if_missing`: concrete XML-native visual plan using shapes, arrows, labels, tables, simple charts, or placeholder panels.
171+
172+
For detailed rules and examples, read `asset-planning.md`.
173+
174+
Good examples:
175+
176+
- `{"asset_type":"architecture_diagram","purpose":"Explain component relationships.","suggested_query":"service architecture diagram","fallback_if_missing":"Draw grouped boxes and arrows with short labels."}`
177+
- `{"asset_type":"logo","purpose":"Identify the customer context.","suggested_query":"customer logo","fallback_if_missing":"Use a text label in a small badge."}`
178+
- `{"asset_type":"chart","purpose":"Show adoption trend.","suggested_query":"monthly adoption trend chart","fallback_if_missing":"Draw a simple line chart with shapes and value labels."}`
179+
180+
## XML Generation Contract
181+
182+
Before writing each slide XML, map the plan fields to concrete decisions:
183+
184+
- `key_message` determines the headline, dominant claim, or main takeaway.
185+
- `layout_type` determines the coordinate structure and element types. Use `visual-planning.md` for concrete layout rules.
186+
- `visual_focus` determines the largest visual region or emphasized object.
187+
- `text_density` caps visible text volume.
188+
- `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.
189+
190+
After creating the PPT, fetch the presentation and verify:
191+
192+
- Page count matches the plan.
193+
- Every page has the planned title and key message represented.
194+
- At least several pages have visibly different XML layout structures.
195+
- Planned `visual_focus` appears as a dominant visual region or object.
196+
- 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.
197+
- `text_density` is reflected in the amount of visible text.
198+
- Pages are not crowded, and any planned `timeline`, `comparison`, or `architecture-diagram` page uses its matching visual structure.
199+
- 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.
200+
- 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.
201+
- 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.

0 commit comments

Comments
 (0)