mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-18 22:33:08 +00:00
refactor: Improve all git operations, add stash support, add improved pull request flow, add worktree file copy options, address code review comments, add cherry pick options
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import type { Feature } from '@automaker/types';
|
||||
import { createLogger, classifyError } from '@automaker/utils';
|
||||
import { areDependenciesSatisfied } from '@automaker/dependency-resolver';
|
||||
import type { TypedEventBus } from './typed-event-bus.js';
|
||||
import type { ConcurrencyManager } from './concurrency-manager.js';
|
||||
import type { SettingsService } from './settings-service.js';
|
||||
@@ -64,6 +65,7 @@ export type ClearExecutionStateFn = (
|
||||
) => Promise<void>;
|
||||
export type ResetStuckFeaturesFn = (projectPath: string) => Promise<void>;
|
||||
export type IsFeatureFinishedFn = (feature: Feature) => boolean;
|
||||
export type LoadAllFeaturesFn = (projectPath: string) => Promise<Feature[]>;
|
||||
|
||||
export class AutoLoopCoordinator {
|
||||
private autoLoopsByProject = new Map<string, ProjectAutoLoopState>();
|
||||
@@ -78,7 +80,8 @@ export class AutoLoopCoordinator {
|
||||
private clearExecutionStateFn: ClearExecutionStateFn,
|
||||
private resetStuckFeaturesFn: ResetStuckFeaturesFn,
|
||||
private isFeatureFinishedFn: IsFeatureFinishedFn,
|
||||
private isFeatureRunningFn: (featureId: string) => boolean
|
||||
private isFeatureRunningFn: (featureId: string) => boolean,
|
||||
private loadAllFeaturesFn?: LoadAllFeaturesFn
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -178,9 +181,31 @@ export class AutoLoopCoordinator {
|
||||
await this.sleep(10000, projectState.abortController.signal);
|
||||
continue;
|
||||
}
|
||||
const nextFeature = pendingFeatures.find(
|
||||
(f) => !this.isFeatureRunningFn(f.id) && !this.isFeatureFinishedFn(f)
|
||||
|
||||
// Load all features for dependency checking (if callback provided)
|
||||
const allFeatures = this.loadAllFeaturesFn
|
||||
? await this.loadAllFeaturesFn(projectPath)
|
||||
: pendingFeatures;
|
||||
|
||||
// Filter to eligible features: not running, not finished, and dependencies satisfied
|
||||
const eligibleFeatures = pendingFeatures.filter(
|
||||
(f) =>
|
||||
!this.isFeatureRunningFn(f.id) &&
|
||||
!this.isFeatureFinishedFn(f) &&
|
||||
areDependenciesSatisfied(f, allFeatures)
|
||||
);
|
||||
|
||||
// Sort eligible features by priority (lower number = higher priority, default 2)
|
||||
eligibleFeatures.sort((a, b) => (a.priority ?? 2) - (b.priority ?? 2));
|
||||
|
||||
const nextFeature = eligibleFeatures[0] ?? null;
|
||||
|
||||
if (nextFeature) {
|
||||
logger.info(
|
||||
`Auto-loop selected feature "${nextFeature.title || nextFeature.id}" ` +
|
||||
`(priority=${nextFeature.priority ?? 2}) from ${eligibleFeatures.length} eligible features`
|
||||
);
|
||||
}
|
||||
if (nextFeature) {
|
||||
projectState.hasEmittedIdleEvent = false;
|
||||
this.executeFeatureFn(
|
||||
|
||||
Reference in New Issue
Block a user