feat: implement Claudeman - Claude session manager with Ralph Loop

Claudeman manages multiple Claude CLI sessions as subprocesses with:
- Session management (start/stop/list/logs)
- Priority-based task queue with dependency support
- Ralph Loop for autonomous task assignment and completion detection
- Time-aware loops for extended work sessions
- JSON file persistence to ~/.claudeman/state.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-18 04:50:46 +01:00
co-authored by Claude Opus 4.5
commit e1bb800473
16 changed files with 2830 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
export type SessionStatus = 'idle' | 'busy' | 'stopped' | 'error';
export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed';
export type RalphLoopStatus = 'stopped' | 'running' | 'paused';
export interface SessionConfig {
id: string;
workingDir: string;
createdAt: number;
}
export interface SessionState {
id: string;
pid: number | null;
status: SessionStatus;
workingDir: string;
currentTaskId: string | null;
createdAt: number;
lastActivityAt: number;
}
export interface TaskDefinition {
id: string;
prompt: string;
workingDir: string;
priority: number;
dependencies: string[];
completionPhrase?: string;
timeoutMs?: number;
}
export interface TaskState {
id: string;
prompt: string;
workingDir: string;
priority: number;
dependencies: string[];
completionPhrase?: string;
timeoutMs?: number;
status: TaskStatus;
assignedSessionId: string | null;
createdAt: number;
startedAt: number | null;
completedAt: number | null;
output: string;
error: string | null;
}
export interface RalphLoopState {
status: RalphLoopStatus;
startedAt: number | null;
minDurationMs: number | null;
tasksCompleted: number;
tasksGenerated: number;
lastCheckAt: number | null;
}
export interface AppState {
sessions: Record<string, SessionState>;
tasks: Record<string, TaskState>;
ralphLoop: RalphLoopState;
config: AppConfig;
}
export interface AppConfig {
pollIntervalMs: number;
defaultTimeoutMs: number;
maxConcurrentSessions: number;
stateFilePath: string;
}
export interface SessionOutput {
stdout: string;
stderr: string;
exitCode: number | null;
}
export interface TaskAssignment {
sessionId: string;
taskId: string;
assignedAt: number;
}
export const DEFAULT_CONFIG: AppConfig = {
pollIntervalMs: 1000,
defaultTimeoutMs: 300000, // 5 minutes
maxConcurrentSessions: 5,
stateFilePath: '',
};
export function createInitialState(): AppState {
return {
sessions: {},
tasks: {},
ralphLoop: {
status: 'stopped',
startedAt: null,
minDurationMs: null,
tasksCompleted: 0,
tasksGenerated: 0,
lastCheckAt: null,
},
config: { ...DEFAULT_CONFIG },
};
}