Skip to content

refactor(slides): streamline create workflow and validation#1887

Open
ethan-zhx wants to merge 9 commits into
mainfrom
refactor/slides-create-workflow-validation
Open

refactor(slides): streamline create workflow and validation#1887
ethan-zhx wants to merge 9 commits into
mainfrom
refactor/slides-create-workflow-validation

Conversation

@ethan-zhx

@ethan-zhx ethan-zhx commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Streamline the Lark Slides create/edit workflow and add validation coverage for XML, namespaces, icon types, text overlap, and screenshot requests.

Changes

  • Add and test XML readback and SML namespace validation flows.
  • Run slide lint before create and validate icon types, text overlap, and screenshot page limits.
  • Reorganize and update the lark-slides workflow and reference documentation.

Test Plan

  • Unit tests pass (not run locally per repository safety instructions)
  • Manual local verification confirms the lark-cli Slides flows work as expected (not run)

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Retrieve full presentation XML or a single slide by ID or number.
    • View XML as JSON, print raw XML, or save it to a file.
    • Added clearer output details for presentation and slide exports.
  • Bug Fixes

    • Screenshot requests now support a maximum of 10 slides, with clearer validation guidance.
    • Improved validation for conflicting or incompatible XML retrieval options.
  • Documentation

    • Expanded slide creation, template, XML retrieval, screenshot, and troubleshooting guidance.
    • Added stricter recommendations for XML validation, icon usage, layout, and visual verification.
  • Quality

    • Enhanced XML linting for schema errors, icons, namespaces, overflow, and whiteboard overlaps.

@github-actions github-actions Bot added the size/XL Architecture-level or global-impact change label Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Slides shortcuts now support bounded screenshot batches and flexible full- or single-slide XML retrieval. The XML linter adds schema, namespace, icon, text-overlap, and whiteboard checks, while Slides skill references document the revised creation, validation, readback, and template workflows.

Changes

Screenshot selector limits

Layer / File(s) Summary
Enforce screenshot selector limits
shortcuts/slides/slides_screenshot.go, shortcuts/slides/slides_screenshot_test.go
SlidesScreenshot documents and enforces a maximum of 10 combined slide selectors across validation, dry-run, and execution paths, with coverage for 11 selectors.

Slides XML retrieval

Layer / File(s) Summary
Define XML retrieval modes
shortcuts/slides/slides_xml_get.go
SlidesXMLGet adds optional output, raw XML, slide ID, and slide number modes with selector and option compatibility validation.
Fetch and emit XML content
shortcuts/slides/slides_xml_get.go
Retrieval supports full presentations and individual slides, returning JSON envelopes, raw XML, or saved-file metadata.
Validate XML retrieval behavior
shortcuts/slides/slides_xml_get_test.go
Tests cover envelope, jq, raw, file, single-slide, and invalid argument behaviors.

XML linting and Slides guidance

Layer / File(s) Summary
Add XML schema and namespace validation
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/scripts/xml_text_overlap_lint_test.py
The linter validates SXSD tags and attributes, SML namespace prefixes, IconPark types and fills, XML parsing, and structured issue aggregation.
Expand geometry and overlap detection
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/scripts/xml_text_overlap_lint_test.py
Element extraction, Unicode-aware text sizing, horizontal overflow detection, and whiteboard external-overlap reporting are expanded and tested.
Document lint and XML workflow
skills/lark-slides/SKILL.md, skills/lark-slides/references/examples.md, skills/lark-slides/references/visual-planning.md, skills/lark-slides/references/iconpark.md, skills/lark-slides/references/xml-schema-quick-ref.md
Guidance adds planning, lint gates, readback, layout, icon, whiteboard, and reliable multi-slide creation rules.
Update Slides command references
skills/lark-slides/references/*
Reference documentation adopts slides +xml-get and updates creation, replacement, screenshot, template, troubleshooting, and validation workflows.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant SlidesXMLGet
  participant SlidesAPI
  participant OutputWriter
  CLI->>SlidesXMLGet: provide presentation and optional slide selector
  SlidesXMLGet->>SlidesAPI: request full or single-slide XML
  SlidesAPI-->>SlidesXMLGet: return XML content
  SlidesXMLGet->>OutputWriter: emit JSON, raw XML, or file metadata
Loading

Possibly related PRs

  • larksuite/cli#1358: Introduced the Slides screenshot implementation extended here with the 10-selector limit.
  • larksuite/cli#1585: Introduced the SlidesXMLGet shortcut modified here for slide selectors and output modes.

Suggested labels: domain/ccm

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly summarizes the main slide workflow and validation refactor.
Description check ✅ Passed The description follows the template with Summary, Changes, Test Plan, and Related Issues sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/slides-create-workflow-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py Dismissed
for icon in icons
if isinstance(icon, dict) and isinstance(icon.get("iconType"), str) and icon["iconType"]
}
_ICONPARK_ICON_TYPES_CACHE = icon_types
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.89189% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.66%. Comparing base (37d490a) to head (7d67a41).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/slides/slides_xml_get.go 67.16% 32 Missing and 12 partials ⚠️
shortcuts/slides/slides_screenshot.go 64.28% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1887      +/-   ##
==========================================
- Coverage   74.66%   74.66%   -0.01%     
==========================================
  Files         877      878       +1     
  Lines       91731    91869     +138     
==========================================
+ Hits        68494    68596     +102     
- Misses      17926    17949      +23     
- Partials     5311     5324      +13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@7d67a41280157390aecb9c9d358451088eedc89a

🧩 Skill update

npx skills add larksuite/cli#refactor/slides-create-workflow-validation -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/slides/slides_screenshot_test.go`:
- Around line 293-298: Update the error assertion in the slide screenshot test
to inspect typed metadata through errs.ProblemOf instead of matching the error
message substring. Assert the expected category, subtype, and parameter metadata
for the maximum-pages validation while retaining the existing requirement that
an error is returned.

In `@shortcuts/slides/slides_screenshot.go`:
- Around line 284-288: Update validateSlidesScreenshotSelectorLimit so the
validation error message contains only the limit violation details, and attach
the “request at most 10 pages at a time” recovery guidance via WithHint.
Construct the error directly with errs.NewValidationError and preserve the
existing nil return when count is within maxSlidesPerScreenshot.

In `@shortcuts/slides/slides_xml_get_test.go`:
- Around line 387-406: Update TestSlidesXMLGetRejectsConflictingSlideSelectors,
TestSlidesXMLGetRejectsEmptySlideID, and
TestSlidesXMLGetRejectsRemoveAttrIDForSingleSlide to validate errors through
errs.ProblemOf(err), matching TestSlidesXMLGetRejectsUnsafeOutputPath. Assert
the expected category, subtype, and parameter metadata, and verify the
underlying cause is preserved instead of only checking ValidationError.Param.

In `@skills/lark-slides/references/examples.md`:
- Around line 10-11: Update the two table-of-contents links for 示例 7 and 示例 8 to
use fragments generated from their exact example headings, including the correct
Markdown anchor normalization. Verify both targets resolve successfully and
preserve the existing link text.
- Around line 57-71: Update the presentation creation flow around
PRESENTATION_ID so the lark-cli slides +create exit status is captured
separately from writing create.json, preserving failures instead of allowing the
pipeline to report jq’s status. Extract .data.xml_presentation_id from
create.json with jq -e and validate that it is a non-empty string before saving
it for readback.

In `@skills/lark-slides/references/troubleshooting.md`:
- Line 13: Update the two-step creation guidance in the troubleshooting
documentation to use the registered command syntax `xml_presentation.slide
create` instead of `xml_presentation.slide.create`, while preserving the
surrounding recovery flow.

In `@skills/lark-slides/references/validation-checklist.md`:
- Line 92: Update the whiteboard coordinate validation guidance in the checklist
to include lower-bound checks: topLeftX and topLeftY must be at least zero, and
width and height must be non-negative, alongside the existing right and bottom
upper bounds.

In `@skills/lark-slides/references/xml-schema-quick-ref.md`:
- Line 149: 更新该 XML schema 快速参考中关于 iconType 的说明,明确要求其必须存在于离线 IconPark 索引
iconpark-index.json 中,而非仅使用“已验证路径”的表述;保持 fillColor 和 iconpark.md 的相关规则不变。

In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 500-536: Update the shape text extraction in the element-building
loop so paragraph boundaries from separate <p> elements are preserved before
line-width estimation. Replace the strip_xml(content) path used for the
element’s “text” value with paragraph-aware normalization that emits newline
separators between paragraphs, and apply the same handling to the related text
extraction around the later reference. Keep existing tag removal and whitespace
behavior for content within each paragraph.
- Around line 733-734: Update lint_slide and the should_flag_overlap flow so
should_flag_horizontal_text_overflow is evaluated before the
declared-bounding-box intersection gate, allowing overflow across gaps to be
detected. Preserve intersection-based handling for other overlap cases, and add
a regression test covering adjacent text boxes with non-intersecting declared
boxes.
- Around line 408-462: Update validate_sml_tag_prefixes to create the Expat
parser with a namespace separator so StartNamespaceDeclHandler is enabled and
namespace_map is populated before prefixed-tag validation. Preserve the existing
declaration scoping and SML_NAMESPACE checks.

In `@skills/lark-slides/SKILL.md`:
- Line 13: Update the global hard constraint in the slide guidance to treat
960x540 as the default canvas size rather than an invariant. Instruct
implementations to preserve and use the declared dimensions of imported or
existing presentations, keeping all content within that presentation’s actual
page boundaries.
- Line 183: Replace the bare Chinese text under the XML <data> element with a
valid XML comment, preserving its guidance that shape, line, table, and chart
elements belong there.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4d4fef28-2413-438b-b56e-985b09dcabb7

📥 Commits

Reviewing files that changed from the base of the PR and between ac2508d and 7d67a41.

📒 Files selected for processing (25)
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • shortcuts/slides/slides_xml_get.go
  • shortcuts/slides/slides_xml_get_test.go
  • skills/lark-slides/SKILL.md
  • skills/lark-slides/references/examples.md
  • skills/lark-slides/references/iconpark.md
  • skills/lark-slides/references/lark-slides-create.md
  • skills/lark-slides/references/lark-slides-media-upload.md
  • skills/lark-slides/references/lark-slides-pptx-template-workflows.md
  • skills/lark-slides/references/lark-slides-replace-pages.md
  • skills/lark-slides/references/lark-slides-replace-slide.md
  • skills/lark-slides/references/lark-slides-screenshot.md
  • skills/lark-slides/references/lark-slides-xml-get.md
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-create.md
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-delete.md
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-get.md
  • skills/lark-slides/references/lark-slides-xml-presentations-get.md
  • skills/lark-slides/references/planning-layer.md
  • skills/lark-slides/references/troubleshooting.md
  • skills/lark-slides/references/validation-checklist.md
  • skills/lark-slides/references/visual-planning.md
  • skills/lark-slides/references/xml-schema-quick-ref.md
  • skills/lark-slides/scripts/xml_text_overlap_lint.py
  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py
💤 Files with no reviewable changes (2)
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-create.md
  • skills/lark-slides/references/lark-slides-media-upload.md

Comment thread shortcuts/slides/slides_screenshot_test.go
Comment thread shortcuts/slides/slides_screenshot.go
Comment thread shortcuts/slides/slides_xml_get_test.go
Comment on lines 10 to 11
- [示例 7: +replace-slide + block_insert 给已有页加图](#示例-7-replace-slide--block_insert-给已有页加图)
- [示例 8: +replace-slide + block_replace 替换一个块](#示例-8-replace-slide--block_replace-替换一个块)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the invalid TOC fragments.

Markdownlint reports both links as unresolved (MD051). Regenerate their fragments from the actual example headings so in-page navigation works.

🧰 Tools
🪛 markdownlint-cli2 (0.23.0)

[warning] 10-10: Link fragments should be valid

(MD051, link-fragments)


[warning] 11-11: Link fragments should be valid

(MD051, link-fragments)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/lark-slides/references/examples.md` around lines 10 - 11, Update the
two table-of-contents links for 示例 7 and 示例 8 to use fragments generated from
their exact example headings, including the correct Markdown anchor
normalization. Verify both targets resolve successfully and preserve the
existing link text.

Source: Linters/SAST tools

Comment thread skills/lark-slides/references/examples.md
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/SKILL.md
Comment thread skills/lark-slides/SKILL.md
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
}
if strings.TrimSpace(runtime.Str("output")) == "" {
return errs.NewValidationError(errs.SubtypeInvalidArgument, "--output cannot be empty").WithParam("--output")
if err := validateSlidesXMLGetSelector(runtime); err != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactor dropped the previous --revision-id lower-bound validation. Before this PR, runtime.Int("revision-id") < -1 returned a typed validation error, but now values such as --revision-id -2 pass validation and are sent to both the dry-run/API params. Please restore the -1 or non-negative check and add a regression test so invalid revisions fail before any API call.

| 在 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` |
| 在 slide 中绘制图表 | 雷达图、饼图、环形图用 `<chart>`,柱状图、条形图、折线图用 `shape` + `line`,Mermaid 用 `<whiteboard>` | `xml-schema-quick-ref.md`、需要 `<whiteboard>` 再看 `lark-slides-whiteboard.md` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guidance points column/bar/line charts to hand-built shape + line drawings, but the schema and asset-planning docs treat column, bar, line, area, radar, pie, doughnut/ring, and combo as supported native <chart> visuals. If agents follow this quick reference, standard data charts become static drawings with worse data fidelity, harder edits, and inconsistent rendering. Please keep all supported standard data charts on native <chart> and reserve shape/line or <whiteboard> only for unsupported/custom visuals such as funnel or scatter.


1. **先规划再写 XML**:新建演示文稿或大幅改写页面时,必须先写入 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`;风格和大纲只能作为规划输入,不能绕过规划层
1. **先规划再写 XML**:新建演示文稿或大幅改写页面时,必须先写入 `.lark-slides/plan/<deck-or-task-id>/slide_plan.json`;模板、风格和大纲只能作为规划输入,不能绕过规划层
2. **创建流程**:简单短 XML(1-3 页、结构简单、特殊字符少)可用 `slides +create --slides '[...]'` 一步创建;复杂内容、含图片/中文大段文本/嵌套引号/较多特殊字符,或超过 10 页时,默认先 `slides +create` 创建空白 PPT,再用 `xml_presentation.slide.create` 逐页添加

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This top-level rule still uses the dotted xml_presentation.slide.create spelling, but the executable CLI form is lark-cli slides xml_presentation.slide create (create is the subcommand after the resource). Because this is in the core rules, agents will copy the wrong command form even if some examples below are correct. Please normalize these guidance mentions to xml_presentation.slide create or show the full lark-cli slides xml_presentation.slide create command consistently.


**CRITICAL — 全局硬约束:PPT 的尺寸是 960x540,确保主体内容在页面边界内。**

**CRITICAL — 图片至关重要:必须有意识的主动多用图片!素材图使用生图工具和搜图工具,缺图时用生图工具生成配图补足;背景图必须使用生图工具,且生图指令中必须明确要求不要出现任何文字。**

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hard requirement conflicts with the new asset-planning rule below that asset_need is metadata only and must not require web search, local download, media upload, or external tools. Read literally, agents will start searching/generating images during planning or template-edit tasks, even when a concrete XML-native fallback is enough or the imported template's visuals should be preserved. Please scope this to the execution phase: plan asset needs and fallbacks first, then only search/generate/upload real assets when the user asks for real media or the chosen workflow explicitly supports it.

sxsd_issues = validate_sxsd_tag_attributes(root) if root is not None else []
iconpark_issues = validate_iconpark_icon_types(root) if root is not None else []
top_level_issues = [*namespace_issues, *sxsd_issues, *iconpark_issues]
presentation = parse_presentation(xml)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new prefixed-namespace lint path can still abort before returning the structured issues. For an input like <ns0:slide xmlns:ns0="http://www.larkoffice.com/sml/2.0">..., parse_xml_root succeeds and namespace_issues is populated, but this call still uses the regex-based parse_presentation, which only recognizes literal <slide> / <presentation> tags and raises XmlTextOverlapLintError. That makes test_lint_xml_rejects_prefixed_sml_tags error instead of reporting sml_prefixed_tag issues. Please either parse slides from the ElementTree root or return top-level namespace/schema issues before the regex presentation parser can fail on prefixed roots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Architecture-level or global-impact change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants