|
| 1 | +# Load Cache Data Skill - Quick Reference |
| 2 | + |
| 3 | +This skill provides tools and documentation for accessing the GitHub Copilot Token Tracker's local session file cache. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# Show last 10 cache entries (default) |
| 9 | +node .github/skills/load-cache-data/load-cache-data.js |
| 10 | + |
| 11 | +# Show last 5 entries |
| 12 | +node .github/skills/load-cache-data/load-cache-data.js --last 5 |
| 13 | + |
| 14 | +# Output as JSON |
| 15 | +node .github/skills/load-cache-data/load-cache-data.js --json |
| 16 | + |
| 17 | +# Show help |
| 18 | +node .github/skills/load-cache-data/load-cache-data.js --help |
| 19 | +``` |
| 20 | + |
| 21 | +## What This Skill Does |
| 22 | + |
| 23 | +1. **Reads actual cache data** - Loads real cache data from export files on disk |
| 24 | +2. **Multiple search locations** - Checks VS Code globalStorage, temp directory, and current directory |
| 25 | +3. **Helps debugging** - Inspect what's being cached and when |
| 26 | +4. **Supports development** - Iterate with real data structures when building features |
| 27 | + |
| 28 | +## Cache File Locations |
| 29 | + |
| 30 | +The script searches for cache export files in these locations (in order): |
| 31 | + |
| 32 | +**Windows:** |
| 33 | +- `%APPDATA%\Code\User\globalStorage\rajbos.copilot-token-tracker\cache.json` |
| 34 | +- `%TEMP%\copilot-token-tracker-cache.json` |
| 35 | +- `.\cache-export.json` |
| 36 | + |
| 37 | +**macOS:** |
| 38 | +- `~/Library/Application Support/Code/User/globalStorage/rajbos.copilot-token-tracker/cache.json` |
| 39 | +- `/tmp/copilot-token-tracker-cache.json` |
| 40 | +- `./cache-export.json` |
| 41 | + |
| 42 | +**Linux:** |
| 43 | +- `~/.config/Code/User/globalStorage/rajbos.copilot-token-tracker/cache.json` |
| 44 | +- `/tmp/copilot-token-tracker-cache.json` |
| 45 | +- `./cache-export.json` |
| 46 | + |
| 47 | +*Note: Also checks other VS Code variants (Insiders, Cursor, VSCodium, Code - Exploration)* |
| 48 | + |
| 49 | +## Important Note |
| 50 | + |
| 51 | +The extension stores its cache in VS Code's internal globalState (SQLite database `state.vscdb`), which is not directly accessible from external scripts. To use this skill with real data: |
| 52 | + |
| 53 | +1. **Export from extension**: Add functionality to export cache to disk |
| 54 | +2. **Export from tests**: Test code can write cache data to one of the expected locations |
| 55 | +3. **Manual export**: Extract cache from globalState and save to disk |
| 56 | + |
| 57 | +To access real cache data, use the extension's API: |
| 58 | + |
| 59 | +```typescript |
| 60 | +// In extension.ts or any file with access to ExtensionContext |
| 61 | +const cacheData = context.globalState.get<Record<string, SessionFileCache>>('sessionFileCache'); |
| 62 | +const entries = Object.entries(cacheData || {}); |
| 63 | + |
| 64 | +// Sort by most recent |
| 65 | +entries.sort((a, b) => (b[1].mtime || 0) - (a[1].mtime || 0)); |
| 66 | + |
| 67 | +// Get last 10 |
| 68 | +const last10 = entries.slice(0, 10); |
| 69 | +``` |
| 70 | + |
| 71 | +## Full Documentation |
| 72 | + |
| 73 | +See [SKILL.md](./SKILL.md) for complete documentation including: |
| 74 | +- Cache structure details |
| 75 | +- Integration with extension code |
| 76 | +- Cache management methods |
| 77 | +- Troubleshooting guide |
| 78 | +- Example use cases |
0 commit comments