@copado/agentia-cli 0.16.0-alpha.0 → 0.18.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 (45) hide show
  1. package/README.md +160 -51
  2. package/dist/commands/auth/get.d.ts +2 -0
  3. package/dist/commands/auth/get.js +46 -8
  4. package/dist/commands/auth/get.js.map +1 -1
  5. package/dist/commands/work/done.d.ts +7 -0
  6. package/dist/commands/work/done.js +99 -0
  7. package/dist/commands/work/done.js.map +1 -0
  8. package/dist/commands/work/get.d.ts +1 -1
  9. package/dist/commands/work/get.js +18 -3
  10. package/dist/commands/work/get.js.map +1 -1
  11. package/dist/commands/work/push.d.ts +7 -0
  12. package/dist/commands/work/push.js +67 -0
  13. package/dist/commands/work/push.js.map +1 -0
  14. package/dist/commands/work/set.d.ts +13 -0
  15. package/dist/commands/work/set.js +103 -0
  16. package/dist/commands/work/set.js.map +1 -0
  17. package/dist/commands/work/submit.d.ts +7 -0
  18. package/dist/commands/work/submit.js +99 -0
  19. package/dist/commands/work/submit.js.map +1 -0
  20. package/dist/commands/work/update.d.ts +1 -1
  21. package/dist/commands/work/update.js +21 -6
  22. package/dist/commands/work/update.js.map +1 -1
  23. package/dist/lib/cicd-gateway.d.ts +9 -1
  24. package/dist/lib/cicd-gateway.js +91 -9
  25. package/dist/lib/cicd-gateway.js.map +1 -1
  26. package/dist/lib/defaults-store.d.ts +9 -0
  27. package/dist/lib/defaults-store.js +31 -0
  28. package/dist/lib/defaults-store.js.map +1 -1
  29. package/dist/lib/git-worktree.d.ts +22 -0
  30. package/dist/lib/git-worktree.js +75 -0
  31. package/dist/lib/git-worktree.js.map +1 -0
  32. package/dist/lib/mcp/tools.d.ts +3 -3
  33. package/dist/lib/mcp/tools.js +11 -8
  34. package/dist/lib/mcp/tools.js.map +1 -1
  35. package/dist/lib/work-active.d.ts +4 -0
  36. package/dist/lib/work-active.js +23 -0
  37. package/dist/lib/work-active.js.map +1 -0
  38. package/dist/lib/work-push.d.ts +20 -0
  39. package/dist/lib/work-push.js +92 -0
  40. package/dist/lib/work-push.js.map +1 -0
  41. package/dist/lib/work-types.d.ts +72 -0
  42. package/dist/lib/work-types.js +107 -0
  43. package/dist/lib/work-types.js.map +1 -1
  44. package/oclif.manifest.json +153 -5
  45. package/package.json +1 -1
@@ -0,0 +1,99 @@
1
+ import { AgentiaCommand } from '../../lib/agentia-command.js';
2
+ import { CicdGateway } from '../../lib/cicd-gateway.js';
3
+ import { readLastBaseBranch } from '../../lib/defaults-store.js';
4
+ import { getCurrentBranch, hasUnpushedCommits, listPendingChanges } from '../../lib/git-worktree.js';
5
+ import { performWorkPush, WorkPushValidationError } from '../../lib/work-push.js';
6
+ import { extractUserStoryFromFeatureBranch, workDoneEndpoint, } from '../../lib/work-types.js';
7
+ export default class WorkDone extends AgentiaCommand {
8
+ static description = [
9
+ 'Mark the current feature/US-XXXX work item done and promote it to the next environment.',
10
+ 'Pushes and registers commits when the branch is ahead of origin, then calls headless work/done',
11
+ '(Promote Action with validate=false).',
12
+ ].join(' ');
13
+ static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --json'];
14
+ async run() {
15
+ await this.parse(WorkDone);
16
+ const branch = await getCurrentBranch();
17
+ const workItem = extractUserStoryFromFeatureBranch(branch);
18
+ if (workItem === undefined) {
19
+ this.error(`Current branch '${branch}' is not a feature/US-XXXX branch.`, {
20
+ exit: 1,
21
+ suggestions: ['Checkout a feature/US-XXXX branch created by `agentia work set`.'],
22
+ });
23
+ }
24
+ const pendingFiles = await listPendingChanges();
25
+ if (pendingFiles.length > 0) {
26
+ this.error([
27
+ 'Uncommitted tracked changes present. Commit them, then try again:',
28
+ ...pendingFiles.map((file) => ` ${file}`),
29
+ ].join('\n'), {
30
+ exit: 2,
31
+ suggestions: ['git add -A && git commit', `${this.config.bin} work done`],
32
+ });
33
+ }
34
+ this.display(() => {
35
+ this.log(`Branch: ${branch}`);
36
+ this.log(`Work item: ${workItem}`);
37
+ });
38
+ let pushResult;
39
+ const needsPush = await hasUnpushedCommits(branch);
40
+ if (needsPush) {
41
+ const baseBranch = (await readLastBaseBranch())?.trim();
42
+ if (baseBranch === undefined || baseBranch.length === 0) {
43
+ this.error('No base branch recorded. Run `agentia work set <work-item>` first.', {
44
+ exit: 1,
45
+ });
46
+ }
47
+ this.display(() => {
48
+ this.log(`Base branch: ${baseBranch}`);
49
+ this.log('Unpushed commits detected; pushing before done.');
50
+ });
51
+ try {
52
+ pushResult = await performWorkPush({
53
+ baseBranch,
54
+ branch,
55
+ hooks: {
56
+ display: (render) => this.display(render),
57
+ log: (message) => this.log(message),
58
+ withSpinner: (message, action) => this.withSpinner(message, action),
59
+ },
60
+ workItem,
61
+ });
62
+ }
63
+ catch (error) {
64
+ if (error instanceof WorkPushValidationError) {
65
+ this.error(error.message, {
66
+ exit: error.exit,
67
+ suggestions: error.suggestions,
68
+ });
69
+ }
70
+ throw error;
71
+ }
72
+ }
73
+ else {
74
+ this.display(() => {
75
+ this.log('Branch is up to date with origin; skipping push.');
76
+ });
77
+ }
78
+ const doneBody = { workItem };
79
+ const done = await this.withSpinner('Marking work item done', () => CicdGateway.call({
80
+ body: doneBody,
81
+ endpoint: workDoneEndpoint(),
82
+ headers: {
83
+ 'Content-Type': 'application/json',
84
+ },
85
+ method: 'POST',
86
+ }));
87
+ this.display(() => {
88
+ this.log(done.message);
89
+ });
90
+ return {
91
+ branch,
92
+ done,
93
+ push: pushResult,
94
+ pushed: needsPush,
95
+ workItem,
96
+ };
97
+ }
98
+ }
99
+ //# sourceMappingURL=done.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"done.js","sourceRoot":"","sources":["../../../src/commands/work/done.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAA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AE,CAAC;gBACf,IAAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;oBAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,WAAW,EAAE,KAAK,CAAC,WAAW;qBAC/B,CAAC,CAAA;gBACJ,CAAC;gBAED,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;gBAChB,IAAI,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAA;YAC9D,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,QAAQ,GAA4B,EAAC,QAAQ,EAAC,CAAA;QACpD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,wBAAwB,EAAE,GAAG,EAAE,CACjE,WAAW,CAAC,IAAI,CAAwB;YACtC,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,gBAAgB,EAAE;YAC5B,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CACH,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;QAEF,OAAO;YACL,MAAM;YACN,IAAI;YACJ,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,SAAS;YACjB,QAAQ;SACT,CAAA;IACH,CAAC"}
@@ -2,7 +2,7 @@ import { AgentiaCommand } from '../../lib/agentia-command.js';
2
2
  import { type UserStory } from '../../lib/work-types.js';
3
3
  export default class WorkGet extends AgentiaCommand {
4
4
  static args: {
5
- id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ id: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
6
  };
7
7
  static description: string;
8
8
  static examples: string[];
@@ -1,23 +1,38 @@
1
1
  import { Args } from '@oclif/core';
2
2
  import { AgentiaCommand } from '../../lib/agentia-command.js';
3
3
  import { CicdGateway } from '../../lib/cicd-gateway.js';
4
+ import { resolveWorkItemId, WorkActiveResolutionError } from '../../lib/work-active.js';
4
5
  import { formatUserStoryDetail, workEndpoint } from '../../lib/work-types.js';
5
6
  export default class WorkGet extends AgentiaCommand {
6
7
  static args = {
7
8
  id: Args.string({
8
- description: 'User story ID',
9
- required: true,
9
+ description: 'User story ID (defaults to the active work item from `work set`)',
10
+ required: false,
10
11
  }),
11
12
  };
12
13
  static description = 'Get a Copado user story by ID';
13
14
  static examples = [
15
+ '<%= config.bin %> <%= command.id %>',
14
16
  '<%= config.bin %> <%= command.id %> a0SKC000000CmZ2AU',
15
17
  '<%= config.bin %> <%= command.id %> a0SKC000000CmZ2AU --json',
16
18
  ];
17
19
  async run() {
18
20
  const { args } = await this.parse(WorkGet);
21
+ let workItemId;
22
+ try {
23
+ workItemId = await resolveWorkItemId(args.id);
24
+ }
25
+ catch (error) {
26
+ if (error instanceof WorkActiveResolutionError) {
27
+ this.error(error.message, {
28
+ exit: 1,
29
+ suggestions: [`${this.config.bin} work set <id>`],
30
+ });
31
+ }
32
+ throw error;
33
+ }
19
34
  const userStory = await this.withSpinner('Fetching user story', () => CicdGateway.call({
20
- endpoint: workEndpoint(args.id),
35
+ endpoint: workEndpoint(workItemId),
21
36
  method: 'GET',
22
37
  }));
23
38
  this.display(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/commands/work/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,qBAAqB,EAAkB,YAAY,EAAC,MAAM,yBAAyB,CAAA;AAE3F,MAAM,CAAC,OAA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+ export default class WorkPush extends AgentiaCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ run(): Promise<WorkPushResult>;
7
+ }
@@ -0,0 +1,67 @@
1
+ import { AgentiaCommand } from '../../lib/agentia-command.js';
2
+ import { readLastBaseBranch } from '../../lib/defaults-store.js';
3
+ import { getCurrentBranch, listPendingChanges } from '../../lib/git-worktree.js';
4
+ import { performWorkPush, WorkPushValidationError } from '../../lib/work-push.js';
5
+ import { extractUserStoryFromFeatureBranch } from '../../lib/work-types.js';
6
+ export default class WorkPush extends AgentiaCommand {
7
+ static description = [
8
+ 'Push the current feature/US-XXXX branch and register commits with Copado.',
9
+ 'Requires a clean working tree and a base branch from `agentia work set`.',
10
+ 'Locks the tip commit, runs `git push origin <branch>`, then calls headless work/push.',
11
+ ].join(' ');
12
+ static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --json'];
13
+ async run() {
14
+ await this.parse(WorkPush);
15
+ const branch = await getCurrentBranch();
16
+ const workItem = extractUserStoryFromFeatureBranch(branch);
17
+ if (workItem === undefined) {
18
+ this.error(`Current branch '${branch}' is not a feature/US-XXXX branch.`, {
19
+ exit: 1,
20
+ suggestions: ['Checkout a feature/US-XXXX branch created by `agentia work set`.'],
21
+ });
22
+ }
23
+ const pendingFiles = await listPendingChanges();
24
+ if (pendingFiles.length > 0) {
25
+ this.error([
26
+ 'Uncommitted tracked changes present. Commit them, then try again:',
27
+ ...pendingFiles.map((file) => ` ${file}`),
28
+ ].join('\n'), {
29
+ exit: 2,
30
+ suggestions: ['git add -A && git commit', `${this.config.bin} work push`],
31
+ });
32
+ }
33
+ const baseBranch = (await readLastBaseBranch())?.trim();
34
+ if (baseBranch === undefined || baseBranch.length === 0) {
35
+ this.error('No base branch recorded. Run `agentia work set <work-item>` first.', {
36
+ exit: 1,
37
+ });
38
+ }
39
+ this.display(() => {
40
+ this.log(`Branch: ${branch}`);
41
+ this.log(`Work item: ${workItem}`);
42
+ this.log(`Base branch: ${baseBranch}`);
43
+ });
44
+ try {
45
+ return await performWorkPush({
46
+ baseBranch,
47
+ branch,
48
+ hooks: {
49
+ display: (render) => this.display(render),
50
+ log: (message) => this.log(message),
51
+ withSpinner: (message, action) => this.withSpinner(message, action),
52
+ },
53
+ workItem,
54
+ });
55
+ }
56
+ catch (error) {
57
+ if (error instanceof WorkPushValidationError) {
58
+ this.error(error.message, {
59
+ exit: error.exit,
60
+ suggestions: error.suggestions,
61
+ });
62
+ }
63
+ throw error;
64
+ }
65
+ }
66
+ }
67
+ //# sourceMappingURL=push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/commands/work/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,2BAA2B,CAAA;AAC9E,OAAO,EAAC,eAAe,EAAE,uBAAuB,EAAC,MAAM,wBAAwB,CAAA;AAC/E,OAAO,EAAC,iCAAiC,EAAsB,MAAM,yBAAyB,CAAA;AAE9F,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,cAAc;IAClD,MAAM,CAAU,WAAW,GAAG;QAC5B,2EAA2E;QAC3E,0EAA0E;QAC1E,uFAAuF;KACxF,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACX,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,EAAE,4CAA4C,CAAC,CAAA;IAEzG,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAE1B,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAA;QACvC,MAAM,QAAQ,GAAG,iCAAiC,CAAC,MAAM,CAAC,CAAA;QAC1D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC,KAAK,CAAC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BACzC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;oBACnC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC;iBACpE;gBACD,QAAQ;aACT,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;gBAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,WAAW,EAAE,KAAK,CAAC,WAAW;iBAC/B,CAAC,CAAA;YACJ,CAAC;YAED,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { AgentiaCommand } from '../../lib/agentia-command.js';
2
+ import { type WorkSetResult } from '../../lib/work-types.js';
3
+ export default class WorkSet extends AgentiaCommand {
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ 'base-branch': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<WorkSetResult>;
13
+ }
@@ -0,0 +1,103 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../lib/cicd-gateway.js';
4
+ import { writeLastWorkSelection } from '../../lib/defaults-store.js';
5
+ import { checkoutFeatureBranch, fetchOriginBranch, listPendingChanges } from '../../lib/git-worktree.js';
6
+ import { featureBranchName, workSetEndpoint, } from '../../lib/work-types.js';
7
+ export default class WorkSet extends AgentiaCommand {
8
+ static args = {
9
+ id: Args.string({
10
+ description: 'User story ID or name',
11
+ required: true,
12
+ }),
13
+ };
14
+ static description = [
15
+ 'Set the active work item and prepare a local feature branch.',
16
+ 'Calls the CICD gateway work/set endpoint, requires a clean tracked working tree,',
17
+ 'fetches the work item base branch from origin, then creates or checks out',
18
+ 'feature/<user-story-name>.',
19
+ ].join(' ');
20
+ static examples = [
21
+ '<%= config.bin %> <%= command.id %> a0SKC000000CmZ2AU',
22
+ '<%= config.bin %> <%= command.id %> US-0001 --json',
23
+ '<%= config.bin %> <%= command.id %> US-0001 --base-branch develop',
24
+ ];
25
+ static flags = {
26
+ 'base-branch': Flags.string({
27
+ description: 'Override the base branch returned by the work/set endpoint',
28
+ }),
29
+ };
30
+ async run() {
31
+ const { args, flags } = await this.parse(WorkSet);
32
+ const setResponse = await this.withSpinner('Setting work item', () => CicdGateway.call({
33
+ body: { workItem: args.id },
34
+ endpoint: workSetEndpoint(),
35
+ headers: {
36
+ 'Content-Type': 'application/json',
37
+ },
38
+ method: 'POST',
39
+ }));
40
+ this.display(() => {
41
+ this.log(setResponse.message);
42
+ });
43
+ const overrideBaseBranch = flags['base-branch']?.trim();
44
+ const baseBranch = (overrideBaseBranch !== undefined && overrideBaseBranch.length > 0
45
+ ? overrideBaseBranch
46
+ : setResponse.baseBranch?.trim());
47
+ if (baseBranch === undefined || baseBranch.length === 0) {
48
+ this.error('Work set response did not include a base branch.', { exit: 1 });
49
+ }
50
+ const userStoryId = setResponse.workItem.id?.trim();
51
+ if (userStoryId === undefined || userStoryId.length === 0) {
52
+ this.error('Work set response did not include a user story ID.', { exit: 1 });
53
+ }
54
+ const userStoryName = setResponse.workItem.name?.trim();
55
+ if (userStoryName === undefined || userStoryName.length === 0) {
56
+ this.error('Work set response did not include a user story name for the feature branch.', { exit: 1 });
57
+ }
58
+ const branch = featureBranchName(userStoryName);
59
+ const pendingFiles = await listPendingChanges();
60
+ if (pendingFiles.length > 0) {
61
+ this.error([
62
+ 'Pending tracked changes present. Stash or commit them, then try again:',
63
+ ...pendingFiles.map((file) => ` ${file}`),
64
+ ].join('\n'), {
65
+ exit: 2,
66
+ suggestions: [`git stash push && ${this.config.bin} work set ${args.id}`],
67
+ });
68
+ }
69
+ this.display(() => {
70
+ this.log('Working tree is clean.');
71
+ });
72
+ await this.withSpinner(`Fetching origin/${baseBranch}`, () => fetchOriginBranch(baseBranch));
73
+ this.display(() => {
74
+ this.log(`Fetched origin/${baseBranch}.`);
75
+ });
76
+ const checkout = await this.withSpinner(`Checking out ${branch}`, () => checkoutFeatureBranch(branch, baseBranch));
77
+ this.display(() => {
78
+ if (checkout.created) {
79
+ this.log(`Created and checked out ${checkout.branch} from ${baseBranch}.`);
80
+ }
81
+ else {
82
+ this.log(`Checked out existing branch ${checkout.branch}.`);
83
+ }
84
+ });
85
+ await writeLastWorkSelection({
86
+ lastBaseBranch: baseBranch,
87
+ lastWorkItem: userStoryName,
88
+ lastWorkItemId: userStoryId,
89
+ });
90
+ return {
91
+ baseBranch,
92
+ command: setResponse.command,
93
+ git: {
94
+ branch: checkout.branch,
95
+ branchCreated: checkout.created,
96
+ fetched: true,
97
+ },
98
+ message: setResponse.message,
99
+ workItem: setResponse.workItem,
100
+ };
101
+ }
102
+ }
103
+ //# sourceMappingURL=set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.js","sourceRoot":"","sources":["../../../src/commands/work/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,sBAAsB,EAAC,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAC,qBAAqB,EAAE,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,2BAA2B,CAAA;AACtG,OAAO,EACL,iBAAiB,EACjB,eAAe,GAGhB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,cAAc;IACjD,M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AAC"}
@@ -0,0 +1,7 @@
1
+ import { AgentiaCommand } from '../../lib/agentia-command.js';
2
+ import { type WorkSubmitResult } from '../../lib/work-types.js';
3
+ export default class WorkSubmit extends AgentiaCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ run(): Promise<WorkSubmitResult>;
7
+ }
@@ -0,0 +1,99 @@
1
+ import { AgentiaCommand } from '../../lib/agentia-command.js';
2
+ import { CicdGateway } from '../../lib/cicd-gateway.js';
3
+ import { readLastBaseBranch } from '../../lib/defaults-store.js';
4
+ import { getCurrentBranch, hasUnpushedCommits, listPendingChanges } from '../../lib/git-worktree.js';
5
+ import { performWorkPush, WorkPushValidationError } from '../../lib/work-push.js';
6
+ import { extractUserStoryFromFeatureBranch, workSubmitEndpoint, } from '../../lib/work-types.js';
7
+ export default class WorkSubmit extends AgentiaCommand {
8
+ static description = [
9
+ 'Submit the current feature/US-XXXX work item for pipeline quality gates and validation.',
10
+ 'Pushes and registers commits when the branch is ahead of origin, then calls headless work/submit',
11
+ '(Promote Action with validate=true).',
12
+ ].join(' ');
13
+ static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --json'];
14
+ async run() {
15
+ await this.parse(WorkSubmit);
16
+ const branch = await getCurrentBranch();
17
+ const workItem = extractUserStoryFromFeatureBranch(branch);
18
+ if (workItem === undefined) {
19
+ this.error(`Current branch '${branch}' is not a feature/US-XXXX branch.`, {
20
+ exit: 1,
21
+ suggestions: ['Checkout a feature/US-XXXX branch created by `agentia work set`.'],
22
+ });
23
+ }
24
+ const pendingFiles = await listPendingChanges();
25
+ if (pendingFiles.length > 0) {
26
+ this.error([
27
+ 'Uncommitted tracked changes present. Commit them, then try again:',
28
+ ...pendingFiles.map((file) => ` ${file}`),
29
+ ].join('\n'), {
30
+ exit: 2,
31
+ suggestions: ['git add -A && git commit', `${this.config.bin} work submit`],
32
+ });
33
+ }
34
+ this.display(() => {
35
+ this.log(`Branch: ${branch}`);
36
+ this.log(`Work item: ${workItem}`);
37
+ });
38
+ let pushResult;
39
+ const needsPush = await hasUnpushedCommits(branch);
40
+ if (needsPush) {
41
+ const baseBranch = (await readLastBaseBranch())?.trim();
42
+ if (baseBranch === undefined || baseBranch.length === 0) {
43
+ this.error('No base branch recorded. Run `agentia work set <work-item>` first.', {
44
+ exit: 1,
45
+ });
46
+ }
47
+ this.display(() => {
48
+ this.log(`Base branch: ${baseBranch}`);
49
+ this.log('Unpushed commits detected; pushing before submit.');
50
+ });
51
+ try {
52
+ pushResult = await performWorkPush({
53
+ baseBranch,
54
+ branch,
55
+ hooks: {
56
+ display: (render) => this.display(render),
57
+ log: (message) => this.log(message),
58
+ withSpinner: (message, action) => this.withSpinner(message, action),
59
+ },
60
+ workItem,
61
+ });
62
+ }
63
+ catch (error) {
64
+ if (error instanceof WorkPushValidationError) {
65
+ this.error(error.message, {
66
+ exit: error.exit,
67
+ suggestions: error.suggestions,
68
+ });
69
+ }
70
+ throw error;
71
+ }
72
+ }
73
+ else {
74
+ this.display(() => {
75
+ this.log('Branch is up to date with origin; skipping push.');
76
+ });
77
+ }
78
+ const submitBody = { workItem };
79
+ const submit = await this.withSpinner('Submitting work item', () => CicdGateway.call({
80
+ body: submitBody,
81
+ endpoint: workSubmitEndpoint(),
82
+ headers: {
83
+ 'Content-Type': 'application/json',
84
+ },
85
+ method: 'POST',
86
+ }));
87
+ this.display(() => {
88
+ this.log(submit.message);
89
+ });
90
+ return {
91
+ branch,
92
+ push: pushResult,
93
+ pushed: needsPush,
94
+ submit,
95
+ workItem,
96
+ };
97
+ }
98
+ }
99
+ //# sourceMappingURL=submit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submit.js","sourceRoot":"","sources":["../../../src/commands/work/submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B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,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;oBAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,WAAW,EAAE,KAAK,CAAC,WAAW;qBAC/B,CAAC,CAAA;gBACJ,CAAC;gBAED,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;gBAChB,IAAI,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAA;YAC9D,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,UAAU,GAA4B,EAAC,QAAQ,EAAC,CAAA;QACtD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,EAAE,GAAG,EAAE,CACjE,WAAW,CAAC,IAAI,CAAwB;YACtC,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,kBAAkB,EAAE;YAC9B,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CACH,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;QAEF,OAAO;YACL,MAAM;YACN,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,SAAS;YACjB,MAAM;YACN,QAAQ;SACT,CAAA;IACH,CAAC"}
@@ -2,7 +2,7 @@ import { AgentiaCommand } from '../../lib/agentia-command.js';
2
2
  import { type UserStory } from '../../lib/work-types.js';
3
3
  export default class WorkUpdate extends AgentiaCommand {
4
4
  static args: {
5
- id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ id: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
6
  };
7
7
  static description: string;
8
8
  static examples: string[];
@@ -1,17 +1,19 @@
1
1
  import { Args } from '@oclif/core';
2
2
  import { AgentiaCommand } from '../../lib/agentia-command.js';
3
3
  import { CicdGateway } from '../../lib/cicd-gateway.js';
4
+ import { resolveWorkItemId, WorkActiveResolutionError } from '../../lib/work-active.js';
4
5
  import { buildWorkMutationPayload, collectWorkMutationFlagKeys, validateNonEmptyStringFields, WORK_STRING_VALIDATION_KEYS, workMutationFlags, } from '../../lib/work-flags.js';
5
6
  import { workEndpoint } from '../../lib/work-types.js';
6
7
  export default class WorkUpdate extends AgentiaCommand {
7
8
  static args = {
8
9
  id: Args.string({
9
- description: 'User story ID',
10
- required: true,
10
+ description: 'User story ID (defaults to the active work item from `work set`)',
11
+ required: false,
11
12
  }),
12
13
  };
13
14
  static description = 'Update a Copado user story by ID';
14
15
  static examples = [
16
+ '<%= config.bin %> <%= command.id %> --title "Updated story"',
15
17
  '<%= config.bin %> <%= command.id %> a0SKC000000CmZ2AU --title "Updated story"',
16
18
  '<%= config.bin %> <%= command.id %> a0SKC000000CmZ2AU --status "In Progress" --json',
17
19
  ];
@@ -23,8 +25,8 @@ export default class WorkUpdate extends AgentiaCommand {
23
25
  this.error('Must provide at least one flag to update.', {
24
26
  exit: 2,
25
27
  suggestions: [
26
- `${this.config.bin} work update ${args.id} --title <title>`,
27
- `${this.config.bin} work update ${args.id} --status <status>`,
28
+ `${this.config.bin} work update --title <title>`,
29
+ `${this.config.bin} work update --status <status>`,
28
30
  ],
29
31
  });
30
32
  }
@@ -33,9 +35,22 @@ export default class WorkUpdate extends AgentiaCommand {
33
35
  if (validationError !== undefined) {
34
36
  this.error(validationError, { exit: 2 });
35
37
  }
38
+ let workItemId;
39
+ try {
40
+ workItemId = await resolveWorkItemId(args.id);
41
+ }
42
+ catch (error) {
43
+ if (error instanceof WorkActiveResolutionError) {
44
+ this.error(error.message, {
45
+ exit: 1,
46
+ suggestions: [`${this.config.bin} work set <id>`],
47
+ });
48
+ }
49
+ throw error;
50
+ }
36
51
  const userStory = await this.withSpinner('Updating user story', () => CicdGateway.call({
37
52
  body: payload,
38
- endpoint: workEndpoint(args.id),
53
+ endpoint: workEndpoint(workItemId),
39
54
  headers: {
40
55
  'Content-Type': 'application/json',
41
56
  },
@@ -43,7 +58,7 @@ export default class WorkUpdate extends AgentiaCommand {
43
58
  }));
44
59
  this.display(() => {
45
60
  const name = userStory.name ?? userStory.title ?? 'unknown name';
46
- const id = userStory.id ?? args.id;
61
+ const id = userStory.id ?? workItemId;
47
62
  this.log(`Updated user story ${name} (ID: ${id}).`);
48
63
  });
49
64
  return userStory;
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/work/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAiB,YAAY,EAAC,MAAM,yBAAyB,CAAA;AAEpE,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,cAAc;IACpD,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,kCAAkC,CAAA;IAChE,MAAM,CAAU,QAAQ,GAAG;QACzB,+EAA+E;QAC/E,qFAAqF;KACtF,CAAA;IACD,MAAM,CAAU,KAAK,GAAG,iBAAiB,CAAA;IAElC,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAE,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QAClD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AAU,CAAA;YACrC,IAAI,CAAC,GAAG,CAAC,sBAAsB,IAAI,SAAS,EAAE,IAAI,CAAC,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,OAAO,SAAS,CAAA;IAClB,CAAC"}
@@ -44,13 +44,20 @@ export type CicdEndpointOptions = {
44
44
  region?: CicdRegion;
45
45
  };
46
46
  export type HttpRequestFn = (url: URL, method: string, headers: Record<string, string>, body: unknown) => Promise<string>;
47
+ export type CicdGatewayErrorRequest = {
48
+ method?: string;
49
+ url?: string;
50
+ };
47
51
  export declare class CicdGatewayError extends Error {
48
52
  readonly categories: string[];
49
53
  readonly code?: string;
54
+ readonly requestMethod?: string;
55
+ readonly requestUrl?: string;
50
56
  readonly statusCode?: number;
51
57
  constructor(message: string, options?: {
52
58
  categories?: string[];
53
59
  code?: string;
60
+ request?: CicdGatewayErrorRequest;
54
61
  statusCode?: number;
55
62
  });
56
63
  }
@@ -58,7 +65,8 @@ export declare function gatewayUserAgent(): string;
58
65
  export declare function createTransactionId(): string;
59
66
  export declare function normalizeCicdBaseUrl(value: string): string;
60
67
  export declare function sanitizeCicdErrorMessage(message: string): string;
61
- export declare function formatCicdGatewayError(status: number, raw: string): Error;
68
+ export declare function maskUrlSecrets(url: string | URL): string;
69
+ export declare function formatCicdGatewayError(status: number, raw: string, request?: CicdGatewayErrorRequest): Error;
62
70
  export declare function cicdApiUrl(serverUrl: string, apiKey: string): URL;
63
71
  export declare function maskedCicdApiUrl(serverUrl: string): string;
64
72
  export declare function discoverCicdBaseUrl(apiKey: string): Promise<string>;