From ab91a56da691c337c4ef9149e22d594123e9c8a1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 14 Oct 2025 20:53:32 -0500 Subject: [PATCH 1/4] Make Nostr git servers configurable --- src/App.tsx | 1 + src/components/AppProvider.tsx | 1 + src/components/GitDialog.tsx | 8 +-- src/components/NostrProvider.tsx | 10 +--- src/contexts/AppContext.ts | 2 + src/hooks/useAIProjectId.test.ts | 1 + src/hooks/useGit.test.ts | 4 ++ src/hooks/useGit.ts | 6 +- src/hooks/useGitHubOAuth.test.ts | 1 + src/lib/git.ts | 11 ++-- src/lib/i18n.ts | 24 ++++++++ src/pages/NostrSettings.tsx | 97 +++++++++++++++++++++++++++++++- src/test/TestApp.tsx | 1 + 13 files changed, 145 insertions(+), 22 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 09bc4ae0..c7f641ce 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -49,6 +49,7 @@ const defaultConfig: AppConfig = { previewDomain: "local-shakespeare.dev", showcaseEnabled: true, showcaseModerator: "npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc", + ngitServers: ["git.shakespeare.diy", "relay.ngit.dev"], }; const presetRelays = [ diff --git a/src/components/AppProvider.tsx b/src/components/AppProvider.tsx index 9c2370be..cb048ea4 100644 --- a/src/components/AppProvider.tsx +++ b/src/components/AppProvider.tsx @@ -26,6 +26,7 @@ const AppConfigSchema = z.object({ language: z.string(), showcaseEnabled: z.boolean(), showcaseModerator: z.string(), + ngitServers: z.array(z.string()), }) satisfies z.ZodType; export function AppProvider(props: AppProviderProps) { diff --git a/src/components/GitDialog.tsx b/src/components/GitDialog.tsx index 1e4f4df9..d24cf90f 100644 --- a/src/components/GitDialog.tsx +++ b/src/components/GitDialog.tsx @@ -52,6 +52,7 @@ import { useToast } from '@/hooks/useToast'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useNostr } from '@nostrify/react'; import { useNostrPublish } from '@/hooks/useNostrPublish'; +import { useAppContext } from '@/hooks/useAppContext'; import { cn } from '@/lib/utils'; import { findCredentialsForRepo } from '@/lib/gitCredentials'; import { nip19 } from 'nostr-tools'; @@ -59,8 +60,6 @@ import { GitManagementDialog } from '@/components/git/GitManagementDialog'; import { MergeDialog } from '@/components/git/MergeDialog'; import { PullRequestDialog } from '@/components/git/PullRequestDialog'; -const GRASP_SERVERS = ["git.shakespeare.diy", "relay.ngit.dev"]; - interface GitDialogProps { projectId: string; children?: React.ReactNode; @@ -92,6 +91,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog const { user } = useCurrentUser(); const { nostr } = useNostr(); const { mutateAsync: publishEvent } = useNostrPublish(); + const { config } = useAppContext(); const projectPath = `/projects/${projectId}`; @@ -299,10 +299,10 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog } // Create repo announcement event (NIP-34 kind 30617) - const cloneUrls = GRASP_SERVERS.map(server => + const cloneUrls = config.ngitServers.map(server => `https://${server}/${nip19.npubEncode(user.pubkey)}/${projectId}.git` ); - const relayUrls = GRASP_SERVERS.map(server => `wss://${server}`); + const relayUrls = config.ngitServers.map(server => `wss://${server}`); await publishEvent({ kind: 30617, diff --git a/src/components/NostrProvider.tsx b/src/components/NostrProvider.tsx index b902f297..9a63edbc 100644 --- a/src/components/NostrProvider.tsx +++ b/src/components/NostrProvider.tsx @@ -15,15 +15,11 @@ const GIT_KINDS = [ 1621, // NIP-34 Issue ]; -const GIT_RELAYS = [ - 'wss://git.shakespeare.diy/', - 'wss://relay.ngit.dev/', -]; - const NostrProvider: React.FC = (props) => { const { children } = props; const { config, presetRelays } = useAppContext(); + const gitRelays = config.ngitServers.map(server => `wss://${server}/`); const queryClient = useQueryClient(); // Create NPool instance only once @@ -50,7 +46,7 @@ const NostrProvider: React.FC = (props) => { if (filters.every((f) => f.kinds?.every((k) => GIT_KINDS.includes(k)))) { // If all filters are git-related, route to all git relays - for (const url of GIT_RELAYS) { + for (const url of gitRelays) { routes.set(url, filters); } } @@ -62,7 +58,7 @@ const NostrProvider: React.FC = (props) => { // If it's a git-related event, also publish to the git relays if (GIT_KINDS.includes(event.kind)) { - for (const url of GIT_RELAYS) { + for (const url of gitRelays) { allRelays.add(url); } } diff --git a/src/contexts/AppContext.ts b/src/contexts/AppContext.ts index de6c8372..160afd03 100644 --- a/src/contexts/AppContext.ts +++ b/src/contexts/AppContext.ts @@ -23,6 +23,8 @@ export interface AppConfig { showcaseEnabled: boolean; /** Npub of the showcase moderator */ showcaseModerator: string; + /** Nostr Git Servers (hostnames) */ + ngitServers: string[]; } export interface AppContextType { diff --git a/src/hooks/useAIProjectId.test.ts b/src/hooks/useAIProjectId.test.ts index 2d733d9c..7f82a42c 100644 --- a/src/hooks/useAIProjectId.test.ts +++ b/src/hooks/useAIProjectId.test.ts @@ -49,6 +49,7 @@ describe('useAIProjectId', () => { previewDomain: 'local-shakespeare.dev', showcaseEnabled: true, showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc', + ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'], }, updateConfig: vi.fn(), }); diff --git a/src/hooks/useGit.test.ts b/src/hooks/useGit.test.ts index 14bdcf4d..5337030f 100644 --- a/src/hooks/useGit.test.ts +++ b/src/hooks/useGit.test.ts @@ -41,6 +41,7 @@ function createWrapper(corsProxy: string) { previewDomain: 'local-test.dev', showcaseEnabled: true, showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc', + ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'], }; return createElement( @@ -81,6 +82,7 @@ describe('useGit', () => { fs: mockFS, nostr: mockNostr, corsProxy: 'https://cors.isomorphic-git.org', + ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'], }); expect(result.current).toEqual({ git: expect.any(Object) }); }); @@ -94,6 +96,7 @@ describe('useGit', () => { fs: mockFS, nostr: mockNostr, corsProxy: 'https://custom-cors.example.com', + ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'], }); expect(result.current).toEqual({ git: expect.any(Object) }); }); @@ -107,6 +110,7 @@ describe('useGit', () => { fs: mockFS, nostr: mockNostr, corsProxy: 'https://cors.isomorphic-git.org', + ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'], }); // Rerender with a different wrapper (different CORS proxy) diff --git a/src/hooks/useGit.ts b/src/hooks/useGit.ts index 52e689ba..66116b6e 100644 --- a/src/hooks/useGit.ts +++ b/src/hooks/useGit.ts @@ -12,11 +12,11 @@ export function useGit(): { git: Git } { const { fs } = useFS(); const { nostr } = useNostr(); const { config } = useAppContext(); - const { corsProxy } = config; + const { corsProxy, ngitServers } = config; const git = useMemo(() => { - return new Git({ fs, nostr, corsProxy }); - }, [fs, nostr, corsProxy]); + return new Git({ fs, nostr, corsProxy, ngitServers }); + }, [fs, nostr, corsProxy, ngitServers]); return { git }; } \ No newline at end of file diff --git a/src/hooks/useGitHubOAuth.test.ts b/src/hooks/useGitHubOAuth.test.ts index bdd18fc2..596e686f 100644 --- a/src/hooks/useGitHubOAuth.test.ts +++ b/src/hooks/useGitHubOAuth.test.ts @@ -22,6 +22,7 @@ function Wrapper({ children }: { children: React.ReactNode }) { previewDomain: 'local-test.dev', showcaseEnabled: true, showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc', + ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'], }; return createElement( diff --git a/src/lib/git.ts b/src/lib/git.ts index 55f96b6f..6a889957 100644 --- a/src/lib/git.ts +++ b/src/lib/git.ts @@ -10,6 +10,7 @@ export interface GitOptions { fs: JSRuntimeFS; nostr: NPool; corsProxy?: string; + ngitServers?: string[]; } interface NostrCloneURI { @@ -28,11 +29,13 @@ export class Git { private fs: JSRuntimeFS; private http: HttpClient; private nostr: NPool; + private ngitServers: string[]; constructor(options: GitOptions) { this.fs = options.fs; this.http = new GitHttp(options.corsProxy); this.nostr = options.nostr; + this.ngitServers = options.ngitServers ?? ['git.shakespeare.diy', 'relay.ngit.dev']; } // Repository initialization and configuration @@ -938,11 +941,7 @@ export class Git { '#d': [nostrURI.d], }; - const gitRelays = new Set([ - 'wss://git.shakespeare.diy/', - 'wss://relay.ngit.dev/', - 'wss://relay.nostr.band/', // General purpose relay as fallback - ]); + const gitRelays = this.ngitServers.map(server => `wss://${server}/`); let events: NostrEvent[] = []; @@ -956,7 +955,7 @@ export class Git { } if (!events.length) { try { - events = await this.nostr.group([...gitRelays]).query([filter], { signal: AbortSignal.timeout(5000) }); + events = await this.nostr.group(gitRelays).query([filter], { signal: AbortSignal.timeout(5000) }); } catch (error) { console.error(`Error querying group relays: ${error}`); } diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index 2e3d26b6..69391b87 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -312,6 +312,10 @@ const resources = { addAccount: 'Add Account', relayConfiguration: 'Relay Configuration', selectedRelay: 'Selected Relay', + nostrGitServers: 'Nostr Git Servers', + addServer: 'Add Server', + serverHostname: 'Server Hostname', + enterHostname: 'Enter hostname (e.g., git.shakespeare.diy)', // Clone Page cloneGitRepository: 'Clone a Git repository into your Shakespeare workspace', @@ -638,6 +642,10 @@ const resources = { addAccount: 'Adicionar Conta', relayConfiguration: 'Configuração de Relay', selectedRelay: 'Relay Selecionado', + nostrGitServers: 'Servidores Git Nostr', + addServer: 'Adicionar Servidor', + serverHostname: 'Nome do Servidor', + enterHostname: 'Digite o nome do host (ex: git.shakespeare.diy)', // Clone Page cloneGitRepository: 'Clone um repositório Git para seu workspace Shakespeare', @@ -964,6 +972,10 @@ const resources = { addAccount: '添加账户', relayConfiguration: '中继配置', selectedRelay: '选定的中继', + nostrGitServers: 'Nostr Git服务器', + addServer: '添加服务器', + serverHostname: '服务器主机名', + enterHostname: '输入主机名(例如:git.shakespeare.diy)', // Clone Page cloneGitRepository: '将Git仓库克隆到您的Shakespeare工作空间', @@ -1290,6 +1302,10 @@ const resources = { addAccount: 'Ƙara Asusu', relayConfiguration: 'Saitunan Relay', selectedRelay: 'Relay da aka zaɓa', + nostrGitServers: 'Sabar Git na Nostr', + addServer: 'Ƙara Sabar', + serverHostname: 'Sunan Sabar', + enterHostname: 'Shigar da sunan mai masaukin baki (misali: git.shakespeare.diy)', // Clone Page cloneGitRepository: 'Clone repository na Git zuwa wurin aikin Shakespeare', @@ -1611,6 +1627,10 @@ const resources = { addAccount: 'Fi Akọọlẹ kun', relayConfiguration: 'Iṣeto Relay', selectedRelay: 'Relay Ti a Yan', + nostrGitServers: 'Awọn olupin Git Nostr', + addServer: 'Fi Olupin kun', + serverHostname: 'Orukọ Olupin', + enterHostname: 'Tẹ orukọ ile-ipamọ sii (fun apẹẹrẹ: git.shakespeare.diy)', // Clone Page cloneGitRepository: 'Clone repository Git si aaye iṣẹ Shakespeare rẹ', @@ -1932,6 +1952,10 @@ const resources = { addAccount: 'Tinye Akaụntụ', relayConfiguration: 'Nhazi Relay', selectedRelay: 'Relay Ahọrọ', + nostrGitServers: 'Ndị sava Git Nostr', + addServer: 'Tinye Sava', + serverHostname: 'Aha Sava', + enterHostname: 'Tinye aha ọbịa (ọmụmaatụ: git.shakespeare.diy)', // Clone Page cloneGitRepository: 'Clone repository Git n\'ogige ọrụ Shakespeare gị', diff --git a/src/pages/NostrSettings.tsx b/src/pages/NostrSettings.tsx index 41de533e..1bad8e30 100644 --- a/src/pages/NostrSettings.tsx +++ b/src/pages/NostrSettings.tsx @@ -1,8 +1,9 @@ -import { ArrowLeft, Wifi, Users, UserPlus, LogOut, Trash2, User, Plus } from 'lucide-react'; +import { ArrowLeft, Wifi, Users, UserPlus, LogOut, Trash2, User, Plus, Server, X } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { Input } from '@/components/ui/input'; +import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Skeleton } from '@/components/ui/skeleton'; import { RelaySelector } from '@/components/RelaySelector'; @@ -13,6 +14,7 @@ import { useNavigate } from 'react-router-dom'; import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts'; import { genUserName } from '@/lib/genUserName'; import { useState } from 'react'; +import { useAppContext } from '@/hooks/useAppContext'; export function NostrSettings() { const { t } = useTranslation(); @@ -21,6 +23,8 @@ export function NostrSettings() { const { authors, currentUser, setLogin, removeLogin, isLoading } = useLoggedInAccounts(); const [showLoginDialog, setShowLoginDialog] = useState(false); const [showSignupDialog, setShowSignupDialog] = useState(false); + const { config, updateConfig } = useAppContext(); + const [newServerHostname, setNewServerHostname] = useState(''); const handleSwitchAccount = (accountId: string) => { setLogin(accountId); @@ -42,6 +46,30 @@ export function NostrSettings() { return account.metadata?.name ?? genUserName(account.pubkey); }; + const handleAddServer = () => { + const hostname = newServerHostname.trim(); + if (!hostname) return; + + // Basic validation - check if it's a valid hostname format + if (!/^[a-zA-Z0-9][a-zA-Z0-9-_.]*[a-zA-Z0-9]$/.test(hostname)) { + return; + } + + updateConfig((current) => ({ + ...current, + ngitServers: [...(current.ngitServers ?? config.ngitServers), hostname], + })); + + setNewServerHostname(''); + }; + + const handleRemoveServer = (hostname: string) => { + updateConfig((current) => ({ + ...current, + ngitServers: (current.ngitServers ?? config.ngitServers).filter(s => s !== hostname), + })); + }; + return (
{isMobile && ( @@ -202,6 +230,71 @@ export function NostrSettings() {
+ + {/* Nostr Git Servers */} + + + + + {t('nostrGitServers')} + + + + {/* Server List */} +
+ {config.ngitServers.map((hostname) => ( +
+ + + {hostname} + + +
+ ))} +
+ + {/* Add Server Form */} +
+
+ + setNewServerHostname(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter') { + handleAddServer(); + } + }} + /> +
+ +
+
+
{/* Login Dialog */} diff --git a/src/test/TestApp.tsx b/src/test/TestApp.tsx index b960a3ee..3b329d77 100644 --- a/src/test/TestApp.tsx +++ b/src/test/TestApp.tsx @@ -38,6 +38,7 @@ export function TestApp({ children }: TestAppProps) { language: 'en', showcaseEnabled: true, showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc', + ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'], }; // Initialize LightningFS for testing From cd59d57db92816f8b0f0bac175c751b2f46ad5db Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 14 Oct 2025 20:56:29 -0500 Subject: [PATCH 2/4] Fix lint --- src/pages/NostrSettings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/NostrSettings.tsx b/src/pages/NostrSettings.tsx index 1bad8e30..222a454c 100644 --- a/src/pages/NostrSettings.tsx +++ b/src/pages/NostrSettings.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'; import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; import { Input } from '@/components/ui/input'; -import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Skeleton } from '@/components/ui/skeleton'; import { RelaySelector } from '@/components/RelaySelector'; From b6a1ba0b5931bb655e204d001df4741a8b84f72d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 14 Oct 2025 21:48:55 -0500 Subject: [PATCH 3/4] Fix tab title --- AGENTS.md | 4 ++-- src/components/OnboardingDialog.tsx | 2 +- src/pages/Index.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 96b38e86..3aa30b40 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ -# Shakespeare - AI-Powered Nostr Website Builder +# Shakespeare - AI-Powered App Builder -Shakespeare is a browser-based AI chat application that allows users to build custom Nostr websites through natural language conversation. All operations including AI chat and Git operations are executed in client-side JavaScript, with API keys stored in browser storage. Simply describe what you want to build, and AI will help you create it. +Shakespeare is a browser-based AI chat application that allows users to build custom web applications through natural language conversation. All operations including AI chat and Git operations are executed in client-side JavaScript, with API keys stored in browser storage. Simply describe what you want to build, and AI will help you create it. ### Virtual Filesystem Layout diff --git a/src/components/OnboardingDialog.tsx b/src/components/OnboardingDialog.tsx index 4788a413..de474787 100644 --- a/src/components/OnboardingDialog.tsx +++ b/src/components/OnboardingDialog.tsx @@ -222,7 +222,7 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps) Welcome to Shakespeare!

- Your AI-powered development assistant for building custom Nostr applications. + Your AI-powered development assistant for building custom applications. Simply describe what you want to build, and AI will help you create it.

diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index e0e5ac9f..da810cbe 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -57,8 +57,8 @@ export default function Index() { }, [providerModel, settings.recentlyUsedModels]); useSeoMeta({ - title: 'Shakespeare - AI-Powered Nostr Development', - description: 'Build custom Nostr websites with AI assistance using Shakespeare, an AI-powered development environment.', + title: 'Shakespeare - Open Source AI Builder', + description: 'Build custom apps with AI assistance using Shakespeare, an AI-powered development environment.', }); // Restore prompt from local storage on mount From 460132ff396289d176894617256ecb134851224e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 14 Oct 2025 23:28:16 -0500 Subject: [PATCH 4/4] Don't display Quilly while the assistant is loading --- src/components/Shakespeare/ChatPane.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 23a445e6..3ab1648e 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -645,8 +645,8 @@ export const ChatPane = forwardRef(({ )} - {/* Error Alert (Console or AI) */} - {displayError && ( + {/* Error Alert (Console or AI) - Don't show while assistant is loading */} + {displayError && !isLoading && (