From 96b7d31475f3cb88f99a3a7d2676bfe6bf221769 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 16 Jul 2025 16:29:20 -0500 Subject: [PATCH] Fix lint errors --- index.html | 5 +++ package-lock.json | 10 +++++ package.json | 1 + public/manifest.webmanifest | 21 ++++++++++ src/components/Shakespeare/ChatPane.tsx | 18 +++++--- src/components/Shakespeare/FileEditor.tsx | 2 +- src/components/Shakespeare/FileTree.tsx | 48 ++++++++++----------- src/components/Shakespeare/PreviewPane.tsx | 30 ++++++------- src/contexts/AISettingsContext.tsx | 1 - src/lib/ai-chat.ts | 2 +- src/lib/ai-tools.ts | 49 +++++++++++----------- src/lib/fs.ts | 19 ++++----- src/main.tsx | 4 +- src/pages/Index.tsx | 15 +++---- src/pages/ProjectView.tsx | 30 ++++++------- tailwind.config.ts | 3 ++ 16 files changed, 152 insertions(+), 106 deletions(-) create mode 100644 public/manifest.webmanifest diff --git a/index.html b/index.html index cd5ada1b..5d5ea381 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,11 @@ + Shakespeare - AI-Powered Nostr Development + + + + diff --git a/package-lock.json b/package-lock.json index 16fccb77..d2351c19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "dependencies": { "@ai-sdk/openai": "^1.3.23", + "@fontsource-variable/inter": "^5.2.6", "@hookform/resolvers": "^3.9.0", "@isomorphic-git/lightning-fs": "^4.6.2", "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.46.4", @@ -1081,6 +1082,15 @@ "integrity": "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==", "license": "MIT" }, + "node_modules/@fontsource-variable/inter": { + "version": "5.2.6", + "resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.2.6.tgz", + "integrity": "sha512-jks/bficUPQ9nn7GvXvHtlQIPudW7Wx8CrlZoY8bhxgeobNxlQan8DclUJuYF2loYRrGpfrhCIZZspXYysiVGg==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, "node_modules/@hookform/resolvers": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-3.10.0.tgz", diff --git a/package.json b/package.json index 65fb421c..01552b7e 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "@ai-sdk/openai": "^1.3.23", + "@fontsource-variable/inter": "^5.2.6", "@hookform/resolvers": "^3.9.0", "@isomorphic-git/lightning-fs": "^4.6.2", "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.46.4", diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest new file mode 100644 index 00000000..5a17280c --- /dev/null +++ b/public/manifest.webmanifest @@ -0,0 +1,21 @@ +{ + "name": "Shakespeare - AI-Powered Nostr Development", + "short_name": "Shakespeare", + "description": "Build custom Nostr websites with AI assistance", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "icons": [ + { + "src": "/icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} \ No newline at end of file diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 611c716b..6b02c5fd 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -10,12 +10,18 @@ import { useAISettings } from '@/contexts/AISettingsContext'; import { aiTools } from '@/lib/ai-tools'; import { z } from 'zod'; +interface ToolCall { + toolCallId: string; + toolName: string; + args: Record; +} + interface Message { id: string; role: 'user' | 'assistant'; content: string; timestamp: Date; - toolCalls?: any[]; + toolCalls?: ToolCall[]; } interface ChatPaneProps { @@ -48,7 +54,7 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) { } }, [messages]); - const createAIChat = async (projectId: string, messages: any[]) => { + const createAIChat = async (projectId: string, messages: Array<{ role: 'user' | 'assistant'; content: string }>) => { if (!isConfigured) { throw new Error('AI settings not configured'); } @@ -224,9 +230,9 @@ When creating new components or pages, follow the existing patterns in the codeb ]; const result = await createAIChat(projectId, aiMessages); - + let assistantContent = ''; - const toolCalls: any[] = []; + const toolCalls: ToolCall[] = []; for await (const part of result.fullStream) { if (part.type === 'text-delta') { @@ -290,7 +296,7 @@ When creating new components or pages, follow the existing patterns in the codeb Settings - +
@@ -389,7 +395,7 @@ When creating new components or pages, follow the existing patterns in the codeb
))} - + {isLoading && (
diff --git a/src/components/Shakespeare/FileEditor.tsx b/src/components/Shakespeare/FileEditor.tsx index 35c77972..e84baa0f 100644 --- a/src/components/Shakespeare/FileEditor.tsx +++ b/src/components/Shakespeare/FileEditor.tsx @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Save, Loader2 } from 'lucide-react'; import { cn } from '@/lib/utils'; diff --git a/src/components/Shakespeare/FileTree.tsx b/src/components/Shakespeare/FileTree.tsx index dca30883..d3f8fc57 100644 --- a/src/components/Shakespeare/FileTree.tsx +++ b/src/components/Shakespeare/FileTree.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { fsManager } from '@/lib/fs'; import { ChevronRight, ChevronDown, File, Folder } from 'lucide-react'; import { cn } from '@/lib/utils'; @@ -21,33 +21,17 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp const [tree, setTree] = useState([]); const [isLoading, setIsLoading] = useState(true); - useEffect(() => { - loadFileTree(); - }, [projectId]); - - const loadFileTree = async () => { - setIsLoading(true); - try { - const structure = await buildFileTree(projectId, ''); - setTree(structure); - } catch (error) { - console.error('Failed to load file tree:', error); - } finally { - setIsLoading(false); - } - }; - - const buildFileTree = async (projectId: string, dirPath: string): Promise => { + const buildFileTree = useCallback(async (projectId: string, dirPath: string): Promise => { const items = await fsManager.listFiles(projectId, dirPath); const nodes: FileNode[] = []; for (const item of items) { const itemPath = dirPath ? `${dirPath}/${item}` : item; const fullPath = `${fsManager['dir']}/${projectId}/${itemPath}`; - + try { const stat = await fsManager['fs'].promises.stat(fullPath); - + if (stat.isDirectory()) { const children = await buildFileTree(projectId, itemPath); nodes.push({ @@ -64,7 +48,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp type: 'file', }); } - } catch (error) { + } catch { // Skip inaccessible items } } @@ -75,7 +59,23 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp } return a.name.localeCompare(b.name); }); - }; + }, [projectId]); + + const loadFileTree = useCallback(async () => { + setIsLoading(true); + try { + const structure = await buildFileTree(projectId, ''); + setTree(structure); + } catch (_error) { + console.error('Failed to load file tree:', _error); + } finally { + setIsLoading(false); + } + }, [projectId, buildFileTree]); + + useEffect(() => { + loadFileTree(); + }, [loadFileTree]); const toggleDirectory = (path: string) => { const toggleNode = (nodes: FileNode[]): FileNode[] => { @@ -103,7 +103,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp const renderNode = (node: FileNode, depth: number = 0) => { const isSelected = selectedFile === node.path; - + return (
{node.name}
- + {node.type === 'directory' && node.isOpen && node.children && (
{node.children.map(child => renderNode(child, depth + 1))} diff --git a/src/components/Shakespeare/PreviewPane.tsx b/src/components/Shakespeare/PreviewPane.tsx index aa018c92..e382352e 100644 --- a/src/components/Shakespeare/PreviewPane.tsx +++ b/src/components/Shakespeare/PreviewPane.tsx @@ -1,8 +1,8 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { fsManager } from '@/lib/fs'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; +import { Tabs, TabsContent } from '@/components/ui/tabs'; import { ScrollArea } from '@/components/ui/scroll-area'; -import { Card } from '@/components/ui/card'; + import { FileTree } from './FileTree'; import { FileEditor } from './FileEditor'; @@ -16,24 +16,24 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { const [fileContent, setFileContent] = useState(''); const [isLoading, setIsLoading] = useState(false); - useEffect(() => { - if (selectedFile) { - loadFileContent(selectedFile); - } - }, [selectedFile, projectId]); - - const loadFileContent = async (filePath: string) => { + const loadFileContent = useCallback(async (filePath: string) => { setIsLoading(true); try { const content = await fsManager.readFile(projectId, filePath); setFileContent(content); - } catch (error) { - console.error('Failed to load file:', error); + } catch (_error) { + console.error('Failed to load file:', _error); setFileContent(''); } finally { setIsLoading(false); } - }; + }, [projectId]); + + useEffect(() => { + if (selectedFile) { + loadFileContent(selectedFile); + } + }, [selectedFile, loadFileContent]); const handleFileSelect = (filePath: string) => { setSelectedFile(filePath); @@ -41,7 +41,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { const handleFileSave = async (content: string) => { if (!selectedFile) return; - + try { await fsManager.writeFile(projectId, selectedFile, content); setFileContent(content); @@ -83,7 +83,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { />
- +
{selectedFile ? ( ) { const result = await streamText({ model: openai('gpt-4-turbo-preview'), messages, diff --git a/src/lib/ai-tools.ts b/src/lib/ai-tools.ts index cc04e3de..969ad2c3 100644 --- a/src/lib/ai-tools.ts +++ b/src/lib/ai-tools.ts @@ -15,34 +15,34 @@ export interface BuildOperation { export type AIToolOperation = FileOperation | BuildOperation; export class AITools { - async executeOperation(operation: AIToolOperation): Promise { + async executeOperation(operation: AIToolOperation): Promise { try { switch (operation.type) { case 'read': return await this.readFile(operation.projectId, operation.filePath); - + case 'write': if (!operation.content) { throw new Error('Content is required for write operations'); } await this.writeFile(operation.projectId, operation.filePath, operation.content); return { success: true, message: 'File written successfully' }; - + case 'delete': await this.deleteFile(operation.projectId, operation.filePath); return { success: true, message: 'File deleted successfully' }; - + case 'list': return await this.listFiles(operation.projectId, operation.filePath); - + case 'exists': return await this.fileExists(operation.projectId, operation.filePath); - + case 'build': return await this.buildProject(operation.projectId); - + default: - throw new Error(`Unknown operation type: ${(operation as any).type}`); + throw new Error(`Unknown operation type: ${(operation as { type: string }).type}`); } } catch (error) { return { error: error.message }; @@ -69,7 +69,7 @@ export class AITools { return await fsManager.fileExists(projectId, filePath); } - private async buildProject(projectId: string): Promise { + private async buildProject(projectId: string): Promise<{ success: boolean; message: string; url: string }> { // TODO: Implement Vite build in browser // For now, return a stub return { @@ -79,44 +79,45 @@ export class AITools { }; } - async getProjectStructure(projectId: string): Promise { - const structure: any = {}; - - async function buildStructure(currentPath: string, obj: any) { + async getProjectStructure(projectId: string): Promise> { + const structure: Record = {}; + + async function buildStructure(currentPath: string, obj: Record) { const items = await fsManager.listFiles(projectId, currentPath); - + for (const item of items) { const itemPath = currentPath ? `${currentPath}/${item}` : item; const fullPath = `${fsManager['dir']}/${projectId}/${itemPath}`; - + try { const stat = await fsManager['fs'].promises.stat(fullPath); if (stat.isDirectory()) { - obj[item] = {}; - await buildStructure(itemPath, obj[item]); + const newObj: Record = {}; + obj[item] = newObj; + await buildStructure(itemPath, newObj); } else { obj[item] = 'file'; } - } catch (error) { + } catch { // Skip inaccessible items } } } - + await buildStructure('', structure); return structure; } async searchFiles(projectId: string, query: string): Promise> { const results: Array<{path: string, content: string}> = []; - + async function searchDirectory(dirPath: string) { const items = await fsManager.listFiles(projectId, dirPath); - + for (const item of items) { const itemPath = dirPath ? `${dirPath}/${item}` : item; const fullPath = `${fsManager['dir']}/${projectId}/${itemPath}`; - + try { const stat = await fsManager['fs'].promises.stat(fullPath); if (stat.isDirectory()) { @@ -127,12 +128,12 @@ export class AITools { results.push({ path: itemPath, content }); } } - } catch (error) { + } catch { // Skip inaccessible files } } } - + await searchDirectory(''); return results; } diff --git a/src/lib/fs.ts b/src/lib/fs.ts index 94d02830..dc086ec9 100644 --- a/src/lib/fs.ts +++ b/src/lib/fs.ts @@ -5,7 +5,7 @@ import { Buffer } from 'buffer'; // Polyfill Buffer for browser if (typeof window !== 'undefined') { - (window as any).Buffer = Buffer; + (window as { Buffer?: typeof Buffer }).Buffer = Buffer; } export interface Project { @@ -28,7 +28,7 @@ export class FileSystemManager { async init() { try { await this.fs.promises.mkdir(this.dir); - } catch (error) { + } catch { // Directory might already exist } } @@ -71,8 +71,7 @@ export class FileSystemManager { singleBranch: true, depth: 1, }); - } catch (error) { - console.error('Failed to clone template:', error); + } catch { // Create basic structure if clone fails await this.createBasicStructure(projectPath); } @@ -146,7 +145,7 @@ export default defineConfig({ const dir = filePath.split('/').slice(0, -1).join('/'); try { await this.fs.promises.mkdir(dir); - } catch (error) { + } catch { // Directory might already exist } await this.fs.promises.writeFile(filePath, content); @@ -170,13 +169,13 @@ export default defineConfig({ createdAt: new Date(project.createdAt), lastModified: new Date(project.lastModified), }); - } catch (error) { + } catch { // Skip invalid projects } } return projects.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()); - } catch (error) { + } catch { return []; } } @@ -191,7 +190,7 @@ export default defineConfig({ createdAt: new Date(project.createdAt), lastModified: new Date(project.lastModified), }; - } catch (error) { + } catch { return null; } } @@ -221,7 +220,7 @@ export default defineConfig({ const fullPath = `${this.dir}/${projectId}/${dirPath}`; try { return await this.fs.promises.readdir(fullPath); - } catch (error) { + } catch { return []; } } @@ -252,7 +251,7 @@ export default defineConfig({ const project = JSON.parse(projectData); project.lastModified = new Date().toISOString(); await this.fs.promises.writeFile(projectFile, JSON.stringify(project, null, 2)); - } catch (error) { + } catch { // Ignore errors updating last modified } } diff --git a/src/main.tsx b/src/main.tsx index f322051d..5dfd85d9 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -6,7 +6,7 @@ import './lib/polyfills.ts'; import App from './App.tsx'; import './index.css'; -// FIXME: a custom font should be used. Eg: -// import '@fontsource-variable/'; +// Using Inter Variable font for modern, clean typography +import '@fontsource-variable/inter'; createRoot(document.getElementById("root")!).render(); diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 4427de5d..c0df58b5 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -1,21 +1,22 @@ import { useSeoMeta } from '@unhead/react'; -// FIXME: Update this page (the content is just a fallback if you fail to update the page) - const Index = () => { useSeoMeta({ - title: 'Welcome to Your Blank App', - description: 'A modern Nostr client application built with React, TailwindCSS, and Nostrify.', + title: 'Shakespeare - AI-Powered Nostr Development', + description: 'Build custom Nostr websites with AI assistance using Shakespeare, an AI-powered development environment.', }); return (

- Welcome to Your Blank App + Shakespeare

-

- Start building your amazing project here! +

+ AI-Powered Nostr Development +

+

+ Build custom Nostr websites with AI assistance

diff --git a/src/pages/ProjectView.tsx b/src/pages/ProjectView.tsx index aaa4ad74..38326475 100644 --- a/src/pages/ProjectView.tsx +++ b/src/pages/ProjectView.tsx @@ -1,10 +1,10 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { useParams } from 'react-router-dom'; import { fsManager, type Project } from '@/lib/fs'; import { ChatPane } from '@/components/Shakespeare/ChatPane'; import { PreviewPane } from '@/components/Shakespeare/PreviewPane'; import { Button } from '@/components/ui/button'; -import { ArrowLeft, Settings } from 'lucide-react'; +import { ArrowLeft } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import { AISettingsDialog } from '@/components/ai/AISettingsDialog'; @@ -15,22 +15,22 @@ export function ProjectView() { const [activeTab, setActiveTab] = useState<'preview' | 'code'>('preview'); const navigate = useNavigate(); - useEffect(() => { - loadProject(); - }, [projectId]); - - const loadProject = async () => { + const loadProject = useCallback(async () => { if (!projectId) return; - + try { const projectData = await fsManager.getProject(projectId); setProject(projectData); - } catch (error) { - console.error('Failed to load project:', error); + } catch (_error) { + console.error('Failed to load project:', _error); } finally { setIsLoading(false); } - }; + }, [projectId]); + + useEffect(() => { + loadProject(); + }, [loadProject]); if (isLoading) { return ( @@ -70,7 +70,7 @@ export function ProjectView() {

{project.id}

- +
@@ -97,9 +97,9 @@ export function ProjectView() {
-
diff --git a/tailwind.config.ts b/tailwind.config.ts index 8ff25367..a555e6f6 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -19,6 +19,9 @@ export default { } }, extend: { + fontFamily: { + sans: ['Inter Variable', 'Inter', 'system-ui', 'sans-serif'], + }, colors: { border: 'hsl(var(--border))', input: 'hsl(var(--input))',