mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Make system prompt static in prep for prompt caching refactor
This commit is contained in:
@@ -78,19 +78,6 @@ Operating System: ${osName()}
|
|||||||
Default Shell: ${defaultShell}
|
Default Shell: ${defaultShell}
|
||||||
Home Directory: ${os.homedir()}
|
Home Directory: ${os.homedir()}
|
||||||
Current Working Directory: ${cwd}
|
Current Working Directory: ${cwd}
|
||||||
VSCode Visible Files: ${
|
|
||||||
vscode.window.visibleTextEditors
|
|
||||||
?.map((editor) => editor.document?.uri?.fsPath)
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(", ") || "(No files open)"
|
|
||||||
}
|
|
||||||
VSCode Opened Tabs: ${
|
|
||||||
vscode.window.tabGroups.all
|
|
||||||
.flatMap((group) => group.tabs)
|
|
||||||
.map((tab) => (tab.input as vscode.TabInputText)?.uri?.fsPath)
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(", ") || "(No tabs open)"
|
|
||||||
}
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const cwd =
|
const cwd =
|
||||||
@@ -349,7 +336,10 @@ export class ClaudeDev {
|
|||||||
this.apiConversationHistory = []
|
this.apiConversationHistory = []
|
||||||
await this.providerRef.deref()?.postStateToWebview()
|
await this.providerRef.deref()?.postStateToWebview()
|
||||||
|
|
||||||
let textBlock: Anthropic.TextBlockParam = { type: "text", text: `Task: \"${task}\"` }
|
let textBlock: Anthropic.TextBlockParam = {
|
||||||
|
type: "text",
|
||||||
|
text: `<task>\n${task}\n</task>\n${this.getPotentiallyRelevantDetails()}`, // cannot be sent with system prompt since it's cached and these details can change
|
||||||
|
}
|
||||||
let imageBlocks: Anthropic.ImageBlockParam[] = this.formatImagesIntoBlocks(images)
|
let imageBlocks: Anthropic.ImageBlockParam[] = this.formatImagesIntoBlocks(images)
|
||||||
|
|
||||||
// TODO: create tools that let Claude interact with VSCode (e.g. open a file, list open files, etc.)
|
// TODO: create tools that let Claude interact with VSCode (e.g. open a file, list open files, etc.)
|
||||||
@@ -500,10 +490,7 @@ export class ClaudeDev {
|
|||||||
}
|
}
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
await this.say("user_feedback", text, images)
|
await this.say("user_feedback", text, images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(this.formatGenericToolFeedback(text), images)
|
||||||
`The user denied this operation and provided the following feedback:\n\"${text}\"`,
|
|
||||||
images
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return "The user denied this operation."
|
return "The user denied this operation."
|
||||||
}
|
}
|
||||||
@@ -540,10 +527,7 @@ export class ClaudeDev {
|
|||||||
}
|
}
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
await this.say("user_feedback", text, images)
|
await this.say("user_feedback", text, images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(this.formatGenericToolFeedback(text), images)
|
||||||
`The user denied this operation and provided the following feedback:\n\"${text}\"`,
|
|
||||||
images
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return "The user denied this operation."
|
return "The user denied this operation."
|
||||||
}
|
}
|
||||||
@@ -590,10 +574,7 @@ export class ClaudeDev {
|
|||||||
if (response !== "yesButtonTapped") {
|
if (response !== "yesButtonTapped") {
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
await this.say("user_feedback", text, images)
|
await this.say("user_feedback", text, images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(this.formatGenericToolFeedback(text), images)
|
||||||
`The user denied this operation and provided the following feedback:\n\"${text}\"`,
|
|
||||||
images
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return "The user denied this operation."
|
return "The user denied this operation."
|
||||||
}
|
}
|
||||||
@@ -628,10 +609,7 @@ export class ClaudeDev {
|
|||||||
if (response !== "yesButtonTapped") {
|
if (response !== "yesButtonTapped") {
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
await this.say("user_feedback", text, images)
|
await this.say("user_feedback", text, images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(this.formatGenericToolFeedback(text), images)
|
||||||
`The user denied this operation and provided the following feedback:\n\"${text}\"`,
|
|
||||||
images
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return "The user denied this operation."
|
return "The user denied this operation."
|
||||||
}
|
}
|
||||||
@@ -671,10 +649,7 @@ export class ClaudeDev {
|
|||||||
if (response !== "yesButtonTapped") {
|
if (response !== "yesButtonTapped") {
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
await this.say("user_feedback", text, images)
|
await this.say("user_feedback", text, images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(this.formatGenericToolFeedback(text), images)
|
||||||
`The user denied this operation and provided the following feedback:\n\"${text}\"`,
|
|
||||||
images
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return "The user denied this operation."
|
return "The user denied this operation."
|
||||||
}
|
}
|
||||||
@@ -760,10 +735,7 @@ export class ClaudeDev {
|
|||||||
if (response !== "yesButtonTapped") {
|
if (response !== "yesButtonTapped") {
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
await this.say("user_feedback", text, images)
|
await this.say("user_feedback", text, images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(this.formatGenericToolFeedback(text), images)
|
||||||
`The user denied this operation and provided the following feedback:\n\"${text}\"`,
|
|
||||||
images
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return "The user denied this operation."
|
return "The user denied this operation."
|
||||||
}
|
}
|
||||||
@@ -792,10 +764,7 @@ export class ClaudeDev {
|
|||||||
if (response !== "yesButtonTapped") {
|
if (response !== "yesButtonTapped") {
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
await this.say("user_feedback", text, images)
|
await this.say("user_feedback", text, images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(this.formatGenericToolFeedback(text), images)
|
||||||
`The user denied this operation and provided the following feedback:\n\"${text}\"`,
|
|
||||||
images
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return "The user denied this operation."
|
return "The user denied this operation."
|
||||||
}
|
}
|
||||||
@@ -894,7 +863,7 @@ export class ClaudeDev {
|
|||||||
}
|
}
|
||||||
const { text, images } = await this.ask("followup", question)
|
const { text, images } = await this.ask("followup", question)
|
||||||
await this.say("user_feedback", text ?? "", images)
|
await this.say("user_feedback", text ?? "", images)
|
||||||
return this.formatIntoToolResponse(`User's response:\n\"${text}\"`, images)
|
return this.formatIntoToolResponse(`<answer>\n${text}\n</answer>`, images)
|
||||||
}
|
}
|
||||||
|
|
||||||
async attemptCompletion(result?: string, command?: string): Promise<ToolResponse> {
|
async attemptCompletion(result?: string, command?: string): Promise<ToolResponse> {
|
||||||
@@ -923,7 +892,7 @@ export class ClaudeDev {
|
|||||||
}
|
}
|
||||||
await this.say("user_feedback", text ?? "", images)
|
await this.say("user_feedback", text ?? "", images)
|
||||||
return this.formatIntoToolResponse(
|
return this.formatIntoToolResponse(
|
||||||
`The user is not pleased with the results. Use the feedback they provided to successfully complete the task, and then attempt completion again.\nUser's feedback:\n\"${text}\"`,
|
`The user is not pleased with the results. Use the feedback they provided to successfully complete the task, and then attempt completion again.\n<feedback>\n${text}\n</feedback>`,
|
||||||
images
|
images
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1119,4 +1088,29 @@ ${this.customInstructions.trim()}
|
|||||||
return { didEndLoop: true, inputTokens: 0, outputTokens: 0 }
|
return { didEndLoop: true, inputTokens: 0, outputTokens: 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prompts
|
||||||
|
|
||||||
|
getPotentiallyRelevantDetails() {
|
||||||
|
// TODO: add more details
|
||||||
|
return `<potentially_relevant_details>
|
||||||
|
VSCode Visible Files: ${
|
||||||
|
vscode.window.visibleTextEditors
|
||||||
|
?.map((editor) => editor.document?.uri?.fsPath)
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(", ") || "(No files open)"
|
||||||
|
}
|
||||||
|
VSCode Opened Tabs: ${
|
||||||
|
vscode.window.tabGroups.all
|
||||||
|
.flatMap((group) => group.tabs)
|
||||||
|
.map((tab) => (tab.input as vscode.TabInputText)?.uri?.fsPath)
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(", ") || "(No tabs open)"
|
||||||
|
}
|
||||||
|
</potentially_relevant_details>`
|
||||||
|
}
|
||||||
|
|
||||||
|
formatGenericToolFeedback(feedback?: string) {
|
||||||
|
return `The user denied this operation and provided the following feedback:\n<feedback>\n${feedback}\n</feedback>\n\n${this.getPotentiallyRelevantDetails()}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user