@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.
@@ -1,37 +1,56 @@
1
1
  import { z } from "zod";
2
2
  import { apiRequest } from "../api-client.js";
3
- import { buildMultipart, filePathsSchema, formatAttachments, readLocalFiles, } from "../attachments.js";
4
- function formatComment(comment, indent = 0) {
3
+ import { filePathsSchema, formatAttachments, uploadLocalFiles, } from "../attachments.js";
4
+ export function formatComment(comment, indent = 0) {
5
5
  const pad = " ".repeat(indent);
6
6
  const author = comment.user ? comment.user.name : "Unknown";
7
+ const owner = comment.owner_type
8
+ ? ` on ${comment.owner_type.toLowerCase()} ${comment.owner_id}`
9
+ : "";
10
+ const reply = comment.parent_id && indent === 0 ? ` (reply to #${comment.parent_id})` : "";
7
11
  const lines = [
8
- `${pad}#${comment.id} by ${author} at ${comment.created_at}`,
12
+ `${pad}#${comment.id} by ${author}${owner}${reply} at ${comment.created_at}`,
9
13
  `${pad} ${comment.body ?? ""}`,
10
14
  ];
11
- if (comment.attachments && comment.attachments.length > 0) {
12
- lines.push(`${pad} Attachments: ${formatAttachments(comment.attachments)}`);
15
+ if (comment.files && comment.files.length > 0) {
16
+ lines.push(`${pad} Attachments: ${formatAttachments(comment.files)}`);
13
17
  }
14
- if (comment.replies && comment.replies.length > 0) {
15
- for (const reply of comment.replies) {
16
- lines.push(formatComment(reply, indent + 1));
17
- }
18
+ for (const r of comment.replies ?? []) {
19
+ lines.push(formatComment(r, indent + 1));
18
20
  }
19
21
  return lines.join("\n");
20
22
  }
23
+ // Issue and project comments share one shape; only the owner path differs.
24
+ const ownerSchema = {
25
+ team_id: z.number().describe("Team ID"),
26
+ issue_id: z
27
+ .number()
28
+ .optional()
29
+ .describe("Issue ID (give exactly one of issue_id or project_id)"),
30
+ project_id: z
31
+ .number()
32
+ .optional()
33
+ .describe("Project ID (give exactly one of issue_id or project_id)"),
34
+ };
35
+ function commentsPath(args) {
36
+ const { team_id, issue_id, project_id } = args;
37
+ if ((issue_id === undefined) === (project_id === undefined)) {
38
+ throw new Error("Give exactly one of issue_id or project_id.");
39
+ }
40
+ return issue_id !== undefined
41
+ ? `/api/v1/teams/${team_id}/issues/${issue_id}/comments`
42
+ : `/api/v1/teams/${team_id}/projects/${project_id}/comments`;
43
+ }
21
44
  export function registerCommentTools(server) {
22
- server.tool("list_comments", "List all comments on an issue, with replies nested under their parent.", {
23
- team_id: z.number().describe("Team ID"),
24
- issue_id: z.number().describe("Issue ID"),
25
- }, async ({ team_id, issue_id }) => {
26
- const comments = await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}/comments`);
45
+ server.tool("list_comments", "List all comments on an issue or a project, with replies nested under their parent.", ownerSchema, async (args) => {
46
+ const comments = await apiRequest(commentsPath(args));
27
47
  const text = comments.map((c) => formatComment(c)).join("\n\n");
28
48
  return {
29
- content: [{ type: "text", text: text || "No comments on this issue." }],
49
+ content: [{ type: "text", text: text || "No comments found." }],
30
50
  };
31
51
  });
32
- server.tool("create_comment", "Post a new comment on an issue. The author is derived from the API token. Pass parent_id to reply to an existing comment, and file_paths to attach local files.", {
33
- team_id: z.number().describe("Team ID"),
34
- issue_id: z.number().describe("Issue ID"),
52
+ server.tool("create_comment", "Post a new comment on an issue or a project. The author is derived from the API token. Pass parent_id to reply to an existing comment, and file_paths to attach local files.", {
53
+ ...ownerSchema,
35
54
  body: z
36
55
  .string()
37
56
  .optional()
@@ -41,19 +60,60 @@ export function registerCommentTools(server) {
41
60
  .optional()
42
61
  .describe("Parent comment ID to reply to"),
43
62
  file_paths: filePathsSchema,
44
- }, async ({ team_id, issue_id, body, parent_id, file_paths }) => {
45
- const files = await readLocalFiles(file_paths ?? []);
46
- const fields = { body, parent_id };
47
- const comment = await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}/comments`, files.length > 0
48
- ? { method: "POST", form: buildMultipart("comment", fields, files) }
49
- : { method: "POST", body: { comment: fields } });
63
+ }, async ({ body, parent_id, file_paths, ...owner }) => {
64
+ const path = commentsPath(owner);
65
+ const uploads = await uploadLocalFiles(file_paths);
66
+ const comment = await apiRequest(path, {
67
+ method: "POST",
68
+ body: {
69
+ comment: { body, parent_id },
70
+ files: uploads.map((u) => u.signedId),
71
+ },
72
+ });
73
+ return {
74
+ content: [
75
+ { type: "text", text: `Comment posted:\n${formatComment(comment)}` },
76
+ ],
77
+ };
78
+ });
79
+ server.tool("delete_comment", "Delete a comment on an issue, along with its replies. Only the comment's author or a team admin can do this.", {
80
+ team_id: z.number().describe("Team ID"),
81
+ issue_id: z.number().describe("Issue ID"),
82
+ comment_id: z.number().describe("Comment ID"),
83
+ }, async ({ team_id, issue_id, comment_id }) => {
84
+ await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}/comments/${comment_id}`, { method: "DELETE" });
85
+ return {
86
+ content: [
87
+ { type: "text", text: `Comment ${comment_id} deleted (with any replies).` },
88
+ ],
89
+ };
90
+ });
91
+ server.tool("remove_comment_attachment", "Remove a file from a comment on an issue or a project. Only the comment's author or a team admin can do this. Get the attachment ID from list_comments.", {
92
+ ...ownerSchema,
93
+ comment_id: z.number().describe("Comment ID"),
94
+ attachment_id: z.number().describe("Attachment ID (shown by list_comments)"),
95
+ }, async ({ comment_id, attachment_id, ...owner }) => {
96
+ await apiRequest(`${commentsPath(owner)}/${comment_id}/attachments/${attachment_id}`, { method: "DELETE" });
50
97
  return {
51
98
  content: [
52
99
  {
53
100
  type: "text",
54
- text: `Comment posted:\n${formatComment(comment)}`,
101
+ text: `Attachment ${attachment_id} removed from comment ${comment_id}.`,
55
102
  },
56
103
  ],
57
104
  };
58
105
  });
106
+ server.tool("list_team_comments", "List every issue and project comment in a team as one flat feed, oldest change first. Use updated_since to see only recent comments.", {
107
+ team_id: z.number().describe("Team ID"),
108
+ updated_since: z
109
+ .string()
110
+ .optional()
111
+ .describe("Only comments created or edited at/after this ISO 8601 timestamp"),
112
+ }, async ({ team_id, updated_since }) => {
113
+ const comments = await apiRequest(`/api/v1/teams/${team_id}/comments`, { params: { updated_since } });
114
+ const text = comments.map((c) => formatComment(c)).join("\n\n");
115
+ return {
116
+ content: [{ type: "text", text: text || "No comments found." }],
117
+ };
118
+ });
59
119
  }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerDecisionTools(server: McpServer): void;
@@ -0,0 +1,64 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { z } from "zod";
3
+ import { apiRequest } from "../api-client.js";
4
+ const ownerSchema = {
5
+ team_id: z.number().describe("Team ID"),
6
+ issue_id: z
7
+ .number()
8
+ .optional()
9
+ .describe("Issue ID (give exactly one of issue_id or project_id)"),
10
+ project_id: z
11
+ .number()
12
+ .optional()
13
+ .describe("Project ID (give exactly one of issue_id or project_id)"),
14
+ };
15
+ function decisionsPath(args) {
16
+ const { team_id, issue_id, project_id } = args;
17
+ if ((issue_id === undefined) === (project_id === undefined)) {
18
+ throw new Error("Give exactly one of issue_id or project_id.");
19
+ }
20
+ return issue_id !== undefined
21
+ ? `/api/v1/teams/${team_id}/issues/${issue_id}/decisions`
22
+ : `/api/v1/teams/${team_id}/projects/${project_id}/decisions`;
23
+ }
24
+ export function registerDecisionTools(server) {
25
+ server.tool("create_decision", "Pin a decision (a short statement of what was decided) to an issue or a project. Keep the returned decision ID: there is no way to list decisions later, and unpin_decision needs it.", {
26
+ ...ownerSchema,
27
+ body: z.string().describe("The decision text (markdown allowed)"),
28
+ pinned_by_email: z
29
+ .string()
30
+ .optional()
31
+ .describe("Email of the team member to credit as pinning it"),
32
+ }, async ({ body, pinned_by_email, ...owner }) => {
33
+ const decision = await apiRequest(decisionsPath(owner), {
34
+ method: "POST",
35
+ body: {
36
+ // The API requires a unique source-message id (decisions normally
37
+ // come from pinned Hourglass chat messages); mint one per call.
38
+ hourglass_message_id: `mcp-${randomUUID()}`,
39
+ body_snapshot: body,
40
+ pinned_by_email,
41
+ },
42
+ });
43
+ const by = decision.pinned_by_user ? ` by ${decision.pinned_by_user.name}` : "";
44
+ return {
45
+ content: [
46
+ {
47
+ type: "text",
48
+ text: `Decision pinned${by} — ID: ${decision.id}\n ${decision.body_snapshot}`,
49
+ },
50
+ ],
51
+ };
52
+ });
53
+ server.tool("unpin_decision", "Unpin a decision from an issue or a project. It is kept as unpinned, not deleted.", {
54
+ ...ownerSchema,
55
+ decision_id: z.number().describe("Decision ID (from create_decision)"),
56
+ }, async ({ decision_id, ...owner }) => {
57
+ await apiRequest(`${decisionsPath(owner)}/${decision_id}`, {
58
+ method: "DELETE",
59
+ });
60
+ return {
61
+ content: [{ type: "text", text: `Decision ${decision_id} unpinned.` }],
62
+ };
63
+ });
64
+ }
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ interface DescribedResource {
4
+ description?: string | null;
5
+ }
6
+ interface SectionToolConfig<R extends DescribedResource> {
7
+ noun: "issue" | "project";
8
+ /** Zod shape for the ids that address one resource. */
9
+ idShape: z.ZodRawShape;
10
+ /** API path of the resource, from the tool args. */
11
+ path: (args: any) => string;
12
+ /** Key the PATCH body is nested under. */
13
+ bodyKey: string;
14
+ /** Resource identifier used in confirmations, from the PATCH response. */
15
+ label: (resource: R, args: any) => string;
16
+ }
17
+ export declare function registerDescriptionSectionTools<R extends DescribedResource>(server: McpServer, cfg: SectionToolConfig<R>): void;
18
+ export {};
@@ -0,0 +1,77 @@
1
+ import { z } from "zod";
2
+ import { apiRequest } from "../api-client.js";
3
+ import { SectionError, appendToSection, getSection, listSections, replaceSection, replaceText, } from "../description-sections.js";
4
+ const textResult = (text) => ({
5
+ content: [{ type: "text", text }],
6
+ });
7
+ // Splicer failures are expected: show the message to the agent as an error
8
+ // result. Anything else (network, auth) propagates.
9
+ function sectionErrorResult(err) {
10
+ if (err instanceof SectionError) {
11
+ return { ...textResult(err.message), isError: true };
12
+ }
13
+ throw err;
14
+ }
15
+ const headingArg = z
16
+ .string()
17
+ .describe('Exact heading text without the leading #s, e.g. "Goals"');
18
+ export function registerDescriptionSectionTools(server, cfg) {
19
+ const { noun, idShape, path, bodyKey, label } = cfg;
20
+ const upper = noun[0].toUpperCase() + noun.slice(1);
21
+ const note = ` Use this instead of update_${noun} for partial description edits.`;
22
+ const fetchDescription = async (args) => (await apiRequest(path(args))).description ?? "";
23
+ // Fetch, splice, PATCH. Returns a short confirmation, never the description.
24
+ const edit = async (args, splice, confirmation) => {
25
+ try {
26
+ const updated = splice(await fetchDescription(args));
27
+ const saved = await apiRequest(path(args), {
28
+ method: "PATCH",
29
+ body: { [bodyKey]: { description: updated } },
30
+ });
31
+ return textResult(confirmation(label(saved, args)));
32
+ }
33
+ catch (err) {
34
+ return sectionErrorResult(err);
35
+ }
36
+ };
37
+ server.tool(`list_${noun}_sections`, `List the headings (with levels) in ${noun === "issue" ? "an issue" : "a project"}'s description. Start here to see what sections exist before reading or editing one.`, idShape, async (args) => {
38
+ const sections = listSections(await fetchDescription(args));
39
+ return textResult(sections.length
40
+ ? sections.map((s) => `${"#".repeat(s.level)} ${s.heading}`).join("\n")
41
+ : "No sections found.");
42
+ });
43
+ server.tool(`get_${noun}_section`, `Read one section of ${noun === "issue" ? "an issue" : "a project"}'s description (heading excluded, subsections included) without loading the whole description. Use this instead of get_${noun} when you only need one section.`, { ...idShape, heading: headingArg }, async (args) => {
44
+ try {
45
+ const body = getSection(await fetchDescription(args), {
46
+ heading: args.heading,
47
+ });
48
+ return textResult(body || "(empty section)");
49
+ }
50
+ catch (err) {
51
+ return sectionErrorResult(err);
52
+ }
53
+ });
54
+ server.tool(`replace_${noun}_section`, `Replace the body of one section of ${noun === "issue" ? "an issue" : "a project"}'s description, keeping its heading. Use when rewriting most of a section; to add to the end use append_to_${noun}_section, for small tweaks use edit_${noun}_description.${note}`, {
55
+ ...idShape,
56
+ heading: headingArg,
57
+ body: z.string().describe("New section body in markdown (heading not included)"),
58
+ }, async (args) => edit(args, (d) => replaceSection(d, { heading: args.heading, body: args.body }), (id) => `Replaced section "${args.heading}" in ${id}.`));
59
+ server.tool(`append_to_${noun}_section`, `Append text to the end of one section of ${noun === "issue" ? "an issue" : "a project"}'s description. Use when adding to a section without touching what is there; to rewrite it use replace_${noun}_section.${note}`, {
60
+ ...idShape,
61
+ heading: headingArg,
62
+ text: z.string().describe("Markdown text to append"),
63
+ }, async (args) => edit(args, (d) => appendToSection(d, { heading: args.heading, text: args.text }), (id) => `Appended to section "${args.heading}" in ${id}.`));
64
+ server.tool(`edit_${noun}_description`, `Find-and-replace literal text in ${noun === "issue" ? "an issue" : "a project"}'s description. Use for small edits inside a section (a word, a line, a checkbox); fails if old_string is not found or matches more than once unless replace_all is true.${note}`, {
65
+ ...idShape,
66
+ old_string: z.string().describe("Exact text to find"),
67
+ new_string: z.string().describe("Replacement text"),
68
+ replace_all: z
69
+ .boolean()
70
+ .optional()
71
+ .describe("Replace every match instead of requiring exactly one"),
72
+ }, async (args) => edit(args, (d) => replaceText(d, {
73
+ oldString: args.old_string,
74
+ newString: args.new_string,
75
+ replaceAll: args.replace_all,
76
+ }), (id) => `Edited description of ${id}.`));
77
+ }
@@ -1,6 +1,6 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { type Attachment } from "../attachments.js";
3
- interface Issue {
3
+ export interface Issue {
4
4
  id: number;
5
5
  identifier: string;
6
6
  title: string;
@@ -28,16 +28,21 @@ interface Issue {
28
28
  id: number;
29
29
  name: string;
30
30
  }[];
31
- attachments?: Attachment[];
32
- milestone?: {
31
+ files?: Attachment[];
32
+ parent_issue_id?: number | null;
33
+ parent_issue?: {
33
34
  id: number;
34
- name: string;
35
+ identifier: string;
35
36
  } | null;
36
- parent_issue?: {
37
+ sub_issues?: {
37
38
  id: number;
38
39
  identifier: string;
39
40
  title: string;
40
- } | null;
41
+ lane: {
42
+ id: number;
43
+ name: string;
44
+ } | null;
45
+ }[];
41
46
  blocking_issues?: {
42
47
  id: number;
43
48
  identifier: string;
@@ -57,5 +62,40 @@ interface Issue {
57
62
  updated_at: string;
58
63
  }
59
64
  export declare function formatIssue(issue: Issue, detailed?: boolean): string;
65
+ interface ActivityChange {
66
+ field: string;
67
+ from: unknown;
68
+ to: unknown;
69
+ }
70
+ export interface ActivityEntry {
71
+ type: "version" | "dependency" | "comment" | "reference";
72
+ id: number;
73
+ cursor: string;
74
+ created_at: string;
75
+ actor?: {
76
+ id: number;
77
+ name: string;
78
+ } | null;
79
+ user?: {
80
+ id: number;
81
+ name: string;
82
+ } | null;
83
+ description?: string;
84
+ changes?: ActivityChange[];
85
+ comment?: {
86
+ id: number;
87
+ body: string | null;
88
+ user: {
89
+ name: string;
90
+ } | null;
91
+ };
92
+ source_issue?: {
93
+ identifier: string;
94
+ title: string;
95
+ };
96
+ source_type?: string;
97
+ }
98
+ export declare function formatActivityEntry(entry: ActivityEntry): string;
99
+ export declare function formatActivityPage(entries: ActivityEntry[], nextBeforeId: string | null): string;
60
100
  export declare function registerIssueTools(server: McpServer): void;
61
101
  export {};