cli-consumption 0.0.17__tar.gz → 0.1.0__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.
- cli_consumption-0.1.0/PKG-INFO +232 -0
- cli_consumption-0.1.0/README.md +204 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/docs/architecture.md +7 -6
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/docs/provider-support.md +89 -9
- cli_consumption-0.1.0/docs/roadmap.md +25 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/pyproject.toml +1 -1
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/__init__.py +8 -0
- cli_consumption-0.1.0/src/cli_consumption/adapters/_shared.py +141 -0
- cli_consumption-0.1.0/src/cli_consumption/adapters/amazon_q.py +218 -0
- cli_consumption-0.1.0/src/cli_consumption/adapters/cline.py +296 -0
- cli_consumption-0.1.0/src/cli_consumption/adapters/kimi.py +226 -0
- cli_consumption-0.1.0/src/cli_consumption/adapters/plandex.py +163 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/cli.py +12 -0
- cli_consumption-0.1.0/tests/test_amazon_q_adapter.py +67 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_cli.py +4 -0
- cli_consumption-0.1.0/tests/test_cline_adapter.py +102 -0
- cli_consumption-0.1.0/tests/test_kimi_adapter.py +82 -0
- cli_consumption-0.1.0/tests/test_plandex_adapter.py +68 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/uv.lock +1 -1
- cli_consumption-0.0.17/PKG-INFO +0 -420
- cli_consumption-0.0.17/README.md +0 -392
- cli_consumption-0.0.17/docs/roadmap.md +0 -37
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/add-cli-adapter/SKILL.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/add-cli-adapter/agents/openai.yaml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/audit-usage-privacy/SKILL.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/audit-usage-privacy/agents/openai.yaml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/evolve-storage-schema/SKILL.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/evolve-storage-schema/agents/openai.yaml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/yeet-github/SKILL.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/yeet-github/agents/openai.yaml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/yolo/SKILL.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.agents/skills/yolo/agents/openai.yaml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.github/workflows/ci.yml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.github/workflows/release.yaml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.gitignore +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.pre-commit-config.yaml +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/.python-version +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/AGENTS.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/CONTRIBUTING.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/LICENSE +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/NOTICE +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/docs/privacy.md +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/__init__.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/__main__.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/aider.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/amp.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/base.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/claude.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/codex.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/continue_cli.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/copilot.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/crush.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/cursor.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/gemini.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/goose.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/grok.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/kilo.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/opencode.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/openhands.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/pi.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/adapters/qwen.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/api.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/dashboard.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/exporting.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/models.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/py.typed +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/storage.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/src/cli_consumption/sync.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/conftest.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_aider_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_amp_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_api.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_claude_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_codex_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_continue_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_copilot_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_crush_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_cursor_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_gemini_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_goose_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_grok_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_kilo_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_opencode_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_openhands_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_pi_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_qwen_adapter.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_storage_and_exports.py +0 -0
- {cli_consumption-0.0.17 → cli_consumption-0.1.0}/tests/test_sync.py +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cli-consumption
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Analyze and consolidate AI coding CLI consumption across machines.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Guillaume-Lombardo/cli-consumption
|
|
6
|
+
Project-URL: Documentation, https://github.com/Guillaume-Lombardo/cli-consumption#readme
|
|
7
|
+
Project-URL: Issues, https://github.com/Guillaume-Lombardo/cli-consumption/issues
|
|
8
|
+
Project-URL: Repository, https://github.com/Guillaume-Lombardo/cli-consumption.git
|
|
9
|
+
Author-email: Guillaume Lombardo <lombardo.guillaume@gmail.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: ai,cli,codex,observability,tokens,usage
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
20
|
+
Requires-Python: >=3.14
|
|
21
|
+
Requires-Dist: fastapi>=0.115
|
|
22
|
+
Requires-Dist: httpx>=0.27
|
|
23
|
+
Requires-Dist: psycopg[binary]>=3.2
|
|
24
|
+
Requires-Dist: sqlalchemy>=2.0
|
|
25
|
+
Requires-Dist: typer>=0.15
|
|
26
|
+
Requires-Dist: uvicorn>=0.34
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# CLI Consumption
|
|
30
|
+
|
|
31
|
+
CLI Consumption measures how AI coding CLIs use models, tokens, tools,
|
|
32
|
+
conversations, and turns. It runs locally, can consolidate copied data from several
|
|
33
|
+
machines, and can send metadata-only snapshots to a central collector.
|
|
34
|
+
|
|
35
|
+
It never stores prompts, responses, tool arguments, credentials, or raw provider
|
|
36
|
+
events. Local token counters are usage metadata, not billing records. Read the
|
|
37
|
+
[privacy boundary](docs/privacy.md) before sharing a database or report.
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
CLI Consumption requires Python 3.14 or newer and uses
|
|
42
|
+
[`uv`](https://docs.astral.sh/uv/).
|
|
43
|
+
|
|
44
|
+
From a checkout, collect every supported CLI detected on the machine and generate a
|
|
45
|
+
self-contained dashboard:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uv sync
|
|
49
|
+
uv run cli-consumption collect --provider all
|
|
50
|
+
uv run cli-consumption export --output reports
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Open `reports/dashboard.html` locally. It makes no network requests. Detailed
|
|
54
|
+
normalized CSV tables are generated only when `--csv` is passed.
|
|
55
|
+
|
|
56
|
+
To collect a single CLI, use its provider name. For example, with Codex:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv run cli-consumption collect --provider codex --database usage.sqlite
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
From PyPI, no permanent installation is required:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv tool run cli-consumption collect --provider all
|
|
66
|
+
uv tool run cli-consumption export --output reports
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To run the latest unreleased GitHub source:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
uv tool run --from git+https://github.com/Guillaume-Lombardo/cli-consumption \
|
|
73
|
+
cli-consumption providers
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Supported CLIs
|
|
77
|
+
|
|
78
|
+
`--provider all` detects the supported data stores found in their default locations.
|
|
79
|
+
Use the provider name below with `--provider` to select one CLI explicitly.
|
|
80
|
+
|
|
81
|
+
| CLI | Provider name | Default local source | Particularities and limits |
|
|
82
|
+
| --- | --- | --- | --- |
|
|
83
|
+
| Aider | `aider` | `~/.aider/analytics.jsonl` | Requires opt-in analytics logging; no projects, tools, cache/reasoning split, or provider-reported durations. |
|
|
84
|
+
| Amazon Q Developer CLI | `amazon-q` | `~/.local/share/amazon-q/data.sqlite3` | Persistent conversations only; request timing is available, but token counters are not. |
|
|
85
|
+
| Amp | `amp` | `~/.local/share/amp/threads/` | Per-inference tokens and context windows; no subthreads, compactions, reasoning split, or latency. |
|
|
86
|
+
| Claude Code | `claude` | `~/.claude/projects/` | Main sessions, tokens, tools, and compactions; no subagents, context windows, or provider-reported durations. `claude-code` is accepted as an alias. |
|
|
87
|
+
| Cline CLI | `cline` | `~/.cline/data/sessions/sessions.db` | Uses the session index and message artifacts; no costs or arbitrary task metadata. |
|
|
88
|
+
| Codex | `codex` | `~/.codex/sessions/` | Richest support: timing, context pressure, settings, compactions, work items, and subagent relationships. |
|
|
89
|
+
| Continue CLI | `continue` | `~/.continue/sessions/` | Token usage when present; session files lack reliable per-message timing and duration. |
|
|
90
|
+
| Crush | `crush` | `~/.local/share/crush/` | Reads registered per-project SQLite stores; token counters are a latest-context snapshot, not additive usage. |
|
|
91
|
+
| Cursor CLI | `cursor` | `~/.cursor/` | Composer 2 transcripts and chat metadata; no per-message time or tokens, and model attribution is incomplete. |
|
|
92
|
+
| Gemini CLI | `gemini` | `~/.gemini/tmp/` | Replays active history and rewinds; hashed projects are not reversed and nested agents are excluded. |
|
|
93
|
+
| GitHub Copilot CLI | `copilot` | `~/.copilot/session-state/` | Tokens are latest shutdown aggregates and cannot be assigned to individual turns. |
|
|
94
|
+
| Goose | `goose` | `~/.local/share/goose/sessions/sessions.db` | Supports SQLite schema v16; no legacy JSONL, subagents, reasoning tokens, or latency. |
|
|
95
|
+
| Grok Build | `grok` | `~/.grok/sessions/` | Per-prompt aggregates, reasoning effort, TTFT, and auto-compactions; no costs or subagent relationships. |
|
|
96
|
+
| Kilo Code | `kilo` | `~/.local/share/kilo/kilo.db` | CLI SQLite store only; excludes legacy IDE tasks, cloud sessions, subagents, context windows, and costs. |
|
|
97
|
+
| Kimi Code CLI | `kimi` | `~/.kimi/sessions/` | Wire v1 events, context windows, and compactions; selected model is not persisted and is reported as `unknown`. |
|
|
98
|
+
| OpenCode | `opencode` | `~/.local/share/opencode/opencode.db` | SQLite v2 only; no legacy storage, child sessions, context windows, or costs. |
|
|
99
|
+
| OpenHands CLI | `openhands` | `~/.openhands/conversations/` | SDK persistence with context windows, reasoning effort, and condensations; excludes cloud-only conversations and delegates. |
|
|
100
|
+
| Pi | `pi` | `~/.pi/agent/sessions/` | Counts all persisted branches; no branch relationships, custom-directory auto-detection, context windows, or provider-reported durations. |
|
|
101
|
+
| Plandex | `plandex` | `/plandex-server` | Requires an offline copy of a self-hosted `PLANDEX_BASE_DIR`; hosted accounts are not accessed, and models/tools are unavailable. |
|
|
102
|
+
| Qwen Code | `qwen` | `~/.qwen/projects/` | Follows the active branch and records context windows and compactions; excludes archived and sidechain sessions. |
|
|
103
|
+
|
|
104
|
+
Provider formats are internal and can change without notice. The detailed extraction
|
|
105
|
+
rules and qualification versions are documented in
|
|
106
|
+
[Provider support](docs/provider-support.md).
|
|
107
|
+
|
|
108
|
+
## Collect copied data
|
|
109
|
+
|
|
110
|
+
`--source [LABEL=]PATH` points to a provider home directory and can be repeated. With
|
|
111
|
+
`--provider all`, each path is inspected and unmatched sources are rejected. With one
|
|
112
|
+
provider selected, each path must contain that provider's expected store.
|
|
113
|
+
|
|
114
|
+
For example, consolidate trusted copies of Codex data from several machines:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
uv run cli-consumption collect --provider codex \
|
|
118
|
+
--source desktop=/data/codex/desktop \
|
|
119
|
+
--source laptop=/data/codex/laptop \
|
|
120
|
+
--source server=/data/codex/server \
|
|
121
|
+
--database usage.sqlite
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Copy only the required provider data. For Codex, copy the `sessions/` directory but
|
|
125
|
+
never `auth.json` or other credentials. Globally identical conversation IDs are
|
|
126
|
+
deduplicated, and the most complete copy wins.
|
|
127
|
+
|
|
128
|
+
Map original working-directory prefixes to stable project labels with repeated
|
|
129
|
+
`--project NAME=PATH_PREFIX` options. The longest matching prefix wins:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
uv run cli-consumption collect --provider codex \
|
|
133
|
+
--source desktop=/data/codex/desktop \
|
|
134
|
+
--project cli-consumption=/home/me/dev/cli-consumption
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Plandex auto-detection checks `/plandex-server`. For any other trusted offline copy of
|
|
138
|
+
a self-hosted server data directory, pass the path explicitly:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
uv run cli-consumption collect --provider plandex \
|
|
142
|
+
--source server=/srv/plandex-server --database usage.sqlite
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Explore and share reports
|
|
146
|
+
|
|
147
|
+
The dashboard can filter by time, provider, machine, project, and model. It reports
|
|
148
|
+
activity, token composition, cache efficiency, latency and duration distributions,
|
|
149
|
+
technical throughput, context pressure, work-item reliability, configuration cohorts,
|
|
150
|
+
compactions, subagent delegation, and ingestion quality. Availability varies by
|
|
151
|
+
provider, as summarized in the table above.
|
|
152
|
+
|
|
153
|
+
Generate a more shareable dashboard by pseudonymizing labels, grouping tool names,
|
|
154
|
+
rounding timestamps to days, and hiding small cohort rows:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
uv run cli-consumption export --output shared-report --share-safe
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Share-safe reports still disclose aggregate work patterns and remain private
|
|
161
|
+
operational data. A technically completed turn is not a measure of task quality or
|
|
162
|
+
productivity.
|
|
163
|
+
|
|
164
|
+
## SQLite and PostgreSQL
|
|
165
|
+
|
|
166
|
+
A file path selects SQLite. A SQLAlchemy URL selects PostgreSQL:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
uv run cli-consumption collect --provider all --database usage.sqlite
|
|
170
|
+
uv run cli-consumption collect --provider all \
|
|
171
|
+
--database postgresql+psycopg://usage@localhost/cli_consumption
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Pass credentials through environment variables or a secret manager rather than shell
|
|
175
|
+
history. `CLI_CONSUMPTION_DATABASE` can provide the database setting.
|
|
176
|
+
|
|
177
|
+
## Central collector API
|
|
178
|
+
|
|
179
|
+
Copied files are simplest for personal or air-gapped use. For recurring collection
|
|
180
|
+
across machines, start the metadata-only API:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
export CLI_CONSUMPTION_API_TOKEN="$(your-secret-provider)"
|
|
184
|
+
uv run cli-consumption serve \
|
|
185
|
+
--database postgresql+psycopg://usage@localhost/cli_consumption \
|
|
186
|
+
--host 0.0.0.0
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Then send all locally detected snapshots from another machine:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
export CLI_CONSUMPTION_API_TOKEN="$(your-secret-provider)"
|
|
193
|
+
uv run cli-consumption sync --provider all \
|
|
194
|
+
--endpoint https://usage.example.test
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The application refuses to bind beyond localhost without a token. Production
|
|
198
|
+
deployments also need TLS and standard operational controls. See
|
|
199
|
+
[Architecture](docs/architecture.md) for the trade-offs.
|
|
200
|
+
|
|
201
|
+
## Commands
|
|
202
|
+
|
|
203
|
+
| Command | Purpose |
|
|
204
|
+
| --- | --- |
|
|
205
|
+
| `collect` | Collect local or copied provider data into SQL. |
|
|
206
|
+
| `sync` | Collect and send metadata-only snapshots to a central API. |
|
|
207
|
+
| `serve` | Run the central collection API. |
|
|
208
|
+
| `export` | Write the HTML dashboard and optional CSV tables. |
|
|
209
|
+
| `providers` | List provider names and support status. |
|
|
210
|
+
|
|
211
|
+
Run `uv run cli-consumption COMMAND --help` for all options.
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
uv sync --all-groups
|
|
217
|
+
uv run pre-commit install
|
|
218
|
+
uv run pre-commit run --all-files
|
|
219
|
+
uv run ruff format --check .
|
|
220
|
+
uv run ruff check .
|
|
221
|
+
uv run ty check
|
|
222
|
+
uv run pytest --cov --cov-report=term-missing
|
|
223
|
+
uv build
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Development uses short-lived branches and squash-merged pull requests into protected
|
|
227
|
+
`main`. Read [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md) before
|
|
228
|
+
changing the project.
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
Licensed under the [Apache License 2.0](LICENSE).
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# CLI Consumption
|
|
2
|
+
|
|
3
|
+
CLI Consumption measures how AI coding CLIs use models, tokens, tools,
|
|
4
|
+
conversations, and turns. It runs locally, can consolidate copied data from several
|
|
5
|
+
machines, and can send metadata-only snapshots to a central collector.
|
|
6
|
+
|
|
7
|
+
It never stores prompts, responses, tool arguments, credentials, or raw provider
|
|
8
|
+
events. Local token counters are usage metadata, not billing records. Read the
|
|
9
|
+
[privacy boundary](docs/privacy.md) before sharing a database or report.
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
CLI Consumption requires Python 3.14 or newer and uses
|
|
14
|
+
[`uv`](https://docs.astral.sh/uv/).
|
|
15
|
+
|
|
16
|
+
From a checkout, collect every supported CLI detected on the machine and generate a
|
|
17
|
+
self-contained dashboard:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv sync
|
|
21
|
+
uv run cli-consumption collect --provider all
|
|
22
|
+
uv run cli-consumption export --output reports
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Open `reports/dashboard.html` locally. It makes no network requests. Detailed
|
|
26
|
+
normalized CSV tables are generated only when `--csv` is passed.
|
|
27
|
+
|
|
28
|
+
To collect a single CLI, use its provider name. For example, with Codex:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv run cli-consumption collect --provider codex --database usage.sqlite
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
From PyPI, no permanent installation is required:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
uv tool run cli-consumption collect --provider all
|
|
38
|
+
uv tool run cli-consumption export --output reports
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To run the latest unreleased GitHub source:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv tool run --from git+https://github.com/Guillaume-Lombardo/cli-consumption \
|
|
45
|
+
cli-consumption providers
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Supported CLIs
|
|
49
|
+
|
|
50
|
+
`--provider all` detects the supported data stores found in their default locations.
|
|
51
|
+
Use the provider name below with `--provider` to select one CLI explicitly.
|
|
52
|
+
|
|
53
|
+
| CLI | Provider name | Default local source | Particularities and limits |
|
|
54
|
+
| --- | --- | --- | --- |
|
|
55
|
+
| Aider | `aider` | `~/.aider/analytics.jsonl` | Requires opt-in analytics logging; no projects, tools, cache/reasoning split, or provider-reported durations. |
|
|
56
|
+
| Amazon Q Developer CLI | `amazon-q` | `~/.local/share/amazon-q/data.sqlite3` | Persistent conversations only; request timing is available, but token counters are not. |
|
|
57
|
+
| Amp | `amp` | `~/.local/share/amp/threads/` | Per-inference tokens and context windows; no subthreads, compactions, reasoning split, or latency. |
|
|
58
|
+
| Claude Code | `claude` | `~/.claude/projects/` | Main sessions, tokens, tools, and compactions; no subagents, context windows, or provider-reported durations. `claude-code` is accepted as an alias. |
|
|
59
|
+
| Cline CLI | `cline` | `~/.cline/data/sessions/sessions.db` | Uses the session index and message artifacts; no costs or arbitrary task metadata. |
|
|
60
|
+
| Codex | `codex` | `~/.codex/sessions/` | Richest support: timing, context pressure, settings, compactions, work items, and subagent relationships. |
|
|
61
|
+
| Continue CLI | `continue` | `~/.continue/sessions/` | Token usage when present; session files lack reliable per-message timing and duration. |
|
|
62
|
+
| Crush | `crush` | `~/.local/share/crush/` | Reads registered per-project SQLite stores; token counters are a latest-context snapshot, not additive usage. |
|
|
63
|
+
| Cursor CLI | `cursor` | `~/.cursor/` | Composer 2 transcripts and chat metadata; no per-message time or tokens, and model attribution is incomplete. |
|
|
64
|
+
| Gemini CLI | `gemini` | `~/.gemini/tmp/` | Replays active history and rewinds; hashed projects are not reversed and nested agents are excluded. |
|
|
65
|
+
| GitHub Copilot CLI | `copilot` | `~/.copilot/session-state/` | Tokens are latest shutdown aggregates and cannot be assigned to individual turns. |
|
|
66
|
+
| Goose | `goose` | `~/.local/share/goose/sessions/sessions.db` | Supports SQLite schema v16; no legacy JSONL, subagents, reasoning tokens, or latency. |
|
|
67
|
+
| Grok Build | `grok` | `~/.grok/sessions/` | Per-prompt aggregates, reasoning effort, TTFT, and auto-compactions; no costs or subagent relationships. |
|
|
68
|
+
| Kilo Code | `kilo` | `~/.local/share/kilo/kilo.db` | CLI SQLite store only; excludes legacy IDE tasks, cloud sessions, subagents, context windows, and costs. |
|
|
69
|
+
| Kimi Code CLI | `kimi` | `~/.kimi/sessions/` | Wire v1 events, context windows, and compactions; selected model is not persisted and is reported as `unknown`. |
|
|
70
|
+
| OpenCode | `opencode` | `~/.local/share/opencode/opencode.db` | SQLite v2 only; no legacy storage, child sessions, context windows, or costs. |
|
|
71
|
+
| OpenHands CLI | `openhands` | `~/.openhands/conversations/` | SDK persistence with context windows, reasoning effort, and condensations; excludes cloud-only conversations and delegates. |
|
|
72
|
+
| Pi | `pi` | `~/.pi/agent/sessions/` | Counts all persisted branches; no branch relationships, custom-directory auto-detection, context windows, or provider-reported durations. |
|
|
73
|
+
| Plandex | `plandex` | `/plandex-server` | Requires an offline copy of a self-hosted `PLANDEX_BASE_DIR`; hosted accounts are not accessed, and models/tools are unavailable. |
|
|
74
|
+
| Qwen Code | `qwen` | `~/.qwen/projects/` | Follows the active branch and records context windows and compactions; excludes archived and sidechain sessions. |
|
|
75
|
+
|
|
76
|
+
Provider formats are internal and can change without notice. The detailed extraction
|
|
77
|
+
rules and qualification versions are documented in
|
|
78
|
+
[Provider support](docs/provider-support.md).
|
|
79
|
+
|
|
80
|
+
## Collect copied data
|
|
81
|
+
|
|
82
|
+
`--source [LABEL=]PATH` points to a provider home directory and can be repeated. With
|
|
83
|
+
`--provider all`, each path is inspected and unmatched sources are rejected. With one
|
|
84
|
+
provider selected, each path must contain that provider's expected store.
|
|
85
|
+
|
|
86
|
+
For example, consolidate trusted copies of Codex data from several machines:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv run cli-consumption collect --provider codex \
|
|
90
|
+
--source desktop=/data/codex/desktop \
|
|
91
|
+
--source laptop=/data/codex/laptop \
|
|
92
|
+
--source server=/data/codex/server \
|
|
93
|
+
--database usage.sqlite
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Copy only the required provider data. For Codex, copy the `sessions/` directory but
|
|
97
|
+
never `auth.json` or other credentials. Globally identical conversation IDs are
|
|
98
|
+
deduplicated, and the most complete copy wins.
|
|
99
|
+
|
|
100
|
+
Map original working-directory prefixes to stable project labels with repeated
|
|
101
|
+
`--project NAME=PATH_PREFIX` options. The longest matching prefix wins:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
uv run cli-consumption collect --provider codex \
|
|
105
|
+
--source desktop=/data/codex/desktop \
|
|
106
|
+
--project cli-consumption=/home/me/dev/cli-consumption
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Plandex auto-detection checks `/plandex-server`. For any other trusted offline copy of
|
|
110
|
+
a self-hosted server data directory, pass the path explicitly:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
uv run cli-consumption collect --provider plandex \
|
|
114
|
+
--source server=/srv/plandex-server --database usage.sqlite
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Explore and share reports
|
|
118
|
+
|
|
119
|
+
The dashboard can filter by time, provider, machine, project, and model. It reports
|
|
120
|
+
activity, token composition, cache efficiency, latency and duration distributions,
|
|
121
|
+
technical throughput, context pressure, work-item reliability, configuration cohorts,
|
|
122
|
+
compactions, subagent delegation, and ingestion quality. Availability varies by
|
|
123
|
+
provider, as summarized in the table above.
|
|
124
|
+
|
|
125
|
+
Generate a more shareable dashboard by pseudonymizing labels, grouping tool names,
|
|
126
|
+
rounding timestamps to days, and hiding small cohort rows:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
uv run cli-consumption export --output shared-report --share-safe
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Share-safe reports still disclose aggregate work patterns and remain private
|
|
133
|
+
operational data. A technically completed turn is not a measure of task quality or
|
|
134
|
+
productivity.
|
|
135
|
+
|
|
136
|
+
## SQLite and PostgreSQL
|
|
137
|
+
|
|
138
|
+
A file path selects SQLite. A SQLAlchemy URL selects PostgreSQL:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
uv run cli-consumption collect --provider all --database usage.sqlite
|
|
142
|
+
uv run cli-consumption collect --provider all \
|
|
143
|
+
--database postgresql+psycopg://usage@localhost/cli_consumption
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Pass credentials through environment variables or a secret manager rather than shell
|
|
147
|
+
history. `CLI_CONSUMPTION_DATABASE` can provide the database setting.
|
|
148
|
+
|
|
149
|
+
## Central collector API
|
|
150
|
+
|
|
151
|
+
Copied files are simplest for personal or air-gapped use. For recurring collection
|
|
152
|
+
across machines, start the metadata-only API:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
export CLI_CONSUMPTION_API_TOKEN="$(your-secret-provider)"
|
|
156
|
+
uv run cli-consumption serve \
|
|
157
|
+
--database postgresql+psycopg://usage@localhost/cli_consumption \
|
|
158
|
+
--host 0.0.0.0
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Then send all locally detected snapshots from another machine:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
export CLI_CONSUMPTION_API_TOKEN="$(your-secret-provider)"
|
|
165
|
+
uv run cli-consumption sync --provider all \
|
|
166
|
+
--endpoint https://usage.example.test
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The application refuses to bind beyond localhost without a token. Production
|
|
170
|
+
deployments also need TLS and standard operational controls. See
|
|
171
|
+
[Architecture](docs/architecture.md) for the trade-offs.
|
|
172
|
+
|
|
173
|
+
## Commands
|
|
174
|
+
|
|
175
|
+
| Command | Purpose |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| `collect` | Collect local or copied provider data into SQL. |
|
|
178
|
+
| `sync` | Collect and send metadata-only snapshots to a central API. |
|
|
179
|
+
| `serve` | Run the central collection API. |
|
|
180
|
+
| `export` | Write the HTML dashboard and optional CSV tables. |
|
|
181
|
+
| `providers` | List provider names and support status. |
|
|
182
|
+
|
|
183
|
+
Run `uv run cli-consumption COMMAND --help` for all options.
|
|
184
|
+
|
|
185
|
+
## Development
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
uv sync --all-groups
|
|
189
|
+
uv run pre-commit install
|
|
190
|
+
uv run pre-commit run --all-files
|
|
191
|
+
uv run ruff format --check .
|
|
192
|
+
uv run ruff check .
|
|
193
|
+
uv run ty check
|
|
194
|
+
uv run pytest --cov --cov-report=term-missing
|
|
195
|
+
uv build
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Development uses short-lived branches and squash-merged pull requests into protected
|
|
199
|
+
`main`. Read [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md) before
|
|
200
|
+
changing the project.
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
Licensed under the [Apache License 2.0](LICENSE).
|
|
@@ -16,11 +16,12 @@ provider files -> adapter -> metadata-only snapshot -> SQL storage -> dashboard/
|
|
|
16
16
|
|
|
17
17
|
- `adapters`: parse a CLI's local data into conversations, turns, model calls, tool
|
|
18
18
|
calls, context-pressure samples, bounded turn settings, compactions, and content-free
|
|
19
|
-
work-item intervals. Codex exposes the complete analytics contract
|
|
20
|
-
Claude Code, Continue CLI, Crush, Cursor CLI, Gemini
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
work-item intervals. Codex exposes the complete analytics contract. Aider, Amazon Q
|
|
20
|
+
Developer CLI, Amp, Cline CLI, Claude Code, Continue CLI, Crush, Cursor CLI, Gemini
|
|
21
|
+
CLI, GitHub Copilot CLI, Goose, Grok Build, Kilo Code, Kimi Code CLI, OpenCode,
|
|
22
|
+
OpenHands CLI, Pi, Plandex, and Qwen Code expose the reliable subset available in
|
|
23
|
+
each local store. The exact differences are maintained in
|
|
24
|
+
[Provider support](provider-support.md).
|
|
24
25
|
- `models`: define the transport boundary shared by offline and API ingestion.
|
|
25
26
|
- `storage`: owns the normalized schema, idempotent replacement rules, SQLite, and
|
|
26
27
|
PostgreSQL engine creation.
|
|
@@ -72,7 +73,7 @@ to an older strict API is rejected before ingestion, so central deployments must
|
|
|
72
73
|
upgrade the server first. Downgrading a writer after rich metadata has been ingested is
|
|
73
74
|
not supported because old writers do not know how to replace the new child rows.
|
|
74
75
|
|
|
75
|
-
## Adapter
|
|
76
|
+
## Adapter qualification
|
|
76
77
|
|
|
77
78
|
Adapters are introduced one at a time because local data formats are undocumented or
|
|
78
79
|
can evolve independently. Each adapter must have synthetic fixtures, format detection,
|