Operate the Feishu Knowledge Base (Wiki), including getting node information, exporting documents, and listing spaces and nodes.
Core Concepts
Markdown as an Intermediate State: Knowledge base documents and local files are converted between each other via the Markdown format, and intermediate files are stored in the /tmp directory.
Usage
/feishu-wiki get <node_token|url> # 获取节点信息
/feishu-wiki export <node_token|url> # 导出为 Markdown
/feishu-wiki spaces # 列出知识空间
/feishu-wiki nodes <space_id> # 列出空间下的节点
CLI Command Details
1. Get Knowledge Base Node Information
# 通过 Token 获取
feishu-cli wiki get <node_token>
# 通过 URL 获取(自动解析)
feishu-cli wiki get https://xxx.feishu.cn/wiki/<node_token>
feishu-cli wiki get https://xxx.larkoffice.com/wiki/<node_token>
Output Example:
知识库节点信息:
空间 ID: <space_id>
节点 Token: <node_token>
文档 Token: <document_token>
文档类型: docx
节点类型: origin
标题: 示例文档标题
有子节点: true
创建者: ou_xxx
所有者: ou_xxx
2. Export Knowledge Base Document as Markdown
# 基本导出(输出到 stdout)
feishu-cli wiki export <node_token>
# 导出到文件
feishu-cli wiki export <node_token> --output /tmp/wiki_doc.md
# 通过 URL 导出
feishu-cli wiki export https://xxx.larkoffice.com/wiki/<token> -o doc.md
# 下载图片到本地
feishu-cli wiki export <node_token> -o doc.md --download-images --assets-dir ./images
Parameter Description:
| Parameter | Description | Default Value |
|---|---|---|
--output, -o |
Output file path | stdout |
--download-images |
Download images locally | false |
--assets-dir |
Image save directory | ./assets |
3. List Knowledge Spaces
feishu-cli wiki spaces
# 指定每页数量
feishu-cli wiki spaces --page-size 20
Parameter Description:
| Parameter | Description | Default Value |
|---|---|---|
--page-size |
Number per page | 50 |
Output Example:
知识空间列表:
1. 空间ID: <space_id>
名称: 技术文档
类型: team
2. 空间ID: 7123456789012345678
名称: 个人笔记
类型: personal
4. List Nodes Under a Space
# 列出根节点
feishu-cli wiki nodes <space_id>
# 列出指定父节点下的子节点
feishu-cli wiki nodes <space_id> --parent <node_token>
# 指定每页数量
feishu-cli wiki nodes <space_id> --page-size 20
Parameter Description:
| Parameter | Description | Default Value |
|---|---|---|
--parent |
Parent node Token (if not specified, lists root nodes) | Root node |
--page-size |
Number per page | 50 |
Output Example:
节点列表(空间: <space_id>):
1. <node_token_1>
标题: 示例文档 1
类型: docx
2. <node_token_2>
标题: API Reference
类型: docx
URL Format Support
| URL Format | Description |
|---|---|
https://xxx.feishu.cn/wiki/<token> |
Feishu China version |
https://xxx.larkoffice.com/wiki/<token> |
Feishu International/Internal version |
https://xxx.larksuite.com/wiki/<token> |
Lark International version |
Typical Workflows
Export Knowledge Base Document for Analysis
# 1. 获取节点信息
feishu-cli wiki get https://xxx.feishu.cn/wiki/<node_token>
# 2. 导出为 Markdown
feishu-cli wiki export <node_token> -o /tmp/wiki_doc.md
# 3. 分析文档内容
cat /tmp/wiki_doc.md
Batch Export Space Documents
# 1. 列出空间
feishu-cli wiki spaces
# 2. 列出节点
feishu-cli wiki nodes <space_id>
# 3. 逐个导出
feishu-cli wiki export <token1> -o /tmp/doc1.md
feishu-cli wiki export <token2> -o /tmp/doc2.md
Identify Directory Nodes
Knowledge base documents may bedirectory nodes(containing child nodes), identified in the following ways:
1. Use wiki get to view node information
feishu-cli wiki get <node_token>
The has_child field in the output indicates whether there are child nodes:
知识库节点信息:
空间 ID: xxx
节点 Token: xxx
文档 Token: xxx
文档类型: docx
节点类型: origin
标题: 目录节点示例
有子节点: true <-- 表示这是目录节点
2. Identify Directory Nodes When Exporting
When exporting a directory node, if the document content appears as:
[Wiki 目录 - 使用 'wiki nodes <space_id> --parent <node_token>' 获取子节点列表]
This indicates it is aWiki directory block(block_type=42), meaning the node is a knowledge base directory, and the child document list is stored in the knowledge base metadata rather than in the document content.
3. Get Child Node List
For directory nodes, use the following command to get child nodes:
# 1. 先获取节点信息,记录 space_id
feishu-cli wiki get <node_token>
# 2. 列出该节点下的子节点
feishu-cli wiki nodes <space_id> --parent <node_token>
Example Workflow:
# 获取知识库节点
feishu-cli wiki get WvHQwCaDKiJZAjkm354cvZNjnxd
# 输出:有子节点: true, 空间 ID: 7540365701802885139
# 获取子节点列表
feishu-cli wiki nodes 7540365701802885139 --parent WvHQwCaDKiJZAjkm354cvZNjnxd
# 输出:列出所有子节点及其文档类型
Notes
- Knowledge Base vs Regular Documents: Knowledge bases use
node_token, regular documents usedocument_id - Permission Requirements: The application needs to have the
wiki:wiki:readonlypermission - Intermediate Files: Exported Markdown is stored by default in the
/tmpdirectory - Directory Nodes: The content of a directory node may be empty or contain only
WikiCatalogblocks (type=42), with the actual content in the child nodes
Image Handling (Important)
When exporting documents, be sure to download images so as to understand the image content in the document:
# 导出并下载图片
feishu-cli wiki export <node_token> \
--output /tmp/wiki_doc.md \
--download-images \
--assets-dir /tmp/wiki_assets
# 查看下载的图片
ls /tmp/wiki_assets/
# 使用 Read 工具读取图片(Claude 支持多模态)
# Read /tmp/wiki_assets/image_1.png
Process:
- When exporting, use
--download-images --assets-dir <dir>Download image - Use
lsto view the downloaded image files - Use the Read tool to read the images one by one and understand the image content
- Integrate the image content into the document analysis