Skip to content

Pinvou/pinvou-agent / pinvou3-app/src-tauri/resources/common/bundle/lark-skills/lark-im

lark-im

Verified

【何时用:仅当用户明确指向飞书/Lark(发到飞书、飞书文档等)时使用;泛指做个文档或PPT或表格或方案默认走本地工具,不要误用飞书】飞书即时通讯:收发消息和管理群聊。发送和回复消息、搜索聊天记录、管理群聊成员、上传下载图片和文件、管理表情回复、发送应用内/短信/电话加急、发送和处理交互卡片(Interactive Card)与卡片按钮回调(card.action.trigger)。当用户需要发消息、查看或搜索聊天记录、下载聊天中的文件、查看群成员、搜索或创建群聊/话题群、管理标记数据、Feed 置顶与标签数据、处理卡片回调时使用。

FileKindSize
SKILL.mdskill md24.6 KB
references/card/card-2.0-schema.mdmarkdown6.0 KB
references/card/components/button.mdmarkdown2.8 KB
references/card/components/chart.mdmarkdown2.2 KB
references/card/components/checker.mdmarkdown1.9 KB
references/card/components/collapsible_panel.mdmarkdown1.8 KB
references/card/components/column_set.mdmarkdown2.5 KB
references/card/components/date_picker.mdmarkdown1.6 KB
references/card/components/div.mdmarkdown1.7 KB
references/card/components/form.mdmarkdown2.2 KB
references/card/components/header.mdmarkdown1.6 KB
references/card/components/hr.mdmarkdown425 B
references/card/components/img.mdmarkdown1.4 KB
references/card/components/img_combination.mdmarkdown1.0 KB
references/card/components/input.mdmarkdown2.0 KB
references/card/components/interactive_container.mdmarkdown2.2 KB
references/card/components/markdown.mdmarkdown3.2 KB
references/card/components/multi_select_person.mdmarkdown1.6 KB
references/card/components/multi_select_static.mdmarkdown1.6 KB
references/card/components/overflow.mdmarkdown1.5 KB
references/card/components/person.mdmarkdown907 B
references/card/components/person_list.mdmarkdown1.2 KB
references/card/components/picker_datetime.mdmarkdown1.5 KB
references/card/components/picker_time.mdmarkdown1.5 KB
references/card/components/recycling_container.mdmarkdown1.5 KB
references/card/components/select_img.mdmarkdown1.9 KB
references/card/components/select_person.mdmarkdown1.5 KB
references/card/components/select_static.mdmarkdown1.8 KB
references/card/components/table.mdmarkdown2.1 KB
references/card/lark-im-card-create.mdmarkdown10.8 KB
references/card/lark-im-card-style.mdmarkdown18.3 KB
references/card/resource/colors.mdmarkdown1.4 KB
references/card/resource/icons.mdmarkdown2.3 KB
references/lark-im-card-action-reply.mdmarkdown9.5 KB
references/lark-im-chat-create.mdmarkdown7.9 KB
references/lark-im-chat-identity.mdmarkdown3.3 KB
references/lark-im-chat-list.mdmarkdown9.3 KB
references/lark-im-chat-members-list.mdmarkdown5.2 KB
references/lark-im-chat-messages-list.mdmarkdown11.1 KB
references/lark-im-chat-search.mdmarkdown8.4 KB
references/lark-im-chat-update.mdmarkdown3.5 KB
references/lark-im-feed-group-list-item.mdmarkdown3.1 KB
references/lark-im-feed-group-list.mdmarkdown2.7 KB
references/lark-im-feed-group-query-item.mdmarkdown2.3 KB
references/lark-im-feed-groups.mdmarkdown18.3 KB
references/lark-im-feed-shortcut-create.mdmarkdown4.2 KB
references/lark-im-feed-shortcut-list.mdmarkdown5.0 KB
references/lark-im-feed-shortcut-remove.mdmarkdown2.1 KB
references/lark-im-flag-cancel.mdmarkdown2.9 KB
references/lark-im-flag-create.mdmarkdown2.7 KB
references/lark-im-flag-list.mdmarkdown4.6 KB
references/lark-im-message-enrichment.mdmarkdown7.0 KB
references/lark-im-message-read-status.mdmarkdown4.3 KB
references/lark-im-messages-edit.mdmarkdown6.4 KB
references/lark-im-messages-mget.mdmarkdown6.8 KB
references/lark-im-messages-reply.mdmarkdown17.1 KB
references/lark-im-messages-resources-download.mdmarkdown4.2 KB
references/lark-im-messages-search.mdmarkdown13.6 KB
references/lark-im-messages-send.mdmarkdown19.3 KB
references/lark-im-reactions.mdmarkdown10.3 KB
references/lark-im-scopes.mdmarkdown2.2 KB
references/lark-im-threads-messages-list.mdmarkdown6.4 KB

references/lark-im-chat-search.md

View on GitHub
# im +chat-search

> **Prerequisite:** Read [`../../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) first to understand authentication, global parameters, and safety rules.

Search the list of group chats visible to a user or bot, including chats the user or bot belongs to and public chats visible to them. Supports keyword matching on chat names and member names, including pinyin and prefix fuzzy search.

This skill maps to the shortcut: `lark-cli im +chat-search` (internally calls `POST /open-apis/im/v2/chats/search`).

## Commands

```bash
# Search chats by keyword
lark-cli im +chat-search --query "project"

# Restrict by search types
lark-cli im +chat-search --query "project" --search-types "private,public_joined"

# Filter by chat mode (group = regular group, topic = topic/thread group)
lark-cli im +chat-search --query "project" --chat-modes "topic"

# Filter by member open_ids (with keyword)
lark-cli im +chat-search --query "project" --member-ids "ou_xxx,ou_yyy"

# Search by member open_ids only
lark-cli im +chat-search --member-ids "ou_xxx,ou_yyy"

# Only show chats you created or manage
lark-cli im +chat-search --query "project" --is-manager

# Set page size
lark-cli im +chat-search --query "project" --page-size 10

# Pagination
lark-cli im +chat-search --query "project" --page-token "xxx"

# Fetch multiple pages automatically, up to 10 pages by default
lark-cli im +chat-search --query "project" --page-all

# JSON output
lark-cli im +chat-search --query "project" --format json

# Preview the request without executing it
lark-cli im +chat-search --query "project" --dry-run
```

## Parameters

| Parameter | Required | Limits | Description |
|------|------|------|------|
| `--query <keyword>` | No (at least one of `--query` / `--member-ids` required) | Max 64 characters | Search keyword. Supports matching localized chat names, member names, multilingual search, pinyin, and prefix fuzzy search. If the query contains `-`, it is automatically wrapped in quotes |
| `--search-types <types>` | No | Comma-separated: `private`, `external`, `public_joined`, `public_not_joined` | Restrict the visible chat types returned by search |
| `--chat-modes <modes>` | No | Comma-separated: `group`, `topic` | Filter by chat mode (server-side): `group` = regular group, `topic` = topic/thread group |
| `--member-ids <ids>` | No (at least one of `--query` / `--member-ids` required) | Up to 50, format `ou_xxx` | Filter by member open_ids; can be used alone or combined with `--query` |
| `--is-manager` | No | - | Only show chats you created or manage |
| `--disable-search-by-user` | No | - | Disable member-name-based matching and search by group name only |
| `--sort <field>` | No | `create_time`, `update_time`, `member_count` | Sort field (always descending) |
| `--page-size <n>` | No | 1-100, default 20 | Number of results per page |
| `--page-token <token>` | No | - | Starting cursor, normally returned by a previous response |
| `--page-all` | No | - | Automatically fetch and merge subsequent pages; capped by `--page-limit` |
| `--page-limit <n>` | No | 1-1000, default 10 | Maximum pages fetched by `--page-all` |
| `--exclude-muted` | No | User identity only | Drop chats the current user has muted (do-not-disturb). Under `--as bot`, the flag is silently inactive (mute is a per-user setting); see "Filtering muted chats" below |
| `--format json` | No | - | Output as JSON |
| `--dry-run` | No | - | Preview the request without executing it |

> **Note:** Supports both `--as user` (default) and `--as bot`. When using bot identity, the app must have bot capability enabled.

With `--page-all`, `--page-token` sets the starting cursor. If `meta.pagination.complete=false`, resume from `meta.pagination.next_token` or raise `--page-limit`.

> **CAUTION:** `--sort` is **always descending** — the search API only ranks the chosen field high-to-low (e.g. `member_count` = most members first). There is no ascending option. If the user asks for "fewest first / ascending / 从少到多", tell them the search API does not support ascending order; any low-to-high view requires re-sorting the fetched page client-side and is not an upstream sort. Do **not** invent values like `member_count_asc` or pass `asc` (they are rejected).

## Output Fields

| Field | Description |
|------|------|
| `chat_id` | Chat ID (`oc_xxx` format) |
| `name` | Chat name |
| `description` | Chat description |
| `owner_id` | Owner ID |
| `external` | Whether the chat is external |
| `chat_status` | Chat status (`normal` / `dissolved` / `dissolved_save`) |

## Filtering muted chats

`--exclude-muted` (user identity only) drops chats the current user has set to do-not-disturb. After the search call, the CLI batches the page's chat_ids through `POST /open-apis/im/v1/chat_user_setting/batch_get_mute_status` and filters client-side. Under `--as bot`, the mute API is UAT-only and the filter is silently skipped.

When the flag is set, the JSON envelope gains a `filter` sub-object (absent otherwise, so existing consumers are unaffected); `fetched_count == returned_count + filtered_count` always holds:

```json
{
  "chats": [...],
  "filter": {
    "applied": "exclude_muted",
    "fetched_count": 20,
    "returned_count": 19,
    "filtered_count": 1,
    "hint": "Filtered out 1 muted chat(s) on this page (19 remaining, including 2 non-member public group(s)); use --page-token to fetch more."
  }
}
```

Note: only confirmed-muted chats count toward `filtered_count`; non-member public groups are retained and surfaced in `hint`. For strict member-only results, combine with `--search-types "private,public_joined,external"`.

## Usage Scenarios

### Scenario 1: Search chats that contain a keyword

```bash
lark-cli im +chat-search --query "design review"
```

### Scenario 2: Search a chat and list recent messages

```bash
# --jq is built into the CLI (no local jq needed); read chat_id from the projected output
lark-cli im +chat-search --query "project" --jq '.data.chats[0].chat_id'
lark-cli im +chat-messages-list --chat-id "<chat_id>"
```

### Scenario 3: Search a chat and send a message

```bash
# --jq is built into the CLI (no local jq needed); read chat_id from the projected output
lark-cli im +chat-search --query "daily report" --jq '.data.chats[0].chat_id'
lark-cli im +messages-send --chat-id "<chat_id>" --text "Today's progress update"
```

## Common Errors and Troubleshooting

| Symptom | Root Cause | Solution |
|---------|---------|---------|
| `--query and --member-ids cannot both be empty` | Both were omitted | Provide at least `--query` or `--member-ids` |
| Empty results | No visible chats matched the keyword or filters | Relax the keyword or filters and try again |
| `invalid --page-size 101: must be between 1 and 100` | page-size is out of range | Use an integer between 1 and 100 |
| Permission denied (99991672) | The bot app does not have `im:chat:read` TAT permission enabled | Enable the permission for the app in the Open Platform console |
| Permission denied (99991679) with `--as user` | UAT is not authorized for `im:chat:read` | Run the on-demand auth flow: `lark-cli auth login --scope "im:chat:read" --no-wait --json` (per lark-shared split-flow; never the blocking login) |
| `Bot ability is not activated` (232025) | The app does not have bot capability enabled | Enable bot capability in the Open Platform console |

## AI Usage Guidance

When the user asks to search chats, follow these rules:

1. **At least one filter required:** `--query` and `--member-ids` cannot both be empty. Either alone or combined together are valid.
2. **Search scope is limited:** only chats visible to the current user or bot can be found (joined chats plus public chats). This is not a global search over all chats.
3. **Control result volume:** the result set may be large. Use `--page-size` deliberately.
4. **Suggest follow-up actions:** after finding a chat, common next steps include listing recent messages (`im +chat-messages-list`) or sending a message (`im +messages-send`).
5. **NEVER fall back to chats list:** If `+chat-search` returns empty results, do NOT attempt to use `+chat-list` or `GET /open-apis/im/v1/chats` as a fallback. The list API is not a search API — it returns all chats without keyword filtering and will not help locate the target chat. Instead, ask the user to refine the keyword or check whether the chat is visible to the current identity.

## References

- [lark-im](../SKILL.md) - all IM commands
- [lark-shared](../../lark-shared/SKILL.md) - authentication and global parameters
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall