mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 12:39:42 +02:00
chore: remove dead code and unused exports (-159 lines)
Remove confirmed-unused code found via team-based codebase analysis: - Dead interfaces: SessionResponse (types.ts), PlannerResult (plan-orchestrator.ts) - Dead functions: withTimeout (session.ts), getOpenCodeAugmentedPath, resetOpenCodeCache (opencode-cli-resolver.ts) - Dead config constants: MAX_RUN_SUMMARY_EVENTS, TRIM_RUN_SUMMARY_TO, MAX_MESSAGES_PER_CHANNEL (buffer-limits.ts), MAX_TRACKED_AGENTS, MAX_SUBAGENT_ACTIVITY_PER_AGENT, MAX_TOOL_RESULTS_PER_AGENT, COMPLETED_TODO_TTL_MS (map-limits.ts) - Dead legacy code: idleTimer property + clearIdleTimer() no-op method + 6 call sites (respawn-controller.ts) - Stale barrel re-exports: createAnsiPatternFull/Simple, validateTokenCounts/Cost, stripAnsi, normalizePhrase, getOpenCodeAugmentedPath (utils/index.ts) - Un-exported internal-only symbols: ErrorMessages (types.ts), destroyRalphLoop (ralph-loop.ts) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -85,26 +85,3 @@ export const MAX_RESPAWN_BUFFER_SIZE = 1 * 1024 * 1024; // 1MB
|
||||
* Size to trim respawn buffer to when max is exceeded.
|
||||
*/
|
||||
export const TRIM_RESPAWN_BUFFER_TO = 512 * 1024; // 512KB
|
||||
|
||||
// ============================================================================
|
||||
// Run Summary Limits
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Maximum number of events to keep in run summary.
|
||||
*/
|
||||
export const MAX_RUN_SUMMARY_EVENTS = 1000;
|
||||
|
||||
/**
|
||||
* Number of events to keep when trimming run summary.
|
||||
*/
|
||||
export const TRIM_RUN_SUMMARY_TO = 800;
|
||||
|
||||
// ============================================================================
|
||||
// Spawn Message Limits
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Maximum messages per spawn communication channel.
|
||||
*/
|
||||
export const MAX_MESSAGES_PER_CHANNEL = 100;
|
||||
|
||||
@@ -14,28 +14,6 @@
|
||||
* @module config/map-limits
|
||||
*/
|
||||
|
||||
// ============================================================================
|
||||
// Agent Tracking Limits
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Maximum number of agents to track across all sessions.
|
||||
* Oldest agents are evicted when limit is exceeded (LRU policy).
|
||||
*/
|
||||
export const MAX_TRACKED_AGENTS = 500;
|
||||
|
||||
/**
|
||||
* Maximum activity entries to keep per agent.
|
||||
* Includes tool calls, status updates, progress reports.
|
||||
*/
|
||||
export const MAX_SUBAGENT_ACTIVITY_PER_AGENT = 100;
|
||||
|
||||
/**
|
||||
* Maximum tool results to keep per agent.
|
||||
* Prevents memory growth from long-running agents with many tool calls.
|
||||
*/
|
||||
export const MAX_TOOL_RESULTS_PER_AGENT = 200;
|
||||
|
||||
// ============================================================================
|
||||
// Session Tracking Limits
|
||||
// ============================================================================
|
||||
@@ -65,11 +43,6 @@ export const MAX_SSE_CLIENTS = 100;
|
||||
*/
|
||||
export const MAX_TODOS_PER_SESSION = 500;
|
||||
|
||||
/**
|
||||
* TTL for completed todo items before cleanup (1 hour).
|
||||
*/
|
||||
export const COMPLETED_TODO_TTL_MS = 60 * 60 * 1000;
|
||||
|
||||
// ============================================================================
|
||||
// Pending Tool Calls Limits
|
||||
// ============================================================================
|
||||
|
||||
@@ -79,12 +79,6 @@ export interface ResearchResult {
|
||||
durationMs: number;
|
||||
}
|
||||
|
||||
export interface PlannerResult {
|
||||
items: PlanItem[];
|
||||
gaps: string[];
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
export interface DetailedPlanResult {
|
||||
success: boolean;
|
||||
items?: PlanItem[];
|
||||
|
||||
+1
-1
@@ -509,7 +509,7 @@ export function getRalphLoop(options?: RalphLoopOptions): RalphLoop {
|
||||
}
|
||||
|
||||
/** Destroys the singleton instance. Use in tests or for cleanup. */
|
||||
export function destroyRalphLoop(): void {
|
||||
function destroyRalphLoop(): void {
|
||||
if (loopInstance) {
|
||||
loopInstance.destroy();
|
||||
loopInstance = null;
|
||||
|
||||
@@ -641,9 +641,6 @@ export class RespawnController extends EventEmitter {
|
||||
/** Current state machine state */
|
||||
private _state: RespawnState = 'stopped';
|
||||
|
||||
/** Timer for idle detection timeout */
|
||||
private idleTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
/** Timer for step delays */
|
||||
private stepTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
@@ -1505,7 +1502,6 @@ export class RespawnController extends EventEmitter {
|
||||
this.elicitationDetected = false; // Clear on new work cycle
|
||||
this.resetHookState(); // Clear hook signals on new work
|
||||
this.lastWorkingPatternTime = now;
|
||||
this.clearIdleTimer();
|
||||
|
||||
// Cancel hook confirmation timer if running
|
||||
this.cancelTrackedTimer('hook-confirm', this.hookConfirmTimer, 'working patterns detected');
|
||||
@@ -1608,7 +1604,6 @@ export class RespawnController extends EventEmitter {
|
||||
* @fires stepCompleted - With step 'update'
|
||||
*/
|
||||
private checkUpdateComplete(): void {
|
||||
this.clearIdleTimer();
|
||||
this.log('Update completed (ready indicator)');
|
||||
this.emit('stepCompleted', 'update');
|
||||
|
||||
@@ -1643,7 +1638,6 @@ export class RespawnController extends EventEmitter {
|
||||
* @fires stepCompleted - With step 'clear'
|
||||
*/
|
||||
private checkClearComplete(): void {
|
||||
this.clearIdleTimer();
|
||||
// Clear the fallback timer since we got prompt detection
|
||||
this.cancelTrackedTimer('clear-fallback', this.clearFallbackTimer, 'prompt detected');
|
||||
this.clearFallbackTimer = null;
|
||||
@@ -1667,7 +1661,6 @@ export class RespawnController extends EventEmitter {
|
||||
* @fires stepCompleted - With step 'init' (if no kickstart)
|
||||
*/
|
||||
private checkInitComplete(): void {
|
||||
this.clearIdleTimer();
|
||||
this.log('/init completed (ready indicator)');
|
||||
|
||||
// P2-004: Record step completion
|
||||
@@ -1715,7 +1708,6 @@ export class RespawnController extends EventEmitter {
|
||||
* @fires stepCompleted - With step 'init'
|
||||
*/
|
||||
private checkMonitoringInitIdle(): void {
|
||||
this.clearIdleTimer();
|
||||
if (this.stepTimer) {
|
||||
clearTimeout(this.stepTimer);
|
||||
this.stepTimer = null;
|
||||
@@ -1757,7 +1749,6 @@ export class RespawnController extends EventEmitter {
|
||||
* @fires stepCompleted - With step 'kickstart'
|
||||
*/
|
||||
private checkKickstartComplete(): void {
|
||||
this.clearIdleTimer();
|
||||
this.log('Kickstart completed (ready indicator)');
|
||||
this.emit('stepCompleted', 'kickstart');
|
||||
|
||||
@@ -1767,22 +1758,10 @@ export class RespawnController extends EventEmitter {
|
||||
this.completeCycle();
|
||||
}
|
||||
|
||||
// Note: Legacy startIdleTimer removed - now using completion-based detection
|
||||
// with startCompletionConfirmTimer() and startNoOutputTimer() instead.
|
||||
|
||||
/** Clear the idle detection timer if running (legacy cleanup) */
|
||||
private clearIdleTimer(): void {
|
||||
if (this.idleTimer) {
|
||||
clearTimeout(this.idleTimer);
|
||||
this.idleTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Clear all timers (idle, step, completion confirm, no-output, pre-filter, step confirm, auto-accept, hook confirm, and clear fallback) */
|
||||
/** Clear all timers (step, completion confirm, no-output, pre-filter, step confirm, auto-accept, hook confirm, and clear fallback) */
|
||||
private clearTimers(): void {
|
||||
// Clear tracked timers map first to avoid stale entries during individual cleanup
|
||||
this.activeTimers.clear();
|
||||
this.clearIdleTimer();
|
||||
if (this.stepTimer) {
|
||||
clearTimeout(this.stepTimer);
|
||||
this.stepTimer = null;
|
||||
|
||||
@@ -49,7 +49,6 @@ import {
|
||||
|
||||
export type { BackgroundTask } from './task-tracker.js';
|
||||
export type { RalphTrackerState, RalphTodoItem, ActiveBashTool } from './types.js';
|
||||
export { withTimeout };
|
||||
|
||||
/** Line buffer flush interval (100ms) - forces processing of partial lines */
|
||||
const LINE_BUFFER_FLUSH_INTERVAL = 100;
|
||||
@@ -97,29 +96,6 @@ const NEWLINE_SPLIT_PATTERN = /\r?\n/;
|
||||
// Claude CLI PATH resolution — shared utility
|
||||
import { getAugmentedPath } from './utils/claude-cli-resolver.js';
|
||||
|
||||
/**
|
||||
* Wraps a promise with a timeout to prevent indefinite hangs.
|
||||
* If the promise doesn't resolve within the timeout, rejects with TimeoutError.
|
||||
*
|
||||
* @param promise - The promise to wrap
|
||||
* @param timeoutMs - Timeout in milliseconds
|
||||
* @param operation - Description of the operation for error messages
|
||||
* @returns Promise that resolves/rejects with the original result or timeout error
|
||||
*/
|
||||
function withTimeout<T>(promise: Promise<T>, timeoutMs: number, operation: string): Promise<T> {
|
||||
let timeoutId: NodeJS.Timeout;
|
||||
|
||||
const timeoutPromise = new Promise<never>((_, reject) => {
|
||||
timeoutId = setTimeout(() => {
|
||||
reject(new Error(`${operation} timed out after ${timeoutMs}ms`));
|
||||
}, timeoutMs);
|
||||
});
|
||||
|
||||
return Promise.race([promise, timeoutPromise]).finally(() => {
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a JSON message from Claude CLI's stream-json output format.
|
||||
* Messages are newline-delimited JSON objects parsed from PTY output.
|
||||
|
||||
+1
-24
@@ -667,7 +667,7 @@ export enum ApiErrorCode {
|
||||
/**
|
||||
* User-friendly error messages for each error code
|
||||
*/
|
||||
export const ErrorMessages: Record<ApiErrorCode, string> = {
|
||||
const ErrorMessages: Record<ApiErrorCode, string> = {
|
||||
[ApiErrorCode.NOT_FOUND]: 'The requested resource was not found',
|
||||
[ApiErrorCode.INVALID_INPUT]: 'Invalid input provided',
|
||||
[ApiErrorCode.SESSION_BUSY]: 'Session is currently busy',
|
||||
@@ -711,29 +711,6 @@ export function createErrorResponse(code: ApiErrorCode, details?: string): ApiRe
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Response for session operations
|
||||
*/
|
||||
export interface SessionResponse {
|
||||
/** Whether the request succeeded */
|
||||
success: boolean;
|
||||
/** Session details if successful (light state — no full buffers) */
|
||||
session?: SessionState & {
|
||||
/** Claude session ID from CLI */
|
||||
claudeSessionId: string | null;
|
||||
/** Total API cost */
|
||||
totalCost: number;
|
||||
/** Number of messages */
|
||||
messageCount: number;
|
||||
/** Whether Claude is working */
|
||||
isWorking: boolean;
|
||||
/** Timestamp of last prompt */
|
||||
lastPromptTime: number;
|
||||
};
|
||||
/** Error message if failed */
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response for quick start operation
|
||||
*/
|
||||
|
||||
+3
-6
@@ -15,13 +15,10 @@ export {
|
||||
ANSI_ESCAPE_PATTERN_SIMPLE,
|
||||
TOKEN_PATTERN,
|
||||
SPINNER_PATTERN,
|
||||
createAnsiPatternFull,
|
||||
createAnsiPatternSimple,
|
||||
stripAnsi,
|
||||
} from './regex-patterns.js';
|
||||
export { MAX_SESSION_TOKENS, validateTokenCounts, validateTokensAndCost } from './token-validation.js';
|
||||
export { stringSimilarity, normalizePhrase, fuzzyPhraseMatch, todoContentHash } from './string-similarity.js';
|
||||
export { MAX_SESSION_TOKENS } from './token-validation.js';
|
||||
export { stringSimilarity, fuzzyPhraseMatch, todoContentHash } from './string-similarity.js';
|
||||
export { assertNever } from './type-safety.js';
|
||||
export { wrapWithNice } from './nice-wrapper.js';
|
||||
export { findClaudeDir, getAugmentedPath } from './claude-cli-resolver.js';
|
||||
export { resolveOpenCodeDir, isOpenCodeAvailable, getOpenCodeAugmentedPath } from './opencode-cli-resolver.js';
|
||||
export { resolveOpenCodeDir, isOpenCodeAvailable } from './opencode-cli-resolver.js';
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
import { execSync } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { delimiter, dirname, join } from 'node:path';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
|
||||
/** Timeout for exec commands (5 seconds) */
|
||||
@@ -71,28 +71,3 @@ export function resolveOpenCodeDir(): string | null {
|
||||
export function isOpenCodeAvailable(): boolean {
|
||||
return resolveOpenCodeDir() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PATH string that includes the directory containing `opencode`.
|
||||
*
|
||||
* Finds the opencode binary (via `which` or common install locations), then
|
||||
* prepends its directory to the current PATH if not already present.
|
||||
* Result is cached for subsequent calls.
|
||||
*/
|
||||
export function getOpenCodeAugmentedPath(): string {
|
||||
const currentPath = process.env.PATH || '';
|
||||
const dir = resolveOpenCodeDir();
|
||||
|
||||
if (dir && !currentPath.split(delimiter).includes(dir)) {
|
||||
return `${dir}${delimiter}${currentPath}`;
|
||||
}
|
||||
|
||||
return currentPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset cached resolution (for testing).
|
||||
*/
|
||||
export function resetOpenCodeCache(): void {
|
||||
_openCodeDir = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user