Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions shortcuts/task/tasklist_add_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var AddTaskToTasklist = common.Shortcut{
Flags: []common.Flag{
{Name: "tasklist-id", Desc: "tasklist id", Required: true},
{Name: "task-id", Desc: "task id (comma-separated for multiple)", Required: true},
{Name: "section-guid", Desc: "section guid"},
},

DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
Expand All @@ -40,6 +41,10 @@ var AddTaskToTasklist = common.Shortcut{
"tasklist_guid": extractTasklistGuid(runtime.Str("tasklist-id")),
}

if sectionGuid := strings.TrimSpace(runtime.Str("section-guid")); sectionGuid != "" {
body["section_guid"] = sectionGuid
}

return common.NewDryRunAPI().
POST("/open-apis/task/v2/tasks/" + taskId + "/add_tasklist").
Params(map[string]interface{}{"user_id_type": "open_id"}).
Expand All @@ -57,6 +62,10 @@ var AddTaskToTasklist = common.Shortcut{
"tasklist_guid": tasklistGuid,
}

if sectionGuid := strings.TrimSpace(runtime.Str("section-guid")); sectionGuid != "" {
body["section_guid"] = sectionGuid
}

var successful []map[string]interface{}
var failed []map[string]interface{}

Expand Down
43 changes: 43 additions & 0 deletions shortcuts/task/tasklist_add_task_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT

package task
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

import (
"strings"
"testing"

"github.com/larksuite/cli/internal/httpmock"
)

func TestAddTaskToTasklist_Success(t *testing.T) {
f, stdout, _, reg := taskShortcutTestFactory(t)
warmTenantToken(t, f, reg)

reg.Register(&httpmock.Stub{
Method: "POST",
URL: "/open-apis/task/v2/tasks/task-1/add_tasklist",
Body: map[string]interface{}{
"code": 0, "msg": "success",
"data": map[string]interface{}{
"task": map[string]interface{}{
"guid": "task-1",
},
},
},
})

s := AddTaskToTasklist
s.AuthTypes = []string{"bot", "user"}

args := []string{"+tasklist-task-add", "--tasklist-id", "tl-123", "--task-id", "task-1", "--section-guid", "sec-456", "--as", "bot", "--format", "json"}
err := runMountedTaskShortcut(t, s, args, f, stdout)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}

out := stdout.String()
if !strings.Contains(out, `"tasklist_guid":"tl-123"`) && !strings.Contains(out, `"tasklist_guid": "tl-123"`) {
t.Errorf("expected tasklist_guid in output, got: %s", out)
}
Comment thread
zero-my marked this conversation as resolved.
}
15 changes: 15 additions & 0 deletions skills/lark-task/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ lark-cli task <resource> <method> [flags] # 调用 API
- `add` — 添加任务成员
- `remove` — 移除任务成员

### sections

- `create` — 创建自定义分组
- `delete` — 删除自定义分组
- `get` — 获取自定义分组详情
- `list` — 获取自定义分组列表
- `patch` — 更新自定义分组
- `tasks` — 获取自定义分组任务列表

## 权限表

| 方法 | 所需 scope |
Expand All @@ -104,3 +113,9 @@ lark-cli task <resource> <method> [flags] # 调用 API
| `subtasks.list` | `task:task:read` |
| `members.add` | `task:task:write` |
| `members.remove` | `task:task:write` |
| `sections.create` | `task:section:write` |
| `sections.delete` | `task:section:write` |
| `sections.get` | `task:section:read` |
| `sections.list` | `task:section:read` |
| `sections.patch` | `task:section:write` |
| `sections.tasks` | `task:section:read` |
7 changes: 7 additions & 0 deletions skills/lark-task/references/lark-task-tasklist-task-add.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ lark-cli task +tasklist-task-add --tasklist-id "<tasklist_guid>" --task-id "<tas

# Add multiple tasks to a tasklist
lark-cli task +tasklist-task-add --tasklist-id "<tasklist_guid>" --task-id "<task_guid>,<another_task_guid>,<third_task_guid>"

# Add a task to a specific section in the tasklist
lark-cli task +tasklist-task-add \
--tasklist-id "<tasklist_guid>" \
--task-id "<task_guid>" \
--section-guid "<section_guid>"
```

## Parameters
Expand All @@ -20,6 +26,7 @@ lark-cli task +tasklist-task-add --tasklist-id "<tasklist_guid>" --task-id "<tas
|-----------|----------|-------------|
| `--tasklist-id <guid>` | Yes | The GUID of the tasklist, or a full AppLink URL. |
| `--task-id <guids>` | Yes | Comma-separated list of task GUIDs to add to the tasklist. For Feishu task applinks, use each task's `guid` query parameter, not the `suite_entity_num` / display task ID like `t104121`. |
| `--section-guid <guid>` | No | The GUID of the custom section to add the tasks to. If omitted, tasks will be added to the default section. |

## Workflow

Expand Down
Loading