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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: actionable GSD dashboard with phase cards, action triggers, and document editing
Adam Eivy4c65420b15d6
diff --git a/.changelog/v1.26.x.md b/.changelog/v1.26.x.mdnew file mode 100644index 0000000000..65f0ed2b12--- /dev/null+++ b/.changelog/v1.26.x.md@@ -0,0 +1,20 @@+# Release v1.26.x - Changelog++Released: YYYY-MM-DD++## Overview++Actionable GSD project management dashboard with phase detail views, action triggers, and document editing.++## 🎉 Features++- **GSD Phase Cards**: Expandable phase cards replace the minimal dot-timeline, showing sub-plans with task checklists, verification status/scores, research content, and summary metadata+- **GSD Phase Actions**: Plan/Execute/Verify buttons on each phase create CoS agent tasks with one click — also shown as a prominent "Next Action" banner at the top+- **GSD Project Header**: Dashboard header with progress bars (phases completed, phases planned), config badges, milestone status, and quick actions (Refresh, Claude Code, New Milestone)+- **GSD Documents Panel**: View and edit `.planning/` documents (PROJECT, ROADMAP, STATE, CONCERNS, RETROSPECTIVE, MILESTONES) with markdown rendering and git commit on save+- **Deep-linkable GSD Views**: Phase expansion and document selection persist in URL params (`?phase=03-apple-health-integration&doc=ROADMAP.md`)++## 🐛 Fixes++- **Phase file parsing**: Backend was looking for hardcoded `PLAN.md` and `VERIFICATION.md` in phase directories, but actual files use prefixed naming (`01-01-PLAN.md`, `01-VERIFICATION.md`) — phases now correctly scan for `*-PLAN.md`, `*-VERIFICATION.md`, `*-RESEARCH.md`, and `*-SUMMARY.md` files+- **Multi-plan phases**: Phases with multiple sub-plans (e.g., `03-01-PLAN.md`, `03-02-PLAN.md`, `03-03-PLAN.md`) are now properly parsed as arrays instead of returning nulldiff --git a/PLAN.md b/PLAN.mdindex 559bf68308..1b9c6bb642 100644--- a/PLAN.md+++ b/PLAN.md@@ -83,6 +83,7 @@ pm2 logs- [x] **GSD Tab: Smart State Detection & Guided Setup** — Extend `GET /api/apps/:id/documents` to return GSD status fields and update GSD tab empty state with stepped setup guide- [x] **GSD Tab: One-Click Agent Spawn & Open Claude Code** — Run buttons on setup steps create CoS tasks, Open Claude Code button launches CLI in app directory+- [x] **GSD Tab: Actionable Dashboard** — Fix phase file parsing bug, add phase action triggers, document CRUD, expandable phase cards with sub-plans/verification/research, deep-linkable phase and document views#### GSD Smart State Detectiondiff --git a/client/src/components/apps/tabs/GsdTab.jsx b/client/src/components/apps/tabs/GsdTab.jsxindex a42116bd4e..ebee890fb7 100644--- a/client/src/components/apps/tabs/GsdTab.jsx+++ b/client/src/components/apps/tabs/GsdTab.jsx@@ -1,9 +1,12 @@import { useState, useEffect } from 'react';+import { useSearchParams } from 'react-router-dom';import { RefreshCw, Compass, CheckCircle, ArrowRight, FolderSearch, FileText, Map, Play, Terminal } from 'lucide-react';import toast from 'react-hot-toast';import BrailleSpinner from '../../BrailleSpinner';-import PhaseTimeline from '../../gsd/PhaseTimeline';+import GsdProjectHeader from '../../gsd/GsdProjectHeader';+import PhaseCardList from '../../gsd/PhaseCardList';import GsdConcernsPanel from '../../cos/tabs/GsdConcernsPanel';+import GsdDocumentsPanel from '../../gsd/GsdDocumentsPanel';import * as api from '../../../services/api';const STEP_DESCRIPTIONS = {@@ -157,11 +160,83 @@ function GsdSetupGuide({ gsd, appId, repoPath, onRefresh }) {);}+function NextActionBanner({ pendingActions, appId }) {+ const [triggering, setTriggering] = useState(false);++ if (!pendingActions?.length) return null;++ // Show the first pending action+ const action = pendingActions[0];+ const actionLabels = {+ plan: { label: 'Plan', desc: 'Create a detailed execution plan', style: 'border-port-warning/30 bg-port-warning/5' },+ execute: { label: 'Execute', desc: 'Execute the plan for this phase', style: 'border-port-accent/30 bg-port-accent/5' },+ verify: { label: 'Verify', desc: 'Verify the implementation', style: 'border-purple-600/30 bg-purple-600/5' },+ };+ const cfg = actionLabels[action.nextAction] || actionLabels.plan;++ const handleTrigger = async () => {+ setTriggering(true);+ const result = await api.triggerGsdPhaseAction(appId, action.phaseId, action.nextAction).catch(() => null);+ setTriggering(false);+ if (result) {+ toast.success(`${action.nextAction} task created for ${action.phaseId}`);+ }+ };++ return (+ <div className={`border rounded-lg p-4 flex items-center justify-between ${cfg.style}`}>+ <div>+ <div className="flex items-center gap-2 mb-1">+ <ArrowRight size={14} className="text-gray-400" />+ <span className="text-sm font-medium text-white">Next: {cfg.label} phase {action.phaseId}</span>+ </div>+ <p className="text-xs text-gray-500">{cfg.desc}</p>+ </div>+ <button+ onClick={handleTrigger}+ disabled={triggering}+ className="px-4 py-2 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-sm flex items-center gap-2 border border-port-accent/30 disabled:opacity-50"+ >+ <Play size={14} /> {triggering ? 'Creating...' : `${cfg.label} Phase`}+ </button>+ </div>+ );+}+export default function GsdTab({ appId, repoPath }) {+ const [searchParams, setSearchParams] = useSearchParams();const [project, setProject] = useState(null);+ const [pendingActions, setPendingActions] = useState([]);const [gsdStatus, setGsdStatus] = useState(null);const [loading, setLoading] = useState(true);+ const expandedPhase = searchParams.get('phase') || null;+ const selectedDoc = searchParams.get('doc') || null;++ const setExpandedPhase = (phaseId) => {+ setSearchParams(prev => {+ const next = new URLSearchParams(prev);+ if (phaseId && phaseId !== expandedPhase) {+ next.set('phase', phaseId);+ } else {+ next.delete('phase');+ }+ return next;+ }, { replace: true });+ };++ const setSelectedDoc = (docName) => {+ setSearchParams(prev => {+ const next = new URLSearchParams(prev);+ if (docName) {+ next.set('doc', docName);+ } else {+ next.delete('doc');+ }+ return next;+ }, { replace: true });+ };+const fetchData = async () => {setLoading(true);@@ -173,13 +248,21 @@ export default function GsdTab({ appId, repoPath }) {// Only fetch project data if we have a roadmap + state (full project)if (gsd.hasRoadmap && gsd.hasState) {- const resp = await fetch(`/api/cos/gsd/projects/${appId}`).catch(() => null);- if (resp?.ok) {- const data = await resp.json().catch(() => null);+ const [projectResp, phasesResp] = await Promise.all([+ fetch(`/api/cos/gsd/projects/${appId}`).catch(() => null),+ fetch(`/api/cos/gsd/projects/${appId}/phases`).catch(() => null),+ ]);+ if (projectResp?.ok) {+ const data = await projectResp.json().catch(() => null);setProject(data);}+ if (phasesResp?.ok) {+ const data = await phasesResp.json().catch(() => null);+ setPendingActions(data?.pendingActions || []);+ }} else {setProject(null);+ setPendingActions([]);}setLoading(false);@@ -198,31 +281,28 @@ export default function GsdTab({ appId, repoPath }) {return <GsdSetupGuide gsd={gsdStatus || {}} appId={appId} repoPath={repoPath} onRefresh={fetchData} />;}- const phaseCount = project?.phases?.length || 0;- const completedPhases = project?.phases?.filter(p => p.status === 'completed').length || 0;-return (<div className="max-w-5xl space-y-6">- <div className="flex items-center justify-between">- <div>- <h3 className="text-lg font-semibold text-white">GSD Project</h3>- <p className="text-sm text-gray-500">{completedPhases}/{phaseCount} phases completed</p>- </div>- <button- onClick={fetchData}- className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"- >- <RefreshCw size={14} /> Refresh- </button>- </div>+ {/* Project Header */}+ <GsdProjectHeader+ project={project}+ pendingActions={pendingActions}+ appId={appId}+ repoPath={repoPath}+ onRefresh={fetchData}+ />- {/* Phase Timeline */}- {project?.phases && (- <div className="bg-port-card border border-port-border rounded-lg p-4">- <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-3">Phases</h4>- <PhaseTimeline phases={project.phases} />- </div>- )}+ {/* Next Action Banner */}+ <NextActionBanner pendingActions={pendingActions} appId={appId} />++ {/* Phase Cards */}+ <PhaseCardList+ phases={project?.phases || []}+ pendingActions={pendingActions}+ appId={appId}+ expandedPhase={expandedPhase}+ onTogglePhase={setExpandedPhase}+ />{/* Concerns */}{project?.concerns && (@@ -235,20 +315,12 @@ export default function GsdTab({ appId, repoPath }) {</div>)}- {/* State Frontmatter */}- {project?.state?.frontmatter && (- <div className="bg-port-card border border-port-border rounded-lg p-4">- <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-3">State</h4>- <div className="grid grid-cols-2 gap-2 text-xs">- {Object.entries(project.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>- )}+ {/* Documents Panel */}+ <GsdDocumentsPanel+ appId={appId}+ selectedDoc={selectedDoc}+ onSelectDoc={setSelectedDoc}+ /></div>);}diff --git a/client/src/components/gsd/GsdDocumentsPanel.jsx b/client/src/components/gsd/GsdDocumentsPanel.jsxnew file mode 100644index 0000000000..9b2fa88e64--- /dev/null+++ b/client/src/components/gsd/GsdDocumentsPanel.jsx@@ -0,0 +1,141 @@+import { useState, useEffect } from 'react';+import { FileText, Pencil, Save, X } from 'lucide-react';+import toast from 'react-hot-toast';+import BrailleSpinner from '../BrailleSpinner';+import MarkdownOutput from '../cos/MarkdownOutput';+import * as api from '../../services/api';++const DOCUMENTS = [+ { key: 'PROJECT.md', label: 'Project' },+ { key: 'ROADMAP.md', label: 'Roadmap' },+ { key: 'STATE.md', label: 'State' },+ { key: 'CONCERNS.md', label: 'Concerns' },+ { key: 'RETROSPECTIVE.md', label: 'Retrospective' },+ { key: 'MILESTONES.md', label: 'Milestones' },+];++export default function GsdDocumentsPanel({ appId, selectedDoc, onSelectDoc }) {+ const [content, setContent] = useState(null);+ const [loading, setLoading] = useState(false);+ const [editing, setEditing] = useState(false);+ const [editContent, setEditContent] = useState('');+ const [saving, setSaving] = useState(false);++ useEffect(() => {+ if (!selectedDoc) return;+ setEditing(false);+ setLoading(true);+ api.getGsdDocument(appId, selectedDoc)+ .then(data => setContent(data?.content || null))+ .catch(() => setContent(null))+ .finally(() => setLoading(false));+ }, [appId, selectedDoc]);++ const enterEditMode = () => {+ setEditContent(content || '');+ setEditing(true);+ };++ const cancelEdit = () => {+ setEditing(false);+ setEditContent('');+ };++ const handleSave = async () => {+ setSaving(true);+ const result = await api.saveGsdDocument(appId, selectedDoc, editContent).catch(() => null);+ setSaving(false);++ if (!result) {+ toast.error('Failed to save document');+ return;+ }++ if (result.noChanges) {+ toast('No changes to commit', { icon: '\u2139\uFE0F' });+ setEditing(false);+ return;+ }++ toast.success(`Committed ${result.created ? 'new' : 'updated'} ${selectedDoc} (${result.hash})`);+ setContent(editContent);+ setEditing(false);+ };++ return (+ <div>+ <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-3">Documents</h4>+ <div className="flex flex-col sm:flex-row gap-4">+ {/* Document pills */}+ <div className="flex sm:flex-col gap-1.5 flex-wrap sm:w-36 shrink-0">+ {DOCUMENTS.map(doc => (+ <button+ key={doc.key}+ onClick={() => onSelectDoc(doc.key)}+ className={`px-3 py-1.5 rounded-lg text-xs text-left transition-colors flex items-center gap-1.5 ${+ selectedDoc === doc.key+ ? 'bg-port-accent/20 text-port-accent border border-port-accent/30'+ : 'bg-port-card border border-port-border text-gray-400 hover:text-white hover:bg-port-border/50'+ }`}+ >+ <FileText size={12} />+ {doc.label}+ </button>+ ))}+ </div>++ {/* Content area */}+ <div className="flex-1 bg-port-card border border-port-border rounded-lg p-4 min-h-[250px] overflow-auto">+ {!selectedDoc ? (+ <p className="text-gray-500 text-sm">Select a document to view</p>+ ) : loading ? (+ <BrailleSpinner text="Loading document" />+ ) : editing ? (+ <div className="space-y-3">+ <div className="flex items-center justify-between">+ <span className="text-sm text-gray-400">Editing {selectedDoc}</span>+ <div className="flex gap-2">+ <button+ onClick={cancelEdit}+ disabled={saving}+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"+ >+ <X size={14} /> Cancel+ </button>+ <button+ onClick={handleSave}+ disabled={saving}+ className="px-3 py-1.5 bg-port-success/20 text-port-success hover:bg-port-success/30 rounded-lg text-xs flex items-center gap-1"+ >+ {saving ? <BrailleSpinner size="sm" /> : <Save size={14} />}+ {saving ? 'Saving...' : 'Save & Commit'}+ </button>+ </div>+ </div>+ <textarea+ value={editContent}+ onChange={e => setEditContent(e.target.value)}+ className="w-full h-[500px] bg-[#0d0d0d] text-gray-200 border border-port-border rounded-lg p-3 font-mono text-sm resize-y focus:outline-none focus:border-port-accent/50"+ spellCheck={false}+ />+ </div>+ ) : content ? (+ <div>+ <div className="flex justify-end mb-2">+ <button+ onClick={enterEditMode}+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"+ >+ <Pencil size={14} /> Edit+ </button>+ </div>+ <MarkdownOutput content={content} />+ </div>+ ) : (+ <p className="text-gray-500 text-sm">Document not found or empty</p>+ )}+ </div>+ </div>+ </div>+ );+}diff --git a/client/src/components/gsd/GsdProjectHeader.jsx b/client/src/components/gsd/GsdProjectHeader.jsxnew file mode 100644index 0000000000..46dc662615--- /dev/null+++ b/client/src/components/gsd/GsdProjectHeader.jsx@@ -0,0 +1,126 @@+import { RefreshCw, Terminal, Play, Settings } from 'lucide-react';+import toast from 'react-hot-toast';+import * as api from '../../services/api';++const STATUS_COLORS = {+ active: 'bg-port-accent text-port-accent',+ completed: 'bg-port-success text-port-success',+ paused: 'bg-port-warning text-port-warning',+};++export default function GsdProjectHeader({ project, pendingActions, appId, repoPath, onRefresh }) {+ const state = project?.state?.frontmatter || {};+ const phases = project?.phases || [];+ const completedPhases = phases.filter(p => p.totalTasks > 0 && p.completedTasks === p.totalTasks && p.verification?.status === 'passed').length;+ const phasesWithPlans = phases.filter(p => p.plans?.length > 0).length;+ const milestoneStatus = state.milestone_status || state.status || 'active';+ const milestoneName = state.current_milestone || state.milestone || 'Current Milestone';+ const projectName = project?.app?.name || appId;+ const mode = project?.config?.mode || state.mode;+ const depth = project?.config?.depth || state.depth;++ const handleOpenClaude = async () => {+ toast('Opening Claude Code...');+ await api.openAppInClaude(appId).catch(() => null);+ };++ const handleNewMilestone = async () => {+ await api.addCosTask({+ description: 'Run /gsd:new-milestone to start a new milestone cycle',+ app: appId,+ priority: 'MEDIUM',+ }).catch(() => null);+ toast.success('New milestone task created');+ };++ const statusStyle = STATUS_COLORS[milestoneStatus] || STATUS_COLORS.active;+ const allPhasesComplete = completedPhases === phases.length && phases.length > 0;++ return (+ <div className="bg-port-card border border-port-border rounded-lg p-5">+ <div className="flex items-start justify-between gap-4">+ <div className="min-w-0 flex-1">+ <div className="flex items-center gap-3 mb-2">+ <h3 className="text-lg font-semibold text-white truncate">{projectName}</h3>+ <span className={`px-2 py-0.5 rounded-full text-xs font-medium bg-opacity-20 ${statusStyle}`}>+ {milestoneStatus}+ </span>+ </div>+ {milestoneName && (+ <p className="text-sm text-gray-400 mb-3">{milestoneName}</p>+ )}++ {/* Progress bars */}+ <div className="grid grid-cols-2 gap-4">+ <div>+ <div className="flex justify-between text-xs text-gray-500 mb-1">+ <span>Phases</span>+ <span>{completedPhases}/{phases.length}</span>+ </div>+ <div className="h-1.5 bg-port-bg rounded-full overflow-hidden">+ <div+ className="h-full bg-port-success rounded-full transition-all"+ style={{ width: phases.length ? `${(completedPhases / phases.length) * 100}%` : '0%' }}+ />+ </div>+ </div>+ <div>+ <div className="flex justify-between text-xs text-gray-500 mb-1">+ <span>Planned</span>+ <span>{phasesWithPlans}/{phases.length}</span>+ </div>+ <div className="h-1.5 bg-port-bg rounded-full overflow-hidden">+ <div+ className="h-full bg-port-accent rounded-full transition-all"+ style={{ width: phases.length ? `${(phasesWithPlans / phases.length) * 100}%` : '0%' }}+ />+ </div>+ </div>+ </div>++ {/* Config badges */}+ {(mode || depth) && (+ <div className="flex gap-2 mt-3">+ {mode && (+ <span className="px-2 py-0.5 bg-port-bg border border-port-border rounded text-xs text-gray-400 flex items-center gap-1">+ <Settings size={10} /> {mode}+ </span>+ )}+ {depth && (+ <span className="px-2 py-0.5 bg-port-bg border border-port-border rounded text-xs text-gray-400">+ depth: {depth}+ </span>+ )}+ </div>+ )}+ </div>++ {/* Action buttons */}+ <div className="flex items-center gap-2 flex-shrink-0">+ {allPhasesComplete && (+ <button+ onClick={handleNewMilestone}+ className="px-3 py-1.5 bg-port-success/20 hover:bg-port-success/30 text-port-success rounded-lg text-xs flex items-center gap-1 border border-port-success/30"+ >+ <Play size={14} /> New Milestone+ </button>+ )}+ {repoPath && (+ <button+ onClick={handleOpenClaude}+ className="px-3 py-1.5 bg-purple-600/20 hover:bg-purple-600/30 text-purple-400 rounded-lg text-xs flex items-center gap-1 border border-purple-600/30"+ >+ <Terminal size={14} /> Claude Code+ </button>+ )}+ <button+ onClick={onRefresh}+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"+ >+ <RefreshCw size={14} /> Refresh+ </button>+ </div>+ </div>+ </div>+ );+}diff --git a/client/src/components/gsd/PhaseCard.jsx b/client/src/components/gsd/PhaseCard.jsxnew file mode 100644index 0000000000..5fdfb4c2dc--- /dev/null+++ b/client/src/components/gsd/PhaseCard.jsx@@ -0,0 +1,224 @@+import { useState } from 'react';+import { ChevronDown, ChevronRight, Play, CheckCircle, Circle, Clock, FileText, Search, ShieldCheck } from 'lucide-react';+import toast from 'react-hot-toast';+import MarkdownOutput from '../cos/MarkdownOutput';+import * as api from '../../services/api';++const STATUS_CONFIG = {+ completed: { color: 'bg-port-success', icon: CheckCircle, label: 'Completed' },+ executed: { color: 'bg-port-accent', icon: Clock, label: 'Executed' },+ planned: { color: 'bg-port-warning', icon: FileText, label: 'Planned' },+ unplanned: { color: 'bg-gray-600', icon: Circle, label: 'Pending' },+};++const ACTION_CONFIG = {+ plan: { label: 'Plan', icon: FileText, style: 'bg-port-warning/20 text-port-warning border-port-warning/30 hover:bg-port-warning/30' },+ execute: { label: 'Execute', icon: Play, style: 'bg-port-accent/20 text-port-accent border-port-accent/30 hover:bg-port-accent/30' },+ verify: { label: 'Verify', icon: ShieldCheck, style: 'bg-purple-600/20 text-purple-400 border-purple-600/30 hover:bg-purple-600/30' },+};++function getPhaseStatus(phase, pendingAction) {+ if (!pendingAction) return 'completed';+ return pendingAction.currentStep;+}++function formatPhaseName(id) {+ // "03-apple-health-integration" → "Apple Health Integration"+ const parts = id.split('-');+ const num = parts[0];+ const name = parts.slice(1).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');+ return { num, name };+}++export default function PhaseCard({ phase, pendingAction, appId, expanded, onToggle }) {+ const [triggeringAction, setTriggeringAction] = useState(false);+ const [expandedPlan, setExpandedPlan] = useState(null);+ const [showResearch, setShowResearch] = useState(false);++ const status = getPhaseStatus(phase, pendingAction);+ const statusCfg = STATUS_CONFIG[status] || STATUS_CONFIG.unplanned;+ const StatusIcon = statusCfg.icon;+ const { num, name } = formatPhaseName(phase.id);+ const actionCfg = pendingAction ? ACTION_CONFIG[pendingAction.nextAction] : null;+ const progressPct = phase.totalTasks > 0 ? (phase.completedTasks / phase.totalTasks) * 100 : 0;++ const handleTriggerAction = async (e) => {+ e.stopPropagation();+ if (!pendingAction) return;+ setTriggeringAction(true);+ const result = await api.triggerGsdPhaseAction(appId, phase.id, pendingAction.nextAction).catch(() => null);+ setTriggeringAction(false);+ if (result) {+ toast.success(`${pendingAction.nextAction} task created for phase ${num}`);+ }+ };++ return (+ <div className="bg-port-card border border-port-border rounded-lg overflow-hidden">+ {/* Collapsed row */}+ <button+ onClick={onToggle}+ className="w-full flex items-center gap-3 p-3 hover:bg-port-border/20 transition-colors text-left"+ >+ {expanded ? <ChevronDown size={14} className="text-gray-500 shrink-0" /> : <ChevronRight size={14} className="text-gray-500 shrink-0" />}+ <div className={`w-2.5 h-2.5 rounded-full shrink-0 ${statusCfg.color}`} title={statusCfg.label} />+ <span className="text-xs text-gray-500 font-mono w-6 shrink-0">{num}</span>+ <span className="text-sm text-gray-200 truncate flex-1">{name || phase.id}</span>++ {/* Progress bar */}+ {phase.totalTasks > 0 && (+ <div className="w-20 flex items-center gap-1.5 shrink-0">+ <div className="flex-1 h-1 bg-port-bg rounded-full overflow-hidden">+ <div className="h-full bg-port-success rounded-full" style={{ width: `${progressPct}%` }} />+ </div>+ <span className="text-xs text-gray-500 w-8 text-right">{phase.completedTasks}/{phase.totalTasks}</span>+ </div>+ )}++ {/* Plan count badge */}+ {phase.plans?.length > 0 && (+ <span className="px-1.5 py-0.5 bg-port-bg border border-port-border rounded text-xs text-gray-400 shrink-0">+ {phase.plans.length} plan{phase.plans.length > 1 ? 's' : ''}+ </span>+ )}++ {/* Verification badge */}+ {phase.verification && (+ <span className={`px-1.5 py-0.5 rounded text-xs shrink-0 ${+ phase.verification.status === 'passed'+ ? 'bg-port-success/20 text-port-success'+ : 'bg-port-warning/20 text-port-warning'+ }`}>+ {phase.verification.score != null ? `${phase.verification.score}/10` : phase.verification.status}+ </span>+ )}++ {/* Next action button */}+ {actionCfg && (+ <button+ onClick={handleTriggerAction}+ disabled={triggeringAction}+ className={`px-2.5 py-1 rounded-lg text-xs flex items-center gap-1 border shrink-0 disabled:opacity-50 ${actionCfg.style}`}+ >+ <actionCfg.icon size={12} /> {triggeringAction ? 'Creating...' : actionCfg.label}+ </button>+ )}+ </button>++ {/* Expanded detail */}+ {expanded && (+ <div className="border-t border-port-border p-4 space-y-4">+ {/* Sub-plans */}+ {phase.plans?.length > 0 && (+ <div>+ <h5 className="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Plans</h5>+ <div className="space-y-2">+ {phase.plans.map((plan, idx) => {+ const isExpanded = expandedPlan === idx;+ const planCompleted = plan.tasks.filter(t => t.completed).length;+ return (+ <div key={plan.filename} className="bg-port-bg border border-port-border rounded-lg overflow-hidden">+ <button+ onClick={() => setExpandedPlan(isExpanded ? null : idx)}+ className="w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-port-border/20"+ >+ {isExpanded ? <ChevronDown size={12} className="text-gray-500" /> : <ChevronRight size={12} className="text-gray-500" />}+ <span className="text-xs font-mono text-gray-400">{plan.filename}</span>+ {plan.frontmatter?.phase && (+ <span className="text-xs text-gray-500 truncate">{plan.frontmatter.phase}</span>+ )}+ <span className="ml-auto text-xs text-gray-500">{planCompleted}/{plan.tasks.length} tasks</span>+ </button>+ {isExpanded && (+ <div className="px-3 pb-3 space-y-2">+ {/* Frontmatter summary */}+ {Object.keys(plan.frontmatter).length > 0 && (+ <div className="flex flex-wrap gap-1.5">+ {Object.entries(plan.frontmatter).slice(0, 6).map(([key, val]) => (+ <span key={key} className="px-1.5 py-0.5 bg-port-card border border-port-border rounded text-xs text-gray-500">+ {key}: <span className="text-gray-300">{String(val).slice(0, 40)}</span>+ </span>+ ))}+ </div>+ )}+ {/* Task checklist */}+ {plan.tasks.length > 0 && (+ <div className="space-y-1">+ {plan.tasks.map((task, ti) => (+ <div key={ti} className="flex items-start gap-2 text-xs">+ <span className={`mt-0.5 shrink-0 ${task.completed ? 'text-port-success' : 'text-gray-600'}`}>+ {task.completed ? '\u2611' : '\u2610'}+ </span>+ <span className={task.completed ? 'text-gray-500 line-through' : 'text-gray-300'}>{task.text}</span>+ </div>+ ))}+ </div>+ )}+ </div>+ )}+ </div>+ );+ })}+ </div>+ </div>+ )}++ {/* Summaries */}+ {phase.summaries?.length > 0 && (+ <div>+ <h5 className="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Summaries</h5>+ <div className="space-y-2">+ {phase.summaries.map(summary => {+ const metrics = summary.frontmatter;+ return (+ <div key={summary.filename} className="bg-port-bg border border-port-border rounded-lg px-3 py-2">+ <span className="text-xs font-mono text-gray-400">{summary.filename}</span>+ {metrics.duration && <span className="text-xs text-gray-500 ml-2">{metrics.duration}</span>}+ {metrics.completed && <span className="text-xs text-gray-500 ml-2">{metrics.completed}</span>}+ </div>+ );+ })}+ </div>+ </div>+ )}++ {/* Verification */}+ {phase.verification && (+ <div>+ <h5 className="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Verification</h5>+ <div className="bg-port-bg border border-port-border rounded-lg px-3 py-2 flex items-center gap-3">+ <span className={`px-2 py-0.5 rounded text-xs font-medium ${+ phase.verification.status === 'passed' ? 'bg-port-success/20 text-port-success' : 'bg-port-warning/20 text-port-warning'+ }`}>+ {phase.verification.status}+ </span>+ {phase.verification.score != null && (+ <span className="text-xs text-gray-400">Score: {phase.verification.score}/10</span>+ )}+ </div>+ </div>+ )}++ {/* Research */}+ {phase.research && (+ <div>+ <button+ onClick={() => setShowResearch(!showResearch)}+ className="flex items-center gap-2 text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2 hover:text-gray-300"+ >+ <Search size={12} />+ Research+ {showResearch ? <ChevronDown size={12} /> : <ChevronRight size={12} />}+ </button>+ {showResearch && (+ <div className="bg-port-bg border border-port-border rounded-lg p-3 max-h-96 overflow-y-auto">+ <MarkdownOutput content={phase.research.raw} />+ </div>+ )}+ </div>+ )}+ </div>+ )}+ </div>+ );+}diff --git a/client/src/components/gsd/PhaseCardList.jsx b/client/src/components/gsd/PhaseCardList.jsxnew file mode 100644index 0000000000..2f4987bf62--- /dev/null+++ b/client/src/components/gsd/PhaseCardList.jsx@@ -0,0 +1,28 @@+import PhaseCard from './PhaseCard';++export default function PhaseCardList({ phases = [], pendingActions = [], appId, expandedPhase, onTogglePhase }) {+ if (phases.length === 0) {+ return <p className="text-xs text-gray-500 italic">No phases found</p>;+ }++ const actionMap = {};+ for (const action of pendingActions) {+ actionMap[action.phaseId] = action;+ }++ return (+ <div className="space-y-2">+ <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider">Phases</h4>+ {phases.map(phase => (+ <PhaseCard+ key={phase.id}+ phase={phase}+ pendingAction={actionMap[phase.id]}+ appId={appId}+ expanded={expandedPhase === phase.id}+ onToggle={() => onTogglePhase(phase.id)}+ />+ ))}+ </div>+ );+}diff --git a/client/src/services/api.js b/client/src/services/api.jsindex a25a904034..96d81ddf1e 100644--- a/client/src/services/api.js+++ b/client/src/services/api.js@@ -1466,6 +1466,15 @@ export const createGsdConcernTasks = (appId, data) => request(`/cos/gsd/projectsmethod: 'POST',body: JSON.stringify(data)});+export const triggerGsdPhaseAction = (appId, phaseId, action) => request(`/cos/gsd/projects/${appId}/phases/${phaseId}/action`, {+ method: 'POST',+ body: JSON.stringify({ action })+});+export const getGsdDocument = (appId, docName) => request(`/cos/gsd/projects/${appId}/documents/${docName}`);+export const saveGsdDocument = (appId, docName, content, commitMessage) => request(`/cos/gsd/projects/${appId}/documents/${docName}`, {+ method: 'PUT',+ body: JSON.stringify({ content, ...(commitMessage && { commitMessage }) })+});// Default export for simplified importsexport default {diff --git a/package-lock.json b/package-lock.jsonindex 28ba5ddb5a..7615f0174b 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "portos",- "version": "1.26.0",+ "version": "1.27.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "portos",- "version": "1.26.0",+ "version": "1.27.0","license": "MIT","dependencies": {"express": "^4.21.2",diff --git a/package.json b/package.jsonindex e48c41854b..380d7ff527 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "portos",- "version": "1.26.0",+ "version": "1.27.0","private": true,"description": "Local dev machine App OS portal","author": "Adam Eivy (@antic|@atomantic)",diff --git a/server/routes/gsd.js b/server/routes/gsd.jsindex ea95f3afd9..d98846febb 100644--- a/server/routes/gsd.js+++ b/server/routes/gsd.js@@ -7,9 +7,14 @@import { Router } from 'express'import { z } from 'zod'+import { existsSync } from 'fs'+import { readFile, writeFile } from 'fs/promises'+import { join, resolve } from 'path'import { asyncHandler, ServerError } from '../lib/errorHandler.js'import * as gsdService from '../services/gsdService.js'import { addTask } from '../services/cos.js'+import { getActiveApps } from '../services/apps.js'+import * as git from '../services/git.js'const router = Router()@@ -21,6 +26,35 @@ const concernIdsSchema = z.object({message: 'Either concernIds or all:true is required'})+const phaseActionSchema = z.object({+ action: z.enum(['plan', 'execute', 'verify'])+})++const documentUpdateSchema = z.object({+ content: z.string(),+ commitMessage: z.string().optional()+})++const GSD_ALLOWED_DOCUMENTS = ['PROJECT.md', 'ROADMAP.md', 'STATE.md', 'CONCERNS.md', 'RETROSPECTIVE.md', 'MILESTONES.md']++const GSD_ACTION_DESCRIPTIONS = {+ plan: (phaseId) => `Run /gsd:plan-phase to create a detailed plan for phase ${phaseId}`,+ execute: (phaseId) => `Run /gsd:execute-phase to execute phase ${phaseId}`,+ verify: (phaseId) => `Run /gsd:verify-work to verify phase ${phaseId} implementation`+}++/**+ * Load app and resolve .planning path, attach to req+ */+async function loadAppPlanning(req) {+ const apps = await getActiveApps()+ const app = apps.find(a => a.id === req.params.appId)+ if (!app?.repoPath) return null+ const planningPath = join(app.repoPath, '.planning')+ if (!existsSync(planningPath)) return null+ return { app, planningPath }+}+// GET /projects — list GSD-enabled projectsrouter.get('/projects', asyncHandler(async (req, res) => {@@ -92,4 +126,94 @@ router.post('/projects/:appId/concerns/tasks', asyncHandler(async (req, res) =>res.json({ created: created.length, tasks: created })}))+// POST /projects/:appId/phases/:phaseId/action — trigger plan/execute/verify as CoS task+router.post('/projects/:appId/phases/:phaseId/action', asyncHandler(async (req, res) => {+ const { action } = phaseActionSchema.parse(req.body)+ const { appId, phaseId } = req.params++ const project = await gsdService.getGsdProject(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 === phaseId)+ if (!phase) {+ throw new ServerError('Phase not found', { status: 404, code: 'GSD_PHASE_NOT_FOUND' })+ }++ const description = GSD_ACTION_DESCRIPTIONS[action](phaseId)+ const result = await addTask({+ description,+ app: appId,+ priority: 'MEDIUM',+ metadata: { gsdPhase: phaseId, gsdAction: action }+ }, 'internal')++ console.log(`🎯 GSD ${action} task created for ${appId} phase ${phaseId}`)+ res.json({ success: true, task: result })+}))++// GET /projects/:appId/documents/:docName — read a .planning/ document+router.get('/projects/:appId/documents/:docName', asyncHandler(async (req, res) => {+ const { docName } = req.params+ if (!GSD_ALLOWED_DOCUMENTS.includes(docName)) {+ throw new ServerError('Document not in allowlist', { status: 400, code: 'INVALID_DOCUMENT' })+ }++ const ctx = await loadAppPlanning(req)+ if (!ctx) {+ throw new ServerError('GSD project not found', { status: 404, code: 'GSD_PROJECT_NOT_FOUND' })+ }++ const filePath = join(ctx.planningPath, docName)+ const resolved = resolve(filePath)+ if (!resolved.startsWith(resolve(ctx.planningPath))) {+ throw new ServerError('Invalid document path', { status: 400, code: 'PATH_TRAVERSAL' })+ }++ if (!existsSync(resolved)) {+ throw new ServerError('Document not found', { status: 404, code: 'NOT_FOUND' })+ }++ const content = await readFile(resolved, 'utf-8')+ res.json({ filename: docName, content })+}))++// PUT /projects/:appId/documents/:docName — save and git commit a .planning/ document+router.put('/projects/:appId/documents/:docName', asyncHandler(async (req, res) => {+ const { docName } = req.params+ if (!GSD_ALLOWED_DOCUMENTS.includes(docName)) {+ throw new ServerError('Document not in allowlist', { status: 400, code: 'INVALID_DOCUMENT' })+ }++ const ctx = await loadAppPlanning(req)+ if (!ctx) {+ throw new ServerError('GSD project not found', { status: 404, code: 'GSD_PROJECT_NOT_FOUND' })+ }++ const filePath = join(ctx.planningPath, docName)+ const resolved = resolve(filePath)+ if (!resolved.startsWith(resolve(ctx.planningPath))) {+ throw new ServerError('Invalid document path', { status: 400, code: 'PATH_TRAVERSAL' })+ }++ const { content, commitMessage } = documentUpdateSchema.parse(req.body)+ const created = !existsSync(resolved)++ await writeFile(resolved, content, 'utf-8')+ const relPath = `.planning/${docName}`+ await git.stageFiles(ctx.app.repoPath, [relPath])++ const status = await git.getStatus(ctx.app.repoPath)+ if (status.clean) {+ return res.json({ success: true, noChanges: true })+ }++ const message = commitMessage || `docs: update .planning/${docName} via PortOS`+ const result = await git.commit(ctx.app.repoPath, message)+ console.log(`📝 ${created ? 'Created' : 'Updated'} .planning/${docName} in ${ctx.app.name} (${result.hash})`)++ res.json({ success: true, hash: result.hash, created })+}))+export default routerdiff --git a/server/services/gsdService.js b/server/services/gsdService.jsindex e5e3a167be..905c700990 100644--- a/server/services/gsdService.js+++ b/server/services/gsdService.js@@ -198,13 +198,9 @@ export async function parseConcernsMd(filePath) {}/**- * Parse PLAN.md in a phase directory+ * Parse a single PLAN.md file content into frontmatter + tasks*/-export async function parsePhasePlan(phasePath) {- const planFile = join(phasePath, 'PLAN.md')- const content = await safeReadFile(planFile)- if (!content) return null-+function parsePlanContent(content) {const frontmatter = {}let bodyContent = content@@ -221,10 +217,8 @@ export async function parsePhasePlan(phasePath) {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) {+ for (const line of bodyContent.split('\n')) {const taskMatch = line.match(/^[-*]\s+\[([ xX])\]\s+(.+)/)if (taskMatch) {tasks.push({@@ -238,27 +232,76 @@ export async function parsePhasePlan(phasePath) {}/**- * Parse VERIFICATION.md in a phase directory+ * Scan phase directory for *-PLAN.md files (e.g. 01-01-PLAN.md, 03-02-PLAN.md)+ * Returns array of sub-plans sorted by filename+ */+export async function parsePhasePlans(phasePath) {+ const entries = await readdir(phasePath).catch(() => [])+ const planFiles = entries.filter(f => f.endsWith('-PLAN.md')).sort()+ if (planFiles.length === 0) return []++ const plans = []+ for (const filename of planFiles) {+ const content = await safeReadFile(join(phasePath, filename))+ if (!content) continue+ plans.push({ filename, ...parsePlanContent(content) })+ }+ return plans+}++/**+ * Parse SUMMARY.md files in a phase directory+ */+export async function parsePhaseSummaries(phasePath) {+ const entries = await readdir(phasePath).catch(() => [])+ const summaryFiles = entries.filter(f => f.endsWith('-SUMMARY.md')).sort()+ if (summaryFiles.length === 0) return []++ const summaries = []+ for (const filename of summaryFiles) {+ const content = await safeReadFile(join(phasePath, filename))+ if (!content) continue+ summaries.push({ filename, ...parsePlanContent(content) })+ }+ return summaries+}++/**+ * Scan phase directory for *-VERIFICATION.md (e.g. 01-VERIFICATION.md)*/export async function parseVerification(phasePath) {- const verifyFile = join(phasePath, 'VERIFICATION.md')- const content = await safeReadFile(verifyFile)+ const entries = await readdir(phasePath).catch(() => [])+ const verifyFile = entries.find(f => f.endsWith('-VERIFICATION.md'))+ if (!verifyFile) return null++ const content = await safeReadFile(join(phasePath, verifyFile))if (!content) return nulllet status = 'unknown'let score = null- // Look for status lineconst statusMatch = content.match(/status:\s*(\w+)/i)if (statusMatch) status = statusMatch[1].toLowerCase()- // Look for scoreconst scoreMatch = content.match(/score:\s*([\d.]+)/i)if (scoreMatch) score = parseFloat(scoreMatch[1])return { status, score, raw: content }}+/**+ * Scan phase directory for *-RESEARCH.md (e.g. 01-RESEARCH.md)+ */+export async function parsePhaseResearch(phasePath) {+ const entries = await readdir(phasePath).catch(() => [])+ const researchFile = entries.find(f => f.endsWith('-RESEARCH.md'))+ if (!researchFile) return null++ const content = await safeReadFile(join(phasePath, researchFile))+ if (!content) return null+ return { filename: researchFile, raw: content }+}+/*** Get full GSD project state for a single app*/@@ -277,6 +320,7 @@ export async function getGsdProject(appIdOrPath) {const roadmap = await parseRoadmapMd(join(planningPath, 'ROADMAP.md'))const state = await parseStateMd(join(planningPath, 'STATE.md'))const concerns = await parseConcernsMd(join(planningPath, 'CONCERNS.md'))+ const projectDoc = await safeReadFile(join(planningPath, 'PROJECT.md'))// Scan for phase directoriesconst phases = []@@ -287,13 +331,20 @@ export async function getGsdProject(appIdOrPath) {for (const entry of entries) {if (!entry.isDirectory()) continueconst phasePath = join(phasesDir, entry.name)- const plan = await parsePhasePlan(phasePath)+ const plans = await parsePhasePlans(phasePath)+ const summaries = await parsePhaseSummaries(phasePath)const verification = await parseVerification(phasePath)+ const research = await parsePhaseResearch(phasePath)+ const totalTasks = plans.reduce((sum, p) => sum + p.tasks.length, 0)+ const completedTasks = plans.reduce((sum, p) => sum + p.tasks.filter(t => t.completed).length, 0)phases.push({id: entry.name,- path: phasePath,- plan,- verification+ plans,+ summaries,+ verification,+ research,+ totalTasks,+ completedTasks})}phases.sort((a, b) => a.id.localeCompare(b.id, undefined, { numeric: true }))@@ -308,6 +359,7 @@ export async function getGsdProject(appIdOrPath) {roadmap,state,concerns,+ projectDoc: projectDoc ? { raw: projectDoc } : null,phases,config}@@ -327,27 +379,24 @@ export async function getGsdPendingActions(appId) {const currentPhase = project.state?.frontmatter?.current_phasefor (const phase of project.phases) {- const hasPlan = !!phase.plan+ const hasPlans = phase.plans?.length > 0const hasVerification = !!phase.verification- const allTasksComplete = phase.plan?.tasks?.every(t => t.completed) ?? false+ const allTasksComplete = phase.totalTasks > 0 && phase.completedTasks === phase.totalTasksconst verificationPassed = phase.verification?.status === 'passed'let nextAction = null- if (!hasPlan) {- // No plan yet — needs research or planning+ if (!hasPlans) {nextAction = 'plan'} else if (!allTasksComplete) {- // Plan exists but tasks incomplete — needs executionnextAction = 'execute'} else if (!hasVerification || !verificationPassed) {- // Tasks complete but not verifiednextAction = 'verify'}if (nextAction) {actions.push({phaseId: phase.id,- currentStep: hasPlan ? (allTasksComplete ? 'executed' : 'planned') : 'unplanned',+ currentStep: hasPlans ? (allTasksComplete ? 'executed' : 'planned') : 'unplanned',nextAction})}