-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Open
huarenmin13
wants to merge
7
commits into
larksuite:main
Choose a base branch
from
huarenmin13:codex/base-field-query-guidance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+430
−14
Open
Changes from all commits
Commits
Show all changes
7 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 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
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,97 @@ | ||
| // 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 或数量", | ||
| "同名目标已存在时报告冲突", | ||
| "不能把已有资源算作本轮新增", | ||
| "不能静默复用或更新", | ||
| "对每类资源只做一次必要盘点", | ||
| "只有命令明确返回逐项结果时才优先使用批量创建", | ||
| "继续配置本轮返回的 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` 传字段对象数组", | ||
| "只有命令明确返回逐项结果时才优先使用批量创建", | ||
| } { | ||
| 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{ | ||
| "遇到首个失败即停止且不自动回滚已创建字段", | ||
| "部分失败返回 `ok:false`", | ||
| "`summary`", | ||
| "`items`", | ||
| "`next_step:\"inspect_items\"`", | ||
| "`missing_scopes`、`identity`、`console_url`", | ||
| "只有 `retryable:true` 的 `failed` 项可重试", | ||
| "`not_attempted` 项应单独继续", | ||
| } { | ||
| 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,57 @@ | ||
| // Copyright (c) 2026 Lark Technologies Pte. Ltd. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package base | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/larksuite/cli/internal/vfs" | ||
| ) | ||
|
|
||
| func TestDataQueryQuickGuideCoversConditionValueShapesWithoutScenarioTemplate(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/", | ||
| "Combine a date boundary and a status exclusion", | ||
| `"<date_field>"`, | ||
| `"<status_field>"`, | ||
| `"<status_value>"`, | ||
| } { | ||
| 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.