feat(im): add UAT support for +messages-send and +messages-reply#180
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdded RuntimeContext.DoAPIAsBot to send SDK requests as a bot; switched IM media uploads to use that bot-only path; expanded IM message shortcuts to allow both user and bot identities and updated docs to describe identity selection and upload behavior. Changes
Sequence DiagramsequenceDiagram
participant IM as IMUploadFunc
participant RC as RuntimeContext
participant AC as APIClient
participant SDK as LarkSDK
IM->>RC: uploadImageToIM / uploadFileToIM(req)
RC->>RC: DoAPIAsBot(req, opts...)
RC->>AC: get or reuse API client
RC->>RC: apply ShortcutHeaderOpts(ctx.ctx) if present
RC->>AC: DoSDKRequest(ctx.ctx, req, core.AsBot, opts...)
AC->>SDK: execute HTTP request as bot
SDK-->>AC: ApiResp
AC-->>RC: ApiResp
RC-->>IM: return result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
skills/lark-im/references/lark-im-messages-send.md (1)
5-22:⚠️ Potential issue | 🟡 MinorUpdate stale
--asparameter description to include user mode.Line 163 still says
botonly, which conflicts with the new behavior documented elsewhere in this file (Line 5, Line 21, Line 221).✏️ Suggested doc fix
-| `--as <identity>` | No | Identity type: `bot` only | +| `--as <identity>` | No | Identity type: `bot` or `user` |Also applies to: 163-163, 214-223
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/lark-im/references/lark-im-messages-send.md` around lines 5 - 22, Update the stale description for the `--as` parameter to reflect both supported identities (user and bot): locate the `--as` flag references (e.g., the parameter description that currently mentions only `bot`) and change the text to explain the two modes (`--as bot` and `--as user`), note the permission/requirement differences (app must be in the chat for bot; `im:message.send_as_user` scope for user), and ensure the three places that still say `bot` only are updated to match the top-of-file behavior and examples.skills/lark-im/references/lark-im-messages-reply.md (1)
5-22:⚠️ Potential issue | 🟡 MinorFix stale
--asparameter doc (bot-only is no longer true).Line 157 conflicts with the updated user/bot identity support described in Line 5 and Line 221.
✏️ Suggested doc fix
-| `--as <identity>` | No | Identity type: `bot` only | +| `--as <identity>` | No | Identity type: `bot` or `user` |Also applies to: 157-157, 214-222
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/lark-im/references/lark-im-messages-reply.md` around lines 5 - 22, The docs contain a stale statement claiming the `--as` parameter is bot-only; update all occurrences of `--as` usage to reflect that it supports both `user` and `bot` identities (remove or reword the "bot-only" assertion), and reconcile the contradictory lines so the intro ("Reply to a specific message") and the identity section both state the same behavior; specifically search for the `--as` token and the identity description blocks and change wording to explain both `--as user` and `--as bot` usage and any scope/app-install requirements consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/im/im_messages_reply.go`:
- Around line 23-25: The change reversed the default identity by setting
AuthTypes so that AuthTypes[0] is "user", which makes the --as flag default to
user; restore the original order so the bot remains the default by ensuring the
AuthTypes slice in the +messages-reply shortcut lists "bot" first (e.g.,
AuthTypes: []string{"bot", "user"}), leaving UserScopes and BotScopes unchanged;
this preserves registerShortcutFlags' behavior (which uses AuthTypes[0] as the
--as default) and avoids breaking existing bot-default workflows.
---
Outside diff comments:
In `@skills/lark-im/references/lark-im-messages-reply.md`:
- Around line 5-22: The docs contain a stale statement claiming the `--as`
parameter is bot-only; update all occurrences of `--as` usage to reflect that it
supports both `user` and `bot` identities (remove or reword the "bot-only"
assertion), and reconcile the contradictory lines so the intro ("Reply to a
specific message") and the identity section both state the same behavior;
specifically search for the `--as` token and the identity description blocks and
change wording to explain both `--as user` and `--as bot` usage and any
scope/app-install requirements consistently.
In `@skills/lark-im/references/lark-im-messages-send.md`:
- Around line 5-22: Update the stale description for the `--as` parameter to
reflect both supported identities (user and bot): locate the `--as` flag
references (e.g., the parameter description that currently mentions only `bot`)
and change the text to explain the two modes (`--as bot` and `--as user`), note
the permission/requirement differences (app must be in the chat for bot;
`im:message.send_as_user` scope for user), and ensure the three places that
still say `bot` only are updated to match the top-of-file behavior and examples.
🪄 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: 7a074dd5-8d1f-4e7c-816c-088f4d66dc57
📒 Files selected for processing (7)
shortcuts/common/runner.goshortcuts/im/helpers.goshortcuts/im/im_messages_reply.goshortcuts/im/im_messages_send.goskills/lark-im/SKILL.mdskills/lark-im/references/lark-im-messages-reply.mdskills/lark-im/references/lark-im-messages-send.md
Greptile SummaryThis PR adds
Confidence Score: 5/5Safe to merge; only finding is a cosmetic dead-code field that has no runtime impact. All P0/P1 concerns are absent. The shortcuts/im/im_messages_send.go and shortcuts/im/im_messages_reply.go — minor dead-code cleanup only. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI
participant UploadAPI as Lark Upload API (bot-only)
participant MsgAPI as Lark Messages API (user or bot)
User->>CLI: lark-cli im +messages-send --as user --image ./photo.png
CLI->>CLI: resolveShortcutIdentity() → user
CLI->>CLI: checkShortcutScopes(UserScopes: im:message.send_as_user)
alt Local file path provided
CLI->>UploadAPI: DoAPIAsBot() POST /im/v1/images [TAT — always bot]
UploadAPI-->>CLI: image_key
end
CLI->>MsgAPI: DoAPIJSON() POST /im/v1/messages [UAT — resolved --as identity]
MsgAPI-->>CLI: message_id, chat_id
CLI-->>User: Output result
Reviews (7): Last reviewed commit: "feat: support im message send/reply with..." | Re-trigger Greptile |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
skills/lark-im/references/lark-im-messages-send.md (1)
5-22:⚠️ Potential issue | 🟡 MinorFix stale
--asparameter description to avoid contradiction.The updated sections say user/bot are supported, but Line 163 still says
botonly.📝 Proposed doc fix
-| `--as <identity>` | No | Identity type: `bot` only | +| `--as <identity>` | No | Identity type: `user` or `bot` |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/lark-im/references/lark-im-messages-send.md` around lines 5 - 22, The docs currently contradict themselves by saying the --as parameter is "bot" only while earlier and elsewhere it states both user and bot are supported; update the stale description that mentions "bot" only to reflect that --as supports both "user" and "bot", adjust any example or explanatory text that restricts it to bot (search for the literal "--as bot" phrase and the sentence claiming bot-only), and ensure the safety constraints and the note about required scopes reference both identities (including the im:message:send_as_user scope for --as user) so the documentation is consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@skills/lark-im/references/lark-im-messages-send.md`:
- Around line 5-22: The docs currently contradict themselves by saying the --as
parameter is "bot" only while earlier and elsewhere it states both user and bot
are supported; update the stale description that mentions "bot" only to reflect
that --as supports both "user" and "bot", adjust any example or explanatory text
that restricts it to bot (search for the literal "--as bot" phrase and the
sentence claiming bot-only), and ensure the safety constraints and the note
about required scopes reference both identities (including the
im:message:send_as_user scope for --as user) so the documentation is consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a7e3b706-9125-4e03-bce5-edb9515a4a10
📒 Files selected for processing (4)
shortcuts/im/im_messages_reply.goshortcuts/im/im_messages_send.goskills/lark-im/references/lark-im-messages-reply.mdskills/lark-im/references/lark-im-messages-send.md
🚧 Files skipped from review as they are similar to previous changes (2)
- shortcuts/im/im_messages_reply.go
- skills/lark-im/references/lark-im-messages-reply.md
b3fac2e to
709fa93
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
skills/lark-im/references/lark-im-messages-send.md (1)
163-163:⚠️ Potential issue | 🟡 MinorDocumentation inconsistency:
--asparameter description says "bot only" but user is now supported.Line 163 states
Identity type: bot only, which contradicts the rest of this document (lines 5, 15, 21-22, 221-222) and the code changes inim_messages_send.gowhereAuthTypes: []string{"bot", "user"}enables both identities.📝 Proposed fix
-| `--as <identity>` | No | Identity type: `bot` only | +| `--as <identity>` | No | Identity type: `bot` (default) or `user` |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/lark-im/references/lark-im-messages-send.md` at line 163, The documentation for the `--as` parameter is incorrect: it currently says "Identity type: `bot` only" but the implementation in im_messages_send.go sets AuthTypes: []string{"bot", "user"}; update the `--as <identity>` row to reflect both supported identities (e.g., "Identity type: `bot` or `user`") and scan this markdown for other mentions (lines referenced in the comment) to make consistent wording and examples that show both `--as bot` and `--as user` where applicable.
🧹 Nitpick comments (2)
shortcuts/im/im_messages_send.go (1)
23-25: Consider removing redundantScopesfield.With both
UserScopesandBotScopesnow defined, theScopesfield on line 23 is never used byScopesForIdentity()since it only falls back toScopeswhen the identity-specific slice is empty. Keeping it is harmless but adds slight noise.♻️ Optional cleanup
Risk: "write", - Scopes: []string{"im:message:send_as_bot"}, UserScopes: []string{"im:message:send_as_user"}, BotScopes: []string{"im:message:send_as_bot"},🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/im/im_messages_send.go` around lines 23 - 25, The struct currently defines Scopes along with UserScopes and BotScopes, but ScopesForIdentity() only uses Scopes as a fallback when the identity-specific slice is empty, and since UserScopes and BotScopes are populated the Scopes field is redundant; remove the Scopes field from the struct (and any references to it) to reduce noise—update the definition that contains Scopes, UserScopes, BotScopes (and any constructor or literal where Scopes is set) so only UserScopes and BotScopes remain, and run tests to ensure ScopesForIdentity() behavior is unchanged.shortcuts/im/im_messages_reply.go (1)
22-24: Same optional cleanup opportunity asim_messages_send.go.The
Scopesfield on line 22 is redundant now that bothUserScopesandBotScopesare defined.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/im/im_messages_reply.go` around lines 22 - 24, The Scopes field is redundant because UserScopes and BotScopes are now explicitly provided; remove the Scopes entry (the "Scopes" key) from the shortcut definition so only UserScopes and BotScopes remain, updating the initializer where Scopes, UserScopes, and BotScopes are defined (referencing the Scopes, UserScopes, and BotScopes symbols in im_messages_reply.go) to avoid duplicated/unused configuration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@skills/lark-im/references/lark-im-messages-send.md`:
- Line 163: The documentation for the `--as` parameter is incorrect: it
currently says "Identity type: `bot` only" but the implementation in
im_messages_send.go sets AuthTypes: []string{"bot", "user"}; update the `--as
<identity>` row to reflect both supported identities (e.g., "Identity type:
`bot` or `user`") and scan this markdown for other mentions (lines referenced in
the comment) to make consistent wording and examples that show both `--as bot`
and `--as user` where applicable.
---
Nitpick comments:
In `@shortcuts/im/im_messages_reply.go`:
- Around line 22-24: The Scopes field is redundant because UserScopes and
BotScopes are now explicitly provided; remove the Scopes entry (the "Scopes"
key) from the shortcut definition so only UserScopes and BotScopes remain,
updating the initializer where Scopes, UserScopes, and BotScopes are defined
(referencing the Scopes, UserScopes, and BotScopes symbols in
im_messages_reply.go) to avoid duplicated/unused configuration.
In `@shortcuts/im/im_messages_send.go`:
- Around line 23-25: The struct currently defines Scopes along with UserScopes
and BotScopes, but ScopesForIdentity() only uses Scopes as a fallback when the
identity-specific slice is empty, and since UserScopes and BotScopes are
populated the Scopes field is redundant; remove the Scopes field from the struct
(and any references to it) to reduce noise—update the definition that contains
Scopes, UserScopes, BotScopes (and any constructor or literal where Scopes is
set) so only UserScopes and BotScopes remain, and run tests to ensure
ScopesForIdentity() behavior is unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 79855ca9-21c8-439b-9a59-102c459aa700
📒 Files selected for processing (7)
shortcuts/common/runner.goshortcuts/im/helpers.goshortcuts/im/im_messages_reply.goshortcuts/im/im_messages_send.goskills/lark-im/SKILL.mdskills/lark-im/references/lark-im-messages-reply.mdskills/lark-im/references/lark-im-messages-send.md
✅ Files skipped from review due to trivial changes (3)
- shortcuts/im/helpers.go
- shortcuts/common/runner.go
- skills/lark-im/references/lark-im-messages-reply.md
🚧 Files skipped from review as they are similar to previous changes (1)
- skills/lark-im/SKILL.md
709fa93 to
ce77c6e
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
skills/lark-im/references/lark-im-messages-send.md (1)
149-164:⚠️ Potential issue | 🟡 MinorUpdate stale
--asparameter description.Line 163 still says
botonly, which conflicts with the updated dual-identity behavior documented elsewhere (e.g., Line 5 and Line 221).📝 Proposed doc fix
-| `--as <identity>` | No | Identity type: `bot` only | +| `--as <identity>` | No | Identity type: `bot` or `user` (default follows shortcut auth/default-as resolution) |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/lark-im/references/lark-im-messages-send.md` around lines 149 - 164, The `--as <identity>` parameter description is stale (currently "bot only"); update the docs entry for `--as <identity>` to reflect dual-identity behavior by allowing both identities (e.g., "bot" and "user") or the exact identity tokens used elsewhere in the doc, and ensure the wording matches other sections that describe dual-identity behavior (so `--as <identity>` lists both supported values and any constraints).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@skills/lark-im/references/lark-im-messages-send.md`:
- Around line 149-164: The `--as <identity>` parameter description is stale
(currently "bot only"); update the docs entry for `--as <identity>` to reflect
dual-identity behavior by allowing both identities (e.g., "bot" and "user") or
the exact identity tokens used elsewhere in the doc, and ensure the wording
matches other sections that describe dual-identity behavior (so `--as
<identity>` lists both supported values and any constraints).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f7153530-aa7b-4b41-8efd-9767ad7fa808
📒 Files selected for processing (7)
shortcuts/common/runner.goshortcuts/im/helpers.goshortcuts/im/im_messages_reply.goshortcuts/im/im_messages_send.goskills/lark-im/SKILL.mdskills/lark-im/references/lark-im-messages-reply.mdskills/lark-im/references/lark-im-messages-send.md
🚧 Files skipped from review as they are similar to previous changes (5)
- shortcuts/im/helpers.go
- skills/lark-im/SKILL.md
- shortcuts/im/im_messages_send.go
- shortcuts/im/im_messages_reply.go
- skills/lark-im/references/lark-im-messages-reply.md
2ffd799 to
37c2f5d
Compare
- Add --as user support to +messages-send and +messages-reply - Add UserScopes (im:message.send_as_user) / BotScopes (im:message:send_as_bot) - Add DoAPIAsBot to RuntimeContext so file/image uploads always use bot identity even when the surrounding command runs as user - Update skill docs and reference files to reflect user/bot support - Default identity remains bot (first element of AuthTypes)
37c2f5d to
1706d1c
Compare
- Add --as user support to +messages-send and +messages-reply - Add UserScopes (im:message.send_as_user) / BotScopes (im:message:send_as_bot) - Add DoAPIAsBot to RuntimeContext so file/image uploads always use bot identity even when the surrounding command runs as user - Update skill docs and reference files to reflect user/bot support - Default identity remains bot (first element of AuthTypes)
Summary
Add user identity (
--as user) support toim +messages-sendandim +messages-reply. Previously both shortcuts were bot-only. With this change, messages can be sent as the authorized end user using a user access token (UAT).Changes
--as usersupport to+messages-sendand+messages-reply; default identity remainsbotUserScopes: im:message.send_as_userandBotScopes: im:message:send_as_botto both shortcutsDoAPIAsBottoRuntimeContextso file/image uploads always use bot identity (upload APIs are bot-only) even when the surrounding command runs as userTest Plan
+messages-send --as user --textsends message with user identity (identity: userin response)+messages-send --as user --imageuploads image with bot identity, sends message with user identity+messages-send --as botcontinues to work as beforeauth login --domain imcorrectly includesim:message.send_as_userscope without errorim:message.send_as_useris not authorizedRelated Issues
Summary by CodeRabbit
New Features
im +messages-send,im +messages-reply) now support both user and bot identities instead of bot-only--as useroptionDocumentation