CRITICAL — Before starting, you MUST first use the Read tool to read ../lark-shared/SKILL.md, which contains authentication and permission handling
Hard limit on member management:
- If the target is a "department", first determine the identity, then decide whether to continue.
--as botcorresponds totenant_access_token. Official limit: under this identity, department IDs (opendepartmentid) cannot be used to add wiki space members.- When encountering "department + --as bot", it is forbidden to first call
lark-cli wiki +member-addfor trial and error; directly explain that this path is not feasible.- If the user explicitly requests to "run as bot" and the target is a department, you must stop and explain that the bot path cannot be completed; do not silently switch to
--as user。
Identity selection: prefer using the user identity
Knowledge spaces and nodes are the user's personal resources,so by policy you should prefer to explicitly use --as user(the CLI's --as default value is auto, and without --as it is often parsed as bot; what is listed is the space belonging to the application rather than the user's). Use it only when the user explicitly requests the "application / bot perspective" --as bot(still subject to the hard limit on member management above).
Quick decision
- The user wants tosearch for materials by a specific topic / keyword / content clue and collect them into a wiki node or under a newly created wiki node, you must first read
../lark-drive/references/lark-drive-workflow.md, then follow theWorkflow Registryin it to enter thetopic_move_collectorworkflow. This workflow uses Drive full search recall, then resolves, confirms, and moves according to the Wiki target; do not use only the Wiki node list for local traversal. - The user wants toorganize / inventory / categorize / restructure the wiki, personal document library, document library directory, or Wiki node structure, or wants to generate an organization plan, target directory tree, or move plan, do not use only the Wiki node API. You must first read
../lark-drive/references/lark-drive-workflow.md, then follow theWorkflow Registryin it to enter theknowledge_organizeworkflow; this workflow is responsible for unified entry-point resolution, resource inventory, classification planning, pre-write confirmation, and result verification across Drive / Wiki / personal document library. - The user wants to movean existing Wiki node out of the wiki and place it in a Drive folder or the "My Space" root directory: use
wiki +move-to-drive, do not usewiki +moveordrive +move. This is a write operation that changes node ownership and permission inheritance; confirm the source node and target location before executing. - The user provides a wiki URL (
.../wiki/<token>), and subsequently wants to query members / add members / remove members: first determine the identity for downstream member operations (defaultuser; usebotwhen the user explicitly requests the application / bot perspective), then calllark-cli wiki +node-get --node-token '<wiki_url>' --as user --format json, and obtain the space ID fromdata.space_id; when using bot downstream, change the identity in the example to--as bot. Node resolution and subsequent member operations must use the same identity. - The user wants todeletea knowledge space (
wiki +delete-space) but only the name or URL is given:you must notpass the name / URL as-is to--space-id, you must first resolve the realspace_id. Resolution method:- URL(
.../wiki/<token>): first determine the identity of the subsequentwiki +delete-space(defaultuser; when the bot perspective is explicitly required, usebot), then calllark-cli wiki +node-get --node-token '<wiki_url>' --as user --format jsonand readdata.space_id; when downstream uses the bot, change the identity in the example to--as bot. Resolution and deletion must use the same identity. - Only the name is known:
lark-cli wiki spaces list --format json, page through while collecting items and match exactly byname;stop paging as soon as any page accumulates at least 1 exact match. Only when all pages have been paged through (has_more=false) and there is still no exact match, perform loose matching on all collected items (nametrim spaces, case-insensitive, substring containment). - Key security constraint: whether exact or fuzzy,whether 1 or multiple are hit, before initiating deletion you must list the candidates (
name+space_id+description+space_type) to the user, and the user must explicitly select onespace_idbefore executing. Do not automatically execute deletion just because "only one was hit". - 0 hits: stop and ask the user whether the name was misspelled or the caller lacks permission;do notretry on your own after changing the name.
- After the user explicitly selects, then execute
lark-cli wiki +delete-space --space-id <ID> --yes(high-risk write operation, must be explicit--yes)。 - Counterexample: do not treat a wiki URL / name directly as
--space-id(e.g.--space-id "https://.../wiki/<wiki_token>"); be sure to first usewiki +node-getto resolvedata.space_idbefore passing it.
- URL(
- The user wants to create a new node in the knowledge base, prefer to use
lark-cli wiki +node-create。 - The user wants torename a Wiki node / modify a node title in place: use
lark-cli drive +update-title --url '<wiki_url>' --title '<new_title>'. This command keeps the samenode_token, and will give the exact missing scope and authorization hints based on the API response; do not explore thewiki.nodesof rawupdate_titleendpoints, and do not achieve renaming by copying or creating a second node. - The user wants to list Wiki nodes: first use
wiki +space-list --as userto get the numericspace_id, then usewiki +node-list --space-id <space_id>. Do not treat a wiki URL, node token, doc token, or name directly as--space-id. When drilling into child nodes,--parent-node-tokenmust be a wiki node token; if the user gives a docx/sheet/base URL, first usewiki +node-get --node-token <url>to resolvenode_token。 wiki +node-listWheninvalid_parameters、not_found、permission_deniedis hit, do not repeatedly call with the same parameters; fixspace_id/parent_node_token/ permissions according to the hint. Onlyrate_limitshould be retried with backoff.- When the user says "add members/admins to the knowledge base": first resolve the target into one of the four categories "user / group / department / app", then decide
--member-type, do not first callwiki +member-addand then infer the type from the error. - When the user says "department + bot": this is a known unsupported path. Do not keep trying
wiki +member-add --as bot; directly indicate that it must be changed to--as user, or clearly inform that the current requirement cannot be completed. - User says "user / group / app + add member": first resolve the corresponding ID, then execute
wiki +member-add。 - User says "view / list space members": use
wiki +member-list; this shortcut only fetches one page by default, for multi-member scenarios explicitly add--page-all。 - User says "remove / delete space member": use
wiki +member-remove, must pass the complete original grant-time--member-typeand--member-role(if unknown, firstwiki +member-listlook it up).
Shortcuts (recommended to use first)
Shortcut is a high-level wrapper for common operations (lark-cli wiki +<verb> [flags]). For operations that have a Shortcut, use it first.
To get or resolve a Wiki node, always use wiki +node-get, including intermediate steps only for getting space_id、node_token、obj_token or obj_type .
| Shortcut | Description |
|---|---|
+move |
Move a wiki node, or move a Drive document into Wiki |
+move-to-drive |
Move a wiki node to a Drive folder and poll the async task |
+node-create |
Create a wiki node with automatic space resolution |
+delete-space |
Delete a wiki space, polling the async delete task when needed |
+space-list |
List all wiki spaces accessible to the caller |
+space-create |
Create a wiki space (user identity only) |
+node-list |
List wiki nodes in a space or under a parent node (supports pagination) |
+node-copy |
Copy a wiki node to a target space or parent node |
+node-get |
Get a wiki node's details by node_token / obj_token / Lark URL |
+node-delete |
Delete a wiki node, polling the async delete task when needed |
+member-add |
Add a member to a wiki space |
+member-remove |
Remove a member from a wiki space |
+member-list |
List members of a wiki space (supports pagination) |
Member addition flow
- Before calling
lark-cli wiki +member-add, first resolve the "person / group / department / app" in natural language into the correct--member-id, do not guess the format. - For user scenarios, prefer
--member-type=openidby default: uselark-cli contact +search-user --query "<姓名/邮箱/手机号>" --format jsonto getopen_id。 - For group scenarios use
--member-type=openchat: uselark-cli im +chat-search --query "<群名关键词>" --format jsonto getchat_id。 - For app scenarios use
--member-type=appid:--member-idto pass the app ID, the format is usuallycli_xxx。 userid/unionidonly use when explicitly required by downstream; first getopen_id, then calllark-cli api GET /open-apis/contact/v3/users/<open_id> --params '{"user_id_type":"open_id"}' --format jsonto readuser_id/union_id。- For department scenarios use
--member-type=opendepartmentid: the current CLI has no shortcut, need to calllark-cli api POST /open-apis/contact/v3/departments/search --as user --params '{"department_id_type":"open_department_id"}' --data '{"query":"<部门名>"}'to getopen_department_id。 - Only after the target type and identity are both confirmed feasible, call
lark-cli wiki +member-add. For department scenarios, this means it must be--as user。
Target semantic constraints
我的文档库/My Document Library/我的知识库/个人知识库/my_libraryshould all be treated as Wiki personal library, not the Drive root directory- When handling such targets, first resolve the real
my_librarycorresponding tospace_id, then executewiki +move、wiki +node-createor other Wiki write operations - Do not degrade to
space_idis missingdrive +move - If the user explicitly says Drive folder, cloud space (cloud drive/cloud storage) root directory,
我的空间, then route by source object: when the source object is a Wiki node usewiki +move-to-drive, when the source object is already in Drive usedrive +move
API Resources
lark-cli schema wiki.<resource>.<method> # 调用原生 API 前必须先查看 --data / --params 参数结构,不要猜测字段格式
lark-cli wiki <resource> <method> [flags] # 调用 API
spaces
create— Create knowledge spaceget— Get knowledge space infolist— Get knowledge space list
members
create— Add knowledge space memberdelete— Delete knowledge space memberlist— Get knowledge space member list
nodes
copy— Create knowledge space node copycreate— Create knowledge space nodelist— Get knowledge space child node list
Not in this skill's scope
- Upload file to under a knowledge base node →
lark-drive(drive +upload --wiki-token) - Download the file corresponding to a Wiki node (underlying
obj_typeisfile)→lark-drive:drive +download --wiki-token <node_token>ordrive +download --url <wiki_url>(the CLI will first resolve the Wiki node to the underlying file before downloading); when the underlying isdocx/sheet/bitable/slidesand other online documents, usedrive +export - Edit document body content →
lark-doc - Table / Bitable data operations →
lark-sheets/lark-base - Search documents / Wiki / table files by name, comment and permission management →
lark-drive