Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | 3x 3x 3x 3x 3x 3x 3x 4x 4x 4x 4x 4x 10x 6x 4x 4x 4x 2x 2x 2x 3x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 4x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 9x 6x 3x 3x 2x 2x 2x 1x 1x 1x 1x 1x 5x 3x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 3x 18x 3x 6x 3x 7x 5x 5x 45x 2x | /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { zodToJsonSchema } from "zod-to-json-schema"; import { ListProjectMilestonesSchema, GetProjectMilestoneSchema, GetMilestoneIssuesSchema, GetMilestoneMergeRequestsSchema, GetMilestoneBurndownEventsSchema, } from "./schema-readonly"; import { CreateProjectMilestoneSchema, EditProjectMilestoneSchema, DeleteProjectMilestoneSchema, PromoteProjectMilestoneSchema, } from "./schema"; import { enhancedFetch } from "../../utils/fetch"; import { resolveNamespaceForAPI } from "../../utils/namespace"; import { cleanGidsFromObject } from "../../utils/idConversion"; import { ToolRegistry, EnhancedToolDefinition } from "../../types"; /** * Milestones tools registry - unified registry containing all milestone operation tools with their handlers */ export const milestonesToolRegistry: ToolRegistry = new Map<string, EnhancedToolDefinition>([ // Read-only tools [ "list_milestones", { name: "list_milestones", description: "Browse release milestones for planning and tracking. Use to see upcoming releases, sprint cycles, or project phases. Supports filtering by state (active/closed) and timeframe. Returns milestone titles, dates, progress statistics. Group milestones apply across all projects.", inputSchema: zodToJsonSchema(ListProjectMilestonesSchema), handler: async (args: unknown): Promise<unknown> => { const options = ListProjectMilestonesSchema.parse(args); const { namespace } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const queryParams = new URLSearchParams(); Object.entries(options).forEach(([key, value]) => { if (value !== undefined && value !== null && key !== "namespace") { queryParams.set(key, String(value)); } }); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones?${queryParams}`; const response = await enhancedFetch(apiUrl, { headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, }, }); if (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const milestones = await response.json(); return cleanGidsFromObject(milestones); }, }, ], [ "get_milestone", { name: "get_milestone", description: "Retrieve comprehensive milestone information including dates, description, and progress metrics. Use to track release status, see associated work, or analyze milestone completion. Shows open/closed issue counts and completion percentage.", inputSchema: zodToJsonSchema(GetProjectMilestoneSchema), handler: async (args: unknown): Promise<unknown> => { const options = GetProjectMilestoneSchema.parse(args); const { namespace, milestone_id } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones/${milestone_id}`; const response = await enhancedFetch(apiUrl, { headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, }, }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const milestone = await response.json(); return cleanGidsFromObject(milestone); }, }, ], [ "get_milestone_issue", { name: "get_milestone_issue", description: "List all issues targeted for a milestone release. Use to track milestone progress, identify blockers, or plan work. Returns issue details with status, assignees, and labels. Essential for release management and sprint planning.", inputSchema: zodToJsonSchema(GetMilestoneIssuesSchema), handler: async (args: unknown): Promise<unknown> => { const options = GetMilestoneIssuesSchema.parse(args); const { namespace, milestone_id } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const queryParams = new URLSearchParams(); Object.entries(options).forEach(([key, value]) => { Iif ( value !== undefined && value !== null && key !== "namespace" && key !== "milestone_id" ) { queryParams.set(key, String(value)); } }); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones/${milestone_id}/issues?${queryParams}`; const response = await enhancedFetch(apiUrl, { headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, }, }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const issues = await response.json(); return cleanGidsFromObject(issues); }, }, ], [ "get_milestone_merge_requests", { name: "get_milestone_merge_requests", description: "List merge requests scheduled for a milestone. Use to track feature completion, review code changes for release, or identify pending work. Shows MR status, approvals, and pipeline status. Critical for release readiness assessment.", inputSchema: zodToJsonSchema(GetMilestoneMergeRequestsSchema), handler: async (args: unknown): Promise<unknown> => { const options = GetMilestoneMergeRequestsSchema.parse(args); const { namespace, milestone_id } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const queryParams = new URLSearchParams(); Object.entries(options).forEach(([key, value]) => { if ( value !== undefined && value !== null && key !== "namespace" && key !== "milestone_id" ) { queryParams.set(key, String(value)); } }); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones/${milestone_id}/merge_requests?${queryParams}`; const response = await enhancedFetch(apiUrl, { headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, }, }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const mergeRequests = await response.json(); return cleanGidsFromObject(mergeRequests); }, }, ], [ "get_milestone_burndown_events", { name: "get_milestone_burndown_events", description: "Track milestone progress with burndown chart data. Use for agile metrics, velocity tracking, and sprint analysis. Returns time-series events showing work completion rate. Premium/Ultimate feature for advanced project analytics.", inputSchema: zodToJsonSchema(GetMilestoneBurndownEventsSchema), handler: async (args: unknown): Promise<unknown> => { const options = GetMilestoneBurndownEventsSchema.parse(args); const { namespace, milestone_id } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones/${milestone_id}/burndown_events`; const response = await enhancedFetch(apiUrl, { headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, }, }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const burndownEvents = await response.json(); return cleanGidsFromObject(burndownEvents); }, }, ], // Write tools [ "create_milestone", { name: "create_milestone", description: "Define a new release milestone or sprint cycle. Use to establish delivery targets, organize work phases, or plan releases. Set title, description, start/due dates. Group milestones coordinate releases across multiple projects.", inputSchema: zodToJsonSchema(CreateProjectMilestoneSchema), handler: async (args: unknown): Promise<unknown> => { const options = CreateProjectMilestoneSchema.parse(args); const { namespace } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const body: Record<string, unknown> = {}; Object.entries(options).forEach(([key, value]) => { if (value !== undefined && value !== null && key !== "namespace") { body[key] = value; } }); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones`; const response = await enhancedFetch(apiUrl, { method: "POST", headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify(body), }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const milestone = await response.json(); return cleanGidsFromObject(milestone); }, }, ], [ "edit_milestone", { name: "edit_milestone", description: "Update milestone properties like dates, description, or state. Use to adjust release schedules, extend sprints, or close completed milestones. Changes apply immediately to all associated issues and MRs.", inputSchema: zodToJsonSchema(EditProjectMilestoneSchema), handler: async (args: unknown): Promise<unknown> => { const options = EditProjectMilestoneSchema.parse(args); const { namespace, milestone_id } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const body: Record<string, unknown> = {}; Object.entries(options).forEach(([key, value]) => { if ( value !== undefined && value !== null && key !== "namespace" && key !== "milestone_id" ) { body[key] = value; } }); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones/${milestone_id}`; const response = await enhancedFetch(apiUrl, { method: "PUT", headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify(body), }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const milestone = await response.json(); return cleanGidsFromObject(milestone); }, }, ], [ "delete_milestone", { name: "delete_milestone", description: "Remove a milestone permanently. Use to clean up cancelled releases or obsolete milestones. Warning: removes milestone association from all issues and MRs. Consider closing instead of deleting for historical tracking.", inputSchema: zodToJsonSchema(DeleteProjectMilestoneSchema), handler: async (args: unknown): Promise<unknown> => { const options = DeleteProjectMilestoneSchema.parse(args); const { namespace, milestone_id } = options; // Resolve namespace type and get proper API path const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/${entityType}/${encodedPath}/milestones/${milestone_id}`; const response = await enhancedFetch(apiUrl, { method: "DELETE", headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, }, }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const result = await response.json(); return cleanGidsFromObject(result); }, }, ], [ "promote_milestone", { name: "promote_milestone", description: "Elevate project milestone to group level for cross-project coordination. Use when a milestone needs to span multiple projects. Consolidates related project milestones into single group milestone. Useful for organizational release planning.", inputSchema: zodToJsonSchema(PromoteProjectMilestoneSchema), handler: async (args: unknown): Promise<unknown> => { const options = PromoteProjectMilestoneSchema.parse(args); const { namespace, milestone_id } = options; // Resolve namespace - for promote, we need to ensure it's a project const { entityType, encodedPath } = await resolveNamespaceForAPI(namespace); if (entityType !== "projects") { throw new Error("Milestone promotion is only available for projects, not groups"); } const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodedPath}/milestones/${encodeURIComponent(milestone_id)}/promote`; const response = await enhancedFetch(apiUrl, { method: "POST", headers: { Authorization: `Bearer ${process.env.GITLAB_TOKEN}`, }, }); Iif (!response.ok) { throw new Error(`GitLab API error: ${response.status} ${response.statusText}`); } const milestone = await response.json(); return cleanGidsFromObject(milestone); }, }, ], ]); /** * Get read-only tool names from the registry */ export function getMilestonesReadOnlyToolNames(): string[] { return [ "list_milestones", "get_milestone", "get_milestone_issue", "get_milestone_merge_requests", "get_milestone_burndown_events", ]; } /** * Get all tool definitions from the registry (for backward compatibility) */ export function getMilestonesToolDefinitions(): EnhancedToolDefinition[] { return Array.from(milestonesToolRegistry.values()); } /** * Get filtered tools based on read-only mode */ export function getFilteredMilestonesTools( readOnlyMode: boolean = false ): EnhancedToolDefinition[] { if (readOnlyMode) { const readOnlyNames = getMilestonesReadOnlyToolNames(); return Array.from(milestonesToolRegistry.values()).filter(tool => readOnlyNames.includes(tool.name) ); } return getMilestonesToolDefinitions(); } |