Skip to content

feat(slides): inline slides reference docs into help output - #2181

Open
ethan-zhx wants to merge 1 commit into
mainfrom
feat/help_info
Open

feat(slides): inline slides reference docs into help output#2181
ethan-zhx wants to merge 1 commit into
mainfrom
feat/help_info

Conversation

@ethan-zhx

@ethan-zhx ethan-zhx commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add skills read routing to lark-cli slides help output, so AI agents see actionable pointers to the reference docs instead of searching blind. Covers domain help, all 12 public shortcuts, and the generated xml_presentation.slide replace method.

Changes

  • Domain help (slides --help): append Slides list routing and Slides document routes blocks explaining how to enumerate slides and where to read the XML schema reference.
  • Shortcut help (+create, +add-slide, +delete-slide, +xml-get, +screenshot, +media-upload, +replace-slide, +update-slide, +history-list, +history-revert, +history-revert-status): each --help now appends a Slides document routes: block with lark-cli skills read pointers to its matching reference doc.
  • Deprecated +replace-pages: routes to the +update-slide replacement docs (lark-slides-update-slide.md + edit-workflows + XML quick-ref) and emits a Deprecated: use slides +update-slide hint — no longer points to the removed lark-slides-replace-pages.md.
  • Method help (xml_presentation.slide replace --help): appends the same Slides document routes: block routing to lark-slides-edit-workflows.md, using the fully-qualified affordance method id xml_presentation.slide.replace for unambiguous matching.
  • Resolve guard: TestSlidesShortcutReferencePathsResolve fails if any mapped reference file is missing on disk, preventing silent route drops.

Test Plan

  • Unit tests pass (verify with make unit-test on a compatible machine)
  • gofmt -l . produces no output
  • go vet ./cmd/service/ passes
  • Manual local verification: ./lark-cli slides +update-slide --help shows Slides document routes: block

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added Slides-specific help guidance, including list workflows and available reference routes.
    • Added targeted help links for Slides shortcuts and presentation editing methods.
    • Updated deprecated +replace-pages guidance to point to +update-slide.
    • Help references can now appear even when no affordance overlay is available.
  • Bug Fixes

    • Improved help routing to avoid stale, unrelated, or incorrect references.
    • Excluded irrelevant screenshot guidance from Slides help results.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d728dc8-5f47-4b6c-aa22-9b968f7aace5

📥 Commits

Reviewing files that changed from the base of the PR and between e31882c and 00b2292.

📒 Files selected for processing (2)
  • cmd/service/affordance.go
  • cmd/service/affordance_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/service/affordance.go
  • cmd/service/affordance_test.go

📝 Walkthrough

Walkthrough

Slides help now routes domains, methods, and shortcuts to validated reference documents. It adds deprecated command guidance, supports reference-only shortcut help, and tests route mappings, path validity, filtering, and idempotent rendering.

Changes

Slides help routing

Layer / File(s) Summary
Reference mappings and definitions
cmd/service/affordance.go, cmd/service/affordance_test.go
Slides shortcuts and methods map to reference paths and deprecated command replacements. Tests validate the mappings and confirm configured filesystem paths exist.
Shortcut help rendering
cmd/service/affordance.go, cmd/service/affordance_test.go
Shortcut help resolves Slides reference routes independently and appends routes and deprecation guidance. Reference-only help renders without an affordance overlay. Tests cover reference routing without overlays and repeated rendering.
Domain help integration
cmd/service/affordance.go, cmd/service/affordance_test.go
Domain help appends Slides list guidance and document-reference routes. Tests validate guidance and references remain lazy after repeated rendering.
Regression and filtering coverage
cmd/service/affordance_test.go
Tests ensure deprecated +replace-pages routes to update-slide documentation. Tests verify screenshot routing includes only the primary reference and excludes the XML quick reference.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HelpRequest
  participant AffordanceHelp
  participant SlidesRouteMap
  participant SkillsFilesystem
  HelpRequest->>AffordanceHelp: request Slides help (domain, method, or shortcut)
  AffordanceHelp->>SlidesRouteMap: resolve reference route
  SlidesRouteMap->>SkillsFilesystem: validate reference path
  SkillsFilesystem-->>AffordanceHelp: return valid path
  AffordanceHelp-->>HelpRequest: render documentation route and guidance
Loading

Possibly related PRs

  • larksuite/cli#2120: Adds Slides shortcuts whose help routes are updated here.
  • larksuite/cli#2143: Adds the +update-slide routing and deprecated +replace-pages guidance covered here.

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding inline Slides reference documentation to help output.
Description check ✅ Passed The description follows the template and clearly documents the scope, changes, verification steps, and related issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 feat/help_info

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.

@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Aug 4, 2026

@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.

🧹 Nitpick comments (3)
cmd/service/affordance.go (1)

269-278: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename the shared route renderer and reuse it for the domain block.

PrepareMethodHelp at Line 343 calls appendSlidesShortcutReferenceRoutes, so the function is no longer shortcut-specific. appendSlidesDomainRoutingHints at Lines 229-232 also re-implements the same "Slides document routes:" header and indented list. Rename the helper to appendSlidesDocumentRoutes and call it from the domain path so one function owns the block format.

♻️ Proposed consolidation
-func appendSlidesShortcutReferenceRoutes(b *strings.Builder, routes []string) {
+func appendSlidesDocumentRoutes(b *strings.Builder, routes []string) {
 	if len(routes) == 0 {
 		return
 	}
 	b.WriteString("\n\nSlides document routes:")
 	for _, route := range routes {
 		b.WriteString("\n  ")
 		b.WriteString(route)
 	}
 }

Then reuse it in appendSlidesDomainRoutingHints:

 	routes := slidesDocumentRoutes(skillFS, []string{
 		"lark-slides/SKILL.md",
 		slidesXMLQuickReferencePath,
 	})
-	if len(routes) == 0 {
-		return
-	}
-	b.WriteString("\n\nSlides document routes:")
-	for _, route := range routes {
-		fmt.Fprintf(b, "\n  %s", route)
-	}
+	appendSlidesDocumentRoutes(b, routes)
 }
🤖 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 `@cmd/service/affordance.go` around lines 269 - 278, Rename
appendSlidesShortcutReferenceRoutes to appendSlidesDocumentRoutes, update the
PrepareMethodHelp call to use the new name, and replace the duplicated “Slides
document routes:” rendering in appendSlidesDomainRoutingHints with this shared
helper.
cmd/service/affordance_test.go (2)

393-401: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the exact route count so the table catches added routes.

The subtest builds skillFS from slidesShortcutReferencePaths[command], which is the same map the table is meant to pin. The assertion only checks containment, so an extra path added to the production map produces an extra entry in got and the test still passes. Compare the length as well, as TestSlidesScreenshotHelpDoesNotIncludeXMLQuickReference already does at Lines 484-486.

💚 Proposed assertion
 			got, ok := readSlidesShortcutReferenceRoutes(sc, skillFS)
 			if !ok || len(got) == 0 {
 				t.Fatalf("shortcut %q has no mapped reference", command)
 			}
+			if len(got) != len(routes) {
+				t.Fatalf("shortcut %q routes = %#v, want exactly %#v", command, got, routes)
+			}
 			for _, route := range routes {
 				if !containsString(got, route) {
 					t.Fatalf("shortcut %q routes = %#v, want %q", command, got, route)
 				}
 			}
🤖 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 `@cmd/service/affordance_test.go` around lines 393 - 401, Update the subtest
around readSlidesShortcutReferenceRoutes to assert that len(got) equals
len(routes) before checking route containment, matching the exact-count
validation used by TestSlidesScreenshotHelpDoesNotIncludeXMLQuickReference. Keep
the existing non-empty and per-route assertions.

Source: Coding guidelines


304-315: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Stub affordanceLookup so the reference-only branch is actually pinned.

This test leaves the package-level affordanceLookup at its real implementation and still calls cmdmeta.SetAffordanceRef(sc, "slides", "+xml-get"). If an overlay exists for that service/method pair, hasAffordance becomes true and PrepareShortcutHelp no longer takes the !hasAffordance && hasReferenceRoutes path that this test is named for. Reverting the new allowance in PrepareShortcutHelp would then not fail this test. Force the no-affordance state, as the sibling tests at Lines 116-120 and Lines 187-194 already do.

As per coding guidelines: "contract tests must assert the changed field or behavior directly so reverting the implementation causes failure".

💚 Proposed test hardening
 func TestPrepareShortcutHelp_SlidesReferenceRouteWithoutAffordance(t *testing.T) {
+	orig := affordanceLookup
+	t.Cleanup(func() { affordanceLookup = orig })
+	affordanceLookup = func(_, _ string) (json.RawMessage, bool) { return nil, false }
+
 	sc := &cobra.Command{Use: "+xml-get", Short: "Fetch presentation XML"}
 	cmdmeta.SetSource(sc, cmdmeta.SourceShortcut, false)
 	cmdmeta.SetDomain(sc, "slides")
 	cmdmeta.SetAffordanceRef(sc, "slides", "+xml-get")
 	cmdutil.SetRisk(sc, "read")
🤖 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 `@cmd/service/affordance_test.go` around lines 304 - 315, Update
TestPrepareShortcutHelp_SlidesReferenceRouteWithoutAffordance to stub the
package-level affordanceLookup, forcing the slides/+xml-get lookup to report no
affordance before calling PrepareShortcutHelp. Follow the stubbing pattern used
by the sibling tests around the existing affordanceLookup setup, and assert the
reference-only behavior so reverting the PrepareShortcutHelp allowance causes
this test to fail.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@cmd/service/affordance_test.go`:
- Around line 393-401: Update the subtest around
readSlidesShortcutReferenceRoutes to assert that len(got) equals len(routes)
before checking route containment, matching the exact-count validation used by
TestSlidesScreenshotHelpDoesNotIncludeXMLQuickReference. Keep the existing
non-empty and per-route assertions.
- Around line 304-315: Update
TestPrepareShortcutHelp_SlidesReferenceRouteWithoutAffordance to stub the
package-level affordanceLookup, forcing the slides/+xml-get lookup to report no
affordance before calling PrepareShortcutHelp. Follow the stubbing pattern used
by the sibling tests around the existing affordanceLookup setup, and assert the
reference-only behavior so reverting the PrepareShortcutHelp allowance causes
this test to fail.

In `@cmd/service/affordance.go`:
- Around line 269-278: Rename appendSlidesShortcutReferenceRoutes to
appendSlidesDocumentRoutes, update the PrepareMethodHelp call to use the new
name, and replace the duplicated “Slides document routes:” rendering in
appendSlidesDomainRoutingHints with this shared helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0958d71e-0a45-459d-a37a-677a6f0eefb1

📥 Commits

Reviewing files that changed from the base of the PR and between 3b66d47 and e31882c.

📒 Files selected for processing (2)
  • cmd/service/affordance.go
  • cmd/service/affordance_test.go

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@00b22920a8b37c302a46a3b54a4b3d0eea91c7c4

🧩 Skill update

npx skills add larksuite/cli#feat/help_info -y -g

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.09677% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.72%. Comparing base (3b66d47) to head (00b2292).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/service/affordance.go 87.09% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2181      +/-   ##
==========================================
+ Coverage   75.70%   75.72%   +0.01%     
==========================================
  Files         944      944              
  Lines      100288   100352      +64     
==========================================
+ Hits        75926    75994      +68     
+ Misses      18565    18563       -2     
+ Partials     5797     5795       -2     

☔ 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.

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

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant