feat: Update Step 7 with tool-based AI + Fix auth callback

Step 7 Updates (AI Chat with Structured Output):
- Created lib/ai-schemas.ts with Zod schema for NodeSuggestion
- Updated app/api/chat/route.ts:
  - Changed import from 'ai' to '@ai-sdk/react' for streamText
  - Added tools configuration with 'suggest_node' tool using NodeSuggestionSchema
  - Added persona support with dynamic system prompts
  - Extracts persona from request data object
- Rewrote app/chat/page.tsx:
  - Changed from server component to client component ('use client')
  - Uses useChat from '@ai-sdk/react' (fixes broken 'ai/react' import)
  - Added experimental_onToolCall handler for node suggestions
  - Redirects to /editor/new with AI-generated title/body as query params
  - Integrated MicrophoneRecorder for voice input
  - Added persona support (currently hardcoded to 'Socratic')
- Added tests/magnitude/07-chat.mag.ts with tests for:
  - Basic chat functionality
  - AI-triggered node suggestions with redirect to editor

Auth Callback Fixes:
- Fixed app/api/auth/callback/route.ts:
  - Changed to use agent.api.com.atproto.server.getSession() to fetch session
  - Previously used agent.getSession() which returned empty did/handle
  - Added user upsert to SurrealDB (INSERT...ON DUPLICATE KEY UPDATE)
  - Fixed variable references (session.did -> did, session.handle -> handle)
  - Properly creates user record before minting JWT

CLAUDE.md Updates:
- Added git commit HEREDOC syntax documentation for proper quote escaping
- Clarified that this project allows direct git commits (no PGP signatures)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-09 01:03:36 +00:00
parent c2f2d10ee1
commit e39f5b857e
6 changed files with 284 additions and 32 deletions

View File

@@ -3,7 +3,13 @@
This document outlines the standards and practices for the development of the
Ponderants application. The AI agent must adhere to these guidelines strictly.
**Git Commits**: For this project, you can skip PGP-signed commits and run git commands directly. You have permission to execute git add, git commit, and git push commands yourself.
**Git Commits**: For this project, you can skip PGP-signed commits and run git commands directly. You have permission to execute git add, git commit, and git push commands yourself. When writing commit messages with git commit -m, always use HEREDOC syntax with single quotes to properly escape special characters:
```bash
git commit -m "$(cat <<'EOF'
Your commit message here
EOF
)"
```
You are an expert-level, full-stack AI coding agent. Your task is to implement
the "Ponderants" application. Product Vision: Ponderants is an AI-powered