@grec0/memory-bank-mcp 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,145 +0,0 @@
1
- import { z } from "zod";
2
- import { getCard, moveCard } from "../operations/cards.js";
3
- import { createComment } from "../operations/comments.js";
4
- import { getLists } from "../operations/lists.js";
5
- import { getBoard } from "../operations/boards.js";
6
- import { getTask, updateTask } from "../operations/tasks.js";
7
- /**
8
- * Zod schema for the workflow action parameters
9
- * @property {string} action - The workflow action to perform (start_working, mark_completed, move_to_testing, move_to_done)
10
- * @property {string} cardId - The ID of the card to perform the action on
11
- * @property {string} [comment] - Optional comment to add with the action
12
- * @property {string[]} [taskIds] - Optional task IDs to mark as completed (for mark_completed action)
13
- * @property {string} [boardId] - Optional board ID (if not provided, will attempt to determine from card)
14
- */
15
- export const workflowActionSchema = z.object({
16
- action: z.enum([
17
- "start_working",
18
- "mark_completed",
19
- "move_to_testing",
20
- "move_to_done",
21
- ]).describe("The workflow action to perform"),
22
- cardId: z.string().describe("The ID of the card to perform the action on"),
23
- comment: z.string().optional().describe("Optional comment to add with the action"),
24
- taskIds: z.array(z.string()).optional().describe("Optional task IDs to mark as completed (for mark_completed action)"),
25
- boardId: z.string().optional().describe("Optional board ID (if not provided, will attempt to determine from card)"),
26
- });
27
- /**
28
- * Performs a workflow action on a card (start working, mark completed, move to testing, move to done)
29
- *
30
- * This function handles common workflow actions for cards in a Kanban board, including
31
- * moving cards between lists, marking tasks as completed, and adding comments to document progress.
32
- *
33
- * @param {WorkflowActionParams} params - Parameters for the workflow action
34
- * @param {string} params.action - The workflow action to perform (start_working, mark_completed, move_to_testing, move_to_done)
35
- * @param {string} params.cardId - The ID of the card to perform the action on
36
- * @param {string} [params.comment] - Optional comment to add with the action
37
- * @param {string[]} [params.taskIds] - Optional task IDs to mark as completed (for mark_completed action)
38
- * @param {string} [params.boardId] - Optional board ID (if not provided, will attempt to determine from card)
39
- * @returns {Promise<object>} The result of the workflow action
40
- * @throws {Error} If the card or board is not found, or if the action cannot be performed
41
- */
42
- export async function performWorkflowAction(params) {
43
- const { action, cardId, comment, taskIds, boardId: providedBoardId } = params;
44
- try {
45
- // Get the card details
46
- const card = await getCard(cardId);
47
- if (!card) {
48
- throw new Error(`Card with ID ${cardId} not found`);
49
- }
50
- // Use the provided boardId or try to determine it
51
- let boardId = providedBoardId;
52
- if (!boardId) {
53
- // Try to get the boardId from the card response
54
- // @ts-ignore - Some card responses include boardId
55
- boardId = card.boardId;
56
- }
57
- if (!boardId) {
58
- throw new Error(`Could not determine board ID for card ${cardId}. Please provide a boardId parameter.`);
59
- }
60
- // Get the board
61
- const board = await getBoard(boardId);
62
- if (!board) {
63
- throw new Error(`Board with ID ${boardId} not found`);
64
- }
65
- // Get all lists on the board
66
- const boardLists = await getLists(boardId);
67
- // Find the target list based on the action
68
- let targetList;
69
- let actionComment = comment;
70
- switch (action) {
71
- case "start_working":
72
- targetList = boardLists.find((list) => list.name.toLowerCase() === "in progress");
73
- actionComment = comment || "🚀 Started working on this card.";
74
- break;
75
- case "mark_completed":
76
- // This action doesn't move the card, just completes tasks
77
- if (taskIds && taskIds.length > 0) {
78
- // Mark all specified tasks as completed
79
- const taskUpdates = await Promise.all(taskIds.map(async (taskId) => {
80
- // First get the task to get its current properties
81
- const task = await getTask(taskId);
82
- // Then update it with the same properties plus isCompleted=true
83
- return updateTask(taskId, {
84
- name: task.name,
85
- position: task.position,
86
- // Use the API's method for marking as completed
87
- // The updateTask function will handle this correctly
88
- });
89
- }));
90
- // Add a comment if provided
91
- if (comment) {
92
- await createComment({
93
- cardId,
94
- text: comment,
95
- });
96
- }
97
- return {
98
- success: true,
99
- action,
100
- cardId,
101
- tasksCompleted: taskUpdates.length,
102
- };
103
- }
104
- else {
105
- throw new Error("No task IDs provided for mark_completed action");
106
- }
107
- case "move_to_testing":
108
- targetList = boardLists.find((list) => list.name.toLowerCase() === "testing" ||
109
- list.name.toLowerCase() === "review");
110
- actionComment = comment ||
111
- "✅ Implementation completed and ready for testing.";
112
- break;
113
- case "move_to_done":
114
- targetList = boardLists.find((list) => list.name.toLowerCase() === "done");
115
- actionComment = comment ||
116
- "🎉 All work completed and verified.";
117
- break;
118
- default:
119
- throw new Error(`Unknown action: ${action}`);
120
- }
121
- if (!targetList) {
122
- throw new Error(`Target list not found for action: ${action}`);
123
- }
124
- // Move the card to the target list
125
- const updatedCard = await moveCard(cardId, targetList.id);
126
- // Add a comment
127
- const newComment = await createComment({
128
- cardId,
129
- text: actionComment || "",
130
- });
131
- return {
132
- success: true,
133
- action,
134
- cardId,
135
- listId: targetList.id,
136
- listName: targetList.name,
137
- card: updatedCard,
138
- comment: newComment,
139
- };
140
- }
141
- catch (error) {
142
- console.error(`Error in performWorkflowAction (${action}):`, error);
143
- throw error;
144
- }
145
- }