diff --git a/_bmad-epics/README.md b/_bmad-epics/README.md new file mode 100644 index 000000000..4f9058840 --- /dev/null +++ b/_bmad-epics/README.md @@ -0,0 +1,225 @@ +# SurfSense 2.0 - Epics & Stories + +**Project:** SurfSense Crypto Co-Pilot +**Created:** 2026-02-01 +**Status:** Planning Complete + +--- + +## Overview + +Tài liệu này tổ chức tất cả epics và user stories cho SurfSense 2.0, được chia thành 4 phases dựa trên PRD. + +--- + +## Epic Summary + +| Epic | Phase | Stories | Status | Priority | Duration | +|------|-------|---------|--------|----------|----------| +| [Epic 1: Extension Core Infrastructure](./epic-1-extension-core-infrastructure.md) | Phase 1 | 6 | ✅ COMPLETED | P0 | 2 weeks | +| [Epic 2: Smart Monitoring & Alerts](./epic-2-smart-monitoring-alerts.md) | Phase 2 | 3 | 📋 PLANNED | P0 | 2 weeks | +| [Epic 3: Trading Intelligence](./epic-3-trading-intelligence.md) | Phase 3 | 3 | 📋 PLANNED | P1 | 2 weeks | +| [Epic 4: Content Creation & Productivity](./epic-4-content-creation-productivity.md) | Phase 4 | 3 | 📋 PLANNED | P2 | 2 weeks | + +**Total:** 4 epics, 15 user stories, 8 weeks + +--- + +## Phase 1: Extension Core Infrastructure ✅ + +**Epic 1** - Foundation cho tất cả features + +### Stories: +1. **Story 1.1:** Side Panel Architecture (FR-EXT-01) +2. **Story 1.2:** AI Chat Interface Integration (FR-EXT-02) +3. **Story 1.3:** Page Context Detection (FR-EXT-03) +4. **Story 1.4:** DexScreener Smart Integration (FR-EXT-04) +5. **Story 1.5:** Quick Capture (FR-EXT-05) +6. **Story 1.6:** Settings Sync với Frontend (FR-EXT-06) + +**Key Deliverables:** +- ✅ Chrome Side Panel working +- ✅ AI chat interface integrated +- ✅ Context detection for DexScreener +- ✅ Token info card +- ✅ Quick capture button +- ✅ Settings sync infrastructure + +--- + +## Phase 2: Smart Monitoring & Alerts 📋 + +**Epic 2** - Risk protection & opportunity alerts + +### Stories: +1. **Story 2.1:** Real-time Price Alerts (FR-EXT-07) +2. **Story 2.2:** Whale Activity Tracker (FR-EXT-08) +3. **Story 2.3:** Rug Pull Early Warning System (FR-EXT-09) + +**Key Deliverables:** +- Watchlist management +- Price/volume/liquidity alerts +- Browser notifications +- Whale transaction monitoring +- Rug pull risk assessment +- Risk score display + +**Business Value:** Risk protection = User trust + +--- + +## Phase 3: Trading Intelligence 📋 + +**Epic 3** - AI-powered trading insights + +### Stories: +1. **Story 3.1:** One-Click Token Analysis (FR-EXT-10) +2. **Story 3.2:** Smart Entry/Exit Suggestions (FR-EXT-11) +3. **Story 3.3:** Portfolio Tracker Integration (FR-EXT-12) + +**Key Deliverables:** +- Comprehensive token analysis +- AI-generated summaries +- Entry/exit suggestions +- Risk/reward calculations +- Wallet connection +- Portfolio tracking +- P&L analytics + +**Business Value:** Better decisions = Better results = Happy users + +--- + +## Phase 4: Content Creation & Productivity 📋 + +**Epic 4** - Tools for creators & power users + +### Stories: +1. **Story 4.1:** Chart Screenshot with Annotations (FR-EXT-13) +2. **Story 4.2:** AI Thread Generator (FR-EXT-14) +3. **Story 4.3:** Quick Actions & Productivity (FR-EXT-15, 16, 17) + +**Key Deliverables:** +- Chart capture & annotation +- Drawing tools +- AI thread generation +- Context menu quick actions +- Smart notifications +- Keyboard shortcuts + +**Business Value:** Content creation = Viral marketing + +--- + +## Implementation Roadmap + +### Week 1-2: Phase 1 ✅ +- [x] Side panel architecture +- [x] Chat interface +- [x] Context detection +- [x] DexScreener integration +- [x] Quick capture +- [x] Settings sync + +### Week 3-4: Phase 2 (Next) +- [ ] Watchlist & alerts +- [ ] Whale tracker +- [ ] Rug pull detection + +### Week 5-6: Phase 3 +- [ ] Token analysis +- [ ] Trading suggestions +- [ ] Portfolio tracker + +### Week 7-8: Phase 4 +- [ ] Chart capture +- [ ] Thread generator +- [ ] Productivity features + +--- + +## Feature Responsibility Matrix + +| Feature | Extension | Frontend | Sync | +|---------|-----------|----------|------| +| Model Selection | 📖 Read-only | ✏️ Full control | API | +| Search Space | 📖 Read-only | ✏️ Full control | API | +| Chat | ✅ Full UI | ✅ Full UI | API | +| Connectors | 📖 Use only | ✏️ Setup | API | +| Documents | 👁️ View | ✏️ Manage | API | +| Watchlist | ✏️ Add/Remove | ✏️ Full | Storage + API | +| Alerts | ✏️ Basic | ✏️ Full | API | +| Settings | 📖 Quick | ✏️ Full | API | + +**Legend:** +- ✅ Full feature +- ✏️ Full control +- 📖 Read-only +- 👁️ View only + +--- + +## Technical Stack + +### Frontend (Extension) +- **Framework:** Plasmo (React + TypeScript) +- **UI:** @assistant-ui/react, shadcn/ui +- **State:** Plasmo Storage, React Context +- **APIs:** Chrome Extension APIs + +### Backend +- **Framework:** FastAPI (Python) +- **AI:** Gemini 1.5 Flash / GPT-4o-mini +- **RAG:** Supabase (pgvector) +- **Cache:** Redis + +### Data Sources +- DexScreener API +- DefiLlama API +- Helius (Solana) +- Alchemy (Ethereum) +- RugCheck API +- Token Sniffer + +--- + +## Success Metrics + +### Phase 1 (✅ COMPLETED) +- [x] Extension installable +- [x] Chat works +- [x] Context detection works +- [x] Token card displays + +### Phase 2 (Target) +- [ ] 100+ tokens in watchlists +- [ ] 1000+ alerts set +- [ ] 0 false positive rug pull warnings + +### Phase 3 (Target) +- [ ] 500+ token analyses +- [ ] 80%+ suggestion accuracy +- [ ] 50+ wallets connected + +### Phase 4 (Target) +- [ ] 100+ charts captured +- [ ] 50+ threads generated +- [ ] 200+ daily shortcut uses + +--- + +## Next Steps + +1. ✅ **Epic 1 Complete** - Phase 1 infrastructure done +2. 🎯 **Start Epic 2** - Begin Phase 2 implementation +3. 📝 **Create Stories** - Break down Epic 2 into individual story files +4. 🚀 **Sprint Planning** - Plan 2-week sprint for Phase 2 + +--- + +## Related Documents + +- [PRD](../_bmad-output/planning-artifacts/prd.md) +- [Extension UX Strategy](../.gemini/antigravity/brain/02a071c7-57fc-4f43-a2e8-516ac511579a/extension-ux-integration-strategy.md) +- [Extension Technical Spec](../.gemini/antigravity/brain/02a071c7-57fc-4f43-a2e8-516ac511579a/extension-sidepanel-technical-spec.md) +- [Feature Brainstorming](../.gemini/antigravity/brain/02a071c7-57fc-4f43-a2e8-516ac511579a/extension-features-brainstorming.md) diff --git a/_bmad-epics/epic-1-extension-core-infrastructure.md b/_bmad-epics/epic-1-extension-core-infrastructure.md new file mode 100644 index 000000000..368aae647 --- /dev/null +++ b/_bmad-epics/epic-1-extension-core-infrastructure.md @@ -0,0 +1,302 @@ +# Epic 1: Extension Core Infrastructure + +**Status:** ✅ COMPLETED +**Phase:** Phase 1 +**Duration:** 2 weeks +**Priority:** P0 (Critical) + +--- + +## Epic Overview + +Xây dựng nền tảng cơ bản cho Chrome Extension với Side Panel architecture, tích hợp AI chat interface từ frontend, và context detection cho các trang crypto. + +**Business Value:** +- Cho phép users chat với AI ngay trong browser +- Tự động detect và extract thông tin token từ DexScreener +- Tái sử dụng tối đa frontend components (giảm development time) +- Foundation cho tất cả features sau này + +--- + +## User Stories + +### Story 1.1: Side Panel Architecture +**[FR-EXT-01]** + +**Là một** crypto trader, +**Tôi muốn** mở AI assistant dưới dạng side panel (không phải popup nhỏ), +**Để** tôi có thể chat với AI trong khi vẫn xem được DexScreener chart. + +**Acceptance Criteria:** +- [ ] Extension icon click → Mở side panel bên phải màn hình +- [ ] Side panel width: 400px (default), resizable 300-600px +- [ ] Side panel không che khuất nội dung chính +- [ ] Side panel persist khi switch tabs +- [ ] Manifest có permission `sidePanel` + +**Technical Notes:** +```typescript +// background/index.ts +chrome.sidePanel + .setPanelBehavior({ openPanelOnActionClick: true }) + .catch((error) => console.error("Failed to set side panel behavior:", error)); +``` + +**Files:** +- `surfsense_browser_extension/sidepanel.tsx` ✅ +- `surfsense_browser_extension/package.json` (add sidePanel permission) ✅ + +--- + +### Story 1.2: AI Chat Interface Integration +**[FR-EXT-02]** + +**Là một** crypto trader, +**Tôi muốn** chat với AI trong extension giống như trên web dashboard, +**Để** tôi có trải nghiệm nhất quán và đầy đủ tính năng. + +**Acceptance Criteria:** +- [ ] Tích hợp `@assistant-ui/react` Thread component +- [ ] Streaming responses hoạt động +- [ ] Thinking steps visualization hiển thị +- [ ] Tool UIs render đúng (images, links, scraping) +- [ ] Attachment handling (upload files/images) +- [ ] Chat history lưu vào Plasmo Storage +- [ ] Chat history sync với backend API + +**Component Reuse:** +```typescript +// From frontend +import { Thread } from "@/components/assistant-ui/thread"; +import { DisplayImageToolUI } from "@/components/tool-ui/display-image"; +import { LinkPreviewToolUI } from "@/components/tool-ui/link-preview"; +import { ScrapeWebpageToolUI } from "@/components/tool-ui/scrape-webpage"; +``` + +**Files:** +- `sidepanel/chat/ChatInterface.tsx` ✅ +- `sidepanel/chat/ChatMessages.tsx` ✅ +- `sidepanel/chat/ChatInput.tsx` ✅ +- `sidepanel/chat/ChatHeader.tsx` ✅ + +--- + +### Story 1.3: Page Context Detection +**[FR-EXT-03]** + +**Là một** crypto trader đang xem DexScreener, +**Tôi muốn** AI tự động hiểu tôi đang xem token nào, +**Để** tôi không cần copy/paste token address mỗi lần. + +**Acceptance Criteria:** +- [ ] Content script detect page type: + - DexScreener → Extract token data + - CoinGecko → Extract coin info + - Twitter/X → Extract crypto discussions + - Generic → Basic page info +- [ ] Token data extracted: + - Token address + - Chain (Solana, Ethereum, Base) + - Price, volume, liquidity + - Pair info +- [ ] Context injected vào chat: "You are viewing $TOKEN on Solana..." +- [ ] Context updates khi user navigate to different token + +**Technical Implementation:** +```typescript +// content.ts +function detectPageType(): PageType { + const hostname = window.location.hostname; + if (hostname.includes('dexscreener.com')) return 'dexscreener'; + if (hostname.includes('coingecko.com')) return 'coingecko'; + if (hostname.includes('twitter.com') || hostname.includes('x.com')) return 'twitter'; + return 'generic'; +} + +function extractDexScreenerData(): TokenData { + // Extract from URL: /solana/address + // Or from page DOM +} +``` + +**Files:** +- `content.ts` ✅ +- `sidepanel/context/PageContextProvider.tsx` ✅ + +--- + +### Story 1.4: DexScreener Smart Integration +**[FR-EXT-04]** + +**Là một** crypto trader trên DexScreener, +**Tôi muốn** thấy token info card ở top của side panel, +**Để** tôi có thể nhanh chóng check safety hoặc xem holders. + +**Acceptance Criteria:** +- [ ] Token Info Card hiển thị khi detect DexScreener page +- [ ] Card shows: + - Token symbol/name + - Current price + - 24h change (%) + - Volume 24h + - Liquidity +- [ ] Quick action buttons: + - "Is this token safe?" → Trigger safety check + - "Show top holders" → Query blockchain + - "Price prediction" → AI analysis +- [ ] Buttons trigger chat with pre-filled context +- [ ] Auto-context: "this token" = token đang xem + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 🪙 BULLA/SOL │ +│ $0.0001 📈 +15% │ +│ Vol: $10K | Liq: $5K │ +│ [Safety Check] [Holders] │ +└─────────────────────────────┘ +``` + +**Files:** +- `sidepanel/dexscreener/TokenInfoCard.tsx` ✅ +- `sidepanel/chat/ChatInterface.tsx` (integrate card) ✅ + +--- + +### Story 1.5: Quick Capture +**[FR-EXT-05]** + +**Là một** crypto trader, +**Tôi muốn** save current page vào search space, +**Để** tôi có thể reference lại sau. + +**Acceptance Criteria:** +- [ ] "📸 Save Current Page" button ở bottom của side panel +- [ ] Button sticky (luôn visible) +- [ ] Click → Capture page content +- [ ] Save vào selected search space +- [ ] Toast notification: "Page saved successfully" +- [ ] Reuse existing capture functionality + +**Files:** +- `sidepanel/chat/QuickCapture.tsx` ✅ + +--- + +### Story 1.6: Settings Sync với Frontend +**[FR-EXT-06]** + +**Là một** SurfSense user, +**Tôi muốn** extension sử dụng cùng model và search space như web dashboard, +**Để** tôi không phải config lại. + +**Acceptance Criteria:** +- [ ] Settings dropdown trong extension header +- [ ] Dropdown shows: + - Current model (read-only) + - Current search space (read-only) + - Links to frontend management +- [ ] Links: + - "Manage Connectors" → Open frontend /settings/connectors + - "View All Chats" → Open frontend /chats + - "Full Settings" → Open frontend /settings +- [ ] State sync: + - Extension reads from backend API + - Model selection synced + - Search space synced + - Enabled connectors synced (read-only) + - Chat history bidirectional sync + +**API Endpoints Needed:** +```typescript +GET /api/user/settings +POST /api/user/settings +GET /api/models/available +GET /api/search-spaces +GET /api/connectors/enabled +``` + +**Plasmo Storage Structure:** +```typescript +interface ExtensionStorage { + settings: { + selectedModel: string; + searchSpaceId: string; + apiKey: string; + }; + cachedSettings: UserSettings; + lastSync: number; +} +``` + +**Files:** +- `sidepanel/chat/ChatHeader.tsx` (add settings dropdown) +- `lib/api/settings-sync.ts` (new) + +--- + +## Technical Dependencies + +### Frontend Components to Reuse +- `@assistant-ui/react` Thread +- Tool UIs (images, links, scraping) +- Thinking steps visualization +- Chat utilities + +### Backend APIs Needed +- `/api/user/settings` - Get/update user settings +- `/api/models/available` - List available models +- `/api/search-spaces` - List search spaces +- `/api/connectors/enabled` - List enabled connectors +- `/api/chat/stream` - Chat streaming (existing) + +### Chrome APIs Used +- `chrome.sidePanel` - Side panel management +- `chrome.storage` - Plasmo Storage +- `chrome.tabs` - Tab management +- `chrome.runtime` - Messaging + +--- + +## Testing Strategy + +### Unit Tests +- [ ] PageContextProvider state management +- [ ] Token data extraction from DexScreener +- [ ] Settings sync logic + +### Integration Tests +- [ ] Side panel opens on icon click +- [ ] Chat streaming works +- [ ] Context detection works on DexScreener +- [ ] Token card displays correctly +- [ ] Quick capture saves page + +### Manual Testing +- [ ] Test on DexScreener.com +- [ ] Test on CoinGecko +- [ ] Test on Twitter +- [ ] Test settings sync with frontend +- [ ] Test chat history persistence + +--- + +## Definition of Done + +- [ ] All 6 stories completed +- [ ] All acceptance criteria met +- [ ] Unit tests passing +- [ ] Integration tests passing +- [ ] Manual testing completed +- [ ] Code reviewed +- [ ] Documentation updated +- [ ] Deployed to staging + +--- + +## Notes + +**Phase 1 Status:** ✅ COMPLETED (as of 2026-02-01) + +**Next Epic:** Epic 2 - Smart Monitoring & Alerts (Phase 2) diff --git a/_bmad-epics/epic-2-smart-monitoring-alerts.md b/_bmad-epics/epic-2-smart-monitoring-alerts.md new file mode 100644 index 000000000..4bc772629 --- /dev/null +++ b/_bmad-epics/epic-2-smart-monitoring-alerts.md @@ -0,0 +1,392 @@ +# Epic 2: Smart Monitoring & Alerts + +**Status:** 📋 PLANNED +**Phase:** Phase 2 +**Duration:** 2 weeks +**Priority:** P0 (Critical - Risk Protection) + +--- + +## Epic Overview + +Xây dựng hệ thống monitoring và alerts thông minh để bảo vệ users khỏi rủi ro và giúp họ không bỏ lỡ cơ hội. Tập trung vào **risk protection** (rug pull detection) và **opportunity alerts** (whale activity, price movements). + +**Business Value:** +- **Risk Protection:** Giúp users tránh mất tiền vào rug pulls +- **Opportunity Alerts:** Không bỏ lỡ whale movements và price spikes +- **Always-On Monitoring:** Background monitoring ngay cả khi browser đóng +- **Competitive Advantage:** Proactive alerts vs passive dashboards (DexScreener/DexTools) + +**Key Differentiator:** AI-driven anomaly detection, không chỉ là threshold alerts. + +--- + +## User Stories + +### Story 2.1: Real-time Price Alerts +**[FR-EXT-07]** + +**Là một** crypto trader, +**Tôi muốn** set price alerts cho tokens trong watchlist, +**Để** tôi được notify khi price hit target mà không cần stare vào chart cả ngày. + +**Acceptance Criteria:** +- [ ] Watchlist management trong side panel + - Add token to watchlist (from DexScreener page) + - Remove token from watchlist + - View all watchlist tokens + - Edit token alerts +- [ ] Alert types: + - Price above threshold (e.g., > $0.001) + - Price below threshold (e.g., < $0.0005) + - Price change % (e.g., +20% in 1h) + - Volume spike (e.g., 3x average volume) + - Liquidity change (e.g., -50% liquidity) +- [ ] Browser notifications: + - Work even when tab closed + - Show token symbol, price, change % + - Click notification → Open DexScreener page +- [ ] Sound alerts (optional): + - Enable/disable per alert + - Different sounds for different alert types +- [ ] Alert history: + - View past alerts + - Mark as read/unread + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 📊 Watchlist (5 tokens) │ +├─────────────────────────────┤ +│ BULLA/SOL $0.0001 +15% │ +│ 🔔 Alert: Price > $0.00015 │ +│ [Edit] [Remove] │ +├─────────────────────────────┤ +│ PEPE/ETH $0.000001 -5% │ +│ 🔕 No alerts │ +│ [Add Alert] │ +├─────────────────────────────┤ +│ [+ Add Token to Watchlist] │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface PriceAlert { + id: string; + tokenAddress: string; + chain: string; + alertType: 'above' | 'below' | 'change_percent' | 'volume_spike' | 'liquidity_change'; + threshold: number; + enabled: boolean; + soundEnabled: boolean; + lastTriggered?: number; +} + +// Background service worker +chrome.alarms.create('checkPriceAlerts', { periodInMinutes: 1 }); +chrome.alarms.onAlarm.addListener(async (alarm) => { + if (alarm.name === 'checkPriceAlerts') { + await checkAllPriceAlerts(); + } +}); +``` + +**Backend API:** +``` +POST /api/watchlist/add +DELETE /api/watchlist/:id +GET /api/watchlist +POST /api/alerts/create +GET /api/alerts/check // Returns triggered alerts +``` + +**Files:** +- `background/alerts/price-alerts.ts` (new) +- `sidepanel/watchlist/WatchlistPanel.tsx` (new) +- `sidepanel/watchlist/AddAlertModal.tsx` (new) + +--- + +### Story 2.2: Whale Activity Tracker +**[FR-EXT-08]** + +**Là một** crypto trader, +**Tôi muốn** được notify khi có whale buy/sell lớn, +**Để** tôi có thể follow smart money và tránh bị dumped. + +**Acceptance Criteria:** +- [ ] Monitor large transactions: + - Configurable thresholds: $10K, $50K, $100K + - Detect buy vs sell + - Show transaction size in USD +- [ ] Wallet clustering detection: + - Identify same entity (multiple wallets) + - Show total holdings across wallets +- [ ] Smart money tracking: + - Track specific wallet addresses + - Alert on their activities + - Show their historical performance +- [ ] Transaction details: + - Wallet address + - Transaction hash + - Amount (tokens + USD) + - Time + - Link to explorer +- [ ] Notification: + - Browser notification for whale activity + - Show in side panel feed + - Filter by token (only watchlist or all) + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 🐋 Whale Activity │ +├─────────────────────────────┤ +│ 2 min ago │ +│ 🟢 BUY $100K BULLA/SOL │ +│ Wallet: 0x1234...5678 │ +│ Amount: 1B tokens │ +│ [View on Explorer] │ +├─────────────────────────────┤ +│ 5 min ago │ +│ 🔴 SELL $50K PEPE/ETH │ +│ Wallet: 0xabcd...ef01 │ +│ ⚠️ Smart Money Wallet │ +│ [Track This Wallet] │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface WhaleTransaction { + id: string; + tokenAddress: string; + chain: string; + type: 'buy' | 'sell'; + amountUSD: number; + amountTokens: string; + walletAddress: string; + txHash: string; + timestamp: number; + isSmartMoney: boolean; +} + +// Poll blockchain for large transactions +async function monitorWhaleActivity() { + const watchlistTokens = await getWatchlistTokens(); + for (const token of watchlistTokens) { + const largeTxs = await fetchLargeTransactions(token, threshold); + for (const tx of largeTxs) { + await notifyWhaleActivity(tx); + } + } +} +``` + +**Data Sources:** +- Solana: Helius API / QuickNode +- Ethereum: Etherscan API / Alchemy +- Base: BaseScan API + +**Files:** +- `background/alerts/whale-tracker.ts` (new) +- `sidepanel/whale/WhaleActivityFeed.tsx` (new) +- `lib/blockchain/transaction-monitor.ts` (new) + +--- + +### Story 2.3: Rug Pull Early Warning System +**[FR-EXT-09]** + +**Là một** crypto trader, +**Tôi muốn** được cảnh báo sớm về rug pull risks, +**Để** tôi không mất tiền vào scam tokens. + +**Acceptance Criteria:** +- [ ] Risk indicators monitored: + - LP removal (liquidity pulled) + - Mint authority changes (can mint more tokens) + - Suspicious holder patterns (top 10 holders > 80%) + - Contract ownership (not renounced) + - Honeypot detection (can't sell) +- [ ] Risk score calculation: + - 0-3: Low risk (green) + - 4-6: Medium risk (yellow) + - 7-10: High risk (red) +- [ ] Risk score display: + - Show on Token Info Card + - Update in real-time + - Explain each risk factor +- [ ] Recommendations: + - SAFE: "Low risk, proceed with caution" + - CAUTION: "Medium risk, do your own research" + - AVOID: "High risk, likely scam" +- [ ] Alerts: + - Notify when risk score increases + - Notify on LP removal + - Notify on mint authority changes + +**UI Design:** +``` +┌─────────────────────────────┐ +│ ⚠️ RUG PULL WARNING │ +├─────────────────────────────┤ +│ Risk Score: 7/10 (High) │ +│ │ +│ 🔴 LP unlocked (High Risk) │ +│ 🟡 Top holder owns 40% │ +│ 🟢 Contract verified │ +│ 🟢 Mint authority renounced │ +│ │ +│ Recommendation: AVOID │ +│ This token shows signs of │ +│ potential rug pull. │ +│ │ +│ [View Full Analysis] │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface RiskAssessment { + tokenAddress: string; + chain: string; + riskScore: number; // 0-10 + riskLevel: 'low' | 'medium' | 'high'; + indicators: { + lpLocked: boolean; + lpLockDuration?: number; // days + mintAuthority: 'renounced' | 'active' | 'unknown'; + topHolderPercent: number; + contractVerified: boolean; + isHoneypot: boolean; + }; + recommendation: 'safe' | 'caution' | 'avoid'; + explanation: string; + timestamp: number; +} + +async function assessRugPullRisk(tokenAddress: string, chain: string): Promise { + // Check LP lock status + const lpLocked = await checkLPLock(tokenAddress, chain); + + // Check mint authority + const mintAuthority = await checkMintAuthority(tokenAddress, chain); + + // Check holder distribution + const holders = await getTopHolders(tokenAddress, chain); + const topHolderPercent = calculateTopHolderPercent(holders); + + // Check contract verification + const contractVerified = await isContractVerified(tokenAddress, chain); + + // Check honeypot + const isHoneypot = await checkHoneypot(tokenAddress, chain); + + // Calculate risk score + const riskScore = calculateRiskScore({ + lpLocked, + mintAuthority, + topHolderPercent, + contractVerified, + isHoneypot, + }); + + return { + tokenAddress, + chain, + riskScore, + riskLevel: getRiskLevel(riskScore), + indicators: { + lpLocked, + mintAuthority, + topHolderPercent, + contractVerified, + isHoneypot, + }, + recommendation: getRecommendation(riskScore), + explanation: generateExplanation(riskScore, indicators), + timestamp: Date.now(), + }; +} +``` + +**Data Sources:** +- LP Lock: RugCheck API, Token Sniffer +- Mint Authority: On-chain data (Solana/Ethereum) +- Holders: Blockchain explorers +- Contract Verification: Etherscan, Solscan +- Honeypot: Honeypot.is API + +**Files:** +- `lib/risk/rug-pull-detector.ts` (new) +- `sidepanel/risk/RiskScoreCard.tsx` (new) +- `background/alerts/risk-monitor.ts` (new) + +--- + +## Technical Dependencies + +### Backend APIs +``` +POST /api/watchlist/add +GET /api/watchlist +POST /api/alerts/create +GET /api/alerts/check +GET /api/whale/transactions +GET /api/risk/assess +``` + +### External APIs +- **Helius API** (Solana transactions) +- **Alchemy** (Ethereum transactions) +- **RugCheck API** (LP lock status) +- **Token Sniffer** (Contract analysis) +- **Honeypot.is** (Honeypot detection) + +### Chrome APIs +- `chrome.alarms` - Periodic checks +- `chrome.notifications` - Browser notifications +- `chrome.storage` - Watchlist persistence + +--- + +## Testing Strategy + +### Unit Tests +- [ ] Risk score calculation +- [ ] Whale transaction detection +- [ ] Alert triggering logic + +### Integration Tests +- [ ] Price alerts trigger correctly +- [ ] Whale activity notifications work +- [ ] Risk assessment updates in real-time + +### Manual Testing +- [ ] Add token to watchlist +- [ ] Set price alert and verify notification +- [ ] Monitor whale activity on live token +- [ ] Check rug pull warning on known scam token + +--- + +## Definition of Done + +- [ ] All 3 stories completed +- [ ] All acceptance criteria met +- [ ] Unit tests passing +- [ ] Integration tests passing +- [ ] Manual testing completed +- [ ] External API integrations working +- [ ] Code reviewed +- [ ] Documentation updated + +--- + +## Notes + +**Priority Justification:** Risk protection (rug pull detection) is CRITICAL for user trust. Users will not use the product if they lose money to scams. + +**Next Epic:** Epic 3 - Trading Intelligence (Phase 3) diff --git a/_bmad-epics/epic-3-trading-intelligence.md b/_bmad-epics/epic-3-trading-intelligence.md new file mode 100644 index 000000000..08848cfb7 --- /dev/null +++ b/_bmad-epics/epic-3-trading-intelligence.md @@ -0,0 +1,490 @@ +# Epic 3: Trading Intelligence + +**Status:** 📋 PLANNED +**Phase:** Phase 3 +**Duration:** 2 weeks +**Priority:** P1 (High - Value Add) + +--- + +## Epic Overview + +Cung cấp AI-powered trading insights để giúp users make better trading decisions. Tập trung vào **comprehensive analysis**, **entry/exit suggestions**, và **portfolio tracking**. + +**Business Value:** +- **Better Decisions:** AI-generated insights giúp users trade smarter +- **Time Savings:** One-click analysis thay vì hours of research +- **Portfolio Management:** Track performance và optimize holdings +- **Competitive Advantage:** AI predictions vs static data (DexScreener/DexTools) + +**Key Differentiator:** AI-first analysis với natural language explanations. + +--- + +## User Stories + +### Story 3.1: One-Click Token Analysis +**[FR-EXT-10]** + +**Là một** crypto trader, +**Tôi muốn** analyze token với một click, +**Để** tôi có comprehensive insights mà không cần research thủ công. + +**Acceptance Criteria:** +- [ ] "Analyze This Token" button trên Token Info Card +- [ ] Comprehensive analysis includes: + - **Contract Analysis:** + - Verified/unverified + - Renounced ownership + - Proxy contract detection + - Source code availability + - **Holder Distribution:** + - Top 10 holders percentage + - Holder count + - Whale concentration + - Distribution chart + - **Liquidity Analysis:** + - Total liquidity (USD) + - LP lock status & duration + - Liquidity history (7d, 30d) + - Liquidity/Market cap ratio + - **Trading Volume:** + - 24h volume + - Volume trend (increasing/decreasing) + - Volume/Liquidity ratio + - Unusual volume spikes + - **Price History:** + - All-time high/low + - 7d, 30d performance + - Price volatility + - Support/resistance levels + - **Social Sentiment:** + - Twitter mentions + - Telegram activity + - Reddit discussions + - Sentiment score (positive/negative/neutral) +- [ ] AI-Generated Summary: + - 2-3 sentence summary + - Key insights highlighted + - Risk assessment + - Trading recommendation +- [ ] Analysis caching: + - Cache for 5 minutes + - Show "Last updated" timestamp + - Refresh button + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 📊 Token Analysis │ +├─────────────────────────────┤ +│ AI Summary: │ +│ "BULLA shows strong holder │ +│ distribution with verified │ +│ contract. Volume increasing │ +│ 200% in 24h. Moderate risk."│ +│ │ +│ Contract: ✅ Verified │ +│ Ownership: ✅ Renounced │ +│ │ +│ Holders: 1,234 │ +│ Top 10: 35% (Good) │ +│ │ +│ Liquidity: $50K │ +│ LP Lock: 90 days │ +│ │ +│ Volume 24h: $100K (+200%) │ +│ Price: $0.0001 (+15%) │ +│ │ +│ Sentiment: 😊 Positive │ +│ Twitter: 500 mentions │ +│ │ +│ Recommendation: BUY │ +│ Confidence: 75% │ +│ │ +│ [View Full Report] │ +│ Last updated: 2 min ago │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface TokenAnalysis { + tokenAddress: string; + chain: string; + timestamp: number; + + contract: { + verified: boolean; + renounced: boolean; + isProxy: boolean; + sourceCode: boolean; + }; + + holders: { + count: number; + top10Percent: number; + distribution: { address: string; percent: number }[]; + }; + + liquidity: { + totalUSD: number; + lpLocked: boolean; + lpLockDuration?: number; + history7d: number[]; + liquidityMcapRatio: number; + }; + + volume: { + volume24h: number; + trend: 'increasing' | 'decreasing' | 'stable'; + volumeLiquidityRatio: number; + spikes: { timestamp: number; volume: number }[]; + }; + + price: { + current: number; + ath: number; + atl: number; + change7d: number; + change30d: number; + volatility: number; + supportLevels: number[]; + resistanceLevels: number[]; + }; + + social: { + twitterMentions: number; + telegramActivity: number; + redditDiscussions: number; + sentimentScore: number; // -1 to 1 + sentiment: 'positive' | 'negative' | 'neutral'; + }; + + aiSummary: string; + recommendation: 'buy' | 'hold' | 'sell' | 'avoid'; + confidence: number; // 0-100 +} + +async function analyzeToken(tokenAddress: string, chain: string): Promise { + // Parallel data fetching + const [contract, holders, liquidity, volume, price, social] = await Promise.all([ + analyzeContract(tokenAddress, chain), + analyzeHolders(tokenAddress, chain), + analyzeLiquidity(tokenAddress, chain), + analyzeVolume(tokenAddress, chain), + analyzePrice(tokenAddress, chain), + analyzeSocial(tokenAddress, chain), + ]); + + // AI-generated summary + const aiSummary = await generateAISummary({ + contract, + holders, + liquidity, + volume, + price, + social, + }); + + return { + tokenAddress, + chain, + timestamp: Date.now(), + contract, + holders, + liquidity, + volume, + price, + social, + aiSummary, + recommendation: getRecommendation(/* ... */), + confidence: calculateConfidence(/* ... */), + }; +} +``` + +**Files:** +- `lib/analysis/token-analyzer.ts` (new) +- `sidepanel/analysis/TokenAnalysisPanel.tsx` (new) +- `sidepanel/analysis/AnalysisSummary.tsx` (new) + +--- + +### Story 3.2: Smart Entry/Exit Suggestions +**[FR-EXT-11]** + +**Là một** crypto trader, +**Tôi muốn** AI suggest entry/exit points, +**Để** tôi maximize profits và minimize losses. + +**Acceptance Criteria:** +- [ ] Technical analysis: + - Support/Resistance levels (3 levels each) + - Fibonacci retracement levels + - Volume profile analysis + - Moving averages (20, 50, 200) +- [ ] AI predictions: + - Predicted price targets (3 levels) + - Time horizon (1h, 4h, 24h) + - Confidence score per prediction +- [ ] Risk/Reward calculation: + - Suggested entry range + - Stop loss level + - Take profit levels (3 targets) + - Risk/Reward ratio +- [ ] Visual representation: + - Price chart with levels marked + - Entry/exit zones highlighted + - Risk/reward visualization +- [ ] Explanation: + - Why these levels? + - What signals support this? + - What could invalidate this? + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 💡 AI Trading Suggestion │ +├─────────────────────────────┤ +│ Current Price: $0.00010 │ +│ │ +│ Entry Zone: 🟢 │ +│ $0.00010 - $0.00012 │ +│ │ +│ Targets: │ +│ 🎯 Target 1: $0.00015 (+25%)│ +│ 🎯 Target 2: $0.00018 (+50%)│ +│ 🎯 Target 3: $0.00022 (+83%)│ +│ │ +│ Stop Loss: 🔴 │ +│ $0.00008 (-20%) │ +│ │ +│ Risk/Reward: 1:3.3 (Good) │ +│ Confidence: 75% │ +│ │ +│ Why? │ +│ • Strong support at $0.0001 │ +│ • Volume increasing │ +│ • Fibonacci 0.618 at $0.00015│ +│ │ +│ [View Chart] [Set Alerts] │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface TradingSuggestion { + tokenAddress: string; + chain: string; + currentPrice: number; + timestamp: number; + + entry: { + min: number; + max: number; + reasoning: string; + }; + + targets: { + level: number; + price: number; + percentGain: number; + confidence: number; + }[]; + + stopLoss: { + price: number; + percentLoss: number; + reasoning: string; + }; + + riskReward: number; + overallConfidence: number; + + technicalLevels: { + support: number[]; + resistance: number[]; + fibonacci: { level: number; price: number }[]; + movingAverages: { period: number; price: number }[]; + }; + + reasoning: string[]; + invalidationConditions: string[]; +} +``` + +**Files:** +- `lib/analysis/trading-suggestions.ts` (new) +- `sidepanel/analysis/TradingSuggestionPanel.tsx` (new) + +--- + +### Story 3.3: Portfolio Tracker Integration +**[FR-EXT-12]** + +**Là một** crypto trader, +**Tôi muốn** track portfolio trong extension, +**Để** tôi biết P&L real-time mà không cần mở nhiều tabs. + +**Acceptance Criteria:** +- [ ] Wallet connection: + - Support MetaMask, Phantom, Coinbase Wallet + - Multi-wallet support + - Auto-detect holdings +- [ ] Portfolio overview: + - Total value (USD) + - 24h P&L ($ and %) + - All-time P&L + - Asset allocation chart +- [ ] Holdings list: + - Token symbol/name + - Amount held + - Current value + - 24h change + - P&L per token + - Entry price (if available) +- [ ] Performance analytics: + - Best/worst performers + - Win rate + - Average hold time + - Total trades +- [ ] Quick actions: + - Analyze token + - Set price alert + - View on DexScreener + - Sell (link to DEX) + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 💼 Portfolio │ +├─────────────────────────────┤ +│ Total Value: $5,234 │ +│ 24h P&L: +$234 (+4.7%) 📈 │ +│ │ +│ Holdings (5 tokens): │ +│ │ +│ BULLA/SOL │ +│ 1,000,000 tokens │ +│ $1,234 (+15%) 📈 │ +│ [Analyze] [Alert] [Sell] │ +│ │ +│ PEPE/ETH │ +│ 500,000,000 tokens │ +│ $2,100 (-5%) 📉 │ +│ [Analyze] [Alert] [Sell] │ +│ │ +│ [+ Add Manual Position] │ +│ │ +│ Performance: │ +│ Best: BULLA (+15%) │ +│ Worst: PEPE (-5%) │ +│ Win Rate: 60% │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface Portfolio { + wallets: { + address: string; + chain: string; + type: 'metamask' | 'phantom' | 'coinbase'; + }[]; + + totalValue: number; + change24h: number; + change24hPercent: number; + + holdings: { + tokenAddress: string; + chain: string; + symbol: string; + name: string; + amount: string; + currentPrice: number; + currentValue: number; + change24h: number; + change24hPercent: number; + entryPrice?: number; + pnl?: number; + pnlPercent?: number; + }[]; + + analytics: { + bestPerformer: { symbol: string; change: number }; + worstPerformer: { symbol: string; change: number }; + winRate: number; + avgHoldTime: number; + totalTrades: number; + }; +} +``` + +**Files:** +- `lib/wallet/wallet-connector.ts` (new) +- `lib/portfolio/portfolio-tracker.ts` (new) +- `sidepanel/portfolio/PortfolioPanel.tsx` (new) + +--- + +## Technical Dependencies + +### Backend APIs +``` +POST /api/analysis/token +GET /api/analysis/suggestions +POST /api/portfolio/connect +GET /api/portfolio/holdings +GET /api/portfolio/analytics +``` + +### External APIs +- **Blockchain Data:** Helius, Alchemy, QuickNode +- **Price Data:** DexScreener API +- **Social Data:** Twitter API, LunarCrush +- **Technical Analysis:** TradingView indicators + +### Wallet Integration +- MetaMask SDK +- Phantom SDK +- Coinbase Wallet SDK + +--- + +## Testing Strategy + +### Unit Tests +- [ ] Token analysis calculation +- [ ] Trading suggestion algorithm +- [ ] Portfolio P&L calculation + +### Integration Tests +- [ ] Wallet connection flow +- [ ] Portfolio data fetching +- [ ] Analysis generation + +### Manual Testing +- [ ] Analyze live token +- [ ] Connect wallet and view portfolio +- [ ] Verify trading suggestions accuracy + +--- + +## Definition of Done + +- [ ] All 3 stories completed +- [ ] All acceptance criteria met +- [ ] Unit tests passing +- [ ] Integration tests passing +- [ ] Manual testing completed +- [ ] Wallet integrations working +- [ ] Code reviewed +- [ ] Documentation updated + +--- + +## Notes + +**Next Epic:** Epic 4 - Content Creation & Productivity (Phase 4) diff --git a/_bmad-epics/epic-4-content-creation-productivity.md b/_bmad-epics/epic-4-content-creation-productivity.md new file mode 100644 index 000000000..cf4ef5e10 --- /dev/null +++ b/_bmad-epics/epic-4-content-creation-productivity.md @@ -0,0 +1,451 @@ +# Epic 4: Content Creation & Productivity + +**Status:** 📋 PLANNED +**Phase:** Phase 4 +**Duration:** 2 weeks +**Priority:** P2 (Medium - Nice to Have) + +--- + +## Epic Overview + +Tạo tools giúp users create content (charts, threads) và improve productivity (quick actions, notifications, shortcuts). Tập trung vào **content creators** và **power users**. + +**Business Value:** +- **Content Creators:** Tools để tạo Twitter threads, chart screenshots +- **Power Users:** Keyboard shortcuts, quick actions để work faster +- **Viral Marketing:** Users share content → Free marketing +- **User Retention:** Productivity features → Sticky product + +**Key Differentiator:** AI-powered content generation vs manual tools. + +--- + +## User Stories + +### Story 4.1: Chart Screenshot with Annotations +**[FR-EXT-13]** + +**Là một** crypto content creator, +**Tôi muốn** capture và annotate charts, +**Để** tôi có thể share insights trên Twitter/Telegram. + +**Acceptance Criteria:** +- [ ] One-click chart capture: + - Capture from DexScreener page + - Auto-detect chart area + - High-resolution screenshot +- [ ] Auto-add metadata: + - Token symbol/name + - Current price + - 24h change + - Volume, liquidity + - Timestamp + - Watermark (optional) +- [ ] Drawing tools: + - Lines (trend lines, support/resistance) + - Arrows (direction indicators) + - Text labels + - Shapes (circles, rectangles) + - Fibonacci retracement +- [ ] Template styles: + - Dark mode (default) + - Light mode + - Neon (crypto aesthetic) + - Custom colors +- [ ] Export options: + - Twitter format (1200x675) + - Telegram format (square) + - Instagram format (1080x1080) + - Custom size + - Copy to clipboard + - Save to file + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 📸 Chart Capture │ +├─────────────────────────────┤ +│ [Capture Chart] │ +│ │ +│ Drawing Tools: │ +│ [Line] [Arrow] [Text] [Fib] │ +│ │ +│ Style: │ +│ ● Dark ○ Light ○ Neon │ +│ │ +│ Metadata: │ +│ ☑ Token info │ +│ ☑ Price & change │ +│ ☑ Volume & liquidity │ +│ ☑ Timestamp │ +│ ☐ Watermark │ +│ │ +│ Export: │ +│ [Twitter] [Telegram] [Copy] │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface ChartCapture { + screenshot: Blob; + metadata: { + tokenSymbol: string; + price: number; + change24h: number; + volume: number; + liquidity: number; + timestamp: number; + }; + annotations: { + type: 'line' | 'arrow' | 'text' | 'shape' | 'fibonacci'; + coordinates: { x: number; y: number }[]; + text?: string; + color: string; + }[]; + style: 'dark' | 'light' | 'neon'; +} + +async function captureChart(): Promise { + // Capture DexScreener chart area + const chartElement = document.querySelector('.chart-container'); + const canvas = await html2canvas(chartElement); + return canvas.toBlob(); +} + +function addAnnotations(canvas: HTMLCanvasElement, annotations: Annotation[]) { + const ctx = canvas.getContext('2d'); + for (const annotation of annotations) { + switch (annotation.type) { + case 'line': + drawLine(ctx, annotation); + break; + case 'arrow': + drawArrow(ctx, annotation); + break; + // ... + } + } +} +``` + +**Files:** +- `lib/capture/chart-capture.ts` (new) +- `sidepanel/capture/ChartCapturePanel.tsx` (new) +- `sidepanel/capture/AnnotationTools.tsx` (new) + +--- + +### Story 4.2: AI Thread Generator +**[FR-EXT-14]** + +**Là một** crypto content creator, +**Tôi muốn** AI generate Twitter threads, +**Để** tôi có thể share insights nhanh chóng. + +**Acceptance Criteria:** +- [ ] Input: + - Token address (auto-filled if on DexScreener) + - Thread topic (optional) + - Thread length (5-10 tweets) + - Tone (bullish/neutral/bearish) +- [ ] AI generation: + - Analyze token data + - Generate thread structure + - Include key stats + - Add charts/screenshots + - Optimize for engagement +- [ ] Thread structure: + - Tweet 1: Hook (attention grabber) + - Tweets 2-4: Analysis (data, insights) + - Tweets 5-7: Implications (what it means) + - Tweet 8-9: Conclusion (summary, CTA) + - Tweet 10: Disclaimer (optional) +- [ ] Editing: + - Edit each tweet + - Reorder tweets + - Add/remove tweets + - Preview thread +- [ ] Export: + - Copy all tweets + - Copy individual tweet + - Tweet directly (Twitter API) + - Save as draft + +**UI Design:** +``` +┌─────────────────────────────┐ +│ 🧵 AI Thread Generator │ +├─────────────────────────────┤ +│ Token: BULLA/SOL │ +│ Topic: [Auto] │ +│ Length: [7 tweets] ▼ │ +│ Tone: ● Bullish ○ Neutral │ +│ │ +│ [Generate Thread] │ +│ │ +│ Preview: │ +│ ┌─────────────────────────┐ │ +│ │ 1/ 🧵 BULLA is showing │ │ +│ │ massive volume spike... │ │ +│ │ [Edit] │ │ +│ ├─────────────────────────┤ │ +│ │ 2/ Contract analysis: │ │ +│ │ ✅ Verified ✅ Renounced│ │ +│ │ [Edit] │ │ +│ └─────────────────────────┘ │ +│ │ +│ [Copy All] [Tweet Now] │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +interface ThreadRequest { + tokenAddress: string; + chain: string; + topic?: string; + length: number; + tone: 'bullish' | 'neutral' | 'bearish'; +} + +interface GeneratedThread { + tweets: { + number: number; + content: string; + type: 'hook' | 'analysis' | 'implication' | 'conclusion' | 'disclaimer'; + includeChart?: boolean; + }[]; + metadata: { + tokenSymbol: string; + keyStats: Record; + }; +} + +async function generateThread(request: ThreadRequest): Promise { + // Analyze token + const analysis = await analyzeToken(request.tokenAddress, request.chain); + + // Generate thread with AI + const prompt = ` + Generate a ${request.length}-tweet thread about ${analysis.symbol}. + Tone: ${request.tone} + Include: price, volume, holders, liquidity, sentiment + Structure: Hook → Analysis → Implications → Conclusion + `; + + const thread = await callAI(prompt, { analysis }); + + return thread; +} +``` + +**Files:** +- `lib/content/thread-generator.ts` (new) +- `sidepanel/content/ThreadGeneratorPanel.tsx` (new) + +--- + +### Story 4.3: Quick Actions & Productivity +**[FR-EXT-15, FR-EXT-16, FR-EXT-17]** + +**Là một** power user, +**Tôi muốn** quick actions và shortcuts, +**Để** tôi có thể work faster. + +**Acceptance Criteria:** + +#### Quick Actions Context Menu (FR-EXT-15) +- [ ] Right-click on token address → Context menu +- [ ] Menu items: + - "Add to Watchlist" + - "Analyze Token" + - "Check Safety" + - "Copy Address" + - "View on Explorer" + - "View on DexScreener" +- [ ] Works on any webpage (not just DexScreener) +- [ ] Auto-detect token address format + +#### Smart Notifications (FR-EXT-16) +- [ ] Notification priority levels: + - High: Rug pull warnings, whale dumps + - Medium: Price alerts, volume spikes + - Low: General updates +- [ ] Quiet hours: + - Set sleep schedule (e.g., 11pm - 7am) + - No notifications during quiet hours + - Emergency alerts only (rug pulls) +- [ ] Grouped notifications: + - Group by token + - Group by type + - Collapse similar notifications +- [ ] Smart batching: + - 5+ alerts → 1 summary notification + - "5 price alerts triggered" + - Click to expand +- [ ] Per-token settings: + - Enable/disable notifications + - Set priority level + - Custom quiet hours + +#### Keyboard Shortcuts (FR-EXT-17) +- [ ] Global shortcuts: + - `Cmd+Shift+S` → Open side panel + - `Cmd+Shift+H` → Hide side panel + - `Cmd+Shift+N` → New chat +- [ ] Context shortcuts (when on DexScreener): + - `Cmd+Shift+A` → Analyze current token + - `Cmd+Shift+W` → Add to watchlist + - `Cmd+Shift+C` → Capture chart + - `Cmd+Shift+T` → Generate thread +- [ ] Portfolio shortcuts: + - `Cmd+Shift+P` → Open portfolio + - `Cmd+Shift+R` → Refresh portfolio +- [ ] Customizable shortcuts: + - User can remap shortcuts + - No conflicts with browser shortcuts + +**UI Design - Settings:** +``` +┌─────────────────────────────┐ +│ ⚙️ Productivity Settings │ +├─────────────────────────────┤ +│ Notifications: │ +│ Priority: [High] [Med] [Low]│ +│ Quiet Hours: 11pm - 7am │ +│ ☑ Group notifications │ +│ ☑ Smart batching │ +│ │ +│ Keyboard Shortcuts: │ +│ Open panel: Cmd+Shift+S │ +│ Analyze: Cmd+Shift+A │ +│ Watchlist: Cmd+Shift+W │ +│ [Customize] │ +│ │ +│ Quick Actions: │ +│ ☑ Context menu enabled │ +│ ☑ Auto-detect addresses │ +└─────────────────────────────┘ +``` + +**Technical Implementation:** +```typescript +// Context menu +chrome.contextMenus.create({ + id: 'analyze-token', + title: 'Analyze Token', + contexts: ['selection'], +}); + +chrome.contextMenus.onClicked.addListener((info, tab) => { + if (info.menuItemId === 'analyze-token') { + const address = extractTokenAddress(info.selectionText); + analyzeToken(address); + } +}); + +// Keyboard shortcuts +chrome.commands.onCommand.addListener((command) => { + switch (command) { + case 'open-panel': + chrome.sidePanel.open(); + break; + case 'analyze-token': + analyzeCurrentToken(); + break; + // ... + } +}); + +// Smart notifications +interface NotificationSettings { + priority: 'high' | 'medium' | 'low'; + quietHours: { start: string; end: string }; + grouping: boolean; + batching: boolean; + perToken: Record; +} + +function shouldShowNotification(notification: Notification, settings: NotificationSettings): boolean { + // Check quiet hours + if (isQuietHours(settings.quietHours) && notification.priority !== 'high') { + return false; + } + + // Check per-token settings + const tokenSettings = settings.perToken[notification.tokenAddress]; + if (tokenSettings && !tokenSettings.enabled) { + return false; + } + + return true; +} +``` + +**Files:** +- `background/context-menu.ts` (new) +- `background/keyboard-shortcuts.ts` (new) +- `background/notifications/smart-notifications.ts` (new) +- `sidepanel/settings/ProductivitySettings.tsx` (new) + +--- + +## Technical Dependencies + +### Chrome APIs +- `chrome.contextMenus` - Context menu +- `chrome.commands` - Keyboard shortcuts +- `chrome.notifications` - Notifications +- `chrome.alarms` - Quiet hours + +### External Libraries +- `html2canvas` - Chart capture +- `fabric.js` - Drawing tools (optional) + +--- + +## Testing Strategy + +### Unit Tests +- [ ] Token address detection +- [ ] Notification priority logic +- [ ] Quiet hours calculation + +### Integration Tests +- [ ] Chart capture works +- [ ] Thread generation works +- [ ] Context menu appears +- [ ] Shortcuts trigger actions + +### Manual Testing +- [ ] Capture chart and annotate +- [ ] Generate thread for live token +- [ ] Test all keyboard shortcuts +- [ ] Verify quiet hours work + +--- + +## Definition of Done + +- [ ] All 3 stories completed +- [ ] All acceptance criteria met +- [ ] Unit tests passing +- [ ] Integration tests passing +- [ ] Manual testing completed +- [ ] Code reviewed +- [ ] Documentation updated + +--- + +## Notes + +**Target Users:** Content creators và power users. + +**Marketing Opportunity:** User-generated content (threads, charts) → Free viral marketing. + +**All Epics Complete!** 🎉