@copado/agentia-cli 0.84.0-alpha.0 → 0.86.0-alpha.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 (101) hide show
  1. package/README.md +778 -161
  2. package/dist/commands/cicd/pipeline/connection/create.d.ts +19 -0
  3. package/dist/commands/cicd/pipeline/connection/create.js +67 -0
  4. package/dist/commands/cicd/pipeline/connection/create.js.map +1 -0
  5. package/dist/commands/cicd/pipeline/connection/delete.d.ts +15 -0
  6. package/dist/commands/cicd/pipeline/connection/delete.js +62 -0
  7. package/dist/commands/cicd/pipeline/connection/delete.js.map +1 -0
  8. package/dist/commands/cicd/pipeline/connection/open.d.ts +12 -0
  9. package/dist/commands/cicd/pipeline/connection/open.js +30 -0
  10. package/dist/commands/cicd/pipeline/connection/open.js.map +1 -0
  11. package/dist/commands/cicd/pipeline/connection/update.d.ts +19 -0
  12. package/dist/commands/cicd/pipeline/connection/update.js +55 -0
  13. package/dist/commands/cicd/pipeline/connection/update.js.map +1 -0
  14. package/dist/commands/cicd/pipeline/create.d.ts +19 -0
  15. package/dist/commands/cicd/pipeline/create.js +42 -0
  16. package/dist/commands/cicd/pipeline/create.js.map +1 -0
  17. package/dist/commands/cicd/pipeline/list.d.ts +3 -0
  18. package/dist/commands/cicd/pipeline/list.js +5 -3
  19. package/dist/commands/cicd/pipeline/list.js.map +1 -1
  20. package/dist/commands/cicd/pipeline/stage-connection/create.d.ts +12 -0
  21. package/dist/commands/cicd/pipeline/stage-connection/create.js +33 -0
  22. package/dist/commands/cicd/pipeline/stage-connection/create.js.map +1 -0
  23. package/dist/commands/cicd/pipeline/stage-connection/delete.d.ts +16 -0
  24. package/dist/commands/cicd/pipeline/stage-connection/delete.js +34 -0
  25. package/dist/commands/cicd/pipeline/stage-connection/delete.js.map +1 -0
  26. package/dist/commands/cicd/pipeline/stage-connection/list.d.ts +10 -0
  27. package/dist/commands/cicd/pipeline/stage-connection/list.js +37 -0
  28. package/dist/commands/cicd/pipeline/stage-connection/list.js.map +1 -0
  29. package/dist/commands/cicd/pipeline/stage-connection/open.d.ts +12 -0
  30. package/dist/commands/cicd/pipeline/stage-connection/open.js +16 -0
  31. package/dist/commands/cicd/pipeline/stage-connection/open.js.map +1 -0
  32. package/dist/commands/cicd/pipeline/stage-connection/update.d.ts +15 -0
  33. package/dist/commands/cicd/pipeline/stage-connection/update.js +38 -0
  34. package/dist/commands/cicd/pipeline/stage-connection/update.js.map +1 -0
  35. package/dist/commands/cicd/pipeline/update.d.ts +20 -0
  36. package/dist/commands/cicd/pipeline/update.js +52 -0
  37. package/dist/commands/cicd/pipeline/update.js.map +1 -0
  38. package/dist/commands/cicd/stage/create.d.ts +14 -0
  39. package/dist/commands/cicd/stage/create.js +28 -0
  40. package/dist/commands/cicd/stage/create.js.map +1 -0
  41. package/dist/commands/cicd/stage/delete.d.ts +14 -0
  42. package/dist/commands/cicd/stage/delete.js +28 -0
  43. package/dist/commands/cicd/stage/delete.js.map +1 -0
  44. package/dist/commands/cicd/stage/get.d.ts +10 -0
  45. package/dist/commands/cicd/stage/get.js +17 -0
  46. package/dist/commands/cicd/stage/get.js.map +1 -0
  47. package/dist/commands/cicd/stage/list.d.ts +12 -0
  48. package/dist/commands/cicd/stage/list.js +27 -0
  49. package/dist/commands/cicd/stage/list.js.map +1 -0
  50. package/dist/commands/cicd/stage/open.d.ts +12 -0
  51. package/dist/commands/cicd/stage/open.js +16 -0
  52. package/dist/commands/cicd/stage/open.js.map +1 -0
  53. package/dist/commands/cicd/stage/update.d.ts +14 -0
  54. package/dist/commands/cicd/stage/update.js +30 -0
  55. package/dist/commands/cicd/stage/update.js.map +1 -0
  56. package/dist/commands/setup/skills/create.d.ts +15 -0
  57. package/dist/commands/setup/skills/create.js +64 -0
  58. package/dist/commands/setup/skills/create.js.map +1 -0
  59. package/dist/commands/setup/skills/update.d.ts +15 -0
  60. package/dist/commands/setup/skills/update.js +64 -0
  61. package/dist/commands/setup/skills/update.js.map +1 -0
  62. package/dist/lib/mcp/tools.d.ts +134 -2
  63. package/dist/lib/mcp/tools.js +383 -5
  64. package/dist/lib/mcp/tools.js.map +1 -1
  65. package/dist/lib/navigation.d.ts +1 -1
  66. package/dist/lib/navigation.js +3 -0
  67. package/dist/lib/navigation.js.map +1 -1
  68. package/dist/lib/pipeline-connection-flags.d.ts +62 -0
  69. package/dist/lib/pipeline-connection-flags.js +309 -0
  70. package/dist/lib/pipeline-connection-flags.js.map +1 -0
  71. package/dist/lib/pipeline-flags.d.ts +74 -0
  72. package/dist/lib/pipeline-flags.js +154 -0
  73. package/dist/lib/pipeline-flags.js.map +1 -0
  74. package/dist/lib/pipeline-stage-connection-flags.d.ts +25 -0
  75. package/dist/lib/pipeline-stage-connection-flags.js +46 -0
  76. package/dist/lib/pipeline-stage-connection-flags.js.map +1 -0
  77. package/dist/lib/pipeline-types.d.ts +91 -2
  78. package/dist/lib/pipeline-types.js +51 -5
  79. package/dist/lib/pipeline-types.js.map +1 -1
  80. package/dist/lib/setup-skills.d.ts +67 -0
  81. package/dist/lib/setup-skills.js +251 -0
  82. package/dist/lib/setup-skills.js.map +1 -0
  83. package/dist/lib/stage-flags.d.ts +19 -0
  84. package/dist/lib/stage-flags.js +29 -0
  85. package/dist/lib/stage-flags.js.map +1 -0
  86. package/dist/lib/stage-types.d.ts +67 -0
  87. package/dist/lib/stage-types.js +69 -0
  88. package/dist/lib/stage-types.js.map +1 -0
  89. package/oclif.manifest.json +2017 -740
  90. package/package.json +9 -2
  91. package/templates/skills/agentia-ai/SKILL.md +34 -0
  92. package/templates/skills/agentia-ai/references/ai-agents.md +70 -0
  93. package/templates/skills/agentia-cicd/SKILL.md +41 -0
  94. package/templates/skills/agentia-cicd/references/data.md +65 -0
  95. package/templates/skills/agentia-cicd/references/environments-and-credentials.md +55 -0
  96. package/templates/skills/agentia-cicd/references/jobs.md +42 -0
  97. package/templates/skills/agentia-cicd/references/pipelines.md +63 -0
  98. package/templates/skills/agentia-cicd/references/promotions.md +58 -0
  99. package/templates/skills/agentia-cicd/references/work.md +84 -0
  100. package/templates/skills/agentia-testing/SKILL.md +34 -0
  101. package/templates/skills/agentia-testing/references/tests.md +65 -0
@@ -7,13 +7,14 @@ import { type JobListFilters } from '../job-types.js';
7
7
  import { type ComparisonMode, type ContentSource, type DependencyResult, type IndexSearchResult, type IndexSource, type MetadataContentResult, type ModuleType, type OrderDirection, type PlatformExperience, type RetrieveMode } from '../metadata-common.js';
8
8
  import { type IndexRefreshResult, type RefreshDeletedMetadataIndexResult } from '../metadata-refresh.js';
9
9
  import { NAVIGATION_RESOURCE_TYPES } from '../navigation.js';
10
- import { type PipelineConnection, type PipelineDescribe, type PipelineListFilters } from '../pipeline-types.js';
10
+ import { type Pipeline, type PipelineConnection, type PipelineListFilters } from '../pipeline-types.js';
11
11
  import { type ProjectDefaultScope } from '../project-defaults.js';
12
12
  import { type Project, type ProjectListFilters } from '../project-types.js';
13
13
  import { type PromotionConflict, type PromotionConflictMode, type PromotionConflictResolutionResult, type PromotionConflictUndoResult } from '../promotion-conflicts.js';
14
14
  import { type PromotionOperation } from '../promotion-run.js';
15
15
  import { type PromotionDetail, type PromotionListFilters } from '../promotion-types.js';
16
16
  import { type GitRepository, type RepositoryListFilters, type RepositoryValidateResult } from '../repository-types.js';
17
+ import { type PipelineStageConnection, type Stage } from '../stage-types.js';
17
18
  import { type User } from '../user-types.js';
18
19
  import { type HeadlessWorkStatusResult } from '../work-types.js';
19
20
  type EnvironmentCreateArgs = {
@@ -111,6 +112,76 @@ type RepositoryCreateArgs = RepositoryMutationArgs & {
111
112
  type RepositoryUpdateArgs = RepositoryMutationArgs & {
112
113
  id: string;
113
114
  };
115
+ type PipelineMutationArgs = {
116
+ active?: boolean;
117
+ blockCommits?: boolean;
118
+ calculateBasedOn?: string;
119
+ enableSmartConflictResolution?: boolean;
120
+ gitRepositoryId?: string;
121
+ id?: string;
122
+ mainBranch?: string;
123
+ name?: string;
124
+ platform?: string;
125
+ };
126
+ type PipelineCreateArgs = PipelineMutationArgs & {
127
+ name: string;
128
+ };
129
+ type PipelineUpdateArgs = PipelineMutationArgs & {
130
+ id: string;
131
+ };
132
+ type StageMutationArgs = {
133
+ metaStage?: string;
134
+ name?: string;
135
+ };
136
+ type StageCreateArgs = StageMutationArgs & {
137
+ name: string;
138
+ };
139
+ type StageUpdateArgs = StageMutationArgs & {
140
+ id: string;
141
+ };
142
+ type StageDeleteArgs = {
143
+ id: string;
144
+ };
145
+ type PipelineStageConnectionCreateArgs = {
146
+ nextPipelineStageConnectionId?: string;
147
+ pipelineId: string;
148
+ stageId: string;
149
+ };
150
+ type PipelineStageConnectionListArgs = {
151
+ pipelineId: string;
152
+ };
153
+ type PipelineStageConnectionUpdateArgs = {
154
+ connectionId: string;
155
+ nextPipelineStageConnectionId?: string;
156
+ pipelineId: string;
157
+ stageId?: string;
158
+ };
159
+ type PipelineStageConnectionDeleteArgs = {
160
+ connectionId: string;
161
+ pipelineId: string;
162
+ };
163
+ type PipelineConnectionMutationArgs = {
164
+ branch?: string;
165
+ destinationBranch?: string;
166
+ destinationEnvironmentId?: string;
167
+ id?: string;
168
+ sourceEnvironmentId?: string;
169
+ stageConnectionId?: string;
170
+ syncMergeState?: string;
171
+ syncPullState?: string;
172
+ };
173
+ type PipelineConnectionCreateArgs = PipelineConnectionMutationArgs & {
174
+ connections?: PipelineConnectionMutationArgs[];
175
+ pipelineId: string;
176
+ };
177
+ type PipelineConnectionUpdateArgs = {
178
+ connections: PipelineConnectionMutationArgs[];
179
+ pipelineId: string;
180
+ };
181
+ type PipelineConnectionDeleteArgs = {
182
+ connectionIds: string[];
183
+ pipelineId: string;
184
+ };
114
185
  type MetadataListArgs = {
115
186
  avoidSourceTracking?: boolean;
116
187
  changeDateFrom?: string;
@@ -234,13 +305,60 @@ declare function pipelineList(args?: PipelineListFilters): Promise<Record<string
234
305
  declare function pipelineGet(args: {
235
306
  id: string;
236
307
  }): Promise<{
237
- pipeline: PipelineDescribe;
308
+ pipeline: import("../pipeline-types.js").PipelineDescribe;
238
309
  }>;
239
310
  declare function pipelineConnectionList(args: {
240
311
  pipelineId?: string;
241
312
  }): Promise<{
242
313
  connections: PipelineConnection[];
243
314
  }>;
315
+ declare function pipelineCreate(args: PipelineCreateArgs): Promise<{
316
+ pipeline: Pipeline;
317
+ }>;
318
+ declare function pipelineUpdate(args: PipelineUpdateArgs): Promise<{
319
+ pipeline: Pipeline;
320
+ }>;
321
+ declare function pipelineConnectionCreate(args: PipelineConnectionCreateArgs): Promise<{
322
+ connections: PipelineConnection[];
323
+ }>;
324
+ declare function pipelineConnectionUpdate(args: PipelineConnectionUpdateArgs): Promise<{
325
+ connections: PipelineConnection[];
326
+ }>;
327
+ declare function pipelineConnectionDelete(args: PipelineConnectionDeleteArgs): Promise<{
328
+ connectionIds: string[];
329
+ pipelineId: string;
330
+ }>;
331
+ declare function stageList(args?: {
332
+ cursor?: string;
333
+ pageSize?: number;
334
+ }): Promise<Record<string, unknown>>;
335
+ declare function stageGet(args: {
336
+ id: string;
337
+ }): Promise<{
338
+ stage: Stage;
339
+ }>;
340
+ declare function stageCreate(args: StageCreateArgs): Promise<{
341
+ stage: Stage;
342
+ }>;
343
+ declare function stageUpdate(args: StageUpdateArgs): Promise<{
344
+ stage: Stage;
345
+ }>;
346
+ declare function stageDelete(args: StageDeleteArgs): Promise<{
347
+ id: string;
348
+ }>;
349
+ declare function pipelineStageConnectionCreate(args: PipelineStageConnectionCreateArgs): Promise<{
350
+ connection: PipelineStageConnection;
351
+ }>;
352
+ declare function pipelineStageConnectionList(args: PipelineStageConnectionListArgs): Promise<{
353
+ connections: PipelineStageConnection[];
354
+ }>;
355
+ declare function pipelineStageConnectionUpdate(args: PipelineStageConnectionUpdateArgs): Promise<{
356
+ connection: PipelineStageConnection;
357
+ }>;
358
+ declare function pipelineStageConnectionDelete(args: PipelineStageConnectionDeleteArgs): Promise<{
359
+ connectionId: string;
360
+ pipelineId: string;
361
+ }>;
244
362
  declare function projectList(args?: ProjectListFilters): Promise<Record<string, unknown>>;
245
363
  declare function repositoryList(args?: RepositoryListFilters): Promise<Record<string, unknown>>;
246
364
  declare function repositoryGet(args: {
@@ -1085,9 +1203,18 @@ export declare const agentiaMcpToolHandlers: {
1085
1203
  metadataRefreshRun: typeof metadataRefreshRun;
1086
1204
  metadataRefreshStatus: typeof metadataRefreshStatus;
1087
1205
  navigationResolve: typeof navigationResolve;
1206
+ pipelineConnectionCreate: typeof pipelineConnectionCreate;
1207
+ pipelineConnectionDelete: typeof pipelineConnectionDelete;
1088
1208
  pipelineConnectionList: typeof pipelineConnectionList;
1209
+ pipelineConnectionUpdate: typeof pipelineConnectionUpdate;
1210
+ pipelineCreate: typeof pipelineCreate;
1089
1211
  pipelineGet: typeof pipelineGet;
1090
1212
  pipelineList: typeof pipelineList;
1213
+ pipelineStageConnectionCreate: typeof pipelineStageConnectionCreate;
1214
+ pipelineStageConnectionDelete: typeof pipelineStageConnectionDelete;
1215
+ pipelineStageConnectionList: typeof pipelineStageConnectionList;
1216
+ pipelineStageConnectionUpdate: typeof pipelineStageConnectionUpdate;
1217
+ pipelineUpdate: typeof pipelineUpdate;
1091
1218
  projectDefaultGet: typeof projectDefaultGet;
1092
1219
  projectDefaultSet: typeof projectDefaultSet;
1093
1220
  projectDefaultUnset: typeof projectDefaultUnset;
@@ -1107,6 +1234,11 @@ export declare const agentiaMcpToolHandlers: {
1107
1234
  repositoryReset: typeof repositoryReset;
1108
1235
  repositoryUpdate: typeof repositoryUpdate;
1109
1236
  repositoryValidate: typeof repositoryValidate;
1237
+ stageCreate: typeof stageCreate;
1238
+ stageDelete: typeof stageDelete;
1239
+ stageGet: typeof stageGet;
1240
+ stageList: typeof stageList;
1241
+ stageUpdate: typeof stageUpdate;
1110
1242
  userGet: typeof userGet;
1111
1243
  workStatus: typeof workStatus;
1112
1244
  deploymentStepCreate: (args: {
@@ -24,7 +24,10 @@ import { normalizeLocalGatewayBaseUrl, readLocalGatewayConfig } from '../local-g
24
24
  import { COMPARISON_MODES, CONTENT_SOURCES, contentResultToCompareSide, createUnifiedDiff, INDEX_SOURCES, MODULE_TYPES, ORDER_DIRECTIONS, PLATFORM_EXPERIENCES, RETRIEVE_MODES, sourceSideLabel, } from '../metadata-common.js';
25
25
  import { buildRefreshDeletedRequest, buildRefreshIndexRequest, refreshStatusEndpoint, resolveRefreshSourceFromEnv, } from '../metadata-refresh.js';
26
26
  import { NAVIGATION_RESOURCE_TYPES, resolveNavigationTarget } from '../navigation.js';
27
- import { normalizePipelineDescribe, normalizePipelines, normalizePipelinesListPage, pipelineConnectionsFromPipelines, pipelineDescribeEndpoint, pipelineListEndpoint, } from '../pipeline-types.js';
27
+ import { parsePipelineConnectionMutationObject, parsePipelineConnectionUpdateObject, validatePipelineConnectionCreatePayload, validatePipelineConnectionUpdatePayload, } from '../pipeline-connection-flags.js';
28
+ import { validatePipelineMutationPayload, } from '../pipeline-flags.js';
29
+ import { buildPipelineStageConnectionCreatePayload, buildPipelineStageConnectionUpdatePayload, } from '../pipeline-stage-connection-flags.js';
30
+ import { normalizePipeline, normalizePipelineConnections, normalizePipelineDescribe, normalizePipelines, normalizePipelinesListPage, PIPELINE_CALCULATE_BASED_ON_VALUES, PIPELINE_CONNECTION_SYNC_STATE_NEEDS_RECALCULATING, PIPELINE_PLATFORMS, pipelineConnectionsEndpoint, pipelineConnectionsFromPipelines, pipelineDescribeEndpoint, pipelineEndpoint, pipelineListEndpoint, } from '../pipeline-types.js';
28
31
  import { buildSetValues, collectSelectedKeys } from '../project-default-flags.js';
29
32
  import { PROJECT_DEFAULT_KEYS } from '../project-defaults.js';
30
33
  import { normalizeProject, normalizeProjectsListPage, projectEndpoint, projectsListEndpoint, } from '../project-types.js';
@@ -33,6 +36,8 @@ import { performPromotionResume, performPromotionRun, PROMOTION_OPERATIONS, PROM
33
36
  import { normalizePromotionDetail, normalizePromotionsListPage, promotionEndpoint, promotionListEndpoint, } from '../promotion-types.js';
34
37
  import { REPOSITORY_STRING_VALIDATION_KEYS, validateNonEmptyStringFields as validateRepositoryNonEmptyStringFields, } from '../repository-flags.js';
35
38
  import { normalizeRepositoriesListPage, normalizeRepository, normalizeRepositoryValidateResult, repositoriesEndpoint, REPOSITORY_AUTH_TYPES, REPOSITORY_PROVIDERS, REPOSITORY_SOURCE_FORMATS, repositoryEndpoint, repositoryResetEndpoint, repositoryValidateEndpoint, withRequiredRepositoryFields, } from '../repository-types.js';
39
+ import { buildStageMutationPayload, validateStagePayload } from '../stage-flags.js';
40
+ import { normalizePipelineStageConnection, normalizeStage, normalizeStagesListPage, pipelineStageConnectionEndpoint, pipelineStageConnectionsEndpoint, STAGE_META_STAGE_SUGGESTIONS, stageEndpoint, stagesEndpoint, } from '../stage-types.js';
36
41
  import { getUserContext } from '../user-context.js';
37
42
  import { DEFAULT_USER_ID, resolveUserId, userEndpoint } from '../user-types.js';
38
43
  import { workStatusEndpoint } from '../work-types.js';
@@ -301,8 +306,7 @@ async function pipelineConnectionList(args) {
301
306
  endpoint: pipelineDescribeEndpoint(args.pipelineId),
302
307
  method: 'GET',
303
308
  });
304
- const pipeline = normalizePipelineDescribe(response);
305
- connections = pipeline.connections ?? [];
309
+ connections = normalizePipelineDescribe(response).connections ?? [];
306
310
  }
307
311
  else {
308
312
  const response = await CicdGateway.call({
@@ -313,6 +317,196 @@ async function pipelineConnectionList(args) {
313
317
  }
314
318
  return { connections };
315
319
  }
320
+ async function pipelineCreate(args) {
321
+ const payload = {
322
+ name: assertRequired(args.name, 'name'),
323
+ ...buildPipelineMcpPayload(args),
324
+ };
325
+ const validationError = validatePipelineMutationPayload(payload);
326
+ if (validationError !== undefined) {
327
+ throw new Error(validationError);
328
+ }
329
+ const response = await CicdGateway.call({
330
+ body: payload,
331
+ endpoint: pipelineListEndpoint(),
332
+ headers: {
333
+ 'Content-Type': 'application/json',
334
+ },
335
+ method: 'POST',
336
+ });
337
+ return { pipeline: normalizePipeline(response) };
338
+ }
339
+ async function pipelineUpdate(args) {
340
+ const id = assertRequired(args.id, 'id');
341
+ const payload = buildPipelineMcpPayload(args);
342
+ if (Object.keys(payload).length === 0) {
343
+ throw new Error('Must provide at least one field to update.');
344
+ }
345
+ const validationError = validatePipelineMutationPayload(payload);
346
+ if (validationError !== undefined) {
347
+ throw new Error(validationError);
348
+ }
349
+ const response = await CicdGateway.call({
350
+ body: payload,
351
+ endpoint: pipelineEndpoint(id),
352
+ headers: {
353
+ 'Content-Type': 'application/json',
354
+ },
355
+ method: 'PATCH',
356
+ });
357
+ return { pipeline: normalizePipeline(response) };
358
+ }
359
+ async function pipelineConnectionCreate(args) {
360
+ const pipelineId = assertRequired(args.pipelineId, 'pipelineId');
361
+ const connections = buildPipelineConnectionMcpCreatePayloads(args);
362
+ for (const [index, connection] of connections.entries()) {
363
+ const validationError = validatePipelineConnectionCreatePayload(connection);
364
+ if (validationError !== undefined) {
365
+ throw new Error(`connections[${index}]: ${validationError}`);
366
+ }
367
+ }
368
+ const response = await CicdGateway.call({
369
+ body: connections,
370
+ endpoint: pipelineConnectionsEndpoint(pipelineId),
371
+ headers: {
372
+ 'Content-Type': 'application/json',
373
+ },
374
+ method: 'POST',
375
+ });
376
+ return { connections: normalizePipelineConnections(response) };
377
+ }
378
+ async function pipelineConnectionUpdate(args) {
379
+ const pipelineId = assertRequired(args.pipelineId, 'pipelineId');
380
+ const connections = buildPipelineConnectionMcpUpdatePayloads(args);
381
+ for (const [index, connection] of connections.entries()) {
382
+ const validationError = validatePipelineConnectionUpdatePayload(connection);
383
+ if (validationError !== undefined) {
384
+ throw new Error(`connections[${index}]: ${validationError}`);
385
+ }
386
+ }
387
+ const response = await CicdGateway.call({
388
+ body: { connections },
389
+ endpoint: pipelineConnectionsEndpoint(pipelineId),
390
+ headers: {
391
+ 'Content-Type': 'application/json',
392
+ },
393
+ method: 'PATCH',
394
+ });
395
+ return { connections: normalizePipelineConnections(response) };
396
+ }
397
+ async function pipelineConnectionDelete(args) {
398
+ const pipelineId = assertRequired(args.pipelineId, 'pipelineId');
399
+ const { connectionIds } = args;
400
+ if (!Array.isArray(connectionIds) || connectionIds.length === 0) {
401
+ throw new Error('connectionIds must be a non-empty array.');
402
+ }
403
+ await CicdGateway.call({
404
+ body: { connectionIds },
405
+ endpoint: pipelineConnectionsEndpoint(pipelineId),
406
+ headers: {
407
+ 'Content-Type': 'application/json',
408
+ },
409
+ method: 'DELETE',
410
+ });
411
+ return { connectionIds, pipelineId };
412
+ }
413
+ async function stageList(args = {}) {
414
+ const response = await CicdGateway.call({
415
+ endpoint: stagesEndpoint(args),
416
+ method: 'GET',
417
+ });
418
+ return mcpPaginatedListPayload('stages', normalizeStagesListPage(response));
419
+ }
420
+ async function stageGet(args) {
421
+ const response = await CicdGateway.call({
422
+ endpoint: stageEndpoint(assertRequired(args.id, 'id')),
423
+ method: 'GET',
424
+ });
425
+ return { stage: normalizeStage(response) };
426
+ }
427
+ async function stageCreate(args) {
428
+ const payload = {
429
+ ...buildStageMutationPayload(args),
430
+ name: assertRequired(args.name, 'name'),
431
+ };
432
+ const validationError = validateStagePayload(payload, true);
433
+ if (validationError !== undefined)
434
+ throw new Error(validationError);
435
+ const response = await CicdGateway.call({
436
+ body: payload,
437
+ endpoint: stagesEndpoint(),
438
+ headers: { 'Content-Type': 'application/json' },
439
+ method: 'POST',
440
+ });
441
+ return { stage: normalizeStage(response) };
442
+ }
443
+ async function stageUpdate(args) {
444
+ const id = assertRequired(args.id, 'id');
445
+ const payload = buildStageMutationPayload(args);
446
+ if (Object.keys(payload).length === 0)
447
+ throw new Error('Must provide at least one field to update.');
448
+ const validationError = validateStagePayload(payload);
449
+ if (validationError !== undefined)
450
+ throw new Error(validationError);
451
+ const response = await CicdGateway.call({
452
+ body: payload,
453
+ endpoint: stageEndpoint(id),
454
+ headers: { 'Content-Type': 'application/json' },
455
+ method: 'PATCH',
456
+ });
457
+ return { stage: normalizeStage(response) };
458
+ }
459
+ async function stageDelete(args) {
460
+ const id = assertRequired(args.id, 'id');
461
+ await CicdGateway.call({ endpoint: stageEndpoint(id), method: 'DELETE' });
462
+ return { id };
463
+ }
464
+ async function pipelineStageConnectionCreate(args) {
465
+ const pipelineId = assertRequired(args.pipelineId, 'pipelineId');
466
+ const payload = buildPipelineStageConnectionCreatePayload({
467
+ 'next-pipeline-stage-connection-id': args.nextPipelineStageConnectionId,
468
+ 'stage-id': args.stageId,
469
+ });
470
+ const response = await CicdGateway.call({
471
+ body: payload,
472
+ endpoint: pipelineStageConnectionsEndpoint(pipelineId),
473
+ headers: { 'Content-Type': 'application/json' },
474
+ method: 'POST',
475
+ });
476
+ return { connection: normalizePipelineStageConnection(response) };
477
+ }
478
+ async function pipelineStageConnectionList(args) {
479
+ const pipelineId = assertRequired(args.pipelineId, 'pipelineId');
480
+ const response = await CicdGateway.call({
481
+ endpoint: pipelineDescribeEndpoint(pipelineId),
482
+ method: 'GET',
483
+ });
484
+ return { connections: normalizePipelineDescribe(response).stageConnections ?? [] };
485
+ }
486
+ async function pipelineStageConnectionUpdate(args) {
487
+ const pipelineId = assertRequired(args.pipelineId, 'pipelineId');
488
+ const connectionId = assertRequired(args.connectionId, 'connectionId');
489
+ const payload = buildPipelineStageConnectionUpdatePayload({
490
+ 'next-pipeline-stage-connection-id': args.nextPipelineStageConnectionId,
491
+ 'stage-id': args.stageId,
492
+ }, connectionId);
493
+ const response = await CicdGateway.call({
494
+ body: payload,
495
+ endpoint: pipelineStageConnectionEndpoint(pipelineId, connectionId),
496
+ headers: { 'Content-Type': 'application/json' },
497
+ method: 'PATCH',
498
+ });
499
+ return { connection: normalizePipelineStageConnection(response) };
500
+ }
501
+ async function pipelineStageConnectionDelete(args) {
502
+ const pipelineId = assertRequired(args.pipelineId, 'pipelineId');
503
+ const connectionId = assertRequired(args.connectionId, 'connectionId');
504
+ await CicdGateway.call({
505
+ endpoint: pipelineStageConnectionEndpoint(pipelineId, connectionId),
506
+ method: 'DELETE',
507
+ });
508
+ return { connectionId, pipelineId };
509
+ }
316
510
  async function projectList(args = {}) {
317
511
  const response = await CicdGateway.call({
318
512
  endpoint: projectsListEndpoint(args),
@@ -507,6 +701,41 @@ function buildRepositoryMcpPayload(args) {
507
701
  }
508
702
  return payload;
509
703
  }
704
+ function buildPipelineMcpPayload(args) {
705
+ const payload = {};
706
+ for (const [key, value] of Object.entries(args)) {
707
+ if (key === 'id' || value === undefined) {
708
+ continue;
709
+ }
710
+ Object.assign(payload, { [key]: value });
711
+ }
712
+ return payload;
713
+ }
714
+ function buildPipelineConnectionMcpCreatePayloads(args) {
715
+ if ('connections' in args && Array.isArray(args.connections)) {
716
+ return args.connections.map((connection, index) => {
717
+ const payload = parsePipelineConnectionMutationObject(connection, index);
718
+ if (payload.syncMergeState === undefined) {
719
+ payload.syncMergeState = PIPELINE_CONNECTION_SYNC_STATE_NEEDS_RECALCULATING;
720
+ }
721
+ if (payload.syncPullState === undefined) {
722
+ payload.syncPullState = PIPELINE_CONNECTION_SYNC_STATE_NEEDS_RECALCULATING;
723
+ }
724
+ return payload;
725
+ });
726
+ }
727
+ const single = parsePipelineConnectionMutationObject(args);
728
+ if (single.syncMergeState === undefined) {
729
+ single.syncMergeState = PIPELINE_CONNECTION_SYNC_STATE_NEEDS_RECALCULATING;
730
+ }
731
+ if (single.syncPullState === undefined) {
732
+ single.syncPullState = PIPELINE_CONNECTION_SYNC_STATE_NEEDS_RECALCULATING;
733
+ }
734
+ return [single];
735
+ }
736
+ function buildPipelineConnectionMcpUpdatePayloads(args) {
737
+ return args.connections.map((connection, index) => parsePipelineConnectionUpdateObject(connection, index));
738
+ }
510
739
  function validateRepositoryPayload(payload) {
511
740
  const validationError = validateRepositoryNonEmptyStringFields(payload, REPOSITORY_STRING_VALIDATION_KEYS);
512
741
  if (validationError !== undefined) {
@@ -922,9 +1151,18 @@ export const agentiaMcpToolHandlers = wrapMcpToolHandlers({
922
1151
  metadataRefreshRun,
923
1152
  metadataRefreshStatus,
924
1153
  navigationResolve,
1154
+ pipelineConnectionCreate,
1155
+ pipelineConnectionDelete,
925
1156
  pipelineConnectionList,
1157
+ pipelineConnectionUpdate,
1158
+ pipelineCreate,
926
1159
  pipelineGet,
927
1160
  pipelineList,
1161
+ pipelineStageConnectionCreate,
1162
+ pipelineStageConnectionDelete,
1163
+ pipelineStageConnectionList,
1164
+ pipelineStageConnectionUpdate,
1165
+ pipelineUpdate,
928
1166
  projectDefaultGet,
929
1167
  projectDefaultSet,
930
1168
  projectDefaultUnset,
@@ -944,6 +1182,11 @@ export const agentiaMcpToolHandlers = wrapMcpToolHandlers({
944
1182
  repositoryReset,
945
1183
  repositoryUpdate,
946
1184
  repositoryValidate,
1185
+ stageCreate,
1186
+ stageDelete,
1187
+ stageGet,
1188
+ stageList,
1189
+ stageUpdate,
947
1190
  userGet,
948
1191
  workStatus,
949
1192
  ...agentiaMcpTestingToolHandlers,
@@ -972,6 +1215,25 @@ const projectSelectorSchema = {
972
1215
  sprint: z.boolean().optional().describe('Select the sprint default.'),
973
1216
  team: z.boolean().optional().describe('Select the team default.'),
974
1217
  };
1218
+ const pipelineMutationSchema = {
1219
+ active: z.boolean().optional().describe('Whether the pipeline is active.'),
1220
+ blockCommits: z.boolean().optional().describe('Block commits on the pipeline.'),
1221
+ calculateBasedOn: z.enum(PIPELINE_CALCULATE_BASED_ON_VALUES).optional().describe('Promotion calculation basis.'),
1222
+ enableSmartConflictResolution: z.boolean().optional().describe('Enable smart conflict resolution.'),
1223
+ gitRepositoryId: z.string().optional().describe('Git repository ID.'),
1224
+ mainBranch: z.string().optional().describe('Main branch name.'),
1225
+ platform: z.enum(PIPELINE_PLATFORMS).optional().describe('Pipeline platform.'),
1226
+ };
1227
+ const pipelineConnectionMutationSchema = {
1228
+ branch: z.string().optional().describe('Source branch for the connection.'),
1229
+ destinationBranch: z.string().optional().describe('Destination branch for the connection.'),
1230
+ destinationEnvironmentId: z.string().optional().describe('Destination environment ID.'),
1231
+ id: z.string().optional().describe('Pipeline connection ID.'),
1232
+ sourceEnvironmentId: z.string().optional().describe('Source environment ID.'),
1233
+ stageConnectionId: z.string().optional().describe('Stage connection ID.'),
1234
+ syncMergeState: z.string().optional().describe('Sync merge state.'),
1235
+ syncPullState: z.string().optional().describe('Sync pull state.'),
1236
+ };
975
1237
  const repositoryMutationSchema = {
976
1238
  allowFunctionsGitCache: z.boolean().optional().describe('Allow Functions Git cache for this repository.'),
977
1239
  authType: z.enum(REPOSITORY_AUTH_TYPES).optional().describe('Repository authentication type.'),
@@ -1161,7 +1423,12 @@ export function registerAgentiaMcpTools(server) {
1161
1423
  }, (args) => safelyHandleTool(() => jobPause(args)));
1162
1424
  server.registerTool('agentia_pipeline_list', {
1163
1425
  description: 'List Copado pipelines via the CICD gateway.',
1164
- inputSchema: listPaginationZodFields,
1426
+ inputSchema: {
1427
+ active: z.boolean().optional().describe('Filter by active status.'),
1428
+ name: z.string().optional().describe('Filter by pipeline name.'),
1429
+ platform: z.enum(PIPELINE_PLATFORMS).optional().describe('Filter by pipeline platform.'),
1430
+ ...listPaginationZodFields,
1431
+ },
1165
1432
  title: 'Agentia Pipeline List',
1166
1433
  }, (args) => safelyHandleTool(() => pipelineList(args || {})));
1167
1434
  server.registerTool('agentia_pipeline_get', {
@@ -1171,13 +1438,124 @@ export function registerAgentiaMcpTools(server) {
1171
1438
  },
1172
1439
  title: 'Agentia Pipeline Get',
1173
1440
  }, (args) => safelyHandleTool(() => pipelineGet(args)));
1441
+ server.registerTool('agentia_pipeline_create', {
1442
+ description: 'Create a Copado pipeline via the CICD gateway.',
1443
+ inputSchema: {
1444
+ ...pipelineMutationSchema,
1445
+ name: z.string().describe('Pipeline name.'),
1446
+ },
1447
+ title: 'Agentia Pipeline Create',
1448
+ }, (args) => safelyHandleTool(() => pipelineCreate(args)));
1449
+ server.registerTool('agentia_pipeline_update', {
1450
+ description: 'Update a Copado pipeline via the CICD gateway.',
1451
+ inputSchema: {
1452
+ ...pipelineMutationSchema,
1453
+ id: z.string().describe('Pipeline Id.'),
1454
+ name: z.string().optional().describe('Pipeline name.'),
1455
+ },
1456
+ title: 'Agentia Pipeline Update',
1457
+ }, (args) => safelyHandleTool(() => pipelineUpdate(args)));
1174
1458
  server.registerTool('agentia_pipeline_connection_list', {
1175
- description: 'List Copado pipeline connections via list or describe endpoints.',
1459
+ description: 'List Copado pipeline connections via describe or pipeline list.',
1176
1460
  inputSchema: {
1177
1461
  pipelineId: z.string().optional().describe('Optional pipeline Id. When set, uses the describe endpoint.'),
1178
1462
  },
1179
1463
  title: 'Agentia Pipeline Connection List',
1180
1464
  }, (args) => safelyHandleTool(() => pipelineConnectionList(args)));
1465
+ server.registerTool('agentia_pipeline_connection_create', {
1466
+ description: 'Create one or more Copado pipeline connections via the CICD gateway.',
1467
+ inputSchema: {
1468
+ ...pipelineConnectionMutationSchema,
1469
+ connections: z
1470
+ .array(z.object(pipelineConnectionMutationSchema))
1471
+ .optional()
1472
+ .describe('Optional array of connections to create in bulk.'),
1473
+ pipelineId: z.string().describe('Pipeline Id.'),
1474
+ },
1475
+ title: 'Agentia Pipeline Connection Create',
1476
+ }, (args) => safelyHandleTool(() => pipelineConnectionCreate(args)));
1477
+ server.registerTool('agentia_pipeline_connection_update', {
1478
+ description: 'Update one or more Copado pipeline connections via the CICD gateway.',
1479
+ inputSchema: {
1480
+ connections: z.array(z.object(pipelineConnectionMutationSchema)).describe('Connections to update.'),
1481
+ pipelineId: z.string().describe('Pipeline Id.'),
1482
+ },
1483
+ title: 'Agentia Pipeline Connection Update',
1484
+ }, (args) => safelyHandleTool(() => pipelineConnectionUpdate(args)));
1485
+ server.registerTool('agentia_pipeline_connection_delete', {
1486
+ description: 'Delete one or more Copado pipeline connections via the CICD gateway.',
1487
+ inputSchema: {
1488
+ connectionIds: z.array(z.string()).describe('Pipeline connection IDs to delete.'),
1489
+ pipelineId: z.string().describe('Pipeline Id.'),
1490
+ },
1491
+ title: 'Agentia Pipeline Connection Delete',
1492
+ }, (args) => safelyHandleTool(() => pipelineConnectionDelete(args)));
1493
+ server.registerTool('agentia_stage_list', {
1494
+ description: 'List Copado stages via the CICD gateway.',
1495
+ inputSchema: listPaginationZodFields,
1496
+ title: 'Agentia Stage List',
1497
+ }, (args) => safelyHandleTool(() => stageList(args || {})));
1498
+ server.registerTool('agentia_stage_get', {
1499
+ description: 'Get a Copado stage via the CICD gateway.',
1500
+ inputSchema: { id: z.string().describe('Stage ID.') },
1501
+ title: 'Agentia Stage Get',
1502
+ }, (args) => safelyHandleTool(() => stageGet(args)));
1503
+ server.registerTool('agentia_stage_create', {
1504
+ description: `Create a Copado stage. Common metaStage values include ${STAGE_META_STAGE_SUGGESTIONS.join(', ')}; custom values are allowed.`,
1505
+ inputSchema: {
1506
+ metaStage: z.string().optional().describe('Stage category; custom values are allowed.'),
1507
+ name: z.string().describe('Stage name.'),
1508
+ },
1509
+ title: 'Agentia Stage Create',
1510
+ }, (args) => safelyHandleTool(() => stageCreate(args)));
1511
+ server.registerTool('agentia_stage_update', {
1512
+ description: 'Update a Copado stage via the CICD gateway.',
1513
+ inputSchema: {
1514
+ id: z.string().describe('Stage ID.'),
1515
+ metaStage: z.string().optional().describe('Stage category; custom values are allowed.'),
1516
+ name: z.string().optional().describe('Stage name.'),
1517
+ },
1518
+ title: 'Agentia Stage Update',
1519
+ }, (args) => safelyHandleTool(() => stageUpdate(args)));
1520
+ server.registerTool('agentia_stage_delete', {
1521
+ description: 'Delete a Copado stage via the CICD gateway.',
1522
+ inputSchema: { id: z.string().describe('Stage ID.') },
1523
+ title: 'Agentia Stage Delete',
1524
+ }, (args) => safelyHandleTool(() => stageDelete(args)));
1525
+ server.registerTool('agentia_pipeline_stage_connection_create', {
1526
+ description: 'Create a pipeline stage connection via the CICD gateway.',
1527
+ inputSchema: {
1528
+ nextPipelineStageConnectionId: z.string().optional().describe('Next pipeline stage connection ID.'),
1529
+ pipelineId: z.string().describe('Pipeline ID.'),
1530
+ stageId: z.string().describe('Stage ID.'),
1531
+ },
1532
+ title: 'Agentia Pipeline Stage Connection Create',
1533
+ }, (args) => safelyHandleTool(() => pipelineStageConnectionCreate(args)));
1534
+ server.registerTool('agentia_pipeline_stage_connection_list', {
1535
+ description: 'List pipeline stage connections from the pipeline describe response.',
1536
+ inputSchema: {
1537
+ pipelineId: z.string().describe('Pipeline ID.'),
1538
+ },
1539
+ title: 'Agentia Pipeline Stage Connection List',
1540
+ }, (args) => safelyHandleTool(() => pipelineStageConnectionList(args)));
1541
+ server.registerTool('agentia_pipeline_stage_connection_update', {
1542
+ description: 'Update a pipeline stage connection via the CICD gateway.',
1543
+ inputSchema: {
1544
+ connectionId: z.string().describe('Pipeline stage connection ID.'),
1545
+ nextPipelineStageConnectionId: z.string().optional().describe('Next pipeline stage connection ID.'),
1546
+ pipelineId: z.string().describe('Pipeline ID.'),
1547
+ stageId: z.string().optional().describe('Stage ID.'),
1548
+ },
1549
+ title: 'Agentia Pipeline Stage Connection Update',
1550
+ }, (args) => safelyHandleTool(() => pipelineStageConnectionUpdate(args)));
1551
+ server.registerTool('agentia_pipeline_stage_connection_delete', {
1552
+ description: 'Delete a pipeline stage connection via the CICD gateway.',
1553
+ inputSchema: {
1554
+ connectionId: z.string().describe('Pipeline stage connection ID.'),
1555
+ pipelineId: z.string().describe('Pipeline ID.'),
1556
+ },
1557
+ title: 'Agentia Pipeline Stage Connection Delete',
1558
+ }, (args) => safelyHandleTool(() => pipelineStageConnectionDelete(args)));
1181
1559
  server.registerTool('agentia_project_list', {
1182
1560
  description: 'List Copado projects via the CICD gateway.',
1183
1561
  inputSchema: {