Skip to content

feat: add okr single create shortcut & skill text opti#1941

Merged
syh-cpdsss merged 5 commits into
mainfrom
feat/okr_single_create_v2
Jul 22, 2026
Merged

feat: add okr single create shortcut & skill text opti#1941
syh-cpdsss merged 5 commits into
mainfrom
feat/okr_single_create_v2

Conversation

@syh-cpdsss

@syh-cpdsss syh-cpdsss commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

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

  • Added lark-cli okr +create for single Objective creation and single Key Result creation under an existing Objective.
  • Added validation and dry-run support for +create, including level-specific ID requirements, simple and richtext content parsing, and typed validation errors.
  • Registered the new OKR shortcut and added unit coverage for validation, dry-run output, successful API calls, and typed error handling.
  • Added dry-run and live E2E coverage for Objective and Key Result creation flows.
  • Updated OKR skill documentation with a quick decision table, +create reference docs, and clearer guidance that separates score updates from progress/completion updates.
  • Refined current-cycle guidance so annual cycles are not selected by default when the user did not explicitly ask for an annual OKR cycle.

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark-cli okr +create flow works as expected
  • Evaluatoin pass

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Added okr +create to create objectives or key results with simple/richtext content, plus --dry-run previews and confirmation output.
    • Enhanced okr +batch-create with --category-id defaulting for objectives.
    • Added pagination support to +cycle-list and +progress-list via --page-size/--page-token, returning has_more/page_token.
  • Bug Fixes
    • Improved “current active cycle” detection by excluding month-only cycles.
  • Documentation
    • Updated OKR v2 reference docs and pagination/shortcuts guidance.
  • Tests
    • Expanded unit and E2E coverage for +create validation, pagination, and live create flows.

@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an okr +create shortcut for creating individual objectives and key-results with strict content validation, changes cycle and progress listings from multi-page to single-page external pagination, extends batch-create with optional objective notes and category IDs, and provides comprehensive documentation and test coverage.

Changes

OKR creation feature

Layer / File(s) Summary
Creation contracts and content validation
shortcuts/okr/okr_create.go (lines 1–166)
Defines creation parameters, strict JSON decoding (rejecting unknown fields and multiple values), and style-specific content parsing (simple vs richtext).
Creation validation and execution
shortcuts/okr/okr_create.go (lines 183–394), shortcuts/okr/shortcuts.go
Implements level-specific validation for --cycle-id vs --objective-id, notes/category gating, dry-run request construction, and typed API calls with response validation.
Creation unit tests
shortcuts/okr/okr_create_test.go
Covers validation for level, IDs, style, content formats (simple JSON structure and rich-text blocks), stdin conflicts, dry-run request details, and execute success/error handling.
Creation registration and E2E tests
shortcuts/okr/shortcuts.go, shortcuts/okr/shortcuts_test.go, tests/cli_e2e/okr/okr_shortcuts_test.go
Registers +create in the shortcut set, adds dry-run and live E2E tests for both objective and key-result creation workflows.

Pagination for listings

Layer / File(s) Summary
Cycle listing pagination
shortcuts/okr/okr_cycle_list.go, shortcuts/okr/okr_cycle_list_test.go, tests/cli_e2e/okr/okr_cycle_list_test.go
Changes from looped multi-page retrieval to single page_size and page_token parameters; maintains local --time-range filtering; returns has_more and page_token instead of total.
Progress listing pagination
shortcuts/okr/okr_progress_list.go, shortcuts/okr/okr_progress_list_test.go, tests/cli_e2e/okr/okr_progress_test.go
Changes from looped multi-page retrieval to single API call with page_size and optional page_token; returns pagination metadata instead of count.

Batch-create extensions

Layer / File(s) Summary
Batch input schema and validation
shortcuts/okr/okr_batch_create.go (lines 27–70)
Extends objective input to include optional notes, notes_mention, and category_id; adds validation for non-blank notes and non-empty mention entries.
Batch category logic and wiring
shortcuts/okr/okr_batch_create.go (lines 81–294)
Implements category resolution (per-objective value or default --category-id flag), conditionally includes fields in dry-run and execute request bodies.
Batch-create extended tests
shortcuts/okr/okr_batch_create_test.go
Validates empty mention entries, tests dry-run output with notes and category IDs, verifies execute request bodies capture expected notes text/mentions and category overrides.

Documentation updates

Layer / File(s) Summary
Creation documentation
skills/lark-okr/references/lark-okr-create.md
Comprehensive guide for +create including parameter table, simple and rich-text input format specifications, workflows, API endpoint mappings, output examples, error handling, and +create vs +batch-create guidance.
Pagination documentation
skills/lark-okr/references/lark-okr-cycle-list.md, skills/lark-okr/references/lark-okr-progress-list.md
Updates cycle and progress list documentation to describe single-page retrieval, explicit pagination parameters, and local filtering semantics.
OKR skill and reference updates
skills/lark-okr/SKILL.md, skills/lark-okr/references/lark-okr-entities.md, skills/lark-okr/references/lark-okr-batch-create.md, skills/lark-okr/references/lark-okr-indicator-update.md, skills/lark-okr/references/lark-okr-indicators.md
Adds quick-decision routing and expanded shortcut catalog; removes documented cycle/objective creation API operations; clarifies +batch-create optional fields and current-cycle terminology; expands indicator examples.

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
Loading

Possibly related PRs

  • larksuite/cli#522: Adds initial OKR shortcuts and cycle-list command that this PR extends.
  • larksuite/cli#1236: Introduces typed error infrastructure (errs and wrapOkrNetworkErr) that +create validation and execution depend on.
  • larksuite/cli#1671: Provides semi-plain text and ContentBlock content handling utilities that +create consumes for strict content validation.

Suggested labels: feature

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding the single OKR create shortcut and related skill updates.
Description check ✅ Passed The description follows the template and covers summary, changes, test plan, and related issues with sufficient detail.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/okr_single_create_v2

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@4f1d8207df0702143920b3cf5d53ba7c883231b9

🧩 Skill update

npx skills add larksuite/cli#feat/okr_single_create_v2 -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e71c761 and d9ff030.

📒 Files selected for processing (9)
  • shortcuts/okr/okr_create.go
  • shortcuts/okr/okr_create_test.go
  • shortcuts/okr/okr_cycle_list.go
  • shortcuts/okr/shortcuts.go
  • shortcuts/okr/shortcuts_test.go
  • skills/lark-okr/SKILL.md
  • skills/lark-okr/references/lark-okr-create.md
  • skills/lark-okr/references/lark-okr-entities.md
  • tests/cli_e2e/okr/okr_shortcuts_test.go

Comment thread shortcuts/okr/okr_create_test.go
Comment thread shortcuts/okr/okr_create.go Outdated
Comment thread shortcuts/okr/okr_create.go
Comment thread shortcuts/okr/okr_create.go Outdated
Comment thread shortcuts/okr/okr_cycle_list.go
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.08638% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.04%. Comparing base (577ff03) to head (4f1d820).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/okr/okr_create.go 74.76% 32 Missing and 21 partials ⚠️
shortcuts/okr/okr_batch_create.go 70.58% 5 Missing and 5 partials ⚠️
shortcuts/okr/okr_progress_list.go 71.42% 4 Missing and 4 partials ⚠️
shortcuts/okr/okr_cycle_list.go 75.00% 4 Missing and 3 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Restore creation operations in the API resource index.

The new +create workflow 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 Objective create operation.
  • skills/lark-okr/SKILL.md#L155-L156: restore the Key Result create operation.
🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between d9ff030 and 6d71c12.

📒 Files selected for processing (10)
  • shortcuts/okr/okr_create_test.go
  • shortcuts/okr/okr_cycle_list.go
  • shortcuts/okr/okr_cycle_list_test.go
  • shortcuts/okr/okr_progress_list.go
  • shortcuts/okr/okr_progress_list_test.go
  • skills/lark-okr/SKILL.md
  • skills/lark-okr/references/lark-okr-cycle-list.md
  • skills/lark-okr/references/lark-okr-progress-list.md
  • tests/cli_e2e/okr/okr_cycle_list_test.go
  • tests/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

Comment thread shortcuts/okr/okr_cycle_list_test.go
Comment thread shortcuts/okr/okr_progress_list.go Outdated
Comment thread skills/lark-okr/references/lark-okr-cycle-list.md Outdated
@syh-cpdsss
syh-cpdsss force-pushed the feat/okr_single_create_v2 branch from 7818160 to 6959399 Compare July 17, 2026 12:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6959399 and 1ab5480.

📒 Files selected for processing (9)
  • shortcuts/okr/okr_batch_create.go
  • shortcuts/okr/okr_batch_create_test.go
  • shortcuts/okr/okr_create.go
  • shortcuts/okr/okr_create_test.go
  • skills/lark-okr/SKILL.md
  • skills/lark-okr/references/lark-okr-batch-create.md
  • skills/lark-okr/references/lark-okr-create.md
  • skills/lark-okr/references/lark-okr-indicator-update.md
  • skills/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

Comment thread shortcuts/okr/okr_batch_create.go
Comment thread skills/lark-okr/references/lark-okr-batch-create.md
Comment thread skills/lark-okr/references/lark-okr-indicator-update.md Outdated
Comment thread skills/lark-okr/references/lark-okr-indicators.md Outdated
Comment thread skills/lark-okr/references/lark-okr-indicators.md Outdated
Comment thread skills/lark-okr/SKILL.md Outdated
@syh-cpdsss
syh-cpdsss force-pushed the feat/okr_single_create_v2 branch from 1ab5480 to cde92d5 Compare July 21, 2026 12:22
@syh-cpdsss
syh-cpdsss force-pushed the feat/okr_single_create_v2 branch from cde92d5 to 4f1d820 Compare July 21, 2026 12:30
@syh-cpdsss
syh-cpdsss merged commit 409a317 into main Jul 22, 2026
26 checks passed
@syh-cpdsss
syh-cpdsss deleted the feat/okr_single_create_v2 branch July 22, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants