Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  • .json files: Standard VS Code Copilot Chat session files
  • .jsonl files: 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:

  1. Workspace Storage: {VSCode User Path}/workspaceStorage/{workspace-id}/chatSessions/*.json
  2. Global Storage (Legacy): {VSCode User Path}/globalStorage/emptyWindowChatSessions/*.json
  3. Copilot Chat Extension Storage: {VSCode User Path}/globalStorage/github.copilot-chat/**/*.json
  4. Copilot CLI Sessions: ~/.copilot/session-state/*.jsonl

Platform-Specific Paths:

  • Windows: %APPDATA%/{Variant}/User
  • macOS: ~/Library/Application Support/{Variant}/User
  • Linux: ~/.config/{Variant}/User (respects XDG_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:

  1. Accepts raw file content along with callbacks for token estimation and model detection.
  2. Supports both .json (Copilot Chat) and .jsonl (CLI/agent) formats, including delta-based JSONL streams.
  3. Counts interactions (user messages), input tokens, and output tokens while grouping by model.
  4. Uses estimateTokensFromText() (lines 1139-1155 in src/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.details for 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 in metadata.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-4o matches key gpt-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 mtime
  • getCachedSessionData() (lines 232-234): Retrieves cached data
  • setCachedSessionData() (lines 236-254): Stores data with FIFO eviction after 1000 files
  • clearExpiredCache() (lines 250-264): Drops cache entries for missing files
  • getSessionFileDataCached() (lines 811-845): Reads session content, parses via parseSessionFileContent(), and caches re
Полный SKILL.md на GitHub

Установить copilot-log-analysis в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

metadata.json

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), без исполняемых скриптов.

Похожие скиллы

Сравнить copilot-log-analysis с