fix(watcher): obfuscate status file name to prevent main agent discovery

This commit is contained in:
Aishanee Shah
2026-04-14 20:31:55 +00:00
parent e937be01bc
commit 3ac89ae244
3 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ export const WatcherAgent = (
context: AgentLoopContext,
): LocalAgentDefinition<typeof WatcherReportSchema> => {
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',
+6 -3
View File
@@ -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}`,
);
@@ -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');