si changes: task tracker prep implementation

This commit is contained in:
Anjali Sridhar
2026-02-22 12:38:56 -08:00
parent 30fe8ff383
commit 5d317614bd
4 changed files with 59 additions and 1 deletions
@@ -178,6 +178,11 @@ export class PromptProvider {
}),
isPlanMode,
),
taskTracker: this.withSection(
'taskTracker',
() => ({}),
config.isTrackerEnabled(),
),
operationalGuidelines: this.withSection(
'operationalGuidelines',
() => ({
@@ -18,6 +18,9 @@ import {
SHELL_TOOL_NAME,
WRITE_FILE_TOOL_NAME,
WRITE_TODOS_TOOL_NAME,
TRACKER_CREATE_TASK_TOOL_NAME,
TRACKER_LIST_TASKS_TOOL_NAME,
TRACKER_UPDATE_TASK_TOOL_NAME,
} from '../tools/tool-names.js';
// --- Options Structs ---
@@ -30,6 +33,7 @@ export interface SystemPromptOptions {
hookContext?: boolean;
primaryWorkflows?: PrimaryWorkflowsOptions;
planningWorkflow?: PlanningWorkflowOptions;
taskTracker?: TaskTrackerOptions;
operationalGuidelines?: OperationalGuidelinesOptions;
sandbox?: SandboxMode;
interactiveYoloMode?: boolean;
@@ -79,6 +83,9 @@ export interface PlanningWorkflowOptions {
approvedPlanPath?: string;
}
export interface TaskTrackerOptions {
}
export interface AgentSkillOptions {
name: string;
description: string;
@@ -113,6 +120,8 @@ ${
: renderPrimaryWorkflows(options.primaryWorkflows)
}
${renderTaskTracker(options.taskTracker)}
${renderOperationalGuidelines(options.operationalGuidelines)}
${renderInteractiveYoloMode(options.interactiveYoloMode)}
@@ -387,6 +396,24 @@ ${trimmed}
return `\n---\n\n<loaded_context>\n${sections.join('\n')}\n</loaded_context>`;
}
export function renderTaskTracker(options?: TaskTrackerOptions): string {
if (!options) return '';
const trackerCreate = `\`${TRACKER_CREATE_TASK_TOOL_NAME}\``;
const trackerList = `\`${TRACKER_LIST_TASKS_TOOL_NAME}\``;
const trackerUpdate = `\`${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. **ATOMICITY**: If a user request involves multiple steps (e.g., "Refactor the backend") or represents a complex task, you must first break this into discrete entries using ${trackerCreate} before writing any code.
3. **PLAN MODE INTEGRATION**: If you construct or are following a documented plan (e.g., in Plan Mode), use the tracker to represent the granular execution state of that plan. Maintain a bidirectional understanding between the plan document and the task graph.
4. **VERIFICATION**: Before marking a task as complete, verify the work is actually done (e.g., run the test, check the file existence).
5. **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.
6. **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 {
+27
View File
@@ -17,6 +17,9 @@ import {
SHELL_TOOL_NAME,
WRITE_FILE_TOOL_NAME,
WRITE_TODOS_TOOL_NAME,
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';
@@ -31,6 +34,7 @@ export interface SystemPromptOptions {
hookContext?: boolean;
primaryWorkflows?: PrimaryWorkflowsOptions;
planningWorkflow?: PlanningWorkflowOptions;
taskTracker?: TaskTrackerOptions;
operationalGuidelines?: OperationalGuidelinesOptions;
sandbox?: SandboxMode;
interactiveYoloMode?: boolean;
@@ -77,6 +81,9 @@ export interface PlanningWorkflowOptions {
approvedPlanPath?: string;
}
export interface TaskTrackerOptions {
}
export interface AgentSkillOptions {
name: string;
description: string;
@@ -112,6 +119,8 @@ ${
: renderPrimaryWorkflows(options.primaryWorkflows)
}
${renderTaskTracker(options.taskTracker)}
${renderOperationalGuidelines(options.operationalGuidelines)}
${renderInteractiveYoloMode(options.interactiveYoloMode)}
@@ -408,6 +417,24 @@ ${trimmed}
return `\n---\n\n<loaded_context>\n${sections.join('\n')}\n</loaded_context>`;
}
export function renderTaskTracker(options?: TaskTrackerOptions): string {
if (!options) return '';
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. **ATOMICITY**: If a user request involves multiple steps (e.g., "Refactor the backend") or represents a complex task, you must first break this into discrete entries using ${trackerCreate} before writing any code.
3. **PLAN MODE INTEGRATION**: If you construct or are following a documented plan (e.g., in Plan Mode), use the tracker to represent the granular execution state of that plan. Maintain a bidirectional understanding between the plan document and the task graph.
4. **VERIFICATION**: Before marking a task as complete, verify the work is actually done (e.g., run the test, check the file existence).
5. **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.
6. **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 {
@@ -15,7 +15,6 @@ export class TrackerService {
private initialized = false;
constructor(readonly trackerDir: string) {
console.log('trackerDir', trackerDir);
this.tasksDir = trackerDir;
}