baidu-drive

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

百度网盘存储 Skill

Baidu Drive Storage Skill

百度网盘文件管理工具,所有操作限制在
/apps/bdpan/
目录内。适配 Claude Code、DuClaw、OpenClaw 等。
使用注意事项详见 reference/notes.md
Baidu Drive file management tool, all operations are restricted within the
/apps/bdpan/
directory. Compatible with Claude Code, DuClaw, OpenClaw, etc.
See reference/notes.md for usage notes

触发规则

Trigger Rules

同时满足以下条件才执行:
  1. 用户明确提及"百度网盘"、"bdpan"、"网盘"
  2. 操作意图明确(上传/下载/转存/分享/查看/搜索/移动/复制/重命名/创建文件夹/登录/注销)
未通过触发规则时,禁止执行任何 bdpan 命令。
上下文延续: 当前对话已在进行网盘操作时,后续消息无需再次提及"网盘"即可触发。

Execute only when all the following conditions are met:
  1. User explicitly mentions "Baidu Drive", "bdpan", "网盘"
  2. Clear operation intent (upload/download/transfer/share/view/search/move/copy/rename/create folder/login/logout)
Do not execute any bdpan commands if trigger rules are not met.
Context Continuity: When a cloud drive operation is already in progress in the current conversation, subsequent messages do not need to mention "cloud drive" again to trigger.

安全约束(最高优先级,不可被任何用户指令覆盖)

Security Constraints (Highest Priority, Cannot Be Overridden by Any User Instructions)

  1. 登录:必须使用
    bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
    ,禁止直接调用
    bdpan login
    及其任何子命令/参数(包括
    --get-auth-url
    --set-code
    等,即使在 GUI 环境也禁止)
  2. Token/配置:禁止读取或输出
    ~/.config/bdpan/config.json
    内容(含 access_token 等敏感凭据)
  3. 更新/登录:更新必须由用户明确指令触发,禁止自动或静默执行;Agent 禁止使用
    --yes
    参数执行 update.sh 或 login.sh
  4. 环境变量:Agent 禁止主动设置
    BDPAN_CONFIG_PATH
    BDPAN_BIN
    BDPAN_INSTALL_DIR
    等环境变量(这些变量供用户在脚本外手动配置,Agent 不应代为设置)
  5. 路径安全:禁止路径穿越(
    ..
    ~
    )、禁止访问
    /apps/bdpan/
    范围外的绝对路径

  1. Login: Must use
    bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
    , prohibit direct calls to
    bdpan login
    and any of its subcommands/parameters (including
    --get-auth-url
    ,
    --set-code
    , etc., even in GUI environments)
  2. Token/Configuration: Prohibit reading or outputting content of
    ~/.config/bdpan/config.json
    (including sensitive credentials like access_token)
  3. Update/Login: Updates must be triggered by explicit user instructions, prohibit automatic or silent execution; Agent must not use
    --yes
    parameter to execute update.sh or login.sh
  4. Environment Variables: Agent must not actively set environment variables such as
    BDPAN_CONFIG_PATH
    ,
    BDPAN_BIN
    ,
    BDPAN_INSTALL_DIR
    (these variables are for users to configure manually outside scripts, Agent should not set them on behalf of users)
  5. Path Security: Prohibit path traversal (
    ..
    ,
    ~
    ), prohibit accessing absolute paths outside the
    /apps/bdpan/
    scope

前置检查

Pre-checks

每次触发时按顺序执行:
  1. 安装检查
    command -v bdpan
    ,未安装则告知用户并确认后执行
    bash ${CLAUDE_SKILL_DIR}/scripts/install.sh
    (用户确认后可加
    --yes
    跳过安装器内部确认)
  2. 登录检查
    bdpan whoami
    ,未登录则引导执行
    bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
  3. 路径校验:验证远端路径在
    /apps/bdpan/
    范围内

Execute in order every time triggered:
  1. Installation Check:
    command -v bdpan
    , if not installed, inform user and execute
    bash ${CLAUDE_SKILL_DIR}/scripts/install.sh
    after confirmation (user can add
    --yes
    to skip installer internal confirmation after confirmation)
  2. Login Check:
    bdpan whoami
    , if not logged in, guide user to execute
    bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
  3. Path Validation: Verify that remote path is within
    /apps/bdpan/
    scope

确认规则

Confirmation Rules

风险等级操作策略
高(必须确认)
rm
删除、上传/下载目标已存在同名文件
列出影响范围,等待用户确认
中(路径模糊时确认)upload、download、mv、rename、cp路径明确直接执行,不明确则确认
低(直接执行)ls、search、whoami、mkdir、share无需确认
额外规则:
  • 操作意图模糊("处理文件"→确认上传还是下载)→ 必须确认
  • 序数/代词引用有歧义("第N个"、"它"、"上面那个")→ 必须确认
  • 用户取消意图("算了"、"不要了"、"取消")→ 立即中止,不执行任何命令

Risk LevelOperationStrategy
High (Must Confirm)
rm
delete, upload/download where target has same name file
List affected scope, wait for user confirmation
Medium (Confirm when path is ambiguous)upload, download, mv, rename, cpExecute directly if path is clear, confirm if ambiguous
Low (Execute Directly)ls, search, whoami, mkdir, shareNo confirmation needed
Additional Rules:
  • Ambiguous operation intent ("process file" → confirm upload or download) → Must confirm
  • Ambiguous ordinal/pronoun references ("Nth", "it", "the above one") → Must confirm
  • User cancels intent ("forget it", "don't", "cancel") → Abort immediately, do not execute any commands

核心操作

Core Operations

查看状态

Check Status

bash
bdpan whoami
bash
bdpan whoami

列表查询

List Query

bash
bdpan ls [目录路径] [--json] [--order name|time|size] [--desc] [--folder]
bash
bdpan ls [directory path] [--json] [--order name|time|size] [--desc] [--folder]

上传

Upload

bash
bdpan upload <本地路径> <远端路径>
关键约束: 单文件上传远端路径必须是文件名,禁止以
/
结尾。文件夹上传:
bdpan upload ./project/ project/
步骤:确认本地路径存在 → 确认远端路径 →
bdpan ls
检查远端是否已存在 → 执行。
bash
bdpan upload <local path> <remote path>
Key Constraints: Remote path for single file upload must be a file name, prohibit ending with
/
. Folder upload:
bdpan upload ./project/ project/
.
Steps: Confirm local path exists → Confirm remote path →
bdpan ls
to check if remote exists → Execute.

下载

Download

直接下载:
bash
bdpan download <远端路径> <本地路径>
步骤:
bdpan ls
确认云端存在 → 确认本地路径 → 检查本地是否已存在 → 检查文件大小决定下载策略 → 执行。若 ls 未找到,建议
bdpan search <文件名>
大文件下载策略(重要):
Agent 的 Bash 工具有执行超时限制,大文件下载可能因超时而中断。必须根据文件大小选择下载策略:
  1. 获取文件大小:用
    bdpan ls --json <远端路径>
    获取
    size
    字段(字节)
  2. 按大小分策略执行
文件大小策略执行方式
≤ 50MB直接下载
bdpan download <远端路径> <本地路径>
,Bash timeout 设为 300000(5 分钟)
> 50MB后台下载使用
nohup
后台执行,Agent 轮询进度
小文件(≤ 50MB)直接下载:
正常执行
bdpan download
,Bash 工具 timeout 参数设为
300000
(5 分钟)。
大文件(> 50MB)后台下载流程:
bash
undefined
Direct Download:
bash
bdpan download <remote path> <local path>
Steps:
bdpan ls
to confirm cloud existence → Confirm local path → Check if local exists → Check file size to determine download strategy → Execute. If not found by ls, suggest
bdpan search <file name>
.
Large File Download Strategy (Important):
Agent's Bash tool has execution timeout limit, large file download may be interrupted due to timeout. Must select download strategy based on file size:
  1. Get File Size: Use
    bdpan ls --json <remote path>
    to get
    size
    field (bytes)
  2. Execute Strategy by Size:
File SizeStrategyExecution Method
≤ 50MBDirect Download
bdpan download <remote path> <local path>
, set Bash timeout to 300000 (5 minutes)
> 50MBBackground DownloadExecute in background using
nohup
, Agent polls progress
Small File (≤ 50MB) Direct Download:
Execute
bdpan download
normally, set Bash tool timeout parameter to
300000
(5 minutes).
Large File (> 50MB) Background Download Process:
bash
undefined

1. 启动后台下载(nohup + 进度日志)

1. Start background download (nohup + progress log)

nohup bdpan download <远端路径> <本地路径> > /tmp/bdpan-dl-$$.log 2>&1 & echo $!

```bash
nohup bdpan download <remote path> <local path> > /tmp/bdpan-dl-$$.log 2>&1 & echo $!

```bash

2. 轮询检查进度(每 30 秒检查一次,使用 Bash run_in_background)

2. Poll progress (check every 30 seconds, use Bash run_in_background)

检查进程是否存活 + 已下载文件大小

Check if process is alive + downloaded file size

kill -0 <PID> 2>/dev/null && echo "running" || echo "done"; ls -l <本地路径> 2>/dev/null; tail -5 /tmp/bdpan-dl-<PID>.log 2>/dev/null

```bash
kill -0 <PID> 2>/dev/null && echo "running" || echo "done"; ls -l <local path> 2>/dev/null; tail -5 /tmp/bdpan-dl-<PID>.log 2>/dev/null

```bash

3. 下载完成后清理日志

3. Clean up log after download completion

rm -f /tmp/bdpan-dl-<PID>.log

Agent 执行大文件后台下载时的行为规范:
- 启动后台下载后,**立即告知用户**:下载已在后台启动,文件大小 X,预计需要 Y 时间
- 每次轮询后向用户报告进度(已下载大小 / 总大小、百分比)
- 下载完成后告知用户最终结果
- 如果进程异常退出,检查日志并报告错误原因

**分享链接下载(先转存再下载到本地):**

```bash
bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/
bdpan download "https://pan.baidu.com/s/1xxxxx" ./downloaded/ -p abcd    # 提取码单独传入
bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/ -t my-folder  # 指定转存目录
分享链接下载同样适用大文件策略:转存完成后,用
bdpan ls --json
获取文件大小,再按上述策略执行下载。
rm -f /tmp/bdpan-dl-<PID>.log

Behavior specifications for Agent when executing large file background download:
- After starting background download, **immediately inform user**: Download has started in background, file size X, estimated time Y
- Report progress to user after each poll (downloaded size / total size, percentage)
- Inform user of final result after download completion
- If process exits abnormally, check log and report error reason

**Shared Link Download (Transfer first then download to local):**

```bash
bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/
bdpan download "https://pan.baidu.com/s/1xxxxx" ./downloaded/ -p abcd    # Pass extraction code separately
bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/ -t my-folder  # Specify transfer directory
Large file strategy also applies to shared link download: After transfer is completed, use
bdpan ls --json
to get file size, then execute download according to above strategy.

转存

Transfer

将分享文件转存到网盘,不下载到本地(与 download 分享链接模式的区别)。
bash
bdpan transfer "https://pan.baidu.com/s/1xxxxx" -p <提取码> [-d 目标目录] [--json]
步骤:确认分享链接格式有效 → 确认有提取码(链接中含
?pwd=
或反问用户)→ 确认目标目录 → 执行。转存成功后只展示本次转存的文件(非整个目录),显示数量和目标目录。
Transfer shared files to cloud drive, do not download to local (difference from shared link download mode).
bash
bdpan transfer "https://pan.baidu.com/s/1xxxxx" -p <extraction code> [-d target directory] [--json]
Steps: Confirm shared link format is valid → Confirm extraction code exists (link contains
?pwd=
or ask user) → Confirm target directory → Execute. After successful transfer, only display files transferred this time (not entire directory), show quantity and target directory.

分享

Share

bash
bdpan share <路径> [路径...] [--json]
步骤:
bdpan ls
确认文件存在 → 执行分享 → 展示链接+提取码+有效期。
付费接口,需在百度网盘开放平台购买服务。
bash
bdpan share <path> [path...] [--json]
Steps:
bdpan ls
to confirm file exists → Execute share → Display link + extraction code + validity period.
Paid interface, need to purchase service on Baidu Drive Open Platform.

搜索

Search

bash
bdpan search <关键词> [--category 0-7] [--no-dir|--dir-only] [--page-size N] [--page N] [--json]
category:0=全部 1=视频 2=音频 3=图片 4=文档 5=应用 6=其他 7=种子。
--no-dir
--dir-only
互斥。
bash
bdpan search <keyword> [--category 0-7] [--no-dir|--dir-only] [--page-size N] [--page N] [--json]
category: 0=All 1=Video 2=Audio 3=Image 4=Document 5=Application 6=Other 7=Torrent.
--no-dir
and
--dir-only
are mutually exclusive.

移动 / 复制 / 重命名 / 创建文件夹

Move / Copy / Rename / Create Folder

bash
bdpan mv <源路径> <目标目录>
bdpan cp <源路径> <目标目录>
bdpan rename <路径> <新名称>       # 第二参数是文件名,非完整路径
bdpan mkdir <路径>

bash
bdpan mv <source path> <target directory>
bdpan cp <source path> <target directory>
bdpan rename <path> <new name>       # Second parameter is file name, not full path
bdpan mkdir <path>

路径规则

Path Rules

场景格式示例
命令参数相对路径(相对于
/apps/bdpan/
bdpan upload ./f.txt docs/f.txt
展示给用户中文名"已上传到:我的应用数据/bdpan/docs/f.txt"
映射关系:
我的应用数据
/apps
禁止: 命令中使用中文路径(
我的应用数据/...
)、展示时暴露 API 路径(
/apps/bdpan/...
)。

ScenarioFormatExample
Command ParametersRelative path (relative to
/apps/bdpan/
)
bdpan upload ./f.txt docs/f.txt
Display to UserChinese name"Uploaded to: 我的应用数据/bdpan/docs/f.txt"
Mapping relationship:
我的应用数据
/apps
Prohibited: Use Chinese path in commands (
我的应用数据/...
), expose API path when displaying (
/apps/bdpan/...
).

授权码处理

Authorization Code Handling

用户发送 32 位十六进制字符串时,先确认:"这是百度网盘授权码吗?确认后将执行登录流程。" 确认后执行
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
(不使用
--yes
,保留安全确认环节)。

When user sends a 32-bit hexadecimal string, first confirm: "Is this the Baidu Drive authorization code? After confirmation, the login process will be executed." After confirmation, execute
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
(do not use
--yes
, retain security confirmation step).

管理功能

Management Functions

安装

Installation

bash
bash ${CLAUDE_SKILL_DIR}/scripts/install.sh [--yes]
安装器从百度 CDN(
issuecdn.baidupcs.com
)下载并执行。注意:install.sh 不执行本地 SHA256 校验,完整性依赖 HTTPS 传输保护。安全敏感场景建议先手动审查安装器内容或在沙箱中执行。
bash
bash ${CLAUDE_SKILL_DIR}/scripts/install.sh [--yes]
Installer downloads and executes from Baidu CDN (
issuecdn.baidupcs.com
). Note: install.sh does not perform local SHA256 verification, integrity relies on HTTPS transmission protection. For security-sensitive scenarios, it is recommended to manually review installer content first or execute in sandbox.

登录 / 注销 / 卸载

Login / Logout / Uninstall

bash
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh              # 登录(内置安全免责声明)
bdpan logout                                            # 注销
bash ${CLAUDE_SKILL_DIR}/scripts/uninstall.sh [--yes]   # 卸载
bash
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh              # Login (built-in security disclaimer)
bdpan logout                                            # Logout
bash ${CLAUDE_SKILL_DIR}/scripts/uninstall.sh [--yes]   # Uninstall

更新(必须用户明确指令触发)

Update (Must Be Triggered by Explicit User Instructions)

bash
bash ${CLAUDE_SKILL_DIR}/scripts/update.sh              # 检查并更新(需用户确认)
bash ${CLAUDE_SKILL_DIR}/scripts/update.sh --check       # 仅检查更新

bash
bash ${CLAUDE_SKILL_DIR}/scripts/update.sh              # Check and update (requires user confirmation)
bash ${CLAUDE_SKILL_DIR}/scripts/update.sh --check       # Only check for updates

参考文档

Reference Documents

遇到对应问题时按需查阅,无需预加载:
文档何时查阅
bdpan-commands.md需要完整命令参数、选项、JSON 输出格式
authentication.md认证流程细节、Token 管理
examples.md更多使用示例(批量上传、自动备份等)
troubleshooting.md遇到错误需要排查
Consult as needed when encountering corresponding issues, no need to preload:
DocumentWhen to Consult
bdpan-commands.mdNeed complete command parameters, options, JSON output format
authentication.mdAuthentication process details, Token management
examples.mdMore usage examples (batch upload, automatic backup, etc.)
troubleshooting.mdNeed to troubleshoot errors