copilot-session-usage 0.2.3__tar.gz → 0.4.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 (119) hide show
  1. copilot_session_usage-0.4.0/.github/changes/requests/skill-breakdown/01-request.md +163 -0
  2. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/CHANGELOG.md +10 -0
  3. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/PKG-INFO +105 -4
  4. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/README.md +104 -3
  5. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/explanation/how-cost-estimation-works.md +18 -0
  6. copilot_session_usage-0.4.0/docs/source/how-to/analyze-specific-session.md +101 -0
  7. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/how-to/batch-and-spending.md +30 -0
  8. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/tutorials/getting-started.md +54 -0
  9. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/justfile +1 -2
  10. copilot_session_usage-0.4.0/knowledge/_schema/Concept.schema.yaml +41 -0
  11. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/_schema/Experiment.schema.yaml +14 -3
  12. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/_schema/Finding.schema.yaml +16 -4
  13. copilot_session_usage-0.4.0/knowledge/_schema/Hypothesis.schema.yaml +45 -0
  14. copilot_session_usage-0.4.0/knowledge/_schema/Outcome.schema.yaml +40 -0
  15. copilot_session_usage-0.4.0/knowledge/_schema/Playbook.schema.yaml +41 -0
  16. copilot_session_usage-0.4.0/knowledge/_schema/Principle.schema.yaml +37 -0
  17. copilot_session_usage-0.4.0/knowledge/_schema/Reference.schema.yaml +34 -0
  18. copilot_session_usage-0.4.0/knowledge/_schema/Structure.schema.yaml +45 -0
  19. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/concepts/index.md +4 -1
  20. copilot_session_usage-0.4.0/knowledge/experiments/index.md +8 -0
  21. copilot_session_usage-0.2.3/knowledge/findings/subagent-logs-use-runsubagent-prefix.md → copilot_session_usage-0.4.0/knowledge/findings/2026.07.02-00.00-subagent-logs-runsubagent-prefix.md +2 -1
  22. copilot_session_usage-0.2.3/knowledge/findings/title-jsonl-not-counted-as-model-turn.md → copilot_session_usage-0.4.0/knowledge/findings/2026.07.02-22.00-title-generation-not-counted-as-model-turn.md +1 -0
  23. copilot_session_usage-0.2.3/knowledge/findings/cache-write-cost-not-tracked.md → copilot_session_usage-0.4.0/knowledge/findings/2026.07.02-23.00-cache-write-approximation.md +1 -0
  24. copilot_session_usage-0.4.0/knowledge/findings/index.md +10 -0
  25. copilot_session_usage-0.4.0/knowledge/guides/index.md +10 -0
  26. copilot_session_usage-0.4.0/knowledge/ideas/index.md +8 -0
  27. copilot_session_usage-0.4.0/knowledge/index.md +17 -0
  28. copilot_session_usage-0.4.0/knowledge/log.md +3 -0
  29. copilot_session_usage-0.4.0/knowledge/principles/index.md +8 -0
  30. copilot_session_usage-0.4.0/knowledge/reference/index.md +9 -0
  31. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/structures/cache-cost-approximation.md +4 -3
  32. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/structures/index.md +4 -1
  33. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/structures/subagent-cost-tracking.md +7 -4
  34. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/structures/vscode-copilot-extension.md +3 -2
  35. copilot_session_usage-0.4.0/skills/copilot-session-usage/SKILL.md +272 -0
  36. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/_internal/core.py +913 -11
  37. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/api.py +26 -2
  38. copilot_session_usage-0.4.0/src/copilot_session_usage/cli.py +632 -0
  39. copilot_session_usage-0.4.0/tests/test_cli.py +597 -0
  40. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/tests/test_core.py +495 -0
  41. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/tests/test_rendering.py +119 -0
  42. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/uv.lock +10 -10
  43. copilot_session_usage-0.2.3/docs/source/how-to/analyze-specific-session.md +0 -46
  44. copilot_session_usage-0.2.3/knowledge/_schema/Concept.schema.yaml +0 -20
  45. copilot_session_usage-0.2.3/knowledge/_schema/Playbook.schema.yaml +0 -19
  46. copilot_session_usage-0.2.3/knowledge/_schema/Principle.schema.yaml +0 -25
  47. copilot_session_usage-0.2.3/knowledge/_schema/Reference.schema.yaml +0 -19
  48. copilot_session_usage-0.2.3/knowledge/_schema/Structure.schema.yaml +0 -26
  49. copilot_session_usage-0.2.3/knowledge/experiments/index.md +0 -5
  50. copilot_session_usage-0.2.3/knowledge/findings/index.md +0 -7
  51. copilot_session_usage-0.2.3/knowledge/guides/index.md +0 -7
  52. copilot_session_usage-0.2.3/knowledge/ideas/index.md +0 -5
  53. copilot_session_usage-0.2.3/knowledge/index.md +0 -16
  54. copilot_session_usage-0.2.3/knowledge/log.md +0 -114
  55. copilot_session_usage-0.2.3/knowledge/principles/index.md +0 -5
  56. copilot_session_usage-0.2.3/knowledge/reference/index.md +0 -6
  57. copilot_session_usage-0.2.3/skills/copilot-session-usage/SKILL.md +0 -98
  58. copilot_session_usage-0.2.3/src/copilot_session_usage/cli.py +0 -287
  59. copilot_session_usage-0.2.3/tests/test_cli.py +0 -280
  60. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.editorconfig +0 -0
  61. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  62. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  63. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/guidelines/knowledge-base.guidelines.md +0 -0
  64. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/pull_request_template.md +0 -0
  65. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/skills/consolidate-knowledge-base/SKILL.md +0 -0
  66. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/skills/record-finding/SKILL.md +0 -0
  67. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/workflows/ci.yml +0 -0
  68. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.github/workflows/publish.yml +0 -0
  69. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.gitignore +0 -0
  70. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/.readthedocs.yaml +0 -0
  71. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/AGENTS.md +0 -0
  72. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/CONTRIBUTING.md +0 -0
  73. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/LICENSE +0 -0
  74. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/_static/changelog.js +0 -0
  75. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/_static/custom.css +0 -0
  76. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/changelog.md +0 -0
  77. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/conf.py +0 -0
  78. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/explanation/index.md +0 -0
  79. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/how-to/export-json.md +0 -0
  80. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/how-to/index.md +0 -0
  81. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/how-to/wsl2.md +0 -0
  82. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/index.md +0 -0
  83. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/installation.md +0 -0
  84. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/reference/api.md +0 -0
  85. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/reference/cli.md +0 -0
  86. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/reference/index.md +0 -0
  87. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/reference/pricing.md +0 -0
  88. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/docs/source/tutorials/index.md +0 -0
  89. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/_schema/Base.schema.yaml +0 -0
  90. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/concepts/copilot-cli.md +0 -0
  91. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/concepts/overview.md +0 -0
  92. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/concepts/session-cost-analysis.md +0 -0
  93. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/concepts/threshold-based-pricing.md +0 -0
  94. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/experiments/verify-subagent-cost-attribution.md +0 -0
  95. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/guides/automation-scripts.md +0 -0
  96. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/guides/cost-optimization.md +0 -0
  97. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/guides/wsl2-setup.md +0 -0
  98. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/ideas/multi-session-efficiency-analytics.md +0 -0
  99. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/principles/findings-are-immutable.md +0 -0
  100. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/reference/debug-log-format.md +0 -0
  101. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/reference/pricing-formats.md +0 -0
  102. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/structures/knowledge-base-information-types.md +0 -0
  103. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/knowledge/structures/session-discovery-algorithm.md +0 -0
  104. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/pyproject.toml +0 -0
  105. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/scripts/refresh_pricing.py +0 -0
  106. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/__init__.py +0 -0
  107. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/_internal/__init__.py +0 -0
  108. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/_internal/copilot_cli.py +0 -0
  109. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/_internal/vscode.py +0 -0
  110. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/data/__init__.py +0 -0
  111. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/data/custom-models-pricing.yml +0 -0
  112. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/data/models-and-pricing.lock +0 -0
  113. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/src/copilot_session_usage/data/models-and-pricing.yml +0 -0
  114. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/tests/conftest.py +0 -0
  115. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/tests/test_api.py +0 -0
  116. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/tests/test_coverage_gaps.py +0 -0
  117. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/tests/test_vscode.py +0 -0
  118. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/tests/test_vscode_platform.py +0 -0
  119. {copilot_session_usage-0.2.3 → copilot_session_usage-0.4.0}/uv.toml +0 -0
@@ -0,0 +1,163 @@
1
+ # Skill-aware cost attribution and faster session lookup
2
+
3
+ ## Context
4
+
5
+ `copilot-session-usage` extracts VS Code Copilot session cost KPIs from local debug logs. It already supports per-model pricing, subagent attribution, and multiple output formats.
6
+
7
+ However, when a user invokes a skill (e.g. `/compendium-generic get-session-costs`), the CLI has no first-class way to report:
8
+
9
+ - which skill(s) were active in a session,
10
+ - how much each skill cost,
11
+ - which tool calls each skill triggered,
12
+ - or how to find a session by its title without manually scanning `copilot-session-usage list` output.
13
+
14
+ Investigating a single skill's cost currently requires ad-hoc Python scripts that grep raw JSONL files for slash-command names, skill discovery events, and tool-call records. This is slow, token-heavy, error-prone, and not reproducible.
15
+
16
+ ## Problem
17
+
18
+ 1. **No skill cost attribution.** A session may be dominated by one skill, but the CLI only reports per-model and per-subagent totals.
19
+ 2. **Session lookup by title is manual.** Users must run `list`, visually scan titles, copy the UUID, then run `id <uuid>`.
20
+ 3. **Subagent names are often `unknown`.** The subagent spawned by `runSubagent` is reported as `unknown` even though its name appears in the debug-log filename.
21
+ 4. **No tool-call attribution.** It is impossible to see which tools a skill consumed tokens on.
22
+ 5. **No stable, concise report format.** Full JSON dumps are large; users often only need skill + cost + token counts.
23
+
24
+ ## Goals
25
+
26
+ Make `copilot-session-usage` **faster, safer, cheaper, and more reproducible** for skill-centric cost analysis by:
27
+
28
+ - detecting skills from system prompts, tool definitions, and user messages,
29
+ - attributing LLM calls and tool calls to the active skill,
30
+ - allowing users to filter sessions by title and skill,
31
+ - fixing subagent name extraction,
32
+ - providing a concise, stable output mode.
33
+
34
+ ## Proposed features
35
+
36
+ ### 1. Skill cost breakdown
37
+
38
+ Add a `--skill-breakdown` flag to `id` and `analyze` that emits a per-skill table:
39
+
40
+ ```markdown
41
+ | Skill | Input Tokens | Output Tokens | Cached Tokens | LLM Calls | Cost |
42
+ |-------|--------------|---------------|---------------|-----------|------|
43
+ | /compendium-generic get-session-costs | 1,137,864 | 15,729 | 1,015,825 | 24 | $0.3636 |
44
+ ```
45
+
46
+ Implementation notes:
47
+
48
+ - Parse `system_prompt_0.json` for loaded skill lists.
49
+ - Parse `tools_0.json` for the `skill` tool definition and any skill-related slash commands.
50
+ - Parse `user_message` events for slash-command invocations (`/<skill-name> ...`).
51
+ - Parse `discovery` events of type `Skill Discovery` as a fallback.
52
+ - Attribute each turn to the most recently invoked skill.
53
+
54
+ ### 2. Filter sessions by title
55
+
56
+ Add `--title <substring>` to `list` and `analyze`:
57
+
58
+ ```bash
59
+ copilot-session-usage list --title "get-session-costs"
60
+ copilot-session-usage analyze --title "grill-me" --latest
61
+ ```
62
+
63
+ This avoids analyzing irrelevant sessions and reduces token consumption.
64
+
65
+ ### 3. Filter analysis by skill
66
+
67
+ Add `--skill <name>` to `id` and `analyze`:
68
+
69
+ ```bash
70
+ copilot-session-usage id <uuid> --skill "/compendium-generic get-session-costs"
71
+ ```
72
+
73
+ When combined with `--format json --minimal`, this returns only the numbers the user asked for.
74
+
75
+ ### 4. Tool-call attribution per skill
76
+
77
+ Add `--tool-breakdown` to `id` and `analyze`:
78
+
79
+ ```markdown
80
+ | Tool | Calls | Skill | Subagent |
81
+ |------|-------|-------|----------|
82
+ | read_file | 25 | /compendium-generic get-session-costs | main, Explore |
83
+ | vscode_askQuestions | 3 | /compendium-generic get-session-costs | main |
84
+ | runSubagent | 1 | /compendium-generic get-session-costs | main |
85
+ ```
86
+
87
+ ### 5. Fix subagent name extraction
88
+
89
+ The subagent log file is named `runSubagent-Explore-functions.runSubagent:4.jsonl`. The CLI should extract `Explore` from the filename instead of reporting `unknown`.
90
+
91
+ Also handle `child_session_ref` events in `main.jsonl` as an additional source of subagent metadata.
92
+
93
+ ### 6. Concise / minimal output mode
94
+
95
+ Add `--minimal` (or extend `--detail minimal`) to return only essential fields:
96
+
97
+ ```bash
98
+ copilot-session-usage id <uuid> --skill "/compendium-generic get-session-costs" --format json --minimal
99
+ ```
100
+
101
+ ```json
102
+ {
103
+ "skill": "/compendium-generic get-session-costs",
104
+ "cost_usd": 0.3636,
105
+ "input_tokens": 1137864,
106
+ "output_tokens": 15729,
107
+ "llm_calls": 24
108
+ }
109
+ ```
110
+
111
+ ### 7. Skill discovery across sessions
112
+
113
+ Add a `skills` command to list skills used over a time window:
114
+
115
+ ```bash
116
+ copilot-session-usage skills --last 7d
117
+ ```
118
+
119
+ Output:
120
+
121
+ ```markdown
122
+ | Skill | Sessions | LLM Calls | Cost |
123
+ |-------|----------|-----------|------|
124
+ | /compendium-generic get-session-costs | 3 | 42 | $0.89 |
125
+ ```
126
+
127
+ ### 8. Metadata cache for faster repeated queries
128
+
129
+ Cache session metadata (title, created_at, has_debug_logs, debug_log_dir) in a small local index keyed by workspace hash. Invalidate when `state.vscdb` mtime changes. This makes `list --title` and `batch` operations near-instant.
130
+
131
+ ## Acceptance criteria
132
+
133
+ - [ ] `copilot-session-usage id <uuid> --skill-breakdown` prints a per-skill cost table.
134
+ - [ ] `copilot-session-usage list --title <substring>` returns only matching sessions.
135
+ - [ ] `copilot-session-usage analyze --title <substring> --latest` analyzes the most recent matching session.
136
+ - [ ] `copilot-session-usage id <uuid> --skill "<name>"` filters the report to that skill.
137
+ - [ ] Subagents spawned by `runSubagent` show their real name, not `unknown`.
138
+ - [ ] `copilot-session-usage id <uuid> --tool-breakdown` prints per-skill/per-subagent tool-call counts.
139
+ - [ ] `copilot-session-usage id <uuid> --format json --minimal` returns a small, stable JSON object.
140
+ - [ ] `copilot-session-usage skills --last 7d` lists skills with aggregated cost.
141
+ - [ ] All new features are covered by unit tests.
142
+ - [ ] `just preflight` passes.
143
+
144
+ ## Non-goals
145
+
146
+ - Do not modify pricing data or model detection logic.
147
+ - Do not add support for non-VS-Code providers (CLI provider remains planned).
148
+ - Do not persist raw debug logs or user message content in the metadata cache.
149
+
150
+ ## Suggested first slice
151
+
152
+ 1. Add `--title` filter to `list` and `analyze`.
153
+ 2. Add `--skill-breakdown` to `id` / `analyze`.
154
+ 3. Fix subagent name extraction (`unknown` → real name).
155
+
156
+ These three changes alone remove the most common manual steps and make skill-cost investigations reproducible from a single CLI command.
157
+
158
+ ## Reference session
159
+
160
+ - Session ID: `44f6a978-243c-4115-aa90-d11c2ccf56e0`
161
+ - Title: `/compendium-generic grill-me here are proposal of improvement in copilot-session-usage, to make its use even way more token efficient:`
162
+ - Skill invoked: `/compendium-generic get-session-costs`
163
+ - Total cost: $0.3636 | 1,137,864 input + 15,729 output tokens | 24 LLM calls
@@ -2,6 +2,16 @@
2
2
 
3
3
  ### Feat
4
4
 
5
+ - add session filtering/aggregation/summaries/field extraction
6
+
7
+ ## v0.3.0 (2026-07-06)
8
+
9
+ ## v0.2.3 (2026-07-03)
10
+
11
+ ## v0.2.2 (2026-07-03)
12
+
13
+ ### Feat
14
+
5
15
  - accurate AIC cost computation using nanoAiu and cache_write
6
16
 
7
17
  ## v0.2.1 (2026-07-02)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: copilot-session-usage
3
- Version: 0.2.3
3
+ Version: 0.4.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/
@@ -49,6 +49,12 @@ copilot-session-usage list
49
49
 
50
50
  # Batch analyze the last 10 sessions
51
51
  copilot-session-usage batch 10
52
+
53
+ # Aggregate cost across all sessions matching a PRD path
54
+ copilot-session-usage analyze --name "PRD: /path/to/prd" --aggregate --format table
55
+
56
+ # List sessions in a debug-logs folder with cost columns
57
+ copilot-session-usage list --dir /path/to/debug-logs --format table
52
58
  ```
53
59
 
54
60
  ## Features
@@ -58,8 +64,17 @@ copilot-session-usage batch 10
58
64
  - **Threshold-aware pricing** — long-context tier switching (e.g. GPT-5.4 > 272k tokens)
59
65
  - **Subagent cost attribution** — tracks `runSubagent` calls and their token usage
60
66
  - **Cross-platform** — macOS, Linux, Windows, WSL2
67
+ - **Three output formats** — `json` (default), `table`, `detailed`
61
68
  - **Three detail levels** — `minimal`, `compact`, `full`
62
69
  - **JSON and table output** — machine-readable or human-friendly
70
+ - **Session filtering** — regex match by name, date-range filtering
71
+ - **Aggregation** — roll up costs across many sessions in one command
72
+ - **Skill-aware cost attribution** — detect skills, attribute LLM and tool calls to the active skill
73
+ - **Skill cost breakdown** — per-skill token counts and estimated cost
74
+ - **Tool-call attribution** — per-skill/per-subagent tool-call counts
75
+ - **Title filtering** — find sessions by title substring
76
+ - **Efficiency summaries** — cache ratio, model split, cost per 1M tokens
77
+ - **Field extraction** — pull specific values with `--query`
63
78
 
64
79
  ## How it works
65
80
 
@@ -91,12 +106,30 @@ just knowledge-validate
91
106
 
92
107
  | Command | Description |
93
108
  |---------|-------------|
94
- | `analyze PATH` | Analyze one session by its debug-log directory |
109
+ | `analyze [PATH]` | Analyze one session by PATH, or many by `--name` regex |
95
110
  | `latest` | Analyze the most recently modified session |
96
111
  | `find TITLE` | Find and analyze a session by title (fuzzy match) |
97
112
  | `id SESSION_ID` | Analyze a session by exact UUID |
98
- | `list` | List recent sessions (metadata only, no cost) |
113
+ | `list` | List recent sessions (metadata only by default) |
99
114
  | `batch N` | Analyze the N most recent sessions in one pass |
115
+ | `skills` | List skills used across sessions with aggregated cost |
116
+
117
+ ### Analysis options
118
+
119
+ | Option | Description |
120
+ |--------|-------------|
121
+ | `--name REGEX` | Filter sessions by title/ID regex (case-insensitive) |
122
+ | `--title SUBSTRING` | Filter sessions by title substring (case-insensitive) |
123
+ | `--since DATE` | Only sessions created after DATE (ISO 8601 with timezone) |
124
+ | `--until DATE` | Only sessions created before DATE (ISO 8601 with timezone) |
125
+ | `--workspace PATH` | Only sessions from this workspace folder |
126
+ | `--aggregate` | Aggregate all matching sessions into one summary |
127
+ | `--summary` | Output a cost-efficiency summary |
128
+ | `--skill-breakdown` | Emit a per-skill cost breakdown |
129
+ | `--tool-breakdown` | Emit a per-skill/per-subagent tool-call count breakdown |
130
+ | `--skill NAME` | Filter the report to a single skill |
131
+ | `--query PATH` | Extract a single field with dot notation |
132
+ | `--query-help` | Print all `--query` field paths |
100
133
 
101
134
  ### Global options
102
135
 
@@ -142,10 +175,62 @@ Output: 22,166 tokens
142
175
  Cached: 1,224,340 (86%)
143
176
  LLM calls: 28
144
177
  Est. cost: $1.0880
178
+ # Per-skill cost breakdown
179
+ $ copilot-session-usage id 19e03be0-9cfa-4f21-a19a-4bdb754b3965 --skill-breakdown --format table
180
+ Per-Skill Breakdown:
181
+ Skill Input Cached Output Calls Cost
182
+ ----------------------------------------------------------------------------
183
+ /compendium-generic get-session-costs 1,137,864 1,015,825 15,729 24 $0.3636
184
+
185
+ # Per-skill/per-subagent tool-call counts
186
+ $ copilot-session-usage id 19e03be0-9cfa-4f21-a19a-4bdb754b3965 --tool-breakdown --format table
187
+ Tool Breakdown:
188
+ Tool Calls Skill Subagent
189
+ ---------------------------------------------------------------------------
190
+ read_file 25 /compendium-generic get-session-costs main
191
+ vscode_askQuestions 3 /compendium-generic get-session-costs main
192
+ runSubagent 1 /compendium-generic get-session-costs main
193
+
194
+ # Concise skill cost (great for scripts)
195
+ $ copilot-session-usage id 19e03be0-9cfa-4f21-a19a-4bdb754b3965 \
196
+ --skill "/compendium-generic get-session-costs" \
197
+ --format json --detail minimal
198
+ {
199
+ "skill": "/compendium-generic get-session-costs",
200
+ "cost_usd": 0.3636,
201
+ "input_tokens": 1137864,
202
+ "output_tokens": 15729,
203
+ "cached_tokens": 1015825,
204
+ "llm_calls": 24
205
+ }
206
+
207
+ # List skills used across the last 7 days
208
+ $ copilot-session-usage skills --last 7d --format table
209
+ Skills across 23 sessions:
210
+ Skill Sessions Input Output Cached Calls Cost
211
+ ---------------------------------------------------------------------------------------------------
212
+ /compendium-generic get-session-costs 3 1137864 15729 1015825 24 $0.3636
145
213
 
214
+ # Filter sessions by title substring
215
+ $ copilot-session-usage list --title "get-session-costs"
216
+ $ copilot-session-usage analyze --title "grill-me" --latest
146
217
  # Batch analyze last 5 sessions since July 1st
147
218
  copilot-session-usage batch 5 --since 2026-07-01
148
219
 
220
+ # Aggregate all PRD-related sessions from the last week
221
+ copilot-session-usage analyze \
222
+ --name "PRD: /path/to/prd" \
223
+ --since 2026-06-30T00:00:00Z \
224
+ --until 2026-07-07T00:00:00Z \
225
+ --aggregate \
226
+ --format table
227
+
228
+ # Cost-efficiency summary for a single session
229
+ copilot-session-usage analyze /path/to/debug-logs --summary --format table
230
+
231
+ # Extract just the total cost from a session
232
+ copilot-session-usage analyze /path/to/debug-logs --query .total.estimated_usd
233
+
149
234
  # WSL2: point to Windows host workspaceStorage
150
235
  copilot-session-usage latest \
151
236
  --workspace-storage /mnt/c/Users/$USER/AppData/Roaming/Code/User/workspaceStorage
@@ -154,7 +239,13 @@ copilot-session-usage latest \
154
239
  ## Python API
155
240
 
156
241
  ```python
157
- from copilot_session_usage.api import analyze_session, analyze_latest, batch_analyze
242
+ from copilot_session_usage.api import (
243
+ analyze_session,
244
+ analyze_latest,
245
+ batch_analyze,
246
+ aggregate_sessions,
247
+ list_sessions,
248
+ )
158
249
 
159
250
  # Analyze a session by path
160
251
  result = analyze_session(Path("/path/to/debug-logs"), detail="full")
@@ -164,6 +255,16 @@ result = analyze_latest(detail="compact")
164
255
 
165
256
  # Batch analyze the last 10 sessions
166
257
  batch = batch_analyze(10, detail="minimal")
258
+
259
+ # Aggregate multiple full analyses into one efficiency summary
260
+ aggregate = aggregate_sessions([result1, result2])
261
+
262
+ # List sessions with regex and date-range filtering
263
+ sessions = list_sessions(
264
+ name_pattern=r"PRD",
265
+ since="2026-07-01T00:00:00Z",
266
+ until="2026-07-07T00:00:00Z",
267
+ )
167
268
  ```
168
269
 
169
270
  ## Development
@@ -33,6 +33,12 @@ copilot-session-usage list
33
33
 
34
34
  # Batch analyze the last 10 sessions
35
35
  copilot-session-usage batch 10
36
+
37
+ # Aggregate cost across all sessions matching a PRD path
38
+ copilot-session-usage analyze --name "PRD: /path/to/prd" --aggregate --format table
39
+
40
+ # List sessions in a debug-logs folder with cost columns
41
+ copilot-session-usage list --dir /path/to/debug-logs --format table
36
42
  ```
37
43
 
38
44
  ## Features
@@ -42,8 +48,17 @@ copilot-session-usage batch 10
42
48
  - **Threshold-aware pricing** — long-context tier switching (e.g. GPT-5.4 > 272k tokens)
43
49
  - **Subagent cost attribution** — tracks `runSubagent` calls and their token usage
44
50
  - **Cross-platform** — macOS, Linux, Windows, WSL2
51
+ - **Three output formats** — `json` (default), `table`, `detailed`
45
52
  - **Three detail levels** — `minimal`, `compact`, `full`
46
53
  - **JSON and table output** — machine-readable or human-friendly
54
+ - **Session filtering** — regex match by name, date-range filtering
55
+ - **Aggregation** — roll up costs across many sessions in one command
56
+ - **Skill-aware cost attribution** — detect skills, attribute LLM and tool calls to the active skill
57
+ - **Skill cost breakdown** — per-skill token counts and estimated cost
58
+ - **Tool-call attribution** — per-skill/per-subagent tool-call counts
59
+ - **Title filtering** — find sessions by title substring
60
+ - **Efficiency summaries** — cache ratio, model split, cost per 1M tokens
61
+ - **Field extraction** — pull specific values with `--query`
47
62
 
48
63
  ## How it works
49
64
 
@@ -75,12 +90,30 @@ just knowledge-validate
75
90
 
76
91
  | Command | Description |
77
92
  |---------|-------------|
78
- | `analyze PATH` | Analyze one session by its debug-log directory |
93
+ | `analyze [PATH]` | Analyze one session by PATH, or many by `--name` regex |
79
94
  | `latest` | Analyze the most recently modified session |
80
95
  | `find TITLE` | Find and analyze a session by title (fuzzy match) |
81
96
  | `id SESSION_ID` | Analyze a session by exact UUID |
82
- | `list` | List recent sessions (metadata only, no cost) |
97
+ | `list` | List recent sessions (metadata only by default) |
83
98
  | `batch N` | Analyze the N most recent sessions in one pass |
99
+ | `skills` | List skills used across sessions with aggregated cost |
100
+
101
+ ### Analysis options
102
+
103
+ | Option | Description |
104
+ |--------|-------------|
105
+ | `--name REGEX` | Filter sessions by title/ID regex (case-insensitive) |
106
+ | `--title SUBSTRING` | Filter sessions by title substring (case-insensitive) |
107
+ | `--since DATE` | Only sessions created after DATE (ISO 8601 with timezone) |
108
+ | `--until DATE` | Only sessions created before DATE (ISO 8601 with timezone) |
109
+ | `--workspace PATH` | Only sessions from this workspace folder |
110
+ | `--aggregate` | Aggregate all matching sessions into one summary |
111
+ | `--summary` | Output a cost-efficiency summary |
112
+ | `--skill-breakdown` | Emit a per-skill cost breakdown |
113
+ | `--tool-breakdown` | Emit a per-skill/per-subagent tool-call count breakdown |
114
+ | `--skill NAME` | Filter the report to a single skill |
115
+ | `--query PATH` | Extract a single field with dot notation |
116
+ | `--query-help` | Print all `--query` field paths |
84
117
 
85
118
  ### Global options
86
119
 
@@ -126,10 +159,62 @@ Output: 22,166 tokens
126
159
  Cached: 1,224,340 (86%)
127
160
  LLM calls: 28
128
161
  Est. cost: $1.0880
162
+ # Per-skill cost breakdown
163
+ $ copilot-session-usage id 19e03be0-9cfa-4f21-a19a-4bdb754b3965 --skill-breakdown --format table
164
+ Per-Skill Breakdown:
165
+ Skill Input Cached Output Calls Cost
166
+ ----------------------------------------------------------------------------
167
+ /compendium-generic get-session-costs 1,137,864 1,015,825 15,729 24 $0.3636
168
+
169
+ # Per-skill/per-subagent tool-call counts
170
+ $ copilot-session-usage id 19e03be0-9cfa-4f21-a19a-4bdb754b3965 --tool-breakdown --format table
171
+ Tool Breakdown:
172
+ Tool Calls Skill Subagent
173
+ ---------------------------------------------------------------------------
174
+ read_file 25 /compendium-generic get-session-costs main
175
+ vscode_askQuestions 3 /compendium-generic get-session-costs main
176
+ runSubagent 1 /compendium-generic get-session-costs main
177
+
178
+ # Concise skill cost (great for scripts)
179
+ $ copilot-session-usage id 19e03be0-9cfa-4f21-a19a-4bdb754b3965 \
180
+ --skill "/compendium-generic get-session-costs" \
181
+ --format json --detail minimal
182
+ {
183
+ "skill": "/compendium-generic get-session-costs",
184
+ "cost_usd": 0.3636,
185
+ "input_tokens": 1137864,
186
+ "output_tokens": 15729,
187
+ "cached_tokens": 1015825,
188
+ "llm_calls": 24
189
+ }
190
+
191
+ # List skills used across the last 7 days
192
+ $ copilot-session-usage skills --last 7d --format table
193
+ Skills across 23 sessions:
194
+ Skill Sessions Input Output Cached Calls Cost
195
+ ---------------------------------------------------------------------------------------------------
196
+ /compendium-generic get-session-costs 3 1137864 15729 1015825 24 $0.3636
129
197
 
198
+ # Filter sessions by title substring
199
+ $ copilot-session-usage list --title "get-session-costs"
200
+ $ copilot-session-usage analyze --title "grill-me" --latest
130
201
  # Batch analyze last 5 sessions since July 1st
131
202
  copilot-session-usage batch 5 --since 2026-07-01
132
203
 
204
+ # Aggregate all PRD-related sessions from the last week
205
+ copilot-session-usage analyze \
206
+ --name "PRD: /path/to/prd" \
207
+ --since 2026-06-30T00:00:00Z \
208
+ --until 2026-07-07T00:00:00Z \
209
+ --aggregate \
210
+ --format table
211
+
212
+ # Cost-efficiency summary for a single session
213
+ copilot-session-usage analyze /path/to/debug-logs --summary --format table
214
+
215
+ # Extract just the total cost from a session
216
+ copilot-session-usage analyze /path/to/debug-logs --query .total.estimated_usd
217
+
133
218
  # WSL2: point to Windows host workspaceStorage
134
219
  copilot-session-usage latest \
135
220
  --workspace-storage /mnt/c/Users/$USER/AppData/Roaming/Code/User/workspaceStorage
@@ -138,7 +223,13 @@ copilot-session-usage latest \
138
223
  ## Python API
139
224
 
140
225
  ```python
141
- from copilot_session_usage.api import analyze_session, analyze_latest, batch_analyze
226
+ from copilot_session_usage.api import (
227
+ analyze_session,
228
+ analyze_latest,
229
+ batch_analyze,
230
+ aggregate_sessions,
231
+ list_sessions,
232
+ )
142
233
 
143
234
  # Analyze a session by path
144
235
  result = analyze_session(Path("/path/to/debug-logs"), detail="full")
@@ -148,6 +239,16 @@ result = analyze_latest(detail="compact")
148
239
 
149
240
  # Batch analyze the last 10 sessions
150
241
  batch = batch_analyze(10, detail="minimal")
242
+
243
+ # Aggregate multiple full analyses into one efficiency summary
244
+ aggregate = aggregate_sessions([result1, result2])
245
+
246
+ # List sessions with regex and date-range filtering
247
+ sessions = list_sessions(
248
+ name_pattern=r"PRD",
249
+ since="2026-07-01T00:00:00Z",
250
+ until="2026-07-07T00:00:00Z",
251
+ )
151
252
  ```
152
253
 
153
254
  ## Development
@@ -103,6 +103,24 @@ VS Code AIC panel at **0.000% error** for Claude models.
103
103
  tracks them separately so `--detail full` can show which fraction of tokens
104
104
  was consumed by subagents vs. the main conversation.
105
105
 
106
+ Subagent names are extracted from the JSONL filename
107
+ (`runSubagent-<Name>-functions.runSubagent:<id>.jsonl`) and from
108
+ `child_session_ref` events in `main.jsonl`.
109
+
110
+ ## Skill attribution
111
+
112
+ Skills are detected from three sources in the debug logs:
113
+
114
+ - `user_message` events containing slash commands such as `/skill-name` or
115
+ `/namespace skill-name`.
116
+ - `discovery` events of type `Skill Discovery` that list loaded skills.
117
+ - `generic` events named `Custom Instructions` that enumerate on-demand skills.
118
+
119
+ Each `llm_request` and `tool_call` is attributed to the most recently invoked
120
+ skill at that timestamp. The result is included in the session report under the
121
+ `skills` key and can be surfaced with `--skill-breakdown`, `--tool-breakdown`,
122
+ or `--skill <name>`.
123
+
106
124
  ---
107
125
 
108
126
  ## Accuracy
@@ -0,0 +1,101 @@
1
+ # Analyze a Specific Session
2
+
3
+ Use this when you know the path to a session's debug-log directory or its UUID,
4
+ and `latest` would pick the wrong session.
5
+
6
+ ## By name regex across all sessions
7
+
8
+ When you want to analyze several related sessions at once, use `analyze --name`
9
+ with a case-insensitive regex. This is more efficient than running `find` or
10
+ `list` and then analyzing each session separately.
11
+
12
+ ```bash
13
+ # Analyze all sessions whose title matches a PRD or feature
14
+ copilot-session-usage analyze --name "feature-x" --format table
15
+
16
+ # Aggregate them into a single summary
17
+ copilot-session-usage analyze --name "feature-x" --aggregate --format table
18
+
19
+ # Cost-efficiency summary for each matching session
20
+ copilot-session-usage analyze --name "feature-x" --summary --format table
21
+ ```
22
+
23
+ Add `--since` and `--until` to narrow the date range, or `--workspace` to
24
+ restrict to one workspace folder.
25
+
26
+ ## By debug-log path
27
+
28
+ Each session is a directory inside VS Code's `workspaceStorage`:
29
+
30
+ ```bash
31
+ copilot-session-usage analyze \
32
+ "/path/to/workspaceStorage/<hash>/GitHub.copilot-chat/debug-logs/<session-uuid>"
33
+ ```
34
+
35
+ The path always ends in a UUID directory. Use `list` to find the right one if
36
+ you're unsure.
37
+
38
+ ## By UUID
39
+
40
+ If you have a session ID from a previous `list` or `find` run:
41
+
42
+ ```bash
43
+ copilot-session-usage id 3a91c012-1b4e-4c8a-9f72-ab12cd34ef56
44
+ ```
45
+
46
+ The tool searches all workspaceStorage roots automatically.
47
+
48
+ ## By title substring
49
+
50
+ ```bash
51
+ copilot-session-usage find "CI pipeline"
52
+ ```
53
+
54
+ Matching is case-insensitive substring search. If multiple sessions match,
55
+ the tool lists them and exits without analyzing — then use `id` to pick one.
56
+
57
+ You can also filter `list` and `analyze` by title substring with `--title`:
58
+
59
+ ```bash
60
+ # List only sessions whose title contains "get-session-costs"
61
+ copilot-session-usage list --title "get-session-costs"
62
+
63
+ # Analyze the most recent matching session
64
+ copilot-session-usage analyze --title "grill-me" --latest --format table
65
+ ```
66
+
67
+ ## Skill-aware analysis
68
+
69
+ When a session invokes a skill (for example `/compendium-generic get-session-costs`),
70
+ you can attribute costs and tool calls to that skill.
71
+
72
+ ```bash
73
+ # Per-skill cost breakdown for a session
74
+ copilot-session-usage id 3a91c012-1b4e-4c8a-9f72-ab12cd34ef56 --skill-breakdown
75
+
76
+ # Per-skill/per-subagent tool-call counts
77
+ copilot-session-usage id 3a91c012-1b4e-4c8a-9f72-ab12cd34ef56 --tool-breakdown
78
+
79
+ # Concise cost for a single skill
80
+ copilot-session-usage id 3a91c012-1b4e-4c8a-9f72-ab12cd34ef56 \
81
+ --skill "/compendium-generic get-session-costs" \
82
+ --format json --detail minimal
83
+ ```
84
+
85
+ ## List skills across sessions
86
+
87
+ ```bash
88
+ # Skills used in the last 7 days, with aggregated cost
89
+ copilot-session-usage skills --last 7d --format table
90
+ ```
91
+
92
+ ## Locating workspaceStorage manually
93
+
94
+ | Platform | Default path |
95
+ |----------|-------------|
96
+ | macOS | `~/Library/Application Support/Code/User/workspaceStorage/` |
97
+ | Linux | `~/.config/Code/User/workspaceStorage/` |
98
+ | Windows | `%APPDATA%\Code\User\workspaceStorage\` |
99
+
100
+ Each subdirectory under `workspaceStorage/` corresponds to one VS Code workspace.
101
+ Inside it, `GitHub.copilot-chat/debug-logs/` contains one directory per session.
@@ -2,6 +2,14 @@
2
2
 
3
3
  Use `batch` with `--since` to aggregate costs for a time window.
4
4
 
5
+ For a specific set of related sessions (for example, all sessions whose title
6
+ matches a PRD or feature), prefer `analyze --name ... --aggregate`. It reads
7
+ only matching sessions and returns a single summary in one command.
8
+
9
+ ```bash
10
+ copilot-session-usage analyze --name "feature-x" --aggregate --format table
11
+ ```
12
+
5
13
  ## Daily cost report
6
14
 
7
15
  ```bash
@@ -53,6 +61,28 @@ copilot-session-usage batch 50 \
53
61
  `--workspace-filter` matches against the workspace folder name (substring,
54
62
  case-insensitive).
55
63
 
64
+ ## Skill spending report
65
+
66
+ Use the `skills` command to see which skills drove the most cost over a time
67
+ window:
68
+
69
+ ```bash
70
+ # Skills used in the last 7 days
71
+ copilot-session-usage skills --last 7d --format table
72
+
73
+ # Skills used since a specific date
74
+ copilot-session-usage skills --since 2026-07-01 --format table
75
+ ```
76
+
77
+ Output:
78
+
79
+ ```
80
+ Skills across 23 sessions:
81
+ Skill Sessions Input Output Cached Calls Cost
82
+ ---------------------------------------------------------------------------------------------------
83
+ /compendium-generic get-session-costs 3 1137864 15729 1015825 24 $0.3636
84
+ ```
85
+
56
86
  ## Automate with cron (macOS/Linux)
57
87
 
58
88
  ```bash