Skip to content

Commit f16629c

Browse files
committed
PR1: address review comments — gate Tools catalog in system.ts for XML only; remove unused protocol param from getToolDescriptionsForMode; protocol selection via non-exported code constant; tests pass
1 parent 1a0a6fe commit f16629c

File tree

4 files changed

+7
-56
lines changed

4 files changed

+7
-56
lines changed
Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,10 @@
11
// npx vitest core/prompts/__tests__/toolProtocolResolver.spec.ts
22

3-
import { describe, it, expect, beforeEach } from "vitest"
4-
import { setToolProtocol, getToolProtocol, resolveToolProtocol } from "../toolProtocolResolver"
3+
import { describe, it, expect } from "vitest"
4+
import { resolveToolProtocol } from "../toolProtocolResolver"
55

66
describe("toolProtocolResolver", () => {
7-
beforeEach(() => {
8-
// Reset to default before each test
9-
setToolProtocol("xml")
10-
})
11-
127
it("should default to xml protocol", () => {
138
expect(resolveToolProtocol()).toBe("xml")
14-
expect(getToolProtocol()).toBe("xml")
15-
})
16-
17-
it("should allow setting protocol to native", () => {
18-
setToolProtocol("native")
19-
expect(resolveToolProtocol()).toBe("native")
20-
expect(getToolProtocol()).toBe("native")
21-
})
22-
23-
it("should allow setting protocol back to xml", () => {
24-
setToolProtocol("native")
25-
expect(getToolProtocol()).toBe("native")
26-
27-
setToolProtocol("xml")
28-
expect(getToolProtocol()).toBe("xml")
29-
})
30-
31-
it("should maintain state across multiple calls", () => {
32-
setToolProtocol("native")
33-
34-
expect(resolveToolProtocol()).toBe("native")
35-
expect(getToolProtocol()).toBe("native")
36-
expect(resolveToolProtocol()).toBe("native")
37-
expect(getToolProtocol()).toBe("native")
389
})
3910
})

src/core/prompts/system.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ async function generatePrompt(
108108
settings,
109109
enableMcpServerCreation,
110110
modelId,
111-
effectiveProtocol,
112111
)}`
113112
: ""
114113

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
import { ToolProtocol } from "@roo-code/types"
22

33
/**
4-
* Internal tool protocol state management.
4+
* Current tool protocol setting.
55
* This is code-only and not exposed through VS Code settings.
6+
* To switch protocols, edit this constant directly in the source code.
67
*/
7-
let currentProtocol: ToolProtocol = "xml"
8-
9-
/**
10-
* Sets the current tool protocol.
11-
* This is an internal API and should not be called by external code.
12-
*
13-
* @param protocol - The tool protocol to set ('xml' or 'native')
14-
*/
15-
export function setToolProtocol(protocol: ToolProtocol): void {
16-
currentProtocol = protocol
17-
}
18-
19-
/**
20-
* Gets the current tool protocol.
21-
*
22-
* @returns The current tool protocol
23-
*/
24-
export function getToolProtocol(): ToolProtocol {
25-
return currentProtocol
26-
}
8+
const CURRENT_TOOL_PROTOCOL: ToolProtocol = "xml" // change to 'native' to enable native protocol
279

2810
/**
2911
* Resolves the effective tool protocol.
3012
*
3113
* @returns The effective tool protocol (defaults to "xml")
3214
*/
3315
export function resolveToolProtocol(): ToolProtocol {
34-
return currentProtocol
16+
return CURRENT_TOOL_PROTOCOL
3517
}

src/core/prompts/tools/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ToolName, ModeConfig, ToolProtocol } from "@roo-code/types"
1+
import type { ToolName, ModeConfig } from "@roo-code/types"
22

33
import { TOOL_GROUPS, ALWAYS_AVAILABLE_TOOLS, DiffStrategy } from "../../../shared/tools"
44
import { McpHub } from "../../../services/mcp/McpHub"
@@ -74,7 +74,6 @@ export function getToolDescriptionsForMode(
7474
settings?: Record<string, any>,
7575
enableMcpServerCreation?: boolean,
7676
modelId?: string,
77-
protocol: ToolProtocol = "xml",
7877
): string {
7978
const config = getModeConfig(mode, customModes)
8079
const args: ToolArgs = {

0 commit comments

Comments
 (0)