Commit Graph
848 Commits
Author SHA1 Message Date
arkonandClaude Opus 4.5 596098015f feat: add StaleExpirationMap utility for TTL-based cache expiration
- Automatically removes entries not accessed within TTL
- Periodic cleanup with configurable interval
- Optional onExpire callback for cleanup notifications
- Refresh TTL on get (configurable)
- Touch, peek, getAge, getRemainingTtl methods
- Full iteration support
- Implements Disposable interface

Useful for caching ephemeral data like pending tool calls, subagent activity.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 04:41:49 +01:00
arkonandClaude Opus 4.5 83e5b0b78e feat: add resource management types and utilities for memory optimization
- Add Disposable, BufferConfig, MemoryMetrics, CleanupRegistration types
- Create src/config/buffer-limits.ts with consolidated buffer size constants
- Create src/config/map-limits.ts with Map size limits to prevent unbounded growth
- Implement BufferAccumulator utility with configurable trim and onTrim callback
- Implement LRUMap with automatic eviction and O(1) operations
- Implement CleanupManager for unified resource cleanup with isStopped guard
- Add comprehensive tests for all new utilities

This lays the foundation for memory leak prevention and performance improvements.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 04:35:20 +01:00
arkon 46434ee6d0 chore: bump version to 0.1402 2026-01-27 23:15:25 +01:00
arkonandClaude Opus 4.5 9fc3d2eda3 fix: plan generation API no longer cancels prematurely
The plan generation API (/api/generate-plan-detailed) was incorrectly
detecting client disconnection because it listened to req.raw.on('close')
which fires when the HTTP request body finishes parsing, not when the
actual TCP connection closes.

This caused the error "Failed to parse plan - no JSON array found" because
the server would cancel all subagent sessions almost immediately after
starting them.

Fix:
- Changed from req.raw.on('close') to socket.on('close')
- Added responseSent flag to only cancel if response hasn't been sent
- Added E2E test to verify the fix

Tested with:
- Simple plan generation: 61 items, 138.5s, quality 0.82
- Smartphone app plan: 53 items, 93.4s, quality 0.75

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 22:06:09 +01:00
arkonandClaude Opus 4.5 2e4d89496f fix: Ralph wizard uses file-based prompt to avoid screen escaping issues
- Add /api/sessions/:id/ralph-prompt/write endpoint to write prompt to @ralph_prompt.md
- Wizard now writes full prompt to file, then sends simple read command to Claude
- Fix session readiness check to wait for prompt character instead of notWorking flag
- Add E2E test infrastructure for ralph-loop workflow (port 3190)
- Add ralph-wizard-prod.mjs script for production testing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 17:46:43 +01:00
arkonandClaude Opus 4.5 b896478ca6 fix: subagent tabs render to correct parent session after restart
- restoreSubagentWindowStates now discovers parent sessions before restoring
- closeSubagentWindow discovers parent before minimizing to prevent wrong tab
- Fixed async handling in subagent:completed event handler

chore: bump version to 0.1389

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 23:37:14 +01:00
arkonandClaude Opus 4.5 6187444118 fix: improve file-link-click tests with proper assertions and error handling
- Add unit tests for file path pattern matching (cmdPattern, extPattern, bashPattern)
- Add tests for invalid/unsafe path rejection
- Fix streaming test to create session when browser tests are skipped
- Fix SSE assertion: 'event:' → 'data:' (correct SSE format)
- Fix API response access: data.session.id → data.sessionId
- Improve error handling: re-throw errors after cleanup instead of swallowing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 04:35:14 +01:00
arkonandClaude Opus 4.5 9aa5973970 fix: rock-solid idle detection in respawn controller
- Add 300-char rolling window to catch working patterns split across PTY chunks
- Check completion message BEFORE working patterns (priority fix)
- Clear rolling window on completion message (transition point)
- Increase working pattern absence threshold from 3s to 8s
- Add Session.isWorking safety check before confirming idle
- Add 20+ more working patterns (Compiling, Building, Processing, etc.)
- Make AI idle checker prompt more conservative (err toward WORKING)
- Update documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 00:55:29 +01:00
arkonandClaude Opus 4.5 1ff1e300f6 feat: add hook-based idle detection for respawn controller
Implement multi-phase improvement to respawn controller's idle detection:

Phase 1 - Stop Hook Detection:
- Add signalStopHook() method - definitive signal when Claude finishes
- 3s confirmation timer to handle race conditions
- Skip AI check when hook received (100% confidence)

Phase 2 - idle_prompt Detection:
- Add signalIdlePrompt() method - fires after 60s+ of idle
- Immediately confirms idle (no confirmation timer needed)

Phase 3 - Transcript File Monitoring:
- New TranscriptWatcher class watches session JSONL files
- Detects: completion, tool execution, plan mode, errors
- Signals respawn controller for supporting detection

Web UI Updates:
- Hook indicator with purple styling and pulse animation
- Shows "Stop hook received" or "idle_prompt hook received"
- 100% confidence displayed with hook-confirmed style

This significantly improves idle detection reliability by using
definitive signals from Claude Code rather than parsing terminal output.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 21:29:35 +01:00
arkonandClaude Opus 4.5 40df0748c5 ui: improve respawn controller layout and filter action log noise
- Stack timers row vertically (timers on top, action log below)
- Reduce action log height to 60px since it's now full width
- Filter action log to show only important entries:
  - Commands sent to console
  - Plan-check with action taken
  - Step completions
- Skip timer starts/cancels, detection updates, ai-check status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 19:59:42 +01:00
arkonandClaude Opus 4.5 c6b16bf815 fix: subagent title extraction race condition
- Add 100ms debounce for new file detection to allow content to be written
- Add subagent:updated event for retroactive description updates
- Extract description in processEntry when first user message is processed
- Add extractDescriptionFromFile helper with retry in file change handler
- Update SubagentTranscriptEntry.content type to support string | array
- Add test coverage for subagent:updated event

Fixes 43% failure rate where subagents displayed raw IDs instead of descriptions
due to race condition when files were discovered before first line was written.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 19:49:58 +01:00
arkonandClaude Opus 4.5 eb98caa812 fix: use temp file for plan checker prompt to avoid E2BIG + fix cancel race condition
The ai-plan-checker.ts was passing the prompt directly as a shell argument,
which can cause E2BIG errors when the terminal buffer is large (8KB+).
This fix applies the same temp file approach already used in ai-idle-checker.ts:
- Write prompt to a temp file instead of passing as shell argument
- Pipe the file to claude via stdin: `cat prompt.txt | claude -p ...`
- Clean up prompt file after check completes

Also fixes a race condition in the cancel() method of both AI checkers where
the poll timer could fire between setting checkCancelled and clearing timers.
Now timers are cleared before resolving the promise to prevent this race.

Includes test utilities and analysis documents for the respawn controller
created by other agents:
- test/respawn-test-utils.ts - MockSession, MockAiIdleChecker utilities
- test/respawn-analysis.md - Code analysis and issue identification
- test/respawn-scenarios.md - Test scenario documentation
- test/respawn-test-plan.md - Testing architecture documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 07:52:40 +01:00
arkonandClaude Opus 4.5 e56c8626e4 feat: persistent token tracking with global stats aggregation
- Add restoreTokens() method to Session class for recovery after restart
- Add GlobalStats type for cumulative usage tracking across all sessions
- Accumulate tokens from deleted sessions into global stats
- Track lifetime session count with incrementSessionsCreated()
- Add /api/stats endpoint for global stats
- Include globalStats in /api/status response
- Frontend shows aggregate tokens + cost in header
- Fix respawn controller config to filter undefined values
- Add 7 new tests for global stats functionality (v0.1343)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 07:26:49 +01:00
arkonandClaude Opus 4.5 ae4c445601 feat: add AI-powered plan mode detection for auto-accept
Adds a two-stage gate before auto-accepting plan mode prompts:
1. Strict regex pre-filter - checks for numbered options + selector
2. AI confirmation - spawns Opus to classify as PLAN_MODE or NOT_PLAN_MODE

This prevents spurious Enter key presses when Claude is paused mid-thought
or experiencing network lag, rather than showing a plan approval prompt.

New files:
- src/ai-plan-checker.ts: AI checker following ai-idle-checker.ts pattern

Config fields added to RespawnConfig:
- aiPlanCheckEnabled (default: true)
- aiPlanCheckModel (default: claude-opus-4-5-20251101)
- aiPlanCheckMaxContext (default: 8000)
- aiPlanCheckTimeoutMs (default: 60000)
- aiPlanCheckCooldownMs (default: 30000)

New events: planCheckStarted, planCheckCompleted, planCheckFailed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 02:55:43 +01:00
arkonandClaude Opus 4.5 0e56e590f3 feat: add AI-powered idle check for respawn controller
Replace the "Worked for Xm Xs" pattern as the sole primary idle
detection signal with a final AI-powered check. When pre-filter
conditions are met (output silence, no working patterns, tokens
stable), a fresh Claude CLI session is spawned in a screen to
analyze terminal output and provide a definitive IDLE/WORKING
verdict before proceeding with the respawn cycle.

New state in state machine: `ai_checking` (between pre-filter
confirmation and `sending_update`). WORKING verdict triggers a
3-minute cooldown. Errors auto-disable after 3 consecutive
failures, falling back to the existing noOutputTimeoutMs safety net.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 18:48:37 +01:00
arkonandClaude Opus 4.5 e8bb9f3493 fix: resolve 11 failing tests across 8 test files
- ralph-tracker: add ✓ to native todo pattern + pre-check, add configure() method
- session: remove stale message expectation from interactive endpoint test
- buffer-management: fix trim count expectations (1202 items triggers second trim)
- cli-commands: replace non-existent toStartWith with toMatch regex
- edge-cases: update error expectation for session-not-found on respawn config PUT
- ralph-integration: respawn config PUT without controller now saves as pre-config
- session-state: fix debouncer shouldFlush(0) - pass timestamp >= delayMs
- timing-utilities: attach catch handlers before advancing fake timers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 04:58:44 +01:00
arkonandClaude Opus 4.5 2e4320fee7 feat: hooks forward stdin data from Claude Code to notifications
The hook commands now read stdin JSON from Claude Code (contains tool_name,
tool_input, etc.) and forward it as the data field to the API. This enables
richer notifications showing actual context (e.g., "Bash: docker push prod").

Previously the curl commands only sent event type and session ID, losing
all hook context data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 04:35:32 +01:00
arkonandClaude Opus 4.5 10222075cb fix: restrict auto-accept to plan mode only, block AskUserQuestion prompts
The auto-accept feature was too aggressive - it would press Enter for any
silence without a completion message, including AskUserQuestion prompts.
Now uses the elicitation_dialog notification hook to detect when Claude is
asking a question, and blocks auto-accept in that case. Only plan mode
approvals (silence with no completion message AND no elicitation signal)
trigger auto-accept.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 03:10:02 +01:00
arkonandClaude Opus 4.5 b4aea57d9c feat: add Claude Code hooks for desktop notifications
Wire Claude Code's official hooks system (Notification, Stop) to POST
back to Claudeman's new /api/hook-event endpoint, which broadcasts SSE
events consumed by the existing NotificationManager for desktop alerts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 02:46:24 +01:00
arkonandClaude Opus 4.5 46c9e0f951 fix: clean up orphaned test screen sessions in afterAll
Integration tests create screen sessions via the web server, but
server.stop() intentionally preserves them (for reattachment in
production). This left 30+ detached screens after each test run.

Fix by recording pre-existing screens in beforeAll, then killing any
new detached claudeman-* screens in afterAll that weren't there at
test start. Never kills attached sessions (user's active work).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 01:34:57 +01:00
arkonandClaude Opus 4.5 99919d6dfb feat: replace SpawnDetector with MCP server for spawn1337 protocol
Instead of parsing terminal output for <spawn1337> tags, spawn capabilities
are now exposed as native MCP tools that Claude Code can call directly.
The MCP server (stdio transport) proxies requests to the existing REST API.

- Add src/mcp-server.ts with 6 tools: spawn_agent, list_agents,
  get_agent_status, get_agent_result, send_agent_message, cancel_agent
- Remove src/spawn-detector.ts and all references in session.ts/server.ts
- Add CLAUDEMAN_API_URL env var propagation to sessions and screens
- Write .mcp.json to case directories during creation
- Remove spawn1337 tag documentation from case-template.md
- Add claudeman-mcp bin entry to package.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:16:21 +01:00
arkonandClaude Opus 4.5 a41240049e feat: disable Ralph/Todo tracker auto-enable by default
Ralph tracker no longer auto-enables on pattern detection. It must be
explicitly enabled per-session (via API) or globally via the new
`ralphEnabled` AppConfig setting. Adds GET/PUT /api/config endpoints
for runtime configuration. Spawn agent ralph enable is unchanged.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 22:14:00 +01:00
arkonandClaude Opus 4.5 1705b7a67d feat: implement spawn1337 autonomous agent protocol
Add full lifecycle management for spawning autonomous Claude sessions as
screen-based agents. Agents communicate via filesystem message bus, signal
completion via RalphTracker <promise> mechanism, and enforce resource budgets
(tokens, cost, timeout, depth limits).

New files:
- spawn-types.ts: Types, YAML parser, factory functions, serialization
- spawn-detector.ts: Terminal pattern detection for spawn1337 tags
- spawn-orchestrator.ts: Agent lifecycle (spawn, monitor, queue, cleanup)
- spawn-claude-md.ts: CLAUDE.md generator for agent sessions

Modified:
- session.ts: SpawnDetector integration, parent/child tracking
- server.ts: Orchestrator wiring, 11 API endpoints, SSE events
- types.ts: Re-exports, SessionState additions

Tests: 80 new tests across 3 test files (all passing)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 10:20:37 +01:00
arkonandClaude Opus 4.5 0e8c8b8c60 feat: auto-accept plan mode and question prompts in respawn controller
When Claude enters plan mode or asks a question (AskUserQuestion), output
stops without a completion message. The new autoAcceptPrompts feature
detects this state and sends Enter after a configurable delay (default 8s)
to accept the plan or select the default option, keeping Claude working
autonomously.

Enabled by default. Adds UI checkbox in the respawn config panel.
Safety: only fires once per silence period, requires prior output,
and won't fire during active respawn cycles.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 01:25:09 +01:00
arkonandClaude Opus 4.5 619f2a3403 fix: clean up test case directories after each test instead of at end
Moves case directory cleanup from afterAll to afterEach in all test
files that create cases. Previously, if the test suite was interrupted
or afterAll timed out, all case directories were left behind. Now each
test cleans up immediately after itself.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 22:54:26 +01:00
arkonandClaude Opus 4.5 ec92e5b1cf fix: respawn controller multi-layer detection and cleanup
- Update idle detection from legacy '↵ send' to completion message pattern
  ("for Xm Xs" time patterns like "Worked for 2m 46s")
- Add confirming_idle state for false positive prevention
- Add completionConfirmMs (5s) and noOutputTimeoutMs (30s) config options
- Add multi-layer detection with confidence scoring (0-100%)
- Fix null pointer error in extractTokenCount with guard clause
- Fix respawn controller not stopping on session cleanup (broadcast respawn:stopped)
- Update tests to use new completion message patterns
- Add detection status UI display (confidence level, waiting state)
- Update CLAUDE.md with new detection documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 19:24:36 +01:00
arkonandClaude Opus 4.5 34fb33fbc6 test: add global test setup with screen limits and reach 1337 tests
- Add test/setup.ts with max 10 concurrent screen sessions limiter
- Add orphaned Claude/screen process cleanup before/after tests
- Add semaphore-based screen slot acquisition for concurrency control
- Update vitest.config.ts with setupFiles and fileParallelism: false
- Add 16 new test files for comprehensive coverage
- Update README badge to show 1337 total tests
- Update CLAUDE.md with test setup documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 11:30:10 +01:00
arkonandClaude Opus 4.5 0d1ca37b6e refactor: rename inner-loop-tracker to ralph-tracker with API improvements
- Rename inner-loop-tracker.ts → ralph-tracker.ts throughout codebase
- Add ralph-config.ts for parsing .claude/ralph-loop.local.md config
- Standardize API error responses using createErrorResponse()
- Add input validation for auto-compact/auto-clear thresholds
- Update UI labels to "Ralph / Todo Tracker" consistently
- Add 46 integration tests for Ralph tracking functionality
- Update test badge to 438 total tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:36:45 +01:00
arkonandClaude Opus 4.5 c33d6e0987 refactor: improve code quality with stricter TypeScript and memory leak prevention
- Add stricter TypeScript compiler flags (noUnusedLocals, noUnusedParameters,
  noImplicitReturns, noImplicitOverride, noFallthroughCasesInSwitch,
  allowUnreachableCode, allowUnusedLabels)
- Remove unused variables caught by stricter flags:
  - Remove unused `renameSession` destructuring in App.tsx
  - Remove unused `BG_GRAY` constant in DirectAttach.ts
  - Remove unused `INPUT_BATCH_INTERVAL` constant in useSessionManager.ts
- Add proper EventEmitter cleanup to RalphLoop:
  - Store bound event handlers for cleanup
  - Add cleanupEventHandlers() method
  - Add destroy() method for complete cleanup
  - Add destroyRalphLoop() singleton cleanup function
- Update ralph-loop tests to use destroy() instead of stop() to prevent
  MaxListenersExceededWarning

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 14:01:47 +01:00
arkonandClaude Opus 4.5 d5ae376e07 feat(tui): add web server auto-start, shell mode, and feature parity
TUI now checks if web server is running on startup and offers to start
it in the background. Added new CLI options: --with-web (auto-start),
--no-web (skip check), -p (port).

TUI feature parity with web interface:
- Shell mode: press 'h' in cases view to start bash instead of Claude
- Multi-start: press 'm' to start 1-20 sessions at once
- Respawn toggle: Ctrl+R to enable/disable respawn on Claude sessions
- Session rename: API support via useSessionManager hook

Security fixes from previous analysis:
- Command injection prevention in screen-manager.ts
- Path traversal protection in server.ts
- Input validation for shell-interpolated values

Also fixes memory leak in session.ts (timer tracking) and flaky test
timeout in session-cleanup.test.ts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 09:54:42 +01:00
arkonandClaude Opus 4.5 921abd42a3 test: add unit tests for CLAUDE.md template generation
Adds 16 tests covering:
- Default template generation with case name and description
- Date placeholder replacement
- Claudeman environment section inclusion
- Work principles and TodoWrite guidance
- Ralph Wiggum Loop section
- Custom template loading and fallback behavior

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 08:36:25 +01:00
arkonandClaude Opus 4.5 2db50f5c61 test: add unit tests for types module utility functions
- Add 10 tests for types.ts helper functions
- Test createErrorResponse with all error codes
- Test createSuccessResponse with and without data
- Test createInitialInnerLoopState defaults
- Test createInitialInnerSessionState structure
- Test createInitialState with Ralph Loop and config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:37:57 +01:00
arkonandClaude Opus 4.5 5f66e052e7 test: add unit tests for StateStore class
- Add 27 tests covering state persistence and retrieval
- Test debounced save behavior with fake timers
- Test session, task, and config CRUD operations
- Test Ralph Loop state management
- Test inner state operations for session tracking
- Test persistence across store instances
- Uses real file system in temp directory for integration tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:33:16 +01:00
arkonandClaude Opus 4.5 e079151ac3 test: add unit tests for SessionManager class
- Add 29 tests covering session lifecycle management
- Test session creation, stopping, and cleanup
- Test event forwarding (output, error, completion, exit)
- Test max concurrent sessions limit
- Test session state persistence and retrieval
- Mock Session class to isolate unit tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:28:11 +01:00
arkonandClaude Opus 4.5 f27cde1e36 test: add unit tests for RalphLoop class
- Add 24 tests covering Ralph Loop lifecycle
- Test start, stop, pause, resume state transitions
- Test elapsed time tracking and min duration
- Test automatic stopping when conditions met
- Test stats reporting
- Use vi.hoisted() for mock state sharing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:23:49 +01:00
arkonandClaude Opus 4.5 e16242d32f test: add unit tests for Task class
- Add 25 tests covering Task model functionality
- Test constructor options and ID generation
- Test lifecycle methods (assign, complete, fail, reset)
- Test completion detection with promise tags
- Test timeout handling with fake timers
- Test serialization (toDefinition, toState, fromState)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:19:49 +01:00
arkonandClaude Opus 4.5 35b0a631a6 test: add unit tests for TaskQueue class
- Add 29 tests covering all TaskQueue methods
- Test priority ordering, dependency satisfaction
- Test task lifecycle (add, update, remove)
- Test filtering methods (pending, running, completed, failed)
- Test clear operations (clearCompleted, clearFailed, clearAll)
- Mock state-store to isolate unit tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:18:12 +01:00
arkonandClaude Opus 4.5 08b76cdb60 perf: add event debouncing to InnerLoopTracker
- Add EVENT_DEBOUNCE_MS constant (50ms) for batching rapid updates
- Add debounce timers and pending flags for todo/loop updates
- Add emitTodoUpdateDebounced() and emitLoopUpdateDebounced() methods
- Add flushPendingEvents() for testing/immediate sync needs
- Update reset()/fullReset() to clear debounce timers
- Replace rapid-fire emit calls with debounced versions
- Reduces UI jitter from rapid consecutive updates
- Tests updated to use flushPendingEvents() for synchronous testing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 05:41:30 +01:00
arkonandClaude Opus 4.5 78ee062c4d fix: update assignTask to use BufferAccumulator API
- Fix TypeScript error: assignTask() was still using string assignment
- Add extended timeout to session.test.ts afterAll hook to prevent
  flaky test failures during cleanup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 05:10:57 +01:00
arkonandClaude Opus 4.5 d741b82966 fix: improve terminal buffer cleaning and test reliability
- Add buffer cleaning to remove junk before Claude banner
- Fix test todo text to avoid pattern conflicts
- Add reset support to inner-config API endpoint

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 04:34:45 +01:00
arkonandClaude Opus 4.5 4f11e029e5 fix: resolve flaky tests and TypeScript errors
- Fix pty-interactive test: use shell mode for reliable output timing
- Fix session-cleanup test: account for restored sessions from parallel tests
- Fix quick-start test: increase afterAll timeout for server.stop()
- Fix scheduled-runs test: skip slow real-Claude test, increase timeout
- Fix TypeScript errors: add non-null assertions for screenSession

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:56:25 +01:00
arkonandClaude Opus 4.5 bc16459ecb refactor: optimize inner-loop-tracker performance and code quality
Performance improvements:
- Throttle cleanupExpiredTodos() to run every 30s instead of every chunk
- Add early exit in detectTodoItems() for lines without todo markers
- Remove redundant PROMISE_PATTERN check from LOOP_START_PATTERN

Code quality:
- Extract activateLoopIfNeeded() helper to eliminate duplicate loop start logic
- Improve hash function using djb2 algorithm for better distribution
- Add guards for empty/whitespace-only content in upsertTodo()
- Simplify startLoop() to use existing enable() method

Tests:
- Add 5 new tests for edge cases and optimizations
- Test empty content handling, early exit, ID uniqueness

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 15:16:22 +01:00
arkonandClaude Opus 4.5 af9290389c fix: detect Claude Code native TodoWrite checkbox format
- Add TODO_NATIVE_PATTERN to match ☐/☒/◐ icons from Claude Code's TodoWrite
- Add TODO_EXCLUDE_PATTERNS to filter out tool invocations (Bash, Search, etc.)
- Update iconToStatus() to recognize ☒ as completed
- Add tests for native checkbox detection

The tracker now correctly parses Claude Code's actual terminal output format
instead of only matching markdown checkboxes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 14:23:22 +01:00
arkonandClaude Opus 4.5 2c38f7924a feat(tracker): disable Ralph Wiggum tracker by default, auto-enable on detection
The InnerLoopTracker is now disabled by default and auto-enables when
Ralph-related patterns are detected:
- /ralph-loop command
- <promise>PHRASE</promise> completion phrases
- TodoWrite tool usage
- Iteration patterns (Iteration 5/50, [5/50])
- Todo checkboxes (- [ ]/- [x]) or indicator icons

This reduces noise for sessions that don't use Ralph loops while
maintaining full functionality when loops are detected.

Changes:
- Add `enabled` property to InnerLoopState type
- Add enable()/disable() methods to InnerLoopTracker
- Implement shouldAutoEnable() for pattern detection
- Update frontend to show "Tracking" status when enabled
- Add CSS for tracking state indicator
- Update CLAUDE.md documentation
- Add comprehensive tests for auto-enable behavior

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 18:34:43 +01:00
arkonandClaude Opus 4.5 684ccc2b07 feat(ralph): enhance Ralph Wiggum loop visualization
Add polished, animated Ralph Wiggum Loop panel with:
- Circular progress ring showing task completion percentage
- Task cards with status indicators (pending/in-progress/completed)
- Animated status badge with pulsing indicator when active
- Completion celebration animation with animated checkmark
- Smart time formatting ("1h 23m" instead of "1.38 hours")

Enhanced detection patterns based on official Ralph plugin:
- /ralph-loop command detection
- Iteration patterns: "Iteration 5/50", "[5/50]"
- Max iterations from YAML: "max-iterations: 50"
- TodoWrite tool output detection

Adds maxIterations field to InnerLoopState for tracking loop limits.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 17:09:56 +01:00
arkonandClaude Opus 4.5 ee8f6bd0cb feat: track Ralph Wiggum loops and todo lists in Claude sessions
Add InnerLoopTracker to detect and expose internal Claude Code state
running inside claudeman sessions by parsing terminal output patterns.

Detection patterns:
- Completion phrases: <promise>PHRASE</promise>
- Todo items: checkbox format, indicator icons, status parentheses
- Loop status: cycle counts, elapsed time, start/completion

New features:
- Inner state panel UI (collapsible, below session tabs)
- SSE events: innerLoopUpdate, innerTodoUpdate, innerCompletionDetected
- API endpoint: GET /api/sessions/:id/inner-state
- State persistence to ~/.claudeman/state-inner.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:21:01 +01:00
arkonandClaude Opus 4.5 a5b8628e53 refactor: hybrid indicator+timeout detection in respawn controller
- Primary: Use '↵ send' indicator for immediate response when ready
- Fallback: Use timeout-based detection for prompt patterns
- Add working indicators: Synthesizing, Brewing, ✻, ✽
- Cleaner step completion handlers (checkUpdateComplete, etc.)

The hybrid approach responds immediately when Claude shows the
suggestion indicator, while still having timeout fallback for
reliability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:32:36 +01:00
arkonandClaude Opus 4.5 c81d014ec1 test: add comprehensive test suite with 129 tests
- Add PTY interactive session tests
- Add SSE event streaming tests
- Add scheduled runs API tests
- Add edge case and error handling tests
- Add integration flow tests for user workflows
- Add respawn controller tests with edge cases
- Add session cleanup and resource management tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 21:35:34 +01:00