Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/prompts/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ ${getToolDescriptionsForMode(
experiments,
partialReadsEnabled,
settings,
enableMcpServerCreation,
)}

${getToolUseGuidelinesSection(codeIndexManager)}
Expand Down
43 changes: 43 additions & 0 deletions src/core/prompts/tools/__tests__/fetch-instructions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { describe, it, expect } from "vitest"
import { getFetchInstructionsDescription } from "../fetch-instructions"

describe("getFetchInstructionsDescription", () => {
it("should include create_mcp_server when enableMcpServerCreation is true", () => {
const description = getFetchInstructionsDescription(true)

expect(description).toContain("create_mcp_server")
expect(description).toContain("create_mode")
expect(description).toContain("Example: Requesting instructions to create an MCP Server")
expect(description).toContain("<task>create_mcp_server</task>")
})

it("should include create_mcp_server when enableMcpServerCreation is undefined (default behavior)", () => {
const description = getFetchInstructionsDescription()

expect(description).toContain("create_mcp_server")
expect(description).toContain("create_mode")
expect(description).toContain("Example: Requesting instructions to create an MCP Server")
expect(description).toContain("<task>create_mcp_server</task>")
})

it("should exclude create_mcp_server when enableMcpServerCreation is false", () => {
const description = getFetchInstructionsDescription(false)

expect(description).not.toContain("create_mcp_server")
expect(description).toContain("create_mode")
expect(description).toContain("Example: Requesting instructions to create a Mode")
expect(description).toContain("<task>create_mode</task>")
expect(description).not.toContain("Example: Requesting instructions to create an MCP Server")
})

it("should have the correct structure", () => {
const description = getFetchInstructionsDescription(true)

expect(description).toContain("## fetch_instructions")
expect(description).toContain("Description: Request to fetch instructions to perform a task")
expect(description).toContain("Parameters:")
expect(description).toContain("- task: (required) The task to get instructions for.")
expect(description).toContain("<fetch_instructions>")
expect(description).toContain("</fetch_instructions>")
})
})
30 changes: 22 additions & 8 deletions src/core/prompts/tools/fetch-instructions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
export function getFetchInstructionsDescription(): string {
return `## fetch_instructions
Description: Request to fetch instructions to perform a task
Parameters:
- task: (required) The task to get instructions for. This can take the following values:
create_mcp_server
create_mode
export function getFetchInstructionsDescription(enableMcpServerCreation?: boolean): string {
const tasks =
enableMcpServerCreation !== false
? ` create_mcp_server
create_mode`
: ` create_mode`

Example: Requesting instructions to create an MCP Server
const example =
enableMcpServerCreation !== false
? `Example: Requesting instructions to create an MCP Server
<fetch_instructions>
<task>create_mcp_server</task>
</fetch_instructions>`
: `Example: Requesting instructions to create a Mode
<fetch_instructions>
<task>create_mode</task>
</fetch_instructions>`

return `## fetch_instructions
Description: Request to fetch instructions to perform a task
Parameters:
- task: (required) The task to get instructions for. This can take the following values:
${tasks}
${example}`
}
8 changes: 6 additions & 2 deletions src/core/prompts/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { CodeIndexManager } from "../../../services/code-index/manager"
const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined> = {
execute_command: (args) => getExecuteCommandDescription(args),
read_file: (args) => getReadFileDescription(args),
fetch_instructions: () => getFetchInstructionsDescription(),
fetch_instructions: (args) => getFetchInstructionsDescription(args.settings?.enableMcpServerCreation),
write_to_file: (args) => getWriteToFileDescription(args),
search_files: (args) => getSearchFilesDescription(args),
list_files: (args) => getListFilesDescription(args),
Expand Down Expand Up @@ -61,6 +61,7 @@ export function getToolDescriptionsForMode(
experiments?: Record<string, boolean>,
partialReadsEnabled?: boolean,
settings?: Record<string, any>,
enableMcpServerCreation?: boolean,
): string {
const config = getModeConfig(mode, customModes)
const args: ToolArgs = {
Expand All @@ -70,7 +71,10 @@ export function getToolDescriptionsForMode(
browserViewportSize,
mcpHub,
partialReadsEnabled,
settings,
settings: {
...settings,
enableMcpServerCreation,
},
experiments,
}

Expand Down
Loading