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
fix: let Better overview runs own PR publication and merge
[._.]/ Adam Eivy11ee667f96e3
diff --git a/server/lib/agentCompletionMode.js b/server/lib/agentCompletionMode.jsindex f1e742752f..c94ee58b63 100644--- a/server/lib/agentCompletionMode.js+++ b/server/lib/agentCompletionMode.js@@ -67,6 +67,8 @@ export const COMPLETION_MODES = Object.freeze({REVIEW_LOOP_FOLLOW_UP: 'review-loop-follow-up',/** The bundled release workflow owns delivery and final verification. */RELEASE_FLOW: 'release-flow',+ /** Better audits own their worktrees and verified PR delivery. */+ AUDIT_FLOW: 'audit-flow',/** TUI host that cannot type a `/do:*` command — commit, then hand off. */TUI_SLASHDO_FREE: 'tui-slashdo-free',/** TUI host that drives its own `/do:pr` | `/do:push` completion workflow. */@@ -111,6 +113,7 @@ const COMPLETION_MODE_RULES = Object.freeze([[COMPLETION_MODES.READ_ONLY, (f) => f.isReadOnly],[COMPLETION_MODES.REVIEW_LOOP_FOLLOW_UP, (f) => f.isReviewLoopFollowUp],[COMPLETION_MODES.RELEASE_FLOW, (f) => f.slashdoCommand === 'release'],+ [COMPLETION_MODES.AUDIT_FLOW, (f) => ['better', 'better-swift'].includes(f.slashdoCommand)],[COMPLETION_MODES.TUI_SLASHDO_FREE, (f) => f.isTui && !f.canRunSlashCommands],[COMPLETION_MODES.TUI, (f) => f.isTui],[COMPLETION_MODES.PORTOS_MERGES, (f) => f.portosMergesBranch],diff --git a/server/lib/agentCompletionMode.test.js b/server/lib/agentCompletionMode.test.jsindex c5e5c26827..d47f058b1b 100644--- a/server/lib/agentCompletionMode.test.js+++ b/server/lib/agentCompletionMode.test.js@@ -81,6 +81,7 @@ describe('resolveCompletionMode', () => {resolveCompletionMode({ isReadOnly: true }),resolveCompletionMode({ isReviewLoopFollowUp: true }),resolveCompletionMode({ slashdoCommand: 'release' }),+ resolveCompletionMode({ slashdoCommand: 'better' }),resolveCompletionMode({ isTui: true, canRunSlashCommands: false }),resolveCompletionMode({ isTui: true }),resolveCompletionMode({ worktreeInfo: wt, willOpenPR: false }),diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 782f3a71e1..5cf70421d9 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -39,6 +39,7 @@ import {buildAuditOutputCompletionSection,buildClaimFlowCompletionSection,buildReleaseFlowCompletionSection,+ buildAuditFlowCompletionSection,buildCliCompletionSection,buildCompletionGuidelineBullet,buildFallbackCompletionInstructions,@@ -548,7 +549,7 @@ You are working in an **isolated git worktree** to avoid conflicts with other ag- **Worktree Path**: \`${worktreeInfo.worktreePath}\`${worktreeInfo.baseBranch ? `- **Based on**: \`${worktreeInfo.baseBranch}\` (latest from origin)` : ''}-**Important**: ${worktreeCommitNote} ${completionMode === COMPLETION_MODES.RELEASE_FLOW ? 'Follow the release workflow branch instructions while preserving unrelated work.' : 'Do NOT manually switch branches or modify the worktree configuration.'}+**Important**: ${worktreeCommitNote} ${[COMPLETION_MODES.RELEASE_FLOW, COMPLETION_MODES.AUDIT_FLOW].includes(completionMode) ? 'Follow the bundled workflow branch instructions while preserving unrelated work.' : 'Do NOT manually switch branches or modify the worktree configuration.'}${buildResumeSection(task, worktreeInfo)}` : '';const simplifySection = buildSimplifySection({@@ -606,6 +607,7 @@ ${buildResumeSection(task, worktreeInfo)}` : '';isTui, sentinelPath, reviewersCsv: claimReviewersCsv(task, codeReviewDefaults, defaultReviewers),leavePrOpen: resolvePrCompletion(task.metadata) === PR_COMPLETIONS.LEAVE_OPEN || leavesPrForHuman(task),}),+ [COMPLETION_MODES.AUDIT_FLOW]: () => buildAuditFlowCompletionSection({ isTui, sentinelPath }),[COMPLETION_MODES.RELEASE_FLOW]: () => buildReleaseFlowCompletionSection({ isTui, sentinelPath }),[COMPLETION_MODES.TUI_SLASHDO_FREE]: buildFullPathTuiCompletion,[COMPLETION_MODES.TUI]: buildFullPathTuiCompletion,@@ -716,7 +718,7 @@ function buildSimplifySection({? 'run `/simplify` to review the changed code for reuse, quality, and efficiency': SIMPLIFY_INLINE_REVIEW;// Discard tasks don't commit, so the simplify-before-commit step is moot.- const simplifySection = mode !== COMPLETION_MODES.RELEASE_FLOW && simplifyEnabled && !isTui && !discardWorktree && !claimFlow ? `+ const simplifySection = ![COMPLETION_MODES.RELEASE_FLOW, COMPLETION_MODES.AUDIT_FLOW].includes(mode) && simplifyEnabled && !isTui && !discardWorktree && !claimFlow ? `## Simplify StepAfter completing your work and before committing, ${simplifyInstruction}. Fix any issues found, then ${worktreeInfo && willOpenPR ? 'commit your changes (do NOT push — on a successful run the system will push and open the PR after you exit; if the run fails, no push or PR happens)' : portosMergesBranch ? 'commit your changes (do NOT push — PortOS merges this branch back into the source checkout after you exit; a pushed copy would only be left behind on origin)' : 'commit and push using `/do:push`'}.` : '';@@ -1022,7 +1024,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet// a JIRA run be told to open a PR whose merge section was suppressed — and// PortOS opened that PR too. `inlineSection` also names WHICH section follows,// so the completion step's cross-reference can't name the wrong one.- const inlineSection = claimFlow || completionMode === COMPLETION_MODES.RELEASE_FLOW ? null : inlinePrLifecycleSection(task, {+ const inlineSection = claimFlow || [COMPLETION_MODES.RELEASE_FLOW, COMPLETION_MODES.AUDIT_FLOW].includes(completionMode) ? null : inlinePrLifecycleSection(task, {providerType: isTui ? PROVIDER_TYPES.TUI : PROVIDER_TYPES.CLI,providerId, providerCommand, leanMode, worktreeInfo, isTruthyMetaFn,});@@ -1154,6 +1156,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet...buildSentinelWriteSteps(1, lightSentinelPath(), sentinelTail)].join('\n'));},+ [COMPLETION_MODES.AUDIT_FLOW]: () => contractSections.push(buildAuditFlowCompletionSection({ isTui, sentinelPath: lightSentinelPath() })),[COMPLETION_MODES.RELEASE_FLOW]: () => contractSections.push(buildReleaseFlowCompletionSection({ isTui, sentinelPath: lightSentinelPath() })),[COMPLETION_MODES.TUI_SLASHDO_FREE]: pushTuiCompletion,[COMPLETION_MODES.TUI]: pushTuiCompletion,@@ -1217,8 +1220,8 @@ function buildLightTaskContextSections({worktreeInfo.baseBranch ? `- **Based on**: \`${worktreeInfo.baseBranch}\`` : null,'',worktreeCommitGuidance({ isTui, mode, canTypeSlashCommands, rendersInlinePrLifecycle, isWorktreeOnExistingBranch, willOpenPR, discardWorktree, claimFlow, noChangeSuccess }),- mode === COMPLETION_MODES.RELEASE_FLOW- ? 'Follow the release workflow branch instructions while preserving unrelated work.'+ [COMPLETION_MODES.RELEASE_FLOW, COMPLETION_MODES.AUDIT_FLOW].includes(mode)+ ? 'Follow the bundled workflow branch instructions while preserving unrelated work.': 'Do NOT manually switch branches or modify the worktree configuration.',// Resuming a previous failed agent's branch: establish what's already done// before writing code (see buildResumeSection). '' when not a resume.diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex a27291bcdf..872f6a26ec 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -3465,6 +3465,35 @@ describe('buildAgentPrompt — slashdo-backed tasks', () => {if (providerType === 'tui') expect(prompt).toContain('.agent-done-release-test');});+ // Regression: overview Better runs previously received commit-only handoffs,+ // leaving their self-managed audit worktrees unpublished on Codex hosts.+ describe.each(['better', 'better-swift'])('%s delivery', (command) => {+ it.each([+ ['tui', 'codex-tui', 'codex'],+ ['cli', 'codex', 'codex'],+ ['tui', 'claude-code-tui', 'claude'],+ ['api', 'test-api', null],+ ])('owns publication on %s/%s', async (providerType, providerId, providerCommand) => {+ vi.mocked(loadSlashdoFile).mockResolvedValue('# Better\n\nCanonical audit procedure.');+ const prompt = await buildAgentPrompt(+ makeTask({ metadata: sanitizeTaskMetadata({+ useWorktree: false, openPR: false, simplify: true,+ worktreeChangesExpected: true, slashdoCommand: command,+ }) }), {}, '/r', null, isTruthyMeta,+ { providerType, providerId, providerCommand, agentId: 'better-test' });+ expect(prompt).toContain('Canonical audit procedure.');+ expect(prompt).toContain('Better Workflow Handoff');+ expect(prompt).toContain('merge into the repository default branch');+ expect(prompt).toContain('current-head CI and configured reviews pass');+ expect(prompt).toContain('A clean audit needs no PR');+ expect(prompt).toContain('report INCOMPLETE');+ expect(prompt).not.toMatch(/Do NOT push|do NOT push|Commit only|commit only|PortOS will (?:push|merge)/);+ expect(prompt).not.toContain('## Completion Workflow');+ expect(prompt).not.toContain('## Simplify Step');+ if (providerType === 'tui') expect(prompt).toContain('.agent-done-better-test');+ });+ });+it('recovers the bundled release for an older queued task whose command was stripped', async () => {vi.mocked(loadSlashdoFile).mockResolvedValue('# Release\n\nCanonical release procedure.');const prompt = await buildAgentPrompt(diff --git a/server/services/promptSections/completion.js b/server/services/promptSections/completion.jsindex e59a105ed0..0687170e57 100644--- a/server/services/promptSections/completion.js+++ b/server/services/promptSections/completion.js@@ -21,6 +21,8 @@ function withNoChangeAuditGuidance(guidance, noChangeSuccess) {: guidance;}+const AUDIT_FLOW_GUIDANCE = 'Follow the bundled Better audit workflow through remediation, verification, PR publication, and cleanup. You own delivery: open the category PRs and merge into the repository default branch when current-head CI and configured reviews pass. If no external reviewers are configured, complete the internal review and merge after CI passes. This launch authorizes that merge by default; honor explicit --scan-only, --no-merge, and read-only constraints. Use plain git and the forge CLI when slash commands are unavailable. Do not stop at local commits or hand publication back to PortOS. A clean audit needs no PR. If any required gate is unavailable or fails, retain the work and report INCOMPLETE with the PR or branch and first unverified checkpoint.';+const RELEASE_FLOW_GUIDANCE = 'Follow the bundled release workflow through its final verification and report. It owns release delivery; do not stop at a prepared commit or hand publication back to PortOS. If it cannot complete, report INCOMPLETE and the first unverified checkpoint instead of claiming a successful release.';const REASONING_ONLY_BULLET = '**This is a reasoning-only task.** The worktree is discarded on exit — do NOT commit, push, merge, or open a PR. Write your result to the completion sentinel (see the Completion section) and stop.';@@ -78,6 +80,7 @@ export function buildCompletionGuidelineBullet({[COMPLETION_MODES.ACTION_OUTPUT]: () => '**This task produces no code output.** Its result is the API request or command your instructions describe (a PortOS endpoint call, a filed tracker issue, …) — do NOT run `/do:push`, `/do:pr`, `/simplify`, `git commit`, `git push`, or open a PR. Write the completion sentinel (see the Completion section) and stop.',[COMPLETION_MODES.DISCARD_WORKTREE]: () => REASONING_ONLY_BULLET,[COMPLETION_MODES.CLAIM_FLOW]: () => '**This is a self-managed claim flow.** Follow the claim prompt above through its phase-specific worktree, PR/MR, review, merge or human-handoff, and cleanup steps. Do NOT stop after committing or hand the lifecycle back to PortOS.',+ [COMPLETION_MODES.AUDIT_FLOW]: () => AUDIT_FLOW_GUIDANCE,[COMPLETION_MODES.RELEASE_FLOW]: () => RELEASE_FLOW_GUIDANCE,[COMPLETION_MODES.READ_ONLY]: () => '**This is a read-only task.** Do NOT commit, push, or modify any files in the repository. Only read data and generate reports.',// A PR follow-up already carries its own PRIMARY OBJECTIVE section with the@@ -122,6 +125,7 @@ const NO_COMMIT_TARGET_MODES = new Set([COMPLETION_MODES.DISCARD_WORKTREE,COMPLETION_MODES.CLAIM_FLOW,COMPLETION_MODES.RELEASE_FLOW,+ COMPLETION_MODES.AUDIT_FLOW,COMPLETION_MODES.READ_ONLY,]);@@ -183,6 +187,10 @@ export function buildFallbackCompletionInstructions({step4: 'Do NOT commit, push, or modify any files — this is a read-only task; read what you need and report your findings',gitHygiene: '- **Do NOT commit, push, or modify any files.** This is a read-only task — read what you need and report your findings.',}),+ [COMPLETION_MODES.AUDIT_FLOW]: () => ({+ step4: AUDIT_FLOW_GUIDANCE,+ gitHygiene: `- ${AUDIT_FLOW_GUIDANCE}`,+ }),[COMPLETION_MODES.RELEASE_FLOW]: () => ({step4: RELEASE_FLOW_GUIDANCE,gitHygiene: `- ${RELEASE_FLOW_GUIDANCE}`,@@ -393,6 +401,16 @@ export function buildReleaseFlowCompletionSection({ isTui = false, sentinelPathreturn lines.join('\n');}+/** Better owns publication; write the sentinel only after recording its final outcome. */+export function buildAuditFlowCompletionSection({ isTui = false, sentinelPath = null } = {}) {+ const lines = ['## Better Workflow Handoff', AUDIT_FLOW_GUIDANCE];+ if (isTui && sentinelPath) {+ lines.push('', 'After verification and delivery, write the outcome to the completion sentinel and stop:', '',+ ...buildSentinelWriteSteps(1, sentinelPath, ' ## Audit outcome\n <merged PR URLs, clean audit result, or INCOMPLETE with the retained branch and first unverified checkpoint>'));+ }+ return lines.join('\n');+}+/** Audit reports are a deliverable even when the run only files issues. */export function buildAuditOutputCompletionSection(task, sentinelPath) {const category = resolveTaskHookType(task);@@ -495,6 +513,7 @@ export function buildAutoMergeCommitStep(baseBranch = null) {* apart from their non-slashdo equivalents.*/export function worktreeCommitGuidance({ isTui, mode = null, canTypeSlashCommands = false, rendersInlinePrLifecycle = false, isWorktreeOnExistingBranch, willOpenPR, discardWorktree, claimFlow = false, noChangeSuccess = false }) {+ if (mode === COMPLETION_MODES.AUDIT_FLOW) return AUDIT_FLOW_GUIDANCE;if (mode === COMPLETION_MODES.RELEASE_FLOW) return RELEASE_FLOW_GUIDANCE;if (discardWorktree) return DISCARD_WORKTREE_NOTE;if (claimFlow) return 'The claim workflow in the Completion section owns the push, PR/MR, review, merge or human-handoff, and cleanup steps.';