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

docs: split PLAN.md into lightweight roadmap + DONE.md archive

Adam Eivy3aa86265fd07
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index cc0ffdd329..21951f3b1c 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -9,6 +9,8 @@
- **App Icon Detection** — Apps can now display their actual project icon (favicon, Xcode AppIcon, etc.) instead of generic SVG icons. Auto-detects icons from well-known paths during app import and config refresh. Supports Xcode/iOS AppIcon.appiconset, web favicons, logos, and common icon locations. Icon served via `GET /api/apps/:id/icon` with fallback to SVG icons. Bulk "Detect Icons" button on Apps page. Apps sorted alphabetically on both Dashboard and Apps pages. App icons shown in Apps list rows.
+- **POST Wordplay Training** — New training module with 4 game modes: Compound Chain, Bridge Word, Double Meaning, and Idiom Twist. Trains creative language pattern recognition and wordplay skills.
+
- **Review Briefing Fullscreen** — Daily Briefing section in Review Hub now has a fullscreen toggle button and increased default content height for better readability
- **Database Management UI** — Switch between Docker and native PostgreSQL from Settings > Database. Shows live status of both backends with connection health, memory count, database size, and table count. Migrate data between backends with one click. Per-backend Backup buttons export SQL dumps from either Docker or native independently. Install/setup native PostgreSQL and fix stale PID files — all from the UI with real-time progress via WebSocket
@@ -24,7 +26,7 @@
- **Native PostgreSQL uses system pg** — Native mode now reuses the existing system PostgreSQL on port 5432 (e.g., Homebrew service) instead of running a separate instance on port 5561. `setup-native` detects an already-running pg, creates the portos user/database, and applies the schema. No dedicated data directory or manual startup needed. Docker mode unchanged on port 5561. Sync between backends is zero-downtime since they run on different ports simultaneously.
-- **CoS feature-ideas task** — Agents now implement the next unchecked PLAN.md item instead of inventing features. When user clarification is needed, agents create a `.plan-questions.md` marker and a `plan_question` notification linking to the Documents tab. Added `{appId}` template variable for prompt linking.
+- **CoS feature-ideas task** — Agents now implement the next unchecked PLAN.md item instead of inventing features. When user clarification is needed, agents create a `.plan-questions.md` marker and a `plan_question` notification linking to the Documents tab. Added `{appId}` template variable for prompt linking. Feature-ideas and documentation tasks now read DONE.md alongside PLAN.md to understand what's already been implemented and avoid re-implementing shipped features.
- **CoS task prompt enhancement** — Enhance prompt now instructs the LLM to research the codebase (find relevant files, patterns, conventions), plan the approach, and produce a codebase-grounded prompt with specific file paths and implementation steps instead of generic advice
## Fixed
diff --git a/DONE.md b/DONE.md
new file mode 100644
index 0000000000..0d65c4c62b
--- /dev/null
+++ b/DONE.md
@@ -0,0 +1,121 @@
+# PortOS — Completed Milestones
+
+Archive of completed work. For active roadmap, see [PLAN.md](./PLAN.md). For project goals, see [GOALS.md](./GOALS.md).
+
+---
+
+## Milestones
+
+- [x] **M0-M3**: Bootstrap, app registry, PM2 integration, log viewer — Core infrastructure
+- [x] **M4**: App Wizard — Register existing apps or create from templates. See [App Wizard](./docs/features/app-wizard.md)
+- [x] **M5**: AI Providers — Multi-provider AI execution with headless Claude CLI
+- [x] **M6**: Dev Tools — Command runner with history and execution tracking
+- [x] **M8**: Prompt Manager — Customizable AI prompts with variables and stages. See [Prompt Manager](./docs/features/prompt-manager.md)
+- [x] **M9**: Streaming Import — Real-time websocket updates during app detection
+- [x] **M10**: Enhanced DevTools — Provider/model selection, screenshots, git status, usage metrics
+- [x] **M11**: AI Agents Page — Process detection and management with colorful UI
+- [x] **M12**: History Improvements — Expandable entries with runtime/output capture
+- [x] **M13**: Autofixer — Autonomous crash detection and repair. See [Autofixer](./docs/features/autofixer.md)
+- [x] **M14**: Chief of Staff — Autonomous agent manager with task orchestration. See [Chief of Staff](./docs/features/chief-of-staff.md)
+- [x] **M15**: Error Handling — Graceful error handling with auto-fix. See [Error Handling](./docs/features/error-handling.md)
+- [x] **M16**: Memory System — Semantic memory with LLM classification. See [Memory System](./docs/features/memory-system.md)
+- [x] **M17**: PM2 Config Enhancement — Per-process port detection and CDP_PORT support
+- [x] **M18**: PM2 Standardization — LLM-powered config refactoring
+- [x] **M19**: CoS Agent Runner — Isolated PM2 process for agent spawning. See [CoS Agent Runner](./docs/features/cos-agent-runner.md)
+- [x] **M20**: AI Error Handling — Enhanced error extraction and CoS integration
+- [x] **M21**: Usage Metrics — Comprehensive AI usage tracking and mobile UI
+- [x] **M22**: Orphan Auto-Retry — Automatic retry for orphaned agents
+- [x] **M23**: Self-Improvement — Automated UI/security/code analysis with Playwright
+- [x] **M24**: Goal-Driven Mode — COS-GOALS.md mission file and always-working behavior
+- [x] **M25**: Task Learning — Completion tracking and success rate analysis
+- [x] **M26**: Scheduled Scripts — Cron-based automation with agent triggering
+- [x] **M27**: CoS Capability Enhancements — Dependency updates, performance tracking, learning insights
+- [x] **M28**: Weekly Digest UI — Visual digest with insights and comparisons
+- [x] **M29**: App Improvement — Comprehensive analysis extended to managed apps
+- [x] **M30**: Configurable Intervals — Per-task-type scheduling (daily, weekly, once, on-demand)
+- [x] **M31**: LLM Memory Classification — Intelligent memory extraction with quality filtering
+- [x] **M32**: Brain System — Second-brain capture and classification. See [Brain System](./docs/features/brain-system.md)
+- [x] **M33**: Soul System — Digital twin identity scaffold management. See [Soul System](./docs/features/soul-system.md)
+- [x] **M34 P1-P2,P4**: Digital Twin — Quantitative personality modeling and confidence scoring. See [Digital Twin](./docs/features/digital-twin.md)
+- [x] **M35**: Chief of Staff Enhancement — Proactive autonomous agent with hybrid memory, missions, LM Studio, thinking levels. See [CoS Enhancement](./docs/features/cos-enhancement.md)
+- [x] **M35.1**: CoS UI — Added Arcane Sigil (3D) avatar style option alongside Cyberpunk 3D
+- [x] **M36**: Browser Management — CDP/Playwright browser page with status, controls, config, and logs
+- [x] **M37**: Autonomous Jobs — Recurring scheduled jobs that the CoS executes proactively using digital twin identity
+- [x] **M38**: Agent Tools — AI content generation, feed browsing, and autonomous engagement for Moltbook agents
+- [x] **M39**: Agent-Centric Drill-Down — Redesigned Agents section with agent-first hierarchy, deep-linkable URLs, and scoped sub-tabs
+- [x] **M40**: Agent Skill System — Task-type-specific prompts, context compaction, negative routing examples, deterministic workflow skills. See [Agent Skills](./docs/features/agent-skills.md)
+- [x] **M41**: CyberCity Immersive Overhaul — Procedural synthwave audio, enhanced post-processing, reflective wet-street ground, settings system
+- [x] **M42 P1-P4**: Unified Digital Twin Identity System — Identity orchestrator, chronotype derivation, personalized taste prompting, behavioral feedback loop, mortality-aware goal tracking, Identity Tab UI dashboard
+- [x] **M43**: Moltworld Platform Support — Second platform integration for AI agents in a shared voxel world
+- [x] **M44 P1-P7**: MeatSpace — Health tracker with death clock, LEV 2045 tracker, alcohol logging, blood/body/epigenetic/eye tracking, lifestyle questionnaire, TSV import, dashboard widget, compact grid overview, genome/epigenetic migration cleanup, Apple Health integration
+- [x] **M45**: Data Backup & Recovery — Rsync-based incremental backup with SHA-256 manifests, PostgreSQL pg_dump, configurable cron schedule, restore with dry-run preview and selective subdirectory restore, Dashboard widget with health status
+- [x] **M46**: Unified Search (Cmd+K) — Global search across brain, memory, history, agents, tasks, and apps
+- [x] **M48 P1-P10**: Google Calendar Integration — MCP push sync, direct Google API via OAuth2, subcalendar management, goal-calendar linking, daily review, auto-configure via CDP, color-coded events, 15-min Day/Week views, Life Calendar consolidated under Calendar > Lifetime
+- [x] **M49 P1-P4**: Life Goals — Enhanced goal model with todos, progress percentage, velocity tracking, projected completion, time tracking aggregates, AI phase planning, calendar time-blocking, automated weekly check-ins with status tracking
+- [x] **M50 P1-P7**: Email Management — Outlook API+Playwright sync, AI triage with security hardening, draft generation, thread capture, per-action models, full Messages UI, Gmail API sync+send
+- [x] **M51**: Memory System PostgreSQL Upgrade — PostgreSQL + pgvector backend with HNSW vector search, tsvector full-text search, federation sync, and pg_dump backup integration
+- [x] **M52**: Update Detection — GitHub release polling with semver comparison, auto-check every 30 min, Socket.IO real-time notifications, Update tab UI with progress tracking, update executor with health polling
+- [x] **M53**: POST (Power On Self Test) — Daily cognitive self-test with mental math drills (P1) and LLM-powered wit & memory drills (P2)
+- [x] **M54**: MeatSpace Life Calendar — "4000 Weeks" mortality-aware time mapping with responsive grid, goal-activity linking, and time feasibility analysis
+- [x] **M55**: POST Enhancement — Memory builder, imagination drills, training mode, 5-min balanced sessions, wordplay training (4 game modes). See [POST](./docs/features/post.md)
+- [x] **M56**: Telegram Bot Integration — External notification channel via Telegram bot with conversational commands, goal check-in persistence
+- [x] **GSD Tab**: Smart State Detection, One-Click Agent Spawn, Actionable Dashboard
+- [x] **Database Management**: Native PostgreSQL mode (reuses system pg on port 5432), Docker/native switching UI, resource stats, sync/start/stop/destroy controls, per-backend backup buttons
+- [x] **Review Hub**: Aggregated review page with alerts, CoS actions, todos, daily briefings, fullscreen toggle, markdown rendering
+- [x] **JIRA Sprint Manager**: Autonomous JIRA triage and implementation as opt-in per-app scheduled task. See [JIRA Sprint Manager](./docs/features/jira-sprint-manager.md)
+- [x] **App Icons + Non-PM2 Support**: App icon detection/display for iOS/macOS/Swift projects, non-PM2 app type management (Swift/Xcode)
+
+---
+
+## Code Audits
+
+See [Security Audit](./docs/SECURITY_AUDIT.md) for the 2025-02-19 security hardening (all 10 items resolved).
+
+### Audit Findings (2026-03-05) — Resolved
+
+Items fixed from audit Passes 1-3 (PRs #67-72):
+- App status computation duplication (apps.js) — unified
+- TOCTOU race in addTask/updateTask/deleteTask — withStateLock mutex added
+- Fetch timeouts missing in cosRunnerClient.js — fetchWithTimeout added to all calls
+- Socket.IO infinite reconnection — capped to 10 attempts with error handler
+- Data race in memory.js loadMemory() — withMemoryLock applied
+- Duplicate getDateString — centralized in lib/fileUtils.js
+- Duplicate HOUR/DAY constants — centralized in lib/fileUtils.js
+- Missing fetch timeouts in moltworld/moltbook api.js — timeout-aware patterns added
+- ChiefOfStaff.jsx useState hooks — reduced from 24 to 19
+
+**Known low-severity:** pm2 ReDoS (GHSA-x5gf-qvw8-r2rm) — no upstream fix, not exploitable via PortOS routes.
+
+---
+
+## Documentation
+
+### Architecture & Guides
+- [Architecture Overview](./docs/ARCHITECTURE.md) - System design, data flow
+- [API Reference](./docs/API.md) - REST endpoints, WebSocket events
+- [Contributing Guide](./docs/CONTRIBUTING.md) - Code guidelines, git workflow
+- [GitHub Actions](./docs/GITHUB_ACTIONS.md) - CI/CD workflow patterns
+- [PM2 Configuration](./docs/PM2.md) - PM2 patterns and best practices
+- [Port Allocation](./docs/PORTS.md) - Port conventions and allocation
+- [Security Audit](./docs/SECURITY_AUDIT.md) - 2025-02-19 hardening audit (all resolved)
+- [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions
+- [Versioning & Releases](./docs/VERSIONING.md) - Version format, release process
+
+### Feature Documentation
+- [Agent Skills](./docs/features/agent-skills.md) - Task-type-specific prompt templates and routing
+- [App Wizard](./docs/features/app-wizard.md) - Register apps and create from templates
+- [Autofixer](./docs/features/autofixer.md) - Autonomous crash detection and repair
+- [Brain System](./docs/features/brain-system.md) - Second-brain capture and classification
+- [Browser Management](./docs/features/browser.md) - CDP/Playwright browser management
+- [Chief of Staff](./docs/features/chief-of-staff.md) - Autonomous agent orchestration
+- [CoS Agent Runner](./docs/features/cos-agent-runner.md) - Isolated agent process management
+- [CoS Enhancement](./docs/features/cos-enhancement.md) - M35 hybrid memory, missions, thinking levels
+- [Digital Twin](./docs/features/digital-twin.md) - Quantitative personality modeling
+- [Error Handling](./docs/features/error-handling.md) - Graceful error handling with auto-fix
+- [Identity System](./docs/features/identity-system.md) - Unified identity architecture (M42 spec)
+- [JIRA Sprint Manager](./docs/features/jira-sprint-manager.md) - Autonomous JIRA triage and implementation
+- [Memory System](./docs/features/memory-system.md) - Semantic memory with LLM classification
+- [Messages Security](./docs/features/messages-security.md) - AI prompt injection threat model and defenses
+- [POST](./docs/features/post.md) - Cognitive self-test and training system
+- [Prompt Manager](./docs/features/prompt-manager.md) - Customizable AI prompts
+- [Soul System](./docs/features/soul-system.md) - Digital twin identity scaffold
diff --git a/PLAN.md b/PLAN.md
index 4530aeaa8a..64a68d4e4d 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -1,245 +1,93 @@
-# Port OS - Implementation Plan
+# PortOS — Development Plan
-See [GOALS.md](./GOALS.md) for project goals and direction.
+For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md](./DONE.md).
---
-## Milestones
-
-### Completed
-
-- [x] **M0-M3**: Bootstrap, app registry, PM2 integration, log viewer - Core infrastructure
-- [x] **M4**: App Wizard - Register existing apps or create from templates. See [App Wizard](./docs/features/app-wizard.md)
-- [x] **M5**: AI Providers - Multi-provider AI execution with headless Claude CLI
-- [x] **M6**: Dev Tools - Command runner with history and execution tracking
-- [x] **M8**: Prompt Manager - Customizable AI prompts with variables and stages. See [Prompt Manager](./docs/features/prompt-manager.md)
-- [x] **M9**: Streaming Import - Real-time websocket updates during app detection
-- [x] **M10**: Enhanced DevTools - Provider/model selection, screenshots, git status, usage metrics
-- [x] **M11**: AI Agents Page - Process detection and management with colorful UI
-- [x] **M12**: History Improvements - Expandable entries with runtime/output capture
-- [x] **M13**: Autofixer - Autonomous crash detection and repair. See [Autofixer](./docs/features/autofixer.md)
-- [x] **M14**: Chief of Staff - Autonomous agent manager with task orchestration. See [Chief of Staff](./docs/features/chief-of-staff.md)
-- [x] **M15**: Error Handling - Graceful error handling with auto-fix. See [Error Handling](./docs/features/error-handling.md)
-- [x] **M16**: Memory System - Semantic memory with LLM classification. See [Memory System](./docs/features/memory-system.md)
-- [x] **M17**: PM2 Config Enhancement - Per-process port detection and CDP_PORT support
-- [x] **M18**: PM2 Standardization - LLM-powered config refactoring
-- [x] **M19**: CoS Agent Runner - Isolated PM2 process for agent spawning. See [CoS Agent Runner](./docs/features/cos-agent-runner.md)
-- [x] **M20**: AI Error Handling - Enhanced error extraction and CoS integration
-- [x] **M21**: Usage Metrics - Comprehensive AI usage tracking and mobile UI
-- [x] **M22**: Orphan Auto-Retry - Automatic retry for orphaned agents
-- [x] **M23**: Self-Improvement - Automated UI/security/code analysis with Playwright
-- [x] **M24**: Goal-Driven Mode - COS-GOALS.md mission file and always-working behavior
-- [x] **M25**: Task Learning - Completion tracking and success rate analysis
-- [x] **M26**: Scheduled Scripts - Cron-based automation with agent triggering
-- [x] **M27**: CoS Capability Enhancements - Dependency updates, performance tracking, learning insights
-- [x] **M28**: Weekly Digest UI - Visual digest with insights and comparisons
-- [x] **M29**: App Improvement - Comprehensive analysis extended to managed apps
-- [x] **M30**: Configurable Intervals - Per-task-type scheduling (daily, weekly, once, on-demand)
-- [x] **M31**: LLM Memory Classification - Intelligent memory extraction with quality filtering
-- [x] **M32**: Brain System - Second-brain capture and classification. See [Brain System](./docs/features/brain-system.md)
-- [x] **M33**: Soul System - Digital twin identity scaffold management. See [Soul System](./docs/features/soul-system.md)
-- [x] **M34 P1-P2,P4**: Digital Twin - Quantitative personality modeling and confidence scoring. See [Digital Twin](./docs/features/digital-twin.md)
-- [x] **M35**: Chief of Staff Enhancement - Proactive autonomous agent with hybrid memory, missions, LM Studio, thinking levels. See [CoS Enhancement](./docs/features/cos-enhancement.md)
-- [x] **M35.1**: CoS UI - Added Arcane Sigil (3D) avatar style option alongside Cyberpunk 3D
-- [x] **M36**: Browser Management - CDP/Playwright browser page with status, controls, config, and logs
-- [x] **M37**: Autonomous Jobs - Recurring scheduled jobs that the CoS executes proactively using digital twin identity
-- [x] **M38**: Agent Tools - AI content generation, feed browsing, and autonomous engagement for Moltbook agents
-- [x] **M39**: Agent-Centric Drill-Down - Redesigned Agents section with agent-first hierarchy, deep-linkable URLs, and scoped sub-tabs
-- [x] **M40**: Agent Skill System - Task-type-specific prompts, context compaction, negative routing examples, deterministic workflow skills. See [Agent Skills](./docs/features/agent-skills.md)
-- [x] **M41**: CyberCity Immersive Overhaul - Procedural synthwave audio, enhanced post-processing, reflective wet-street ground, settings system
-- [x] **M42 P1-P3**: Unified Digital Twin Identity System - Identity orchestrator, chronotype derivation, personalized taste prompting, behavioral feedback loop, mortality-aware goal tracking
-- [x] **M42 P4**: Unified Digital Twin Identity System - Identity Tab UI dashboard with completeness header, 5 summary cards, derive actions
-- [x] **M43**: Moltworld Platform Support - Second platform integration for AI agents in a shared voxel world
-- [x] **M44 P1-P5**: MeatSpace - Health tracker with death clock, LEV 2045 tracker, alcohol logging, blood/body/epigenetic/eye tracking, lifestyle questionnaire, TSV import, dashboard widget, compact grid overview
-
-- [x] **M51**: Memory System PostgreSQL Upgrade - PostgreSQL + pgvector backend with HNSW vector search, tsvector full-text search, federation sync, and pg_dump backup integration
-- [x] **M44 P6**: MeatSpace - Genome/Epigenetic Migration cleanup (route comments updated to `/api/meatspace/genome/`, IdentityTab genome link points to `/meatspace/genome`)
-- [x] **M53**: POST (Power On Self Test) - Daily cognitive self-test with mental math drills (P1) and LLM-powered wit & memory drills (P2).
-- [x] **M44 P7**: MeatSpace - Apple Health Integration (live sync via Health Auto Export app + bulk XML import)
-- [x] **M46**: Unified Search (Cmd+K) - Global search across brain, memory, history, agents, tasks, and apps
-- [x] **GSD Tab**: Smart State Detection, One-Click Agent Spawn, Actionable Dashboard
-- [x] **M55**: POST Enhancement — Memory builder, imagination drills, training mode, 5-min balanced sessions. See [POST](./docs/features/post.md)
-- [x] **M54**: MeatSpace Life Calendar — "4000 Weeks" mortality-aware time mapping with responsive grid, goal-activity linking, and time feasibility analysis
-- [x] **M45**: Data Backup & Recovery - Rsync-based incremental backup with SHA-256 manifests, PostgreSQL pg_dump, configurable cron schedule, restore with dry-run preview and selective subdirectory restore, Dashboard widget with health status
-- [x] **M48 P1-P10**: Google Calendar Integration - MCP push sync, direct Google API via OAuth2, subcalendar management, goal-calendar linking, daily review, auto-configure via CDP, color-coded events, 15-min Day/Week views, Life Calendar consolidated under Calendar > Lifetime
-- [x] **M49 P1**: Life Goals — Enhanced goal model with todos, progress percentage, velocity tracking, projected completion, time tracking aggregates
-- [x] **M50 P1-P7**: Email Management - Outlook API+Playwright sync, AI triage with security hardening, draft generation, thread capture, per-action models, full Messages UI, Gmail API sync+send
-- [x] **M52**: Update Detection - GitHub release polling with semver comparison, auto-check every 30 min, Socket.IO real-time notifications, Update tab UI with progress tracking, update executor with health polling
-- [x] **M56**: Telegram Bot Integration - External notification channel via Telegram bot with conversational commands, goal check-in persistence. Replaces M47.
-
-### Planned
-
-- [ ] **M50 P8-P10**: Email Management - Digital Twin voice drafting, CoS automation & rules, auto-send with AI review gate
-- [x] **M49 P2-P4**: Life Goals — AI phase planning, calendar time-blocking, automated weekly check-ins with status tracking
-- [ ] **M34 P5-P7**: Digital Twin - Multi-modal capture, advanced testing, personas
-- [ ] **M42 P5**: Unified Digital Twin Identity System - Cross-Insights Engine. See [Identity System](./docs/features/identity-system.md)
+## Next Up
----
-
-## Planned Feature Details
-
-### M49: Life Goals & Todo Planning
-
-Extends the existing goal system in `server/services/identity.js` and `data/digital-twin/goals.json`. Adds rich progress tracking, todo sub-tasks, calendar time-blocking, and AI-powered check-ins. Gets its own top-level Goals page (not buried under Digital Twin).
+1. **M50 P8**: Messages — Digital Twin voice drafting for email responses (reads COMMUNICATION.md, PERSONALITY.md, VALUES.md + thread context)
+2. **M42 P5**: Cross-Insights Engine — connect genome + taste + personality + goals into derived insights. See [Identity System](./docs/features/identity-system.md)
+3. **M34 P5-P7**: Digital Twin — Multi-modal capture, advanced testing, personas
-**Phases:**
+## Planned Details
-- **P1: Enhanced Goal Model & Todos** *(Complete)* — Added `progress` (0-100), `progressHistory[]`, `todos[]` with priority/estimate/status to goal schema. Velocity (percent/month + trend) and projected completion computed at query time. Time tracking aggregated from progressLog. Progress bars in list view, todo CRUD in detail panel.
-- **P2: Calendar Time-Blocking** *(Complete)* — Schedule time blocks on Google Calendar based on phase milestones and time block config (preferred days, time slot, session duration). Google Calendar OAuth upgraded from readonly to read-write scope with upgrade detection. Calendar event CRUD via googleapis.
-- **P3: Check-in & Evaluation** *(Complete)* — Automated weekly goal check-ins via `job-goal-check-in` autonomous job with gate. Computes expected vs actual progress, determines on-track/behind/at-risk status, generates AI assessment and recommendations via LLM, sends Telegram notification. Check-in history displayed in goal detail panel.
-- **P4: AI Phase Planning** *(Complete)* — AI-powered phase generation (3-7 milestones with target dates) via LLM. Editable proposed phases with reorder, add/remove. Accept to persist as milestones with description and order fields.
+### M50 P8-P10: Email Management (Remaining)
-**Data:** Extended `data/digital-twin/goals.json` with `todos[]`, `progressHistory[]`, `velocity{}`, `checkIns[]`, `calendarConfig{}`, `timeTracking{}` per goal. `checkInSchedule{}` at root level.
-
-**Routes:** Extend `/api/digital-twin/identity/goals` with: `PUT /:id/progress`, `POST /:id/check-in`, `POST /:id/todos`, `PUT /:id/todos/:tid`, `POST /:id/schedule`, `POST /evaluate`
-
-**Nav:** Top-level sidebar item "Goals" (alphabetically between Digital Twin and Insights)
-
-*Touches: server/services/identity.js (extend), new server/services/goalEvaluator.js, server/routes/identity.js (extend), client/src/pages/Goals.jsx, client/src/components/goals/tabs/, Layout.jsx, autonomousJobs.js*
+- [ ] **P8: Digital Twin voice drafting** — Draft responses using Digital Twin voice/style
+- [ ] **P9: CoS Automation & Rules** — Automated classification on new emails via CoS job, rule-based pre-filtering, email-to-task pipeline, priority email notifications
+- [ ] **P10: Auto-Send with AI Review Gate** — Configurable per-account trust level (manual > review-assisted > auto-send). Second LLM reviews drafts for prompt injection, tone drift, leaked instructions. See [Messages Security](./docs/features/messages-security.md)
-### M50: Messages (Email Management)
+### M42 P5: Cross-Insights Engine
-Multi-provider email integration — Gmail via Google API (shared OAuth with Calendar), Outlook/Teams via CDP browser automation (Playwright). Unified Messages page with Inbox, Drafts, Sync, and Config sub-pages.
+- [ ] Connect genome markers, taste profiles, personality traits, and goal progress into cross-domain derived insights
-Always review before send — AI-generated drafts go to an outbox queue. The user reviews, edits, and approves each response before it's sent. No auto-send.
+### M34 P5-P7: Digital Twin Enhancement
-**Completed:** P1-P7 (Email sync, AI triage, reply generation, thread capture, config, per-action models, prompt injection hardening, per-message re-fetch, Gmail API sync+send).
+- [ ] **P5**: Multi-modal capture (voice, video, image-based identity modeling)
+- [ ] **P6**: Advanced testing (deeper behavioral profiling)
+- [ ] **P7**: Personas (context-specific identity modes)
-**Remaining:**
+---
-- [ ] **P8: Digital Twin voice drafting** — Draft responses using Digital Twin voice/style (reads COMMUNICATION.md, PERSONALITY.md, VALUES.md + recent thread context)
-- [ ] **P9: CoS Automation & Rules** — Automated classification on new emails via CoS job, rule-based pre-filtering, email-to-task pipeline, priority email notifications
-- [ ] **P10: Auto-Send with AI Review Gate** — Configurable per-account trust level (manual → review-assisted → auto-send). Second LLM reviews drafts for prompt injection, tone drift, leaked instructions. See [Messages Security](./docs/features/messages-security.md)
+## Outstanding Audit Findings (2026-03-05)
-**Data:** `data/messages/accounts.json`, `data/messages/cache/{accountId}.json`, `data/messages/selectors.json`, `settings.json` (messages key for AI config + templates)
+**Known low-severity:** pm2 ReDoS (GHSA-x5gf-qvw8-r2rm) — no upstream fix, not exploitable via PortOS routes.
-**Routes:** `GET /api/messages/inbox`, `GET /api/messages/:accountId/:messageId`, `GET /api/messages/thread/:accountId/:threadId`, `POST /api/messages/sync/:accountId`, `POST /api/messages/:accountId/:messageId/refresh`, `POST /api/messages/fetch-full/:accountId`, `POST /api/messages/accounts/:id/cache/clear`, `POST /api/messages/evaluate`, `POST /api/messages/drafts/generate`, CRUD for accounts/drafts/selectors
+### Architecture (still present)
+- [ ] `server/services/cos.js` (~3950 lines, 53 exports) — God file, needs decomposition
+- [ ] `server/services/subAgentSpawner.js` (~3300 lines) — Mega service
+- [ ] Circular dependency: `cos.js` <> `subAgentSpawner.js` via dynamic imports
+- [ ] `client/src/services/api.js` (~1850 lines) — Monolithic API client
+- [ ] `server/services/digital-twin.js` (~2800 lines) — Mixed concerns
+- [ ] `server/routes/cos.js` (~1350 lines) — Business logic in route handlers
+- [ ] `server/routes/scaffold.js` (~1670 lines) — God route file
+- [ ] Inconsistent pagination patterns and error response envelope
+
+### Bugs & Code Quality (still present)
+- [ ] `server/services/agentActionExecutor.js:137` — Complex array fallback logic
+- [ ] `client/src/pages/PromptManager.jsx` — Fetch calls missing response.ok check
+- [ ] `server/services/memory.js` — Sort comparison not type-safe for dates
+- [ ] `server/services/memorySync.js` + `server/lib/db.js` — Unsafe `rows[0]` access without bounds check
+- [ ] Hardcoded localhost in `lmStudioManager.js`, `memoryClassifier.js`
+- [ ] Empty `.catch(() => {})` in several client files
+- [ ] Silent catch blocks in `useTheme.js`, `runner.js`, `db.js`, `Settings.jsx`
+
+### DRY (still present)
+- [ ] Duplicate DATA_DIR/path constants in 29 files
+- [ ] 65 instances of `mkdir({recursive:true})` vs centralized `ensureDir()`
+
+### Test Coverage
+- ~29% service coverage, ~12% route coverage
+- Critical gaps: `cos.js`, `cosRunnerClient.js`, `agentActionExecutor.js`, `memorySync.js`
-**Nav:** Collapsible "Messages" sidebar section with Drafts, Inbox, Sync, Config sub-pages
+---
-### Tier 1: Identity Integration (aligns with M42 direction)
+## Future Ideas
-- **Chronotype-Aware Scheduling** — Chronotype derivation exists (M42 P1) but isn't applied to task scheduling yet. Use peak-focus windows from genome sleep markers to schedule deep-work tasks during peak hours, routine tasks during low-energy. Display energy curve on Schedule tab. *Touches: taskSchedule.js, genome.js, CoS Schedule tab*
-- **Identity Context Injection** — Identity context is used for taste questions (M42 P2.5) but not yet injected as a system preamble for general AI calls. Build identity brief from EXISTENTIAL.md, taste, personality, autobiography; inject via toolkit. Per-task-type toggle. *Touches: portos-ai-toolkit, runner.js, CoS Config*
+### Tier 1: Identity Integration
+- **Chronotype-Aware Scheduling** — Use genome sleep markers for peak-focus task scheduling
+- **Identity Context Injection** — Per-task-type toggle for digital twin preamble injection (basic injection exists, needs granular control)
### Tier 2: Deeper Autonomy
-
-- **Agent Confidence & Autonomy Levels** — Graduated autonomy tiers based on historical success rates and blast radius. System earns more autonomy over time. *Touches: cos.js, taskLearning.js, CoS Tasks UI*
-- **Content Calendar** — Unified calendar view of planned content across platforms. CoS auto-schedules based on engagement patterns. Draft → review → published pipeline. *Touches: New ContentCalendar page/route*
-- **Proactive Insight Alerts** — Real-time notifications when: brain captures connect to old memories, agent success rate drops, goals stall, costs spike. *Touches: notifications.js, brain.js, taskLearning.js*
-- **Goal Decomposition Engine** — Auto-decompose new goals into task sequences with dependencies by analyzing codebase and capabilities. Goal → task → outcome lineage tracking. *Touches: cos.js, goalProgress.js, missions.js*
+- **Agent Confidence & Autonomy Levels** — Graduate from static presets to dynamic tiers based on success rates
+- **Content Calendar** — Unified calendar view of planned content across platforms
+- **Proactive Insight Alerts** — Notifications for brain connections, success drops, goal stalls, cost spikes
+- **Goal Decomposition Engine** — Auto-decompose goals into task sequences with dependencies
### Tier 3: Knowledge & Legacy
-
-- **Knowledge Graph Visualization** — Interactive force-directed graph mapping connections between brain captures, memories, goals, agent outputs. Color-coded nodes, semantic link edges. *Touches: New visualization component, brain.js, memory.js*
-- **Time Capsule Snapshots** — Periodic versioned archives of full digital twin state. "Then vs. Now" comparison view tracking identity evolution. *Touches: New timeCapsule service, digital-twin snapshots*
-- **Autobiography Prompt Chains** — Themed prompt chains (childhood → education → career → turning points → hopes) that build on prior answers. LLM-generated follow-ups. *(Extends M34 P5)* *Touches: autobiography.js, Digital Twin UI*
-- **Legacy Export Format** — Compile autobiography, personality, genome, taste, decisions, brain highlights into portable human-readable document (Markdown/PDF). *Touches: New export service*
+- **Knowledge Graph Visualization** — Extend existing BrainGraph 3D view to full knowledge graph (goals, agent outputs, memories)
+- **Time Capsule Snapshots** — Periodic versioned archives of digital twin state with "Then vs. Now" comparison
+- **Autobiography Prompt Chains** — LLM-generated follow-ups building on prior autobiography answers
+- **Legacy Export Format** — Compile identity into portable Markdown/PDF document
### Tier 4: Developer Experience
-
-- **Dashboard Customization** — Drag-and-drop widget reordering, show/hide toggles, named layouts ("morning briefing", "deep work"). *Touches: Dashboard.jsx, settings.js, dnd-kit*
-- **Workspace Contexts** — Active project context that syncs shell, git, tasks, and browser to current project. Persists across navigation. *Touches: Settings state, Layout context, Shell/Git/Browser*
-- **Inline Code Review Annotations** — Surface self-improvement findings as inline annotations in a code viewer. One-click "fix this" spawns CoS task. *Touches: New code viewer, selfImprovement.js*
+- **Dashboard Customization** — Drag-and-drop widget reordering, show/hide toggles, named layouts
+- **Workspace Contexts** — Active project context syncing across shell, git, tasks, browser
+- **Inline Code Review Annotations** — Surface self-improvement findings as inline annotations with one-click fix
### Tier 5: Multi-Modal & Future
-
-- **Voice Capture for Brain** — Microphone button using Web Speech API for transcription. Feeds into brain classification pipeline. *Touches: Brain capture UI, Web Speech API*
-- **RSS/Feed Ingestion** — Passive ingestion from subscribed feeds, LLM-classified by user interests. Brain becomes personalized research aggregator. *Touches: New feedIngestion service, Brain inbox*
-- **Ambient Dashboard Mode** — Live status board for wall-mounted displays: tasks, agent activity, health, schedule, energy curve. Real-time WebSocket updates. *Touches: New AmbientDashboard page*
-- **Dynamic Skill Marketplace** — Skills as JSON/YAML documents in data/skills/. CoS discovers and routes dynamically. Self-generates new skill templates from task patterns. *Touches: taskClassifier.js, Prompt Manager*
-
----
-
-## Documentation
-
-### Architecture & Guides
-- [Architecture Overview](./docs/ARCHITECTURE.md) - System design, data flow
-- [API Reference](./docs/API.md) - REST endpoints, WebSocket events
-- [Contributing Guide](./docs/CONTRIBUTING.md) - Code guidelines, git workflow
-- [GitHub Actions](./docs/GITHUB_ACTIONS.md) - CI/CD workflow patterns
-- [PM2 Configuration](./docs/PM2.md) - PM2 patterns and best practices
-- [Port Allocation](./docs/PORTS.md) - Port conventions and allocation
-- [Security Audit](./docs/SECURITY_AUDIT.md) - 2025-02-19 hardening audit (all resolved)
-- [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions
-- [Versioning & Releases](./docs/VERSIONING.md) - Version format, release process
-
-### Feature Documentation
-- [Agent Skills](./docs/features/agent-skills.md) - Task-type-specific prompt templates and routing
-- [App Wizard](./docs/features/app-wizard.md) - Register apps and create from templates
-- [Autofixer](./docs/features/autofixer.md) - Autonomous crash detection and repair
-- [Brain System](./docs/features/brain-system.md) - Second-brain capture and classification
-- [Browser Management](./docs/features/browser.md) - CDP/Playwright browser management
-- [Chief of Staff](./docs/features/chief-of-staff.md) - Autonomous agent orchestration
-- [CoS Agent Runner](./docs/features/cos-agent-runner.md) - Isolated agent process management
-- [CoS Enhancement](./docs/features/cos-enhancement.md) - M35 hybrid memory, missions, thinking levels
-- [Digital Twin](./docs/features/digital-twin.md) - Quantitative personality modeling
-- [Error Handling](./docs/features/error-handling.md) - Graceful error handling with auto-fix
-- [Identity System](./docs/features/identity-system.md) - Unified identity architecture (M42 spec)
-- [JIRA Sprint Manager](./docs/features/jira-sprint-manager.md) - Autonomous JIRA triage and implementation
-- [Memory System](./docs/features/memory-system.md) - Semantic memory with LLM classification
-- [Messages Security](./docs/features/messages-security.md) - AI prompt injection threat model and defenses
-- [POST](./docs/features/post.md) - Cognitive self-test and training system
-- [Prompt Manager](./docs/features/prompt-manager.md) - Customizable AI prompts
-- [Soul System](./docs/features/soul-system.md) - Digital twin identity scaffold
-
----
-
-## Code Audits
-
-See [Security Audit](./docs/SECURITY_AUDIT.md) for the 2025-02-19 security hardening (all 10 items resolved).
-
-### Outstanding Audit Findings (2026-03-05)
-
-Three audit passes identified remaining items across architecture, bugs, code quality, and test coverage. Resolved items from Passes 1-3 have been removed (fixed via PRs #67-72).
-
-**Known low-severity:** pm2 ReDoS (GHSA-x5gf-qvw8-r2rm) — no upstream fix, not exploitable via PortOS routes.
-
-#### Architecture & SOLID
-- [ ] **[CRITICAL]** `server/services/cos.js` (~3800 lines) — God file with 40+ exports. Needs decomposition.
-- [ ] **[CRITICAL]** `server/services/subAgentSpawner.js` (~3300 lines) — Mega service spanning model selection, spawning, worktrees, JIRA, git, memory.
-- [ ] **[CRITICAL]** Circular dependency: `cos.js` ↔ `subAgentSpawner.js` via dynamic imports.
-- [ ] **[HIGH]** `client/src/services/api.js` (1627 lines) — Monolithic API client mixing 20+ domains.
-- [ ] **[HIGH]** `server/services/digital-twin.js` (2823 lines) — Mixed CRUD, LLM testing, enrichment, export.
-- [ ] **[HIGH]** `server/routes/cos.js` (1253 lines) — Business logic mixed with HTTP handlers.
-- [ ] **[HIGH]** `server/routes/scaffold.js` (1270 lines) — God route file.
-- [ ] **[HIGH]** `server/routes/apps.js:68-77,126-135` — Duplicated app status computation.
-- [ ] **[HIGH]** `client/src/pages/ChiefOfStaff.jsx` (864 lines) — 24 useState hooks.
-- [ ] **[MEDIUM]** Inconsistent pagination patterns and error response envelope.
-
-#### Bugs & Performance
-- [ ] **[CRITICAL]** `server/services/cos.js` TOCTOU race: addTask/updateTask/deleteTask lack withStateLock mutex.
-- [ ] **[CRITICAL]** `server/services/cosRunnerClient.js` — 12 fetch calls missing timeouts.
-- [ ] **[HIGH]** `server/services/cosRunnerClient.js` — Socket.IO with infinite reconnection, no error handler.
-- [ ] **[HIGH]** `server/services/memory.js` — Data race: loadMemory() outside withMemoryLock.
-- [ ] **[HIGH]** `server/services/agentActionExecutor.js:137` — Unsafe array fallback may yield non-array.
-- [ ] **[HIGH]** `client/src/pages/PromptManager.jsx` — Fetch calls missing response.ok check.
-- [ ] **[MEDIUM]** `server/services/cos.js` — Migration rename fallback silently swallowed; agent index lazy-load race.
-- [ ] **[MEDIUM]** `server/services/memory.js` — Sort comparison not type-safe for dates.
-
-#### Code Quality
-- [ ] **[HIGH]** `server/services/memorySync.js:156` + `server/lib/db.js:85` — Unsafe `rows[0]` access without bounds check.
-- [ ] **[MEDIUM]** Hardcoded localhost in `server/services/lmStudioManager.js`, `server/services/memoryClassifier.js`.
-- [ ] **[MEDIUM]** Empty `.catch(() => {})` in 5 client files (`client/src/pages/Browser.jsx`, `Shell.jsx`, `client/src/components/cos/TaskAddForm.jsx`, `client/src/hooks/useAgentFeedbackToast.jsx`, `client/src/components/meatspace/HealthCategorySection.jsx`).
-- [ ] **[MEDIUM]** `client/src/pages/DevTools.jsx` — Stale closure risk.
-- [ ] **[MEDIUM]** Silent catch blocks in `client/src/hooks/useTheme.js`, `server/services/runner.js`, `server/lib/db.js`, `client/src/pages/Settings.jsx`.
-
-#### DRY
-- [ ] **[HIGH]** Duplicate `getDateString` in `server/services/agentActivity.js` + `server/services/productivity.js`.
-- [ ] **[HIGH]** Duplicate HOUR/DAY constants in `server/services/autonomousJobs.js` + `server/services/taskSchedule.js`.
-- [ ] **[HIGH]** Duplicate DATA_DIR/path constants in 8+ files.
-- [ ] **[MEDIUM]** Missing fetch timeouts in `server/integrations/moltworld/api.js` + `server/integrations/moltbook/api.js`.
-- [ ] **[MEDIUM]** 39 instances of `mkdir({recursive:true})` vs centralized `ensureDir()`.
-
-#### Test Coverage
-- Overall: ~29% service coverage, ~12% route coverage
-- Critical gaps: `server/services/cos.js`, `server/services/cosRunnerClient.js`, `server/services/agentActionExecutor.js`, `server/services/memorySync.js`
-- High gaps: `server/services/autoFixer.js`, `server/services/digital-twin.js`, `server/services/memory.js`, `server/services/brain.js`, `server/services/pm2.js`, `server/services/shell.js`, `server/services/instances.js`
-
----
-
-## Next Actions
-
-1. **M50 P8**: Messages — Digital Twin voice drafting for email responses
-2. **M42 P5**: Cross-Insights Engine — connect genome + taste + personality + goals into derived insights
-4. **M34 P5-P7**: Digital Twin — Multi-modal capture, advanced testing, personas
+- **Voice Capture for Brain** — Microphone + Web Speech API transcription to brain pipeline
+- **RSS/Feed Ingestion** — Passive feed ingestion classified by interests
+- **Ambient Dashboard Mode** — Live status board for wall-mounted displays
+- **Dynamic Skill Marketplace** — Self-generating skill templates from task patterns
diff --git a/server/services/cos.js b/server/services/cos.js
index 8507e2f846..336964c14d 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -1314,7 +1314,7 @@ function getSelfImprovementTaskDescription(taskType) {
'performance': 'Profile and optimize slow components, queries, and renders',
'test-coverage': 'Add missing tests for uncovered code paths',
'documentation': 'Update documentation, comments, and README files',
- 'feature-ideas': 'Implement a feature idea aligned with GOALS.md (worktree+PR)',
+ 'feature-ideas': 'Implement a feature idea aligned with GOALS.md and PLAN.md (worktree+PR)',
'accessibility': 'Audit and fix accessibility issues (ARIA, keyboard nav, contrast)',
'dependency-updates': 'Check for and safely update outdated dependencies',
'error-handling': 'Improve error handling patterns and recovery logic',
@@ -1342,7 +1342,7 @@ function getAppImprovementTaskDescription(taskType, app) {
'typing': `Add/fix TypeScript types in ${app.name}`,
'ui-bugs': `Review UI for visual bugs in ${app.name}`,
'mobile-responsive': `Check mobile responsiveness of ${app.name}`,
- 'feature-ideas': `Implement a feature idea for ${app.name} aligned with GOALS.md (worktree+PR)`,
+ 'feature-ideas': `Implement a feature idea for ${app.name} aligned with GOALS.md and PLAN.md (worktree+PR)`,
'release-check': `Verify release readiness for ${app.name}`,
'jira-sprint-manager': `Triage and implement JIRA sprint tickets for ${app.name} (worktree+PR)`
};
@@ -1752,10 +1752,10 @@ Use model: claude-opus-4-5-20251101 for comprehensive test design`,
Review and improve PortOS documentation:
-1. Update PLAN.md:
- - Mark completed milestones
- - Add any new features implemented
- - Document architectural decisions
+1. Update PLAN.md and DONE.md:
+ - Move completed milestones from PLAN.md to DONE.md
+ - Add any new features implemented to DONE.md
+ - Keep PLAN.md focused on next actions and future work
2. Check docs/ folder:
- Are all features documented?
@@ -1788,18 +1788,20 @@ You are working in a git worktree on a feature branch. Your goal is to implement
## Research Phase
1. Read GOALS.md for context on user goals and priorities
-2. Read PLAN.md for the current roadmap and planned work
-3. Search for existing feature idea documents:
+2. Read PLAN.md for the current roadmap and planned work (next actions, audit findings, future ideas)
+3. Read DONE.md to understand what has already been implemented (avoid re-implementing existing features)
+4. Search for existing feature idea documents:
- Check .planning/research/FEATURES.md for planned features
- Check .planning/ directory for any feature specs or research docs
- Check data/COS-GOALS.md for CoS-specific goals
-4. Review recent completed tasks to understand what's already been done
-5. Review recent git log to see what's been implemented recently
+5. Review recent completed tasks to understand what's already been done
+6. Review recent git log to see what's been implemented recently
## Selection Phase
-6. Choose ONE feature to implement that:
+7. Choose ONE feature to implement that:
- Aligns with GOALS.md priorities
+ - Is NOT already completed in DONE.md (avoid re-implementing shipped features)
- Is NOT already planned in PLAN.md (avoid duplicating roadmap work)
- Is NOT already documented in existing feature idea files
- Is a small, self-contained improvement (completable in one session)
@@ -1807,14 +1809,14 @@ You are working in a git worktree on a feature branch. Your goal is to implement
## Implementation Phase
-7. Implement the feature:
+8. Implement the feature:
- Write clean, tested code
- Follow existing patterns in the codebase
- Run tests to ensure nothing is broken
-8. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
+9. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
-9. Commit with a clear description of the feature and rationale
+10. Commit with a clear description of the feature and rationale
Use model: claude-opus-4-5-20251101 for creative feature development`,
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index dc9477393b..afff3775d2 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -290,9 +290,9 @@ Repository: {repoPath}
- Is information current?
- Add missing guides if needed
-4. Update PLAN.md or similar if present:
- - Mark completed milestones
- - Document architectural decisions
+4. Update PLAN.md and DONE.md if present:
+ - Move completed milestones from PLAN.md to DONE.md
+ - Keep PLAN.md focused on next actions and future work
Commit documentation improvements.`,
@@ -333,28 +333,29 @@ Repository: {repoPath}
## Phase 1 — Find the Next Task
1. Read PLAN.md from {repoPath}
-2. If PLAN.md does not exist, is empty, or has no unchecked items (\`- [ ]\`), go to **Phase 4 — Brainstorm**.
-3. Find the first unchecked item (\`- [ ]\`) that does NOT have a \`<!-- NEEDS_INPUT -->\` annotation
-4. If all unchecked items have \`<!-- NEEDS_INPUT -->\`, go to **Phase 4 — Brainstorm**.
+2. Read DONE.md from {repoPath} (if it exists) to understand what has already been implemented
+3. If PLAN.md does not exist, is empty, or has no unchecked items (\`- [ ]\`), go to **Phase 4 — Brainstorm**.
+4. Find the first unchecked item (\`- [ ]\`) that does NOT have a \`<!-- NEEDS_INPUT -->\` annotation
+5. If all unchecked items have \`<!-- NEEDS_INPUT -->\`, go to **Phase 4 — Brainstorm**.
## Phase 2 — Evaluate Feasibility
-5. Read relevant source files to understand the scope of the item
-6. Determine: can this be implemented without user clarification?
+6. Read relevant source files to understand the scope of the item
+7. Determine: can this be implemented without user clarification?
- Consider: are requirements clear? Are there ambiguous design choices? Does it depend on external decisions?
## Phase 3a — Implement (if feasible)
-7. Implement the feature:
+8. Implement the feature:
- Write clean, tested code following existing patterns
- Run tests to ensure nothing is broken
-8. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
-9. Check the PLAN.md item: change \`- [ ]\` to \`- [x]\`
-10. Commit with a clear description referencing the PLAN.md item
+9. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
+10. Check the PLAN.md item: change \`- [ ]\` to \`- [x]\`
+11. Commit with a clear description referencing the PLAN.md item
## Phase 3b — Request Clarification (if not feasible)
-7. Create a file named \`.plan-questions.md\` in the repository root with this format:
+8. Create a file named \`.plan-questions.md\` in the repository root with this format:
\`\`\`
# Plan Question: <short title summarizing the PLAN.md item>
@@ -365,9 +366,9 @@ Repository: {repoPath}
- <question 1>
- <question 2>
\`\`\`
-8. Annotate the PLAN.md item by appending \` <!-- NEEDS_INPUT -->\` to its line
-9. Commit both changes with message "chore: flag PLAN.md item needing user input"
-10. Do NOT open a PR — stop here
+9. Annotate the PLAN.md item by appending \` <!-- NEEDS_INPUT -->\` to its line
+10. Commit both changes with message "chore: flag PLAN.md item needing user input"
+11. Do NOT open a PR — stop here
## Phase 4 — Brainstorm a New Feature
@@ -375,21 +376,23 @@ When PLAN.md is missing, empty, or fully completed, brainstorm and implement a n
1. Read GOALS.md from {repoPath} for context on the app's goals and priorities.
If no GOALS.md exists, focus on general improvements.
-2. Review the codebase structure, recent git log, and any README or docs to understand the app
-3. Identify ONE small, high-impact feature that:
+2. Read DONE.md from {repoPath} (if it exists) to avoid re-implementing completed features
+3. Review the codebase structure, recent git log, and any README or docs to understand the app
+4. Identify ONE small, high-impact feature that:
- Aligns with GOALS.md priorities (if available)
+ - Is NOT already in DONE.md (avoid re-implementing shipped features)
- Saves user time, improves UX, or makes the app more useful
- Is self-contained and completable in one session
- Does NOT duplicate existing functionality
-4. Implement the feature:
+5. Implement the feature:
- Write clean, tested code following existing patterns
- Run tests to ensure nothing is broken
-5. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
-6. Add the feature as a checked item in PLAN.md (create the file if needed):
+6. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
+7. Add the feature as a checked item in PLAN.md (create the file if needed):
\`\`\`
- [x] <description of the feature you implemented>
\`\`\`
-7. Commit with a clear description of the feature and rationale`,
+8. Commit with a clear description of the feature and rationale`,
'error-handling': `[Improvement: {appName}] Improve Error Handling
@@ -618,7 +621,7 @@ Repository: {repoPath}
// Prompt versions — bump when a default prompt changes so existing instances auto-upgrade.
// Only non-customized prompts (promptCustomized !== true) are upgraded.
const PROMPT_VERSIONS = {
- 'feature-ideas': 4 // v4: brainstorm new feature when PLAN.md is missing/empty/done
+ 'feature-ideas': 5 // v5: read DONE.md to avoid re-implementing completed features
};
// Known previous default prompts for legacy migration.
@@ -734,7 +737,74 @@ Repository: {repoPath}
\`\`\`
7. Annotate the PLAN.md item by appending \` <!-- NEEDS_INPUT -->\` to its line
8. Commit both changes with message "chore: flag PLAN.md item needing user input"
-9. Do NOT open a PR — stop here`
+9. Do NOT open a PR — stop here`,
+ // v4 default prompt (before DONE.md support)
+ `[Improvement: {appName}] Implement Next Planned Feature
+
+You are working in a git worktree on a feature branch. Your goal is to implement the next planned item from PLAN.md, or brainstorm a new feature if no plan exists.
+
+Repository: {repoPath}
+
+## Phase 1 — Find the Next Task
+
+1. Read PLAN.md from {repoPath}
+2. If PLAN.md does not exist, is empty, or has no unchecked items (\`- [ ]\`), go to **Phase 4 — Brainstorm**.
+3. Find the first unchecked item (\`- [ ]\`) that does NOT have a \`<!-- NEEDS_INPUT -->\` annotation
+4. If all unchecked items have \`<!-- NEEDS_INPUT -->\`, go to **Phase 4 — Brainstorm**.
+
+## Phase 2 — Evaluate Feasibility
+
+5. Read relevant source files to understand the scope of the item
+6. Determine: can this be implemented without user clarification?
+ - Consider: are requirements clear? Are there ambiguous design choices? Does it depend on external decisions?
+
+## Phase 3a — Implement (if feasible)
+
+7. Implement the feature:
+ - Write clean, tested code following existing patterns
+ - Run tests to ensure nothing is broken
+8. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
+9. Check the PLAN.md item: change \`- [ ]\` to \`- [x]\`
+10. Commit with a clear description referencing the PLAN.md item
+
+## Phase 3b — Request Clarification (if not feasible)
+
+7. Create a file named \`.plan-questions.md\` in the repository root with this format:
+ \`\`\`
+ # Plan Question: <short title summarizing the PLAN.md item>
+
+ ## PLAN.md Item
+ <the exact text of the unchecked item>
+
+ ## Questions
+ - <question 1>
+ - <question 2>
+ \`\`\`
+8. Annotate the PLAN.md item by appending \` <!-- NEEDS_INPUT -->\` to its line
+9. Commit both changes with message "chore: flag PLAN.md item needing user input"
+10. Do NOT open a PR — stop here
+
+## Phase 4 — Brainstorm a New Feature
+
+When PLAN.md is missing, empty, or fully completed, brainstorm and implement a new feature:
+
+1. Read GOALS.md from {repoPath} for context on the app's goals and priorities.
+ If no GOALS.md exists, focus on general improvements.
+2. Review the codebase structure, recent git log, and any README or docs to understand the app
+3. Identify ONE small, high-impact feature that:
+ - Aligns with GOALS.md priorities (if available)
+ - Saves user time, improves UX, or makes the app more useful
+ - Is self-contained and completable in one session
+ - Does NOT duplicate existing functionality
+4. Implement the feature:
+ - Write clean, tested code following existing patterns
+ - Run tests to ensure nothing is broken
+5. Run \`/simplify\` to review changed code for reuse, quality, and efficiency. Fix any issues found.
+6. Add the feature as a checked item in PLAN.md (create the file if needed):
+ \`\`\`
+ - [x] <description of the feature you implemented>
+ \`\`\`
+7. Commit with a clear description of the feature and rationale`
]
};