mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Use a single browser instance to scrape multiple sites
This commit is contained in:
@@ -27,6 +27,7 @@ import { truncateHalfConversation } from "./utils/context-management"
|
||||
import { extractTextFromFile } from "./utils/extract-text"
|
||||
import { regexSearchFiles } from "./utils/ripgrep"
|
||||
import { parseMentions } from "./utils/context-mentions"
|
||||
import { UrlScraper } from "./utils/UrlScraper"
|
||||
|
||||
const SYSTEM_PROMPT =
|
||||
async () => `You are Claude Dev, a highly skilled software developer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
|
||||
@@ -250,6 +251,7 @@ export class ClaudeDev {
|
||||
readonly taskId: string
|
||||
private api: ApiHandler
|
||||
private terminalManager: TerminalManager
|
||||
private urlScraper: UrlScraper
|
||||
private didEditFile: boolean = false
|
||||
private customInstructions?: string
|
||||
private alwaysAllowReadOnly: boolean
|
||||
@@ -275,6 +277,7 @@ export class ClaudeDev {
|
||||
this.providerRef = new WeakRef(provider)
|
||||
this.api = buildApiHandler(apiConfiguration)
|
||||
this.terminalManager = new TerminalManager()
|
||||
this.urlScraper = new UrlScraper(provider.context)
|
||||
this.customInstructions = customInstructions
|
||||
this.alwaysAllowReadOnly = alwaysAllowReadOnly ?? false
|
||||
|
||||
@@ -675,6 +678,7 @@ export class ClaudeDev {
|
||||
abortTask() {
|
||||
this.abort = true // will stop any autonomously running promises
|
||||
this.terminalManager.disposeAll()
|
||||
this.urlScraper.closeBrowser()
|
||||
}
|
||||
|
||||
async executeTool(toolName: ToolName, toolInput: any): Promise<[boolean, ToolResponse]> {
|
||||
@@ -1643,14 +1647,14 @@ ${this.customInstructions.trim()}
|
||||
if (block.type === "text") {
|
||||
return {
|
||||
...block,
|
||||
text: await parseMentions(block.text, cwd, this.providerRef.deref()?.urlScraper),
|
||||
text: await parseMentions(block.text, cwd, this.urlScraper),
|
||||
}
|
||||
} else if (block.type === "tool_result") {
|
||||
const isUserMessage = (text: string) => text.includes("<feedback>") || text.includes("<answer>")
|
||||
if (typeof block.content === "string" && isUserMessage(block.content)) {
|
||||
return {
|
||||
...block,
|
||||
content: await parseMentions(block.content, cwd, this.providerRef.deref()?.urlScraper),
|
||||
content: await parseMentions(block.content, cwd, this.urlScraper),
|
||||
}
|
||||
} else if (Array.isArray(block.content)) {
|
||||
const parsedContent = await Promise.all(
|
||||
@@ -1658,11 +1662,7 @@ ${this.customInstructions.trim()}
|
||||
if (contentBlock.type === "text" && isUserMessage(contentBlock.text)) {
|
||||
return {
|
||||
...contentBlock,
|
||||
text: await parseMentions(
|
||||
contentBlock.text,
|
||||
cwd,
|
||||
this.providerRef.deref()?.urlScraper
|
||||
),
|
||||
text: await parseMentions(contentBlock.text, cwd, this.urlScraper),
|
||||
}
|
||||
}
|
||||
return contentBlock
|
||||
|
||||
Reference in New Issue
Block a user