-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(base): improve field creation and query guidance #2114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zhouyue-bytedance
merged 17 commits into
larksuite:main
from
huarenmin13:codex/base-field-query-guidance
Aug 7, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9ba8ffa
fix(base): improve field creation and query guidance
huarenmin13 c88ec54
test(base): strengthen guidance contracts
huarenmin13 bfbe90d
fix(base): generalize data-query filter guidance
huarenmin13 db0506b
fix(base): generalize creation guidance
huarenmin13 a1f350e
fix(base): report partial field-create results
huarenmin13 03c4bee
fix(base): preserve partial field-create recovery metadata
huarenmin13 4d1fb9a
fix(base): separate partial field recovery
huarenmin13 f22e5b0
perf(base): 缩短字段批量创建的空等
huarenmin13 1eac5d2
fix(base): 收紧不支持字段行为的终止边界
huarenmin13 16e1431
perf(base): 压缩字段批量创建的评测开销
huarenmin13 fcc5e6b
chore(base): 同步 main 并保留字段评测优化
huarenmin13 bcb3ceb
perf(base): 收敛字段批量创建的上下文
huarenmin13 3b223bb
fix(base): 恢复批量字段输出与分页默认契约
huarenmin13 f8673e5
chore(merge): sync latest main error presentation contract
huarenmin13 4af48f7
fix(base): present batch field errors before partial output
huarenmin13 dc18110
fix(base): allow recovery before retrying failed field writes
huarenmin13 6680508
fix(base): preserve partial field recovery contracts
huarenmin13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // Copyright (c) 2026 Lark Technologies Pte. Ltd. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package base | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/larksuite/cli/internal/vfs" | ||
| ) | ||
|
|
||
| func TestBaseSkillKeepsCreateSemanticsLiteralAndGeneric(t *testing.T) { | ||
| const skillPath = "../../skills/lark-base/SKILL.md" | ||
| content, err := vfs.ReadFile(skillPath) | ||
| if err != nil { | ||
| t.Fatalf("read lark-base skill: %v", err) | ||
| } | ||
|
|
||
| skill := string(content) | ||
| normalizedSkill := strings.Join(strings.Fields(skill), " ") | ||
| for _, want := range []string{ | ||
| "用户要求“新增/创建”时", | ||
| "本轮 create 返回的对象、ID 或数量", | ||
| "不能把已有资源算作本轮新增", | ||
| "按具体命令或 guide 的同名契约处理", | ||
| "不得自行改写用户语义", | ||
| "对每类资源只做一次必要盘点", | ||
| "只有命令明确返回逐项结果时才优先使用批量创建", | ||
| "继续配置本轮返回的 ID", | ||
| } { | ||
| if !strings.Contains(normalizedSkill, want) { | ||
| t.Fatalf("lark-base skill missing %q", want) | ||
| } | ||
| } | ||
|
|
||
| for _, forbidden := range []string{ | ||
| "base_table_", | ||
| "larkoffice.com/base/", | ||
| "grading_pass_rate", | ||
| } { | ||
| if strings.Contains(skill, forbidden) { | ||
| t.Fatalf("lark-base skill must remain generic, found %q", forbidden) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestFieldCreateBatchContractStaysConsistentAcrossSkillAndReferences(t *testing.T) { | ||
| readNormalized := func(path string) string { | ||
| t.Helper() | ||
| content, err := vfs.ReadFile(path) | ||
| if err != nil { | ||
| t.Fatalf("read %s: %v", path, err) | ||
| } | ||
| return strings.Join(strings.Fields(string(content)), " ") | ||
| } | ||
|
|
||
| skill := readNormalized("../../skills/lark-base/SKILL.md") | ||
| fieldJSON := readNormalized("../../skills/lark-base/references/lark-base-field-json.md") | ||
| fieldCreate := readNormalized("../../skills/lark-base/references/lark-base-field-create.md") | ||
|
|
||
| for _, want := range []string{ | ||
| "同一表创建多个字段时,默认一次向 `+field-create --json` 传字段对象数组", | ||
| "预计串行运行时间超过 caller/tool timeout 时按时间预算拆分", | ||
| "不按固定条数切块", | ||
| "仅创建一个或多个只含 `name` + `type:text` 的简单字段时按 `+field-create --help` 即可", | ||
| "其他类型或属性必读", | ||
| "除上述简单 text fast path 外,写字段前先读", | ||
| "只有命令明确返回逐项结果时才优先使用批量创建", | ||
| "`+field-create` 数组是顺序单项请求,按 caller timeout 而非固定条数拆分", | ||
| } { | ||
| if !strings.Contains(skill, want) { | ||
| t.Fatalf("lark-base skill missing %q", want) | ||
| } | ||
| } | ||
| for _, want := range []string{ | ||
| "单个字段定义始终是 JSON 对象", | ||
| "`+field-create --json` 接受一个字段对象或非空字段对象数组", | ||
| "`+field-update --json` 只接受一个字段对象", | ||
| } { | ||
| if !strings.Contains(fieldJSON, want) { | ||
| t.Fatalf("field JSON SSOT missing %q", want) | ||
| } | ||
| } | ||
| if strings.Contains(fieldJSON, "`--json` 必须是 JSON 对象") { | ||
| t.Fatal("field JSON SSOT must not apply the update-only top-level object rule to field-create") | ||
| } | ||
| for _, want := range []string{ | ||
| "预计串行运行时间超过 caller/tool timeout 时按时间预算拆分,不按固定条数切块", | ||
| "遇到首个失败即停止且不自动回滚已创建字段", | ||
| "部分失败返回 `ok:false`", | ||
| "`summary`", | ||
| "`items`", | ||
| "`next_step:\"inspect_items\"`", | ||
| "`missing_scopes`、`identity`、`console_url`", | ||
| "`challenge_url`", | ||
| "`retryable:true` 只表示该 `failed` 项可原样自动重试", | ||
| "否则先按该项 `hint` 完成授权或修正输入,再重新提交该项", | ||
| "`not_attempted` 项应单独继续", | ||
| "调用方超时且未收到命令终态输出时,不要重投整个数组", | ||
| "先按本次提交的字段名定向读回,再只提交缺失项", | ||
| "没有写前快照时,读回命中的同名项只能标记为 `ambiguous`", | ||
| "不得计作本轮 `created`", | ||
| } { | ||
| if !strings.Contains(fieldCreate, want) { | ||
| t.Fatalf("field-create reference missing %q", want) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright (c) 2026 Lark Technologies Pte. Ltd. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package base | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/larksuite/cli/internal/vfs" | ||
| ) | ||
|
|
||
| func TestDataQueryQuickGuideCoversConditionValueShapesWithoutCaseArtifacts(t *testing.T) { | ||
| const guidePath = "../../skills/lark-base/references/lark-base-data-query-guide.md" | ||
| content, err := vfs.ReadFile(guidePath) | ||
| if err != nil { | ||
| t.Fatalf("read data-query quick guide: %v", err) | ||
| } | ||
| guide := string(content) | ||
| normalizedGuide := strings.Join(strings.Fields(guide), " ") | ||
|
|
||
| for _, want := range []string{ | ||
| "Common `Condition.value` shapes", | ||
| "`is` / `isNot`", | ||
| "exactly one option name", | ||
| "`isGreater`", | ||
| "`isLess`", | ||
| "`isEmpty`", | ||
| "`isNotEmpty`", | ||
| "uses `[]`", | ||
| `["Today"]`, | ||
| `["ExactDate","<epoch_ms>"]`, | ||
| "Use relative date keywords only for relative requests", | ||
| "[lark-base-data-query.md](lark-base-data-query.md)", | ||
| } { | ||
| if !strings.Contains(normalizedGuide, want) { | ||
| t.Fatalf("quick guide missing %q", want) | ||
| } | ||
| } | ||
|
|
||
| if len(content) > 6*1024 { | ||
| t.Fatalf("quick guide grew to %d bytes; keep full DSL details in lark-base-data-query.md", len(content)) | ||
| } | ||
|
|
||
| for _, forbidden := range []string{ | ||
| "base_table_", | ||
| "bytedance.larkoffice.com/base/", | ||
| } { | ||
| if strings.Contains(normalizedGuide, forbidden) { | ||
| t.Fatalf("quick guide must remain generic, found %q", forbidden) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.