cmte
Version:
Design by Committee™ except it's just you and LLMs
72 lines (67 loc) • 1.65 kB
JavaScript
/**
* Simplified state management for Committee
*
* This module implements minimal in-memory state management for tracking workflow context
* and progress.
*/
import fs from 'fs/promises';
import path from 'path';
import yaml from 'js-yaml';
import { logger } from '../../utils/logger.js';
/**
* Create a new empty state
*/
export function createEmptyState() {
return {
context: {},
progress: []
};
}
/**
* Add a new progress entry to the state
* @param state The current state
* @param phaseId The ID of the phase that was completed
* @param setId The ID of the set that was completed
* @param context The context at the time of completion
* @returns A new state with the added progress entry
*/
export function addProgressEntry(state, phaseId, setId, context) {
return {
...state,
progress: [
...state.progress,
{
phaseId,
setId,
timestamp: Date.now(),
context
}
],
context: context || state.context
};
}
/**
* Check if a set has been completed
* @param state The state
* @param phaseId The phase ID
* @param setId The set ID
* @returns True if the set has been completed
*/
export function isSetCompleted(state, phaseId, setId) {
return state.progress.some(entry => entry.phaseId === phaseId && entry.setId === setId);
}
/**
* Update the context in the state
* @param state The current state
* @param newContext The new context to merge
* @returns A new state with updated context
*/
export function updateContext(state, newContext) {
return {
...state,
context: {
...state.context,
...newContext
}
};
}