SuperAPI AI Directory

lark-wiki

Office & productivity

View repository

Updated 10-14 05: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 limits 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 limitation: under this identity, a department ID (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 state that this path is not feasible.
  • If the user explicitly requests "run as bot" and the target is a department, you must stop and explain that the bot path cannot complete it; do not silently switch to --as user。

Identity selection: Prefer using the user identity

Knowledge spaces and nodes are both personal resources of the user.As a policy, you should preferentially explicitly use --as user(the CLI's --as default is auto); without --as , it is often parsed as bot, and what is listed is the spaces belonging to the app rather than the user's. Only use --as botwhen the user explicitly requests the "app / bot perspective" (still subject to the hard limits on member management above).

Quick decisions

  • 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 a full Drive search for 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 the unified entry resolution, resource inventory, classification plan, pre-write confirmation, and result verification for Drive / Wiki / personal document library.
  • The user wants tomove an existing Wiki node out of the wiki and place it in a Drive folder or the root directory of "My Space": 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 execution.
  • 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 app / bot perspective), then call lark-cli wiki +node-get --node-token '<wiki_url>' --as user --format json, 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 a name or URL is given:must notpass the name / URL as-is to --space-id; the real space_idmust be resolved first. 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 json, read data.space_id; when downstream uses bot, change the identity in the example to --as bot. Resolution and deletion must use the same identity.
    • Only know the name:lark-cli wiki spaces list --format json, page through while collecting items and match exactly by name ;once any page accumulates at least 1 exact match, stop paging. 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 hits, 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 hit".
    • 0 hits: stop and ask the user whether the name was misspelled or the caller lacks permission;do notchange the name yourself and retry.
    • After the user has explicitly selected, execute lark-cli wiki +delete-space --space-id <ID> --yes(high-risk write operation, must be explicitly --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 using lark-cli wiki +node-create。
  • The user wants torename a Wiki node in place / modify the node title: use lark-cli drive +update-title --url '<wiki_url>' --title '<new_title>'. This command keeps the same node_token, and based on the API response gives the exact missing scope and authorization hints; do not explore the wiki.nodes of the raw update_title endpoint, and do not implement 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 hits invalid_parameters、not_found、permission_denied , 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.
  • The user says "add a member/admin to the knowledge base": first resolve the target into one of the four categories "user / group / department / app", then decide --member-type; do not call wiki +member-add first and then infer the type from the error.
  • The user says "department + bot": this is a known unsupported path. Do not keep trying wiki +member-add --as bot; directly prompt that it must be changed to --as user, or clearly inform that the current request 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 --member-type and --member-role(if unknown, first wiki +member-list look it up).

Shortcuts (prefer using these first)

Shortcut is a high-level wrapper for common operations (lark-cli wiki +<verb> [flags]). For operations with a Shortcut, prefer using it.

Always use wiki +node-getto get or resolve Wiki nodes, 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 process

  • 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, default to prioritizing --member-type=openid: 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 Use only 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 my_library to the corresponding real space_id, then execute wiki +move、wiki +node-create or other Wiki write operations
  • Do not degrade to space_id just because an explicit drive +move
  • If the user explicitly says Drive folder, cloud space (cloud disk/cloud storage) root directory,我的空间, then branch 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 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, comments and permission management → lark-drive