← 返回 Skills 市场
songofhawk

Feishu Docx Cli

作者 songofhawk · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ⚠ suspicious
280
总下载
0
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install feishu-docx-cli
功能描述
🚀 最完整的飞书文档 CLI 管理工具 核心优势: - 📄 完整文档生命周期管理(创建/读取/写入/修改) - 🖼️ 支持本地图片上传到文档(官方工具不支持) - 🔐 自动授权管理(添加/移除协作者权限) - 💡 智能错误提示(告诉用户缺少什么权限、如何修复) 相比官方 feishu_doc 工具的突破...
使用说明 (SKILL.md)

Feishu Docx CLI - 飞书文档管理工具

🏆 目前最完整的飞书文档管理 CLI 工具

解决了官方工具无法上传图片、无法管理权限的核心痛点

功能特性

功能 命令 状态
创建文档 create ✅ 支持
读取内容 read ✅ 支持
写入/覆盖 write ✅ 支持
追加内容 append ✅ 支持
上传图片 upload-image ✅ 支持
权限管理 permissions ✅ 支持

快速开始

1. 配置飞书应用

# 配置 OpenClaw 飞书通道
openclaw configure --section feishu

需要提前在 飞书开放平台 创建应用,并获取:

  • App ID
  • App Secret

2. 所需权限

在飞书开放平台 → 应用 → 权限管理,启用以下权限:

docx:document                    # 访问文档
docx:document:write_only         # 写入文档
docx:document.block:convert      # Markdown 转换
docx:permission.member           # 权限管理
drive:file:upload                # 文件上传
drive:drive:readonly             # 云盘读取

配置完成后,重新发布应用。

3. 使用示例

创建文档

# 创建空白文档
python3 scripts/feishu-doc.py create "我的文档"

# 创建到指定文件夹
python3 scripts/feishu-doc.py create "我的文档" --folder fldcnXXX

输出:

✅ 文档创建成功
   标题: 我的文档
   Token: OZ6cdpu7iodrP3x6DkGcwFcanQK
   链接: https://feishu.cn/docx/OZ6cdpu7iodrP3x6DkGcwFcanQK

读取文档

python3 scripts/feishu-doc.py read OZ6cdpu7iodrP3x6DkGcwFcanQK

写入文档(覆盖)

# 从 Markdown 文件写入
python3 scripts/feishu-doc.py write OZ6cdpu7iodrP3x6DkGcwFcanQK article.md

追加内容

python3 scripts/feishu-doc.py append OZ6cdpu7iodrP3x6DkGcwFcanQK "## 新章节\
\
这是追加的内容"

上传图片

# 自动找到第一个空的图片 block
python3 scripts/feishu-doc.py upload-image OZ6cdpu7iodrP3x6DkGcwFcanQK ./image.png

# 指定 block ID
python3 scripts/feishu-doc.py upload-image OZ6cdpu7iodrP3x6DkGcwFcanQK ./image.png --block-id doxcnXXX

创建图片 block 的方法

python3 scripts/feishu-doc.py append OZ6cdpu7iodrP3x6DkGcwFcanQK "![图片描述](placeholder.png)"

权限管理

# 查看当前权限
python3 scripts/feishu-doc.py permissions list OZ6cdpu7iodrP3x6DkGcwFcanQK

# 添加查看权限
python3 scripts/feishu-doc.py permissions add OZ6cdpu7iodrP3x6DkGcwFcanQK ou_dca3e767c3cddad35149d63ce99f948c --perm view

# 添加编辑权限
python3 scripts/feishu-doc.py permissions add OZ6cdpu7iodrP3x6DkGcwFcanQK ou_dca3e767c3cddad35149d63ce99f948c --perm edit

# 移除权限
python3 scripts/feishu-doc.py permissions remove OZ6cdpu7iodrP3x6DkGcwFcanQK ou_dca3e767c3cddad35149d63ce99f948c

完整工作流程

场景:创建图文并茂的文档

# 1. 创建文档
python3 scripts/feishu-doc.py create "产品说明书"
# 输出: Token = ABC123

# 2. 写入文字内容
python3 scripts/feishu-doc.py write ABC123 content.md

# 3. 创建图片占位符
python3 scripts/feishu-doc.py append ABC123 "\
## 产品截图\
\
![产品图1](placeholder.png)\
\
![产品图2](placeholder.png)"

# 4. 上传图片
python3 scripts/feishu-doc.py upload-image ABC123 ./screenshot1.png
python3 scripts/feishu-doc.py upload-image ABC123 ./screenshot2.png

# 5. 分享给团队成员
python3 scripts/feishu-doc.py permissions add ABC123 ou_member1 --perm edit
python3 scripts/feishu-doc.py permissions add ABC123 ou_member2 --perm view

# 6. 查看文档链接
echo "https://feishu.cn/docx/ABC123"

API 参考

文档操作

# 创建
POST /docx/v1/documents
{"title": "标题", "folder_token": "可选"}

# 读取
GET /docx/v1/documents/{doc_token}/raw_content

# Markdown 转换
POST /docx/v1/documents/convert
{"content_type": "markdown", "content": "..."}

# 写入 blocks
POST /docx/v1/documents/{doc_token}/blocks/{doc_token}/children
{"children": [...]}

# 删除内容
DELETE /docx/v1/documents/{doc_token}/blocks/{doc_token}/children/batch_delete
{"start_index": 0, "end_index": N}

图片上传

# 上传图片
POST /drive/v1/medias/upload_all
Content-Type: multipart/form-data
{
  "file": \x3Cbinary>,
  "file_name": "image.png",
  "parent_type": "docx_image",
  "parent_node": "doxcnXXX",  # 图片 block ID
  "size": "12345"
}
# 返回: file_token

# 更新 block
PATCH /docx/v1/documents/{doc_token}/blocks/{block_id}
{"replace_image": {"token": "file_token"}}

权限管理

# 列权限
GET /docx/v1/documents/{doc_token}/permission/member/list

# 添加权限
POST /docx/v1/documents/{doc_token}/permission/member/create
{"member_type": "openid", "member_id": "...", "perm": "view/edit/full_access"}

# 移除权限
DELETE /docx/v1/documents/{doc_token}/permission/member/delete?member_type=openid&member_id=...

常见问题

Q: 提示权限不足怎么办?

A: 检查飞书开放平台应用的权限设置:

  1. 登录 飞书开放平台
  2. 找到你的应用
  3. 权限管理 → 启用所需权限
  4. 重新发布应用
  5. 等待 5-10 分钟生效

Q: 上传图片失败?

A: 确保:

  1. 图片 block 已创建(用 append 添加 ![描述](path)
  2. 图片文件存在且可读
  3. 文件大小不超过 20MB
  4. 格式为 PNG/JPG

Q: 如何获取 member_id?

A: member_id 是用户的 Open ID,可以通过:

  • 飞书用户管理后台查看
  • 或者使用飞书用户 API 查询

Q: Markdown 表格支持吗?

A: 飞书 API 不支持 Markdown 表格,会显示为普通文本。建议:

  • 使用列表代替表格
  • 或者手动在飞书编辑器中创建表格

与官方 feishu_doc 对比

功能 官方 feishu_doc 本工具 feishu-docx-cli
创建文档 ✅ 支持 ✅ 支持
读取内容 ✅ 支持 ✅ 支持
写入内容 ✅ 支持 ✅ 支持
图片上传 不支持 完整支持
权限管理 不支持 一键授权
CLI 界面 ❌ 无 ✅ 完整 CLI
错误提示 ❌ 通用模糊 ✅ 精准可操作
工作流支持 ❌ 需手动组合 ✅ 完整生命周期

⭐ 核心突破

1. 图片上传(独家)

官方 feishu_doc 工具不支持图片上传,甚至文档说要用 IM API 的 image_key(也是错的)。

本工具使用正确的 API 流程:

drive/v1/medias/upload_all → 获取 file_token → replace_image 更新 block

2. 权限管理(独家)

支持一键分享文档、添加/移除协作者:

# 添加编辑权限
feishu-doc permissions add DOC_TOKEN USER_ID --perm edit

# 添加查看权限
feishu-doc permissions add DOC_TOKEN USER_ID --perm view

3. 智能错误提示

不是简单的"请求失败",而是告诉用户:

  • 缺少什么权限
  • 去哪里开启权限
  • 如何重新发布应用 | 批量操作 | ❌ 无 | ✅ 支持 |

扩展开发

你可以基于此脚本扩展更多功能:

from scripts.feishu_doc import get_token, api

token = get_token()

# 自定义 API 调用
result = api('GET', '/docx/v1/documents/XXX/blocks', token)

参考

安全使用建议
This package implements the advertised Feishu doc CLI and uses the official Feishu API host, but the metadata failed to declare that it reads your OpenClaw config (~/.openclaw/openclaw.json) to obtain the Feishu App ID and App Secret. Before installing/running: 1) Inspect ~/.openclaw/openclaw.json and the two scripts to confirm you're comfortable granting them the App ID/Secret. 2) Only provide an app_id/app_secret for an app you control; limit that app's permissions (avoid overly broad scopes). 3) Run the scripts in a controlled environment (non-root user, isolated workspace) if you don't fully trust the source. 4) If you need stronger assurance, ask the publisher for a provenance link or sign-off (homepage/repo) and/or run the scripts through your own code review or sandboxed runtime. The main risk here is the undeclared requirement for sensitive credentials and access to a local config file — not obfuscated or obviously malicious behavior, but a metadata mismatch that deserves caution.
功能分析
Type: OpenClaw Skill Name: feishu-docx-cli Version: 1.1.0 The feishu-docx-cli skill bundle is a legitimate tool for managing Feishu documents via the official Feishu Open API. The Python scripts (feishu-doc-manager.py and feishu-doc.py) implement standard document CRUD operations, image uploads, and permission management by securely retrieving credentials from the local OpenClaw configuration file (~/.openclaw/openclaw.json). No evidence of data exfiltration, malicious execution, or prompt injection was found; all network traffic is directed to the official Feishu endpoint (open.feishu.cn).
能力评估
Purpose & Capability
Name, description, SKILL.md, and the two included Python scripts all consistently implement a Feishu document CLI with create/read/write/append/image upload/permission features. Network calls target the official Feishu API host (open.feishu.cn). The implemented capabilities match the stated purpose.
Instruction Scope
SKILL.md instructs users to run the provided scripts and to configure an OpenClaw Feishu channel (openclaw configure). The runtime instructions and examples align with the code's behavior (calling Feishu endpoints, uploading files, updating blocks). There are no instructions that read unrelated system files or exfiltrate arbitrary data beyond Feishu operations.
Install Mechanism
There is no install spec; this is instruction-plus-source only. No remote downloads or installers are executed by the skill itself. Code is executed locally when the user runs the scripts, which is the expected low-risk pattern for an instruction-only skill with shipped scripts.
Credentials
Registry metadata declares no required env vars or config paths, but both scripts explicitly read the OpenClaw config at ~/.openclaw/openclaw.json to obtain Feishu App ID and App Secret and then exchange them for a tenant_access_token. The skill therefore requires sensitive credentials (app_id/app_secret) and access to a specific user config file — this is proportionate to the stated Feishu functionality, but it is not declared in the metadata, creating an incoherence that the user should notice.
Persistence & Privilege
The skill is not marked always:true and does not request installation-level persistence or modify other skills. It runs as a user-invoked CLI and does not alter system-wide settings. Autonomous model invocation is allowed by default but there is no evidence the skill abuses it.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install feishu-docx-cli
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /feishu-docx-cli 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
### feishu-docx-cli 1.1.0 - 完善文档和描述,明确突出与官方工具相比的独家突破和优势(如图片上传、权限管理)。 - 增强官方对比表,强调核心功能差异,新增“核心突破”讲解。 - 增加亮点介绍和修正部分标题与用语,更加突出工具特色和用户价值。 - 保持全部已支持功能与命令用法说明,便于用户参考和操作。
v1.0.1
- 增强描述内容,突出与官方工具对比的核心优势(文档权限、图片上传、错误提示等)。 - 标题和简介部分新增图标和营销语,强调“最完整的飞书文档 CLI 管理工具”。 - 增加“核心优势”和“突破”板块,清晰列举与官方 feishu_doc 的差异化功能。 - 主要文档结构、用法、API说明等无实质性变动,仅优化了前文概要,便于新用户理解选择理由。 - 其余内容保持不变,确保兼容原有使用方式。
v1.0.0
feishu-docx-cli 1.0.0 - Initial release of a complete Feishu (Lark) document management CLI tool - Supports creating, reading, writing, and appending to documents - Enables image upload to documents via CLI - Provides document permissions management (view, edit, remove) - Offers clear error messages and operation guidance - Includes detailed usage instructions and common troubleshooting tips
元数据
Slug feishu-docx-cli
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 3
常见问题

Feishu Docx Cli 是什么?

🚀 最完整的飞书文档 CLI 管理工具 核心优势: - 📄 完整文档生命周期管理(创建/读取/写入/修改) - 🖼️ 支持本地图片上传到文档(官方工具不支持) - 🔐 自动授权管理(添加/移除协作者权限) - 💡 智能错误提示(告诉用户缺少什么权限、如何修复) 相比官方 feishu_doc 工具的突破... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 280 次。

如何安装 Feishu Docx Cli?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install feishu-docx-cli」即可一键安装,无需额外配置。

Feishu Docx Cli 是免费的吗?

是的,Feishu Docx Cli 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Feishu Docx Cli 支持哪些平台?

Feishu Docx Cli 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Feishu Docx Cli?

由 songofhawk(@songofhawk)开发并维护,当前版本 v1.1.0。

💬 留言讨论