Skip to content

Commit 482485b

Browse files
committed
docs(skills): document drive +status in lark-drive skill
Adds references/lark-drive-status.md covering parameters, output schema, the type=file scoping rule, and the network-traffic caveat (hash is streamed in memory, but bytes still cross the wire). Notes that --local-dir is bounded to cwd by the CLI's path validation, and that when a user wants to compare a directory outside cwd the agent should ask the user to relocate or to switch the agent's working directory rather than `cd`-ing on its own. Wires +status into the Shortcuts table in SKILL.md.
1 parent 9c1f32e commit 482485b

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

skills/lark-drive/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ Shortcut 是对常用操作的高级封装(`lark-cli drive +<verb> [flags]`)
228228
| [`+upload`](references/lark-drive-upload.md) | Upload a local file to a Drive folder or wiki node |
229229
| [`+create-folder`](references/lark-drive-create-folder.md) | Create a Drive folder, optionally under a parent folder, with bot auto-grant support |
230230
| [`+download`](references/lark-drive-download.md) | Download a file from Drive to local |
231+
| [`+status`](references/lark-drive-status.md) | Compare a local directory with a Drive folder by SHA-256 content hash; reports `new_local` / `new_remote` / `modified` / `unchanged` (read-only diff primitive for sync workflows). `--local-dir` 必须是 cwd 内的相对路径,越界路径 CLI 会直接拒绝;目标在 cwd 外时引导用户切换 agent 工作目录,不要私自 `cd` 绕过。 |
231232
| [`+create-shortcut`](references/lark-drive-create-shortcut.md) | Create a shortcut to an existing Drive file in another folder |
232233
| [`+add-comment`](references/lark-drive-add-comment.md) | Add a comment to doc/docx/sheet/slides, also supports wiki URL resolving to doc/docx/sheet/slides |
233234
| [`+export`](references/lark-drive-export.md) | Export a doc/docx/sheet/bitable to a local file with limited polling |
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
# drive +status
3+
4+
> **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。
5+
6+
按 SHA-256 内容哈希比较本地目录与飞书云空间文件夹,输出四类差异:
7+
8+
| 字段 | 含义 |
9+
|------|------|
10+
| `new_local` | 仅本地存在 |
11+
| `new_remote` | 仅云端存在 |
12+
| `modified` | 双端都存在但 hash 不一致 |
13+
| `unchanged` | 双端都存在且 hash 一致 |
14+
15+
只读命令:流式 hash,不下载落盘;但双端都有的文件会从云端拉一份字节流过来在内存里算 hash,大目录 / 大文件会有可观的网络流量。
16+
17+
## 命令
18+
19+
```bash
20+
# 基础用法 —— 两个必填参数
21+
lark-cli drive +status \
22+
--local-dir ./repo \
23+
--folder-token fldcnxxxxxxxxx
24+
25+
# 只看 hash 不一致的项(结合 --jq 过滤)
26+
lark-cli drive +status \
27+
--local-dir ./repo \
28+
--folder-token fldcnxxxxxxxxx \
29+
--jq '.modified'
30+
```
31+
32+
## 参数
33+
34+
| 标志 | 必填 | 类型 | 说明 |
35+
|------|------|------|------|
36+
| `--local-dir` || path | 本地根目录(**必须是 cwd 的相对路径**;绝对路径或逃逸到 cwd 外的相对路径会被 CLI 直接拒绝) |
37+
| `--folder-token` || string | Drive 文件夹 token |
38+
39+
## 输出 schema
40+
41+
```json
42+
{
43+
"new_local": [{"rel_path": "..."}],
44+
"new_remote": [{"rel_path": "...", "file_token": "..."}],
45+
"modified": [{"rel_path": "...", "file_token": "..."}],
46+
"unchanged": [{"rel_path": "...", "file_token": "..."}]
47+
}
48+
```
49+
50+
`rel_path` 始终用 `/` 作为分隔符(跨平台一致),相对于 `--local-dir``--folder-token` 的根。仅本地存在时没有 `file_token` 字段。
51+
52+
## 比较范围
53+
54+
- **只比对 Drive `type=file` 的二进制文件**。在线文档(`docx` / `sheet` / `bitable` / `mindnote` / `slides`)和快捷方式(`shortcut`)都被跳过 —— 它们没有等价的本地二进制可对齐,否则会在 `new_remote` 里产生大量误报。
55+
- 子文件夹会递归遍历;rel_path 形如 `sub1/sub2/file.txt`
56+
- 本地侧只比对常规文件(regular file);符号链接、设备文件等被忽略。
57+
58+
## 范围限制
59+
60+
`+status` 的本地侧只接受 cwd 下的相对路径。如果用户想比对的目录在 cwd 之外,**不要 agent 自己 `cd` 绕过**;告诉用户切换 agent 工作目录到合适的祖先后重试,或者把目标软链接到 cwd 内。CLI 会在路径越界时直接报错(`unsafe file path`),无需在 skill 这一层提前手动校验。
61+
62+
## 典型用法
63+
64+
把 +status 当作"先看差异、再决定怎么同步"的只读探针。常见接驳场景:
65+
66+
- 想知道云端有什么本地没有的内容 → 看 `new_remote`,按需选择性拉取(`drive +download --file-token <token>`)。
67+
- 想把本地新增的内容推到云端 → 看 `new_local`,再 `drive +upload --file <path> --folder-token <parent>`(注意 +upload 不接受 0 字节文件)。
68+
- 想知道哪些文件在云端被同事改过 → 看 `modified`,逐个 `drive +download` 查内容差异。
69+
70+
## 性能注意
71+
72+
- `unchanged` + `modified` 的总字节数 = 本次需从云端下载的流量。100GB 的双端共享内容意味着 100GB 网络往返。
73+
- 仅一侧存在的文件不会被下载。
74+
- Hash 计算在内存里流式做(io.Copy → sha256.New),不会把云端文件落到磁盘。
75+
76+
## 所需 scope
77+
78+
| 操作 | scope |
79+
|------|-------|
80+
| 列出文件夹 / 子目录 | `drive:drive.metadata:readonly` |
81+
| 下载并 hash 文件 | `drive:file:download` |
82+
83+
如果当前 token 缺这些 scope,命令会直接报 `missing_scope` 并提示重新登录。`drive:drive` 在部分企业被策略禁用,所以 +status 故意只声明上面这两个细粒度 scope。
84+
85+
## 参考
86+
87+
- [lark-drive](../SKILL.md) —— 云空间全部命令
88+
- [lark-shared](../../lark-shared/SKILL.md) —— 认证和全局参数
89+
- [lark-drive-upload](lark-drive-upload.md) / [lark-drive-download](lark-drive-download.md) —— 把 +status 输出接到推/拉动作上

0 commit comments

Comments
 (0)