-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathupdate_milestone.ts
More file actions
208 lines (196 loc) · 6.42 KB
/
Copy pathupdate_milestone.ts
File metadata and controls
208 lines (196 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import type { ToolConfig } from '@/tools/types'
interface UpdateMilestoneParams {
owner: string
repo: string
milestone_number: number
title?: string
state?: 'open' | 'closed'
description?: string
due_on?: string
apiKey: string
}
interface UpdateMilestoneResponse {
success: boolean
output: {
content: string
metadata: {
number: number
title: string
description: string | null
state: string
html_url: string
due_on: string | null
open_issues: number
closed_issues: number
updated_at: string
}
}
}
export const updateMilestoneTool: ToolConfig<UpdateMilestoneParams, UpdateMilestoneResponse> = {
id: 'github_update_milestone',
name: 'GitHub Update Milestone',
description: 'Update a milestone in a repository',
version: '1.0.0',
params: {
owner: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository owner',
},
repo: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository name',
},
milestone_number: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'Milestone number to update',
},
title: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New milestone title',
},
state: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New state: open or closed',
},
description: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New description',
},
due_on: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New due date (ISO 8601 format)',
},
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'GitHub API token',
},
},
request: {
url: (params) =>
`https://api.github.com/repos/${params.owner}/${params.repo}/milestones/${params.milestone_number}`,
method: 'PATCH',
headers: (params) => ({
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
'X-GitHub-Api-Version': '2022-11-28',
}),
body: (params) => {
const body: Record<string, any> = {}
if (params.title !== undefined) body.title = params.title
if (params.state !== undefined) body.state = params.state
if (params.description !== undefined) body.description = params.description
if (params.due_on !== undefined) body.due_on = params.due_on
return body
},
},
transformResponse: async (response) => {
const data = await response.json()
const content = `Updated milestone: ${data.title} (#${data.number})
State: ${data.state}
Due: ${data.due_on ?? 'No due date'}
${data.html_url}`
return {
success: true,
output: {
content,
metadata: {
number: data.number,
title: data.title,
description: data.description ?? null,
state: data.state,
html_url: data.html_url,
due_on: data.due_on ?? null,
open_issues: data.open_issues,
closed_issues: data.closed_issues,
updated_at: data.updated_at,
},
},
}
},
outputs: {
content: { type: 'string', description: 'Human-readable result' },
metadata: {
type: 'object',
description: 'Updated milestone metadata',
properties: {
number: { type: 'number', description: 'Milestone number' },
title: { type: 'string', description: 'Title' },
description: { type: 'string', description: 'Description', optional: true },
state: { type: 'string', description: 'State' },
html_url: { type: 'string', description: 'Web URL' },
due_on: { type: 'string', description: 'Due date', optional: true },
open_issues: { type: 'number', description: 'Open issues' },
closed_issues: { type: 'number', description: 'Closed issues' },
updated_at: { type: 'string', description: 'Update date' },
},
},
},
}
export const updateMilestoneV2Tool: ToolConfig<UpdateMilestoneParams, any> = {
id: 'github_update_milestone_v2',
name: updateMilestoneTool.name,
description: updateMilestoneTool.description,
version: '2.0.0',
params: updateMilestoneTool.params,
request: updateMilestoneTool.request,
transformResponse: async (response: Response) => {
const data = await response.json()
return {
success: true,
output: {
...data,
description: data.description ?? null,
due_on: data.due_on ?? null,
},
}
},
outputs: {
id: { type: 'number', description: 'Milestone ID' },
node_id: { type: 'string', description: 'GraphQL node ID' },
number: { type: 'number', description: 'Milestone number' },
title: { type: 'string', description: 'Milestone title' },
description: { type: 'string', description: 'Milestone description', optional: true },
state: { type: 'string', description: 'State (open or closed)' },
url: { type: 'string', description: 'API URL' },
html_url: { type: 'string', description: 'GitHub web URL' },
labels_url: { type: 'string', description: 'Labels API URL' },
due_on: { type: 'string', description: 'Due date (ISO 8601)', optional: true },
open_issues: { type: 'number', description: 'Number of open issues' },
closed_issues: { type: 'number', description: 'Number of closed issues' },
created_at: { type: 'string', description: 'Creation timestamp' },
updated_at: { type: 'string', description: 'Last update timestamp' },
closed_at: { type: 'string', description: 'Close timestamp', optional: true },
creator: {
type: 'object',
description: 'Milestone creator',
optional: true,
properties: {
login: { type: 'string', description: 'Username' },
id: { type: 'number', description: 'User ID' },
node_id: { type: 'string', description: 'GraphQL node ID' },
avatar_url: { type: 'string', description: 'Avatar image URL' },
url: { type: 'string', description: 'API URL' },
html_url: { type: 'string', description: 'Profile page URL' },
type: { type: 'string', description: 'User or Organization' },
site_admin: { type: 'boolean', description: 'GitHub staff indicator' },
},
},
},
}