diff --git a/src/components/ProjectTemplatesSection.tsx b/src/components/ProjectTemplatesSection.tsx
new file mode 100644
index 00000000..695a3ea0
--- /dev/null
+++ b/src/components/ProjectTemplatesSection.tsx
@@ -0,0 +1,218 @@
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { FileCode2, Trash2, Plus } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Textarea } from '@/components/ui/textarea';
+import { Label } from '@/components/ui/label';
+import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
+import { Separator } from '@/components/ui/separator';
+import { Alert, AlertDescription } from '@/components/ui/alert';
+import { useAppContext } from '@/hooks/useAppContext';
+import { useToast } from '@/hooks/useToast';
+
+interface ProjectTemplate {
+ name: string;
+ description: string;
+ url: string;
+}
+
+export function ProjectTemplatesSection() {
+ const { t } = useTranslation();
+ const { config, updateConfig } = useAppContext();
+ const { toast } = useToast();
+ const [newTemplateName, setNewTemplateName] = useState('');
+ const [newTemplateDescription, setNewTemplateDescription] = useState('');
+ const [newTemplateUrl, setNewTemplateUrl] = useState('');
+
+ const templates = config.templates || [];
+
+ const handleAddTemplate = () => {
+ if (!newTemplateName.trim() || !newTemplateDescription.trim() || !newTemplateUrl.trim()) {
+ return;
+ }
+
+ const newTemplate: ProjectTemplate = {
+ name: newTemplateName.trim(),
+ description: newTemplateDescription.trim(),
+ url: newTemplateUrl.trim(),
+ };
+
+ updateConfig((current) => ({
+ ...current,
+ templates: [...(current.templates || []), newTemplate],
+ }));
+
+ toast({
+ title: t('templateAdded'),
+ description: t('templateAddedDescription', { name: newTemplateName.trim() }),
+ });
+
+ setNewTemplateName('');
+ setNewTemplateDescription('');
+ setNewTemplateUrl('');
+ };
+
+ const handleRemoveTemplate = (index: number) => {
+ const templateName = templates[index]?.name || 'template';
+ const newTemplates = templates.filter((_, i) => i !== index);
+
+ updateConfig((current) => ({
+ ...current,
+ templates: newTemplates,
+ }));
+
+ toast({
+ title: t('templateDeleted'),
+ description: t('templateDeletedDescription', { name: templateName }),
+ });
+ };
+
+ const handleUpdateTemplate = (index: number, updatedTemplate: ProjectTemplate) => {
+ const newTemplates = [...templates];
+ newTemplates[index] = updatedTemplate;
+
+ updateConfig((current) => ({
+ ...current,
+ templates: newTemplates,
+ }));
+ };
+
+ return (
+
+ {/* Divider */}
+
+
+ {/* Project Templates Header */}
+
+
+
+
{t('projectTemplates')}
+
+
+ {t('projectTemplatesDescription')}
+
+
+
+ {/* Configured Templates List */}
+ {templates.length > 0 ? (
+
+ {templates.map((template, index) => (
+
+
+
+
+
+ {template.name}
+
+
+
+
+
+
+ handleUpdateTemplate(index, { ...template, name: e.target.value })}
+ />
+
+
+
+
+
+
+ handleUpdateTemplate(index, { ...template, url: e.target.value })}
+ />
+
+
+
+
+
+
+ ))}
+
+ ) : (
+
+
+ {t('noTemplatesConfigured')}
+
+
+ )}
+
+ {/* Add New Template */}
+
+
+
+
+
+
{t('addProjectTemplate')}
+
+
+
+
+
+
+ setNewTemplateName(e.target.value)}
+ />
+
+
+
+
+
+
+ setNewTemplateUrl(e.target.value)}
+ />
+
+
+
+
+
+
+
+ );
+}
diff --git a/src/lib/system.test.ts b/src/lib/system.test.ts
index fe689fca..cb08ae5c 100644
--- a/src/lib/system.test.ts
+++ b/src/lib/system.test.ts
@@ -291,15 +291,6 @@ describe('makeSystemPrompt', () => {
});
describe('CORS proxy section', () => {
- it('should not include CORS proxy section when not provided', async () => {
- const result = await makeSystemPrompt({
- ...baseOpts,
- config: { ...testConfig, corsProxy: '' },
- });
-
- expect(result).not.toContain('## Working Around CORS Issues');
- });
-
it('should include CORS proxy information when provided', async () => {
const result = await makeSystemPrompt(baseOpts);
@@ -582,7 +573,7 @@ Skills: {{ skills.length }}`;
expect(result).toContain('**MKStack**');
expect(result).toContain('Build Nostr clients with React.');
expect(result).toContain('https://gitlab.com/soapbox-pub/mkstack.git');
- expect(result).toContain('Settings > System');
+ expect(result).toContain('Settings > AI');
});
it('should highlight current template when it matches a configured template', async () => {
diff --git a/src/lib/system.ts b/src/lib/system.ts
index 618be6a1..3a0be858 100644
--- a/src/lib/system.ts
+++ b/src/lib/system.ts
@@ -36,9 +36,9 @@ You are operating within **Shakespeare**, an AI-powered website builder that all
- **Current Page**: {{ location.href }}
- **Current Working Directory**: {{ cwd }}
- **Repository URL**: {% if repositoryUrl %}{{ repositoryUrl }}{% else %}none{% endif %}
-- **Project Template**: {% if projectTemplate %}{{ projectTemplate.name }}{% else %}unknown{% endif %}
+{% if projectTemplate %}- **Project Template**: {{ projectTemplate.name }}{% endif %}
-Users can add or remove templates in Settings > System (\`{{ location.origin }}/settings/system\`).
+Users can add or remove templates in Settings > AI (\`{{ location.origin }}/settings/ai\`).
## What Shakespeare Is
@@ -91,12 +91,12 @@ The Shakespeare interface consists of several key areas:
4. **Settings** (\`/settings\`): Accessible from the sidebar menu, includes:
- **Preferences** (\`/settings/preferences\`): Theme and language settings
- - **AI Settings** (\`/settings/ai\`): Configure AI providers and API keys
+ - **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 (project template, ESM CDN, CORS proxy, etc.)
+ - **System Settings** (\`/settings/system\`): Advanced configuration (ESM CDN, CORS proxy, service worker, etc.)
- **About** (\`/settings/about\`): License information and project details
## User Actions
diff --git a/src/locales/en.json b/src/locales/en.json
index b5babca9..4d8bc9a0 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -513,5 +513,15 @@
"templateUpdateFailedDescription": "Failed to update the project template from the remote repository. Using the cached version instead.",
"templatesDirectory": "Templates Directory",
"templatesDirectoryDescription": "Directory where project templates are cached in the virtual filesystem.",
- "terminal": "Terminal"
+ "terminal": "Terminal",
+ "templateName": "Template Name",
+ "templateDescription": "Description",
+ "templateGitUrl": "Git URL",
+ "addProjectTemplate": "Add Project Template",
+ "templateAdded": "Template Added",
+ "templateAddedDescription": "Project template '{{name}}' has been added successfully.",
+ "templateDeleted": "Template Deleted",
+ "templateDeletedDescription": "Project template '{{name}}' has been deleted.",
+ "noTemplatesConfigured": "No project templates configured yet. Add a template to get started.",
+ "atLeastOneTemplateRequired": "At least one template is required"
}
diff --git a/src/pages/AISettings.tsx b/src/pages/AISettings.tsx
index 0742355d..ab18f815 100644
--- a/src/pages/AISettings.tsx
+++ b/src/pages/AISettings.tsx
@@ -39,6 +39,7 @@ import { AI_PROVIDER_PRESETS, type PresetProvider } from '@/lib/aiProviderPreset
import { ExternalFavicon } from '@/components/ExternalFavicon';
import { MCPServersSection } from '@/components/MCPServersSection';
import { PluginsSection } from '@/components/PluginsSection';
+import { ProjectTemplatesSection } from '@/components/ProjectTemplatesSection';
interface SortableProviderItemProps {
provider: AIProvider;
@@ -570,6 +571,9 @@ export function AISettings() {
+ {/* Project Templates Section */}
+
+
{/* MCP Servers Section */}
diff --git a/src/pages/SystemSettings.tsx b/src/pages/SystemSettings.tsx
index 63672fb6..a6ade8bc 100644
--- a/src/pages/SystemSettings.tsx
+++ b/src/pages/SystemSettings.tsx
@@ -1,4 +1,4 @@
-import { Settings, ArrowLeft, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Plus } from "lucide-react";
+import { Settings, ArrowLeft, RefreshCw, Trash2, XCircle, Loader2, RotateCcw } from "lucide-react";
import { useTranslation } from 'react-i18next';
import { useState, useEffect, useMemo } from "react";
import { Button } from "@/components/ui/button";
@@ -23,7 +23,6 @@ export function SystemSettings() {
const { toast } = useToast();
const { serviceWorkerRegistration, updateServiceWorker, clearCache } = useOffline();
- const [templatesInput, setTemplatesInput] = useState(config.templates);
const [esmUrlInput, setEsmUrlInput] = useState(config.esmUrl);
const [corsProxyInput, setCorsProxyInput] = useState(config.corsProxy);
const [faviconUrlInput, setFaviconUrlInput] = useState(config.faviconUrl);
@@ -39,7 +38,6 @@ export function SystemSettings() {
// Check which settings differ from defaults
const isModified = useMemo(() => ({
- templates: JSON.stringify(config.templates) !== JSON.stringify(defaultConfig.templates),
esmUrl: config.esmUrl !== defaultConfig.esmUrl,
corsProxy: config.corsProxy !== defaultConfig.corsProxy,
faviconUrl: config.faviconUrl !== defaultConfig.faviconUrl,
@@ -56,15 +54,6 @@ export function SystemSettings() {
}), [config, defaultConfig]);
// Restore functions - clear the value from config to use the default
- const restoreTemplates = () => {
- const defaultValue = defaultConfig.templates;
- setTemplatesInput(defaultValue);
- updateConfig((current) => {
- const { templates, ...rest } = current;
- return rest;
- });
- };
-
const restoreEsmUrl = () => {
const defaultValue = defaultConfig.esmUrl;
setEsmUrlInput(defaultValue);
@@ -409,137 +398,6 @@ export function SystemSettings() {
- {/* Project Templates Configuration */}
-
-
-
-
-
{t('projectTemplates')}
- {isModified.templates && (
-
- )}
-
-
-
-
- {templatesInput.map((template, index) => (
-
-
-
-
- {
- const newTemplates = [...templatesInput];
- newTemplates[index] = { ...template, name: e.target.value };
- setTemplatesInput(newTemplates);
- updateConfig((current) => ({
- ...current,
- templates: newTemplates,
- }));
- }}
- />
-
-
-
-
-
-
- {
- const newTemplates = [...templatesInput];
- newTemplates[index] = { ...template, url: e.target.value };
- setTemplatesInput(newTemplates);
- updateConfig((current) => ({
- ...current,
- templates: newTemplates,
- }));
- }}
- />
-
-
-
-
- ))}
-
-
- {isModified.templates && (
-
- )}
-
-
- {t('projectTemplatesDescription')}
-
-
-
-
-
-
{/* CORS Proxy Configuration */}