copilot-session-usage 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.
- copilot_session_usage-0.1.0/.editorconfig +29 -0
- copilot_session_usage-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- copilot_session_usage-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- copilot_session_usage-0.1.0/.github/guidelines/knowledge-base.guidelines.md +105 -0
- copilot_session_usage-0.1.0/.github/pull_request_template.md +14 -0
- copilot_session_usage-0.1.0/.github/workflows/ci.yml +70 -0
- copilot_session_usage-0.1.0/.github/workflows/publish.yml +32 -0
- copilot_session_usage-0.1.0/.gitignore +220 -0
- copilot_session_usage-0.1.0/AGENTS.md +85 -0
- copilot_session_usage-0.1.0/CONTRIBUTING.md +49 -0
- copilot_session_usage-0.1.0/LICENSE +21 -0
- copilot_session_usage-0.1.0/PKG-INFO +187 -0
- copilot_session_usage-0.1.0/README.md +171 -0
- copilot_session_usage-0.1.0/docs/source/api.md +19 -0
- copilot_session_usage-0.1.0/docs/source/cli.md +7 -0
- copilot_session_usage-0.1.0/docs/source/conf.py +34 -0
- copilot_session_usage-0.1.0/docs/source/index.md +40 -0
- copilot_session_usage-0.1.0/justfile +113 -0
- copilot_session_usage-0.1.0/knowledge/_schema/Concept.schema.yaml +27 -0
- copilot_session_usage-0.1.0/knowledge/_schema/Playbook.schema.yaml +27 -0
- copilot_session_usage-0.1.0/knowledge/_schema/Reference.schema.yaml +27 -0
- copilot_session_usage-0.1.0/knowledge/concepts/copilot-cli.md +48 -0
- copilot_session_usage-0.1.0/knowledge/concepts/cost-optimization.md +55 -0
- copilot_session_usage-0.1.0/knowledge/concepts/index.md +10 -0
- copilot_session_usage-0.1.0/knowledge/concepts/overview.md +47 -0
- copilot_session_usage-0.1.0/knowledge/concepts/session-cost-analysis.md +47 -0
- copilot_session_usage-0.1.0/knowledge/concepts/session-discovery-algorithm.md +81 -0
- copilot_session_usage-0.1.0/knowledge/concepts/subagent-cost-tracking.md +151 -0
- copilot_session_usage-0.1.0/knowledge/concepts/threshold-based-pricing.md +131 -0
- copilot_session_usage-0.1.0/knowledge/concepts/vscode-copilot-extension.md +80 -0
- copilot_session_usage-0.1.0/knowledge/guides/automation-scripts.md +54 -0
- copilot_session_usage-0.1.0/knowledge/guides/index.md +4 -0
- copilot_session_usage-0.1.0/knowledge/guides/wsl2-setup.md +48 -0
- copilot_session_usage-0.1.0/knowledge/ideas/index.md +3 -0
- copilot_session_usage-0.1.0/knowledge/ideas/multi-session-efficiency-analytics.md +222 -0
- copilot_session_usage-0.1.0/knowledge/index.md +10 -0
- copilot_session_usage-0.1.0/knowledge/log.md +114 -0
- copilot_session_usage-0.1.0/knowledge/reference/debug-log-format.md +110 -0
- copilot_session_usage-0.1.0/knowledge/reference/index.md +4 -0
- copilot_session_usage-0.1.0/knowledge/reference/pricing-formats.md +55 -0
- copilot_session_usage-0.1.0/pyproject.toml +72 -0
- copilot_session_usage-0.1.0/skills/copilot-session-usage/SKILL.md +98 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/__init__.py +10 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/_internal/__init__.py +1 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/_internal/copilot_cli.py +18 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/_internal/core.py +1016 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/_internal/vscode.py +242 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/api.py +211 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/cli.py +282 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/data/__init__.py +0 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/data/custom-models-pricing.yml +22 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/data/models-and-pricing.lock +7 -0
- copilot_session_usage-0.1.0/src/copilot_session_usage/data/models-and-pricing.yml +269 -0
- copilot_session_usage-0.1.0/tests/conftest.py +26 -0
- copilot_session_usage-0.1.0/tests/test_api.py +245 -0
- copilot_session_usage-0.1.0/tests/test_cli.py +274 -0
- copilot_session_usage-0.1.0/tests/test_core.py +756 -0
- copilot_session_usage-0.1.0/tests/test_coverage_gaps.py +94 -0
- copilot_session_usage-0.1.0/tests/test_rendering.py +594 -0
- copilot_session_usage-0.1.0/tests/test_vscode.py +406 -0
- copilot_session_usage-0.1.0/tests/test_vscode_platform.py +284 -0
- copilot_session_usage-0.1.0/uv.lock +2129 -0
- copilot_session_usage-0.1.0/uv.toml +6 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
trim_trailing_whitespace = true
|
|
8
|
+
|
|
9
|
+
[*.py]
|
|
10
|
+
indent_style = space
|
|
11
|
+
indent_size = 4
|
|
12
|
+
max_line_length = 100
|
|
13
|
+
|
|
14
|
+
[*.{yml,yaml}]
|
|
15
|
+
indent_style = space
|
|
16
|
+
indent_size = 2
|
|
17
|
+
|
|
18
|
+
[*.{json,jsonc}]
|
|
19
|
+
indent_style = space
|
|
20
|
+
indent_size = 2
|
|
21
|
+
|
|
22
|
+
[*.{md,rst}]
|
|
23
|
+
indent_style = space
|
|
24
|
+
indent_size = 2
|
|
25
|
+
trim_trailing_whitespace = false
|
|
26
|
+
|
|
27
|
+
[justfile]
|
|
28
|
+
indent_style = space
|
|
29
|
+
indent_size = 4
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Report a bug or unexpected behavior
|
|
4
|
+
title: "[BUG] "
|
|
5
|
+
labels: [bug]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Description
|
|
9
|
+
|
|
10
|
+
A clear description of the bug.
|
|
11
|
+
|
|
12
|
+
## Reproduction
|
|
13
|
+
|
|
14
|
+
Steps to reproduce:
|
|
15
|
+
1. Run `...`
|
|
16
|
+
2. See error
|
|
17
|
+
|
|
18
|
+
## Expected behavior
|
|
19
|
+
|
|
20
|
+
What you expected to happen.
|
|
21
|
+
|
|
22
|
+
## Environment
|
|
23
|
+
|
|
24
|
+
- OS:
|
|
25
|
+
- Python version:
|
|
26
|
+
- copilot-session-usage version:
|
|
27
|
+
|
|
28
|
+
## Logs
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Paste any relevant output here.
|
|
32
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea or enhancement
|
|
4
|
+
title: "[FEAT] "
|
|
5
|
+
labels: [enhancement]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Description
|
|
9
|
+
|
|
10
|
+
A clear description of the feature or enhancement.
|
|
11
|
+
|
|
12
|
+
## Motivation
|
|
13
|
+
|
|
14
|
+
Why is this needed? What problem does it solve?
|
|
15
|
+
|
|
16
|
+
## Proposed solution
|
|
17
|
+
|
|
18
|
+
How should this work?
|
|
19
|
+
|
|
20
|
+
## Alternatives
|
|
21
|
+
|
|
22
|
+
Any alternative approaches considered.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "knowledge/**/*.md"
|
|
3
|
+
description: "How coding agents maintain the OKF knowledge bundle in knowledge/."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Knowledge Base Maintenance Guidelines
|
|
7
|
+
|
|
8
|
+
The `knowledge/` directory is an [OKF](https://github.com/gsemet/okf-schema) (Open Knowledge Format) bundle. It is **not** bundled in the wheel — it lives at repo root for agent and maintainer reference only.
|
|
9
|
+
|
|
10
|
+
## What Is OKF?
|
|
11
|
+
|
|
12
|
+
OKF is a lightweight convention for organizing markdown knowledge bases with validated YAML frontmatter. Each document has a `type` field that maps to a JSON Schema in `knowledge/_schema/`.
|
|
13
|
+
|
|
14
|
+
## Schema Files
|
|
15
|
+
|
|
16
|
+
| Schema | For Documents | Purpose |
|
|
17
|
+
|--------|--------------|---------|
|
|
18
|
+
| `_schema/Concept.schema.yml` | `concepts/*.md` | Core concepts and explanatory documents |
|
|
19
|
+
| `_schema/Playbook.schema.yml` | `guides/*.md` | Step-by-step guides and actionable workflows |
|
|
20
|
+
| `_schema/Reference.schema.yml` | `reference/*.md` | Structured data, schemas, or lookup tables |
|
|
21
|
+
|
|
22
|
+
## When to Add a New Document
|
|
23
|
+
|
|
24
|
+
| You want to... | Use type | Put in |
|
|
25
|
+
|----------------|----------|--------|
|
|
26
|
+
| Explain how something works | `Concept` | `knowledge/concepts/` |
|
|
27
|
+
| Provide a step-by-step procedure | `Playbook` | `knowledge/guides/` |
|
|
28
|
+
| Document a format, schema, or lookup table | `Reference` | `knowledge/reference/` |
|
|
29
|
+
| Brainstorm a future feature | `Concept` | `knowledge/ideas/` |
|
|
30
|
+
|
|
31
|
+
**Important rules**:
|
|
32
|
+
|
|
33
|
+
- document only what is not trivial for Coding Agents.
|
|
34
|
+
- do not paraphrase existing documentation or code, you can point if needed.
|
|
35
|
+
- focus on explaining how the external world works, like truthful facts, not opinions or speculation.
|
|
36
|
+
- each knowledge file should be focussed, concise, with important information at the top. Avoid long, rambling documents.
|
|
37
|
+
- prefere short, focussed documents with links and relationships.
|
|
38
|
+
|
|
39
|
+
## Required Frontmatter
|
|
40
|
+
|
|
41
|
+
Every `.md` file under `knowledge/` (except `index.md` and `log.md`) must have:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
---
|
|
45
|
+
type: Concept # or Playbook, Reference
|
|
46
|
+
title: Human-Readable Title
|
|
47
|
+
description: Short summary of what this document covers.
|
|
48
|
+
tags: [keyword, another-tag]
|
|
49
|
+
timestamp: 2026-07-01T00:00:00Z
|
|
50
|
+
---
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Rules:
|
|
54
|
+
|
|
55
|
+
- `type` must match the `const` in the corresponding schema file.
|
|
56
|
+
- `title` and `description` must be non-empty strings.
|
|
57
|
+
- `tags` is optional but strongly encouraged for searchability.
|
|
58
|
+
- `timestamp` must be ISO 8601 (`YYYY-MM-DDTHH:MM:SSZ`).
|
|
59
|
+
|
|
60
|
+
## After Adding or Editing a File
|
|
61
|
+
|
|
62
|
+
1. **Run validation:**
|
|
63
|
+
```bash
|
|
64
|
+
just knowledge-validate
|
|
65
|
+
```
|
|
66
|
+
2. **Run lint (auto-fixes frontmatter formatting):**
|
|
67
|
+
```bash
|
|
68
|
+
just knowledge-lint
|
|
69
|
+
```
|
|
70
|
+
3. **Verify with the check-only variant:**
|
|
71
|
+
```bash
|
|
72
|
+
just knowledge-lint-check
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
All three commands must pass before committing.
|
|
76
|
+
|
|
77
|
+
## When to Update Existing Documents
|
|
78
|
+
|
|
79
|
+
| Trigger | Update |
|
|
80
|
+
|---------|--------|
|
|
81
|
+
| New VS Code Copilot version or new event types | `concepts/vscode-copilot-extension.md` |
|
|
82
|
+
| New JSONL fields in debug logs | `reference/debug-log-format.md` |
|
|
83
|
+
| New pricing tiers or model names | `reference/pricing-formats.md` + `models-and-pricing.yml` |
|
|
84
|
+
| Pricing data drift | Run `just refresh-pricing` |
|
|
85
|
+
| New cost-optimization pattern discovered | `concepts/cost-optimization.md` |
|
|
86
|
+
|
|
87
|
+
## Log Updates
|
|
88
|
+
|
|
89
|
+
Add a dated entry to `knowledge/log.md` for significant changes (refactors, bug fixes, discoveries). Use plain ISO-8601 date headings:
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
## 2026-07-01
|
|
93
|
+
|
|
94
|
+
### brief-topic
|
|
95
|
+
- Bullet describing the change.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Avoid parenthetical annotations in headings — they trigger OKF validation warnings.
|
|
99
|
+
|
|
100
|
+
## Pre-Commit Checklist
|
|
101
|
+
|
|
102
|
+
- [ ] New or edited files have valid YAML frontmatter
|
|
103
|
+
- [ ] `just knowledge-validate` passes (0 errors, 0 warnings)
|
|
104
|
+
- [ ] `just knowledge-lint-check` passes
|
|
105
|
+
- [ ] `just preflight` passes (includes knowledge checks)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
Brief description of the change.
|
|
4
|
+
|
|
5
|
+
## Changes
|
|
6
|
+
|
|
7
|
+
- List specific changes made.
|
|
8
|
+
|
|
9
|
+
## Checklist
|
|
10
|
+
|
|
11
|
+
- [ ] `just preflight` passes locally
|
|
12
|
+
- [ ] Tests added or updated for new behavior
|
|
13
|
+
- [ ] Documentation updated (README, docs/)
|
|
14
|
+
- [ ] Knowledge base validated (`just knowledge-validate`)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
workflow_call:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: uv sync --all-groups
|
|
28
|
+
|
|
29
|
+
- name: Run style check
|
|
30
|
+
run: uv run -- ruff format --check src tests
|
|
31
|
+
|
|
32
|
+
- name: Run linter
|
|
33
|
+
run: uv run -- ruff check src tests
|
|
34
|
+
|
|
35
|
+
- name: Run type checker
|
|
36
|
+
run: uv run -- mypy src
|
|
37
|
+
|
|
38
|
+
- name: Run tests with coverage
|
|
39
|
+
run: uv run -- pytest tests/ --cov=copilot_session_usage --cov-report=xml --cov-fail-under=85
|
|
40
|
+
|
|
41
|
+
- name: Upload coverage
|
|
42
|
+
uses: codecov/codecov-action@v5
|
|
43
|
+
with:
|
|
44
|
+
files: ./coverage.xml
|
|
45
|
+
fail_ci_if_error: false
|
|
46
|
+
|
|
47
|
+
cross-platform:
|
|
48
|
+
runs-on: ${{ matrix.os }}
|
|
49
|
+
strategy:
|
|
50
|
+
fail-fast: false
|
|
51
|
+
matrix:
|
|
52
|
+
os: [macos-latest, windows-latest]
|
|
53
|
+
python-version: ["3.12"]
|
|
54
|
+
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
|
|
58
|
+
- name: Install uv
|
|
59
|
+
uses: astral-sh/setup-uv@v5
|
|
60
|
+
with:
|
|
61
|
+
python-version: ${{ matrix.python-version }}
|
|
62
|
+
|
|
63
|
+
- name: Install just
|
|
64
|
+
uses: extractions/setup-just@v2
|
|
65
|
+
|
|
66
|
+
- name: Install dependencies
|
|
67
|
+
run: uv sync --all-groups
|
|
68
|
+
|
|
69
|
+
- name: Run preflight
|
|
70
|
+
run: just preflight
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ci:
|
|
9
|
+
uses: ./.github/workflows/ci.yml
|
|
10
|
+
|
|
11
|
+
publish:
|
|
12
|
+
needs: ci
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
environment:
|
|
15
|
+
name: pypi
|
|
16
|
+
url: https://pypi.org/p/copilot-session-usage
|
|
17
|
+
permissions:
|
|
18
|
+
id-token: write
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
with:
|
|
23
|
+
fetch-depth: 0
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
uses: astral-sh/setup-uv@v5
|
|
27
|
+
|
|
28
|
+
- name: Build package
|
|
29
|
+
run: uv build
|
|
30
|
+
|
|
31
|
+
- name: Publish to PyPI
|
|
32
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
|
|
220
|
+
.agents/changes/
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# AGENTS.md — copilot-session-usage
|
|
2
|
+
|
|
3
|
+
**copilot-session-usage** is a PyPI-installable Python package that extracts VS Code Copilot session cost KPIs from local debug logs.
|
|
4
|
+
|
|
5
|
+
## Quick Navigation
|
|
6
|
+
|
|
7
|
+
- **[README](README.md)** — User-facing overview and quickstart
|
|
8
|
+
- **[CONTRIBUTING](CONTRIBUTING.md)** — Developer setup and conventions
|
|
9
|
+
- **[.github/guidelines/knowledge-base.guidelines.md](.github/guidelines/knowledge-base.guidelines.md)** - How to use, update and maintain the knowledge base
|
|
10
|
+
|
|
11
|
+
## Technology Stack
|
|
12
|
+
|
|
13
|
+
- **Language**: Python 3.10+
|
|
14
|
+
- **CLI Framework**: Click
|
|
15
|
+
- **YAML Processing**: ruamel.yaml
|
|
16
|
+
- **Package Manager**: uv
|
|
17
|
+
- **Build Tool**: hatchling + hatch-vcs
|
|
18
|
+
- **Task Runner**: just
|
|
19
|
+
|
|
20
|
+
## Project Structure
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
copilot-session-usage/
|
|
24
|
+
├── src/copilot_session_usage/ # Main package
|
|
25
|
+
│ ├── __init__.py # Version re-export
|
|
26
|
+
│ ├── api.py # Public Python API
|
|
27
|
+
│ ├── cli.py # Click CLI entry point
|
|
28
|
+
│ ├── _internal/ # Internal implementation
|
|
29
|
+
│ │ ├── core.py # Cost analysis, JSONL parsing, shaping
|
|
30
|
+
│ │ ├── vscode.py # VS Code workspace discovery
|
|
31
|
+
│ │ └── copilot_cli.py # Stub for future CLI support
|
|
32
|
+
│ └── data/ # Bundled pricing data
|
|
33
|
+
│ ├── models-and-pricing.yml
|
|
34
|
+
│ ├── models-and-pricing.lock
|
|
35
|
+
│ └── custom-models-pricing.yml
|
|
36
|
+
├── tests/ # pytest test suite
|
|
37
|
+
├── docs/ # Sphinx documentation
|
|
38
|
+
├── knowledge/ # OKF knowledge base
|
|
39
|
+
├── skills/ # Agent skill definition
|
|
40
|
+
├── justfile # Task automation
|
|
41
|
+
├── pyproject.toml # Project configuration
|
|
42
|
+
└── uv.toml # uv configuration
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Main Commands
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
just dev # Install dev dependencies
|
|
49
|
+
just test # Run unit tests
|
|
50
|
+
just tests-coverage # Run tests with 85% coverage threshold
|
|
51
|
+
just preflight # Full validation (format → lint → typecheck → test → coverage)
|
|
52
|
+
just docs # Build Sphinx docs
|
|
53
|
+
just docs-serve # Serve docs with auto-reload
|
|
54
|
+
just build # Build wheel + sdist
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Knowledge Base operations
|
|
58
|
+
|
|
59
|
+
When user wants you to debug how VS Code, Copilot CLI, works, how their cost,
|
|
60
|
+
billing, pricing works, when you discover important information that you might
|
|
61
|
+
have to remember, you have to ask yourself this questions: Is this information
|
|
62
|
+
worth remembering for me of for other coding agents, potentially run on
|
|
63
|
+
a different developer's machine ?
|
|
64
|
+
|
|
65
|
+
If you think some discoveries are worth remembering, you have to update the
|
|
66
|
+
knowledge base.
|
|
67
|
+
You have to follow the guidelines in `.github/guidelines/knowledge-base.guidelines.md`
|
|
68
|
+
to understand the rules of the knowledge base in `knowledge/`.
|
|
69
|
+
|
|
70
|
+
## Key Conventions
|
|
71
|
+
|
|
72
|
+
- **Public API**: `api.py` — all functions accept optional `agent` parameter for future routing
|
|
73
|
+
- **Internal modules**: `_internal/` — not part of public API
|
|
74
|
+
- **Pricing data**: Bundled in `src/copilot_session_usage/data/`; loaded via `load_pricing()`
|
|
75
|
+
- **Provider routing**: `--agent {vscode,cli}` — `cli` raises `NotImplementedError`
|
|
76
|
+
- **Detail levels**: `minimal` < `compact` < `full`
|
|
77
|
+
- **Output formats**: `json`, `table`, `detailed` (alias for table + full detail)
|
|
78
|
+
|
|
79
|
+
## Before You Commit
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
just preflight
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
All checks must pass. Coverage threshold is 85%.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributing to copilot-session-usage
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Clone the repository
|
|
7
|
+
git clone https://github.com/gsemet/copilot-session-usage
|
|
8
|
+
cd copilot-session-usage
|
|
9
|
+
|
|
10
|
+
# Install dependencies (uses uv)
|
|
11
|
+
just dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Development workflow
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Run tests
|
|
18
|
+
just test
|
|
19
|
+
|
|
20
|
+
# Run full validation
|
|
21
|
+
just preflight
|
|
22
|
+
|
|
23
|
+
# Build documentation
|
|
24
|
+
just docs
|
|
25
|
+
|
|
26
|
+
# Serve docs with auto-reload
|
|
27
|
+
just docs-serve
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Code style
|
|
31
|
+
|
|
32
|
+
- **Formatter**: ruff (line length 100)
|
|
33
|
+
- **Linter**: ruff, ty, mypy
|
|
34
|
+
- **Type checker**: mypy (strict)
|
|
35
|
+
- **Test runner**: pytest with pytest-cov
|
|
36
|
+
|
|
37
|
+
## Adding features
|
|
38
|
+
|
|
39
|
+
1. Add or update code in `src/copilot_session_usage/`
|
|
40
|
+
2. Add tests in `tests/`
|
|
41
|
+
3. Update documentation in `docs/source/`
|
|
42
|
+
4. Run `just preflight` to validate
|
|
43
|
+
5. Submit a pull request
|
|
44
|
+
|
|
45
|
+
## Release process
|
|
46
|
+
|
|
47
|
+
1. Tag a release: `git tag v1.2.3`
|
|
48
|
+
2. Push tags: `git push --tags`
|
|
49
|
+
3. CI builds and publishes to PyPI via OIDC
|
|
@@ -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.
|