Skip to content

Commit cc2cb36

Browse files
committed
chore(test): drop test-only tool-use interfaces from shared/tools
What: remove the AttemptCompletionToolUse and WriteToFileToolUse interface declarations from src/shared/tools.ts and retype their three spec consumers to the generic ToolUse<"attempt_completion"> / ToolUse<"write_to_file">. Why: both interfaces had zero production references at origin/main; the only importers were three specs. ToolUse<TName> already resolves nativeArgs through NativeToolArgs, so the named aliases added no type information over the generic form. knip could not report them because knip.json exempts src/shared/*.ts with a "!" suffix, so the deadness was proven by importer grep instead. Impact: no behavior change. Type-level only: params widens from a Pick of one or two keys to Partial<Record<ToolParamName, string>>, which accepts a superset, and nativeArgs keeps its exact shape. src and webview-ui typecheck, knip dev and production stay clean, and the affected suites (1246 tests across core/tools and core/task) pass. The TOOL_DISPLAY_NAMES row from the same plan was already removed upstream by 1cbc0f4 (#527), and the directoryExists dedup was stopped because the two copies enforce different error contracts (the roo-config copy re-throws on EACCES and is test-locked; the custom-instructions copy swallows all errors).
1 parent 159c42e commit cc2cb36

4 files changed

Lines changed: 38 additions & 52 deletions

File tree

‎src/core/task/__tests__/Task.persistence.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ClineProvider } from "../../webview/ClineProvider"
2020
import { ContextProxy } from "../../config/ContextProxy"
2121
import { providerIdentifiers } from "@roo-code/types/provider-identifiers"
2222
import { attemptCompletionTool, type AttemptCompletionCallbacks } from "../../tools/AttemptCompletionTool"
23-
import type { AttemptCompletionToolUse } from "../../../shared/tools"
23+
import type { ToolUse } from "../../../shared/tools"
2424

2525
type TaskPersistenceAccess = {
2626
addToApiConversationHistory: (message: Anthropic.MessageParam) => Promise<void>
@@ -533,7 +533,7 @@ describe("Task persistence", () => {
533533
completionEmitted = true
534534
})
535535

536-
const block: AttemptCompletionToolUse = {
536+
const block: ToolUse<"attempt_completion"> = {
537537
type: "tool_use",
538538
id: completionCallId,
539539
name: "attempt_completion",

‎src/core/task/__tests__/truncated-native-tool-args.spec.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
import { isValidToolName } from "../../tools/validateToolUse"
24-
import type { ToolUse, WriteToFileToolUse } from "../../../shared/tools"
24+
import type { ToolUse } from "../../../shared/tools"
2525

2626
describe("Truncated native tool-call args on finalize failure (issue #1221)", () => {
2727
/**
@@ -60,7 +60,7 @@ describe("Truncated native tool-call args on finalize failure (issue #1221)", ()
6060
// A write_to_file call whose `content` was cut off mid-stream - exactly
6161
// the scenario in #1221. The streaming phase already populated nativeArgs
6262
// from the incomplete partial-json parse before finalize failed.
63-
const truncated: WriteToFileToolUse = {
63+
const truncated: ToolUse<"write_to_file"> = {
6464
type: "tool_use",
6565
name: "write_to_file",
6666
params: {},
@@ -76,7 +76,7 @@ describe("Truncated native tool-call args on finalize failure (issue #1221)", ()
7676
})
7777

7878
it("companion: without the fix, the same truncated call would NOT have been blocked", () => {
79-
const truncated: WriteToFileToolUse = {
79+
const truncated: ToolUse<"write_to_file"> = {
8080
type: "tool_use",
8181
name: "write_to_file",
8282
params: {},
@@ -100,7 +100,7 @@ describe("Truncated native tool-call args on finalize failure (issue #1221)", ()
100100
// with the freshly-finalized one instead of taking this branch at all -
101101
// this test just confirms a complete, valid nativeArgs is never touched
102102
// by wouldBeBlocked's guard simulation.
103-
const complete: WriteToFileToolUse = {
103+
const complete: ToolUse<"write_to_file"> = {
104104
type: "tool_use",
105105
name: "write_to_file",
106106
params: {},

‎src/core/tools/__tests__/attemptCompletionTool.spec.ts‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RooCodeEventName, TodoItem } from "@roo-code/types"
22

3-
import { AttemptCompletionToolUse } from "../../../shared/tools"
3+
import { ToolUse } from "../../../shared/tools"
44

55
// Mock the formatResponse module before importing the tool
66
vi.mock("../../prompts/responses", () => ({
@@ -82,7 +82,7 @@ describe("attemptCompletionTool", () => {
8282

8383
describe("todo list validation", () => {
8484
it("should allow completion when there is no todo list", async () => {
85-
const block: AttemptCompletionToolUse = {
85+
const block: ToolUse<"attempt_completion"> = {
8686
type: "tool_use",
8787
name: "attempt_completion",
8888
params: { result: "Task completed successfully" },
@@ -108,7 +108,7 @@ describe("attemptCompletionTool", () => {
108108
})
109109

110110
it("should allow completion when todo list is empty", async () => {
111-
const block: AttemptCompletionToolUse = {
111+
const block: ToolUse<"attempt_completion"> = {
112112
type: "tool_use",
113113
name: "attempt_completion",
114114
params: { result: "Task completed successfully" },
@@ -133,7 +133,7 @@ describe("attemptCompletionTool", () => {
133133
})
134134

135135
it("should allow completion when all todos are completed", async () => {
136-
const block: AttemptCompletionToolUse = {
136+
const block: ToolUse<"attempt_completion"> = {
137137
type: "tool_use",
138138
name: "attempt_completion",
139139
params: { result: "Task completed successfully" },
@@ -163,7 +163,7 @@ describe("attemptCompletionTool", () => {
163163
})
164164

165165
it("should prevent completion when there are pending todos", async () => {
166-
const block: AttemptCompletionToolUse = {
166+
const block: ToolUse<"attempt_completion"> = {
167167
type: "tool_use",
168168
name: "attempt_completion",
169169
params: { result: "Task completed successfully" },
@@ -206,7 +206,7 @@ describe("attemptCompletionTool", () => {
206206
})
207207

208208
it("should prevent completion when there are in-progress todos", async () => {
209-
const block: AttemptCompletionToolUse = {
209+
const block: ToolUse<"attempt_completion"> = {
210210
type: "tool_use",
211211
name: "attempt_completion",
212212
params: { result: "Task completed successfully" },
@@ -249,7 +249,7 @@ describe("attemptCompletionTool", () => {
249249
})
250250

251251
it("should prevent completion when there are mixed incomplete todos", async () => {
252-
const block: AttemptCompletionToolUse = {
252+
const block: ToolUse<"attempt_completion"> = {
253253
type: "tool_use",
254254
name: "attempt_completion",
255255
params: { result: "Task completed successfully" },
@@ -293,7 +293,7 @@ describe("attemptCompletionTool", () => {
293293
})
294294

295295
it("should allow completion when setting is disabled even with incomplete todos", async () => {
296-
const block: AttemptCompletionToolUse = {
296+
const block: ToolUse<"attempt_completion"> = {
297297
type: "tool_use",
298298
name: "attempt_completion",
299299
params: { result: "Task completed successfully" },
@@ -337,7 +337,7 @@ describe("attemptCompletionTool", () => {
337337
})
338338

339339
it("should prevent completion when setting is enabled with incomplete todos", async () => {
340-
const block: AttemptCompletionToolUse = {
340+
const block: ToolUse<"attempt_completion"> = {
341341
type: "tool_use",
342342
name: "attempt_completion",
343343
params: { result: "Task completed successfully" },
@@ -381,7 +381,7 @@ describe("attemptCompletionTool", () => {
381381
})
382382

383383
it("should allow completion when setting is enabled but all todos are completed", async () => {
384-
const block: AttemptCompletionToolUse = {
384+
const block: ToolUse<"attempt_completion"> = {
385385
type: "tool_use",
386386
name: "attempt_completion",
387387
params: { result: "Task completed successfully" },
@@ -426,7 +426,7 @@ describe("attemptCompletionTool", () => {
426426

427427
describe("tool failure guardrail", () => {
428428
it("should prevent completion when a previous tool failed in the current turn", async () => {
429-
const block: AttemptCompletionToolUse = {
429+
const block: ToolUse<"attempt_completion"> = {
430430
type: "tool_use",
431431
name: "attempt_completion",
432432
params: { result: "Task completed successfully" },
@@ -461,7 +461,7 @@ describe("attemptCompletionTool", () => {
461461
})
462462

463463
it("should allow completion when no tools failed", async () => {
464-
const block: AttemptCompletionToolUse = {
464+
const block: ToolUse<"attempt_completion"> = {
465465
type: "tool_use",
466466
name: "attempt_completion",
467467
params: { result: "Task completed successfully" },
@@ -494,7 +494,7 @@ describe("attemptCompletionTool", () => {
494494
const persistenceReady = new Promise<boolean>((resolve) => {
495495
markPersistenceReady = () => resolve(true)
496496
})
497-
const block: AttemptCompletionToolUse = {
497+
const block: ToolUse<"attempt_completion"> = {
498498
type: "tool_use",
499499
name: "attempt_completion",
500500
params: { result: "9" },
@@ -572,7 +572,7 @@ describe("attemptCompletionTool", () => {
572572

573573
it("does not delegate or emit completion when child history persistence fails", async () => {
574574
const persistenceError = new Error("history unavailable")
575-
const block: AttemptCompletionToolUse = {
575+
const block: ToolUse<"attempt_completion"> = {
576576
type: "tool_use",
577577
name: "attempt_completion",
578578
params: { result: "9" },
@@ -621,7 +621,7 @@ describe("attemptCompletionTool", () => {
621621
})
622622

623623
it("does not delegate or report an error when child history persistence is cancelled", async () => {
624-
const block: AttemptCompletionToolUse = {
624+
const block: ToolUse<"attempt_completion"> = {
625625
type: "tool_use",
626626
name: "attempt_completion",
627627
params: { result: "9" },
@@ -670,7 +670,7 @@ describe("attemptCompletionTool", () => {
670670
})
671671

672672
it("does not reopen the parent when persistence is cancelled during approval", async () => {
673-
const block: AttemptCompletionToolUse = {
673+
const block: ToolUse<"attempt_completion"> = {
674674
type: "tool_use",
675675
name: "attempt_completion",
676676
params: { result: "9" },
@@ -722,7 +722,7 @@ describe("attemptCompletionTool", () => {
722722
})
723723

724724
it("falls through to standalone completion when parent delegation becomes stale after approval", async () => {
725-
const block: AttemptCompletionToolUse = {
725+
const block: ToolUse<"attempt_completion"> = {
726726
type: "tool_use",
727727
name: "attempt_completion",
728728
params: { result: "9" },
@@ -782,7 +782,7 @@ describe("attemptCompletionTool", () => {
782782
})
783783

784784
it("does not resume the parent when the parent is no longer awaiting this child", async () => {
785-
const block: AttemptCompletionToolUse = {
785+
const block: ToolUse<"attempt_completion"> = {
786786
type: "tool_use",
787787
name: "attempt_completion",
788788
params: { result: "9" },
@@ -832,7 +832,7 @@ describe("attemptCompletionTool", () => {
832832
})
833833

834834
it("delegates an interrupted subtask completion when the parent is still delegated and awaiting that child", async () => {
835-
const block: AttemptCompletionToolUse = {
835+
const block: ToolUse<"attempt_completion"> = {
836836
type: "tool_use",
837837
name: "attempt_completion",
838838
params: { result: "9" },
@@ -886,7 +886,7 @@ describe("attemptCompletionTool", () => {
886886
})
887887

888888
it("does not resume the parent when the parent is active but awaiting a different child", async () => {
889-
const block: AttemptCompletionToolUse = {
889+
const block: ToolUse<"attempt_completion"> = {
890890
type: "tool_use",
891891
name: "attempt_completion",
892892
params: { result: "9" },
@@ -936,7 +936,7 @@ describe("attemptCompletionTool", () => {
936936
})
937937

938938
it("emits TaskCompleted only when completion is accepted", async () => {
939-
const block: AttemptCompletionToolUse = {
939+
const block: ToolUse<"attempt_completion"> = {
940940
type: "tool_use",
941941
name: "attempt_completion",
942942
params: { result: "2" },
@@ -973,7 +973,7 @@ describe("attemptCompletionTool", () => {
973973
})
974974

975975
it("does not emit TaskCompleted when persistence is cancelled", async () => {
976-
const block: AttemptCompletionToolUse = {
976+
const block: ToolUse<"attempt_completion"> = {
977977
type: "tool_use",
978978
name: "attempt_completion",
979979
params: { result: "2" },
@@ -1003,7 +1003,7 @@ describe("attemptCompletionTool", () => {
10031003

10041004
it("reports accepted-completion persistence failures with persistence context", async () => {
10051005
const persistenceError = new Error("history write failed")
1006-
const block: AttemptCompletionToolUse = {
1006+
const block: ToolUse<"attempt_completion"> = {
10071007
type: "tool_use",
10081008
name: "attempt_completion",
10091009
params: { result: "2" },
@@ -1032,7 +1032,7 @@ describe("attemptCompletionTool", () => {
10321032
})
10331033

10341034
it("reports telemetry but does not emit the public TaskCompleted event when user provides follow-up feedback", async () => {
1035-
const block: AttemptCompletionToolUse = {
1035+
const block: ToolUse<"attempt_completion"> = {
10361036
type: "tool_use",
10371037
name: "attempt_completion",
10381038
params: { result: "2" },
@@ -1074,7 +1074,7 @@ describe("attemptCompletionTool", () => {
10741074
})
10751075

10761076
it("durably persists queued completion feedback before continuing", async () => {
1077-
const block: AttemptCompletionToolUse = {
1077+
const block: ToolUse<"attempt_completion"> = {
10781078
type: "tool_use",
10791079
name: "attempt_completion",
10801080
params: { result: "Done" },
@@ -1105,7 +1105,7 @@ describe("attemptCompletionTool", () => {
11051105
})
11061106

11071107
it("does not continue when queued completion feedback persistence fails", async () => {
1108-
const block: AttemptCompletionToolUse = {
1108+
const block: ToolUse<"attempt_completion"> = {
11091109
type: "tool_use",
11101110
name: "attempt_completion",
11111111
params: { result: "Done" },
@@ -1136,7 +1136,7 @@ describe("attemptCompletionTool", () => {
11361136
})
11371137

11381138
it("records image-only completion feedback before continuing", async () => {
1139-
const block: AttemptCompletionToolUse = {
1139+
const block: ToolUse<"attempt_completion"> = {
11401140
type: "tool_use",
11411141
name: "attempt_completion",
11421142
params: { result: "Done" },
@@ -1162,7 +1162,7 @@ describe("attemptCompletionTool", () => {
11621162
})
11631163

11641164
it("does not clear pending metadata when stale delegation continues without an action id", async () => {
1165-
const block: AttemptCompletionToolUse = {
1165+
const block: ToolUse<"attempt_completion"> = {
11661166
type: "tool_use",
11671167
name: "attempt_completion",
11681168
params: { result: "Done" },
@@ -1232,7 +1232,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
12321232
}
12331233

12341234
it("does not emit a duplicate telemetry installment when replaying an already-completed subtask from history", async () => {
1235-
const block: AttemptCompletionToolUse = {
1235+
const block: ToolUse<"attempt_completion"> = {
12361236
type: "tool_use",
12371237
name: "attempt_completion",
12381238
params: { result: "done" },
@@ -1269,7 +1269,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
12691269
})
12701270

12711271
it("does not emit the public TaskCompleted event when replaying an already-completed subtask from history", async () => {
1272-
const block: AttemptCompletionToolUse = {
1272+
const block: ToolUse<"attempt_completion"> = {
12731273
type: "tool_use",
12741274
name: "attempt_completion",
12751275
params: { result: "done" },
@@ -1310,7 +1310,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
13101310
})
13111311

13121312
it("emits the public TaskCompleted API event only when completion is accepted, but reports telemetry either way", async () => {
1313-
const block: AttemptCompletionToolUse = {
1313+
const block: ToolUse<"attempt_completion"> = {
13141314
type: "tool_use",
13151315
name: "attempt_completion",
13161316
params: { result: "done" },
@@ -1342,7 +1342,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
13421342
})
13431343

13441344
it("still reports telemetry for a model-initiated completion even when the user provides follow-up feedback instead of accepting", async () => {
1345-
const block: AttemptCompletionToolUse = {
1345+
const block: ToolUse<"attempt_completion"> = {
13461346
type: "tool_use",
13471347
name: "attempt_completion",
13481348
params: { result: "done" },

‎src/shared/tools.ts‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,6 @@ export interface McpToolUse {
182182
partial: boolean
183183
}
184184

185-
/**
186-
* @public
187-
*/
188-
export interface AttemptCompletionToolUse extends ToolUse<"attempt_completion"> {
189-
name: "attempt_completion"
190-
params: Partial<Pick<Record<ToolParamName, string>, "result">>
191-
}
192-
193-
/** @internal Type used by tool-argument regression tests. */
194-
export interface WriteToFileToolUse extends ToolUse<"write_to_file"> {
195-
name: "write_to_file"
196-
params: Partial<Pick<Record<ToolParamName, string>, "path" | "content">>
197-
}
198-
199185
// Define tool group configuration
200186
export type ToolGroupConfig = {
201187
tools: readonly string[]

0 commit comments

Comments
 (0)