Skip to content

Commit 4d6548e

Browse files
committed
feat(workflows): refactor workflow execution and state management
Introduce new state machine implementation for workflow execution with improved input handling and error management. Replace queue-based execution with a runner class that orchestrates steps using finite state machine patterns. Add new input providers for user and controller input with event-based communication. Implement proper state transitions and error handling throughout the workflow lifecycle. Remove deprecated queue implementation and consolidate execution logic into a single runner class. Add comprehensive type definitions for workflow states and transitions. The changes improve maintainability and provide a more robust foundation for future workflow features like autonomous mode and chained prompts.
1 parent bb8514d commit 4d6548e

File tree

19 files changed

+1454
-1109
lines changed

19 files changed

+1454
-1109
lines changed

src/cli/commands/start.command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export function registerStartCommand(program: Command): void {
2828
// Comprehensive terminal clearing
2929
clearTerminal();
3030

31-
const { runWorkflowQueue } = await import('../../workflows/index.js');
31+
const { runWorkflow } = await import('../../workflows/index.js');
3232
const { ValidationError } = await import('../../runtime/services/validation.js');
3333

3434
try {
35-
await runWorkflowQueue({ cwd, specificationPath });
35+
await runWorkflow({ cwd, specificationPath });
3636
console.log('\n✓ Workflow completed successfully');
3737
process.exit(0);
3838
} catch (error) {

src/cli/tui/app-shell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ export function App(props: { initialToast?: InitialToast }) {
196196
const specPath = path.join(cwd, '.codemachine', 'inputs', 'specifications.md')
197197

198198
pendingWorkflowStart = () => {
199-
import("../../workflows/execution/queue.js").then(({ runWorkflowQueue }) => {
200-
runWorkflowQueue({ cwd, specificationPath: specPath }).catch((error) => {
199+
import("../../workflows/execution/run.js").then(({ runWorkflow }) => {
200+
runWorkflow({ cwd, specificationPath: specPath }).catch((error) => {
201201
// Emit error event to show toast with actual error message
202202
const errorMsg = error instanceof Error ? error.message : String(error)
203203
;(process as NodeJS.EventEmitter).emit('app:error', { message: errorMsg })

src/cli/tui/routes/home/hooks/use-home-commands.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function useHomeCommands(options: UseHomeCommandsOptions) {
6363
const specPath = getAbsoluteSpecPath()
6464

6565
try {
66-
const { validateSpecification } = await import("../../../../../workflows/execution/queue.js")
66+
const { validateSpecification } = await import("../../../../../workflows/execution/run.js")
6767
await validateSpecification(specPath)
6868
} catch (error) {
6969
if (error instanceof Error) {

src/workflows/execution/errors.ts

Lines changed: 0 additions & 122 deletions
This file was deleted.

src/workflows/execution/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from './run.js';
2-
export * from './queue.js';
2+
export * from './runner.js';
33
export * from './step.js';
44
export * from '../behaviors/index.js';

0 commit comments

Comments
 (0)