Skip to content

fix(im): add im:message scope for user identity send/reply#237

Merged
MaxHuang22 merged 1 commit intolarksuite:mainfrom
sammi-bytedance:fix/send_msg_scope
Apr 2, 2026
Merged

fix(im): add im:message scope for user identity send/reply#237
MaxHuang22 merged 1 commit intolarksuite:mainfrom
sammi-bytedance:fix/send_msg_scope

Conversation

@sammi-bytedance
Copy link
Copy Markdown
Contributor

@sammi-bytedance sammi-bytedance commented Apr 2, 2026

Summary

  • Add im:message as a required scope for user identity (--as user) in +messages-send and +messages-reply shortcuts
  • Update skill reference docs to document both im:message.send_as_user and im:message scopes for user identity

Changes

  • shortcuts/im/im_messages_send.go: add im:message to UserScopes
  • shortcuts/im/im_messages_reply.go: add im:message to UserScopes
  • skills/lark-im/references/lark-im-messages-send.md: document im:message requirement for --as user
  • skills/lark-im/references/lark-im-messages-reply.md: document im:message requirement for --as user

Test Plan

  • Run lark-cli im +messages-send --user-id <ou_xxx> --text "test" --as user and verify the scope prompt includes im:message
  • Run lark-cli im +messages-reply --message-id <om_xxx> --text "test" --as user and verify the scope prompt includes im:message

🤖 Generated with Claude Code

Change-Id: I99be906896da9ebe9d5951d14f3e7da0bcd2b3ad
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact labels Apr 2, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 2, 2026

Greptile Summary

This PR adds the im:message scope to UserScopes for both +messages-send and +messages-reply shortcuts, fixing an incomplete scope list for user-identity (--as user) operations. The corresponding reference documentation is updated in both places where scope requirements are described. The changes are minimal, consistent, and aligned with how ScopesForIdentity selects scopes at runtime.

Key changes:

  • shortcuts/im/im_messages_send.go and shortcuts/im/im_messages_reply.go: UserScopes now includes both im:message.send_as_user and im:message
  • skills/lark-im/references/lark-im-messages-send.md and skills/lark-im/references/lark-im-messages-reply.md: both the description paragraph and the notes/caveats bullet are updated to document both required scopes

Observations:

  • im:message.send_as_user is listed in the recommend.deny section of scope_overrides.json (it won't be auto-recommended), while the newly added im:message is not — this difference in treatment is worth confirming is intentional, since both are now required together for user-identity sends.
  • No tests were added to assert the new scope list for these two shortcuts; given the project's scope handling is covered by general ScopesForIdentity unit tests, this is low risk but worth noting.

Confidence Score: 4/5

Safe to merge — the change is a targeted, low-risk scope addition with matching documentation updates.

All four changed files are consistent with each other and with the rest of the codebase's scope patterns. The only open question is whether im:message should be added to the recommend.deny list alongside im:message.send_as_user, which is a minor style/consistency concern that does not affect runtime correctness.

No files require special attention; the optional follow-up is in internal/registry/scope_overrides.json (not changed by this PR).

Important Files Changed

Filename Overview
shortcuts/im/im_messages_send.go Adds "im:message" to UserScopes alongside "im:message.send_as_user"; change is consistent and correct
shortcuts/im/im_messages_reply.go Mirrors the same UserScopes fix as im_messages_send.go; consistent change
skills/lark-im/references/lark-im-messages-send.md Documentation updated in both the intro paragraph and the notes bullet to reflect both required user scopes
skills/lark-im/references/lark-im-messages-reply.md Documentation updated identically to the send reference; consistent with code change

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as lark-cli
    participant Runner as Runner (ScopesForIdentity)
    participant API as Lark API

    User->>CLI: im +messages-send --as user ...
    CLI->>Runner: identity = "user"
    Runner-->>CLI: UserScopes: ["im:message.send_as_user", "im:message"]
    CLI->>User: Prompt: authorize im:message.send_as_user + im:message
    User-->>CLI: Authorized
    CLI->>API: POST /open-apis/im/v1/messages (UAT)
    API-->>CLI: 200 OK (message_id, chat_id)
    CLI-->>User: Output result

    Note over CLI,Runner: Before fix: only im:message.send_as_user was in UserScopes
    Note over CLI,Runner: After fix: im:message also required (matches Lark API requirement)
Loading

Reviews (1): Last reviewed commit: "fix(im): add im:message scope for user i..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@449ab57a464b104c3db27d9f125a5250d7a4fd23

🧩 Skill update

npx skills add sammi-bytedance/larksuite-cli#fix/send_msg_scope -y -g

@MaxHuang22 MaxHuang22 merged commit 56ed529 into larksuite:main Apr 2, 2026
13 checks passed
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/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants