MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / execute

Method execute

src/core/tools/NewTaskTool.ts:23–127  ·  view source on GitHub ↗
(params: NewTaskParams, task: Task, callbacks: ToolCallbacks)

Source from the content-addressed store, hash-verified

21 readonly name = "new_task" as const
22
23 async execute(params: NewTaskParams, task: Task, callbacks: ToolCallbacks): Promise<void> {
24 const { mode, message, todos } = params
25 const { askApproval, handleError, pushToolResult } = callbacks
26
27 try {
28 // Validate required parameters.
29 if (!mode) {
30 task.consecutiveMistakeCount++
31 task.recordToolError("new_task")
32 task.didToolFailInCurrentTurn = true
33 pushToolResult(await task.sayAndCreateMissingParamError("new_task", "mode"))
34 return
35 }
36
37 if (!message) {
38 task.consecutiveMistakeCount++
39 task.recordToolError("new_task")
40 task.didToolFailInCurrentTurn = true
41 pushToolResult(await task.sayAndCreateMissingParamError("new_task", "message"))
42 return
43 }
44
45 // Get the VSCode setting for requiring todos.
46 const provider = task.providerRef.deref()
47
48 if (!provider) {
49 pushToolResult(formatResponse.toolError("Provider reference lost"))
50 return
51 }
52
53 const state = await provider.getState()
54
55 // Use Package.name (dynamic at build time) as the VSCode configuration namespace.
56 // Supports multiple extension variants (e.g., stable/nightly) without hardcoded strings.
57 const requireTodos = vscode.workspace
58 .getConfiguration(Package.name)
59 .get<boolean>("newTaskRequireTodos", false)
60
61 // Check if todos are required based on VSCode setting.
62 // Note: `undefined` means not provided, empty string is valid.
63 if (requireTodos && todos === undefined) {
64 task.consecutiveMistakeCount++
65 task.recordToolError("new_task")
66 task.didToolFailInCurrentTurn = true
67 pushToolResult(await task.sayAndCreateMissingParamError("new_task", "todos"))
68 return
69 }
70
71 // Parse todos if provided, otherwise use empty array
72 let todoItems: TodoItem[] = []
73 if (todos) {
74 try {
75 todoItems = parseMarkdownChecklist(todos)
76 } catch (error) {
77 task.consecutiveMistakeCount++
78 task.recordToolError("new_task")
79 task.didToolFailInCurrentTurn = true
80 pushToolResult(formatResponse.toolError("Invalid todos format: must be a markdown checklist"))

Callers

nothing calls this directly

Calls 12

parseMarkdownChecklistFunction · 0.90
getModeBySlugFunction · 0.90
pushToolResultFunction · 0.85
askApprovalFunction · 0.85
handleErrorFunction · 0.85
recordToolErrorMethod · 0.80
getStateMethod · 0.65
getMethod · 0.65
getConfigurationMethod · 0.65
replaceMethod · 0.65

Tested by

no test coverage detected