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
refactor: pin OpenCode's agent vendor-wide and give the sentinel contract one seam
[._.]/ Adam Eivy7e3217b25da7
diff --git a/server/lib/cliProviderArgs.test.js b/server/lib/cliProviderArgs.test.jsindex efa6f450b7..f01f262c35 100644--- a/server/lib/cliProviderArgs.test.js+++ b/server/lib/cliProviderArgs.test.js@@ -73,13 +73,16 @@ describe('cliProviderArgs', () => {});});+ // Every OpenCode argv below ends in `--agent build`: OpenCode's role is argv+ // state, so an un-pinned invocation opens in whatever agent the install+ // defaults to (#7405). See ensureOpencodeAgent in providerVendors.js.describe('buildCliArgs — OpenCode Ollama', () => {it('runs `opencode run -m ollama/<model>` (prompt rides stdin)', () => {const args = buildCliArgs({id: 'opencode-ollama', command: 'opencode', args: ['run'],ollamaBacked: true, defaultModel: 'qwen2.5:7b',});- expect(args).toEqual(['run', '-m', 'ollama/qwen2.5:7b']);+ expect(args).toEqual(['run', '-m', 'ollama/qwen2.5:7b', '--agent', 'build']);});it('prepends the run subcommand when the saved args dropped it', () => {@@ -87,12 +90,12 @@ describe('cliProviderArgs', () => {id: 'opencode-ollama', command: 'opencode', args: [], ollamaBacked: true,defaultModel: 'qwen2.5:7b',});- expect(args).toEqual(['run', '-m', 'ollama/qwen2.5:7b']);+ expect(args).toEqual(['run', '-m', 'ollama/qwen2.5:7b', '--agent', 'build']);});it('omits -m when no model is configured (opencode falls back to its own default)', () => {const args = buildCliArgs({ id: 'opencode-ollama', command: 'opencode', args: ['run'], ollamaBacked: true, defaultModel: null });- expect(args).toEqual(['run']);+ expect(args).toEqual(['run', '--agent', 'build']);});it('respects a user-baked -m pin and skips injection', () => {@@ -100,7 +103,7 @@ describe('cliProviderArgs', () => {id: 'opencode-ollama', command: 'opencode', args: ['run', '-m', 'ollama/custom'], ollamaBacked: true,defaultModel: 'qwen2.5:7b',});- expect(args).toEqual(['run', '-m', 'ollama/custom']);+ expect(args).toEqual(['run', '-m', 'ollama/custom', '--agent', 'build']);});it('takes the opencode path for a path-configured binary (not the Claude fallback)', () => {@@ -108,7 +111,15 @@ describe('cliProviderArgs', () => {id: 'opencode-ollama', command: '/opt/homebrew/bin/opencode', args: ['run'], ollamaBacked: true,defaultModel: 'qwen2.5:7b',});- expect(args).toEqual(['run', '-m', 'ollama/qwen2.5:7b']);+ expect(args).toEqual(['run', '-m', 'ollama/qwen2.5:7b', '--agent', 'build']);+ });++ it('respects an agent the operator already pinned', () => {+ const args = buildCliArgs({+ id: 'opencode-ollama', command: 'opencode', args: ['run', '--agent', 'plan'],+ ollamaBacked: true, defaultModel: 'qwen2.5:7b',+ });+ expect(args).toEqual(['run', '--agent', 'plan', '-m', 'ollama/qwen2.5:7b']);});});@@ -329,7 +340,7 @@ describe('cliProviderArgs', () => {it('is a no-op for providers with no effort control', () => {expect(buildCliArgs({ id: 'opencode', command: 'opencode', defaultModel: 'qwen3', effort: 'high' }))- .toEqual(['run', '-m', 'qwen3']);+ .toEqual(['run', '-m', 'qwen3', '--agent', 'build']);expect(buildCliArgs({ id: 'grok-cli', command: 'grok', defaultModel: 'grok-4', effort: 'high' })).not.toContain('--effort');});diff --git a/server/lib/providerVendors.js b/server/lib/providerVendors.jsindex 067fdd0efe..3a38e2f857 100644--- a/server/lib/providerVendors.js+++ b/server/lib/providerVendors.js@@ -351,39 +351,36 @@ function appendOpencodeModel(args, provider, model) {const opencodeSpawnConfig = (provider, args) => ({ command: provider?.command || 'opencode', args, stdinMode: 'prompt' });-function opencodeCliArgs(baseArgs, { model, provider }) {- const args = baseArgs.includes('run') ? [...baseArgs] : ['run', ...baseArgs];- return appendOpencodeModel(args, provider, model);-}-/**- * Pin OpenCode's tool-enabled `build` agent on an ordinary interactive TUI- * session, unless the argv already selects one.+ * Pin OpenCode's tool-enabled `build` agent unless the argv already selects one.** Unlike every other vendor here, OpenCode's ROLE — not just its permissions —- * is argv/config state, and the seeded TUI provider records ship `args: []`.- * A bare `opencode` therefore opens in whatever agent that install defaults to- * (or last used), which is how a task-completion run came up as a read-only- * specialist and refused to write its own completion sentinel, asking a human- * that an unattended run has none of (#7405). The prompt cannot fix that: the- * host role outranks prompt text for a small local model, so the flag is the- * fix and the prompt's sentinel-write permission line is the belt.+ * is argv state, and the seeded records ship `args: []` (TUI) / `args: ["run"]`+ * (headless). A bare invocation therefore opens in whatever agent that install+ * defaults to, which is how a completion run came up as a read-only specialist+ * and refused to write its own sentinel (#7405 — the contract it could not+ * reconcile is `SENTINEL_WRITE_PERMISSION_NOTE` in promptSections/completion.js).+ * Argv, not `OPENCODE_CONFIG_CONTENT`: that env var is stripped for a+ * gateway-backed wrapper (`cliChildEnv.js`), and a `data.reference` seed edit+ * would never reach an install's already-stored record.*- * Idempotent, and scoped to the interactive path only: `applyCommandDefaults`- * is never reached by a public-review posture (its argv comes from- * `buildVendorSpawnConfig`), so pinning the tool-enabled agent here cannot- * widen the `--agent plan` recipe that hardens a public-content review.+ * Idempotent on `--agent`, which is what lets the public-review recipes keep+ * their `--agent plan` while sharing these builders.** @param {string[]} args* @returns {string[]}*/-function ensureOpencodeTuiArgs(args = []) {- const out = [...args];- // `--agent` is spelled the same on the bare TUI binary and on `opencode run`.- if (!argvHasFlag(out, ['--agent'])) out.push('--agent', OPENCODE_BUILD_AGENT);- return out;+const ensureOpencodeAgent = (args) =>+ argvHasFlag(args, ['--agent']) ? args : [...args, '--agent', OPENCODE_BUILD_AGENT];++function opencodeCliArgs(baseArgs, { model, provider }) {+ const args = baseArgs.includes('run') ? [...baseArgs] : ['run', ...baseArgs];+ return ensureOpencodeAgent(appendOpencodeModel(args, provider, model));}+/** `applyCommandDefaults` arm — both TUI spawn paths share it, so they can't drift. */+const ensureOpencodeTuiArgs = (args = []) => ensureOpencodeAgent([...args]);+/*** An OpenCode wrapper this install can actually run the tool-free gate on.* Three conditions, each closing a different way the stage would otherwise bediff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.jsindex cebac4c17b..3e3a7a37ad 100644--- a/server/lib/tuiHandshake.test.js+++ b/server/lib/tuiHandshake.test.js@@ -648,14 +648,9 @@ describe('tuiHandshake.applyCommandDefaults', () => {expect(applyCommandDefaults('kimi', ['-y'])).toEqual(['-y']);});- // #7405: the seeded OpenCode TUI records ship `args: []`, so a bare- // `opencode` opened in whatever agent that install defaults to. A- // task-completion run came up as a read-only specialist and refused to write- // its own completion sentinel, stalling an unattended run on a question.- it('pins the tool-enabled OpenCode agent on an interactive session', () => {- expect(applyCommandDefaults('opencode', [])).toEqual(['--agent', 'build']);- });-+ // The bare-argv case is asserted by the catalog-derived parity guard below+ // (BUILDER_POSTURE_EXEMPTIONS); these two cover what it does not. Why the+ // pin exists at all: ensureOpencodeAgent in providerVendors.js (#7405).it('respects an OpenCode agent the operator already pinned, in either flag form', () => {expect(applyCommandDefaults('opencode', ['--agent', 'plan'])).toEqual(['--agent', 'plan']);expect(applyCommandDefaults('opencode', ['--agent=plan'])).toEqual(['--agent=plan']);@@ -1526,10 +1521,12 @@ describe('tuiHandshake — parity with the shipped provider catalog', () => {const PROCESS_TYPES = new Set(['tui', 'cli']);const withDeclaredCommand = seedProviders.filter((p) => PROCESS_TYPES.has(p.type) && Boolean(p.command));- // Commands `applyCommandDefaults` deliberately has NO arm for, and where the- // unattended-run posture actually comes from. Both are asserted below, so an- // exemption can't rot into "we just forgot this vendor":- // - the builder must still inject nothing for it, and+ // Commands whose unattended-run POSTURE does not come from+ // `applyCommandDefaults`, and where it comes from instead. Both are asserted+ // below, so an exemption can't rot into "we just forgot this vendor":+ // - the builder must inject exactly what the entry declares (`builderInjects`,+ // default nothing — an arm may still inject something that is not a+ // posture, which is why this is a declaration rather than "injects nothing"), and// - the recorded alternate channel must still carry the posture in the seed.// A vendor absent from BOTH this map and `applyCommandDefaults` fails.//@@ -1537,14 +1534,12 @@ describe('tuiHandshake — parity with the shipped provider catalog', () => {// unattended posture at all — it must carry a `reason`, so the next vendor// resolves this by making a documented call rather than inventing a marker// string to satisfy the assertion.- const POSTURE_NOT_FROM_BUILDER = new Map([+ const BUILDER_POSTURE_EXEMPTIONS = new Map([// claude's `--dangerously-skip-permissions` rides in the seed `args`.['claude', { channel: 'args', marker: '--dangerously-skip-permissions' }],// opencode has no argv approval/trust gate; its permission posture is- // configured through OPENCODE_CONFIG_CONTENT (see cliChildEnv.js). Its- // builder arm injects a ROLE rather than a posture — `--agent build` pins- // the tool-enabled agent so a bare session cannot open as OpenCode's- // read-only one and refuse to write its own completion sentinel (#7405).+ // configured through OPENCODE_CONFIG_CONTENT (see cliChildEnv.js). Its arm+ // injects a ROLE, not a posture — see ensureOpencodeAgent (#7405).['opencode', { channel: 'envVars', marker: '"permission":"allow"', builderInjects: ['--agent', 'build'] }],]);@@ -1577,13 +1572,9 @@ describe('tuiHandshake — parity with the shipped provider catalog', () => {// with no arm falls through `return args` unchanged and launches interactive,// then stalls on its first tool-approval prompt with nobody at the keyboard.describe.each(tuiCommands)('applyCommandDefaults("%s")', (command) => {- const exemption = POSTURE_NOT_FROM_BUILDER.get(command);+ const exemption = BUILDER_POSTURE_EXEMPTIONS.get(command);if (exemption) {- // An exempt vendor's POSTURE comes from another channel, but its arm may- // still inject something else (opencode's agent-role pin). Whatever that- // is must be declared here, so the assertion stays exact and a new,- // undeclared injection still fails.it('injects only what its exemption declares (its posture comes from another channel)', () => {expect(applyCommandDefaults(command, [])).toEqual(exemption.builderInjects || []);});@@ -1615,7 +1606,7 @@ describe('tuiHandshake — parity with the shipped provider catalog', () => {expect(applyCommandDefaults(command, []),`No applyCommandDefaults arm for "${command}". Add one (see ensureCursorTuiArgs), `- + 'or record why its posture arrives another way in POSTURE_NOT_FROM_BUILDER.'+ + 'or record why its posture arrives another way in BUILDER_POSTURE_EXEMPTIONS.').not.toEqual([]);});}diff --git a/server/services/agentCliSpawning.test.js b/server/services/agentCliSpawning.test.jsindex 12f1e69dcf..8173e3e9c6 100644--- a/server/services/agentCliSpawning.test.js+++ b/server/services/agentCliSpawning.test.js@@ -200,6 +200,10 @@ describe('buildCliSpawnConfig', () => {expect(config.args[config.args.length - 1]).toBe('--print');});+ // The trailing `--agent build` on every OpenCode argv below pins the+ // tool-enabled agent: OpenCode's role is argv state, so an un-pinned+ // invocation opens in whatever agent the install defaults to (#7405). See+ // ensureOpencodeAgent in lib/providerVendors.js.it('runs `opencode run -m ollama/<model>` for a headless OpenCode Ollama agent', () => {const config = buildCliSpawnConfig({ id: 'opencode-ollama', command: 'opencode', args: ['run'], ollamaBacked: true },@@ -207,7 +211,7 @@ describe('buildCliSpawnConfig', () => {);expect(config.command).toBe('opencode');- expect(config.args).toEqual(['run', '-m', 'ollama/qwen2.5:7b']);+ expect(config.args).toEqual(['run', '-m', 'ollama/qwen2.5:7b', '--agent', 'build']);expect(config.stdinMode).toBe('prompt');// OpenCode emits plain text, so no stream-json format is requested.expect(config.streamFormat).toBeUndefined();@@ -220,14 +224,14 @@ describe('buildCliSpawnConfig', () => {);expect(config.command).toBe('opencode');- expect(config.args).toEqual(['run', '-m', 'mtplx/mtplx']);+ expect(config.args).toEqual(['run', '-m', 'mtplx/mtplx', '--agent', 'build']);expect(config.stdinMode).toBe('prompt');});it('prepends the run subcommand for OpenCode even if saved args dropped it', () => {const config = buildCliSpawnConfig({ id: 'opencode-ollama', command: 'opencode', args: [], ollamaBacked: true }, 'qwen2.5:7b');- expect(config.args).toEqual(['run', '-m', 'ollama/qwen2.5:7b']);+ expect(config.args).toEqual(['run', '-m', 'ollama/qwen2.5:7b', '--agent', 'build']);});it('respects a user-baked -m pin on an OpenCode provider and does not duplicate it', () => {@@ -236,7 +240,7 @@ describe('buildCliSpawnConfig', () => {'qwen2.5:7b',);- expect(config.args).toEqual(['run', '-m', 'ollama/custom']);+ expect(config.args).toEqual(['run', '-m', 'ollama/custom', '--agent', 'build']);});it('runs `grok` headless with plain output, permission bypass, and stdin prompt file (no --model for configured-default)', () => {diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex fe60135c61..fdfc9dfc63 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -1793,12 +1793,12 @@ describe('buildLightContextPrompt', () => {expect(prompt).toMatch(/watches this sentinel/);});- // #7405 — an OpenCode MTPLX TUI task-completion run read its host's- // read-only role as covering the sentinel too ("the edits/sentinel can't- // happen here"), then went looking for the path in `runner-state.json` /- // `state.json` because a SIBLING run's agent id was visible in the shared- // checkout's branch state. It asked a human how to proceed and stalled: an- // unattended run has nobody to answer. Both halves are prompt contract.+ // #7405 — a run read its HOST's read-only role as covering the sentinel too+ // ("the edits/sentinel can't happen here"), then hunted for the path in+ // `runner-state.json` / `state.json` because a SIBLING run's agent id was+ // visible in the shared checkout's branch state. It stalled on a question+ // an unattended run has nobody to answer. The full account is on+ // SENTINEL_WRITE_PERMISSION_NOTE in promptSections/completion.js.describe('sentinel-write permission (#7405)', () => {const SENTINEL_PATH = '/shared-checkout/.agent-done-agent-07ddbb85';@@ -1816,16 +1816,27 @@ describe('buildLightContextPrompt', () => {// through state files instead of writing the file it was handed.expect([...new Set(prompt.match(/[\w/.-]*\.agent-done[\w.-]*/g))]).toEqual([SENTINEL_PATH]);expect(prompt).not.toMatch(/## Read-Only Task/);- expect(prompt).toMatch(/Writing that one file is ALWAYS permitted/);// No second place to look the path up.expect(prompt).toMatch(/Do NOT look one up in `runner-state\.json`, `state\.json`, a branch name, or a worktree name/);});- it('carves the sentinel out of the read-only do-not-modify rule', () => {- const prompt = completionPrompt({ readOnly: true });- expect(prompt).toMatch(/## Read-Only Task/);- // The banner and the sentinel instruction sit in the same section; a- // small local model read them as a contradiction and wrote nothing.+ // The boundary contract, not the section helper: every TUI task shape+ // that PRINTS a sentinel path must also say the write is permitted.+ // `buildAuditOutputCompletionSection` proves the hazard is real — it+ // interpolates a path and carries no note of its own, and is safe only+ // because it is appended after a section that does.+ it.each([+ ['plain completion', {}],+ ['read-only', { readOnly: true }],+ ['no-code / API action', { noCodeOutput: true }],+ ['reasoning-only worktree', { discardWorktree: true }],+ ['self-managed claim flow', { claimFlow: true }],+ ])('pairs the sentinel path with the write permission for a %s task', (_label, metadata) => {+ const prompt = completionPrompt(metadata);+ expect(prompt).toContain(SENTINEL_PATH);+ expect(prompt).toMatch(/Writing that one file is ALWAYS permitted/);+ // The carve-out has to name the rules it overrides, or a section whose+ // own banner forbids edits still reads as a contradiction.expect(prompt).toMatch(/no read-only, do-not-modify, or restricted-session rule applies to it/);});});diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.jsindex e358c7d010..8c873d7a24 100644--- a/server/services/agentTuiSpawning.js+++ b/server/services/agentTuiSpawning.js@@ -1152,6 +1152,10 @@ export async function spawnTuiAgent({// which can take seconds, and a host restart that begins in that window is// still an interruption rather than an outcome (#3202).const duration = Date.now() - (agentData?.startedAt || Date.now());+ // Read ONCE: the shared finalize decides the run's outcome from it and the+ // diagnostic below reports on it, and two reads could disagree about the+ // same run.+ const wroteSentinel = sentinelPresent();const finalizeOutcome = finalizeAgentRunCommon({agentId,agentData,@@ -1161,7 +1165,7 @@ export async function spawnTuiAgent({duration,executionId,laneName,- sentinelPresent: sentinelPresent(),+ sentinelPresent: wroteSentinel,errorExecutionFallback: `TUI agent ended: ${reason}`,});@@ -1175,14 +1179,18 @@ export async function spawnTuiAgent({const { finalSuccess, finalError, terminatedByUser } = finalizeOutcome;// Name the path the run was supposed to write when it ends without one.- // The sentinel is the PRIMARY finalize path, so reaching here without it- // means the run either died or talked itself out of the write — and the- // second shape is silent today: a model that decided its session was not- // allowed to write the file (#7405) leaves an ordinary "TUI agent ended"- // line and nothing an operator can grep for. Placed after the shared- // finalize, so the paused / host-abandoned / user-terminated paths (which- // legitimately produce no sentinel) have already returned or are excluded.- if (doneSentinelPath && !terminatedByUser && !sentinelPresent()) {+ // The sentinel is the PRIMARY finalize path for a TUI, so reaching here+ // without it means the run either died or talked itself out of the write —+ // and the second shape is otherwise silent, leaving an ordinary "TUI agent+ // ended" line and nothing an operator can grep for (#7405; the prompt-side+ // contract is SENTINEL_WRITE_PERMISSION_NOTE). Deliberately NOT gated on+ // `finalSuccess`: a run that stalls on a question is reaped as a failure,+ // which is exactly the case this exists to name. Placed after the shared+ // finalize, so the paused and host-abandoned paths have already returned+ // and only a user kill — a legitimate no-sentinel exit — needs excluding.+ // A CLI run is out of scope: it signals completion by exiting, so the same+ // warn in `agentRunFinalize` would fire on every headless run.+ if (doneSentinelPath && !terminatedByUser && !wroteSentinel) {emitLog('warn', `⚠️ ${agentId} finalized (${reason}) with no completion sentinel — expected ${doneSentinelPath}`, { agentId });}diff --git a/server/services/promptSections/completion.js b/server/services/promptSections/completion.jsindex 717bc19f8c..61286aac10 100644--- a/server/services/promptSections/completion.js+++ b/server/services/promptSections/completion.js@@ -26,18 +26,21 @@ const AUDIT_FLOW_GUIDANCE = 'Follow the bundled Better audit workflow through reconst 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.';/**- * Why a run that was told not to touch the repository may still write ONE file.+ * Why a run told not to touch the repository may still write ONE file — the+ * canonical account of #7405, which every other reference in the tree points at.*- * A completion sentinel is PortOS's done-signal, not a repository edit — but- * every section that emits one also carries a "do not modify anything" rule- * (read-only, reasoning-only, no-code-output), and the agent's HOST may hand it- * a restricted role on top of that. A small local model resolves the apparent- * conflict the safe way and writes nothing, then asks a human an unattended run- * does not have: an OpenCode MTPLX TUI run stalled exactly there, refusing the- * sentinel because "the current session is a read-only file-search specialist"- * (#7405). Stating the carve-out is what makes the write reachable.+ * A completion sentinel is PortOS's done-signal, not a repository edit, but+ * every section that emits one also carries a "do not modify anything" rule,+ * and the agent's HOST may hand it a restricted role on top of that. A small+ * local model resolves the apparent conflict the safe way and writes nothing,+ * then asks a human an unattended run does not have: an OpenCode MTPLX TUI run+ * stalled exactly there, refusing the sentinel because "the current session is+ * a read-only file-search specialist". (The role itself is pinned away at the+ * spawn site now — `ensureOpencodeAgent` in lib/providerVendors.js — so this+ * note is the belt, not the fix.) Stating the carve-out is what makes the write+ * reachable when some future host does the same thing.*- * The second sentence is the other half of that stall: the same run went+ * The second sentence answers the other half of that stall: the same run went* looking for its sentinel path in `runner-state.json` / `state.json` after* noticing a SIBLING run's agent id in the shared checkout's branch state, and* never wrote one. There is no such lookup — `doneSentinelPath(cwd, agentId)`@@ -47,6 +50,24 @@ const RELEASE_FLOW_GUIDANCE = 'Follow the bundled release workflow through its f*/export const SENTINEL_WRITE_PERMISSION_NOTE = 'Writing that one file is ALWAYS permitted, whatever the task shape or your host role says — it is PortOS\'s completion signal, not a repository edit, so no read-only, do-not-modify, or restricted-session rule applies to it. Use the sentinel path exactly as printed in this section: it is this run\'s only one. Do NOT look one up in `runner-state.json`, `state.json`, a branch name, or a worktree name, and do NOT treat another agent id in this workspace as a conflict — the filename already scopes the sentinel to you.';+/**+ * The closing sentence every sentinel-emitting section shares: PortOS is+ * already watching, so the write IS the handoff and nothing follows it.+ */+const SENTINEL_WATCH_TAIL = 'PortOS watches this sentinel and finalizes the run shortly after it appears — do NOT run `/quit` and do NOT wait for anything after writing the sentinel.';++/**+ * One sentinel-emitting completion section: the mode's own notice, its write+ * instruction, the shared watch tail, and the write-permission note.+ *+ * The three sections below used to assemble this shape by hand with the tail+ * typed out three times — which is how the permission note would have become a+ * per-section splice the next mode had to remember. Composing it here keeps+ * "prints a sentinel path" and "says the write is permitted" one fact.+ */+const sentinelCompletionSection = (notice, writeInstruction) =>+ [notice, '', `${writeInstruction} ${SENTINEL_WATCH_TAIL}`, '', SENTINEL_WRITE_PERMISSION_NOTE].join('\n');+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.';const DISCARD_WORKTREE_HYGIENE = '- **Do NOT commit, push, or open a PR.** This worktree is discarded on exit — your only output is the completion sentinel (see the Completion section above).';@@ -361,15 +382,11 @@ export function buildToolFreeReasoningCompletionSection() {* a markdown summary (breaking the hook's structured-JSON sentinel contract).*/export function buildProgrammaticOutputCompletionSection(sentinelPath) {- return [+ return sentinelCompletionSection(// Shared constant: a pre-spawn task-type hook's prompt points here BY NAME.- `## ${PROGRAMMATIC_OUTPUT_COMPLETION_HEADING}`,- 'This is a reasoning task, not a code change. The worktree you are in is **discarded on exit** — any commits, pushes, or PRs are thrown away and have no effect. Do NOT run `/do:push`, `/do:pr`, `git commit`, `git push`, or open a pull request.',- '',- `When you have finished reasoning, write your result to \`${sentinelPath}\` in the exact payload format described in your task instructions, then stop. PortOS watches this sentinel and finalizes the run shortly after it appears — do NOT run \`/quit\` and do NOT wait for anything after writing the sentinel.`,- '',- SENTINEL_WRITE_PERMISSION_NOTE- ].join('\n');+ `## ${PROGRAMMATIC_OUTPUT_COMPLETION_HEADING}\nThis is a reasoning task, not a code change. The worktree you are in is **discarded on exit** — any commits, pushes, or PRs are thrown away and have no effect. Do NOT run \`/do:push\`, \`/do:pr\`, \`git commit\`, \`git push\`, or open a pull request.`,+ `When you have finished reasoning, write your result to \`${sentinelPath}\` in the exact payload format described in your task instructions, then stop.`+ );}/**@@ -387,13 +404,10 @@ export function buildProgrammaticOutputCompletionSection(sentinelPath) {export function buildReadOnlyCompletionSection({ isTui = false, sentinelPath = null } = {}) {const notice = '## Read-Only Task\nDo NOT commit, push, or modify any files in the repository. Read data and report findings only.';if (!isTui || !sentinelPath) return notice;- return [+ return sentinelCompletionSection(notice,- '',- `When you have finished, write a short markdown summary of what you found (and where you recorded it) to \`${sentinelPath}\`, then stop. PortOS watches this sentinel and finalizes the run shortly after it appears — do NOT run \`/quit\` and do NOT wait for anything after writing the sentinel.`,- '',- SENTINEL_WRITE_PERMISSION_NOTE- ].join('\n');+ `When you have finished, write a short markdown summary of what you found (and where you recorded it) to \`${sentinelPath}\`, then stop.`+ );}/**@@ -410,13 +424,10 @@ export function buildReadOnlyCompletionSection({ isTui = false, sentinelPath = nexport function buildActionOutputCompletionSection({ isTui = false, sentinelPath = null } = {}) {const notice = '## Completion (No Code Output)\nThis task produces **no code change** — its result is delivered DURING the run by the API request or command your instructions describe (a PATCH to a PortOS endpoint, a filed tracker issue, …), not by a commit and not by this sentinel. Do NOT run `/do:push`, `/do:pr`, `/simplify`, `git commit`, `git push`, or open a pull request; there is nothing to push.';if (!isTui || !sentinelPath) return notice;- return [+ return sentinelCompletionSection(notice,- '',- `Your task is complete once that request succeeds. Then write a short summary, including any structured report required by your task, to \`${sentinelPath}\` and stop — PortOS watches this sentinel and finalizes the run shortly after it appears. Do NOT run \`/quit\` and do NOT wait for anything after writing the sentinel.`,- '',- SENTINEL_WRITE_PERMISSION_NOTE- ].join('\n');+ `Your task is complete once that request succeeds. Then write a short summary, including any structured report required by your task, to \`${sentinelPath}\` and stop.`+ );}/** The release procedure is the deliverable; the sentinel only records its verified outcome. */