Skip to content

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

address review (claude): pin api-path Target App suppression via buildPrompt call args

[._.]/ Adam Eivy1dca70ec066e
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index 5c8b5a0576..cbbe274e3a 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -56,6 +56,7 @@ tryReadFile: vi.fn().mockResolvedValue(null),
}));
import { buildLightContextPrompt, buildAgentPrompt, buildCompletionGuidelineBullet } from './agentPromptBuilder.js';
+import { buildPrompt } from './promptService.js';
import { isTruthyMeta } from './agentState.js';
function makeTask(overrides = {}) {
@@ -675,6 +676,31 @@ describe('buildAgentPrompt — provider type routing', () => {
expect(prompt).toMatch(/^## Completion$/m);
});
+ // The api/full path renders "### Target Application" from the cos-agent-briefing
+ // template's {{#task.metadata.app}} section, so the app is suppressed by stripping
+ // it from the task handed to buildPrompt (rather than by buildTaskBlock). Assert on
+ // the mocked buildPrompt's call args since the template render itself is mocked out.
+ describe('api-path Target Application suppression', () => {
+ const apiOpts = { providerType: 'api' };
+ const wt = { branchName: 'b', worktreePath: '/tmp/wt' };
+
+ it('strips the PortOS default app from the template task so its section stays empty', async () => {
+ buildPrompt.mockClear();
+ await buildAgentPrompt(
+ makeTask({ metadata: { app: 'portos-default' } }), {}, '/r', wt, isTruthyMeta, apiOpts);
+ const briefing = buildPrompt.mock.calls.find(([name]) => name === 'cos-agent-briefing');
+ expect(briefing?.[1]?.task?.metadata?.app).toBeUndefined();
+ });
+
+ it('keeps a managed app on the template task so it scopes the work', async () => {
+ buildPrompt.mockClear();
+ await buildAgentPrompt(
+ makeTask({ metadata: { app: 'comics' } }), {}, '/r', wt, isTruthyMeta, apiOpts);
+ const briefing = buildPrompt.mock.calls.find(([name]) => name === 'cos-agent-briefing');
+ expect(briefing?.[1]?.task?.metadata?.app).toBe('comics');
+ });
+ });
+
describe('split system/user prompt (Claude providers)', () => {
const wt = { branchName: 'cos/t/a', worktreePath: '/tmp/wt', baseBranch: 'main' };
const splitTask = () => makeTask({ metadata: { context: 'Some context', openPR: false } });