feishu-cli-read
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese飞书文档阅读技能
Feishu Document Reading Skill
从飞书云文档或知识库读取内容,转换为 Markdown 格式后进行分析和展示。
Read content from Feishu cloud documents or knowledge bases, convert it to Markdown format, then analyze and display it.
核心概念
Core Concepts
Markdown 作为中间态:本地文档与飞书云文档之间通过 Markdown 格式进行转换,中间文件存储在 目录中。
/tmpMarkdown as intermediate state: Conversion between local documents and Feishu cloud documents is completed through Markdown format, and intermediate files are stored in the directory.
/tmp使用方法
Usage
bash
/feishu-read <document_id>
/feishu-read <node_token>
/feishu-read <url>bash
/feishu-read <document_id>
/feishu-read <node_token>
/feishu-read <url>执行流程
Execution Flow
-
解析参数
- 判断 URL 类型:
- → 普通文档,使用
/docx/doc export - → 知识库文档,使用
/wiki/wiki export
- 如果是 Token,根据格式判断类型
- 判断 URL 类型:
-
导出为 Markdown(含图片下载)普通文档:bash
feishu-cli doc export <document_id> --output /tmp/feishu_doc.md --download-images --assets-dir /tmp/feishu_assets知识库文档:bashfeishu-cli wiki export <node_token> --output /tmp/feishu_wiki.md --download-images --assets-dir /tmp/feishu_assets重要:务必使用参数下载文档中的图片到本地。--download-images可选参数:- :在 Markdown 顶部添加 YAML front matter(含标题和文档 ID)
--front-matter - :保留文本颜色和背景色(输出为 HTML
--highlight标签)<span> - :展开 @用户为友好格式(默认开启,需要 contact:user.base:readonly 权限)
--expand-mentions
-
读取文本内容
- 使用 Read 工具读取导出的 Markdown 文件
- 分析文档结构和文本内容
-
读取并理解图片内容
- 检查 目录是否有下载的图片
/tmp/feishu_assets - 使用 Read 工具逐个读取图片文件,理解图片内容
- 将图片内容整合到文档分析中
bash# 列出下载的图片 ls /tmp/feishu_assets/ # 使用 Read 工具查看图片(Claude 支持多模态) # Read /tmp/feishu_assets/image_1.png - 检查
-
报告结果
- 提供文档摘要(包含图片内容描述)
- 保留 Markdown 文件和图片供用户进一步操作
-
Parse parameters
- Judge URL type:
- → Regular document, use
/docx/doc export - → Knowledge base document, use
/wiki/wiki export
- If it is a Token, judge the type according to the format
- Judge URL type:
-
Export to Markdown (including image download)Regular document:bash
feishu-cli doc export <document_id> --output /tmp/feishu_doc.md --download-images --assets-dir /tmp/feishu_assetsKnowledge base document:bashfeishu-cli wiki export <node_token> --output /tmp/feishu_wiki.md --download-images --assets-dir /tmp/feishu_assetsImportant: Be sure to use theparameter to download images in the document to local.--download-imagesOptional parameters:- : Add YAML front matter (including title and document ID) at the top of Markdown
--front-matter - : Retain text color and background color (output as HTML
--highlighttags)<span> - : Expand @ users to friendly format (enabled by default, requires contact:user.base:readonly permission)
--expand-mentions
-
Read text content
- Use the Read tool to read the exported Markdown file
- Analyze document structure and text content
-
Read and understand image content
- Check if there are downloaded images in the directory
/tmp/feishu_assets - Use the Read tool to read image files one by one to understand the image content
- Integrate image content into document analysis
bash# List downloaded images ls /tmp/feishu_assets/ # Use Read tool to view images (Claude supports multimodal) # Read /tmp/feishu_assets/image_1.png - Check if there are downloaded images in the
-
Report results
- Provide document summary (including image content description)
- Retain Markdown files and images for further user operations
输出格式
Output Format
向用户报告:
- 文档标题
- 文档结构概要(标题层级)
- 内容摘要(关键信息)
- 图片内容描述(如有图片)
- Markdown 文件路径(供后续使用)
- 图片文件路径(如有下载)
Report to users:
- Document title
- Document structure overview (title hierarchy)
- Content summary (key information)
- Image content description (if there are images)
- Markdown file path (for subsequent use)
- Image file path (if downloaded)
支持的 URL 格式
Supported URL Formats
| URL 格式 | 类型 | 命令 |
|---|---|---|
| 普通文档 | |
| 知识库 | |
| 普通文档 | |
| 知识库 | |
| URL Format | Type | Command |
|---|---|---|
| Regular Document | |
| Knowledge Base | |
| Regular Document | |
| Knowledge Base | |
示例
Examples
bash
undefinedbash
undefined读取普通文档
Read regular document
/feishu-read <document_id>
/feishu-read https://xxx.feishu.cn/docx/<document_id>
/feishu-read <document_id>
/feishu-read https://xxx.feishu.cn/docx/<document_id>
读取知识库文档
Read knowledge base document
/feishu-read <node_token>
/feishu-read https://xxx.feishu.cn/wiki/<node_token>
undefined/feishu-read <node_token>
/feishu-read https://xxx.feishu.cn/wiki/<node_token>
undefined图片处理流程(重要)
Image Processing Flow (Important)
文档中的图片需要特别处理才能理解其内容:
Images in documents require special processing to understand their content:
步骤 1:导出时下载图片
Step 1: Download images when exporting
bash
undefinedbash
undefined知识库文档
Knowledge base document
feishu-cli wiki export <node_token>
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
feishu-cli wiki export <node_token>
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
普通文档
Regular document
feishu-cli doc export <document_id>
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
undefinedfeishu-cli doc export <document_id>
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
--output /tmp/doc.md
--download-images
--assets-dir /tmp/doc_assets
undefined步骤 2:检查下载的图片
Step 2: Check downloaded images
bash
ls -la /tmp/doc_assets/bash
ls -la /tmp/doc_assets/输出示例:
Output example:
image_1.png (403KB)
image_1.png (403KB)
image_2.png (394KB)
image_2.png (394KB)
undefinedundefined步骤 3:使用 Read 工具查看图片
Step 3: View images with Read tool
Claude 支持多模态,可以直接理解图片内容:
undefinedClaude supports multimodal, and can directly understand image content:
undefined在 Claude 中使用 Read 工具读取图片
Use Read tool in Claude to read images
Read /tmp/doc_assets/image_1.png
Read /tmp/doc_assets/image_2.png
undefinedRead /tmp/doc_assets/image_1.png
Read /tmp/doc_assets/image_2.png
undefined步骤 4:整合分析
Step 4: Integrate analysis
将图片内容与文档文本结合,提供完整的文档分析。
Combine image content with document text to provide complete document analysis.
完整示例
Complete Example
bash
undefinedbash
undefined1. 导出文档和图片
1. Export document and images
feishu-cli wiki export <node_token>
-o /tmp/wiki_doc.md
--download-images
--assets-dir /tmp/wiki_assets
-o /tmp/wiki_doc.md
--download-images
--assets-dir /tmp/wiki_assets
feishu-cli wiki export <node_token>
-o /tmp/wiki_doc.md
--download-images
--assets-dir /tmp/wiki_assets
-o /tmp/wiki_doc.md
--download-images
--assets-dir /tmp/wiki_assets
2. 查看图片列表
2. View image list
ls /tmp/wiki_assets/
ls /tmp/wiki_assets/
3. 读取 Markdown 内容
3. Read Markdown content
Read /tmp/wiki_doc.md
Read /tmp/wiki_doc.md
4. 读取每张图片理解内容
4. Read each image to understand content
Read /tmp/wiki_assets/image_1.png
Read /tmp/wiki_assets/image_1.png
Read /tmp/wiki_assets/image_2.png
Read /tmp/wiki_assets/image_2.png
5. 综合分析后向用户报告
5. Report to user after comprehensive analysis
undefinedundefined目录节点识别与处理
Directory Node Identification and Processing
知识库文档可能是目录节点(包含子节点),通过以下方式识别:
Knowledge base documents may be directory nodes (containing child nodes), which are identified in the following ways:
1. 识别目录节点
1. Identify directory nodes
当导出知识库文档时,如果 Markdown 内容显示为:
markdown
[Wiki 目录 - 使用 'wiki nodes <space_id> --parent <node_token>' 获取子节点列表]说明这是一个Wiki 目录节点(block_type=42),子文档列表存储在知识库元数据中。
When exporting a knowledge base document, if the Markdown content shows:
markdown
[Wiki Directory - Use 'wiki nodes <space_id> --parent <node_token>' to get the list of child nodes]It means this is a Wiki directory node (block_type=42), and the sub-document list is stored in the knowledge base metadata.
2. 获取子节点列表
2. Get child node list
bash
undefinedbash
undefined1. 先获取节点信息,记录 space_id
1. First get node information, record space_id
feishu-cli wiki get <node_token>
feishu-cli wiki get <node_token>
2. 列出该节点下的子节点
2. List child nodes under this node
feishu-cli wiki nodes <space_id> --parent <node_token>
undefinedfeishu-cli wiki nodes <space_id> --parent <node_token>
undefined3. 完整处理流程
3. Complete processing flow
bash
undefinedbash
undefined步骤 1:尝试导出文档
Step 1: Try to export the document
feishu-cli wiki export <node_token> -o /tmp/doc.md
feishu-cli wiki export <node_token> -o /tmp/doc.md
步骤 2:检查内容
Step 2: Check content
如果显示 "[Wiki 目录...]",说明是目录节点
If it shows "[Wiki Directory...]", it is a directory node
步骤 3:获取节点信息
Step 3: Get node information
feishu-cli wiki get <node_token>
feishu-cli wiki get <node_token>
记录 space_id 和 has_child 字段
Record space_id and has_child fields
步骤 4:获取子节点
Step 4: Get child nodes
feishu-cli wiki nodes <space_id> --parent <node_token>
feishu-cli wiki nodes <space_id> --parent <node_token>
步骤 5:逐个导出子节点
Step 5: Export child nodes one by one
feishu-cli wiki export <child_node_token_1> -o /tmp/child1.md
feishu-cli wiki export <child_node_token_2> -o /tmp/child2.md
undefinedfeishu-cli wiki export <child_node_token_1> -o /tmp/child1.md
feishu-cli wiki export <child_node_token_2> -o /tmp/child2.md
undefined错误处理与边界情况
Error Handling and Edge Cases
1. 常见错误
1. Common Errors
| 错误 | 原因 | 解决 |
|---|---|---|
| 参数错误 | 检查 token 格式 |
| 节点不存在 | 检查 token 是否正确 |
| 无权限访问 | 确认应用有 wiki:wiki:readonly 权限 |
| 知识空间不存在 | 检查 space_id 是否正确 |
空内容或 | 特殊块类型 | 见「目录节点识别」章节 |
| Error | Cause | Solution |
|---|---|---|
| Parameter error | Check token format |
| Node does not exist | Check if the token is correct |
| No access permission | Confirm the application has wiki:wiki:readonly permission |
| Knowledge space does not exist | Check if space_id is correct |
Empty content or | Special block type | See the "Directory Node Identification" section |
2. 边界情况处理
2. Edge Case Handling
情况 1:文档内容为空
- 检查文档是否真的为空
- 检查是否有权限查看内容
- 检查是否是目录节点(见上文)
情况 2:图片下载失败
- 检查 目录是否可写
--assets-dir - 检查网络连接
- 图片可能已被删除或过期
情况 3:部分块类型无法识别
- 飞书 API 可能返回未知的块类型
- 这些块会显示为
<!-- Unknown block type: XX --> - 这是正常现象,不影响其他内容的读取
情况 4:大型文档
- 超过 1000 个块的文档可能需要分页获取
- 使用 自动分页
feishu-cli doc blocks <doc_id> --all
Case 1: Document content is empty
- Check if the document is actually empty
- Check if you have permission to view the content
- Check if it is a directory node (see above)
Case 2: Image download failed
- Check if the directory is writable
--assets-dir - Check network connection
- The image may have been deleted or expired
Case 3: Some block types cannot be identified
- Feishu API may return unknown block types
- These blocks will be displayed as
<!-- Unknown block type: XX --> - This is normal and does not affect the reading of other content
Case 4: Large documents
- Documents with more than 1000 blocks may need to be obtained in pages
- Use for automatic paging
feishu-cli doc blocks <doc_id> --all
3. 重试机制
3. Retry Mechanism
如果遇到网络错误或 API 限流:
bash
undefinedIf you encounter network errors or API rate limiting:
bash
undefined添加 --debug 查看详细错误信息
Add --debug to view detailed error information
feishu-cli wiki export <token> --debug
feishu-cli wiki export <token> --debug
等待几秒后重试
Retry after waiting a few seconds
sleep 5 && feishu-cli wiki export <token>
undefinedsleep 5 && feishu-cli wiki export <token>
undefined导出格式说明
Export Format Description
导出的 Markdown 支持以下飞书特有块类型的转换:
| 飞书块类型 | Markdown 表现 |
|---|---|
| Callout 高亮块 | |
| 块级/行内公式 | |
| 画板 (Board) | |
| ISV 块 (Mermaid) | 画板链接 |
| QuoteContainer | |
| AddOns/SyncedBlock | 透明展开子块内容 |
| Iframe | |
使用 参数时,带颜色的文本输出为 标签。
--highlight<span style="color:...">The exported Markdown supports conversion of the following Feishu-specific block types:
| Feishu Block Type | Markdown Representation |
|---|---|
| Callout highlight block | 6 types of GitHub-style alerts such as |
| Block/inline formula | |
| Board | |
| ISV block (Mermaid) | Board link |
| QuoteContainer | |
| AddOns/SyncedBlock | Transparently expand child block content |
| Iframe | |
When using the parameter, colored text is output as tags.
--highlight<span style="color:...">注意事项
Notes
- 务必下载图片:不下载图片只能看到 引用,无法理解图片内容
feishu://media/<token> - 逐个读取图片:使用 Read 工具读取每张图片,Claude 会自动理解图片内容
- 整合分析:将图片描述与文档文本结合,提供完整的内容摘要
- 识别目录节点:目录节点的内容是子节点列表,不是实际文档内容
- 公式内容:导出的 LaTeX 公式保持原文,可直接被 Markdown 渲染器显示
- Callout 类型:支持 NOTE/WARNING/TIP/CAUTION/IMPORTANT/SUCCESS 六种高亮块类型
- Be sure to download images: If you don't download images, you can only see references and cannot understand the image content
feishu://media/<token> - Read images one by one: Use the Read tool to read each image, Claude will automatically understand the image content
- Integrated analysis: Combine image descriptions with document text to provide a complete content summary
- Identify directory nodes: The content of directory nodes is a list of child nodes, not actual document content
- Formula content: The exported LaTeX formula remains unchanged and can be directly displayed by the Markdown renderer
- Callout types: Supports six highlight block types: NOTE/WARNING/TIP/CAUTION/IMPORTANT/SUCCESS