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

address review: centralize LLM drill types, fix branch collisions, update schema, check remote branches

Adam Eivyc8a4f1a89509
diff --git a/client/src/components/meatspace/post/PostHistory.jsx b/client/src/components/meatspace/post/PostHistory.jsx
index f532c1a834..b27a576c01 100644
--- a/client/src/components/meatspace/post/PostHistory.jsx
+++ b/client/src/components/meatspace/post/PostHistory.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
import { ArrowLeft, ChevronDown, ChevronRight } from 'lucide-react';
import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid } from 'recharts';
import { getPostSessions, getPostStats } from '../../../services/api';
+import { LLM_DRILL_TYPES } from './constants';
const DRILL_LABELS = {
'doubling-chain': 'Doubling Chain',
@@ -16,8 +17,6 @@ const DRILL_LABELS = {
'pun-wordplay': 'Pun & Wordplay'
};
-const LLM_DRILL_TYPES = ['word-association', 'story-recall', 'verbal-fluency', 'wit-comeback', 'pun-wordplay'];
-
const RANGES = [
{ label: '7d', days: 7 },
{ label: '30d', days: 30 },
diff --git a/client/src/components/meatspace/post/PostSessionLauncher.jsx b/client/src/components/meatspace/post/PostSessionLauncher.jsx
index 6a37b0667c..1f89fd3da4 100644
--- a/client/src/components/meatspace/post/PostSessionLauncher.jsx
+++ b/client/src/components/meatspace/post/PostSessionLauncher.jsx
@@ -1,6 +1,7 @@
import { useState, useEffect } from 'react';
import { Zap, History, Settings, Play, Brain } from 'lucide-react';
import { getProviders } from '../../../services/api';
+import { LLM_DRILL_TYPES } from './constants';
const DRILL_LABELS = {
'doubling-chain': 'Doubling Chain',
@@ -15,8 +16,6 @@ const DRILL_LABELS = {
'pun-wordplay': 'Pun & Wordplay'
};
-const LLM_DRILL_TYPES = ['word-association', 'story-recall', 'verbal-fluency', 'wit-comeback', 'pun-wordplay'];
-
export default function PostSessionLauncher({ config, recentSessions, onStart, onViewHistory, onViewConfig }) {
const [tags, setTags] = useState({ sleep: '', caffeine: '', stress: '' });
const [providers, setProviders] = useState([]);
diff --git a/client/src/components/meatspace/post/PostSessionResults.jsx b/client/src/components/meatspace/post/PostSessionResults.jsx
index 2fb3d2ef61..6f118845f8 100644
--- a/client/src/components/meatspace/post/PostSessionResults.jsx
+++ b/client/src/components/meatspace/post/PostSessionResults.jsx
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { CheckCircle, Save, ArrowLeft, ChevronDown, ChevronUp } from 'lucide-react';
+import { LLM_DRILL_TYPES } from './constants';
const DRILL_LABELS = {
'doubling-chain': 'Doubling Chain',
@@ -14,8 +15,6 @@ const DRILL_LABELS = {
'pun-wordplay': 'Pun & Wordplay'
};
-const LLM_DRILL_TYPES = ['word-association', 'story-recall', 'verbal-fluency', 'wit-comeback', 'pun-wordplay'];
-
export default function PostSessionResults({ session, tags = {}, onSaved, onBack }) {
const { drillResults, sessionScore, state, saveSession } = session;
const [expandedDrill, setExpandedDrill] = useState(null);
diff --git a/client/src/components/meatspace/post/constants.js b/client/src/components/meatspace/post/constants.js
new file mode 100644
index 0000000000..9a63f3c7bd
--- /dev/null
+++ b/client/src/components/meatspace/post/constants.js
@@ -0,0 +1 @@
+export const LLM_DRILL_TYPES = ['word-association', 'story-recall', 'verbal-fluency', 'wit-comeback', 'pun-wordplay'];
diff --git a/client/src/components/meatspace/tabs/PostTab.jsx b/client/src/components/meatspace/tabs/PostTab.jsx
index fb77b3a9c2..8f5bfa411e 100644
--- a/client/src/components/meatspace/tabs/PostTab.jsx
+++ b/client/src/components/meatspace/tabs/PostTab.jsx
@@ -7,8 +7,7 @@ import PostLlmDrillRunner from '../post/PostLlmDrillRunner';
import PostSessionResults from '../post/PostSessionResults';
import PostHistory from '../post/PostHistory';
import PostDrillConfig from '../post/PostDrillConfig';
-
-const LLM_DRILL_TYPES = ['word-association', 'story-recall', 'verbal-fluency', 'wit-comeback', 'pun-wordplay'];
+import { LLM_DRILL_TYPES } from '../post/constants';
export default function PostTab() {
const [view, setView] = useState('launcher');
diff --git a/client/src/hooks/usePostSession.js b/client/src/hooks/usePostSession.js
index 45168520a9..b305e07e23 100644
--- a/client/src/hooks/usePostSession.js
+++ b/client/src/hooks/usePostSession.js
@@ -1,8 +1,7 @@
import { useState, useCallback, useRef } from 'react';
import { generatePostDrill, submitPostSession, scorePostLlmDrill } from '../services/api';
import toast from 'react-hot-toast';
-
-const LLM_DRILL_TYPES = ['word-association', 'story-recall', 'verbal-fluency', 'wit-comeback', 'pun-wordplay'];
+import { LLM_DRILL_TYPES } from '../components/meatspace/post/constants';
// States: idle → loading → drilling → between-drills → complete → saving → saved
const STATES = {
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 18da371839..a1908a7a74 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -473,7 +473,24 @@ export const featureAgentSchema = z.object({
priority: featureAgentPrioritySchema.default('MEDIUM')
});
-export const featureAgentUpdateSchema = featureAgentSchema.deepPartial();
+// Update schema: all fields optional, no defaults (prevents overwriting existing values)
+export const featureAgentUpdateSchema = z.object({
+ name: z.string().min(1).max(200).optional(),
+ description: z.string().min(1).max(2000).optional(),
+ persona: z.string().max(5000).optional(),
+ appId: z.string().min(1).optional(),
+ schedule: z.object({
+ mode: featureAgentScheduleModeSchema.optional(),
+ intervalMs: z.number().int().min(30000).optional(),
+ pauseBetweenRunsMs: z.number().int().min(0).optional()
+ }).optional(),
+ goals: z.array(z.string()).optional(),
+ constraints: z.array(z.string()).optional(),
+ providerId: z.string().optional().nullable(),
+ model: z.string().optional().nullable(),
+ autonomyLevel: featureAgentAutonomySchema.optional(),
+ priority: featureAgentPrioritySchema.optional()
+});
/**
* Validate data against a schema
diff --git a/server/services/featureAgents.js b/server/services/featureAgents.js
index e602557e84..a3fa891818 100644
--- a/server/services/featureAgents.js
+++ b/server/services/featureAgents.js
@@ -74,8 +74,8 @@ export async function createFeatureAgent(input) {
const id = `fa-${uuidv4().slice(0, 8)}`;
const now = new Date().toISOString();
- const slug = input.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || id;
- const branchName = `feature-agent/${slug}`;
+ const slug = input.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'agent';
+ const branchName = `feature-agent/${slug}-${id.replace('fa-', '')}`;
const agent = {
id,
...input,
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 646cfb4c0b..1d0efa997b 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -1469,7 +1469,7 @@ export async function spawnAgentForTask(task) {
// Feature agent tasks: use persistent worktree instead of creating a new one
if (task.metadata?.featureAgentRun && task.metadata?.featureAgentId) {
- const { getFeatureAgent, buildFeatureAgentPrompt } = await import('./featureAgents.js');
+ const { getFeatureAgent } = await import('./featureAgents.js');
const fa = await getFeatureAgent(task.metadata.featureAgentId).catch(() => null);
if (fa) {
const faWorktreePath = join(PATHS.cos, 'feature-agents', fa.id, 'worktree');
diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.js
index f9ef0943c7..f7fade2de6 100644
--- a/server/services/worktreeManager.js
+++ b/server/services/worktreeManager.js
@@ -175,12 +175,16 @@ export async function createPersistentWorktree(featureAgentId, sourceWorkspace,
.then(() => `origin/${baseBranch}`)
.catch(() => baseBranch);
- // Check if branch already exists
- const branchExists = (await execGit(['branch', '--list', branchName], sourceWorkspace)).trim();
+ // Check if branch already exists (local or remote)
+ const localBranchExists = (await execGit(['branch', '--list', branchName], sourceWorkspace)).trim();
+ const remoteBranchExists = (await execGit(['branch', '-r', '--list', `origin/${branchName}`], sourceWorkspace)).trim();
- if (branchExists) {
- // Branch exists - create worktree from existing branch
+ if (localBranchExists) {
+ // Local branch exists - create worktree from existing branch
await execGit(['worktree', 'add', FA_WORKTREES, branchName], sourceWorkspace);
+ } else if (remoteBranchExists) {
+ // Remote branch exists but no local - track it
+ await execGit(['worktree', 'add', '--track', '-b', branchName, FA_WORKTREES, `origin/${branchName}`], sourceWorkspace);
} else {
// New branch - create from base
await execGit(['worktree', 'add', '-b', branchName, FA_WORKTREES, baseRef], sourceWorkspace);
diff --git a/server/services/worktreeManager.test.js b/server/services/worktreeManager.test.js
index 91dbcda2ef..a2d9a0b1cf 100644
--- a/server/services/worktreeManager.test.js
+++ b/server/services/worktreeManager.test.js
@@ -1,4 +1,5 @@
import { describe, it, expect } from 'vitest';
+import { join } from 'path';
/**
* Tests for the worktree manager service.
@@ -112,7 +113,7 @@ detached
describe('Persistent Worktree Path Construction', () => {
function buildPersistentWorktreePath(worktreesDir, featureAgentId) {
- return `${worktreesDir}/../feature-agents/${featureAgentId}/worktree`;
+ return join(worktreesDir, '..', 'feature-agents', featureAgentId, 'worktree');
}
it('should place worktree under feature-agents directory', () => {