Skip to content

Commit 512f52f

Browse files
committed
Merge PR Kilo-Org#684 with conflict resolution preserving current VSCLM fixes
2 parents c82e8c6 + 99f79ee commit 512f52f

File tree

14 files changed

+735
-31
lines changed

14 files changed

+735
-31
lines changed

.husky/pre-push

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/types/src/tool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { z } from "zod"
44
* ToolGroup
55
*/
66

7-
export const toolGroups = ["read", "edit", "browser", "command", "mcp", "modes"] as const
7+
export const toolGroups = ["read", "edit", "browser", "command", "vsclmt", "mcp", "modes"] as const
88

99
export const toolGroupsSchema = z.enum(toolGroups)
1010

@@ -25,6 +25,7 @@ export const toolNames = [
2525
"list_files",
2626
"list_code_definition_names",
2727
"browser_action",
28+
"use_vsclmt",
2829
"use_mcp_tool",
2930
"access_mcp_resource",
3031
"ask_followup_question",

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { listCodeDefinitionNamesTool } from "../tools/listCodeDefinitionNamesToo
2121
import { searchFilesTool } from "../tools/searchFilesTool"
2222
import { browserActionTool } from "../tools/browserActionTool"
2323
import { executeCommandTool } from "../tools/executeCommandTool"
24+
import { useVSCLMT } from "../tools/vsclmt"
2425
import { useMcpToolTool } from "../tools/useMcpToolTool"
2526
import { accessMcpResourceTool } from "../tools/accessMcpResourceTool"
2627
import { askFollowupQuestionTool } from "../tools/askFollowupQuestionTool"
@@ -213,6 +214,8 @@ export async function presentAssistantMessage(cline: Task, recursionDepth: numbe
213214
return `[${block.name} for '${block.params.path}']`
214215
case "browser_action":
215216
return `[${block.name} for '${block.params.action}']`
217+
case "use_vsclmt":
218+
return `[${block.name} for '${block.params.tool_name}']`
216219
case "use_mcp_tool":
217220
return `[${block.name} for '${block.params.server_name}']`
218221
case "access_mcp_resource":
@@ -533,6 +536,9 @@ export async function presentAssistantMessage(cline: Task, recursionDepth: numbe
533536
case "execute_command":
534537
await executeCommandTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
535538
break
539+
case "use_vsclmt":
540+
await useVSCLMT(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
541+
break
536542
case "use_mcp_tool":
537543
await useMcpToolTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
538544
break

src/core/prompts/sections/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export { getSystemInfoSection } from "./system-info"
33
export { getObjectiveSection } from "./objective"
44
export { addCustomInstructions } from "./custom-instructions"
55
export { getSharedToolUseSection } from "./tool-use"
6+
export { getVSCLMTSection } from "./vsclmt"
67
export { getMcpServersSection } from "./mcp-servers"
78
export { getToolUseGuidelinesSection } from "./tool-use-guidelines"
89
export { getCapabilitiesSection } from "./capabilities"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { ToolInfo } from "../../../services/vsclm/VSCLMToolsService"
2+
3+
export function getVSCLMTSection(selectedVSCLMT: ToolInfo[]): string {
4+
if (!selectedVSCLMT || selectedVSCLMT.length === 0) {
5+
return ""
6+
}
7+
8+
const toolDescriptions = selectedVSCLMT
9+
.map((tool) => {
10+
const displayName = tool.displayName || tool.name
11+
const description = tool.description || tool.userDescription || "No description available"
12+
13+
let toolSection = `### ${displayName}
14+
**Provider Extension:** ${tool.providerExtensionDisplayName} (${tool.providerExtensionId})
15+
**Description:** ${description}
16+
17+
**Tool Name:** ${tool.name}`
18+
19+
// Add input schema information if available
20+
if (tool.inputSchema && typeof tool.inputSchema === "object") {
21+
try {
22+
const schemaStr = JSON.stringify(tool.inputSchema, null, 2)
23+
toolSection += `
24+
**Input Schema:**
25+
\`\`\`json
26+
${schemaStr}
27+
\`\`\``
28+
} catch (error) {
29+
// If schema can't be serialized, skip it
30+
console.log(`Error serializing input schema for tool ${tool.name}:`, error)
31+
}
32+
}
33+
34+
// Add tags if available
35+
if (tool.tags && tool.tags.length > 0) {
36+
toolSection += `
37+
**Tags:** ${tool.tags.join(", ")}`
38+
}
39+
40+
return toolSection
41+
})
42+
.join("\n\n")
43+
44+
return `## VS Code Language Model Tools
45+
46+
The following VS Code Language Model tools are available for use. You can invoke them using the \`use_vsclmt\` tool with the appropriate tool name and arguments.
47+
48+
${toolDescriptions}
49+
50+
**Usage:** To use any of these tools, use the \`use_vsclmt\` tool with the \`tool_name\` parameter set to the exact tool name shown above, and provide any required arguments as a JSON string in the \`arguments\` parameter.`
51+
}

src/core/prompts/system.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { DiffStrategy } from "../../shared/tools"
1616
import { formatLanguage } from "../../shared/language"
1717
import { isEmpty } from "../../utils/object"
1818

19+
import { VSCLMToolsService } from "../../services/vsclm/VSCLMToolsService"
1920
import { McpHub } from "../../services/mcp/McpHub"
2021
import { CodeIndexManager } from "../../services/code-index/manager"
2122

@@ -27,6 +28,7 @@ import {
2728
getSystemInfoSection,
2829
getObjectiveSection,
2930
getSharedToolUseSection,
31+
getVSCLMTSection,
3032
getMcpServersSection,
3133
getToolUseGuidelinesSection,
3234
getCapabilitiesSection,
@@ -54,6 +56,7 @@ async function generatePrompt(
5456
cwd: string,
5557
supportsComputerUse: boolean,
5658
mode: Mode,
59+
vsclmtService?: VSCLMToolsService,
5760
mcpHub?: McpHub,
5861
diffStrategy?: DiffStrategy,
5962
browserViewportSize?: string,
@@ -87,8 +90,9 @@ async function generatePrompt(
8790
const hasMcpServers = mcpHub && mcpHub.getServers().length > 0
8891
const shouldIncludeMcp = hasMcpGroup && hasMcpServers
8992

90-
const [modesSection, mcpServersSection] = await Promise.all([
93+
const [modesSection, vsclmtSection, mcpServersSection] = await Promise.all([
9194
getModesSection(context),
95+
vsclmtService ? getVSCLMTSection(vsclmtService.getSelectedTools()) : Promise.resolve(""),
9296
shouldIncludeMcp
9397
? getMcpServersSection(mcpHub, effectiveDiffStrategy, enableMcpServerCreation)
9498
: Promise.resolve(""),
@@ -121,6 +125,8 @@ ${getToolDescriptionsForMode(
121125
122126
${getToolUseGuidelinesSection(codeIndexManager)}
123127
128+
${vsclmtSection}
129+
124130
${mcpServersSection}
125131
126132
${getCapabilitiesSection(cwd, supportsComputerUse, shouldIncludeMcp ? mcpHub : undefined, effectiveDiffStrategy, codeIndexManager, clineProviderState /* kilocode_change */)}
@@ -148,6 +154,7 @@ export const SYSTEM_PROMPT = async (
148154
context: vscode.ExtensionContext,
149155
cwd: string,
150156
supportsComputerUse: boolean,
157+
vsclmtService?: VSCLMToolsService,
151158
mcpHub?: McpHub,
152159
diffStrategy?: DiffStrategy,
153160
browserViewportSize?: string,
@@ -225,6 +232,7 @@ ${customInstructions}`
225232
cwd,
226233
supportsComputerUse,
227234
currentMode.slug,
235+
vsclmtService,
228236
mcpHub,
229237
effectiveDiffStrategy,
230238
browserViewportSize,

src/core/prompts/tools/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { getListCodeDefinitionNamesDescription } from "./list-code-definition-na
1919
import { getBrowserActionDescription } from "./browser-action"
2020
import { getAskFollowupQuestionDescription } from "./ask-followup-question"
2121
import { getAttemptCompletionDescription } from "./attempt-completion"
22+
import { getVSCLMTDescription } from "./vsclmt"
2223
import { getUseMcpToolDescription } from "./use-mcp-tool"
2324
import { getAccessMcpResourceDescription } from "./access-mcp-resource"
2425
import { getSwitchModeDescription } from "./switch-mode"
@@ -36,6 +37,7 @@ import { type ClineProviderState } from "../../webview/ClineProvider"
3637

3738
// Map of tool names to their description functions
3839
const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined> = {
40+
use_vsclmt: (args) => getVSCLMTDescription(args),
3941
execute_command: (args) => getExecuteCommandDescription(args),
4042
read_file: (args) => {
4143
// Check if the current model should use the simplified read_file tool
@@ -183,6 +185,7 @@ export {
183185
getBrowserActionDescription,
184186
getAskFollowupQuestionDescription,
185187
getAttemptCompletionDescription,
188+
getVSCLMTDescription,
186189
getUseMcpToolDescription,
187190
getAccessMcpResourceDescription,
188191
getSwitchModeDescription,

src/core/prompts/tools/vsclmt.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { ToolArgs } from "./types"
2+
3+
export function getVSCLMTDescription(args: ToolArgs): string {
4+
return `## use_vsclmt
5+
6+
Access and invoke VS Code Language Model tools that are selected and available in the current workspace.
7+
8+
Required parameters:
9+
- tool_name: The name of the VS Code LM tool to invoke
10+
11+
Optional parameters:
12+
- arguments: JSON string containing the arguments for the tool
13+
14+
The tool will:
15+
1. Validate that the specified VS Code LM tool is available and selected
16+
2. Parse and validate the provided arguments
17+
3. Invoke the tool using VS Code's native language model tool system
18+
4. Return the tool's result or any error messages
19+
20+
Use this tool to leverage VS Code's ecosystem of language model tools for enhanced functionality.
21+
22+
Example:
23+
<use_vsclmt>
24+
<tool_name>example-tool</tool_name>
25+
<arguments>{"param1": "value1", "param2": "value2"}</arguments>
26+
</use_vsclmt>`
27+
}

src/core/task/Task.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,6 +2354,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
23542354
// kilocode_change end
23552355

23562356
/*private kilocode_change*/ async getSystemPrompt(): Promise<string> {
2357+
const vsclmtService = this.providerRef.deref()?.getVSCLMToolService()
23572358
const { mcpEnabled } = (await this.providerRef.deref()?.getState()) ?? {}
23582359
let mcpHub: McpHub | undefined
23592360
if (mcpEnabled ?? true) {
@@ -2407,6 +2408,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
24072408
this.cwd,
24082409
// kilocode_change: supports images => supports browser
24092410
(this.api.getModel().info.supportsImages ?? false) && (browserToolEnabled ?? true),
2411+
vsclmtService,
24102412
mcpHub,
24112413
this.diffStrategy,
24122414
browserViewportSize,

0 commit comments

Comments
 (0)