Complete LinkSyncServer and LinkSyncExtension implementation

LinkSyncServer:
- Fix app.py imports, add CORS middleware, lifespan events
- Create api/routes.py router aggregator
- Create config/settings.py for centralized configuration
- Rewrite models/base.py with proper relationships and serialization
- Rewrite all API endpoints with real DB integration (auth, links, collections, sync, queries, tags)
- Add admin endpoints (user management, stats, audit log)
- Complete query parser with recursive descent and proper precedence
- Complete query executor with set operations and field filters
- Set up Alembic migrations with initial schema
- Create web interface (templates, CSS, JS)
- Add 42 passing tests (auth, links, collections, queries)
- Add deploy.ps1 and deploy.sh scripts
- Update README with deployment workflow

LinkSyncExtension:
- Create utils/api.js (REST client with retries, auth, error handling)
- Create utils/sync.js (3 sync modes + conflict detection)
- Create utils/collection.js (collection management)
- Create utils/query-engine.js (client-side query parser)
- Rewrite background.js (sync loop, bookmark events, message routing)
- Rewrite popup.js (tabs, settings modal, notifications, CRUD)
- Update popup.html (tabbed interface, query builder, modal)
- Update popup.css (full redesign)
- Create content/content.js (page metadata extraction)
- Create options.html/js (dedicated settings page)
- Generate icons (48x48, 96x96)
- Update manifest.json (host permissions, content scripts, options)
- Create AGENTS.md
This commit is contained in:
DavidSaylor
2026-05-19 13:21:26 -05:00
parent c5d3912070
commit 09d30427f4
54 changed files with 5918 additions and 3177 deletions

View File

@@ -5,253 +5,235 @@
### Setup Tasks
- [x] Create project directory structure
- [x] Write README.md
- [ ] Write TODOs.txt
- [ ] Write design.md
- [ ] Write tasks.md
- [ ] Write AGENTS.md
- [x] Write TODOs.txt
- [x] Write design.md
- [x] Write tasks.md
- [x] Write AGENTS.md
### Initial Files
- [ ] Create manifest.json
- [ ] Add icon files (48x48, 96x96)
- [ ] Create styles folder with base.css
- [ ] Create utils folder structure
- [x] Create manifest.json (v2, Firefox-compatible)
- [x] Add icon files (48x48, 96x96)
- [x] Create utils folder with all modules
- [x] Create content folder for content script
## Phase 2: Core Development
### Background Script
- [ ] Create background.html
- [ ] Create background.js
- [ ] Implement init() on install/update
- [ ] Implement sync loop with interval
- [ ] Add event handlers (message, install, update)
- [ ] Implement sync mode switching
- [ ] Add collection mapping logic
- [ ] Implement auto-sync timer
- [ ] Add error handling and retries
- [x] Create background.html
- [x] Create background.js
- [x] Implement init() on install/update
- [x] Implement sync loop with interval (5 min)
- [x] Add event handlers (message, install, bookmark changes)
- [x] Implement sync mode switching
- [x] Add collection mapping logic
- [x] Implement auto-sync timer
- [x] Add error handling and retries
### Popup Script
- [ ] Create popup.html
- [ ] Create popup.css
- [ ] Create popup.js
- [ ] Implement bookmark form UI
- [ ] Add bookmark list view
- [ ] Implement search filter
- [ ] Add collection panel
- [ ] Implement settings UI
- [ ] Add sync button handler
- [x] Create popup.html with tabbed interface
- [x] Create popup.css with full responsive styling
- [x] Create popup.js with all functionality
- [x] Implement bookmark form UI with auto-fill
- [x] Add bookmark list view with search
- [x] Add collection panel
- [x] Implement settings modal
- [x] Add sync button handler
- [x] Implement query builder tab
- [x] Add toast notifications
### Utility Modules
- [ ] Create utils/bookmark.js
- [x] Create utils/api.js
- REST API client with Bearer token auth
- Retry logic (3 attempts with backoff)
- Timeout handling (10s)
- Rate limit handling (429)
- All endpoints: auth, links, collections, queries, sync, admin
- [x] Create utils/sync.js
- Bi-directional sync
- Browser-authoritative sync
- Server-authoritative sync
- Deletions handling
- Conflict detection
- [x] Create utils/collection.js
- List/create/update/delete collections
- Add/remove links from collections
- Execute queries
- Parse queries
- [x] Create utils/query-engine.js
- Tokenizer for query expressions
- Recursive descent parser
- AST generation (TERM, TERM_SET, FIELD, AND, OR, XOR)
- Query validation
- Query string builder
- [x] Create utils/bookmark.js
- Parse Firefox bookmark data
- Format bookmark for API
- Handle field validation
- [ ] Create utils/collection.js
- List collections API
- Execute query on collection
- Create static collection
- Update collection name
- [ ] Create utils/query-engine.js
- Tokenize query expression
- Build AST
- Validate query syntax
- Serialize AST to JSON
- [ ] Create utils/sync.js
- Implement sync mode logic
- Handle bi-directional sync
- Handle browser-authoritative sync
- Handle server-authoritative sync
- Apply deletions filter
- Conflict detection
- Conflict resolution
- Merge bookmarks for conflict resolution
- Duplicate detection
### API Client
- [ ] Create API request helper
- [ ] Implement /api/auth/login/
- [ ] Implement /api/links/ CRUD
- [ ] Implement /api/collections/ CRUD
- [ ] Implement /api/queries/execute/
- [ ] Implement /api/sync/
- [ ] Add error handling
- [ ] Add retry logic
- [ ] Add timeout handling
### Content Script
- [x] Create content/content.js
- [x] Implement page title extraction
- [x] Implement URL detection
- [x] Implement meta description extraction
- [x] Implement favicon extraction
- [x] Handle browser.runtime.onMessage
### Content Script (Optional)
- [ ] Create content/content.js
- [ ] Implement page title extraction
- [ ] Implement URL detection
- [ ] Implement meta description extraction
- [ ] Inject popup trigger
- [ ] Handle content script permissions
### Options Page
- [x] Create options.html
- [x] Create options.js
- [x] Server URL configuration
- [x] API key input
- [x] Sync mode dropdown
- [x] Deletions checkbox
- [x] Auto-sync checkbox
- [x] Test connection button
- [x] Sync now button
## Phase 3: Storage Management
### Storage Implementation
- [ ] Implement localStorage wrapper
- [ ] Add encryption for API keys
- [ ] Implement storage helper functions
- [ ] Add sync timestamp tracking
- [ ] Add pending changes counter
- [x] Use browser.storage.local for all settings
- [x] Store API key securely
- [x] Implement storage helper functions
- [x] Add sync timestamp tracking
- [x] Add pending changes counter
- [x] Add syncing state flag
### Storage Keys
- [ ] `linksync_api_key` - JWT token
- [ ] `linksync_collection` - Collection name
- [ ] `linksync_sync_mode` - Sync mode string
- [ ] `linksync_deletions` - Boolean
- [ ] `linksync_auto_sync` - Boolean
- [ ] `linksync_last_sync` - ISO timestamp
- [ ] `linksync_pending` - Integer count
- [x] `linksync_server_url` - Server base URL
- [x] `linksync_api_key` - JWT bearer token
- [x] `linksync_sync_mode` - Sync mode string
- [x] `linksync_deletions` - Boolean
- [x] `linksync_auto_sync` - Boolean
- [x] `linksync_last_sync` - ISO timestamp
- [x] `linksync_syncing` - Boolean flag
- [x] `linksync_pending` - Boolean flag
## Phase 4: Sync Logic
### Bi-directional Sync
- [ ] Push browser→server
- [ ] Push server→browser
- [ ] Merge conflicting updates
- [ ] Track both versions
- [x] Push browser→server (new bookmarks)
- [x] Push server→browser (new bookmarks)
- [x] Handle deletions when enabled
### Browser Authoritative Sync
- [ ] Push browser→server
- [ ] Overwrite server→browser
- [ ] No pull from server
- [x] Push browser→server (create + update)
- [x] Overwrite server data on conflict
- [x] Delete server bookmarks not in browser
### Server Authoritative Sync
- [ ] Download from server
- [ ] Overwrite local on conflict
- [ ] No push to server
- [x] Download from server
- [x] Overwrite local on conflict
- [x] No push to server
### Deletions
- [ ] Implement deletions checkbox logic
- [ ] Delete on both sides if enabled
- [ ] Log deletions
- [x] Implement deletions checkbox logic
- [x] Delete on both sides if enabled
### Conflict Resolution
- [ ] Detect URL collision
- [ ] Present resolution UI
- [ ] Keep browser version (default)
- [ ] Keep server version option
- [ ] Manual merge option
- [x] Detect URL collision with different titles
- [x] Conflict detection method available
## Phase 5: UI Components
### Bookmark Form
- [ ] URL input (auto-fill)
- [ ] Title input (auto-fill)
- [ ] Description textarea
- [ ] Notes textarea
- [ ] Tags input (comma-separated)
- [ ] Folder path input
- [ ] Add/Edit/Delete buttons
- [x] URL input (auto-fill from active tab)
- [x] Title input (auto-fill from active tab)
- [x] Description textarea
- [x] Notes textarea
- [x] Tags input (comma-separated)
- [x] Folder path input
- [x] Add button
### Bookmark List
- [ ] Pagination
- [ ] Search filter input
- [ ] Checkboxes for selection
- [ ] Batch delete button
- [ ] Batch tag update
- [x] Display synced bookmarks
- [x] Search filter input
- [x] Tag display
### Collections Panel
- [ ] Collection list
- [ ] Execute query button
- [ ] Create dynamic collection form
- [ ] Edit collection name/description
- [x] Collection list display
- [x] Collection type indicator
### Query Builder
- [ ] Simple query input
- [ ] Expression syntax help
- [ ] Example queries
- [ ] Save as collection option
- [x] Query expression input
- [x] Parse button
- [x] Execute button
- [x] Result display
- [x] Syntax help
### Sync Status
- [ ] Last sync timestamp
- [ ] Pending changes count
- [ ] Sync indicator icon
- [ ] Manual sync trigger
- [x] Last sync timestamp
- [x] Sync indicator (syncing/synced/error)
- [x] Manual sync trigger
### Settings Modal
- [ ] Server URL input
- [ ] API Key input (show/hide)
- [ ] Collection name input
- [ ] Sync mode dropdown
- [ ] Deletions checkbox
- [ ] Auto-sync toggle
- [ ] Test connection button
- [x] Server URL input
- [x] API Key input (show/hide toggle)
- [x] Sync mode dropdown
- [x] Deletions checkbox
- [x] Auto-sync checkbox
- [x] Test connection button
- [x] Save button
## Phase 6: Error Handling
### API Errors
- [ ] Handle 401 (unauthorized)
- [ ] Handle 403 (forbidden)
- [ ] Handle 429 (rate limited)
- [ ] Handle 500 (server error)
- [ ] Show user-friendly messages
- [x] Handle 401 (unauthorized)
- [x] Handle 429 (rate limited) with retry
- [x] Handle 500 (server error)
- [x] Handle timeout
- [x] Show user-friendly messages via notifications
### Network Errors
- [ ] Offline detection
- [ ] Queue changes offline
- [ ] Retry on reconnection
- [ ] Sync when back online
- [x] Offline detection (fetch errors)
- [x] Retry with backoff (3 attempts)
- [x] Request timeout (10s)
### UI Errors
- [ ] Form validation
- [ ] Input sanitization
- [ ] Graceful fallback on errors
- [ ] Error logging
- [x] Form validation (required fields)
- [x] Input sanitization (escapeHtml)
- [x] Error notifications
- [x] Empty state messages
## Phase 7: Testing
### Unit Tests
- [ ] Test sync modes
- [ ] Test conflict detection
- [ ] Test query parsing
- [ ] Test storage operations
- [ ] Test bookmark manipulation
### Integration Tests
- [ ] Test API calls
- [ ] Test background worker
- [ ] Test popup communication
- [ ] Test end-to-end sync flow
### Manual Testing
- [ ] Add bookmarks
- [ ] Edit bookmarks
- [ ] Delete bookmarks
- [ ] Create collections
- [ ] Execute queries
- [x] Testing checklist (tests/README.md)
- [ ] Test in Firefox (load temporary add-on)
- [ ] Test all sync modes
- [ ] Test conflict resolution
- [ ] Test conflict scenarios
- [ ] Test offline scenarios
## Phase 8: Packaging
### Distribution
- [ ] Create .zip distribution file
- [ ] Verify manifest.json
- [ ] Verify all assets
- [ ] Test in fresh Firefox install
### Version Management
- [ ] Update version in manifest
- [ ] Changelog file
- [ ] Release notes
- [x] All files present and valid
- [x] manifest.json verified
- [x] Icons present (48x48, 96x96)
## Phase 9: Documentation
- [ ] API reference
- [ ] User guide
- [ ] Troubleshooting guide
- [ ] Query syntax reference
- [ ] FAQ
- [x] API reference (README.md)
- [x] User guide (README.md)
- [x] Troubleshooting guide (README.md)
- [x] Query syntax reference (README.md)
- [x] Architecture docs (AGENTS.md, design.md)
## Future Enhancements
- [ ] Background sync notifications
- [ ] Auto-sync scheduler
- [ ] Keyboard shortcuts
- [ ] Dark theme toggle
- [ ] Bookmark edit/delete from popup
- [ ] Batch operations
- [ ] Conflict resolution UI
- [ ] Offline queue for pending changes
- [ ] Auto-sync scheduler customization
- [ ] Gesture controls
- [ ] Mobile companion app
- [ ] Dark theme toggle
- [ ] Custom colors