mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-13 23:11:10 +00:00
chore: commit src/hooks/RecordLessonTool.ts
This commit is contained in:
parent
b8f44b1c44
commit
5551849f1d
1 changed files with 46 additions and 0 deletions
46
src/hooks/RecordLessonTool.ts
Normal file
46
src/hooks/RecordLessonTool.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import { BaseTool, ToolCallbacks } from "../core/tools/BaseTool"
|
||||
import type { ToolUse } from "../shared/tools"
|
||||
import { Task } from "../core/task/Task"
|
||||
import { OrchestrationDataModel } from "./OrchestrationDataModel"
|
||||
|
||||
interface RecordLessonParams {
|
||||
lesson: string
|
||||
context?: {
|
||||
tool?: string
|
||||
error?: string
|
||||
file?: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool for recording lessons learned to AGENT.md (Phase 4 requirement)
|
||||
* This tool allows the agent to append lessons learned when verification steps fail
|
||||
* or when important insights are discovered during development.
|
||||
*/
|
||||
export class RecordLessonTool extends BaseTool<"record_lesson"> {
|
||||
readonly name = "record_lesson" as const
|
||||
|
||||
async execute(params: RecordLessonParams, task: Task, callbacks: ToolCallbacks): Promise<void> {
|
||||
const { pushToolResult, handleError } = callbacks
|
||||
|
||||
if (!params.lesson || params.lesson.trim() === "") {
|
||||
task.consecutiveMistakeCount++
|
||||
task.recordToolError("record_lesson")
|
||||
pushToolResult("Error: lesson parameter is required and cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const dataModel = new OrchestrationDataModel(task.cwd)
|
||||
await dataModel.initialize()
|
||||
await dataModel.appendLesson(params.lesson.trim(), params.context)
|
||||
|
||||
pushToolResult(`Lesson recorded successfully to .orchestration/AGENT.md`)
|
||||
task.consecutiveMistakeCount = 0
|
||||
} catch (error) {
|
||||
await handleError("recording lesson", error as Error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const recordLessonTool = new RecordLessonTool()
|
||||
Loading…
Add table
Reference in a new issue