From f27f22a75f4724f7b115c0581d0cb0f6f64d4c75 Mon Sep 17 00:00:00 2001 From: "i.seliverstov" Date: Sun, 11 Oct 2026 22:46:31 +0500 Subject: [PATCH 1/2] feat(mcp): create edit and delete epics and stories --- alfy-mcp/README.md | 3 + alfy-mcp/src/server.ts | 2 + alfy-mcp/src/tools/project-groups.ts | 51 +++++++++++ alfy-mcp/tests/tools/project-groups.spec.ts | 93 +++++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 alfy-mcp/src/tools/project-groups.ts create mode 100644 alfy-mcp/tests/tools/project-groups.spec.ts diff --git a/alfy-mcp/README.md b/alfy-mcp/README.md index f277e44..0809e58 100644 --- a/alfy-mcp/README.md +++ b/alfy-mcp/README.md @@ -122,6 +122,9 @@ read -rs ALFY_MCP_TOKEN - `complete_sprint` — `id` и обязательный `moveTo`: `backlog` либо UUID запланированного спринта. Незавершённые задачи и открытые истории переносятся; выполненные задачи остаются в закрытом спринте. - `delete_sprint` — `id` и `confirm: true`. Задачи и истории сохраняются, назначение удалённого спринта очищается. - `list_project_groups` — дерево эпиков и историй с UUID и назначениями спринтов/релизов. +- `create_project_group` — `title` и необязательные `description`, `color`, `parentId`: без родителя создаёт эпик, с UUID эпика — историю. Даты `startDate` и `dueDate` (`YYYY-MM-DD`) доступны только эпикам. +- `update_project_group` — `id` и изменяемые поля: название, описание, цвет, статус `open`/`done`, даты эпика, `parentId` для смены эпика истории. Пропущенные поля сохраняются; `null` очищает описание, цвет или дату, но не родителя. Статус группы не меняет статусы задач. +- `delete_project_group` — `id` и `confirm: true`. Удаление эпика удаляет его истории; задачи сохраняются без привязки к удалённым группам. - `move_story_to_sprint` — `storyId` и обязательный `sprintId`: UUID незакрытого спринта этого проекта либо `null` для бэклога. Перенос истории и её задач атомарен; задачи закрытых спринтов сохраняются. Ответ `{ updated: number }` содержит число перенесённых задач, включая скрытые выполненные. Пустую историю тоже можно перенести. Например, после `list_project_groups` перенести выбранную историю и её задачи можно вызовом `move_story_to_sprint({ projectId, storyId, sprintId })`. Отдельную задачу переносят через `update_task({ id, sprintId })`. diff --git a/alfy-mcp/src/server.ts b/alfy-mcp/src/server.ts index 06f16fc..dcb3e8c 100644 --- a/alfy-mcp/src/server.ts +++ b/alfy-mcp/src/server.ts @@ -5,6 +5,7 @@ import { registerTaskTools } from './tools/tasks.js'; import { registerQuestionTools } from './tools/questions.js'; import { registerProgressTools } from './tools/progress.js'; import { registerProjectTools } from './tools/projects.js'; +import { registerProjectGroupTools } from './tools/project-groups.js'; import { registerSprintTools } from './tools/sprints.js'; /** @@ -23,6 +24,7 @@ export function createServer(client: AlfyRestClient): McpServer { registerProgressTools(server, client); registerProjectTools(server, client); registerSprintTools(server, client); + registerProjectGroupTools(server, client); return server; } diff --git a/alfy-mcp/src/tools/project-groups.ts b/alfy-mcp/src/tools/project-groups.ts new file mode 100644 index 0000000..1e57afc --- /dev/null +++ b/alfy-mcp/src/tools/project-groups.ts @@ -0,0 +1,51 @@ +import { z } from 'zod'; +import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; +import type { AlfyRestClient } from '../rest-client.js'; + +const projectId = z.string().uuid().describe('UUID проекта'); +const id = z.string().uuid().describe('UUID эпика или истории из list_project_groups'); +const title = z.string().trim().min(1).describe('Название эпика или истории'); +const parentId = z.string().uuid().describe('UUID родительского эпика этого проекта'); +const date = z.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable().optional().describe('Дата эпика YYYY-MM-DD; null очищает дату. Для историй даты не поддерживаются'); + +function toText(data: unknown): { content: [{ type: 'text'; text: string }] } { + return { content: [{ type: 'text', text: JSON.stringify(data) }] }; +} + +/** Регистрирует создание, редактирование и удаление эпиков и историй через REST API с правами владельца токена. */ +export function registerProjectGroupTools(server: McpServer, client: AlfyRestClient): void { + server.registerTool('create_project_group', { + description: 'Создать эпик или историю. Без parentId создаётся эпик; с UUID эпика в parentId — история внутри него. Возвращает созданную группу с UUID. Даты доступны только эпикам.', + inputSchema: { + projectId, title, + parentId: parentId.optional(), + description: z.string().optional().describe('Описание'), + color: z.string().optional().describe('Цвет, например #ff0000'), + startDate: date, + dueDate: date, + }, + }, async ({ projectId, ...body }) => toText(await client.post(`/projects/${projectId}/groups`, body))); + + server.registerTool('update_project_group', { + description: 'Редактировать эпик или историю: название, описание, цвет, статус open/done, даты эпика. parentId переносит историю в другой эпик этого проекта; null для parentId не поддерживается. Пропущенные поля сохраняются; null очищает описание, цвет или дату. Статус группы не меняет статусы её задач. Для переноса в спринт используйте move_story_to_sprint.', + inputSchema: { + projectId, id, + title: title.optional(), + parentId: parentId.optional(), + description: z.string().nullable().optional().describe('Описание или null для очистки'), + color: z.string().nullable().optional().describe('Цвет или null для очистки'), + status: z.enum(['open', 'done']).optional().describe('open — открыть, done — завершить группу'), + startDate: date, + dueDate: date, + }, + }, async ({ projectId, id, ...body }) => toText(await client.patch(`/projects/${projectId}/groups/${id}`, body))); + + server.registerTool('delete_project_group', { + description: 'Удалить эпик или историю при confirm=true. При удалении эпика удаляются и дочерние истории. Задачи сохраняются, их привязка к удалённым группам очищается.', + inputSchema: { projectId, id, confirm: z.literal(true).describe('Подтверждение удаления группы и её дочерних историй') }, + annotations: { destructiveHint: true }, + }, async ({ projectId, id }) => { + await client.del(`/projects/${projectId}/groups/${id}`); + return toText({ ok: true }); + }); +} diff --git a/alfy-mcp/tests/tools/project-groups.spec.ts b/alfy-mcp/tests/tools/project-groups.spec.ts new file mode 100644 index 0000000..562aad9 --- /dev/null +++ b/alfy-mcp/tests/tools/project-groups.spec.ts @@ -0,0 +1,93 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { Client } from '@modelcontextprotocol/sdk/client/index.js'; +import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js'; +import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; +import type { AlfyRestClient } from '../../src/rest-client.js'; +import { RestError } from '../../src/rest-client.js'; +import { createServer } from '../../src/server.js'; + +const PROJECT = '00000000-0000-4000-8000-000000000001'; +const EPIC = '00000000-0000-4000-8000-000000000002'; +const STORY = '00000000-0000-4000-8000-000000000003'; + +describe('эпики и истории через MCP', () => { + let client: Client; + let server: McpServer; + let rest: { get: ReturnType; post: ReturnType; patch: ReturnType; del: ReturnType }; + + beforeEach(async () => { + rest = { get: vi.fn(), post: vi.fn(), patch: vi.fn(), del: vi.fn() }; + server = createServer(rest as unknown as AlfyRestClient); + client = new Client({ name: 'group-tests', version: '1.0.0' }); + const [a, b] = InMemoryTransport.createLinkedPair(); + await Promise.all([client.connect(a), server.connect(b)]); + }); + + afterEach(async () => { + await Promise.all([client.close(), server.close()]); + }); + + it('публикует инструменты вместе с чтением дерева', async () => { + const { tools } = await client.listTools(); + expect(tools.map(tool => tool.name)).toEqual(expect.arrayContaining([ + 'list_project_groups', 'create_project_group', 'update_project_group', 'delete_project_group', + ])); + expect(tools.find(tool => tool.name === 'delete_project_group')?.annotations?.destructiveHint).toBe(true); + }); + + it.each([ + { title: 'Эпик', description: 'Описание', color: '#123456', startDate: '2026-10-11', dueDate: '2026-10-20' }, + { title: 'История', parentId: EPIC }, + ])('создаёт группу с правильным родителем и возвращает UUID: $title', async (body) => { + const saved = { id: STORY, ...body }; + rest.post.mockResolvedValue(saved); + const result = await client.callTool({ name: 'create_project_group', arguments: { projectId: PROJECT, ...body } }); + expect(result.isError).not.toBe(true); + expect(rest.post).toHaveBeenCalledTimes(1); + expect(rest.post).toHaveBeenCalledWith(`/projects/${PROJECT}/groups`, body); + expect(result.content).toEqual([{ type: 'text', text: JSON.stringify(saved) }]); + }); + + it.each([ + { title: 'Новое название' }, + { description: null, color: null, startDate: null, dueDate: null }, + { parentId: EPIC, status: 'done' }, + { status: 'open', description: 'Описание' }, + ])('редактирует только переданные поля и сохраняет null: %j', async (body) => { + rest.patch.mockResolvedValue({ id: STORY, ...body }); + const result = await client.callTool({ name: 'update_project_group', arguments: { projectId: PROJECT, id: STORY, ...body } }); + expect(result.isError).not.toBe(true); + expect(rest.patch).toHaveBeenCalledTimes(1); + expect(rest.patch).toHaveBeenCalledWith(`/projects/${PROJECT}/groups/${STORY}`, body); + }); + + it.each([ + ['create_project_group', { projectId: PROJECT, title: ' ' }], + ['create_project_group', { projectId: PROJECT, title: 'История', parentId: 'bad' }], + ['update_project_group', { projectId: PROJECT, id: STORY, parentId: null }], + ['update_project_group', { projectId: PROJECT, id: STORY, status: 'closed' }], + ['update_project_group', { projectId: PROJECT, id: STORY, startDate: '11.10.2026' }], + ['delete_project_group', { projectId: PROJECT, id: STORY }], + ['delete_project_group', { projectId: PROJECT, id: STORY, confirm: false }], + ])('отклоняет неверные параметры %s до REST', async (name, args) => { + const result = await client.callTool({ name: name as string, arguments: args }); + expect(result.isError).toBe(true); + expect(rest.post).not.toHaveBeenCalled(); + expect(rest.patch).not.toHaveBeenCalled(); + expect(rest.del).not.toHaveBeenCalled(); + }); + + it('удаляет подтверждённую группу только из указанного проекта', async () => { + const result = await client.callTool({ name: 'delete_project_group', arguments: { projectId: PROJECT, id: EPIC, confirm: true } }); + expect(rest.del).toHaveBeenCalledTimes(1); + expect(rest.del).toHaveBeenCalledWith(`/projects/${PROJECT}/groups/${EPIC}`); + expect(result.content).toEqual([{ type: 'text', text: '{"ok":true}' }]); + }); + + it.each([400, 403, 404])('передаёт отказ API %s без ложного успеха', async (status) => { + rest.patch.mockRejectedValue(new RestError(status, 'Group update rejected')); + const result = await client.callTool({ name: 'update_project_group', arguments: { projectId: PROJECT, id: STORY, title: 'Новое' } }); + expect(result.isError).toBe(true); + expect(JSON.stringify(result.content)).toContain('Group update rejected'); + }); +}); From 08e5f4fd30dcff3a805b17fc2d8d1c574e05112f Mon Sep 17 00:00:00 2001 From: "i.seliverstov" Date: Mon, 12 Oct 2026 16:05:49 +0500 Subject: [PATCH 2/2] style(agile): increase spacing between task cards --- alfy-bot-frontend/src/features/projects/ui/AgileCell.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alfy-bot-frontend/src/features/projects/ui/AgileCell.vue b/alfy-bot-frontend/src/features/projects/ui/AgileCell.vue index 31d60c3..2ada48f 100644 --- a/alfy-bot-frontend/src/features/projects/ui/AgileCell.vue +++ b/alfy-bot-frontend/src/features/projects/ui/AgileCell.vue @@ -31,7 +31,7 @@ function handleChange(event: any) { :group="{ name: 'agile-tasks' }" :animation="150" ghost-class="opacity-30" - class="flex-1 space-y-1 min-h-[20px]" + class="flex-1 space-y-3 min-h-[20px]" @change="handleChange" >