diff --git a/src/core/Cline.ts b/src/core/Cline.ts index ff462c61d0..96879e30f6 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -46,6 +46,7 @@ import { HistoryItem } from "../shared/HistoryItem" import { ClineAskResponse, ClineCheckpointRestore } from "../shared/WebviewMessage" import { calculateApiCost } from "../utils/cost" import { fileExistsAtPath } from "../utils/fs" +import { LLMFileAccessController } from "../services/llm-access-control/LLMFileAccessController" import { arePathsEqual, getReadablePath } from "../utils/path" import { fixModelHtmlEscaping, removeInvalidChars } from "../utils/string" import { AssistantMessageContent, parseAssistantMessage, ToolParamName, ToolUseName } from "./assistant-message" @@ -80,6 +81,7 @@ export class Cline { private chatSettings: ChatSettings apiConversationHistory: Anthropic.MessageParam[] = [] clineMessages: ClineMessage[] = [] + private llmAccessController: LLMFileAccessController private askResponse?: ClineAskResponse private askResponseText?: string private askResponseImages?: string[] @@ -123,6 +125,7 @@ export class Cline { images?: string[], historyItem?: HistoryItem, ) { + this.llmAccessController = new LLMFileAccessController(cwd) this.providerRef = new WeakRef(provider) this.api = buildApiHandler(apiConfiguration) this.terminalManager = new TerminalManager() @@ -748,6 +751,9 @@ export class Cline { // if the extension process were killed, then on restart the clineMessages might not be empty, so we need to set it to [] when we create a new Cline client (otherwise webview would show stale messages from previous session) this.clineMessages = [] this.apiConversationHistory = [] + // Initialize the LLM access controller + await this.llmAccessController.initialize() + await this.providerRef.deref()?.postStateToWebview() await this.say("text", task, images) @@ -774,6 +780,9 @@ export class Cline { // this.checkpointTrackerErrorMessage = "Checkpoints are only available for new tasks" // } + // Initialize the LLM access controller + await this.llmAccessController.initialize() + const modifiedClineMessages = await this.getSavedClineMessages() // Remove any resume messages that may have been added before diff --git a/src/services/llm-access-control/LLMFileAccessController.ts b/src/services/llm-access-control/LLMFileAccessController.ts index b5139c43a8..5410e8c823 100644 --- a/src/services/llm-access-control/LLMFileAccessController.ts +++ b/src/services/llm-access-control/LLMFileAccessController.ts @@ -40,6 +40,10 @@ export class LLMFileAccessController { try { const ignorePath = path.join(this.cwd, ".clineignore") if (await fileExistsAtPath(ignorePath)) { + // We need to reset ignore. Otherwise we will be adding duplicate patterns from re-reading the .clineignore + // Will be switching to globby in next PR + this.ignoreInstance = ignore() + this.ignoreInstance.add(LLMFileAccessController.DEFAULT_PATTERNS) const content = await fs.readFile(ignorePath, "utf8") const customPatterns = content .split("\n")