Skip to content

Comments

feat: multi-provider session scanning for discover and learn#255

Open
sahilmgandhi wants to merge 1 commit intortk-ai:masterfrom
sahilmgandhi:feature/multi-provider-discover
Open

feat: multi-provider session scanning for discover and learn#255
sahilmgandhi wants to merge 1 commit intortk-ai:masterfrom
sahilmgandhi:feature/multi-provider-discover

Conversation

@sahilmgandhi
Copy link

@sahilmgandhi sahilmgandhi commented Feb 23, 2026

A followup to #254, wanted to add more provider support for rtk discover and rtk learn. We don't need it for rtk gain since all rtk commands automatically populate the sqllite db with usage data.

Summary

  • Add session scanning support for Codex CLI, Cline, and Cursor alongside existing Claude Code provider
  • New --tool / -t flag on rtk discover and rtk learn to filter by tool (claude, codex, cline, cursor)
  • Report header now shows which tools were scanned; "Bash commands" → "shell commands"

New Providers

Provider Session Format Location
CodexProvider JSONL rollout files ~/.codex/sessions/ ($CODEX_HOME override)
ClineProvider JSON conversation history ~/.cline/tasks/ + VS Code extension storage
CursorProvider SQLite databases state.vscdb (desktop) + store.db (agent CLI)

Shared Infrastructure

  • ToolSource enum with short_name() / display_name()
  • build_providers(tool_filter) factory with validation
  • cutoff_from_days(), is_recent(), join_tool_uses_with_results() shared helpers
  • OUTPUT_PREVIEW_CHARS constant (was magic 1000 in 4 places)

Design Decisions

  • Providers that aren't installed return Ok(vec![]) — no errors for missing tools
  • Cursor parsing is best-effort (undocumented format, read-only SQLite access)
  • Project filtering: Claude encodes CWD internally; Codex peeks at SessionMeta; Cline/Cursor don't have project-scoped sessions
  • No new dependencies — rusqlite already existed for tracking

Test plan

  • 36 new unit tests across all 3 providers + trait tests (446 total, all passing)
  • cargo fmt --all --check clean
  • cargo clippy --all-targets — 0 errors
  • Manual: rtk discover --all scans all installed tools
  • Manual: rtk discover --tool claude filters to Claude only
  • Manual: rtk discover --tool invalid returns helpful error
  • Manual: rtk discover --format json includes tools_scanned field
  ┌────────────────────┬───────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  │        Test        │              Command              │                                                                 Result                                                                 │
  ├────────────────────┼───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ Scan all tools     │ rtk discover --all                │ PASS — Header shows Tools: Claude Code, Codex CLI, Cline, Cursor. Found 319 sessions (316 Claude + 3 Cline). Reports "shell commands". │
  ├────────────────────┼───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ Filter by tool     │ rtk discover --tool claude --all  │ PASS — Header shows Tools: Claude Code. Found 316 sessions (Claude only).                                                              │
  ├────────────────────┼───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ Invalid tool error │ rtk discover --tool invalid --all │ PASS — Error: Unknown tool 'invalid'. Valid options: claude, codex, cline, cursor (exit code 1).                                       │
  ├────────────────────┼───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ JSON tools_scanned │ rtk discover --all --format json  │ PASS — JSON includes "tools_scanned": ["Claude Code", "Codex CLI", "Cline", "Cursor"].                                                 │
  └────────────────────┴───────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Add support for scanning sessions from Codex CLI, Cline, and Cursor
in addition to Claude Code. Each tool has a dedicated provider that
knows how to find and parse its session format:

- CodexProvider: JSONL rollout files from ~/.codex/sessions/
- ClineProvider: JSON conversation files from ~/.cline/tasks/
- CursorProvider: SQLite databases (state.vscdb + store.db)

Both `rtk discover` and `rtk learn` now loop over all installed
providers. A new `--tool` / `-t` flag filters to a single tool.
The report header shows which tools were scanned.

Shared infrastructure: ToolSource enum, cutoff_from_days(),
is_recent(), join_tool_uses_with_results(), OUTPUT_PREVIEW_CHARS
constant to reduce duplication across providers.
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