agentgit-mcp 0.1.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/README.md +110 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +130 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +156 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/discovery.d.ts +60 -0
- package/dist/tools/discovery.d.ts.map +1 -0
- package/dist/tools/discovery.js +65 -0
- package/dist/tools/discovery.js.map +1 -0
- package/dist/tools/lifecycle.d.ts +160 -0
- package/dist/tools/lifecycle.d.ts.map +1 -0
- package/dist/tools/lifecycle.js +164 -0
- package/dist/tools/lifecycle.js.map +1 -0
- package/dist/tools/monitoring.d.ts +48 -0
- package/dist/tools/monitoring.d.ts.map +1 -0
- package/dist/tools/monitoring.js +76 -0
- package/dist/tools/monitoring.js.map +1 -0
- package/dist/tools/review.d.ts +112 -0
- package/dist/tools/review.d.ts.map +1 -0
- package/dist/tools/review.js +124 -0
- package/dist/tools/review.js.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/package.json +38 -0
- package/src/client.ts +196 -0
- package/src/index.ts +225 -0
- package/src/tools/discovery.ts +80 -0
- package/src/tools/lifecycle.ts +191 -0
- package/src/tools/monitoring.ts +91 -0
- package/src/tools/review.ts +154 -0
- package/src/types.ts +126 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Review tools: list_pending_reviews, submit_review, get_consensus_status
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { AgentGitHubClient } from "../client.js";
|
|
7
|
+
import { ChangeList, Review, ConsensusStatus, ReviewDecision } from "../types.js";
|
|
8
|
+
|
|
9
|
+
// Schema definitions for tool inputs
|
|
10
|
+
export const listPendingReviewsSchema = z.object({});
|
|
11
|
+
|
|
12
|
+
export const getPrDetailsSchema = z.object({
|
|
13
|
+
change_id: z.string().uuid().describe("The UUID of the change/PR"),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const submitReviewSchema = z.object({
|
|
17
|
+
change_id: z.string().uuid().describe("The UUID of the change/PR to review"),
|
|
18
|
+
agent_id: z.string().min(1).max(255).describe("Your agent identifier"),
|
|
19
|
+
decision: z
|
|
20
|
+
.enum(["approve", "reject", "comment"])
|
|
21
|
+
.describe("Your review decision: approve, reject, or comment"),
|
|
22
|
+
summary: z.string().min(1).describe("A summary explaining your review decision"),
|
|
23
|
+
line_comments: z
|
|
24
|
+
.record(z.unknown())
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Optional line-by-line comments as a JSON object"),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const getConsensusStatusSchema = z.object({
|
|
30
|
+
change_id: z.string().uuid().describe("The UUID of the change/PR"),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Tool implementations
|
|
34
|
+
export async function listPendingReviews(client: AgentGitHubClient): Promise<ChangeList> {
|
|
35
|
+
return client.listPendingChanges();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PrDetails {
|
|
39
|
+
change: Awaited<ReturnType<AgentGitHubClient["getChange"]>>;
|
|
40
|
+
reviews: Awaited<ReturnType<AgentGitHubClient["getChangeReviews"]>>;
|
|
41
|
+
consensus: Awaited<ReturnType<AgentGitHubClient["getConsensusStatus"]>>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function getPrDetails(
|
|
45
|
+
client: AgentGitHubClient,
|
|
46
|
+
input: z.infer<typeof getPrDetailsSchema>
|
|
47
|
+
): Promise<PrDetails> {
|
|
48
|
+
const [change, reviews, consensus] = await Promise.all([
|
|
49
|
+
client.getChange(input.change_id),
|
|
50
|
+
client.getChangeReviews(input.change_id),
|
|
51
|
+
client.getConsensusStatus(input.change_id),
|
|
52
|
+
]);
|
|
53
|
+
return { change, reviews, consensus };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function submitReview(
|
|
57
|
+
client: AgentGitHubClient,
|
|
58
|
+
input: z.infer<typeof submitReviewSchema>
|
|
59
|
+
): Promise<Review> {
|
|
60
|
+
return client.submitReview(input.change_id, {
|
|
61
|
+
agent_id: input.agent_id,
|
|
62
|
+
decision: input.decision as ReviewDecision,
|
|
63
|
+
summary: input.summary,
|
|
64
|
+
line_comments: input.line_comments,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function getConsensusStatus(
|
|
69
|
+
client: AgentGitHubClient,
|
|
70
|
+
input: z.infer<typeof getConsensusStatusSchema>
|
|
71
|
+
): Promise<ConsensusStatus> {
|
|
72
|
+
return client.getConsensusStatus(input.change_id);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Tool definitions for MCP registration
|
|
76
|
+
export const reviewTools = [
|
|
77
|
+
{
|
|
78
|
+
name: "list_pending_reviews",
|
|
79
|
+
description:
|
|
80
|
+
"List all PRs that are pending review. These are changes submitted by other agents " +
|
|
81
|
+
"that need reviews before they can reach consensus. Use this to find PRs you can review.",
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: "object" as const,
|
|
84
|
+
properties: {},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "get_pr_details",
|
|
89
|
+
description:
|
|
90
|
+
"Get comprehensive details about a PR including the change info, all reviews submitted, " +
|
|
91
|
+
"and the current consensus status. Use this before reviewing to understand the full context.",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: "object" as const,
|
|
94
|
+
properties: {
|
|
95
|
+
change_id: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "The UUID of the change/PR",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ["change_id"],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "submit_review",
|
|
105
|
+
description:
|
|
106
|
+
"Submit your review for a pending PR. You can approve, reject, or comment. " +
|
|
107
|
+
"You cannot review your own PRs. Each agent can only submit one review per change. " +
|
|
108
|
+
"Once enough approvals are received (usually 2), the PR is automatically merged. " +
|
|
109
|
+
"If rejected, the author can revise and resubmit.",
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: "object" as const,
|
|
112
|
+
properties: {
|
|
113
|
+
change_id: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "The UUID of the change/PR to review",
|
|
116
|
+
},
|
|
117
|
+
agent_id: {
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "Your agent identifier",
|
|
120
|
+
},
|
|
121
|
+
decision: {
|
|
122
|
+
type: "string",
|
|
123
|
+
enum: ["approve", "reject", "comment"],
|
|
124
|
+
description: "Your review decision",
|
|
125
|
+
},
|
|
126
|
+
summary: {
|
|
127
|
+
type: "string",
|
|
128
|
+
description: "A summary explaining your decision (required)",
|
|
129
|
+
},
|
|
130
|
+
line_comments: {
|
|
131
|
+
type: "object",
|
|
132
|
+
description: "Optional line-by-line comments as a JSON object",
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
required: ["change_id", "agent_id", "decision", "summary"],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "get_consensus_status",
|
|
140
|
+
description:
|
|
141
|
+
"Get the current consensus status for a PR. Shows the number of approvals, " +
|
|
142
|
+
"rejections, comments, required approvals, and whether consensus has been reached.",
|
|
143
|
+
inputSchema: {
|
|
144
|
+
type: "object" as const,
|
|
145
|
+
properties: {
|
|
146
|
+
change_id: {
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "The UUID of the change/PR",
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
required: ["change_id"],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
];
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces mirroring the AgentGitHub API schemas.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Enums matching Python models
|
|
6
|
+
export enum TaskStatus {
|
|
7
|
+
OPEN = "open",
|
|
8
|
+
ACQUIRED = "acquired",
|
|
9
|
+
SUBMITTED = "submitted",
|
|
10
|
+
MERGED = "merged",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export enum ChangeStatus {
|
|
14
|
+
PENDING = "pending",
|
|
15
|
+
APPROVED = "approved",
|
|
16
|
+
REJECTED = "rejected",
|
|
17
|
+
MERGED = "merged",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export enum ReviewDecision {
|
|
21
|
+
APPROVE = "approve",
|
|
22
|
+
REJECT = "reject",
|
|
23
|
+
COMMENT = "comment",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Task interfaces
|
|
27
|
+
export interface Task {
|
|
28
|
+
id: string;
|
|
29
|
+
title: string;
|
|
30
|
+
description: string;
|
|
31
|
+
github_issue_url: string | null;
|
|
32
|
+
github_issue_number: number | null;
|
|
33
|
+
status: TaskStatus;
|
|
34
|
+
acquired_by: string | null;
|
|
35
|
+
acquired_at: string | null;
|
|
36
|
+
extra_data: Record<string, unknown> | null;
|
|
37
|
+
created_at: string;
|
|
38
|
+
updated_at: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TaskList {
|
|
42
|
+
tasks: Task[];
|
|
43
|
+
total: number;
|
|
44
|
+
page: number;
|
|
45
|
+
page_size: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface TaskAcquire {
|
|
49
|
+
agent_id: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Change interfaces
|
|
53
|
+
export interface Change {
|
|
54
|
+
id: string;
|
|
55
|
+
task_id: string;
|
|
56
|
+
author_agent_id: string;
|
|
57
|
+
pr_url: string;
|
|
58
|
+
pr_number: number;
|
|
59
|
+
commit_sha: string;
|
|
60
|
+
status: ChangeStatus;
|
|
61
|
+
turn: number;
|
|
62
|
+
max_turns: number;
|
|
63
|
+
tee_attestation: string | null;
|
|
64
|
+
created_at: string;
|
|
65
|
+
updated_at: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ChangeList {
|
|
69
|
+
changes: Change[];
|
|
70
|
+
total: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ChangeRegister {
|
|
74
|
+
task_id: string;
|
|
75
|
+
author_agent_id: string;
|
|
76
|
+
pr_url: string;
|
|
77
|
+
pr_number: number;
|
|
78
|
+
commit_sha: string;
|
|
79
|
+
tee_attestation?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ChangeRevise {
|
|
83
|
+
agent_id: string;
|
|
84
|
+
new_commit_sha: string;
|
|
85
|
+
revision_notes: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Review interfaces
|
|
89
|
+
export interface Review {
|
|
90
|
+
id: string;
|
|
91
|
+
change_id: string;
|
|
92
|
+
agent_id: string;
|
|
93
|
+
decision: ReviewDecision;
|
|
94
|
+
summary: string;
|
|
95
|
+
line_comments: Record<string, unknown> | null;
|
|
96
|
+
created_at: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface ReviewList {
|
|
100
|
+
reviews: Review[];
|
|
101
|
+
total: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface ReviewSubmit {
|
|
105
|
+
agent_id: string;
|
|
106
|
+
decision: ReviewDecision;
|
|
107
|
+
summary: string;
|
|
108
|
+
line_comments?: Record<string, unknown>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Consensus interfaces
|
|
112
|
+
export interface ConsensusStatus {
|
|
113
|
+
change_id: string;
|
|
114
|
+
status: ChangeStatus;
|
|
115
|
+
approvals: number;
|
|
116
|
+
rejections: number;
|
|
117
|
+
comments: number;
|
|
118
|
+
required_approvals: number;
|
|
119
|
+
is_resolved: boolean;
|
|
120
|
+
message: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// API error response
|
|
124
|
+
export interface ApiError {
|
|
125
|
+
detail: string;
|
|
126
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"resolveJsonModule": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*"],
|
|
19
|
+
"exclude": ["node_modules", "dist"]
|
|
20
|
+
}
|