@copado/agentia-cli 0.27.0-alpha.0 → 0.29.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 (95) hide show
  1. package/README.md +170 -86
  2. package/dist/commands/environment/list.d.ts +5 -1
  3. package/dist/commands/environment/list.js +10 -8
  4. package/dist/commands/environment/list.js.map +1 -1
  5. package/dist/commands/job/list.d.ts +4 -2
  6. package/dist/commands/job/list.js +10 -12
  7. package/dist/commands/job/list.js.map +1 -1
  8. package/dist/commands/pipeline/list.d.ts +6 -1
  9. package/dist/commands/pipeline/list.js +10 -7
  10. package/dist/commands/pipeline/list.js.map +1 -1
  11. package/dist/commands/project/list.d.ts +4 -1
  12. package/dist/commands/project/list.js +7 -5
  13. package/dist/commands/project/list.js.map +1 -1
  14. package/dist/commands/promotion/list.d.ts +4 -2
  15. package/dist/commands/promotion/list.js +8 -6
  16. package/dist/commands/promotion/list.js.map +1 -1
  17. package/dist/commands/setup.d.ts +12 -0
  18. package/dist/commands/setup.js +52 -0
  19. package/dist/commands/setup.js.map +1 -0
  20. package/dist/commands/work/list.d.ts +4 -1
  21. package/dist/commands/work/list.js +7 -5
  22. package/dist/commands/work/list.js.map +1 -1
  23. package/dist/commands/work/set.js +8 -1
  24. package/dist/commands/work/set.js.map +1 -1
  25. package/dist/commands/work/submit.d.ts +5 -0
  26. package/dist/commands/work/submit.js +93 -5
  27. package/dist/commands/work/submit.js.map +1 -1
  28. package/dist/commands/work/test.d.ts +10 -0
  29. package/dist/commands/work/test.js +61 -0
  30. package/dist/commands/work/test.js.map +1 -0
  31. package/dist/lib/agentia-command.d.ts +3 -0
  32. package/dist/lib/agentia-command.js +12 -1
  33. package/dist/lib/agentia-command.js.map +1 -1
  34. package/dist/lib/cicd-gateway.d.ts +3 -0
  35. package/dist/lib/cicd-gateway.js +19 -2
  36. package/dist/lib/cicd-gateway.js.map +1 -1
  37. package/dist/lib/defaults-store.d.ts +3 -0
  38. package/dist/lib/defaults-store.js +24 -0
  39. package/dist/lib/defaults-store.js.map +1 -1
  40. package/dist/lib/environment-flags.d.ts +3 -1
  41. package/dist/lib/environment-flags.js +3 -1
  42. package/dist/lib/environment-flags.js.map +1 -1
  43. package/dist/lib/environment-types.d.ts +4 -1
  44. package/dist/lib/environment-types.js +2 -0
  45. package/dist/lib/environment-types.js.map +1 -1
  46. package/dist/lib/git-worktree.d.ts +4 -0
  47. package/dist/lib/git-worktree.js +46 -2
  48. package/dist/lib/git-worktree.js.map +1 -1
  49. package/dist/lib/job-types.d.ts +7 -4
  50. package/dist/lib/job-types.js +8 -15
  51. package/dist/lib/job-types.js.map +1 -1
  52. package/dist/lib/list-pagination.d.ts +46 -0
  53. package/dist/lib/list-pagination.js +106 -0
  54. package/dist/lib/list-pagination.js.map +1 -0
  55. package/dist/lib/local-quality-gates.d.ts +45 -0
  56. package/dist/lib/local-quality-gates.js +103 -0
  57. package/dist/lib/local-quality-gates.js.map +1 -0
  58. package/dist/lib/mcp/tools.d.ts +67 -75
  59. package/dist/lib/mcp/tools.js +28 -360
  60. package/dist/lib/mcp/tools.js.map +1 -1
  61. package/dist/lib/mcp/work-tools.d.ts +73 -0
  62. package/dist/lib/mcp/work-tools.js +475 -0
  63. package/dist/lib/mcp/work-tools.js.map +1 -0
  64. package/dist/lib/open-browser.d.ts +3 -0
  65. package/dist/lib/open-browser.js +13 -1
  66. package/dist/lib/open-browser.js.map +1 -1
  67. package/dist/lib/pipeline-types.d.ts +6 -1
  68. package/dist/lib/pipeline-types.js +10 -6
  69. package/dist/lib/pipeline-types.js.map +1 -1
  70. package/dist/lib/project-flags.d.ts +3 -2
  71. package/dist/lib/project-flags.js +3 -1
  72. package/dist/lib/project-flags.js.map +1 -1
  73. package/dist/lib/project-setup.d.ts +80 -0
  74. package/dist/lib/project-setup.js +383 -0
  75. package/dist/lib/project-setup.js.map +1 -0
  76. package/dist/lib/project-types.d.ts +5 -1
  77. package/dist/lib/project-types.js +6 -10
  78. package/dist/lib/project-types.js.map +1 -1
  79. package/dist/lib/promotion-flags.d.ts +4 -3
  80. package/dist/lib/promotion-flags.js +3 -8
  81. package/dist/lib/promotion-flags.js.map +1 -1
  82. package/dist/lib/promotion-types.d.ts +8 -5
  83. package/dist/lib/promotion-types.js +10 -14
  84. package/dist/lib/promotion-types.js.map +1 -1
  85. package/dist/lib/setup-templates.d.ts +11 -0
  86. package/dist/lib/setup-templates.js +181 -0
  87. package/dist/lib/setup-templates.js.map +1 -0
  88. package/dist/lib/work-flags.d.ts +3 -1
  89. package/dist/lib/work-flags.js +3 -1
  90. package/dist/lib/work-flags.js.map +1 -1
  91. package/dist/lib/work-types.d.ts +20 -1
  92. package/dist/lib/work-types.js +16 -3
  93. package/dist/lib/work-types.js.map +1 -1
  94. package/oclif.manifest.json +194 -18
  95. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable max-lines -- Tool schemas and registrations are intentionally colocated. */
2
2
  import { z } from 'zod';
3
- import { normalizeEnvironments } from '../../commands/environment/list.js';
3
+ import { normalizeEnvironmentsListPage } from '../../commands/environment/list.js';
4
4
  import { buildMetadataCompareFileRequests } from '../../commands/metadata/content/compare.js';
5
5
  import { buildMetadataContentRequest } from '../../commands/metadata/content/get.js';
6
6
  import { buildMetadataCompareRequest } from '../../commands/metadata/index/compare.js';
@@ -9,89 +9,33 @@ import { assertRequired } from '../assert.js';
9
9
  import { CicdGateway, normalizeCicdBaseUrl } from '../cicd-gateway.js';
10
10
  import { CICD_REGIONS } from '../cicd-region.js';
11
11
  import { ALL_CREDENTIAL_TYPES, credentialLabel, getCicdBaseUrl, getCredential, maskSecret, setCicdBaseUrl, setCredential, } from '../credential-store.js';
12
- import { readDefaults, readLastBaseBranch, readLastWorkItem, resolveDefaults, unsetDefaults, writeDefaults, writeLastWorkSelection, } from '../defaults-store.js';
12
+ import { readDefaults, readLastWorkItem, resolveDefaults, unsetDefaults, writeDefaults, } from '../defaults-store.js';
13
13
  import { runEnvironmentAuthStatus } from '../environment-auth-status.js';
14
14
  import { buildCreatePayload, buildMutationPayload, ENVIRONMENT_STRING_VALIDATION_KEYS, validateNonEmptyStringFields, } from '../environment-flags.js';
15
15
  import { DEFAULT_ENVIRONMENT_PLATFORM, DEFAULT_ENVIRONMENT_TYPE, ENVIRONMENT_TYPES, environmentEndpoint, environmentsListEndpoint, } from '../environment-types.js';
16
- import { checkoutFeatureBranch, fetchOriginBranch, getCurrentBranch, hasUnpushedCommits, listPendingChanges, } from '../git-worktree.js';
17
- import { JOB_LIST_LIMIT_MAX, JOB_LIST_LIMIT_MIN, jobEndpoint, jobKillEndpoint, jobListEndpoint, jobPauseEndpoint, jobResultLogEndpoint, jobResumeEndpoint, jobRunEndpoint, normalizeJob, normalizeJobOperation, normalizeJobs, resolveJobStepForLog, } from '../job-types.js';
16
+ import { jobEndpoint, jobKillEndpoint, jobListEndpoint, jobPauseEndpoint, jobResultLogEndpoint, jobResumeEndpoint, jobRunEndpoint, normalizeJob, normalizeJobOperation, normalizeJobsListPage, resolveJobStepForLog, } from '../job-types.js';
17
+ import { listPaginationZodFields, mcpPaginatedListPayload } from '../list-pagination.js';
18
18
  import { normalizeLocalGatewayBaseUrl, readLocalGatewayConfig } from '../local-gateway-config.js';
19
19
  import { COMPARISON_MODES, CONTENT_SOURCES, contentResultToCompareSide, createUnifiedDiff, INDEX_SOURCES, MODULE_TYPES, ORDER_DIRECTIONS, PLATFORM_EXPERIENCES, RETRIEVE_MODES, sourceSideLabel, } from '../metadata-common.js';
20
20
  import { buildRefreshDeletedRequest, buildRefreshIndexRequest, refreshStatusEndpoint, resolveRefreshSourceFromEnv, } from '../metadata-refresh.js';
21
- import { normalizePipelineDescribe, normalizePipelines, pipelineConnectionsFromPipelines, pipelineDescribeEndpoint, pipelineListEndpoint, } from '../pipeline-types.js';
21
+ import { normalizePipelineDescribe, normalizePipelines, normalizePipelinesListPage, pipelineConnectionsFromPipelines, pipelineDescribeEndpoint, pipelineListEndpoint, } from '../pipeline-types.js';
22
22
  import { buildSetValues, collectSelectedKeys } from '../project-default-flags.js';
23
23
  import { PROJECT_DEFAULT_KEYS } from '../project-defaults.js';
24
- import { normalizeProject, normalizeProjects, projectEndpoint, projectsListEndpoint, } from '../project-types.js';
24
+ import { normalizeProject, normalizeProjectsListPage, projectEndpoint, projectsListEndpoint, } from '../project-types.js';
25
25
  import { buildPromotionConflictResolutionRequest, normalizePromotionConflicts, PROMOTION_CONFLICT_MODES, promotionConflictContentEndpoint, promotionConflictResolveEndpoint, promotionConflictsEndpoint, promotionConflictUndoEndpoint, withPromotionConflictErrorTranslation, } from '../promotion-conflicts.js';
26
- import { normalizePromotionDetail, normalizePromotions, PROMOTION_LIST_LIMIT_MAX, PROMOTION_LIST_LIMIT_MIN, promotionEndpoint, promotionListEndpoint, } from '../promotion-types.js';
26
+ import { normalizePromotionDetail, normalizePromotionsListPage, promotionEndpoint, promotionListEndpoint, } from '../promotion-types.js';
27
27
  import { getUserContext } from '../user-context.js';
28
28
  import { DEFAULT_USER_ID, resolveUserId, userEndpoint } from '../user-types.js';
29
- import { resolveWorkItemId } from '../work-active.js';
30
- import { buildWorkCreatePayload } from '../work-defaults.js';
31
- import { validateNonEmptyStringFields as validateWorkNonEmptyStringFields, WORK_STRING_VALIDATION_KEYS, } from '../work-flags.js';
32
- import { performWorkPush } from '../work-push.js';
33
- import { extractUserStoryFromFeatureBranch, featureBranchName, normalizeUserStories, workCreateEndpoint, workDoneEndpoint, workEndpoint, workListEndpoint, workSetEndpoint, workStatusEndpoint, workSubmitEndpoint, } from '../work-types.js';
29
+ import { workStatusEndpoint } from '../work-types.js';
34
30
  import { safelyHandleTool } from './result.js';
31
+ import { agentiaMcpWorkToolHandlers, registerAgentiaMcpWorkTools } from './work-tools.js';
35
32
  const MAX_LIMIT = 2000;
36
- const WORK_MUTATION_PAYLOAD_KEYS = [
37
- 'acceptanceCriteria',
38
- 'actualPoints',
39
- 'asA',
40
- 'assignee',
41
- 'cancellationReason',
42
- 'closeDate',
43
- 'epic',
44
- 'excludedFromCbm',
45
- 'feature',
46
- 'functionalRequirements',
47
- 'ownerId',
48
- 'plannedPoints',
49
- 'priority',
50
- 'project',
51
- 'recordType',
52
- 'releaseId',
53
- 'soThat',
54
- 'sourceCredential',
55
- 'sourceEnvironment',
56
- 'sprintId',
57
- 'status',
58
- 'team',
59
- 'technicalSpecifications',
60
- 'theme',
61
- 'title',
62
- 'wantTo',
63
- ];
64
- function buildWorkMutationPayloadFromArgs(args) {
65
- const payload = {};
66
- for (const key of WORK_MUTATION_PAYLOAD_KEYS) {
67
- const value = args[key];
68
- if (value !== undefined) {
69
- Object.assign(payload, { [key]: value });
70
- }
71
- }
72
- return payload;
73
- }
74
33
  async function environmentList(args = {}) {
75
- const filters = {};
76
- if (args.name !== undefined) {
77
- filters.name = args.name;
78
- }
79
- if (args.orgId !== undefined) {
80
- filters.orgId = args.orgId;
81
- }
82
- if (args.platform !== undefined) {
83
- filters.platform = args.platform;
84
- }
85
- if (args.type !== undefined) {
86
- filters.type = args.type;
87
- }
88
34
  const response = await CicdGateway.call({
89
- endpoint: environmentsListEndpoint(filters),
35
+ endpoint: environmentsListEndpoint(args),
90
36
  method: 'GET',
91
37
  });
92
- const environments = normalizeEnvironments(response);
93
- const limit = args.limit === undefined ? environments.length : Math.min(Math.max(args.limit, 1), MAX_LIMIT);
94
- return { environments: environments.slice(0, limit) };
38
+ return mcpPaginatedListPayload('environments', normalizeEnvironmentsListPage(response));
95
39
  }
96
40
  async function environmentGet(args) {
97
41
  const environment = await CicdGateway.call({
@@ -105,7 +49,7 @@ async function promotionList(args = {}) {
105
49
  endpoint: promotionListEndpoint(args),
106
50
  method: 'GET',
107
51
  });
108
- return { promotions: normalizePromotions(response) };
52
+ return mcpPaginatedListPayload('promotions', normalizePromotionsListPage(response));
109
53
  }
110
54
  async function promotionGet(args) {
111
55
  const response = await CicdGateway.call({
@@ -187,9 +131,10 @@ async function environmentUpdate(args) {
187
131
  async function jobList(args) {
188
132
  const filters = {
189
133
  context: args.context,
134
+ cursor: args.cursor,
190
135
  id: args.id,
191
- limit: args.limit,
192
136
  name: args.name,
137
+ pageSize: args.pageSize,
193
138
  parent: args.parent,
194
139
  status: args.status,
195
140
  type: args.type,
@@ -205,7 +150,7 @@ async function jobList(args) {
205
150
  endpoint: jobListEndpoint(filters),
206
151
  method: 'GET',
207
152
  });
208
- return { jobs: normalizeJobs(response) };
153
+ return mcpPaginatedListPayload('jobs', normalizeJobsListPage(response));
209
154
  }
210
155
  async function jobGet(args) {
211
156
  const response = await CicdGateway.call({
@@ -242,12 +187,12 @@ async function jobPause(args) {
242
187
  });
243
188
  return { result: normalizeJobOperation(result) };
244
189
  }
245
- async function pipelineList() {
190
+ async function pipelineList(args = {}) {
246
191
  const response = await CicdGateway.call({
247
- endpoint: pipelineListEndpoint(),
192
+ endpoint: pipelineListEndpoint(args),
248
193
  method: 'GET',
249
194
  });
250
- return { pipelines: normalizePipelines(response) };
195
+ return mcpPaginatedListPayload('pipelines', normalizePipelinesListPage(response));
251
196
  }
252
197
  async function pipelineGet(args) {
253
198
  const response = await CicdGateway.call({
@@ -276,18 +221,11 @@ async function pipelineConnectionList(args) {
276
221
  return { connections };
277
222
  }
278
223
  async function projectList(args = {}) {
279
- const filters = {};
280
- if (args.mine) {
281
- filters.mine = true;
282
- }
283
- if (typeof args.name === 'string') {
284
- filters.name = args.name;
285
- }
286
224
  const response = await CicdGateway.call({
287
- endpoint: projectsListEndpoint(filters),
225
+ endpoint: projectsListEndpoint(args),
288
226
  method: 'GET',
289
227
  });
290
- return { projects: normalizeProjects(response) };
228
+ return mcpPaginatedListPayload('projects', normalizeProjectsListPage(response));
291
229
  }
292
230
  async function userGet(args = {}) {
293
231
  const user = await CicdGateway.call({
@@ -499,99 +437,6 @@ async function metadataDependencyList(args) {
499
437
  });
500
438
  return { result };
501
439
  }
502
- async function workList(args = {}) {
503
- const filters = {
504
- assigneeId: args.assigneeId,
505
- assigneeName: args.assigneeName,
506
- name: args.name,
507
- ownerId: args.ownerId,
508
- ownerName: args.ownerName,
509
- projectId: args.projectId,
510
- projectName: args.projectName,
511
- status: args.status,
512
- title: args.title,
513
- };
514
- const assignedToMe = args.assignedToMe === true;
515
- const ownedByMe = args.ownedByMe === true;
516
- if (assignedToMe && ownedByMe) {
517
- throw new Error('Use either assignedToMe or ownedByMe, not both.');
518
- }
519
- if (assignedToMe && args.assigneeId !== undefined) {
520
- throw new Error('Cannot use assignedToMe with assigneeId.');
521
- }
522
- if (ownedByMe && args.ownerId !== undefined) {
523
- throw new Error('Cannot use ownedByMe with ownerId.');
524
- }
525
- if (assignedToMe || ownedByMe) {
526
- const userContext = await getUserContext();
527
- const userId = userContext.id;
528
- if (userId === undefined || userId.trim().length === 0) {
529
- throw new Error('Current user ID is unavailable from the CICD gateway context.');
530
- }
531
- if (assignedToMe) {
532
- filters.assigneeId = userId;
533
- }
534
- else {
535
- filters.ownerId = userId;
536
- }
537
- }
538
- const response = await CicdGateway.call({
539
- endpoint: workListEndpoint(filters),
540
- method: 'GET',
541
- });
542
- return { userStories: normalizeUserStories(response) };
543
- }
544
- async function workGet(args = {}) {
545
- const workItemId = await resolveWorkItemId(args.id);
546
- const userStory = await CicdGateway.call({
547
- endpoint: workEndpoint(workItemId),
548
- method: 'GET',
549
- });
550
- return { userStory };
551
- }
552
- async function workCreate(args = {}) {
553
- const explicitPayload = buildWorkMutationPayloadFromArgs(args);
554
- const [localDefaults, globalDefaults] = await Promise.all([readDefaults('local'), readDefaults('global')]);
555
- const resolvedDefaults = resolveDefaults(localDefaults, globalDefaults, [...PROJECT_DEFAULT_KEYS]);
556
- const payload = await buildWorkCreatePayload(explicitPayload, resolvedDefaults);
557
- const validationError = validateWorkNonEmptyStringFields(payload, WORK_STRING_VALIDATION_KEYS);
558
- if (validationError !== undefined) {
559
- throw new Error(validationError);
560
- }
561
- const userStory = await CicdGateway.call({
562
- body: payload,
563
- endpoint: workCreateEndpoint(),
564
- headers: { 'Content-Type': 'application/json' },
565
- method: 'POST',
566
- });
567
- return { userStory };
568
- }
569
- async function workUpdate(args) {
570
- const payload = buildWorkMutationPayloadFromArgs(args);
571
- if (Object.keys(payload).length === 0) {
572
- throw new Error('Must provide at least one field to update.');
573
- }
574
- const validationError = validateWorkNonEmptyStringFields(payload, WORK_STRING_VALIDATION_KEYS);
575
- if (validationError !== undefined) {
576
- throw new Error(validationError);
577
- }
578
- const workItemId = await resolveWorkItemId(args.id);
579
- const userStory = await CicdGateway.call({
580
- body: payload,
581
- endpoint: workEndpoint(workItemId),
582
- headers: { 'Content-Type': 'application/json' },
583
- method: 'PATCH',
584
- });
585
- return { userStory };
586
- }
587
- async function workDelete(args) {
588
- const id = assertRequired(args.id, 'id');
589
- await CicdGateway.call({
590
- endpoint: workEndpoint(id),
591
- method: 'DELETE',
592
- });
593
- return { deleted: true, id };
594
- }
595
440
  function authCredentialResult(type) {
596
441
  if (type === 'cicd') {
597
442
  const localConfig = readLocalGatewayConfig();
@@ -756,50 +601,6 @@ async function metadataRefreshDeleted(args) {
756
601
  });
757
602
  return { result };
758
603
  }
759
- function assertCleanWorktree(pendingFiles) {
760
- if (pendingFiles.length > 0) {
761
- throw new Error(`Uncommitted tracked changes present:\n${pendingFiles.map((file) => ` ${file}`).join('\n')}`);
762
- }
763
- }
764
- const mcpWorkPushHooks = {
765
- display: (render) => render(),
766
- log() { },
767
- withSpinner: async (_message, action) => action(),
768
- };
769
- async function workSet(args) {
770
- const setResponse = await CicdGateway.call({
771
- body: { workItem: assertRequired(args.id, 'id') },
772
- endpoint: workSetEndpoint(),
773
- headers: { 'Content-Type': 'application/json' },
774
- method: 'POST',
775
- });
776
- const baseBranch = args.baseBranch?.trim() || setResponse.baseBranch?.trim();
777
- const userStoryId = setResponse.workItem.id?.trim();
778
- const userStoryName = setResponse.workItem.name?.trim();
779
- if (!baseBranch || !userStoryId || !userStoryName)
780
- throw new Error('Work set response is missing a base branch, user story ID, or name.');
781
- assertCleanWorktree(await listPendingChanges());
782
- const branch = featureBranchName(userStoryName);
783
- await fetchOriginBranch(baseBranch);
784
- const checkout = await checkoutFeatureBranch(branch, baseBranch);
785
- await writeLastWorkSelection({ lastBaseBranch: baseBranch, lastWorkItem: userStoryName, lastWorkItemId: userStoryId });
786
- return { ...setResponse, baseBranch, git: { branch: checkout.branch, branchCreated: checkout.created, fetched: true } };
787
- }
788
- async function resolveCurrentWorkBranch() {
789
- const branch = await getCurrentBranch();
790
- const workItem = extractUserStoryFromFeatureBranch(branch);
791
- if (workItem === undefined)
792
- throw new Error(`Current branch '${branch}' is not a feature/US-XXXX branch.`);
793
- assertCleanWorktree(await listPendingChanges());
794
- return { branch, workItem };
795
- }
796
- async function workPush() {
797
- const { branch, workItem } = await resolveCurrentWorkBranch();
798
- const baseBranch = (await readLastBaseBranch())?.trim();
799
- if (!baseBranch)
800
- throw new Error('No base branch recorded. Run work set first.');
801
- return performWorkPush({ baseBranch, branch, hooks: mcpWorkPushHooks, workItem });
802
- }
803
604
  async function workStatus(args = {}) {
804
605
  const workItem = args.id?.trim() || (await readLastWorkItem());
805
606
  if (!workItem)
@@ -807,25 +608,6 @@ async function workStatus(args = {}) {
807
608
  const result = await CicdGateway.call({ endpoint: workStatusEndpoint(workItem), method: 'GET' });
808
609
  return { result };
809
610
  }
810
- async function workSubmitOrDone(kind) {
811
- const { branch, workItem } = await resolveCurrentWorkBranch();
812
- const pushed = await hasUnpushedCommits(branch);
813
- const push = pushed ? await workPush() : undefined;
814
- const endpoint = kind === 'submit' ? workSubmitEndpoint() : workDoneEndpoint();
815
- const result = await CicdGateway.call({
816
- body: { workItem },
817
- endpoint,
818
- headers: { 'Content-Type': 'application/json' },
819
- method: 'POST',
820
- });
821
- return { branch, [kind]: result, ...(push === undefined ? {} : { push }), pushed, workItem };
822
- }
823
- async function workSubmit() {
824
- return workSubmitOrDone('submit');
825
- }
826
- async function workDone() {
827
- return workSubmitOrDone('done');
828
- }
829
611
  export const agentiaMcpToolHandlers = {
830
612
  authGet,
831
613
  authSet,
@@ -864,16 +646,8 @@ export const agentiaMcpToolHandlers = {
864
646
  promotionGet,
865
647
  promotionList,
866
648
  userGet,
867
- workCreate,
868
- workDelete,
869
- workDone,
870
- workGet,
871
- workList,
872
- workPush,
873
- workSet,
874
649
  workStatus,
875
- workSubmit,
876
- workUpdate,
650
+ ...agentiaMcpWorkToolHandlers,
877
651
  };
878
652
  const environmentMutationSchema = {
879
653
  apexTestLevel: z.string().optional().describe('Apex test level.'),
@@ -898,47 +672,12 @@ const projectSelectorSchema = {
898
672
  sprint: z.boolean().optional().describe('Select the sprint default.'),
899
673
  team: z.boolean().optional().describe('Select the team default.'),
900
674
  };
901
- const workMutationSchema = {
902
- acceptanceCriteria: z.string().optional().describe('Acceptance criteria.'),
903
- actualPoints: z.number().int().optional().describe('Actual points.'),
904
- asA: z.string().optional().describe('User story "as a" clause.'),
905
- assignee: z.string().optional().describe('Assignee ID.'),
906
- cancellationReason: z.string().optional().describe('Cancellation reason.'),
907
- closeDate: z.string().optional().describe('Close date.'),
908
- epic: z.string().optional().describe('Epic.'),
909
- excludedFromCbm: z.boolean().optional().describe('Exclude from CBM.'),
910
- feature: z.string().optional().describe('Feature.'),
911
- functionalRequirements: z.string().optional().describe('Functional requirements.'),
912
- ownerId: z.string().optional().describe('Owner ID.'),
913
- plannedPoints: z.number().int().optional().describe('Planned points.'),
914
- priority: z.number().int().optional().describe('Priority.'),
915
- project: z.string().optional().describe('Project ID.'),
916
- recordType: z.string().optional().describe('Record type.'),
917
- releaseId: z.string().optional().describe('Release ID.'),
918
- soThat: z.string().optional().describe('User story "so that" clause.'),
919
- sourceCredential: z.string().optional().describe('Source credential ID.'),
920
- sourceEnvironment: z.string().optional().describe('Source environment ID.'),
921
- sprintId: z.string().optional().describe('Sprint ID.'),
922
- status: z.string().optional().describe('Status.'),
923
- team: z.string().optional().describe('Team.'),
924
- technicalSpecifications: z.string().optional().describe('Technical specifications.'),
925
- theme: z.string().optional().describe('Theme.'),
926
- title: z.string().optional().describe('Title.'),
927
- wantTo: z.string().optional().describe('User story "want to" clause.'),
928
- };
929
675
  const promotionListSchema = {
930
676
  createdById: z.string().optional().describe('Filter by creator ID.'),
931
677
  createdByName: z.string().optional().describe('Filter by creator name.'),
932
678
  destinationEnvironmentId: z.string().optional().describe('Filter by destination environment ID.'),
933
679
  destinationEnvironmentName: z.string().optional().describe('Filter by destination environment name.'),
934
680
  isBackPromotion: z.boolean().optional().describe('Filter by back promotion.'),
935
- limit: z
936
- .number()
937
- .int()
938
- .min(PROMOTION_LIST_LIMIT_MIN)
939
- .max(PROMOTION_LIST_LIMIT_MAX)
940
- .optional()
941
- .describe(`Maximum number of promotions to return (${PROMOTION_LIST_LIMIT_MIN}-${PROMOTION_LIST_LIMIT_MAX}).`),
942
681
  name: z.string().optional().describe('Filter by name.'),
943
682
  pipelineId: z.string().optional().describe('Filter by pipeline ID.'),
944
683
  pipelineName: z.string().optional().describe('Filter by pipeline name.'),
@@ -948,29 +687,17 @@ const promotionListSchema = {
948
687
  sourceEnvironmentName: z.string().optional().describe('Filter by source environment name.'),
949
688
  status: z.string().optional().describe('Filter by status.'),
950
689
  userStoryId: z.string().optional().describe('Filter by user story ID.'),
951
- };
952
- const workListSchema = {
953
- assignedToMe: z.boolean().optional().describe('Filter by the current user as assignee.'),
954
- assigneeId: z.string().optional().describe('Filter by assignee ID.'),
955
- assigneeName: z.string().optional().describe('Filter by assignee name.'),
956
- name: z.string().optional().describe('Filter by name.'),
957
- ownedByMe: z.boolean().optional().describe('Filter by the current user as owner.'),
958
- ownerId: z.string().optional().describe('Filter by owner ID.'),
959
- ownerName: z.string().optional().describe('Filter by owner name.'),
960
- projectId: z.string().optional().describe('Filter by project ID.'),
961
- projectName: z.string().optional().describe('Filter by project name.'),
962
- status: z.string().optional().describe('Filter by status.'),
963
- title: z.string().optional().describe('Filter by title.'),
690
+ ...listPaginationZodFields,
964
691
  };
965
692
  export function registerAgentiaMcpTools(server) {
966
693
  server.registerTool('agentia_environment_list', {
967
694
  description: 'List Copado environments via the CICD gateway.',
968
695
  inputSchema: {
969
- limit: z.number().int().min(1).max(MAX_LIMIT).optional().describe('Maximum number of environments to return.'),
970
696
  name: z.string().optional().describe('Filter by name.'),
971
697
  orgId: z.string().optional().describe('Filter by Salesforce org ID.'),
972
698
  platform: z.string().optional().describe('Filter by platform.'),
973
699
  type: z.string().optional().describe('Filter by environment type.'),
700
+ ...listPaginationZodFields,
974
701
  },
975
702
  title: 'Agentia Environment List',
976
703
  }, (args) => safelyHandleTool(() => environmentList(args || {})));
@@ -1015,18 +742,12 @@ export function registerAgentiaMcpTools(server) {
1015
742
  inputSchema: {
1016
743
  context: z.string().optional().describe('Contains match on JobExecution context.'),
1017
744
  id: z.string().optional().describe('Exact JobExecution Id.'),
1018
- limit: z
1019
- .number()
1020
- .int()
1021
- .min(JOB_LIST_LIMIT_MIN)
1022
- .max(JOB_LIST_LIMIT_MAX)
1023
- .optional()
1024
- .describe(`Maximum number of jobs to return (${JOB_LIST_LIMIT_MIN}-${JOB_LIST_LIMIT_MAX}).`),
1025
745
  mine: z.boolean().optional().describe('List only jobs owned by the current user.'),
1026
746
  name: z.string().optional().describe('Contains match on JobExecution name.'),
1027
747
  parent: z.string().optional().describe('Exact parent record Id.'),
1028
748
  status: z.string().optional().describe('Exact Copado job status.'),
1029
749
  type: z.string().optional().describe('Contains match on Job Template name.'),
750
+ ...listPaginationZodFields,
1030
751
  },
1031
752
  title: 'Agentia Job List',
1032
753
  }, (args) => safelyHandleTool(() => jobList(args)));
@@ -1068,9 +789,9 @@ export function registerAgentiaMcpTools(server) {
1068
789
  }, (args) => safelyHandleTool(() => jobPause(args)));
1069
790
  server.registerTool('agentia_pipeline_list', {
1070
791
  description: 'List Copado pipelines via the CICD gateway.',
1071
- inputSchema: {},
792
+ inputSchema: listPaginationZodFields,
1072
793
  title: 'Agentia Pipeline List',
1073
- }, () => safelyHandleTool(() => pipelineList()));
794
+ }, (args) => safelyHandleTool(() => pipelineList(args || {})));
1074
795
  server.registerTool('agentia_pipeline_get', {
1075
796
  description: 'Describe a Copado pipeline via the CICD gateway.',
1076
797
  inputSchema: {
@@ -1090,6 +811,7 @@ export function registerAgentiaMcpTools(server) {
1090
811
  inputSchema: {
1091
812
  mine: z.boolean().optional().describe('When true, list only projects owned by or related to the current user.'),
1092
813
  name: z.string().optional().describe('Filter by name (partial match).'),
814
+ ...listPaginationZodFields,
1093
815
  },
1094
816
  title: 'Agentia Project List',
1095
817
  }, (args) => safelyHandleTool(() => projectList(args || {})));
@@ -1128,38 +850,7 @@ export function registerAgentiaMcpTools(server) {
1128
850
  inputSchema: projectSelectorSchema,
1129
851
  title: 'Agentia Project Default Unset',
1130
852
  }, (args) => safelyHandleTool(() => projectDefaultUnset(args || {})));
1131
- server.registerTool('agentia_work_list', {
1132
- description: 'List Copado user stories via the CICD gateway.',
1133
- inputSchema: workListSchema,
1134
- title: 'Agentia Work List',
1135
- }, (args) => safelyHandleTool(() => workList(args || {})));
1136
- server.registerTool('agentia_work_get', {
1137
- description: 'Get a Copado user story by Id via the CICD gateway. Omit Id to use the active work item from work set.',
1138
- inputSchema: {
1139
- id: z.string().optional().describe('User story Id. Defaults to the active work item from work set.'),
1140
- },
1141
- title: 'Agentia Work Get',
1142
- }, (args) => safelyHandleTool(() => workGet(args || {})));
1143
- server.registerTool('agentia_work_create', {
1144
- description: 'Create a Copado user story via the CICD gateway.',
1145
- inputSchema: workMutationSchema,
1146
- title: 'Agentia Work Create',
1147
- }, (args) => safelyHandleTool(() => workCreate(args || {})));
1148
- server.registerTool('agentia_work_update', {
1149
- description: 'Update a Copado user story by Id via the CICD gateway. Omit Id to use the active work item from work set.',
1150
- inputSchema: {
1151
- ...workMutationSchema,
1152
- id: z.string().optional().describe('User story Id. Defaults to the active work item from work set.'),
1153
- },
1154
- title: 'Agentia Work Update',
1155
- }, (args) => safelyHandleTool(() => workUpdate(args)));
1156
- server.registerTool('agentia_work_delete', {
1157
- description: 'Delete a Copado user story by Id via the CICD gateway.',
1158
- inputSchema: {
1159
- id: z.string().describe('User story Id.'),
1160
- },
1161
- title: 'Agentia Work Delete',
1162
- }, (args) => safelyHandleTool(() => workDelete(args)));
853
+ registerAgentiaMcpWorkTools(server);
1163
854
  server.registerTool('agentia_metadata_list', {
1164
855
  description: 'Search the Copado metadata index via the CICD gateway.',
1165
856
  inputSchema: {
@@ -1352,33 +1043,10 @@ export function registerAgentiaMcpTools(server) {
1352
1043
  },
1353
1044
  title: 'Agentia Metadata Refresh Deleted',
1354
1045
  }, (args) => safelyHandleTool(() => metadataRefreshDeleted(args)));
1355
- server.registerTool('agentia_work_set', {
1356
- description: 'Set the active work item, then fetch and check out its feature branch in the MCP server current Git repository. Changes the current branch.',
1357
- inputSchema: {
1358
- baseBranch: z.string().optional().describe('Override the base branch returned by Copado.'),
1359
- id: z.string().describe('User story ID or name.'),
1360
- },
1361
- title: 'Agentia Work Set',
1362
- }, (args) => safelyHandleTool(() => workSet(args)));
1363
1046
  server.registerTool('agentia_work_status', {
1364
1047
  description: 'Get work status and related jobs. Defaults to the active work item from work set.',
1365
1048
  inputSchema: { id: z.string().optional().describe('User story ID or name.') },
1366
1049
  title: 'Agentia Work Status',
1367
1050
  }, (args) => safelyHandleTool(() => workStatus(args || {})));
1368
- server.registerTool('agentia_work_push', {
1369
- description: 'Push and register commits for the current feature branch in the MCP server current Git repository. Pushes to origin.',
1370
- inputSchema: {},
1371
- title: 'Agentia Work Push',
1372
- }, () => safelyHandleTool(() => workPush()));
1373
- server.registerTool('agentia_work_submit', {
1374
- description: 'Submit the current feature-branch work item. Pushes and registers unpushed commits in the MCP server current Git repository first.',
1375
- inputSchema: {},
1376
- title: 'Agentia Work Submit',
1377
- }, () => safelyHandleTool(() => workSubmit()));
1378
- server.registerTool('agentia_work_done', {
1379
- description: 'Mark the current feature-branch work item done. Pushes and registers unpushed commits in the MCP server current Git repository first.',
1380
- inputSchema: {},
1381
- title: 'Agentia Work Done',
1382
- }, () => safelyHandleTool(() => workDone()));
1383
1051
  }
1384
1052
  //# sourceMappingURL=tools.js.map