feat(drive): extract copy reference doc and add auth diagnostic boundary rule - #2105
Conversation
…ary rule - Add references/lark-drive-copy.md with structured copy workflow: URL-based token extraction, search-based file discovery, and copy command shape - Update quick-decision copy bullet to reference the new doc; remove verbose inline param docs and ban unnecessary schema/inspect/list pre-calls - Update files.copy entry in API Resources to point to reference doc - Add auth-diagnostic boundary blockquote: skip auth status checks for deterministic resource errors (not found, invalid token, unsupported type)
📝 WalkthroughWalkthroughDrive guidance now separates authentication diagnostics from deterministic resource errors and centralizes file-copy procedures in a new reference covering token resolution, copy parameters, folder targets, result handling, wiki tokens, and confirmation retries. ChangesDrive guidance
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/lark-drive/SKILL.md`:
- Line 15: Update the “认证诊断边界” guidance to document `lark-cli auth status --json
--verify` for explicit login or token validity checks, replacing unqualified
`lark-cli auth status`; retain `lark-cli whoami` for identity display and
preserve the existing triggers and resource-error exclusions.
- Line 26: 明确普通复制操作是 schema 预检的例外:在 skills/lark-drive/SKILL.md
第26行和第178-182行更新复制说明及通用 drive.<resource>.<method> 规则,明确排除 files.copy;同步在
skills/lark-drive/references/lark-drive-copy.md
第34行保持该例外说明一致,并确保普通文档、表格、多维表格、幻灯片和文件复制直接使用 lark-cli drive files copy。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e77a0890-0ec9-4dfb-bf0b-68708a4f7f5f
📒 Files selected for processing (2)
skills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-copy.md
|
|
||
| **CRITICAL — 开始前 MUST 先用 Read 工具读取 [`../lark-shared/SKILL.md`](../lark-shared/SKILL.md),其中包含认证、权限处理** | ||
|
|
||
| > **认证诊断边界:** 读取共享认证规则不等于需要预查认证状态。普通 Drive 任务直接执行目标命令;仅当用户明确要求检查登录态或身份,或目标命令返回明确的认证、scope 或权限错误时,才运行 `lark-cli auth status` 或 `lark-cli whoami`。`invalid token`、`not found`、`unsupported type` 等确定性资源错误应停止或纠正输入,不触发认证诊断。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)SKILL\.md$|lark-(drive|shared)' || true
echo "== target lines =="
cat -n skills/lark-drive/SKILL.md | sed -n '1,40p'
echo "== related auth commands =="
rg -n "auth status|whoami|--verify|--json|login|认证诊断\\|认证" skills/lark-drive/SKILL.md skills/lark-shared/SKILL.md 2>/dev/null || true
echo "== git diff stat/name =="
git diff --stat HEAD~1..HEAD 2>/dev/null || git diff --stat 2>/dev/null || true
git diff -- skills/lark-drive/SKILL.md 2>/dev/null | sed -n '1,200p' || trueRepository: larksuite/cli
Length of output: 12920
Point login/token checks to the shared verified auth-status command.
Update this boundary to use lark-cli auth status --json --verify for login/token validity checks; unqualified auth status should not be the documented diagnostic form. Keep lark-cli whoami for identity display.
🧰 Tools
🪛 SkillSpector (2.4.4)
[warning] 69: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.
Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.
(Memory Poisoning (MP2))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/lark-drive/SKILL.md` at line 15, Update the “认证诊断边界” guidance to
document `lark-cli auth status --json --verify` for explicit login or token
validity checks, replacing unqualified `lark-cli auth status`; retain `lark-cli
whoami` for identity display and preserve the existing triggers and
resource-error exclusions.
|
|
||
| - 用户要把**已有 Wiki 节点移出知识库,放到 Drive 文件夹或“我的空间”根目录**:切到 `lark-wiki`,使用 `lark-cli wiki +move-to-drive`;不要把 Wiki token 直接交给 `drive +move`。这是会改变文档归属和权限继承的写操作,执行前确认源节点与目标位置。 | ||
| - 用户要**复制文档 / 创建副本 / 另存为副本**时,使用 `lark-cli drive files copy`。先用 `lark-cli schema drive.files.copy --format json` 确认参数;如果来源是 wiki URL/token,先用 `lark-cli drive +inspect` 获取底层 `token` 和 `type`,不要把 wiki token 直接当 `file_token`。`params.file_token` 传源文档 token,`data.folder_token` 传目标文件夹 token,`data.name` 传副本名称,`data.type` 传源文件类型(如 `docx` / `sheet` / `bitable` / `slides`)。示例:`lark-cli drive files copy --params '{"file_token":"<DOC_TOKEN>"}' --data '{"folder_token":"<FOLDER_TOKEN>","name":"<COPY_NAME>","type":"docx"}'`。如返回 `confirmation_required`,按 `lark-shared` 高风险审批协议向用户确认后,在原命令末尾追加 `--yes` 重试。 | ||
| - 用户要**复制文档 / 创建副本 / 另存为副本**时,读取 [`references/lark-drive-copy.md`](references/lark-drive-copy.md),按其中参数来源使用 `lark-cli drive files copy`;非 wiki 的普通复制不要先跑 schema、inspect 或全量 list。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | grep -E '(^|/)skills/lark-drive/(SKILL.md|references/lark-drive-copy.md)$' || true
echo
echo "== relevant snippets =="
for f in skills/lark-drive/SKILL.md skills/lark-drive/references/lark-drive-copy.md; do
if [ -f "$f" ]; then
echo "--- $f line count: $(wc -l < "$f")"
fi
done
echo "--- skills/lark-drive/SKILL.md line 20-30"
sed -n '20,30p' skills/lark-drive/SKILL.md
echo "--- skills/lark-drive/SKILL.md schema/api related ranges"
rg -n "schema|native API|Files 普通复制|Lark文档|copy|普通 docx|sheet|bitable|slides|file" skills/lark-drive/SKILL.md -C 2 || true
echo "--- skills/lark-drive/references/lark-drive-copy.md line 25-45"
sed -n '25,45p' skills/lark-drive/references/lark-drive-copy.md
echo "--- copy file schema/list/.inspect/metas references"
rg -n "schema|inspect|list|batch_query|copy" skills/lark-drive/references/lark-drive-copy.md -C 2 || trueRepository: larksuite/cli
Length of output: 17688
Clarify that copy is the schema preflight exemption.
schema drive.files.copy / drive files copy is an drive <resource> <method> API call, but the copy quick-decision and reference explicitly forbid the schema preflight for ordinary docx/sheet/bitable/slides/file copies. Make the generic drive.<resource>.<method> schema rule explicitly exempt files.copy, or remove the copy exception.
skills/lark-drive/SKILL.md#L178-L182skills/lark-drive/SKILL.md#L26skills/lark-drive/references/lark-drive-copy.md#L34
🧰 Tools
🪛 SkillSpector (2.4.4)
[warning] 69: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.
Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.
(Memory Poisoning (MP2))
📍 Affects 2 files
skills/lark-drive/SKILL.md#L26-L26(this comment)skills/lark-drive/references/lark-drive-copy.md#L34-L34
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/lark-drive/SKILL.md` at line 26, 明确普通复制操作是 schema 预检的例外:在
skills/lark-drive/SKILL.md 第26行和第178-182行更新复制说明及通用 drive.<resource>.<method>
规则,明确排除 files.copy;同步在 skills/lark-drive/references/lark-drive-copy.md
第34行保持该例外说明一致,并确保普通文档、表格、多维表格、幻灯片和文件复制直接使用 lark-cli drive files copy。
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@9200ec0a401046673792c54be44ed644e64f2e06🧩 Skill updatenpx skills add yballul-bytedance/cli#auto-research-sync/01KYN276B4WWF3QH3Y50JDAYM8/mr-1290-9926613d -y -g |
Summary
This PR improves the
lark-driveskill in two related ways: it extracts the verbose file-copy workflow into a dedicated reference document, and it adds an explicit auth-diagnostic boundary rule to prevent unnecessary auth status checks on deterministic resource errors.Changes
skills/lark-drive/references/lark-drive-copy.md: structured copy workflow covering URL-based token extraction, search-based file discovery (with title-match safety rules), copy command shape, result usage, and boundary rules (no pre-call to schema/inspect/list for ordinary copies; wiki-only path still requires+inspect).skills/lark-drive/SKILL.md— quick-decision copy bullet: replaced verbose inline parameter documentation with a concise pointer to the new reference doc; explicitly bans unnecessaryschema,+inspect, anddrive files listpre-calls for non-wiki copies.skills/lark-drive/SKILL.md— API Resourcesfiles.copyentry: updated description to reference the new doc instead of pointing back to the quick-decision section.skills/lark-drive/SKILL.md— auth diagnostic boundary blockquote: new rule after the CRITICAL preamble clarifying thatauth status/whoamishould only be invoked on explicit user request or on auth/scope/permission errors, not on deterministic resource errors likenot found,invalid token, orunsupported type.Test Plan
skills/lark-drive/references/lark-drive-copy.mdis present and links correctly from SKILL.md.files.copyentry in the API Resources section references the new doc.git diff --check— no whitespace errors (already verified clean).Related Issues
Auto research task: 01KYN276B4WWF3QH3Y50JDAYM8
Summary by CodeRabbit