/** * State types and file helpers for mission-control * * Types for state.json, run.json, and file read/write operations. * All tool mutations go through here. */ export type PhaseStatus = "pending" | "in_progress" | "done" | "removed"; export type TaskStatus = "pending" | "in_progress" | "done" | "failed" | "removed"; export type RunStatus = "in_progress" | "done" | "failed" | "paused"; /** * Volatile UI state - stored in .pi/mission-control/state.json * Resets on every new pi session */ export interface State { active_run_id: string | null; current_phase: string; current_status_message: string; } /** * Task artifact paths */ export interface TaskPaths { contract: string; worker_output: string; auditor_report: string; } /** * Task definition - stored within Phase in run.json */ export interface Task { id: string; name: string; status: TaskStatus; started_at: string | null; finish_at: string | null; file: string; paths: TaskPaths; } /** * Phase definition - stored in run.json */ export interface Phase { id: string; name: string; status: PhaseStatus; started_at: string | null; finish_at: string | null; file: string; tasks: Task[]; } /** * Artifact references in run.json */ export interface Artifacts { requirements: string; architecture: string; validation: string; } /** * Persistent run state - stored in .pi/mission-control/runs//run.json */ export interface Run { run_id: string; started_at: string; finish_at: string | null; status: RunStatus; artifacts: Artifacts; phases: Phase[]; } export declare const defaultState: State; /** * Get the project root (cwd) */ export declare function getProjectRoot(): string; /** * Get the base mission-control directory path */ export declare function getMissionControlDir(): string; /** * Get the state.json file path */ export declare function getStateFilePath(): string; /** * Get the memory directory path */ export declare function getMemoryDir(): string; /** * Get the long-term memory file path */ export declare function getLongTermMemoryPath(): string; /** * Get the runs directory path */ export declare function getRunsDir(): string; /** * Get a specific run directory path */ export declare function getRunDir(runId: string): string; /** * Get the run.json file path for a specific run */ export declare function getRunFilePath(runId: string): string; /** * Get the tasks directory path for a specific run */ export declare function getTasksDir(runId: string): string; /** * Get a specific task directory path */ export declare function getTaskDir(runId: string, taskId: string): string; /** * Ensure a directory exists (recursive) */ export declare function ensureDir(dirPath: string): void; /** * Read and parse JSON file */ export declare function readJson(filePath: string): T | null; /** * Write JSON file (with pretty formatting) */ export declare function writeJson(filePath: string, data: T): void; /** * Read a text file */ export declare function readText(filePath: string): string | null; /** * Write a text file */ export declare function writeText(filePath: string, content: string): void; /** * Check if a file exists */ export declare function fileExists(filePath: string): boolean; /** * Copy a file from source to destination (skip if exists when specified) */ export declare function copyFile(src: string, dest: string, skipIfExists?: boolean): boolean; /** * Copy a directory recursively (skip existing files when specified) * Returns count of files copied */ export declare function copyDir(src: string, dest: string, skipIfExists?: boolean): number; /** * Read the current state.json * Returns default state if file doesn't exist */ export declare function readState(): State; /** * Write state.json */ export declare function writeState(state: State): void; /** * Update specific fields in state.json */ export declare function updateState(updates: Partial): State; /** * Read a run.json file */ export declare function readRun(runId: string): Run | null; /** * Write a run.json file */ export declare function writeRun(run: Run): void; /** * Update specific fields in a run */ export declare function updateRun(runId: string, updates: Partial): Run | null; /** * Get current ISO timestamp */ export declare function getTimestamp(): string; /** * Generate a run ID from current timestamp * Format: run-YYYYMMDD-HHmmss */ export declare function generateRunId(): string; /** * Find a phase by ID in a run */ export declare function findPhase(run: Run, phaseId: string): Phase | undefined; /** * Generate the next phase ID */ export declare function generatePhaseId(run: Run): string; /** * Create a new phase */ export declare function createPhase(id: string, name: string, file: string): Phase; /** * Add a phase to a run */ export declare function addPhaseToRun(run: Run, phase: Phase): Run; /** * Update a phase in a run */ export declare function updatePhaseInRun(run: Run, phaseId: string, updates: Partial): Run; /** * Find a task by ID in a run (searches all phases) */ export declare function findTask(run: Run, taskId: string): { phase: Phase; task: Task; phaseIndex: number; taskIndex: number; } | null; /** * Generate the next task ID for a phase */ export declare function generateTaskId(phase: Phase): string; /** * Create a new task */ export declare function createTask(id: string, name: string, file: string): Task; /** * Add a task to a phase within a run */ export declare function addTaskToRun(run: Run, phaseId: string, task: Task): Run; /** * Update a task in a run */ export declare function updateTaskInRun(run: Run, taskId: string, updates: Partial): Run; /** * Check if all tasks in a phase are done */ export declare function areAllTasksDone(phase: Phase): boolean; /** * Check if all phases in a run are done */ export declare function areAllPhasesDone(run: Run): boolean; /** * List all run IDs in the runs directory */ export declare function listRunIds(): string[]; /** * List all runs with their basic info */ export declare function listRuns(): Array<{ runId: string; run: Run | null; }>; /** * Check if mission-control has been scaffolded */ export declare function isScaffolded(): boolean; /** * Create the initial run.json structure */ export declare function createInitialRun(runId: string): Run; /** * Create the base mission-control directory structure */ export declare function createBaseStructure(): void; /** * Create a new run directory structure */ export declare function createRunStructure(runId: string): void; /** * Get the appropriate timestamp field to update based on status */ export declare function getTimestampForStatus(status: PhaseStatus | TaskStatus, currentStatus: PhaseStatus | TaskStatus): { started_at?: string; finish_at?: string; } | null; //# sourceMappingURL=state.d.ts.map