From 3ac89ae244b8f0ec430663b044e23bbb3337c0fc Mon Sep 17 00:00:00 2001 From: Aishanee Shah Date: Tue, 14 Apr 2026 20:31:55 +0000 Subject: [PATCH] fix(watcher): obfuscate status file name to prevent main agent discovery --- packages/core/src/agents/watcher-agent.ts | 2 +- packages/core/src/core/client.ts | 9 ++++++--- packages/core/src/core/client_watcher.test.ts | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/core/src/agents/watcher-agent.ts b/packages/core/src/agents/watcher-agent.ts index 909c03b865..736b455b4a 100644 --- a/packages/core/src/agents/watcher-agent.ts +++ b/packages/core/src/agents/watcher-agent.ts @@ -38,7 +38,7 @@ export const WatcherAgent = ( context: AgentLoopContext, ): LocalAgentDefinition => { const projectTempDir = context.config.storage.getProjectTempDir(); - const statusFilePath = path.join(projectTempDir, 'watcher_status.md'); + const statusFilePath = path.join(projectTempDir, '.sys_state_cache.log'); return { name: 'watcher', diff --git a/packages/core/src/core/client.ts b/packages/core/src/core/client.ts index 747cda9eff..959f8ff7c0 100644 --- a/packages/core/src/core/client.ts +++ b/packages/core/src/core/client.ts @@ -327,7 +327,7 @@ export class GeminiClient { // Clean up Watcher status file try { const projectTempDir = this.config.storage.getProjectTempDir(); - const statusFilePath = path.join(projectTempDir, 'watcher_status.md'); + const statusFilePath = path.join(projectTempDir, '.sys_state_cache.log'); if (fs.existsSync(statusFilePath)) { fs.unlinkSync(statusFilePath); } @@ -1346,7 +1346,7 @@ export class GeminiClient { const interval = this.config.getExperimentalWatcherInterval(); const projectTempDir = this.config.storage.getProjectTempDir(); - const statusFilePath = path.join(projectTempDir, 'watcher_status.md'); + const statusFilePath = path.join(projectTempDir, '.sys_state_cache.log'); // Ensure the file exists before the subagent tries to read it if (!fs.existsSync(statusFilePath)) { @@ -1416,7 +1416,10 @@ export class GeminiClient { // Internally write the status report to avoid requiring user permission const projectTempDir = this.config.storage.getProjectTempDir(); - const statusFilePath = path.join(projectTempDir, 'watcher_status.md'); + const statusFilePath = path.join( + projectTempDir, + '.sys_state_cache.log', + ); debugLogger.log( `[Watcher] Writing status report to ${statusFilePath}`, ); diff --git a/packages/core/src/core/client_watcher.test.ts b/packages/core/src/core/client_watcher.test.ts index fb3fd355ac..9badb0b738 100644 --- a/packages/core/src/core/client_watcher.test.ts +++ b/packages/core/src/core/client_watcher.test.ts @@ -50,7 +50,7 @@ describe('GeminiClient Watcher Integration', () => { afterEach(() => { vi.unstubAllEnvs(); const projectTempDir = config.storage.getProjectTempDir(); - const statusFilePath = path.join(projectTempDir, 'watcher_status.md'); + const statusFilePath = path.join(projectTempDir, '.sys_state_cache.log'); if (fs.existsSync(statusFilePath)) { fs.unlinkSync(statusFilePath); } @@ -261,7 +261,7 @@ describe('GeminiClient Watcher Integration', () => { // Verify the status file exists (written by GeminiClient internally) const projectTempDir = config.storage.getProjectTempDir(); - const statusFilePath = path.join(projectTempDir, 'watcher_status.md'); + const statusFilePath = path.join(projectTempDir, '.sys_state_cache.log'); expect(fs.existsSync(statusFilePath)).toBe(true); const content = fs.readFileSync(statusFilePath, 'utf-8'); expect(content).toContain('# Watcher Memory State'); @@ -353,7 +353,7 @@ I hope this status update is helpful! } const projectTempDir = config.storage.getProjectTempDir(); - const statusFilePath = path.join(projectTempDir, 'watcher_status.md'); + const statusFilePath = path.join(projectTempDir, '.sys_state_cache.log'); expect(fs.existsSync(statusFilePath)).toBe(true); const content = fs.readFileSync(statusFilePath, 'utf-8'); expect(content).toContain('Messy test direction');