Class: Ace::LLM::Providers::CLI::Atoms::SessionFinders::PiSessionFinder
- Inherits:
-
Object
- Object
- Ace::LLM::Providers::CLI::Atoms::SessionFinders::PiSessionFinder
- Defined in:
- lib/ace/llm/providers/cli/atoms/session_finders/pi_session_finder.rb
Overview
Finds a Pi agent session by scanning JSONL session files.
Pi stores sessions under ~/.pi/agent/sessions/<encoded-path>/*.jsonl Path encoding: replace ‘/` with `-`, wrap in `–` Session ID: `type:“session”` entry → `id` field First user message: `message.role:“user”` + `message.content.text`
Constant Summary collapse
- DEFAULT_BASE =
File.("~/.pi/agent/sessions").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/pi_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 |