Skip to content

Commit 02e2f3e

Browse files
Ark0Nclaude
andcommitted
refactor: remove dead code and narrow internal exports (knip sweep)
Knip-driven cleanup. All changes verified with tsc --noEmit, lint, and build. Removed (zero consumers): - VERIFICATION_PROMPT constant + its barrel re-export - createInitialOrchestratorPersistState factory - transcriptWatcher singleton export - createAnsiPatternFull / createAnsiPatternSimple factories - TimerInfo interface + unused AiCheckResult/AiPlanCheckResult imports in respawn-controller.ts - 35 unused Zod z.infer \`*Input\` types in schemas.ts - Dead re-exports: SessionMode from session.ts, AuthSessionRecord from web/ports/index.ts, EnhancedPlanTask/CheckpointReview from ralph-tracker.ts, 7 unused entries in utils/index.ts - 14 event/config interfaces that lived only as JSDoc hints (no TS type position usage): Session/Respawn/RalphLoop/RalphTracker/ SessionManager/SessionAutoOps/Subagent/TaskQueue/TaskTracker/ TranscriptWatcher/Image/OrchestratorLoop Events + RespawnPreset + SessionOutput Narrowed to module scope (kept but no longer exported): - buildPermissionArgs in session-cli-builder.ts - 28 type/interface declarations used only within their own file: Ai{Idle,Plan}Check{Config,State}, BashToolParser{Events,Config}, FileStream/CreateStream{Options,Result}, PlanSubagentEvent, SubagentCallback, RalphLoopConfig, RalphLoop{Events,Options}, ActiveTimerInfo, DetectionStatus, ActionLogEntry, AutoOpsCallbacks, TunnelStatus, Timer/LRUMap/StaleExpirationMap Options, AuthState, SessionListenerDeps, SseStreamManagerDeps, and 8 more Docs: CLAUDE.md advice for global-regex `lastIndex` now points to the remaining `execPattern()` helper instead of the deleted factories. Knip delta: unused files 42→0, unused exports 161→16, unused types 92→0. The 16 remaining exports are a mobile-test helper toolkit intentionally kept for upcoming tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 41300f0 commit 02e2f3e

36 files changed

Lines changed: 35 additions & 391 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Codeman is a Claude Code session manager with web interface and autonomous Ralph
9090
- **Single-line prompts only** — `writeViaMux()` sends text+Enter separately; multi-line breaks Ink
9191
- **ESM only** — Never `require()`, use `await import()`. `tsx` masks CJS/ESM issues in dev but production breaks
9292
- **Package ≠ product name** — npm: `aicodeman`, product: **Codeman**. Release renames tags accordingly
93-
- **Global regex `lastIndex`** — Use `createAnsiPatternFull/Simple()` factories, not shared `g`-flag patterns in loops
93+
- **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)
9494
9595
**Import conventions**: Utils from `./utils`, types from `./types` (barrel), config from specific `./config/*` files.
9696

src/ai-idle-checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141

4242
// ========== Types ==========
4343

44-
export type AiIdleCheckConfig = AiCheckerConfigBase;
44+
type AiIdleCheckConfig = AiCheckerConfigBase;
4545

4646
export type AiCheckVerdict = 'IDLE' | 'WORKING' | 'ERROR';
4747

src/ai-plan-checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ import {
4040

4141
// ========== Types ==========
4242

43-
export type AiPlanCheckConfig = AiCheckerConfigBase;
43+
type AiPlanCheckConfig = AiCheckerConfigBase;
4444

4545
export type AiPlanCheckVerdict = 'PLAN_MODE' | 'NOT_PLAN_MODE' | 'ERROR';
4646

4747
export type AiPlanCheckResult = AiCheckerResultBase<AiPlanCheckVerdict>;
4848

49-
export type AiPlanCheckState = AiCheckerStateBase<AiPlanCheckVerdict>;
49+
type AiPlanCheckState = AiCheckerStateBase<AiPlanCheckVerdict>;
5050

5151
// ========== Constants ==========
5252

src/bash-tool-parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const LOG_FILE_MENTION_PATTERN = /([/~][^\s'"<>|;&\n]*(?:\.log|\.txt|\.out|\/log
9999
/**
100100
* Events emitted by BashToolParser.
101101
*/
102-
export interface BashToolParserEvents {
102+
interface BashToolParserEvents {
103103
/** New Bash tool with file paths started */
104104
toolStart: [tool: ActiveBashTool];
105105
/** Bash tool completed */
@@ -111,7 +111,7 @@ export interface BashToolParserEvents {
111111
/**
112112
* Configuration options for BashToolParser.
113113
*/
114-
export interface BashToolParserConfig {
114+
interface BashToolParserConfig {
115115
/** Session ID this parser belongs to */
116116
sessionId: string;
117117
/** Whether the parser is enabled (default: true) */

src/file-stream-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const STREAM_INACTIVITY_TIMEOUT_MS = INACTIVITY_TIMEOUT_MS;
4848
/**
4949
* Represents an active file stream.
5050
*/
51-
export interface FileStream {
51+
interface FileStream {
5252
/** Unique stream identifier */
5353
id: string;
5454
/** Session this stream belongs to */
@@ -74,7 +74,7 @@ export interface FileStream {
7474
/**
7575
* Options for creating a file stream.
7676
*/
77-
export interface CreateStreamOptions {
77+
interface CreateStreamOptions {
7878
/** Session ID requesting the stream */
7979
sessionId: string;
8080
/** Path to the file to stream */
@@ -94,7 +94,7 @@ export interface CreateStreamOptions {
9494
/**
9595
* Result of creating a stream.
9696
*/
97-
export interface CreateStreamResult {
97+
interface CreateStreamResult {
9898
success: boolean;
9999
streamId?: string;
100100
error?: string;

src/image-watcher.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ import { KeyedDebouncer } from './utils/index.js';
1717

1818
// ========== Types ==========
1919

20-
export interface ImageWatcherEvents {
21-
'image:detected': (event: ImageDetectedEvent) => void;
22-
'image:error': (error: Error, sessionId?: string) => void;
23-
}
24-
2520
// ========== Constants ==========
2621

2722
/** Supported image file extensions (lowercase) */

src/orchestrator-loop.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,6 @@ const POST_PHASE_DELAY_MS = 1000;
6060
// Events
6161
// ═══════════════════════════════════════════════════════════════
6262

63-
export interface OrchestratorLoopEvents {
64-
stateChanged: (state: OrchestratorState, prevState: OrchestratorState) => void;
65-
planProgress: (phase: string, detail: string) => void;
66-
planReady: (plan: OrchestratorPlan) => void;
67-
phaseStarted: (phase: OrchestratorPhase) => void;
68-
phaseCompleted: (phase: OrchestratorPhase) => void;
69-
phaseFailed: (phase: OrchestratorPhase, reason: string) => void;
70-
taskAssigned: (task: OrchestratorTask, sessionId: string) => void;
71-
taskCompleted: (task: OrchestratorTask) => void;
72-
taskFailed: (task: OrchestratorTask, error: string) => void;
73-
verificationResult: (phase: OrchestratorPhase, result: VerificationResult) => void;
74-
completed: (stats: OrchestratorStats) => void;
75-
error: (error: Error) => void;
76-
}
77-
7863
// ═══════════════════════════════════════════════════════════════
7964
// OrchestratorLoop
8065
// ═══════════════════════════════════════════════════════════════

src/plan-orchestrator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface DetailedPlanResult {
6868

6969
export type ProgressCallback = (phase: string, detail: string) => void;
7070

71-
export interface PlanSubagentEvent {
71+
interface PlanSubagentEvent {
7272
type: 'started' | 'progress' | 'completed' | 'failed';
7373
agentId: string;
7474
agentType: 'research' | 'planner';
@@ -80,7 +80,7 @@ export interface PlanSubagentEvent {
8080
error?: string;
8181
}
8282

83-
export type SubagentCallback = (event: PlanSubagentEvent) => void;
83+
type SubagentCallback = (event: PlanSubagentEvent) => void;
8484

8585
// ============================================================================
8686
// JSON Repair Helper

src/prompts/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,4 @@
77

88
export { RESEARCH_AGENT_PROMPT } from './research-agent.js';
99
export { PLANNER_PROMPT } from './planner.js';
10-
export {
11-
PHASE_EXECUTION_PROMPT,
12-
TEAM_LEAD_PROMPT,
13-
VERIFICATION_PROMPT,
14-
REPLAN_PROMPT,
15-
SINGLE_TASK_PROMPT,
16-
} from './orchestrator.js';
10+
export { PHASE_EXECUTION_PROMPT, TEAM_LEAD_PROMPT, REPLAN_PROMPT, SINGLE_TASK_PROMPT } from './orchestrator.js';

src/prompts/orchestrator.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,6 @@ Suggested teammate roles:
5757
Each teammate should focus on their assigned task area. Monitor their progress.
5858
When ALL tasks are complete and you've verified the results, output: <promise>{COMPLETION_PHRASE}</promise>`;
5959

60-
/**
61-
* Verification prompt — asks Claude to verify phase completion.
62-
*
63-
* Placeholders:
64-
* - {PHASE_NAME}: Phase name
65-
* - {CRITERIA}: Numbered verification criteria
66-
* - {PASS_PHRASE}: Phrase to output on success
67-
* - {FAIL_PHRASE}: Phrase to output on failure
68-
*/
69-
export const VERIFICATION_PROMPT = `Review the work done in "{PHASE_NAME}". Check these criteria:
70-
71-
{CRITERIA}
72-
73-
If ALL criteria are met, respond with: {PASS_PHRASE}
74-
If ANY criteria fail, respond with: {FAIL_PHRASE} and explain what failed.`;
75-
7660
/**
7761
* Replan prompt — gives failure context and asks for recovery.
7862
*

0 commit comments

Comments
 (0)