tktop 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.
- tktop-0.1.0/.coverage +0 -0
- tktop-0.1.0/.env.example +23 -0
- tktop-0.1.0/.github/workflows/ci.yml +34 -0
- tktop-0.1.0/.github/workflows/release.yml +51 -0
- tktop-0.1.0/.gitignore +50 -0
- tktop-0.1.0/AGENTS.md +60 -0
- tktop-0.1.0/LICENSE +21 -0
- tktop-0.1.0/Makefile +34 -0
- tktop-0.1.0/PKG-INFO +150 -0
- tktop-0.1.0/README.md +95 -0
- tktop-0.1.0/devbox.json +16 -0
- tktop-0.1.0/docs/plans/2026-06-08-tktop.md +3680 -0
- tktop-0.1.0/docs/plans/2026-06-13-codex-support.md +161 -0
- tktop-0.1.0/docs/plans/2026-06-13-pip-distribution.md +191 -0
- tktop-0.1.0/docs/specs/2026-06-08-tktop-design.md +954 -0
- tktop-0.1.0/pyproject.toml +78 -0
- tktop-0.1.0/scripts/release.py +14 -0
- tktop-0.1.0/src/tktop/__init__.py +6 -0
- tktop-0.1.0/src/tktop/adapter/__init__.py +0 -0
- tktop-0.1.0/src/tktop/adapter/claude.py +177 -0
- tktop-0.1.0/src/tktop/adapter/codex.py +265 -0
- tktop-0.1.0/src/tktop/adapter/factory.py +23 -0
- tktop-0.1.0/src/tktop/adapter/protocol.py +15 -0
- tktop-0.1.0/src/tktop/cli.py +33 -0
- tktop-0.1.0/src/tktop/config.py +237 -0
- tktop-0.1.0/src/tktop/llm/__init__.py +0 -0
- tktop-0.1.0/src/tktop/llm/anthropic_provider.py +34 -0
- tktop-0.1.0/src/tktop/llm/factory.py +24 -0
- tktop-0.1.0/src/tktop/llm/ollama.py +37 -0
- tktop-0.1.0/src/tktop/llm/openai_provider.py +44 -0
- tktop-0.1.0/src/tktop/llm/prompt.py +108 -0
- tktop-0.1.0/src/tktop/llm/protocol.py +10 -0
- tktop-0.1.0/src/tktop/llm/vertex.py +59 -0
- tktop-0.1.0/src/tktop/metrics/__init__.py +0 -0
- tktop-0.1.0/src/tktop/metrics/aggregator.py +67 -0
- tktop-0.1.0/src/tktop/metrics/drift.py +259 -0
- tktop-0.1.0/src/tktop/metrics/pricing.py +48 -0
- tktop-0.1.0/src/tktop/metrics/types.py +95 -0
- tktop-0.1.0/src/tktop/release.py +145 -0
- tktop-0.1.0/src/tktop/tui/__init__.py +0 -0
- tktop-0.1.0/src/tktop/tui/app.py +38 -0
- tktop-0.1.0/src/tktop/tui/screens/__init__.py +0 -0
- tktop-0.1.0/src/tktop/tui/screens/analysis.py +126 -0
- tktop-0.1.0/src/tktop/tui/screens/dashboard.py +189 -0
- tktop-0.1.0/src/tktop/tui/screens/help.py +82 -0
- tktop-0.1.0/src/tktop/tui/screens/history.py +173 -0
- tktop-0.1.0/src/tktop/tui/screens/overview.py +138 -0
- tktop-0.1.0/src/tktop/tui/screens/provider_picker.py +59 -0
- tktop-0.1.0/src/tktop/tui/screens/turn_detail.py +71 -0
- tktop-0.1.0/src/tktop/tui/styles.tcss +87 -0
- tktop-0.1.0/src/tktop/tui/widgets/__init__.py +0 -0
- tktop-0.1.0/src/tktop/tui/widgets/alert_panel.py +32 -0
- tktop-0.1.0/src/tktop/tui/widgets/cost_graph.py +120 -0
- tktop-0.1.0/src/tktop/tui/widgets/session_card.py +32 -0
- tktop-0.1.0/src/tktop/tui/widgets/token_bars.py +60 -0
- tktop-0.1.0/src/tktop/tui/widgets/token_graph.py +10 -0
- tktop-0.1.0/src/tktop/tui/widgets/tool_table.py +33 -0
- tktop-0.1.0/tests/conftest.py +30 -0
- tktop-0.1.0/tests/fixtures/codex_session.jsonl +9 -0
- tktop-0.1.0/tests/fixtures/codex_session_index.jsonl +1 -0
- tktop-0.1.0/tests/fixtures/session_simple.json +13 -0
- tktop-0.1.0/tests/fixtures/transcript_drift.jsonl +7 -0
- tktop-0.1.0/tests/fixtures/transcript_simple.jsonl +5 -0
- tktop-0.1.0/tests/fixtures/transcript_with_tools.jsonl +6 -0
- tktop-0.1.0/tests/test_adapter_claude.py +92 -0
- tktop-0.1.0/tests/test_adapter_codex.py +237 -0
- tktop-0.1.0/tests/test_aggregator.py +240 -0
- tktop-0.1.0/tests/test_config.py +153 -0
- tktop-0.1.0/tests/test_config_settings.py +72 -0
- tktop-0.1.0/tests/test_cost_graph.py +92 -0
- tktop-0.1.0/tests/test_drift.py +167 -0
- tktop-0.1.0/tests/test_history.py +146 -0
- tktop-0.1.0/tests/test_integration.py +32 -0
- tktop-0.1.0/tests/test_integration_codex.py +32 -0
- tktop-0.1.0/tests/test_llm_factory.py +47 -0
- tktop-0.1.0/tests/test_llm_ollama.py +58 -0
- tktop-0.1.0/tests/test_pricing.py +73 -0
- tktop-0.1.0/tests/test_prompt.py +110 -0
- tktop-0.1.0/tests/test_release.py +37 -0
- tktop-0.1.0/tests/test_session_title.py +92 -0
- tktop-0.1.0/tests/test_token_bars.py +36 -0
- tktop-0.1.0/tests/test_types.py +47 -0
tktop-0.1.0/.coverage
ADDED
|
Binary file
|
tktop-0.1.0/.env.example
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Claude data directory (default: ~/.claude)
|
|
2
|
+
# TKTOP_CLAUDE_DIR=~/.claude
|
|
3
|
+
|
|
4
|
+
# LLM provider: ollama | anthropic | vertex | openai
|
|
5
|
+
TKTOP_LLM_PROVIDER=ollama
|
|
6
|
+
|
|
7
|
+
# Ollama settings
|
|
8
|
+
TKTOP_OLLAMA_HOST=http://localhost:11434
|
|
9
|
+
TKTOP_OLLAMA_MODEL=llama3
|
|
10
|
+
|
|
11
|
+
# Anthropic settings (if using anthropic provider)
|
|
12
|
+
# TKTOP_ANTHROPIC_API_KEY=sk-ant-...
|
|
13
|
+
# TKTOP_ANTHROPIC_MODEL=claude-sonnet-4-6
|
|
14
|
+
|
|
15
|
+
# Vertex AI settings (if using vertex provider)
|
|
16
|
+
# TKTOP_VERTEX_PROJECT=my-project
|
|
17
|
+
# TKTOP_VERTEX_REGION=us-central1
|
|
18
|
+
# TKTOP_VERTEX_MODEL=claude-sonnet-4-6
|
|
19
|
+
|
|
20
|
+
# OpenAI-compatible settings (if using openai provider)
|
|
21
|
+
# TKTOP_OPENAI_BASE_URL=https://api.openai.com/v1
|
|
22
|
+
# TKTOP_OPENAI_API_KEY=sk-...
|
|
23
|
+
# TKTOP_OPENAI_MODEL=gpt-4o
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- name: Check out repository
|
|
12
|
+
uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
|
|
19
|
+
- name: Install tooling
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
python -m pip install -e ".[dev]" build
|
|
23
|
+
|
|
24
|
+
- name: Lint
|
|
25
|
+
run: ruff check src tests
|
|
26
|
+
|
|
27
|
+
- name: Security scan
|
|
28
|
+
run: bandit -r src/tktop/ -q
|
|
29
|
+
|
|
30
|
+
- name: Test
|
|
31
|
+
run: pytest -q
|
|
32
|
+
|
|
33
|
+
- name: Build distributions
|
|
34
|
+
run: python -m build
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Check out repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.13"
|
|
20
|
+
|
|
21
|
+
- name: Install build tooling
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
python -m pip install build
|
|
25
|
+
|
|
26
|
+
- name: Build distributions
|
|
27
|
+
run: python -m build
|
|
28
|
+
|
|
29
|
+
- name: Upload build artifacts
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
|
|
35
|
+
publish:
|
|
36
|
+
needs: build
|
|
37
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
permissions:
|
|
40
|
+
id-token: write
|
|
41
|
+
environment:
|
|
42
|
+
name: pypi
|
|
43
|
+
steps:
|
|
44
|
+
- name: Download build artifacts
|
|
45
|
+
uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: dist
|
|
48
|
+
path: dist/
|
|
49
|
+
|
|
50
|
+
- name: Publish to PyPI
|
|
51
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
tktop-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# OS
|
|
2
|
+
.DS_Store
|
|
3
|
+
Thumbs.db
|
|
4
|
+
|
|
5
|
+
# Editors
|
|
6
|
+
.vscode/
|
|
7
|
+
.idea/
|
|
8
|
+
*.swp
|
|
9
|
+
*.swo
|
|
10
|
+
*~
|
|
11
|
+
|
|
12
|
+
# Environment
|
|
13
|
+
.env
|
|
14
|
+
.env.*
|
|
15
|
+
.devbox/
|
|
16
|
+
|
|
17
|
+
# Build
|
|
18
|
+
build/
|
|
19
|
+
dist/
|
|
20
|
+
out/
|
|
21
|
+
|
|
22
|
+
# Dependencies
|
|
23
|
+
node_modules/
|
|
24
|
+
vendor/
|
|
25
|
+
__pycache__/
|
|
26
|
+
*.pyc
|
|
27
|
+
|
|
28
|
+
# Binaries
|
|
29
|
+
*.exe
|
|
30
|
+
*.dll
|
|
31
|
+
*.so
|
|
32
|
+
*.dylib
|
|
33
|
+
|
|
34
|
+
# Logs
|
|
35
|
+
*.log
|
|
36
|
+
|
|
37
|
+
# Python
|
|
38
|
+
*.egg-info/
|
|
39
|
+
*.egg
|
|
40
|
+
.eggs/
|
|
41
|
+
|
|
42
|
+
# Virtual environments
|
|
43
|
+
.venv/
|
|
44
|
+
venv/
|
|
45
|
+
|
|
46
|
+
# PyInstaller
|
|
47
|
+
*.spec
|
|
48
|
+
|
|
49
|
+
# Don't ignore .env.example
|
|
50
|
+
!.env.example
|
tktop-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Codex Repository Instructions
|
|
2
|
+
|
|
3
|
+
## Project
|
|
4
|
+
|
|
5
|
+
`tktop` is a Python 3.13+ Textual TUI for monitoring token usage, cost, tools,
|
|
6
|
+
and drift in coding-agent sessions. The current adapter reads Claude Code
|
|
7
|
+
session metadata and JSONL transcripts from `~/.claude`.
|
|
8
|
+
|
|
9
|
+
## Source Of Truth
|
|
10
|
+
|
|
11
|
+
- Product and architecture specification: `docs/specs/2026-06-08-tktop-design.md`
|
|
12
|
+
- Historical implementation record: `docs/plans/2026-06-08-tktop.md`
|
|
13
|
+
- User-facing setup and usage: `README.md`
|
|
14
|
+
|
|
15
|
+
The implementation record documents how the current code was built. Do not
|
|
16
|
+
replay its completed tasks or embedded commit steps. For new work, inspect the
|
|
17
|
+
current code and tests first, then update the specification when behavior or
|
|
18
|
+
architecture changes.
|
|
19
|
+
|
|
20
|
+
## Repository Layout
|
|
21
|
+
|
|
22
|
+
- `src/tktop/adapter/`: coding-agent session adapters
|
|
23
|
+
- `src/tktop/metrics/`: data models, aggregation, pricing, and drift detection
|
|
24
|
+
- `src/tktop/llm/`: analysis prompts and provider integrations
|
|
25
|
+
- `src/tktop/tui/`: Textual application, screens, widgets, and styles
|
|
26
|
+
- `tests/`: unit and integration tests with local fixtures
|
|
27
|
+
|
|
28
|
+
## Development Commands
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
make install
|
|
32
|
+
make test
|
|
33
|
+
make lint
|
|
34
|
+
make security
|
|
35
|
+
make check
|
|
36
|
+
make run
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Run focused tests while iterating, then run `make check` before committing.
|
|
40
|
+
`make audit` performs the optional dependency vulnerability scan.
|
|
41
|
+
|
|
42
|
+
## Engineering Conventions
|
|
43
|
+
|
|
44
|
+
- Preserve the adapter and provider protocols when adding implementations.
|
|
45
|
+
- Keep blocking file or network work out of the Textual UI event loop.
|
|
46
|
+
- Handle malformed or missing external session data gracefully.
|
|
47
|
+
- Add or update tests for behavior changes.
|
|
48
|
+
- Keep Ruff compatibility with Python 3.13 and the configured 100-character
|
|
49
|
+
line length.
|
|
50
|
+
- Never commit API keys, `.env`, local session data, or generated build output.
|
|
51
|
+
- Do not modify files under `.git/`; local hooks are not portable project
|
|
52
|
+
configuration.
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
- Keep Claude-specific names when they describe supported product behavior,
|
|
57
|
+
model IDs, environment variables, or the Claude Code data format.
|
|
58
|
+
- Keep agent workflow instructions vendor-neutral and compatible with Codex.
|
|
59
|
+
- Use `docs/specs/` for current design documentation and `docs/plans/` for
|
|
60
|
+
implementation plans or historical execution records.
|
tktop-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 K Hari Sankar
|
|
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.
|
tktop-0.1.0/Makefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.PHONY: install run test lint security audit check binary clean release
|
|
2
|
+
|
|
3
|
+
install:
|
|
4
|
+
pip install -e ".[dev]"
|
|
5
|
+
|
|
6
|
+
run:
|
|
7
|
+
python -m tktop.cli
|
|
8
|
+
|
|
9
|
+
test:
|
|
10
|
+
pytest -v
|
|
11
|
+
|
|
12
|
+
lint:
|
|
13
|
+
ruff check src/ tests/
|
|
14
|
+
|
|
15
|
+
security:
|
|
16
|
+
bandit -r src/tktop/ -q
|
|
17
|
+
|
|
18
|
+
audit:
|
|
19
|
+
pip-audit
|
|
20
|
+
|
|
21
|
+
check: lint security test
|
|
22
|
+
@echo "✅ All checks passed."
|
|
23
|
+
|
|
24
|
+
binary:
|
|
25
|
+
pyinstaller --onefile --name tktop --paths src src/tktop/cli.py --add-data "src/tktop/tui/styles.tcss:tktop/tui"
|
|
26
|
+
@echo "✅ Binary at dist/tktop ($(du -h dist/tktop | cut -f1))"
|
|
27
|
+
|
|
28
|
+
clean:
|
|
29
|
+
rm -rf build/ dist/ *.egg-info src/*.egg-info *.spec
|
|
30
|
+
find . -type d -name __pycache__ -exec rm -rf {} +
|
|
31
|
+
|
|
32
|
+
release:
|
|
33
|
+
@test -n "$(VERSION)" || (echo "VERSION is required, for example: make release VERSION=0.1.1"; exit 1)
|
|
34
|
+
python3 scripts/release.py "$(VERSION)"
|
tktop-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tktop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Token monitor for coding agents — like htop for AI spend
|
|
5
|
+
Project-URL: Homepage, https://github.com/chanilharisankar/tktop
|
|
6
|
+
Project-URL: Repository, https://github.com/chanilharisankar/tktop
|
|
7
|
+
Project-URL: Issues, https://github.com/chanilharisankar/tktop/issues
|
|
8
|
+
Author: Harisan Sankar
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 K Hari Sankar
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
|
+
Classifier: Environment :: Console
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
38
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
39
|
+
Classifier: Topic :: Utilities
|
|
40
|
+
Requires-Python: >=3.13
|
|
41
|
+
Requires-Dist: httpx>=0.27.0
|
|
42
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
43
|
+
Requires-Dist: rich>=13.0.0
|
|
44
|
+
Requires-Dist: textual>=1.0.0
|
|
45
|
+
Requires-Dist: typer>=0.12.0
|
|
46
|
+
Requires-Dist: watchfiles>=0.21.0
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: bandit>=1.7.0; extra == 'dev'
|
|
49
|
+
Requires-Dist: build>=1.2.0; extra == 'dev'
|
|
50
|
+
Requires-Dist: pip-audit>=2.7.0; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
|
|
56
|
+
# tktop
|
|
57
|
+
|
|
58
|
+
Token monitor for coding agents. Like `htop` for your AI spend.
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- **Live dashboard** — real-time token usage breakdown (input/output/cache)
|
|
63
|
+
- **Token flow graph** — sparkline showing output tokens per turn
|
|
64
|
+
- **Tool stats** — see which tools consume the most calls
|
|
65
|
+
- **Drift detection** — 9 algorithms detecting loops, thrashing, runaway sessions
|
|
66
|
+
- **Cost tracking** — per-session cost estimates by model
|
|
67
|
+
- **Turn drill-down** — inspect individual turns with token split and content preview
|
|
68
|
+
- **LLM analysis** — on-demand optimization suggestions via Ollama/Anthropic/Vertex AI/OpenAI
|
|
69
|
+
|
|
70
|
+
## Install
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# From PyPI
|
|
74
|
+
pip install tktop
|
|
75
|
+
|
|
76
|
+
# Upgrade to the latest release
|
|
77
|
+
pip install -U tktop
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
tktop # launch interactive session list
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Keybindings
|
|
87
|
+
|
|
88
|
+
| Key | Action |
|
|
89
|
+
|-----|--------|
|
|
90
|
+
| `↑/↓` or `j/k` | Navigate |
|
|
91
|
+
| `enter` | Select / drill-down |
|
|
92
|
+
| `a` | Run LLM analysis |
|
|
93
|
+
| `r` | Refresh |
|
|
94
|
+
| `escape` | Back |
|
|
95
|
+
| `q` | Quit |
|
|
96
|
+
|
|
97
|
+
## Supported Agents
|
|
98
|
+
|
|
99
|
+
- [x] Claude Code
|
|
100
|
+
- [x] Codex
|
|
101
|
+
- [ ] Cursor (planned)
|
|
102
|
+
- [ ] Aider (planned)
|
|
103
|
+
|
|
104
|
+
## LLM Analysis
|
|
105
|
+
|
|
106
|
+
Copy `.env.example` to `.env` and configure:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cp .env.example .env
|
|
110
|
+
# Edit .env with your provider settings
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Supported providers: `ollama` (default), `anthropic`, `vertex`, `openai`
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
make install # install in dev mode
|
|
119
|
+
make test # run tests
|
|
120
|
+
make clean # clean build artifacts
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Local development still uses an editable install:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install -e ".[dev]"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
For maintainers, a versioned release can be prepared with:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
make release VERSION=0.1.1
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Devbox
|
|
136
|
+
|
|
137
|
+
If you have the Devbox CLI installed, you can bootstrap the repo with:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
devbox shell
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
On first entry, the shell creates `.venv`, installs `.[dev]`, and activates the
|
|
144
|
+
environment for the session.
|
|
145
|
+
|
|
146
|
+
License: MIT. See [LICENSE](LICENSE).
|
|
147
|
+
|
|
148
|
+
Repository instructions for Codex are in [`AGENTS.md`](AGENTS.md). The current
|
|
149
|
+
design is documented in
|
|
150
|
+
[`docs/specs/2026-06-08-tktop-design.md`](docs/specs/2026-06-08-tktop-design.md).
|
tktop-0.1.0/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# tktop
|
|
2
|
+
|
|
3
|
+
Token monitor for coding agents. Like `htop` for your AI spend.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Live dashboard** — real-time token usage breakdown (input/output/cache)
|
|
8
|
+
- **Token flow graph** — sparkline showing output tokens per turn
|
|
9
|
+
- **Tool stats** — see which tools consume the most calls
|
|
10
|
+
- **Drift detection** — 9 algorithms detecting loops, thrashing, runaway sessions
|
|
11
|
+
- **Cost tracking** — per-session cost estimates by model
|
|
12
|
+
- **Turn drill-down** — inspect individual turns with token split and content preview
|
|
13
|
+
- **LLM analysis** — on-demand optimization suggestions via Ollama/Anthropic/Vertex AI/OpenAI
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# From PyPI
|
|
19
|
+
pip install tktop
|
|
20
|
+
|
|
21
|
+
# Upgrade to the latest release
|
|
22
|
+
pip install -U tktop
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
tktop # launch interactive session list
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Keybindings
|
|
32
|
+
|
|
33
|
+
| Key | Action |
|
|
34
|
+
|-----|--------|
|
|
35
|
+
| `↑/↓` or `j/k` | Navigate |
|
|
36
|
+
| `enter` | Select / drill-down |
|
|
37
|
+
| `a` | Run LLM analysis |
|
|
38
|
+
| `r` | Refresh |
|
|
39
|
+
| `escape` | Back |
|
|
40
|
+
| `q` | Quit |
|
|
41
|
+
|
|
42
|
+
## Supported Agents
|
|
43
|
+
|
|
44
|
+
- [x] Claude Code
|
|
45
|
+
- [x] Codex
|
|
46
|
+
- [ ] Cursor (planned)
|
|
47
|
+
- [ ] Aider (planned)
|
|
48
|
+
|
|
49
|
+
## LLM Analysis
|
|
50
|
+
|
|
51
|
+
Copy `.env.example` to `.env` and configure:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cp .env.example .env
|
|
55
|
+
# Edit .env with your provider settings
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Supported providers: `ollama` (default), `anthropic`, `vertex`, `openai`
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
make install # install in dev mode
|
|
64
|
+
make test # run tests
|
|
65
|
+
make clean # clean build artifacts
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Local development still uses an editable install:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install -e ".[dev]"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For maintainers, a versioned release can be prepared with:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
make release VERSION=0.1.1
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Devbox
|
|
81
|
+
|
|
82
|
+
If you have the Devbox CLI installed, you can bootstrap the repo with:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
devbox shell
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
On first entry, the shell creates `.venv`, installs `.[dev]`, and activates the
|
|
89
|
+
environment for the session.
|
|
90
|
+
|
|
91
|
+
License: MIT. See [LICENSE](LICENSE).
|
|
92
|
+
|
|
93
|
+
Repository instructions for Codex are in [`AGENTS.md`](AGENTS.md). The current
|
|
94
|
+
design is documented in
|
|
95
|
+
[`docs/specs/2026-06-08-tktop-design.md`](docs/specs/2026-06-08-tktop-design.md).
|
tktop-0.1.0/devbox.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/.devbox.schema.json",
|
|
3
|
+
"packages": [
|
|
4
|
+
"python@3.13",
|
|
5
|
+
"git",
|
|
6
|
+
"uv"
|
|
7
|
+
],
|
|
8
|
+
"shell": {
|
|
9
|
+
"init_hook": "if [ ! -f .venv/.tktop-devbox-ready ]; then\n python -m venv .venv\n . .venv/bin/activate\n python -m pip install --upgrade pip\n python -m pip install -e \".[dev]\"\n touch .venv/.tktop-devbox-ready\nfi\n. .venv/bin/activate\n",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"check": "make check",
|
|
12
|
+
"lint": "make lint",
|
|
13
|
+
"test": "make test"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|