飞书云盘增强命令组。分块上传大文件(>20MB 自动 3 段式)、流式下载、 文档异步导出(markdown 快捷路径 / sheet+bitable csv / sub-id / 有界轮询 + resume)、 文档异步导入、文件/文件夹移动(folder 自动轮询)、富文本评论(text/mention_user/link + wiki URL 解析 + 局部评论)、通用异步任务查询。 当用户请求"上传大文件"、"下载云盘文件"、"导出为 pdf/markdown/xlsx"、"导入 docx 到云文档"、"移动文件夹"、"添加文档评论"、"@某人评论文档"、"从 wiki 链接评论"、 "查询异步任务状态"、"drive 任务 resume"、"分块上传"、"feishu drive"、"lark drive"时使用。 本 skill 与老的 file/media/comment 命令组并存,提供更强能力(User Token 支持、 异步 resume、富文本评论),基础场景仍可用 file/media。
drive 命令组提供与老 file / media / comment add 命令并存的增强能力:
分块上传、markdown 快捷导出、异步任务 resume、富文本评论、wiki 链接解析。
feishu-cli:如尚未安装,请前往 riba2534/feishu-cli 获取安装方式。
drive 命令默认走 User Access Token(执行 feishu-cli auth login 登录)feishu-cli auth check --scope "drive:file:upload" 可验证 scope# 上传(>20MB 自动走 3 段式分块 upload_prepare/upload_part/upload_finish)
feishu-cli drive upload --file /tmp/report.pdf
feishu-cli drive upload --file /tmp/big.zip --folder-token fldxxx --name "年度报告.zip"
# 下载(流式 + 路径校验 + --overwrite + --timeout)
feishu-cli drive download --file-token boxcnxxxx --output ./report.pdf
feishu-cli drive download --file-token boxcnxxxx --output ./downloads/ --overwrite
feishu-cli drive download --file-token boxcnxxxx --output ./big.zip --timeout 10m
关键点:
drive upload 分块上传每片独立重试 3 次,使用 io.SectionReader 外层只打开文件一次drive download 的 --output 可以是文件路径(直接用)或目录(文件名用 file_token 本身,暂不从响应头解析)--output ./downloads/report.pdf# docx → markdown:走 /docs/v1/content 快捷路径,立即返回(不跑异步 export_tasks)
feishu-cli drive export --token docxxxx --doc-type docx --file-extension markdown --output-dir ./exports
# docx → pdf:走异步 export_tasks,有界轮询 10×5s,超时返回 next_command
feishu-cli drive export --token docxxxx --doc-type docx --file-extension pdf --output-dir ./exports
# sheet → csv 指定 sheet_id
feishu-cli drive export --token sheetxxxx --doc-type sheet --file-extension csv --sub-id sheet_1
# bitable → csv 指定 table_id
feishu-cli drive export --token basexxxx --doc-type bitable --file-extension csv --sub-id tblxxxx
支持的格式:
--doc-type: doc / docx / sheet / bitable--file-extension: docx / pdf / xlsx / csv / markdown(markdown 仅 docx 支持)超时后的 resume 流程:
# drive export 超时会输出:
# next_command: feishu-cli drive task-result --scenario export --ticket abc --file-token xxx
# 1. 轮询任务状态
feishu-cli drive task-result --scenario export --ticket abc --file-token xxx
# 2. 任务完成后下载产物
feishu-cli drive export-download --file-token boxxxx --output-dir ./exports
drive export-download — 下载已完成的导出文件feishu-cli drive export-download --file-token boxxxx --output-dir ./exports
feishu-cli drive export-download --file-token boxxxx --file-name "报告.pdf" --overwrite
# 本地文件 → 云文档(docx / sheet / bitable)
feishu-cli drive import --file report.docx --type docx
feishu-cli drive import --file data.xlsx --type sheet --folder-token fldxxx
feishu-cli drive import --file bigsheet.csv --type bitable --folder-token fldxxx
# 大文件(>20MB)自动走分块媒体上传
feishu-cli drive import --file big.docx --type docx
关键技术点:
/medias/upload_all 端点(parent_type=ccm_import_open + extra),不在用户云盘留下中间文件(这是和老 doc import-file 的核心区别)next_command# 文件移动(同步,立即返回)
feishu-cli drive move --file-token boxxxx --type docx --folder-token fldxxx
# 文件夹移动(异步,自动轮询 task_check 30×2s)
feishu-cli drive move --file-token fldxxx --type folder --folder-token fldyyy
关键点:
task_id,可用 drive task-result --scenario task_check 接力# 全局评论
feishu-cli drive add-comment --doc doccnxxxx --content '[{"type":"text","text":"需要修改标题"}]'
# 通过 docx URL
feishu-cli drive add-comment --doc "https://xxx.feishu.cn/docx/doccnxxxx" \
--content '[{"type":"text","text":"评论内容"}]'
# 通过 wiki URL(自动解析到真实 docx)
feishu-cli drive add-comment --doc "https://xxx.feishu.cn/wiki/nodxxxx" \
--content '[{"type":"text","text":"收到"}]'
# 局部评论(锚定到 docx block)
feishu-cli drive add-comment --doc doccnxxxx --block-id blk_xxx \
--content '[{"type":"text","text":"这段重写"}]'
# 富文本:文本 + 提及用户 + 链接混合
feishu-cli drive add-comment --doc doccnxxxx --content '[
{"type":"text","text":"请 "},
{"type":"mention_user","mention_user":"ou_xxx"},
{"type":"text","text":" 查看 "},
{"type":"link","link":"https://feishu.cn"}
]'
reply_elements 元素类型:
text — 纯文本mention_user — 提及用户(传 mention_user 或 text 字段作为 open_id)link — 链接(传 link 或 text 字段作为 URL)文档输入格式:
docx token(直接传)docx URL(https://xxx.feishu.cn/docx/xxx)doc URL(旧版文档)wiki URL(自动解析到真实 obj_token + obj_type)# 查询导入任务
feishu-cli drive task-result --scenario import --ticket abcxxx
# 查询导出任务(需要额外传 file-token 作为原始文档 token)
feishu-cli drive task-result --scenario export --ticket abcxxx --file-token docxxxx
# 查询 folder move 等通用任务
feishu-cli drive task-result --scenario task_check --task-id taskxxx
三种 scenario:import / export / task_check。用于 drive export / drive import / drive move 超时后的接力完成。
feishu-cli drive upload --file big_video.mp4 --folder-token fldxxx --name "会议录像.mp4"
# 自动走分块,stderr 输出分片进度
# 上传: 会议录像.mp4 (104857600 bytes)
# 分片上传: 文件大小 100.0 MB, 分片大小 4.0 MB, 共 25 个分片
# 分片 1/25 上传完成 (4.0 MB)
# ...
# file_token 返回后可直接在飞书里访问
# 通过 /docs/v1/content 快捷路径,秒出不用等
for doc_id in doc1 doc2 doc3; do
feishu-cli drive export --token $doc_id --doc-type docx --file-extension markdown --output-dir ./docs
done
# 1. 触发导出
TICKET=$(feishu-cli drive export --token docxxxxx --doc-type docx --file-extension pdf -o json | jq -r '.ticket // empty')
# 2. 如果超时,输出会带 next_command
# 手动或脚本化接力:
feishu-cli drive task-result --scenario export --ticket $TICKET --file-token docxxxxx
# 3. 任务就绪后下载产物
feishu-cli drive export-download --file-token boxxxx --output-dir ./exports
# 不需要先解析 wiki 到 docx,drive add-comment 自动反查
feishu-cli drive add-comment \
--doc "https://xxx.feishu.cn/wiki/nodxxxxx" \
--content '[
{"type":"text","text":"收到,已处理 "},
{"type":"mention_user","mention_user":"ou_abc123"}
]'
# drive import 走临时媒体(不污染云盘)
feishu-cli drive import --file report.docx --type docx --folder-token fldxxx
# 大文件(>20MB)同样走分块
feishu-cli drive import --file big_sheet.xlsx --type sheet --folder-token fldxxx
| 老命令 | 新 drive 命令 | 差异 |
|---|---|---|
file upload | drive upload | drive 支持 User Token + 分块 + 每片重试 |
file download | drive download | drive 支持 User Token + --overwrite + --timeout + 路径校验 |
file move | drive move | drive 文件夹移动自动轮询 task_check |
doc export-file --type pdf | drive export --doc-type docx --file-extension pdf | drive 增加 markdown 快捷路径 + sub-id + resume |
doc import-file --type docx | drive import --type docx | drive 走 /medias/upload_all(不留中间文件) |
comment add --type docx | drive add-comment --doc <url> | drive 支持富文本 + wiki 解析 + 局部评论 |
老命令不会被删除,仍然可以用(走 App Token 简单场景),但新能力只在 drive 命令组里。
| 命令 | 所需 scope |
|---|---|
drive upload | drive:file:upload |
drive download | drive:file:download |
drive export / export-download | docs:document.content:read、docs:document:export、drive:drive.metadata:readonly、drive:file:download |
drive import | docs:document.media:upload、docs:document:import |
drive move | space:document:move |
drive add-comment | docs:document.comment:create、docs:document.comment:write_only、docx:document:readonly(若 docx)、wiki:node:read(若 wiki URL) |
drive task-result | drive:drive.metadata:readonly |
drive 命令未登录时会统一提示 feishu-cli auth loginnext_commanddocx 或 doc 的 wiki 节点;其他类型(sheet/bitable/mindnote 等)会报错--block-id 锚点,doc(旧版文档)不支持drive download:--output 为目录时使用 file_token 作为文件名(不从响应头解析);要自定义名字请显式传文件路径minutes download(参见 feishu-cli-vc):从响应头按 Content-Disposition > filename* > Content-Type 推导扩展名 > {token}.media 优先级解析