CommandCodeAI / CommandCodeAI/command-code
Expose session token usage and spend via an MCP tool or context injection
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 4k
- Forks
- 350
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Feature Description
The current session's token usage and spend in USD are only accessible via the /context and /usage slash commands, which require manual user input. There is no way for the model (agent) to programmatically read these metrics within a session. I propose exposing this data through one of:
- An MCP tool the model can call (e.g. get_session_usage) that returns token count, context window percentage, credits used, and spend in USD.
- Injecting the data into the session context (system prompt or environment variable) so it's always available to the model.
- Persisting token cost alongside each message in session transcripts (~/.commandcode/projects/*.jsonl) so the model can compute it from the history.
This would enable building skills like a "session-insights" agent that answers "how many tokens have we used?" or "what's the spend so far?" on demand.
Use Case
I want to ask "how many tokens have we used in this session?" or "what's the bill so far in USD?" and get an instant answer without having to manually run slash commands and paste output. A skill that surfaces this data would be far more useful if the model can fetch it directly rather than asking the user to type /context and /usage.
Additional Context
The session transcript files (~/.commandcode/projects/users-*/.jsonl) store conversation text and basic metadata (timestamp, source) but no token counts or cost data. The history.jsonl file also lacks this. As a result, the model has zero visibility into usage metrics — it can only ask the user to run slash commands and interpret what they paste back.
How important is this to you?
Important for my workflow
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die vorhandenen /context- und /usage-Slash-Command-Einstiegspunkte nachzuverfolgen, um zu sehen, wo Sitzungs-Token, Kontextfenster-, Credit- und Ausgabenmetriken berechnet werden. Untersuche die Sitzungsprotokolle und history.jsonl unter ~/.commandcode/projects/*.jsonl, um zu bestätigen, welche Metadaten derzeit persistiert werden. Lege einen Implementierungspfad fest und überprüfe, dass das Modell die genaue Nutzung der aktuellen Sitzung und die Ausgaben in USD ohne Copy-and-paste durch den Benutzer abrufen kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Bereich
- cli
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Ruhig
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100