1
>
/*---------------------------------------------------------------------------------------------
manageTodoListTool.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
7
>
import { Disposable } from '../../../../../../base/common/lifecycle.js';
8
>
import { Codicon } from '../../../../../../base/common/codicons.js';
9
>
import { IJSONSchema, IJSONSchemaMap } from '../../../../../../base/common/jsonSchema.js';
10
>
import { ThemeIcon } from '../../../../../../base/common/themables.js';
11
>
import {
12
>
IToolData,
13
>
IToolImpl,
14
>
IToolInvocation,
15
>
IToolResult,
16
>
ToolDataSource,
17
>
IToolInvocationPreparationContext,
18
>
IPreparedToolInvocation,
19
>
ToolInvocationPresentation
20
>
} from '../languageModelToolsService.js';
21
>
import { ILogService } from '../../../../../../platform/log/common/log.js';
22
>
import { ITelemetryService } from '../../../../../../platform/telemetry/common/telemetry.js';
23
>
import { IChatTodo, IChatTodoListService } from '../chatTodoListService.js';
24
>
import { localize } from '../../../../../../nls.js';
25
>
import { MarkdownString } from '../../../../../../base/common/htmlContent.js';
26
>
import { URI } from '../../../../../../base/common/uri.js';
27
>
28
>
export const ManageTodoListToolToolId = 'manage_todo_list';
29
>
30
>
export function createManageTodoListToolData(): IToolData {
31
>
const inputSchema: IJSONSchema & { properties: IJSONSchemaMap } = {
32
>
type: 'object',
33
>
properties: {
34
>
todoList: {
35
>
type: 'array',
36
>
description: 'Complete array of all todo items. Must include ALL items - both existing and new.',
37
>
items: {
38
>
type: 'object',
39
>
properties: {
40
>
id: {
41
>
type: 'number',
42
>
description: 'Unique identifier for the todo. Use sequential numbers starting from 1.'
43
>
},
44
>
title: {
45
>
type: 'string',
46
>
description: 'Concise action-oriented todo label (3-7 words). Displayed in UI.'
47
>
},
48
>
status: {
49
>
type: 'string',
50
>
enum: ['not-started', 'in-progress', 'completed'],
51
>
description: 'not-started: Not begun | in-progress: Currently working (max 1) | completed: Fully finished with no blockers'
52
>
},
53
>
},
54
>
required: ['id', 'title', 'status']
55
>
}
56
>
}
57
>
},
58
>
required: ['todoList']
59
>
};
60
>
61
>
return {
62
>
id: ManageTodoListToolToolId,
63
>
toolReferenceName: 'todo',
64
>
legacyToolReferenceFullNames: ['todos'],
65
>
canBeReferencedInPrompt: true,
66
>
icon: ThemeIcon.fromId(Codicon.checklist.id),
67
>
displayName: localize('tool.manageTodoList.displayName', 'Manage and track todo items for task planning'),
68
>
userDescription: localize('tool.manageTodoList.userDescription', 'Manage and track todo items for task planning'),
69
>
modelDescription: 'Manage a structured todo list to track progress and plan tasks throughout your coding session. Use this tool VERY frequently to ensure task visibility and proper planning.\n\nWhen to use this tool:\n- Complex multi-step work requiring planning and tracking\n- When user provides multiple tasks or requests (numbered/comma-separated)\n- After receiving new instructions that require multiple steps\n- BEFORE starting work on any todo (mark as in-progress)\n- IMMEDIATELY after completing each todo (mark completed individually)\n- When breaking down larger tasks into smaller actionable steps\n- To give users visibility into your progress and planning\n\nWhen NOT to use:\n- Single, trivial tasks that can be completed in one step\n- Purely conversational/informational requests\n- When just reading files or performing simple searches\n\nCRITICAL workflow:\n1. Plan tasks by writing todo list with specific, actionable items\n2. Mark ONE todo as in-progress before starting work\n3. Complete the work for that specific todo\n4. Mark that todo as completed IMMEDIATELY\n5. Move to next todo and repeat\n\nTodo states:\n- not-started: Todo not yet begun\n- in-progress: Currently working (limit ONE at a time)\n- completed: Finished successfully\n\nIMPORTANT: Mark todos completed as soon as they are done. Do not batch completions.',
70
>
source: ToolDataSource.Internal,
71
>
inputSchema: inputSchema
72
>
};
73
>
}
74
>
75
>
export const ManageTodoListToolData: IToolData = createManageTodoListToolData();
76
>
77
>
interface IManageTodoListToolInputParams {
78
>
operation?: 'write' | 'read'; // Optional, defaults to 'write'
79
>
todoList: Array<{
80
>
id: number;
81
>
title: string;
82
>
status: 'not-started' | 'in-progress' | 'completed';
83
>
}>;
84
>
// used for todo read only
85
>
chatSessionResource?: string;
86
>
}
87
>
88
>
export class ManageTodoListTool extends Disposable implements IToolImpl {
89
>
90
>
constructor(
91
@IChatTodoListService private readonly chatTodoListService: IChatTodoListService,
92
@ILogService private readonly logService: ILogService,