Skip to content

feat(im): cli support feed group#1102

Open
zhumiaoxin wants to merge 1 commit into
larksuite:mainfrom
zhumiaoxin:feat/feed-group
Open

feat(im): cli support feed group#1102
zhumiaoxin wants to merge 1 commit into
larksuite:mainfrom
zhumiaoxin:feat/feed-group

Conversation

@zhumiaoxin
Copy link
Copy Markdown
Collaborator

@zhumiaoxin zhumiaoxin commented May 26, 2026

Summary

Add IM feed group support documentation for lark-cli, making the raw im feed.groups.* APIs discoverable and easier for agents to use correctly.

Changes

  • Register feed.groups methods in the lark-im skill index with user-only identity requirements and required OAuth scopes.
  • Add a feed group reference covering create, update, delete, list, batch query, item add/remove, item query, and item list flows.
  • Document request/response shapes, pagination behavior, soft-deleted results, enum values, permissions, and example commands for feed group operations.

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark-cli im feed.groups <command> flow works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Added two IM shortcuts: +feed-group-list-item and +feed-group-query-item to list/query feed-group items with chat-name enrichment and optional auto-pagination.
  • Documentation
    • Added full feed-groups API and shortcut reference docs with examples, enums, scopes, and usage notes.
    • Clarified +flag-create and +flag-cancel descriptions (feed-layer semantics, best-effort double-cancel, item-type auto-detection).
  • Tests
    • Added comprehensive tests for pagination, enrichment, validation, table output, and dry-run behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

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

Run ID: e6169f16-83d1-4f26-b1c5-f0d6760304ec

📥 Commits

Reviewing files that changed from the base of the PR and between 5150232 and 4c53228.

📒 Files selected for processing (12)
  • shortcuts/im/helpers_test.go
  • shortcuts/im/im_feed_group_item_test.go
  • shortcuts/im/im_feed_group_items.go
  • shortcuts/im/im_feed_group_list_item.go
  • shortcuts/im/im_feed_group_query_item.go
  • shortcuts/im/im_flag_cancel.go
  • shortcuts/im/im_flag_create.go
  • shortcuts/im/shortcuts.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-feed-group-list-item.md
  • skills/lark-im/references/lark-im-feed-group-query-item.md
  • skills/lark-im/references/lark-im-feed-groups.md
✅ Files skipped from review due to trivial changes (5)
  • shortcuts/im/im_flag_cancel.go
  • skills/lark-im/references/lark-im-feed-group-query-item.md
  • skills/lark-im/references/lark-im-feed-group-list-item.md
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-feed-groups.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • shortcuts/im/im_flag_create.go
  • shortcuts/im/helpers_test.go
  • shortcuts/im/shortcuts.go
  • shortcuts/im/im_feed_group_items.go
  • shortcuts/im/im_feed_group_query_item.go
  • shortcuts/im/im_feed_group_item_test.go

📝 Walkthrough

Walkthrough

Adds two IM feed-group shortcuts (+feed-group-list-item, +feed-group-query-item) with enrichment, pagination, DryRun, helpers, tests, CLI registration; tweaks ImFlagCreate/ImFlagCancel descriptions; and adds comprehensive feed.groups documentation and SKILL entries.

Changes

IM feed-groups and shortcuts

Layer / File(s) Summary
Test scaffolding and shortcuts tests
shortcuts/im/im_feed_group_item_test.go, shortcuts/im/helpers_test.go
Adds HTTP-recording test scaffolding and a broad test suite covering enrichment, pagination, validation, DryRun, and output rendering; updates test expectations to include new shortcuts.
Feed-group item helpers
shortcuts/im/im_feed_group_items.go
Adds enrichFeedGroupItemsChatName and renderFeedGroupItemsTable with scope constants and graceful-degradation behavior for unresolved feed IDs.
List-item shortcut and pagination
shortcuts/im/im_feed_group_list_item.go
Implements ImFeedGroupListItem with flags, validation, single-page and --page-all accumulation, enrichment via chats.batch_query, table rendering, and DryRun support.
Query-item shortcut and body builder
shortcuts/im/im_feed_group_query_item.go
Implements ImFeedGroupQueryItem with path encoding, CSV --feed-id parsing into items (feed_type:"chat"), POST execution, enrichment, and DryRun output.
Shortcuts registration
shortcuts/im/shortcuts.go
Adds the two new shortcuts to the Shortcuts() slice so they appear in the CLI list.
Flag shortcut metadata updates
shortcuts/im/im_flag_cancel.go, shortcuts/im/im_flag_create.go
Reformats exported metadata and updates Description strings to clarify feed-layer behavior and best-effort double-cancel semantics; no runtime changes.
SKILL index and feed.groups reference
skills/lark-im/SKILL.md, skills/lark-im/references/lark-im-feed-groups.md, skills/lark-im/references/*
Adds feed.groups API subsection and comprehensive reference pages plus per-shortcut docs covering endpoints, enums, shared rules schema, examples, and permission scope mappings (im:feed_group_v1).

Sequence Diagram(s)

sequenceDiagram
  participant CLI as lark-cli shortcut
  participant FeedGroups as feed.groups.list_item / batch_query_item
  participant ChatBatch as chats.batch_query
  CLI->>FeedGroups: GET/POST (list_item or batch_query_item)
  FeedGroups-->>CLI: items + deleted_items (+page_token)
  CLI->>ChatBatch: POST /chats/batch_query (feed_ids)
  ChatBatch-->>CLI: chat_name lookup map
  CLI->>CLI: inject chat_name, render table / print DryRun
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • larksuite/cli#770: Prior PR introducing the +flag-cancel and +flag-create shortcut implementations; related to the metadata description refinements here.

Suggested reviewers

  • YangJunzhou-01
  • liangshuo-1

🐰 I hopped through docs and code tonight,
New feed groups bloom and flags read right.
Shortcuts stitch pages, tests run true,
Chat names resolve, tables bloom too.
A tiny rabbit cheers this tidy sight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% 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 'feat(im): cli support feed group' clearly and concisely describes the main change: adding CLI support for IM feed groups.
Description check ✅ Passed The PR description follows the template structure with Summary, Changes, Test Plan, and Related Issues sections, all appropriately filled with relevant information.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added domain/im PR touches the im domain size/L Large or sensitive change across domains or core paths labels May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 72.55814% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.15%. Comparing base (ee9d090) to head (4c53228).
⚠️ Report is 44 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/im/im_feed_group_list_item.go 70.47% 17 Missing and 14 partials ⚠️
shortcuts/im/im_feed_group_items.go 71.64% 10 Missing and 9 partials ⚠️
shortcuts/im/im_feed_group_query_item.go 78.04% 5 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1102      +/-   ##
==========================================
+ Coverage   67.92%   69.15%   +1.23%     
==========================================
  Files         601      633      +32     
  Lines       55766    59525    +3759     
==========================================
+ Hits        37880    41167    +3287     
- Misses      14751    15020     +269     
- Partials     3135     3338     +203     

☔ View full report in Codecov by Sentry.
📢 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

github-actions Bot commented May 26, 2026

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@4c53228cf3fea1469a679501ff976d08024498b8

🧩 Skill update

npx skills add zhumiaoxin/cli#feat/feed-group -y -g

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/im/im_feed_group_item_test.go`:
- Around line 64-94: The test runtime is constructed without using
cmdutil.TestFactory, so update the helper to build the runtime via
cmdutil.TestFactory(t, config) (or the equivalent TestFactory constructor)
instead of whatever newUserShortcutRuntime currently returns; locate
newFGRuntime and the helper functions
newUserShortcutRuntime/shortcutRoundTripFunc and change the runtime creation to
call cmdutil.TestFactory with the appropriate test config, then set runtime.Cmd
(newFGCmd) and runtime.Format = "json" as before so Execute still uses the
mocked HTTP transport.
🪄 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: a775c48d-7762-4afb-979e-dda41c11a314

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec7254 and fc70ed5.

📒 Files selected for processing (10)
  • shortcuts/im/helpers_test.go
  • shortcuts/im/im_feed_group_item_test.go
  • shortcuts/im/im_feed_group_items.go
  • shortcuts/im/im_feed_group_list_item.go
  • shortcuts/im/im_feed_group_query_item.go
  • shortcuts/im/im_flag_cancel.go
  • shortcuts/im/im_flag_create.go
  • shortcuts/im/shortcuts.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-feed-groups.md
✅ Files skipped from review due to trivial changes (3)
  • shortcuts/im/im_flag_create.go
  • shortcuts/im/im_flag_cancel.go
  • skills/lark-im/references/lark-im-feed-groups.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-im/SKILL.md

Comment on lines +64 to +94
func newFGRuntime(t *testing.T, sc common.Shortcut, flags map[string]string, recorded *[]recordedFGRequest, responder fgResponder) *common.RuntimeContext {
t.Helper()
pageByPath := map[string]int{}
rt := shortcutRoundTripFunc(func(req *http.Request) (*http.Response, error) {
rec := recordedFGRequest{
method: req.Method,
path: req.URL.Path,
query: req.URL.Query(),
}
if req.Body != nil {
data, _ := io.ReadAll(req.Body)
if len(data) > 0 {
_ = json.Unmarshal(data, &rec.body)
}
}
if recorded != nil {
*recorded = append(*recorded, rec)
}
pageByPath[req.URL.Path]++
status, body := 200, interface{}(map[string]interface{}{"code": 0, "data": map[string]interface{}{}})
if responder != nil {
status, body = responder(req.URL.Path, pageByPath[req.URL.Path])
}
return shortcutJSONResponse(status, body), nil
})

runtime := newUserShortcutRuntime(t, rt)
runtime.Cmd = newFGCmd(t, sc, flags)
runtime.Format = "json"
return runtime
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify newUserShortcutRuntime and shortcutRoundTripFunc are defined and use correct pattern

echo "=== Searching for newUserShortcutRuntime definition ==="
rg -n "func newUserShortcutRuntime" --type=go shortcuts/im/

echo ""
echo "=== Searching for shortcutRoundTripFunc definition ==="
rg -n "func shortcutRoundTripFunc|type shortcutRoundTripFunc" --type=go shortcuts/im/

echo ""
echo "=== Checking if they use cmdutil.TestFactory ==="
rg -n -A10 "func new(User|Bot)ShortcutRuntime" --type=go shortcuts/im/ | rg -i "cmdutil.TestFactory|TestFactory"

Repository: larksuite/cli

Length of output: 460


Use cmdutil.TestFactory in HTTP-mocking test runtimes
shortcuts/im/im_feed_group_item_test.go’s newFGRuntime calls newUserShortcutRuntime/shortcutRoundTripFunc from shortcuts/im/helpers_network_test.go, but those runtime helper constructors don’t use cmdutil.TestFactory(t, config) for unit tests that exercise Execute with mocked HTTP. Update the helpers to construct the runtime via cmdutil.TestFactory.

🤖 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 `@shortcuts/im/im_feed_group_item_test.go` around lines 64 - 94, The test
runtime is constructed without using cmdutil.TestFactory, so update the helper
to build the runtime via cmdutil.TestFactory(t, config) (or the equivalent
TestFactory constructor) instead of whatever newUserShortcutRuntime currently
returns; locate newFGRuntime and the helper functions
newUserShortcutRuntime/shortcutRoundTripFunc and change the runtime creation to
call cmdutil.TestFactory with the appropriate test config, then set runtime.Cmd
(newFGCmd) and runtime.Format = "json" as before so Execute still uses the
mocked HTTP transport.

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

Labels

domain/im PR touches the im domain 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