@lark-apaas/coding-miaoda-sandbox-skills 0.1.0-dev.28c4f05 → 0.1.0-dev.4e64c13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/miaoda/animation-skill/SKILL.md +348 -0
- package/miaoda/authz-cli/SKILL.md +1 -0
- package/miaoda/charts-skill/SKILL.md +264 -0
- package/miaoda/creative-to-fullstack/SKILL.md +157 -0
- package/miaoda/creative-to-fullstack/references/artifact-signals.md +46 -0
- package/miaoda/creative-to-fullstack/references/ui-to-function.md +134 -0
- package/miaoda/data-analysis/SKILL.md +151 -0
- package/miaoda/data-analysis/references/json-output-specification.md +277 -0
- package/miaoda/data-analysis/references/post-analysis-guide.md +77 -0
- package/miaoda/data-analysis/references/python-analysis-reference.md +272 -0
- package/miaoda/data-analysis/references/tmp-file-management-guide.md +100 -0
- package/miaoda/debug-investigation/SKILL.md +21 -18
- package/miaoda/extract-json-schema/SKILL.md +147 -0
- package/miaoda/lark-apps/SKILL.md +37 -0
- package/miaoda/lark-apps/references/openapi-key.md +80 -0
- package/miaoda/lark-apps-authz/SKILL.md +292 -0
- package/miaoda/lark-apps-authz/references/permission-points.md +39 -0
- package/miaoda/lark-apps-authz/references/role.md +122 -0
- package/miaoda/lark-apps-db/SKILL.md +226 -0
- package/miaoda/lark-apps-db/references/full-reference.md +302 -0
- package/miaoda/lark-apps-file/SKILL.md +216 -0
- package/miaoda/lark-apps-ops/SKILL.md +62 -0
- package/miaoda/lark-apps-ops/references/lark-apps-access-scope-get.md +30 -0
- package/miaoda/lark-apps-ops/references/lark-apps-access-scope-set.md +40 -0
- package/miaoda/lark-apps-ops/references/lark-apps-cache.md +62 -0
- package/miaoda/lark-apps-ops/references/lark-apps-env.md +46 -0
- package/miaoda/lark-apps-ops/references/lark-apps-local-dev.md +25 -0
- package/miaoda/lark-apps-ops/references/lark-apps-member.md +93 -0
- package/miaoda/lark-apps-ops/references/lark-apps-observability.md +46 -0
- package/miaoda/lark-apps-ops/references/lark-apps-plugin-install.md +36 -0
- package/miaoda/lark-apps-ops/references/lark-apps-plugin-list.md +23 -0
- package/miaoda/lark-apps-ops/references/lark-apps-plugin-uninstall.md +25 -0
- package/miaoda/lark-apps-ops/references/lark-apps-release-create.md +30 -0
- package/miaoda/lark-apps-ops/references/lark-apps-release-get.md +28 -0
- package/miaoda/lark-apps-ops/references/lark-apps-release-list.md +31 -0
- package/miaoda/lark-apps-ops/references/lark-apps-update.md +30 -0
- package/miaoda/lark-apps-ops/references/openapi-key.md +80 -0
- package/miaoda/miaoda-file/SKILL.md +1 -0
- package/miaoda/miaoda-sql/SKILL.md +6 -2
- package/miaoda/performance-review/SKILL.md +144 -0
- package/miaoda/performance-review/references/business-analyzer.md +139 -0
- package/miaoda/performance-review/references/examples.md +107 -0
- package/miaoda/reviewer-usage/SKILL.md +111 -0
- package/miaoda/testing-guide/SKILL.md +218 -0
- package/miaoda-design/lark-apps-comment/SKILL.md +110 -0
- package/miaoda-design/lark-apps-ops/SKILL.md +45 -0
- package/miaoda-design/lark-apps-ops/references/lark-apps-release-create.md +51 -0
- package/miaoda-design/lark-apps-ops/references/lark-apps-release-get.md +28 -0
- package/miaoda-design/lark-apps-ops/references/lark-apps-release-list.md +31 -0
- package/miaoda-design/lark-apps-ops/references/lark-apps-update.md +33 -0
- package/{shared → miaoda-modern}/lark-apps/SKILL.md +5 -5
- package/miaoda-modern/lark-apps/references/openapi-key.md +80 -0
- package/miaoda-modern/lark-apps-ops/SKILL.md +62 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-access-scope-get.md +30 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-access-scope-set.md +40 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-cache.md +62 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-env.md +46 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-local-dev.md +25 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-member.md +93 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-observability.md +46 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-plugin-install.md +36 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-plugin-list.md +23 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-plugin-uninstall.md +25 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-release-create.md +30 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-release-get.md +28 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-release-list.md +31 -0
- package/miaoda-modern/lark-apps-ops/references/lark-apps-update.md +30 -0
- package/{shared/lark-apps → miaoda-modern/lark-apps-ops}/references/openapi-key.md +3 -3
- package/miaoda-modern/memory/SKILL.md +86 -0
- package/package.json +1 -1
- package/shared/lark-cli/SKILL.md +221 -0
- package/shared/lark-cli/lark-base/README.md +56 -0
- package/shared/lark-cli/lark-base/references/lark-base-commands.md +108 -0
- package/shared/lark-cli/lark-calendar/README.md +158 -0
- package/shared/lark-cli/lark-calendar/references/lark-calendar-meeting.md +30 -0
- package/shared/lark-cli/lark-calendar/references/lark-calendar-room-find.md +108 -0
- package/shared/lark-cli/lark-calendar/references/lark-calendar-suggestion.md +120 -0
- package/shared/lark-cli/lark-contact/README.md +35 -0
- package/shared/lark-cli/lark-contact/references/lark-contact-get-user.md +13 -0
- package/shared/lark-cli/lark-contact/references/lark-contact-search-user.md +121 -0
- package/shared/lark-cli/lark-doc/README.md +67 -0
- package/shared/lark-cli/lark-doc/references/lark-doc-fetch.md +138 -0
- package/shared/lark-cli/lark-doc/references/lark-doc-history.md +61 -0
- package/shared/lark-cli/lark-drive/README.md +129 -0
- package/shared/lark-cli/lark-drive/references/lark-drive-files-list.md +183 -0
- package/shared/lark-cli/lark-im/README.md +84 -0
- package/shared/lark-cli/lark-im/references/lark-im-chat-list.md +140 -0
- package/shared/lark-cli/lark-im/references/lark-im-chat-members-list.md +84 -0
- package/shared/lark-cli/lark-im/references/lark-im-chat-search.md +135 -0
- package/shared/lark-cli/lark-im/references/lark-im-reactions.md +232 -0
- package/shared/lark-cli/lark-minutes/README.md +51 -0
- package/shared/lark-cli/lark-minutes/references/lark-minutes-download.md +130 -0
- package/shared/lark-cli/lark-sheets/README.md +173 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-changeset.md +105 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-chart.md +45 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-conditional-format.md +42 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-filter-view.md +49 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-filter.md +42 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-float-image.md +43 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-formula-verify.md +64 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-history.md +70 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-pivot-table.md +44 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-read-data.md +216 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-search-replace.md +67 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-sheet-structure.md +52 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-sparkline.md +47 -0
- package/shared/lark-cli/lark-sheets/references/lark-sheets-workbook.md +69 -0
- package/shared/lark-cli/lark-sheets/scripts/sheets_df.py +32 -0
- package/shared/lark-cli/lark-slides/README.md +86 -0
- package/shared/lark-cli/lark-slides/references/lark-slides-history.md +105 -0
- package/shared/lark-cli/lark-slides/references/lark-slides-xml-presentation-slide-get.md +108 -0
- package/shared/lark-cli/lark-slides/references/lark-slides-xml-presentations-get.md +77 -0
- package/shared/lark-cli/lark-task/README.md +93 -0
- package/shared/lark-cli/lark-task/references/lark-task-get-my-tasks.md +57 -0
- package/shared/lark-cli/lark-task/references/lark-task-get-related-tasks.md +49 -0
- package/shared/lark-cli/lark-task/references/lark-task-search.md +36 -0
- package/shared/lark-cli/lark-task/references/lark-task-tasklist-search.md +35 -0
- package/shared/lark-cli/lark-vc/README.md +40 -0
- package/shared/lark-cli/lark-vc/references/lark-vc-recording.md +31 -0
- package/shared/lark-cli/lark-whiteboard/README.md +35 -0
- package/shared/lark-cli/lark-whiteboard/references/lark-whiteboard-export.md +59 -0
- package/shared/lark-cli/lark-wiki/README.md +50 -0
- package/shared/lark-cli/lark-wiki/references/lark-wiki-node-get.md +59 -0
- package/shared/lark-cli/lark-wiki/references/lark-wiki-node-list.md +95 -0
- package/shared/lark-cli/lark-wiki/references/lark-wiki-space-list.md +68 -0
- package/miaoda-design/attachment/SKILL.md +0 -58
- /package/{shared → miaoda}/memory/SKILL.md +0 -0
- /package/{shared → miaoda-modern}/animation-skill/SKILL.md +0 -0
- /package/{shared → miaoda-modern}/charts-skill/SKILL.md +0 -0
- /package/{shared → miaoda-modern}/data-analysis/SKILL.md +0 -0
- /package/{shared → miaoda-modern}/data-analysis/references/json-output-specification.md +0 -0
- /package/{shared → miaoda-modern}/data-analysis/references/post-analysis-guide.md +0 -0
- /package/{shared → miaoda-modern}/data-analysis/references/python-analysis-reference.md +0 -0
- /package/{shared → miaoda-modern}/data-analysis/references/tmp-file-management-guide.md +0 -0
- /package/{shared → miaoda-modern}/extract-json-schema/SKILL.md +0 -0
- /package/{shared → miaoda-modern}/performance-review/SKILL.md +0 -0
- /package/{shared → miaoda-modern}/performance-review/references/business-analyzer.md +0 -0
- /package/{shared → miaoda-modern}/performance-review/references/examples.md +0 -0
- /package/{shared → miaoda-modern}/reviewer-usage/SKILL.md +0 -0
- /package/{shared → miaoda-modern}/testing-guide/SKILL.md +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# drive files list(原生 API:读取 Drive 文件夹清单)
|
|
2
|
+
|
|
3
|
+
`drive files list` 是原生 API 命令,不是 shortcut。它用于读取 Drive 根目录或某个 Drive 文件夹的直接子项;如果要递归盘点目录树,Agent 必须基于返回的子文件夹 token 继续调用本命令。
|
|
4
|
+
|
|
5
|
+
## 什么时候使用
|
|
6
|
+
|
|
7
|
+
| 场景 | 是否使用 | 说明 |
|
|
8
|
+
|------|----------|------|
|
|
9
|
+
| 盘点一个已确认的 Drive 文件夹树 | 使用 | 从目标 `folder_token` 开始递归列取 |
|
|
10
|
+
| 盘点用户明确确认的 Drive 根目录 | 使用 | 第一层用空 `folder_token`,子文件夹继续按普通文件夹递归 |
|
|
11
|
+
| 验证移动 / 创建后的实际位置 | 使用 | 读取目标目录直接子项,再按需递归验证 |
|
|
12
|
+
| 根据关键词、标题、时间、owner 找资源 | 不使用 | 本 API 只按文件夹层级列取直接子项,不做关键词检索 |
|
|
13
|
+
| 读取 Docx 正文内容 | 不使用 | 属 lark-doc 能力 |
|
|
14
|
+
| 读取 Sheet 内部数据 | 不使用 | 切到 `lark-sheets`;多维表格 / Base 切 `lark-base` |
|
|
15
|
+
|
|
16
|
+
## 标准命令模板
|
|
17
|
+
|
|
18
|
+
读取普通文件夹:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
lark-cli drive files list \
|
|
22
|
+
--params '{"folder_token":"<folder_token>","page_size":200}' \
|
|
23
|
+
--format json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
继续翻页:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
lark-cli drive files list \
|
|
30
|
+
--params '{"folder_token":"<folder_token>","page_size":200,"page_token":"<PAGE_TOKEN>"}' \
|
|
31
|
+
--format json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
读取当前用户 Drive 根目录的直接子项:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
lark-cli drive files list \
|
|
38
|
+
--params '{"folder_token":"","page_size":200}' \
|
|
39
|
+
--format json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
也可以省略 `folder_token` 字段来请求根目录,但在 Agent 编排中建议显式传空字符串,避免把“忘记传参数”和“确认请求根目录”混在一起。
|
|
43
|
+
|
|
44
|
+
## 按时间排序
|
|
45
|
+
|
|
46
|
+
默认不要传 `order_by` / `direction`;服务端会按默认顺序返回。只有用户明确要求按创建时间或编辑时间排序时,才使用服务端排序参数。
|
|
47
|
+
|
|
48
|
+
按创建时间升序列出当前文件夹直接子项:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
lark-cli drive files list \
|
|
52
|
+
--params '{"folder_token":"<folder_token>","order_by":"CreatedTime","direction":"ASC","page_size":200}' \
|
|
53
|
+
--format json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
按编辑时间降序列出当前文件夹直接子项:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
lark-cli drive files list \
|
|
60
|
+
--params '{"folder_token":"<folder_token>","order_by":"EditedTime","direction":"DESC","page_size":200}' \
|
|
61
|
+
--format json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
以上示例返回排序后的当前页;如果返回 `has_more=true`,保持相同 `folder_token` / `order_by` / `direction` / `page_size`,把 `next_page_token` 放入 `page_token` 继续翻页。
|
|
65
|
+
|
|
66
|
+
## 参数规则
|
|
67
|
+
|
|
68
|
+
1. `folder_token` 必须放在 `--params` JSON 里;不要使用不存在的 `--folder-token` flag。
|
|
69
|
+
2. `page_token` 必须放在 `--params` JSON 里;不要依赖 shell 变量拼接不完整的 JSON。
|
|
70
|
+
3. 默认不要传 `order_by` / `direction`;只有用户明确要求按创建时间 / 编辑时间排序时才使用服务端排序参数。
|
|
71
|
+
4. 排序参数映射:创建时间 -> `order_by:"CreatedTime"`;编辑时间 / 修改时间 -> `order_by:"EditedTime"`;升序 -> `direction:"ASC"`;降序 -> `direction:"DESC"`。不要省略排序参数后再用 Python / shell 客户端排序替代。
|
|
72
|
+
5. 排序查询建议带 `page_size:200` 减少翻页;只有用户要求完整分页、递归盘点、大目录全量导出,或当前页返回 `has_more=true` 后继续翻页时,才加入 `page_token`。
|
|
73
|
+
6. `page_size` 在分页、递归盘点或全量导出时建议显式设置为 `200`。如果服务端或环境返回参数错误,再降级到服务端允许的值,并记录降级原因。
|
|
74
|
+
7. 调用前如果不确定字段结构,先运行 `lark-cli schema drive.files.list` 查看 `--params` 结构。
|
|
75
|
+
|
|
76
|
+
## 返回结构与解析
|
|
77
|
+
|
|
78
|
+
`--format json` 输出中,Agent 只使用 `data` 中符合 `schema drive.files.list` 的 API 返回字段。
|
|
79
|
+
|
|
80
|
+
常用字段:
|
|
81
|
+
|
|
82
|
+
| 字段 | 用途 |
|
|
83
|
+
|------|------|
|
|
84
|
+
| `data.files` | 当前页直接子项列表 |
|
|
85
|
+
| `data.has_more` | 当前目录是否还有下一页 |
|
|
86
|
+
| `data.next_page_token` | 下一页 token;当 `has_more=true` 时放回 `--params.page_token` |
|
|
87
|
+
| `data.files[].type` | 文件类型;等于 `folder` 时可递归 |
|
|
88
|
+
| `data.files[].token` | 当前资源 token;文件夹递归时作为下一层 `folder_token` |
|
|
89
|
+
| `data.files[].name` | 生成路径和展示标题 |
|
|
90
|
+
| `data.files[].url` | 资源浏览器链接 |
|
|
91
|
+
| `data.files[].owner_id` | 资源所有者 |
|
|
92
|
+
| `data.files[].created_time` / `data.files[].modified_time` | 创建 / 更新时间 |
|
|
93
|
+
|
|
94
|
+
字段名以 `schema drive.files.list` 为准。Agent MUST 以实际返回为准;如果字段缺失,先用 `schema drive.files.list` 或一页样本确认结构,不要猜测。
|
|
95
|
+
|
|
96
|
+
## 根目录语义
|
|
97
|
+
|
|
98
|
+
1. `folder_token` 为空字符串或省略时,请求的是当前调用用户的 Drive 根目录直接子项。
|
|
99
|
+
2. 根目录返回值不是递归结果;不能把根目录第一页或直接子项数量当作整个云空间资源总量。
|
|
100
|
+
3. 根目录只作为目录树起点。返回的子文件夹必须用其自己的 `folder_token` 继续调用 `drive files list`。
|
|
101
|
+
4. 根据 schema 描述,根目录第一层清单不支持分页且不返回快捷方式;不要基于根目录响应推断子文件夹内容、根目录第一层快捷方式或无法分页的根目录剩余项已经被覆盖。
|
|
102
|
+
|
|
103
|
+
## 递归盘点规则
|
|
104
|
+
|
|
105
|
+
1. 只对返回项中的 `folder` 类型继续递归。
|
|
106
|
+
2. 每个目录独立维护分页状态;一个目录的 `page_token` 不可复用于其他目录。
|
|
107
|
+
3. 对每个目录持续请求,直到返回 `has_more=false`。非根目录的普通文件夹清单可能返回 `type=shortcut` 条目;不要假设这些条目会携带 `shortcut_info` 目标信息。
|
|
108
|
+
4. 递归过程中生成稳定 `path`;不要只保存标题,否则同名资源无法区分。
|
|
109
|
+
5. URL、owner、创建时间和更新时间优先使用 `files.list` 返回字段;如果字段缺失,以实际返回为准,不要从标题或路径猜元数据。
|
|
110
|
+
6. 深度、数量、每目录页数等限制只能作为内部批次 checkpoint;不能作为递归完成条件。
|
|
111
|
+
7. 达到深度 checkpoint 时,把更深层子文件夹加入 continuation queue,并在下一批从这些子文件夹继续,保留原始 `path`。
|
|
112
|
+
8. 达到数量 checkpoint 时,保存当前目录、当前页 token、剩余目录队列和已收集资源计数,并立即继续下一批;不要进入分析或规划阶段。
|
|
113
|
+
|
|
114
|
+
### 递归算法
|
|
115
|
+
|
|
116
|
+
Agent 盘点 Drive 文件夹树时,按以下顺序执行:
|
|
117
|
+
|
|
118
|
+
1. 初始化待处理队列,放入起点目录:
|
|
119
|
+
- 普通文件夹:`{folder_token:"<folder_token>", path:"<folder_name>"}`
|
|
120
|
+
- Drive 根目录:`{folder_token:"", path:""}`
|
|
121
|
+
2. 从队列取出一个目录,请求第一页。
|
|
122
|
+
3. 用 `(folder_token, page_token)` 生成当前页 key;同一页 key 只允许追加一次,避免 retry 时重复计数。
|
|
123
|
+
4. 从 `data.files` 取当前页直接子项,按 `dedupe_key` 去重后生成 `path` 并加入结果集。
|
|
124
|
+
5. 如果新追加的子项是 `folder`,把子文件夹 token、子路径和 depth 加入队列。
|
|
125
|
+
6. 如果 `has_more=true`,取 `data.next_page_token` 继续请求同一目录下一页。
|
|
126
|
+
7. 同一目录分页结束后,再处理队列中的下一个目录。
|
|
127
|
+
8. 如果达到深度、数量或每目录页数 checkpoint,把当前目录 / 页 token / 剩余队列 / 已访问页 key / dedupe key 写入 continuation queue,并继续下一批。
|
|
128
|
+
9. 普通队列和 continuation queue 都为空,且没有分页 blocker 时,才可以认为本次确认范围盘点完成。
|
|
129
|
+
|
|
130
|
+
简化伪代码:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
queue = [root_or_start_folder]
|
|
134
|
+
visited_pages = set()
|
|
135
|
+
dedupe_keys = set()
|
|
136
|
+
while queue not empty:
|
|
137
|
+
folder = queue.pop()
|
|
138
|
+
page_token = folder.page_token or ""
|
|
139
|
+
retry_without_token = 0
|
|
140
|
+
while true:
|
|
141
|
+
page_key = (folder.folder_token, page_token or "first")
|
|
142
|
+
page = drive files list(folder.folder_token, page_token)
|
|
143
|
+
if page_key not in visited_pages:
|
|
144
|
+
append only files whose dedupe_key is not in dedupe_keys
|
|
145
|
+
enqueue newly appended child folders with folder_token, path, and depth
|
|
146
|
+
add page_key to visited_pages
|
|
147
|
+
if page.has_more != true:
|
|
148
|
+
break
|
|
149
|
+
next = page.next_page_token
|
|
150
|
+
if next is empty:
|
|
151
|
+
retry_without_token += 1
|
|
152
|
+
if retry_without_token >= 3:
|
|
153
|
+
record pagination blocker for folder
|
|
154
|
+
break
|
|
155
|
+
continue
|
|
156
|
+
page_token = next
|
|
157
|
+
retry_without_token = 0
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 分页与异常
|
|
161
|
+
|
|
162
|
+
1. 默认手动处理 `has_more` 和返回中的 `next_page_token`。
|
|
163
|
+
2. 不要使用 `--page-all` 作为脚本 JSON 解析输入;自动翻页输出可能不适合直接 `json.loads`。
|
|
164
|
+
3. 如果 `has_more=true` 但没有可用的 `next_page_token`,重试同一页最多 3 次。
|
|
165
|
+
4. 重试后仍无 continuation token 时,记录受影响的目录和 pagination blocker,停止扩展该目录;不要无限循环,也不要宣称该目录已完整覆盖。
|
|
166
|
+
5. 如果触发深度、数量或每目录页数限制,把它视为批处理 checkpoint;在确认范围内继续下一批,而不是把当前结果说成完整。
|
|
167
|
+
6. 不要因为达到 `max_depth=3`、`max_items=500` 或类似单批阈值就结束盘点;只有队列耗尽或遇到权限 / API / 工具预算 blocker 才能结束当前确认范围的盘点。
|
|
168
|
+
|
|
169
|
+
## JSON 解析规则
|
|
170
|
+
|
|
171
|
+
1. stdout 是数据通道。脚本解析 JSON 时只读取 stdout。
|
|
172
|
+
2. stderr 可能包含刷新 token、进度、warning 或其他提示;不要把 stderr 合并进 JSON 输入,例如不要用 `2>&1` 后再 `json.loads`。
|
|
173
|
+
3. 使用 `--format json` 保持 stdout 为结构化 JSON;解析 Drive 文件清单时只读取 `data.files` / `data.has_more` / `data.next_page_token` 等 schema 字段。
|
|
174
|
+
4. 不要用根目录响应数量或当前页数量推断递归总量;递归总量必须由实际遍历并去重后的资源集合计算。
|
|
175
|
+
|
|
176
|
+
## 常见错误
|
|
177
|
+
|
|
178
|
+
| 错误用法 | 问题 | 正确做法 |
|
|
179
|
+
|----------|------|----------|
|
|
180
|
+
| `lark-cli drive files list --folder-token <token>` | `files.list` 不提供 `--folder-token` flag | 使用 `--params '{"folder_token":"<token>"}'` |
|
|
181
|
+
| 根目录返回 N 项就认为云空间只有 N 项 | 根目录只返回直接子项,不是递归结果 | 对返回的子文件夹继续递归 |
|
|
182
|
+
| `--page-all \| python json.loads(...)` | 自动翻页输出不适合作为单个 JSON 对象解析 | 手动使用 `page_token` 翻页并逐页解析 |
|
|
183
|
+
| `cmd 2>&1` 后解析 JSON | stderr 提示污染 JSON 输入 | 只解析 stdout,stderr 作为日志处理 |
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# im (v1)
|
|
2
|
+
|
|
3
|
+
## Core Concepts
|
|
4
|
+
|
|
5
|
+
- **Chat**: A group chat or P2P conversation, identified by `chat_id` (oc_xxx).
|
|
6
|
+
- **Message**: A single message in a chat, identified by `message_id` (om_xxx).
|
|
7
|
+
- **Reaction**: An emoji reaction on a message.
|
|
8
|
+
- **Member**: An entry in a chat's member list — a user account or a bot (returned in separate `users[]` / `bots[]` buckets).
|
|
9
|
+
|
|
10
|
+
所有命令以当前用户身份运行(`--as user`,默认值,无需显式指定);能否读到某个群 / 成员 / 消息取决于该用户对目标资源的可见性。
|
|
11
|
+
|
|
12
|
+
## Resource Relationships
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Chat (oc_xxx)
|
|
16
|
+
├── Message (om_xxx)
|
|
17
|
+
│ └── Reaction (emoji)
|
|
18
|
+
└── Member (user / bot)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Shortcuts(推荐优先使用)
|
|
22
|
+
|
|
23
|
+
Shortcut 是对常用操作的高级封装(`lark-cli im +<verb> [flags]`)。有 Shortcut 的操作优先使用。本沙箱只透出以下 3 个只读快捷命令:
|
|
24
|
+
|
|
25
|
+
| Shortcut | 说明 |
|
|
26
|
+
|----------|------|
|
|
27
|
+
| [`+chat-list`](references/lark-im-chat-list.md) | List chats the current user is a member of; defaults to groups; pass --types=p2p,group to include p2p single chats; supports sorting, auto-pagination (--page-all), --exclude-muted |
|
|
28
|
+
| [`+chat-members-list`](references/lark-im-chat-members-list.md) | List members of a chat; returns separate users[] / bots[] buckets; --member-types filters which kinds to return; --page-all pagination; surfaces truncations[] when the server caps a bucket |
|
|
29
|
+
| [`+chat-search`](references/lark-im-chat-search.md) | Search visible group chats by --query keyword and/or --member-ids; e.g. look up chat_id by group name; supports type filters, sorting, auto-pagination (--page-all), and --exclude-muted |
|
|
30
|
+
|
|
31
|
+
## API Resources
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
lark-cli schema im.<resource>.<method> # 调用 API 前必须先查看参数结构
|
|
35
|
+
lark-cli im <resource> <method> [flags] # 调用 API
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> **重要**:使用原生 API 时,必须先运行 `schema` 查看 `--data` / `--params` 参数结构,不要猜测字段格式。
|
|
39
|
+
|
|
40
|
+
本沙箱只透出以下只读 API 命令(均为 read-only);**不要**尝试列表之外的 `im <service>/<api>` 组合。
|
|
41
|
+
|
|
42
|
+
### chats
|
|
43
|
+
|
|
44
|
+
- `get` — 获取群信息。调用方需在目标群内才能拿到完整信息;内部群还需与群属于同一租户。
|
|
45
|
+
|
|
46
|
+
### chat.members
|
|
47
|
+
|
|
48
|
+
- `bots` — 读取群内机器人成员信息。上游 skill 未提供 typed-flag 文档,调用前先 `lark-cli schema im.chat.members.bots` 查看参数与返回结构。
|
|
49
|
+
- `get` — 读取群成员信息。上游 skill 未提供 typed-flag 文档,调用前先 `lark-cli schema im.chat.members.get` 查看参数与返回结构。
|
|
50
|
+
|
|
51
|
+
### chat.moderation
|
|
52
|
+
|
|
53
|
+
- `get` — 获取群成员发言权限。调用方需在目标群内并与群属于同一租户。
|
|
54
|
+
|
|
55
|
+
### chat.nickname
|
|
56
|
+
|
|
57
|
+
- `get` — 获取自己的群昵称(self-only);未设置昵称时返回空字符串。
|
|
58
|
+
|
|
59
|
+
### chat.user_setting
|
|
60
|
+
|
|
61
|
+
- `batch_query` — 批量查询当前用户在群内的个人偏好设置(如 `is_muted` 静音普通消息、`is_mute_at_all` 静音 @all 消息);单次最多 10 个群;调用方需在每个目标群内。
|
|
62
|
+
|
|
63
|
+
### pins
|
|
64
|
+
|
|
65
|
+
- `list` — 获取群内 Pin 消息。
|
|
66
|
+
|
|
67
|
+
### reactions
|
|
68
|
+
|
|
69
|
+
- `batch_query` — 批量获取多条消息的表情回复。[Must-read](references/lark-im-reactions.md)
|
|
70
|
+
- `list` — 获取单条消息的表情回复记录。[Must-read](references/lark-im-reactions.md)
|
|
71
|
+
|
|
72
|
+
## 权限表
|
|
73
|
+
|
|
74
|
+
| 方法 | 所需 scope |
|
|
75
|
+
|------|-----------|
|
|
76
|
+
| `chats.get` | `im:chat:read` |
|
|
77
|
+
| `+chat-list` / `+chat-search` | `im:chat:read` |
|
|
78
|
+
| `chat.members.get` | `im:chat.members:read` |
|
|
79
|
+
| `+chat-members-list` | `im:chat.members:read` |
|
|
80
|
+
| `chat.user_setting.batch_query` | `im:chat.user_setting:read` |
|
|
81
|
+
| `chat.moderation.get` | `im:chat.moderation:read` |
|
|
82
|
+
| `reactions.batch_query` | `im:message.reactions:read` |
|
|
83
|
+
| `reactions.list` | `im:message.reactions:read` |
|
|
84
|
+
| `pins.list` | `im:message.pins:read` |
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# im +chat-list
|
|
2
|
+
|
|
3
|
+
List chats the current user is a member of. **Not a search API — there is no `--query` parameter; the call always returns the full member list, paginated.** For keyword-based lookup (e.g. find a group by name or by member), use [`+chat-search`](lark-im-chat-search.md) instead.
|
|
4
|
+
|
|
5
|
+
**Defaults to groups only**; pass `--types=p2p,group` (or `--types p2p --types group`) to also include p2p single chats. Supports pagination, sort order, and muted-chat filtering.
|
|
6
|
+
|
|
7
|
+
This skill maps to the shortcut: `lark-cli im +chat-list` (internally calls `GET /open-apis/im/v1/chats`).
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# List the user's chats (default sort: create_time, ascending)
|
|
13
|
+
lark-cli im +chat-list
|
|
14
|
+
|
|
15
|
+
# Sort by recent activity (most recently active first)
|
|
16
|
+
lark-cli im +chat-list --sort active_time
|
|
17
|
+
|
|
18
|
+
# Limit page size
|
|
19
|
+
lark-cli im +chat-list --page-size 50
|
|
20
|
+
|
|
21
|
+
# Pagination
|
|
22
|
+
lark-cli im +chat-list --page-token "xxx"
|
|
23
|
+
|
|
24
|
+
# Fetch multiple pages automatically, up to 10 pages by default
|
|
25
|
+
lark-cli im +chat-list --page-all
|
|
26
|
+
|
|
27
|
+
# Drop muted chats
|
|
28
|
+
lark-cli im +chat-list --exclude-muted
|
|
29
|
+
|
|
30
|
+
# JSON output
|
|
31
|
+
lark-cli im +chat-list --format json
|
|
32
|
+
|
|
33
|
+
# Preview the request without executing it
|
|
34
|
+
lark-cli im +chat-list --dry-run
|
|
35
|
+
|
|
36
|
+
# Include p2p single chats — comma form
|
|
37
|
+
lark-cli im +chat-list --types p2p,group
|
|
38
|
+
|
|
39
|
+
# Same, using repeat flag instead of CSV
|
|
40
|
+
lark-cli im +chat-list --types p2p --types group
|
|
41
|
+
|
|
42
|
+
# Only p2p single chats
|
|
43
|
+
lark-cli im +chat-list --types p2p
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Parameters
|
|
47
|
+
|
|
48
|
+
| Parameter | Required | Limits | Description |
|
|
49
|
+
|------|------|------|------|
|
|
50
|
+
| `--user-id-type <type>` | No | `open_id` (default), `union_id`, `user_id` | ID type used for `owner_id` in the response |
|
|
51
|
+
| `--types <strings>` | No | `group`, `p2p` (comma-separated or repeated) | Chat types to include. Omitted = groups only (backward compatible) |
|
|
52
|
+
| `--sort <field>` | No | `create_time` (default, ascending), `active_time` (descending) | Result ordering |
|
|
53
|
+
| `--page-size <n>` | No | 1-100, default 20 | Number of results per page |
|
|
54
|
+
| `--page-token <token>` | No | - | Starting cursor, normally returned by a previous response |
|
|
55
|
+
| `--page-all` | No | - | Automatically fetch and merge subsequent pages; capped by `--page-limit` |
|
|
56
|
+
| `--page-limit <n>` | No | 1-1000, default 10 | Maximum pages fetched by `--page-all` |
|
|
57
|
+
| `--exclude-muted` | No | - | Drop chats the current user has muted (do-not-disturb); see "Filtering muted chats" below |
|
|
58
|
+
| `--format json` | No | - | Output as JSON |
|
|
59
|
+
| `--dry-run` | No | - | Preview the request without executing it |
|
|
60
|
+
|
|
61
|
+
With `--page-all`, `--page-token` sets the starting cursor. If `meta.pagination.complete=false`, resume from `meta.pagination.next_token` or raise `--page-limit`.
|
|
62
|
+
|
|
63
|
+
## Output Fields
|
|
64
|
+
|
|
65
|
+
| Field | Description |
|
|
66
|
+
|------|------|
|
|
67
|
+
| `chat_id` | Chat ID (`oc_xxx` format) |
|
|
68
|
+
| `name` | Chat name |
|
|
69
|
+
| `description` | Chat description |
|
|
70
|
+
| `owner_id` | Owner ID (type controlled by `--user-id-type`) |
|
|
71
|
+
| `external` | Whether the chat is external |
|
|
72
|
+
| `chat_status` | Chat status (`normal` / `dissolved` / `dissolved_save`) |
|
|
73
|
+
| `chat_mode` | Chat mode discriminator: `group` (regular) / `topic` (topic group) / `p2p` (single chat) |
|
|
74
|
+
| `p2p_target_type` | Peer type, e.g., `user` |
|
|
75
|
+
| `p2p_target_id` | Peer ID (type controlled by `--user-id-type`) |
|
|
76
|
+
|
|
77
|
+
## Including p2p single chats
|
|
78
|
+
|
|
79
|
+
Default behavior lists groups only — same as before this feature. To include p2p, pass `--types`:
|
|
80
|
+
|
|
81
|
+
| User intent | Call |
|
|
82
|
+
|---|---|
|
|
83
|
+
| "list my groups" / 我的群 / 我加入了哪些群 | (default, omit `--types`) |
|
|
84
|
+
| "list my p2p chats" / 我的单聊 / 我跟谁有 1v1 | `--types p2p` |
|
|
85
|
+
| "all my chats" / 全部聊天 / 所有会话 (ambiguous) | `--types p2p,group` |
|
|
86
|
+
|
|
87
|
+
For p2p rows in the response: `name` is the peer's display name, `owner_id` follows group semantics, `chat_mode = "p2p"`, and `p2p_target_type` / `p2p_target_id` identify the peer.
|
|
88
|
+
|
|
89
|
+
## Filtering muted chats
|
|
90
|
+
|
|
91
|
+
`--exclude-muted` drops chats the current user has set to do-not-disturb. After the list 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.
|
|
92
|
+
|
|
93
|
+
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:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"chats": [...],
|
|
98
|
+
"filter": {
|
|
99
|
+
"applied": "exclude_muted",
|
|
100
|
+
"fetched_count": 20,
|
|
101
|
+
"returned_count": 17,
|
|
102
|
+
"filtered_count": 3,
|
|
103
|
+
"hint": "Filtered out 3 muted chat(s) on this page (17 remaining); use --page-token to fetch more."
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Usage Scenarios
|
|
109
|
+
|
|
110
|
+
### Scenario 1: List my recent chats
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
lark-cli im +chat-list --sort active_time --page-size 10
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Scenario 2: List my non-muted chats sorted by activity
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
lark-cli im +chat-list --sort active_time --exclude-muted
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Scenario 3: Iterate all my chats programmatically
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
TOKEN=""
|
|
126
|
+
while :; do
|
|
127
|
+
RESP=$(lark-cli im +chat-list --page-size 100 --page-token "$TOKEN" --format json)
|
|
128
|
+
echo "$RESP" | jq -r '.data.chats[].chat_id'
|
|
129
|
+
HAS_MORE=$(echo "$RESP" | jq -r '.data.has_more')
|
|
130
|
+
[ "$HAS_MORE" = "true" ] || break
|
|
131
|
+
TOKEN=$(echo "$RESP" | jq -r '.data.page_token')
|
|
132
|
+
done
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Common Errors and Troubleshooting
|
|
136
|
+
|
|
137
|
+
| Symptom | Root Cause | Solution |
|
|
138
|
+
|---------|---------|---------|
|
|
139
|
+
| `invalid --page-size 101: must be between 1 and 100` | page-size is out of range | Use an integer between 1 and 100 |
|
|
140
|
+
| Permission denied | The current identity is not authorized for `im:chat:read` | 鉴权由沙箱运行环境提供,无需手动补登录;确认目标群对当前用户可见后重试 |
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# im +chat-members-list
|
|
2
|
+
|
|
3
|
+
List the members of a chat. Users and bots are returned in **separate buckets** — `users[]` and `bots[]` — with per-bucket totals (`user_total` / `bot_total`). Use `--member-types` to return only one kind.
|
|
4
|
+
|
|
5
|
+
This skill maps to the shortcut: `lark-cli im +chat-members-list` (internally calls `GET /open-apis/im/v1/chats/{chat_id}/members/list`).
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Single page (default)
|
|
11
|
+
lark-cli im +chat-members-list --chat-id oc_xxx
|
|
12
|
+
|
|
13
|
+
# Only users, or users + bots
|
|
14
|
+
lark-cli im +chat-members-list --chat-id oc_xxx --member-types user
|
|
15
|
+
lark-cli im +chat-members-list --chat-id oc_xxx --member-types user,bot
|
|
16
|
+
|
|
17
|
+
# Walk every page (capped by --page-limit; 0 = unlimited)
|
|
18
|
+
lark-cli im +chat-members-list --chat-id oc_xxx --page-all --page-limit 0
|
|
19
|
+
|
|
20
|
+
# Fetch one page starting at a specific cursor
|
|
21
|
+
lark-cli im +chat-members-list --chat-id oc_xxx --page-token "xxx"
|
|
22
|
+
|
|
23
|
+
# Continue automatically from a specific cursor
|
|
24
|
+
lark-cli im +chat-members-list --chat-id oc_xxx --page-token "xxx" --page-all
|
|
25
|
+
|
|
26
|
+
# JSON output / preview the request
|
|
27
|
+
lark-cli im +chat-members-list --chat-id oc_xxx --format json
|
|
28
|
+
lark-cli im +chat-members-list --chat-id oc_xxx --dry-run
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Parameters
|
|
32
|
+
|
|
33
|
+
| Parameter | Required | Limits | Description |
|
|
34
|
+
|------|------|------|------|
|
|
35
|
+
| `--chat-id <id>` | Yes | `oc_xxx` | Target chat |
|
|
36
|
+
| `--member-types <strings>` | No | `user`, `bot` (comma-separated or repeated) | Member types to return. Omitted = all |
|
|
37
|
+
| `--member-id-type <type>` | No | `open_id` (default), `union_id`, `user_id` | ID type for `member_id` in the response |
|
|
38
|
+
| `--page-size <n>` | No | 1-100, default 20 | Results per page. With `--page-all` and no explicit `--page-size`, the max (100) is used automatically to minimize round-trips |
|
|
39
|
+
| `--page-token <token>` | No | - | Starting cursor, normally returned by a previous response |
|
|
40
|
+
| `--page-all` | No | - | Automatically walk every page (capped by `--page-limit`) |
|
|
41
|
+
| `--page-limit <n>` | No | default 10, `0` = unlimited | Max pages to fetch with `--page-all` |
|
|
42
|
+
| `--page-delay <ms>` | No | default 200, `0` = no delay | Delay between pages during `--page-all` (throttle to avoid rate limits on large lists) |
|
|
43
|
+
| `--format json` | No | - | Output as JSON |
|
|
44
|
+
| `--dry-run` | No | - | Preview the request without executing it |
|
|
45
|
+
|
|
46
|
+
> The caller must be in the target chat, and must belong to the same tenant for internal chats.
|
|
47
|
+
|
|
48
|
+
## Output Fields
|
|
49
|
+
|
|
50
|
+
| Field | Description |
|
|
51
|
+
|------|------|
|
|
52
|
+
| `chat_id` | The queried chat ID |
|
|
53
|
+
| `users` | Array of user members (`member_id`, `name`, `tenant_key`, …) |
|
|
54
|
+
| `bots` | Array of bot members (`member_id`, `app_id`, `name`, …) |
|
|
55
|
+
| `user_total` / `bot_total` | Server-reported totals for each bucket |
|
|
56
|
+
| `truncations` | Non-empty when the server **capped a bucket** due to security config — see below |
|
|
57
|
+
| `has_more` / `page_token` | Paging signals from the final page fetched |
|
|
58
|
+
|
|
59
|
+
## Truncation: the result may be incomplete
|
|
60
|
+
|
|
61
|
+
The server applies a security cap to large member lists. When a bucket is capped, the response carries a `truncations[]` entry (e.g. `[{"limit": 100, "member_type": "user"}]`) **on the final page only**. The shortcut surfaces this two ways so it is never missed:
|
|
62
|
+
|
|
63
|
+
- **stderr**: `⚠️ member list truncated by server security config: user bucket capped at 100 — the list is INCOMPLETE.`
|
|
64
|
+
- **stdout JSON**: the `truncations` array is preserved verbatim in the output.
|
|
65
|
+
|
|
66
|
+
A truncated result is *not* fixable by paging further — it is a server-side cap. Treat `users`/`bots` as a partial list whenever `truncations` is non-empty.
|
|
67
|
+
|
|
68
|
+
## Pagination notes
|
|
69
|
+
|
|
70
|
+
- Default fetches a single page. Pass `--page-all` to drain every page.
|
|
71
|
+
- With `--page-all` and no explicit `--page-size`, the shortcut uses the maximum page size (100) so a full walk takes the fewest round-trips. An explicit `--page-size` is always honored.
|
|
72
|
+
- `--page-all` sleeps `--page-delay` ms (default 200) between pages to avoid hammering the API when a tenant has no server-side member cap and the list spans many pages. Set `--page-delay 0` to disable.
|
|
73
|
+
- `--page-all` stops at `--page-limit` pages (default 10). When it stops early, `has_more` stays `true` so you know the result is incomplete; re-run with `--page-limit 0` for everything.
|
|
74
|
+
- `--page-token` and `--page-all` together: automatic pagination starts at the supplied cursor and continues until exhaustion or `--page-limit`.
|
|
75
|
+
- Across pages, `users[]` and `bots[]` are concatenated; `truncations` / `has_more` / `page_token` come from the last page fetched.
|
|
76
|
+
|
|
77
|
+
## Common Errors and Troubleshooting
|
|
78
|
+
|
|
79
|
+
| Symptom | Root Cause | Solution |
|
|
80
|
+
|---------|---------|---------|
|
|
81
|
+
| `--chat-id is required` | `--chat-id` omitted | Provide the `oc_xxx` chat ID |
|
|
82
|
+
| `invalid --page-size 101: must be between 1 and 100` | out of range | Use 1-100 |
|
|
83
|
+
| `--member-types contains invalid value` | value other than `user`/`bot` | Use `user`, `bot`, or both |
|
|
84
|
+
| Permission denied | missing `im:chat.members:read` | 鉴权由沙箱运行环境提供,无需手动补登录;确认目标群对当前用户可见后重试 |
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# im +chat-search
|
|
2
|
+
|
|
3
|
+
Search the list of group chats visible to the current user, including chats the user belongs to and public chats visible to them. Supports keyword matching on chat names and member names, including pinyin and prefix fuzzy search.
|
|
4
|
+
|
|
5
|
+
This skill maps to the shortcut: `lark-cli im +chat-search` (internally calls `POST /open-apis/im/v2/chats/search`).
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Search chats by keyword
|
|
11
|
+
lark-cli im +chat-search --query "project"
|
|
12
|
+
|
|
13
|
+
# Restrict by search types
|
|
14
|
+
lark-cli im +chat-search --query "project" --search-types "private,public_joined"
|
|
15
|
+
|
|
16
|
+
# Filter by chat mode (group = regular group, topic = topic/thread group)
|
|
17
|
+
lark-cli im +chat-search --query "project" --chat-modes "topic"
|
|
18
|
+
|
|
19
|
+
# Filter by member open_ids (with keyword)
|
|
20
|
+
lark-cli im +chat-search --query "project" --member-ids "ou_xxx,ou_yyy"
|
|
21
|
+
|
|
22
|
+
# Search by member open_ids only
|
|
23
|
+
lark-cli im +chat-search --member-ids "ou_xxx,ou_yyy"
|
|
24
|
+
|
|
25
|
+
# Only show chats you created or manage
|
|
26
|
+
lark-cli im +chat-search --query "project" --is-manager
|
|
27
|
+
|
|
28
|
+
# Set page size
|
|
29
|
+
lark-cli im +chat-search --query "project" --page-size 10
|
|
30
|
+
|
|
31
|
+
# Pagination
|
|
32
|
+
lark-cli im +chat-search --query "project" --page-token "xxx"
|
|
33
|
+
|
|
34
|
+
# Fetch multiple pages automatically, up to 10 pages by default
|
|
35
|
+
lark-cli im +chat-search --query "project" --page-all
|
|
36
|
+
|
|
37
|
+
# JSON output
|
|
38
|
+
lark-cli im +chat-search --query "project" --format json
|
|
39
|
+
|
|
40
|
+
# Preview the request without executing it
|
|
41
|
+
lark-cli im +chat-search --query "project" --dry-run
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Parameters
|
|
45
|
+
|
|
46
|
+
| Parameter | Required | Limits | Description |
|
|
47
|
+
|------|------|------|------|
|
|
48
|
+
| `--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 |
|
|
49
|
+
| `--search-types <types>` | No | Comma-separated: `private`, `external`, `public_joined`, `public_not_joined` | Restrict the visible chat types returned by search |
|
|
50
|
+
| `--chat-modes <modes>` | No | Comma-separated: `group`, `topic` | Filter by chat mode (server-side): `group` = regular group, `topic` = topic/thread group |
|
|
51
|
+
| `--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` |
|
|
52
|
+
| `--is-manager` | No | - | Only show chats you created or manage |
|
|
53
|
+
| `--disable-search-by-user` | No | - | Disable member-name-based matching and search by group name only |
|
|
54
|
+
| `--sort <field>` | No | `create_time`, `update_time`, `member_count` | Sort field (always descending) |
|
|
55
|
+
| `--page-size <n>` | No | 1-100, default 20 | Number of results per page |
|
|
56
|
+
| `--page-token <token>` | No | - | Starting cursor, normally returned by a previous response |
|
|
57
|
+
| `--page-all` | No | - | Automatically fetch and merge subsequent pages; capped by `--page-limit` |
|
|
58
|
+
| `--page-limit <n>` | No | 1-1000, default 10 | Maximum pages fetched by `--page-all` |
|
|
59
|
+
| `--exclude-muted` | No | - | Drop chats the current user has muted (do-not-disturb); see "Filtering muted chats" below |
|
|
60
|
+
| `--format json` | No | - | Output as JSON |
|
|
61
|
+
| `--dry-run` | No | - | Preview the request without executing it |
|
|
62
|
+
|
|
63
|
+
With `--page-all`, `--page-token` sets the starting cursor. If `meta.pagination.complete=false`, resume from `meta.pagination.next_token` or raise `--page-limit`.
|
|
64
|
+
|
|
65
|
+
> **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).
|
|
66
|
+
|
|
67
|
+
## Output Fields
|
|
68
|
+
|
|
69
|
+
| Field | Description |
|
|
70
|
+
|------|------|
|
|
71
|
+
| `chat_id` | Chat ID (`oc_xxx` format) |
|
|
72
|
+
| `name` | Chat name |
|
|
73
|
+
| `description` | Chat description |
|
|
74
|
+
| `owner_id` | Owner ID |
|
|
75
|
+
| `external` | Whether the chat is external |
|
|
76
|
+
| `chat_status` | Chat status (`normal` / `dissolved` / `dissolved_save`) |
|
|
77
|
+
|
|
78
|
+
## Filtering muted chats
|
|
79
|
+
|
|
80
|
+
`--exclude-muted` 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.
|
|
81
|
+
|
|
82
|
+
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:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"chats": [...],
|
|
87
|
+
"filter": {
|
|
88
|
+
"applied": "exclude_muted",
|
|
89
|
+
"fetched_count": 20,
|
|
90
|
+
"returned_count": 19,
|
|
91
|
+
"filtered_count": 1,
|
|
92
|
+
"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."
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
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"`.
|
|
98
|
+
|
|
99
|
+
## Usage Scenarios
|
|
100
|
+
|
|
101
|
+
### Scenario 1: Search chats that contain a keyword
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
lark-cli im +chat-search --query "design review"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Scenario 2: Search a chat and list its members
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
CHAT_ID=$(lark-cli im +chat-search --query "project" --format json | jq -r '.data.chats[0].chat_id')
|
|
111
|
+
lark-cli im +chat-members-list --chat-id "$CHAT_ID"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Common Errors and Troubleshooting
|
|
115
|
+
|
|
116
|
+
| Symptom | Root Cause | Solution |
|
|
117
|
+
|---------|---------|---------|
|
|
118
|
+
| `--query and --member-ids cannot both be empty` | Both were omitted | Provide at least `--query` or `--member-ids` |
|
|
119
|
+
| Empty results | No visible chats matched the keyword or filters | Relax the keyword or filters and try again |
|
|
120
|
+
| `invalid --page-size 101: must be between 1 and 100` | page-size is out of range | Use an integer between 1 and 100 |
|
|
121
|
+
| Permission denied | The current identity is not authorized for `im:chat:read` | 鉴权由沙箱运行环境提供,无需手动补登录;确认目标群对当前用户可见后重试 |
|
|
122
|
+
|
|
123
|
+
## AI Usage Guidance
|
|
124
|
+
|
|
125
|
+
When the user asks to search chats, follow these rules:
|
|
126
|
+
|
|
127
|
+
1. **At least one filter required:** `--query` and `--member-ids` cannot both be empty. Either alone or combined together are valid.
|
|
128
|
+
2. **Search scope is limited:** only chats visible to the current user can be found (joined chats plus public chats). This is not a global search over all chats.
|
|
129
|
+
3. **Control result volume:** the result set may be large. Use `--page-size` deliberately.
|
|
130
|
+
4. **Suggest follow-up actions:** after finding a chat, a common next step is listing its members (`im +chat-members-list`).
|
|
131
|
+
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.
|
|
132
|
+
|
|
133
|
+
## References
|
|
134
|
+
|
|
135
|
+
- [lark-im](../README.md) - all IM commands
|