Skip to content

feat(drive): document copy workflow guidance - #2184

Open
SongHantian wants to merge 7 commits into
larksuite:mainfrom
SongHantian:auto-research-sync/01KYVM5CMVBXCSZWETFR6Y4VAQ/mr-1358-5fb17c0d
Open

feat(drive): document copy workflow guidance#2184
SongHantian wants to merge 7 commits into
larksuite:mainfrom
SongHantian:auto-research-sync/01KYVM5CMVBXCSZWETFR6Y4VAQ/mr-1358-5fb17c0d

Conversation

@SongHantian

@SongHantian SongHantian commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Document the Drive file copy workflow so agents use the native copy API with stable parameters and avoid unnecessary schema, inspect, or metadata calls.

Changes

  • Added a dedicated Drive copy reference covering source selection, fixed drive files copy parameters, wiki/folder URL handling, post-copy editing boundaries, and error recovery.
  • Updated the Drive skill routing guidance for copy operations, title search uniqueness, authentication diagnostics, and the files.copy API exception.

Test Plan

  • git diff --check

Related Issues

Auto research task: 01KYVM5CMVBXCSZWETFR6Y4VAQ

Summary by CodeRabbit

  • New Features

    • Added precise title-based search guidance, including long-title matching and duplicate-result handling.
    • Added a streamlined copy-and-edit workflow using the newly created copy for subsequent edits.
    • Added clearer handling for validation errors and uncertain request outcomes.
  • Bug Fixes

    • Refined authentication guidance to apply only when identity checks or authentication-related errors require it.
    • Clarified when verification is unnecessary and when additional information is needed.

@CLAassistant

CLAassistant commented Aug 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR updates Lark Drive guidance. Authentication rules are conditional. Search guidance defines strict title matching. Copy guidance defines source selection, token use, limited reads, completion behavior, and error recovery.

Changes

Lark Drive skill guidance

Layer / File(s) Summary
Conditional authentication and title search rules
skills/lark-drive/SKILL.md, skills/lark-drive/references/lark-drive-search.md
Shared authentication guidance is read only for explicit identity checks or authentication-related errors. Title searches use --only-title, validate long-title results, and require one unique match before write operations.
Copy workflow and error recovery
skills/lark-drive/references/lark-drive-copy.md
The copy workflow selects one unique source, performs one copy, uses the returned token for edits, limits block-ID reads, and handles deterministic, validation, and uncertain transport failures.

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

Possibly related PRs

  • larksuite/cli#2159: Updates the same Lark Drive authentication, copy, and search guidance.
  • larksuite/cli#2226: Introduces the shared authentication guidance that this PR loads conditionally.

Suggested labels: documentation

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: documenting the Drive copy workflow.
Description check ✅ Passed The description includes all required sections and clearly explains the workflow changes, with a specific diff check in the test plan.
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.

@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 Aug 4, 2026

@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: 1

🧹 Nitpick comments (1)
skills/lark-drive/references/lark-drive-copy.md (1)

17-22: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy lift

Add executable coverage for the fixed copy contract.

Lines 17-22 define the exact drive files copy request, but tests/cli_e2e/drive/coverage.md reports no workflow test for this command. Add a contract test that verifies --file-token, data.folder_token, data.name, and data.type, including rejection of a missing folder_token. Otherwise, a CLI change can silently invalidate this reference and the routing in skills/lark-drive/SKILL.md.

🤖 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/references/lark-drive-copy.md` around lines 17 - 22, Add
executable contract coverage for the `drive files copy` request documented in
`lark-drive-copy.md`, covering `--file-token`, `data.folder_token`, `data.name`,
and `data.type`. Include a negative case that rejects a missing `folder_token`,
and register the workflow in `tests/cli_e2e/drive/coverage.md` so changes to the
CLI contract or `skills/lark-drive/SKILL.md` routing are detected.
🤖 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/references/lark-drive-copy.md`:
- Around line 46-50: 在“错误恢复”部分补充 drive files copy 的未知结果处理:对超时、连接重置、5xx
等可能已到达服务端的传输失败不得自动重试;优先使用可用的幂等机制或结果核对,无法核对时先征得用户确认再重试,并保留现有确定性错误的停止规则。

---

Nitpick comments:
In `@skills/lark-drive/references/lark-drive-copy.md`:
- Around line 17-22: Add executable contract coverage for the `drive files copy`
request documented in `lark-drive-copy.md`, covering `--file-token`,
`data.folder_token`, `data.name`, and `data.type`. Include a negative case that
rejects a missing `folder_token`, and register the workflow in
`tests/cli_e2e/drive/coverage.md` so changes to the CLI contract or
`skills/lark-drive/SKILL.md` routing are detected.
🪄 Autofix

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: 91003c75-5e28-485a-be69-926189f4f313

📥 Commits

Reviewing files that changed from the base of the PR and between 811d37e and 9188319.

📒 Files selected for processing (2)
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-copy.md

Comment thread skills/lark-drive/references/lark-drive-copy.md Outdated
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add SongHantian/cli#auto-research-sync/01KYVM5CMVBXCSZWETFR6Y4VAQ/mr-1358-5fb17c0d -y -g

@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: 1

🤖 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 13: 更新认证与确认路由规则,将未结构化但明确表示登录态失败的 Drive/API 错误(包括 `1061005 auth failed`
等资源引用中的错误)纳入读取 `../lark-shared/SKILL.md` 的认证诊断路径;保留 `invalid token`、`not
found`、`unsupported type` 及租户安全策略等确定性业务错误不触发诊断。
🪄 Autofix

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: bd261e7f-b4d8-41a7-9b0f-905020f8231e

📥 Commits

Reviewing files that changed from the base of the PR and between 9188319 and 12742be.

📒 Files selected for processing (2)
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-copy.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-drive/references/lark-drive-copy.md

Comment thread skills/lark-drive/SKILL.md Outdated
Comment thread skills/lark-drive/SKILL.md Outdated

- 用户要把**已有 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` 参数契约;首次调用不预查 `--help` 或 schema,仅在返回明确的结构化参数错误后查询 schema

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个 张超 那边现在在封装成drive +copy

Comment thread skills/lark-drive/SKILL.md Outdated
- 用户要**整理云盘 / 文件夹 / 文档库 / 知识库 / 个人文档库**,或要“盘点目录结构、找出未归档/临时/重复/空目录、生成整理方案”,必须先阅读 [`references/lark-drive-workflow.md`](references/lark-drive-workflow.md),再按其中 `Workflow Registry` 进入 [`knowledge_organize`](references/lark-drive-workflow-knowledge-organize.md) workflow。默认只生成方案;创建目录、移动资源、申请权限都必须单独确认。
- 按主题跨范围查找并集中归档,进入 `topic_move_collector`;对已知文件夹、文档库或知识库做目录盘点和结构重组,进入 `knowledge_organize`;只移动一个已明确资源时仍使用原子移动命令。
- 用户要**搜文档 / Wiki / 电子表格 / 多维表格 / 云空间(云盘/云存储)对象**,优先使用 `lark-cli drive +search`。自然语言里"最近我编辑过的"、"我创建的"(→ `--created-by-me`,原始创建者语义)、"我负责/owner 的"(→ `--mine`,owner 语义)、"最近一周我打开过的 xxx"、"某人 owner 的 docx" 等直接映射到扁平 flag,避免手写嵌套 JSON。
- 用户要**搜文档 / Wiki / 电子表格 / 多维表格 / 云空间(云盘/云存储)对象**,包括按标题判断资源是否存在、是否唯一或是否重复时,优先使用 `lark-cli drive +search --query "<标题或关键词>"`;`drive files list` 只用于用户明确要求枚举文件夹直接子项,不能替代标题搜索。存在多个完整标题严格相等的候选时停止,不要选择第一项或执行写操作。`+search` 不接受位置参数。自然语言里"最近我编辑过的"、"我创建的"(→ `--created-by-me`,原始创建者语义)、"我负责/owner 的"(→ `--mine`,owner 语义)、"最近一周我打开过的 xxx"、"某人 owner 的 docx" 等直接映射到扁平 flag,避免手写嵌套 JSON。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

不加这个的话,agent的表现是什么,是否能放到search或者files list的ref skill中,感觉把一个很边界场景放到这里有点不合适

Comment thread skills/lark-drive/SKILL.md Outdated

```bash
lark-cli schema drive.<resource>.<method> # 调用 API 前必须先查看参数结构
lark-cli schema drive.<resource>.<method> # 原生 API 调用前查看参数结构;普通 files.copy 例外

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

为什么例外。。

Comment thread skills/lark-drive/SKILL.md Outdated
```

> **重要**:使用原生 API 时,必须先运行 `schema` 查看 `--data` / `--params` 参数结构,不要猜测字段格式。
> **重要**:使用原生 API 时,必须先运行 `schema` 查看 `--data` / `--params` 参数结构,不要猜测字段格式。普通 `drive files copy` 是例外:执行前读取 [`references/lark-drive-copy.md`](references/lark-drive-copy.md),直接使用其中的固定参数契约;仅在命令返回结构化参数错误后再查 schema。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里也是,尽量不要在这种通用描述下,针对单个特殊case做特化说明,这样后面每优化一个场景,就在后面追加一条,很不优雅

Comment thread skills/lark-drive/SKILL.md Outdated

- 用户要把**已有 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` 参数契约;首次调用不预查 `--help` 或 schema,仅在返回明确的结构化参数错误后查询 schema

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

不要引导“首次调用不预查 --help 或 schema,仅在返回明确的结构化参数错误后查询 schema。”这种,可能会放大错误率

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

成功率优先

@SongHantian
SongHantian force-pushed the auto-research-sync/01KYVM5CMVBXCSZWETFR6Y4VAQ/mr-1358-5fb17c0d branch from 8b0422f to dfeadd0 Compare August 10, 2026 06:39
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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/references/lark-drive-copy.md`:
- Around line 53-54: Update the post-copy guidance in the final
structured-success workflow to state that if drive +copy succeeds but the
following edit fails, retain data.file_token and retry only the edit; do not
repeat the full copy workflow, which could create a duplicate.

In `@skills/lark-drive/references/lark-drive-search.md`:
- Around line 28-29: Update the full-title search guidance to require checking
all paginated drive +search results when has_more=true, using the same query
until either uniqueness is proven or a documented pagination limit is reached.
Permit write operations only for exactly one strict match across the checked
pages; otherwise report no match or list candidates and request clarification.
🪄 Autofix

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: 31c7909a-5935-4676-b399-bfe6b2fe40f1

📥 Commits

Reviewing files that changed from the base of the PR and between 2016120 and dfeadd0.

📒 Files selected for processing (3)
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-copy.md
  • skills/lark-drive/references/lark-drive-search.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-drive/SKILL.md

Comment thread skills/lark-drive/references/lark-drive-copy.md Outdated
Comment thread skills/lark-drive/references/lark-drive-search.md Outdated
Comment thread skills/lark-drive/SKILL.md Outdated
# drive (v1)

**CRITICAL — 开始前 MUST 先用 Read 工具读取 [`../lark-shared/SKILL.md`](../lark-shared/SKILL.md),其中包含认证、权限处理**
**认证与确认路由:** 普通 Drive 请求直接执行目标命令。仅当用户要求检查登录态或身份,或目标命令返回认证失败(含 `1061005`)、授权、scope、权限或 `confirmation_required` 时,读取 [`../lark-shared/SKILL.md`](../lark-shared/SKILL.md) 处理。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个和当前这个改动应该无关,先改回去吧,担心会对整体准确率有影响


# drive +search(云空间/云盘/云存储搜索:扁平 flag,面向自然语言场景)

> **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个也是,改回去吧,不要删掉


# drive +copy

> **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。

@wittam-01 wittam-01 Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

改回去,不要删掉

Comment thread skills/lark-drive/references/lark-drive-copy.md Outdated
Comment thread skills/lark-drive/references/lark-drive-copy.md
Comment thread skills/lark-drive/references/lark-drive-copy.md Outdated
本节定义复制后操作的路由;状态无关的后续操作直接执行,状态依赖的文档编辑再进入 `lark-doc` 通用更新流程。

1. 需要按标题定位源文件时,先按 [`lark-drive-search.md`](lark-drive-search.md) 使用 `drive +search` 得到唯一匹配的源资源;已提供可直接使用的 URL 或 token 时从该资源开始。
2. 使用已确认的源 URL,或真实 token 与 type,执行一次 `drive +copy`。目标位置使用用户给出的文件夹 URL/token;复制到“我的空间”或未指定其他目标位置时使用 `--folder-token my_space`。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个skill本身已经有指引如何复制到文件夹或者目标位置了,是否不需要重复提示

2. 使用已确认的源 URL,或真实 token 与 type,执行一次 `drive +copy`。目标位置使用用户给出的文件夹 URL/token;复制到“我的空间”或未指定其他目标位置时使用 `--folder-token my_space`。
3. 从成功响应的 `data.file_token` 或 `data.url` 取得新副本;后续只操作该副本,不重新搜索副本,也不操作源 token。
4. 后续写入所需的目标 token、位置和内容均可由用户输入与复制响应确定时,直接按对应资源 Skill 执行写入,不为获取这些参数而预读副本。
5. 需要当前结构才能确定写入位置时,按对应资源 Skill 读取必要的最小范围;不得猜测 block ID 或正文范围。写入返回明确成功且没有 warning 后即完成;仅在用户要求验证、返回部分成功或 warning,或下一步依赖服务端最新状态时读取结果。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个也是,预期应该不需要专门引导


- bot 身份复制成功后,CLI 会自动尝试给当前 CLI 用户授予新副本的 `full_access`,结果在输出的 `data.permission_grant` 字段中;授权失败不影响复制本身的成功状态

## 复制后继续处理

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

感觉这一小节,保留#1就好,其他都不是必须的。感觉为了节省token太严格限制agent对操作了

@SongHantian
SongHantian force-pushed the auto-research-sync/01KYVM5CMVBXCSZWETFR6Y4VAQ/mr-1358-5fb17c0d branch from 5e50600 to aaedf5e Compare August 10, 2026 13:05
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.

3 participants