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
add stash-cleanup scheduled task type
[._.]/ Adam Eivycd423dee0841
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.jsonindex c007d13c82..c65c502321 100644--- a/server/services/taskPromptDefaults/integrity.snapshot.json+++ b/server/services/taskPromptDefaults/integrity.snapshot.json@@ -23,6 +23,7 @@"error-handling": "9afba2e99b90a8d5771c75e7f0615d96","typing": "1f2758ce0bb62d789a21aec241549531","release-check": "afa9039cfbff21d77d601dc74eb5b81f",+ "stash-cleanup": "f9de8b10937919ceb6656fbdb70179c4","jira-sprint-manager": "3e63c8a3bdf0d5a05a30faaa2dc07980","do-replan": "35660eb7b43e4259a6a9253ed288a1db","jira-status-report": "9d374a9d8ccb92c5c8fd0aa9899e79a5",@@ -63,6 +64,7 @@"ux": 1,"data-safety": 1,"simplify": 1,+ "stash-cleanup": 1,"release-check": 9},"REFERENCE_WATCH_AUDITED_VERSION": 3,diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.jsindex a31daee868..e081d37a24 100644--- a/server/services/taskPromptDefaults/prompts.js+++ b/server/services/taskPromptDefaults/prompts.js@@ -1448,6 +1448,45 @@ Summarize:- Number of review iterations needed- Any unresolved issues`,+ 'stash-cleanup': `[Improvement: {appName}] Git Stash Cleanup++Repository: {repoPath}++Audit every entry in \`git stash list\` for {appName} and clear out anything that is stale, superseded, or unrecoverable — without losing real unlanded work. This never produces a commit; it is a working-tree hygiene pass.++## Step 0: Handle a mid-flight conflict first++Run \`git status\` (\`cd {repoPath}\` first). If it shows unmerged paths (a \`git stash pop\` left the tree conflicted), resolve that BEFORE touching the rest of the stash list:++1. For each conflicted file, read the conflict markers and compare the stashed side against the current HEAD/\`main\` side for that region.+2. If the stashed side is fully superseded — HEAD already contains the same change or a superset of it (verify by grepping the file for the added identifiers/lines and reading the surrounding code, not just eyeballing the diff) — resolve with \`git checkout --ours <file>\` and \`git add <file>\`.+3. If the stashed side adds anything HEAD does not already have, STOP. Do not attempt to hand-merge two live versions of the same logic. Leave the conflict markers in place, note exactly which file(s) and which lines are in conflict, and report it — this needs a human to resolve.+4. Once every conflicted file is resolved (or none were conflicted), confirm \`git status\` is clean before continuing to Step 1. A conflict resolved this way produces no diff against HEAD by construction, so there is nothing to commit.++If Step 0 stopped on an unresolved conflict, skip the rest of this task and go straight to Step 3 (Report).++## Step 1: Triage every remaining stash++Run \`git stash list\`. For each \`stash@{N}\`:++1. \`git stash show -p stash@{N} --stat\` for an overview, then the full \`git stash show -p stash@{N}\` for the patch.+2. For every changed symbol or section in the patch, check whether current \`main\`/HEAD already contains the same change or a superset of it — grep the target file(s) for the added identifiers, read the surrounding code, and compare. If the stash's message references a branch name, also check \`git branch -a\` and \`git log --all --oneline\` for whether that branch was already merged or deleted (a strong signal the stash is redundant leftover cruft).+3. Classify each stash:+ - **SUPERSEDED** — the change (or a superset of it) already exists on \`main\`. Safe to drop.+ - **STALE/ABANDONED** — old WIP, exploratory scratch, lockfile-only diff noise, a reference to a file that no longer exists in the repo, or a change that contradicts current architecture/policy (check this repo's CLAUDE.md before assuming). Safe to drop.+ - **REAL UNLANDED WORK** — a coherent change that is not on \`main\` and is not obviously abandoned. Do NOT drop it. Note what it does, which files it touches, and how stale the underlying branch/context looks.+4. Before diffing two stashes independently, check for duplicates: \`diff <(git stash show -p stash@{A}) <(git stash show -p stash@{B})\`. Identical stashes are one unit — classify and act on them together.++## Step 2: Act++- Drop every stash classified SUPERSEDED or STALE/ABANDONED: \`git stash drop stash@{N}\`. Re-run \`git stash list\` after each drop, since indices shift.+- Leave every stash classified REAL UNLANDED WORK in place. Do not apply, pop, or drop it.+- Only run \`git stash clear\` once you have classified the ENTIRE list and confirmed nothing in it is REAL UNLANDED WORK.++## Step 3: Report++Summarize: how many stashes were reviewed, how many were dropped (grouped by reason: superseded vs. stale/abandoned), and — for anything classified REAL UNLANDED WORK — what it is, which files it touches, and a recommendation (recover as a branch, cherry-pick specific hunks, or leave it for the user to decide). When in doubt about whether a stash is safe to drop, leave it in the stash and say so in the report rather than dropping it.`,+'jira-sprint-manager': `[Improvement: {appName}] JIRA Sprint ManagerTriage and implement JIRA tickets for {appName}:diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.jsindex a066aa30f4..63202ca2c9 100644--- a/server/services/taskPromptDefaults/versions.js+++ b/server/services/taskPromptDefaults/versions.js@@ -41,6 +41,7 @@ export const PROMPT_VERSIONS = {'ux': 1, // v1: walk the running UI with Playwright MCP against a 7-item named UX checklist and file ONE tracker item per finding via {trackerInstructions} — read-only on source, no branches/PRs. Net-new type (no PREVIOUS_DEFAULT_PROMPTS entry needed). Mode (file-issues vs implement) is injected at dispatch via {modeInstructions} / applyAuditModeWrapper — no prompt bump required.'data-safety': 1, // v1: data/upgrade-safety audit (migrations, schema parity, version gates). Mode injected at dispatch.'simplify': 1, // v1: dead-code/duplication audit. Mode injected at dispatch.+ 'stash-cleanup': 1, // v1: triage git stash list — supersession check against main, drop superseded/stale entries, leave real unlanded work in place. Net-new type (no PREVIOUS_DEFAULT_PROMPTS entry needed).'release-check': 9, // v9: Step 1 reconciles missing GitHub Releases against git release tags (publishing any missing tag with .changelog/vX.Y.Z.md as body and --latest=false when a newer version exists) BEFORE evaluating if enough unreleased work has accumulated; v8: database-backed release tests are provisioned and run using the repo's documented isolated test database before the release PR gate; v7: Step 1 also reads the UNCOLLECTED changelog fragments (the fragment dir, plus whatever preview command that repo documents — release-check is a generic {appName} prompt, so it never names a PortOS script to run) and counts substantive entries across the assembled notes — reading only the staged `.changelog/NEXT.md` under-counts a release whose entries are still per-branch fragments, so a ready release reported as "not enough work". v6: generic {appName} body (older defaults hardcoded "PortOS")};diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.jsindex a9a151da07..aab5c5c8a5 100644--- a/server/services/taskSchedule.js+++ b/server/services/taskSchedule.js@@ -210,6 +210,13 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [// copy-paste drift — distinct from `code-quality` (which is the broader DRY /// long-function / TODO pass). Defaults to file-issues.'simplify',+ // Audits `git stash list` for {appName} and drops entries already superseded+ // by (or a subset of) current `main`/HEAD, or that are stale/abandoned scratch+ // work — without discarding real unlanded work. On-demand only (no cadence+ // makes sense for something the user notices ad hoc); non-committing+ // coordinator posture, since a cleared stash is a repo-hygiene side effect,+ // never a commit. See DEFAULT_TASK_PROMPTS['stash-cleanup'].+ 'stash-cleanup',// PortOS-only: researches the current best local LLMs per category and// refreshes the bundled suggested-models catalog (server/lib/localLlmCatalog.js)// + the editorial family ranking (server/lib/localModelHeuristics.js), opening a@@ -402,6 +409,14 @@ export const DEFAULT_TASK_INTERVALS = {// live main checkout so its branch/ref checks describe the real release flow;// a CoS worktree hides that checkout and creates an irrelevant task branch.'release-check': { type: INTERVAL_TYPES.ON_DEMAND, enabled: false, providerId: null, model: null, prompt: null, taskMetadata: { ...NON_COMMITTING_COORDINATOR_METADATA } },+ // stash-cleanup triages `git stash list` and drops what's superseded/stale,+ // leaving real unlanded work in place for the user to recover by hand. It+ // runs in the app's live checkout (never a CoS worktree — a stash is a+ // property of the checkout it was taken in) and, like the other coordinators,+ // ships no code of its own. On-demand only: unlike branch/issue reconcile,+ // there's no useful cadence for a stash a user hasn't necessarily touched+ // since the last run — they trigger it when they notice stash clutter.+ 'stash-cleanup': { type: INTERVAL_TYPES.ON_DEMAND, enabled: false, providerId: null, model: null, prompt: null, taskMetadata: { ...NON_COMMITTING_COORDINATOR_METADATA } },'pr-reviewer': { type: INTERVAL_TYPES.CUSTOM, intervalMs: 7200000, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null, taskMetadata: { readOnly: true, pipeline: { stages: [{ name: 'Security Scan', promptKey: 'pr-reviewer-security', readOnly: true }, { name: 'Code Review & Merge', promptKey: 'pr-reviewer-review', readOnly: false }] } } },'code-reviewer-a': { ...CODE_REVIEWER_INTERVAL },'code-reviewer-b': { ...CODE_REVIEWER_INTERVAL },@@ -498,7 +513,8 @@ export const MANAGED_AGENT_OPTIONS = {// claim-work delegates to one of the above prompt bodies, each of which// creates its own worktree + PR — so the same lock applies to the router.'claim-work': ['useWorktree', 'openPR', 'claimFlow'],- 'release-check': ['useWorktree', 'openPR', 'worktreeChangesExpected']+ 'release-check': ['useWorktree', 'openPR', 'worktreeChangesExpected'],+ 'stash-cleanup': ['useWorktree', 'openPR', 'worktreeChangesExpected']};// Strip managed-agent fields from a per-app override map before merging on top@@ -2250,6 +2266,7 @@ export const TASK_TYPE_DESCRIPTIONS = {'ux': 'UX/design audit — file issues (default) or implement fixes','data-safety': 'Data/upgrade-safety audit — file issues (default) or implement fixes','simplify': 'Dead-code/duplication audit — file issues (default) or implement removals',+ 'stash-cleanup': 'Triage git stash list — drop entries superseded by or stale relative to main, leave real unlanded work in place','refresh-local-llm-catalog': "Refresh PortOS's bundled suggested local-model catalog + editorial ranking (PortOS repo only)",'layered-intelligence': "Read this app's goals + telemetry, ask a reasoning model for one improvement, and file one deduplicated tracker issue — no code, no agent"};diff --git a/server/services/taskTypeHooks.js b/server/services/taskTypeHooks.jsindex 629aeff1cb..9431e8ab71 100644--- a/server/services/taskTypeHooks.js+++ b/server/services/taskTypeHooks.js@@ -136,6 +136,7 @@ export function resolveTaskHookType(task) {*/export const NON_COMMITTING_COORDINATOR_TASK_TYPES = new Set(['branch-reconcile', 'issue-reconcile', 'branch-cleanup', 'jira-status-report', 'release-check',+ 'stash-cleanup',]);/**diff --git a/server/services/workflow.js b/server/services/workflow.jsindex ada5805792..3b3c9174fb 100644--- a/server/services/workflow.js+++ b/server/services/workflow.js@@ -41,7 +41,7 @@ export const WORKFLOW_STAGES = [id: 'hygiene',label: 'Hygiene',description: 'Reset state: clean up merged branches and stale agent data so downstream stages start clean.',- taskTypes: ['branch-reconcile'],+ taskTypes: ['branch-reconcile', 'stash-cleanup'],jobIds: ['job-agent-data-cleanup']},{