copilot-session-usage 0.4.0__tar.gz → 0.5.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.
Files changed (108) hide show
  1. copilot_session_usage-0.5.0/.github/guidelines/git-commit-message.guideline.md +99 -0
  2. copilot_session_usage-0.5.0/.github/skills/gh-release-notes/SKILL.md +234 -0
  3. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/AGENTS.md +1 -0
  4. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/CHANGELOG.md +7 -0
  5. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/PKG-INFO +2 -1
  6. copilot_session_usage-0.5.0/docs/source/how-to/add-commit-trailer.md +133 -0
  7. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/how-to/index.md +1 -0
  8. copilot_session_usage-0.5.0/docs/source/reference/cli.md +11 -0
  9. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/justfile +3 -0
  10. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/pyproject.toml +1 -0
  11. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/skills/copilot-session-usage/SKILL.md +55 -0
  12. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/_internal/core.py +257 -91
  13. copilot_session_usage-0.5.0/src/copilot_session_usage/_internal/git.py +126 -0
  14. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/_internal/vscode.py +43 -0
  15. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/cli.py +110 -1
  16. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/test_cli.py +137 -0
  17. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/test_core.py +213 -5
  18. copilot_session_usage-0.5.0/tests/test_git.py +176 -0
  19. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/test_rendering.py +11 -10
  20. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/uv.lock +35 -0
  21. copilot_session_usage-0.4.0/docs/source/reference/cli.md +0 -7
  22. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.editorconfig +0 -0
  23. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  24. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  25. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/changes/requests/skill-breakdown/01-request.md +0 -0
  26. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/guidelines/knowledge-base.guidelines.md +0 -0
  27. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/pull_request_template.md +0 -0
  28. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/skills/consolidate-knowledge-base/SKILL.md +0 -0
  29. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/skills/record-finding/SKILL.md +0 -0
  30. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/workflows/ci.yml +0 -0
  31. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.github/workflows/publish.yml +0 -0
  32. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.gitignore +0 -0
  33. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/.readthedocs.yaml +0 -0
  34. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/CONTRIBUTING.md +0 -0
  35. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/LICENSE +0 -0
  36. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/README.md +0 -0
  37. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/_static/changelog.js +0 -0
  38. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/_static/custom.css +0 -0
  39. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/changelog.md +0 -0
  40. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/conf.py +0 -0
  41. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/explanation/how-cost-estimation-works.md +0 -0
  42. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/explanation/index.md +0 -0
  43. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/how-to/analyze-specific-session.md +0 -0
  44. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/how-to/batch-and-spending.md +0 -0
  45. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/how-to/export-json.md +0 -0
  46. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/how-to/wsl2.md +0 -0
  47. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/index.md +0 -0
  48. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/installation.md +0 -0
  49. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/reference/api.md +0 -0
  50. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/reference/index.md +0 -0
  51. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/reference/pricing.md +0 -0
  52. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/tutorials/getting-started.md +0 -0
  53. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/docs/source/tutorials/index.md +0 -0
  54. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Base.schema.yaml +0 -0
  55. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Concept.schema.yaml +0 -0
  56. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Experiment.schema.yaml +0 -0
  57. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Finding.schema.yaml +0 -0
  58. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Hypothesis.schema.yaml +0 -0
  59. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Outcome.schema.yaml +0 -0
  60. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Playbook.schema.yaml +0 -0
  61. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Principle.schema.yaml +0 -0
  62. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Reference.schema.yaml +0 -0
  63. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/_schema/Structure.schema.yaml +0 -0
  64. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/concepts/copilot-cli.md +0 -0
  65. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/concepts/index.md +0 -0
  66. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/concepts/overview.md +0 -0
  67. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/concepts/session-cost-analysis.md +0 -0
  68. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/concepts/threshold-based-pricing.md +0 -0
  69. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/experiments/index.md +0 -0
  70. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/experiments/verify-subagent-cost-attribution.md +0 -0
  71. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/findings/2026.07.02-00.00-subagent-logs-runsubagent-prefix.md +0 -0
  72. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/findings/2026.07.02-22.00-title-generation-not-counted-as-model-turn.md +0 -0
  73. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/findings/2026.07.02-23.00-cache-write-approximation.md +0 -0
  74. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/findings/index.md +0 -0
  75. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/guides/automation-scripts.md +0 -0
  76. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/guides/cost-optimization.md +0 -0
  77. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/guides/index.md +0 -0
  78. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/guides/wsl2-setup.md +0 -0
  79. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/ideas/index.md +0 -0
  80. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/ideas/multi-session-efficiency-analytics.md +0 -0
  81. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/index.md +0 -0
  82. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/log.md +0 -0
  83. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/principles/findings-are-immutable.md +0 -0
  84. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/principles/index.md +0 -0
  85. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/reference/debug-log-format.md +0 -0
  86. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/reference/index.md +0 -0
  87. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/reference/pricing-formats.md +0 -0
  88. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/structures/cache-cost-approximation.md +0 -0
  89. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/structures/index.md +0 -0
  90. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/structures/knowledge-base-information-types.md +0 -0
  91. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/structures/session-discovery-algorithm.md +0 -0
  92. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/structures/subagent-cost-tracking.md +0 -0
  93. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/knowledge/structures/vscode-copilot-extension.md +0 -0
  94. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/scripts/refresh_pricing.py +0 -0
  95. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/__init__.py +0 -0
  96. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/_internal/__init__.py +0 -0
  97. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/_internal/copilot_cli.py +0 -0
  98. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/api.py +0 -0
  99. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/data/__init__.py +0 -0
  100. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/data/custom-models-pricing.yml +0 -0
  101. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/data/models-and-pricing.lock +0 -0
  102. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/src/copilot_session_usage/data/models-and-pricing.yml +0 -0
  103. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/conftest.py +0 -0
  104. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/test_api.py +0 -0
  105. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/test_coverage_gaps.py +0 -0
  106. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/test_vscode.py +0 -0
  107. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/tests/test_vscode_platform.py +0 -0
  108. {copilot_session_usage-0.4.0 → copilot_session_usage-0.5.0}/uv.toml +0 -0
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: Git Commit Message Guideline 1.0
3
+ description: Guidelines for writing conventional commits that communicate intent and user impact
4
+ metadata:
5
+ owner: Gaetan Semet <gaetan.semet@ampere.cars>
6
+ keywords: [git, commit, conventional, message, changelog]
7
+ guideline-id: 45c42e46-0781-4954-a410-1f380f5553f3
8
+ ---
9
+
10
+ # Git Commit Message Guideline
11
+
12
+ Write clear, focused commit messages following Conventional Commits format. Commit messages communicate *why* changes were made—enabling automated changelog generation, bug investigation, and decision-making during upgrades. Focus on user impact, not implementation details.
13
+
14
+ ## Core Rules
15
+
16
+ ### Rule 1: Use Conventional Commit Format
17
+
18
+ **Apply:** Format every title as `type(scope): description`
19
+
20
+ **Why:** Enables automated changelog generation and consistent pattern parsing.
21
+
22
+ **Types:** `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `ci`, `chore`, `build`, `revert`
23
+
24
+ **Examples:**
25
+ ```
26
+ feat(auth): add two-factor authentication support
27
+ fix(api): resolve request timeout in user endpoint
28
+ docs(readme): update installation instructions
29
+ perf(cache): optimize query performance by 40%
30
+ test(validators): add email format validation tests
31
+ ```
32
+
33
+ ---
34
+
35
+ ### Rule 2: Keep Title Under 50 Characters, Body Under 72 Per Line
36
+
37
+ **Apply:** Enforce character limits for scannability and terminal compatibility.
38
+
39
+ **Why:** Short titles force clarity; wrapped body text maintains readability in terminals and email clients.
40
+
41
+ **Example:**
42
+ ```
43
+ feat(cache): implement LRU eviction policy
44
+
45
+ Reduces memory usage in long-running processes by
46
+ automatically removing least-recently-used items.
47
+
48
+ Changes:
49
+ - Cache drops oldest accessed items upon limit
50
+ - Configurable cache size (default 1000)
51
+ - < 2% performance overhead on reads
52
+
53
+ Users can set CACHE_SIZE environment variable.
54
+ ```
55
+
56
+ ---
57
+
58
+ ### Rule 3: Focus Body on User Impact, Not Implementation Details
59
+
60
+ **Apply:** Describe what users gain and must know; exclude refactoring details, internal functions, and test additions.
61
+
62
+ **Why:** Users deciding whether to upgrade, developers integrating changes, and bug investigators need user-level context—not code structure details.
63
+
64
+ **Example:**
65
+ ```
66
+ fix(api): allow null values in optional response fields
67
+
68
+ Optional fields now omitted from JSON when empty,
69
+ reducing response payload by ~15% for sparse data.
70
+
71
+ Migration:
72
+ - Check `field in response` instead of `field != null`
73
+ - Response schema updated in API reference
74
+ ```
75
+
76
+ ---
77
+
78
+ ### Rule 4: Include Breaking Changes with Migration Guidance
79
+
80
+ **Apply:** Use `!` in title and `BREAKING CHANGE:` section. Provide explicit migration steps.
81
+
82
+ **Why:** Breaking changes require user action; clear guidance reduces upgrade confusion.
83
+
84
+ **Example:**
85
+ ```
86
+ feat(api)!: change pagination to cursor-based tokens
87
+
88
+ Cursors improve performance with large datasets.
89
+
90
+ BREAKING CHANGE: Replaced `pagination_offset` and
91
+ `pagination_limit` with `pagination.cursor`.
92
+
93
+ Migration:
94
+ Old: GET /users?limit=10&offset=20
95
+ New: GET /users?limit=10&cursor=xyz123
96
+
97
+ Update code to use `response.pagination.cursor`
98
+ in next request instead of offset/limit.
99
+ ```
@@ -0,0 +1,234 @@
1
+ # Release Notes Generator (Git Diff Based)
2
+
3
+ Generate **end-user friendly** release notes by analyzing actual code changes between releases.
4
+ No scripts required — uses git commands to understand what changed and why it matters.
5
+
6
+ ---
7
+
8
+ ## Quick Start
9
+
10
+ Provide your repository and range:
11
+
12
+ ```
13
+ Generate release notes from v1.0.0 to v1.1.0 in /path/to/repo
14
+ ```
15
+
16
+ Or reference the last release:
17
+
18
+ ```
19
+ What changed since the last release tag?
20
+ ```
21
+
22
+ ---
23
+
24
+ ## What It Does
25
+
26
+ 1. **Reads actual diffs** — examines code changes, not just commit messages
27
+ 2. **Interprets for end-users** — no technical jargon, functions, or variable names
28
+ 3. **Categorizes intelligently** — Features, Enhancements, Bug Fixes, Breaking Changes
29
+ 4. **Consolidates related changes** — groups related diffs, eliminates back-and-forth noise
30
+ 5. **Outputs clean markdown** — Slack-ready format suitable for announcements
31
+
32
+ ---
33
+
34
+ ## Input
35
+
36
+ Accept either:
37
+
38
+ - **Natural language**: "Show release notes from v1.2.0 to v1.3.0"
39
+ - **Range spec**: `from_tag=v1.2.0 to_tag=v1.3.0 repo_path=/path/to/repo`
40
+ - **Last release**: `since_tag=v1.2.0` (everything from tag to HEAD)
41
+
42
+ Required:
43
+ - Repository path (optional: defaults to current directory)
44
+ - Range: `from_tag` + `to_tag`, OR `since_tag`, OR `last_n_commits`
45
+
46
+ ---
47
+
48
+ ## Analysis Process
49
+
50
+ ### Step 1: Collect Commits
51
+ ```bash
52
+ git log v1.0.0..v1.1.0 --oneline --no-merges
53
+ ```
54
+ Gather all commits in the specified range with their messages.
55
+
56
+ ### Step 2: Examine Diffs
57
+ ```bash
58
+ git diff v1.0.0..v1.1.0 -- src/
59
+ ```
60
+ Read actual code changes line-by-line to understand what changed.
61
+
62
+ ### Step 3: Interpret Changes
63
+
64
+ Translate technical changes into user impact:
65
+
66
+ | Code Change | User Impact |
67
+ |-------------|------------|
68
+ | `+ const darkMode = true` in settings | "Dark mode toggle now available in settings" |
69
+ | Deleted login retry logic | "Removed automatic retry on login timeout" |
70
+ | `+ validateEmail()` function | "Email validation improved during signup" |
71
+ | Updated database schema version | "Database schema upgraded (run migration)" |
72
+ | Added 10+ calls to cache layer | "Improved performance on large operations" |
73
+ | Removed old CSV export code | "CSV export removed; use Excel or PDF instead" |
74
+
75
+ **Key: Focus on the user's experience, not the code implementation.**
76
+
77
+ ### Step 4: Identify Breaking Changes
78
+
79
+ Breaking changes come from:
80
+ - **Commit messages** containing: "BREAKING", "Breaking", "!:"
81
+ - **Diffs showing**: removed public APIs, changed file formats, data migrations
82
+ - **Config changes**: renamed settings, changed defaults
83
+
84
+ ### Step 5: Consolidate
85
+ - If a feature was added then removed → don't mention it
86
+ - If something changed multiple times → only note the final state
87
+ - If multiple commits fix the same issue → merge into one bullet
88
+
89
+ ### Step 6: Categorize & Format
90
+
91
+ Organize changes into buckets:
92
+
93
+ ```markdown
94
+ # Release Notes - v1.1.0
95
+
96
+ ## New Features
97
+ - Added dark mode toggle in settings
98
+ - New PDF export option
99
+
100
+ ## Enhancements
101
+ - Improved search performance (now supports partial matches)
102
+ - Faster file opening for large documents
103
+
104
+ ## Bug Fixes
105
+ - Fixed login failures on slow connections
106
+ - Resolved crash when uploading 10MB+ files
107
+
108
+ ## Breaking Changes
109
+ - Database schema updated — run migration before upgrading
110
+ - CSV export removed; use Excel or PDF instead
111
+
112
+ ---
113
+ **Notes:**
114
+ - Dark mode requires display driver update on Windows 7
115
+ - Migration tool available at: docs/migrate-db.md
116
+ ```
117
+
118
+ ---
119
+
120
+ ## Workflow for Agent
121
+
122
+ 1. **Parse input** — extract `from_tag`, `to_tag`, `repo_path`, and optional filters
123
+ 2. **Fetch commits** — run `git log` with range, collect hashes & messages
124
+ 3. **Read diffs per file** — `git show <hash>` for each commit, examine changed files
125
+ 4. **Interpret impact** — what does each change mean to users?
126
+ 5. **Detect breaking changes** — scan for BREAKING markers, API removals, schema changes
127
+ 6. **Group by category** — assign each change to Features/Enhancements/Bug Fixes/Breaking/Other
128
+ 7. **Consolidate** — merge related items, remove duplicates and flip-flops
129
+ 8. **Format markdown** — generate clean bullet points with proper headings
130
+ 9. **Add footnotes** — include migration notes, setup requirements, important links
131
+
132
+ ---
133
+
134
+ ## Output Format
135
+
136
+ **Ultra-concise markdown** (aim for 100-200 words total):
137
+
138
+ ```markdown
139
+ # Release Notes - v1.1.0
140
+
141
+ ## New Features
142
+ - Dark mode toggle in settings
143
+ - PDF export option
144
+
145
+ ## Enhancements
146
+ - Improved search performance (supports partial matches)
147
+ - Faster file opening for large documents
148
+
149
+ ## Bug Fixes
150
+ - Fixed login failures on slow connections
151
+ - Resolved crash when uploading 10MB+ files
152
+
153
+ ## Breaking Changes
154
+ - Database schema updated — run migration before upgrading
155
+
156
+ **Learn more:**
157
+ - [Dark Mode Guide](https://docs.example.com/settings#dark-mode)
158
+ - [Upgrade Instructions](https://docs.example.com/upgrade#database)
159
+ ```
160
+
161
+ **Key Rules:**
162
+ - One line per bullet point
163
+ - No sub-bullets or elaborate descriptions
164
+ - Total length: <200 words
165
+ - User impact only (not implementation details)
166
+ - Use fragment identifiers (`#section-name`) to point to specific docs sections
167
+ - Multiple links OK if they point to different topics (Skill Analysis, Aggregation, etc.)
168
+ - Link from feature description → to exact readthedocs section where users will find details
169
+
170
+ ---
171
+
172
+ ## How to Use This Skill in a Session
173
+
174
+ **User Query:**
175
+ ```
176
+ Generate release notes from v2.1.0 to v2.2.0 for /path/to/my-app
177
+ ```
178
+
179
+ **Agent Workflow:**
180
+ 1. Navigate to repo: `cd /path/to/my-app`
181
+ 2. Fetch commits: `git log v2.1.0..v2.2.0 --oneline --no-merges`
182
+ 3. For each commit, examine changes: `git show <hash>`
183
+ 4. Interpret: What's the user impact? (not the code details)
184
+ 5. Categorize: Feature? Bug fix? Breaking change?
185
+ 6. Consolidate: Merge similar items
186
+ 7. Format: Clean markdown with categories
187
+ 8. Output: Save to RELEASE_NOTES.md
188
+
189
+ ---
190
+
191
+ ## Best Practices
192
+
193
+ ✅ **Do:**
194
+ - Read actual diffs to understand changes
195
+ - Use end-user language ("improved performance" not "optimized O(n) loop")
196
+ - Include breaking changes prominently
197
+ - Group related changes
198
+ - Add notes about migrations or setup
199
+
200
+ ❌ **Don't:**
201
+ - Copy commit messages verbatim
202
+ - Include function/variable names
203
+ - Mention internal refactors users won't notice
204
+ - Include secrets, passwords, or internal URLs
205
+ - Make up changes not shown in diffs
206
+
207
+ ---
208
+
209
+ ## Common Patterns
210
+
211
+ **Performance improvements:**
212
+ > "Improved search speed when filtering 1000+ records"
213
+
214
+ **New integrations:**
215
+ > "Added support for OAuth login via GitHub"
216
+
217
+ **Data format changes:**
218
+ > "Settings file now uses JSON instead of YAML (auto-converted on first run)"
219
+
220
+ **Removed features:**
221
+ > "Removed IE 11 support to modernize codebase"
222
+
223
+ **API changes:**
224
+ > "Changed user profile endpoint response format (see migration guide)"
225
+
226
+ ---
227
+
228
+ ## Limitations
229
+
230
+ - Requires git repository with proper tags
231
+ - Complex changes may need human interpretation
232
+ - Very large diffs (1000+ files) summarized by file count
233
+ - Works best with semantic versioning (v1.0.0 format)
234
+ - Needs meaningful commit messages for best results
@@ -7,6 +7,7 @@
7
7
  - **[README](README.md)** — User-facing overview and quickstart
8
8
  - **[CONTRIBUTING](CONTRIBUTING.md)** — Developer setup and conventions
9
9
  - **[.github/guidelines/knowledge-base.guidelines.md](.github/guidelines/knowledge-base.guidelines.md)** - How to use, update and maintain the knowledge base
10
+ - **[.github/guidelines/git-commit-message.guideline.md](.github/guidelines/git-commit-message.guideline.md)** — Commit message conventions
10
11
 
11
12
  ## Technology Stack
12
13
 
@@ -2,6 +2,13 @@
2
2
 
3
3
  ### Feat
4
4
 
5
+ - **cli**: add amend-commit command to inject session cost trailers
6
+
7
+ ## v0.4.0 (2026-07-08)
8
+
9
+ ### Feat
10
+
11
+ - skill-aware cost attribution and tool-call tracking
5
12
  - add session filtering/aggregation/summaries/field extraction
6
13
 
7
14
  ## v0.3.0 (2026-07-06)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: copilot-session-usage
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Usage and cost analytics for GitHub Copilot and Copilot-CLI session logs
5
5
  Project-URL: Homepage, https://github.com/gsemet/copilot-session-usage
6
6
  Project-URL: Documentation, https://copilot-session-usage.readthedocs.io/en/stable/
@@ -11,6 +11,7 @@ License-Expression: MIT
11
11
  License-File: LICENSE
12
12
  Requires-Python: >=3.10
13
13
  Requires-Dist: click>=8.0
14
+ Requires-Dist: gitpython>=3.1.0
14
15
  Requires-Dist: ruamel-yaml>=0.18.0
15
16
  Description-Content-Type: text/markdown
16
17
 
@@ -0,0 +1,133 @@
1
+ # Add a Session Cost Trailer to a Commit
2
+
3
+ Use `amend-commit` to append per-model token usage to the current Git commit
4
+ as machine-readable trailers. This is useful for attributing cost to a change
5
+ after a Copilot coding session, without editing the commit message by hand.
6
+
7
+ ## What the trailer looks like
8
+
9
+ One `Copilot-Session-Usage-Acc` trailer is added per model used in the
10
+ session, followed by a single `Copilot-Session-Usage-AIC` total-cost trailer:
11
+
12
+ ```text
13
+ Copilot-Session-Usage-Acc: Moonshot AI:Kimi K2.7 Code,in:24.90,out:0.06,cache:21.88,aic:2.31
14
+ Copilot-Session-Usage-Acc: Anthropic:Claude Haiku 4.5,in:0.03,out:0,cache:0,aic:0.01
15
+ Copilot-Session-Usage-AIC: 23
16
+ ```
17
+
18
+ Beware, the costs are **accumulated** for the entire session, not just the current commit.
19
+ If you commit multiple times during a session, the trailers will reflect the total usage
20
+ up to that point.
21
+
22
+ When a change spans several VS Code Copilot sessions, pass each session ID
23
+ with a separate `--session-id` argument. The costs are merged before the
24
+ trailers are written. Add `--with-session-id` to also burn one
25
+ `Copilot-Session-Usage-Session-ID` trailer per session ID, which is useful
26
+ when you later want to rewrite the commit chain with commit-accurate costs.
27
+
28
+ The vendor and model name come from the bundled pricing data. Vendor names are
29
+ rendered with human-readable casing (`Moonshot AI`, `Anthropic`, `OpenAI`, …),
30
+ and model names keep the casing from `data/models-and-pricing.yml`.
31
+
32
+ Token counts are expressed in millions of tokens with two decimals. The
33
+ `aic` value and the `Copilot-Session-Usage-AIC` line show the cost in AI
34
+ credits (USD) with two decimals. If the commit already contains
35
+ `Copilot-Session-Usage-Acc` or `Copilot-Session-Usage-AIC` trailers, they are
36
+ replaced so the values stay fresh. Other trailers, such as `Signed-off-by`,
37
+ are preserved and kept at the end of the message.
38
+
39
+ ## From VS Code Copilot context
40
+
41
+ When running inside a VS Code Copilot agent session, the session log is exposed
42
+ as the context variable `VSCODE_TARGET_SESSION_LOG`. Its value looks like:
43
+
44
+ ```text
45
+ # Mac:
46
+ /Users/<you>/Library/Application Support/Code/User/workspaceStorage/<hash>/GitHub.copilot-chat/debug-logs/<session-id>
47
+ ```
48
+
49
+ The session ID is the last path component. Extract it and pass it to
50
+ `amend-commit`:
51
+
52
+ ```bash
53
+ SESSION_ID=$(basename "{{VSCODE_TARGET_SESSION_LOG}}")
54
+ copilot-session-usage amend-commit --session-id "$SESSION_ID"
55
+ ```
56
+
57
+ `VSCODE_TARGET_SESSION_LOG` is provided by VS Code Copilot as a **context**
58
+ variable, not as an environment variable. If it is not available, use one of
59
+ the methods below to locate the session ID manually.
60
+
61
+ ## Find the session ID manually
62
+
63
+ List recent sessions and pick the right one:
64
+
65
+ ```bash
66
+ # Show recent sessions with IDs and titles
67
+ copilot-session-usage list --format table
68
+
69
+ # Search by title substring
70
+ copilot-session-usage list --title "refactor auth" --format table
71
+ ```
72
+
73
+ Then pass the UUID to `amend-commit`:
74
+
75
+ ```bash
76
+ copilot-session-usage amend-commit --session-id 3a91c012-1b4e-4c8a-9f72-ab12cd34ef56
77
+ ```
78
+
79
+ ## Multiple sessions per commit
80
+
81
+ If a single change spanned several VS Code Copilot sessions, provide all
82
+ session IDs. The token counts and costs are accumulated and written as one
83
+ trailer block:
84
+
85
+ ```bash
86
+ copilot-session-usage amend-commit \
87
+ --session-id "abc-123" \
88
+ --session-id "def-456" \
89
+ --session-id "ghi-789"
90
+ ```
91
+
92
+ Add `--with-session-id` to also record every contributing session ID:
93
+
94
+ ```bash
95
+ copilot-session-usage amend-commit \
96
+ --session-id "abc-123" \
97
+ --session-id "def-456" \
98
+ --with-session-id
99
+ ```
100
+
101
+ This produces:
102
+
103
+ ```text
104
+ Copilot-Session-Usage-Session-ID: abc-123
105
+ Copilot-Session-Usage-Session-ID: def-456
106
+ Copilot-Session-Usage-Acc: Moonshot AI:Kimi K2.7 Code,in:24.90,out:0.06,cache:21.88,aic:2.31
107
+ Copilot-Session-Usage-AIC: 23
108
+ ```
109
+
110
+ This will allow another process, not done by Copilot-Session-Cost, to later rewrite
111
+ the commit chain with commit-accurate costs.
112
+
113
+ ## Preview before amending
114
+
115
+ Use `--dry-run` to see the trailers that would be injected without modifying
116
+ the commit:
117
+
118
+ ```bash
119
+ copilot-session-usage amend-commit --session-id "$SESSION_ID" --dry-run
120
+ ```
121
+
122
+ ## Work in a different repository
123
+
124
+ By default the current working directory is used to locate the Git repository.
125
+ Override it with `--repo`:
126
+
127
+ ```bash
128
+ copilot-session-usage amend-commit --session-id "$SESSION_ID" --repo /path/to/repo
129
+ ```
130
+
131
+ ## Full command reference
132
+
133
+ See [CLI reference](../reference/cli.md) for all options and exit codes.
@@ -6,6 +6,7 @@ Task-oriented recipes for common workflows.
6
6
  :maxdepth: 1
7
7
 
8
8
  analyze-specific-session
9
+ add-commit-trailer
9
10
  export-json
10
11
  batch-and-spending
11
12
  wsl2
@@ -0,0 +1,11 @@
1
+ # CLI Reference
2
+
3
+ This page is auto-generated from the Click command definitions. For a
4
+ step-by-step guide on using `amend-commit` to inject session cost trailers
5
+ into Git commits, see [How to add a session cost trailer](../how-to/add-commit-trailer.md).
6
+
7
+ ```{eval-rst}
8
+ .. click:: copilot_session_usage.cli:cli
9
+ :prog: copilot-session-usage
10
+ :nested: full
11
+ ```
@@ -129,3 +129,6 @@ clean:
129
129
  run-cli:
130
130
  uv run -- copilot-session-usage batch 6 --format table
131
131
  uv run -- copilot-session-usage batch 6 --format detailed
132
+
133
+ run-amend-commit SESSION_ID:
134
+ uv run copilot-session-usage amend-commit --session-id {{SESSION_ID}}
@@ -9,6 +9,7 @@ license = "MIT"
9
9
  dependencies = [
10
10
  "click>=8.0",
11
11
  "ruamel.yaml>=0.18.0",
12
+ "GitPython>=3.1.0",
12
13
  ]
13
14
 
14
15
  [project.scripts]
@@ -9,6 +9,10 @@ Extract VS Code Copilot session cost KPIs from local debug logs.
9
9
  If you do not have information about which session to use, use `VSCODE_TARGET_SESSION_LOG`
10
10
  to find the current session ID.
11
11
 
12
+ `VSCODE_TARGET_SESSION_LOG` is provided by VS Code Copilot as a **context/template variable**,
13
+ not as an environment variable. Extract the session UUID from the last path component and
14
+ pass it to the CLI with `--session-id`.
15
+
12
16
  Beware of `latest` session ID when several sessions are running in parallel.
13
17
 
14
18
  ## When to use
@@ -101,6 +105,13 @@ copilot-session-usage batch 10
101
105
 
102
106
  # Full detail JSON output
103
107
  copilot-session-usage latest --detail full --format json
108
+
109
+ # Amend the current HEAD commit with accumulated session cost trailers.
110
+ # Extract <session-id> from VSCODE_TARGET_SESSION_LOG in the Copilot context.
111
+ copilot-session-usage amend-commit --session-id <session-id>
112
+
113
+ # Preview trailers without amending
114
+ copilot-session-usage amend-commit --session-id <session-id> --dry-run
104
115
  ```
105
116
 
106
117
  ## Skill-Aware Analysis
@@ -175,6 +186,50 @@ copilot-session-usage analyze --title "feature" --aggregate --skill-breakdown --
175
186
  - **Single-skill filtering** — focus analysis on one skill with `--skill SKILL`
176
187
  - **Skill aggregation** — list all skills and their costs across sessions with `skills` command
177
188
  - **Field extraction** with dot notation (`--query`)
189
+ - **Commit amendment** with accumulated per-model cost trailers (`amend-commit`)
190
+
191
+ ## Injecting cost trailers into commits
192
+
193
+ Use `amend-commit` to update the HEAD commit with accumulated session usage
194
+ as Git commit-message trailers. One line is emitted per model, plus a total
195
+ AIC (AI credits) summary line:
196
+
197
+ ```
198
+ Copilot-Session-Usage-Acc: Moonshot AI:Kimi K2.7 Code,in:24.90,out:0.06,cache:21.88,aic:2.31
199
+ Copilot-Session-Usage-AIC: 23
200
+ ```
201
+
202
+ The vendor and model name come from the actual session context (debug-log
203
+ `llm_request` events and bundled pricing data). Vendor names are rendered with
204
+ human-readable casing (for example, `Moonshot AI` instead of `moonshot_ai`), and
205
+ model names keep the casing from the pricing data (for example, `Kimi K2.7 Code`
206
+ instead of the lower-cased log identifier `kimi-k2.7-code`). Token counts are in
207
+ millions of tokens with two decimals; AIC values are rounded to two decimals.
208
+
209
+ When a change spans several VS Code Copilot sessions, pass each session ID
210
+ with a separate `--session-id` argument. The costs are accumulated and written
211
+ as one trailer block. Add `--with-session-id` to also burn one
212
+ `Copilot-Session-Usage-Session-ID` trailer per session ID, which makes it
213
+ possible to rewrite the commit chain with commit-accurate costs later.
214
+
215
+ ### Finding the current session ID
216
+
217
+ `VSCODE_TARGET_SESSION_LOG` is provided in the Copilot agent context as a
218
+ template variable, **not** an environment variable. Extract the session UUID
219
+ from the last path component:
220
+
221
+ ```bash
222
+ # VSCODE_TARGET_SESSION_LOG looks like:
223
+ # /.../workspaceStorage/<hash>/GitHub.copilot-chat/debug-logs/<session-id>
224
+ SESSION_ID=$(basename "{{VSCODE_TARGET_SESSION_LOG}}")
225
+ copilot-session-usage amend-commit --session-id "$SESSION_ID"
226
+ ```
227
+
228
+ If the context does not expose the variable, fall back to `copilot-session-usage latest`
229
+ or `copilot-session-usage list` to identify the session manually.
230
+
231
+ `amend-commit` preserves any existing `Signed-off-by` trailer by placing the
232
+ new cost trailers immediately before it, not after it.
178
233
 
179
234
  ## Pricing Data
180
235