copilot-session-usage 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: copilot-session-usage
3
+ Version: 0.1.0
4
+ Summary: Usage and cost analytics for GitHub Copilot and Copilot-CLI session logs
5
+ Project-URL: Homepage, https://github.com/gsemet/copilot-session-usage
6
+ Project-URL: Documentation, https://copilot-session-usage.readthedocs.io
7
+ Project-URL: Repository, https://github.com/gsemet/copilot-session-usage
8
+ Project-URL: Issues, https://github.com/gsemet/copilot-session-usage/issues
9
+ Author-email: Gaetan Semet <gaetan@xeberon.net>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: click>=8.0
14
+ Requires-Dist: ruamel-yaml>=0.18.0
15
+ Description-Content-Type: text/markdown
16
+
17
+ # copilot-session-usage
18
+
19
+ [![CI](https://github.com/gsemet/copilot-session-usage/actions/workflows/ci.yml/badge.svg)](https://github.com/gsemet/copilot-session-usage/actions/workflows/ci.yml)
20
+ [![Coverage](https://img.shields.io/codecov/c/github/gsemet/copilot-session-usage)](https://codecov.io/gh/gsemet/copilot-session-usage)
21
+ [![PyPI](https://img.shields.io/pypi/v/copilot-session-usage)](https://pypi.org/project/copilot-session-usage/)
22
+ [![Python Versions](https://img.shields.io/pypi/pyversions/copilot-session-usage)](https://pypi.org/project/copilot-session-usage/)
23
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
24
+ [![Type checked](https://img.shields.io/badge/type%20checked-mypy%2Fty-blue.svg)](./)
25
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
26
+
27
+ Extract VS Code Copilot session cost KPIs (tokens, estimated USD, model, duration) from local debug logs.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ uv tool install copilot-session-usage
33
+ ```
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ # Analyze the most recent session
39
+ copilot-session-usage latest
40
+
41
+ # Analyze a specific session by its debug-log directory
42
+ copilot-session-usage analyze /path/to/session/debug-logs
43
+
44
+ # List recent sessions (metadata only)
45
+ copilot-session-usage list
46
+
47
+ # Batch analyze the last 10 sessions
48
+ copilot-session-usage batch 10
49
+ ```
50
+
51
+ ## Features
52
+
53
+ - **Token-level cost estimation** — per-model pricing with cache-hit discounts
54
+ - **Multi-model sessions** — correctly handles sessions that call multiple models (e.g. Claude + Kimi)
55
+ - **Threshold-aware pricing** — long-context tier switching (e.g. GPT-5.4 > 272k tokens)
56
+ - **Subagent cost attribution** — tracks `runSubagent` calls and their token usage
57
+ - **Cross-platform** — macOS, Linux, Windows, WSL2
58
+ - **Three detail levels** — `minimal`, `compact`, `full`
59
+ - **JSON and table output** — machine-readable or human-friendly
60
+
61
+ ## How it works
62
+
63
+ `copilot-session-usage` reads VS Code Copilot debug logs stored in
64
+ `~/Library/Application Support/Code/User/workspaceStorage/` (macOS),
65
+ `%APPDATA%\Code\User\workspaceStorage\` (Windows), or
66
+ `~/.config/Code/User/workspaceStorage/` (Linux).
67
+
68
+ Each session directory contains a `GitHub.copilot-chat/debug-logs/` folder with
69
+ JSONL files. The tool parses these files, extracts token counts per model,
70
+ applies per-model pricing (including cache-hit discounts and long-context tier
71
+ switching), and estimates the session cost in USD.
72
+
73
+ Subagent calls (`runSubagent`) are tracked separately so you can see how much
74
+ token usage was delegated to helper agents.
75
+
76
+ ## Knowledge base
77
+
78
+ This project includes an OKF knowledge bundle in `knowledge/` with structured
79
+ guidelines for contributors. Validate it with:
80
+
81
+ ```bash
82
+ just knowledge-validate
83
+ ```
84
+
85
+ ## Usage
86
+
87
+ ### Commands
88
+
89
+ | Command | Description |
90
+ |---------|-------------|
91
+ | `analyze PATH` | Analyze one session by its debug-log directory |
92
+ | `latest` | Analyze the most recently modified session |
93
+ | `find TITLE` | Find and analyze a session by title (fuzzy match) |
94
+ | `id SESSION_ID` | Analyze a session by exact UUID |
95
+ | `list` | List recent sessions (metadata only, no cost) |
96
+ | `batch N` | Analyze the N most recent sessions in one pass |
97
+
98
+ ### Global options
99
+
100
+ | Option | Description |
101
+ |--------|-------------|
102
+ | `--workspace-storage PATH` | Override workspaceStorage directory (auto-detected by default) |
103
+ | `--agent {vscode,cli}` | Provider to use (`cli` not yet implemented) |
104
+ | `--detail {minimal,compact,full}` | Detail level (default: `compact`) |
105
+ | `--format {json,table,detailed}` | Output format (default: `table`) |
106
+ | `--output PATH` | Write output to file instead of stdout |
107
+
108
+ ### Examples
109
+
110
+ ```bash
111
+ # Full detail for the latest session
112
+ $ copilot-session-usage latest --detail full
113
+ {
114
+ "session_id": "f5cbde8a-ec40-466f-86e6-f95c343b6c58",
115
+ "session_dir": "/Users/az02065/Library/Application Support/Code/User/workspaceStorage/c016ff4fabbe9f918719a00c9c741058/GitHub.copilot-chat/debug-logs/f5cbde8a-ec40-466f-86e6-f95c343b6c58",
116
+ ...
117
+ }
118
+
119
+ # JSON output for a specific session
120
+ $ copilot-session-usage analyze /path/to/debug-logs --format json --output report.json
121
+
122
+ # Find sessions containing "refactor" in the title
123
+ $ copilot-session-usage find "refactor"
124
+ Multiple sessions match 'implem':
125
+ 2026-07-01T21:15:12Z 'Implement copilot-session-usage spec' (id: c890dd60-43d6-44f0-b57c-ab505dfa003b)
126
+ 2026-06-26T18:21:21Z 'Resume PRD implementation' (id: 9368ab3e-1c93-4125-8271-d5bd024b057a)
127
+ 2026-06-26T09:19:52Z 'Resume Workflow PRD implementation' (id: 1214eb3f-add0-41a5-84d4-88720218e60e)
128
+ ...
129
+
130
+ # Get summary for a given session (found by `find`)
131
+ $ copilot-session-usage id 19e03be0-9cfa-4f21-a19a-4bdb754b3965 --format table
132
+ Session: 19e03be0-9cfa-4f21-a19a-4bdb754b3965
133
+ Title: Implementation of new feature X
134
+ Started: 2026-07-01T20:37:34Z
135
+ Duration: 40588s (active: 1083s)
136
+ Models: claude-sonnet-4.6, claude-haiku-4.5, Kimi-K2.6-azure
137
+ Input: 1,425,790 tokens
138
+ Output: 22,166 tokens
139
+ Cached: 1,224,340 (86%)
140
+ LLM calls: 28
141
+ Est. cost: $1.0880
142
+
143
+ # Batch analyze last 5 sessions since July 1st
144
+ copilot-session-usage batch 5 --since 2026-07-01
145
+
146
+ # WSL2: point to Windows host workspaceStorage
147
+ copilot-session-usage latest \
148
+ --workspace-storage /mnt/c/Users/$USER/AppData/Roaming/Code/User/workspaceStorage
149
+ ```
150
+
151
+ ## Python API
152
+
153
+ ```python
154
+ from copilot_session_usage.api import analyze_session, analyze_latest, batch_analyze
155
+
156
+ # Analyze a session by path
157
+ result = analyze_session(Path("/path/to/debug-logs"), detail="full")
158
+
159
+ # Analyze the most recent session
160
+ result = analyze_latest(detail="compact")
161
+
162
+ # Batch analyze the last 10 sessions
163
+ batch = batch_analyze(10, detail="minimal")
164
+ ```
165
+
166
+ ## Development
167
+
168
+ ```bash
169
+ # Install dependencies
170
+ just dev
171
+
172
+ # Run tests
173
+ just test
174
+
175
+ # Run full validation
176
+ just preflight
177
+
178
+ # Build docs
179
+ just docs
180
+
181
+ # Serve docs with auto-reload
182
+ just docs-serve
183
+ ```
184
+
185
+ ## License
186
+
187
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,16 @@
1
+ copilot_session_usage/__init__.py,sha256=fOVG3PXlOomI1QT7z5SyA746fpbdJTtr63wXE-r2R7s,281
2
+ copilot_session_usage/api.py,sha256=fUXwJGlRpvqfkmHvXdfzcwp5VE5i24T_rUBVFwkO57I,6830
3
+ copilot_session_usage/cli.py,sha256=TLY6Ab_mMLljhlxppvNfEQ4Xc29xZlGlA1W94yZJMVU,9498
4
+ copilot_session_usage/_internal/__init__.py,sha256=sxn8qRXfsEyKyuiXTHuhYAM5fs42GF2m4Qm12EBeDxk,39
5
+ copilot_session_usage/_internal/copilot_cli.py,sha256=y0-YyUKwP1dif0orb6cLQrt80eBfD9Sazy8me2gMT_g,704
6
+ copilot_session_usage/_internal/core.py,sha256=OFMDRPGrGYe8Rr75MSvv45ZRI70N50lCypnhtAYht9s,38827
7
+ copilot_session_usage/_internal/vscode.py,sha256=sVtnGFom3kRVNlqgMl_ylaZmApOQk1US7Nle0wrQxls,9210
8
+ copilot_session_usage/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ copilot_session_usage/data/custom-models-pricing.yml,sha256=2s74LQxm4tmloEhb4Ha7gVoORYoxAIt9LVpiDsyVqug,842
10
+ copilot_session_usage/data/models-and-pricing.lock,sha256=JXUq2FH4WnZrISWK4Q48R6oWEG0WuS3wAgUwG5umvIw,272
11
+ copilot_session_usage/data/models-and-pricing.yml,sha256=DTmLXPRb-f-xl0My-uHy4OJGRCWrzH6UARkb3sEF0zg,5562
12
+ copilot_session_usage-0.1.0.dist-info/METADATA,sha256=zh5SrFynEbD37XVbo3sbsistVD63yV8n293k0l1fIEg,6623
13
+ copilot_session_usage-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
14
+ copilot_session_usage-0.1.0.dist-info/entry_points.txt,sha256=ZY4Km9tWEHBgVTCTpcL5EFod0sibUizMj7qKkWZKhMI,72
15
+ copilot_session_usage-0.1.0.dist-info/licenses/LICENSE,sha256=QJiCkAnFtBdu7R1YVheQ4fmz2m5rR_KUMjI47zbSjyg,1069
16
+ copilot_session_usage-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ copilot-session-usage = copilot_session_usage.cli:cli
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gaetan Semet
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.