@omnicoreos/planka-mcp 0.2.0 → 0.3.0
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.
- package/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/marketplace.json +26 -0
- package/.claude-plugin/plugin.json +45 -0
- package/.codex-plugin/mcp.json +16 -0
- package/.codex-plugin/plugin.json +27 -0
- package/.mcp.json +17 -0
- package/CHANGELOG.md +510 -0
- package/README.es.md +294 -55
- package/README.md +293 -55
- package/dist/cli/init.d.ts +101 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +481 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/client.d.ts +32 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +106 -32
- package/dist/client.js.map +1 -1
- package/dist/config/policy.d.ts +82 -0
- package/dist/config/policy.d.ts.map +1 -0
- package/dist/config/policy.js +226 -0
- package/dist/config/policy.js.map +1 -0
- package/dist/errors.d.ts +5 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +62 -5
- package/dist/errors.js.map +1 -1
- package/dist/identity.generated.d.ts +2 -1
- package/dist/identity.generated.d.ts.map +1 -1
- package/dist/identity.generated.js +2 -1
- package/dist/identity.generated.js.map +1 -1
- package/dist/index.js +85 -10
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts +21 -0
- package/dist/instructions.d.ts.map +1 -0
- package/dist/instructions.js +37 -0
- package/dist/instructions.js.map +1 -0
- package/dist/operations/actions.d.ts +654 -0
- package/dist/operations/actions.d.ts.map +1 -0
- package/dist/operations/actions.js +154 -0
- package/dist/operations/actions.js.map +1 -0
- package/dist/operations/archive.d.ts +28 -0
- package/dist/operations/archive.d.ts.map +1 -0
- package/dist/operations/archive.js +74 -0
- package/dist/operations/archive.js.map +1 -0
- package/dist/operations/attachments.d.ts +1 -1
- package/dist/operations/attachments.d.ts.map +1 -1
- package/dist/operations/attachments.js +3 -1
- package/dist/operations/attachments.js.map +1 -1
- package/dist/operations/board-id.d.ts +1 -1
- package/dist/operations/board-id.d.ts.map +1 -1
- package/dist/operations/board-id.js +13 -7
- package/dist/operations/board-id.js.map +1 -1
- package/dist/operations/boards.d.ts +96 -19
- package/dist/operations/boards.d.ts.map +1 -1
- package/dist/operations/boards.js +377 -93
- package/dist/operations/boards.js.map +1 -1
- package/dist/operations/card-brief.d.ts +91 -0
- package/dist/operations/card-brief.d.ts.map +1 -0
- package/dist/operations/card-brief.js +79 -0
- package/dist/operations/card-brief.js.map +1 -0
- package/dist/operations/cards.d.ts +34 -9
- package/dist/operations/cards.d.ts.map +1 -1
- package/dist/operations/cards.js +60 -14
- package/dist/operations/cards.js.map +1 -1
- package/dist/operations/comments.d.ts +61 -4
- package/dist/operations/comments.d.ts.map +1 -1
- package/dist/operations/comments.js +91 -8
- package/dist/operations/comments.js.map +1 -1
- package/dist/operations/duplicate.d.ts +16 -0
- package/dist/operations/duplicate.d.ts.map +1 -0
- package/dist/operations/duplicate.js +43 -0
- package/dist/operations/duplicate.js.map +1 -0
- package/dist/operations/labels.d.ts +1 -1
- package/dist/operations/labels.d.ts.map +1 -1
- package/dist/operations/labels.js +7 -4
- package/dist/operations/labels.js.map +1 -1
- package/dist/operations/lists.d.ts +63 -1
- package/dist/operations/lists.d.ts.map +1 -1
- package/dist/operations/lists.js +97 -2
- package/dist/operations/lists.js.map +1 -1
- package/dist/operations/members.d.ts +39 -0
- package/dist/operations/members.d.ts.map +1 -0
- package/dist/operations/members.js +107 -0
- package/dist/operations/members.js.map +1 -0
- package/dist/operations/projects.d.ts +16 -0
- package/dist/operations/projects.d.ts.map +1 -1
- package/dist/operations/projects.js +54 -9
- package/dist/operations/projects.js.map +1 -1
- package/dist/operations/tasks.d.ts +1 -1
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/operations/tasks.js +5 -3
- package/dist/operations/tasks.js.map +1 -1
- package/dist/operations/users.d.ts +123 -0
- package/dist/operations/users.d.ts.map +1 -0
- package/dist/operations/users.js +180 -0
- package/dist/operations/users.js.map +1 -0
- package/dist/operations/verify.d.ts +84 -0
- package/dist/operations/verify.d.ts.map +1 -0
- package/dist/operations/verify.js +124 -0
- package/dist/operations/verify.js.map +1 -0
- package/dist/prompts.d.ts +48 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +155 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +38 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +127 -0
- package/dist/resources.js.map +1 -0
- package/dist/schemas/entities.d.ts +115 -24
- package/dist/schemas/entities.d.ts.map +1 -1
- package/dist/schemas/entities.js +48 -0
- package/dist/schemas/entities.js.map +1 -1
- package/dist/schemas/requests.d.ts +121 -46
- package/dist/schemas/requests.d.ts.map +1 -1
- package/dist/schemas/requests.js +57 -12
- package/dist/schemas/requests.js.map +1 -1
- package/dist/schemas/responses.d.ts +541 -186
- package/dist/schemas/responses.d.ts.map +1 -1
- package/dist/schemas/responses.js +13 -2
- package/dist/schemas/responses.js.map +1 -1
- package/dist/tools/activity.d.ts +150 -0
- package/dist/tools/activity.d.ts.map +1 -0
- package/dist/tools/activity.js +198 -0
- package/dist/tools/activity.js.map +1 -0
- package/dist/tools/annotations.d.ts +52 -0
- package/dist/tools/annotations.d.ts.map +1 -0
- package/dist/tools/annotations.js +214 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/attachments.d.ts +28 -4
- package/dist/tools/attachments.d.ts.map +1 -1
- package/dist/tools/attachments.js +53 -34
- package/dist/tools/attachments.js.map +1 -1
- package/dist/tools/card-ops.d.ts +232 -0
- package/dist/tools/card-ops.d.ts.map +1 -0
- package/dist/tools/card-ops.js +333 -0
- package/dist/tools/card-ops.js.map +1 -0
- package/dist/tools/cards.d.ts +90 -8
- package/dist/tools/cards.d.ts.map +1 -1
- package/dist/tools/cards.js +411 -128
- package/dist/tools/cards.js.map +1 -1
- package/dist/tools/comments.d.ts +226 -22
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +163 -134
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/dispatch.d.ts +47 -0
- package/dist/tools/dispatch.d.ts.map +1 -0
- package/dist/tools/dispatch.js +63 -0
- package/dist/tools/dispatch.js.map +1 -0
- package/dist/tools/guard.d.ts +9 -0
- package/dist/tools/guard.d.ts.map +1 -0
- package/dist/tools/guard.js +20 -0
- package/dist/tools/guard.js.map +1 -0
- package/dist/tools/index.d.ts +748 -450
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +136 -17
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/labels.d.ts +213 -18
- package/dist/tools/labels.d.ts.map +1 -1
- package/dist/tools/labels.js +218 -203
- package/dist/tools/labels.js.map +1 -1
- package/dist/tools/lists.d.ts +222 -15
- package/dist/tools/lists.d.ts.map +1 -1
- package/dist/tools/lists.js +175 -156
- package/dist/tools/lists.js.map +1 -1
- package/dist/tools/members.d.ts +128 -0
- package/dist/tools/members.d.ts.map +1 -0
- package/dist/tools/members.js +150 -0
- package/dist/tools/members.js.map +1 -0
- package/dist/tools/navigation.d.ts +22 -2
- package/dist/tools/navigation.d.ts.map +1 -1
- package/dist/tools/navigation.js +60 -15
- package/dist/tools/navigation.js.map +1 -1
- package/dist/tools/queries.d.ts +196 -166
- package/dist/tools/queries.d.ts.map +1 -1
- package/dist/tools/queries.js +125 -155
- package/dist/tools/queries.js.map +1 -1
- package/dist/tools/tasks.d.ts +26 -6
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +110 -55
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/users.d.ts +130 -0
- package/dist/tools/users.d.ts.map +1 -0
- package/dist/tools/users.js +165 -0
- package/dist/tools/users.js.map +1 -0
- package/docs/planka-2x-gotchas.md +121 -5
- package/docs/tools.md +771 -187
- package/docs/troubleshooting.md +137 -5
- package/hooks/hooks.json +15 -0
- package/hooks/preflight.mjs +100 -0
- package/package.json +6 -1
- package/scripts/setup.sh +8 -26
- package/scripts/sync-identity.mjs +55 -1
- package/server.json +87 -6
- package/tests/smoke/planka-smoke.mjs +512 -72
- package/workflow/skills/planka-close-card/SKILL.md +18 -5
- package/workflow/skills/planka-orchestrator/SKILL.md +36 -7
package/dist/tools/comments.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Comment tools for PLANKA MCP server.
|
|
3
3
|
*/
|
|
4
|
-
import { createComment, getCommentsForCard, updateComment, deleteComment, } from "../operations/comments.js";
|
|
4
|
+
import { createComment, getComments, getCommentsForCard, updateComment, deleteComment, COMMENTS_PAGE_SIZE, COMMENTS_MAX_PAGES, } from "../operations/comments.js";
|
|
5
|
+
import { verifiedDelete, verifiedWrite, writeResult, } from "../operations/verify.js";
|
|
5
6
|
import { PlankaError } from "../errors.js";
|
|
7
|
+
import { dispatchAction } from "./dispatch.js";
|
|
8
|
+
import { guarded } from "./guard.js";
|
|
6
9
|
/**
|
|
7
|
-
* Tool:
|
|
8
|
-
* Add a comment to a card.
|
|
10
|
+
* Tool: planka_create_comment
|
|
9
11
|
*/
|
|
10
|
-
export const
|
|
11
|
-
name: "
|
|
12
|
-
description: "
|
|
12
|
+
export const createCommentTool = {
|
|
13
|
+
name: "planka_create_comment",
|
|
14
|
+
description: "Comment on a card: status updates, notes, agent activity logs. Verified by re-reading the card's comments.",
|
|
13
15
|
inputSchema: {
|
|
14
16
|
type: "object",
|
|
15
17
|
properties: {
|
|
@@ -24,46 +26,43 @@ export const addCommentTool = {
|
|
|
24
26
|
},
|
|
25
27
|
required: ["cardId", "text"],
|
|
26
28
|
},
|
|
27
|
-
handler: async (params) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
isError: true,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
29
|
+
handler: async (params) => guarded(async () => {
|
|
30
|
+
const written = await verifiedWrite({
|
|
31
|
+
write: () => createComment({ cardId: params.cardId, text: params.text }),
|
|
32
|
+
reread: () => getCommentsForCard({ cardId: params.cardId }),
|
|
33
|
+
landed: (comments, comment) => comments.some((c) => c.id === comment.id && c.text === params.text),
|
|
34
|
+
});
|
|
35
|
+
return writeResult({
|
|
36
|
+
cardId: params.cardId,
|
|
37
|
+
comment: {
|
|
38
|
+
id: written.result.id,
|
|
39
|
+
text: written.result.text,
|
|
40
|
+
createdAt: written.result.createdAt,
|
|
41
|
+
},
|
|
42
|
+
}, written);
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Tool: planka_add_comment (DEPRECATED alias of planka_create_comment)
|
|
47
|
+
*/
|
|
48
|
+
export const addCommentTool = {
|
|
49
|
+
name: "planka_add_comment",
|
|
50
|
+
description: "DEPRECATED: use planka_create_comment. Kept so existing callers keep working; it forwards every argument unchanged.",
|
|
51
|
+
inputSchema: createCommentTool.inputSchema,
|
|
52
|
+
// Routed through dispatchAction so the alias inherits planka_create_comment's
|
|
53
|
+
// access policy instead of walking around PLANKA_DISABLED_TOOLS.
|
|
54
|
+
handler: (params) => dispatchAction("planka_add_comment", { ...params, action: "create" }, { create: createCommentTool }),
|
|
59
55
|
};
|
|
56
|
+
/** Comments returned when the caller does not say. Planka's page holds 50. */
|
|
57
|
+
const DEFAULT_LIMIT = 20;
|
|
60
58
|
/**
|
|
61
59
|
* Tool: planka_get_comments
|
|
62
|
-
*
|
|
60
|
+
* One honest page of a card's comments, oldest first.
|
|
63
61
|
*/
|
|
64
62
|
export const getCommentsTool = {
|
|
65
63
|
name: "planka_get_comments",
|
|
66
|
-
description: "
|
|
64
|
+
description: "Read a card's comments, oldest first. Planka serves them 50 at a time: this returns `limit` of them (default 20) plus hasMore and nextBeforeId to continue. " +
|
|
65
|
+
'Use all:true to walk every page (up to ' + COMMENTS_MAX_PAGES + ' of them, then truncated:true). commentCount is what THIS response carries, never the card total.',
|
|
67
66
|
inputSchema: {
|
|
68
67
|
type: "object",
|
|
69
68
|
properties: {
|
|
@@ -71,26 +70,60 @@ export const getCommentsTool = {
|
|
|
71
70
|
type: "string",
|
|
72
71
|
description: "The card ID",
|
|
73
72
|
},
|
|
73
|
+
limit: {
|
|
74
|
+
type: "number",
|
|
75
|
+
description: `How many comments to return (default 20, max ${COMMENTS_PAGE_SIZE} — Planka's page size).`,
|
|
76
|
+
},
|
|
77
|
+
beforeId: {
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "Cursor: returns comments OLDER than this comment id. Pass the nextBeforeId of the previous answer.",
|
|
80
|
+
},
|
|
81
|
+
all: {
|
|
82
|
+
type: "boolean",
|
|
83
|
+
description: `Read every page instead of one (up to ${COMMENTS_MAX_PAGES} pages). Sets truncated:true if the card has even more.`,
|
|
84
|
+
},
|
|
85
|
+
order: {
|
|
86
|
+
type: "string",
|
|
87
|
+
enum: ["asc", "desc"],
|
|
88
|
+
description: 'Reading order: "asc" (default) oldest first, the order the thread was written; "desc" newest first.',
|
|
89
|
+
},
|
|
74
90
|
},
|
|
75
91
|
required: ["cardId"],
|
|
76
92
|
},
|
|
77
93
|
handler: async (params) => {
|
|
78
94
|
try {
|
|
79
|
-
const
|
|
95
|
+
const result = await getComments({
|
|
96
|
+
cardId: params.cardId,
|
|
97
|
+
...(params.all ? { all: true } : { limit: params.limit ?? DEFAULT_LIMIT }),
|
|
98
|
+
...(params.beforeId ? { beforeId: params.beforeId } : {}),
|
|
99
|
+
order: params.order ?? "asc",
|
|
100
|
+
});
|
|
101
|
+
const body = {
|
|
102
|
+
cardId: params.cardId,
|
|
103
|
+
// Comments in THIS response. The card's real total only ever comes
|
|
104
|
+
// from planka_get_card (Planka's own commentsTotal).
|
|
105
|
+
commentCount: result.comments.length,
|
|
106
|
+
order: params.order ?? "asc",
|
|
107
|
+
hasMore: result.hasMore,
|
|
108
|
+
...(result.nextBeforeId ? { nextBeforeId: result.nextBeforeId } : {}),
|
|
109
|
+
...(result.truncated
|
|
110
|
+
? {
|
|
111
|
+
truncated: true,
|
|
112
|
+
truncatedReason: `stopped after ${result.pagesFetched} pages of ${COMMENTS_PAGE_SIZE}; pass beforeId=nextBeforeId to keep reading`,
|
|
113
|
+
}
|
|
114
|
+
: {}),
|
|
115
|
+
comments: result.comments.map((c) => ({
|
|
116
|
+
id: c.id,
|
|
117
|
+
text: c.text,
|
|
118
|
+
author: c.authorName,
|
|
119
|
+
createdAt: c.createdAt,
|
|
120
|
+
})),
|
|
121
|
+
};
|
|
80
122
|
return {
|
|
81
123
|
content: [
|
|
82
124
|
{
|
|
83
125
|
type: "text",
|
|
84
|
-
text: JSON.stringify(
|
|
85
|
-
cardId: params.cardId,
|
|
86
|
-
commentCount: comments.length,
|
|
87
|
-
comments: comments.map((c) => ({
|
|
88
|
-
id: c.id,
|
|
89
|
-
text: c.text,
|
|
90
|
-
author: c.authorName,
|
|
91
|
-
createdAt: c.createdAt,
|
|
92
|
-
})),
|
|
93
|
-
}, null, 2),
|
|
126
|
+
text: JSON.stringify(body),
|
|
94
127
|
},
|
|
95
128
|
],
|
|
96
129
|
};
|
|
@@ -107,12 +140,74 @@ export const getCommentsTool = {
|
|
|
107
140
|
},
|
|
108
141
|
};
|
|
109
142
|
/**
|
|
110
|
-
* Tool:
|
|
111
|
-
|
|
143
|
+
* Tool: planka_update_comment
|
|
144
|
+
*/
|
|
145
|
+
export const updateCommentTool = {
|
|
146
|
+
name: "planka_update_comment",
|
|
147
|
+
description: "Rewrite a comment, by ID from planka_get_comments. Only the agent user's own comments. Verified by re-reading the card's comments.",
|
|
148
|
+
inputSchema: {
|
|
149
|
+
type: "object",
|
|
150
|
+
properties: {
|
|
151
|
+
commentId: { type: "string", description: "The comment ID" },
|
|
152
|
+
text: { type: "string", description: "New comment text (markdown supported)" },
|
|
153
|
+
},
|
|
154
|
+
required: ["commentId", "text"],
|
|
155
|
+
},
|
|
156
|
+
handler: async (params) => guarded(async () => {
|
|
157
|
+
const written = await verifiedWrite({
|
|
158
|
+
write: () => updateComment({ commentId: params.commentId, text: params.text }),
|
|
159
|
+
reread: (comment) => getCommentsForCard({ cardId: comment.cardId }),
|
|
160
|
+
landed: (comments) => comments.some((c) => c.id === params.commentId && c.text === params.text),
|
|
161
|
+
});
|
|
162
|
+
return writeResult({
|
|
163
|
+
cardId: written.result.cardId,
|
|
164
|
+
comment: {
|
|
165
|
+
id: written.result.id,
|
|
166
|
+
text: written.result.text,
|
|
167
|
+
updatedAt: written.result.updatedAt,
|
|
168
|
+
},
|
|
169
|
+
}, written);
|
|
170
|
+
}),
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Tool: planka_delete_comment
|
|
174
|
+
*/
|
|
175
|
+
export const deleteCommentTool = {
|
|
176
|
+
name: "planka_delete_comment",
|
|
177
|
+
description: "Delete a comment, by ID from planka_get_comments. Only the agent user's own comments. Confirmed by re-reading the card's comments.",
|
|
178
|
+
inputSchema: {
|
|
179
|
+
type: "object",
|
|
180
|
+
properties: {
|
|
181
|
+
commentId: { type: "string", description: "The comment ID" },
|
|
182
|
+
},
|
|
183
|
+
required: ["commentId"],
|
|
184
|
+
},
|
|
185
|
+
handler: async (params) => guarded(async () => {
|
|
186
|
+
const deleted = await verifiedDelete({
|
|
187
|
+
del: () => deleteComment({ commentId: params.commentId }),
|
|
188
|
+
confirmGone: async (comment) => {
|
|
189
|
+
if (!comment)
|
|
190
|
+
return null;
|
|
191
|
+
const after = await getCommentsForCard({ cardId: comment.cardId });
|
|
192
|
+
return !after.some((c) => c.id === params.commentId);
|
|
193
|
+
},
|
|
194
|
+
unknownReason: "Planka did not echo the deleted comment, so its card is unknown and the delete could not be confirmed — call planka_get_comments on the card to see whether it is gone",
|
|
195
|
+
});
|
|
196
|
+
return writeResult({
|
|
197
|
+
commentId: params.commentId,
|
|
198
|
+
...(deleted.result ? { cardId: deleted.result.cardId } : {}),
|
|
199
|
+
message: deleted.verified
|
|
200
|
+
? `Comment ${params.commentId} deleted`
|
|
201
|
+
: `Comment ${params.commentId} delete NOT confirmed — check with planka_get_comments before retrying`,
|
|
202
|
+
}, deleted);
|
|
203
|
+
}),
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Tool: planka_manage_comment (DEPRECATED alias)
|
|
112
207
|
*/
|
|
113
208
|
export const manageCommentTool = {
|
|
114
209
|
name: "planka_manage_comment",
|
|
115
|
-
description: "
|
|
210
|
+
description: "DEPRECATED: use planka_update_comment / planka_delete_comment (and planka_create_comment to write one). Kept so existing callers keep working; it only routes `action` to those tools.",
|
|
116
211
|
inputSchema: {
|
|
117
212
|
type: "object",
|
|
118
213
|
properties: {
|
|
@@ -121,88 +216,22 @@ export const manageCommentTool = {
|
|
|
121
216
|
enum: ["update", "delete"],
|
|
122
217
|
description: "Action to perform",
|
|
123
218
|
},
|
|
124
|
-
commentId: {
|
|
125
|
-
|
|
126
|
-
description: "The comment ID",
|
|
127
|
-
},
|
|
128
|
-
text: {
|
|
129
|
-
type: "string",
|
|
130
|
-
description: "New comment text (required for update)",
|
|
131
|
-
},
|
|
219
|
+
commentId: { type: "string", description: "The comment ID" },
|
|
220
|
+
text: { type: "string", description: "New comment text (required for update)" },
|
|
132
221
|
},
|
|
133
222
|
required: ["action", "commentId"],
|
|
134
223
|
},
|
|
135
|
-
handler: async (params) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (!params.text) {
|
|
140
|
-
return {
|
|
141
|
-
content: [
|
|
142
|
-
{
|
|
143
|
-
type: "text",
|
|
144
|
-
text: "Error: text is required for update action",
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
isError: true,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
const comment = await updateComment({
|
|
151
|
-
commentId: params.commentId,
|
|
152
|
-
text: params.text,
|
|
153
|
-
});
|
|
154
|
-
return {
|
|
155
|
-
content: [
|
|
156
|
-
{
|
|
157
|
-
type: "text",
|
|
158
|
-
text: JSON.stringify({
|
|
159
|
-
success: true,
|
|
160
|
-
comment: {
|
|
161
|
-
id: comment.id,
|
|
162
|
-
text: comment.text,
|
|
163
|
-
updatedAt: comment.updatedAt,
|
|
164
|
-
},
|
|
165
|
-
}, null, 2),
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
case "delete": {
|
|
171
|
-
await deleteComment({ commentId: params.commentId });
|
|
172
|
-
return {
|
|
173
|
-
content: [
|
|
174
|
-
{
|
|
175
|
-
type: "text",
|
|
176
|
-
text: JSON.stringify({
|
|
177
|
-
success: true,
|
|
178
|
-
message: `Comment ${params.commentId} deleted`,
|
|
179
|
-
}, null, 2),
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
default:
|
|
185
|
-
return {
|
|
186
|
-
content: [
|
|
187
|
-
{
|
|
188
|
-
type: "text",
|
|
189
|
-
text: `Error: Unknown action '${params.action}'`,
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
isError: true,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
if (error instanceof PlankaError) {
|
|
198
|
-
return {
|
|
199
|
-
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
200
|
-
isError: true,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
throw error;
|
|
204
|
-
}
|
|
205
|
-
},
|
|
224
|
+
handler: async (params) => dispatchAction("planka_manage_comment", params, {
|
|
225
|
+
update: updateCommentTool,
|
|
226
|
+
delete: deleteCommentTool,
|
|
227
|
+
}),
|
|
206
228
|
};
|
|
207
|
-
export const commentTools = [
|
|
229
|
+
export const commentTools = [
|
|
230
|
+
createCommentTool,
|
|
231
|
+
getCommentsTool,
|
|
232
|
+
updateCommentTool,
|
|
233
|
+
deleteCommentTool,
|
|
234
|
+
addCommentTool,
|
|
235
|
+
manageCommentTool,
|
|
236
|
+
];
|
|
208
237
|
//# sourceMappingURL=comments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/tools/comments.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,aAAa,
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/tools/comments.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACT,4GAA4G;IAC9G,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,aAAa;aAC3B;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACjD;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC7B;IACD,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;gBACvB,CAAC,CAAC,WAAW,MAAM,CAAC,SAAS,UAAU;gBACvC,CAAC,CAAC,WAAW,MAAM,CAAC,SAAS,wEAAwE;SACxG,EACD,OAAO,CACR,CAAC;IACJ,CAAC,CAAC;CACL,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACT,wLAAwL;IAC1L,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBAC1B,WAAW,EAAE,mBAAmB;aACjC;YACD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE;YAC5D,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wCAAwC,EAAE;SAChF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;KAClC;IACD,OAAO,EAAE,KAAK,EAAE,MAIf,EAAE,EAAE,CACH,cAAc,CAAC,uBAAuB,EAAE,MAAM,EAAE;QAC9C,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,iBAAiB;KAC1B,CAAC;CACL,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,iBAAiB;IACjB,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,cAAc;IACd,iBAAiB;CAClB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** The slice of a tool this module needs. Avoids importing the registry. */
|
|
2
|
+
export interface DispatchTarget {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
required?: string[];
|
|
6
|
+
};
|
|
7
|
+
handler: (params: any) => Promise<{
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}>;
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Required inputSchema fields that never arrived.
|
|
17
|
+
*
|
|
18
|
+
* The inputSchema is JSON Schema, not Zod: this only checks presence, which is
|
|
19
|
+
* what stops a missing `tasks` from blowing up inside the handler as "Cannot
|
|
20
|
+
* read properties of undefined (reading 'map')".
|
|
21
|
+
*/
|
|
22
|
+
export declare function missingRequiredArgs(schema: {
|
|
23
|
+
required?: string[];
|
|
24
|
+
}, args: unknown): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Routes a deprecated `action` argument to the tool that replaced it.
|
|
27
|
+
*
|
|
28
|
+
* `optional` lists fields the target declares required but the deployment may
|
|
29
|
+
* fill in (today: boardId, from PLANKA_DEFAULT_BOARD_ID) — the target handler
|
|
30
|
+
* owns that fallback, so the alias must not reject the call first.
|
|
31
|
+
*/
|
|
32
|
+
export declare function dispatchAction(aliasName: string, params: {
|
|
33
|
+
action?: string;
|
|
34
|
+
} & Record<string, unknown>, targets: Record<string, DispatchTarget>, optional?: readonly string[]): Promise<{
|
|
35
|
+
content: Array<{
|
|
36
|
+
type: string;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}>;
|
|
39
|
+
isError?: boolean;
|
|
40
|
+
} | {
|
|
41
|
+
content: {
|
|
42
|
+
type: "text";
|
|
43
|
+
text: string;
|
|
44
|
+
}[];
|
|
45
|
+
isError: true;
|
|
46
|
+
}>;
|
|
47
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/tools/dispatch.ts"],"names":[],"mappings":"AAqBA,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAErC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC;QAChC,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC,CAAC;QACzD,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC,CAAC;CACJ;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAC/B,IAAI,EAAE,OAAO,GACZ,MAAM,EAAE,CAOV;AASD;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EACvC,QAAQ,GAAE,SAAS,MAAM,EAAgB;aA1C9B,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;cAC9C,OAAO;;;;;;;GAkEpB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecated-alias plumbing.
|
|
3
|
+
*
|
|
4
|
+
* The three `planka_manage_*` tools used an `action` enum, which JSON Schema
|
|
5
|
+
* cannot condition `required` on ("boardId is required if action=create").
|
|
6
|
+
* Every one of them therefore grew 20-40 lines of hand-written "which field
|
|
7
|
+
* does this action need?" checks — and that is exactly where the empty-PATCH
|
|
8
|
+
* bugs came from.
|
|
9
|
+
*
|
|
10
|
+
* The tools are now one per action, each with a real `required`. The old names
|
|
11
|
+
* survive as aliases that route `action` to the tool that replaced it, and the
|
|
12
|
+
* presence check they used to do by hand is done here, once, from the target's
|
|
13
|
+
* own schema.
|
|
14
|
+
*
|
|
15
|
+
* The alias also inherits the target's access policy: an alias that reached the
|
|
16
|
+
* handler directly was a way around `PLANKA_DISABLED_TOOLS`
|
|
17
|
+
* (`planka_manage_lists {action:"delete"}` running a disabled
|
|
18
|
+
* `planka_delete_list`), so the policy is consulted on the TARGET's name here.
|
|
19
|
+
*/
|
|
20
|
+
import { toolBlockedReason } from "../config/policy.js";
|
|
21
|
+
/**
|
|
22
|
+
* Required inputSchema fields that never arrived.
|
|
23
|
+
*
|
|
24
|
+
* The inputSchema is JSON Schema, not Zod: this only checks presence, which is
|
|
25
|
+
* what stops a missing `tasks` from blowing up inside the handler as "Cannot
|
|
26
|
+
* read properties of undefined (reading 'map')".
|
|
27
|
+
*/
|
|
28
|
+
export function missingRequiredArgs(schema, args) {
|
|
29
|
+
const required = schema.required ?? [];
|
|
30
|
+
const received = args && typeof args === "object" ? args : {};
|
|
31
|
+
return required.filter((field) => received[field] === undefined || received[field] === null);
|
|
32
|
+
}
|
|
33
|
+
function toolError(text) {
|
|
34
|
+
return {
|
|
35
|
+
content: [{ type: "text", text }],
|
|
36
|
+
isError: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Routes a deprecated `action` argument to the tool that replaced it.
|
|
41
|
+
*
|
|
42
|
+
* `optional` lists fields the target declares required but the deployment may
|
|
43
|
+
* fill in (today: boardId, from PLANKA_DEFAULT_BOARD_ID) — the target handler
|
|
44
|
+
* owns that fallback, so the alias must not reject the call first.
|
|
45
|
+
*/
|
|
46
|
+
export async function dispatchAction(aliasName, params, targets, optional = ["boardId"]) {
|
|
47
|
+
const action = params.action;
|
|
48
|
+
const target = action ? targets[action] : undefined;
|
|
49
|
+
if (!target) {
|
|
50
|
+
return toolError(`Error: unknown action '${action}' for ${aliasName}. Use one of: ${Object.keys(targets).join(", ")}.`);
|
|
51
|
+
}
|
|
52
|
+
const missing = missingRequiredArgs(target.inputSchema, params).filter((field) => !optional.includes(field));
|
|
53
|
+
if (missing.length > 0) {
|
|
54
|
+
return toolError(`Error: ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} required for action '${action}'. ` +
|
|
55
|
+
`${aliasName} is deprecated — call ${target.name} instead, which declares this in its schema.`);
|
|
56
|
+
}
|
|
57
|
+
// The alias must not be a bypass: the target's own policy decides.
|
|
58
|
+
const blocked = toolBlockedReason(target.name);
|
|
59
|
+
if (blocked)
|
|
60
|
+
return toolError(blocked);
|
|
61
|
+
return target.handler(params);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/tools/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAaxD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA+B,EAC/B,IAAa;IAEb,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IACvC,MAAM,QAAQ,GACZ,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAgC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,CACrE,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAa;KACvB,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,SAAiB,EACjB,MAAqD,EACrD,OAAuC,EACvC,WAA8B,CAA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AC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,OAAO,CAAC,CAAC,SAAS,SAAS,EAC/C,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAYxB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The try/catch every tool handler repeats: a PlankaError becomes a tool error
|
|
3
|
+
* the model can read, anything else keeps bubbling up as a bug.
|
|
4
|
+
*/
|
|
5
|
+
import { PlankaError } from "../errors.js";
|
|
6
|
+
export async function guarded(run) {
|
|
7
|
+
try {
|
|
8
|
+
return await run();
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error instanceof PlankaError) {
|
|
12
|
+
return {
|
|
13
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
14
|
+
isError: true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/tools/guard.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAO3C,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,GAAqB;IAErB,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,UAAU,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;gBACrE,OAAO,EAAE,IAAa;aACvB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|