copilot-log-analysis
БесплатноБез исполняемых скриптовНе проверенAnalyzing GitHub Copilot session log files to extract token usage, model information, and interaction data. Use when working with session files, understanding…
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
Copilot Log Analysis Skill
This skill documents the methods and approaches used by the GitHub Copilot Token Tracker extension to analyze Copilot session log files. These files contain chat sessions, token usage, and model information.
Overview
The extension analyzes two types of log files:
.jsonfiles: Standard VS Code Copilot Chat session files.jsonlfiles: Copilot CLI/Agent mode sessions (one JSON event per line)
Session File Discovery
Key Method: getCopilotSessionFiles()
Location: src/extension.ts (lines 975-1073)
Helper Methods: getVSCodeUserPaths() (lines 934-972), scanDirectoryForSessionFiles() (lines 1078-1110)
This method discovers session files across all VS Code variants and locations:
Supported VS Code Variants:
- VS Code (Stable)
- VS Code Insiders
- VS Code Exploration
- VSCodium
- Cursor
- VS Code Server/Remote
File Locations Checked:
- Workspace Storage:
{VSCode User Path}/workspaceStorage/{workspace-id}/chatSessions/*.json - Global Storage (Legacy):
{VSCode User Path}/globalStorage/emptyWindowChatSessions/*.json - Copilot Chat Extension Storage:
{VSCode User Path}/globalStorage/github.copilot-chat/**/*.json - Copilot CLI Sessions:
~/.copilot/session-state/*.jsonl
Platform-Specific Paths:
- Windows:
%APPDATA%/{Variant}/User - macOS:
~/Library/Application Support/{Variant}/User - Linux:
~/.config/{Variant}/User(respectsXDG_CONFIG_HOME) - Remote/Server:
~/.vscode-server/data/User,~/.vscode-server-insiders/data/User
Helper Method: getVSCodeUserPaths()
Location: src/extension.ts (lines 934-972)
Returns all possible VS Code user data paths for different variants and platforms.
Helper Method: scanDirectoryForSessionFiles()
Location: src/extension.ts (lines 1078-1110)
Recursively scans directories for .json and .jsonl session files.
Field Extraction Methods
Parsing and Token Accounting: parseSessionFileContent()
Location: src/sessionParser.ts (lines 184-347)
Purpose: Parses session files and returns tokens, interactions, model usage, and editor type-safe model IDs.
How it works:
- Accepts raw file content along with callbacks for token estimation and model detection.
- Supports both
.json(Copilot Chat) and.jsonl(CLI/agent) formats, including delta-based JSONL streams. - Counts interactions (user messages), input tokens, and output tokens while grouping by model.
- Uses
estimateTokensFromText()(lines 1139-1155 insrc/extension.ts) for character-to-token estimation.
Model Detection Logic: getModelFromRequest()
Location: src/extension.ts (lines 1102-1134)
- Primary:
request.result.metadata.modelId - Fallback: parses
request.result.detailsfor known model patterns - Detected patterns: GPT-3.5-Turbo, GPT-4 family (4, 4.1, 4o, 4o-mini, 5, o3-mini, o4-mini), Claude Sonnet (3.5, 3.7, 4), Gemini (2.5 Pro, 3 Pro, 3 Pro Preview); defaults to
gpt-4 - Display name mapping in
getModelDisplayName()(lines 1778-1811) adds variants such as GPT-5 family, Claude Haiku, Claude Opus, Gemini 3 Flash, Grok, and Raptor when present inmetadata.modelId.
Editor Type Detection: getEditorTypeFromPath()
Location: src/extension.ts (lines 111-143)
Purpose: Determines which VS Code variant created the session file.
Detection patterns:
- Contains
/.copilot/session-state/→'Copilot CLI' - Contains
/code - insiders/→'VS Code Insiders' - Contains
/code - exploration/→'VS Code Exploration' - Contains
/vscodium/→'VSCodium' - Contains
/cursor/→'Cursor' - Contains
.vscode-server-insiders/→'VS Code Server (Insiders)' - Contains
.vscode-server/→'VS Code Server' - Contains
/code/→'VS Code' - Default →
'Unknown'
Token Estimation Algorithm
Character-to-Token Conversion: estimateTokensFromText()
Location: src/extension.ts (lines 1139-1155)
Approach: Uses model-specific character-to-token ratios
- Default ratio: 0.25 (4 characters per token)
- Model-specific ratios loaded from
src/tokenEstimators.json - Formula:
Math.ceil(text.length * tokensPerChar)
Model matching:
- Checks if model name includes the key from tokenEstimators
- Example:
gpt-4omatches keygpt-4o
Caching Strategy
Cache Structure: SessionFileCache
Location: src/extension.ts (lines 72-77)
Stores pre-calculated tokens, interactions, model usage, and file mtime to avoid re-processing unchanged files.
Cache Methods:
isCacheValid()(lines 227-230): Validates cached entry by mtimegetCachedSessionData()(lines 232-234): Retrieves cached datasetCachedSessionData()(lines 236-254): Stores data with FIFO eviction after 1000 filesclearExpiredCache()(lines 250-264): Drops cache entries for missing filesgetSessionFileDataCached()(lines 811-845): Reads session content, parses viaparseSessionFileContent(), and caches re
Установить copilot-log-analysis в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл copilot-log-analysis?
Analyzing GitHub Copilot session log files to extract token usage, model information, and interaction data. Use when working with session files, understanding the extension's log analysis methods, or debugging token tracking issues.
Как установить скилл copilot-log-analysis?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл copilot-log-analysis запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic