SuperAPI AI Directory

lark-wiki

Office & productivity

View repository

Updated 10-15 08:33

About this skill

wiki (v2)

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 bot corresponds to tenant_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-add for 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 the Workflow Registry in it to enter the topic_move_collector workflow. 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 the Workflow Registry in it to enter the knowledge_organize workflow; 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 use wiki +move or drive +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 (default user; use botwhen the user explicitly requests the application / bot perspective), then call lark-cli wiki +node-get --node-token '<wiki_url>' --as user --format json, and obtain the space ID from data.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 real space_id. Resolution method:
    • URL(.../wiki/<token>): first determine the identity of the subsequent wiki +delete-space (default user; when the bot perspective is explicitly required, use bot), then call lark-cli wiki +node-get --node-token '<wiki_url>' --as user --format jsonand read data.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 by name ;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 (name trim 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 one space_id before 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 use wiki +node-get to resolve data.space_id before passing it.
  • 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 same node_token, and will give the exact missing scope and authorization hints based on the API response; do not explore the wiki.nodes of raw update_title endpoints, 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 user to get the numeric space_id, then use wiki +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-token must be a wiki node token; if the user gives a docx/sheet/base URL, first use wiki +node-get --node-token <url> to resolve node_token。
  • wiki +node-list When invalid_parameters、not_found、permission_denied is hit, do not repeatedly call with the same parameters; fix space_id / parent_node_token / permissions according to the hint. Only rate_limit should 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 call wiki +member-add and 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-type and --member-role(if unknown, first wiki +member-list look 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: use lark-cli contact +search-user --query "<姓名/邮箱/手机号>" --format json to get open_id。
  • For group scenarios use --member-type=openchat: use lark-cli im +chat-search --query "<群名关键词>" --format json to get chat_id。
  • For app scenarios use --member-type=appid:--member-id to pass the app ID, the format is usually cli_xxx。
  • userid / unionid only use when explicitly required by downstream; first get open_id, then call lark-cli api GET /open-apis/contact/v3/users/<open_id> --params '{"user_id_type":"open_id"}' --format json to read user_id / union_id。
  • For department scenarios use --member-type=opendepartmentid: the current CLI has no shortcut, need to call lark-cli api POST /open-apis/contact/v3/departments/search --as user --params '{"department_id_type":"open_department_id"}' --data '{"query":"<部门名>"}' to get open_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_library should all be treated as Wiki personal library, not the Drive root directory
  • When handling such targets, first resolve the real my_library corresponding to space_id, then execute wiki +move、wiki +node-create or other Wiki write operations
  • Do not degrade to space_id is missing drive +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 use wiki +move-to-drive, when the source object is already in Drive use drive +move

API Resources

lark-cli schema wiki.<resource>.<method>   # 调用原生 API 前必须先查看 --data / --params 参数结构,不要猜测字段格式
lark-cli wiki <resource> <method> [flags]  # 调用 API

spaces

  • create — Create knowledge space
  • get — Get knowledge space info
  • list — Get knowledge space list

members

  • create — Add knowledge space member
  • delete — Delete knowledge space member
  • list — Get knowledge space member list

nodes

  • copy — Create knowledge space node copy
  • create — Create knowledge space node
  • list — 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_type is file)→ lark-drive:drive +download --wiki-token <node_token> or drive +download --url <wiki_url>(the CLI will first resolve the Wiki node to the underlying file before downloading); when the underlying is docx/sheet/bitable/slides and other online documents, use drive +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