Skip to content

feat(drive): extract copy reference doc and add auth diagnostic boundary rule - #2105

Open
yballul-bytedance wants to merge 1 commit into
larksuite:mainfrom
yballul-bytedance:auto-research-sync/01KYN276B4WWF3QH3Y50JDAYM8/mr-1290-9926613d
Open

feat(drive): extract copy reference doc and add auth diagnostic boundary rule#2105
yballul-bytedance wants to merge 1 commit into
larksuite:mainfrom
yballul-bytedance:auto-research-sync/01KYN276B4WWF3QH3Y50JDAYM8/mr-1290-9926613d

Conversation

@yballul-bytedance

@yballul-bytedance yballul-bytedance commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR improves the lark-drive skill 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

  • New file 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 unnecessary schema, +inspect, and drive files list pre-calls for non-wiki copies.
  • skills/lark-drive/SKILL.md — API Resources files.copy entry: 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 that auth status / whoami should only be invoked on explicit user request or on auth/scope/permission errors, not on deterministic resource errors like not found, invalid token, or unsupported type.

Test Plan

  • Verify skills/lark-drive/references/lark-drive-copy.md is present and links correctly from SKILL.md.
  • Confirm the quick-decision copy bullet in SKILL.md points to the new reference and no longer embeds inline parameter docs.
  • Confirm the files.copy entry in the API Resources section references the new doc.
  • Confirm the auth diagnostic boundary blockquote appears immediately after the CRITICAL line in SKILL.md.
  • Run git diff --check — no whitespace errors (already verified clean).

Related Issues

Auto research task: 01KYN276B4WWF3QH3Y50JDAYM8

Summary by CodeRabbit

  • Documentation
    • Clarified when authentication diagnostics are appropriate during Drive operations.
    • Added guidance for copying Drive files, including source identification, destination selection, and handling returned file tokens.
    • Documented special handling for wiki sources and approval-required copy operations.
    • Updated copy instructions to use the standard Drive copy command and avoid export/import workarounds.

…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)
@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact labels Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Drive 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.

Changes

Drive guidance

Layer / File(s) Summary
Authentication diagnostic boundary
skills/lark-drive/SKILL.md
Defines when to run authentication or identity diagnostics and when to stop and correct deterministic resource errors.
File-copy workflow reference
skills/lark-drive/references/lark-drive-copy.md, skills/lark-drive/SKILL.md
Adds detailed drive files copy guidance and routes quick-decision and API-method instructions to the reference while prohibiting export/import workarounds.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • larksuite/cli#1326: Updates Drive guidance for authentication and error-handling boundaries.
  • larksuite/cli#1673: Updates document-copy guidance and prohibits export/import reconstruction.
  • larksuite/cli#1913: Routes Drive decision guidance to dedicated reference documentation.

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately captures the main changes: copy reference extraction and auth diagnostic boundary.
Description check ✅ Passed The description follows the required template and covers summary, changes, test plan, and related issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 29a97db and 9200ec0.

📒 Files selected for processing (2)
  • skills/lark-drive/SKILL.md
  • skills/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` 等确定性资源错误应停止或纠正输入,不触发认证诊断。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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' || true

Repository: 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 || true

Repository: 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-L182
  • skills/lark-drive/SKILL.md#L26
  • skills/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。

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@9200ec0a401046673792c54be44ed644e64f2e06

🧩 Skill update

npx skills add yballul-bytedance/cli#auto-research-sync/01KYN276B4WWF3QH3Y50JDAYM8/mr-1290-9926613d -y -g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant