refactor(03-02): wire AgentExecutor into AutoModeService

- Add AgentExecutor import to auto-mode-service.ts
- Add agentExecutor as constructor parameter (optional, with default)
- Initialize AgentExecutor with TypedEventBus, FeatureStateManager,
  PlanApprovalService, and SettingsService dependencies

This enables constructor injection for testing and prepares for
incremental delegation of runAgent() logic to AgentExecutor.
The AgentExecutor contains the full execution pipeline;
runAgent() delegation will be done incrementally to ensure
stability.
This commit is contained in:
Shirone
2026-01-27 16:36:28 +01:00
parent d003e9f803
commit a5c02e2418

View File

@@ -91,6 +91,7 @@ import {
detectSpecFallback, detectSpecFallback,
extractSummary, extractSummary,
} from './spec-parser.js'; } from './spec-parser.js';
import { AgentExecutor } from './agent-executor.js';
const execAsync = promisify(exec); const execAsync = promisify(exec);
@@ -209,6 +210,7 @@ export class AutoModeService {
private autoLoopAbortController: AbortController | null = null; private autoLoopAbortController: AbortController | null = null;
private config: AutoModeConfig | null = null; private config: AutoModeConfig | null = null;
private planApprovalService: PlanApprovalService; private planApprovalService: PlanApprovalService;
private agentExecutor: AgentExecutor;
private settingsService: SettingsService | null = null; private settingsService: SettingsService | null = null;
// Track consecutive failures to detect quota/API issues (legacy global, now per-project in autoLoopsByProject) // Track consecutive failures to detect quota/API issues (legacy global, now per-project in autoLoopsByProject)
private consecutiveFailures: { timestamp: number; error: string }[] = []; private consecutiveFailures: { timestamp: number; error: string }[] = [];
@@ -223,7 +225,8 @@ export class AutoModeService {
eventBus?: TypedEventBus, eventBus?: TypedEventBus,
worktreeResolver?: WorktreeResolver, worktreeResolver?: WorktreeResolver,
featureStateManager?: FeatureStateManager, featureStateManager?: FeatureStateManager,
planApprovalService?: PlanApprovalService planApprovalService?: PlanApprovalService,
agentExecutor?: AgentExecutor
) { ) {
this.events = events; this.events = events;
this.eventBus = eventBus ?? new TypedEventBus(events); this.eventBus = eventBus ?? new TypedEventBus(events);
@@ -238,6 +241,15 @@ export class AutoModeService {
this.planApprovalService = this.planApprovalService =
planApprovalService ?? planApprovalService ??
new PlanApprovalService(this.eventBus, this.featureStateManager, this.settingsService); new PlanApprovalService(this.eventBus, this.featureStateManager, this.settingsService);
// AgentExecutor encapsulates the core agent execution pipeline
this.agentExecutor =
agentExecutor ??
new AgentExecutor(
this.eventBus,
this.featureStateManager,
this.planApprovalService,
this.settingsService
);
} }
/** /**