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
suppress redundant Target App line for the PortOS default app in agent prompts
[._.]/ Adam Eivy3c08d12ca226
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 93f71942cf..181958ab4a 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -22,6 +22,7 @@ import { isOpencodeCommand } from '../lib/providerModels.js';import { shellQuote } from '../lib/shellQuote.js';import * as jiraService from './jira.js';import { emitLog } from './cosEvents.js';+import { PORTOS_APP_ID } from './apps.js';const ROOT_DIR = PATHS.root;const AGENTS_DIR = PATHS.cosAgents;@@ -213,7 +214,11 @@ function renderFileListField(header, items, formatItem, formatInline, asList) {*/export function buildTaskBlock(task, { screenshotsAsList = false } = {}) {const description = task.description;- const targetApp = task.metadata?.app ? `**Target App**: ${task.metadata.app}` : '';+ // Only surface **Target App** for MANAGED apps — it scopes cross-repo work the+ // agent's cwd wouldn't otherwise reveal. For the PortOS default app the agent+ // already runs in the PortOS directory, so the line is redundant noise.+ const app = task.metadata?.app;+ const targetApp = app && app !== PORTOS_APP_ID ? `**Target App**: ${app}` : '';const screenshots = renderFileListField('Screenshots', task.metadata?.screenshots,(s) => `\`${s}\``, (s) => s, screenshotsAsList@@ -723,8 +728,15 @@ ${task.metadata.jiraBranch ? 'Commit your changes to this branch. Do NOT switch// predates the {{reviewLoopFollowUpSection}} placeholder; the built-in// fallback is the source of truth for that section, and silently dropping// it would leave the agent with no instructions and the loop would not run.+ // The template renders `### Target Application` from `task.metadata.app`. Drop+ // the app for the PortOS default so that section stays empty — the api agent+ // already runs in the PortOS directory, matching buildTaskBlock's behavior for+ // the light/fallback paths. Managed-app tasks keep the scoping line.+ const templateTask = task.metadata?.app === PORTOS_APP_ID+ ? { ...task, metadata: { ...task.metadata, app: undefined } }+ : task;const promptData = isReviewLoopFollowUp ? null : await buildPrompt('cos-agent-briefing', {- task,+ task: templateTask,config,memorySection,claudeMdSection,@@ -896,8 +908,10 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet// --- Task block --------------------------------------------------------// cwd is set by the spawner and the agent knows its own id from the- // runner, so the prompt skips that metadata. Target app is kept because- // it scopes managed-app work. Shared with the full path via buildTaskBlock.+ // runner, so the prompt skips that metadata. Target app is kept only for+ // MANAGED apps because it scopes cross-repo work; the PortOS default app is+ // suppressed in buildTaskBlock since cwd already reveals it. Shared with the+ // full path via buildTaskBlock.const taskBlock = buildTaskBlock(task, { screenshotsAsList: true });sections.push(taskBlock.description);if (taskBlock.targetApp) sections.push(taskBlock.targetApp);diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex ccea9a5212..5c8b5a0576 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -110,13 +110,20 @@ describe('buildLightContextPrompt', () => {expect(prompt).not.toMatch(/\*\*Working Directory\*\*:/);});- it('shows Target App when set', () => {+ it('shows Target App for a managed app', () => {const prompt = buildLightContextPrompt(makeTask({ metadata: { app: 'comics' } }),'/r', null, isTruthyMeta);expect(prompt).toMatch(/\*\*Target App\*\*: comics/);});+ it('omits Target App for the PortOS default app (cwd already scopes it)', () => {+ const prompt = buildLightContextPrompt(+ makeTask({ metadata: { app: 'portos-default' } }),+ '/r', null, isTruthyMeta);+ expect(prompt).not.toMatch(/\*\*Target App\*\*/);+ });+it('renders attached context (multiline and single-line)', () => {const single = buildLightContextPrompt(makeTask({ metadata: { context: 'one-liner' } }), '/r', null, isTruthyMeta);