From 075495fe7cc7b4f302140e742ac9b6f6c220f05b Mon Sep 17 00:00:00 2001 From: MK Fain Date: Wed, 3 Dec 2025 21:42:58 -0600 Subject: [PATCH] Move Chat System Prompt to AI Settings and add Shakespeare context - Created src/lib/globalChatSystem.ts with comprehensive default prompt - Includes Shakespeare platform overview and architecture - Describes user interface and available actions - Lists helpful resource blog posts for user assistance - Moved Chat System Prompt setting from System Settings to AI Settings - Now under the "System Prompts" section in Advanced settings - Grouped with Project System Prompt for better organization - Updated GlobalChatProvider to use the new default prompt module - Added new translation keys for the reorganized UI: - systemPrompts, systemPromptsDescription - projectSystemPrompt, projectSystemPromptDescription - globalChatSystemPrompt, globalChatSystemPromptDescription - Removed redundant code from SystemSettings.tsx Resources included in the new default prompt: - AI model selection guide - Configuring AI providers - Using local AI models - Editing code in Shakespeare - Deploying and sharing projects - Importing existing projects - Version control with Git - Debugging tips - Better prompting techniques --- &1 | 147 ++++++++++++++++++++++++++ src/components/GlobalChatProvider.tsx | 8 +- src/lib/globalChatSystem.ts | 96 +++++++++++++++++ src/locales/en.json | 6 ++ src/pages/AISettings.tsx | 79 ++++++++++++-- src/pages/SystemSettings.tsx | 66 +----------- 6 files changed, 324 insertions(+), 78 deletions(-) create mode 100644 &1 create mode 100644 src/lib/globalChatSystem.ts diff --git a/&1 b/&1 new file mode 100644 index 00000000..25d67bc5 --- /dev/null +++ b/&1 @@ -0,0 +1,147 @@ + + + + + Shakespeare Resources - FAQ & Guides | Soapbox + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    📚 Resource Hub

    🎭 Shakespeare Resources

    Find answers to common questions and explore our latest guides.

    Video Tutorial Playlist

    Watch our complete video guide series to master Shakespeare

    This playlist includes step-by-step tutorials covering all major Shakespeare features

    🔄 Import Projects
    📝 Version Control
    💻 Code Editing
    🚀 Deployment
    🤖 AI Models
    ⚙️ AI Providers

    Frequently Asked Questions

    Get quick answers to the most common questions about Shakespeare

    Shakespeare Guides and Tutorials

    Deep dive into becoming a Shakespeare power user

    Get the latest Shakespeare updates and resources

    Stay updated with the latest features and announcements. Optionally provide your npub to link your account.

    * indicates required
    + + \ No newline at end of file diff --git a/src/components/GlobalChatProvider.tsx b/src/components/GlobalChatProvider.tsx index b3735d43..9ec7650c 100644 --- a/src/components/GlobalChatProvider.tsx +++ b/src/components/GlobalChatProvider.tsx @@ -7,16 +7,12 @@ import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useLocalStorage } from '@/hooks/useLocalStorage'; import { parseProviderModel } from '@/lib/parseProviderModel'; import { createAIClient } from '@/lib/ai-client'; +import { defaultGlobalChatSystemPrompt } from '@/lib/globalChatSystem'; // Maximum context size in characters (approximately 50k tokens worth) // This leaves room for the system prompt and response const MAX_CONTEXT_CHARS = 150000; -// Default system prompt for global chat -const DEFAULT_GLOBAL_CHAT_SYSTEM_PROMPT = `You are a helpful AI assistant. You're here to have a friendly conversation and help answer questions on any topic. - -Keep your responses concise but informative. Be friendly and conversational.`; - interface GlobalChatProviderProps { children: ReactNode; } @@ -102,7 +98,7 @@ export function GlobalChatProvider({ children }: GlobalChatProviderProps) { const client = createAIClient(provider, config.corsProxy, user?.signer); // Build messages for API using captured current messages - const systemPrompt = config.globalChatSystemPrompt || DEFAULT_GLOBAL_CHAT_SYSTEM_PROMPT; + const systemPrompt = config.globalChatSystemPrompt || defaultGlobalChatSystemPrompt; const apiMessages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [ { role: 'system', content: systemPrompt }, diff --git a/src/lib/globalChatSystem.ts b/src/lib/globalChatSystem.ts new file mode 100644 index 00000000..536ec1cc --- /dev/null +++ b/src/lib/globalChatSystem.ts @@ -0,0 +1,96 @@ +/** + * Default system prompt for global chat. + * This provides context about Shakespeare to help users with questions about the platform. + */ +export const defaultGlobalChatSystemPrompt = `You are a helpful AI assistant integrated into Shakespeare, an AI-powered website builder. You're here to have a friendly conversation and help answer questions on any topic. + +Keep your responses concise but informative. Be friendly and conversational. + +# Your Environment + +You are operating within **Shakespeare**, an AI-powered website builder that allows users to create custom applications through natural language conversation. + +Users can add or remove templates in Settings > AI. + +## What Shakespeare Is + +Shakespeare is a web-based development environment where users can build websites and applications by chatting with an AI assistant. The platform combines the power of AI-driven development with a user-friendly interface that requires no coding knowledge from the user. + +**Important Architecture Notes:** + +- **Browser-Based Storage**: All project files are stored locally in the browser's IndexedDB. If users clear browser data, they may lose their projects. +- **AI Provider Independence**: Shakespeare connects to various AI providers (OpenAI, Anthropic, Shakespeare AI, etc.). Each provider has its own pricing and authentication. +- **Shakespeare AI Credits**: Some AI providers like Shakespeare AI allow users to purchase credits with Bitcoin Lightning, linked to their Nostr identity. These credits are stored on the provider's servers and tied to the user's Nostr pubkey. +- **Cross-Browser Access**: + - **AI Credits**: Users who buy credits with Nostr-enabled providers (like Shakespeare AI) can access those credits from any browser by logging into the same Nostr account (Settings > Nostr). + - **Project Files**: Files are browser-specific. Users can export/import files via Settings > Storage, or sync via Git (Settings > Git) to access projects across browsers. +- **No Central Shakespeare Server**: Shakespeare itself is just client-side software running in the browser. It doesn't store user data or AI credits centrally. + +## User Interface + +The Shakespeare interface consists of several key areas: + +1. **Homepage** (\`/\`): A simple interface with: + - A large textarea where users can describe what they want to build + - A submit button to create new projects from their description + - A left sidebar containing the list of existing projects for easy access + +2. **Project View** (\`/projects/:projectId\`): A split-pane interface with: + - **Left Pane**: AI chat interface where users converse with the AI + - **Right Pane**: Toggles between two views: + - **Preview Mode**: Live preview of the website being built + - **Code View**: File explorer and code editor with syntax highlighting + +3. **Settings** (\`/settings\`): Accessible from the sidebar menu, includes: + - **Preferences** (\`/settings/preferences\`): Theme and language settings + - **AI Settings** (\`/settings/ai\`): Configure AI providers, API keys, project templates, MCP servers, and plugins + - **Git Settings** (\`/settings/git\`): Configure Git credentials for version control + - **Deploy Settings** (\`/settings/deploy\`): Configure deployment providers (Shakespeare, Netlify, Vercel, nsite) + - **Nostr Settings** (\`/settings/nostr\`): Manage Nostr accounts, relay connections, and ngit servers + - **Storage Settings** (\`/settings/storage\`): Export/import project files, manage browser storage + - **System Settings** (\`/settings/system\`): Advanced configuration (ESM CDN, CORS proxy, service worker, etc.) + - **About** (\`/settings/about\`): License information and project details + +## User Actions + +Users interact with Shakespeare by: + +1. **Creating Projects**: Describing what they want to build in natural language +2. **Chatting with AI**: Requesting features, modifications, and improvements through conversation +3. **Manual Code Editing**: Switching to code view to make direct file edits when desired +4. **Previewing Changes**: Viewing their website in real-time as it's being built +5. **Project Management**: Organizing and accessing multiple projects from the homepage +6. **Deploying Projects**: Publishing their creations to public URLs (requires Nostr login) + +## Helpful Resources + +When users ask questions about Shakespeare, you may recommend these helpful blog posts and guides: + +- **Choosing AI Models**: Learn how to select the best AI model for your project + - https://soapbox.pub/blog/shakespeare-ai-model-selection + +- **Configuring AI Providers**: Set up and configure different AI providers + - https://soapbox.pub/blog/shakespeare-configuring-ai-providers + +- **Using Local AI Models**: Run AI models locally on your own hardware + - https://soapbox.pub/blog/shakespeare-local-ai-model + +- **Editing Code**: Tips for manually editing code in Shakespeare + - https://soapbox.pub/blog/shakespeare-editing-code + +- **Deploying & Sharing Projects**: How to deploy and share your projects + - https://soapbox.pub/blog/shakespeare-deploying-sharing-projects + +- **Importing Existing Projects**: Bring existing projects into Shakespeare + - https://soapbox.pub/blog/shakespeare-importing-existing-projects + +- **Version Control with Git**: Using Git for version control in Shakespeare + - https://soapbox.pub/blog/shakespeare-version-control + +- **Debugging**: Troubleshooting and debugging your projects + - https://soapbox.pub/blog/debugging-in-shakespeare + +- **Better Prompting**: Tips for writing better prompts to get better results + - https://soapbox.pub/blog/how-to-prompt-better-projects + +When a user's question relates to one of these topics, provide a helpful answer and include the relevant link(s) so they can learn more.`; diff --git a/src/locales/en.json b/src/locales/en.json index 784edce5..d93ef144 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -63,7 +63,13 @@ "shareErrorReports": "Share error reports", "shareErrorReportsDescription": "Help improve this app by automatically sending crash and error reports.", "systemPrompt": "System Prompt", + "systemPrompts": "System Prompts", "systemPromptDescription": "AI system prompt controlling the assistant's behavior and knowledge.", + "systemPromptsDescription": "Configure the AI system prompts for project development and global chat.", + "projectSystemPrompt": "Project System Prompt", + "projectSystemPromptDescription": "System prompt used when the AI works on your projects. Supports Nunjucks templating for dynamic content.", + "globalChatSystemPrompt": "Chat System Prompt", + "globalChatSystemPromptDescription": "System prompt for the global chat assistant. This prompt provides context about Shakespeare and helpful resources.", "english": "English", "portuguese": "Portuguese", "chinese": "Chinese", diff --git a/src/pages/AISettings.tsx b/src/pages/AISettings.tsx index 43181dd9..d8bdc5a5 100644 --- a/src/pages/AISettings.tsx +++ b/src/pages/AISettings.tsx @@ -1,6 +1,6 @@ import { useState, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import { Check, Bot, ArrowLeft, Trash2, GripVertical, ChevronDown, RotateCcw, FileText, Plus, Edit } from 'lucide-react'; +import { Check, Bot, ArrowLeft, Trash2, GripVertical, ChevronDown, RotateCcw, FileText, Plus, Edit, MessageCircle } from 'lucide-react'; import { DndContext, closestCenter, @@ -44,6 +44,7 @@ import { MCPServersSection } from '@/components/MCPServersSection'; import { PluginsSection } from '@/components/PluginsSection'; import { ProjectTemplatesSection } from '@/components/ProjectTemplatesSection'; import { defaultSystemPrompt } from '@/lib/system'; +import { defaultGlobalChatSystemPrompt } from '@/lib/globalChatSystem'; interface SortableProviderItemProps { provider: AIProvider; @@ -217,12 +218,20 @@ export function AISettings() { const [activeCreditsDialog, setActiveCreditsDialog] = useState(null); const [showAdvanced, setShowAdvanced] = useState(false); const [systemPromptInput, setSystemPromptInput] = useState(config.systemPrompt || defaultSystemPrompt); + const [chatSystemPromptInput, setChatSystemPromptInput] = useState( + config.globalChatSystemPrompt || defaultGlobalChatSystemPrompt + ); // Check if system prompt differs from default const isSystemPromptModified = useMemo(() => (config.systemPrompt || defaultSystemPrompt) !== (defaultConfig.systemPrompt || defaultSystemPrompt), [config, defaultConfig]); + // Check if chat system prompt differs from default + const isChatSystemPromptModified = useMemo(() => + (config.globalChatSystemPrompt || defaultGlobalChatSystemPrompt) !== defaultGlobalChatSystemPrompt, + [config]); + const restoreSystemPrompt = () => { const defaultValue = defaultSystemPrompt; setSystemPromptInput(defaultValue); @@ -232,6 +241,14 @@ export function AISettings() { }); }; + const restoreChatSystemPrompt = () => { + setChatSystemPromptInput(defaultGlobalChatSystemPrompt); + updateConfig((current) => { + const { globalChatSystemPrompt, ...rest } = current; + return rest; + }); + }; + const sensors = useSensors( useSensor(PointerSensor), useSensor(KeyboardSensor, { @@ -684,28 +701,34 @@ export function AISettings() {
    -

    {t('systemPrompt')}

    - {isSystemPromptModified && ( +

    {t('systemPrompts')}

    + {(isSystemPromptModified || isChatSystemPromptModified) && (
    )}

    - {t('systemPromptDescription')} + {t('systemPromptsDescription')}

    - +
    - {t('systemPrompt')} + {t('projectSystemPrompt')} + {isSystemPromptModified && ( +
    + )}
    +

    + {t('projectSystemPromptDescription')} +