Skip to content

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

Open
syh-cpdsss wants to merge 3 commits into
mainfrom
feat/okr_single_create_v2
Open

feat: add okr single create shortcut & skill text opti#1941
syh-cpdsss wants to merge 3 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, including --dry-run previews and creation confirmations.
    • Enhanced +cycle-list and +progress-list with --page-size/--page-token, returning has_more/page_token.
  • Bug Fixes
    • Improved “current active cycle” detection by excluding month-only cycles.
  • Documentation
    • Expanded OKR v2 guidance, added +create reference pages, and updated cycle/progress pagination semantics.
  • Tests
    • Added unit and E2E coverage for +create validation and pagination, including error handling 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3f556a9-3f68-4673-bb2b-4c46173afbaf

📥 Commits

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

📒 Files selected for processing (8)
  • shortcuts/okr/okr_create.go
  • shortcuts/okr/okr_create_test.go
  • shortcuts/okr/okr_cycle_list_test.go
  • shortcuts/okr/okr_progress_list.go
  • shortcuts/okr/okr_progress_list_test.go
  • skills/lark-okr/references/lark-okr-cycle-list.md
  • skills/lark-okr/references/lark-okr-progress-list.md
  • tests/cli_e2e/okr/okr_shortcuts_test.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • skills/lark-okr/references/lark-okr-cycle-list.md
  • shortcuts/okr/okr_progress_list.go
  • skills/lark-okr/references/lark-okr-progress-list.md
  • shortcuts/okr/okr_cycle_list_test.go
  • shortcuts/okr/okr_progress_list_test.go
  • shortcuts/okr/okr_create.go
  • shortcuts/okr/okr_create_test.go

📝 Walkthrough

Walkthrough

Adds an okr +create shortcut for objectives and key results, introduces validated content handling and API execution, changes cycle and progress listings to external pagination, and updates related tests and documentation.

Changes

OKR workflows

Layer / File(s) Summary
Creation inputs and validation
shortcuts/okr/okr_create.go, shortcuts/okr/okr_create_test.go
Adds level-specific identifier validation and strict simple/rich-text content parsing.
Creation API flow and registration
shortcuts/okr/okr_create.go, shortcuts/okr/shortcuts.go, shortcuts/okr/okr_create_test.go, tests/cli_e2e/okr/okr_shortcuts_test.go
Adds objective and key-result dry-run/live requests, response ID handling, shortcut registration, and unit/E2E coverage.
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
Adds page parameters, switches to single-page retrieval, and returns pagination metadata while retaining local time filtering.
Progress listing pagination
shortcuts/okr/okr_progress_list.go, shortcuts/okr/okr_progress_list_test.go, tests/cli_e2e/okr/okr_progress_test.go
Adds page parameters, switches to single-page retrieval, and replaces total-count output with pagination metadata.
OKR command documentation
skills/lark-okr/SKILL.md, skills/lark-okr/references/*
Documents creation, content formats, pagination behavior, command selection, endpoints, outputs, and current-cycle terminology.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • larksuite/cli#522: Modifies existing OKR cycle-list behavior and adds shortcuts in the same OKR domain.
  • larksuite/cli#574: Touches the same OKR progress-list pagination behavior.
  • larksuite/cli#1671: Introduces related semi-plain content infrastructure used by OKR content validation.

Suggested labels: feature, domain/ccm

Suggested reviewers: zhangzq0

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant OKRCreate
  participant OKRv2API
  CLI->>OKRCreate: provide creation flags and content
  OKRCreate->>OKRv2API: POST objective or key-result request
  OKRv2API-->>OKRCreate: return created identifier
  OKRCreate-->>CLI: print creation result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.43% 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 clearly summarizes the main change: adding the OKR single-create shortcut and related skill text updates.
Description check ✅ Passed The description includes the required sections and covers the PR scope, changes, test plan, and related issues sufficiently.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 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@6959399ec49cff55bf755ec0ffecfca449484f0b

🧩 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
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 75.10373% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.02%. Comparing base (6ecbfaf) to head (6959399).
⚠️ Report is 38 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/okr/okr_create.go 75.54% 28 Missing and 17 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   74.66%   75.02%   +0.35%     
==========================================
  Files         878      895      +17     
  Lines       91764    94483    +2719     
==========================================
+ Hits        68520    70889    +2369     
- Misses      17930    18164     +234     
- Partials     5314     5430     +116     

☔ 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
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.

1 participant