Merge remote-tracking branch 'origin/main' into nostr-git-support

This commit is contained in:
Alex Gleason committed 2025-10-15 14:59:02 -05:00
commit 6a456e64f0
17 files changed
+151 -28

No files matched your search

+1
View File
@@ -49,6 +49,7 @@ const defaultConfig: AppConfig = {
previewDomain: "local-shakespeare.dev",
showcaseEnabled: true,
showcaseModerator: "npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc",
ngitServers: ["git.shakespeare.diy", "relay.ngit.dev"],
};
const presetRelays = [
+1
View File
@@ -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<AppConfig>;
export function AppProvider(props: AppProviderProps) {
+4 -4
View File
@@ -55,6 +55,7 @@ import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useNostr } from '@nostrify/react';
import { useNostrPublish } from '@/hooks/useNostrPublish';
import { usePullRequests } from '@/hooks/usePullRequests';
import { useAppContext } from '@/hooks/useAppContext';
import { cn } from '@/lib/utils';
import { findCredentialsForRepo } from '@/lib/gitCredentials';
import { nip19 } from 'nostr-tools';
@@ -62,8 +63,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;
@@ -96,6 +95,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
const { nostr } = useNostr();
const { mutateAsync: publishEvent } = useNostrPublish();
const { data: pullRequests, isLoading: isLoadingPRs } = usePullRequests(originUrl);
const { config } = useAppContext();
const projectPath = `/projects/${projectId}`;
@@ -303,10 +303,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,
+3 -7
View File
@@ -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<NostrProviderProps> = (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<NostrProviderProps> = (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<NostrProviderProps> = (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);
}
}
+1 -1
View File
@@ -222,7 +222,7 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
Welcome to Shakespeare!
</h2>
<p className="text-lg text-muted-foreground max-w-md mx-auto">
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.
</p>
</div>
+2 -2
View File
@@ -645,8 +645,8 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
</div>
)}
{/* Error Alert (Console or AI) */}
{displayError && (
{/* Error Alert (Console or AI) - Don't show while assistant is loading */}
{displayError && !isLoading && (
<Quilly
error={displayError}
onDismiss={handleErrorDismiss}
+2
View File
@@ -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 {
+1
View File
@@ -49,6 +49,7 @@ describe('useAIProjectId', () => {
previewDomain: 'local-shakespeare.dev',
showcaseEnabled: true,
showcaseModerator: 'npub1jvnpg4c6ljadf5t6ry0w9q0rnm4mksde87kglkrc993z46c39axsgq89sc',
ngitServers: ['git.shakespeare.diy', 'relay.ngit.dev'],
},
updateConfig: vi.fn(),
});
+4
View File
@@ -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)
+3 -3
View File
@@ -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 };
}
+1
View File
@@ -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(
+5 -6
View File
@@ -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<string>([
'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}`);
}
+24
View File
@@ -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ị',
+2 -2
View File
@@ -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
+94 -1
View File
@@ -1,7 +1,8 @@
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 { Input } from '@/components/ui/input';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Skeleton } from '@/components/ui/skeleton';
@@ -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 (
<div className="p-6 space-y-6">
{isMobile && (
@@ -202,6 +230,71 @@ export function NostrSettings() {
</div>
</CardContent>
</Card>
{/* Nostr Git Servers */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Server className="h-5 w-5" />
{t('nostrGitServers')}
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
{/* Server List */}
<div className="space-y-2">
{config.ngitServers.map((hostname) => (
<div
key={hostname}
className="flex items-center gap-2 p-2 rounded-md border bg-muted/20"
>
<Server className="h-4 w-4 text-muted-foreground shrink-0" />
<span className="font-mono text-sm flex-1 truncate">
{hostname}
</span>
<Button
variant="ghost"
size="icon"
onClick={() => handleRemoveServer(hostname)}
className="h-8 w-8 p-0 text-muted-foreground hover:text-destructive hover:bg-transparent shrink-0"
disabled={config.ngitServers.length <= 1}
>
<X className="h-4 w-4" />
</Button>
</div>
))}
</div>
{/* Add Server Form */}
<div className="flex gap-2">
<div className="flex-1">
<Label htmlFor="new-server-hostname" className="sr-only">
{t('serverHostname')}
</Label>
<Input
id="new-server-hostname"
placeholder={t('enterHostname')}
value={newServerHostname}
onChange={(e) => setNewServerHostname(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
handleAddServer();
}
}}
/>
</div>
<Button
onClick={handleAddServer}
disabled={!newServerHostname.trim()}
variant="outline"
size="sm"
className="h-10 shrink-0"
>
<Plus className="h-4 w-4 mr-2" />
{t('addServer')}
</Button>
</div>
</CardContent>
</Card>
</div>
{/* Login Dialog */}
+1
View File
@@ -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