Skip to content

feat: support user identity for im +chat-create#242

Merged
YangJunzhou-01 merged 1 commit intolarksuite:mainfrom
shifengjuan-dev:feat/support_uat_for_create_chat
Apr 3, 2026
Merged

feat: support user identity for im +chat-create#242
YangJunzhou-01 merged 1 commit intolarksuite:mainfrom
shifengjuan-dev:feat/support_uat_for_create_chat

Conversation

@shifengjuan-dev
Copy link
Copy Markdown
Contributor

@shifengjuan-dev shifengjuan-dev commented Apr 3, 2026

  • Add --as user support to +chat-create
  • Add UserScopes (im:chat:create_by_user) / BotScopes (im:chat:create)
  • Update skill docs and reference files to reflect user/bot support
  • Default identity remains bot (first element of AuthTypes)

Change-Id: I6be0a160567a0d87a92f176ae12297a11d06dcb1

Summary

Allow im +chat-create to run with user identity (UAT), so logged-in users can create group chats as themselves instead of always going through bot identity.

Changes

  • Add --as user support to +chat-create
  • Add "user" to AuthTypes in im_chat_create.go
  • Add UserScopes: ["im:chat:create_by_user"] and BotScopes: ["im:chat:create"] to distinguish per-identity scopes
  • Update SKILL.md and reference doc to reflect user/bot support
  • Default identity remains bot (first element of AuthTypes)

Test Plan

  • Unit tests pass
  • Manual: lark-cli im +chat-create --name "test" --as user creates group with user identity
  • Manual: lark-cli im +chat-create --name "test" --as bot still works as before
  • Manual: auto-detect picks user when logged in, bot when not logged in

Summary by CodeRabbit

  • New Features

    • Chat creation now supports both user and bot identities (was bot-only).
    • New option to choose creation identity; identity may be inferred when not specified.
    • Identity-specific permission scopes added; set-bot-manager is valid and effective only when using bot identity, and is rejected for user identity.
  • Documentation

    • Guides updated with separate bot/user workflows, examples, owner behavior, and permission troubleshooting.

@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 3, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Im +chat-create shortcut and related docs updated to support both bot and user identities: shortcut metadata changed (description, AuthTypes, replaced Scopes with UserScopes/BotScopes), --set-bot-manager flagged as bot-only with runtime validation, and documentation expanded with identity-specific guidance and troubleshooting.

Changes

Cohort / File(s) Summary
Shortcut Metadata
shortcuts/im/im_chat_create.go
Make ImChatCreate identity-aware: description updated to "user/bot"; Scopes removed; added UserScopes: ["im:chat:create_by_user"] and BotScopes: ["im:chat:create"]; AuthTypes expanded to ["bot","user"]; clarify --set-bot-manager flag; add validation error if --set-bot-manager used while runtime is not bot; conditional inclusion of set_bot_manager in requests adjusted for dry-run vs execute.
Documentation: skill index
skills/lark-im/SKILL.md
Update +chat-create summary to indicate dual identity support (user/bot).
Documentation: chat-create reference
skills/lark-im/references/lark-im-chat-create.md
Add --as <identity> (bot/user) guidance, list identity-specific scopes, clarify how --owner/--set-bot-manager behave per identity, and provide separate usage flows and permission troubleshooting.
Documentation: identity guidance
skills/lark-im/references/lark-im-chat-identity.md
When identity is omitted, recommendation now says to infer identity from context instead of defaulting to bot; minor wording tweak.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CLI as CLI (+flags)
  participant Runtime as Runtime/Auth
  participant API as IM API

  CLI->>Runtime: parse flags (`--as`, `--set-bot-manager`, `--dry-run`)
  Runtime-->>CLI: resolve identity (bot or user)
  CLI->>Runtime: validate flags (if `--set-bot-manager` require bot)
  alt validation fails
    Runtime-->>CLI: return validation error ("--set-bot-manager is only supported with bot identity")
  else validation passes
    CLI->>API: POST /im/chat.create (use identity token, include appropriate scope and set_bot_manager only when bot)
    API-->>CLI: creation response or dry-run result
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • YangJunzhou-01
  • MaxHuang22

Poem

🐰 A hop, a nibble, a cheerful wink,
Bot and user both now share the link.
Flags aligned and scopes in play,
Chats are born in either way. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding user identity support to the im +chat-create command.
Description check ✅ Passed The PR description includes all required template sections (Summary, Changes, Test Plan) with comprehensive details about the implementation and verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 3, 2026

Greptile Summary

This PR adds --as user (UAT) support to im +chat-create, splitting scopes into UserScopes/BotScopes, adding a Validate guard for --set-bot-manager under user identity, and updating the reference docs and skill table accordingly. The implementation is sound; the only remaining inconsistency is that Execute omits the runtime.IsBot() guard around set_bot_manager that DryRun correctly applies (safe today because Validate blocks the invalid path, but fragile on future refactors).

Confidence Score: 5/5

Safe to merge; the single remaining finding is a P2 defensive-code suggestion that does not affect current behavior.

All prior review concerns (stale Scopes field, incomplete --query placeholder) are resolved. The only open finding is a minor inconsistency between DryRun and Execute that is fully guarded by validation, warranting no score reduction below 5.

shortcuts/im/im_chat_create.go — Execute function's set_bot_manager guard is inconsistent with DryRun

Important Files Changed

Filename Overview
shortcuts/im/im_chat_create.go Adds user identity support: AuthTypes now ["bot","user"], splits scopes into UserScopes/BotScopes, adds Validate guard for --set-bot-manager. DryRun correctly gates set_bot_manager on IsBot() but Execute does not.
shortcuts/common/testing.go Adds TestNewRuntimeContextWithIdentity helper to set resolvedAs field for tests — clean and correctly scoped to the testing package.
shortcuts/im/builders_test.go Refactors ImChatCreate dry-run test to use TestNewRuntimeContextWithIdentity with explicit "bot" identity; test now accurately exercises the IsBot() guard in DryRun.
skills/lark-im/references/lark-im-chat-create.md Rewrites reference doc with per-identity sections, scope requirements, updated AI guidance, and new user-identity examples; reasonably complete.
skills/lark-im/SKILL.md Updates shortcut description table entry to reflect user/bot support — trivial doc-only change.
skills/lark-im/references/lark-im-chat-identity.md Minor wording update to the identity recommendation table — no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[lark-cli im +chat-create] --> B{--as flag}
    B -->|bot / default| C[BotScopes: im:chat:create]
    B -->|user| D[UserScopes: im:chat:create_by_user]
    C --> E{Validate}
    D --> E
    E -->|--set-bot-manager + user| F[ErrValidation]
    E -->|pass| G[Execute]
    G --> H[POST /open-apis/im/v1/chats]
    H --> I{set_bot_manager?}
    I -->|Bool flag true| J[qp: set_bot_manager=true]
    I -->|false| K[omit param]
    J --> L[API Response]
    K --> L
Loading

Reviews (8): Last reviewed commit: "feat: support user identity for im +chat..." | Re-trigger Greptile

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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/lark-im/references/lark-im-chat-create.md`:
- Line 55: Update the documentation entry for the `--as <identity>` flag in
skills/lark-im/references/lark-im-chat-create.md to stop stating "default
`bot`"; instead indicate the identity is auto-detected (e.g., "auto-detected:
`user` when logged in, otherwise `bot`") where the table currently lists `bot`
as the default (the table cell containing "`--as <identity>` | No | `bot` or
`user` | Identity type (default `bot`)"). Make the same replacement for the
other occurrence of the default wording elsewhere in the file so both mentions
reflect the auto-detect behavior.
- Line 64: The example command "contact +search-user --query" is incomplete;
update the sentence to include a placeholder query value and a brief example so
users can run it directly—for example, show using an email or name as the query
(e.g., alice@example.com or "Alice Smith") and mention this returns the user's
open_id; edit the line containing contact +search-user --query to include that
placeholder and a short note about extracting open_id from the command output.

In `@skills/lark-im/SKILL.md`:
- Line 59: The two identity docs are inconsistent: update the section
referencing `chats.create` to match the `+chat-create` row (or vice versa) so
both state the same caller support (either "user/bot" or "bot-only"); locate the
table row for `+chat-create` and the descriptive paragraph that mentions
`chats.create` and make their wording identical about caller support and the
ability to create private/public chats and invite users/bots.
🪄 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: 24498786-2806-4318-bfd7-364e12966645

📥 Commits

Reviewing files that changed from the base of the PR and between 51a6ada and f4e939a.

📒 Files selected for processing (3)
  • shortcuts/im/im_chat_create.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-chat-create.md

@shifengjuan-dev shifengjuan-dev changed the title feat: support im chat create with uat feat: support user identity for im +chat-create Apr 3, 2026
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.

🧹 Nitpick comments (1)
shortcuts/im/im_chat_create.go (1)

35-35: Clarify --set-bot-manager behavior when using --as user identity.

The flag description ("set the bot that creates this chat as manager") assumes bot identity. The documentation lacks clarity on whether this flag works with --as user, where a user (not a bot) is creating the chat. The code currently passes this parameter to the API unconditionally without validation or identity-aware logic.

Update the flag description or documentation to clarify behavior per identity, or add validation to warn/prevent use with user identity if the API doesn't support it in that context.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/im/im_chat_create.go` at line 35, The flag description for
"set-bot-manager" is ambiguous when the CLI is invoked with the "--as user"
identity: update either the flag text in shortcuts/im/im_chat_create.go (the
Name "set-bot-manager" flag) to explicitly state it only applies when creating
the chat as a bot, or add identity-aware validation where the flag is
parsed—detect the "--as" identity (user vs bot) and if "--as user" is used,
either reject the flag with a clear error/warning or ignore it and log a warning
before passing parameters to the API; ensure the change references the
"set-bot-manager" flag and the "--as" identity handling code path so behavior is
explicit and consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@shortcuts/im/im_chat_create.go`:
- Line 35: The flag description for "set-bot-manager" is ambiguous when the CLI
is invoked with the "--as user" identity: update either the flag text in
shortcuts/im/im_chat_create.go (the Name "set-bot-manager" flag) to explicitly
state it only applies when creating the chat as a bot, or add identity-aware
validation where the flag is parsed—detect the "--as" identity (user vs bot) and
if "--as user" is used, either reject the flag with a clear error/warning or
ignore it and log a warning before passing parameters to the API; ensure the
change references the "set-bot-manager" flag and the "--as" identity handling
code path so behavior is explicit and consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 75f7ba08-856e-459c-88c0-83496871b5f8

📥 Commits

Reviewing files that changed from the base of the PR and between f4e939a and fdbf254.

📒 Files selected for processing (2)
  • shortcuts/im/im_chat_create.go
  • skills/lark-im/references/lark-im-chat-create.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-im/references/lark-im-chat-create.md

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.

🧹 Nitpick comments (2)
skills/lark-im/references/lark-im-chat-create.md (1)

33-34: Consider adding --as bot to the --set-bot-manager example for clarity.

The example works because bot is the implicit default identity, but since line 59 explicitly states --set-bot-manager is "only effective with --as bot," adding the flag would make the example self-documenting and avoid confusion.

📝 Suggested doc fix
 # Make the creating bot a group manager
-lark-cli im +chat-create --name "My Group" --set-bot-manager
+lark-cli im +chat-create --name "My Group" --set-bot-manager --as 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-chat-create.md` around lines 33 - 34,
Update the example command that makes the creating bot a group manager so it
explicitly includes the identity flag by changing the invocation of the command
shown as lark-cli im +chat-create --name "My Group" --set-bot-manager to include
--as bot; locate the example in lark-im-chat-create.md (the line containing that
command) and add the --as bot flag to the command so the sample is
self-documenting and matches the note that --set-bot-manager is only effective
with --as bot.
shortcuts/im/im_chat_create.go (1)

37-51: Consider adding identity validation to DryRun for consistency.

The Validate function correctly rejects --set-bot-manager when using user identity. However, DryRun (lines 37-47) will still render the request with set_bot_manager=true even when --as user is specified, which could confuse users into thinking the combination is valid.

If DryRun is intended to show "what would be sent regardless of validity," this is fine. Otherwise, consider adding the same check in DryRun or documenting that --dry-run bypasses validation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/im/im_chat_create.go` around lines 37 - 51, DryRun currently always
sets params["set_bot_manager"]=true when runtime.Bool("set-bot-manager") is
true, which can mislead users when identity is not a bot; update the DryRun
function (the DryRun closure) to mirror the Validate logic by checking
runtime.Bool("set-bot-manager") && runtime.IsBot() and only add
params["set_bot_manager"]=true when runtime.IsBot() is true (otherwise omit the
key), using the same runtime.Bool("set-bot-manager") and runtime.IsBot() checks
that Validate uses to keep DryRun consistent with validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@shortcuts/im/im_chat_create.go`:
- Around line 37-51: DryRun currently always sets params["set_bot_manager"]=true
when runtime.Bool("set-bot-manager") is true, which can mislead users when
identity is not a bot; update the DryRun function (the DryRun closure) to mirror
the Validate logic by checking runtime.Bool("set-bot-manager") &&
runtime.IsBot() and only add params["set_bot_manager"]=true when runtime.IsBot()
is true (otherwise omit the key), using the same runtime.Bool("set-bot-manager")
and runtime.IsBot() checks that Validate uses to keep DryRun consistent with
validation.

In `@skills/lark-im/references/lark-im-chat-create.md`:
- Around line 33-34: Update the example command that makes the creating bot a
group manager so it explicitly includes the identity flag by changing the
invocation of the command shown as lark-cli im +chat-create --name "My Group"
--set-bot-manager to include --as bot; locate the example in
lark-im-chat-create.md (the line containing that command) and add the --as bot
flag to the command so the sample is self-documenting and matches the note that
--set-bot-manager is only effective with --as bot.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ad75b72-3eb6-4098-82db-557e28764bb1

📥 Commits

Reviewing files that changed from the base of the PR and between fdbf254 and e598851.

📒 Files selected for processing (3)
  • shortcuts/im/im_chat_create.go
  • skills/lark-im/references/lark-im-chat-create.md
  • skills/lark-im/references/lark-im-chat-identity.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-im/references/lark-im-chat-identity.md

@shifengjuan-dev shifengjuan-dev force-pushed the feat/support_uat_for_create_chat branch from e598851 to cf0bfab Compare April 3, 2026 06:35
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 3, 2026

CLA assistant check
All committers have signed the CLA.

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

♻️ Duplicate comments (1)
skills/lark-im/references/lark-im-chat-create.md (1)

61-61: ⚠️ Potential issue | 🟡 Minor

Document auto-detect behavior for --as parameter.

The PR objectives state "auto-detect picks user when logged in and bot when not," but the parameter table doesn't explain what happens when --as is omitted. Users need to understand the default resolution logic.

📝 Suggested documentation enhancement
-| `--as <identity>` | No | `bot` or `user` | Identity type |
+| `--as <identity>` | No | `bot` or `user` | Identity type (auto-detected if omitted: `user` when logged in, otherwise `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-chat-create.md` at line 61, Update the
`--as` parameter documentation to explicitly state the auto-detect behavior when
the flag is omitted: document that the CLI will auto-detect and use `user` when
a user is logged in and `bot` when not, and show the default resolution (e.g.,
"`--as` omitted → auto-detect: `user` if logged in, otherwise `bot`"); ensure
this text is added to the parameter table row for `--as` and optionally include
a short note or example near the `--as` description to clarify the default.
🧹 Nitpick comments (3)
skills/lark-im/references/lark-im-chat-create.md (3)

59-59: Strengthen --set-bot-manager restriction wording.

The phrase "only effective with" is weaker than the actual implementation, which validates and returns an error "--set-bot-manager is only supported with bot identity (--as bot)" when used with user identity. Consider using "only supported with" to match the validation behavior.

📝 Suggested wording improvement
-| `--set-bot-manager` | No | - | Set the creating bot as a group manager (only effective with `--as bot`) |
+| `--set-bot-manager` | No | - | Set the creating bot as a group manager (only supported with `--as 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-chat-create.md` at line 59, Update the
table row for the `--set-bot-manager` flag to match the runtime validation:
replace the phrase "only effective with `--as bot`" with "only supported with
bot identity (`--as bot`)" so the docs reflect the actual error message
`"--set-bot-manager is only supported with bot identity (--as bot)"`; ensure the
change is applied to the `--set-bot-manager` description in the file so wording
aligns with the validation logic.

57-57: Consider cross-referencing detailed owner inference logic.

The default owner behavior is correct, but users may benefit from a reference to the complete inference logic documented in lark-im-chat-identity.md (lines 20-35), which covers edge cases like when a bot creates with/without --owner specified.

📚 Suggested cross-reference
-| `--owner <open_id>` | No | Format `ou_xxx` | Owner open_id (defaults to the bot when using `--as bot`, or the authorized user when using `--as user`) |
+| `--owner <open_id>` | No | Format `ou_xxx` | Owner open_id (defaults to the bot when using `--as bot`, or the authorized user when using `--as user`; see [lark-im-chat-identity.md](lark-im-chat-identity.md) for detailed inference logic) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-im/references/lark-im-chat-create.md` at line 57, Update the
`--owner <open_id>` option description to include a short cross-reference to the
detailed owner inference logic in lark-im-chat-identity.md so readers can
inspect edge cases; explicitly mention that the default behavior (bot when `--as
bot`, authorized user when `--as user`) is summarized here and link or point to
lark-im-chat-identity.md for the full inference rules (see its owner inference
section).

68-92: Consider reducing duplication with cross-reference.

The two-step flow for error 232043 is documented both here and in lark-im-chat-identity.md (lines 38-45). This creates a maintenance burden—updates must be synchronized. Consider providing a brief summary here with a cross-reference to the detailed guidance in the identity document.

📚 Example cross-reference approach
-Bot cannot directly invite other users during group creation (error 232043). Use the **two-step flow** below. Do NOT pass other users' open_ids in `--users` during group creation.
+When a bot creates a group and includes users who are mutually invisible to the bot in `--users`, the request fails with error 232043. See [lark-im-chat-identity.md](lark-im-chat-identity.md#inviting-members-during-group-creation) for the detailed two-step flow. Brief summary:

 1. **Get the current user's open_id:** Run `lark-cli contact +search-user --query "<name or email>"` to retrieve it.

Then shorten or remove steps 2-4 in favor of the cross-reference.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-im/references/lark-im-chat-create.md` around lines 68 - 92,
Replace the full two-step flow for error 232043 with a concise summary and a
cross-reference to the canonical detailed guidance in lark-im-chat-identity.md:
keep a short note that bots cannot invite others during group creation (error
232043), that the workaround is a two-step flow (create group with the current
user's open_id using the lark-cli im +chat-create command, then add other
members via lark-cli im chat.members create as a user), and point readers to
lark-im-chat-identity.md for the exact commands and details (including using
succeed_type=1 and checking invalid_id_list); remove the duplicated step-by-step
commands here to avoid maintenance drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/lark-im/references/lark-im-chat-create.md`:
- Line 68: The sentence "Bot cannot directly invite other users during group
creation (error 232043)" is too absolute; change it to clarify scope by stating
that the restriction applies only when the bot and the users are not mutually
visible. Update the wording near the "two-step flow" guidance so it says bots
can invite users during creation if they are mutually visible, and otherwise
follow the two-step flow and do NOT pass other users' open_ids in `--users`;
keep the error code 232043 as the failure case when mutual visibility is not
present.

---

Duplicate comments:
In `@skills/lark-im/references/lark-im-chat-create.md`:
- Line 61: Update the `--as` parameter documentation to explicitly state the
auto-detect behavior when the flag is omitted: document that the CLI will
auto-detect and use `user` when a user is logged in and `bot` when not, and show
the default resolution (e.g., "`--as` omitted → auto-detect: `user` if logged
in, otherwise `bot`"); ensure this text is added to the parameter table row for
`--as` and optionally include a short note or example near the `--as`
description to clarify the default.

---

Nitpick comments:
In `@skills/lark-im/references/lark-im-chat-create.md`:
- Line 59: Update the table row for the `--set-bot-manager` flag to match the
runtime validation: replace the phrase "only effective with `--as bot`" with
"only supported with bot identity (`--as bot`)" so the docs reflect the actual
error message `"--set-bot-manager is only supported with bot identity (--as
bot)"`; ensure the change is applied to the `--set-bot-manager` description in
the file so wording aligns with the validation logic.
- Line 57: Update the `--owner <open_id>` option description to include a short
cross-reference to the detailed owner inference logic in
lark-im-chat-identity.md so readers can inspect edge cases; explicitly mention
that the default behavior (bot when `--as bot`, authorized user when `--as
user`) is summarized here and link or point to lark-im-chat-identity.md for the
full inference rules (see its owner inference section).
- Around line 68-92: Replace the full two-step flow for error 232043 with a
concise summary and a cross-reference to the canonical detailed guidance in
lark-im-chat-identity.md: keep a short note that bots cannot invite others
during group creation (error 232043), that the workaround is a two-step flow
(create group with the current user's open_id using the lark-cli im +chat-create
command, then add other members via lark-cli im chat.members create as a user),
and point readers to lark-im-chat-identity.md for the exact commands and details
(including using succeed_type=1 and checking invalid_id_list); remove the
duplicated step-by-step commands here to avoid maintenance drift.
🪄 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: 5c57e88c-55f2-4d21-8e4d-623d3be55acb

📥 Commits

Reviewing files that changed from the base of the PR and between e598851 and cf0bfab.

📒 Files selected for processing (4)
  • shortcuts/im/im_chat_create.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-chat-create.md
  • skills/lark-im/references/lark-im-chat-identity.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-im/references/lark-im-chat-identity.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • skills/lark-im/SKILL.md
  • shortcuts/im/im_chat_create.go

@shifengjuan-dev shifengjuan-dev force-pushed the feat/support_uat_for_create_chat branch 2 times, most recently from 694ae8d to d7153bc Compare April 3, 2026 07:21
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shortcuts/im/im_chat_create.go (1)

29-35: ⚠️ Potential issue | 🟡 Minor

Update the --owner help text for user mode.

Line 33 still says omission defaults to the bot, so lark-cli im +chat-create --help now contradicts the new --as user behavior.

📝 Suggested help-text fix
-		{Name: "owner", Desc: "owner open_id (ou_xxx); defaults to the bot if not specified"},
+		{Name: "owner", Desc: "owner open_id (ou_xxx); omit to use the API's default owner for the active identity"},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/im/im_chat_create.go` around lines 29 - 35, The help text for the
"--owner" flag (the entry with Name: "owner" in the flag definitions in
shortcuts/im/im_chat_create.go) is outdated; change its Desc from "owner open_id
(ou_xxx); defaults to the bot if not specified" to reflect the new --as behavior
(e.g. indicate it defaults to the current user when running with "--as user",
otherwise to the bot) so that lark-cli im +chat-create --help accurately
describes owner selection.
♻️ Duplicate comments (1)
skills/lark-im/references/lark-im-chat-create.md (1)

66-68: ⚠️ Potential issue | 🟠 Major

Qualify the bot invite restriction.

Line 68 is still too absolute. Bots can invite users during creation when those users are mutually visible; error 232043 is the mutually-invisible case. As written, this conflicts with the bot example above and pushes readers into the two-step flow unnecessarily.

📝 Suggested wording
-Bot cannot directly invite other users during group creation (error 232043). Use the **two-step flow** below. Do NOT pass other users' open_ids in `--users` during group creation.
+When a bot creates a group and includes users who are mutually invisible to the bot, the request fails with error 232043. Use the **two-step flow** below for that case. If the target users are visible to the bot, you can invite them directly during creation.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-im/references/lark-im-chat-create.md` around lines 66 - 68, The
sentence under the "When using `--as bot`" section is too absolute; update the
wording to qualify that bots cannot invite users during group creation only when
those users are mutually invisible (error 232043) and that bots can invite
mutually-visible users directly, so avoid telling readers to always use the
two-step flow or to never pass other users' open_ids in `--users`; instead
mention the mutually-visible exception, cite error 232043, and keep the guidance
about the two-step flow for the mutually-invisible case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/lark-im/references/lark-im-chat-create.md`:
- Around line 57-59: Update the docs for the `--set-bot-manager` flag in
lark-im-chat-create.md to reflect runtime validation: change the note "only
effective with `--as bot`" to "only supported with `--as bot`" (or add a brief
note that the CLI will reject the flag when used with `--as user`), so the table
entry for `--set-bot-manager` accurately matches the behavior when using `--as
bot` vs `--as user`.

---

Outside diff comments:
In `@shortcuts/im/im_chat_create.go`:
- Around line 29-35: The help text for the "--owner" flag (the entry with Name:
"owner" in the flag definitions in shortcuts/im/im_chat_create.go) is outdated;
change its Desc from "owner open_id (ou_xxx); defaults to the bot if not
specified" to reflect the new --as behavior (e.g. indicate it defaults to the
current user when running with "--as user", otherwise to the bot) so that
lark-cli im +chat-create --help accurately describes owner selection.

---

Duplicate comments:
In `@skills/lark-im/references/lark-im-chat-create.md`:
- Around line 66-68: The sentence under the "When using `--as bot`" section is
too absolute; update the wording to qualify that bots cannot invite users during
group creation only when those users are mutually invisible (error 232043) and
that bots can invite mutually-visible users directly, so avoid telling readers
to always use the two-step flow or to never pass other users' open_ids in
`--users`; instead mention the mutually-visible exception, cite error 232043,
and keep the guidance about the two-step flow for the mutually-invisible case.
🪄 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: c9077349-429b-4c4a-8d29-c47fdb15c268

📥 Commits

Reviewing files that changed from the base of the PR and between cf0bfab and 694ae8d.

📒 Files selected for processing (4)
  • shortcuts/im/im_chat_create.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-chat-create.md
  • skills/lark-im/references/lark-im-chat-identity.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-im/references/lark-im-chat-identity.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-im/SKILL.md

@shifengjuan-dev shifengjuan-dev force-pushed the feat/support_uat_for_create_chat branch from c79e930 to 202e2eb Compare April 3, 2026 07:34
YangJunzhou-01
YangJunzhou-01 previously approved these changes Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add shifengjuan-dev/lark-cli#feat/support_uat_for_create_chat -y -g

  - Add --as user support to +chat-create
  - Add UserScopes (im:chat:create_by_user) / BotScopes (im:chat:create)
  - Update skill docs and reference files to reflect user/bot support
  - Default identity remains bot (first element of AuthTypes)

Change-Id: I6be0a160567a0d87a92f176ae12297a11d06dcb1
@shifengjuan-dev shifengjuan-dev force-pushed the feat/support_uat_for_create_chat branch from 202e2eb to e9cc07b Compare April 3, 2026 08:19
@github-actions github-actions bot added size/L Large or sensitive change across domains or core paths and removed size/M Single-domain feat or fix with limited business impact labels Apr 3, 2026
@YangJunzhou-01 YangJunzhou-01 merged commit a641fdd into larksuite:main Apr 3, 2026
10 checks passed
@liangshuo-1 liangshuo-1 mentioned this pull request Apr 3, 2026
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.

3 participants