-
Notifications
You must be signed in to change notification settings - Fork 13k
feat (core): Implement tracker related SI changes #19964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b5db5d3
f737126
448af0a
2d6ee8f
9618f8f
6a24077
ae96477
91e7881
e6b68e7
ba73124
e32d8a2
1e743ea
23194dd
de0ce2c
eed1ca6
eb33db5
daf9da2
41cf395
fc298e3
30fe8ff
5d31761
53755c5
ed8a773
aa1803f
f76d73e
34788a7
3d89cc5
f5b6028
c1252b4
776c8aa
273deb6
ed7ecde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,9 @@ import { | |||||||||||||||||||||||||
| READ_FILE_PARAM_END_LINE, | ||||||||||||||||||||||||||
| SHELL_PARAM_IS_BACKGROUND, | ||||||||||||||||||||||||||
| EDIT_PARAM_OLD_STRING, | ||||||||||||||||||||||||||
| TRACKER_CREATE_TASK_TOOL_NAME, | ||||||||||||||||||||||||||
| TRACKER_LIST_TASKS_TOOL_NAME, | ||||||||||||||||||||||||||
| TRACKER_UPDATE_TASK_TOOL_NAME, | ||||||||||||||||||||||||||
| } from '../tools/tool-names.js'; | ||||||||||||||||||||||||||
| import type { HierarchicalMemory } from '../config/memory.js'; | ||||||||||||||||||||||||||
| import { DEFAULT_CONTEXT_FILENAME } from '../tools/memoryTool.js'; | ||||||||||||||||||||||||||
|
|
@@ -41,6 +44,7 @@ export interface SystemPromptOptions { | |||||||||||||||||||||||||
| hookContext?: boolean; | ||||||||||||||||||||||||||
| primaryWorkflows?: PrimaryWorkflowsOptions; | ||||||||||||||||||||||||||
| planningWorkflow?: PlanningWorkflowOptions; | ||||||||||||||||||||||||||
| taskTracker?: boolean; | ||||||||||||||||||||||||||
| operationalGuidelines?: OperationalGuidelinesOptions; | ||||||||||||||||||||||||||
| sandbox?: SandboxMode; | ||||||||||||||||||||||||||
| interactiveYoloMode?: boolean; | ||||||||||||||||||||||||||
|
|
@@ -66,6 +70,7 @@ export interface PrimaryWorkflowsOptions { | |||||||||||||||||||||||||
| enableGrep: boolean; | ||||||||||||||||||||||||||
| enableGlob: boolean; | ||||||||||||||||||||||||||
| approvedPlan?: { path: string }; | ||||||||||||||||||||||||||
| taskTracker?: boolean; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export interface OperationalGuidelinesOptions { | ||||||||||||||||||||||||||
|
|
@@ -83,6 +88,7 @@ export interface PlanningWorkflowOptions { | |||||||||||||||||||||||||
| planModeToolsList: string; | ||||||||||||||||||||||||||
| plansDir: string; | ||||||||||||||||||||||||||
| approvedPlanPath?: string; | ||||||||||||||||||||||||||
| taskTracker?: boolean; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export interface AgentSkillOptions { | ||||||||||||||||||||||||||
|
|
@@ -120,6 +126,8 @@ ${ | |||||||||||||||||||||||||
| : renderPrimaryWorkflows(options.primaryWorkflows) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ${options.taskTracker ? renderTaskTracker() : ''} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ${renderOperationalGuidelines(options.operationalGuidelines)} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ${renderInteractiveYoloMode(options.interactiveYoloMode)} | ||||||||||||||||||||||||||
|
|
@@ -464,6 +472,24 @@ ${trimmed} | |||||||||||||||||||||||||
| return `\n---\n\n<loaded_context>\n${sections.join('\n')}\n</loaded_context>`; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export function renderTaskTracker(): string { | ||||||||||||||||||||||||||
| const trackerCreate = formatToolName(TRACKER_CREATE_TASK_TOOL_NAME); | ||||||||||||||||||||||||||
| const trackerList = formatToolName(TRACKER_LIST_TASKS_TOOL_NAME); | ||||||||||||||||||||||||||
| const trackerUpdate = formatToolName(TRACKER_UPDATE_TASK_TOOL_NAME); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return ` | ||||||||||||||||||||||||||
| # TASK MANAGEMENT PROTOCOL | ||||||||||||||||||||||||||
| You are operating with a persistent file-based task tracking system located at \`.tracker/tasks/\`. You must adhere to the following rules: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| 1. **NO IN-MEMORY LISTS**: Do not maintain a mental list of tasks or write markdown checkboxes in the chat. Use the provided tools (${trackerCreate}, ${trackerList}, ${trackerUpdate}) for all state management. | ||||||||||||||||||||||||||
| 2. **IMMEDIATE DECOMPOSITION**: Upon receiving a task, evaluate its functional complexity and scope. If the request involves more than a single atomic modification, or necessitates research before execution, you MUST immediately decompose it into discrete entries using ${trackerCreate}. | ||||||||||||||||||||||||||
anj-s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
| 3. **IGNORE FORMATTING BIAS**: Trigger the protocol based on the **objective complexity** of the goal, regardless of whether the user provided a structured list or a single block of text/paragraph. "Paragraph-style" goals that imply multiple actions are multi-step projects and MUST be tracked. | ||||||||||||||||||||||||||
| 4. **PLAN MODE INTEGRATION**: If an approved plan exists, you MUST use the ${trackerCreate} tool to decompose it into discrete tasks before writing any code. Maintain a bidirectional understanding between the plan document and the task graph. | ||||||||||||||||||||||||||
| 5. **VERIFICATION**: Before marking a task as complete, verify the work is actually done (e.g., run the test, check the file existence). | ||||||||||||||||||||||||||
| 6. **STATE OVER CHAT**: If the user says "I think we finished that," but the tool says it is 'pending', trust the tool--or verify explicitly before updating. | ||||||||||||||||||||||||||
| 7. **DEPENDENCY MANAGEMENT**: Respect task topology. Never attempt to execute a task if its dependencies are not marked as 'closed'. If you are blocked, focus only on the leaf nodes of the task graph.`.trim(); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export function renderPlanningWorkflow( | ||||||||||||||||||||||||||
| options?: PlanningWorkflowOptions, | ||||||||||||||||||||||||||
| ): string { | ||||||||||||||||||||||||||
|
|
@@ -583,6 +609,9 @@ function workflowStepStrategy(options: PrimaryWorkflowsOptions): string { | |||||||||||||||||||||||||
| if (options.approvedPlan) { | ||||||||||||||||||||||||||
| return `2. **Strategy:** An approved plan is available for this task. Treat this file as your single source of truth. You MUST read this file before proceeding. If you discover new requirements or need to change the approach, confirm with the user and update this plan file to reflect the updated design decisions or discovered requirements. Once all implementation and verification steps are finished, provide a **final summary** of the work completed against the plan and offer clear **next steps** to the user (e.g., 'Open a pull request').`; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (options.approvedPlan && options.taskTracker) { | ||||||||||||||||||||||||||
| return `2. **Strategy:** An approved plan is available for this task. Treat this file as your single source of truth and invoke the task tracker tool to create tasks for this plan. You MUST read this file before proceeding. If you discover new requirements or need to change the approach, confirm with the user and update this plan file to reflect the updated design decisions or discovered requirements. Make sure to update the tracker task list based on this updated plan. Once all implementation and verification steps are finished, provide a **final summary** of the work completed against the plan and offer clear **next steps** to the user (e.g., 'Open a pull request').`; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
609
to
+614
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new
Suggested change
References
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if (options.enableWriteTodosTool) { | ||||||||||||||||||||||||||
| return `2. **Strategy:** Formulate a grounded plan based on your research.${ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,19 +154,18 @@ export const LS_TOOL_NAME_LEGACY = 'list_directory'; // Just to be safe if anyth | |
|
|
||
| export const EDIT_TOOL_NAMES = new Set([EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME]); | ||
|
|
||
| export const TRACKER_CREATE_TASK_TOOL_NAME = 'tracker_create_task'; | ||
| export const TRACKER_UPDATE_TASK_TOOL_NAME = 'tracker_update_task'; | ||
| export const TRACKER_GET_TASK_TOOL_NAME = 'tracker_get_task'; | ||
| export const TRACKER_LIST_TASKS_TOOL_NAME = 'tracker_list_tasks'; | ||
| export const TRACKER_ADD_DEPENDENCY_TOOL_NAME = 'tracker_add_dependency'; | ||
| export const TRACKER_VISUALIZE_TOOL_NAME = 'tracker_visualize'; | ||
|
|
||
| // Tool Display Names | ||
| export const WRITE_FILE_DISPLAY_NAME = 'WriteFile'; | ||
| export const EDIT_DISPLAY_NAME = 'Edit'; | ||
| export const ASK_USER_DISPLAY_NAME = 'Ask User'; | ||
| export const READ_FILE_DISPLAY_NAME = 'ReadFile'; | ||
| export const GLOB_DISPLAY_NAME = 'FindFiles'; | ||
| export const TRACKER_CREATE_TASK_TOOL_NAME = 'tracker_create_task'; | ||
anj-s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export const TRACKER_UPDATE_TASK_TOOL_NAME = 'tracker_update_task'; | ||
| export const TRACKER_GET_TASK_TOOL_NAME = 'tracker_get_task'; | ||
| export const TRACKER_LIST_TASKS_TOOL_NAME = 'tracker_list_tasks'; | ||
| export const TRACKER_ADD_DEPENDENCY_TOOL_NAME = 'tracker_add_dependency'; | ||
| export const TRACKER_VISUALIZE_TOOL_NAME = 'tracker_visualize'; | ||
|
|
||
| /** | ||
| * Mapping of legacy tool names to their current names. | ||
|
|
@@ -229,6 +228,12 @@ export const ALL_BUILTIN_TOOL_NAMES = [ | |
| GET_INTERNAL_DOCS_TOOL_NAME, | ||
| ENTER_PLAN_MODE_TOOL_NAME, | ||
| EXIT_PLAN_MODE_TOOL_NAME, | ||
| TRACKER_CREATE_TASK_TOOL_NAME, | ||
| TRACKER_UPDATE_TASK_TOOL_NAME, | ||
| TRACKER_GET_TASK_TOOL_NAME, | ||
| TRACKER_LIST_TASKS_TOOL_NAME, | ||
| TRACKER_ADD_DEPENDENCY_TOOL_NAME, | ||
| TRACKER_VISUALIZE_TOOL_NAME, | ||
|
Comment on lines
+231
to
+236
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ] as const; | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a test for this in https://github.com/google-gemini/gemini-cli/blob/a5fd5d0b9fcafcc2eb1cc92e8e6405716dbb103f/packages/core/src/core/prompts.test.ts