# Process Engines for Committee

This module implements the core process engines for the Committee project, providing structured execution of AI-assisted workflows.

## Two-Phase Processor

The Two-Phase Processor is the core execution engine that implements the "thinking then response" pattern. It's designed to:

1. Render a thinking prompt template with context
2. Send the thinking prompt to Claude
3. Save the thinking output to a file
4. Enhance the context with the thinking result
5. Render a response prompt with the enhanced context
6. Send the response prompt to Claude
7. Save the response output to a file
8. Return both thinking and response results

### Usage

```typescript
import { runTwoPhaseProcess, TwoPhaseProcessorConfig } from '../processors/two-phase.js';
import { createContext } from '../templates/context.js';

// Create context
const context = createContext();
context.directiveName = 'embed';
context.role = 'architect';

// Run the two-phase process
const result = await runTwoPhaseProcess({
  role: 'architect',
  phase: 'draft-spec-creation',
  thinkingPromptTemplate: 'templates/draft-spec-thinking.md',
  responsePromptTemplate: 'templates/draft-spec-response.md',
  context,
  outputPath: {
    thinking: '_dev/embed/draft-spec-thinking.md',
    response: '_dev/embed/draft-spec.md',
  },
  modelConfig: {
    temperature: 0.7,
    maxTokens: 4000,
  },
});

// Use the results
console.log('Thinking result:', result.thinking);
console.log('Response result:', result.response);
```

### Configuration

The `TwoPhaseProcessorConfig` interface defines the configuration for the two-phase processor:

```typescript
interface TwoPhaseProcessorConfig {
  role: 'service' | 'architect' | 'pm';
  phase: string;
  thinkingPromptTemplate: string;
  responsePromptTemplate: string;
  context: Record<string, any>;
  outputPath: {
    thinking: string;
    response: string;
  };
  modelConfig?: {
    thinkingModel?: string;
    responseModel?: string;
    temperature?: number;
    maxTokens?: number;
  };
}
```

### Utility Functions

The module also includes utilities for working with the two-phase processor:

- `resolveOutputPaths`: Resolves output paths using placeholders
- `mergeModelConfig`: Merges model configuration with defaults
- `createThinkingConfig`: Creates configuration for the thinking phase
- `createResponseConfig`: Creates configuration for the response phase
- `validateConfig`: Validates the two-phase processor configuration

### Testing

You can run the two-phase processor test script to see it in action:

```
npm run test:two-phase
```

This creates sample templates and runs a simple two-phase process, saving the results to the `_dev/test-two-phase` directory.

## Next Steps

Future process engines to be implemented:

1. Feedback Collector
2. Architect Processor
3. Human Review Processor
4. Service Planning Processor
5. Cross-Team Review Processor
6. PM Processor 