Qiniu Cloud Storage Management (qshell)
This skill wraps the qshell CLI to let you manage Qiniu Kodo storage through natural language. It handles prerequisite checks, command selection, and result formatting automatically.
Pre-flight Checks
Before executing any storage operation, run these checks in order. The reason for checking every time is that qshell state can change between sessions (uninstalled, credentials expired), and failing silently leads to confusing errors.
1. Installation Check
CODEBLOCK0
If this fails, the user doesn't have qshell installed. Stop and guide them through installation (see references/install-guide.md).
2. Authentication Check
CODEBLOCK1
If the output is empty or shows an error, the user needs to configure credentials:
qshell account <AccessKey> <SecretKey> <Name>
Direct them to
Qiniu Key Management to get their AK/SK.
3. Proceed with the Request
Once both checks pass, execute the user's request using the command reference below.
Command Reference
Uploading Files
Choose the upload method based on what the user provides:
- - Single file, under 100MB: INLINECODE2
- Single file, 100MB or larger:
qshell rput [--overwrite] <Bucket> <Key> <LocalFile> — rput uses resumable upload, so if it fails partway through, re-running the same command resumes from where it left off rather than starting over. - Entire directory:
qshell qupload2 --src-dir=<Dir> --bucket=<Bucket> [--overwrite] [--key-prefix=<Prefix>] [--thread-count=<N>] — if some files fail during batch upload, qupload2 logs failures to a local file. Re-running the same command retries only the failed files.
To decide which to use: check the file size first (ls -lh <file>). If the user points to a directory rather than a file, use qupload2.
Key (remote path) inference: When the user doesn't specify a remote path, use the local filename as the Key. If they mention a remote directory like images/, concatenate it as images/filename.ext.
After a successful upload: Run qshell domains <Bucket> to get the bound domain, then show the user the full access URL: http(s)://<Domain>/<Key>. Prefer CDN domains when multiple domains are available.
Downloading Files
- - Single file: INLINECODE11
- Batch download: Requires a config file. See
references/batch-download.md for the JSON format.
File Operations
| Operation | Command |
|---|
| List files | INLINECODE13 |
| File info |
qshell stat <Bucket> <Key> |
| Delete file |
qshell delete <Bucket> <Key> |
| Copy file |
qshell copy <SrcBucket> <SrcKey> <DstBucket> [-k <DstKey>] |
| Move/rename |
qshell move <SrcBucket> <SrcKey> <DstBucket> [-k <DstKey>] |
When listing files, use --limit 20 by default to keep output manageable. However, if the user explicitly asks for "all" files or a large number, omit the limit or set a high value to respect their intent.
Before deleting: Always run qshell stat first and show the file details to the user. Wait for explicit confirmation before executing qshell delete. This prevents accidental data loss — deleted files in Kodo cannot be recovered without versioning enabled.
Bucket Management
| Operation | Command |
|---|
| List buckets | INLINECODE21 |
| Bucket domains |
qshell domains <Bucket> |
| Create bucket |
qshell mkbucket <Bucket> --region <Region> |
Region values: z0 (East China), z1 (North China), z2 (South China), na0 (North America), as0 (Southeast Asia), cn-east-2 (East China - Zhejiang 2)
CDN and Network
| Operation | Command |
|---|
| Fetch URL to bucket | INLINECODE30 |
| CDN refresh URLs |
qshell cdnrefresh -i <file> |
| CDN refresh dirs |
qshell cdnrefresh -r -i <file> |
| CDN prefetch |
qshell cdnprefetch -i <file> |
| Private download URL |
qshell privateurl <PublicUrl> [--deadline <timestamp>] |
Error Recovery
When a command fails, diagnose and guide the user rather than just showing the raw error:
| Error pattern | What happened | What to do |
|---|
| INLINECODE35 | Local file path is wrong | Help the user verify the path exists |
| INLINECODE36 / INLINECODE37 |
Credentials missing or expired | Re-run
qshell account |
|
no such bucket | Bucket name doesn't exist | Run
qshell buckets to show available ones |
|
file exists | Remote file already exists | Ask if they want to add
--overwrite |
|
key doesn't exist | Remote key not found | Use
qshell listbucket2 to find the correct key |
|
bad token /
expired token | Auth token expired | Re-run
qshell account |
| Network timeout | Connectivity issue | Suggest checking network and retrying |
Reference Files
- -
references/install-guide.md — Platform-specific installation instructions (Windows, macOS, Linux) - INLINECODE49 — JSON config format for
qdownload batch downloads
Examples
Example 1:
Input: "Upload ./logo.png to my-bucket"
Steps: Check file size -> qshell fput my-bucket logo.png ./logo.png -> qshell domains my-bucket -> Return URL
Example 2:
Input: "List all jpg files in my-bucket"
Steps: qshell listbucket2 my-bucket --limit 100 -> Filter results for .jpg suffix -> Display
Example 3:
Input: "Delete old-file.txt from my-bucket"
Steps: qshell stat my-bucket old-file.txt -> Show file info -> Wait for user confirmation -> INLINECODE56
七牛云存储管理 (qshell)
此技能封装了 qshell 命令行工具,让您可以通过自然语言管理七牛 Kodo 存储。它自动完成前置检查、命令选择和结果格式化。
前置检查
在执行任何存储操作之前,请按顺序运行这些检查。每次都要检查的原因是 qshell 的状态可能在会话之间发生变化(未安装、凭证过期),静默失败会导致令人困惑的错误。
1. 安装检查
bash
qshell --version
如果此命令失败,说明用户未安装 qshell。请停止操作并引导用户完成安装(参见 references/install-guide.md)。
2. 认证检查
bash
qshell user ls
如果输出为空或显示错误,用户需要配置凭证:
bash
qshell account
引导用户前往七牛密钥管理获取 AK/SK。
3. 执行请求
两项检查均通过后,使用下面的命令参考执行用户的请求。
命令参考
上传文件
根据用户提供的内容选择上传方式:
- - 单个文件,小于100MB:qshell fput [--overwrite]
- 单个文件,100MB及以上:qshell rput [--overwrite] — rput 使用断点续传,如果中途失败,重新运行相同命令会从中断处继续,而不是从头开始。
- 整个目录:qshell qupload2 --src-dir= --bucket= [--overwrite] [--key-prefix=] [--thread-count=] — 如果批量上传过程中部分文件失败,qupload2 会将失败记录到本地文件。重新运行相同命令只会重试失败的文件。
如何选择:先检查文件大小(ls -lh )。如果用户指向的是目录而非文件,则使用 qupload2。
Key(远程路径)推断:当用户未指定远程路径时,使用本地文件名作为 Key。如果用户提到远程目录如 images/,则拼接为 images/filename.ext。
上传成功后:运行 qshell domains 获取绑定的域名,然后向用户展示完整的访问 URL:http(s):///。当有多个域名时,优先使用 CDN 域名。
下载文件
- - 单个文件:qshell get [-o ]
- 批量下载:需要配置文件。JSON 格式参见 references/batch-download.md。
文件操作
| 操作 | 命令 |
|---|
| 列出文件 | qshell listbucket2 <Bucket> [--prefix <P>] [--limit <N>] [--marker <M>] |
| 文件信息 |
qshell stat
|
| 删除文件 | qshell delete |
| 复制文件 | qshell copy [-k ] |
| 移动/重命名 | qshell move [-k ] |
列出文件时,默认使用 --limit 20 以保持输出可控。但如果用户明确要求列出所有文件或大量文件,则省略限制或设置较高值以尊重用户意图。
删除前:始终先运行 qshell stat 并向用户展示文件详情。等待用户明确确认后再执行 qshell delete。这可以防止意外数据丢失——未启用版本控制的情况下,Kodo 中删除的文件无法恢复。
存储空间管理
| 操作 | 命令 |
|---|
| 列出存储空间 | qshell buckets |
| 存储空间域名 |
qshell domains |
| 创建存储空间 | qshell mkbucket --region |
区域值:z0(华东)、z1(华北)、z2(华南)、na0(北美)、as0(东南亚)、cn-east-2(华东-浙江2)
CDN 与网络
| 操作 | 命令 |
|---|
| 抓取 URL 到存储空间 | qshell fetch <URL> <Bucket> <Key> |
| CDN 刷新 URL |
qshell cdnrefresh -i |
| CDN 刷新目录 | qshell cdnrefresh -r -i |
| CDN 预热 | qshell cdnprefetch -i |
| 私有下载 URL | qshell privateurl [--deadline ] |
错误恢复
当命令失败时,诊断问题并引导用户,而不是仅显示原始错误:
| 错误模式 | 发生了什么 | 如何处理 |
|---|
| no such file or directory | 本地文件路径错误 | 帮助用户验证路径是否存在 |
| invalid account / no auth |
凭证缺失或过期 | 重新运行 qshell account |
| no such bucket | 存储空间名称不存在 | 运行 qshell buckets 显示可用存储空间 |
| file exists | 远程文件已存在 | 询问是否要添加 --overwrite |
| key doesnt exist | 远程 Key 未找到 | 使用 qshell listbucket2 查找正确的 Key |
| bad token / expired token | 认证令牌过期 | 重新运行 qshell account |
| Network timeout | 网络连接问题 | 建议检查网络并重试 |
参考文件
- - references/install-guide.md — 各平台安装说明(Windows、macOS、Linux)
- references/batch-download.md — qdownload 批量下载的 JSON 配置格式
示例
示例 1:
输入:上传 ./logo.png 到 my-bucket
步骤:检查文件大小 -> qshell fput my-bucket logo.png ./logo.png -> qshell domains my-bucket -> 返回 URL
示例 2:
输入:列出 my-bucket 中所有 jpg 文件
步骤:qshell listbucket2 my-bucket --limit 100 -> 过滤 .jpg 后缀的结果 -> 展示
示例 3:
输入:从 my-bucket 删除 old-file.txt
步骤:qshell stat my-bucket old-file.txt -> 显示文件信息 -> 等待用户确认 -> qshell delete my-bucket old-file.txt