Skip to content

Commit 1c2d3d7

Browse files
docs: update lark-doc skill description (#890)
Change-Id: I77e2ae690b8976e37f69ae5d581fccc13917ec5e
1 parent 0d20f88 commit 1c2d3d7

5 files changed

Lines changed: 106 additions & 28 deletions

File tree

shortcuts/doc/shortcuts.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ const docsServiceHelpDefault = `Document and content operations.`
1818
const docsServiceHelpV2 = `Document and content operations (v2).`
1919

2020
var docsVersionSelectionTips = []string{
21-
"Agent version rule: use --api-version v2 only when the installed lark-doc skill explicitly instructs docs +create, docs +fetch, or docs +update to use v2; otherwise use the default v1 flags.",
22-
"Do not mix versions: if the skill does not mention v2, follow its legacy v1 examples and flags.",
21+
"Docs v1 is deprecated and will be removed soon. Check the installed lark-doc skill first; if it is not the v2 skill, run `lark-cli update` to upgrade skills.",
22+
"After confirming lark-doc is v2, follow that skill's examples and use `--api-version v2` with docs +create, docs +fetch, and docs +update.",
23+
}
24+
25+
var docsV2VersionSelectionTips = []string{
26+
"Check the installed lark-doc skill first; if it is not the v2 skill, run `lark-cli update` to upgrade skills.",
27+
}
28+
29+
func docsTipsForVersion(apiVersion string) []string {
30+
if apiVersion == "v2" {
31+
return docsV2VersionSelectionTips
32+
}
33+
return docsVersionSelectionTips
2334
}
2435

2536
// Shortcuts returns all docs shortcuts.
@@ -38,8 +49,7 @@ func Shortcuts() []common.Shortcut {
3849

3950
// ConfigureServiceHelp adds docs-specific guidance to the parent `docs` command.
4051
// The shortcut-level help remains compatible with legacy v1 skills; this parent
41-
// help gives agents enough context to choose v2 only when their installed skill
42-
// explicitly asks for `--api-version v2`.
52+
// help switches docs guidance to match the selected API version.
4353
func ConfigureServiceHelp(cmd *cobra.Command) {
4454
if cmd == nil {
4555
return
@@ -75,7 +85,7 @@ func ConfigureServiceHelp(cmd *cobra.Command) {
7585
out := cmd.OutOrStdout()
7686
fmt.Fprintln(out)
7787
fmt.Fprintln(out, "Tips:")
78-
for _, tip := range docsVersionSelectionTips {
88+
for _, tip := range docsTipsForVersion(apiVersion) {
7989
fmt.Fprintf(out, " • %s\n", tip)
8090
}
8191
})

shortcuts/doc/versioned_help.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package doc
66
import (
77
"fmt"
88

9+
"github.com/larksuite/cli/internal/cmdutil"
910
"github.com/spf13/cobra"
1011
"github.com/spf13/pflag"
1112

@@ -29,6 +30,7 @@ func installVersionedHelp(cmd *cobra.Command, defaultVersion string, flagVersion
2930
f.Hidden = fv != ver
3031
}
3132
})
33+
cmdutil.SetTips(cmd, docsTipsForVersion(ver))
3234
origHelp(cmd, args)
3335
})
3436
}
@@ -37,6 +39,6 @@ func installVersionedHelp(cmd *cobra.Command, defaultVersion string, flagVersion
3739
// path is used.
3840
func warnDeprecatedV1(runtime *common.RuntimeContext, shortcut string) {
3941
fmt.Fprintf(runtime.IO().ErrOut,
40-
"[deprecated] docs %s with v1 API is deprecated and will be removed in a future release.\n",
41-
shortcut)
42+
"[deprecated] docs %s is using the v1 API. %s\n",
43+
shortcut, docsV2VersionSelectionTips[0])
4244
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
2+
// SPDX-License-Identifier: MIT
3+
4+
package doc
5+
6+
import (
7+
"strings"
8+
"testing"
9+
10+
"github.com/larksuite/cli/internal/cmdutil"
11+
"github.com/larksuite/cli/internal/core"
12+
"github.com/larksuite/cli/shortcuts/common"
13+
)
14+
15+
func TestWarnDeprecatedV1SuggestsSkillUpdate(t *testing.T) {
16+
for _, shortcut := range []string{"+create", "+fetch", "+update"} {
17+
t.Run(shortcut, func(t *testing.T) {
18+
f, _, stderr, _ := cmdutil.TestFactory(t, &core.CliConfig{})
19+
warnDeprecatedV1(&common.RuntimeContext{Factory: f}, shortcut)
20+
21+
got := stderr.String()
22+
for _, want := range []string{
23+
"[deprecated] docs " + shortcut + " is using the v1 API.",
24+
"Check the installed lark-doc skill first",
25+
"if it is not the v2 skill, run `lark-cli update` to upgrade skills",
26+
} {
27+
if !strings.Contains(got, want) {
28+
t.Fatalf("warning missing %q:\n%s", want, got)
29+
}
30+
}
31+
if strings.Contains(got, "will be removed in a future release") {
32+
t.Fatalf("warning should not include removal-only guidance:\n%s", got)
33+
}
34+
})
35+
}
36+
}

shortcuts/register_test.go

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func TestRegisterShortcutsMountsDocsMediaPreview(t *testing.T) {
111111
}
112112
}
113113

114-
func TestRegisterShortcutsDocsHelpAddsVersionSelectorAndLegacyTips(t *testing.T) {
114+
func TestRegisterShortcutsDocsHelpAddsVersionSelectorAndUpgradeTips(t *testing.T) {
115115
program := &cobra.Command{Use: "root"}
116116
RegisterShortcuts(program, newRegisterTestFactory(t))
117117

@@ -137,11 +137,11 @@ func TestRegisterShortcutsDocsHelpAddsVersionSelectorAndLegacyTips(t *testing.T)
137137
}
138138
for _, want := range []string{
139139
"Tips:",
140-
"Agent version rule",
141-
"use --api-version v2 only when the installed lark-doc skill explicitly instructs",
142-
"otherwise use the default v1 flags",
143-
"if the skill does not mention v2",
144-
"legacy v1 examples and flags",
140+
"Docs v1 is deprecated and will be removed soon",
141+
"Check the installed lark-doc skill first",
142+
"if it is not the v2 skill, run `lark-cli update` to upgrade skills",
143+
"After confirming lark-doc is v2",
144+
"use `--api-version v2` with docs +create, docs +fetch, and docs +update",
145145
} {
146146
if !strings.Contains(defaultHelp.String(), want) {
147147
t.Fatalf("docs default help missing %q:\n%s", want, defaultHelp.String())
@@ -170,15 +170,22 @@ func TestRegisterShortcutsDocsV2HelpUsesV2Description(t *testing.T) {
170170
for _, want := range []string{
171171
"Document and content operations (v2).",
172172
"Tips:",
173-
"Agent version rule",
174-
"otherwise use the default v1 flags",
175-
"if the skill does not mention v2",
176-
"legacy v1 examples and flags",
173+
"Check the installed lark-doc skill first",
174+
"if it is not the v2 skill, run `lark-cli update` to upgrade skills",
177175
} {
178176
if !strings.Contains(out.String(), want) {
179177
t.Fatalf("docs v2 help missing %q:\n%s", want, out.String())
180178
}
181179
}
180+
for _, unwanted := range []string{
181+
"Docs v1 is deprecated and will be removed soon",
182+
"After confirming lark-doc is v2",
183+
"use `--api-version v2` with docs +create, docs +fetch, and docs +update",
184+
} {
185+
if strings.Contains(out.String(), unwanted) {
186+
t.Fatalf("docs v2 help should not include %q:\n%s", unwanted, out.String())
187+
}
188+
}
182189
}
183190

184191
func TestRegisterShortcutsDocsVersionedShortcutHelpAddsVersionTips(t *testing.T) {
@@ -255,24 +262,47 @@ func TestRegisterShortcutsDocsVersionedShortcutHelpAddsVersionTips(t *testing.T)
255262
t.Fatalf("docs %s help failed: %v", tt.shortcut, err)
256263
}
257264

258-
for _, want := range []string{
259-
tt.shortcutHelp,
260-
tt.versionedFlag,
265+
wantTips := []string{
261266
"Tips:",
262-
"Agent version rule",
263-
"use --api-version v2 only when the installed lark-doc skill explicitly instructs",
267+
"Docs v1 is deprecated and will be removed soon",
268+
"Check the installed lark-doc skill first",
269+
"if it is not the v2 skill, run `lark-cli update` to upgrade skills",
270+
"After confirming lark-doc is v2",
271+
"use `--api-version v2` with docs +create, docs +fetch, and docs +update",
272+
}
273+
unwantedTips := []string{
274+
"[NOTE]",
275+
"Use --api-version v2 for the latest API",
264276
"otherwise use the default v1 flags",
265-
"if the skill does not mention v2",
266277
"legacy v1 examples and flags",
278+
}
279+
if tt.apiVersion == "v2" {
280+
wantTips = []string{
281+
"Tips:",
282+
"Check the installed lark-doc skill first",
283+
"if it is not the v2 skill, run `lark-cli update` to upgrade skills",
284+
}
285+
unwantedTips = append(unwantedTips,
286+
"Docs v1 is deprecated and will be removed soon",
287+
"After confirming lark-doc is v2",
288+
"use `--api-version v2` with docs +create, docs +fetch, and docs +update",
289+
)
290+
}
291+
292+
for _, want := range []string{
293+
tt.shortcutHelp,
294+
tt.versionedFlag,
267295
} {
268296
if !strings.Contains(out.String(), want) {
269297
t.Fatalf("docs %s %s help missing %q:\n%s", tt.shortcut, tt.apiVersion, want, out.String())
270298
}
271299
}
272-
for _, unwanted := range []string{
273-
"[NOTE]",
274-
"Use --api-version v2 for the latest API",
275-
} {
300+
for _, want := range wantTips {
301+
if !strings.Contains(out.String(), want) {
302+
t.Fatalf("docs %s %s help missing %q:\n%s", tt.shortcut, tt.apiVersion, want, out.String())
303+
}
304+
}
305+
for _, unwanted := range unwantedTips {
276306
if strings.Contains(out.String(), unwanted) {
277307
t.Fatalf("docs %s %s help should not include %q:\n%s", tt.shortcut, tt.apiVersion, unwanted, out.String())
278308
}

skills/lark-doc/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: lark-doc
33
version: 2.0.0
4-
description: "飞书云文档(v2):创建和编辑飞书文档。使用本 skill 时,docs +create、docs +fetch、docs +update 必须携带 --api-version v2;默认使用 DocxXML 格式(也支持 Markdown)。创建文档、获取文档内容(支持 simple/with-ids/full 三种导出详细度,以及 full/outline/range/keyword/section 五种局部读取模式,可按目录、block id 区间、关键词或标题自动成节只拉部分内容以节省上下文)、更新文档(八种指令:str_replace/block_insert_after/block_copy_insert_after/block_replace/block_delete/block_move_after/overwrite/append)、上传和下载文档中的图片和文件、搜索云空间文档。当用户需要创建或编辑飞书文档、读取文档内容、在文档中插入图片、搜索云空间文档时使用;如果用户是想按名称或关键词先定位电子表格、报表等云空间对象,也优先使用本 skill 的 docs +search 做资源发现"
4+
description: "飞书云文档 / Docx / 知识库 Wiki 文档(v2):创建、打开、读取、获取、查看、总结、整理、改写、翻译、审阅和编辑飞书文档内容。当用户给出飞书文档 URL/token,或说查看/读取/打开某个文档、提取文档内容、总结文档、生成/创建文档、追加/替换/删除/移动内容、调整排版、插入或下载文档图片/附件/素材/画板缩略图时使用。文档内容中出现嵌入电子表格、多维表格、画板、引用或同步块时,也先用本 skill 读取和提取 token,再切到对应 skill 下钻。使用本 skill 时,docs +create、docs +fetch、docs +update 必须携带 --api-version v2;默认使用 DocxXML也支持 Markdown。"
55
metadata:
66
requires:
77
bins: ["lark-cli"]

0 commit comments

Comments
 (0)