feat: wire story-promotion into update_task_status + filter done stories from get_claude_context

update_task_status now delegates to updateTaskStatusWithStoryPromotion
and surfaces story_status_change ('promoted' | 'demoted' | null) in the
response so Claude Code can act on story completion without a separate
read call.

get_claude_context adds an OR-filter on tasks so stories where every
task is DONE are skipped — only surfaces stories that still have work to
do (no tasks, or at least one non-DONE task).
This commit is contained in:
Janpeter Visser 2026-04-30 18:22:47 +02:00
parent 7425584921
commit e2c86eb4d9
2 changed files with 10 additions and 6 deletions

View file

@ -58,6 +58,10 @@ export function registerGetClaudeContextTool(server: McpServer) {
where: {
sprint_id: activeSprint.id,
status: { in: ['OPEN', 'IN_SPRINT'] },
OR: [
{ tasks: { none: {} } },
{ tasks: { some: { status: { not: 'DONE' } } } },
],
},
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
select: {

View file

@ -1,10 +1,10 @@
import { z } from 'zod'
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { prisma } from '../prisma.js'
import { requireWriteAccess } from '../auth.js'
import { userCanAccessTask } from '../access.js'
import { toolError, toolJson, withToolErrors } from '../errors.js'
import { TASK_STATUS_API_VALUES, taskStatusFromApi, taskStatusToApi } from '../status.js'
import { updateTaskStatusWithStoryPromotion } from '../lib/tasks-status-update.js'
const inputSchema = z.object({
task_id: z.string().min(1),
@ -31,15 +31,15 @@ export function registerUpdateTaskStatusTool(server: McpServer) {
if (!(await userCanAccessTask(task_id, auth.userId))) {
return toolError(`Task ${task_id} not found or not accessible`)
}
const task = await prisma.task.update({
where: { id: task_id },
data: { status: dbStatus },
select: { id: true, status: true, implementation_plan: true },
})
const { task, storyStatusChange } = await updateTaskStatusWithStoryPromotion(
task_id,
dbStatus,
)
return toolJson({
id: task.id,
status: taskStatusToApi(task.status),
implementation_plan: task.implementation_plan,
story_status_change: storyStatusChange,
})
}),
)