feat(sheets): add --ai-only to +formula-verify for AI formula status - #1959
feat(sheets): add --ai-only to +formula-verify for AI formula status#1959wenzhuozhen wants to merge 3 commits into
Conversation
…polling BE-2: +formula-verify gains --ai-only, mapping to verify_formula tool input ai_only=true. AI formulas (AI_WRITE / AI_CLASSIFY / …) compute asynchronously; --ai-only is a single-shot polling probe (no built-in wait/timeout) that skips the ordinary 7-Excel-error scan and returns current AI-formula compute status. Coexists with --sheet-id/--range and honors --exit-on-error. BE-4: mirror sheet-skill-spec SoT docs (AI formula list in lark-sheets-formula-translation, --ai-only + async polling section in lark-sheets-formula-verify) and regenerate flag_defs_gen.go. Spec source: active@6fe4ea7389c6d0631dc8279ee7506c357d0600325e28ffabdc97d9a66339e762
…rding Mirror from sheet-skill-spec SoT (ee/sheet-skill-spec MR!55): - formula-translation: full AI function param details (range rules, AI_TRANSLATE language keys, AI_EXTRACT type, AI_CLASSIFY modes, AI_INFER/AI_IMPORTDATA array semantics) - formula-verify: clarify --ai-only convergence expectation, drop implementation-leaking phrasing
📝 WalkthroughWalkthroughThe ChangesAI formula verification
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant FormulaVerifyCLI
participant formulaVerifyInput
participant verify_formula
FormulaVerifyCLI->>formulaVerifyInput: parse --ai-only and selectors
formulaVerifyInput->>verify_formula: send ai_only=true and optional ranges
verify_formula-->>FormulaVerifyCLI: return current AI formula status
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@bf638654a1a7d2fa3f2516d5b6b7a028d2b090ee🧩 Skill updatenpx skills add larksuite/cli#feat/lark-sheets-develop-ai-formula -y -g |
Sync the lark-sheets AI formula skill from sheet-skill-spec (SoT) after the product change that merges all AI formulas into one AI() function: - formula-translation reference: single =AI(prompt, [range]) function with syntax (incl. variadic =AI(part1, part2, ...) concatenation), per-case usage table (translate / sentiment / classify / extract / summarize / rewrite / generate / cleanup / keywords / multi-cell prompt), and prompt best practices - formula-verify reference + --ai-only flag def: unified AI() wording - flag_defs_gen.go regenerated from flag-defs.json - lark_sheet_formula_verify.go: drop stale AI_WRITE / AI_CLASSIFY names in the ai_only comment, reference the unified AI() function Co-authored-by: TRAE CLI <noreply@bytedance.com>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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-sheets/references/lark-sheets-formula-translation.md`:
- Around line 38-42: Add a supported language identifier, such as text, to the
fenced formula example blocks containing the AI formulas, including both
locations referenced by the comment. Keep the formula examples unchanged.
- Line 72: Update the structured-output example in the formula translation
guidance to use valid JSON with double-quoted property names and concrete JSON
values; describe the permitted score range separately rather than using “0-100”
as a value. Keep the existing category and score fields and guidance intact.
- Line 87: Update the post-write validation guidance around
lark-sheets-formula-verify and +formula-verify --ai-only so completion requires
every AI formula to have status done and no failure or unsupported statuses.
Continue polling while any formula is pending, and do not declare the run
complete merely because pending formulas are absent.
In `@skills/lark-sheets/references/lark-sheets-formula-verify.md`:
- Line 73: Update the AI formula signature in lark-sheets-formula-verify.md to
match lark-sheets-formula-translation.md by including the variadic form
=AI(part1, part2, ...), or explicitly state that =AI(prompt, [range]) is
shorthand for it.
🪄 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: d72e1c61-bf87-48d4-9cdf-ec8d6dc6eb87
📒 Files selected for processing (5)
shortcuts/sheets/data/flag-defs.jsonshortcuts/sheets/flag_defs_gen.goshortcuts/sheets/lark_sheet_formula_verify.goskills/lark-sheets/references/lark-sheets-formula-translation.mdskills/lark-sheets/references/lark-sheets-formula-verify.md
🚧 Files skipped from review as they are similar to previous changes (3)
- shortcuts/sheets/flag_defs_gen.go
- shortcuts/sheets/data/flag-defs.json
- shortcuts/sheets/lark_sheet_formula_verify.go
| ``` | ||
| =AI(prompt) | ||
| =AI(prompt, range) | ||
| =AI(part1, part2, ...) | ||
| ``` |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add language identifiers to the fenced formula examples.
The two fenced blocks trigger markdownlint MD040. Use an appropriate identifier such as text or the repository’s supported formula-language identifier.
Also applies to: 78-81
🧰 Tools
🪛 markdownlint-cli2 (0.23.0)
[warning] 38-38: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 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-sheets/references/lark-sheets-formula-translation.md` around
lines 38 - 42, Add a supported language identifier, such as text, to the fenced
formula example blocks containing the AI formulas, including both locations
referenced by the comment. Keep the formula examples unchanged.
Source: Linters/SAST tools
| 1. **明确输出格式**:与其写"分析一下",不如写"判断情绪,只返回 Positive / Neutral / Negative"。限定可选值能让结果可机读、可再计算。 | ||
| 2. **指定语言**:写"翻译成中文"比只写"翻译"更稳定。 | ||
| 3. **指定长度**:如"总结成一句话""30 字以内"。 | ||
| 4. **需要结构化时明确要 JSON**:如提示"返回 JSON:{category:'', score:0-100}",AI 能较稳定地输出结构化结果。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use a valid JSON example.
{'category':'', 'score':0-100} is not valid JSON because it uses single quotes and a non-value range expression. Show valid JSON, and describe the allowed score range separately.
🤖 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-sheets/references/lark-sheets-formula-translation.md` at line 72,
Update the structured-output example in the formula translation guidance to use
valid JSON with double-quoted property names and concrete JSON values; describe
the permitted score range separately rather than using “0-100” as a value. Keep
the existing category and score fields and guidance intact.
|
|
||
| 对整列逐行跑 AI,推荐**模板单元格 + `--copy-to-range` 向下扩展**:在种子单元格写 `=AI("<提示词>", A2)`,再用 `--copy-to-range` 扩展到整列,相对引用会随行自增(`A2` → `A3` → …)。这样每行独立计算、行为可预测,比依赖单条公式一次铺开整列更稳。 | ||
|
|
||
| **写完 AI 公式后的校验**:AI 公式异步计算,少量公式通常很快就能算出结果;一次批量写入较多公式时,部分公式在校验时仍处于计算中(pending)属于正常现象。写完后用 `lark-sheets-formula-verify` 的 `+formula-verify --ai-only` 查看 AI 公式计算状态,直到不再有 pending 即算完成。细节见 `lark-sheets-formula-verify`。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not equate “no pending” with successful completion.
A failed or unsupported AI formula is also no longer pending. Require all formulas to be done with no failure statuses before declaring the run complete.
Proposed wording
-写完后用 `lark-sheets-formula-verify` 的 `+formula-verify --ai-only` 查看 AI 公式计算状态,直到不再有 pending 即算完成。
+写完后用 `lark-sheets-formula-verify` 的 `+formula-verify --ai-only` 查看状态,直到所有公式均为 done 且没有 failed/unsupported 状态;若出现失败,应先处理后再交付。📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| **写完 AI 公式后的校验**:AI 公式异步计算,少量公式通常很快就能算出结果;一次批量写入较多公式时,部分公式在校验时仍处于计算中(pending)属于正常现象。写完后用 `lark-sheets-formula-verify` 的 `+formula-verify --ai-only` 查看 AI 公式计算状态,直到不再有 pending 即算完成。细节见 `lark-sheets-formula-verify`。 | |
| **写完 AI 公式后的校验**:AI 公式异步计算,少量公式通常很快就能算出结果;一次批量写入较多公式时,部分公式在校验时仍处于计算中(pending)属于正常现象。写完后用 `lark-sheets-formula-verify` 的 `+formula-verify --ai-only` 查看状态,直到所有公式均为 done 且没有 failed/unsupported 状态;若出现失败,应先处理后再交付。细节见 `lark-sheets-formula-verify`。 |
🤖 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-sheets/references/lark-sheets-formula-translation.md` at line 87,
Update the post-write validation guidance around lark-sheets-formula-verify and
+formula-verify --ai-only so completion requires every AI formula to have status
done and no failure or unsupported statuses. Continue polling while any formula
is pending, and do not declare the run complete merely because pending formulas
are absent.
|
|
||
| ## AI 公式校验(`--ai-only`) | ||
|
|
||
| 飞书表格提供一个统一的 **`AI` 公式**(`=AI(prompt, [range])`,用自然语言驱动翻译 / 分类 / 情感分析 / 信息提取 / 总结 / 润色等,写法与清单见 `lark-sheets-formula-translation`)。AI 公式的写入与普通公式一致(复用 `+cells-set` / `set_cell_range`,无需特殊接口),但**计算是异步的**:写入后要等 AI 算完才有结果。普通的 `+formula-verify` 只扫本地单元格值(7 类 Excel 错误),看不到 AI 公式的计算状态。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep the AI signature consistent with the translation reference.
This parenthetical only advertises =AI(prompt, [range]), while skills/lark-sheets/references/lark-sheets-formula-translation.md also documents =AI(part1, part2, ...). Include the variadic form or explicitly state that the notation is shorthand.
🤖 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-sheets/references/lark-sheets-formula-verify.md` at line 73,
Update the AI formula signature in lark-sheets-formula-verify.md to match
lark-sheets-formula-translation.md by including the variadic form =AI(part1,
part2, ...), or explicitly state that =AI(prompt, [range]) is shorthand for it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1959 +/- ##
==========================================
+ Coverage 74.72% 75.15% +0.43%
==========================================
Files 886 912 +26
Lines 92621 96455 +3834
==========================================
+ Hits 69208 72494 +3286
- Misses 18052 18383 +331
- Partials 5361 5578 +217 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Add a
--ai-onlymode tosheets +formula-verifyso agents can check the compute status of asynchronous AI formulas (AI_WRITE / AI_CLASSIFY / AI_SENTIMENT / AI_EXTRACT / AI_POLISH / AI_SUMMARY / AI_TRANSLATE), and enrich the lark-sheets skill docs with AI-formula parameter details and clearer verify guidance.Changes
sheets +formula-verify: add--ai-onlyflag, mapped to theverify_formulatool inputai_only=true. It skips the ordinary 7-Excel-error scan and returns the current AI-formula compute status; a single call is a status probe and coexists with--sheet-id/--sheet-name/--range, honoring--exit-on-error.flag_defs_gen.goand add dry-run cases for--ai-only.sheet-skill-speccanonical source):lark-sheets-formula-translation: full AI-function parameter details — range rules,AI_TRANSLATElanguage keys,AI_EXTRACTextract-type,AI_CLASSIFYthree modes,AI_INFER/AI_IMPORTDATAarray semantics.lark-sheets-formula-verify: clarify--ai-onlyconvergence expectation (small batches resolve quickly; pending on large batches is normal) and drop implementation-leaking phrasing.Test Plan
go test ./shortcuts/sheets/ -run 'TestFormulaVerify|FlagDef')lark-cli sheets +formula-verify --ai-onlyflow works end-to-end against a real spreadsheet (returnsai_formula_total/done/pending/failed+status)Related Issues
Summary by CodeRabbit
New Features
--ai-onlyoption to+formula-verifyto verify only AI formulas and skip standard Excel-style error scanning.--rangefilters.Documentation
AIformula syntax, supported use cases, and best practices.