skiagram_core/adapters/cursor.rs
1//! Cursor adapter — STUB, intentionally deferred (CLAUDE.md §11 v0.4).
2//!
3//! Schema VERIFIED against real local data 2026-06-16 (Windows, `%APPDATA%`):
4//! - Chat lives in the **`cursorDiskKV`** table of `state.vscdb` (NOT `ItemTable`,
5//! which only holds UI/workbench keys). Cross-workspace conversations are in
6//! `User/globalStorage/state.vscdb`; per-workspace ones under
7//! `User/workspaceStorage/<hash>/state.vscdb`.
8//! - Keys: `composerData:<composerId>` = one conversation
9//! (`modelConfig.modelName`, `contextTokensUsed`/`contextTokenLimit`,
10//! `fullConversationHeadersOnly` ordering); `bubbleId:<composerId>:<bubbleId>`
11//! = one message (`type`, `requestId`, `toolFormerData`, `toolResults`, and a
12//! `tokenCount: { inputTokens, outputTokens }`).
13//!
14//! WHY DEFERRED (not a difficulty — a payoff problem): on real data the per-message
15//! `tokenCount` is **~99% zeroed** (3 of 275 bubbles non-zero in a real
16//! globalStorage db) and `modelConfig.modelName` is frequently the literal
17//! `"default"` (unresolvable to a price). So Cursor cannot deliver skiagram's core
18//! "correct accounting" wedge — it would be a structural-only adapter (sessions /
19//! models / context-window fill) like the Copilot one. Implementing it also pulls
20//! in `rusqlite` with the bundled C SQLite (a compiled dep on a project that prizes
21//! a lean static binary, §12). The cost/benefit doesn't clear the bar yet; revisit
22//! if Cursor starts recording real per-request usage. Open READ-ONLY when built.
23
24use crate::adapters::Adapter;
25use crate::model::{Session, SessionRef};
26
27pub struct Cursor;
28
29impl Adapter for Cursor {
30 fn id(&self) -> &'static str {
31 "cursor"
32 }
33
34 fn detect(&self) -> bool {
35 // `config_dir` = %APPDATA% / ~/Library/Application Support / ~/.config.
36 directories::BaseDirs::new().is_some_and(|b| {
37 b.config_dir()
38 .join("Cursor")
39 .join("User")
40 .join("workspaceStorage")
41 .is_dir()
42 })
43 }
44
45 fn discover(&self) -> anyhow::Result<Vec<SessionRef>> {
46 anyhow::bail!("cursor adapter not yet implemented — deferred by design (Cursor's per-request token counts are ~99% zeroed on real data); see adapters/cursor.rs module docs")
47 }
48
49 fn parse(&self, _r: &SessionRef) -> anyhow::Result<Session> {
50 anyhow::bail!("cursor adapter not yet implemented")
51 }
52}