refactor(core): consolidate execute() arguments into ExecuteOptions (#25101)

This commit is contained in:
Michael Bleigh
2026-04-10 10:11:17 -07:00
committed by GitHub
parent 1d36309f5f
commit 3b7c17a22c
69 changed files with 849 additions and 527 deletions
+38 -16
View File
@@ -135,9 +135,9 @@ describe('ExitPlanModeTool', () => {
expect(result).toBe(false);
// Verify it auto-approved internally
const executeResult = await invocation.execute(
new AbortController().signal,
);
const executeResult = await invocation.execute({
abortSignal: new AbortController().signal,
});
expect(executeResult.llmContent).toContain('Plan approved');
});
@@ -164,7 +164,9 @@ describe('ExitPlanModeTool', () => {
const invocation = tool.build({ plan_filename: planRelativePath });
await invocation.shouldConfirmExecute(new AbortController().signal);
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
expect(result.llmContent).toContain('Plan file is empty');
expect(result.llmContent).toContain('write content to the plan');
@@ -175,7 +177,9 @@ describe('ExitPlanModeTool', () => {
const invocation = tool.build({ plan_filename: planRelativePath });
await invocation.shouldConfirmExecute(new AbortController().signal);
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
expect(result.llmContent).toContain('Plan file does not exist');
});
@@ -197,7 +201,9 @@ describe('ExitPlanModeTool', () => {
approvalMode: ApprovalMode.DEFAULT,
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
const expectedPath = path.join(mockPlansDir, 'test.md');
expect(result).toEqual({
@@ -225,7 +231,9 @@ Read and follow the plan strictly during implementation.`,
approvalMode: ApprovalMode.AUTO_EDIT,
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
const expectedPath = path.join(mockPlansDir, 'test.md');
expect(result).toEqual({
@@ -256,7 +264,9 @@ Read and follow the plan strictly during implementation.`,
feedback: 'Please add more details.',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
const expectedPath = path.join(mockPlansDir, 'test.md');
expect(result).toEqual({
@@ -282,7 +292,9 @@ Revise the plan based on the feedback.`,
approved: false,
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
const expectedPath = path.join(mockPlansDir, 'test.md');
expect(result).toEqual({
@@ -308,7 +320,7 @@ Ask the user for specific feedback on how to improve the plan.`,
approvalMode: ApprovalMode.AUTO_EDIT,
});
await invocation.execute(new AbortController().signal);
await invocation.execute({ abortSignal: new AbortController().signal });
expect(loggers.logPlanExecution).toHaveBeenCalledWith(
mockConfig,
@@ -330,7 +342,9 @@ Ask the user for specific feedback on how to improve the plan.`,
await confirmDetails.onConfirm(ToolConfirmationOutcome.Cancel);
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
expect(result).toEqual({
llmContent:
@@ -348,7 +362,9 @@ Ask the user for specific feedback on how to improve the plan.`,
// Simulate the scheduler's policy ALLOW path: execute() is called
// directly without ever calling shouldConfirmExecute(), leaving
// approvalPayload null.
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
const expectedPath = path.join(mockPlansDir, 'test.md');
expect(result.llmContent).toContain('Plan approved');
@@ -367,7 +383,9 @@ Ask the user for specific feedback on how to improve the plan.`,
const invocation = tool.build({ plan_filename: planRelativePath });
// Directly call execute to trigger the internal getAllowApprovalMode
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
expect(result.llmContent).toContain('YOLO mode');
expect(mockConfig.setApprovalMode).toHaveBeenCalledWith(
@@ -381,7 +399,9 @@ Ask the user for specific feedback on how to improve the plan.`,
const invocation = tool.build({ plan_filename: planRelativePath });
// Directly call execute to trigger the internal getAllowApprovalMode
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
expect(result.llmContent).toContain('Default mode');
expect(mockConfig.setApprovalMode).toHaveBeenCalledWith(
@@ -406,7 +426,9 @@ Ask the user for specific feedback on how to improve the plan.`,
approvalMode: mode,
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});
expect(result.llmContent).toContain(expected);
};
@@ -440,7 +462,7 @@ Ask the user for specific feedback on how to improve the plan.`,
});
await expect(
invocation.execute(new AbortController().signal),
invocation.execute({ abortSignal: new AbortController().signal }),
).rejects.toThrow(/Unexpected approval mode/);
};