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
docs: replan — archive 7 completed items, add World Builder Phase 2 + Workflow Phase 2 ideas
Adam Eivy688f32226825
diff --git a/DONE.md b/DONE.mdindex dd2e5ae0b7..ff56b9ee30 100644--- a/DONE.md+++ b/DONE.md@@ -4,6 +4,16 @@ Archive of completed work. For active roadmap, see [PLAN.md](./PLAN.md). For pro---+## 2026-05-09++- **Creative Director — i2v continuity fidelity (per-scene `imageStrength`)** — Added `imageStrength` (0..1, nullable) to `creativeDirectorSceneSchema` + `creativeDirectorSceneUpdateSchema`; `sceneRunner.resolveImageStrength` defaults continuation scenes (`useContinuationFromPrior=true`) to 0.85 and lets the evaluator override on retry. Already threaded through `videoGen/local.js#generateVideo` → mediaJobQueue. `creativeDirectorPrompts.js` surfaces the current setting on the evaluate view; `cd-treatment.md` / `cd-evaluate.md` document the knob; `TreatmentTab.jsx` shows "str X" on the scene chip. (PR #208)+- **CoS Workflow tab + canonical scheduled-task ordering** — New `/cos/workflow` page renders the full set of scheduled tasks + autonomous jobs as a left-to-right pipeline grouped into 7 canonical stages (Hygiene → Review → Plan → Audit → Build → Report → Ambient). Each card surfaces schedule, last-run, run count, enabled state, and live "due / waiting / disabled / waiting-on-dependencies" badge plus inline `runAfter` arrows. Backed by `server/services/workflow.js` + `routes/cosWorkflowRoutes.js` (`GET /api/cos/workflow`, `GET /api/cos/workflow/stages`). Two default `runAfter` wirings ship: `do-replan` runs after `pr-reviewer` + `branch-cleanup`, `feature-ideas` runs after `do-replan`. 16 new unit tests + 3 schedule tests. (PR #212)+- **World Builder for Media Gen** — `/media/world-builder` takes a one-line starter prompt (e.g. "moebius and scavengers reign meets Prophet inspired sci-fi universe") and asks the chosen LLM to expand it into a structured prompt set: positive `stylePrompt` prefix, `negativePrompt`, and 6–10 variations across five canonical buckets (landscapes, environments, characters, structures, vehicles). Per-template provider/model picker, batch-render compiles `stylePrompt + variation.prompt` for every selected bucket and queues through the existing image-gen pipeline (local mflux or Codex). Each batch lands in an auto-named Media Collection ("World: <name> — <timestamp>"). Backed by `server/services/worldBuilder.js`, `worldBuilderExpand.js`, `worldBuilderCollectionHook.js`, `routes/worldBuilder.js`. State in `data/world-builder.json`. 20 new tests. Nav manifest entry `nav.media.world-builder`. (PR #211)+- **Dismissible CoS Learning AI Recommendations** — Each recommendation in the Learning Analytics panel has an X to dismiss. Persists to `data/cos/dismissed-recommendations.json` and filters from future loads. Count-based alerts ("unknown errors occurred 74 times") record the count snapshot and only re-surface if the count grows ≥1.5× and at least +20. Rate-based recommendations stay dismissed until restored. "Show dismissed" expander lets you restore individually or clear all.+- **CoS review-loop tasks loop until clean and merge the PR** — Scheduled or user tasks running with worktree + openPR + reviewLoop now spawn a follow-up internal task once the PR is open and the initial Copilot review is requested. The follow-up agent attaches a fresh worktree to the PR branch (new `existingBranch` option on `createWorktree`), runs the full `/do:rpr`-style poll/fix/push/re-request loop until Copilot returns zero unresolved comments (or hits a 10-iteration guardrail), then `gh pr merge --squash --auto --delete-branch`. The follow-up's cleanup pass passes `skipMerge: true` so the worktree branch isn't re-merged on top of the squash-merge. GitLab MRs and other non-GitHub forges still skip the loop. (`server/services/agentLifecycle.js#spawnReviewLoopFollowUp`, `agentPromptBuilder.js#reviewLoopFollowUpSection`)+- **CyberCity v2 — Phase 1 operational legibility** — Per-building health glyphs, "needs attention" pane, search overlay, status filter chips (`CityFilterBar.jsx`), clickable HUD stats, hover preview with quick actions, mobile/touch support. Phase 2 (interactive systems map / drill-down + agent-paths) still pending — see [docs/features/cybercity-v2.md](./docs/features/cybercity-v2.md).+- **Better Audit follow-up — socket.js disconnect cleanup** — `socket.on('disconnect')` calls `shellService.detachSocketSessions(socket)` which transitively calls `unsubscribeSessionList(socket)` (`server/services/shell.js:217`). The cleanup the audit flagged as missing is wired correctly via the higher-level helper.+## 2026-05-06- **Creative Director — multi-frame evaluator sampling** — `extractEvaluationFrames` in `server/lib/ffmpeg.js` probes total frames and writes 5 timeline-tagged samples; `sceneRunner.handleRenderCompleted` calls it before evaluator enqueue; `buildEvaluatePrompt` lists every frame with explicit late-intent guidance. Falls back to single thumbnail on extraction failure.diff --git a/PLAN.md b/PLAN.mdindex a585ba8adb..d817ee0973 100644--- a/PLAN.md+++ b/PLAN.md@@ -7,18 +7,17 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md]## Next Up1. **Voice agent next power-ups** — `ui_read` (extract visible page text so "what does this say?" works without hand-navigation), destructive-action confirmation gate (pause and require spoken "confirm" when `ui_click` matches `/delete|remove|discard|reset|clear/i`), proactive CoS speech (server-pushed voice with quiet-hours policy + barge-in contract).-2. **Chronotype-aware CoS scheduling** — M42 ships chronotype derivation but `taskSchedule.js` still routes round-robin. Add a `temporalPreference` field to CoS task schema (`focus` / `low-energy` / `any`) and shift priority by time-of-day from the identity chronotype profile. Targeted addition (~150 lines), no new deps.-3. **God-file test coverage** — `cos.js` (3071 lines) and `agentLifecycle.js` (1314 lines) still have no test sibling. Add tests for `evaluateTasks` priority ordering + `dequeueNextTask` capacity guards (cos), and `spawnAgentForTask` + `handleAgentCompletion` error recovery (agentLifecycle).+2. **Chronotype-aware CoS scheduling** — M42 ships chronotype derivation (`identity.js#getChronotype` + `getEnergyZones`) but `taskSchedule.js` still routes round-robin. Add a `temporalPreference` field to CoS task schema (`focus` / `low-energy` / `any`) and shift priority by time-of-day from the identity chronotype profile. Targeted addition (~150 lines), no new deps.+3. **God-file test coverage** — `cos.js` (3115 lines) and `agentLifecycle.js` (1435 lines) still have no test sibling. Add tests for `evaluateTasks` priority ordering + `dequeueNextTask` capacity guards (cos), and `spawnAgentForTask` + `handleAgentCompletion` error recovery (agentLifecycle). Both files are still growing — 44 LOC since last replan; add coverage before further surgery.## Backlog### Creative Director follow-ups-The pipeline now has multi-frame evaluation, auto-accept watchdog, and a cheap smoke fixture (see DONE.md 2026-05-06). The first real E2E run surfaced these remaining targets:+The pipeline now has multi-frame evaluation, auto-accept watchdog, cheap smoke fixture, and per-scene `imageStrength` continuation anchoring (see DONE.md). Remaining targets surfaced by the long E2E run:-- [x] **i2v continuity fidelity.** `useContinuationFromPrior: true` feeds the prior scene's last frame as `sourceImagePath` but doesn't pin `imageStrength`. Renders sometimes drift hard from the seed (a "blue ball" continuation generates a totally new scene that loosely starts from the seed). `imageStrength` is already threaded through `videoGen/local.js`; surface it as a per-scene knob in the treatment schema (default ~0.85 for continuation scenes, lower if the prompt deliberately changes the subject) and pipe it through `sceneRunner.params`.- [ ] **Audio continuity across scenes.** mlx-video-with-audio generates audio per-clip; concatenated scenes have audible cuts at scene boundaries. Either render scenes silently and add a single backing audio pass at stitch time, or apply a short crossfade in `videoTimeline/local.js#buildFfmpegArgs` (already does video crossfades — extend to audio with `acrossfade`).-- [ ] **Duplicate evaluator spawn dedup.** During the long E2E run, server logs showed `Task already being spawned, skipping duplicate` followed seconds later by a *second* agent spawning for the exact same task id. The CoS task lane logic ends up double-acquiring. Reproduce in a unit test against `taskSchedule` / `agentLifecycle` and fix the de-dup window.+- [ ] **Duplicate evaluator spawn dedup.** During the long E2E run, server logs showed `Task already being spawned, skipping duplicate` followed seconds later by a *second* agent spawning for the exact same task id. The CoS task lane logic ends up double-acquiring. Reproduce in a unit test against `taskSchedule` / `agentLifecycle` and fix the de-dup window (`agentLifecycle.js:114`).- [ ] **Render slowness on long sessions.** Per-scene render time degraded from ~3.5 min (early) to 10–30 min (late) within one project — likely accumulated listeners + queue races. Profile after sustained use; the round-22 dedup work probably already helps; verify.### LTX-2.3 dgrauet runtime — wire native modes@@ -26,7 +25,7 @@ The pipeline now has multi-frame evaluation, auto-accept watchdog, and a cheap sThe dgrauet/ltx-2-mlx runtime ships with FFLF (true keyframe interpolation), audio-to-video, and native video Extend (see DONE.md 2026-05-06). Remaining gaps:- [ ] **Native FFLF deeper test on real keyframe pairs.** FFLF wiring is verified on synthetic ball-motion keyframes (commit `ef5d9081`). Validate with REAL pairs: take last frame of clip A + first frame of clip B from the same scene/camera, render an interpolation, confirm temporally-coherent transition. If it looks weak even on similar keyframes, file a follow-up to expose more pipeline knobs in the UI (cfg-scale, stg-scale, stage1-steps).-- [ ] **Add UI hint under FFLF mode.** "Use keyframes that share scene geometry — same camera, same subject; the model interpolates between them. Random unrelated images produce a visual cut." Prevents the "looks like two stills" complaint that surfaced during testing.+- [ ] **Add UI hint under FFLF mode.** Current advisory note says "Experimental — last frame is advisory" but doesn't guide users on *what makes a good keyframe pair*. Add: "Use keyframes that share scene geometry — same camera, same subject; the model interpolates between them. Random unrelated images produce a visual cut." Prevents the "looks like two stills" complaint that surfaced during testing. (`client/src/pages/VideoGen.jsx` ~line 917)- [ ] **Once dgrauet is the default for everything we care about, deprecate notapalindrome models.** Mark `ltx2_unified`, `ltx23_unified`, `ltx23_distilled_q4` with `deprecated: true` in `server/lib/mediaModels.js` so the model dropdown groups them under a "Legacy" section. Eventually drop them and the `runtime: 'mlx_video'` dispatch entirely (~50 LOC removal in videoGen/local.js).### Other backlog@@ -35,38 +34,37 @@ The dgrauet/ltx-2-mlx runtime ships with FFLF (true keyframe interpolation), aud- [ ] **Voice CoS tool expansion** — `calendar_today` / `calendar_next` (Google Calendar via existing MCP), `meatspace_log_workout` (wraps `meatspaceHealth.js`), `weather_now` (needs API choice — OpenWeather / WeatherKit / NWS), `timer_set` (reuses `agentActionExecutor.js` scheduled actions).- [ ] **Voice agent vision fallback** — `ui_describe_visually` tool: screenshot the current tab (or a named canvas/chart) and send to a vision-capable model so "what's on this chart?" works on non-DOM content (CyberCity, graph views). Depends on a vision provider in `portos-ai-toolkit`.- [ ] **Voice agent — explicit long-term memory routing** — pipeline already routes capture verbs to `brain_capture`. Remaining: on retrieval-shaped voice turns, inject top-N relevant memories into the system prompt via `brain_search` so it's self-improving rather than ambient.-- [ ] **CyberCity v2** — Transform from decorative scene to interactive systems map. See [cybercity-v2.md](./docs/features/cybercity-v2.md). Phase 1 (operational legibility) underway: per-building health glyphs, "needs attention" pane, search overlay, status filter chips, clickable HUD stats, hover preview with quick actions, mobile/touch support.+- [ ] **CyberCity v2 — Phase 2+** — Phase 1 operational legibility shipped (per-building health glyphs, attention pane, search overlay, filter chips, hover quick-actions, mobile). Remaining: deeper drill-down (per-agent spatial trail, system flow lines between buildings, recent-action timeline overlay). See [cybercity-v2.md](./docs/features/cybercity-v2.md).- [ ] **M50 P9 — CoS Automation & Rules** — Automated email classification, rule-based pre-filtering, email-to-task pipeline.- [ ] **M50 P10 — Auto-Send with AI Review Gate** — Per-account/per-recipient trust level + dual-LLM review (drafter + reviewer). Only auto-send when both approve or trust ≥ 0.9. See [Messages Security](./docs/features/messages-security.md).- [ ] **M34 P5-P7 — Digital Twin** — Multi-modal capture (voice/video/image identity sources), advanced testing, personas. Ties to GOALS.md secondary "Multi-Modal Identity Capture".- [ ] **Multi-reference image editing for FLUX.2** — UI on the Image Gen page that accepts 2+ reference images plus an edit prompt (e.g. "put the subject from image A into the scene from image B"). When this lands, swap the model registry's 9B entry to [`black-forest-labs/FLUX.2-klein-9B-kv`](https://huggingface.co/black-forest-labs/FLUX.2-klein-9B-kv) — KV-cache optimization gives up to 2.5× speedup on multi-reference workflows. Work involves: schema for multi-image payload (`referenceImages: [...]`), client multi-uploader, server FormData parsing, and adapting `flux2_macos.py` to call the multi-reference pipeline API. Separately-gated repo on HF — user must request access.+- [ ] **World Builder Phase 2 — external SD-API + per-bucket model overrides.** The shipped batch render only supports local mflux + Codex. Wire the existing external SD-API providers (Together, Replicate, Fal) into the world-builder batch path so high-end renders are practical, and let each bucket pick its own model (e.g. characters → SDXL portrait LoRA, environments → Flux-pro). Single touchpoint: `server/services/worldBuilder.js#compileBatchPrompts` + `worldBuilderCollectionHook.js`. (Surfaced from PR #211 follow-ups.)### Better Audit follow-ups-- [ ] **[HIGH][DRY]** `server/services/socket.js` disconnect handler — `broadcastToSet` / `registerSubscriber` extraction is shipped; the `shellService.unsubscribeSessionList(socket)` call is still missing on socket disconnect (lines 487–498).-- [ ] **[HIGH][CODE]** `server/services/cos.js:3069` — remove `NODE_ENV !== 'test' && VITEST !== 'true'` init guard (test-specific hack in prod).+- [ ] **[HIGH][CODE]** `server/services/cos.js:3113` — remove `NODE_ENV !== 'test' && VITEST !== 'true'` init guard (test-specific hack in prod boot path).- [ ] **[HIGH][TESTS]** Create test files for `server/services/clinvar.js` and `server/services/telegramBridge.js`.- [ ] **[MEDIUM][CLIENT]** 4 components still redefine `formatBytes`/`formatTime`/`formatDuration`/`timeAgo`/`formatDate` locally instead of importing from `client/src/utils/formatters.js`: `pages/VideoTimelineEditor.jsx`, `pages/VideoTimeline.jsx`, `components/settings/MortalLoomTab.jsx`, `components/brain/tabs/ImportTab.jsx`. (Down from 8.)-- [ ] **[MEDIUM][PERF]** `server/services/feeds.js:234-260` — full-sort-then-paginate on every request.-- [ ] **[MEDIUM][CODE]** Magic numbers in `cos.js:166,357`, `lmStudioManager.js:66`; brittle `err.message.includes`/`startsWith` checks in `routes/voice.js:160` and `services/visionTest.js:124`.+- [ ] **[MEDIUM][PERF]** `server/services/feeds.js#getItems` (lines 303–319) — full-sort-then-paginate on every request. Pre-sort once at write time or maintain a per-feed index.+- [ ] **[MEDIUM][CODE]** Magic numbers in `cos.js:166,357`, `lmStudioManager.js:66`; brittle `err.message.startsWith('unknown piper voice:')` in `routes/voice.js:160` and `err.message.includes('not initialized')` in `services/visionTest.js:124`.### Deferred Architecture (human-led planning)-- `server/services/cos.js` (3071 LOC) — split into cosTaskStore / cosTaskGenerator / cosJobScheduler / cosHealthMonitor.-- `server/services/agentLifecycle.js` (1314 LOC) — extract prepareAgentWorkspace / resolveProvider / processCompletion.+- `server/services/cos.js` (3115 LOC) — split into cosTaskStore / cosTaskGenerator / cosJobScheduler / cosHealthMonitor.+- `server/services/agentLifecycle.js` (1435 LOC) — extract prepareAgentWorkspace / resolveProvider / processCompletion.- `server/services/identity.js` (1917 LOC) — separate genomic markers + longevity + goals + todos.-- `server/services/taskSchedule.js` (2233 LOC) — extract prompt management to `taskPromptService.js`.-- `server/services/taskLearning.js` (1845 LOC) — separate metrics aggregation from heuristic routing.+- `server/services/taskSchedule.js` (2369 LOC) — extract prompt management to `taskPromptService.js`.+- `server/services/taskLearning.js` (1939 LOC) — separate metrics aggregation from heuristic routing.- `server/services/autonomousJobs.js` (1567 LOC) — extract job registry / scheduler / execution paths.- `server/services/voice/tools.js` (1284 LOC) — group by domain (UI control / calendar / brain / media) into sibling modules.-- `server/services/git.js` (1215 LOC) — extract command builders + parsers.-- `server/services/socket.js` — split into domain-specific socket modules.+- `server/services/git.js` (1271 LOC) — extract command builders + parsers.- `server/cos-runner/index.js` (1076 LOC) — extract spawn / lifecycle / IPC layers.- `server/services/memory.js` (1049 LOC) — separate retrieval, classification, and persistence.- `server/services/xcodeScripts.js` (1131 LOC) — collapse repeated AppleScript builders.-- `server/routes/apps.js` (1126 LOC) — extract `npm install` orchestration to `appBuilder.js`.-- `client/src/pages/VideoGen.jsx` (1335 LOC) — extract mode-specific control panels (i2v / a2v / extend / FFLF) into siblings.-- `client/src/pages/ImageGen.jsx` (1136 LOC) — extract preset picker + multi-reference uploader.+- `server/routes/apps.js` (1180 LOC) — extract `npm install` orchestration to `appBuilder.js`.+- `client/src/pages/VideoGen.jsx` (1334 LOC) — extract mode-specific control panels (i2v / a2v / extend / FFLF) into siblings.+- `client/src/pages/ImageGen.jsx` (1161 LOC) — extract preset picker + multi-reference uploader.- `client/src/components/goals/GoalDetailPanel.jsx` (1252 LOC) — god component.- `client/src/components/meatspace/tabs/CalendarTab.jsx` (1269 LOC) — extract grid renderer + goal-link panels.- `client/src/components/cos/tabs/ScheduleTab.jsx` (1088 LOC) — extract schedule editor + run history table.@@ -94,3 +92,4 @@ All dependencies audited and justified (2026-04-28). 0 removals. See [docs/DEPS.- **Inline Code Review Annotations** — One-click fix from self-improvement findings.- **Major Dependency Upgrades** — React 19, Zod 4, PM2 6, Vite 8.- **Dynamic Skill Marketplace** — Self-generating skill templates from task patterns.+- **Workflow tab Phase 2** — drag-and-drop ordering of stages, custom user-defined stages, per-app workflow overrides. Builds on the new `/cos/workflow` pipeline.