Fix lint errors

This commit is contained in:
Alex Gleason committed 2025-07-16 16:29:20 -05:00
1 parent 08024d2269
commit 96b7d31475
16 files changed
+152 -106

No files matched your search

+5
View File
@@ -3,6 +3,11 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shakespeare - AI-Powered Nostr Development</title>
<meta name="description" content="Build custom Nostr websites with AI assistance using Shakespeare, an AI-powered development environment">
<meta property="og:type" content="website">
<meta property="og:title" content="Shakespeare - AI-Powered Nostr Development">
<meta property="og:description" content="Build custom Nostr websites with AI assistance using Shakespeare, an AI-powered development environment">
<meta http-equiv="content-security-policy" content="default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'self' https:; font-src 'self'; base-uri 'self'; manifest-src 'self'; connect-src 'self' blob: https: wss:; img-src 'self' data: blob: https:; media-src 'self' https:">
<link rel="manifest" href="/manifest.webmanifest">
</head>
+10
View File
@@ -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",
+1
View File
@@ -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",
+21
View File
@@ -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"
}
]
}
+12 -6
View File
@@ -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<string, unknown>;
}
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
</Button>
</div>
<div className="flex-1 flex items-center justify-center">
<div className="text-center space-y-4">
<Bot className="h-12 w-12 mx-auto text-muted-foreground" />
@@ -389,7 +395,7 @@ When creating new components or pages, follow the existing patterns in the codeb
</div>
</div>
))}
{isLoading && (
<div className="flex gap-2">
<div className="w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0">
+1 -1
View File
@@ -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';
+24 -24
View File
@@ -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<FileNode[]>([]);
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<FileNode[]> => {
const buildFileTree = useCallback(async (projectId: string, dirPath: string): Promise<FileNode[]> => {
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 (
<div key={node.path}>
<div
@@ -132,7 +132,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
)}
<span className="text-sm truncate">{node.name}</span>
</div>
{node.type === 'directory' && node.isOpen && node.children && (
<div>
{node.children.map(child => renderNode(child, depth + 1))}
+15 -15
View File
@@ -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<string>('');
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) {
/>
</ScrollArea>
</div>
<div className="flex-1">
{selectedFile ? (
<FileEditor
-1
View File
@@ -53,7 +53,6 @@ export function AISettingsProvider({ children }: { children: ReactNode }) {
}
// eslint-disable-next-line react-refresh/only-export-components
export function useAISettings() {
const context = useContext(AISettingsContext);
if (!context) {
+1 -1
View File
@@ -13,7 +13,7 @@ const buildSchema = z.object({
projectId: z.string(),
});
export async function createAIChat(projectId: string, messages: any[]) {
export async function createAIChat(projectId: string, messages: Array<{ role: 'user' | 'assistant'; content: string }>) {
const result = await streamText({
model: openai('gpt-4-turbo-preview'),
messages,
+25 -24
View File
@@ -15,34 +15,34 @@ export interface BuildOperation {
export type AIToolOperation = FileOperation | BuildOperation;
export class AITools {
async executeOperation(operation: AIToolOperation): Promise<any> {
async executeOperation(operation: AIToolOperation): Promise<unknown> {
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<any> {
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<any> {
const structure: any = {};
async function buildStructure(currentPath: string, obj: any) {
async getProjectStructure(projectId: string): Promise<Record<string, unknown>> {
const structure: Record<string, unknown> = {};
async function buildStructure(currentPath: string, obj: Record<string, unknown>) {
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<string, unknown> = {};
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<Array<{path: string, content: string}>> {
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;
}
+9 -10
View File
@@ -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
}
}
+2 -2
View File
@@ -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/<font-name>';
// Using Inter Variable font for modern, clean typography
import '@fontsource-variable/inter';
createRoot(document.getElementById("root")!).render(<App />);
+8 -7
View File
@@ -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 (
<div className="min-h-screen flex items-center justify-center bg-gray-100 dark:bg-gray-900">
<div className="text-center">
<h1 className="text-4xl font-bold mb-4 text-gray-900 dark:text-gray-100">
Welcome to Your Blank App
Shakespeare
</h1>
<p className="text-xl text-gray-600 dark:text-gray-400">
Start building your amazing project here!
<p className="text-xl text-gray-600 dark:text-gray-400 mb-2">
AI-Powered Nostr Development
</p>
<p className="text-lg text-gray-500 dark:text-gray-500">
Build custom Nostr websites with AI assistance
</p>
</div>
</div>
+15 -15
View File
@@ -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() {
<p className="text-sm text-muted-foreground">{project.id}</p>
</div>
</div>
<div className="flex items-center space-x-2">
<AISettingsDialog />
<div className="flex space-x-2">
@@ -97,9 +97,9 @@ export function ProjectView() {
<ChatPane projectId={project.id} projectName={project.name} />
</div>
<div className="flex-1">
<PreviewPane
projectId={project.id}
activeTab={activeTab}
<PreviewPane
projectId={project.id}
activeTab={activeTab}
/>
</div>
</div>
+3
View File
@@ -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))',