diff --git a/CLAUDE.md b/CLAUDE.md index 1b060c44..204f7250 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -90,7 +90,7 @@ Codeman is a Claude Code session manager with web interface and autonomous Ralph - **Single-line prompts only** — `writeViaMux()` sends text+Enter separately; multi-line breaks Ink - **ESM only** — Never `require()`, use `await import()`. `tsx` masks CJS/ESM issues in dev but production breaks - **Package ≠ product name** — npm: `aicodeman`, product: **Codeman**. Release renames tags accordingly -- **Global regex `lastIndex`** — Use `createAnsiPatternFull/Simple()` factories, not shared `g`-flag patterns in loops +- **Global regex `lastIndex`** — Shared `g`-flag patterns in loops must reset `lastIndex = 0` first, or use the `execPattern()` helper in `utils/regex-patterns.ts` (resets automatically) **Import conventions**: Utils from `./utils`, types from `./types` (barrel), config from specific `./config/*` files. diff --git a/src/ai-idle-checker.ts b/src/ai-idle-checker.ts index a4940c0e..4b462aec 100644 --- a/src/ai-idle-checker.ts +++ b/src/ai-idle-checker.ts @@ -41,7 +41,7 @@ import { // ========== Types ========== -export type AiIdleCheckConfig = AiCheckerConfigBase; +type AiIdleCheckConfig = AiCheckerConfigBase; export type AiCheckVerdict = 'IDLE' | 'WORKING' | 'ERROR'; diff --git a/src/ai-plan-checker.ts b/src/ai-plan-checker.ts index c03b0ce2..711c98a4 100644 --- a/src/ai-plan-checker.ts +++ b/src/ai-plan-checker.ts @@ -40,13 +40,13 @@ import { // ========== Types ========== -export type AiPlanCheckConfig = AiCheckerConfigBase; +type AiPlanCheckConfig = AiCheckerConfigBase; export type AiPlanCheckVerdict = 'PLAN_MODE' | 'NOT_PLAN_MODE' | 'ERROR'; export type AiPlanCheckResult = AiCheckerResultBase; -export type AiPlanCheckState = AiCheckerStateBase; +type AiPlanCheckState = AiCheckerStateBase; // ========== Constants ========== diff --git a/src/bash-tool-parser.ts b/src/bash-tool-parser.ts index 76586c4e..bb89e3e9 100644 --- a/src/bash-tool-parser.ts +++ b/src/bash-tool-parser.ts @@ -99,7 +99,7 @@ const LOG_FILE_MENTION_PATTERN = /([/~][^\s'"<>|;&\n]*(?:\.log|\.txt|\.out|\/log /** * Events emitted by BashToolParser. */ -export interface BashToolParserEvents { +interface BashToolParserEvents { /** New Bash tool with file paths started */ toolStart: [tool: ActiveBashTool]; /** Bash tool completed */ @@ -111,7 +111,7 @@ export interface BashToolParserEvents { /** * Configuration options for BashToolParser. */ -export interface BashToolParserConfig { +interface BashToolParserConfig { /** Session ID this parser belongs to */ sessionId: string; /** Whether the parser is enabled (default: true) */ diff --git a/src/file-stream-manager.ts b/src/file-stream-manager.ts index 1d28b112..342350f7 100644 --- a/src/file-stream-manager.ts +++ b/src/file-stream-manager.ts @@ -48,7 +48,7 @@ const STREAM_INACTIVITY_TIMEOUT_MS = INACTIVITY_TIMEOUT_MS; /** * Represents an active file stream. */ -export interface FileStream { +interface FileStream { /** Unique stream identifier */ id: string; /** Session this stream belongs to */ @@ -74,7 +74,7 @@ export interface FileStream { /** * Options for creating a file stream. */ -export interface CreateStreamOptions { +interface CreateStreamOptions { /** Session ID requesting the stream */ sessionId: string; /** Path to the file to stream */ @@ -94,7 +94,7 @@ export interface CreateStreamOptions { /** * Result of creating a stream. */ -export interface CreateStreamResult { +interface CreateStreamResult { success: boolean; streamId?: string; error?: string; diff --git a/src/image-watcher.ts b/src/image-watcher.ts index 280dba9b..35454909 100644 --- a/src/image-watcher.ts +++ b/src/image-watcher.ts @@ -17,11 +17,6 @@ import { KeyedDebouncer } from './utils/index.js'; // ========== Types ========== -export interface ImageWatcherEvents { - 'image:detected': (event: ImageDetectedEvent) => void; - 'image:error': (error: Error, sessionId?: string) => void; -} - // ========== Constants ========== /** Supported image file extensions (lowercase) */ diff --git a/src/orchestrator-loop.ts b/src/orchestrator-loop.ts index 2d7ccdc2..97737211 100644 --- a/src/orchestrator-loop.ts +++ b/src/orchestrator-loop.ts @@ -60,21 +60,6 @@ const POST_PHASE_DELAY_MS = 1000; // Events // ═══════════════════════════════════════════════════════════════ -export interface OrchestratorLoopEvents { - stateChanged: (state: OrchestratorState, prevState: OrchestratorState) => void; - planProgress: (phase: string, detail: string) => void; - planReady: (plan: OrchestratorPlan) => void; - phaseStarted: (phase: OrchestratorPhase) => void; - phaseCompleted: (phase: OrchestratorPhase) => void; - phaseFailed: (phase: OrchestratorPhase, reason: string) => void; - taskAssigned: (task: OrchestratorTask, sessionId: string) => void; - taskCompleted: (task: OrchestratorTask) => void; - taskFailed: (task: OrchestratorTask, error: string) => void; - verificationResult: (phase: OrchestratorPhase, result: VerificationResult) => void; - completed: (stats: OrchestratorStats) => void; - error: (error: Error) => void; -} - // ═══════════════════════════════════════════════════════════════ // OrchestratorLoop // ═══════════════════════════════════════════════════════════════ diff --git a/src/plan-orchestrator.ts b/src/plan-orchestrator.ts index fbed932f..5edddb1e 100644 --- a/src/plan-orchestrator.ts +++ b/src/plan-orchestrator.ts @@ -68,7 +68,7 @@ export interface DetailedPlanResult { export type ProgressCallback = (phase: string, detail: string) => void; -export interface PlanSubagentEvent { +interface PlanSubagentEvent { type: 'started' | 'progress' | 'completed' | 'failed'; agentId: string; agentType: 'research' | 'planner'; @@ -80,7 +80,7 @@ export interface PlanSubagentEvent { error?: string; } -export type SubagentCallback = (event: PlanSubagentEvent) => void; +type SubagentCallback = (event: PlanSubagentEvent) => void; // ============================================================================ // JSON Repair Helper diff --git a/src/prompts/index.ts b/src/prompts/index.ts index 281e48c3..9d881357 100644 --- a/src/prompts/index.ts +++ b/src/prompts/index.ts @@ -7,10 +7,4 @@ export { RESEARCH_AGENT_PROMPT } from './research-agent.js'; export { PLANNER_PROMPT } from './planner.js'; -export { - PHASE_EXECUTION_PROMPT, - TEAM_LEAD_PROMPT, - VERIFICATION_PROMPT, - REPLAN_PROMPT, - SINGLE_TASK_PROMPT, -} from './orchestrator.js'; +export { PHASE_EXECUTION_PROMPT, TEAM_LEAD_PROMPT, REPLAN_PROMPT, SINGLE_TASK_PROMPT } from './orchestrator.js'; diff --git a/src/prompts/orchestrator.ts b/src/prompts/orchestrator.ts index dafcf161..1c71e66a 100644 --- a/src/prompts/orchestrator.ts +++ b/src/prompts/orchestrator.ts @@ -57,22 +57,6 @@ Suggested teammate roles: Each teammate should focus on their assigned task area. Monitor their progress. When ALL tasks are complete and you've verified the results, output: {COMPLETION_PHRASE}`; -/** - * Verification prompt — asks Claude to verify phase completion. - * - * Placeholders: - * - {PHASE_NAME}: Phase name - * - {CRITERIA}: Numbered verification criteria - * - {PASS_PHRASE}: Phrase to output on success - * - {FAIL_PHRASE}: Phrase to output on failure - */ -export const VERIFICATION_PROMPT = `Review the work done in "{PHASE_NAME}". Check these criteria: - -{CRITERIA} - -If ALL criteria are met, respond with: {PASS_PHRASE} -If ANY criteria fail, respond with: {FAIL_PHRASE} and explain what failed.`; - /** * Replan prompt — gives failure context and asks for recovery. * diff --git a/src/ralph-config.ts b/src/ralph-config.ts index bf7c0704..eb36284c 100644 --- a/src/ralph-config.ts +++ b/src/ralph-config.ts @@ -24,7 +24,7 @@ const YAML_LINE_PATTERN = /^([a-zA-Z_-]+):\s*"?([^"\n]+)"?\s*$/gm; /** * Ralph Loop configuration from .claude/ralph-loop.local.md */ -export interface RalphLoopConfig { +interface RalphLoopConfig { enabled: boolean; iteration: number; maxIterations: number | null; diff --git a/src/ralph-loop.ts b/src/ralph-loop.ts index 651c940b..346a2955 100644 --- a/src/ralph-loop.ts +++ b/src/ralph-loop.ts @@ -34,19 +34,11 @@ import { RalphLoopStatus, getErrorMessage } from './types.js'; /** * Events emitted by RalphLoop */ -export interface RalphLoopEvents { - started: () => void; - stopped: () => void; - taskAssigned: (taskId: string, sessionId: string) => void; - taskCompleted: (taskId: string) => void; - taskFailed: (taskId: string, error: string) => void; - error: (error: Error) => void; -} /** * Configuration options for RalphLoop */ -export interface RalphLoopOptions { +interface RalphLoopOptions { /** How often to check for new tasks (default from config) */ pollIntervalMs?: number; /** Minimum time to run before stopping (null = no minimum) */ diff --git a/src/ralph-tracker.ts b/src/ralph-tracker.ts index 8cf5a4c0..eacf24c9 100644 --- a/src/ralph-tracker.ts +++ b/src/ralph-tracker.ts @@ -19,7 +19,6 @@ * Key exports: * - `RalphTracker` class — main tracker, extends EventEmitter * - `RalphTrackerEvents` interface — typed event map - * - Re-exports: `EnhancedPlanTask`, `CheckpointReview` from ralph-plan-tracker * * Key methods: `processData(data)` — feed terminal output, `getState()`, * `getTodos()`, `getCompletionHistory()`, `getPlanTasks()`, `reset()` @@ -66,9 +65,6 @@ import { RalphStallDetector } from './ralph-stall-detector.js'; import { RalphStatusParser } from './ralph-status-parser.js'; import { STALE_DATA_MAX_AGE_MS, INACTIVITY_TIMEOUT_MS } from './config/server-timing.js'; -// Re-export sub-module types for backward compatibility -export type { EnhancedPlanTask, CheckpointReview } from './ralph-plan-tracker.js'; - // ========== Configuration Constants ========== // Note: MAX_TODOS_PER_SESSION and MAX_LINE_BUFFER_SIZE are imported from config modules @@ -390,32 +386,6 @@ const P2_PRIORITY_PATTERNS = [ * @event circuitBreakerUpdate - Fired when circuit breaker state changes * @event exitGateMet - Fired when dual-condition exit gate is met */ -export interface RalphTrackerEvents { - /** Emitted when loop state changes */ - loopUpdate: (state: RalphTrackerState) => void; - /** Emitted when todo list is modified */ - todoUpdate: (todos: RalphTodoItem[]) => void; - /** Emitted when completion phrase detected (loop finished) */ - completionDetected: (phrase: string) => void; - /** Emitted when tracker auto-enables from disabled state */ - enabled: () => void; - /** Emitted when a RALPH_STATUS block is parsed */ - statusBlockDetected: (block: RalphStatusBlock) => void; - /** Emitted when circuit breaker state changes */ - circuitBreakerUpdate: (status: CircuitBreakerStatus) => void; - /** Emitted when dual-condition exit gate is met (completion indicators >= 2 AND EXIT_SIGNAL: true) */ - exitGateMet: (data: { completionIndicators: number; exitSignal: boolean }) => void; - /** Emitted when iteration count hasn't changed for an extended period (stall warning) */ - iterationStallWarning: (data: { iteration: number; stallDurationMs: number }) => void; - /** Emitted when iteration count hasn't changed for critical period (stall critical) */ - iterationStallCritical: (data: { iteration: number; stallDurationMs: number }) => void; - /** Emitted when a common/risky completion phrase is detected (P1-002) */ - phraseValidationWarning: (data: { - phrase: string; - reason: 'common' | 'short' | 'numeric'; - suggestedPhrase: string; - }) => void; -} /** * RalphTracker - Parses terminal output to detect Ralph Wiggum loops and todos diff --git a/src/respawn-controller.ts b/src/respawn-controller.ts index f80155c3..6ed14dac 100644 --- a/src/respawn-controller.ts +++ b/src/respawn-controller.ts @@ -27,7 +27,7 @@ * - `RespawnController` class — state machine, extends EventEmitter * - `RespawnConfig` interface — all configuration options * - `RespawnState` type — union of all state machine states - * - `DetectionStatus`, `ActiveTimerInfo`, `RespawnEvents` — status/event types + * - `DetectionStatus`, `ActiveTimerInfo` — status types * * Key methods: `start()`, `stop()`, `getStatus()`, `getConfig()`, * `getDetectionStatus()`, `getActiveTimers()`, `getAggregateMetrics()`, @@ -46,8 +46,8 @@ import { EventEmitter } from 'node:events'; import { randomUUID } from 'node:crypto'; import { Session } from './session.js'; -import { AiIdleChecker, type AiCheckResult, type AiCheckState } from './ai-idle-checker.js'; -import { AiPlanChecker, type AiPlanCheckResult } from './ai-plan-checker.js'; +import { AiIdleChecker, type AiCheckState } from './ai-idle-checker.js'; +import { AiPlanChecker } from './ai-plan-checker.js'; import type { TeamWatcher } from './team-watcher.js'; import { BufferAccumulator, ANSI_ESCAPE_PATTERN_SIMPLE, assertNever, CleanupManager } from './utils/index.js'; import { MAX_RESPAWN_BUFFER_SIZE, TRIM_RESPAWN_BUFFER_TO as RESPAWN_BUFFER_TRIM_SIZE } from './config/buffer-limits.js'; @@ -99,13 +99,13 @@ const PLAN_MODE_SELECTOR_PATTERN = /[❯>]\s*\d+\./; * Each layer provides a confidence signal that Claude has finished working. */ /** Active timer info for UI display */ -export interface ActiveTimerInfo { +interface ActiveTimerInfo { name: string; remainingMs: number; totalMs: number; } -export interface DetectionStatus { +interface DetectionStatus { /** Layer 0: Stop hook received (highest priority - definitive signal) */ stopHookReceived: boolean; /** Timestamp when Stop hook was received */ @@ -488,70 +488,13 @@ export interface RespawnConfig { * @event error - Fired on errors * @event log - Fired for debug logging */ -/** Timer info for countdown display */ -export interface TimerInfo { - name: string; - durationMs: number; - endsAt: number; - reason?: string; -} - /** Action log entry for detailed UI feedback */ -export interface ActionLogEntry { +interface ActionLogEntry { type: string; detail: string; timestamp: number; } -export interface RespawnEvents { - /** State machine transition */ - stateChanged: (state: RespawnState, prevState: RespawnState) => void; - /** New respawn cycle started */ - respawnCycleStarted: (cycleNumber: number) => void; - /** Respawn cycle finished */ - respawnCycleCompleted: (cycleNumber: number) => void; - /** Command sent to session */ - stepSent: (step: string, input: string) => void; - /** Step completed (ready indicator detected) */ - stepCompleted: (step: string) => void; - /** Detection status update for UI display */ - detectionUpdate: (status: DetectionStatus) => void; - /** Auto-accept sent for plan mode approval */ - autoAcceptSent: () => void; - /** AI idle check started */ - aiCheckStarted: () => void; - /** AI idle check completed with verdict */ - aiCheckCompleted: (result: AiCheckResult) => void; - /** AI idle check failed */ - aiCheckFailed: (error: string) => void; - /** AI idle check cooldown state changed */ - aiCheckCooldown: (active: boolean, endsAt: number | null) => void; - /** AI plan check started */ - planCheckStarted: () => void; - /** AI plan check completed with verdict */ - planCheckCompleted: (result: AiPlanCheckResult) => void; - /** AI plan check failed */ - planCheckFailed: (error: string) => void; - /** Timer started for countdown display */ - timerStarted: (timer: TimerInfo) => void; - /** Timer cancelled */ - timerCancelled: (timerName: string, reason?: string) => void; - /** Timer completed */ - timerCompleted: (timerName: string) => void; - /** Verbose action log for detailed UI feedback */ - actionLog: (action: ActionLogEntry) => void; - /** Error occurred */ - error: (error: Error) => void; - /** Debug log message */ - log: (message: string) => void; - /** Stuck state warning emitted */ - stuckStateWarning: (state: RespawnState, durationMs: number) => void; - /** Stuck state recovery triggered */ - stuckStateRecovery: (state: RespawnState, durationMs: number, attempt: number) => void; - /** Respawn blocked by external signal */ - respawnBlocked: (data: { reason: string; details: string }) => void; -} - /** * Convert milliseconds to a non-negative whole number of seconds for countdown display. * Rounds up so that e.g. 1200 ms shows as 2 s (never under-reports remaining time). diff --git a/src/session-auto-ops.ts b/src/session-auto-ops.ts index 48d3f61f..8bbadb53 100644 --- a/src/session-auto-ops.ts +++ b/src/session-auto-ops.ts @@ -93,7 +93,7 @@ const DEFAULT_AUTO_COMPACT_THRESHOLD = 110_000; /** * Callbacks required by SessionAutoOps to interact with the parent Session. */ -export interface AutoOpsCallbacks { +interface AutoOpsCallbacks { /** Send a command via the terminal multiplexer */ writeCommand: (command: string) => Promise; /** Check if Claude is currently working */ @@ -109,12 +109,6 @@ export interface AutoOpsCallbacks { /** * Events emitted by SessionAutoOps. */ -export interface SessionAutoOpsEvents { - /** Auto-compact was triggered and the /compact command was sent */ - autoCompact: (data: { tokens: number; threshold: number; prompt?: string }) => void; - /** Auto-clear was triggered and the /clear command was sent */ - autoClear: (data: { tokens: number; threshold: number }) => void; -} /** * Manages auto-compact and auto-clear automation for a Session. diff --git a/src/session-cli-builder.ts b/src/session-cli-builder.ts index efc58c7f..afc538c3 100644 --- a/src/session-cli-builder.ts +++ b/src/session-cli-builder.ts @@ -15,7 +15,7 @@ import { getAugmentedPath } from './utils/index.js'; * Build Claude CLI permission flags based on the configured mode. * Returns an array of args to pass to the CLI. */ -export function buildPermissionArgs(claudeMode: ClaudeMode, allowedTools?: string): string[] { +function buildPermissionArgs(claudeMode: ClaudeMode, allowedTools?: string): string[] { switch (claudeMode) { case 'dangerously-skip-permissions': return ['--dangerously-skip-permissions']; diff --git a/src/session-manager.ts b/src/session-manager.ts index ad645e6a..5f813c82 100644 --- a/src/session-manager.ts +++ b/src/session-manager.ts @@ -30,18 +30,6 @@ import { SessionState } from './types.js'; /** * Events emitted by SessionManager */ -export interface SessionManagerEvents { - /** Fired when a new session starts successfully */ - sessionStarted: (session: Session) => void; - /** Fired when a session stops (graceful or forced) */ - sessionStopped: (sessionId: string) => void; - /** Fired when a session encounters an error */ - sessionError: (sessionId: string, error: string) => void; - /** Fired when a session produces terminal output */ - sessionOutput: (sessionId: string, output: string) => void; - /** Fired when a completion phrase is detected */ - sessionCompletion: (sessionId: string, phrase: string) => void; -} /** * Manages multiple Claude sessions with lifecycle coordination. diff --git a/src/session.ts b/src/session.ts index a47270a2..6a498fcb 100644 --- a/src/session.ts +++ b/src/session.ts @@ -154,63 +154,6 @@ export interface ClaudeMessage { * Event signatures emitted by the Session class. * Subscribe using `session.on('eventName', handler)`. */ -export interface SessionEvents { - /** Processed text output (ANSI stripped) */ - output: (data: string) => void; - /** Parsed JSON message from Claude CLI */ - message: (msg: ClaudeMessage) => void; - /** Error output from the session */ - error: (data: string) => void; - /** Session process exited */ - exit: (code: number | null) => void; - /** One-shot prompt completed with result and cost */ - completion: (result: string, cost: number) => void; - /** Raw terminal data (includes ANSI codes) */ - terminal: (data: string) => void; - /** Signal to clear terminal display (after mux attach) */ - clearTerminal: () => void; - /** New background task started */ - taskCreated: (task: BackgroundTask) => void; - /** Background task status changed */ - taskUpdated: (task: BackgroundTask) => void; - /** Background task finished successfully */ - taskCompleted: (task: BackgroundTask) => void; - /** Background task failed with error */ - taskFailed: (task: BackgroundTask, error: string) => void; - /** Auto-clear triggered due to token threshold */ - autoClear: (data: { tokens: number; threshold: number }) => void; - /** Auto-compact triggered due to token threshold */ - autoCompact: (data: { tokens: number; threshold: number; prompt?: string }) => void; - /** Ralph loop state changed */ - ralphLoopUpdate: (state: RalphTrackerState) => void; - /** Ralph todo list updated */ - ralphTodoUpdate: (todos: RalphTodoItem[]) => void; - /** Ralph completion phrase detected */ - ralphCompletionDetected: (phrase: string) => void; - /** RALPH_STATUS block detected */ - ralphStatusBlockDetected: (block: import('./types.js').RalphStatusBlock) => void; - /** Circuit breaker state changed */ - ralphCircuitBreakerUpdate: (status: import('./types.js').CircuitBreakerStatus) => void; - /** Dual-condition exit gate met */ - ralphExitGateMet: (data: { completionIndicators: number; exitSignal: boolean }) => void; - /** Bash tool with file paths started */ - bashToolStart: (tool: ActiveBashTool) => void; - /** Bash tool completed */ - bashToolEnd: (tool: ActiveBashTool) => void; - /** Active Bash tools list updated */ - bashToolsUpdate: (tools: ActiveBashTool[]) => void; - /** CLI info (version, model, account) updated */ - cliInfoUpdated: (info: { - version: string | null; - model: string | null; - accountType: string | null; - latestVersion: string | null; - }) => void; -} - -// SessionMode is imported from types.ts (single source of truth) -// Re-export for backwards compatibility with any external consumers -export type { SessionMode } from './types.js'; /** * Core session class that wraps a PTY process running Claude CLI or a shell. diff --git a/src/subagent-watcher.ts b/src/subagent-watcher.ts index 8d5e0674..08041dda 100644 --- a/src/subagent-watcher.ts +++ b/src/subagent-watcher.ts @@ -134,17 +134,6 @@ export interface SubagentToolResult { isError: boolean; // Whether result is an error } -export interface SubagentEvents { - 'subagent:discovered': (info: SubagentInfo) => void; - 'subagent:updated': (info: SubagentInfo) => void; - 'subagent:tool_call': (data: SubagentToolCall) => void; - 'subagent:tool_result': (data: SubagentToolResult) => void; - 'subagent:progress': (data: SubagentProgress) => void; - 'subagent:message': (data: SubagentMessage) => void; - 'subagent:completed': (info: SubagentInfo) => void; - 'subagent:error': (error: Error, agentId?: string) => void; -} - // ========== Constants ========== const CLAUDE_PROJECTS_DIR = join(homedir(), '.claude/projects'); diff --git a/src/task-queue.ts b/src/task-queue.ts index bf668d0b..66793a8b 100644 --- a/src/task-queue.ts +++ b/src/task-queue.ts @@ -17,14 +17,6 @@ import { getStore } from './state-store.js'; /** * Events emitted by TaskQueue */ -export interface TaskQueueEvents { - /** Fired when a task is added to the queue */ - taskAdded: (task: Task) => void; - /** Fired when a task is removed from the queue */ - taskRemoved: (taskId: string) => void; - /** Fired when a task's state changes */ - taskUpdated: (task: Task) => void; -} /** * Priority queue for managing tasks with dependency support. diff --git a/src/task-tracker.ts b/src/task-tracker.ts index eabb2ce1..e59b9f2c 100644 --- a/src/task-tracker.ts +++ b/src/task-tracker.ts @@ -153,16 +153,6 @@ export interface BackgroundTask { * @event taskCompleted - Task finished successfully * @event taskFailed - Task finished with error */ -export interface TaskTrackerEvents { - /** New task created */ - taskCreated: (task: BackgroundTask) => void; - /** Task state updated */ - taskUpdated: (task: BackgroundTask) => void; - /** Task completed successfully */ - taskCompleted: (task: BackgroundTask) => void; - /** Task failed with error */ - taskFailed: (task: BackgroundTask, error: string) => void; -} /** * TaskTracker - Detects and tracks background tasks in Claude Code sessions. diff --git a/src/transcript-watcher.ts b/src/transcript-watcher.ts index 356e0397..8eb01644 100644 --- a/src/transcript-watcher.ts +++ b/src/transcript-watcher.ts @@ -20,7 +20,7 @@ import { createInterface } from 'node:readline'; /** * Parsed transcript entry from the JSONL file */ -export interface TranscriptEntry { +interface TranscriptEntry { type: 'user' | 'assistant' | 'system' | 'result'; timestamp: string; message?: { @@ -35,7 +35,7 @@ export interface TranscriptEntry { }; } -export interface TranscriptContentBlock { +interface TranscriptContentBlock { type: 'text' | 'tool_use' | 'tool_result'; text?: string; name?: string; @@ -68,15 +68,6 @@ export interface TranscriptState { lastUpdateAt: string | null; } -export interface TranscriptWatcherEvents { - 'transcript:update': (state: TranscriptState) => void; - 'transcript:complete': (state: TranscriptState) => void; - 'transcript:tool_start': (toolName: string) => void; - 'transcript:tool_end': (toolName: string, isError: boolean) => void; - 'transcript:error': (error: Error) => void; - 'transcript:plan_mode': () => void; -} - // ========== Constants ========== /** How often to check for new content when file watching fails */ @@ -435,7 +426,3 @@ export class TranscriptWatcher extends EventEmitter { } } } - -// ========== Singleton Export ========== - -export const transcriptWatcher = new TranscriptWatcher(); diff --git a/src/tunnel-manager.ts b/src/tunnel-manager.ts index b8728737..083b11d2 100644 --- a/src/tunnel-manager.ts +++ b/src/tunnel-manager.ts @@ -33,7 +33,7 @@ import { getErrorMessage } from './types.js'; // ========== Types ========== -export interface TunnelStatus { +interface TunnelStatus { running: boolean; url: string | null; } diff --git a/src/types/orchestrator.ts b/src/types/orchestrator.ts index b2ec40f3..df820d25 100644 --- a/src/types/orchestrator.ts +++ b/src/types/orchestrator.ts @@ -268,18 +268,3 @@ export function createInitialOrchestratorStats(): OrchestratorStats { replanCount: 0, }; } - -/** Factory function for initial orchestrator persist state */ -export function createInitialOrchestratorPersistState( - config: OrchestratorConfig = DEFAULT_ORCHESTRATOR_CONFIG -): OrchestratorPersistState { - return { - state: 'idle', - plan: null, - currentPhaseIndex: 0, - startedAt: null, - completedAt: null, - config, - stats: createInitialOrchestratorStats(), - }; -} diff --git a/src/types/respawn.ts b/src/types/respawn.ts index 8413ecf4..fd9bafc3 100644 --- a/src/types/respawn.ts +++ b/src/types/respawn.ts @@ -230,22 +230,6 @@ export interface TimingHistory { /** * Named respawn configuration preset for quick setup */ -export interface RespawnPreset { - /** Unique preset identifier */ - id: string; - /** User-friendly preset name */ - name: string; - /** Description of when to use this preset */ - description?: string; - /** The respawn configuration (without enabled flag) */ - config: Omit; - /** Duration in minutes (optional default) */ - durationMinutes?: number; - /** Whether this is a built-in preset */ - builtIn?: boolean; - /** Timestamp when created */ - createdAt: number; -} /** * Persisted respawn configuration for mux sessions. diff --git a/src/types/session.ts b/src/types/session.ts index 01cf3584..e3ee4247 100644 --- a/src/types/session.ts +++ b/src/types/session.ts @@ -150,11 +150,3 @@ export interface SessionState { /** * Output captured from a session */ -export interface SessionOutput { - /** Standard output content */ - stdout: string; - /** Standard error content */ - stderr: string; - /** Exit code of the process, null if still running */ - exitCode: number | null; -} diff --git a/src/utils/cleanup-manager.ts b/src/utils/cleanup-manager.ts index 8f1ea99d..229dc480 100644 --- a/src/utils/cleanup-manager.ts +++ b/src/utils/cleanup-manager.ts @@ -14,7 +14,7 @@ import type { Disposable, CleanupRegistration, CleanupResourceType } from '../ty /** * Options for setTimeout/setInterval with automatic cleanup. */ -export interface TimerOptions { +interface TimerOptions { /** Human-readable description for debugging */ description?: string; } diff --git a/src/utils/index.ts b/src/utils/index.ts index 9ffa0fc7..ded4d09b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -7,17 +7,14 @@ */ export { BufferAccumulator } from './buffer-accumulator.js'; -export { LRUMap, type LRUMapOptions } from './lru-map.js'; -export { CleanupManager, type TimerOptions } from './cleanup-manager.js'; +export { CleanupManager } from './cleanup-manager.js'; export { Debouncer, KeyedDebouncer } from './debouncer.js'; -export { StaleExpirationMap, type StaleExpirationMapOptions } from './stale-expiration-map.js'; +export { StaleExpirationMap } from './stale-expiration-map.js'; export { ANSI_ESCAPE_PATTERN_FULL, ANSI_ESCAPE_PATTERN_SIMPLE, TOKEN_PATTERN, SPINNER_PATTERN, - createAnsiPatternFull, - createAnsiPatternSimple, stripAnsi, SAFE_PATH_PATTERN, execPattern, @@ -27,4 +24,4 @@ export { stringSimilarity, fuzzyPhraseMatch, todoContentHash } from './string-si export { assertNever } from './type-safety.js'; export { wrapWithNice } from './nice-wrapper.js'; export { findClaudeDir, getAugmentedPath } from './claude-cli-resolver.js'; -export { resolveOpenCodeDir, isOpenCodeAvailable } from './opencode-cli-resolver.js'; +export { resolveOpenCodeDir } from './opencode-cli-resolver.js'; diff --git a/src/utils/lru-map.ts b/src/utils/lru-map.ts index 2fe4757b..6ed44b0e 100644 --- a/src/utils/lru-map.ts +++ b/src/utils/lru-map.ts @@ -10,7 +10,7 @@ /** * Configuration options for LRUMap. */ -export interface LRUMapOptions { +interface LRUMapOptions { /** Maximum number of entries before eviction */ maxSize: number; /** Optional callback when an entry is evicted */ diff --git a/src/utils/regex-patterns.ts b/src/utils/regex-patterns.ts index d8cc81ae..47970a49 100644 --- a/src/utils/regex-patterns.ts +++ b/src/utils/regex-patterns.ts @@ -40,24 +40,6 @@ export const ANSI_ESCAPE_PATTERN_SIMPLE = /\x1b\[[0-9;]*[A-Za-z]/g; */ export const TOKEN_PATTERN = /(\d+(?:\.\d+)?)\s*([kKmM])?\s*tokens/; -/** - * Creates a fresh copy of ANSI_ESCAPE_PATTERN_FULL. - * Use when you need a pattern without shared lastIndex state. - */ -export function createAnsiPatternFull(): RegExp { - // eslint-disable-next-line no-control-regex - return /\x1b(?:\[[0-9;?]*[A-Za-z]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[=>])/g; -} - -/** - * Creates a fresh copy of ANSI_ESCAPE_PATTERN_SIMPLE. - * Use when you need a pattern without shared lastIndex state. - */ -export function createAnsiPatternSimple(): RegExp { - // eslint-disable-next-line no-control-regex - return /\x1b\[[0-9;]*[A-Za-z]/g; -} - /** * Strips ANSI escape codes from text using the comprehensive pattern. * @param text - Text containing ANSI escape codes diff --git a/src/utils/stale-expiration-map.ts b/src/utils/stale-expiration-map.ts index f5e35925..5f52623d 100644 --- a/src/utils/stale-expiration-map.ts +++ b/src/utils/stale-expiration-map.ts @@ -22,7 +22,7 @@ interface TimedEntry { /** * Configuration options for StaleExpirationMap. */ -export interface StaleExpirationMapOptions { +interface StaleExpirationMapOptions { /** Time-to-live in milliseconds before entries expire */ ttlMs: number; /** How often to run cleanup (default: ttlMs / 2) */ diff --git a/src/web/middleware/auth.ts b/src/web/middleware/auth.ts index 0ec3e52d..f7b186c0 100644 --- a/src/web/middleware/auth.ts +++ b/src/web/middleware/auth.ts @@ -23,7 +23,7 @@ import { export const AUTH_COOKIE_NAME = 'codeman_session'; /** State returned from registerAuthMiddleware for cleanup in server stop() */ -export interface AuthState { +interface AuthState { authSessions: StaleExpirationMap | null; authFailures: StaleExpirationMap | null; qrAuthFailures: StaleExpirationMap | null; diff --git a/src/web/ports/index.ts b/src/web/ports/index.ts index 57d22f74..2373015f 100644 --- a/src/web/ports/index.ts +++ b/src/web/ports/index.ts @@ -11,5 +11,5 @@ export type { EventPort } from './event-port.js'; export type { RespawnPort } from './respawn-port.js'; export type { ConfigPort } from './config-port.js'; export type { InfraPort, ScheduledRun } from './infra-port.js'; -export type { AuthPort, AuthSessionRecord } from './auth-port.js'; +export type { AuthPort } from './auth-port.js'; export type { OrchestratorPort } from './orchestrator-port.js'; diff --git a/src/web/schemas.ts b/src/web/schemas.ts index a5569952..87629d1e 100644 --- a/src/web/schemas.ts +++ b/src/web/schemas.ts @@ -549,45 +549,6 @@ export const RalphLoopStartSchema = z.object({ .optional(), }); -// ========== Inferred Types ========== - -export type CreateSessionInput = z.infer; -export type RunPromptInput = z.infer; -export type ResizeInput = z.infer; -export type CreateCaseInput = z.infer; -export type QuickStartInput = z.infer; -export type HookEventInput = z.infer; -export type RespawnConfigInput = z.infer; -export type ConfigUpdateInput = z.infer; -export type SettingsUpdateInput = z.infer; -export type SessionInputWithLimitInput = z.infer; -export type SessionNameInput = z.infer; -export type SessionColorInput = z.infer; -export type RalphConfigInput = z.infer; -export type FixPlanImportInput = z.infer; -export type RalphPromptWriteInput = z.infer; -export type AutoClearInput = z.infer; -export type AutoCompactInput = z.infer; -export type ImageWatcherInput = z.infer; -export type FlickerFilterInput = z.infer; -export type QuickRunInput = z.infer; -export type ScheduledRunInput = z.infer; -export type LinkCaseInput = z.infer; -export type GeneratePlanInput = z.infer; -export type GeneratePlanDetailedInput = z.infer; -export type CancelPlanInput = z.infer; -export type PlanTaskUpdateInput = z.infer; -export type PlanTaskAddInput = z.infer; -export type CpuLimitInput = z.infer; -export type ModelConfigUpdateInput = z.infer; -export type SubagentWindowStatesInput = z.infer; -export type SubagentParentMapInput = z.infer; -export type InteractiveRespawnInput = z.infer; -export type RespawnEnableInput = z.infer; -export type PushSubscribeInput = z.infer; -export type PushPreferencesUpdateInput = z.infer; -export type RalphLoopStartInput = z.infer; - // ========== Orchestrator Loop ========== /** POST /api/orchestrator/start */ @@ -612,6 +573,3 @@ export const OrchestratorStartSchema = z.object({ export const OrchestratorRejectSchema = z.object({ feedback: z.string().min(1).max(10000), }); - -export type OrchestratorStartInput = z.infer; -export type OrchestratorRejectInput = z.infer; diff --git a/src/web/session-listener-wiring.ts b/src/web/session-listener-wiring.ts index 12f7edf9..0d14d245 100644 --- a/src/web/session-listener-wiring.ts +++ b/src/web/session-listener-wiring.ts @@ -58,7 +58,7 @@ export interface SessionListenerRefs { } /** Dependencies injected by WebServer — keeps listener creation decoupled from server internals. */ -export interface SessionListenerDeps { +interface SessionListenerDeps { broadcast(event: string, data: unknown): void; batchTerminalData(sessionId: string, data: string): void; batchTaskUpdate(sessionId: string, task: BackgroundTask): void; diff --git a/src/web/sse-stream-manager.ts b/src/web/sse-stream-manager.ts index da0c3afa..8a2aecba 100644 --- a/src/web/sse-stream-manager.ts +++ b/src/web/sse-stream-manager.ts @@ -35,7 +35,7 @@ import { const SSE_PADDING = ':' + 'p'.repeat(SSE_PADDING_SIZE) + '\n'; /** Dependencies injected by WebServer — keeps SseStreamManager decoupled from session/respawn state. */ -export interface SseStreamManagerDeps { +interface SseStreamManagerDeps { /** Get session state with respawn info for session:updated broadcasts */ getSessionStateWithRespawn(sessionId: string): unknown; }