Class: Agent::Sessions::Adapters::Copilot

Inherits:
Base
  • Object
show all
Defined in:
lib/agent/sessions/adapters/copilot.rb

Overview

GitHub Copilot CLI. Verified against a real store on this machine (2026-08-24): ~/.copilot/session-store.db, schema_version 3, one session.

This store has MOVED since tokentelemetry's parser was written against it: that reads ~/.copilot/session-state//events.jsonl, and no such file exists here. The session-state// directory does still exist as a companion (workspace.yaml, checkpoints/, files/, research/), but the session record itself is now a row in SQLite. An adapter following the older spec would report nothing on a current install — the failure this gem's verified_on dates exist to make visible.

Constant Summary collapse

SESSION_COLUMNS =

created_at/updated_at are ISO 8601 strings here, not the epoch milliseconds opencode and Cursor use — verified against a real row ("2026-05-26T04:36:01.288Z").

"id, cwd, created_at, updated_at"

Constants inherited from Base

Base::FIDELITIES

Constants included from Enumeration

Enumeration::MAX_LINE_BYTES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#base_dir, fidelity_value, homedir_config, #initialize, #locate, #retention, #retention_source, store_configs, #verify, #warnings

Methods included from Enumeration

#bytes_for, #encode_project, #project_dir_name, #project_path_for, #session_id_from, #started_at_for, #updated_at_for

Constructor Details

This class inherits a constructor from Agent::Sessions::Adapters::Base

Class Method Details

.reader_classObject



23
# File 'lib/agent/sessions/adapters/copilot.rb', line 23

def self.reader_class = Readers::Copilot

Instance Method Details

#project_pathsObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/agent/sessions/adapters/copilot.rb', line 63

def project_paths
  db_path = primary_layer.path
  return [] unless File.exist?(db_path)

  paths = []
  each_session_row(db_path, "SELECT DISTINCT cwd FROM sessions ORDER BY cwd") do |row|
    paths << row.first if row.first.is_a?(String)
  end
  paths.uniq
end

#sessionsObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/agent/sessions/adapters/copilot.rb', line 38

def sessions
  db_path = primary_layer.path
  return [].lazy unless File.exist?(db_path)

  Enumerator.new do |yielder|
    each_session_row(db_path, "SELECT #{SESSION_COLUMNS} FROM sessions") do |row|
      yielder << build_row_session(db_path, row)
    end
  end.lazy
end

#sessions_for_project(dir) ⇒ Object

cwd is a real column holding a real absolute path, so filtering is a WHERE clause rather than a read-and-compare loop.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/agent/sessions/adapters/copilot.rb', line 51

def sessions_for_project(dir)
  dir = File.expand_path(dir)
  db_path = primary_layer.path
  return [].lazy unless File.exist?(db_path)

  Enumerator.new do |yielder|
    each_session_row(db_path, "SELECT #{SESSION_COLUMNS} FROM sessions WHERE cwd = ?", [dir]) do |row|
      yielder << build_row_session(db_path, row)
    end
  end.lazy
end