SuperAPI AI Directory

lark-wiki

Office & productivity

View repository

Updated 10-13 21:32

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 restriction: with this identity, you cannot use a department ID (opendepartmentid) to add a knowledge space member.
  • 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 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 both the user's personal resources;as a policy, you should preferentially explicitly use --as user(the CLI's --as default value is auto, and without --as it is often parsed as bot, which lists the spaces the application belongs to rather than the user's). Only use --as botwhen the user explicitly requests the "application / bot perspective" (still subject to the hard limits on member management above).

Quick decisions

  • When the user wants tosearch for materials by a specific topic / keyword / content clue and collect them into a knowledge base node or under a newly created knowledge base 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 full Drive search for recall, then resolves, confirms, and moves according to the Wiki target; do not merely use the Wiki node list for a local traversal.
  • When the user wants toorganize / inventory / categorize / restructure a knowledge base, 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 only use 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 of Drive / Wiki / personal document library, resource inventory, classification plan, pre-write confirmation, and result verification.
  • When the user wants to movean existing Wiki node out of the knowledge base 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 executing.
  • When the user provides a knowledge base URL (.../wiki/<token>), and subsequently wants to query members / add members / remove members: first determine the identity for the 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, to 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.
  • When the user wants todeletea knowledge space (wiki +delete-space) but only provided a name or URL: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 for the subsequent wiki +delete-space (default user; use botwhen the bot perspective is explicitly requested), then call lark-cli wiki +node-get --node-token '<wiki_url>' --as user --format json, read data.space_id; when downstream uses the bot, change the identity in the example to --as bot. Parsing and deletion must use the same identity.
    • Name only:lark-cli wiki spaces list --format json, collect items while paging and match exactly by name ;stop paging once any page has accumulated at least 1 exact match. Only when all pages have been paged through (has_more=false) and there is still no exact match should you perform a loose match on all collected items (name trim spaces, case-insensitive, substring containment).
    • Key security constraint: whether exact or fuzzy,whether 1 match or multiple matches, 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 match" was found.
    • 0 matches: 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 explicitly selects, then execute lark-cli wiki +delete-space --space-id <ID> --yes(high-risk write operation, must be explicit --yes)。
    • Counterexample: do not directly treat a wiki URL / name as --space-id(e.g. --space-id "https://.../wiki/<wiki_token>"); be sure to first use wiki +node-get to parse out 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 will provide the accurate missing scope and authorization hints based on the API response; do not explore the raw wiki.nodes 's 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 directly treat a wiki URL, node token, doc token, or name as --space-id. When drilling into child nodes, --parent-node-token must be a wiki node token; if the user provides a docx/sheet/base URL, first use wiki +node-get --node-token <url> to parse out node_token。
  • wiki +node-list hit 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 parse 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.
  • 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 state that the current requirement cannot be completed.
  • The user says "user / group / app + add member": first parse the corresponding ID, then execute wiki +member-add。
  • The 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。
  • The user says "remove / delete space member": use wiki +member-remove, and you must pass in the full --member-type and --member-rolefrom the original grant (if unknown, first wiki +member-list check).

Shortcuts (recommended for priority use)

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 parse a Wiki node, always use wiki +node-get, including intermediate steps whose only purpose is to get 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 parse the "person / group / department / app" from the natural language into the correct --member-id, and do not guess the format.
  • For user scenarios, prioritize --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 Use it only when downstream explicitly requires it; 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, so you 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 have both been confirmed to be 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 just because an explicit 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 information
  • 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 a file 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 type 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 / spreadsheet files by name, comment and permission management → lark-drive