Skip to content

feat(task): add task shortcuts with skill docs and tests#377

Open
ILUO wants to merge 23 commits intolarksuite:mainfrom
ILUO:feat/task-shortcuts-skill-docs-tests
Open

feat(task): add task shortcuts with skill docs and tests#377
ILUO wants to merge 23 commits intolarksuite:mainfrom
ILUO:feat/task-shortcuts-skill-docs-tests

Conversation

@ILUO
Copy link
Copy Markdown
Contributor

@ILUO ILUO commented Apr 10, 2026

Summary

Add new task shortcuts for related task listing, task search, ancestor setup,
task event subscription, and tasklist search, together with matching skill
documentation and table-driven tests.

Changes

  • Add new task shortcuts:
    • task +get-related-tasks
    • task +search
    • task +set-ancestor
    • task +subscribe_event
    • task +tasklist-search
  • Register the new shortcuts in shortcuts/task/shortcuts.go
  • Add shared task query helpers for filtering, pagination cursor handling, and output shaping
  • Add table-driven tests for all newly introduced task shortcut files
  • Add and refine task skill docs for the new shortcuts
  • Clarify task skill guidance for:
    • fuzzy query routing (+search first)
    • page_token behavior in +get-related-tasks
    • task/tasklist member name rendering
    • task subscription semantics

Test Plan

  • go test ./shortcuts/task ./shortcuts/event
  • Added table-driven tests for the new task shortcut files
  • Verified newly added task shortcut source files remain at or above 80% local coverage

Related Issues

N/A

Summary by CodeRabbit

  • New Features

    • Added task commands: search (+search) with filters (creator/assignee/follower, completion, due-range via CSV), pagination and detail enrichment, pretty/JSON output; get related tasks (+get-related-tasks) with created-by/followed-by filters and pagination; set/clear ancestor (+set-ancestor); subscribe to task events (+subscribe-event); tasklist search (+tasklist-search) with filters, pagination, and detail lookup.
  • Documentation

    • Added user guides and reference pages for all new task/tasklist commands.
  • Tests

    • Added test coverage for all new commands and helper logic.

@github-actions github-actions bot added domain/task PR touches the task domain size/L Large or sensitive change across domains or core paths labels Apr 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

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 five new task shortcuts (+get-related-tasks, +search, +set-ancestor, +subscribe-event, +tasklist-search), query/output helper utilities, comprehensive unit/integration tests, registration of the shortcuts in the task registry, and documentation pages for each shortcut.

Changes

Cohort / File(s) Summary
Get Related Tasks
shortcuts/task/task_get_related_tasks.go, shortcuts/task/task_get_related_tasks_test.go
Adds +get-related-tasks shortcut with dry-run/execute flows, pagination, include-complete/page-all/page-token flags, creator/follower filters, aggregation and post-filtering, and tests including pagination and filtering scenarios.
Search Task
shortcuts/task/task_search.go, shortcuts/task/task_search_test.go
Adds +search shortcut: request body builder, pagination, per-hit detail enrichment (GET /tasks/:guid) with fallback, due-range parsing, output formatting, dry-run/validate hooks, and tests for body building, dry-run, and execution.
Set Ancestor
shortcuts/task/task_set_ancestor.go, shortcuts/task/task_set_ancestor_test.go
Adds +set-ancestor shortcut with required --task-id and optional --ancestor-id, dry-run and execute POST flows, response handling via HandleTaskApiResult, and tests for body building and execution behavior.
Subscribe Event
shortcuts/task/task_subscribe_event.go, shortcuts/task/task_subscribe_event_test.go
Adds +subscribe-event shortcut that POSTs to /task_subscription, parses response, returns formatted confirmation, and includes dry-run/execute tests.
Search Tasklist
shortcuts/task/task_tasklist_search.go, shortcuts/task/task_tasklist_search_test.go
Adds +tasklist-search shortcut with creator/create-time filters, pagination, search-then-enrich pattern (GET /tasklists/:guid), truncated URLs, formatted output, and tests for body building, dry-run, and execution.
Query & Output Helpers
shortcuts/task/task_query_helpers.go, shortcuts/task/task_query_helpers_test.go
Introduces CSV/time parsing, time-range builders, filter merging/validation, task summary/related-task output shaping, pretty renderer, and corresponding unit tests.
Shortcut Registration
shortcuts/task/shortcuts.go
Registers new shortcuts: SetAncestorTask, GetRelatedTasks, SearchTask, SubscribeTaskEvent, SearchTasklist.
Documentation
skills/lark-task/SKILL.md, skills/lark-task/references/lark-task-*.md
Adds reference docs and SKILL guidance for the five new shortcuts (examples, flags, pagination/auth notes) and updates selection/formatting guidance.

Sequence Diagram(s)

sequenceDiagram
    participant User as User (CLI)
    participant CLI as lark-cli Runtime
    participant SearchAPI as Task Search API
    participant DetailAPI as Task Detail API

    User->>CLI: run `task +search --query ...`
    CLI->>SearchAPI: POST /open-apis/task/v2/tasks/search (body, page loop)
    SearchAPI-->>CLI: returns hits + page_token/has_more
    CLI->>DetailAPI: GET /open-apis/task/v2/tasks/:guid (per hit)
    DetailAPI-->>CLI: returns task detail or error
    CLI->>User: render aggregated results (pretty/json) and next page token
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • liangshuo-1
  • zero-my
  • tengchengwei

Poem

🐰 I nibble through flags and paginate the night,
Tasks and tasklists twinkle under CLI light.
Ancestors set, subscriptions hum a tune,
Searches yield secrets beneath the moon.
Hooray — this rabbit hops home, code tucked tight 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main additions: new task shortcuts, skill documentation, and tests, which matches the substantial changeset.
Description check ✅ Passed The description provides a comprehensive summary, detailed change list, completed test plan with checkmarks, and related issues section, fully following the template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 10, 2026

Greptile Summary

Adds five new task shortcuts (+get-related-tasks, +search, +set-ancestor, +subscribe-event, +tasklist-search) with matching helper utilities, table-driven tests, and skill documentation. +set-ancestor now correctly surfaces API-level errors via HandleTaskApiResult, resolving the prior concern on that file. The two new findings here are both P2: parseTimeRangeMillis in task_query_helpers.go is unreachable from production code and should be removed or wired in, and the parseTimeRangeRFC3339 subtests in TestRenderRelatedTasksPretty are inadvertently nested inside the outer loop, causing them to run twice.

Confidence Score: 4/5

Safe to merge once open P1 issues from prior review rounds are resolved; new findings in this pass are P2 only.

Multiple P1 findings flagged in earlier review rounds remain unaddressed (scope/risk mismatch on SubscribeTaskEvent, missing user_id_type=open_id on search POSTs, stale pagination contract in GetRelatedTasks, empty SubscribeTaskEvent body). New findings this pass are both P2. Score reflects convergence on code quality but ongoing correctness concerns on several shortcuts.

shortcuts/task/task_subscribe_event.go (scope + empty body), shortcuts/task/task_search.go and task_tasklist_search.go (missing query param), shortcuts/task/task_get_related_tasks.go (pagination metadata), shortcuts/task/task_query_helpers.go (dead function)

Important Files Changed

Filename Overview
shortcuts/task/task_query_helpers.go Shared helpers for CSV splitting, time range parsing, output formatting, and filter building — parseTimeRangeMillis is defined but never called from production code.
shortcuts/task/task_query_helpers_test.go Table-driven tests for helpers; parseTimeRangeRFC3339 subtests are inadvertently nested inside the TestRenderRelatedTasksPretty loop and run twice.
shortcuts/task/task_search.go Adds +search shortcut with filter/pagination support; search POST omits user_id_type=open_id query param (flagged in prior review).
shortcuts/task/task_tasklist_search.go Adds +tasklist-search shortcut; tasklist search POST omits user_id_type=open_id query param (flagged in prior review).
shortcuts/task/task_get_related_tasks.go Adds +get-related-tasks with client-side filtering; has_more/page_token reflect pre-filter server state when --created-by-me/--followed-by-me are active (flagged in prior review).
shortcuts/task/task_subscribe_event.go Adds +subscribe-event shortcut; declares Risk: "write" with a read-only scope and sends a POST with no flags or body (both flagged in prior review).
shortcuts/task/task_set_ancestor.go Adds +set-ancestor shortcut; now correctly calls HandleTaskApiResult to surface API-level errors — prior concern resolved.
shortcuts/task/shortcuts.go Registers five new shortcuts in the task command list; change is correct and complete.
shortcuts/event/subscribe.go Adds task.task.update_user_access_v2 to the common event type list; straightforward addition.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User invokes task shortcut] --> B{Which command?}
    B --> C["+search\ntask_search.go"]
    B --> D["+get-related-tasks\ntask_get_related_tasks.go"]
    B --> E["+set-ancestor\ntask_set_ancestor.go"]
    B --> F["+subscribe-event\ntask_subscribe_event.go"]
    B --> G["+tasklist-search\ntask_tasklist_search.go"]
    C --> C1[buildTaskSearchBody]
    C1 --> C2[POST /task/v2/tasks/search]
    C2 --> C3[GET /task/v2/tasks/:guid per hit]
    C3 --> C4[outputTaskSummary]
    D --> D1[GET list_related_task paginated]
    D1 --> D2[Client-side filter created-by-me/followed-by-me]
    D2 --> D3[outputRelatedTask]
    E --> E1[POST set_ancestor_task]
    E1 --> E2[HandleTaskApiResult]
    F --> F1[POST task_subscription empty body]
    G --> G1[buildTasklistSearchBody]
    G1 --> G2[POST /task/v2/tasklists/search]
    G2 --> G3[GET /task/v2/tasklists/:guid per hit]
    C1 & G1 & D1 -.-> H[task_query_helpers.go]
Loading

Reviews (13): Last reviewed commit: "docs(task): remove auth status --json gu..." | Re-trigger Greptile

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
shortcuts/task/task_tasklist_search_test.go (1)

109-113: Consider using an explicit field instead of inferring from test name.

The validation skip logic relies on the test name containing "error", which is fragile and could break if test names are refactored.

♻️ Suggested improvement
 	tests := []struct {
 		name      string
 		setup     func(*cobra.Command)
 		wantParts []string
+		wantErr   bool
 	}{
 		{
 			name: "valid dry run",
 			setup: func(cmd *cobra.Command) {
 				_ = cmd.Flags().Set("query", "Q2")
 				_ = cmd.Flags().Set("page-token", "pt_tl")
 			},
 			wantParts: []string{"POST /open-apis/task/v2/tasklists/search", `"query":"Q2"`},
 		},
 		{
 			name: "dry run error on invalid create time",
 			setup: func(cmd *cobra.Command) {
 				_ = cmd.Flags().Set("create-time", "bad-time")
 			},
 			wantParts: []string{"error:"},
+			wantErr:   true,
 		},
 	}

Then use if !tt.wantErr { ... } instead of strings.Contains(tt.name, "error").

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/task/task_tasklist_search_test.go` around lines 109 - 113, The test
currently skips calling SearchTasklist.Validate by checking
strings.Contains(tt.name, "error"), which is fragile; change the logic to use
the test case's explicit expectation field (tt.wantErr) instead: replace the
conditional that uses tt.name with if !tt.wantErr { if err :=
SearchTasklist.Validate(nil, runtime); err != nil { t.Fatalf("Validate() error =
%v", err) } } so validation runs for cases not expecting an error and is robust
to renaming.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@shortcuts/task/task_subscribe_event_test.go`:
- Around line 50-52: The test is widening SubscribeTaskEvent.AuthTypes to
include "bot" and then exercising "--as bot", which bypasses the intended
user-only shortcut; revert the patching and exercise the happy-path with a user
identity instead (call runMountedTaskShortcut with args using "--as", "user"),
or alternatively keep the current positive case but add a separate negative test
that leaves SubscribeTaskEvent.AuthTypes unchanged and asserts that invoking
runMountedTaskShortcut with "--as", "bot" returns an error (i.e., bot auth is
refused). Ensure references to SubscribeTaskEvent, AuthTypes, and
runMountedTaskShortcut are used to locate and update the test.

In `@shortcuts/task/task_tasklist_search.go`:
- Around line 110-113: When getTasklistDetail(runtime, tasklistID) fails we
currently append only {"guid": tasklistID}, which leaves tasklist["name"] nil
and causes the pretty-printer to render "<nil>"; update both failure branches
(the one at getTasklistDetail and the similar one around lines 135-137) to
include a safe "name" value (e.g., the GUID or a placeholder like "(unknown
tasklist: <guid>)") when appending to tasklists so the formatter will print a
sensible fallback instead of "<nil>" while preserving the guid in the map.

In `@skills/lark-task/references/lark-task-get-related-tasks.md`:
- Around line 7-8: The docs and CLI disagree on the unit for page_token (docs
say microseconds, CLI help in shortcuts/task/task_get_related_tasks.go describes
milliseconds); reconcile them by making the CLI help text match the canonical
unit used by +get-related-tasks (choose microseconds if that is intended) —
update the --page-token flag description in the TaskGetRelatedTasks command
(look for the flag/usage string in task_get_related_tasks.go and any references
to PageToken or page-token) so it explicitly states "microseconds" (or convert
behavior and tests to milliseconds if you decide to keep ms), and ensure any
parsing/serialization (e.g., where PageToken is parsed) uses the same unit.

---

Nitpick comments:
In `@shortcuts/task/task_tasklist_search_test.go`:
- Around line 109-113: The test currently skips calling SearchTasklist.Validate
by checking strings.Contains(tt.name, "error"), which is fragile; change the
logic to use the test case's explicit expectation field (tt.wantErr) instead:
replace the conditional that uses tt.name with if !tt.wantErr { if err :=
SearchTasklist.Validate(nil, runtime); err != nil { t.Fatalf("Validate() error =
%v", err) } } so validation runs for cases not expecting an error and is robust
to renaming.
🪄 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: a8a083f7-b4e6-4b8c-990f-a81ef6fb1ebf

📥 Commits

Reviewing files that changed from the base of the PR and between c16a021 and 9601035.

📒 Files selected for processing (19)
  • shortcuts/task/shortcuts.go
  • shortcuts/task/task_get_related_tasks.go
  • shortcuts/task/task_get_related_tasks_test.go
  • shortcuts/task/task_query_helpers.go
  • shortcuts/task/task_query_helpers_test.go
  • shortcuts/task/task_search.go
  • shortcuts/task/task_search_test.go
  • shortcuts/task/task_set_ancestor.go
  • shortcuts/task/task_set_ancestor_test.go
  • shortcuts/task/task_subscribe_event.go
  • shortcuts/task/task_subscribe_event_test.go
  • shortcuts/task/task_tasklist_search.go
  • shortcuts/task/task_tasklist_search_test.go
  • skills/lark-task/SKILL.md
  • skills/lark-task/references/lark-task-get-related-tasks.md
  • skills/lark-task/references/lark-task-search.md
  • skills/lark-task/references/lark-task-set-ancestor.md
  • skills/lark-task/references/lark-task-subscribe-event.md
  • skills/lark-task/references/lark-task-tasklist-search.md

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 10, 2026

Tip:

Greploop — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.

Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@shortcuts/task/task_query_helpers.go`:
- Around line 25-53: The parseTimeRangeMillis function currently allows reversed
ranges; after successfully parsing both startMillis and endMillis (use
parseTimeFlagSec outputs turned into milliseconds strings in
parseTimeRangeMillis), add a validation step: if both startMillis and endMillis
are non-empty, convert them to integers (e.g., with strconv.ParseInt) and ensure
start <= end, returning a descriptive error (e.g., "start time must be <= end
time") if the check fails; keep existing error behavior for individual
parseTimeFlagSec failures and only perform this additional comparison when both
endpoints are present.
🪄 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: a787f92c-84b4-470f-997f-19a5629eb991

📥 Commits

Reviewing files that changed from the base of the PR and between 9bc54e9 and a09c568.

📒 Files selected for processing (2)
  • shortcuts/task/task_query_helpers.go
  • shortcuts/task/task_query_helpers_test.go
✅ Files skipped from review due to trivial changes (1)
  • shortcuts/task/task_query_helpers_test.go

@github-actions github-actions bot added size/XL Architecture-level or global-impact change and removed size/L Large or sensitive change across domains or core paths labels Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/task PR touches the task domain size/XL Architecture-level or global-impact change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant