Skip to content

Commit 1ad7141

Browse files
authored
Merge pull request #161 from rajbos/copilot/add-local-cache-agent-skill
Add load-cache-data agent skill for inspecting session file cache
2 parents 874ec1f + 00dd0dd commit 1ad7141

5 files changed

Lines changed: 768 additions & 9 deletions

File tree

.github/skills/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ Agent Skills are directories containing a `SKILL.md` file and optional supportin
3232
- Schema documentation references
3333
- Usage examples and troubleshooting guides
3434

35+
### load-cache-data
36+
37+
**Purpose**: Load and inspect the last 10 rows from the local session file cache to iterate with real data.
38+
39+
**Use this skill when:**
40+
- Inspecting cached session file data
41+
- Debugging cache behavior or validation logic
42+
- Understanding what data is being cached
43+
- Working with real cached data for testing or development
44+
- Iterating on features that rely on cached statistics
45+
46+
**Contents:**
47+
- Cache structure and storage location (VS Code globalState)
48+
- Methods for accessing and managing the cache
49+
- Example scripts demonstrating cache data access
50+
- Cache validation and lifecycle documentation
51+
- Integration with the extension's token tracking
52+
3553
## Using Agent Skills
3654

3755
### In VS Code
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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

Comments
 (0)