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: add GSD observer dashboard to CoS with planning context injection

Adam Eivyd8f11725e1e4
diff --git a/.changelog/v1.17.x.md b/.changelog/v1.17.x.md
index f53649f245..3c09e63744 100644
--- a/.changelog/v1.17.x.md
+++ b/.changelog/v1.17.x.md
@@ -10,3 +10,6 @@ Roadmap expansion with three new productivity milestones.
- **M48-M50 roadmap milestones** — added Google Calendar Integration (M48), Life Goals & Todo Planning (M49), and Email Management (M50) to PLAN.md with full phase specs, dependency graph, routes, data schemas, and nav placement
- **Core goal #11** — added "Personal Productivity & Life Management" to GOALS.md, covering calendar sync, goal tracking with AI check-ins, and email management with Digital Twin voice drafting
+- **GSD dashboard tab** — new CoS tab at `/cos/gsd` that scans managed apps for `.planning/` directories and displays roadmap progress, phase status, and concerns with severity badges
+- **Concerns-to-tasks pipeline** — parse GSD CONCERNS.md items (tech debt, bugs, security) with severity mapping and create CoS tasks directly from the dashboard
+- **Planning context injection** — agents spawned for GSD-enabled apps automatically receive STATE.md, CONCERNS.md, and ROADMAP.md content in their prompts for richer project awareness
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 0f2e85cb02..08e754c836 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -48,6 +48,7 @@ import {
Skull,
HeartPulse,
ClipboardList,
+ Compass,
Eye,
Scale,
Lightbulb
@@ -84,6 +85,7 @@ const navItems = [
{ to: '/cos/briefing', label: 'Briefing', icon: Newspaper },
{ to: '/cos/config', label: 'Config', icon: Settings },
{ to: '/cos/digest', label: 'Digest', icon: Calendar },
+ { to: '/cos/gsd', label: 'GSD', icon: Compass },
{ to: '/cos/health', label: 'Health', icon: Activity },
{ to: '/cos/jobs', label: 'Jobs', icon: Bot },
{ to: '/cos/learning', label: 'Learning', icon: GraduationCap },
diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.js
index c8221a5f42..1f4ec71876 100644
--- a/client/src/components/cos/constants.js
+++ b/client/src/components/cos/constants.js
@@ -7,6 +7,7 @@ import {
Settings,
Calendar,
Clock,
+ Compass,
GraduationCap,
Bot,
Flame,
@@ -21,6 +22,7 @@ export const TABS = [
{ id: 'scripts', label: 'Scripts', icon: Terminal },
{ id: 'schedule', label: 'Schedule', icon: Clock },
{ id: 'digest', label: 'Digest', icon: Calendar },
+ { id: 'gsd', label: 'GSD', icon: Compass },
{ id: 'productivity', label: 'Streaks', icon: Flame },
{ id: 'learning', label: 'Learning', icon: GraduationCap },
{ id: 'memory', label: 'Memory', icon: Brain },
diff --git a/client/src/components/cos/index.js b/client/src/components/cos/index.js
index 384b4b849a..555350e39d 100644
--- a/client/src/components/cos/index.js
+++ b/client/src/components/cos/index.js
@@ -33,5 +33,6 @@ export { default as MemoryTab } from './tabs/MemoryTab';
export { default as HealthTab } from './tabs/HealthTab';
export { default as ConfigTab } from './tabs/ConfigTab';
export { default as DigestTab } from './tabs/DigestTab';
+export { default as GsdTab } from './tabs/GsdTab';
export { default as ProductivityTab } from './tabs/ProductivityTab';
export { default as BriefingTab } from './tabs/BriefingTab';
diff --git a/client/src/components/cos/tabs/GsdConcernsPanel.jsx b/client/src/components/cos/tabs/GsdConcernsPanel.jsx
new file mode 100644
index 0000000000..e1556e569a
--- /dev/null
+++ b/client/src/components/cos/tabs/GsdConcernsPanel.jsx
@@ -0,0 +1,105 @@
+import { useState } from 'react';
+import { AlertTriangle, Bug, Shield, Zap, Package, ChevronDown, ChevronUp, Plus } from 'lucide-react';
+import toast from 'react-hot-toast';
+import * as api from '../../../services/api';
+
+const SEVERITY_CONFIG = {
+ CRITICAL: { color: 'text-port-error border-port-error/30 bg-port-error/10', icon: Shield, label: 'Critical' },
+ HIGH: { color: 'text-port-warning border-port-warning/30 bg-port-warning/10', icon: Bug, label: 'High' },
+ MEDIUM: { color: 'text-port-accent border-port-accent/30 bg-port-accent/10', icon: Zap, label: 'Medium' },
+ LOW: { color: 'text-gray-400 border-gray-500/30 bg-gray-500/10', icon: Package, label: 'Low' }
+};
+
+export default function GsdConcernsPanel({ appId, concerns, onTaskCreated }) {
+ const [expanded, setExpanded] = useState({});
+ const [creating, setCreating] = useState(null);
+
+ if (!concerns?.sections?.length) {
+ return <p className="text-sm text-gray-500 italic">No concerns found</p>;
+ }
+
+ const toggleSection = (title) => {
+ setExpanded(prev => ({ ...prev, [title]: !prev[title] }));
+ };
+
+ const handleCreateTask = async (concernId) => {
+ setCreating(concernId);
+ const result = await api.createGsdConcernTasks(appId, { concernIds: [concernId] }).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setCreating(null);
+ if (result) {
+ toast.success('Task created from concern');
+ onTaskCreated?.();
+ }
+ };
+
+ const handleCreateAll = async () => {
+ setCreating('all');
+ const result = await api.createGsdConcernTasks(appId, { all: true }).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setCreating(null);
+ if (result) {
+ toast.success(`Created ${result.created || 0} tasks from concerns`);
+ onTaskCreated?.();
+ }
+ };
+
+ return (
+ <div>
+ <div className="flex items-center justify-between mb-3">
+ <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider">Concerns</h4>
+ <button
+ onClick={handleCreateAll}
+ disabled={creating === 'all'}
+ className="flex items-center gap-1 px-2 py-1 text-xs bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded transition-colors disabled:opacity-50"
+ >
+ <Plus size={12} /> Create All Tasks
+ </button>
+ </div>
+ <div className="space-y-2">
+ {concerns.sections.map(section => {
+ const config = SEVERITY_CONFIG[section.severity] || SEVERITY_CONFIG.LOW;
+ const SeverityIcon = config.icon;
+ const isExpanded = expanded[section.title];
+
+ return (
+ <div key={section.title} className={`border rounded-lg ${config.color.split(' ')[1]} ${config.color.split(' ')[2]}`}>
+ <button
+ onClick={() => toggleSection(section.title)}
+ className="flex items-center justify-between w-full px-3 py-2 text-left"
+ >
+ <div className="flex items-center gap-2">
+ <SeverityIcon size={14} className={config.color.split(' ')[0]} />
+ <span className="text-sm font-medium text-gray-300">{section.title}</span>
+ <span className={`text-xs px-1.5 py-0.5 rounded ${config.color}`}>{config.label}</span>
+ <span className="text-xs text-gray-500">({section.items?.length || 0})</span>
+ </div>
+ {isExpanded ? <ChevronUp size={14} className="text-gray-500" /> : <ChevronDown size={14} className="text-gray-500" />}
+ </button>
+ {isExpanded && section.items?.length > 0 && (
+ <div className="px-3 pb-2 space-y-1">
+ {section.items.map(item => (
+ <div key={item.id} className="flex items-center justify-between gap-2 py-1 border-t border-port-border/50">
+ <span className="text-xs text-gray-400 flex-1">{item.text}</span>
+ <button
+ onClick={() => handleCreateTask(item.id)}
+ disabled={creating === item.id}
+ className="shrink-0 px-1.5 py-0.5 text-[10px] bg-port-accent/10 hover:bg-port-accent/20 text-port-accent rounded transition-colors disabled:opacity-50"
+ >
+ {creating === item.id ? '...' : '+ Task'}
+ </button>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/components/cos/tabs/GsdProjectCard.jsx b/client/src/components/cos/tabs/GsdProjectCard.jsx
new file mode 100644
index 0000000000..8741543886
--- /dev/null
+++ b/client/src/components/cos/tabs/GsdProjectCard.jsx
@@ -0,0 +1,138 @@
+import { useState } from 'react';
+import { ChevronDown, ChevronUp } from 'lucide-react';
+import toast from 'react-hot-toast';
+import * as api from '../../../services/api';
+import GsdConcernsPanel from './GsdConcernsPanel';
+
+const PHASE_STATUS_COLORS = {
+ completed: 'bg-port-success',
+ 'in-progress': 'bg-port-accent',
+ planned: 'bg-port-warning',
+ pending: 'bg-gray-600'
+};
+
+const LIFECYCLE_STEPS = ['research', 'plan', 'execute', 'verify'];
+
+function PhaseTimeline({ phases = [] }) {
+ if (phases.length === 0) return <p className="text-xs text-gray-500 italic">No phases found</p>;
+
+ return (
+ <div className="space-y-1.5">
+ {phases.map(phase => (
+ <div key={phase.id || phase.name} className="flex items-center gap-2">
+ <div className={`w-2 h-2 rounded-full shrink-0 ${PHASE_STATUS_COLORS[phase.status] || 'bg-gray-600'}`} />
+ <span className="text-xs text-gray-400 font-mono w-8 shrink-0">{phase.id || '??'}</span>
+ <span className="text-xs text-gray-300 truncate flex-1">{phase.title || phase.name}</span>
+ {phase.lifecycle && (
+ <div className="flex gap-0.5">
+ {LIFECYCLE_STEPS.map(step => (
+ <div
+ key={step}
+ className={`w-1.5 h-1.5 rounded-full ${
+ phase.lifecycle[step] === 'done' ? 'bg-port-success' :
+ phase.lifecycle[step] === 'active' ? 'bg-port-accent' :
+ 'bg-gray-700'
+ }`}
+ title={`${step}: ${phase.lifecycle[step] || 'pending'}`}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ ))}
+ </div>
+ );
+}
+
+export default function GsdProjectCard({ project, onRefresh }) {
+ const [expanded, setExpanded] = useState(false);
+ const [detail, setDetail] = useState(null);
+ const [loading, setLoading] = useState(false);
+
+ const loadDetail = async () => {
+ if (detail) return;
+ setLoading(true);
+ const data = await api.getGsdProject(project.appId).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setLoading(false);
+ if (data) setDetail(data);
+ };
+
+ const handleExpand = () => {
+ if (!expanded) loadDetail();
+ setExpanded(!expanded);
+ };
+
+ const phaseCount = detail?.phases?.length || 0;
+ const completedPhases = detail?.phases?.filter(p => p.status === 'completed').length || 0;
+
+ return (
+ <div className="bg-port-card border border-port-border rounded-lg overflow-hidden">
+ <button
+ onClick={handleExpand}
+ className="flex items-center justify-between w-full px-4 py-3 text-left hover:bg-white/5 transition-colors"
+ >
+ <div className="flex items-center gap-3 min-w-0">
+ <span className="text-sm font-semibold text-white truncate">{project.appName}</span>
+ {project.hasRoadmap && (
+ <span className="text-xs text-gray-500 font-mono shrink-0">
+ {completedPhases}/{phaseCount} phases
+ </span>
+ )}
+ </div>
+ <div className="flex items-center gap-2">
+ {project.hasConcerns && (
+ <span className="text-[10px] px-1.5 py-0.5 rounded bg-port-warning/20 text-port-warning">concerns</span>
+ )}
+ {expanded ? <ChevronUp size={16} className="text-gray-500" /> : <ChevronDown size={16} className="text-gray-500" />}
+ </div>
+ </button>
+
+ {expanded && (
+ <div className="px-4 pb-4 border-t border-port-border/50 pt-3 space-y-4">
+ {loading ? (
+ <p className="text-xs text-gray-500">Loading project details...</p>
+ ) : detail ? (
+ <>
+ {/* Phase Timeline */}
+ {detail.phases && (
+ <div>
+ <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-2">Phases</h4>
+ <PhaseTimeline phases={detail.phases} />
+ </div>
+ )}
+
+ {/* Concerns */}
+ {detail.concerns && (
+ <GsdConcernsPanel
+ appId={project.appId}
+ concerns={detail.concerns}
+ onTaskCreated={onRefresh}
+ />
+ )}
+
+ {/* State Info */}
+ {detail.state?.frontmatter && (
+ <div>
+ <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-2">State</h4>
+ <div className="grid grid-cols-2 gap-2 text-xs">
+ {Object.entries(detail.state.frontmatter).map(([key, value]) => (
+ <div key={key} className="bg-port-bg rounded px-2 py-1">
+ <span className="text-gray-500">{key}:</span>{' '}
+ <span className="text-gray-300">{String(value)}</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ </>
+ ) : (
+ <p className="text-xs text-gray-500">Failed to load project details</p>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/cos/tabs/GsdTab.jsx b/client/src/components/cos/tabs/GsdTab.jsx
new file mode 100644
index 0000000000..ea01554155
--- /dev/null
+++ b/client/src/components/cos/tabs/GsdTab.jsx
@@ -0,0 +1,71 @@
+import { useState, useEffect, useCallback } from 'react';
+import { RefreshCw, Compass } from 'lucide-react';
+import toast from 'react-hot-toast';
+import * as api from '../../../services/api';
+import GsdProjectCard from './GsdProjectCard';
+
+export default function GsdTab() {
+ const [projects, setProjects] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [refreshing, setRefreshing] = useState(false);
+
+ const fetchData = useCallback(async () => {
+ const projectsData = await api.getGsdProjects().catch(() => ({ projects: [] }));
+ setProjects(projectsData.projects || projectsData || []);
+ setLoading(false);
+ }, []);
+
+ useEffect(() => {
+ fetchData();
+ }, [fetchData]);
+
+ const handleRefresh = async () => {
+ setRefreshing(true);
+ await fetchData();
+ setRefreshing(false);
+ toast.success('GSD data refreshed');
+ };
+
+ if (loading) {
+ return <p className="text-sm text-gray-500">Loading GSD projects...</p>;
+ }
+
+ return (
+ <div className="space-y-6">
+ {/* Header */}
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <Compass size={18} className="text-port-accent" />
+ <h2 className="text-lg font-semibold text-white">GSD Projects</h2>
+ <span className="text-xs text-gray-500">({projects.length})</span>
+ </div>
+ <button
+ onClick={handleRefresh}
+ disabled={refreshing}
+ className="flex items-center gap-1.5 px-3 py-1.5 text-xs bg-port-card border border-port-border hover:border-port-accent/50 text-gray-400 hover:text-white rounded transition-colors disabled:opacity-50"
+ >
+ <RefreshCw size={12} className={refreshing ? 'animate-spin' : ''} /> Refresh
+ </button>
+ </div>
+
+ {/* Project Cards */}
+ {projects.length === 0 ? (
+ <div className="text-center py-12 text-gray-500">
+ <Compass size={48} className="mx-auto mb-3 opacity-30" />
+ <p className="text-sm">No GSD-enabled projects found</p>
+ <p className="text-xs mt-1">Apps with a <code className="text-port-accent">.planning/</code> directory will appear here</p>
+ </div>
+ ) : (
+ <div className="space-y-3">
+ {projects.map(project => (
+ <GsdProjectCard
+ key={project.appId}
+ project={project}
+ onRefresh={fetchData}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsx
index 8ab7a70417..048e9149e9 100644
--- a/client/src/pages/ChiefOfStaff.jsx
+++ b/client/src/pages/ChiefOfStaff.jsx
@@ -30,6 +30,7 @@ import {
ScriptsTab,
ScheduleTab,
DigestTab,
+ GsdTab,
ProductivityTab,
LearningTab,
MemoryTab,
@@ -817,6 +818,11 @@ export default function ChiefOfStaff() {
<DigestTab />
</div>
)}
+ {activeTab === 'gsd' && (
+ <div role="tabpanel" id="tabpanel-gsd" aria-labelledby="tab-gsd">
+ <GsdTab />
+ </div>
+ )}
{activeTab === 'productivity' && (
<div role="tabpanel" id="tabpanel-productivity" aria-labelledby="tab-productivity">
<ProductivityTab />
diff --git a/client/src/services/api.js b/client/src/services/api.js
index 60fb28b7dc..700b02b57d 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -1424,6 +1424,17 @@ export const connectPeer = (id) => request(`/instances/peers/${id}/connect`, { m
export const probePeer = (id) => request(`/instances/peers/${id}/probe`, { method: 'POST' });
export const queryPeer = (id, path) => request(`/instances/peers/${id}/query?path=${encodeURIComponent(path)}`);
+// GSD (Get Stuff Done) Integration
+export const getGsdProjects = () => request('/cos/gsd/projects');
+export const getGsdProject = (appId) => request(`/cos/gsd/projects/${appId}`);
+export const getGsdConcerns = (appId) => request(`/cos/gsd/projects/${appId}/concerns`);
+export const getGsdPhases = (appId) => request(`/cos/gsd/projects/${appId}/phases`);
+export const getGsdPhase = (appId, phaseId) => request(`/cos/gsd/projects/${appId}/phases/${phaseId}`);
+export const createGsdConcernTasks = (appId, data) => request(`/cos/gsd/projects/${appId}/concerns/tasks`, {
+ method: 'POST',
+ body: JSON.stringify(data)
+});
+
// Default export for simplified imports
export default {
get: (endpoint, options) => request(endpoint, { method: 'GET', ...options }),
diff --git a/package-lock.json b/package-lock.json
index d0162d57e2..c17f660146 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.17.1",
+ "version": "1.18.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.17.1",
+ "version": "1.18.0",
"license": "MIT",
"dependencies": {
"express": "^4.21.2",
diff --git a/package.json b/package.json
index dbbad80358..09d571a85e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.17.1",
+ "version": "1.18.0",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/index.js b/server/index.js
index 69841caac1..bde8cf9a32 100644
--- a/server/index.js
+++ b/server/index.js
@@ -26,6 +26,7 @@ import automationSchedulesRoutes from './routes/automationSchedules.js';
import agentActivityRoutes from './routes/agentActivity.js';
import agentToolsRoutes from './routes/agentTools.js';
import cosRoutes from './routes/cos.js';
+import gsdRoutes from './routes/gsd.js';
import scriptsRoutes from './routes/scripts.js';
import memoryRoutes from './routes/memory.js';
import notificationsRoutes from './routes/notifications.js';
@@ -205,6 +206,7 @@ app.use('/api/agents/tools/moltworld', moltworldToolsRoutes);
app.use('/api/agents/tools', agentToolsRoutes);
// Existing running agents routes (process management)
app.use('/api/agents', agentsRoutes);
+app.use('/api/cos/gsd', gsdRoutes);
app.use('/api/cos/scripts', scriptsRoutes); // Mount before /api/cos to avoid route conflicts
app.use('/api/cos', cosRoutes);
app.use('/api/memory', memoryRoutes);
diff --git a/server/routes/gsd.js b/server/routes/gsd.js
new file mode 100644
index 0000000000..ea95f3afd9
--- /dev/null
+++ b/server/routes/gsd.js
@@ -0,0 +1,95 @@
+/**
+ * GSD (Get Stuff Done) API Routes
+ *
+ * Mounted at /api/cos/gsd
+ * Provides endpoints for scanning, analyzing, and acting on GSD project state.
+ */
+
+import { Router } from 'express'
+import { z } from 'zod'
+import { asyncHandler, ServerError } from '../lib/errorHandler.js'
+import * as gsdService from '../services/gsdService.js'
+import { addTask } from '../services/cos.js'
+
+const router = Router()
+
+// Validation schemas
+const concernIdsSchema = z.object({
+ concernIds: z.array(z.string()).optional(),
+ all: z.boolean().optional()
+}).refine(data => data.all || (data.concernIds && data.concernIds.length > 0), {
+ message: 'Either concernIds or all:true is required'
+})
+
+
+// GET /projects — list GSD-enabled projects
+router.get('/projects', asyncHandler(async (req, res) => {
+ const projects = await gsdService.scanForGsdProjects()
+ res.json({ projects })
+}))
+
+// GET /projects/:appId — project detail
+router.get('/projects/:appId', asyncHandler(async (req, res) => {
+ const project = await gsdService.getGsdProject(req.params.appId)
+ if (!project) {
+ throw new ServerError('GSD project not found', { status: 404, code: 'GSD_PROJECT_NOT_FOUND' })
+ }
+ res.json(project)
+}))
+
+// GET /projects/:appId/concerns — parsed CONCERNS.md with severity
+router.get('/projects/:appId/concerns', asyncHandler(async (req, res) => {
+ const project = await gsdService.getGsdProject(req.params.appId)
+ if (!project) {
+ throw new ServerError('GSD project not found', { status: 404, code: 'GSD_PROJECT_NOT_FOUND' })
+ }
+ res.json({ concerns: project.concerns })
+}))
+
+// GET /projects/:appId/phases — phase list with status
+router.get('/projects/:appId/phases', asyncHandler(async (req, res) => {
+ const project = await gsdService.getGsdProject(req.params.appId)
+ if (!project) {
+ throw new ServerError('GSD project not found', { status: 404, code: 'GSD_PROJECT_NOT_FOUND' })
+ }
+ const pendingActions = await gsdService.getGsdPendingActions(req.params.appId)
+ res.json({ phases: project.phases, pendingActions })
+}))
+
+// GET /projects/:appId/phases/:phaseId — phase detail
+router.get('/projects/:appId/phases/:phaseId', asyncHandler(async (req, res) => {
+ const project = await gsdService.getGsdProject(req.params.appId)
+ if (!project) {
+ throw new ServerError('GSD project not found', { status: 404, code: 'GSD_PROJECT_NOT_FOUND' })
+ }
+ const phase = project.phases.find(p => p.id === req.params.phaseId)
+ if (!phase) {
+ throw new ServerError('Phase not found', { status: 404, code: 'GSD_PHASE_NOT_FOUND' })
+ }
+ res.json(phase)
+}))
+
+// POST /projects/:appId/concerns/tasks — create CoS tasks from selected concerns
+router.post('/projects/:appId/concerns/tasks', asyncHandler(async (req, res) => {
+ const body = concernIdsSchema.parse(req.body)
+ const allTasks = await gsdService.generateConcernTasks(req.params.appId)
+
+ if (allTasks.length === 0) {
+ throw new ServerError('No concerns found for this project', { status: 404, code: 'NO_CONCERNS' })
+ }
+
+ const tasksToCreate = body.all
+ ? allTasks
+ : allTasks.filter(t => body.concernIds.includes(t.metadata.gsdConcern))
+
+ const created = []
+ for (const task of tasksToCreate) {
+ const result = await addTask(task, 'internal')
+ created.push(result)
+ }
+
+ console.log(`📋 Created ${created.length} CoS tasks from GSD concerns for ${req.params.appId}`)
+ res.json({ created: created.length, tasks: created })
+}))
+
+export default router
diff --git a/server/services/gsdService.js b/server/services/gsdService.js
new file mode 100644
index 0000000000..e5e3a167be
--- /dev/null
+++ b/server/services/gsdService.js
@@ -0,0 +1,387 @@
+/**
+ * GSD (Get Stuff Done) Scanner Service
+ *
+ * Scans managed apps for .planning/ directories and parses GSD project state.
+ * Provides concern analysis and phase tracking for the Chief of Staff GSD integration.
+ */
+
+import { readFile, readdir, stat } from 'fs/promises'
+import { join } from 'path'
+import { createHash } from 'crypto'
+import { getActiveApps } from './apps.js'
+
+// 30-second TTL cache per app
+const projectCache = new Map()
+const CACHE_TTL = 30000
+
+function getCached(key) {
+ const entry = projectCache.get(key)
+ if (entry && Date.now() - entry.ts < CACHE_TTL) return entry.data
+ return null
+}
+function setCache(key, data) {
+ projectCache.set(key, { data, ts: Date.now() })
+}
+
+// Severity mapping for CONCERNS.md sections
+const SEVERITY_MAP = {
+ 'security considerations': 'CRITICAL',
+ 'known bugs': 'HIGH',
+ 'missing critical features': 'HIGH',
+ 'tech debt': 'MEDIUM',
+ 'performance': 'MEDIUM',
+ 'fragile areas': 'MEDIUM',
+ 'test coverage': 'MEDIUM',
+ 'dependencies at risk': 'LOW',
+ 'scaling limits': 'LOW'
+}
+
+/**
+ * Generate a deterministic hash ID from section title and item text
+ */
+function hashId(section, text) {
+ return createHash('md5').update(`${section}:${text}`).digest('hex').slice(0, 12)
+}
+
+/**
+ * Safely read a file, returning null if it doesn't exist
+ */
+async function safeReadFile(filePath) {
+ const content = await readFile(filePath, 'utf-8').catch(err => {
+ if (err.code === 'ENOENT') return null
+ throw err
+ })
+ return content
+}
+
+/**
+ * Safely stat a path, returning null if it doesn't exist
+ */
+async function safeStat(path) {
+ return stat(path).catch(err => {
+ if (err.code === 'ENOENT') return null
+ throw err
+ })
+}
+
+/**
+ * Scan all active apps for .planning/ directories
+ * Returns array of project summaries
+ */
+export async function scanForGsdProjects() {
+ const apps = await getActiveApps()
+ const projects = []
+
+ for (const app of apps) {
+ if (!app.repoPath) continue
+ const planningPath = join(app.repoPath, '.planning')
+ const planningInfo = await safeStat(planningPath)
+
+ if (planningInfo?.isDirectory()) {
+ const roadmapInfo = await safeStat(join(planningPath, 'ROADMAP.md'))
+ const stateInfo = await safeStat(join(planningPath, 'STATE.md'))
+ const concernsInfo = await safeStat(join(planningPath, 'CONCERNS.md'))
+
+ projects.push({
+ appId: app.id,
+ appName: app.name,
+ repoPath: app.repoPath,
+ planningPath,
+ hasRoadmap: !!roadmapInfo,
+ hasState: !!stateInfo,
+ hasConcerns: !!concernsInfo
+ })
+ }
+ }
+
+ console.log(`📋 GSD scan found ${projects.length} projects with .planning/`)
+ return projects
+}
+
+/**
+ * Parse ROADMAP.md to extract milestone table rows
+ */
+export async function parseRoadmapMd(filePath) {
+ const content = await safeReadFile(filePath)
+ if (!content) return null
+
+ const milestones = []
+ const lines = content.split('\n')
+
+ for (const line of lines) {
+ if (!line.startsWith('|')) continue
+ // Skip header separator rows (e.g., |---|---|---|)
+ if (/^\|[\s-]+\|/.test(line) && !line.match(/[a-zA-Z0-9]/)) continue
+ // Skip header rows
+ if (line.toLowerCase().includes('phase') && line.toLowerCase().includes('title')) continue
+
+ const cells = line.split('|').map(c => c.trim()).filter(Boolean)
+ if (cells.length >= 3) {
+ milestones.push({
+ phase: cells[0],
+ title: cells[1],
+ status: cells[2]
+ })
+ }
+ }
+
+ return { milestones, raw: content }
+}
+
+/**
+ * Parse STATE.md to extract YAML frontmatter
+ */
+export async function parseStateMd(filePath) {
+ const content = await safeReadFile(filePath)
+ if (!content) return null
+
+ const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/)
+ if (!frontmatterMatch) return { frontmatter: {}, raw: content }
+
+ const frontmatter = {}
+ const lines = frontmatterMatch[1].split('\n')
+ for (const line of lines) {
+ const colonIdx = line.indexOf(':')
+ if (colonIdx === -1) continue
+ const key = line.slice(0, colonIdx).trim()
+ const value = line.slice(colonIdx + 1).trim()
+ if (key) frontmatter[key] = value
+ }
+
+ return { frontmatter, raw: content }
+}
+
+/**
+ * Parse CONCERNS.md to extract sections with severity
+ */
+export async function parseConcernsMd(filePath) {
+ const content = await safeReadFile(filePath)
+ if (!content) return null
+
+ const sections = []
+ let currentSection = null
+ const lines = content.split('\n')
+
+ for (const line of lines) {
+ const headerMatch = line.match(/^##\s+(.+)/)
+ if (headerMatch) {
+ currentSection = {
+ title: headerMatch[1].trim(),
+ severity: 'MEDIUM',
+ items: []
+ }
+ // Map severity based on section title
+ const lowerTitle = currentSection.title.toLowerCase()
+ for (const [pattern, severity] of Object.entries(SEVERITY_MAP)) {
+ if (lowerTitle.includes(pattern)) {
+ currentSection.severity = severity
+ break
+ }
+ }
+ sections.push(currentSection)
+ continue
+ }
+
+ if (currentSection) {
+ const itemMatch = line.match(/^-\s+(.+)/)
+ if (itemMatch) {
+ const text = itemMatch[1].trim()
+ currentSection.items.push({
+ id: hashId(currentSection.title, text),
+ text
+ })
+ }
+ }
+ }
+
+ return { sections }
+}
+
+/**
+ * Parse PLAN.md in a phase directory
+ */
+export async function parsePhasePlan(phasePath) {
+ const planFile = join(phasePath, 'PLAN.md')
+ const content = await safeReadFile(planFile)
+ if (!content) return null
+
+ const frontmatter = {}
+ let bodyContent = content
+
+ const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/)
+ if (frontmatterMatch) {
+ const fmLines = frontmatterMatch[1].split('\n')
+ for (const line of fmLines) {
+ const colonIdx = line.indexOf(':')
+ if (colonIdx === -1) continue
+ const key = line.slice(0, colonIdx).trim()
+ const value = line.slice(colonIdx + 1).trim()
+ if (key) frontmatter[key] = value
+ }
+ bodyContent = content.slice(frontmatterMatch[0].length)
+ }
+
+ // Extract checkpoint tasks (lines with checkbox markers)
+ const tasks = []
+ const taskLines = bodyContent.split('\n')
+ for (const line of taskLines) {
+ const taskMatch = line.match(/^[-*]\s+\[([ xX])\]\s+(.+)/)
+ if (taskMatch) {
+ tasks.push({
+ completed: taskMatch[1].toLowerCase() === 'x',
+ text: taskMatch[2].trim()
+ })
+ }
+ }
+
+ return { frontmatter, tasks, raw: content }
+}
+
+/**
+ * Parse VERIFICATION.md in a phase directory
+ */
+export async function parseVerification(phasePath) {
+ const verifyFile = join(phasePath, 'VERIFICATION.md')
+ const content = await safeReadFile(verifyFile)
+ if (!content) return null
+
+ let status = 'unknown'
+ let score = null
+
+ // Look for status line
+ const statusMatch = content.match(/status:\s*(\w+)/i)
+ if (statusMatch) status = statusMatch[1].toLowerCase()
+
+ // Look for score
+ const scoreMatch = content.match(/score:\s*([\d.]+)/i)
+ if (scoreMatch) score = parseFloat(scoreMatch[1])
+
+ return { status, score, raw: content }
+}
+
+/**
+ * Get full GSD project state for a single app
+ */
+export async function getGsdProject(appIdOrPath) {
+ const cached = getCached(`project:${appIdOrPath}`)
+ if (cached) return cached
+
+ const apps = await getActiveApps()
+ const app = apps.find(a => a.id === appIdOrPath || a.repoPath === appIdOrPath)
+ if (!app) return null
+
+ const planningPath = join(app.repoPath, '.planning')
+ const planningInfo = await safeStat(planningPath)
+ if (!planningInfo?.isDirectory()) return null
+
+ const roadmap = await parseRoadmapMd(join(planningPath, 'ROADMAP.md'))
+ const state = await parseStateMd(join(planningPath, 'STATE.md'))
+ const concerns = await parseConcernsMd(join(planningPath, 'CONCERNS.md'))
+
+ // Scan for phase directories
+ const phases = []
+ const phasesDir = join(planningPath, 'phases')
+ const phasesDirInfo = await safeStat(phasesDir)
+ if (phasesDirInfo?.isDirectory()) {
+ const entries = await readdir(phasesDir, { withFileTypes: true })
+ for (const entry of entries) {
+ if (!entry.isDirectory()) continue
+ const phasePath = join(phasesDir, entry.name)
+ const plan = await parsePhasePlan(phasePath)
+ const verification = await parseVerification(phasePath)
+ phases.push({
+ id: entry.name,
+ path: phasePath,
+ plan,
+ verification
+ })
+ }
+ phases.sort((a, b) => a.id.localeCompare(b.id, undefined, { numeric: true }))
+ }
+
+ // Read config if present
+ const configContent = await safeReadFile(join(planningPath, 'config.json'))
+ const config = configContent ? JSON.parse(configContent) : null
+
+ const result = {
+ app: { id: app.id, name: app.name, repoPath: app.repoPath },
+ roadmap,
+ state,
+ concerns,
+ phases,
+ config
+ }
+
+ setCache(`project:${appIdOrPath}`, result)
+ return result
+}
+
+/**
+ * Analyze project state to find phases ready to advance
+ */
+export async function getGsdPendingActions(appId) {
+ const project = await getGsdProject(appId)
+ if (!project) return []
+
+ const actions = []
+ const currentPhase = project.state?.frontmatter?.current_phase
+
+ for (const phase of project.phases) {
+ const hasPlan = !!phase.plan
+ const hasVerification = !!phase.verification
+ const allTasksComplete = phase.plan?.tasks?.every(t => t.completed) ?? false
+ const verificationPassed = phase.verification?.status === 'passed'
+
+ let nextAction = null
+ if (!hasPlan) {
+ // No plan yet — needs research or planning
+ nextAction = 'plan'
+ } else if (!allTasksComplete) {
+ // Plan exists but tasks incomplete — needs execution
+ nextAction = 'execute'
+ } else if (!hasVerification || !verificationPassed) {
+ // Tasks complete but not verified
+ nextAction = 'verify'
+ }
+
+ if (nextAction) {
+ actions.push({
+ phaseId: phase.id,
+ currentStep: hasPlan ? (allTasksComplete ? 'executed' : 'planned') : 'unplanned',
+ nextAction
+ })
+ }
+ }
+
+ return actions
+}
+
+/**
+ * Generate CoS task objects from CONCERNS.md items
+ */
+export async function generateConcernTasks(appId) {
+ const project = await getGsdProject(appId)
+ if (!project?.concerns) return []
+
+ const tasks = []
+ for (const section of project.concerns.sections) {
+ for (const item of section.items) {
+ tasks.push({
+ id: `gsd-concern-${item.id}`,
+ description: `[GSD:Concern] ${section.title}: ${item.text}`,
+ priority: section.severity === 'CRITICAL' ? 'HIGH' : section.severity,
+ metadata: {
+ gsdConcern: item.id,
+ gsdSourceFile: 'CONCERNS.md',
+ gsdSection: section.title,
+ gsdSeverity: section.severity,
+ app: project.app.id
+ },
+ taskType: 'internal'
+ })
+ }
+ }
+
+ return tasks
+}
+
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 862863429a..63855001e1 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -2488,6 +2488,25 @@ ${task.metadata.jiraBranch ? 'Commit your changes to this branch. Do NOT switch
})
: null;
+ // Build .planning/ context section for GSD-enabled apps
+ let planningContextSection = '';
+ if (task.metadata?.app) {
+ const planningPath = join(workspaceDir, '.planning');
+ const hasPlanningDir = await stat(planningPath).then(s => s.isDirectory()).catch(() => false);
+ if (hasPlanningDir) {
+ const planningParts = [];
+ const stateContent = await readFile(join(planningPath, 'STATE.md'), 'utf-8').catch(() => null);
+ if (stateContent) planningParts.push(`### Current State\n\`\`\`\n${stateContent.slice(0, 1000)}\n\`\`\``);
+ const concernsContent = await readFile(join(planningPath, 'CONCERNS.md'), 'utf-8').catch(() => null);
+ if (concernsContent) planningParts.push(`### Known Concerns\n\`\`\`\n${concernsContent.slice(0, 1500)}\n\`\`\``);
+ const roadmapContent = await readFile(join(planningPath, 'ROADMAP.md'), 'utf-8').catch(() => null);
+ if (roadmapContent) planningParts.push(`### Roadmap\n\`\`\`\n${roadmapContent.slice(0, 1000)}\n\`\`\``);
+ if (planningParts.length > 0) {
+ planningContextSection = `\n## Project Planning Context (.planning/)\nThis project has GSD planning documents. Use this context to understand priorities and known issues.\n\n${planningParts.join('\n\n')}\n`;
+ }
+ }
+ }
+
// Try to use the prompt template system
const promptData = await buildPrompt('cos-agent-briefing', {
task,
@@ -2499,6 +2518,7 @@ ${task.metadata.jiraBranch ? 'Commit your changes to this branch. Do NOT switch
jiraSection,
compactionSection,
skillSection,
+ planningContextSection,
soulSection: digitalTwinSection, // Backwards compatibility for prompt templates
timestamp: new Date().toISOString()
}).catch(() => null);
@@ -2527,7 +2547,7 @@ ${Array.isArray(task.metadata?.screenshots) && task.metadata.screenshots.length
${worktreeSection}
${jiraSection}
${compactionSection}
-${skillSection ? `## Task-Type Skill Guidelines\n\n${skillSection}\n` : ''}
+${skillSection ? `## Task-Type Skill Guidelines\n\n${skillSection}\n` : ''}${planningContextSection}
## Instructions
1. Analyze the task requirements carefully
2. Make necessary changes to complete the task