@arii/boomtick-mcp 0.6.1 → 0.7.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.
Files changed (141) hide show
  1. package/.mcp/schemas/boomtick.health.json +22 -3
  2. package/.mcp/schemas/boomtick_health.json +22 -3
  3. package/.mcp/schemas/github.checkout_branch.json +16 -3
  4. package/.mcp/schemas/github.comment_triage_summary.json +16 -3
  5. package/.mcp/schemas/github.create_issue.json +72 -3
  6. package/.mcp/schemas/github.create_pull_request.json +16 -3
  7. package/.mcp/schemas/github.get_merge_conflict_files.json +40 -3
  8. package/.mcp/schemas/github.get_pr.json +12 -3
  9. package/.mcp/schemas/github.get_pr_commits.json +12 -3
  10. package/.mcp/schemas/github.get_pr_diff.json +30 -3
  11. package/.mcp/schemas/github.get_pr_reviews.json +24 -3
  12. package/.mcp/schemas/github.issue_comment.json +19 -3
  13. package/.mcp/schemas/github.issue_update.json +72 -3
  14. package/.mcp/schemas/github.issue_view.json +17 -3
  15. package/.mcp/schemas/github.open_replacement_pr.json +16 -3
  16. package/.mcp/schemas/github.search_open_prs.json +130 -3
  17. package/.mcp/schemas/github_checkout_branch.json +16 -3
  18. package/.mcp/schemas/github_comment_triage_summary.json +16 -3
  19. package/.mcp/schemas/github_create_issue.json +72 -3
  20. package/.mcp/schemas/github_create_pull_request.json +16 -3
  21. package/.mcp/schemas/github_get_merge_conflict_files.json +40 -3
  22. package/.mcp/schemas/github_get_pr.json +12 -3
  23. package/.mcp/schemas/github_get_pr_commits.json +12 -3
  24. package/.mcp/schemas/github_get_pr_diff.json +30 -3
  25. package/.mcp/schemas/github_get_pr_reviews.json +24 -3
  26. package/.mcp/schemas/github_issue_comment.json +19 -3
  27. package/.mcp/schemas/github_issue_update.json +72 -3
  28. package/.mcp/schemas/github_issue_view.json +17 -3
  29. package/.mcp/schemas/github_open_replacement_pr.json +16 -3
  30. package/.mcp/schemas/github_search_open_prs.json +130 -3
  31. package/.mcp/schemas/jules.cancel_session.json +38 -3
  32. package/.mcp/schemas/jules.create_session.json +52 -3
  33. package/.mcp/schemas/jules.get_messages.json +19 -3
  34. package/.mcp/schemas/jules.get_pr.json +23 -3
  35. package/.mcp/schemas/jules.get_session.json +38 -3
  36. package/.mcp/schemas/jules.list_sessions.json +53 -3
  37. package/.mcp/schemas/jules.send_message.json +31 -3
  38. package/.mcp/schemas/jules.trigger_feedback.json +28 -3
  39. package/.mcp/schemas/jules_cancel_session.json +38 -3
  40. package/.mcp/schemas/jules_create_session.json +52 -3
  41. package/.mcp/schemas/jules_get_messages.json +19 -3
  42. package/.mcp/schemas/jules_get_pr.json +23 -3
  43. package/.mcp/schemas/jules_get_session.json +38 -3
  44. package/.mcp/schemas/jules_list_sessions.json +53 -3
  45. package/.mcp/schemas/jules_send_message.json +31 -3
  46. package/.mcp/schemas/jules_trigger_feedback.json +28 -3
  47. package/.mcp/schemas/repo.check_jules_status.json +128 -0
  48. package/.mcp/schemas/repo.commit_patch.json +23 -3
  49. package/.mcp/schemas/repo.create_branch.json +28 -3
  50. package/.mcp/schemas/repo.create_repair_branch.json +31 -3
  51. package/.mcp/schemas/repo.get_changed_files.json +11 -3
  52. package/.mcp/schemas/repo.get_command_schema.json +29 -3
  53. package/.mcp/schemas/repo.get_package_scripts.json +11 -3
  54. package/.mcp/schemas/repo.get_workflow_runs.json +12 -3
  55. package/.mcp/schemas/repo.logs.json +14 -3
  56. package/.mcp/schemas/repo.multi_exec.json +89 -0
  57. package/.mcp/schemas/repo.read_agent_context.json +117 -5
  58. package/.mcp/schemas/repo.read_ci_logs.json +46 -3
  59. package/.mcp/schemas/repo.run_tests.json +31 -3
  60. package/.mcp/schemas/repo_check_jules_status.json +128 -0
  61. package/.mcp/schemas/repo_commit_patch.json +23 -3
  62. package/.mcp/schemas/repo_create_branch.json +28 -3
  63. package/.mcp/schemas/repo_create_repair_branch.json +31 -3
  64. package/.mcp/schemas/repo_get_changed_files.json +11 -3
  65. package/.mcp/schemas/repo_get_command_schema.json +29 -3
  66. package/.mcp/schemas/repo_get_package_scripts.json +11 -3
  67. package/.mcp/schemas/repo_get_workflow_runs.json +12 -3
  68. package/.mcp/schemas/repo_logs.json +14 -3
  69. package/.mcp/schemas/repo_multi_exec.json +89 -0
  70. package/.mcp/schemas/repo_read_agent_context.json +117 -5
  71. package/.mcp/schemas/repo_read_ci_logs.json +46 -3
  72. package/.mcp/schemas/repo_run_tests.json +31 -3
  73. package/CHANGELOG.md +22 -0
  74. package/README.md +29 -6
  75. package/actions/run-project-gate/action.yml +1 -1
  76. package/dist/config/dynamic.js +34 -0
  77. package/dist/config/github.js +16 -0
  78. package/dist/config/repo.js +28 -0
  79. package/dist/config.js +16 -81
  80. package/dist/config.test.js +10 -3
  81. package/dist/http.js +10 -0
  82. package/dist/mcp/definitions.js +76 -41
  83. package/dist/mcp/http.js +32 -9
  84. package/dist/mcp/http.test.js +62 -4
  85. package/dist/mcp/server.js +69 -10
  86. package/dist/mcp/server.test.js +59 -1
  87. package/dist/tools/contract.js +1079 -45
  88. package/dist/tools/github.comment_triage_summary.js +3 -10
  89. package/dist/tools/github.get_merge_conflict_files.js +4 -2
  90. package/dist/tools/github.get_pr_diff.js +3 -11
  91. package/dist/tools/jules/cancel-session.js +2 -9
  92. package/dist/tools/jules/cli.js +31 -0
  93. package/dist/tools/jules/create-session.js +12 -2
  94. package/dist/tools/jules/create-session.test.js +7 -0
  95. package/dist/tools/jules/get-messages.js +2 -9
  96. package/dist/tools/jules/list-sessions.js +4 -35
  97. package/dist/tools/jules/send-message.js +2 -9
  98. package/dist/tools/jules/session.js +26 -0
  99. package/dist/tools/jules/shared.js +2 -50
  100. package/dist/tools/jules/trigger-feedback.js +2 -10
  101. package/dist/tools/repo.check_jules_status.js +148 -0
  102. package/dist/tools/repo.check_jules_status.test.js +47 -0
  103. package/dist/tools/repo.multi_exec.js +21 -0
  104. package/dist/tools/repo.multi_exec.test.js +13 -0
  105. package/dist/tools/repo.read_agent_context.js +65 -3
  106. package/dist/tools/repo.read_agent_context.test.js +30 -1
  107. package/dist/tools/repo.run_tests.js +13 -1
  108. package/package.json +3 -2
  109. package/scripts/sync-contracts.ts +11 -2
  110. package/src/config/dynamic.ts +37 -0
  111. package/src/config/github.ts +16 -0
  112. package/src/config/repo.ts +36 -0
  113. package/src/config.test.ts +11 -3
  114. package/src/config.ts +16 -89
  115. package/src/http.ts +13 -0
  116. package/src/mcp/definitions.ts +110 -41
  117. package/src/mcp/http.test.ts +75 -5
  118. package/src/mcp/http.ts +40 -14
  119. package/src/mcp/server.test.ts +72 -1
  120. package/src/mcp/server.ts +72 -11
  121. package/src/tools/contract.ts +1194 -36
  122. package/src/tools/github.comment_triage_summary.ts +3 -12
  123. package/src/tools/github.get_merge_conflict_files.ts +5 -2
  124. package/src/tools/github.get_pr_diff.ts +3 -13
  125. package/src/tools/jules/cancel-session.ts +2 -11
  126. package/src/tools/jules/cli.ts +42 -0
  127. package/src/tools/jules/create-session.test.ts +9 -0
  128. package/src/tools/jules/create-session.ts +13 -2
  129. package/src/tools/jules/get-messages.ts +2 -11
  130. package/src/tools/jules/list-sessions.ts +5 -39
  131. package/src/tools/jules/send-message.ts +2 -11
  132. package/src/tools/jules/session.ts +28 -0
  133. package/src/tools/jules/shared.ts +2 -63
  134. package/src/tools/jules/trigger-feedback.ts +2 -13
  135. package/src/tools/repo.check_jules_status.test.ts +55 -0
  136. package/src/tools/repo.check_jules_status.ts +176 -0
  137. package/src/tools/repo.multi_exec.test.ts +15 -0
  138. package/src/tools/repo.multi_exec.ts +23 -0
  139. package/src/tools/repo.read_agent_context.test.ts +35 -1
  140. package/src/tools/repo.read_agent_context.ts +68 -3
  141. package/src/tools/repo.run_tests.ts +14 -1
@@ -1,23 +1,16 @@
1
1
  import { z } from "zod";
2
- import { runCommand } from "../lib/shell.js";
2
+ import { runTDCli } from "./jules/cli.js";
3
3
  export const CommentTriageSummaryInputSchema = z.object({
4
4
  prNumber: z.number(),
5
5
  body: z.string(),
6
6
  });
7
7
  export async function commentTriageSummaryHandler(args) {
8
- const result = await runCommand("td", [
8
+ const output = await runTDCli([
9
9
  "gh",
10
10
  "post-comment",
11
11
  "--pr", args.prNumber.toString(),
12
12
  "--body", args.body
13
- ]);
14
- if (result.exitCode !== 0) {
15
- throw new Error(`Failed to comment on PR: ${result.stderr}`);
16
- }
17
- const output = JSON.parse(result.stdout);
18
- if (output.status === "error") {
19
- throw new Error(`Failed to comment on PR: ${output.message}`);
20
- }
13
+ ], "comment on PR");
21
14
  return {
22
15
  success: true,
23
16
  commentUrl: output.html_url || output.url
@@ -9,10 +9,12 @@ export async function getMergeConflictFilesHandler(args) {
9
9
  const baseBranch = args.baseBranch || "main";
10
10
  const headRef = args.headRef || "HEAD";
11
11
  const conflictFiles = await getMergeConflictFiles(baseBranch, headRef);
12
+ const hasConflicts = conflictFiles.length > 0;
12
13
  return {
13
- prNumber: args.prNumber,
14
+ hasConflicts,
15
+ conflictedFiles: conflictFiles,
16
+ prNumber: args.prNumber ?? null,
14
17
  baseBranch,
15
18
  headRef,
16
- conflictFiles,
17
19
  };
18
20
  }
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { runCommand } from "../lib/shell.js";
3
2
  import { resolveRepo } from "../lib/git.js";
3
+ import { runTDCli } from "./jules/cli.js";
4
4
  export const GetPrDiffInputSchema = z.object({
5
5
  prNumber: z.number().describe("The number of the pull request to get the diff for."),
6
6
  repo: z.string().optional().describe("The target repository override (e.g. org/repo)."),
@@ -8,17 +8,9 @@ export const GetPrDiffInputSchema = z.object({
8
8
  export async function getPrDiffHandler(args) {
9
9
  const params = GetPrDiffInputSchema.parse(args);
10
10
  const targetRepo = resolveRepo(params.repo);
11
- const result = await runCommand("td", [
11
+ const output = await runTDCli([
12
12
  "gh", "pr-diff", params.prNumber.toString(), "--repo", targetRepo
13
- ]);
14
- if (result.exitCode !== 0) {
15
- throw new Error(`Failed to get PR diff: ${result.stderr}`);
16
- }
17
- const output = JSON.parse(result.stdout);
18
- if (output.status === "error") {
19
- throw new Error(`Failed to get PR diff: ${output.message}`);
20
- }
21
- // Every TypeScript tool file must be a pure routing shim
13
+ ], "get PR diff");
22
14
  return {
23
15
  prNumber: output.prNumber,
24
16
  files: output.files,
@@ -1,17 +1,10 @@
1
1
  import { z } from "zod";
2
- import { runCommand } from "../../lib/shell.js";
2
+ import { runTDCli } from "./cli.js";
3
3
  export const CancelJulesSessionInputSchema = z.object({
4
4
  sessionId: z.string(),
5
5
  });
6
6
  export async function cancelJulesSessionHandler(input) {
7
- const result = await runCommand("td", ["agent", "cancel", input.sessionId]);
8
- if (result.exitCode !== 0) {
9
- throw new Error(`Failed to cancel session: ${result.stderr}`);
10
- }
11
- const output = JSON.parse(result.stdout);
12
- if (output.status === "error") {
13
- throw new Error(`Failed to cancel session: ${output.message}`);
14
- }
7
+ await runTDCli(["agent", "cancel", input.sessionId], "cancel session");
15
8
  return {
16
9
  id: input.sessionId.replace("sessions/", ""),
17
10
  status: "FAILED",
@@ -0,0 +1,31 @@
1
+ import { runCommand } from "../../lib/shell.js";
2
+ function tryParseJson(text) {
3
+ try {
4
+ return JSON.parse(text);
5
+ }
6
+ catch {
7
+ return null;
8
+ }
9
+ }
10
+ export async function runTDCli(args, actionName) {
11
+ const result = await runCommand("td", args);
12
+ const stdout = result.stdout.trim();
13
+ const output = stdout.startsWith("{") ? tryParseJson(stdout) : null;
14
+ if (output?.status === "error") {
15
+ const errorMsg = output.message ?? "Unknown error";
16
+ if (actionName) {
17
+ throw new Error(`Failed to ${actionName}: ${errorMsg}`);
18
+ }
19
+ throw new Error(`td returned error: ${errorMsg}`);
20
+ }
21
+ if (result.exitCode !== 0) {
22
+ if (actionName) {
23
+ throw new Error(`Failed to ${actionName}: ${result.stderr || stdout}`);
24
+ }
25
+ throw new Error(`td command failed (${args.join(" ")}): ${result.stderr || stdout}`);
26
+ }
27
+ if (!output) {
28
+ throw new Error(`td returned non-JSON output with exit code 0: ${stdout}`);
29
+ }
30
+ return output;
31
+ }
@@ -4,16 +4,26 @@ export const CreateJulesSessionInputSchema = z.object({
4
4
  task: z.string(),
5
5
  branch: z.string().optional(),
6
6
  pr: z.number().optional(),
7
+ repo: z.string().optional(),
7
8
  });
8
9
  export async function createJulesSessionHandler(input) {
9
10
  let branch = input.branch;
10
11
  if (!branch && input.pr) {
11
- const prData = await runTDCli(["gh", "view", input.pr.toString()]);
12
+ const ghArgs = ["gh", "view", input.pr.toString()];
13
+ if (input.repo) {
14
+ ghArgs.push("--repo", input.repo);
15
+ }
16
+ const prData = await runTDCli(ghArgs);
12
17
  branch = prData.pr.headRefName;
13
18
  }
14
19
  if (!branch) {
15
20
  branch = process.env.DEFAULT_BASE_BRANCH || "main";
16
21
  }
17
- const output = await runTDCli(["agent", "dispatch", branch, input.task]);
22
+ const dispatchArgs = ["agent", "dispatch"];
23
+ if (input.repo) {
24
+ dispatchArgs.push("--repo", input.repo);
25
+ }
26
+ dispatchArgs.push(branch, input.task);
27
+ const output = await runTDCli(dispatchArgs);
18
28
  return parseJulesSession(output.session || output);
19
29
  }
@@ -41,6 +41,13 @@ describe("createJulesSessionHandler", () => {
41
41
  "agent", "dispatch", "feature-x", "do work"
42
42
  ]);
43
43
  });
44
+ it("should create a session with repo parameter", async () => {
45
+ const result = await createJulesSessionHandler({ task: "do work", branch: "main", repo: "arii/portfolio" });
46
+ expect(result.id).toBe("1234567890");
47
+ expect(shell.runCommand).toHaveBeenCalledWith("td", [
48
+ "agent", "dispatch", "--repo", "arii/portfolio", "main", "do work"
49
+ ]);
50
+ });
44
51
  it("should create a session with PR number", async () => {
45
52
  vi.mocked(shell.runCommand).mockImplementation(async (cmd, args) => {
46
53
  if (args[1] === "view") {
@@ -1,17 +1,10 @@
1
1
  import { z } from "zod";
2
- import { runCommand } from "../../lib/shell.js";
2
+ import { runTDCli } from "./cli.js";
3
3
  export const GetJulesMessagesInputSchema = z.object({
4
4
  sessionId: z.string(),
5
5
  });
6
6
  export async function getJulesMessagesHandler(input) {
7
- const result = await runCommand("td", ["agent", "messages", input.sessionId]);
8
- if (result.exitCode !== 0) {
9
- throw new Error(`Failed to get messages: ${result.stderr}`);
10
- }
11
- const output = JSON.parse(result.stdout);
12
- if (output.status === "error") {
13
- throw new Error(`Failed to get messages: ${output.message}`);
14
- }
7
+ const output = await runTDCli(["agent", "messages", input.sessionId], "get messages");
15
8
  return {
16
9
  id: input.sessionId.replace("sessions/", ""),
17
10
  messages: output.messages,
@@ -1,43 +1,12 @@
1
1
  import { z } from "zod";
2
- import { runCommand } from "../../lib/shell.js";
2
+ import { runTDCli } from "./cli.js";
3
+ import { parseJulesSession } from "./session.js";
3
4
  export const ListJulesSessionsInputSchema = z.object({
4
5
  pageSize: z.number().optional(),
5
6
  pageToken: z.string().optional(),
6
7
  });
7
8
  export async function listJulesSessionsHandler(input) {
8
- const result = await runCommand("td", ["agent", "sync"]);
9
- if (result.exitCode !== 0) {
10
- throw new Error(`Failed to list sessions: ${result.stderr}`);
11
- }
12
- const output = JSON.parse(result.stdout);
13
- if (output.status === "error") {
14
- throw new Error(`Failed to list sessions: ${output.message}`);
15
- }
9
+ const output = await runTDCli(["agent", "sync"], "list sessions");
16
10
  const sessions = output.sessions || [];
17
- return sessions.map((session) => {
18
- const name = session.name || "";
19
- const id = name.startsWith("sessions/") ? name.substring(9) : name;
20
- let status = "PENDING";
21
- if (session.state === "SUCCEEDED" || session.state === "COMPLETED")
22
- status = "COMPLETED";
23
- else if (session.state === "FAILED" || session.state === "CANCELLED" || session.state === "TERMINATED")
24
- status = "FAILED";
25
- else if (session.state === "IN_PROGRESS")
26
- status = "IN_PROGRESS";
27
- let pullRequestUrl;
28
- if (session.outputs && Array.isArray(session.outputs)) {
29
- for (const out of session.outputs) {
30
- if (out.pullRequest && out.pullRequest.url) {
31
- pullRequestUrl = out.pullRequest.url;
32
- break;
33
- }
34
- }
35
- }
36
- return {
37
- id,
38
- status,
39
- createdAt: session.createTime ? new Date(session.createTime) : new Date(),
40
- pullRequestUrl,
41
- };
42
- });
11
+ return sessions.map((session) => parseJulesSession(session));
43
12
  }
@@ -1,19 +1,12 @@
1
1
  import { z } from "zod";
2
- import { runCommand } from "../../lib/shell.js";
2
+ import { runTDCli } from "./cli.js";
3
3
  export const SendJulesMessageInputSchema = z.object({
4
4
  sessionId: z.union([z.string(), z.array(z.string())]),
5
5
  message: z.string(),
6
6
  });
7
7
  export async function sendJulesMessageHandler(input) {
8
8
  const sessionIds = Array.isArray(input.sessionId) ? input.sessionId.join(",") : input.sessionId;
9
- const result = await runCommand("td", ["agent", "send", sessionIds, input.message]);
10
- if (result.exitCode !== 0) {
11
- throw new Error(`Failed to send message: ${result.stderr}`);
12
- }
13
- const output = JSON.parse(result.stdout);
14
- if (output.status === "error") {
15
- throw new Error(`Failed to send message: ${output.message}`);
16
- }
9
+ await runTDCli(["agent", "send", sessionIds, input.message], "send message");
17
10
  return {
18
11
  id: Array.isArray(input.sessionId) ? input.sessionId.map(id => id.replace("sessions/", "")) : input.sessionId.replace("sessions/", ""),
19
12
  status: "success",
@@ -0,0 +1,26 @@
1
+ export function parseJulesSession(data) {
2
+ const name = data.name || "";
3
+ const id = name.startsWith("sessions/") ? name.substring(9) : name;
4
+ let status = "PENDING";
5
+ if (data.state === "SUCCEEDED" || data.state === "COMPLETED")
6
+ status = "COMPLETED";
7
+ else if (data.state === "FAILED" || data.state === "CANCELLED" || data.state === "TERMINATED")
8
+ status = "FAILED";
9
+ else if (data.state === "IN_PROGRESS")
10
+ status = "IN_PROGRESS";
11
+ let pullRequestUrl;
12
+ if (data.outputs && Array.isArray(data.outputs)) {
13
+ for (const out of data.outputs) {
14
+ if (out.pullRequest && out.pullRequest.url) {
15
+ pullRequestUrl = out.pullRequest.url;
16
+ break;
17
+ }
18
+ }
19
+ }
20
+ return {
21
+ id,
22
+ status,
23
+ createdAt: data.createTime ? new Date(data.createTime) : new Date(),
24
+ pullRequestUrl,
25
+ };
26
+ }
@@ -1,50 +1,2 @@
1
- import { runCommand } from "../../lib/shell.js";
2
- function tryParseJson(text) {
3
- try {
4
- return JSON.parse(text);
5
- }
6
- catch {
7
- return null;
8
- }
9
- }
10
- export async function runTDCli(args) {
11
- const result = await runCommand("td", args);
12
- const stdout = result.stdout.trim();
13
- const output = stdout.startsWith("{") ? tryParseJson(stdout) : null;
14
- if (output?.status === "error") {
15
- throw new Error(`td returned error: ${output.message ?? "Unknown error"}`);
16
- }
17
- if (result.exitCode !== 0) {
18
- throw new Error(`td command failed (${args.join(" ")}): ${result.stderr || stdout}`);
19
- }
20
- if (!output) {
21
- throw new Error(`td returned non-JSON output with exit code 0: ${stdout}`);
22
- }
23
- return output;
24
- }
25
- export function parseJulesSession(data) {
26
- const name = data.name || "";
27
- const id = name.startsWith("sessions/") ? name.substring(9) : name;
28
- let status = "PENDING";
29
- if (data.state === "SUCCEEDED" || data.state === "COMPLETED")
30
- status = "COMPLETED";
31
- else if (data.state === "FAILED" || data.state === "CANCELLED" || data.state === "TERMINATED")
32
- status = "FAILED";
33
- else if (data.state === "IN_PROGRESS")
34
- status = "IN_PROGRESS";
35
- let pullRequestUrl;
36
- if (data.outputs && Array.isArray(data.outputs)) {
37
- for (const out of data.outputs) {
38
- if (out.pullRequest && out.pullRequest.url) {
39
- pullRequestUrl = out.pullRequest.url;
40
- break;
41
- }
42
- }
43
- }
44
- return {
45
- id,
46
- status,
47
- createdAt: data.createTime ? new Date(data.createTime) : new Date(),
48
- pullRequestUrl,
49
- };
50
- }
1
+ export * from "./cli.js";
2
+ export * from "./session.js";
@@ -1,16 +1,8 @@
1
1
  import { z } from "zod";
2
- import { runCommand } from "../../lib/shell.js";
2
+ import { runTDCli } from "./cli.js";
3
3
  export const TriggerJulesFeedbackInputSchema = z.object({
4
4
  sessionId: z.string(),
5
5
  });
6
6
  export async function triggerJulesFeedbackHandler(input) {
7
- const result = await runCommand("td", ["agent", "trigger-feedback", input.sessionId]);
8
- if (result.exitCode !== 0) {
9
- throw new Error(`Failed to trigger feedback: ${result.stderr}`);
10
- }
11
- const output = JSON.parse(result.stdout);
12
- if (output.status === "error") {
13
- throw new Error(`Failed to trigger feedback: ${output.message}`);
14
- }
15
- return output;
7
+ return await runTDCli(["agent", "trigger-feedback", input.sessionId], "trigger feedback");
16
8
  }
@@ -0,0 +1,148 @@
1
+ import { z } from "zod";
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import * as crypto from "crypto";
5
+ import { config } from "../config.js";
6
+ export const CheckJulesStatusInputSchema = z.object({
7
+ sessionId: z.string().optional().describe("The unique ID or task ID of the Jules session."),
8
+ commitSha: z.string().optional().describe("Commit SHA for idempotency key verification."),
9
+ failureLog: z.string().optional().describe("Failure log content for idempotency key calculation."),
10
+ poll: z.boolean().optional().describe("Whether to poll until session completion or timeout."),
11
+ timeoutMs: z.number().int().optional().describe("Timeout in milliseconds when polling."),
12
+ intervalMs: z.number().int().optional().describe("Polling interval in milliseconds."),
13
+ });
14
+ function calculateHash(commitSha, failureLog) {
15
+ const hash = crypto.createHash("sha256");
16
+ return hash.update(`${commitSha}:${failureLog.trim()}`).digest("hex");
17
+ }
18
+ export async function checkJulesStatusHandler(input) {
19
+ let resolvedTaskId = input.sessionId || process.env.TASK_ID;
20
+ if (!resolvedTaskId) {
21
+ return {
22
+ sessionId: "",
23
+ status: "NOT_FOUND",
24
+ completed: false,
25
+ message: "No session ID provided.",
26
+ };
27
+ }
28
+ const sessionId = resolvedTaskId.startsWith("sessions/") ? resolvedTaskId : `sessions/${resolvedTaskId}`;
29
+ const apiKey = process.env.JULES_API_KEY;
30
+ if (!apiKey) {
31
+ return {
32
+ sessionId,
33
+ status: "NOT_FOUND",
34
+ completed: false,
35
+ message: "JULES_API_KEY environment variable not set.",
36
+ };
37
+ }
38
+ const commitSha = input.commitSha || process.env.GITHUB_SHA || process.env.COMMIT_SHA;
39
+ let idempotencyHash;
40
+ let isDuplicate = false;
41
+ if (commitSha && input.failureLog) {
42
+ idempotencyHash = calculateHash(commitSha, input.failureLog);
43
+ const artifactsDir = path.join(config.repoPath || process.cwd(), "artifacts");
44
+ const hashTrackingFile = path.join(artifactsDir, `.jules-dispatch-${sessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}.hash`);
45
+ if (fs.existsSync(hashTrackingFile)) {
46
+ try {
47
+ const existingHash = fs.readFileSync(hashTrackingFile, "utf8").trim();
48
+ if (existingHash === idempotencyHash) {
49
+ isDuplicate = true;
50
+ }
51
+ }
52
+ catch (e) {
53
+ console.warn("⚠️ Could not read previous Jules dispatch hash file during status check:", e);
54
+ }
55
+ }
56
+ }
57
+ const url = `https://jules.googleapis.com/v1alpha/${sessionId}`;
58
+ const poll = input.poll ?? false;
59
+ const timeoutMs = input.timeoutMs ?? 60000;
60
+ const intervalMs = input.intervalMs ?? 5000;
61
+ const startTime = Date.now();
62
+ const fetchSession = async () => {
63
+ const response = await fetch(url, {
64
+ method: "GET",
65
+ headers: {
66
+ "Content-Type": "application/json",
67
+ "x-goog-api-key": apiKey,
68
+ },
69
+ });
70
+ if (!response.ok) {
71
+ return null;
72
+ }
73
+ return await response.json();
74
+ };
75
+ while (true) {
76
+ let sessionData = null;
77
+ try {
78
+ sessionData = await fetchSession();
79
+ }
80
+ catch (e) {
81
+ console.warn(`⚠️ Error fetching Jules session status for ${sessionId}:`, e);
82
+ }
83
+ if (!sessionData) {
84
+ return {
85
+ sessionId,
86
+ status: "NOT_FOUND",
87
+ completed: false,
88
+ idempotencyHash,
89
+ isDuplicate,
90
+ message: `Failed to retrieve session data for ${sessionId}`,
91
+ };
92
+ }
93
+ const rawState = sessionData.state || "UNKNOWN";
94
+ let status = "IN_PROGRESS";
95
+ if (rawState === "SUCCEEDED" || rawState === "COMPLETED") {
96
+ status = "COMPLETED";
97
+ }
98
+ else if (rawState === "FAILED" || rawState === "CANCELLED" || rawState === "TERMINATED") {
99
+ status = "FAILED";
100
+ }
101
+ else if (rawState === "IN_PROGRESS" || rawState === "PENDING") {
102
+ status = "IN_PROGRESS";
103
+ }
104
+ let remediationBranch;
105
+ let pullRequestUrl;
106
+ if (sessionData.sourceContext?.githubRepoContext?.startingBranch) {
107
+ remediationBranch = sessionData.sourceContext.githubRepoContext.startingBranch;
108
+ }
109
+ if (Array.isArray(sessionData.outputs)) {
110
+ for (const output of sessionData.outputs) {
111
+ if (output?.pullRequest?.url) {
112
+ pullRequestUrl = output.pullRequest.url;
113
+ }
114
+ if (output?.pullRequest?.branch || output?.gitBranch) {
115
+ remediationBranch = output?.pullRequest?.branch || output?.gitBranch;
116
+ }
117
+ }
118
+ }
119
+ const completed = status === "COMPLETED";
120
+ if (!poll || status === "COMPLETED" || status === "FAILED") {
121
+ return {
122
+ sessionId,
123
+ status,
124
+ rawState,
125
+ completed,
126
+ remediationBranch,
127
+ pullRequestUrl,
128
+ idempotencyHash,
129
+ isDuplicate,
130
+ message: `Session state: ${rawState}`,
131
+ };
132
+ }
133
+ if (Date.now() - startTime >= timeoutMs) {
134
+ return {
135
+ sessionId,
136
+ status: "TIMED_OUT",
137
+ rawState,
138
+ completed: false,
139
+ remediationBranch,
140
+ pullRequestUrl,
141
+ idempotencyHash,
142
+ isDuplicate,
143
+ message: `Polling timed out after ${timeoutMs}ms (current state: ${rawState})`,
144
+ };
145
+ }
146
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
147
+ }
148
+ }
@@ -0,0 +1,47 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
+ import { checkJulesStatusHandler } from "./repo.check_jules_status.js";
3
+ describe("repo.check_jules_status MCP Tool Handler", () => {
4
+ const originalEnv = process.env;
5
+ beforeEach(() => {
6
+ vi.clearAllMocks();
7
+ process.env = { ...originalEnv };
8
+ delete process.env.TASK_ID;
9
+ delete process.env.JULES_API_KEY;
10
+ global.fetch = vi.fn();
11
+ });
12
+ afterEach(() => {
13
+ process.env = originalEnv;
14
+ vi.restoreAllMocks();
15
+ });
16
+ it("returns NOT_FOUND status if no session ID or JULES_API_KEY is available", async () => {
17
+ const result = await checkJulesStatusHandler({});
18
+ expect(result.status).toBe("NOT_FOUND");
19
+ expect(result.completed).toBe(false);
20
+ });
21
+ it("checks Jules session status and returns response object", async () => {
22
+ process.env.JULES_API_KEY = "test-api-key";
23
+ vi.mocked(global.fetch).mockResolvedValue({
24
+ ok: true,
25
+ json: vi.fn().mockResolvedValue({
26
+ name: "sessions/test-session-123",
27
+ state: "SUCCEEDED",
28
+ outputs: [
29
+ {
30
+ pullRequest: {
31
+ url: "https://github.com/org/repo/pull/100",
32
+ branch: "remediation-branch-123",
33
+ },
34
+ },
35
+ ],
36
+ }),
37
+ });
38
+ const result = await checkJulesStatusHandler({
39
+ sessionId: "test-session-123",
40
+ });
41
+ expect(result.sessionId).toBe("sessions/test-session-123");
42
+ expect(result.status).toBe("COMPLETED");
43
+ expect(result.completed).toBe(true);
44
+ expect(result.remediationBranch).toBe("remediation-branch-123");
45
+ expect(result.pullRequestUrl).toBe("https://github.com/org/repo/pull/100");
46
+ });
47
+ });
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ import { runTDCli } from "./jules/shared.js";
3
+ export const MultiExecInputSchema = z.object({
4
+ command: z.string().describe("Shell command to execute sequentially across repositories"),
5
+ repos: z.array(z.string()).optional().describe("Optional list of repository names to target"),
6
+ continueOnError: z.boolean().optional().default(true).describe("Whether to continue execution if a repo command fails"),
7
+ });
8
+ export async function multiExecHandler(input) {
9
+ const args = MultiExecInputSchema.parse(input);
10
+ const cliArgs = ["multi-repo", "exec", args.command];
11
+ if (args.repos) {
12
+ for (const r of args.repos) {
13
+ cliArgs.push("-r", r);
14
+ }
15
+ }
16
+ if (args.continueOnError === false) {
17
+ cliArgs.push("--fail-fast");
18
+ }
19
+ const output = await runTDCli(cliArgs, "execute command across ecosystem repositories");
20
+ return output;
21
+ }
@@ -0,0 +1,13 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { multiExecHandler } from "./repo.multi_exec.js";
3
+ describe("MultiExec Tool", () => {
4
+ it("should execute a command sequentially across repositories", async () => {
5
+ const res = await multiExecHandler({
6
+ command: "echo test-vitest-exec",
7
+ repos: ["arii/boomtick"],
8
+ });
9
+ expect(res.status).toBe("success");
10
+ expect(res.total_repos).toBe(1);
11
+ expect(res.results[0].stdout).toContain("test-vitest-exec");
12
+ });
13
+ });