refactor: remove todo tool (#35989)
This commit is contained in:
@@ -11,7 +11,6 @@ import { GrepTool } from "./grep"
|
||||
import { ReadTool } from "./read"
|
||||
import { TaskTool } from "./task"
|
||||
import { Database } from "@opencode-ai/core/database/database"
|
||||
import { TodoWriteTool } from "./todo"
|
||||
import { WebFetchTool } from "./webfetch"
|
||||
import { WriteTool } from "./write"
|
||||
import { InvalidTool } from "./invalid"
|
||||
@@ -39,7 +38,6 @@ import { Format } from "../format"
|
||||
import { InstanceState } from "@/effect/instance-state"
|
||||
import { EffectBridge } from "@/effect/bridge"
|
||||
import { Question } from "../question"
|
||||
import { Todo } from "../session/todo"
|
||||
import { LSP } from "@/lsp/lsp"
|
||||
import { Instruction } from "../session/instruction"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
@@ -97,7 +95,6 @@ const layer = Layer.effect(
|
||||
const task = yield* TaskTool
|
||||
const read = yield* ReadTool
|
||||
const question = yield* QuestionTool
|
||||
const todo = yield* TodoWriteTool
|
||||
const lsptool = yield* LspTool
|
||||
const plan = yield* PlanExitTool
|
||||
const webfetch = yield* WebFetchTool
|
||||
@@ -211,7 +208,6 @@ const layer = Layer.effect(
|
||||
write: Tool.init(writetool),
|
||||
task: Tool.init(task),
|
||||
fetch: Tool.init(webfetch),
|
||||
todo: Tool.init(todo),
|
||||
search: Tool.init(websearch),
|
||||
skill: Tool.init(skilltool),
|
||||
patch: Tool.init(patchtool),
|
||||
@@ -234,7 +230,6 @@ const layer = Layer.effect(
|
||||
tool.write,
|
||||
tool.task,
|
||||
tool.fetch,
|
||||
tool.todo,
|
||||
tool.search,
|
||||
tool.skill,
|
||||
tool.patch,
|
||||
@@ -426,7 +421,6 @@ export const node = LayerNode.make({
|
||||
Config.node,
|
||||
Plugin.node,
|
||||
Question.node,
|
||||
Todo.node,
|
||||
Agent.node,
|
||||
Skill.node,
|
||||
Session.node,
|
||||
|
||||
@@ -117,9 +117,6 @@ export const TaskTool = Tool.define(
|
||||
subagent: next,
|
||||
})
|
||||
const childToolDenies = [
|
||||
...(next.permission.some((rule) => rule.permission === "todowrite")
|
||||
? []
|
||||
: [{ permission: "todowrite" as const, pattern: "*" as const, action: "deny" as const }]),
|
||||
...(next.permission.some((rule) => rule.permission === id)
|
||||
? []
|
||||
: [{ permission: id, pattern: "*" as const, action: "deny" as const }]),
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import { Effect, Schema } from "effect"
|
||||
import * as Tool from "./tool"
|
||||
import DESCRIPTION_WRITE from "./todowrite.txt"
|
||||
import { Todo } from "../session/todo"
|
||||
|
||||
export const Parameters = Schema.Struct({
|
||||
todos: Schema.mutable(Schema.Array(Todo.Info)).annotate({ description: "The updated todo list" }),
|
||||
})
|
||||
|
||||
type Metadata = {
|
||||
todos: Todo.Info[]
|
||||
}
|
||||
|
||||
export const TodoWriteTool = Tool.define<typeof Parameters, Metadata, Todo.Service>(
|
||||
"todowrite",
|
||||
Effect.gen(function* () {
|
||||
const todo = yield* Todo.Service
|
||||
|
||||
return {
|
||||
description: DESCRIPTION_WRITE,
|
||||
parameters: Parameters,
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context<Metadata>) =>
|
||||
Effect.gen(function* () {
|
||||
yield* ctx.ask({
|
||||
permission: "todowrite",
|
||||
patterns: ["*"],
|
||||
always: ["*"],
|
||||
metadata: {},
|
||||
})
|
||||
|
||||
yield* todo.update({
|
||||
sessionID: ctx.sessionID,
|
||||
todos: params.todos,
|
||||
})
|
||||
|
||||
return {
|
||||
title: `${params.todos.filter((x) => x.status !== "completed").length} todos`,
|
||||
output: JSON.stringify(params.todos, null, 2),
|
||||
metadata: {
|
||||
todos: params.todos,
|
||||
},
|
||||
}
|
||||
}),
|
||||
} satisfies Tool.DefWithoutID<typeof Parameters, Metadata>
|
||||
}),
|
||||
)
|
||||
@@ -1,44 +0,0 @@
|
||||
Create and maintain a structured task list for the current coding session. Tracks progress, organizes multi-step work, and surfaces status to the user.
|
||||
|
||||
## When to use
|
||||
Use proactively when:
|
||||
- The task requires 3+ distinct steps or actions (not just 3 tool calls for a single conceptual step)
|
||||
- The work is non-trivial and benefits from planning
|
||||
- The user provides multiple tasks (numbered or comma-separated) or explicitly asks for a todo list
|
||||
- New instructions arrive - capture them as todos
|
||||
- You start a task - mark it `in_progress` (only one at a time) before working
|
||||
- You finish a task - mark it `completed` and add any follow-ups discovered during the work
|
||||
|
||||
## When NOT to use
|
||||
Skip when:
|
||||
- The work is a single, straightforward task (or <3 trivial steps)
|
||||
- The request is purely informational or conversational
|
||||
- Tracking adds no organizational value
|
||||
|
||||
## States
|
||||
- `pending` - not started
|
||||
- `in_progress` - actively working (exactly ONE at a time)
|
||||
- `completed` - finished successfully
|
||||
- `cancelled` - no longer needed
|
||||
|
||||
## Rules
|
||||
- Update status in real time; don't batch completions
|
||||
- Mark `completed` only after the required work is actually done, including any required verification. Never based on intent.
|
||||
- Keep exactly one `in_progress` while work remains
|
||||
- If blocked or partial, keep it `in_progress` and add a follow-up todo describing the blocker
|
||||
- Preserve user-provided commands verbatim (flags, args, order)
|
||||
- Items should be specific and actionable; break large work into smaller steps
|
||||
|
||||
## Examples
|
||||
|
||||
Use it:
|
||||
- "Add a dark mode toggle and run the tests" -> multi-step feature + explicit verification
|
||||
- "Rename getCwd -> getCurrentWorkingDirectory across the repo" -> grep reveals 15 occurrences in 8 files
|
||||
- "Implement registration, catalog, cart, checkout" -> multiple complex features
|
||||
|
||||
Skip it:
|
||||
- "How do I print Hello World in Python?" -> informational
|
||||
- "Add a comment to calculateTotal" -> single edit
|
||||
- "Run npm install and tell me what happened" -> one command
|
||||
|
||||
When in doubt, use it.
|
||||
Reference in New Issue
Block a user