diff --git a/packages/app/src/i18n/zh.ts b/packages/app/src/i18n/zh.ts index a422a5d61dd1..2f89c4f58a6a 100644 --- a/packages/app/src/i18n/zh.ts +++ b/packages/app/src/i18n/zh.ts @@ -19,6 +19,9 @@ export const dict = { "command.category.agent": "智能体", "command.category.permissions": "权限", "command.category.workspace": "工作区", + "command.clearTasks": "清除任务", + "command.clearTasks.description": "清除所有待办任务", + "command.category.tasks": "任务", "command.category.settings": "设置", "theme.scheme.system": "系统", diff --git a/packages/opencode/src/command/index.ts b/packages/opencode/src/command/index.ts index 140d2b8a7a66..5872bef974e5 100644 --- a/packages/opencode/src/command/index.ts +++ b/packages/opencode/src/command/index.ts @@ -59,6 +59,8 @@ export function hints(template: string) { export const Default = { INIT: "init", REVIEW: "review", + CLEAR_TASKS: "clear-tasks", + CLEAR_TASKS_ZH: "清除任务", } as const export interface Interface { @@ -99,6 +101,24 @@ export const layer = Layer.effect( subtask: true, hints: hints(PROMPT_REVIEW), } + commands[Default.CLEAR_TASKS] = { + name: Default.CLEAR_TASKS, + description: "clear all active tasks", + source: "command", + get template() { + return "Call todowrite with an empty todos array [] to clear all remaining tasks." + }, + hints: [], + } + commands[Default.CLEAR_TASKS_ZH] = { + name: Default.CLEAR_TASKS_ZH, + description: "清除所有待办任务", + source: "command", + get template() { + return "Call todowrite with an empty todos array [] to clear all remaining tasks." + }, + hints: [], + } for (const [name, command] of Object.entries(cfg.command ?? {})) { commands[name] = { diff --git a/packages/opencode/src/session/todo.ts b/packages/opencode/src/session/todo.ts index 32a837046478..5c18012e4779 100644 --- a/packages/opencode/src/session/todo.ts +++ b/packages/opencode/src/session/todo.ts @@ -70,7 +70,7 @@ export const layer = Layer.effect( db.select().from(TodoTable).where(eq(TodoTable.session_id, sessionID)).orderBy(asc(TodoTable.position)).all(), ), ) - return rows.map((row) => ({ + return rows.filter((row) => row.status === "pending" || row.status === "in_progress").map((row) => ({ content: row.content, status: row.status, priority: row.priority, diff --git a/packages/opencode/src/tool/todowrite.txt b/packages/opencode/src/tool/todowrite.txt index 2737cd18b62a..96ef861b6585 100644 --- a/packages/opencode/src/tool/todowrite.txt +++ b/packages/opencode/src/tool/todowrite.txt @@ -1,4 +1,4 @@ -Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. +Use this tool to create and manage a structured task list. Completed/cancelled tasks are auto-removed for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. It also helps the user understand the progress of the task and overall progress of their requests. ## When to Use This Tool