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(cos): add goal progress tracking widget to dashboard

Adam Eivy67c63f3894dd
diff --git a/.changelog/v0.13.x.md b/.changelog/v0.13.x.md
index 431e2a8c58..329c9562f1 100644
--- a/.changelog/v0.13.x.md
+++ b/.changelog/v0.13.x.md
@@ -131,3 +131,14 @@ This release expands the genome dashboard with comprehensive cancer predispositi
- **Mini legend** — visual guide showing Less-to-More color scale
- **New API endpoint** — `GET /api/cos/productivity/calendar?weeks=N` returns calendar-optimized daily activity data with intensity calculations
- Directly addresses user preference for "quick visual summaries of recent task completion directly on the dashboard"
+
+### Goal Progress Dashboard Widget
+- **Visual goal progress tracking** — new dashboard widget maps completed CoS tasks to goal categories defined in COS-GOALS.md
+- **5 goal categories** tracked: Codebase Quality, Self-Improvement, Documentation, User Engagement, and System Health — each with icon, color, and task type mappings
+- **Engagement levels** — progress bars show relative task volume per goal (low/medium/high based on completed tasks)
+- **Success rate indicators** — each goal shows its success percentage with color-coded status (green >80%, amber 50-80%, red <50%)
+- **Insights row** — highlights most active and least active (needs attention) goal areas
+- **Parses COS-GOALS.md** — dynamically reads Active Goals section to extract goal names and items
+- **Task-to-goal mapping** — analyzes task types and keywords from learning data to attribute tasks to appropriate goals
+- **New API endpoints** — `GET /api/cos/goal-progress` (full data) and `GET /api/cos/goal-progress/summary` (compact for dashboard)
+- Addresses COS-GOALS.md "Metrics to Track" requirement and user preference for key performance metrics displayed prominently
diff --git a/client/src/components/GoalProgressWidget.jsx b/client/src/components/GoalProgressWidget.jsx
new file mode 100644
index 0000000000..4a587a7bca
--- /dev/null
+++ b/client/src/components/GoalProgressWidget.jsx
@@ -0,0 +1,156 @@
+import { useState, useEffect, memo } from 'react';
+import { Link } from 'react-router-dom';
+import {
+ Target,
+ ChevronRight,
+ TrendingUp,
+ AlertTriangle
+} from 'lucide-react';
+import * as api from '../services/api';
+
+/**
+ * GoalProgressWidget - Shows progress toward user goals on the dashboard
+ * Maps completed CoS tasks to goal categories from COS-GOALS.md
+ */
+const GoalProgressWidget = memo(function GoalProgressWidget() {
+ const [progress, setProgress] = useState(null);
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ const loadData = async () => {
+ const data = await api.getCosGoalProgressSummary().catch(() => null);
+ setProgress(data);
+ setLoading(false);
+ };
+
+ loadData();
+ // Refresh every 60 seconds
+ const interval = setInterval(loadData, 60000);
+ return () => clearInterval(interval);
+ }, []);
+
+ // Don't render while loading or if no goals
+ if (loading || !progress?.goals?.length) {
+ return null;
+ }
+
+ const { goals, summary } = progress;
+
+ // Color mappings for engagement levels
+ const getColorClasses = (color, engagement) => {
+ const intensityMap = {
+ high: { emerald: 'bg-emerald-500', purple: 'bg-purple-500', blue: 'bg-blue-500', pink: 'bg-pink-500', green: 'bg-green-500', gray: 'bg-gray-500' },
+ medium: { emerald: 'bg-emerald-500/60', purple: 'bg-purple-500/60', blue: 'bg-blue-500/60', pink: 'bg-pink-500/60', green: 'bg-green-500/60', gray: 'bg-gray-500/60' },
+ low: { emerald: 'bg-emerald-500/30', purple: 'bg-purple-500/30', blue: 'bg-blue-500/30', pink: 'bg-pink-500/30', green: 'bg-green-500/30', gray: 'bg-gray-500/30' }
+ };
+ return intensityMap[engagement]?.[color] || 'bg-gray-500/30';
+ };
+
+ const getTextColorClass = (color) => {
+ const colorMap = {
+ emerald: 'text-emerald-400',
+ purple: 'text-purple-400',
+ blue: 'text-blue-400',
+ pink: 'text-pink-400',
+ green: 'text-green-400',
+ gray: 'text-gray-400'
+ };
+ return colorMap[color] || 'text-gray-400';
+ };
+
+ return (
+ <div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6">
+ {/* Header */}
+ <div className="flex items-center justify-between mb-4">
+ <div className="flex items-center gap-3">
+ <div className="text-2xl" aria-hidden="true">
+ <Target className="w-6 h-6 text-port-accent" />
+ </div>
+ <div>
+ <h3 className="text-lg font-semibold text-white">Goal Progress</h3>
+ <p className="text-sm text-gray-500">
+ {summary.totalTasks} tasks toward {summary.totalGoals} goals
+ </p>
+ </div>
+ </div>
+ <Link
+ to="/cos/tasks"
+ className="flex items-center gap-1 text-sm text-port-accent hover:text-port-accent/80 transition-colors min-h-[40px] px-2"
+ >
+ <span className="hidden sm:inline">View Tasks</span>
+ <ChevronRight size={16} />
+ </Link>
+ </div>
+
+ {/* Goal Progress Bars */}
+ <div className="space-y-3">
+ {goals.map((goal) => (
+ <div key={goal.name} className="group">
+ <div className="flex items-center justify-between mb-1">
+ <div className="flex items-center gap-2">
+ <span className="text-base" aria-hidden="true">{goal.icon}</span>
+ <span className="text-sm font-medium text-gray-300">{goal.name}</span>
+ </div>
+ <div className="flex items-center gap-2">
+ {goal.successRate !== null && (
+ <span className={`text-xs ${goal.successRate >= 80 ? 'text-port-success' : goal.successRate >= 50 ? 'text-port-warning' : 'text-port-error'}`}>
+ {goal.successRate}%
+ </span>
+ )}
+ <span className="text-xs text-gray-500">
+ {goal.tasks} task{goal.tasks !== 1 ? 's' : ''}
+ </span>
+ </div>
+ </div>
+ {/* Progress bar */}
+ <div className="h-2 bg-port-border rounded-full overflow-hidden">
+ <div
+ className={`h-full rounded-full transition-all duration-500 ${getColorClasses(goal.color, goal.engagement)}`}
+ style={{
+ width: `${Math.min(100, Math.max(5, (goal.tasks / Math.max(...goals.map(g => g.tasks), 1)) * 100))}%`
+ }}
+ />
+ </div>
+ </div>
+ ))}
+ </div>
+
+ {/* Insights Row */}
+ {(summary.mostActive || summary.leastActive) && (
+ <div className="mt-4 pt-4 border-t border-port-border">
+ <div className="flex flex-wrap gap-3 text-xs">
+ {summary.mostActive && (
+ <div className="flex items-center gap-1.5 text-port-success">
+ <TrendingUp size={12} />
+ <span>Most active: {summary.mostActive}</span>
+ </div>
+ )}
+ {summary.leastActive && (
+ <div className="flex items-center gap-1.5 text-port-warning">
+ <AlertTriangle size={12} />
+ <span>Needs attention: {summary.leastActive}</span>
+ </div>
+ )}
+ </div>
+ </div>
+ )}
+
+ {/* Overall Success Rate */}
+ {summary.overallSuccessRate !== null && (
+ <div className="mt-3 text-center">
+ <span className="text-xs text-gray-500">
+ Overall success rate:{' '}
+ <span className={`font-medium ${
+ summary.overallSuccessRate >= 80 ? 'text-port-success' :
+ summary.overallSuccessRate >= 50 ? 'text-port-warning' : 'text-port-error'
+ }`}>
+ {summary.overallSuccessRate}%
+ </span>
+ </span>
+ </div>
+ )}
+ </div>
+ );
+});
+
+export default GoalProgressWidget;
diff --git a/client/src/pages/Dashboard.jsx b/client/src/pages/Dashboard.jsx
index 90ce37a92f..8666f79b4b 100644
--- a/client/src/pages/Dashboard.jsx
+++ b/client/src/pages/Dashboard.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback, useMemo } from 'react';
import { Link } from 'react-router-dom';
import AppTile from '../components/AppTile';
import CosDashboardWidget from '../components/CosDashboardWidget';
+import GoalProgressWidget from '../components/GoalProgressWidget';
import * as api from '../services/api';
import socket from '../services/socket';
@@ -91,6 +92,11 @@ export default function Dashboard() {
<CosDashboardWidget />
</div>
+ {/* Goal Progress Widget */}
+ <div className="mb-6">
+ <GoalProgressWidget />
+ </div>
+
{/* App Grid */}
{apps.length === 0 ? (
<div className="bg-port-card border border-port-border rounded-xl p-8 sm:p-12 text-center">
diff --git a/client/src/services/api.js b/client/src/services/api.js
index 0128f83c6a..8d84edd7f0 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -621,6 +621,8 @@ export const getCosActivityCalendar = (weeks = 12) => request(`/cos/productivity
export const getCosQuickSummary = () => request('/cos/quick-summary');
export const getCosRecentTasks = (limit = 10) => request(`/cos/recent-tasks?limit=${limit}`);
export const getCosActionableInsights = () => request('/cos/actionable-insights');
+export const getCosGoalProgress = () => request('/cos/goal-progress');
+export const getCosGoalProgressSummary = () => request('/cos/goal-progress/summary');
// Task Schedule (Configurable Intervals)
export const getCosSchedule = () => request('/cos/schedule');
diff --git a/server/routes/cos.js b/server/routes/cos.js
index c61f31faa3..d233707236 100644
--- a/server/routes/cos.js
+++ b/server/routes/cos.js
@@ -13,6 +13,7 @@ import * as autonomousJobs from '../services/autonomousJobs.js';
import * as taskTemplates from '../services/taskTemplates.js';
import { enhanceTaskPrompt } from '../services/taskEnhancer.js';
import * as productivity from '../services/productivity.js';
+import * as goalProgress from '../services/goalProgress.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
const router = Router();
@@ -1084,4 +1085,17 @@ router.get('/quick-summary', asyncHandler(async (req, res) => {
});
}));
+// GET /api/cos/goal-progress - Get progress toward user goals
+// Maps completed tasks to goal categories from COS-GOALS.md
+router.get('/goal-progress', asyncHandler(async (req, res) => {
+ const progress = await goalProgress.getGoalProgress();
+ res.json(progress);
+}));
+
+// GET /api/cos/goal-progress/summary - Get compact goal progress for dashboard
+router.get('/goal-progress/summary', asyncHandler(async (req, res) => {
+ const summary = await goalProgress.getGoalProgressSummary();
+ res.json(summary);
+}));
+
export default router;
diff --git a/server/services/goalProgress.js b/server/services/goalProgress.js
new file mode 100644
index 0000000000..12418b9169
--- /dev/null
+++ b/server/services/goalProgress.js
@@ -0,0 +1,245 @@
+/**
+ * Goal Progress Service
+ *
+ * Tracks progress toward user goals defined in COS-GOALS.md by analyzing
+ * completed CoS tasks and mapping them to goal categories.
+ *
+ * Goals are extracted from COS-GOALS.md's Active Goals section.
+ * Task completions are categorized by keywords and mapped to goal progress.
+ */
+
+import { readFile } from 'fs/promises'
+import { join, dirname } from 'path'
+import { fileURLToPath } from 'url'
+import { readJSONFile, PATHS } from '../lib/fileUtils.js'
+
+const __filename = fileURLToPath(import.meta.url)
+const __dirname = dirname(__filename)
+const GOALS_FILE = join(PATHS.data, 'COS-GOALS.md')
+const LEARNING_FILE = join(PATHS.cos, 'learning.json')
+
+/**
+ * Goal category mappings - maps goal names to task type patterns
+ * Each goal has keywords that match against task types and descriptions
+ */
+const GOAL_MAPPINGS = {
+ 'Codebase Quality': {
+ icon: '🔧',
+ color: 'emerald',
+ keywords: ['security', 'audit', 'mobile', 'responsive', 'dry', 'dead-code', 'test', 'coverage', 'console', 'lint', 'refactor'],
+ taskTypes: ['self-improve:security-audit', 'self-improve:mobile-responsive', 'self-improve:feature', 'app-improve:security', 'app-improve:mobile']
+ },
+ 'Self-Improvement': {
+ icon: '🧠',
+ color: 'purple',
+ keywords: ['capability', 'improvement', 'learn', 'analysis', 'error', 'retry', 'prioritization', 'a11y', 'i18n', 'seo'],
+ taskTypes: ['self-improve:general', 'self-improve:brainstorm', 'idle-review']
+ },
+ 'Documentation': {
+ icon: '📚',
+ color: 'blue',
+ keywords: ['document', 'docs', 'readme', 'plan', 'report', 'summary', 'changelog'],
+ taskTypes: ['self-improve:documentation', 'app-improve:documentation']
+ },
+ 'User Engagement': {
+ icon: '💬',
+ color: 'pink',
+ keywords: ['feedback', 'suggest', 'goal', 'status', 'clarify', 'user', 'engagement'],
+ taskTypes: ['user-task']
+ },
+ 'System Health': {
+ icon: '💚',
+ color: 'green',
+ keywords: ['health', 'pm2', 'memory', 'performance', 'monitor', 'alert', 'process', 'service'],
+ taskTypes: ['auto-fix', 'internal-task']
+ }
+}
+
+/**
+ * Parse COS-GOALS.md to extract active goals
+ * @returns {Promise<Array>} Parsed goals with titles and items
+ */
+async function parseGoalsFile() {
+ const content = await readFile(GOALS_FILE, 'utf-8').catch(() => null)
+ if (!content) return []
+
+ const goals = []
+ const lines = content.split('\n')
+ let inActiveGoals = false
+ let currentGoal = null
+
+ for (const line of lines) {
+ // Detect Active Goals section
+ if (line.startsWith('## Active Goals')) {
+ inActiveGoals = true
+ continue
+ }
+
+ // Stop at next major section
+ if (inActiveGoals && line.startsWith('## ') && !line.includes('Active Goals')) {
+ inActiveGoals = false
+ continue
+ }
+
+ if (!inActiveGoals) continue
+
+ // Parse goal headers (### Goal N: Name)
+ const goalMatch = line.match(/^### Goal \d+:\s*(.+)/)
+ if (goalMatch) {
+ if (currentGoal) goals.push(currentGoal)
+ const name = goalMatch[1].trim()
+ currentGoal = {
+ name,
+ items: [],
+ mapping: GOAL_MAPPINGS[name] || { icon: '🎯', color: 'gray', keywords: [], taskTypes: [] }
+ }
+ continue
+ }
+
+ // Parse goal items (- item text)
+ if (currentGoal && line.match(/^- /)) {
+ currentGoal.items.push(line.replace(/^- /, '').trim())
+ }
+ }
+
+ if (currentGoal) goals.push(currentGoal)
+ return goals
+}
+
+/**
+ * Get task completion statistics from learning data
+ * @returns {Promise<Object>} Task completion stats by type
+ */
+async function getTaskStats() {
+ const learning = await readJSONFile(LEARNING_FILE, null)
+ if (!learning?.byTaskType) return {}
+ return learning.byTaskType
+}
+
+/**
+ * Calculate progress for each goal based on completed tasks
+ * @param {Array} goals - Parsed goals from COS-GOALS.md
+ * @param {Object} taskStats - Task completion statistics
+ * @returns {Array} Goals with progress metrics
+ */
+function calculateGoalProgress(goals, taskStats) {
+ return goals.map(goal => {
+ let totalTasks = 0
+ let succeededTasks = 0
+ let recentActivity = 0 // Tasks in last 24h (approximated from streak/recent)
+
+ // Sum up tasks matching this goal's task types
+ for (const taskType of goal.mapping.taskTypes) {
+ const stats = taskStats[taskType]
+ if (stats) {
+ totalTasks += stats.completed || 0
+ succeededTasks += stats.succeeded || 0
+ }
+ }
+
+ // Also check for keyword matches in other task types
+ for (const [taskType, stats] of Object.entries(taskStats)) {
+ // Skip if already counted by taskTypes
+ if (goal.mapping.taskTypes.includes(taskType)) continue
+
+ // Check if task type contains any of this goal's keywords
+ const hasKeyword = goal.mapping.keywords.some(kw =>
+ taskType.toLowerCase().includes(kw.toLowerCase())
+ )
+ if (hasKeyword) {
+ totalTasks += stats.completed || 0
+ succeededTasks += stats.succeeded || 0
+ }
+ }
+
+ // Calculate success rate
+ const successRate = totalTasks > 0 ? Math.round((succeededTasks / totalTasks) * 100) : null
+
+ // Estimate engagement level (low/medium/high based on task count)
+ let engagement = 'low'
+ if (totalTasks >= 20) engagement = 'high'
+ else if (totalTasks >= 5) engagement = 'medium'
+
+ return {
+ name: goal.name,
+ icon: goal.mapping.icon,
+ color: goal.mapping.color,
+ itemCount: goal.items.length,
+ metrics: {
+ totalTasks,
+ succeededTasks,
+ successRate,
+ engagement
+ }
+ }
+ })
+}
+
+/**
+ * Get goal progress summary for dashboard display
+ * @returns {Promise<Object>} Goal progress data
+ */
+async function getGoalProgress() {
+ const [goals, taskStats] = await Promise.all([
+ parseGoalsFile(),
+ getTaskStats()
+ ])
+
+ const goalsWithProgress = calculateGoalProgress(goals, taskStats)
+
+ // Calculate overall stats
+ const totalTasks = goalsWithProgress.reduce((sum, g) => sum + g.metrics.totalTasks, 0)
+ const totalSucceeded = goalsWithProgress.reduce((sum, g) => sum + g.metrics.succeededTasks, 0)
+
+ // Find most and least engaged goals
+ const sorted = [...goalsWithProgress].sort((a, b) => b.metrics.totalTasks - a.metrics.totalTasks)
+ const mostActive = sorted[0]?.name || null
+ const leastActive = sorted[sorted.length - 1]?.name || null
+
+ return {
+ goals: goalsWithProgress,
+ summary: {
+ totalGoals: goals.length,
+ totalTasks,
+ totalSucceeded,
+ overallSuccessRate: totalTasks > 0 ? Math.round((totalSucceeded / totalTasks) * 100) : null,
+ mostActive,
+ leastActive: leastActive !== mostActive ? leastActive : null
+ },
+ updatedAt: new Date().toISOString()
+ }
+}
+
+/**
+ * Get a brief summary suitable for dashboard widget
+ * @returns {Promise<Object>} Compact goal progress summary
+ */
+async function getGoalProgressSummary() {
+ const progress = await getGoalProgress()
+
+ // Return top 3 goals by activity for compact display
+ const topGoals = progress.goals
+ .sort((a, b) => b.metrics.totalTasks - a.metrics.totalTasks)
+ .slice(0, 5)
+ .map(g => ({
+ name: g.name,
+ icon: g.icon,
+ color: g.color,
+ tasks: g.metrics.totalTasks,
+ successRate: g.metrics.successRate,
+ engagement: g.metrics.engagement
+ }))
+
+ return {
+ goals: topGoals,
+ summary: progress.summary,
+ updatedAt: progress.updatedAt
+ }
+}
+
+export {
+ getGoalProgress,
+ getGoalProgressSummary,
+ parseGoalsFile,
+ GOAL_MAPPINGS
+}