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
feat(cos): add do-replan as scheduled task type (weekly, disabled by default)
Adam Eivy8fd5b4b25d22
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d333aff7f7..47d0f338be 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,7 @@## Added+- **CoS scheduled task: `do-replan` — weekly auto-audit of every managed app's PLAN.md.** New scheduled task type that runs the bundled `/do:replan` slashdo command against each managed app on a configurable cadence (default: **weekly**, **disabled per app** — enable individually from the Schedule tab). Pairs with the manual `/do:replan` button shipped in the same release: the button is for one-shot triggering, this task is for autopilot. When enabled, the agent spins up a worktree on the app's repo, follows the full `do:replan` flow (archive completed items to DONE.md, prune stale items, surface 1-3 new opportunities, rewrite PLAN.md to be lean), commits, and opens a PR for the user to review — never pushes directly to the default branch. The task prompt uses a new `{slashdoReplan}` placeholder that resolves at runtime to the live body of `lib/slashdo/commands/do/replan.md` (mirrors the existing `{reviewChecklist}` pattern), so the slashdo command stays the single source of truth and any future edits to it propagate automatically without prompt-version bumps. Existing apps see the new task as disabled (per-app overrides default to `enabled: false`); newly-created apps inherit the same default. Files: `server/services/taskSchedule.js` (new entry in `SELF_IMPROVEMENT_TASK_TYPES`, `DEFAULT_TASK_INTERVALS`, `DEFAULT_TASK_PROMPTS`; generalized slashdo cache from a single-purpose `_reviewChecklistCache` to a keyed `_slashdoCache`), `server/services/cos.js` (description copy), `client/src/components/UpcomingTasksWidget.jsx` (📋 icon), `client/src/components/cos/tabs/TaskItem.jsx` (description→type inference for replan/PLAN.md keywords), `server/services/taskSchedule.test.js` (3 new tests covering core-types membership, default interval shape, and `{slashdoReplan}` runtime substitution).- **`/do:replan` button under each app's Agent Operations section.** Adds a sixth slashdo button to the Agent Operations row on every app's Overview tab (and to the server-side allowlist that gates `POST /api/cos/tasks/slashdo`) so the user can queue an automated PLAN.md audit/triage agent for any managed app the same way they queue `/do:push`, `/do:review`, etc. Clicking the cyan `/do:replan` button creates a CoS task pre-loaded with the upstream `lib/slashdo/commands/do/replan.md` content (which archives done items to DONE.md, prunes stale entries, and suggests new work), then routes the user to `/cos/agents` to watch it run. Files: `client/src/components/apps/SlashDoPanel.jsx`, `server/routes/cosTaskRoutes.js`.- **Ask Yourself — slice (b) closes: voice tool + ⌘K palette action.** The text-chat half of "Ask Yourself" shipped on 2026-04-24, and per-turn promotions shipped on 2026-04-28; the remaining slice-(b) item — voice integration — is now done. New `ui_ask` voice tool in `server/services/voice/tools.js` consumes `askService.runAsk`'s async iterable (`sources`/`delta`/`done`/`error` events), accumulates the answer, and returns `{ ok, content, sourceCount, sources, providerId, model, summary }`. The tool's description tells the voice LLM to speak `content` verbatim, so the existing sentence-boundary TTS path in `pipeline.js` reads it aloud — no new client-side wiring required. Tool is gated by a new `ask` intent group with a tight regex (`ask my ?self|advise me|coach me|draft (a|an|my|me|something)|what.* on my plate|what (did|do|should) i (decide|think|believe|say|want|do)|why did i|when did i|recall (my|that|when)`) so small tool-use models (qwen3-4b, granite, etc.) only see it on RAG-style turns and don't get tempted to call it on plain UI/capture phrasings. `pipeline.js` now propagates the voice turn's `AbortSignal` through `ctx.signal` so barge-in tears down the upstream askService stream instead of silently leaking tokens into a closed connection. The palette half: `ui_ask` added to `PALETTE_ACTIONS` in `server/routes/palette.js` under section `Ask`, label `Ask Yourself` — `⌘K` exposes it with description/parameters auto-hydrated from the voice tool registry, and `POST /api/palette/action/ui_ask { args: { question, mode? } }` returns the answer + source kinds/titles synchronously so non-voice callers (palette, scripts) get the same RAG pipeline. 17 new tests (7 ui_ask tool, 5 ask-intent classifier, 3 ui_ask spec gating, 2 palette manifest + dispatch) — full server suite green at 2785/2785. Closes the last item in the PLAN.md "Ask Yourself — slice (b)" backlog. Files: `server/services/voice/tools.js`, `server/services/voice/tools.test.js`, `server/services/voice/pipeline.js`, `server/routes/palette.js`, `server/routes/palette.test.js`, `PLAN.md`.- **Ask Yourself: one-click promote each assistant turn into a Brain note, CoS task, or Goal progress entry.** Closes the second half of "Ask Yourself — slice (b)" — the Ask page's twin-flavored answers were trapped in the conversation. Each assistant turn now shows three buttons below its source chips: **Save to Brain** (calls `brainService.captureThought` with the answer text), **Create task** (creates a CoS task with the answer as the description, capped at 280 chars and tagged with a "Promoted from Ask Yourself <id>" context note), and **Attach to goal…** (inline goal picker → `identityService.addProgressEntry` writes the answer as a `progressLog` note dated today). After a successful promotion the button mutates to a green "Saved to Brain"/"Task created"/"Attached: <goal title>" chip that deep-links to the saved record (`/brain/inbox`, `/cos`, `/digital-twin/goals?id=…`). Server-side, every promotion also pins the conversation (`promoted = true`) so anything saved elsewhere survives the 30-day expiry sweep — without that, a saved brain note could outlive the conversation it cites. New endpoint `POST /api/ask/:id/turns/:turnId/promote` validates a discriminated zod union — `{ target: 'brain' }`, `{ target: 'task', priority? }`, `{ target: 'goal', goalId }` — fails fast with 400/404/409 on missing turns, user turns, empty content, missing goals, or duplicate tasks. 13 new route tests; the full server suite remains green at 2746/2746. The remaining slice-(b) item — the `ui_ask` voice tool + palette whitelist — is still pending. Files: `server/routes/ask.js`, `server/routes/ask.test.js`, `client/src/services/apiAsk.js`, `client/src/pages/Ask.jsx`, `PLAN.md`.diff --git a/client/src/components/UpcomingTasksWidget.jsx b/client/src/components/UpcomingTasksWidget.jsxindex b2ffa40e95..7524121d00 100644--- a/client/src/components/UpcomingTasksWidget.jsx+++ b/client/src/components/UpcomingTasksWidget.jsx@@ -57,7 +57,8 @@ const UpcomingTasksWidget = memo(function UpcomingTasksWidget() {'documentation': '📝','feature-ideas': '💡','accessibility': '♿',- 'dependency-updates': '📦'+ 'dependency-updates': '📦',+ 'do-replan': '📋'};return icons[taskType] || '📋';};diff --git a/client/src/components/cos/tabs/TaskItem.jsx b/client/src/components/cos/tabs/TaskItem.jsxindex 15b6f41aa4..e618e6afde 100644--- a/client/src/components/cos/tabs/TaskItem.jsx+++ b/client/src/components/cos/tabs/TaskItem.jsx@@ -50,6 +50,7 @@ function extractTaskType(description) {if (d.includes('dependency')) return 'task:dependency-updates';if (d.includes('jira') && d.includes('report')) return 'task:jira-status-report';if (d.includes('jira') || d.includes('sprint')) return 'task:jira-sprint-manager';+ if (d.includes('replan') || d.includes('audit plan.md') || d.includes('plan.md')) return 'task:do-replan';}// General task type classificationdiff --git a/server/routes/cos.test.js b/server/routes/cos.test.jsindex 931d9dd330..839766dfbe 100644--- a/server/routes/cos.test.js+++ b/server/routes/cos.test.js@@ -769,17 +769,24 @@ describe('CoS Routes', () => {});describe('POST /api/cos/tasks/slashdo', () => {- it('should create a task from a slashdo command', async () => {+ it.each([+ 'push',+ 'review',+ 'replan',+ 'release',+ 'better',+ 'better-swift'+ ])('should create a task from slashdo command %s', async (command) => {loadSlashdoCommand.mockResolvedValue('command content');- cos.addTask.mockResolvedValue({ id: 'task-sd1', status: 'pending' });+ cos.addTask.mockResolvedValue({ id: `task-sd-${command}`, status: 'pending' });const response = await request(app).post('/api/cos/tasks/slashdo')- .send({ command: 'push', app: 'my-app' });+ .send({ command, app: 'my-app' });expect(response.status).toBe(200);- expect(response.body.id).toBe('task-sd1');- expect(loadSlashdoCommand).toHaveBeenCalledWith('push');+ expect(response.body.id).toBe(`task-sd-${command}`);+ expect(loadSlashdoCommand).toHaveBeenCalledWith(command);});it('should return 400 for invalid command', async () => {diff --git a/server/services/cos.js b/server/services/cos.jsindex 25e6858b04..4675a8a5e6 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -1065,7 +1065,8 @@ function getTaskDescription(taskType, appName) {'feature-ideas': `Implement a feature idea for ${appName} aligned with GOALS.md and PLAN.md (worktree+PR)`,'release-check': `Verify release readiness for ${appName}`,'jira-sprint-manager': `Triage and implement JIRA sprint tickets for ${appName} (worktree+PR)`,- 'jira-status-report': `Generate JIRA weekly status report for ${appName}`+ 'jira-status-report': `Generate JIRA weekly status report for ${appName}`,+ 'do-replan': `Replan: audit PLAN.md for ${appName}, archive done items, prune stale work (worktree+PR)`};return descriptions[taskType] ?? null;}@@ -1085,7 +1086,8 @@ function getTaskDescription(taskType, appName) {'typing': 'Add or fix TypeScript/JSDoc type annotations','release-check': 'Verify release readiness (changelog, version, tests)','jira-sprint-manager': 'Triage and implement JIRA sprint tickets (worktree+PR)',- 'jira-status-report': 'Generate JIRA weekly status report'+ 'jira-status-report': 'Generate JIRA weekly status report',+ 'do-replan': 'Replan: audit PLAN.md, archive done items, prune stale work (worktree+PR)'};return descriptions[taskType] ?? null;}diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.jsindex 3b8e16332b..32078dc3de 100644--- a/server/services/taskSchedule.js+++ b/server/services/taskSchedule.js@@ -706,6 +706,20 @@ Do NOT comment on JIRA tickets directly — all action items go to the Review Hu9. Generate a summary report covering triage actions taken and implementation work completed`,+ 'do-replan': `[Improvement: {appName}] Replan — Audit PLAN.md++Run the project's \`/do:replan\` slashdo command for {appName} in autonomous (non-interactive) mode.++Repository: {repoPath}++The full \`/do:replan\` command body follows. Apply it to {repoPath} exactly as written, then commit any changes. Default mode is autonomous — do NOT prompt the user; run \`--interactive\` only if the user has explicitly asked for it (they have not).++Scope: this task operates against the managed app's repository, NOT PortOS. All edits must land in {repoPath} (PLAN.md, DONE.md, GOALS.md, docs/) — never write to PortOS itself.++---++{slashdoReplan}`,+'jira-status-report': `[Task: {appName}] JIRA Weekly Status ReportGenerate a JIRA status report for {appName} (App ID: {appId}).@@ -1260,13 +1274,13 @@ Before reviewing code quality, scan each PR for malicious content:]};-// Unified default interval settings for all 19 task types+// Unified default interval settings for all task typesexport const SELF_IMPROVEMENT_TASK_TYPES = ['security', 'code-quality', 'test-coverage', 'performance','accessibility', 'branch-cleanup', 'console-errors', 'dependency-updates', 'documentation','ui-bugs', 'mobile-responsive', 'feature-ideas', 'error-handling','typing', 'release-check', 'pr-reviewer', 'code-reviewer-a', 'code-reviewer-b',- 'jira-sprint-manager', 'jira-status-report'+ 'jira-sprint-manager', 'jira-status-report', 'do-replan'];// Shared config for code-reviewer-a and code-reviewer-b (two instances for independent provider/model configuration)@@ -1292,7 +1306,8 @@ const DEFAULT_TASK_INTERVALS = {'code-reviewer-a': { ...CODE_REVIEWER_INTERVAL },'code-reviewer-b': { ...CODE_REVIEWER_INTERVAL },'jira-sprint-manager': { type: INTERVAL_TYPES.DAILY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null, taskMetadata: { useWorktree: true, openPR: true, simplify: true } },- 'jira-status-report': { type: INTERVAL_TYPES.WEEKLY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null, taskMetadata: { readOnly: true } }+ 'jira-status-report': { type: INTERVAL_TYPES.WEEKLY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null, taskMetadata: { readOnly: true } },+ 'do-replan': { type: INTERVAL_TYPES.WEEKLY, enabled: false, providerId: null, model: null, prompt: null, taskMetadata: { useWorktree: true, openPR: true } }};/**@@ -2065,19 +2080,23 @@ export function getDefaultPrompt(taskType) {return DEFAULT_TASK_PROMPTS[taskType] || null;}-// Cache the review checklist content (loaded from bundled slashdo submodule)-let _reviewChecklistCache = null;-async function loadReviewChecklist() {- if (_reviewChecklistCache) return _reviewChecklistCache;- _reviewChecklistCache = await loadSlashdoFile('review', { stripFrontmatter: true }) || '';- return _reviewChecklistCache;+// Cache slashdo command bodies loaded from the bundled submodule+const _slashdoCache = {};+async function loadSlashdoCommandBody(commandName) {+ if (_slashdoCache[commandName]) return _slashdoCache[commandName];+ _slashdoCache[commandName] = await loadSlashdoFile(commandName, { stripFrontmatter: true }) || '';+ return _slashdoCache[commandName];}async function resolvePromptPlaceholders(prompt) {if (prompt.includes('{reviewChecklist}')) {- const checklist = await loadReviewChecklist().catch(() => '');+ const checklist = await loadSlashdoCommandBody('review').catch(() => '');prompt = prompt.replace(/\{reviewChecklist\}/g, checklist);}+ if (prompt.includes('{slashdoReplan}')) {+ const replan = await loadSlashdoCommandBody('replan').catch(() => '');+ prompt = prompt.replace(/\{slashdoReplan\}/g, replan);+ }return prompt;}diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex 5047a38f80..96696ddea8 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -138,6 +138,26 @@ describe('taskSchedule', () => {expect(SELF_IMPROVEMENT_TASK_TYPES).toContain('test-coverage')expect(SELF_IMPROVEMENT_TASK_TYPES).toContain('performance')expect(SELF_IMPROVEMENT_TASK_TYPES).toContain('dependency-updates')+ expect(SELF_IMPROVEMENT_TASK_TYPES).toContain('do-replan')+ })+ })++ describe('do-replan task type', () => {+ it('should default to weekly, disabled, with worktree+PR metadata', async () => {+ const interval = await getTaskInterval('do-replan')+ expect(interval.type).toBe('weekly')+ expect(interval.enabled).toBe(false)+ expect(interval.taskMetadata?.useWorktree).toBe(true)+ expect(interval.taskMetadata?.openPR).toBe(true)+ })++ it('should expose a default prompt that delegates to the slashdo command', () => {+ const prompt = getDefaultPrompt('do-replan')+ expect(prompt).toBeDefined()+ expect(prompt).toContain('Replan')+ expect(prompt).toContain('{appName}')+ expect(prompt).toContain('{repoPath}')+ expect(prompt).toContain('{slashdoReplan}')})})@@ -487,6 +507,15 @@ describe('taskSchedule', () => {expect(prompt).toContain('unknown-type')expect(prompt).toContain('{repoPath}')})++ it('should substitute {slashdoReplan} with the bundled replan command body', async () => {+ const { loadSlashdoFile } = await import('../lib/fileUtils.js')+ loadSlashdoFile.mockResolvedValueOnce('# Replan Command\n\nSentinel body for substitution test.')+ const prompt = await getTaskPrompt('do-replan')+ expect(prompt).not.toContain('{slashdoReplan}')+ expect(prompt).toContain('Sentinel body for substitution test.')+ expect(loadSlashdoFile).toHaveBeenCalledWith('replan', { stripFrontmatter: true })+ })})describe('resetExecutionHistory', () => {