@denvermullets/jait 1.4.0 → 1.6.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/dist/api-client.d.ts +5 -1
- package/dist/api-client.js +60 -34
- package/dist/attachments.d.ts +9 -2
- package/dist/attachments.js +93 -29
- package/dist/description-sections.d.ts +44 -0
- package/dist/description-sections.js +156 -0
- package/dist/index.js +8 -0
- package/dist/tools/comments.d.ts +20 -0
- package/dist/tools/comments.js +85 -25
- package/dist/tools/decisions.d.ts +2 -0
- package/dist/tools/decisions.js +64 -0
- package/dist/tools/description-section-tools.d.ts +18 -0
- package/dist/tools/description-section-tools.js +77 -0
- package/dist/tools/issues.d.ts +46 -6
- package/dist/tools/issues.js +180 -30
- package/dist/tools/labels.js +39 -0
- package/dist/tools/notifications.d.ts +2 -0
- package/dist/tools/notifications.js +62 -0
- package/dist/tools/projects.js +81 -13
- package/dist/tools/recurring-issues.d.ts +2 -0
- package/dist/tools/recurring-issues.js +132 -0
- package/dist/tools/sub-issues.d.ts +32 -0
- package/dist/tools/sub-issues.js +90 -0
- package/package.json +4 -4
package/dist/tools/issues.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../api-client.js";
|
|
3
|
-
import {
|
|
2
|
+
import { apiRequest, apiRequestWithHeaders } from "../api-client.js";
|
|
3
|
+
import { attachUploads, filePathsSchema, formatAttachments, uploadLocalFiles, } from "../attachments.js";
|
|
4
|
+
import { registerDescriptionSectionTools } from "./description-section-tools.js";
|
|
4
5
|
const priorityEnum = z
|
|
5
6
|
.enum(["urgent", "high", "medium", "low", "no_priority"])
|
|
6
7
|
.describe("Issue priority");
|
|
@@ -19,15 +20,18 @@ export function formatIssue(issue, detailed = false) {
|
|
|
19
20
|
lines.push(` Due: ${issue.due_date}`);
|
|
20
21
|
if (issue.estimate !== null)
|
|
21
22
|
lines.push(` Estimate: ${issue.estimate}`);
|
|
23
|
+
// List rows carry only the parent's id; detail rows render the full parent below.
|
|
24
|
+
if (!detailed && issue.parent_issue_id)
|
|
25
|
+
lines.push(` Parent issue ID: ${issue.parent_issue_id}`);
|
|
22
26
|
if (detailed) {
|
|
23
27
|
if (issue.description)
|
|
24
28
|
lines.push(` Description: ${issue.description}`);
|
|
25
|
-
if (issue.
|
|
26
|
-
lines.push(` Attachments: ${formatAttachments(issue.
|
|
27
|
-
if (issue.milestone)
|
|
28
|
-
lines.push(` Milestone: ${issue.milestone.name}`);
|
|
29
|
+
if (issue.files && issue.files.length > 0)
|
|
30
|
+
lines.push(` Attachments: ${formatAttachments(issue.files)}`);
|
|
29
31
|
if (issue.parent_issue)
|
|
30
|
-
lines.push(` Parent: ${issue.parent_issue.identifier}
|
|
32
|
+
lines.push(` Parent: ${issue.parent_issue.identifier} (ID: ${issue.parent_issue.id})`);
|
|
33
|
+
if (issue.sub_issues && issue.sub_issues.length > 0)
|
|
34
|
+
lines.push(` Sub-issues: ${issue.sub_issues.map((i) => `${i.identifier} (${i.title}) [${i.lane?.name ?? "?"}, ID: ${i.id}]`).join(", ")}`);
|
|
31
35
|
// API semantics (from the Rails issue serializer / associations):
|
|
32
36
|
// blocked_issues = issues THIS issue blocks (its dependents) -> "Blocking:"
|
|
33
37
|
// blocking_issues = issues that block THIS issue (its blockers) -> "Blocked by:"
|
|
@@ -50,26 +54,83 @@ export function formatIssue(issue, detailed = false) {
|
|
|
50
54
|
return lines.join("\n");
|
|
51
55
|
}
|
|
52
56
|
// create/update respond with the summary serializer, which omits attachments,
|
|
53
|
-
// so
|
|
54
|
-
function attachedNote(
|
|
55
|
-
if (
|
|
57
|
+
// so list what the attach call returned.
|
|
58
|
+
function attachedNote(attached) {
|
|
59
|
+
if (attached.length === 0)
|
|
56
60
|
return "";
|
|
57
|
-
return `\n Attached: ${
|
|
61
|
+
return `\n Attached: ${formatAttachments(attached)}`;
|
|
62
|
+
}
|
|
63
|
+
function attachmentsPath(teamId, issueId) {
|
|
64
|
+
return `/api/v1/teams/${teamId}/issues/${issueId}/attachments`;
|
|
65
|
+
}
|
|
66
|
+
function formatValue(value) {
|
|
67
|
+
if (value === null || value === undefined || value === "")
|
|
68
|
+
return "none";
|
|
69
|
+
if (typeof value === "object") {
|
|
70
|
+
const v = value;
|
|
71
|
+
return String(v.name ?? v.identifier ?? v.id ?? JSON.stringify(v));
|
|
72
|
+
}
|
|
73
|
+
return String(value);
|
|
74
|
+
}
|
|
75
|
+
export function formatActivityEntry(entry) {
|
|
76
|
+
const when = entry.created_at;
|
|
77
|
+
switch (entry.type) {
|
|
78
|
+
case "comment": {
|
|
79
|
+
const c = entry.comment;
|
|
80
|
+
const who = c?.user?.name ?? "Someone";
|
|
81
|
+
return `${when} — ${who} commented (#${c?.id}): ${c?.body ?? ""}`;
|
|
82
|
+
}
|
|
83
|
+
case "reference": {
|
|
84
|
+
const who = entry.user?.name ?? "Someone";
|
|
85
|
+
const src = entry.source_issue;
|
|
86
|
+
return `${when} — ${who} referenced this from ${src?.identifier} (${src?.title}) in a ${entry.source_type}`;
|
|
87
|
+
}
|
|
88
|
+
default: {
|
|
89
|
+
const who = entry.actor?.name ?? "System";
|
|
90
|
+
const changes = (entry.changes ?? [])
|
|
91
|
+
.map((c) => `${c.field}: ${formatValue(c.from)} → ${formatValue(c.to)}`)
|
|
92
|
+
.join("; ");
|
|
93
|
+
return `${when} — ${who} ${entry.description ?? entry.type}${changes ? ` (${changes})` : ""}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export function formatActivityPage(entries, nextBeforeId) {
|
|
98
|
+
if (entries.length === 0)
|
|
99
|
+
return "No activity found.";
|
|
100
|
+
const lines = entries.map(formatActivityEntry);
|
|
101
|
+
if (nextBeforeId)
|
|
102
|
+
lines.push(`\nOlder entries exist: pass before_id "${nextBeforeId}" to see them.`);
|
|
103
|
+
return lines.join("\n");
|
|
58
104
|
}
|
|
59
105
|
export function registerIssueTools(server) {
|
|
106
|
+
registerDescriptionSectionTools(server, {
|
|
107
|
+
noun: "issue",
|
|
108
|
+
idShape: {
|
|
109
|
+
team_id: z.number().describe("Team ID"),
|
|
110
|
+
issue_id: z.number().describe("Issue ID"),
|
|
111
|
+
},
|
|
112
|
+
path: ({ team_id, issue_id }) => `/api/v1/teams/${team_id}/issues/${issue_id}`,
|
|
113
|
+
bodyKey: "issue",
|
|
114
|
+
label: (issue) => issue.identifier,
|
|
115
|
+
});
|
|
60
116
|
server.tool("list_issues", "List issues for a team, with optional filters", {
|
|
61
117
|
team_id: z.number().describe("Team ID"),
|
|
62
118
|
lane_id: z.number().optional().describe("Filter by status lane ID"),
|
|
63
119
|
assignee_id: z.number().optional().describe("Filter by assignee ID"),
|
|
64
120
|
project_id: z.number().optional().describe("Filter by project ID"),
|
|
65
121
|
priority: priorityEnum.optional(),
|
|
66
|
-
|
|
122
|
+
parent_issue_id: z
|
|
123
|
+
.union([z.number(), z.literal("none")])
|
|
124
|
+
.optional()
|
|
125
|
+
.describe("Filter by parent: an issue ID lists that issue's direct sub-issues; 'none' lists only top-level issues (no parent)"),
|
|
126
|
+
}, async ({ team_id, lane_id, assignee_id, project_id, priority, parent_issue_id, }) => {
|
|
67
127
|
const issues = await apiRequest(`/api/v1/teams/${team_id}/issues`, {
|
|
68
128
|
params: {
|
|
69
129
|
lane_id: lane_id,
|
|
70
130
|
assignee_id: assignee_id,
|
|
71
131
|
project_id: project_id,
|
|
72
132
|
priority,
|
|
133
|
+
parent_issue_id,
|
|
73
134
|
},
|
|
74
135
|
});
|
|
75
136
|
const text = issues.map((i) => formatIssue(i)).join("\n\n");
|
|
@@ -77,7 +138,7 @@ export function registerIssueTools(server) {
|
|
|
77
138
|
content: [{ type: "text", text: text || "No issues found." }],
|
|
78
139
|
};
|
|
79
140
|
});
|
|
80
|
-
server.tool("get_issue", "Get full details of a specific issue", {
|
|
141
|
+
server.tool("get_issue", "Get full details of a specific issue. For a long description, use list_issue_sections and get_issue_section to read just part of it.", {
|
|
81
142
|
team_id: z.number().describe("Team ID"),
|
|
82
143
|
issue_id: z.number().describe("Issue ID"),
|
|
83
144
|
}, async ({ team_id, issue_id }) => {
|
|
@@ -124,11 +185,14 @@ export function registerIssueTools(server) {
|
|
|
124
185
|
.optional()
|
|
125
186
|
.describe("Due date in YYYY-MM-DD format"),
|
|
126
187
|
estimate: z.number().optional().describe("Estimate value"),
|
|
127
|
-
|
|
128
|
-
|
|
188
|
+
parent_issue_id: z
|
|
189
|
+
.number()
|
|
190
|
+
.optional()
|
|
191
|
+
.describe("Parent issue ID — creates this issue as a sub-issue of that issue (same team only)"),
|
|
129
192
|
file_paths: filePathsSchema,
|
|
130
|
-
}, async ({ team_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate,
|
|
131
|
-
|
|
193
|
+
}, async ({ team_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate, parent_issue_id, file_paths, }) => {
|
|
194
|
+
// Upload before creating, so a bad file fails the call with nothing created.
|
|
195
|
+
const uploads = await uploadLocalFiles(file_paths);
|
|
132
196
|
let resolvedLaneId = lane_id;
|
|
133
197
|
if (!resolvedLaneId) {
|
|
134
198
|
const lanes = await apiRequest(`/api/v1/teams/${team_id}/lanes`);
|
|
@@ -155,26 +219,30 @@ export function registerIssueTools(server) {
|
|
|
155
219
|
label_ids,
|
|
156
220
|
due_date,
|
|
157
221
|
estimate,
|
|
158
|
-
milestone_id,
|
|
159
222
|
parent_issue_id,
|
|
160
223
|
};
|
|
161
|
-
const issue = await apiRequest(`/api/v1/teams/${team_id}/issues`,
|
|
162
|
-
|
|
163
|
-
|
|
224
|
+
const issue = await apiRequest(`/api/v1/teams/${team_id}/issues`, {
|
|
225
|
+
method: "POST",
|
|
226
|
+
body: { issue: fields },
|
|
227
|
+
});
|
|
228
|
+
const attached = await attachUploads(attachmentsPath(team_id, issue.id), uploads);
|
|
164
229
|
return {
|
|
165
230
|
content: [
|
|
166
231
|
{
|
|
167
232
|
type: "text",
|
|
168
|
-
text: `Issue created successfully:\n\n${formatIssue(issue, true)}${attachedNote(
|
|
233
|
+
text: `Issue created successfully:\n\n${formatIssue(issue, true)}${attachedNote(attached)}`,
|
|
169
234
|
},
|
|
170
235
|
],
|
|
171
236
|
};
|
|
172
237
|
});
|
|
173
|
-
server.tool("update_issue", "Update an existing issue (change priority, reassign, move lane, etc.)", {
|
|
238
|
+
server.tool("update_issue", "Update an existing issue (change priority, reassign, move lane, etc.). For partial description edits prefer edit_issue_description (small edits), replace_issue_section (rewriting a section) or append_to_issue_section (adding text).", {
|
|
174
239
|
team_id: z.number().describe("Team ID"),
|
|
175
240
|
issue_id: z.number().describe("Issue ID"),
|
|
176
241
|
title: z.string().optional().describe("New title"),
|
|
177
|
-
description: z
|
|
242
|
+
description: z
|
|
243
|
+
.string()
|
|
244
|
+
.optional()
|
|
245
|
+
.describe("New description. Use only for a full rewrite or when seeding a new description; for partial edits use edit_issue_description, replace_issue_section or append_to_issue_section"),
|
|
178
246
|
priority: priorityEnum.optional(),
|
|
179
247
|
lane_id: z.number().optional().describe("Move to lane ID"),
|
|
180
248
|
assignee_id: z.number().optional().describe("Reassign to user ID"),
|
|
@@ -182,9 +250,14 @@ export function registerIssueTools(server) {
|
|
|
182
250
|
label_ids: z.array(z.number()).optional().describe("Set label IDs"),
|
|
183
251
|
due_date: z.string().optional().describe("Due date in YYYY-MM-DD format"),
|
|
184
252
|
estimate: z.number().optional().describe("Estimate value"),
|
|
253
|
+
parent_issue_id: z
|
|
254
|
+
.number()
|
|
255
|
+
.nullable()
|
|
256
|
+
.optional()
|
|
257
|
+
.describe("Set the parent issue (makes this a sub-issue of it, same team only), or null to detach it and make it top-level"),
|
|
185
258
|
file_paths: filePathsSchema,
|
|
186
|
-
}, async ({ team_id, issue_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate, file_paths, }) => {
|
|
187
|
-
const
|
|
259
|
+
}, async ({ team_id, issue_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate, parent_issue_id, file_paths, }) => {
|
|
260
|
+
const uploads = await uploadLocalFiles(file_paths);
|
|
188
261
|
const fields = {};
|
|
189
262
|
if (title !== undefined)
|
|
190
263
|
fields.title = title;
|
|
@@ -204,14 +277,91 @@ export function registerIssueTools(server) {
|
|
|
204
277
|
fields.due_date = due_date;
|
|
205
278
|
if (estimate !== undefined)
|
|
206
279
|
fields.estimate = estimate;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
280
|
+
if (parent_issue_id !== undefined)
|
|
281
|
+
fields.parent_issue_id = parent_issue_id;
|
|
282
|
+
if (Object.keys(fields).length === 0 && uploads.length === 0) {
|
|
283
|
+
return {
|
|
284
|
+
content: [
|
|
285
|
+
{ type: "text", text: "Error: Nothing to update." },
|
|
286
|
+
],
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const issuePath = `/api/v1/teams/${team_id}/issues/${issue_id}`;
|
|
290
|
+
// The API rejects an empty `issue` object, so an attach-only call skips the PATCH.
|
|
291
|
+
const issue = Object.keys(fields).length > 0
|
|
292
|
+
? await apiRequest(issuePath, {
|
|
293
|
+
method: "PATCH",
|
|
294
|
+
body: { issue: fields },
|
|
295
|
+
})
|
|
296
|
+
: await apiRequest(issuePath);
|
|
297
|
+
const attached = await attachUploads(attachmentsPath(team_id, issue_id), uploads);
|
|
298
|
+
return {
|
|
299
|
+
content: [
|
|
300
|
+
{
|
|
301
|
+
type: "text",
|
|
302
|
+
text: `Issue updated successfully:\n\n${formatIssue(issue, true)}${attachedNote(attached)}`,
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
server.tool("remove_issue_attachment", "Remove a file attached to an issue. Get the attachment ID from get_issue.", {
|
|
308
|
+
team_id: z.number().describe("Team ID"),
|
|
309
|
+
issue_id: z.number().describe("Issue ID"),
|
|
310
|
+
attachment_id: z.number().describe("Attachment ID (shown by get_issue)"),
|
|
311
|
+
}, async ({ team_id, issue_id, attachment_id }) => {
|
|
312
|
+
await apiRequest(`${attachmentsPath(team_id, issue_id)}/${attachment_id}`, {
|
|
313
|
+
method: "DELETE",
|
|
314
|
+
});
|
|
315
|
+
return {
|
|
316
|
+
content: [
|
|
317
|
+
{ type: "text", text: `Attachment ${attachment_id} removed.` },
|
|
318
|
+
],
|
|
319
|
+
};
|
|
320
|
+
});
|
|
321
|
+
server.tool("move_issue", "Move an issue to another team you belong to. It is renumbered there (new identifier). The lane is matched by name (else the team's first lane), the assignee is kept only if they are a member of the target team, and the project, labels and parent/sub-issue links are cleared.", {
|
|
322
|
+
team_id: z.number().describe("The issue's current team ID"),
|
|
323
|
+
issue_id: z.number().describe("Issue ID"),
|
|
324
|
+
target_team_id: z.number().describe("Team ID to move the issue to"),
|
|
325
|
+
}, async ({ team_id, issue_id, target_team_id }) => {
|
|
326
|
+
const issue = await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}/move`, { method: "PATCH", body: { target_team_id } });
|
|
327
|
+
return {
|
|
328
|
+
content: [
|
|
329
|
+
{
|
|
330
|
+
type: "text",
|
|
331
|
+
text: `Issue moved:\n\n${formatIssue(issue, true)}`,
|
|
332
|
+
},
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
});
|
|
336
|
+
server.tool("get_issue_activity", "Get an issue's history: field changes, dependency changes, comments and references from other issues, oldest first. Returns the newest `limit` entries; page back with before_id.", {
|
|
337
|
+
team_id: z.number().describe("Team ID"),
|
|
338
|
+
issue_id: z.number().describe("Issue ID"),
|
|
339
|
+
types: z
|
|
340
|
+
.array(z.enum(["versions", "dependencies", "comments", "references"]))
|
|
341
|
+
.optional()
|
|
342
|
+
.describe("Only these entry types (default: all)"),
|
|
343
|
+
since: z
|
|
344
|
+
.string()
|
|
345
|
+
.optional()
|
|
346
|
+
.describe("Only entries after this ISO 8601 timestamp"),
|
|
347
|
+
limit: z
|
|
348
|
+
.number()
|
|
349
|
+
.int()
|
|
350
|
+
.min(1)
|
|
351
|
+
.max(500)
|
|
352
|
+
.optional()
|
|
353
|
+
.describe("Max entries (default 100)"),
|
|
354
|
+
before_id: z
|
|
355
|
+
.string()
|
|
356
|
+
.optional()
|
|
357
|
+
.describe("Cursor from a previous call, to get older entries"),
|
|
358
|
+
}, async ({ team_id, issue_id, types, since, limit, before_id }) => {
|
|
359
|
+
const { data, headers } = await apiRequestWithHeaders(`/api/v1/teams/${team_id}/issues/${issue_id}/activity`, { params: { types: types?.join(","), since, limit, before_id } });
|
|
210
360
|
return {
|
|
211
361
|
content: [
|
|
212
362
|
{
|
|
213
363
|
type: "text",
|
|
214
|
-
text:
|
|
364
|
+
text: formatActivityPage(data, headers.get("X-Next-Before-Id")),
|
|
215
365
|
},
|
|
216
366
|
],
|
|
217
367
|
};
|
package/dist/tools/labels.js
CHANGED
|
@@ -29,4 +29,43 @@ export function registerLabelTools(server) {
|
|
|
29
29
|
],
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
|
+
server.tool("update_label", "Rename a label or change its color.", {
|
|
33
|
+
team_id: z.number().describe("Team ID"),
|
|
34
|
+
label_id: z.number().describe("Label ID"),
|
|
35
|
+
name: z.string().optional().describe("New name (must be unique within team)"),
|
|
36
|
+
color: z.string().optional().describe("New hex color code (e.g. #ef4444)"),
|
|
37
|
+
}, async ({ team_id, label_id, name, color }) => {
|
|
38
|
+
const fields = {};
|
|
39
|
+
if (name !== undefined)
|
|
40
|
+
fields.name = name;
|
|
41
|
+
if (color !== undefined)
|
|
42
|
+
fields.color = color;
|
|
43
|
+
if (Object.keys(fields).length === 0) {
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{ type: "text", text: "Error: Give a name or a color to change." },
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const label = await apiRequest(`/api/v1/teams/${team_id}/labels/${label_id}`, { method: "PATCH", body: { label: fields } });
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: `Label updated: ${label.name} (${label.color}) — ID: ${label.id}`,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
server.tool("delete_label", "Delete a label from a team. It is removed from every issue that carries it.", {
|
|
61
|
+
team_id: z.number().describe("Team ID"),
|
|
62
|
+
label_id: z.number().describe("Label ID"),
|
|
63
|
+
}, async ({ team_id, label_id }) => {
|
|
64
|
+
await apiRequest(`/api/v1/teams/${team_id}/labels/${label_id}`, {
|
|
65
|
+
method: "DELETE",
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: "text", text: `Label ${label_id} deleted.` }],
|
|
69
|
+
};
|
|
70
|
+
});
|
|
32
71
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { apiRequest } from "../api-client.js";
|
|
3
|
+
function formatNotification(n) {
|
|
4
|
+
const state = n.read_at ? "read" : "UNREAD";
|
|
5
|
+
return `[${state}] #${n.id} ${n.created_at} — ${n.message}\n ${n.issue.identifier}: ${n.issue.title} (issue ID: ${n.issue.id}, team ID: ${n.issue.team_id})`;
|
|
6
|
+
}
|
|
7
|
+
export function registerNotificationTools(server) {
|
|
8
|
+
server.tool("list_notifications", "List your notifications (assignments, comments, mentions, status changes on issues you follow), newest first.", {
|
|
9
|
+
unread_only: z.boolean().optional().describe("Only unread notifications"),
|
|
10
|
+
limit: z
|
|
11
|
+
.number()
|
|
12
|
+
.int()
|
|
13
|
+
.min(1)
|
|
14
|
+
.max(200)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Max notifications (default 50)"),
|
|
17
|
+
before_id: z
|
|
18
|
+
.number()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Only notifications older than this notification ID, for paging"),
|
|
21
|
+
}, async ({ unread_only, limit, before_id }) => {
|
|
22
|
+
const res = await apiRequest("/api/v1/notifications", {
|
|
23
|
+
params: { unread: unread_only ? 1 : undefined, limit, before_id },
|
|
24
|
+
});
|
|
25
|
+
const header = `${res.meta.unread_count} unread`;
|
|
26
|
+
const body = res.notifications.map(formatNotification).join("\n\n");
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{ type: "text", text: body ? `${header}\n\n${body}` : `${header}. No notifications found.` },
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
server.tool("get_unread_notification_count", "Get how many unread notifications you have.", {}, async () => {
|
|
34
|
+
const res = await apiRequest("/api/v1/notifications/unread_count");
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: "text", text: `${res.unread_count} unread notifications.` }],
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
server.tool("mark_notification_read", "Mark one notification as read.", { notification_id: z.number().describe("Notification ID") }, async ({ notification_id }) => {
|
|
40
|
+
const n = await apiRequest(`/api/v1/notifications/${notification_id}/read`, { method: "PATCH" });
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: "text", text: `Marked read:\n${formatNotification(n)}` }],
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
server.tool("mark_all_notifications_read", "Mark all your notifications as read, optionally only those for one team or created before a time.", {
|
|
46
|
+
team_id: z.number().optional().describe("Only this team's notifications"),
|
|
47
|
+
before: z
|
|
48
|
+
.string()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("Only notifications created before this ISO 8601 timestamp"),
|
|
51
|
+
}, async ({ team_id, before }) => {
|
|
52
|
+
const res = await apiRequest("/api/v1/notifications/read_all", { method: "PATCH", params: { team_id, before } });
|
|
53
|
+
return {
|
|
54
|
+
content: [
|
|
55
|
+
{
|
|
56
|
+
type: "text",
|
|
57
|
+
text: `Marked ${res.marked} notifications read; ${res.unread_count} still unread.`,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
package/dist/tools/projects.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../api-client.js";
|
|
2
|
+
import { apiRequest, apiRequestWithHeaders } from "../api-client.js";
|
|
3
|
+
import { attachUploads, filePathsSchema, formatAttachments, uploadLocalFiles, } from "../attachments.js";
|
|
4
|
+
import { registerDescriptionSectionTools } from "./description-section-tools.js";
|
|
5
|
+
import { formatActivityPage } from "./issues.js";
|
|
3
6
|
const projectStatusEnum = z
|
|
4
7
|
.enum(["backlog", "started", "paused", "completed", "cancelled"])
|
|
5
8
|
.describe("Project status");
|
|
@@ -25,10 +28,10 @@ function formatProject(project, detailed = false) {
|
|
|
25
28
|
if (project.roadmap_commitment)
|
|
26
29
|
lines.push(` Roadmap: ${project.roadmap_commitment}`);
|
|
27
30
|
if (detailed) {
|
|
28
|
-
if (project.milestone)
|
|
29
|
-
lines.push(` Milestone: ${project.milestone.name}`);
|
|
30
31
|
if (project.labels?.length > 0)
|
|
31
32
|
lines.push(` Labels: ${project.labels.map((l) => l.name).join(", ")}`);
|
|
33
|
+
if (project.files && project.files.length > 0)
|
|
34
|
+
lines.push(` Attachments: ${formatAttachments(project.files)}`);
|
|
32
35
|
if (project.issues_count !== undefined)
|
|
33
36
|
lines.push(` Issues: ${project.issues_count}`);
|
|
34
37
|
lines.push(` Created: ${project.created_at}`);
|
|
@@ -44,7 +47,7 @@ export function registerProjectTools(server) {
|
|
|
44
47
|
content: [{ type: "text", text: text || "No projects found." }],
|
|
45
48
|
};
|
|
46
49
|
});
|
|
47
|
-
server.tool("get_project", "Get full details of a specific project", {
|
|
50
|
+
server.tool("get_project", "Get full details of a specific project. For a long description, use list_project_sections and get_project_section to read just part of it.", {
|
|
48
51
|
team_id: z.number().describe("Team ID"),
|
|
49
52
|
project_id: z.number().describe("Project ID"),
|
|
50
53
|
}, async ({ team_id, project_id }) => {
|
|
@@ -60,7 +63,6 @@ export function registerProjectTools(server) {
|
|
|
60
63
|
status: projectStatusEnum.optional().describe("Defaults to backlog"),
|
|
61
64
|
priority: priorityEnum.optional().describe("Defaults to no_priority"),
|
|
62
65
|
lead_id: z.number().optional().describe("Project lead user ID"),
|
|
63
|
-
milestone_id: z.number().optional().describe("Milestone ID"),
|
|
64
66
|
start_date: z
|
|
65
67
|
.string()
|
|
66
68
|
.optional()
|
|
@@ -71,7 +73,7 @@ export function registerProjectTools(server) {
|
|
|
71
73
|
.describe("Due date in YYYY-MM-DD format"),
|
|
72
74
|
label_ids: z.array(z.number()).optional().describe("Label IDs"),
|
|
73
75
|
roadmap_commitment: roadmapCommitmentEnum.optional(),
|
|
74
|
-
}, async ({ team_id, name, description, status, priority, lead_id,
|
|
76
|
+
}, async ({ team_id, name, description, status, priority, lead_id, start_date, due_date, label_ids, roadmap_commitment, }) => {
|
|
75
77
|
const project = await apiRequest(`/api/v1/teams/${team_id}/projects`, {
|
|
76
78
|
method: "POST",
|
|
77
79
|
body: {
|
|
@@ -81,7 +83,6 @@ export function registerProjectTools(server) {
|
|
|
81
83
|
status: status || "backlog",
|
|
82
84
|
priority: priority || "no_priority",
|
|
83
85
|
lead_id,
|
|
84
|
-
milestone_id,
|
|
85
86
|
start_date,
|
|
86
87
|
due_date,
|
|
87
88
|
label_ids,
|
|
@@ -98,15 +99,17 @@ export function registerProjectTools(server) {
|
|
|
98
99
|
],
|
|
99
100
|
};
|
|
100
101
|
});
|
|
101
|
-
server.tool("update_project", "Update an existing project (change status, priority, lead, dates, etc.)", {
|
|
102
|
+
server.tool("update_project", "Update an existing project (change status, priority, lead, dates, etc.). For partial description edits prefer edit_project_description (small edits), replace_project_section (rewriting a section) or append_to_project_section (adding text).", {
|
|
102
103
|
team_id: z.number().describe("Team ID"),
|
|
103
104
|
project_id: z.number().describe("Project ID"),
|
|
104
105
|
name: z.string().optional().describe("New name"),
|
|
105
|
-
description: z
|
|
106
|
+
description: z
|
|
107
|
+
.string()
|
|
108
|
+
.optional()
|
|
109
|
+
.describe("New description. Use only for a full rewrite or when seeding a new description; for partial edits use edit_project_description, replace_project_section or append_to_project_section"),
|
|
106
110
|
status: projectStatusEnum.optional(),
|
|
107
111
|
priority: priorityEnum.optional(),
|
|
108
112
|
lead_id: z.number().optional().describe("New lead user ID"),
|
|
109
|
-
milestone_id: z.number().optional().describe("Milestone ID"),
|
|
110
113
|
start_date: z
|
|
111
114
|
.string()
|
|
112
115
|
.optional()
|
|
@@ -117,7 +120,7 @@ export function registerProjectTools(server) {
|
|
|
117
120
|
.describe("Due date in YYYY-MM-DD format"),
|
|
118
121
|
label_ids: z.array(z.number()).optional().describe("Set label IDs"),
|
|
119
122
|
roadmap_commitment: roadmapCommitmentEnum.nullable().optional(),
|
|
120
|
-
}, async ({ team_id, project_id, name, description, status, priority, lead_id,
|
|
123
|
+
}, async ({ team_id, project_id, name, description, status, priority, lead_id, start_date, due_date, label_ids, roadmap_commitment, }) => {
|
|
121
124
|
const fields = {};
|
|
122
125
|
if (name !== undefined)
|
|
123
126
|
fields.name = name;
|
|
@@ -129,8 +132,6 @@ export function registerProjectTools(server) {
|
|
|
129
132
|
fields.priority = priority;
|
|
130
133
|
if (lead_id !== undefined)
|
|
131
134
|
fields.lead_id = lead_id;
|
|
132
|
-
if (milestone_id !== undefined)
|
|
133
|
-
fields.milestone_id = milestone_id;
|
|
134
135
|
if (start_date !== undefined)
|
|
135
136
|
fields.start_date = start_date;
|
|
136
137
|
if (due_date !== undefined)
|
|
@@ -163,4 +164,71 @@ export function registerProjectTools(server) {
|
|
|
163
164
|
],
|
|
164
165
|
};
|
|
165
166
|
});
|
|
167
|
+
server.tool("add_project_attachments", "Attach local files to a project. Existing attachments are kept.", {
|
|
168
|
+
team_id: z.number().describe("Team ID"),
|
|
169
|
+
project_id: z.number().describe("Project ID"),
|
|
170
|
+
file_paths: filePathsSchema.unwrap().min(1),
|
|
171
|
+
}, async ({ team_id, project_id, file_paths }) => {
|
|
172
|
+
const uploads = await uploadLocalFiles(file_paths);
|
|
173
|
+
const attached = await attachUploads(`/api/v1/teams/${team_id}/projects/${project_id}/attachments`, uploads);
|
|
174
|
+
return {
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
type: "text",
|
|
178
|
+
text: `Attached to project ${project_id}: ${formatAttachments(attached)}`,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
server.tool("remove_project_attachment", "Remove a file attached to a project. Get the attachment ID from get_project.", {
|
|
184
|
+
team_id: z.number().describe("Team ID"),
|
|
185
|
+
project_id: z.number().describe("Project ID"),
|
|
186
|
+
attachment_id: z.number().describe("Attachment ID (shown by get_project)"),
|
|
187
|
+
}, async ({ team_id, project_id, attachment_id }) => {
|
|
188
|
+
await apiRequest(`/api/v1/teams/${team_id}/projects/${project_id}/attachments/${attachment_id}`, { method: "DELETE" });
|
|
189
|
+
return {
|
|
190
|
+
content: [
|
|
191
|
+
{ type: "text", text: `Attachment ${attachment_id} removed.` },
|
|
192
|
+
],
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
server.tool("get_project_activity", "Get a project's change history (name, description, status, priority, lead, dates, roadmap commitment), oldest first. Returns the newest `limit` entries; page back with before_id.", {
|
|
196
|
+
team_id: z.number().describe("Team ID"),
|
|
197
|
+
project_id: z.number().describe("Project ID"),
|
|
198
|
+
since: z
|
|
199
|
+
.string()
|
|
200
|
+
.optional()
|
|
201
|
+
.describe("Only entries after this ISO 8601 timestamp"),
|
|
202
|
+
limit: z
|
|
203
|
+
.number()
|
|
204
|
+
.int()
|
|
205
|
+
.min(1)
|
|
206
|
+
.max(500)
|
|
207
|
+
.optional()
|
|
208
|
+
.describe("Max entries (default 100)"),
|
|
209
|
+
before_id: z
|
|
210
|
+
.string()
|
|
211
|
+
.optional()
|
|
212
|
+
.describe("Cursor from a previous call, to get older entries"),
|
|
213
|
+
}, async ({ team_id, project_id, since, limit, before_id }) => {
|
|
214
|
+
const { data, headers } = await apiRequestWithHeaders(`/api/v1/teams/${team_id}/projects/${project_id}/activity`, { params: { since, limit, before_id } });
|
|
215
|
+
return {
|
|
216
|
+
content: [
|
|
217
|
+
{
|
|
218
|
+
type: "text",
|
|
219
|
+
text: formatActivityPage(data, headers.get("X-Next-Before-Id")),
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
registerDescriptionSectionTools(server, {
|
|
225
|
+
noun: "project",
|
|
226
|
+
idShape: {
|
|
227
|
+
team_id: z.number().describe("Team ID"),
|
|
228
|
+
project_id: z.number().describe("Project ID"),
|
|
229
|
+
},
|
|
230
|
+
path: ({ team_id, project_id }) => `/api/v1/teams/${team_id}/projects/${project_id}`,
|
|
231
|
+
bodyKey: "project",
|
|
232
|
+
label: (project) => `project "${project.name}"`,
|
|
233
|
+
});
|
|
166
234
|
}
|