diff --git a/packages/cli/src/ui/themes/theme.ts b/packages/cli/src/ui/themes/theme.ts index 76f692c6..88868790 100644 --- a/packages/cli/src/ui/themes/theme.ts +++ b/packages/cli/src/ui/themes/theme.ts @@ -65,18 +65,11 @@ export const ansiTheme: ColorsTheme = { }; export class Theme { - /** - * The user-facing name of the theme. - */ - readonly name: string; - /** * The default foreground color for text when no specific highlight rule applies. * This is an Ink-compatible color string (hex or name). */ readonly defaultColor: string; - - readonly colors: ColorsTheme; /** * Stores the mapping from highlight.js class names (e.g., 'hljs-keyword') * to Ink-compatible color strings (hex or name). @@ -256,13 +249,11 @@ export class Theme { * @param rawMappings The raw CSSProperties mappings from a react-syntax-highlighter theme object. */ constructor( - name: string, + readonly name: string, rawMappings: Record, - colors: ColorsTheme, + readonly colors: ColorsTheme, ) { - this.name = name; this._colorMap = Object.freeze(this._buildColorMap(rawMappings)); // Build and freeze the map - this.colors = colors; // Determine the default foreground color const rawDefaultColor = rawMappings['hljs']?.color; diff --git a/packages/server/src/core/client.ts b/packages/server/src/core/client.ts index a1cec704..d4bcdeca 100644 --- a/packages/server/src/core/client.ts +++ b/packages/server/src/core/client.ts @@ -23,7 +23,6 @@ import { ReadManyFilesTool } from '../tools/read-many-files.js'; // Import ReadM import { getResponseText } from '../utils/generateContentResponseUtilities.js'; export class GeminiClient { - private config: Config; private client: GoogleGenAI; private model: string; private generateContentConfig: GenerateContentConfig = { @@ -32,9 +31,8 @@ export class GeminiClient { }; private readonly MAX_TURNS = 100; - constructor(config: Config) { + constructor(private config: Config) { this.client = new GoogleGenAI({ apiKey: config.getApiKey() }); - this.config = config; this.model = config.getModel(); } diff --git a/packages/server/src/core/turn.ts b/packages/server/src/core/turn.ts index 25601164..47ca051b 100644 --- a/packages/server/src/core/turn.ts +++ b/packages/server/src/core/turn.ts @@ -84,7 +84,6 @@ export type ServerGeminiStreamEvent = // A turn manages the agentic loop turn within the server context. export class Turn { - private readonly chat: Chat; private readonly availableTools: Map; // Use passed-in tools private pendingToolCalls: Array<{ callId: string; @@ -95,8 +94,10 @@ export class Turn { private confirmationDetails: ToolCallConfirmationDetails[]; private debugResponses: GenerateContentResponse[]; - constructor(chat: Chat, availableTools: ServerTool[]) { - this.chat = chat; + constructor( + private readonly chat: Chat, + availableTools: ServerTool[], + ) { this.availableTools = new Map(availableTools.map((t) => [t.name, t])); this.pendingToolCalls = []; this.fnResponses = []; diff --git a/packages/server/src/tools/edit.ts b/packages/server/src/tools/edit.ts index 5dbeaf41..3b317a08 100644 --- a/packages/server/src/tools/edit.ts +++ b/packages/server/src/tools/edit.ts @@ -59,13 +59,11 @@ export class EditTool extends BaseTool { static readonly Name = 'replace'; // Keep static name private shouldAlwaysEdit = false; - private readonly rootDirectory: string; - /** * Creates a new instance of the EditLogic * @param rootDirectory Root directory to ground this tool in. */ - constructor(rootDirectory: string) { + constructor(private readonly rootDirectory: string) { // Note: The description here mentions other tools like ReadFileTool/WriteFileTool // by name. This might need updating if those tool names change. super( diff --git a/packages/server/src/tools/glob.ts b/packages/server/src/tools/glob.ts index f51456c3..d9d91c7a 100644 --- a/packages/server/src/tools/glob.ts +++ b/packages/server/src/tools/glob.ts @@ -32,16 +32,11 @@ export interface GlobToolParams { export class GlobTool extends BaseTool { static readonly Name = 'glob'; // Keep static name - /** - * The root directory that this tool is grounded in. - */ - private rootDirectory: string; - /** * Creates a new instance of the GlobLogic * @param rootDirectory Root directory to ground this tool in. */ - constructor(rootDirectory: string) { + constructor(private rootDirectory: string) { super( GlobTool.Name, 'FindFiles', // Display name handled by CLI wrapper diff --git a/packages/server/src/tools/grep.ts b/packages/server/src/tools/grep.ts index 1873a794..e3253ecf 100644 --- a/packages/server/src/tools/grep.ts +++ b/packages/server/src/tools/grep.ts @@ -54,13 +54,11 @@ interface GrepMatch { export class GrepTool extends BaseTool { static readonly Name = 'search_file_content'; // Keep static name - private rootDirectory: string; - /** * Creates a new instance of the GrepLogic * @param rootDirectory Root directory to ground this tool in. All operations will be restricted to this directory. */ - constructor(rootDirectory: string) { + constructor(private rootDirectory: string) { super( GrepTool.Name, 'SearchText', diff --git a/packages/server/src/tools/ls.ts b/packages/server/src/tools/ls.ts index 628daad5..01da5121 100644 --- a/packages/server/src/tools/ls.ts +++ b/packages/server/src/tools/ls.ts @@ -61,17 +61,11 @@ export interface FileEntry { export class LSTool extends BaseTool { static readonly Name = 'list_directory'; - /** - * The root directory that this tool is grounded in. - * All path operations will be restricted to this directory. - */ - private rootDirectory: string; - /** * Creates a new instance of the LSLogic * @param rootDirectory Root directory to ground this tool in. All operations will be restricted to this directory. */ - constructor(rootDirectory: string) { + constructor(private rootDirectory: string) { super( LSTool.Name, 'ReadFolder', diff --git a/packages/server/src/tools/read-file.ts b/packages/server/src/tools/read-file.ts index 6cd70302..598b4691 100644 --- a/packages/server/src/tools/read-file.ts +++ b/packages/server/src/tools/read-file.ts @@ -37,9 +37,8 @@ export class ReadFileTool extends BaseTool { static readonly Name: string = 'read_file'; private static readonly DEFAULT_MAX_LINES = 2000; private static readonly MAX_LINE_LENGTH = 2000; - private rootDirectory: string; - constructor(rootDirectory: string) { + constructor(private rootDirectory: string) { super( ReadFileTool.Name, 'ReadFile', diff --git a/packages/server/src/tools/read-many-files.ts b/packages/server/src/tools/read-many-files.ts index fad05759..0b4b090d 100644 --- a/packages/server/src/tools/read-many-files.ts +++ b/packages/server/src/tools/read-many-files.ts @@ -116,14 +116,13 @@ export class ReadManyFilesTool extends BaseTool< ToolResult > { static readonly Name: string = 'read_many_files'; - readonly targetDir: string; /** * Creates an instance of ReadManyFilesTool. * @param targetDir The absolute root directory within which this tool is allowed to operate. * All paths provided in `params` will be resolved relative to this directory. */ - constructor(targetDir: string) { + constructor(readonly targetDir: string) { const parameterSchema: Record = { type: 'object', properties: { diff --git a/packages/server/src/tools/shell.ts b/packages/server/src/tools/shell.ts index 1224dc8f..592acc2b 100644 --- a/packages/server/src/tools/shell.ts +++ b/packages/server/src/tools/shell.ts @@ -25,10 +25,9 @@ import { spawn } from 'child_process'; export class ShellTool extends BaseTool { static Name: string = 'execute_bash_command'; - private readonly config: Config; private whitelist: Set = new Set(); - constructor(config: Config) { + constructor(private readonly config: Config) { const toolDisplayName = 'Shell'; const descriptionUrl = new URL('shell.md', import.meta.url); const toolDescription = fs.readFileSync(descriptionUrl, 'utf-8'); @@ -38,7 +37,6 @@ export class ShellTool extends BaseTool { toolDescription, toolParameterSchema, ); - this.config = config; } getDescription(params: ShellToolParams): string { diff --git a/packages/server/src/tools/terminal.ts b/packages/server/src/tools/terminal.ts index 514ad682..7320cfb2 100644 --- a/packages/server/src/tools/terminal.ts +++ b/packages/server/src/tools/terminal.ts @@ -46,8 +46,6 @@ interface QueuedCommand { export class TerminalTool extends BaseTool { static Name: string = 'execute_bash_command'; - private readonly rootDirectory: string; - private readonly outputLimit: number; private bashProcess: ChildProcessWithoutNullStreams | null = null; private currentCwd: string; private isExecuting: boolean = false; @@ -58,12 +56,11 @@ export class TerminalTool extends BaseTool { private resolveShellReady: (() => void) | undefined; private rejectShellReady: ((reason?: unknown) => void) | undefined; private readonly backgroundTerminalAnalyzer: BackgroundTerminalAnalyzer; - private readonly config: Config; constructor( - rootDirectory: string, - config: Config, - outputLimit: number = MAX_OUTPUT_LENGTH, + private readonly rootDirectory: string, + private readonly config: Config, + private readonly outputLimit: number = MAX_OUTPUT_LENGTH, ) { const toolDisplayName = 'Terminal'; const toolDescription = `Executes one or more bash commands sequentially in a secure and persistent interactive shell session. Can run commands in the foreground (waiting for completion) or background (returning after launch, with subsequent status polling). @@ -131,7 +128,6 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es toolDescription, toolParameterSchema, ); - this.config = config; this.rootDirectory = path.resolve(rootDirectory); this.currentCwd = this.rootDirectory; this.outputLimit = outputLimit; diff --git a/packages/server/src/tools/write-file.ts b/packages/server/src/tools/write-file.ts index 814efa86..d24080d2 100644 --- a/packages/server/src/tools/write-file.ts +++ b/packages/server/src/tools/write-file.ts @@ -41,9 +41,7 @@ export class WriteFileTool extends BaseTool { static readonly Name: string = 'write_file'; private shouldAlwaysWrite = false; - private readonly rootDirectory: string; - - constructor(rootDirectory: string) { + constructor(private readonly rootDirectory: string) { super( WriteFileTool.Name, 'WriteFile',