|
| 1 | +--- |
| 2 | +warning: DO NOT CHANGE THIS MANUALLY, THIS IS GENERATED BY https://github/duckdb/community-extensions repository, check README there |
| 3 | +title: agent_data |
| 4 | +excerpt: | |
| 5 | + DuckDB Community Extensions |
| 6 | + A DuckDB extension written in Rust for querying, analysing and inspecting AI coding agents history. Read conversations, plans, todos, history, and usage stats directly from your local agent data directories. |
| 7 | +
|
| 8 | +extension: |
| 9 | + name: agent_data |
| 10 | + description: A DuckDB extension written in Rust for querying, analysing and inspecting AI coding agents history. Read conversations, plans, todos, history, and usage stats directly from your local agent data directories. |
| 11 | + version: 0.1.0 |
| 12 | + language: Rust |
| 13 | + build: cargo |
| 14 | + license: MIT |
| 15 | + excluded_platforms: "wasm_mvp;wasm_eh;wasm_threads;linux_amd64_musl" |
| 16 | + requires_toolchains: "rust" |
| 17 | + maintainers: |
| 18 | + - axsaucedo |
| 19 | + |
| 20 | +repo: |
| 21 | + github: axsaucedo/agent_data_duckdb |
| 22 | + ref: 1348a6d1a25ada29f78087e1469dfbff3bb095e1 |
| 23 | + |
| 24 | +docs: |
| 25 | + hello_world: | |
| 26 | + -- How many conversations have I had with Claude? |
| 27 | + SELECT COUNT(DISTINCT session_id) AS sessions, |
| 28 | + COUNT(*) AS total_messages |
| 29 | + -- Calling the functions without params defaults to Claude folder. |
| 30 | + FROM read_conversations(); |
| 31 | +
|
| 32 | + -- What did I work on this week? |
| 33 | + SELECT date, message_count, tool_call_count |
| 34 | + FROM read_stats() |
| 35 | + ORDER BY date DESC |
| 36 | + LIMIT 7; |
| 37 | +
|
| 38 | + -- Which tools does github copilot use most? |
| 39 | + SELECT tool_name, COUNT(*) AS uses |
| 40 | + FROM read_conversations('~/.copilot') |
| 41 | + WHERE tool_name IS NOT NULL |
| 42 | + GROUP BY tool_name |
| 43 | + ORDER BY uses DESC |
| 44 | + LIMIT 10; |
| 45 | +
|
| 46 | + -- What are my active todos in my custom claude path? |
| 47 | + SELECT content, status |
| 48 | + FROM read_todos('~/work_folder/.claude') |
| 49 | + WHERE status != 'completed' |
| 50 | + ORDER BY item_index; |
| 51 | +
|
| 52 | + -- Compare activity across Claude and Copilot |
| 53 | + SELECT source, COUNT(DISTINCT session_id) AS sessions, COUNT(*) AS messages |
| 54 | + FROM ( |
| 55 | + SELECT * FROM read_conversations(path='~/.claude') |
| 56 | + UNION ALL |
| 57 | + SELECT * FROM read_conversations(path='~/.copilot') |
| 58 | + ) |
| 59 | + GROUP BY source; |
| 60 | +
|
| 61 | + extended_description: | |
| 62 | +
|
| 63 | + **Supported agents:** [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (`~/.claude`) and [GitHub Copilot CLI](https://docs.github.com/en/copilot/github-copilot-in-the-cli) (`~/.copilot`). |
| 64 | +
|
| 65 | + > OpenAI Codex and Gemini CLI Coming Soon™. |
| 66 | +
|
| 67 | + Written in 🦀 Rust. |
| 68 | +
|
| 69 | + ### Default Behavior |
| 70 | +
|
| 71 | + When called **without arguments**, each function reads from its provider's default path: |
| 72 | +
|
| 73 | + | Function | Default path | Detected as | |
| 74 | + |----------|-------------|-------------| |
| 75 | + | `read_conversations()` | `~/.claude` | Claude Code | |
| 76 | + | `read_plans()` | `~/.claude` | Claude Code | |
| 77 | + | `read_todos()` | `~/.claude` | Claude Code | |
| 78 | + | `read_history()` | `~/.claude` | Claude Code | |
| 79 | + | `read_stats()` | `~/.claude` | Claude Code | |
| 80 | +
|
| 81 | + To read Copilot data, pass the path explicitly: |
| 82 | +
|
| 83 | + ```sql |
| 84 | + FROM read_conversations(path='~/.copilot'); |
| 85 | + ``` |
| 86 | +
|
| 87 | + ### Available Functions |
| 88 | +
|
| 89 | + All functions accept two optional parameters: |
| 90 | + - **`path`** — data directory path (default: `~/.claude`). Auto-detected from folder structure (`projects/` → Claude, `session-state/` → Copilot). |
| 91 | + - **`source`** — explicit provider override: `'claude'` or `'copilot'`. Use when auto-detection fails or for non-standard directory layouts. |
| 92 | +
|
| 93 | + Every table includes a **`source`** column (`'claude'` or `'copilot'`) as the first column. |
| 94 | +
|
| 95 | + > `read_conversations([path (opt)], [source (opt)])` |
| 96 | +
|
| 97 | + ## Join Keys |
| 98 | +
|
| 99 | + Tables can be joined within the same source: |
| 100 | +
|
| 101 | + ```sql |
| 102 | + -- Conversations ↔ History (via session_id) |
| 103 | + SELECT c.*, h.display |
| 104 | + FROM read_conversations(path='~/.claude') c |
| 105 | + JOIN read_history(path='~/.claude') h ON c.session_id = h.session_id; |
| 106 | +
|
| 107 | + -- Cross-source: always filter by source |
| 108 | + SELECT * FROM ( |
| 109 | + SELECT * FROM read_conversations(path='~/.claude') |
| 110 | + UNION ALL |
| 111 | + SELECT * FROM read_conversations(path='~/.copilot') |
| 112 | + ) WHERE source = 'copilot'; |
| 113 | + ``` |
| 114 | +
|
| 115 | + | Join | Left Key | Right Key | Notes | |
| 116 | + |------|----------|-----------|-------| |
| 117 | + | conversations <-> history | `session_id` | `session_id` | Same source only | |
| 118 | + | conversations <-> todos | `session_id` | `session_id` | Same source only | |
| 119 | + | conversations <-> plans | `slug` | `plan_name` | Claude only | |
| 120 | + | conversations <-> history | `project_path` | `project` | Claude only | |
| 121 | +
|
| 122 | + For full documentation, see the [GitHub repository](https://github.com/axsaucedo/duckdb-claude-ext). |
| 123 | +
|
| 124 | +extension_star_count: 0 |
| 125 | +extension_star_count_pretty: 0 |
| 126 | +extension_download_count: null |
| 127 | +extension_download_count_pretty: n/a |
| 128 | +image: '/images/community_extensions/social_preview/preview_community_extension_agent_data.png' |
| 129 | +layout: community_extension_doc |
| 130 | +--- |
| 131 | + |
| 132 | +### Installing and Loading |
| 133 | +```sql |
| 134 | +INSTALL {{ page.extension.name }} FROM community; |
| 135 | +LOAD {{ page.extension.name }}; |
| 136 | +``` |
| 137 | + |
| 138 | +{% if page.docs.hello_world %} |
| 139 | +### Example |
| 140 | +```sql |
| 141 | +{{ page.docs.hello_world }}``` |
| 142 | +{% endif %} |
| 143 | +
|
| 144 | +{% if page.docs.extended_description %} |
| 145 | +### About {{ page.extension.name }} |
| 146 | +{{ page.docs.extended_description }} |
| 147 | +{% endif %} |
| 148 | +
|
| 149 | +### Added Functions |
| 150 | +
|
| 151 | +<div class="extension_functions_table"></div> |
| 152 | +
|
| 153 | +| function_name | function_type | description | comment | examples | |
| 154 | +|--------------------|---------------|-------------------------------------------------------------------------|-----------------------------------------------------------------|--------------------------------------------------------------------------| |
| 155 | +| read_conversations | table | Read conversation messages and tool calls from AI coding agent sessions | Supports Claude Code and GitHub Copilot CLI with auto-detection | [SELECT * FROM read_conversations(path='~/.claude') LIMIT 10;] | |
| 156 | +| read_plans | table | Read plan and strategy markdown files from agent sessions | Claude: plans/*.md, Copilot: session-state/*/plan.md | [SELECT plan_name, file_size FROM read_plans();] | |
| 157 | +| read_todos | table | Read todo and checklist items with status tracking | Claude: todos/*.json, Copilot: checkpoint markdown checklists | [SELECT content, status FROM read_todos() WHERE status != 'completed';] | |
| 158 | +| read_history | table | Read command and prompt history | Claude: history.jsonl, Copilot: command-history-state.json | [SELECT display FROM read_history() ORDER BY line_number DESC LIMIT 10;] | |
| 159 | +| read_stats | table | Read daily activity statistics (message, session, and tool call counts) | Currently Claude only — returns empty for Copilot | [SELECT date, message_count FROM read_stats() ORDER BY date DESC;] | |
| 160 | +
|
| 161 | +
|
0 commit comments