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
unfreeze scheduled prompts stuck on the retired [App Improvement:] header
[._.]/ Adam Eivy83945be30aab
diff --git a/server/services/taskPromptDefaults.js b/server/services/taskPromptDefaults.jsindex e5b4ea3644..7c60ea5ab9 100644--- a/server/services/taskPromptDefaults.js+++ b/server/services/taskPromptDefaults.js@@ -10,8 +10,8 @@** The content lives in ./taskPromptDefaults/ — prompts.js (current defaults),* versions.js (PROMPT_VERSIONS + audit anchor), previousDefaults.js (prior- * shipped defaults) — and this barrel re-exports it so existing imports keep- * working. taskPromptDefaults.test.js pins the exported values against a hash+ * shipped defaults), shippedPrompts.js (the shared "is this a shipped default?"+ * check) — and this barrel re-exports it so existing imports keep working. taskPromptDefaults.test.js pins the exported values against a hash* snapshot so a split/refactor can't silently alter the upgrade contract.** Distribution-model machinery (see AGENTS.md "Distribution model"):@@ -25,3 +25,4 @@export { DEFAULT_TASK_PROMPTS } from './taskPromptDefaults/prompts.js';export { PROMPT_VERSIONS, REFERENCE_WATCH_AUDITED_VERSION } from './taskPromptDefaults/versions.js';export { PREVIOUS_DEFAULT_PROMPTS } from './taskPromptDefaults/previousDefaults.js';+export { promptMatchesShippedDefault, normalizeLegacyPromptHeader } from './taskPromptDefaults/shippedPrompts.js';diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.jsindex 64d35fb172..2296876c76 100644--- a/server/services/taskPromptDefaults.test.js+++ b/server/services/taskPromptDefaults.test.js@@ -132,22 +132,24 @@ describe('taskPromptDefaults integrity snapshot', () => {expect(actual).toEqual(SNAPSHOT.PREVIOUS_DEFAULT_PROMPTS);});- // feature-ideas v10: rejected-ideas ledger consultation (issue #2621).- // Pins the version-bump pairing — the prompt change ships WITH its version- // bump and the outgoing v9 default preserved for cross-install auto-upgrade.- it('feature-ideas v10 consults REJECTED.md and closed-unmerged PRs, preserving the v9 default', () => {+ // feature-ideas v11: product-source precedence (PRD.md → GOALS.md → docs),+ // on top of v10's rejected-ideas ledger consultation (issue #2621). Pins the+ // version-bump pairing — the prompt change ships WITH its version bump and+ // the outgoing v10 default preserved for cross-install auto-upgrade.+ it('feature-ideas v11 reads PRD.md before GOALS.md, preserving the v10 default', () => {const current = DEFAULT_TASK_PROMPTS['feature-ideas'];expect(current).toContain('REJECTED.md');expect(current).toContain('is:unmerged');- expect(PROMPT_VERSIONS['feature-ideas']).toBe(10);+ expect(current).toContain('`PRD.md`');+ expect(PROMPT_VERSIONS['feature-ideas']).toBe(11);const previous = PREVIOUS_DEFAULT_PROMPTS['feature-ideas'];- const v9 = previous[previous.length - 1];- // The outgoing v9 default lacked the rejected-ideas consultation and is- // preserved verbatim so installs holding it are recognized and upgraded.- expect(v9).not.toContain('REJECTED.md');- expect(v9).toContain('.changelog/');- expect(v9).not.toBe(current);+ const v10 = previous[previous.length - 1];+ // The outgoing v10 default read GOALS.md only and is preserved verbatim so+ // installs holding it are recognized and upgraded.+ expect(v10).toContain('REJECTED.md');+ expect(v10).not.toContain('PRD.md');+ expect(v10).not.toBe(current);});// plan-feature v5: omitted optional preloads fall back to direct inventory,diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.jsonindex 94a8744fb0..8ab11b5f17 100644--- a/server/services/taskPromptDefaults/integrity.snapshot.json+++ b/server/services/taskPromptDefaults/integrity.snapshot.json@@ -17,7 +17,7 @@"react-lifecycle": "14b3816d1bcc10f0d7d6357e55cc5e69","observability": "fdb4d77df5891cfb653a5da2553ecf8a","copy": "6a0959e898d37fb4d4d7445dfc8008c9",- "feature-ideas": "d3282f16da29efe2d53595b3b34778bc",+ "feature-ideas": "804f62f1dadadbfa8a0bcd4aff16b2e8","plan-feature": "87f71a894757f89354da4e2119e07118","plan-task": "b85fe92999aa4ee4a8910320457c4242","claim-issue": "9bf278ab141120625cd6faf854622f91",@@ -45,7 +45,7 @@},"PROMPT_VERSIONS": {"do-replan": 2,- "feature-ideas": 10,+ "feature-ideas": 11,"plan-task": 18,"claim-issue": 22,"claim-issue-gitlab": 20,@@ -64,6 +64,9 @@"test-coverage": 2,"performance": 2,"accessibility": 2,+ "console-errors": 2,+ "error-handling": 2,+ "typing": 2,"dependency-updates": 4,"documentation": 6,"ui-bugs": 2,@@ -85,6 +88,7 @@"59a57f1bb445138c30ab4fa23630c6f8"],"feature-ideas": [+ "abc098e3acf4eb6b9d1211680ec0440f","d67a9028aeb8bb8348453951f878501b","c6a399399245872401666d5c67c716cc","a4a4b4d7191ae58b82140295c3df5926",@@ -92,7 +96,8 @@"5a0350fa6db8ac040fb638fdd4a31700","d076e19a6848f6452f4d1078b096ba4b","73cdc70f8d14fc909668054bbcee1259",- "0741418bd275b8953131155f8bc89460"+ "0741418bd275b8953131155f8bc89460",+ "d3282f16da29efe2d53595b3b34778bc"],"plan-task": ["4df36bed4974ff41f369c86828e7f94f",@@ -181,7 +186,8 @@"af99e76b4881d1a18234eff0d58d49a4"],"security": [- "d0f54c1fbe62d067b1a23ee0a9f3528c"+ "d0f54c1fbe62d067b1a23ee0a9f3528c",+ "b199739b21a8c45ed3778b2339ebf55f"],"code-quality": ["b1cce8f89218844746746ceb576553c1"diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.jsindex ed4a9470f5..e9909d6602 100644--- a/server/services/taskPromptDefaults/previousDefaults.js+++ b/server/services/taskPromptDefaults/previousDefaults.js@@ -32,6 +32,41 @@ 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.+ `[Self-Improvement] Feature Review and Development++Evaluate existing features and consider new ones to make PortOS more useful:++1. Read data/COS-GOALS.md for context on user goals+2. Review recent completed tasks and user feedback to understand patterns+3. Assess current features:+ - Are existing features working well toward our goals?+ - Are there features that could be improved or refined?+ - Are there features that are underperforming or causing friction?++4. Choose ONE action to take (in order of preference):+ a) IMPROVE an existing feature that isn't meeting its potential+ - Identify what's not working and why+ - Make targeted improvements to increase effectiveness+ b) ADD a new high-impact feature+ - Something that saves user time, improves the developer experience, or makes CoS more helpful+ c) ARCHIVE a feature that is not helping our goals+ - This requires a high bar: document clear evidence of why it's not useful+ - Check usage patterns, goal alignment, and whether the feature creates noise+ - Move the feature config to disabled with a reason, don't delete code++5. Implement it:+ - Write clean, tested code+ - Follow existing patterns+ - Update relevant documentation++6. Commit with a clear description of the change and rationale++Think critically about what we have before adding more.`,// v1 default prompt`[Improvement: {appName}] Feature Review and Development@@ -486,7 +521,81 @@ 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`+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)+ `[Improvement: {appName}] Implement Next Planned Feature++Your goal is to implement the next planned item from PLAN.md, or brainstorm a new feature if no plan exists.++Repository: {repoPath}+{planConstraint}+## Phase 1 — Find the Next Task++1. Read PLAN.md from {repoPath}+2. Skim recent \`.changelog/\` entries and \`git log\` (last 50 commits) to understand what has already shipped — do NOT re-implement completed features+3. If the **Item Constraint** block above named a specific \`[plan-id]\`, find the matching \`- [ ]\` line and use that — do NOT pick a different one, do NOT brainstorm. If the line is missing, has been checked, or carries \`<!-- NEEDS_INPUT -->\`, exit cleanly without commits or PR.+4. Otherwise, if PLAN.md does not exist, is empty, or has no unchecked items (\`- [ ]\`), go to **Phase 4 — Brainstorm**.+5. Otherwise, find the first unchecked item (\`- [ ]\`) that does NOT have a \`<!-- NEEDS_INPUT -->\` annotation.+6. If all unchecked items have \`<!-- NEEDS_INPUT -->\`, go to **Phase 4 — Brainstorm**.++## Phase 2 — Evaluate Feasibility++7. Read relevant source files to understand the scope of the item+8. 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)++9. Implement the feature:+ - Write clean, tested code following existing patterns+ - Run tests to ensure nothing is broken+10. **Review your changed code for reuse, quality, and efficiency** (DRY, dead code, naming, simpler equivalents, missed edge cases) and fix any findings. Claude Code can run \`/simplify\` for this pass; on other CLIs, do the equivalent diff review by hand.+11. Check the PLAN.md item: change \`- [ ]\` to \`- [x]\`. **Preserve the \`[plan-id]\` slug verbatim** — only the box character flips, never the ID. Reference the slug in the commit message (e.g. \`feat([plan-id]): …\`).+12. Commit with a clear description referencing the PLAN.md item++## Phase 3b — Request Clarification (if not feasible)++9. 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, including its [plan-id]>++ ## Questions+ - <question 1>+ - <question 2>+ \`\`\`+10. **Move the unchecked item to the bottom of PLAN.md and annotate it with \` <!-- NEEDS_INPUT -->\`** — remove the line from its current position and append it at the end of the file with the annotation, **preserving its \`[plan-id]\` slug**. This keeps the queue moving so the next \`feature-ideas\` run picks up a different actionable item instead of repeatedly tripping on this one.+11. Commit both changes (the new \`.plan-questions.md\` file and the PLAN.md move) with message \`chore: flag PLAN.md item needing user input\`. Then proceed to the **Completion** section below so the clarification PR is opened for the user to review — do NOT leave the worktree orphaned.++## 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. Skim recent \`.changelog/\` entries and the last 50 \`git log\` entries to avoid re-implementing completed features+3. Read REJECTED.md from {repoPath} (if it exists) to understand previously rejected ideas — do NOT re-propose an idea matching a rejected entry+4. Check the repo's recently closed-unmerged PRs (\`gh pr list --state closed --search "is:unmerged" --limit 20\`, or the forge's equivalent) — a brainstormed feature whose PR the user closed WITHOUT merging was rejected; treat those ideas as rejected too+5. Review the codebase structure, recent git log, and any README or docs to understand the app+6. Identify ONE small, high-impact feature that:+ - Aligns with GOALS.md priorities (if available)+ - Is NOT already shipped per recent \`.changelog/\` entries or \`git log\` (avoid re-implementing shipped features)+ - Does NOT match a REJECTED.md entry or a closed-unmerged automation PR (rejected ideas stay rejected)+ - Saves user time, improves UX, or makes the app more useful+ - Is self-contained and completable in one session+ - Does NOT duplicate existing functionality+7. Implement the feature:+ - Write clean, tested code following existing patterns+ - Run tests to ensure nothing is broken+8. **Review your changed code for reuse, quality, and efficiency** (DRY, dead code, naming, simpler equivalents, missed edge cases) and fix any findings. Claude Code can run \`/simplify\` for this pass; on other CLIs, do the equivalent diff review by hand.+9. Add the feature as a checked item in PLAN.md (create the file if needed) **with a slug ID** derived from the feature title (lowercase kebab-case, ≤50 chars, unique against every existing \`[slug]\` in PLAN.md):+ \`\`\`+ - [x] [<slug-of-feature>] <description of the feature you implemented>+ \`\`\`+10. Commit with a clear description of the feature and rationale`,],'plan-task': [// v14 default (pre-local-reviewer invocation and verified immediate merge)@@ -9130,6 +9239,38 @@ Analyze PortOS codebase for security vulnerabilities:4. Check server/lib/commandAllowlist.js is comprehensiveFix 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.+ `[App Improvement: {appName}] Security Audit++Analyze the {appName} codebase for security vulnerabilities:++Repository: {repoPath}++1. Review routes/controllers for:+ - Command injection in exec/spawn calls+ - Path traversal in file operations+ - Missing input validation+ - XSS vulnerabilities+ - SQL/NoSQL injection++2. Review services for:+ - Unsafe eval() or Function()+ - Hardcoded credentials+ - Insecure dependencies++3. Review client code for:+ - XSS vulnerabilities+ - Sensitive data in localStorage+ - CSRF protection++4. Check authentication and authorization:+ - Secure password handling+ - Token management+ - Access control++Fix any vulnerabilities found and commit with security advisory notes.`,],'code-quality': [// prior default (pre-genericization / intermediate)diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.jsindex 24b718aa9d..6379f3bc27 100644--- a/server/services/taskPromptDefaults/prompts.js+++ b/server/services/taskPromptDefaults/prompts.js@@ -688,14 +688,27 @@ Repository: {repoPath}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.+1. **Establish the product direction from the repository's own documents**, in+ this order of precedence. Make a best effort rather than assuming a missing+ document means the app has no direction:+ - Read \`PRD.md\` from the root of {repoPath} if it exists. Treat its+ requirements, acceptance criteria, success metrics, constraints, and+ non-goals as the primary statement of what the app should do.+ - Read \`GOALS.md\` from the root of {repoPath} if it exists. Use it for+ strategic context alongside the PRD, or as the primary statement of+ desired direction when there is no PRD.+ - If neither exists, fall back to the root \`README.md\`, \`docs/README.md\`,+ relevant guides, architecture notes, and ADRs. Extract stated users,+ problems, workflows, constraints, and success signals rather than+ inventing a product direction.+ - If PRD.md and GOALS.md conflict, follow the PRD's concrete requirements+ and success criteria, and name the tension in your commit message.2. Skim recent \`.changelog/\` entries and the last 50 \`git log\` entries to avoid re-implementing completed features3. Read REJECTED.md from {repoPath} (if it exists) to understand previously rejected ideas — do NOT re-propose an idea matching a rejected entry4. Check the repo's recently closed-unmerged PRs (\`gh pr list --state closed --search "is:unmerged" --limit 20\`, or the forge's equivalent) — a brainstormed feature whose PR the user closed WITHOUT merging was rejected; treat those ideas as rejected too5. Review the codebase structure, recent git log, and any README or docs to understand the app6. Identify ONE small, high-impact feature that:- - Aligns with GOALS.md priorities (if available)+ - Aligns with PRD.md requirements and success criteria when available; otherwise with GOALS.md or the documentation gathered in step 1- Is NOT already shipped per recent \`.changelog/\` entries or \`git log\` (avoid re-implementing shipped features)- Does NOT match a REJECTED.md entry or a closed-unmerged automation PR (rejected ideas stay rejected)- Saves user time, improves UX, or makes the app more usefuldiff --git a/server/services/taskPromptDefaults/shippedPrompts.js b/server/services/taskPromptDefaults/shippedPrompts.jsnew file mode 100644index 0000000000..6566ef5833--- /dev/null+++ b/server/services/taskPromptDefaults/shippedPrompts.js@@ -0,0 +1,48 @@+/**+ * Recognizing a stored prompt as a shipped default.+ *+ * Shared by taskScheduleStore.js (legacy-version inference + the+ * promptCustomized self-heal) and taskPromptService.js (claim-flow default+ * resolution), which previously carried byte-identical copies of this check.+ * A genuine user edit never matches a shipped default, so a match means the+ * stored prompt is safe to auto-upgrade.+ *+ * See ../taskPromptDefaults.js and AGENTS.md "Distribution model".+ */+import { DEFAULT_TASK_PROMPTS } from './prompts.js';+import { PREVIOUS_DEFAULT_PROMPTS } from './previousDefaults.js';++// The basic improvement prompts shipped under an `[App Improvement: {appName}]`+// header until the self-improvement / app-improvement schedules were unified,+// which renamed it to `[Improvement: {appName}]` without preserving the+// outgoing bodies in PREVIOUS_DEFAULT_PROMPTS. Installs carrying that+// generation therefore stopped matching any shipped default, were flagged+// `promptCustomized` by the legacy migration, and have been frozen out of every+// prompt upgrade since. For most task types the rename changed the header line+// and nothing else, so normalize it on both sides instead of re-registering a+// near-duplicate body per task type. (Bodies that changed further in the same+// era — `security`, `feature-ideas` — still carry their own entry.)+const LEGACY_HEADER = '[App Improvement: ';+const CURRENT_HEADER = '[Improvement: ';++export const normalizeLegacyPromptHeader = (prompt) => (+ typeof prompt === 'string' && prompt.startsWith(LEGACY_HEADER)+ ? CURRENT_HEADER + prompt.slice(LEGACY_HEADER.length)+ : prompt+);++/**+ * True when a stored prompt matches a shipped default for this task — the+ * current default or any prior one in PREVIOUS_DEFAULT_PROMPTS — ignoring the+ * retired `[App Improvement: …]` header spelling.+ */+export function promptMatchesShippedDefault(prompt, taskType) {+ if (!prompt || !DEFAULT_TASK_PROMPTS[taskType]) return false;+ const normalized = normalizeLegacyPromptHeader(prompt);+ return (+ normalized === DEFAULT_TASK_PROMPTS[taskType] ||+ (PREVIOUS_DEFAULT_PROMPTS[taskType] || []).some(+ (body) => normalizeLegacyPromptHeader(body) === normalized+ )+ );+}diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.jsindex 83bf63df59..a1fc676bef 100644--- a/server/services/taskPromptDefaults/versions.js+++ b/server/services/taskPromptDefaults/versions.js@@ -10,7 +10,7 @@ export const PROMPT_VERSIONS = {// Current claim-flow bumps retire the Copilot fallback, drive local reviewers// fail closed, verify the remote merge state, and clean up without force-delete.'do-replan': 2, // v2: scheduled issue-quality gate rejects speculative/future-only work and keeps valid current refactors claimable- 'feature-ideas': 10, // v10: Phase 4 (Brainstorm) consults the repo's REJECTED.md and recently closed-unmerged PRs before proposing, so ideas the user already declined aren't re-proposed (mirrors idle-review's REJECTED.md contract). v9: drop DONE.md reads — use `.changelog/` + `git log` (last 50) as the completed-work signal+ 'feature-ideas': 11, // v11: Phase 4 (Brainstorm) establishes product direction from the repo's own documents in precedence order — root `PRD.md` first, then `GOALS.md`, then README/docs — and the candidate test cites PRD requirements when one exists. v9's "read GOALS.md, else focus on general improvements" ignored a PRD entirely, so a repo whose product intent lives in PRD.md (PortOS included) had its most specific source unread. Mirrors plan-feature v2. v10: Phase 4 (Brainstorm) consults the repo's REJECTED.md and recently closed-unmerged PRs before proposing, so ideas the user already declined aren't re-proposed (mirrors idle-review's REJECTED.md contract). v9: drop DONE.md reads — use `.changelog/` + `git log` (last 50) as the completed-work signal'plan-task': 18, // v18: scheduled plan-task no longer instructs a code-review loop; v17: the implement + changelog steps name `AGENTS.md` (or `CLAUDE.md`) as the repo-conventions file (#4852 made AGENTS.md canonical; the dual naming keeps a managed app that still carries only the old name discoverable). v16: every reviewer that can read the working tree runs BEFORE the PR is opened — Phase 6 splits the configured list into LOCAL reviewers (every non-`@<login>` token, reviewed against `git diff origin/main...HEAD`) and PR-SIDE reviewers (`@<login>` plus any auto-requested review bot), opens the PR only once the branch is review-clean, and then waits on those PR-side reviewers plus required CI. Previously the PR was opened first and every reviewer ran against its diff, so each round of findings landed as follow-up commits on an already-public PR. v14: claim worktree creation passes `--no-track`, so a branch based on `origin/main` cannot inherit `main` as its upstream and make a config-derived push write directly to the default branch; the later `git push -u` sets the intended branch upstream. v13: Phase 5's changelog step reads the repo's documented convention FIRST (per-branch fragment directory + helper script, as PortOS now uses) and only falls back to detect-and-append when none is documented; the Phase 6 review-stuck note no longer names `.changelog/NEXT.md` as the file it wrote. v12: the reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — the bare `antigravity` slug is a command that exists nowhere, and a review-loop agent that probed for it concluded no reviewer was available and merged on its own self-review. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v11: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree. v10: Phase 3 "decide, don't defer" — an *ambiguous* PLAN.md item no longer jumps to the Phase 3b clarification PR; the agent picks the most reasonable reading, notes it, and implements. Phase 3b is reserved for destructive/irreversible or genuinely-human-gated items. Mirrors claim-issue v7 + CLAUDE.md. v9: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v8: Phase-6 merge fallback prefers --merge over --squash (after --auto), matching the /do:pr + review-loop default and PortOS's merge-only policy'claim-issue': 22, // v22: Phase 2 releases `good first issue` / `help wanted` (one best-effort `--remove-label` per label, since a combined edit fails the whole call when either label is absent) alongside the assignee + `in-progress` markers, and does not restore them when the claim is later released. v21: an epic is no longer a dead end — Phase 1 treats an UNdecomposed epic as eligible (last-resort, after every atomic issue) and routes it to the new Phase 1b, which reuses an existing child split or files one (2–8 independently shippable slices, each `Part of #<epic>`), rewrites the epic body with a `## Decomposed into` checklist, stamps the `decomposed` label, and then claims the first slice. Phase 3's too-large branch decomposes instead of parking to `needs-input`. Before this, a queue holding only epics ended every run with nothing done. `decomposed` is the convergence marker the perpetualWork detector reads (isActionableIssue). v20: canonicalize GitHub's ssh.github.com SSH-over-443 alias before host-aware identity probes. v19: host-aware GitHub identity probes use the repository origin, and probe failures stay transient instead of parking an assigned-only queue. v18: explicit issue-page claims ignore existing assignees; auto-pick resolves the authenticated login so self-assigned issues remain retryable; open continuation handoffs clear in-progress and all assignees. v17: mirrors plan-task v17 — Phase 4 and Phase 5 name `AGENTS.md` (or `CLAUDE.md`) as the repo-conventions file (#4852). v16: Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder (resolveIssueExcludeLabelsBlock, cosTaskGenerator.js) — the fixed NON_ACTIONABLE_ISSUE_LABELS set plus any app-configured `taskMetadata.issueExcludeLabels` extras (e.g. `good first issue`), so the live claim agent honors the same per-app exclusions the perpetual-drain detector applies, not just the hardcoded set. The pinned-target constraint (`/do:next <num>` / the work-item picker) also re-checks that resolved list, not just the fixed 3, so a target that gained an excluded label after the picker snapshot still isn't force-claimed. Phase 1's candidate fetch widened to `--limit 500` (was 100), matching perpetualWork.js's detector — the label filter runs on the fetched page, so a small cap risked missing eligible work further down a busy queue. v15: Phase 5 is now the pre-PR local review (LOCAL reviewers = every non-`@<login>` token, run against the branch diff; an unsatisfied one blocks PR creation entirely) and Phase 6 opens the PR, satisfies the PR-SIDE reviewers (`@<login>` plus any auto-requested review bot) and required CI, then merges. v13: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v12: claim worktree creation passes `--no-track`, so a branch based on `origin/main` cannot inherit `main` as its upstream and make a config-derived push write directly to the default branch; the later `git push -u` sets the intended branch upstream. v11: EVERY Phase-3 release now converges — the "already fixed / superseded" case CLOSES the issue (with a comment naming what delivered it) and the "stale reference" case tags `needs-input`, instead of both releasing the issue open and unlabeled. `isActionableIssue` (perpetualWork.js) can only see labels/assignees/epic/in-flight, so a body-or-comment-driven release left the issue looking actionable and the perpetual drain re-spawned a no-op agent on it every tick. v10: Phase 5's changelog step defers to the convention the repo documents (per-branch fragment directory + helper script when present) instead of prescribing an append to `.changelog/NEXT.md`. v9: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v8: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree. v7: Phase 3 no longer releases/parks an *ambiguous* issue to `needs-input` — the agent decides (picks the most reasonable reading, records it in an issue comment, ships) rather than punting the choice back to a human; `needs-input` is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. Mirrors the "Decide, don't defer" policy in CLAUDE.md. v6: Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix — mirrors the perpetualWork detector so a `[Epic]`-titled issue with no `epic` label stops re-spawning a claim agent that always skips it (perpetual drain now converges/parks). v5: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v4: Phase 5 chooses the issue trailer deliberately (Closes for a full ship, Refs + a `## Remaining` section for a partial one) and Phase 7 reconciles the issue with the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the `in-progress` claim — so a partial ship is never left OPEN + `in-progress` (a zombie the claim queue skips forever). v3: Phase 3 tags an ambiguous/too-large issue `needs-input` (not just a comment) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge instead of re-picking the same un-actionable issue. v2: stop treating the bare `plan` label as a skip — `plan` is the claimable-queue label (do-replan --issues labels every migrated backlog item `plan`), so v1's exclusion emptied the whole actionable queue; now skip only true epics (`epic` label or "(epic)" title)'claim-issue-gitlab': 20, // v20: mirrors claim-issue v22 — Phase 2 releases `good first issue` / `help wanted` (one best-effort `--unlabel` per label) alongside the assignee + `in-progress` markers. v19: mirrors claim-issue v21 — Phase 1b decomposes an undecomposed epic into per-slice issues (`Part of #<epic>`, `decomposed` marker label on the parent) and claims the first slice, and the too-large branch splits rather than parking. v18: explicit issue-page claims ignore existing assignees; auto-pick resolves the authenticated login so self-assigned issues remain retryable; open continuation handoffs clear in-progress and all assignees. v17: mirrors claim-issue v17 — the repo-conventions file is named `AGENTS.md` (or `CLAUDE.md`) (#4852). v16: the Phase 1 and Phase 6 glab recipes use `--output json` instead of `-F json`. On `glab issue list`, `-F` is `--output-format` (details|ids|urls) — a DIFFERENT flag from `--output` (text|json) — so that spelling was accepted, ignored, and answered with the human table at exit 0; an agent piping that to `jq` got nothing and could not distinguish it from "no issues". `--output json` is correct on every glab subcommand, so the mr recipes are normalized to the same spelling in this bump. v15: mirrors claim-issue v16 — Phase 1 step 4's blocking-label check is now the `{issueExcludeLabels}` placeholder. v14: mirrors claim-issue v15 — Phase 5 runs the LOCAL reviewers against the branch diff before any MR exists, Phase 6 opens the MR and satisfies the MR-SIDE reviewers + pipeline before merging. v12: follow-up issue recipes choose independent slashdo dispatch hints (`model:`/`effort:`) and contributor labels (`good first issue`/`help wanted`) instead of only `plan`. v11: claim worktree creation passes `--no-track`, so a branch based on the default-branch remote ref does not inherit it as an upstream; the later `git push -u` sets the intended branch upstream. v10: mirrors claim-issue v11 — every Phase-3 release converges (close the already-fixed/superseded issue, tag the stale-reference one `needs-input`) so the perpetual drain stops re-picking it. v9: mirrors claim-issue v10 — Phase 5's changelog step defers to the repo's documented convention (per-branch fragments) rather than prescribing a `.changelog/NEXT.md` append. v8: reviewer bullets name the antigravity reviewer's actual PATH binary (`agy`) — mirrors plan-task v12. The same bump adds the missing-binary guard: a reviewer whose CLI is not on PATH is UNSATISFIED, never a clean review the agent substitutes its own self-review for. v7: worktree is created under PortOS's shared worktrees dir (`{worktreesRoot}` → data/cos/worktrees) instead of a repo-relative `data/cos/worktrees/` path, so the agent's checkout no longer lands inside the managed app's working tree (mirrors claim-issue v8). v6: mirrors claim-issue v7 — Phase 3 decides an *ambiguous* issue (record the chosen reading in an issue note, ship) instead of parking it to `needs-input`, which is reserved for destructive/irreversible or genuinely-human-gated (hardware/credentials) cases. v5: mirrors claim-issue v6 — Phase 1 epic skip also recognizes a leading `[epic]` bracket or `Epic:` colon title tag (e.g. "[Epic] …" / "Epic: …"), not just an `epic` label or a "(epic)" suffix, so the GitLab detector/agent converge on epic-titled issues too. v4: per-kind reviewer bullets name `grok` alongside `claude`/`codex`/`antigravity` as a local-CLI reviewer (grok is now a selectable Review Loop reviewer). v3: mirrors claim-issue v4 — Phase 5 chooses Closes-vs-Refs deliberately and Phase 7 reconciles the issue with the partial-ship hybrid (close + scoped follow-up when separable, else "done/remaining" note + release the `in-progress` claim) so a partial ship is never stranded. v2: Phase 3 tags an ambiguous/too-large issue `needs-input` (mirrors claim-issue v3) so it's excluded from future autonomous claims — required for `perpetual` (drain-until-done) mode to converge. v1: GitLab sibling of claim-issue — same 7-phase /claim --issues flow over `glab` issues + merge requests. Reached via the claim-work router when an app's resolved workTracker is 'gitlab'.@@ -35,6 +35,14 @@ export const PROMPT_VERSIONS = {'test-coverage': 2, // v2: generic {appName} body (older default hardcoded "PortOS")'performance': 2, // v2: generic {appName} body (older default hardcoded "PortOS")'accessibility': 2, // v2: generic {appName} + the app UI (older default hardcoded "PortOS" + http://localhost:5555)+ // These three shipped a body change but never carried a PROMPT_VERSIONS entry,+ // so `if (PROMPT_VERSIONS[taskType] && …)` skipped them and their stored+ // prompts could never auto-upgrade — even once the promptCustomized self-heal+ // clears the flag. Versioned now so the `[App Improvement: …]`-header+ // generation converges on the current body.+ 'console-errors': 2, // v2: `[Improvement: {appName}]` header (older default used `[App Improvement: {appName}]`)+ 'error-handling': 2, // v2: `[Improvement: {appName}]` header (older default used `[App Improvement: {appName}]`)+ 'typing': 2, // v2: `[Improvement: {appName}]` header (older default used `[App Improvement: {appName}]`)'dependency-updates': 4, // v4: the Phase 1 GitLab MR listing gains `--output json` — without it glab answers with the human table, which carries the head branch but NOT the author, while the classification right below it reads both. The same bump drops `--state` from the MR-list recipes — that flag does not exist (MR state is selected by presence flags `--merged`/`--closed`/`--all`, and OPEN is the default), so `--state opened` exited 1 with `Unknown flag: --state` and Phase 1 skipped its bot-PR triage entirely on GitLab repos. v3: Phase 1 triages open Dependabot/Renovate PRs first (evidence → MERGE / FIX-THEN-MERGE / CLOSE / LEAVE, including conflict + CI-failure repair on the bot branch) before Phase 2 updates anything the bots didn't cover — an agent that bumped packages itself was duplicating and conflicting with open bot PRs. v2: generic {appName} body (older default hardcoded "PortOS")'documentation': 6, // v6: the changelog step names `AGENTS.md` (or `CLAUDE.md`) as the file carrying the repo's documented convention — #4852 made AGENTS.md the canonical cross-vendor agent-instructions filename, and a managed app that adopted it would otherwise be told to read a file it no longer has. v5: the changelog step defers to the convention the repo documents (some repos collect per-branch fragments in a directory so parallel agents don't conflict) instead of prescribing an append to `.changelog/NEXT.md`. v4: generic {appName} body (v1 hardcoded "PortOS"; v2/v3 retired DONE.md wording)'ui-bugs': 2, // v2: generic {appName} + the app UI (older default hardcoded "PortOS" + http://localhost:5555)diff --git a/server/services/taskPromptService.js b/server/services/taskPromptService.jsindex 377c19cff2..72155515c7 100644--- a/server/services/taskPromptService.js+++ b/server/services/taskPromptService.js@@ -34,7 +34,8 @@ import {DEFAULT_TASK_PROMPTS,PROMPT_VERSIONS,REFERENCE_WATCH_AUDITED_VERSION,- PREVIOUS_DEFAULT_PROMPTS+ PREVIOUS_DEFAULT_PROMPTS,+ promptMatchesShippedDefault} from './taskPromptDefaults.js';// Re-export the prompt data/compat constants so existing importers of this@@ -54,12 +55,6 @@ const CLAIM_FLOW_DEFAULT_PROMPTS = Object.freeze({'plan-task': PREVIOUS_DEFAULT_PROMPTS['plan-task'].at(-1)});-function isShippedDefaultPrompt(prompt, taskType) {- if (!prompt || !DEFAULT_TASK_PROMPTS[taskType]) return false;- return prompt === DEFAULT_TASK_PROMPTS[taskType]- || (PREVIOUS_DEFAULT_PROMPTS[taskType] || []).includes(prompt);-}-// ============================================================// Prompt getters// ============================================================@@ -100,7 +95,7 @@ async function resolvePromptPlaceholders(prompt) {export async function getTaskPrompt(taskType, { claimFlow = false } = {}) {const interval = await getTaskInterval(taskType);- const storedDefault = claimFlow && isShippedDefaultPrompt(interval.prompt, taskType);+ const storedDefault = claimFlow && promptMatchesShippedDefault(interval.prompt, taskType);let prompt = (interval.prompt && !storedDefault ? interval.prompt : null)|| (claimFlow ? CLAIM_FLOW_DEFAULT_PROMPTS[taskType] : null)|| DEFAULT_TASK_PROMPTS[taskType]diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex 9b7710edd0..4eb8e3bd12 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -427,6 +427,85 @@ describe('taskSchedule', () => {})})+ describe('[App Improvement: …] header generation', () => {+ // The unification of the self-improvement and app-improvement schedules+ // renamed every basic prompt header from `[App Improvement: {appName}]` to+ // `[Improvement: {appName}]` without preserving the outgoing bodies. Every+ // install carrying that generation stopped matching a shipped default, got+ // stamped promptCustomized by the legacy migration, and has been frozen out+ // of every prompt upgrade since — nine task types on a real install. These+ // fixtures are the bodies those installs actually stored.+ const legacyConsoleErrors = `[App Improvement: {appName}] Console Error Investigation++Find and fix console errors in {appName}:++Repository: {repoPath}++1. If the app has a UI, check browser console for errors+2. Check server logs for errors+3. For each error:+ - Identify the source file and line+ - Understand the root cause+ - Implement a fix++4. Test fixes and commit changes`+ const legacySecurity = PREVIOUS_DEFAULT_PROMPTS['security'].find((p) => p.startsWith('[App Improvement: '))+ const legacyFeatureIdeas = PREVIOUS_DEFAULT_PROMPTS['feature-ideas'].find((p) => p.startsWith('[Self-Improvement] '))++ const loadOne = async (taskType, prompt, promptVersion) => {+ mockSchedule({+ tasks: { [taskType]: { type: 'once', enabled: false, providerId: null, model: null, prompt, promptVersion, promptCustomized: true } }+ })+ return (await loadSchedule()).tasks[taskType]+ }++ it.each([+ ['console-errors', legacyConsoleErrors, 1],+ ['security', legacySecurity, 1],+ ['feature-ideas', legacyFeatureIdeas, 2],+ ])('self-heals and upgrades a stored %s prompt from that generation', async (taskType, prompt, storedVersion) => {+ 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])+ })++ // Without a PROMPT_VERSIONS entry the auto-upgrade block is skipped+ // entirely, so clearing promptCustomized alone would leave these three+ // pinned to the legacy body forever.+ it('versions the task types whose only shipped revision was the header rename', () => {+ for (const t of ['console-errors', 'error-handling', 'typing']) {+ expect(PROMPT_VERSIONS[t], `PROMPT_VERSIONS['${t}']`).toBeGreaterThanOrEqual(2)+ }+ })++ it('preserves a genuine user customization that merely uses the legacy header', async () => {+ const custom = '[App Improvement: {appName}] My own audit that matches no shipped default.'+ const task = await loadOne('console-errors', custom, 1)+ expect(task.prompt).toBe(custom)+ expect(task.promptCustomized).toBe(true)+ })++ // The frozen feature-ideas body sent every run to `data/COS-GOALS.md`, a+ // file the same unification folded into the root GOALS.md.+ it('retires the COS-GOALS.md reference once feature-ideas upgrades', async () => {+ const task = await loadOne('feature-ideas', legacyFeatureIdeas, 2)+ expect(legacyFeatureIdeas).toContain('data/COS-GOALS.md')+ expect(task.prompt).not.toContain('COS-GOALS.md')+ })+ })++ describe('feature-ideas product-source precedence', () => {+ it('reads PRD.md first and falls back to GOALS.md when brainstorming', () => {+ const prompt = DEFAULT_TASK_PROMPTS['feature-ideas']+ expect(prompt).toContain('`PRD.md`')+ expect(prompt).toContain('`GOALS.md`')+ // Precedence, not just presence: the PRD instruction must come first.+ expect(prompt.indexOf('`PRD.md`')).toBeLessThan(prompt.indexOf('`GOALS.md`'))+ expect(prompt).toContain('follow the PRD\'s concrete requirements')+ })+ })+describe('changelog-fragment prompt revision (issue #3998)', () => {// Pins that each task type touched by this revision actually participates in// the auto-upgrade path: it is in PROMPT_VERSIONS, loadSchedule walks it, anddiff --git a/server/services/taskScheduleStore.js b/server/services/taskScheduleStore.jsindex e0a6fef8c8..549ae7a0c2 100644--- a/server/services/taskScheduleStore.js+++ b/server/services/taskScheduleStore.js@@ -15,7 +15,10 @@ import {import {DEFAULT_TASK_PROMPTS,PROMPT_VERSIONS,- PREVIOUS_DEFAULT_PROMPTS+ // True when a stored prompt matches a shipped default (current or prior).+ // A genuine user edit never does, so loadSchedule treats a match as+ // "not really customized" — see taskPromptDefaults/shippedPrompts.js.+ promptMatchesShippedDefault} from './taskPromptDefaults.js';const DATA_DIR = PATHS.cos;@@ -132,19 +135,6 @@ function migrateScheduleV1toV2(schedule) {return migrated;}-// True when a stored prompt byte-matches a shipped default for this task — the-// current default or any prior one in PREVIOUS_DEFAULT_PROMPTS. Used by-// loadSchedule both to recognize legacy (unversioned) prompts and to self-heal a-// prompt mis-flagged as customized. A genuine user edit never byte-matches a-// shipped default, so callers can treat a match as "not really customized".-function promptMatchesShippedDefault(prompt, taskType) {- if (!prompt || !DEFAULT_TASK_PROMPTS[taskType]) return false;- return (- prompt === DEFAULT_TASK_PROMPTS[taskType] ||- (PREVIOUS_DEFAULT_PROMPTS[taskType] || []).includes(prompt)- );-}-/*** Read and normalize schedule data without deciding whether the normalized* result should be persisted. Callers that mutate the result must do so inside@@ -224,7 +214,7 @@ async function readSchedule() {// Matches current default — assign current version (no upgrade needed)config.promptVersion = PROMPT_VERSIONS[taskType] || 1;needsSave = true;- } else if ((PREVIOUS_DEFAULT_PROMPTS[taskType] || []).includes(config.prompt)) {+ } else if (promptMatchesShippedDefault(config.prompt, taskType)) {// Matches a known previous default — assign version 1 so auto-upgrade triggersconfig.promptVersion = 1;needsSave = true;@@ -237,11 +227,13 @@ async function readSchedule() {}// Self-heal a mis-flagged customization: a prompt marked promptCustomized- // that nonetheless byte-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 (e.g. the basic self-improvement- // prompts that hardcoded the app name as "PortOS"). Clear the flag so the- // auto-upgrade below can replace the stale default.+ // 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.if (config.promptCustomized && promptMatchesShippedDefault(config.prompt, taskType)) {config.promptCustomized = false;needsSave = true;