Fix the subagents eval.

This commit is contained in:
Christian Gunderman
2026-02-02 23:51:06 -08:00
parent 5be38c3a27
commit 849b3b255c
4 changed files with 37 additions and 2 deletions
+27 -1
View File
@@ -11,8 +11,13 @@ import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { env } from 'node:process';
import { setTimeout as sleep } from 'node:timers/promises';
import { DEFAULT_GEMINI_MODEL, GEMINI_DIR } from '@google/gemini-cli-core';
import {
DEFAULT_GEMINI_MODEL,
GEMINI_DIR,
AcknowledgedAgentsService,
} from '@google/gemini-cli-core';
import fs from 'node:fs';
import crypto from 'node:crypto';
import * as pty from '@lydell/node-pty';
import stripAnsi from 'strip-ansi';
import * as os from 'node:os';
@@ -356,6 +361,27 @@ export class TestRig {
);
}
async acknowledgeAgents(agents: Record<string, string>) {
// Use realpath to ensure the path matches what the CLI sees (e.g. /var vs /private/var on macOS)
const projectRoot = fs.realpathSync(this.testDir!);
const originalHome = process.env['GEMINI_CLI_HOME'];
process.env['GEMINI_CLI_HOME'] = this.homeDir!;
try {
const service = new AcknowledgedAgentsService();
for (const [name, content] of Object.entries(agents)) {
const hash = crypto.createHash('sha256').update(content).digest('hex');
await service.acknowledge(projectRoot, name, hash);
}
} finally {
if (originalHome) {
process.env['GEMINI_CLI_HOME'] = originalHome;
} else {
delete process.env['GEMINI_CLI_HOME'];
}
}
}
createFile(fileName: string, content: string) {
const filePath = join(this.testDir!, fileName);
writeFileSync(filePath, content);