Files
app/package.json
Albert f8990008bc 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

53 lines
1.3 KiB
JSON

{
"name": "ponderants",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "npx magnitude"
},
"dependencies": {
"@ai-sdk/google": "latest",
"@ai-sdk/react": "latest",
"@atproto/api": "latest",
"@atproto/oauth-client-node": "^0.3.10",
"@deepgram/sdk": "latest",
"@google/generative-ai": "^0.24.1",
"@mantine/core": "latest",
"@mantine/form": "latest",
"@mantine/hooks": "latest",
"@mantine/notifications": "^8.3.6",
"@react-three/drei": "latest",
"@react-three/fiber": "latest",
"@tabler/icons-react": "^3.35.0",
"ai": "latest",
"jsonwebtoken": "latest",
"next": "latest",
"openid-client": "latest",
"react": "latest",
"react-dom": "latest",
"surrealdb": "latest",
"three": "latest",
"umap-js": "latest",
"zod": "latest"
},
"devDependencies": {
"@types/jsonwebtoken": "latest",
"@types/node": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"eslint": "latest",
"eslint-config-next": "latest",
"jiti": "^2.6.1",
"magnitude-test": "latest",
"playwright": "^1.56.1",
"postcss": "latest",
"postcss-preset-mantine": "latest",
"postcss-simple-vars": "latest",
"typescript": "latest"
}
}