@copado/agentia-cli 1.0.0-beta.4 → 1.0.0-beta.5
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.
- package/CHANGELOG.md +19 -0
- package/README.md +265 -244
- package/dist/commands/cicd/work/test/apex.js +37 -4
- package/dist/commands/cicd/work/test.js +20 -1
- package/dist/lib/cicd-gateway.js +2 -1
- package/dist/lib/local-quality-gates.js +4 -1
- package/dist/lib/mcp/work-tools.js +42 -8
- package/dist/lib/plugin-host/event-log.js +3 -0
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/setup-templates.js +2 -1
- package/dist/lib/work-apex-test-failures.js +13 -0
- package/dist/lib/work-apex-test.js +4 -1
- package/oclif.manifest.json +72 -49
- package/package.json +1 -1
- package/templates/skills/agentia-cicd/SKILL.md +1 -1
- package/templates/skills/agentia-cicd/references/work.md +2 -2
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import { AgentiaCommand } from '../../../../lib/agentia-command.js';
|
|
3
|
-
import {
|
|
3
|
+
import { planWorkApexTestRun, recordWorkApexTestOutcome, WorkApexRerunError, } from '../../../../lib/work-apex-test-failures.js';
|
|
4
|
+
import { DEFAULT_APEX_TEST_WAIT_MINUTES, formatWorkApexTestHuman, parseApexTestClassNames, runWorkApexTests, skippedWorkApexTestResult, validateApexTestWaitMinutes, WorkApexTestError, } from '../../../../lib/work-apex-test.js';
|
|
4
5
|
export default class WorkTestApex extends AgentiaCommand {
|
|
5
6
|
static description = [
|
|
6
7
|
'Run specified Apex test classes via Salesforce CLI (`sf apex run test`) with code coverage.',
|
|
7
8
|
'Usually run from project-root local quality gates (`.agentia_quality_gates.sh` / `.agentia_quality_gates.cmd`) when those scripts are configured.',
|
|
9
|
+
'When `--apex-test-classes` is omitted or empty, logs that no Apex tests were specified and exits without running Salesforce CLI.',
|
|
10
|
+
'Failed runs save `.agentia/apex.tests.<user-story>.json`; successful runs delete that file.',
|
|
11
|
+
'`--rerun-failed-apex-tests` runs the previously failed classes (optionally filtered by `--apex-test-classes`).',
|
|
8
12
|
'Prints the test-run summary when the run passes, or failing tests with their messages and stack traces when it fails.',
|
|
13
|
+
'Exits with the same process exit code as Salesforce CLI (`sf`), including 100 when Apex tests fail.',
|
|
9
14
|
].join(' ');
|
|
10
15
|
static examples = [
|
|
11
16
|
'<%= config.bin %> <%= command.id %> -t HelloWorldTest',
|
|
12
17
|
'<%= config.bin %> <%= command.id %> --apex-test-classes=MyTest,OtherTest',
|
|
13
18
|
'<%= config.bin %> <%= command.id %> -t MyTest,OtherTest -w 10 --json',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> -t "$AGENTIA_APEX_TEST_CLASSES"',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> --rerun-failed-apex-tests',
|
|
14
21
|
];
|
|
15
22
|
static flags = {
|
|
16
23
|
'apex-test-classes': Flags.string({
|
|
17
24
|
char: 't',
|
|
18
|
-
description: 'Comma-separated Apex test class names to run',
|
|
19
|
-
|
|
25
|
+
description: 'Comma-separated Apex test class names to run. Omit or leave empty to skip without running Salesforce CLI.',
|
|
26
|
+
}),
|
|
27
|
+
'rerun-failed-apex-tests': Flags.boolean({
|
|
28
|
+
default: false,
|
|
29
|
+
description: 'Rerun Apex classes saved from the last failure for this user story (`.agentia/apex.tests.<user-story>.json`). Combined with --apex-test-classes, only matching failed classes run.',
|
|
20
30
|
}),
|
|
21
31
|
wait: Flags.integer({
|
|
22
32
|
char: 'w',
|
|
@@ -36,8 +46,30 @@ export default class WorkTestApex extends AgentiaCommand {
|
|
|
36
46
|
catch (error) {
|
|
37
47
|
this.error(error.message, { exit: 2 });
|
|
38
48
|
}
|
|
49
|
+
let plan;
|
|
50
|
+
try {
|
|
51
|
+
plan = await planWorkApexTestRun({
|
|
52
|
+
requestedClassNames: classNames,
|
|
53
|
+
rerunFailed: flags['rerun-failed-apex-tests'] === true,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof WorkApexRerunError) {
|
|
58
|
+
this.error(error.message, { exit: 2 });
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
if (plan.kind === 'skip') {
|
|
63
|
+
const result = skippedWorkApexTestResult(waitMinutes);
|
|
64
|
+
this.display(() => {
|
|
65
|
+
this.log(plan.message);
|
|
66
|
+
});
|
|
67
|
+
this.logElapsed(startedAt);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
39
70
|
try {
|
|
40
|
-
const result = await this.withSpinner(`Running Apex tests (${classNames.join(', ')}), waiting up to ${waitMinutes} minute(s)`, () => runWorkApexTests({ classNames, waitMinutes }));
|
|
71
|
+
const result = await this.withSpinner(`Running Apex tests (${plan.classNames.join(', ')}), waiting up to ${waitMinutes} minute(s)`, () => runWorkApexTests({ classNames: plan.classNames, waitMinutes }));
|
|
72
|
+
await recordWorkApexTestOutcome({ failed: false, result, userStory: plan.userStory });
|
|
41
73
|
this.display(() => {
|
|
42
74
|
this.log(formatWorkApexTestHuman(result));
|
|
43
75
|
});
|
|
@@ -46,6 +78,7 @@ export default class WorkTestApex extends AgentiaCommand {
|
|
|
46
78
|
}
|
|
47
79
|
catch (error) {
|
|
48
80
|
if (error instanceof WorkApexTestError) {
|
|
81
|
+
await recordWorkApexTestOutcome({ failed: true, result: error.result, userStory: plan.userStory });
|
|
49
82
|
this.display(() => {
|
|
50
83
|
this.log(formatWorkApexTestHuman(error.result));
|
|
51
84
|
});
|
|
@@ -2,7 +2,7 @@ import { Flags } from '@oclif/core';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { AgentiaCommand } from '../../../lib/agentia-command.js';
|
|
4
4
|
import { getCurrentBranch } from '../../../lib/git-worktree.js';
|
|
5
|
-
import { LocalQualityGatesError, resolveLocalQualityGatesScript } from '../../../lib/local-quality-gates.js';
|
|
5
|
+
import { LocalQualityGatesError, parseQualityGatesEnvAssignments, resolveLocalQualityGatesScript, } from '../../../lib/local-quality-gates.js';
|
|
6
6
|
import { runWorkTestLocalQualityGates } from '../../../lib/stock-quality-gates.js';
|
|
7
7
|
import { reportLocalQualityGatesFailure, reportLocalQualityGatesOutcome, } from '../../../lib/work-local-run-tests.js';
|
|
8
8
|
import { extractUserStoryFromFeatureBranch } from '../../../lib/work-types.js';
|
|
@@ -17,6 +17,8 @@ export default class WorkTest extends AgentiaCommand {
|
|
|
17
17
|
static examples = [
|
|
18
18
|
'<%= config.bin %> <%= command.id %>',
|
|
19
19
|
'<%= config.bin %> <%= command.id %> --local --apex-test-classes=MyTest,OtherTest',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> --local --rerun-failed-apex-tests',
|
|
21
|
+
'<%= config.bin %> <%= command.id %> -e SKIP_LWC_TESTS=1 -e TOOL_API_KEY=secret',
|
|
20
22
|
'<%= config.bin %> <%= command.id %> --json',
|
|
21
23
|
'<%= config.bin %> <%= command.id %> --cloud',
|
|
22
24
|
];
|
|
@@ -28,10 +30,19 @@ export default class WorkTest extends AgentiaCommand {
|
|
|
28
30
|
default: false,
|
|
29
31
|
description: 'Run remote Copado quality gates (not implemented yet).',
|
|
30
32
|
}),
|
|
33
|
+
env: Flags.string({
|
|
34
|
+
char: 'e',
|
|
35
|
+
description: 'Extra environment variable for the quality-gate script as NAME=value. Repeatable. Applied before reserved AGENTIA_APEX_* variables.',
|
|
36
|
+
multiple: true,
|
|
37
|
+
}),
|
|
31
38
|
local: Flags.boolean({
|
|
32
39
|
default: false,
|
|
33
40
|
description: 'Run local project-root quality gates scripts. Used by default when --cloud is omitted.',
|
|
34
41
|
}),
|
|
42
|
+
'rerun-failed-apex-tests': Flags.boolean({
|
|
43
|
+
default: false,
|
|
44
|
+
description: 'Pass AGENTIA_APEX_RERUN_FAILED=--rerun-failed-apex-tests to local quality gates so sample scripts forward that flag to work test apex.',
|
|
45
|
+
}),
|
|
35
46
|
};
|
|
36
47
|
async run() {
|
|
37
48
|
const { flags } = await this.parse(WorkTest);
|
|
@@ -45,6 +56,12 @@ export default class WorkTest extends AgentiaCommand {
|
|
|
45
56
|
suggestions: [`${this.config.bin} cicd work test --local`],
|
|
46
57
|
});
|
|
47
58
|
}
|
|
59
|
+
try {
|
|
60
|
+
parseQualityGatesEnvAssignments(flags.env);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
this.error(error.message, { exit: 2 });
|
|
64
|
+
}
|
|
48
65
|
let qualityGates;
|
|
49
66
|
try {
|
|
50
67
|
const scriptPath = resolveLocalQualityGatesScript();
|
|
@@ -60,7 +77,9 @@ export default class WorkTest extends AgentiaCommand {
|
|
|
60
77
|
}
|
|
61
78
|
qualityGates = await runWorkTestLocalQualityGates({
|
|
62
79
|
apexTestClasses: flags['apex-test-classes'],
|
|
80
|
+
env: flags.env,
|
|
63
81
|
onWarning: (message) => this.warn(message),
|
|
82
|
+
rerunFailed: flags['rerun-failed-apex-tests'] === true,
|
|
64
83
|
});
|
|
65
84
|
if (qualityGates.ran && qualityGates.scriptPath !== undefined) {
|
|
66
85
|
this.display(() => {
|
package/dist/lib/cicd-gateway.js
CHANGED
|
@@ -9,6 +9,7 @@ const CicdGatewayError = modules["cicd-gateway.js"]["CicdGatewayError"]
|
|
|
9
9
|
const GATEWAY_EVENT_API_CALL = modules["cicd-gateway.js"]["GATEWAY_EVENT_API_CALL"]
|
|
10
10
|
const GATEWAY_EVENT_UNKNOWN = modules["cicd-gateway.js"]["GATEWAY_EVENT_UNKNOWN"]
|
|
11
11
|
const MCP_CICD_DEFAULT_REQUEST_TIMEOUT_MS = modules["cicd-gateway.js"]["MCP_CICD_DEFAULT_REQUEST_TIMEOUT_MS"]
|
|
12
|
+
const PLUGIN_GATEWAY_EVENT_SERVICE = modules["cicd-gateway.js"]["PLUGIN_GATEWAY_EVENT_SERVICE"]
|
|
12
13
|
const buildGatewayEventLogPayload = modules["cicd-gateway.js"]["buildGatewayEventLogPayload"]
|
|
13
14
|
const cicdApiUrl = modules["cicd-gateway.js"]["cicdApiUrl"]
|
|
14
15
|
const createTransactionId = modules["cicd-gateway.js"]["createTransactionId"]
|
|
@@ -40,4 +41,4 @@ const scheduleGatewayEventLog = modules["cicd-gateway.js"]["scheduleGatewayEvent
|
|
|
40
41
|
const setGatewayEventLogSenderForTests = modules["cicd-gateway.js"]["setGatewayEventLogSenderForTests"]
|
|
41
42
|
const setHttpRequestForTests = modules["cicd-gateway.js"]["setHttpRequestForTests"]
|
|
42
43
|
const tryResolveCicdCredentials = modules["cicd-gateway.js"]["tryResolveCicdCredentials"]
|
|
43
|
-
export {AGENTIA_CLIENT_ORIGIN_ENV, AGENTIA_IDE_VERSION_ENV, AI_GATEWAY_EVENT_SERVICE, CICD_ENV, CRT_GATEWAY_EVENT_SERVICE, CicdGateway, CicdGatewayError, GATEWAY_EVENT_API_CALL, GATEWAY_EVENT_UNKNOWN, MCP_CICD_DEFAULT_REQUEST_TIMEOUT_MS, buildGatewayEventLogPayload, cicdApiUrl, createTransactionId, discoverCicdBaseUrl, flushGatewayEventLogsForTests, formatCicdGatewayError, formatGatewayEventTimestamp, gatewayEventSource, gatewayRefererHeaders, gatewayUserAgent, getActiveHttpRequestOptionsForTests, getGatewayClientOrigin, getGatewayReferer, getGatewayTransactionId, isCicdWarningResponseBody, isCicdWarningStatus, maskUrlSecrets, maskedCicdApiUrl, normalizeCicdBaseUrl, parseRetryAfterHeader, resetGatewayEventLogSenderForTests, resetHttpRequestForTests, resolveAndValidateCicdEndpoint, resolveCicdCredentials, resolveCicdRequestTimeoutMs, resolveConfiguredCicdBaseUrl, runWithGatewayTransactionContext, scheduleGatewayEventLog, setGatewayEventLogSenderForTests, setHttpRequestForTests, tryResolveCicdCredentials};
|
|
44
|
+
export {AGENTIA_CLIENT_ORIGIN_ENV, AGENTIA_IDE_VERSION_ENV, AI_GATEWAY_EVENT_SERVICE, CICD_ENV, CRT_GATEWAY_EVENT_SERVICE, CicdGateway, CicdGatewayError, GATEWAY_EVENT_API_CALL, GATEWAY_EVENT_UNKNOWN, MCP_CICD_DEFAULT_REQUEST_TIMEOUT_MS, PLUGIN_GATEWAY_EVENT_SERVICE, buildGatewayEventLogPayload, cicdApiUrl, createTransactionId, discoverCicdBaseUrl, flushGatewayEventLogsForTests, formatCicdGatewayError, formatGatewayEventTimestamp, gatewayEventSource, gatewayRefererHeaders, gatewayUserAgent, getActiveHttpRequestOptionsForTests, getGatewayClientOrigin, getGatewayReferer, getGatewayTransactionId, isCicdWarningResponseBody, isCicdWarningStatus, maskUrlSecrets, maskedCicdApiUrl, normalizeCicdBaseUrl, parseRetryAfterHeader, resetGatewayEventLogSenderForTests, resetHttpRequestForTests, resolveAndValidateCicdEndpoint, resolveCicdCredentials, resolveCicdRequestTimeoutMs, resolveConfiguredCicdBaseUrl, runWithGatewayTransactionContext, scheduleGatewayEventLog, setGatewayEventLogSenderForTests, setHttpRequestForTests, tryResolveCicdCredentials};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {modules} from './runtime.js';
|
|
2
|
+
const AGENTIA_APEX_RERUN_FAILED_ENV = modules["local-quality-gates.js"]["AGENTIA_APEX_RERUN_FAILED_ENV"]
|
|
3
|
+
const AGENTIA_APEX_RERUN_FAILED_FLAG = modules["local-quality-gates.js"]["AGENTIA_APEX_RERUN_FAILED_FLAG"]
|
|
2
4
|
const AGENTIA_APEX_TEST_CLASSES_ENV = modules["local-quality-gates.js"]["AGENTIA_APEX_TEST_CLASSES_ENV"]
|
|
3
5
|
const LocalQualityGatesError = modules["local-quality-gates.js"]["LocalQualityGatesError"]
|
|
4
6
|
const QUALITY_GATES_SCRIPT_UNIX = modules["local-quality-gates.js"]["QUALITY_GATES_SCRIPT_UNIX"]
|
|
5
7
|
const QUALITY_GATES_SCRIPT_WINDOWS = modules["local-quality-gates.js"]["QUALITY_GATES_SCRIPT_WINDOWS"]
|
|
6
8
|
const buildQualityGatesCommand = modules["local-quality-gates.js"]["buildQualityGatesCommand"]
|
|
9
|
+
const parseQualityGatesEnvAssignments = modules["local-quality-gates.js"]["parseQualityGatesEnvAssignments"]
|
|
7
10
|
const qualityGatesScriptName = modules["local-quality-gates.js"]["qualityGatesScriptName"]
|
|
8
11
|
const resetLocalQualityGatesForTests = modules["local-quality-gates.js"]["resetLocalQualityGatesForTests"]
|
|
9
12
|
const resolveLocalQualityGatesScript = modules["local-quality-gates.js"]["resolveLocalQualityGatesScript"]
|
|
10
13
|
const runLocalQualityGates = modules["local-quality-gates.js"]["runLocalQualityGates"]
|
|
11
14
|
const setLocalQualityGatesExistsSyncForTests = modules["local-quality-gates.js"]["setLocalQualityGatesExistsSyncForTests"]
|
|
12
15
|
const setLocalQualityGatesSpawnForTests = modules["local-quality-gates.js"]["setLocalQualityGatesSpawnForTests"]
|
|
13
|
-
export {AGENTIA_APEX_TEST_CLASSES_ENV, LocalQualityGatesError, QUALITY_GATES_SCRIPT_UNIX, QUALITY_GATES_SCRIPT_WINDOWS, buildQualityGatesCommand, qualityGatesScriptName, resetLocalQualityGatesForTests, resolveLocalQualityGatesScript, runLocalQualityGates, setLocalQualityGatesExistsSyncForTests, setLocalQualityGatesSpawnForTests};
|
|
16
|
+
export {AGENTIA_APEX_RERUN_FAILED_ENV, AGENTIA_APEX_RERUN_FAILED_FLAG, AGENTIA_APEX_TEST_CLASSES_ENV, LocalQualityGatesError, QUALITY_GATES_SCRIPT_UNIX, QUALITY_GATES_SCRIPT_WINDOWS, buildQualityGatesCommand, parseQualityGatesEnvAssignments, qualityGatesScriptName, resetLocalQualityGatesForTests, resolveLocalQualityGatesScript, runLocalQualityGates, setLocalQualityGatesExistsSyncForTests, setLocalQualityGatesSpawnForTests};
|
|
@@ -6,18 +6,19 @@ import { reconcileWorkSetCredential, sanitizeWorkSetUserStory } from '../credent
|
|
|
6
6
|
import { readDefaults, resolveDefaults, writeLastWorkSelection, } from '../defaults-store.js';
|
|
7
7
|
import { checkoutFeatureBranch, fetchOriginBranch, fetchOriginBranchIfExists, listPendingChanges, } from '../git-worktree.js';
|
|
8
8
|
import { listPaginationZodFields, mcpPaginatedListPayload } from '../list-pagination.js';
|
|
9
|
-
import { LocalQualityGatesError, runLocalQualityGates } from '../local-quality-gates.js';
|
|
9
|
+
import { LocalQualityGatesError, parseQualityGatesEnvAssignments, runLocalQualityGates, } from '../local-quality-gates.js';
|
|
10
10
|
import { FULL_METADATA_SELECTION_TYPES_HELP } from '../nested-metadata-registry.js';
|
|
11
11
|
import { PROJECT_DEFAULT_KEYS } from '../project-defaults.js';
|
|
12
12
|
import { performPromotionRun, PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS, resolvePromotionIdForWorkItem, } from '../promotion-run.js';
|
|
13
13
|
import { runWorkTestLocalQualityGates } from '../stock-quality-gates.js';
|
|
14
14
|
import { getUserContext } from '../user-context.js';
|
|
15
15
|
import { resolveWorkItemId } from '../work-active.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { planWorkApexTestRun, recordWorkApexTestOutcome } from '../work-apex-test-failures.js';
|
|
17
|
+
import { DEFAULT_APEX_TEST_WAIT_MINUTES, parseApexTestClassNames, runWorkApexTests, skippedWorkApexTestResult, validateApexTestWaitMinutes, WorkApexTestError, } from '../work-apex-test.js';
|
|
18
18
|
import { buildWorkCommitRequest, normalizeWorkCommitInput, performWorkCommit, resolveWorkCommitPlatformExperience, WORK_COMMIT_ACTIONS, WORK_COMMIT_CHANGES_HELP, WORK_COMMIT_DEFAULT_TIMEOUT_SECONDS, WORK_COMMIT_METADATA_CATEGORY_HELP, } from '../work-commit.js';
|
|
19
19
|
import { buildWorkCreatePayload } from '../work-defaults.js';
|
|
20
20
|
import { validateWorkMutationPayload, WORK_LONG_TEXT_MAX_LENGTH, WORK_SHORT_TEXT_MAX_LENGTH, } from '../work-flags.js';
|
|
21
|
+
import { fetchUserStory } from '../work-get.js';
|
|
21
22
|
import { performWorkLocalCommit } from '../work-local-commit.js';
|
|
22
23
|
import { reportLocalQualityGatesFailure, reportLocalQualityGatesOutcome, } from '../work-local-run-tests.js';
|
|
23
24
|
import { capturingWorkPushHooks, performWorkPush, resolveActiveFeatureWorkItem, resolveWorkPushContext, resolveWorkPushNeed, } from '../work-push.js';
|
|
@@ -379,13 +380,16 @@ async function workTest(args = {}) {
|
|
|
379
380
|
if (args.cloud === true) {
|
|
380
381
|
throw new Error('Cloud quality gates are not implemented yet. Pass local: true or omit cloud to run project-root quality gates.');
|
|
381
382
|
}
|
|
383
|
+
parseQualityGatesEnvAssignments(args.env);
|
|
382
384
|
let qualityGates;
|
|
383
385
|
try {
|
|
384
386
|
qualityGates = await runWorkTestLocalQualityGates({
|
|
385
387
|
apexTestClasses: args.apexTestClasses,
|
|
388
|
+
env: args.env,
|
|
386
389
|
onOutput() {
|
|
387
390
|
// Capture output for the tool result/error; do not stream to the MCP stdio transport.
|
|
388
391
|
},
|
|
392
|
+
rerunFailed: args.rerunFailedApexTests === true,
|
|
389
393
|
});
|
|
390
394
|
}
|
|
391
395
|
catch (error) {
|
|
@@ -417,9 +421,26 @@ async function workTest(args = {}) {
|
|
|
417
421
|
};
|
|
418
422
|
}
|
|
419
423
|
async function workTestApex(args) {
|
|
420
|
-
const classNames = parseApexTestClassNames(
|
|
424
|
+
const classNames = parseApexTestClassNames(args.apexTestClasses);
|
|
421
425
|
const waitMinutes = validateApexTestWaitMinutes(args.wait ?? DEFAULT_APEX_TEST_WAIT_MINUTES);
|
|
422
|
-
|
|
426
|
+
const plan = await planWorkApexTestRun({
|
|
427
|
+
requestedClassNames: classNames,
|
|
428
|
+
rerunFailed: args.rerunFailedApexTests === true,
|
|
429
|
+
});
|
|
430
|
+
if (plan.kind === 'skip') {
|
|
431
|
+
return skippedWorkApexTestResult(waitMinutes);
|
|
432
|
+
}
|
|
433
|
+
try {
|
|
434
|
+
const result = await runWorkApexTests({ classNames: plan.classNames, waitMinutes });
|
|
435
|
+
await recordWorkApexTestOutcome({ failed: false, result, userStory: plan.userStory });
|
|
436
|
+
return result;
|
|
437
|
+
}
|
|
438
|
+
catch (error) {
|
|
439
|
+
if (error instanceof WorkApexTestError) {
|
|
440
|
+
await recordWorkApexTestOutcome({ failed: true, result: error.result, userStory: plan.userStory });
|
|
441
|
+
}
|
|
442
|
+
throw error;
|
|
443
|
+
}
|
|
423
444
|
}
|
|
424
445
|
function hasMcpSimpleCommitArgs(args) {
|
|
425
446
|
return (args.action !== undefined ||
|
|
@@ -790,7 +811,7 @@ export function registerAgentiaMcpWorkTools(server) {
|
|
|
790
811
|
title: 'Agentia Work Submit',
|
|
791
812
|
}, (args) => safelyHandleTool(() => workSubmit(args || {})));
|
|
792
813
|
server.registerTool('agentia_work_test', {
|
|
793
|
-
description: 'Run quality gates for the current work item. With local=true (the default when cloud is omitted), runs project-root .agentia_quality_gates.sh (macOS/Linux) or .agentia_quality_gates.cmd (Windows) when present. When no project script exists, warns and runs the stock Agentia setup sample from a temporary file. With cloud=true, runs remote Copado quality gates (not implemented yet).',
|
|
814
|
+
description: 'Run quality gates for the current work item. With local=true (the default when cloud is omitted), runs project-root .agentia_quality_gates.sh (macOS/Linux) or .agentia_quality_gates.cmd (Windows) when present. When no project script exists, warns and runs the stock Agentia setup sample from a temporary file. With cloud=true, runs remote Copado quality gates (not implemented yet). Optional env is an array of NAME=value strings injected into the quality-gate script environment (same as CLI -e/--env).',
|
|
794
815
|
inputSchema: {
|
|
795
816
|
apexTestClasses: z
|
|
796
817
|
.string()
|
|
@@ -800,19 +821,32 @@ export function registerAgentiaMcpWorkTools(server) {
|
|
|
800
821
|
.boolean()
|
|
801
822
|
.optional()
|
|
802
823
|
.describe('Run remote Copado quality gates (not implemented yet).'),
|
|
824
|
+
env: z
|
|
825
|
+
.array(z.string())
|
|
826
|
+
.optional()
|
|
827
|
+
.describe('Extra environment variables for the quality-gate script as NAME=value strings (same as CLI -e/--env). Applied before reserved AGENTIA_APEX_* variables.'),
|
|
803
828
|
local: z
|
|
804
829
|
.boolean()
|
|
805
830
|
.optional()
|
|
806
831
|
.describe('Run local project-root quality gates scripts. Used by default when cloud is omitted.'),
|
|
832
|
+
rerunFailedApexTests: z
|
|
833
|
+
.boolean()
|
|
834
|
+
.optional()
|
|
835
|
+
.describe('Pass AGENTIA_APEX_RERUN_FAILED=--rerun-failed-apex-tests to local quality gates so sample scripts forward that flag to work test apex.'),
|
|
807
836
|
},
|
|
808
837
|
title: 'Agentia Work Test',
|
|
809
838
|
}, (args) => safelyHandleTool(() => workTest(args || {})));
|
|
810
839
|
server.registerTool('agentia_work_test_apex', {
|
|
811
|
-
description: 'Run specified Apex test classes via Salesforce CLI (`sf apex run test`) with code coverage. Usually run from project-root local quality gates (`.agentia_quality_gates.sh` / `.agentia_quality_gates.cmd`) when those scripts are configured. Returns the test-run summary when the run passes. Failed runs include failing tests with Message and StackTrace.',
|
|
840
|
+
description: 'Run specified Apex test classes via Salesforce CLI (`sf apex run test`) with code coverage. Usually run from project-root local quality gates (`.agentia_quality_gates.sh` / `.agentia_quality_gates.cmd`) when those scripts are configured. When apexTestClasses is omitted or empty, skips Salesforce CLI and returns skipped=true. Failed runs save `.agentia/apex.tests.<user-story>.json`; successful runs delete that file. rerunFailedApexTests runs the previously failed classes. Returns the test-run summary when the run passes. Failed runs include failing tests with Message and StackTrace.',
|
|
812
841
|
inputSchema: {
|
|
813
842
|
apexTestClasses: z
|
|
814
843
|
.string()
|
|
815
|
-
.
|
|
844
|
+
.optional()
|
|
845
|
+
.describe('Comma-separated Apex test class names to run. Omit or leave empty to skip without running Salesforce CLI.'),
|
|
846
|
+
rerunFailedApexTests: z
|
|
847
|
+
.boolean()
|
|
848
|
+
.optional()
|
|
849
|
+
.describe('Rerun Apex classes saved from the last failure for this user story. Combined with apexTestClasses, only matching failed classes run.'),
|
|
816
850
|
wait: z
|
|
817
851
|
.number()
|
|
818
852
|
.int()
|