CommandCodeAI / CommandCodeAI/command-code
Expose session token usage and spend via an MCP tool or context injection
Nessuno ha ancora preso questa issue.
- Lingua principale
- Nessun dato sulla lingua
- Stelle
- 4k
- Fork
- 350
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando i punti di ingresso degli slash command esistenti /context e /usage per vedere dove vengono calcolati il token di sessione, la finestra di contesto, i crediti e le metriche di spesa. Ispeziona le trascrizioni delle sessioni e history.jsonl in ~/.commandcode/projects/*.jsonl per confermare quali metadati vengono attualmente persistiti. Definisci un percorso di implementazione e verifica che il modello possa recuperare l'utilizzo accurato della sessione corrente e la spesa in USD senza che l'utente debba fare copia-incolla.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Tranquilla
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100