feat: add okr single create shortcut & skill text opti#1941
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds an ChangesOKR creation feature
Pagination for listings
Batch-create extensions
Documentation updates
Estimated code review effort: 4 (Complex) | ~75 minutes Sequence Diagram(s)sequenceDiagram
participant User as User
participant CLI as okr +create
participant Validate as Validate
participant OKRv2API as OKR v2 API
User->>CLI: --level, cycle/objective IDs, --style, --content, optional --notes/--category-id
CLI->>Validate: enforce level rules, parse content by style
Validate-->>CLI: validation error or parsed params
alt validation passed
CLI->>OKRv2API: POST objective or key-result
OKRv2API-->>CLI: return objective_id or key_result_id
CLI-->>User: success: created ID
else validation failed
CLI-->>User: error: validation message
end
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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@4f1d8207df0702143920b3cf5d53ba7c883231b9🧩 Skill updatenpx skills add larksuite/cli#feat/okr_single_create_v2 -y -g |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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 `@shortcuts/okr/okr_create_test.go`:
- Around line 351-363: Update the dry-run contract assertions at
shortcuts/okr/okr_create_test.go:351-363 to parse the structured envelope and
assert the objective API method, exact path, query fields, and serialized
content body; apply the same structured assertions at
shortcuts/okr/okr_create_test.go:381-390 for the key-result method, path, and
rich-text body. Replace substring method/path checks with exact structured-field
assertions at tests/cli_e2e/okr/okr_shortcuts_test.go:41-45 and
tests/cli_e2e/okr/okr_shortcuts_test.go:68-72, preserving the existing expected
API values.
In `@shortcuts/okr/okr_create.go`:
- Around line 126-149: Add typed validation in the level switch around the
existing cycleID and objectiveID handling: reject --objective-id when level is
"objective" and reject --cycle-id when level is "key-result", before processing
the applicable identifier. Use the existing errs.NewValidationError pattern with
the corresponding option parameter, while preserving current validation for
identifiers that apply to the selected level.
- Around line 46-89: Update the JSON decoding in the simple-style and
ContentBlock branches of the content parsing flow to reject unknown fields,
including typos such as “mentions.” Use strict decoder behavior for both
SemiPlainContent and ContentBlock, and preserve the existing typed --content
validation errors by wrapping unknown-field decode failures with the same
validation error context and cause.
- Around line 162-185: Replace the loose map contracts in the OKR create flow
with typed request, query, response, and output structs. Add one explicit
projection function per required map shape for the objective and key-result API
calls, and pass the typed models through CallAPITyped. Apply the same boundary
conversion to the response extraction and output payload sections referenced at
the additional locations, preserving their existing fields and behavior.
In `@shortcuts/okr/okr_cycle_list.go`:
- Around line 67-70: Update the month-cycle guard in the cycle classification
logic to compare cycleEnd against the next-month boundary derived from
cycleStart, rather than using AddDate with a one-year offset. Add coverage for
this month-cycle path in TestIsCurrentActiveCycle while preserving existing
behavior for other cycle types.
🪄 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
Run ID: c9bf3b10-03f8-4ff5-bee7-d0abdc475dc0
📒 Files selected for processing (9)
shortcuts/okr/okr_create.goshortcuts/okr/okr_create_test.goshortcuts/okr/okr_cycle_list.goshortcuts/okr/shortcuts.goshortcuts/okr/shortcuts_test.goskills/lark-okr/SKILL.mdskills/lark-okr/references/lark-okr-create.mdskills/lark-okr/references/lark-okr-entities.mdtests/cli_e2e/okr/okr_shortcuts_test.go
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1941 +/- ##
==========================================
+ Coverage 75.00% 75.04% +0.04%
==========================================
Files 900 902 +2
Lines 95187 95638 +451
==========================================
+ Hits 71395 71774 +379
- Misses 18311 18343 +32
- Partials 5481 5521 +40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
skills/lark-okr/SKILL.md (1)
111-113: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRestore creation operations in the API resource index.
The new
+createworkflow is documented, but its Objective and Key Result creation operations are absent from the API Resources index. Restore both entries, or explicitly document the actual endpoints used by the shortcut.
skills/lark-okr/SKILL.md#L111-L113: restore the Objectivecreateoperation.skills/lark-okr/SKILL.md#L155-L156: restore the Key Resultcreateoperation.🤖 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-okr/SKILL.md` around lines 111 - 113, The API Resources index omits creation operations required by the documented +create workflow. In skills/lark-okr/SKILL.md lines 111-113, restore the Objective create entry under cycle.objectives, and in lines 155-156, restore the Key Result create entry; if the shortcut uses different endpoints, document those actual endpoints instead.
🤖 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 `@shortcuts/okr/okr_cycle_list_test.go`:
- Around line 125-140: The validation tests for
TestCycleListValidate_InvalidPageSize in
shortcuts/okr/okr_cycle_list_test.go:125-140 and the corresponding progress-list
test in shortcuts/okr/okr_progress_list_test.go:128-144 should assert the typed
pagination validation error fields directly. Verify the error classification and
that its parameter identifies --page-size, replacing the string-substring check
while preserving the invalid-input failure assertion.
In `@shortcuts/okr/okr_progress_list.go`:
- Around line 79-80: Update the page-token handling in the OKR progress list
flow to preserve the value returned by runtime.Str("page-token") exactly,
without strings.TrimSpace or any other normalization, in both affected
locations. Continue omitting the parameter only when the original value is
empty, so Validate, DryRun, and Execute transmit identical tokens.
In `@skills/lark-okr/references/lark-okr-cycle-list.md`:
- Around line 10-11: Update the example labels to reflect single-page retrieval:
in skills/lark-okr/references/lark-okr-cycle-list.md lines 10-11, describe the
default invocation as retrieving the first page; in
skills/lark-okr/references/lark-okr-progress-list.md line 5, rename the
key-result example so it does not claim to list all records.
---
Outside diff comments:
In `@skills/lark-okr/SKILL.md`:
- Around line 111-113: The API Resources index omits creation operations
required by the documented +create workflow. In skills/lark-okr/SKILL.md lines
111-113, restore the Objective create entry under cycle.objectives, and in lines
155-156, restore the Key Result create entry; if the shortcut uses different
endpoints, document those actual endpoints instead.
🪄 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
Run ID: 7d94b0c9-56ca-4f9e-8b5b-1b96edff1ff9
📒 Files selected for processing (10)
shortcuts/okr/okr_create_test.goshortcuts/okr/okr_cycle_list.goshortcuts/okr/okr_cycle_list_test.goshortcuts/okr/okr_progress_list.goshortcuts/okr/okr_progress_list_test.goskills/lark-okr/SKILL.mdskills/lark-okr/references/lark-okr-cycle-list.mdskills/lark-okr/references/lark-okr-progress-list.mdtests/cli_e2e/okr/okr_cycle_list_test.gotests/cli_e2e/okr/okr_progress_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- shortcuts/okr/okr_create_test.go
7818160 to
6959399
Compare
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 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 `@shortcuts/okr/okr_batch_create.go`:
- Around line 55-70: Require Notes to be non-empty whenever NotesMention is
provided, returning the existing typed validation error pattern for invalid
input; update the batch validation flow around Notes and NotesMention so
mentions cannot be silently discarded by createObjective or DryRun.
In `@skills/lark-okr/references/lark-okr-batch-create.md`:
- Line 89: Update the validation for the batch-create Objective input to reject
any non-empty notes_mention when notes is absent, returning the established
typed validation error rather than silently dropping the mention. Locate the
relevant Objective input validation and notes-writing logic, and explicitly
document this constraint in the notes_mention field description.
In `@skills/lark-okr/references/lark-okr-indicator-update.md`:
- Line 45: 在 +indicator-update 工作流警告文本中,将“将改量化指标”更正为“将该量化指标”,保持其余内容不变。
In `@skills/lark-okr/references/lark-okr-indicators.md`:
- Around line 117-118: 修复默认初始进度说明中以“使用”结尾的截断句,明确未携带
start_value/current_value/target_value/unit 时表示 O/KR 尚未设置进度;仅在必须计算数值时将其视作
0%,汇报时不要将其表述为已配置的真实 0%。
- Around line 73-77: The sample payload’s enum annotations are inconsistent with
the documented tables. Update current_value_calculate_type to use 0|1|2 and
indicator_status to use -1|0|1|2, preserving the surrounding field descriptions
and payload structure.
In `@skills/lark-okr/SKILL.md`:
- Around line 63-64: Update the progress judgment rule in SKILL.md so the
Markdown link to lark-okr-indicators.md, including its opening bracket and link
text, remains on a single line; preserve the surrounding Chinese guidance
unchanged.
🪄 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
Run ID: 9270ec42-539e-4b37-9fcb-80689d6d4690
📒 Files selected for processing (9)
shortcuts/okr/okr_batch_create.goshortcuts/okr/okr_batch_create_test.goshortcuts/okr/okr_create.goshortcuts/okr/okr_create_test.goskills/lark-okr/SKILL.mdskills/lark-okr/references/lark-okr-batch-create.mdskills/lark-okr/references/lark-okr-create.mdskills/lark-okr/references/lark-okr-indicator-update.mdskills/lark-okr/references/lark-okr-indicators.md
🚧 Files skipped from review as they are similar to previous changes (2)
- shortcuts/okr/okr_create.go
- shortcuts/okr/okr_create_test.go
1ab5480 to
cde92d5
Compare
cde92d5 to
4f1d820
Compare
Summary
This PR adds a single-item OKR creation shortcut so agents can create one Objective or add one Key Result without using the batch-create flow. It also updates the OKR skill guidance to make common read, create, progress, score, and alignment paths easier for agents to choose correctly.
Changes
lark-cli okr +createfor single Objective creation and single Key Result creation under an existing Objective.+create, including level-specific ID requirements,simpleandrichtextcontent parsing, and typed validation errors.+createreference docs, and clearer guidance that separates score updates from progress/completion updates.Test Plan
lark-cli okr +createflow works as expectedRelated Issues
Summary by CodeRabbit
okr +createto create objectives or key results withsimple/richtextcontent, plus--dry-runpreviews and confirmation output.okr +batch-createwith--category-iddefaulting for objectives.+cycle-listand+progress-listvia--page-size/--page-token, returninghas_more/page_token.+createvalidation, pagination, and live create flows.