Skip to content

fix: support Claude Code session log format in readCursorTranscripts#350

Open
pickmemory wants to merge 1 commit intoEvoMap:mainfrom
pickmemory:fix/claude-code-session-log-support
Open

fix: support Claude Code session log format in readCursorTranscripts#350
pickmemory wants to merge 1 commit intoEvoMap:mainfrom
pickmemory:fix/claude-code-session-log-support

Conversation

@pickmemory
Copy link
Copy Markdown

Summary

  • formatSessionLog now handles Claude Code's JSONL format (type: "user"/"assistant") alongside the existing OpenClaw format (type: "message"). Extracts content from Claude Code's array-of-content-blocks, skips thinking blocks and meta messages.
  • readCursorTranscripts widens the time window from 24h to 7 days. Claude Code session logs are write-once — mtime never updates after the session ends, so the 24h filter left 0 usable files (only the current session, which gets skipped by RECENCY_GUARD_MS).
  • readCursorTranscripts dispatches .jsonl files to formatSessionLog (JSON-aware) and .txt files to formatCursorTranscript (plain-text). Previously all files went through the plain-text formatter, returning raw JSON lines for .jsonl input.

Motivation

When using EVOLVER_CURSOR_TRANSCRIPTS_DIR to point evolver at Claude Code's session log directory (~/.claude/projects/<project>/*.jsonl), evolver produced [NO SESSION LOGS FOUND] because:

  1. No files qualified under the 24h mtime window (write-once files)
  2. The plain-text formatter couldn't parse JSONL structure
  3. formatSessionLog only matched OpenClaw's type: "message" envelope, not Claude Code's type: "user"/"assistant"

Test plan

  • Verified with EVOLVER_VERBOSE=true node index.js run — session log size increased from 23 chars to 1975 chars
  • End-to-end hook workflow tested: signal → evolver run → prompt generation with real session content
  • Backward compatible: OpenClaw format still works (same data.type === 'message' check preserved)

🤖 Generated with Claude Code

Three changes to make evolver properly read Claude Code .jsonl session logs:

1. formatSessionLog: handle Claude Code format (top-level type "user"/"assistant")
   alongside existing OpenClaw format (type "message"). Skip thinking blocks and
   meta messages. Extract content from Claude Code's array-of-content-blocks.

2. readCursorTranscripts: widen time window from 24h to 7 days since Claude Code
   session logs are write-once (mtime never updates after session ends).

3. readCursorTranscripts: dispatch to formatSessionLog for .jsonl files and
   formatCursorTranscript for .txt files (Cursor agent-transcripts).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant