copilot-session-tools 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. copilot_session_tools-0.1.1/CHANGELOG.md +31 -0
  2. copilot_session_tools-0.1.1/LICENSE +21 -0
  3. copilot_session_tools-0.1.1/PKG-INFO +375 -0
  4. copilot_session_tools-0.1.1/README.md +344 -0
  5. copilot_session_tools-0.1.1/pyproject.toml +186 -0
  6. copilot_session_tools-0.1.1/src/copilot_session_tools/__init__.py +72 -0
  7. copilot_session_tools-0.1.1/src/copilot_session_tools/cli.py +993 -0
  8. copilot_session_tools-0.1.1/src/copilot_session_tools/database.py +1848 -0
  9. copilot_session_tools-0.1.1/src/copilot_session_tools/html_exporter.py +270 -0
  10. copilot_session_tools-0.1.1/src/copilot_session_tools/markdown_exporter.py +426 -0
  11. copilot_session_tools-0.1.1/src/copilot_session_tools/py.typed +0 -0
  12. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/__init__.py +73 -0
  13. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/cli.py +606 -0
  14. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/content.py +313 -0
  15. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/diff.py +297 -0
  16. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/discovery.py +365 -0
  17. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/git.py +114 -0
  18. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/models.py +122 -0
  19. copilot_session_tools-0.1.1/src/copilot_session_tools/scanner/vscode.py +693 -0
  20. copilot_session_tools-0.1.1/src/copilot_session_tools/web/__init__.py +107 -0
  21. copilot_session_tools-0.1.1/src/copilot_session_tools/web/templates/error.html +61 -0
  22. copilot_session_tools-0.1.1/src/copilot_session_tools/web/templates/index.html +1072 -0
  23. copilot_session_tools-0.1.1/src/copilot_session_tools/web/templates/session.html +1592 -0
  24. copilot_session_tools-0.1.1/src/copilot_session_tools/web/webapp.py +610 -0
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2025-02-13
9
+
10
+ ### Added
11
+
12
+ - **Scanner**: Scan VS Code workspace storage (Stable and Insiders editions) to find Copilot chat sessions
13
+ - **Scanner**: GitHub Copilot CLI chat history support (JSONL format from `~/.copilot/session-state`)
14
+ - **Scanner**: Support for VS Code JSONL append-log format (VS Code >=1.109)
15
+ - **Database**: SQLite storage with FTS5 full-text search indexing
16
+ - **Database**: Two-layer design with raw compressed JSON as source of truth and derived tables
17
+ - **Database**: Incremental scan support (only imports new/changed sessions)
18
+ - **CLI**: `scan` command to import sessions from VS Code and CLI
19
+ - **CLI**: `search` command with advanced query syntax (field filters, exact phrases, boolean logic)
20
+ - **CLI**: `stats` command for database statistics
21
+ - **CLI**: `export` command for JSON export
22
+ - **CLI**: `export-markdown` command for Markdown export
23
+ - **CLI**: `export-html` command for self-contained HTML export
24
+ - **CLI**: `import-json` command for JSON import
25
+ - **CLI**: `rebuild` command to recreate derived tables from raw JSON
26
+ - **Web**: Flask-based web interface for browsing chat sessions
27
+ - **Web**: Full-text search with highlighting
28
+ - **Web**: Dark mode support via CSS `prefers-color-scheme`
29
+ - **Web**: Syntax highlighting for code blocks
30
+ - **Web**: Incremental refresh without restarting
31
+ - **Tracking**: Tool invocations, file changes, and command runs from chat sessions
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 copilot-session-tools contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,375 @@
1
+ Metadata-Version: 2.4
2
+ Name: copilot-session-tools
3
+ Version: 0.1.1
4
+ Summary: A collection of tools for VS Code GitHub Copilot chat history
5
+ Keywords: copilot,github,vscode,chat,archive,history
6
+ Author: Arithmomaniac
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: Utilities
16
+ Requires-Dist: orjson>=3.9.0
17
+ Requires-Dist: jinja2>=3.0.0
18
+ Requires-Dist: markdown>=3.4.0
19
+ Requires-Dist: copilot-session-tools[cli,web] ; extra == 'all'
20
+ Requires-Dist: typer>=0.12.0 ; extra == 'cli'
21
+ Requires-Dist: rich>=13.0.0 ; extra == 'cli'
22
+ Requires-Dist: flask>=3.0.0 ; extra == 'web'
23
+ Requires-Python: >=3.12
24
+ Project-URL: Homepage, https://github.com/Arithmomaniac/copilot-session-tools
25
+ Project-URL: Repository, https://github.com/Arithmomaniac/copilot-session-tools
26
+ Project-URL: Issues, https://github.com/Arithmomaniac/copilot-session-tools/issues
27
+ Provides-Extra: all
28
+ Provides-Extra: cli
29
+ Provides-Extra: web
30
+ Description-Content-Type: text/markdown
31
+
32
+ # Copilot Session Tools
33
+
34
+ [![CI](https://github.com/Arithmomaniac/copilot-session-tools/actions/workflows/ci.yml/badge.svg)](https://github.com/Arithmomaniac/copilot-session-tools/actions/workflows/ci.yml) [![PyPI](https://img.shields.io/pypi/v/copilot-session-tools)](https://pypi.org/project/copilot-session-tools/) [![Python](https://img.shields.io/pypi/pyversions/copilot-session-tools)](https://pypi.org/project/copilot-session-tools/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
35
+
36
+ Create a searchable archiveof your VS Code and GitHub Copilot CLI chat history, with a web viewer similar to [simonw/claude-code-transcripts](https://github.com/simonw/claude-code-transcripts).
37
+
38
+ This project was informed by and borrows patterns from several excellent open-source projects:
39
+
40
+ | Project | What We Borrowed |
41
+ |---------|------------------|
42
+ | [simonw/claude-code-transcripts](https://github.com/simonw/claude-code-transcripts) | HTML transcript generation, pagination approach, CLI structure |
43
+ | [Arbuzov/copilot-chat-history](https://github.com/Arbuzov/copilot-chat-history) | VS Code Copilot chat session data format, workspace organization |
44
+ | [jazzyalex/agent-sessions](https://github.com/jazzyalex/agent-sessions) | Multi-agent session concept, SQLite indexing patterns |
45
+ | [tad-hq/universal-session-viewer](https://github.com/tad-hq/universal-session-viewer) | FTS5 full-text search design, session metadata schema |
46
+
47
+ ## Features
48
+
49
+ - **Scan** VS Code workspace storage to find Copilot chat sessions (format based on [Arbuzov/copilot-chat-history](https://github.com/Arbuzov/copilot-chat-history))
50
+ - **Support** for both VS Code Stable and Insiders editions
51
+ - **GitHub Copilot CLI** chat history support (JSONL format from `~/.copilot/session-state`)
52
+ - **Store** chat history in a SQLite database with FTS5 full-text search (inspired by [tad-hq/universal-session-viewer](https://github.com/tad-hq/universal-session-viewer))
53
+ - **Browse** your archive with a web interface (similar to [simonw/claude-code-transcripts](https://github.com/simonw/claude-code-transcripts))
54
+ - **Export/Import** sessions as JSON, Markdown, or self-contained HTML for backup or migration
55
+ - **Tool invocations & file changes** tracking from chat sessions
56
+
57
+ ## Project Structure
58
+
59
+ This is a Python package with optional extras for CLI and web interfaces:
60
+
61
+ - **Base package**: Core utilities (database, scanner, markdown exporter)
62
+ - **[cli] extra**: Command-line interface built with Typer
63
+ - **[web] extra**: Flask-based web interface for browsing chat sessions
64
+ - **[all] extra**: Both CLI and web interfaces
65
+
66
+ ## Installation
67
+
68
+ ```bash
69
+ # Install with CLI
70
+ pip install copilot-session-tools[cli]
71
+
72
+ # Install with web interface
73
+ pip install copilot-session-tools[web]
74
+
75
+ # Install everything (CLI + web)
76
+ pip install copilot-session-tools[all]
77
+ ```
78
+
79
+ > **Tip:** Also works with `pipx install` or `uvx --with` if you prefer isolated tool environments.
80
+
81
+ ### From source (development)
82
+
83
+ ```bash
84
+ git clone https://github.com/Arithmomaniac/copilot-session-tools.git
85
+ cd copilot-session-tools
86
+
87
+ # Install uv if you haven't already
88
+ pip install uv
89
+
90
+ # Install with all dependencies
91
+ uv sync --all-extras
92
+ ```
93
+
94
+ ## Usage
95
+
96
+ ### 1. Scan for Chat Sessions
97
+
98
+ Scan your VS Code workspace storage and GitHub Copilot CLI sessions to import into the database:
99
+
100
+ ```bash
101
+ # Scan both VS Code (Stable and Insiders) and CLI sessions
102
+ copilot-session-tools scan
103
+
104
+ # Scan only VS Code Stable
105
+ copilot-session-tools scan --edition stable
106
+
107
+ # Scan only VS Code Insiders
108
+ copilot-session-tools scan --edition insider
109
+
110
+ # Use a custom database path
111
+ copilot-session-tools scan --db my_chats.db
112
+
113
+ # Scan custom storage paths
114
+ copilot-session-tools scan --storage-path /path/to/workspaceStorage
115
+
116
+ # Verbose output
117
+ copilot-session-tools scan --verbose
118
+
119
+ # Force re-import of all sessions
120
+ copilot-session-tools scan --full
121
+ ```
122
+
123
+ **Incremental Updates**: By default, the `scan` command only adds new sessions and updates changed ones based on file modification time. Use `--full` to re-import all sessions.
124
+
125
+ **CLI Support**: The scanner automatically detects and imports GitHub Copilot CLI chat sessions from `~/.copilot/session-state/` by default.
126
+
127
+ ### 2. Start the Web Server
128
+
129
+ Browse your chat archive in a web interface:
130
+
131
+ ```bash
132
+ # Start the web server (uses copilot_chats.db by default)
133
+ copilot-session-tools web
134
+
135
+ # Custom options
136
+ copilot-session-tools web --db my_chats.db --port 8080 --title "My Copilot Chats"
137
+ ```
138
+
139
+ Then open `http://127.0.0.1:5000/` in your browser.
140
+
141
+ ### 3. Search Chats
142
+
143
+ Search through your chat history from the command line:
144
+
145
+ ```bash
146
+ # Basic search
147
+ copilot-session-tools search "authentication"
148
+
149
+ # Limit results
150
+ copilot-session-tools search "React hooks" --limit 50
151
+
152
+ # Filter by role
153
+ copilot-session-tools search "error" --role assistant
154
+
155
+ # Search only tool invocations
156
+ copilot-session-tools search "git" --tools-only
157
+
158
+ # Show full content (not truncated)
159
+ copilot-session-tools search "complex query" --full
160
+ ```
161
+
162
+ **Advanced Search Syntax:**
163
+
164
+ The search supports powerful query syntax:
165
+
166
+ - **Multiple words:** `python function` matches messages containing both words (AND logic)
167
+ - **Exact phrases:** `"python function"` matches the exact phrase
168
+ - **Field filters:** Filter by specific fields directly in the query:
169
+ - `role:user` - Filter to user messages only
170
+ - `role:assistant` - Filter to assistant messages only
171
+ - `workspace:my-project` - Filter to a specific workspace
172
+ - `title:session-name` - Filter by session title
173
+
174
+ ```bash
175
+ # Search for "function" only in user messages
176
+ copilot-session-tools search "role:user function"
177
+
178
+ # Search in a specific workspace
179
+ copilot-session-tools search "workspace:my-project python"
180
+
181
+ # Combine filters
182
+ copilot-session-tools search "workspace:react role:assistant hooks"
183
+
184
+ # Sort by date instead of relevance
185
+ copilot-session-tools search "python" --sort date
186
+ ```
187
+
188
+ ### 4. View Statistics
189
+
190
+ ```bash
191
+ copilot-session-tools stats
192
+ ```
193
+
194
+ ### 5. Export/Import
195
+
196
+ ```bash
197
+ # Export all sessions to JSON
198
+ copilot-session-tools export --output chats.json
199
+
200
+ # Export to stdout
201
+ copilot-session-tools export
202
+
203
+ # Export as Markdown files
204
+ copilot-session-tools export-markdown --output-dir ./markdown-archive
205
+
206
+ # Export a single session
207
+ copilot-session-tools export-markdown --session-id abc123 --output-dir ./session
208
+
209
+ # Include file diffs in markdown
210
+ copilot-session-tools export-markdown --include-diffs
211
+
212
+ # Export as self-contained HTML (same rendering as web viewer, no server needed)
213
+ copilot-session-tools export-html --output-dir ./html-archive
214
+
215
+ # Export a single session as HTML
216
+ copilot-session-tools export-html --session-id abc123 --output-dir ./session
217
+
218
+ # Import from JSON
219
+ copilot-session-tools import-json chats.json
220
+ ```
221
+
222
+ ## Chat Storage Locations
223
+
224
+ ### VS Code
225
+
226
+ VS Code stores Copilot chat history in workspace-specific storage:
227
+
228
+ | OS | Path |
229
+ |----|------|
230
+ | Windows | `%APPDATA%\Code\User\workspaceStorage\{hash}\` |
231
+ | macOS | `~/Library/Application Support/Code/User/workspaceStorage/{hash}/` |
232
+ | Linux | `~/.config/Code/User/workspaceStorage/{hash}/` |
233
+
234
+ For VS Code Insiders, replace `Code` with `Code - Insiders`.
235
+
236
+ ### GitHub Copilot CLI
237
+
238
+ The GitHub Copilot CLI stores chat history in JSONL format:
239
+
240
+ | OS | Path |
241
+ |----|------|
242
+ | All | `~/.copilot/session-state/` (current format, v0.0.342+) |
243
+ | All | `~/.copilot/history-session-state/` (legacy format) |
244
+
245
+ The scanner automatically detects and imports both VS Code and CLI sessions by default.
246
+
247
+ ## Database Schema
248
+
249
+ The SQLite database uses a two-layer design:
250
+
251
+ 1. **`raw_sessions` table** - Stores compressed raw JSON as the source of truth
252
+ 2. **Derived tables** - Can be dropped and recreated from raw_sessions without migrations
253
+
254
+ ```sql
255
+ -- Raw sessions table (source of truth)
256
+ CREATE TABLE raw_sessions (
257
+ id INTEGER PRIMARY KEY,
258
+ session_id TEXT UNIQUE NOT NULL,
259
+ raw_json_compressed BLOB NOT NULL, -- zlib-compressed original JSON
260
+ workspace_name TEXT,
261
+ workspace_path TEXT,
262
+ source_file TEXT,
263
+ vscode_edition TEXT,
264
+ source_file_mtime REAL,
265
+ source_file_size INTEGER,
266
+ imported_at TIMESTAMP
267
+ );
268
+
269
+ -- Derived sessions table
270
+ CREATE TABLE sessions (
271
+ id INTEGER PRIMARY KEY,
272
+ session_id TEXT UNIQUE NOT NULL,
273
+ workspace_name TEXT,
274
+ workspace_path TEXT,
275
+ created_at TEXT,
276
+ updated_at TEXT,
277
+ source_file TEXT,
278
+ vscode_edition TEXT,
279
+ custom_title TEXT,
280
+ imported_at TIMESTAMP,
281
+ type TEXT DEFAULT 'vscode' -- 'vscode' or 'cli'
282
+ );
283
+
284
+ -- Messages table
285
+ CREATE TABLE messages (
286
+ id INTEGER PRIMARY KEY,
287
+ session_id TEXT NOT NULL,
288
+ message_index INTEGER NOT NULL,
289
+ role TEXT NOT NULL,
290
+ content TEXT NOT NULL,
291
+ timestamp TEXT,
292
+ cached_markdown TEXT
293
+ );
294
+
295
+ -- Full-text search virtual table
296
+ CREATE VIRTUAL TABLE messages_fts USING fts5(content);
297
+
298
+ -- Tool invocations, file changes, and command runs are also tracked
299
+ ```
300
+
301
+ ### Rebuilding Derived Tables
302
+
303
+ When the schema changes, you can rebuild all derived tables from the stored raw JSON:
304
+
305
+ ```bash
306
+ copilot-session-tools rebuild --db copilot_chats.db
307
+ ```
308
+
309
+ This drops and recreates the sessions, messages, and related tables without needing to re-scan the original VS Code storage.
310
+
311
+ ## Web Viewer Features
312
+
313
+ The web interface includes:
314
+
315
+ - **Session list** with workspace names and message counts, sorted by most recent message
316
+ - **Workspace filtering** to focus on specific projects
317
+ - **Full-text search** with highlighting
318
+ - **Dark mode support** via CSS `prefers-color-scheme`
319
+ - **Responsive design** for mobile and desktop
320
+ - **Syntax highlighting** for code blocks
321
+ - **Incremental refresh** to update without restarting
322
+
323
+ ## Development
324
+
325
+ ```bash
326
+ # Clone the repository
327
+ git clone https://github.com/Arithmomaniac/copilot-session-tools.git
328
+ cd copilot-session-tools
329
+
330
+ # Install uv
331
+ pip install uv
332
+
333
+ # Sync the workspace (installs all packages in development mode)
334
+ uv sync
335
+
336
+ # Run tests
337
+ uv run pytest
338
+
339
+ # Run tests with coverage
340
+ uv run pytest --cov
341
+
342
+ # Run the CLI
343
+ uv run copilot-session-tools --help
344
+ ```
345
+
346
+ ## Agent Skills
347
+
348
+ This repository includes [Agent Skills](https://claude-plugins.dev) for AI coding agents (Claude Code, Cursor, VS Code, Codex, and more):
349
+
350
+ | Skill | Description |
351
+ |-------|-------------|
352
+ | **search-copilot-chats** | Search, browse, and export archived Copilot chat sessions using this tool's CLI |
353
+ | **scanner-refresh** | Research recent changes in Copilot repos and update the scanner for new event types |
354
+
355
+ ### Install a skill
356
+
357
+ ```bash
358
+ # Install the search skill (Claude Code is the default client)
359
+ npx skills-installer install @Arithmomaniac/copilot-session-tools/search-copilot-chats
360
+
361
+ # For other clients
362
+ npx skills-installer install @Arithmomaniac/copilot-session-tools/search-copilot-chats --client cursor
363
+ ```
364
+
365
+ Skills are automatically available when working in this repository (project-level `.claude/skills/`).
366
+
367
+ ## Related Projects
368
+
369
+ - [simonw/claude-code-transcripts](https://github.com/simonw/claude-code-transcripts) - Inspiration for the web viewer
370
+ - [Arbuzov/copilot-chat-history](https://github.com/Arbuzov/copilot-chat-history) - VS Code extension for viewing chat history
371
+ - [microsoft/vscode-copilot-chat](https://github.com/microsoft/vscode-copilot-chat) - Official VS Code Copilot Chat extension
372
+
373
+ ## License
374
+
375
+ MIT License - see [LICENSE](LICENSE) for details.