mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 23:31:13 -07:00
feat(plan): create a metric for execution of plans generated in plan mode (#18236)
This commit is contained in:
@@ -15,6 +15,11 @@ import { ApprovalMode } from '../policy/types.js';
|
||||
import * as fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import { validatePlanPath } from '../utils/planUtils.js';
|
||||
import * as loggers from '../telemetry/loggers.js';
|
||||
|
||||
vi.mock('../telemetry/loggers.js', () => ({
|
||||
logPlanExecution: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('ExitPlanModeTool', () => {
|
||||
let tool: ExitPlanModeTool;
|
||||
@@ -288,6 +293,30 @@ Ask the user for specific feedback on how to improve the plan.`,
|
||||
});
|
||||
});
|
||||
|
||||
it('should log plan execution event when plan is approved', async () => {
|
||||
const planRelativePath = createPlanFile('test.md', '# Content');
|
||||
const invocation = tool.build({ plan_path: planRelativePath });
|
||||
|
||||
const confirmDetails = await invocation.shouldConfirmExecute(
|
||||
new AbortController().signal,
|
||||
);
|
||||
if (confirmDetails === false) return;
|
||||
|
||||
await confirmDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce, {
|
||||
approved: true,
|
||||
approvalMode: ApprovalMode.AUTO_EDIT,
|
||||
});
|
||||
|
||||
await invocation.execute(new AbortController().signal);
|
||||
|
||||
expect(loggers.logPlanExecution).toHaveBeenCalledWith(
|
||||
mockConfig,
|
||||
expect.objectContaining({
|
||||
approval_mode: ApprovalMode.AUTO_EDIT,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should return cancellation message when cancelled', async () => {
|
||||
const planRelativePath = createPlanFile('test.md', '# Content');
|
||||
const invocation = tool.build({ plan_path: planRelativePath });
|
||||
|
||||
@@ -22,6 +22,8 @@ import { validatePlanPath, validatePlanContent } from '../utils/planUtils.js';
|
||||
import { ApprovalMode } from '../policy/types.js';
|
||||
import { checkExhaustive } from '../utils/checks.js';
|
||||
import { resolveToRealPath, isSubpath } from '../utils/paths.js';
|
||||
import { logPlanExecution } from '../telemetry/loggers.js';
|
||||
import { PlanExecutionEvent } from '../telemetry/types.js';
|
||||
|
||||
/**
|
||||
* Returns a human-readable description for an approval mode.
|
||||
@@ -226,6 +228,8 @@ export class ExitPlanModeInvocation extends BaseToolInvocation<
|
||||
this.config.setApprovalMode(newMode);
|
||||
this.config.setApprovedPlanPath(resolvedPlanPath);
|
||||
|
||||
logPlanExecution(this.config, new PlanExecutionEvent(newMode));
|
||||
|
||||
const description = getApprovalModeDescription(newMode);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user