initialize class

This commit is contained in:
Evan 2025-01-31 15:15:31 -08:00
parent 2a078fee77
commit ef8d49c768
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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")