Class: Ace::LLM::Providers::CLI::Atoms::SessionFinders::ClaudeSessionFinder
- Inherits:
-
Object
- Object
- Ace::LLM::Providers::CLI::Atoms::SessionFinders::ClaudeSessionFinder
- Defined in:
- lib/ace/llm/providers/cli/atoms/session_finders/claude_session_finder.rb
Overview
Finds a Claude Code session by scanning JSONL session files.
Claude stores sessions under ~/.claude/projects/<encoded-path>/*.jsonl Path encoding: replace ‘/` and `.` with `-` Session ID: `sessionId` field on conversation entries First user message: `type:“user”` with `message.content` string
Constant Summary collapse
- DEFAULT_BASE =
File.("~/.claude/projects").freeze
Class Method Summary collapse
-
.call(working_dir:, prompt:, base_path: DEFAULT_BASE, max_candidates: 5) ⇒ Hash?
{ session_id:, session_path: } or nil.
Class Method Details
.call(working_dir:, prompt:, base_path: DEFAULT_BASE, max_candidates: 5) ⇒ Hash?
Returns { session_id:, session_path: } or nil.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ace/llm/providers/cli/atoms/session_finders/claude_session_finder.rb', line 25 def self.call(working_dir:, prompt:, base_path: DEFAULT_BASE, max_candidates: 5) encoded = encode_path(working_dir) project_dir = File.join(base_path, encoded) return nil unless File.directory?(project_dir) candidates = Dir.glob(File.join(project_dir, "*.jsonl")) .sort_by { |f| -File.mtime(f).to_f } .first(max_candidates) candidates.each do |path| result = scan_file(path, prompt) return result if result end nil rescue nil end |