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
address review (claude): correct the extracted bodies and finish the upgrade path
[._.]/ Adam Eivy3cd9df8f3a11
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.jsindex b90e460568..c8a0eea42f 100644--- a/server/services/taskPromptDefaults.test.js+++ b/server/services/taskPromptDefaults.test.js@@ -9,7 +9,6 @@ import {PREVIOUS_DEFAULT_PROMPTS,} from './taskPromptDefaults.js';import { hashPromptBody, buildPromptIntegritySnapshot } from './taskPromptDefaults/integrityHash.js';-import { DEFAULT_TASK_INTERVALS } from './taskScheduleRegistry.js';import { EPIC_DECOMPOSED_LABEL } from './perpetualWork.js';// The claim prompts build their contributor-label release from this helper, so the// test asserts against the same source rather than re-typing the command text.@@ -291,14 +290,28 @@ describe('taskPromptDefaults integrity snapshot', () => {// The other direction, and the one that actually bites: taskScheduleStore's// auto-upgrade block is gated on `PROMPT_VERSIONS[taskType] && …`, so a- // SCHEDULE prompt with no entry is silently exempt from upgrade forever — a- // body change ships and no install ever receives it. console-errors,- // error-handling and typing were frozen exactly that way. Pipeline stage- // bodies are excluded because they are never persisted (see the- // "unversioned pipeline stage body" cases below).- it('every scheduled default prompt is versioned, so none is silently exempt from auto-upgrade', () => {+ // prompt with no entry is silently exempt from upgrade forever — a body+ // change ships and no install ever receives it. console-errors,+ // error-handling and typing were frozen exactly that way.+ //+ // The exemptions are an explicit ALLOWLIST, not a derived predicate. Keying+ // off "absent from DEFAULT_TASK_INTERVALS" would exempt any future body that+ // merely isn't a schedule key yet — the exact regression this guards — so a+ // new unversioned prompt has to be justified by naming it here.+ const UNPERSISTED_PROMPT_KEYS = [+ // Pipeline stage bodies: getStagePrompt reads them live from this catalog+ // and never persists them, so an edit reaches every install on the next+ // dispatch (their pipeline's SCHEDULE key carries the version instead).+ 'pr-reviewer-security',+ 'pr-reviewer-review',+ 'code-reviewer-review',+ 'code-reviewer-implement',+ 'branch-cleanup',+ ];++ it('every persisted default prompt is versioned, so none is silently exempt from auto-upgrade', () => {for (const key of Object.keys(DEFAULT_TASK_PROMPTS)) {- if (!DEFAULT_TASK_INTERVALS[key]) continue;+ if (UNPERSISTED_PROMPT_KEYS.includes(key)) continue;expect(PROMPT_VERSIONS[key], `PROMPT_VERSIONS['${key}']`).toBeTypeOf('number');}});diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.jsonindex efef421386..643e723f2e 100644--- a/server/services/taskPromptDefaults/integrity.snapshot.json+++ b/server/services/taskPromptDefaults/integrity.snapshot.json@@ -67,8 +67,6 @@"console-errors": 2,"error-handling": 2,"typing": 2,- "jira-sprint-manager": 1,- "jira-status-report": 1,"dependency-updates": 4,"documentation": 6,"ui-bugs": 2,@@ -82,7 +80,9 @@"copy": 1,"stash-cleanup": 2,"repo-sync": 1,- "release-check": 12+ "release-check": 12,+ "jira-sprint-manager": 1,+ "jira-status-report": 1},"REFERENCE_WATCH_AUDITED_VERSION": 3,"PREVIOUS_DEFAULT_PROMPTS": {@@ -188,8 +188,8 @@"af99e76b4881d1a18234eff0d58d49a4"],"security": [- "d0f54c1fbe62d067b1a23ee0a9f3528c",- "b199739b21a8c45ed3778b2339ebf55f"+ "b199739b21a8c45ed3778b2339ebf55f",+ "d0f54c1fbe62d067b1a23ee0a9f3528c"],"code-quality": ["62752723eba7a39aa94e010911923cc8",@@ -204,7 +204,6 @@"4fea5eb3585bdc150980934b289016bc"],"accessibility": [- "6c927b9b70950e9a38fc5944d15cad3b","ce7377d0ac57cbf0526074cfb95e3803","b07cfe1e367411036ef1d4cc4b6e9d2e"],@@ -223,11 +222,9 @@"b375f95ae2274f03d06ba5ceff5705d8"],"ui-bugs": [- "ac85ee1bd35c1475f78b75b198dd6c97","01d2a7e034713195f33071f2c71a3c99"],"mobile-responsive": [- "699b2fe64ee663d5d9e2e70919592dd4","636bdc17fa39ed2f2e27623284c8e04c"],"release-check": [@@ -267,7 +264,7 @@"f9de8b10937919ceb6656fbdb70179c4"],"console-errors": [- "ed7a4fe732c5227d3951df4ed63d1b0c",+ "23b1a2e33cb414f27d4002b51d315e83","3e3f690729ead5e312927ae4bce330c0"],"error-handling": [diff --git a/server/services/taskPromptDefaults/integrityHash.js b/server/services/taskPromptDefaults/integrityHash.jsindex 7a4545362f..ba93d888b5 100644--- a/server/services/taskPromptDefaults/integrityHash.js+++ b/server/services/taskPromptDefaults/integrityHash.js@@ -13,43 +13,33 @@ import { PORTOS_API_URL } from '../../lib/ports.js';const API_URL_PLACEHOLDER = '{{PORTOS_API_URL}}';-// Prompt bodies embed an install origin three different ways:+// Prompt bodies embed the install's API origin two different ways://// 1. Current defaults interpolate PORTOS_API_URL at module load, so the body// text varies with PORTOS_API_URL / PORTOS_HOST / PORT.// 2. Preserved historical defaults (pre-genericization) hardcode-// `http://localhost:5555` — the API origin that WAS the default when they-// shipped.-// 3. Preserved pre-unification self-improvement defaults drove the UI with-// Playwright, so they hardcode the *UI* origin, `http://localhost:5554`.+// `http://localhost:5555` — the origin that WAS the default when they+// shipped. Those bytes are frozen history and never change again, so the+// literal is pinned here rather than derived from PORTS.API.//-// (2) and (3) are frozen history and never change again, so both literals are-// pinned here rather than derived from PORTS. Each collapses to a placeholder so-// a body hashes identically on every install — (1) and (2) share one, since they-// name the same origin, while (3) gets its own so a body carrying the UI origin-// never hashes the same as one carrying the API origin.-//-// Normalizing only (1) made the snapshot reproducible solely on a machine whose-// PORTOS_API_URL happened to equal the legacy origin: anywhere else — a custom-// PORTOS_HOST, or simply a shell with PORT set, as inside a CoS agent — the five-// bodies carrying the literal hashed differently and the integrity test failed-// while nothing had actually drifted (issue #3359).+// Both collapse to the same placeholder so a body hashes identically on every+// install. Normalizing only (1) made the snapshot reproducible solely on a+// machine whose PORTOS_API_URL happened to equal the legacy origin: anywhere+// else — a custom PORTOS_HOST, or simply a shell with PORT set, as inside a CoS+// agent — the five bodies carrying the literal hashed differently and the+// integrity test failed while nothing had actually drifted (issue #3359).const LEGACY_API_ORIGIN = 'http://localhost:5555';-const LEGACY_UI_ORIGIN = 'http://localhost:5554';-const UI_URL_PLACEHOLDER = '{{PORTOS_UI_URL}}';-// Longest first: the origins can overlap — `PORTOS_API_URL=http://localhost`-// (port 80) is a prefix of the legacy literals, and replacing it first would turn+// Longest first: the two origins can overlap — `PORTOS_API_URL=http://localhost`+// (port 80) is a prefix of the legacy literal, and replacing it first would turn// `http://localhost:5555` into `{{PORTOS_API_URL}}:5555`, which the legacy pass// can then no longer match. Replacing the longer candidate first leaves only-// standalone occurrences of the shorter one. The sort is stable, so on a length-// tie (an install whose API origin IS one of the legacy literals) the configured-// apiUrl still wins and current defaults keep hashing as {{PORTOS_API_URL}}.+// standalone occurrences of the shorter one.export const normalizePromptForHash = (body, apiUrl = PORTOS_API_URL) => (- [[apiUrl, API_URL_PLACEHOLDER], [LEGACY_API_ORIGIN, API_URL_PLACEHOLDER], [LEGACY_UI_ORIGIN, UI_URL_PLACEHOLDER]]- .filter(([origin]) => origin)- .sort((a, b) => b[0].length - a[0].length)- .reduce((out, [origin, placeholder]) => out.split(origin).join(placeholder), String(body))+ [apiUrl, LEGACY_API_ORIGIN]+ .filter(Boolean)+ .sort((a, b) => b.length - a.length)+ .reduce((out, origin) => out.split(origin).join(API_URL_PLACEHOLDER), String(body)));export const hashPromptBody = (body, apiUrl = PORTOS_API_URL) => createHash('md5')diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.jsindex 64fdc15f9c..ec5cb326a6 100644--- a/server/services/taskPromptDefaults/previousDefaults.js+++ b/server/services/taskPromptDefaults/previousDefaults.js@@ -32,11 +32,7 @@ Scope: this task operates against the managed app's repository, NOT PortOS. All{slashdoReplan}`,],'feature-ideas': [- // Pre-genericization default, from before the self-improvement and- // app-improvement schedules were unified. It hardcodes "PortOS" and points- // at `data/COS-GOALS.md`, a file that unification folded into the root- // GOALS.md — so an install still pinned here sends every run looking for a- // file that no longer exists. Preserved so that install auto-upgrades.+ // Outgoing pre-unification default, self-improvement schedule.`[Self-Improvement] Feature Review and DevelopmentEvaluate existing features and consider new ones to make PortOS more useful:@@ -522,8 +518,8 @@ When PLAN.md is missing, empty, or fully completed, brainstorm and implement a n- [x] [<slug-of-feature>] <description of the feature you implemented>\`\`\`8. Commit with a clear description of the feature and rationale`,- // v10 default prompt (before Phase 1 + Phase 4 consult PRD.md as the- // primary product source, with GOALS.md as the fallback)+ // v10 default prompt (before Phase 4 consults PRD.md as the primary+ // product source, with GOALS.md as the fallback)`[Improvement: {appName}] Implement Next Planned FeatureYour goal is to implement the next planned item from PLAN.md, or brainstorm a new feature if no plan exists.@@ -9215,33 +9211,7 @@ NEVER leave the issue OPEN with \`in-progress\` still on it — that strands it// brief Feb-2026 `${PORTOS_UI_URL}`-interpolated variants are intentionally// omitted: they were never released (≈51 min on main) and resolve per-install.'security': [- // prior default — app name hardcoded as "PortOS"- `[Self-Improvement] Security Audit--Analyze PortOS codebase for security vulnerabilities:--1. Review server/routes/*.js for:- - Command injection in exec/spawn calls- - Path traversal in file operations- - Missing input validation- - XSS in rendered content--2. Review server/services/*.js for:- - Unsafe eval() or Function()- - Hardcoded credentials- - SQL/NoSQL injection--3. Review client/src/ for:- - XSS vulnerabilities in React- - Sensitive data in localStorage- - CSRF protection--4. Check server/lib/commandAllowlist.js is comprehensive--Fix any vulnerabilities and commit with security advisory notes.`,- // v1 genericized default, shipped under the retired `[App Improvement: …]`- // header. The header rename is handled by normalizeLegacyPromptHeader- // (shippedPrompts.js); this body is preserved because step 4 changed too.+ // Outgoing pre-unification default, app-improvement schedule.`[App Improvement: {appName}] Security AuditAnalyze the {appName} codebase for security vulnerabilities:@@ -9271,6 +9241,30 @@ Repository: {repoPath}- Access controlFix any vulnerabilities found and commit with security advisory notes.`,+ // prior default — app name hardcoded as "PortOS"+ `[Self-Improvement] Security Audit++Analyze PortOS codebase for security vulnerabilities:++1. Review server/routes/*.js for:+ - Command injection in exec/spawn calls+ - Path traversal in file operations+ - Missing input validation+ - XSS in rendered content++2. Review server/services/*.js for:+ - Unsafe eval() or Function()+ - Hardcoded credentials+ - SQL/NoSQL injection++3. Review client/src/ for:+ - XSS vulnerabilities in React+ - Sensitive data in localStorage+ - CSRF protection++4. Check server/lib/commandAllowlist.js is comprehensive++Fix any vulnerabilities and commit with security advisory notes.`,],'code-quality': [// Outgoing pre-unification default, app-improvement schedule.@@ -9410,23 +9404,6 @@ Analyze PortOS for performance issues:Optimize and commit improvements.`,],'accessibility': [- // Outgoing pre-unification default, self-improvement schedule.- `[Self-Improvement] Accessibility Audit--Use Playwright MCP to audit PortOS accessibility:--1. Navigate to http://localhost:5554/-2. Use browser_snapshot to get accessibility tree-3. Check each main route for:- - Missing ARIA labels- - Missing alt text on images- - Insufficient color contrast- - Keyboard navigation issues- - Focus indicators--4. Fix accessibility issues in React components-5. Add appropriate aria-* attributes-6. Test and commit changes`,// Outgoing pre-unification default, app-improvement schedule.`[App Improvement: {appName}] Accessibility Audit@@ -9836,19 +9813,6 @@ Repository: {repoPath}Commit documentation improvements.`,],'ui-bugs': [- // Outgoing pre-unification default, self-improvement schedule.- `[Self-Improvement] UI Bug Analysis--Use Playwright MCP (browser_navigate, browser_snapshot, browser_console_messages) to analyze PortOS UI:--1. Navigate to http://localhost:5554/-2. Check each main route: /, /apps, /cos, /cos/tasks, /cos/agents, /devtools, /devtools/history, /providers, /usage-3. For each route:- - Take a browser_snapshot to see the page structure- - Check browser_console_messages for JavaScript errors- - Look for broken UI elements, missing data, failed requests-4. Fix any bugs found in the React components or API routes-5. Run tests and commit changes`,// prior default (pre-genericization / intermediate)`[Self-Improvement] UI Bug Analysis@@ -9864,23 +9828,6 @@ Use Playwright MCP (browser_navigate, browser_snapshot, browser_console_messages5. Run tests and commit changes`,],'mobile-responsive': [- // Outgoing pre-unification default, self-improvement schedule.- `[Self-Improvement] Mobile Responsiveness Analysis--Use Playwright MCP to test PortOS at different viewport sizes:--1. browser_resize to mobile (375x812), then navigate to http://localhost:5554/-2. Take browser_snapshot and analyze for:- - Text overflow or truncation- - Buttons too small to tap (< 44px)- - Horizontal scrolling issues- - Elements overlapping- - Navigation usability-3. Repeat at tablet (768x1024) and desktop (1440x900)-4. Fix Tailwind CSS responsive classes (sm:, md:, lg:) as needed-5. Test fixes and commit changes--Focus on these routes: /cos, /cos/tasks, /devtools, /providers`,// prior default (pre-genericization / intermediate)`[Self-Improvement] Mobile Responsiveness Analysis@@ -11678,7 +11625,7 @@ Summarize: how many stashes were reviewed, how many were dropped (grouped by reaUse Playwright MCP to find and fix console errors:-1. Navigate to http://localhost:5554/+1. Navigate to http://localhost:5555/2. Call browser_console_messages with level: "error"3. Visit each route and capture errors:- /, /apps, /cos, /cos/tasks, /cos/agentsdiff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.jsindex 55acb6cd6a..4ca55ca957 100644--- a/server/services/taskPromptDefaults/versions.js+++ b/server/services/taskPromptDefaults/versions.js@@ -57,12 +57,12 @@ export const PROMPT_VERSIONS = {// auto-upgrade forever: taskScheduleStore's upgrade block is gated on// `PROMPT_VERSIONS[taskType] && …`, so a body change ships and no install// ever receives it. console-errors, error-handling and typing were frozen- // that way for months. Every schedule key therefore carries an entry, v1+ // that way for months. Every PERSISTED prompt therefore carries an entry, v1// meaning "shipped once, never revised" — taskPromptDefaults.test.js enforces- // the parity so the next new scheduled prompt cannot repeat it. (Pipeline- // STAGE bodies stay unversioned on purpose: they are read live from the- // catalog and never persisted, so an edit reaches every install on the next- // dispatch.)+ // the parity against an explicit allowlist, so the next new prompt has to+ // justify itself to stay unversioned. (Pipeline STAGE bodies are on that+ // allowlist: they are read live from the catalog and never persisted, so an+ // edit reaches every install on the next dispatch.)'jira-sprint-manager': 1,'jira-status-report': 1,};diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex 60aa981664..3971afb2a0 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -448,16 +448,27 @@ describe('taskSchedule', () => {// One case per shape the freeze took: header-only drift, a body that also// changed, a type whose ONLY revision was the split (so it had no// PROMPT_VERSIONS entry at all), and the older self-improvement generation.- it.each([+ //+ // Each runs under BOTH version stamps a frozen install can carry. The+ // legacy migration wrote `promptVersion = PROMPT_VERSIONS[taskType]`+ // alongside the customized flag, so an install flagged after its type was+ // versioned holds the CURRENT version with a RETIRED body — and clearing+ // the flag alone leaves `storedVersion < current` false, so the upgrade+ // never fires. Testing only the version-1 stamp misses that entirely.+ const ERAS = [['console-errors', '[App Improvement: '],['security', '[App Improvement: '],['typing', '[App Improvement: '],['console-errors', '[Self-Improvement] '],['feature-ideas', '[Self-Improvement] '],- ])('self-heals and upgrades a stored %s prompt from the %s generation', async (taskType, header) => {+ ]+ it.each(ERAS.flatMap(([taskType, header]) => [+ [taskType, header, 'pre-versioning', 1],+ [taskType, header, 'current-version', PROMPT_VERSIONS[taskType]],+ ]))('self-heals and upgrades a stored %s prompt from the %s generation (%s stamp)', async (taskType, header, _label, storedVersion) => {const prompt = fromEra(taskType, header)expect(prompt, `no ${header} body registered for ${taskType}`).toBeDefined()- const task = await loadOne(taskType, prompt, 1)+ const task = await loadOne(taskType, prompt, storedVersion)expect(task.promptCustomized).toBe(false)expect(task.prompt).toBe(DEFAULT_TASK_PROMPTS[taskType])expect(task.promptVersion).toBe(PROMPT_VERSIONS[taskType])diff --git a/server/services/taskScheduleStore.js b/server/services/taskScheduleStore.jsindex 4ac02b5c4a..a626be131c 100644--- a/server/services/taskScheduleStore.js+++ b/server/services/taskScheduleStore.js@@ -227,12 +227,23 @@ async function readSchedule() {// that nonetheless matches a shipped default was never user-edited — it// was flagged by an earlier legacy migration that ran before this task// carried a PREVIOUS_DEFAULT_PROMPTS entry (the basic self-improvement- // prompts that hardcoded the app name as "PortOS", and the whole- // `[App Improvement: …]`-header generation the schedule unification- // renamed without preserving). Clear the flag so the auto-upgrade below- // can replace the stale default.+ // prompts that hardcoded the app name as "PortOS", and both+ // pre-unification generations — `[Self-Improvement] …` and+ // `[App Improvement: …]` — that the schedule unification replaced without+ // preserving). Clear the flag so the auto-upgrade below can replace the+ // stale default.+ //+ // Clearing the flag is NOT enough on its own. That legacy migration+ // stamped `promptVersion = PROMPT_VERSIONS[taskType]` alongside the flag,+ // so an install flagged after a type was versioned carries the CURRENT+ // version while holding a RETIRED body — the upgrade below then sees+ // `storedVersion < current` as false and leaves the stale prompt in place+ // forever, now un-flagged so nothing else notices. Reset the version to 1+ // whenever the body is a prior default rather than the current one, which+ // is the same stamp the version-inference branch above applies.if (config.promptCustomized && promptMatchesShippedDefault(config.prompt, taskType)) {config.promptCustomized = false;+ if (config.prompt !== DEFAULT_TASK_PROMPTS[taskType]) config.promptVersion = 1;needsSave = true;}