New session? Run:
bd prime·bd ready
| Command | Purpose |
|---|---|
bd ready |
Available tasks |
bd update <id> --status in_progress |
Start task |
bd close <id> |
Complete task |
/commit |
Create commit |
- Runtime: Chrome Extension (Manifest V3)
- Language: TypeScript (ES2022, strict mode)
- Build: Vite + @crxjs/vite-plugin
- Testing: Vitest + jsdom
- Storage: chrome.storage.local
npm install # Install dependencies
npm run dev # Development mode
npm run build # Production build
npm test # Run tests with watch
npm run test:ci # CI tests with coverage
npm run tdd # TDD modeFor Maintainers:
-
Update version in
manifest.json:"version": "1.2.0"
-
Commit the version bump:
git commit -m "chore: bump version to 1.2.0" -
Create tag (must match manifest version):
git tag v1.2.0
-
Push commits and tags:
git push && git push --tags -
CI automatically:
- Validates tag matches manifest version
- Runs tests and builds extension
- Creates GitHub release with ZIP artifact
- Publishes to Chrome Web Store
- Version mismatch error: Ensure git tag (e.g.,
v1.2.0) matchesmanifest.jsonversion (1.2.0) - CWS publish fails: Check GitHub Actions logs for API errors
- Service Account not authorized: Verify Service Account email is added to Chrome Web Store Developer Dashboard (Account → Service Accounts)
- Manual fallback: If CWS automation fails, GitHub release ZIP is available for manual upload at Chrome Developer Dashboard
Before automated CWS publishing works, you need:
- Extension ID from Chrome Web Store (requires initial manual submission)
- Google Cloud Service Account with JSON key
- Service Account added to Chrome Web Store Developer Dashboard
- GitHub Secrets configured:
CWS_SERVICE_ACCOUNT_JSON,CWS_EXTENSION_ID
3-layer pattern for CSP compliance:
MAIN World (injector.ts) → Patches fetch/XHR, extracts Pinterest API data
↓ postMessage
ISOLATED World (content.ts) → DOM manipulation, caching, overlays
↓ chrome.runtime.sendMessage
Background (background.ts) → Download handler
| File | Purpose |
|---|---|
src/injector.ts |
Fetch/XHR interception, API data extraction |
src/content.ts |
Pin detection, overlay rendering, cache management |
src/background.ts |
Download handler via Chrome Downloads API |
src/utils/statsCache.ts |
3-layer cache (memory + storage + DOM) |
src/types/pinterest.ts |
Pinterest API type definitions |
src/types/messages.ts |
Inter-script message protocols |
injector.tspatchesfetch()andXMLHttpRequest- Intercepts Pinterest API responses matching patterns
- Extracts engagement data (saves, comments, shares, reactions)
- Sends to
content.tsviapostMessage content.tscreates glassmorphism overlays on pins- Download requests go to
background.tsviachrome.runtime
All critical and high-priority issues from initial code review have been resolved:
- ✅ Debug
cache.clearAll()removed - ✅
fetchedPinsSet memory leak fixed - ✅ Page unload cleanup handlers added
- ✅ LRU cache with 5,000 entry limit + 24h TTL
- ✅ postMessage origin validation (window.origin, not
'*') - ✅ Download URL allowlist (Pinterest CDN only)
- ✅ Unused modules removed (domObserver, rateLimiter)
- ✅ Batch size unified (5→20)
- ✅ MutationObserver debounce improved (100ms→500ms)
- ✅ Duplicate constants extracted
- ✅ Comprehensive error handling in init()
- ✅ Layout thrashing eliminated (batch DOM reads)
- ✅ Test fixtures using correct PinData type
Status: Production-ready! All 12 beads tasks closed, 24/24 tests passing.
- Use
PinDatatype (not legacyPinStats) - Validate URLs before download (Pinterest CDN only)
- Add cleanup handlers for timers/observers
- Keep batch size consistent between content/injector
- Update README.md for user-facing changes
- Update CLAUDE.md for workflow changes