← 返回 Skills 市场
飞书文档管理器Pro
作者
thinkingmanyangyang
· GitHub ↗
· v1.0.0
· MIT-0
118
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install feishu-doc-manager-pro
功能描述
飞书文档管理技能。支持创建、读取、写入、删除文档和文档块。当用户需要操作飞书文档时使用此技能。触发条件:(1) 创建飞书文档 (2) 读取飞书文档内容 (3) 写入/追加内容到飞书文档 (4) 删除文档块 (5) 清空文档。
使用说明 (SKILL.md)
飞书文档管理器
完整的飞书文档操作技能,支持创建、读取、写入、删除文档。
前置配置
1. 开通权限
在飞书开放平台开通以下权限:
| 权限标识 | 权限名称 | 用途 |
|---|---|---|
docx:document |
获取、新建、删除文档 | 创建/删除文档 |
docx:document:write_only |
编辑文档 | 写入/删除块 |
docx:document:readonly |
读取文档 | 读取内容 |
docs:permission.member |
文档权限管理 | 协作者管理 |
2. 添加文档应用
在飞书客户端:
- 打开文档 → 右上角 "..."
- 更多 → 添加文档应用
- 搜索应用 → 添加,授予 "可编辑" 权限
3. 获取 Token
$config = Get-Content "$env:USERPROFILE\.openclaw\openclaw.json" | ConvertFrom-Json
$appId = $config.channels.feishu.appId
$appSecret = $config.channels.feishu.appSecret
$body = @{ app_id = $appId; app_secret = $appSecret } | ConvertTo-Json
$resp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" -Method Post -Body $body -ContentType "application/json"
$token = $resp.tenant_access_token
核心操作
1. 创建文档
$createBody = '{"title":"文档标题","folder_token":""}'
$createResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents" -Method Post -Body ([System.Text.Encoding]::UTF8.GetBytes($createBody)) -ContentType "application/json; charset=utf-8" -Headers @{ Authorization = "Bearer $token" }
$documentId = $createResp.data.document.document_id
Write-Host "文档 ID: $documentId"
Write-Host "文档链接: https://xxx.feishu.cn/docx/$documentId"
2. 读取文档内容
# 获取文档所有块
$blocksResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children" -Method Get -Headers @{ Authorization = "Bearer $token" }
foreach ($block in $blocksResp.data.items) {
Write-Host "类型: $($block.block_type), ID: $($block.block_id)"
}
3. 写入内容
# 写入标题和文本
$writeBody = '{"index":-1,"children":[{"block_type":3,"heading1":{"elements":[{"text_run":{"content":"标题"}}]}},{"block_type":2,"text":{"elements":[{"text_run":{"content":"文本内容"}}]}}]}'
$writeResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children" -Method Post -Body ([System.Text.Encoding]::UTF8.GetBytes($writeBody)) -ContentType "application/json; charset=utf-8" -Headers @{ Authorization = "Bearer $token" }
块类型说明:
| block_type | 类型 | 说明 |
|---|---|---|
| 2 | text | 普通文本 |
| 3 | heading1 | 一级标题 |
| 4 | heading2 | 二级标题 |
| 12 | bullet | 无序列表 |
4. 删除块(重要)
使用 batch_delete API 批量删除:
# 获取当前块数量
$blocksResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children" -Method Get -Headers @{ Authorization = "Bearer $token" }
$totalBlocks = $blocksResp.data.items.Count
# 删除所有块(左闭右开区间)
$deleteBody = @{
start_index = 0
end_index = $totalBlocks
} | ConvertTo-Json
$delResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children/batch_delete?document_revision_id=-1" -Method Delete -Body ([System.Text.Encoding]::UTF8.GetBytes($deleteBody)) -ContentType "application/json; charset=utf-8" -Headers @{ Authorization = "Bearer $token" }
if ($delResp.code -eq 0) {
Write-Host "✅ 删除成功"
}
API 说明:
- URL:
DELETE /documents/:document_id/blocks/:block_id/children/batch_delete - 参数:
start_index(起始索引)、end_index(结束索引,左闭右开) - 注意:
start_index必须小于end_index
5. 清空文档并写入新内容
# 1. 获取块数量
$blocksResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children" -Method Get -Headers @{ Authorization = "Bearer $token" }
$totalBlocks = $blocksResp.data.items.Count
# 2. 删除所有块
if ($totalBlocks -gt 0) {
$deleteBody = @{ start_index = 0; end_index = $totalBlocks } | ConvertTo-Json
Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children/batch_delete?document_revision_id=-1" -Method Delete -Body ([System.Text.Encoding]::UTF8.GetBytes($deleteBody)) -ContentType "application/json; charset=utf-8" -Headers @{ Authorization = "Bearer $token" } | Out-Null
}
# 3. 写入新内容
$writeBody = '{"index":-1,"children":[{"block_type":3,"heading1":{"elements":[{"text_run":{"content":"新标题"}}]}},{"block_type":2,"text":{"elements":[{"text_run":{"content":"新内容"}}]}}]}'
Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children" -Method Post -Body ([System.Text.Encoding]::UTF8.GetBytes($writeBody)) -ContentType "application/json; charset=utf-8" -Headers @{ Authorization = "Bearer $token" }
Write-Host "✅ 文档已更新"
Wiki 文档处理
Wiki 文档需要先获取实际的 obj_token:
# Wiki URL: https://xxx.feishu.cn/wiki/XXXXXXXX
$wikiToken = "SRDiwPCx8iEtx6kreaCckFW3nOb"
# 获取实际文档 ID
$wikiResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/wiki/v2/spaces/get_node?token=$wikiToken" -Method Get -Headers @{ Authorization = "Bearer $token" }
$documentId = $wikiResp.data.node.obj_token
Write-Host "实际文档 ID: $documentId"
常见错误
| 错误码 | 说明 | 解决方案 |
|---|---|---|
| 1770032 | 权限不足 | 添加应用为文档协作者 |
| 1770002 | 文档不存在 | 检查 document_id |
| 9499 | JSON 格式错误 | 使用纯 JSON 字符串 |
完整示例:更新天气文档
# 配置
$config = Get-Content "$env:USERPROFILE\.openclaw\openclaw.json" | ConvertFrom-Json
$appId = $config.channels.feishu.appId
$appSecret = $config.channels.feishu.appSecret
# 获取 Token
$body = @{ app_id = $appId; app_secret = $appSecret } | ConvertTo-Json
$resp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" -Method Post -Body $body -ContentType "application/json"
$token = $resp.tenant_access_token
$documentId = "你的文档ID"
# 获取天气
$weather = curl.exe -s "wttr.in/Tianjin?format=3"
$timeStr = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
# 清空文档
$blocksResp = Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children" -Method Get -Headers @{ Authorization = "Bearer $token" }
if ($blocksResp.data.items.Count -gt 0) {
$deleteBody = @{ start_index = 0; end_index = $blocksResp.data.items.Count } | ConvertTo-Json
Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children/batch_delete?document_revision_id=-1" -Method Delete -Body ([System.Text.Encoding]::UTF8.GetBytes($deleteBody)) -ContentType "application/json; charset=utf-8" -Headers @{ Authorization = "Bearer $token" } | Out-Null
}
# 写入天气
$writeBody = '{"index":-1,"children":[{"block_type":3,"heading1":{"elements":[{"text_run":{"content":"天津天气"}}]}},{"block_type":2,"text":{"elements":[{"text_run":{"content":"' + $weather + '"}}]}},{"block_type":2,"text":{"elements":[{"text_run":{"content":"更新时间: ' + $timeStr + '"}}]}}]}'
Invoke-RestMethod -Uri "https://open.feishu.cn/open-apis/docx/v1/documents/$documentId/blocks/$documentId/children" -Method Post -Body ([System.Text.Encoding]::UTF8.GetBytes($writeBody)) -ContentType "application/json; charset=utf-8" -Headers @{ Authorization = "Bearer $token" }
Write-Host "✅ 天气已更新"
参考文档
安全使用建议
Before installing or running this skill: (1) Note that the SKILL.md tells the agent to read your local OpenClaw config (~\ .openclaw\openclaw.json) to pull appId/appSecret — the skill does not declare these as required credentials. That means it will access sensitive secrets unless you prevent it. (2) Only install if you trust the author; verify the skill owner and source (the _meta.json ownerId does not match the registry ownerId provided), and prefer a signed/official source. (3) If you must use it, create a dedicated Feishu app with the minimum scopes needed, use short-lived tokens, and avoid exposing tenant/app secrets in a shared/local config. (4) Consider updating the skill to require explicit environment variables or to accept a user-provided token at runtime rather than reading local config files. (5) Test in an isolated account or sandbox before using it against important documents, because the API calls include deletion/clear operations that permanently remove content.
功能分析
Type: OpenClaw Skill
Name: feishu-doc-manager-pro
Version: 1.0.0
The skill provides Feishu document management but performs high-risk actions by reading sensitive API credentials (appId and appSecret) directly from the local filesystem ($env:USERPROFILE\.openclaw\openclaw.json) in SKILL.md. While these operations are plausibly necessary for the stated purpose of authenticating with the Feishu API (open.feishu.cn), the direct access to local secrets and the inclusion of external network calls (e.g., to wttr.in) represent a significant attack surface for credential theft or unauthorized data access.
能力评估
Purpose & Capability
The skill claims to manage Feishu documents and the SKILL.md contains Feishu API calls that match that purpose. However, it expects an app_id/app_secret to fetch a tenant token by reading $env:USERPROFILE\.openclaw\openclaw.json (not declared in requires.env). The skill should declare required credentials or use a documented, least-privilege auth flow; the implicit reliance on a local OpenClaw config is disproportionate and undeclared.
Instruction Scope
Runtime instructions explicitly instruct the agent to read a local file ($env:USERPROFILE\.openclaw\openclaw.json) to extract appId and appSecret, then call Feishu APIs using the token. Reading an agent/user config file is outside the stated surface of 'document management' and is sensitive. Other operations (create/read/write/delete blocks) are in-scope for document management. The example also calls an external wttr.in endpoint (harmless for weather), but the main issue is the file access and implicit credential harvesting.
Install Mechanism
This is an instruction-only skill with no install spec and no code files to install. That minimizes install-time risk (nothing is downloaded or written by an installer).
Credentials
The skill declares no required environment variables or primary credential, yet its examples require app_id and app_secret pulled from a local config file. That means it implicitly needs sensitive credentials but does not declare them. Also, the required Feishu scopes include doc creation/deletion and write-only editing — powerful permissions appropriate for destructive operations but worth explicit disclosure before granting.
Persistence & Privilege
always is false and the skill is user-invocable and allowed to run autonomously by default (normal). The skill does not request permanent agent-wide presence or modify other skills' config in the provided instructions.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install feishu-doc-manager-pro - 安装完成后,直接呼叫该 Skill 的名称或使用
/feishu-doc-manager-pro触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
支持创建、读取、写入、删除文档块;包含batch_delete批量删除功能;Wiki文档处理
元数据
常见问题
飞书文档管理器Pro 是什么?
飞书文档管理技能。支持创建、读取、写入、删除文档和文档块。当用户需要操作飞书文档时使用此技能。触发条件:(1) 创建飞书文档 (2) 读取飞书文档内容 (3) 写入/追加内容到飞书文档 (4) 删除文档块 (5) 清空文档。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 118 次。
如何安装 飞书文档管理器Pro?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install feishu-doc-manager-pro」即可一键安装,无需额外配置。
飞书文档管理器Pro 是免费的吗?
是的,飞书文档管理器Pro 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
飞书文档管理器Pro 支持哪些平台?
飞书文档管理器Pro 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 飞书文档管理器Pro?
由 thinkingmanyangyang(@thinkingmanyangyang)开发并维护,当前版本 v1.0.0。
推荐 Skills