feat: cw task add CLI command + {AGENT_ID} prompt placeholder
- Add `createTaskForAgent` tRPC mutation: resolves agent → task → phase, creates sibling task
- Add `cw task add <name> --agent-id <id>` CLI command
- Replace `{AGENT_ID}` and `{AGENT_NAME}` placeholders in writeInputFiles() before flushing
- Update docs/agent.md and docs/cli-config.md
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
requirePhaseRepository,
|
||||
requireDispatchManager,
|
||||
requireChangeSetRepository,
|
||||
requireAgentManager,
|
||||
} from './_helpers.js';
|
||||
|
||||
export function taskProcedures(publicProcedure: ProcedureBuilder) {
|
||||
@@ -213,5 +214,55 @@ export function taskProcedures(publicProcedure: ProcedureBuilder) {
|
||||
return edges;
|
||||
}),
|
||||
|
||||
createTaskForAgent: publicProcedure
|
||||
.input(z.object({
|
||||
agentId: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
description: z.string().optional(),
|
||||
category: z.enum(['execute', 'research', 'discuss', 'plan', 'detail', 'refine', 'verify', 'merge', 'review']).optional(),
|
||||
}))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const agentManager = requireAgentManager(ctx);
|
||||
const taskRepository = requireTaskRepository(ctx);
|
||||
|
||||
const agent = await agentManager.get(input.agentId);
|
||||
if (!agent) {
|
||||
throw new TRPCError({
|
||||
code: 'NOT_FOUND',
|
||||
message: `Agent '${input.agentId}' not found`,
|
||||
});
|
||||
}
|
||||
if (!agent.taskId) {
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: `Agent '${agent.name}' has no assigned task`,
|
||||
});
|
||||
}
|
||||
|
||||
const agentTask = await taskRepository.findById(agent.taskId);
|
||||
if (!agentTask) {
|
||||
throw new TRPCError({
|
||||
code: 'NOT_FOUND',
|
||||
message: `Agent's task '${agent.taskId}' not found`,
|
||||
});
|
||||
}
|
||||
if (!agentTask.phaseId) {
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: `Agent's task has no phase — cannot create sibling task`,
|
||||
});
|
||||
}
|
||||
|
||||
return taskRepository.create({
|
||||
phaseId: agentTask.phaseId,
|
||||
initiativeId: agentTask.initiativeId,
|
||||
name: input.name,
|
||||
description: input.description ?? null,
|
||||
category: input.category ?? 'execute',
|
||||
type: 'auto',
|
||||
status: 'pending',
|
||||
});
|
||||
}),
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user