Skip to content

Commit 259643c

Browse files
StevenTCramerhannesrudolph
authored andcommitted
refactor: improve type safety for fetch_instructions tool
- Export FetchInstructionsToolDirective type from tool-directives index - Add FetchInstructionsToolDirective to main directives exports - Update fetchInstructionsTool function to use specific type instead of generic ToolDirective - Add proper type import in presentAssistantMessage for fetch_instructions handling This improves type safety and makes the codebase more maintainable by using specific types instead of generic ones.
1 parent bfd5cd7 commit 259643c

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/core/message-parsing/directives/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type {
2020
SwitchModeToolDirective,
2121
NewTaskToolDirective,
2222
SearchAndReplaceToolDirective,
23+
FetchInstructionsToolDirective,
2324
} from "./tool-directives"
2425
export { type LogDirective, logLevels } from "./LogDirective"
2526

src/core/message-parsing/directives/tool-directives/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type { ToolResponse } from "./ToolResponse"
22
export type { ToolParamName } from "./ToolParamName"
33
export type { ExecuteCommandToolDirective } from "./ExecuteCommandToolDirective"
44
export type { ReadFileToolDirective } from "./ReadFileToolDirective"
5-
// export type { FetchInstructionsToolDirective } from "./FetchInstructionsToolDirective"
5+
export type { FetchInstructionsToolDirective } from "./FetchInstructionsToolDirective"
66
export type { WriteToFileToolDirective } from "./WriteToFileToolDirective"
77
export type { InsertCodeBlockToolDirective } from "./InsertCodeBlockToolDirective"
88
export type { CodebaseSearchToolDirective } from "./CodebaseSearchToolDirective"

src/core/message-parsing/presentAssistantMessage.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
NewTaskToolDirective,
2424
AttemptCompletionToolDirective,
2525
BrowserActionToolDirective,
26+
FetchInstructionsToolDirective,
2627
} from "./directives"
2728

2829
import { defaultModeSlug, getModeBySlug } from "../../shared/modes"
@@ -504,7 +505,13 @@ export async function presentAssistantMessage(cline: Task) {
504505

505506
break
506507
case "fetch_instructions":
507-
await fetchInstructionsTool(cline, block, askApproval, handleError, pushToolResult)
508+
await fetchInstructionsTool(
509+
cline,
510+
block as FetchInstructionsToolDirective,
511+
askApproval,
512+
handleError,
513+
pushToolResult,
514+
)
508515
break
509516
case "list_files":
510517
await listFilesTool(

src/core/tools/fetchInstructionsTool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { fetchInstructions } from "../prompts/instructions/instructions"
33
import { ClineSayTool } from "../../shared/ExtensionMessage"
44
import { formatResponse } from "../prompts/responses"
55
import { AskApproval, HandleError, PushToolResult } from "../../shared/tools"
6-
import { ToolDirective } from "../message-parsing/directives"
6+
import { FetchInstructionsToolDirective } from "../message-parsing/directives"
77

88
export async function fetchInstructionsTool(
99
cline: Task,
10-
block: ToolDirective,
10+
block: FetchInstructionsToolDirective,
1111
askApproval: AskApproval,
1212
handleError: HandleError,
1313
pushToolResult: PushToolResult,

0 commit comments

Comments
 (0)