feat(12-05): add spawnArchitectDecompose tRPC procedure

- Import buildDecomposePrompt from agent prompts
- Add spawnArchitectDecompose procedure for decompose mode
- Validates plan and phase exist before spawning
- Spawns agent with decompose mode and comprehensive prompt
This commit is contained in:
Lukas May
2026-02-01 11:50:35 +01:00
parent 7ff979becf
commit 1fcbdf5e10

View File

@@ -17,7 +17,7 @@ import type { PlanRepository } from '../db/repositories/plan-repository.js';
import type { DispatchManager } from '../dispatch/types.js';
import type { CoordinationManager } from '../coordination/types.js';
import type { Phase, Plan, Task } from '../db/schema.js';
import { buildDiscussPrompt, buildBreakdownPrompt } from '../agent/prompts.js';
import { buildDiscussPrompt, buildBreakdownPrompt, buildDecomposePrompt } from '../agent/prompts.js';
/**
* Initialize tRPC with our context type.
@@ -1056,6 +1056,49 @@ export const appRouter = router({
mode: 'breakdown',
});
}),
/**
* Spawn architect in decompose mode.
* Uses comprehensive decompose prompt to break a plan into executable tasks.
*/
spawnArchitectDecompose: publicProcedure
.input(z.object({
name: z.string().min(1),
planId: z.string().min(1),
context: z.string().optional(),
}))
.mutation(async ({ ctx, input }) => {
const agentManager = requireAgentManager(ctx);
const planRepo = requirePlanRepository(ctx);
const phaseRepo = requirePhaseRepository(ctx);
// 1. Get plan and its phase
const plan = await planRepo.findById(input.planId);
if (!plan) {
throw new TRPCError({
code: 'NOT_FOUND',
message: `Plan '${input.planId}' not found`,
});
}
const phase = await phaseRepo.findById(plan.phaseId);
if (!phase) {
throw new TRPCError({
code: 'NOT_FOUND',
message: `Phase '${plan.phaseId}' not found`,
});
}
// 2. Build decompose prompt
const prompt = buildDecomposePrompt(plan, phase, input.context);
// 3. Spawn agent in decompose mode
return agentManager.spawn({
name: input.name,
taskId: input.planId, // Associate with plan
prompt,
mode: 'decompose',
});
}),
});
/**