@@ -29,7 +29,7 @@ import { GlobalFileNames } from "../../shared/globalFileNames"
2929import { HistoryItem } from "../../shared/HistoryItem"
3030import { ExtensionMessage } from "../../shared/ExtensionMessage"
3131import { Mode , PromptComponent , defaultModeSlug , getModeBySlug , getGroupName } from "../../shared/modes"
32- import { EXPERIMENT_IDS , experiments as Experiments , experimentDefault , ExperimentId } from "../../shared/experiments"
32+ import { experimentDefault } from "../../shared/experiments"
3333import { formatLanguage } from "../../shared/language"
3434import { Terminal , TERMINAL_SHELL_INTEGRATION_TIMEOUT } from "../../integrations/terminal/Terminal"
3535import { downloadTask } from "../../integrations/misc/export-markdown"
@@ -68,42 +68,37 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
6868 public static readonly tabPanelId = "roo-cline.TabPanelProvider"
6969 private static activeInstances : Set < ClineProvider > = new Set ( )
7070 private disposables : vscode . Disposable [ ] = [ ]
71- // not private, so it can be accessed from webviewMessageHandler
72- view ?: vscode . WebviewView | vscode . WebviewPanel
73- // not private, so it can be accessed from webviewMessageHandler
74- // callers could update to get viewLaunched() getter function
75- isViewLaunched = false
71+ private view ?: vscode . WebviewView | vscode . WebviewPanel
7672 private clineStack : Cline [ ] = [ ]
77- // not private, so it can be accessed from webviewMessageHandler
78- workspaceTracker ? : WorkspaceTracker
79- // not protected, so it can be accessed from webviewMessageHandler.
80- // Could modify code to use getMcpHub() instead.
81- mcpHub ?: McpHub // Change from private to protected
82- // not private, so it can be accessed from webviewMessageHandler
83- latestAnnouncementId = "apr-04-2025-boomerang" // update for Boomerang Tasks announcement
84- // not private, so it can be accessed from webviewMessageHandler
85- settingsImportedAt ?: number
73+ private _workspaceTracker ?: WorkspaceTracker // workSpaceTracker read-only for access outside this class
74+ public get workspaceTracker ( ) : WorkspaceTracker | undefined {
75+ return this . _workspaceTracker
76+ }
77+ protected mcpHub ?: McpHub // Change from private to protected
78+
79+ public isViewLaunched = false
80+ public settingsImportedAt ?: number
81+ public readonly latestAnnouncementId = "apr-04-2025-boomerang" // update for Boomerang Tasks announcement
8682 public readonly contextProxy : ContextProxy
8783 public readonly providerSettingsManager : ProviderSettingsManager
8884 public readonly customModesManager : CustomModesManager
8985
9086 constructor (
9187 readonly context : vscode . ExtensionContext ,
92- // not private, so it can be accessed from webviewMessageHandler
93- readonly outputChannel : vscode . OutputChannel ,
88+ private readonly outputChannel : vscode . OutputChannel ,
9489 private readonly renderContext : "sidebar" | "editor" = "sidebar" ,
9590 ) {
9691 super ( )
9792
98- this . outputChannel . appendLine ( "ClineProvider instantiated" )
93+ this . log ( "ClineProvider instantiated" )
9994 this . contextProxy = new ContextProxy ( context )
10095 ClineProvider . activeInstances . add ( this )
10196
10297 // Register this provider with the telemetry service to enable it to add
10398 // properties like mode and provider.
10499 telemetryService . setProvider ( this )
105100
106- this . workspaceTracker = new WorkspaceTracker ( this )
101+ this . _workspaceTracker = new WorkspaceTracker ( this )
107102
108103 this . providerSettingsManager = new ProviderSettingsManager ( this . context )
109104
@@ -118,7 +113,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
118113 this . mcpHub . registerClient ( )
119114 } )
120115 . catch ( ( error ) => {
121- this . outputChannel . appendLine ( `Failed to initialize MCP Hub: ${ error } ` )
116+ this . log ( `Failed to initialize MCP Hub: ${ error } ` )
122117 } )
123118 }
124119
@@ -203,13 +198,13 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
203198 - https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
204199 */
205200 async dispose ( ) {
206- this . outputChannel . appendLine ( "Disposing ClineProvider..." )
201+ this . log ( "Disposing ClineProvider..." )
207202 await this . removeClineFromStack ( )
208- this . outputChannel . appendLine ( "Cleared task" )
203+ this . log ( "Cleared task" )
209204
210205 if ( this . view && "dispose" in this . view ) {
211206 this . view . dispose ( )
212- this . outputChannel . appendLine ( "Disposed webview" )
207+ this . log ( "Disposed webview" )
213208 }
214209
215210 while ( this . disposables . length ) {
@@ -220,12 +215,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
220215 }
221216 }
222217
223- this . workspaceTracker ?. dispose ( )
224- this . workspaceTracker = undefined
218+ this . _workspaceTracker ?. dispose ( )
219+ this . _workspaceTracker = undefined
225220 await this . mcpHub ?. unregisterClient ( )
226221 this . mcpHub = undefined
227222 this . customModesManager ?. dispose ( )
228- this . outputChannel . appendLine ( "Disposed all disposables" )
223+ this . log ( "Disposed all disposables" )
229224 ClineProvider . activeInstances . delete ( this )
230225
231226 // Unregister from McpServerManager
@@ -338,7 +333,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
338333 }
339334
340335 async resolveWebviewView ( webviewView : vscode . WebviewView | vscode . WebviewPanel ) {
341- this . outputChannel . appendLine ( "Resolving webview view" )
336+ this . log ( "Resolving webview view" )
342337
343338 if ( ! this . contextProxy . isInitialized ) {
344339 await this . contextProxy . initialize ( )
@@ -441,7 +436,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
441436 // If the extension is starting a new session, clear previous task state.
442437 await this . removeClineFromStack ( )
443438
444- this . outputChannel . appendLine ( "Webview view resolved" )
439+ this . log ( "Webview view resolved" )
445440 }
446441
447442 public async initClineWithSubTask ( parent : Cline , task ?: string , images ?: string [ ] ) {
@@ -807,7 +802,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
807802 await this . postStateToWebview ( )
808803 }
809804
810- // not private, so it can be accessed from webviewMessageHandler
811805 async updateApiConfiguration ( providerSettings : ProviderSettings ) {
812806 // Update mode's default config.
813807 const { mode } = await this . getState ( )
@@ -914,14 +908,17 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
914908 return getSettingsDirectoryPath ( globalStoragePath )
915909 }
916910
917- // not private, so it can be accessed from webviewMessageHandler
918- async ensureCacheDirectoryExists ( ) {
911+ private async ensureCacheDirectoryExists ( ) {
919912 const { getCacheDirectoryPath } = await import ( "../../shared/storagePathManager" )
920913 const globalStoragePath = this . contextProxy . globalStorageUri . fsPath
921914 return getCacheDirectoryPath ( globalStoragePath )
922915 }
923916
924- // not private, so it can be accessed from webviewMessageHandler
917+ async writeModelsToCache < T > ( filename : string , data : T ) {
918+ const cacheDir = await this . ensureCacheDirectoryExists ( )
919+ await fs . writeFile ( path . join ( cacheDir , filename ) , JSON . stringify ( data ) )
920+ }
921+
925922 async readModelsFromCache ( filename : string ) : Promise < Record < string , ModelInfo > | undefined > {
926923 const filePath = path . join ( await this . ensureCacheDirectoryExists ( ) , filename )
927924 const fileExists = await fileExistsAtPath ( filePath )
@@ -951,7 +948,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
951948 throw new Error ( "Invalid response from OpenRouter API" )
952949 }
953950 } catch ( error ) {
954- this . outputChannel . appendLine (
951+ this . log (
955952 `Error exchanging code for API key: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
956953 )
957954 throw error
@@ -980,7 +977,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
980977 throw new Error ( "Invalid response from Glama API" )
981978 }
982979 } catch ( error ) {
983- this . outputChannel . appendLine (
980+ this . log (
984981 `Error exchanging code for API key: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
985982 )
986983 throw error
@@ -1030,7 +1027,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
10301027
10311028 await this . postStateToWebview ( )
10321029 } catch ( error ) {
1033- this . outputChannel . appendLine (
1030+ this . log (
10341031 `Error create new api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
10351032 )
10361033 vscode . window . showErrorMessage ( t ( "common:errors.create_api_config" ) )
@@ -1380,14 +1377,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
13801377 // ContextProxy
13811378
13821379 // @deprecated - Use `ContextProxy#setValue` instead.
1383- // not private, so it can be accessed from webviewMessageHandler
1384- async updateGlobalState < K extends keyof GlobalState > ( key : K , value : GlobalState [ K ] ) {
1380+ private async updateGlobalState < K extends keyof GlobalState > ( key : K , value : GlobalState [ K ] ) {
13851381 await this . contextProxy . setValue ( key , value )
13861382 }
13871383
13881384 // @deprecated - Use `ContextProxy#getValue` instead.
1389- // not private, so it can be accessed from webviewMessageHandler
1390- getGlobalState < K extends keyof GlobalState > ( key : K ) {
1385+ private getGlobalState < K extends keyof GlobalState > ( key : K ) {
13911386 return this . contextProxy . getValue ( key )
13921387 }
13931388
0 commit comments