Commit graph

9 commits

Author SHA1 Message Date
jedarden
26e824772d fix(types): update NeedleEventType to match current NEEDLE output
- Updated NeedleEventType union to reflect actual event types emitted by NEEDLE
- Fixed outdated event type names (e.g., bead.claimed → bead.claim.succeeded)
- Added missing event types (worker.errored, worker.exhausted, peer.stale, etc.)
- Updated parser test to use correct event types
- Verified parser compatibility with 86,545 actual NEEDLE log events (100% success rate)

The parser's normalizeJsonl function accepts any string for event_type,
ensuring forward compatibility with new NEEDLE versions. The type
definition update is primarily for documentation and IDE support.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 22:29:50 -04:00
jedarden
51520a35ac feat(bd-6q2): refactor parser to emit NeedleEvent, keep LogEvent as adapter
- Tighten parseNeedleEvent signature to accept string (JSON line) and
  preserve all canonical fields (timestamp, event_type, worker_id,
  session_id, sequence, bead_id, data)
- Make parseLogLine a thin adapter that calls parseNeedleEvent then
  projects to legacy LogEvent via needleEventToLogEvent
- Add comprehensive parseNeedleEvent unit tests covering canonical format,
  session_id/sequence/data round-trip, all 47 NeedleEventType values,
  schema version validation, and legacy format conversion
- Rewrite parser.real-logs.integration.test.ts to assert NeedleEvent
  shape against real ~/.needle/logs/*.jsonl fixtures

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 13:00:41 -04:00
jedarden
374be30dac fix(bd-vqd): Align NeedleLogEntry and parser with NEEDLE telemetry format
- NeedleLogEntry.worker: accept string | NeedleWorkerObject (NEEDLE emits
  flat runner-provider-model-identifier strings)
- Add optional level field to NeedleLogEntry (NEEDLE always includes it)
- parseNeedleFormat: reconstruct worker as runner-provider-model-identifier
  from legacy object form (was missing provider and model)
- parseNeedleFormat: gate provider/model extraction on object form (was
  accessing .provider/.model unconditionally, yielding undefined)
- parseNeedleFormat: prefer entry.level over inferred level
- inferLogLevel: match NEEDLE's _needle_telemetry_infer_level rules exactly
  (prefix/suffix matching: error.*, *.failed, *.retry, debug.*)
- Add NeedleEventType, NeedleWorkerStatus types to types.ts
- Add session/provider/model optional fields to LogEvent
- Fix store.ts status detection: match on exact NEEDLE event types instead
  of substring-based heuristics
- Update all tests to match corrected behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 22:39:04 -04:00
jeda
76919e94b9 feat(bd-193s): Add NEEDLE log format tests to parser.test.ts
Add comprehensive test coverage for NEEDLE structured log format:
- worker.started event parsing
- bead.claimed event with bead_id extraction
- bead.completed event with duration
- bead.claim_retry event (warn level inference)
- bead.claim_exhausted event (error level inference)
- heartbeat.emitted event
- worker.idle event
- effort.recorded event
- Level inference from event names (error, warn, debug, info)
- ISO 8601 timestamp conversion to Unix milliseconds
- Worker identifier flattening (runner-identifier format)
- Mixed NEEDLE and legacy format handling

Uses actual log samples from ~/.needle/logs/ as test fixtures.

Co-Authored-By: Claude Worker <noreply@anthropic.com>
2026-03-04 23:19:52 +00:00
jeda
f1a6bb6691 feat(bd-2fxx): Align parser to NEEDLE's actual log schema
- Accept ISO timestamp strings, convert to Unix milliseconds for internal use
- Use 'event' field as event type (map to 'msg' for internal use)
- Flatten worker object to string: ${runner}-${identifier}
- Infer log level from event name (error/warn/info/debug)
- Extract bead_id, duration_ms from data payload
- Add session, provider, model fields from NEEDLE format
- Maintain backward compatibility with legacy format
- Add comprehensive NEEDLE format test cases

Verified with actual NEEDLE log files:
- 146/146 lines parsed successfully
- Correctly identifies error-level events (claim_exhausted)
- Correctly identifies warn-level events (claim_retry)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Worker <noreply@anthropic.com>
2026-03-04 23:19:21 +00:00
jeda
1a331eafaa feat(bd-122): Parse conversation events from NEEDLE logs
Add ConversationEvent types and parsing functions to extract conversation
events from NEEDLE log entries:

Types added to types.ts:
- ConversationRole: system, user, assistant, tool
- ConversationEventType: prompt, response, thinking, tool_call, tool_result
- PromptEvent: User input/prompt
- ResponseEvent: Assistant response text
- ThinkingEvent: Internal reasoning/thinking block
- ToolCallEvent: Tool being called with arguments
- ToolResultEvent: Result from a tool call
- ConversationSession: Complete conversation session
- ConversationParseOptions: Options for parsing

Functions added to parser.ts:
- isConversationEvent(): Check if log event contains conversation content
- parseConversationEvent(): Parse single log event to conversation event
- parseConversationEvents(): Parse multiple log events
- parseConversationLine(): Parse single log line
- parseConversationContent(): Parse multi-line log content
- formatConversationEvent(): Format for display

Features:
- Supports explicit conversation fields (conversation_role, conversation_type)
- Supports content fields (prompt, response, thinking, tool_result)
- Supports tool call parsing with arguments normalization
- Content truncation for large responses
- Human-readable tool summaries (e.g., "Read /src/main.ts")
- Filtering options for thinking blocks and tool results

Comprehensive unit tests added for all conversation parsing functions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Worker <noreply@anthropic.com>
2026-03-04 04:23:09 +00:00
jeda
f8e17ee2ab feat(bd-3jl): FileHeatmap integration complete + build fixes
FileHeatmap component is fully integrated into main TUI app:
- Keyboard shortcut 'H' toggles heatmap view
- Real-time file access aggregation from event store
- Shows most-touched files with multiple sort modes
- All tests passing (943 tests, including 130 FileHeatmap tests)

Additional fixes:
- Fixed ErrorGroupPanel options to support bottom property
- Added vitest globals configuration for proper TypeScript support
- Fixed type assertions in server.test.ts
- Created comprehensive integration documentation

Co-Authored-By: Claude Worker <noreply@anthropic.com>
2026-03-04 04:18:13 +00:00
jeda
43f5640442 feat(bd-3dz): Add comprehensive unit tests for parser.ts
Added extensive test coverage including:
- Edge cases with optional field type validation
- Unicode and special character handling
- Very long messages and timestamps
- Custom field preservation (arrays, objects, nested data)
- Performance tests with large batches (1000, 5000, 10000 lines)
- Mixed valid/invalid line handling
- Empty string handling for optional fields
- Duration formatting edge cases
- Worker ID edge cases

All 67 tests passing, performance target met (<1s for 1000 lines, <5s for 10000 lines).

Co-Authored-By: Claude Worker <noreply@anthropic.com>
2026-03-04 03:11:38 +00:00
jeda
57e8193f7b feat(bd-2kf): Add comprehensive test coverage for parser and store
- Add 36 parser tests covering:
  - parseLogLine with valid/invalid inputs
  - parseLogLines for multi-line parsing
  - formatEvent with all options
  - Edge cases: malformed JSON, missing fields, colorization

- Add 35 store tests covering:
  - InMemoryEventStore add/query operations
  - Worker status tracking (active/idle/error)
  - Event filtering by worker, level, bead, timestamp
  - maxEvents limit and LRU trimming
  - getStore/resetStore singleton management

- Close phase beads (bd-2pa, bd-n8l, bd-2nu) as infrastructure complete
- Close test beads (bd-5eh, bd-2en) with comprehensive coverage
- Total: 91 tests passing across parser, store, and tailer

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-03 10:43:24 +00:00