Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: improve Add App UX and plan M8-M9

Adam Eivy31403f996a4a
diff --git a/PLAN.md b/PLAN.md
index fbe61bce56..ed0491eb27 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -34,6 +34,8 @@ pm2 logs
- [x] M5: AI providers + headless executor
- [x] M6: Dev tools (history, command runner)
- [ ] M7: App templates (create from templates, template management)
+- [ ] M8: Prompt manager (customizable AI prompts, variables, stages)
+- [ ] M9: Streaming import detection (websocket updates, progressive discovery)
### Documentation
- [Contributing Guide](./docs/CONTRIBUTING.md) - Code guidelines, git workflow
@@ -180,3 +182,85 @@ Templates are stored in `./data/templates/` with:
| POST /api/templates | Add custom template |
| POST /api/templates/create | Create app from template |
| DELETE /api/templates/:id | Remove custom template |
+
+---
+
+## M8: Prompt Manager (Planned)
+
+Customizable AI prompts for all backend AI operations. Inspired by void-private's prompt management architecture.
+
+### Architecture
+- **File-based prompts**: Prompts stored as `.md` files for easy editing and version control
+- **Variable system**: Reusable variables with metadata, categories, and usage tracking
+- **Stage configuration**: Each prompt stage defines provider, model type, and execution options
+- **Template rendering**: Mustache-like syntax with conditionals, arrays, and nested data
+
+### Directory Structure
+```
+./data/prompts/
+├── stages/ # Individual prompt templates (.md files)
+│ ├── app-detection.md
+│ ├── code-analysis.md
+│ └── ...
+├── variables.json # Reusable prompt variables
+└── stage-config.json # Stage metadata and provider config
+```
+
+### Features
+1. **Prompt Stages**: Define different prompts for different AI tasks (detection, analysis, etc.)
+2. **Variables**: Reusable content blocks (personas, formats, constraints)
+3. **Per-Stage Provider Config**: Each stage can use different AI providers/models
+4. **Web UI**: Edit prompts, variables, and preview rendered output
+5. **Template Syntax**: `{{variable}}`, `{{#condition}}...{{/condition}}`, arrays
+
+### UI Pages
+- `/prompts` - Prompt Manager with tabs for Stages, Variables, Elements
+- Live preview with test variables
+- Insert variable references
+
+### API Endpoints
+| Route | Description |
+|-------|-------------|
+| GET /api/prompts | List all prompt stages |
+| GET /api/prompts/:stage | Get stage template |
+| PUT /api/prompts/:stage | Update stage/template |
+| POST /api/prompts/:stage/preview | Preview compiled prompt |
+| GET /api/prompts/variables | List all variables |
+| PUT /api/prompts/variables/:key | Update variable |
+| POST /api/prompts/variables | Create variable |
+| DELETE /api/prompts/variables/:key | Delete variable |
+
+---
+
+## M9: Streaming Import Detection (Planned)
+
+Enhanced app import with real-time websocket updates as AI discovers project configuration.
+
+### Features
+1. **Progressive Discovery**: Form fields update in real-time as AI analyzes the project
+2. **Status Animations**: Visual indicators showing detection progress
+3. **PM2 Detection**: Check if app is already running in PM2
+4. **Websocket Updates**: Server streams discoveries to UI as they happen
+
+### Discovery Steps (streamed to UI)
+1. Validating directory path
+2. Reading package.json
+3. Detecting project type (React, Express, monorepo, etc.)
+4. Finding configuration files
+5. Extracting ports from configs
+6. Detecting start commands
+7. Checking PM2 process status
+8. AI-powered analysis for name, description
+9. Generating PM2 process names
+
+### UI/UX
+- Progress indicator with current step
+- Form fields animate in as values are discovered
+- Already-running indicator if detected in PM2
+- Expandable "Detection Log" showing raw discovery output
+
+### API
+| Route | Description |
+|-------|-------------|
+| WS /api/detect/stream | Websocket for streaming detection |
+| GET /api/detect/pm2-status | Check if app running in PM2 |
diff --git a/client/src/pages/CreateApp.jsx b/client/src/pages/CreateApp.jsx
index 01a0e05899..f048b1fd0f 100644
--- a/client/src/pages/CreateApp.jsx
+++ b/client/src/pages/CreateApp.jsx
@@ -32,38 +32,9 @@ export default function CreateApp() {
api.getActiveProvider().then(p => setHasAiProvider(!!p)).catch(() => {});
}, []);
- // Validate path on blur
- const handlePathBlur = async () => {
- if (!repoPath) {
- setPathValid(null);
- return;
- }
-
- setDetecting(true);
- const result = await api.detectRepo(repoPath).catch(() => ({ valid: false }));
- setPathValid(result.valid);
- setDetecting(false);
-
- if (result.valid) {
- // Apply basic detection
- if (result.packageJson?.name && !name) {
- setName(result.packageJson.name);
- }
- if (result.startCommands?.length > 0 && startCommands === 'npm run dev') {
- setStartCommands(result.startCommands.join('\n'));
- }
- if (result.detectedPorts?.vite && !uiPort) {
- setUiPort(String(result.detectedPorts.vite));
- }
- if (result.detectedPorts?.main && !apiPort) {
- setApiPort(String(result.detectedPorts.main));
- }
- }
- };
-
// AI-powered detection
const handleAiDetect = async () => {
- if (!repoPath || !pathValid) return;
+ if (!repoPath) return;
setError(null);
setAiDetecting(true);
@@ -92,6 +63,45 @@ export default function CreateApp() {
if (d.pm2ProcessNames?.length > 0) setPm2Names(d.pm2ProcessNames.join(', '));
};
+ // Import button handler - validates path, then runs AI detection if available
+ const handleImport = async () => {
+ if (!repoPath) return;
+
+ setError(null);
+
+ // First validate the path
+ if (pathValid === null) {
+ setDetecting(true);
+ const result = await api.detectRepo(repoPath).catch(() => ({ valid: false }));
+ setPathValid(result.valid);
+ setDetecting(false);
+
+ if (!result.valid) {
+ setError('Invalid directory path');
+ return;
+ }
+
+ // Apply basic detection
+ if (result.packageJson?.name && !name) {
+ setName(result.packageJson.name);
+ }
+ if (result.startCommands?.length > 0 && startCommands === 'npm run dev') {
+ setStartCommands(result.startCommands.join('\n'));
+ }
+ if (result.detectedPorts?.vite && !uiPort) {
+ setUiPort(String(result.detectedPorts.vite));
+ }
+ if (result.detectedPorts?.main && !apiPort) {
+ setApiPort(String(result.detectedPorts.main));
+ }
+ }
+
+ // Then run AI detection if provider is available
+ if (hasAiProvider) {
+ await handleAiDetect();
+ }
+ };
+
// Submit form
const handleSubmit = async (e) => {
e.preventDefault();
@@ -132,49 +142,35 @@ export default function CreateApp() {
{/* Path Input */}
<div className="bg-port-card border border-port-border rounded-xl p-6">
<label className="block text-sm text-gray-400 mb-2">Project Directory</label>
- <div className="flex gap-2">
- <input
- type="text"
- value={repoPath}
- onChange={(e) => { setRepoPath(e.target.value); setPathValid(null); setDetected(null); }}
- onBlur={handlePathBlur}
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- if (pathValid && hasAiProvider) {
- handleAiDetect();
- } else if (!pathValid) {
- handlePathBlur();
- }
- }
- }}
- placeholder="/Users/you/projects/my-app"
- className="flex-1 px-4 py-3 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none font-mono"
- />
- {hasAiProvider && pathValid && (
- <button
- type="button"
- onClick={handleAiDetect}
- disabled={aiDetecting}
- className="px-4 py-3 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors disabled:opacity-50 whitespace-nowrap"
- >
- {aiDetecting ? 'Detecting...' : 'Detect with AI'}
- </button>
- )}
- </div>
+ <input
+ type="text"
+ value={repoPath}
+ onChange={(e) => { setRepoPath(e.target.value); setPathValid(null); setDetected(null); }}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ handleImport();
+ }
+ }}
+ placeholder="/Users/you/projects/my-app"
+ className="w-full px-4 py-3 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none font-mono"
+ />
{detecting && (
<p className="mt-2 text-sm text-gray-500">Validating path...</p>
)}
+ {aiDetecting && (
+ <p className="mt-2 text-sm text-port-accent">Detecting project configuration with AI...</p>
+ )}
+
{pathValid === false && (
<p className="mt-2 text-sm text-port-error">Invalid directory path</p>
)}
- {pathValid === true && !detected && (
+ {pathValid === true && !detected && !aiDetecting && (
<p className="mt-2 text-sm text-port-success">
Valid project directory
- {hasAiProvider && ' — click "Detect with AI" for smart configuration'}
</p>
)}
@@ -190,6 +186,25 @@ export default function CreateApp() {
</p>
</div>
)}
+
+ {/* Action Buttons - Always visible */}
+ <div className="flex gap-3 mt-4">
+ <button
+ type="button"
+ onClick={() => navigate('/templates')}
+ className="flex-1 px-6 py-3 bg-port-border hover:bg-port-border/80 text-white rounded-lg transition-colors"
+ >
+ Create from Template
+ </button>
+ <button
+ type="button"
+ onClick={handleImport}
+ disabled={!repoPath || detecting || aiDetecting}
+ className="flex-1 px-6 py-3 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors disabled:opacity-50"
+ >
+ {detecting ? 'Validating...' : aiDetecting ? 'Detecting...' : 'Import'}
+ </button>
+ </div>
</div>
{/* App Details */}
@@ -281,32 +296,32 @@ export default function CreateApp() {
</div>
)}
- {/* Submit */}
+ {/* Submit - only shown after detection */}
{pathValid && (
<div className="flex justify-between items-center">
<button
type="button"
- onClick={() => navigate(-1)}
+ onClick={() => {
+ setPathValid(null);
+ setDetected(null);
+ setName('');
+ setDescription('');
+ setUiPort('');
+ setApiPort('');
+ setStartCommands('npm run dev');
+ setPm2Names('');
+ }}
className="px-4 py-2 text-gray-400 hover:text-white"
>
- Cancel
+ Reset
+ </button>
+ <button
+ type="submit"
+ disabled={!name || submitting}
+ className="px-6 py-3 bg-port-success hover:bg-port-success/80 text-white rounded-lg transition-colors disabled:opacity-50"
+ >
+ {submitting ? 'Saving...' : 'Save App'}
</button>
- <div className="flex gap-3">
- <button
- type="button"
- onClick={() => navigate('/templates')}
- className="px-6 py-3 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors"
- >
- Create from Template
- </button>
- <button
- type="submit"
- disabled={!name || submitting}
- className="px-6 py-3 bg-port-success hover:bg-port-success/80 text-white rounded-lg transition-colors disabled:opacity-50"
- >
- {submitting ? 'Importing...' : 'Import App'}
- </button>
- </div>
</div>
)}
</form>