Commit Graph

10 Commits

Author SHA1 Message Date
b457e94ccb chore: Add dotenv as devDependency
Added for potential use in development scripts and testing utilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 14:13:13 +00:00
6cce6403fb fix: Sync pnpm-lock.yaml with package.json React Three Fiber versions
Updates lockfile to match the specific versions of @react-three/drei,
@react-three/fiber, and three specified in package.json. This resolves
the ERR_PNPM_OUTDATED_LOCKFILE error during Vercel deployment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 20:27:53 +00:00
d0978f5f7f fix: Update embedding dimensions to 3072 and add Vercel Analytics
- Updated GOOGLE_EMBEDDING_DIMENSIONS to 3072 to match gemini-embedding-001 output
- Updated database schema embedding index from 768 to 3072 dimensions
- Recreated production database index with correct dimensions
- Added @vercel/analytics package for production analytics
- Added Analytics component to root layout

This fixes the galaxy visualization issue caused by dimension mismatch between
the embedding model output (3072) and the database index (768).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 19:00:37 +00:00
740d819622 fix: Resolve TypeScript build errors for production deployment
- Add type assertion for SurrealDB query results in debug/nodes route
- Install @types/three for Three.js type definitions
- Exclude tests directory from TypeScript compilation
- Wrap useSearchParams in Suspense boundary on login page (Next.js 16 requirement)

All routes now build successfully for production deployment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 15:27:13 +00:00
0ed2d6c0b3 feat: Improve UI layout and navigation
- Increase logo size (48x48 desktop, 56x56 mobile) for better visibility
- Add logo as favicon
- Add logo to mobile header
- Move user menu to navigation bars (sidebar on desktop, bottom bar on mobile)
- Fix desktop chat layout - container structure prevents voice controls cutoff
- Fix mobile bottom bar - use icon-only ActionIcons instead of truncated text buttons
- Hide Create Node/New Conversation buttons on mobile to save header space
- Make fixed header and voice controls work properly with containers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 14:43:11 +00:00
684a6b53fa feat: Step 10 - Node Editor & AI-Powered Linking
Implemented the node editor page with AI-powered link suggestions using
vector similarity search. This feature allows users to create and edit
nodes while discovering semantically related content from their existing
nodes.

**Node Editor Page** (`app/editor/[id]/page.tsx`):
- Full-featured form with title and body fields using Mantine forms
- Pre-fill support from query parameters (for AI chat redirects)
- "Find Related" button to discover similar nodes via vector search
- "Publish Node" button to save nodes to ATproto + SurrealDB
- Real-time suggestions display with similarity scores
- Mantine notifications for user feedback

**Link Suggestion API** (`app/api/suggest-links/route.ts`):
- Authenticates using SurrealDB JWT from cookies
- Generates embeddings for draft text using Google AI (gemini-embedding-001)
- Performs vector similarity search using SurrealDB's cosine similarity
- Returns top 5 most similar nodes with scores
- Enforces row-level security (users can only search their own nodes)
- Comprehensive error handling with detailed logging

**UI Enhancements** (`app/layout.tsx`):
- Added @mantine/notifications package for toast notifications
- Integrated Notifications component into root layout
- Imported notifications styles for proper rendering

**Testing** (`tests/magnitude/10-linking.mag.ts`):
- Editor page rendering verification
- Pre-filled form from query params test
- Full publish workflow test (happy path)
- Form validation test (unhappy path)

**Technical Implementation**:
- Vector embeddings: 768-dimension vectors from gemini-embedding-001
- Similarity metric: Cosine similarity via SurrealDB vector functions
- Authentication: JWT-based with automatic row-level security
- Error handling: Proper HTTP status codes and user notifications
- Cookie domain: Uses 127.0.0.1 to match OAuth redirect URI

**Note**: Tests may fail if GOOGLE_AI_API_KEY is invalid. Update the key
in .env to enable full AI functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 02:15:38 +00:00
6ff6bae270 feat: Implement OAuth with DPoP using @atproto/oauth-client-node
Replace manual OAuth implementation with official @atproto/oauth-client-node library to properly support DPoP (Demonstrating Proof of Possession) authentication.

Changes:
- Added @atproto/oauth-client-node dependency
- Created OAuth state store (SurrealDB-backed) for CSRF protection
- Created OAuth session store (SurrealDB-backed) for token persistence
- Created OAuth client singleton with localhost exception for development
- Rewrote /api/auth/login to use client.authorize()
- Rewrote /api/auth/callback to use client.callback() with DPoP
- Updated lib/auth/session.ts with getAuthenticatedAgent() for ATproto API calls
- Updated db/schema.surql with oauth_state and oauth_session tables
- Added scripts/apply-schema.js for database schema management
- Created plans/oauth-dpop-implementation.md with detailed implementation plan
- Removed legacy lib/auth/atproto.ts and lib/auth/oauth-state.ts
- Updated .env to use localhost exception (removed BLUESKY_CLIENT_ID)

The OAuth client now handles:
- PKCE code generation and verification
- DPoP proof generation and signing
- Automatic token refresh
- Session persistence across server restarts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 01:40:04 +00:00
c2f2d10ee1 feat: Step 7 & 9 - AI Chat + Voice client integration
Implement AI-powered chat interface with voice input capabilities.

Step 7 (Chat Interface):
- Create ChatInterface component with Vercel AI SDK useChat hook
- Create /api/chat route using Google Gemini (gemini-1.5-flash)
- Implement thoughtful interviewer system prompt
- Add real-time message streaming
- Auto-scroll to latest messages

Step 9 (Voice Client):
- Create MicrophoneRecorder component
- Integrate real-time voice transcription via Deepgram
- Direct WebSocket connection using temporary tokens
- Real-time transcript display in chat input
- Auto-submit on speech_final event
- Add @tabler/icons-react for microphone icons

Architecture:
- Client requests temporary Deepgram token from /api/voice-token
- MediaRecorder captures audio in 250ms chunks
- WebSocket sends audio directly to Deepgram
- Transcripts update chat input in real-time
- Final transcript auto-submits to AI chat

Security:
- Deepgram API key never exposed to client
- Temporary tokens expire in 60 seconds
- Chat requires authentication via SurrealDB JWT

Testing:
- Add magnitude test for voice recording flow
- Tests cover happy path with mocked WebSocket

Known Issue:
- Page compilation needs debugging (useChat import path verified)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 00:27:40 +00:00
e43d6493d2 feat: Step 6 - Write-through cache API
Implement the core write-through cache pattern for node creation.
This is the architectural foundation of the application.

Changes:
- Add @google/generative-ai dependency for embeddings
- Create lib/db.ts: SurrealDB connection helper with JWT auth
- Create lib/ai.ts: AI embedding generation using text-embedding-004
- Create app/api/nodes/route.ts: POST endpoint implementing write-through cache

Write-through cache flow:
1. Authenticate user via SurrealDB JWT
2. Publish node to ATproto PDS (source of truth)
3. Generate 768-dimensional embedding via Google AI
4. Cache node + embedding + links in SurrealDB

Updated schema to use 768-dimensional embeddings (text-embedding-004)
instead of 1536 dimensions.

Security:
- Row-level permissions enforced via SurrealDB JWT
- All secrets server-side only
- ATproto OAuth tokens from secure cookies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 00:12:46 +00:00
e544c95f2f feat: Step 1 - Project setup & smoke test
Initialize Next.js 16 (App Router) project with all core dependencies:
- Next.js, React 19, TypeScript configuration
- Mantine UI components (@mantine/core, @mantine/hooks)
- ATproto SDK for Bluesky integration
- SurrealDB client (updated to latest non-deprecated version)
- Vercel AI SDK with Google AI provider
- Deepgram SDK for voice-to-text
- React Three Fiber for 3D visualization
- UMAP.js for dimensionality reduction
- Magnitude test framework for E2E testing
- Playwright for browser automation

Created basic app structure with homepage displaying "Ponderants" text.
Configured magnitude.config.ts for testing framework.
Added .example.env with all required environment variables.

Test: Smoke test verifies app boots and renders homepage.
Status: ✓ Test passed (8.4s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 20:38:55 +00:00