@salesforce/afv-skills 1.25.0 → 1.27.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 (32) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/skills/dx-devops-test-failures-analyze/SKILL.md +89 -0
  4. package/skills/dx-devops-test-failures-analyze/references/code-analyzer-violations.md +26 -0
  5. package/skills/dx-devops-test-failures-analyze/references/failure-categories.md +85 -0
  6. package/skills/{checking-devops-prerequisites/SKILL.md → dx-devops-test-failures-analyze/references/prerequisite-checks.md} +8 -37
  7. package/skills/{creating-fix-work-item/SKILL.md → dx-devops-test-failures-analyze/references/work-item-creation.md} +8 -12
  8. package/skills/dx-devops-test-pipeline-configure/SKILL.md +72 -0
  9. package/skills/dx-devops-test-pipeline-configure/references/configuring-quality-gate.md +133 -0
  10. package/skills/dx-devops-test-pipeline-configure/references/configuring-test-provider.md +80 -0
  11. package/skills/dx-devops-test-pipeline-configure/references/error-handling.md +39 -0
  12. package/skills/dx-devops-test-pipeline-configure/references/gotchas.md +37 -0
  13. package/skills/dx-devops-test-pipeline-configure/references/prerequisite-checks.md +112 -0
  14. package/skills/dx-devops-test-pipeline-configure/references/syncing-test-providers.md +69 -0
  15. package/skills/dx-devops-test-suite-assignments-configure/SKILL.md +74 -0
  16. package/skills/dx-devops-test-suite-assignments-configure/references/api-endpoint.md +30 -0
  17. package/skills/dx-devops-test-suite-assignments-configure/references/error-handling.md +14 -0
  18. package/skills/dx-devops-test-suite-assignments-configure/references/prerequisite-checks.md +112 -0
  19. package/skills/{recommending-devops-tests/SKILL.md → dx-devops-test-suite-assignments-configure/references/recommendation-logic.md} +10 -26
  20. package/skills/dx-devops-test-suite-assignments-configure/references/suite-assignment-modes.md +99 -0
  21. package/skills/dx-devops-test-suite-run/SKILL.md +111 -0
  22. package/skills/dx-devops-test-suite-run/references/error-handling.md +31 -0
  23. package/skills/dx-devops-test-suite-run/references/polling-configuration.md +78 -0
  24. package/skills/dx-devops-test-suite-run/references/prerequisite-checks.md +112 -0
  25. package/skills/dx-devops-test-suite-run/references/retrigger-mode.md +51 -0
  26. package/skills/analyzing-test-failures/SKILL.md +0 -159
  27. package/skills/configuring-quality-gate/SKILL.md +0 -120
  28. package/skills/configuring-test-provider/SKILL.md +0 -113
  29. package/skills/managing-suite-assignments/SKILL.md +0 -161
  30. package/skills/polling-test-results/SKILL.md +0 -72
  31. package/skills/running-devops-test-suite/SKILL.md +0 -144
  32. package/skills/syncing-test-providers/SKILL.md +0 -108
@@ -0,0 +1,39 @@
1
+ # Error Handling — All Modes
2
+
3
+ Never expose raw API error messages, stack traces, or JSON payloads to the user. Map response status codes to plain-language messages.
4
+
5
+ ## Mode A — Configure a test provider
6
+
7
+ | Status | User-facing message |
8
+ |---|---|
9
+ | 400 | "The request was invalid. Check that the provider ID and pipeline ID are correct." |
10
+ | 403 | "You don't have permission to configure test providers on this pipeline." |
11
+ | 404 | "The pipeline or test provider was not found." |
12
+ | 409 | "That provider appears to already be configured on this pipeline. To pick up new suites, re-sync it instead." |
13
+ | 500 | "A server error occurred. Try again in a few minutes." |
14
+
15
+ ## Mode B — Sync a configured provider
16
+
17
+ | Status | User-facing message |
18
+ |---|---|
19
+ | 400 | "The sync request was invalid. Check that the provider ID and pipeline ID are correct." |
20
+ | 403 | "You don't have permission to sync test providers on this pipeline." |
21
+ | 404 | "The pipeline or test provider was not found." |
22
+ | 500 | "A server error occurred. Try again in a few minutes." |
23
+
24
+ ## Mode C — Configure a quality gate
25
+
26
+ | Status | User-facing message |
27
+ |---|---|
28
+ | 400 | "The quality gate configuration is invalid. Check that all rule types and thresholds are correct." |
29
+ | 403 | "You don't have permission to configure quality gates on this org." |
30
+ | 500 | "A server error occurred. Try again in a few minutes." |
31
+
32
+ ## Prerequisite / environment errors
33
+
34
+ | Error condition | Response |
35
+ |---|---|
36
+ | `sf org list` fails entirely | "Could not reach the Salesforce CLI. Make sure `sf` is installed and on your PATH." |
37
+ | `sf org display` returns auth error | Surface plain-language re-auth instructions. Do not expose the raw error. |
38
+ | `DevopsPipeline` query fails with 5xx | "The DevOps Center org is returning a server error. Try again in a few minutes." |
39
+ | Any check throws unexpectedly | "Something went wrong checking prerequisites. Error: [plain summary]. Let's try again — or resolve it manually and let me know when ready." |
@@ -0,0 +1,37 @@
1
+ # Critical Gotchas
2
+
3
+ ## Duplicate provider configuration (the big one)
4
+
5
+ `POST /connect/devops/pipeline/<pipelineId>/testProvider` **creates a new provider configuration record** (`DevopsPipelineTestProvider`). Use it ONLY to configure a provider for the **first time** (Mode A).
6
+
7
+ To re-sync an already-configured provider for new suites, use `POST /connect/devops/sync` (Mode B). Calling the configure endpoint on an already-configured provider produces **duplicate** `DevopsPipelineTestProvider` records.
8
+
9
+ **Decision tree:**
10
+
11
+ - Provider is **Available** → configure via `POST .../pipeline/<id>/testProvider` (Mode A).
12
+ - Provider is **Configured**, new suites missing → sync via `POST /connect/devops/sync` (Mode B).
13
+ - Provider is **Configured**, suites missing only when assigning to a stage → stage-assignment gap; redirect to `dx-devops-test-suite-assignments-configure`.
14
+
15
+ ## API name differences
16
+
17
+ | Issue | Resolution |
18
+ |---|---|
19
+ | `DevopsPipeline` query returns empty | DevOps Center not installed on the target org, or wrong org alias — ask the user to verify |
20
+ | `DevopsWorkItem` sObject not supported | Use `WorkItem` (no namespace) — the correct API name for this org version |
21
+ | `sf plugins` doesn't match `agentforce` | The installed plugin is `@salesforce/plugin-agent` — match on `plugin-agent` too |
22
+
23
+ ## Trigger-type rules
24
+
25
+ | Issue | Resolution |
26
+ |---|---|
27
+ | Review trigger is pipeline-level, not stage-level | Query `DevopsPipelineStageTrigger` where `TriggerType = 'Review'` and `RelatedRecordId = <pipelineId>` |
28
+ | Connect API `testSuites` returns empty with `?stageId=` | Use `?triggerId=<reviewTriggerId>` — `stageId` only works for stage-level triggers |
29
+
30
+ ## Endpoint families
31
+
32
+ - **Configure provider:** `POST /connect/devops/pipeline/<pipelineId>/testProvider`
33
+ - **Sync provider:** `POST /connect/devops/sync`
34
+ - **List providers:** `GET /connect/devopstesting/pipeline/<pipelineId>/testProviders?status=all`
35
+ - **Quality gate:** `POST /connect/devopstesting/qualityGate`
36
+
37
+ Note the `devops` vs `devopstesting` path segment differs between sync/configure and the listing/quality-gate endpoints — copy them exactly.
@@ -0,0 +1,112 @@
1
+ # Prerequisite Checks — Shared DevOps Center Gate
2
+
3
+ Shared environment gate for every DevOps Center testing skill. Run these checks **before** any query or system call. On any failure, surface the plain-language message and stop until the user resolves it — never proceed to a write with an unverified environment.
4
+
5
+ > **API version:** All DevOps testing system calls target Salesforce API **v67.0** (minimum required).
6
+
7
+ **Important:** All DevOps Center data (pipelines, stages, test suites, executions) lives in the Salesforce org — NOT in the local repository. Never search the filesystem for pipeline configuration. Always query the org using `sf data query` or `sf api request rest`.
8
+
9
+ **Object model — use the STANDARD objects, never the `sf_devops__` managed package:** DevOps Center testing data lives in standard platform objects — `DevopsPipeline`, `DevopsPipelineStage`, `DevopsPipelineStageTrigger`, `DevopsTestSuite`, `DevopsTestSuiteStage`, `DevopsTestSuiteExecution`, `DevopsProject`, `WorkItem`. Do **NOT** query the legacy managed-package objects (`sf_devops__Pipeline__c`, `sf_devops__Pipeline_Stage__c`, etc.) and do **NOT** gate on a `PackageLicense` / namespace check for `sf_devops`. "DevOps Center installed" is determined **solely** by whether `DevopsPipeline` is queryable and returns records (Prerequisite 4) — never by the presence of the `sf_devops__` namespace. If a `sf_devops__*` object is missing, that is expected and is NOT evidence that DevOps Center is uninstalled.
10
+
11
+ ## How skills use this
12
+
13
+ Run Prerequisites 1–4 in order. Prerequisite 5 (stage) is run **only** when the operation targets a specific pipeline stage (configuring a gate, running/retriggering a suite, mapping a suite). Carry forward the resolved `doce-org-alias`, `pipelineId`, and (when applicable) `stageId`.
14
+
15
+ Resolve the **DevOps Center org alias** without asking the user unless genuinely ambiguous:
16
+ 1. If the user named an org alias in their message, use it.
17
+ 2. Otherwise, use the default org (`sf org display --json`, no `--target-org`).
18
+ 3. Only if the default org has no `DevopsPipeline` records (Prereq 4 fails), ask: "Which org alias is your DevOps Center org?"
19
+
20
+ ---
21
+
22
+ ## Prerequisite 1 — Salesforce org: active login
23
+
24
+ ```bash
25
+ sf org list --json
26
+ ```
27
+
28
+ Look for at least one entry in `result.nonScratchOrgs`, `result.scratchOrgs`, or `result.sandboxes` with `"connectedStatus": "Connected"`.
29
+
30
+ - **Pass:** at least one org is Connected
31
+ - **Fail:** no orgs listed, or all show a non-connected status
32
+
33
+ **On fail:** "No authenticated Salesforce org found. Run `sf org login web --alias <your-alias>` in your terminal, then come back."
34
+
35
+ ---
36
+
37
+ ## Prerequisite 2 — Agentforce DX plugin installed
38
+
39
+ ```bash
40
+ sf plugins --json
41
+ ```
42
+
43
+ Look for a plugin entry whose `name` contains `plugin-agent`, `agentforce`, or `einstein` (case-insensitive).
44
+
45
+ - **Pass:** plugin found
46
+ - **Fail:** no matching entry
47
+
48
+ **On fail:** "The Agentforce DX Plugin is not installed. Run `sf plugins install @salesforce/plugin-agent`, then restart the IDE and try again."
49
+
50
+ ---
51
+
52
+ ## Prerequisite 3 — DevOps Center org authenticated
53
+
54
+ ```bash
55
+ sf org display --target-org <doce-org-alias> --json
56
+ ```
57
+
58
+ Check that `"connectedStatus"` is `"Connected"`.
59
+
60
+ - **Pass:** Connected
61
+ - **Fail:** expired session or error
62
+
63
+ **On fail:** "Your DevOps Center org session has expired. Run `sf org login web --alias <doce-org-alias>` to re-authenticate."
64
+
65
+ ---
66
+
67
+ ## Prerequisite 4 — Pipeline identified
68
+
69
+ ```bash
70
+ sf data query \
71
+ --query "SELECT Id, Name, CreatedDate FROM DevopsPipeline ORDER BY Name ASC" \
72
+ --target-org <doce-org-alias> \
73
+ --json
74
+ ```
75
+
76
+ - **Pass (exactly one):** use it automatically — do NOT ask.
77
+ - **Pass (multiple):** if the user already named a pipeline, match by name. Otherwise display a numbered list and ask:
78
+ ```text
79
+ Found <N> pipelines:
80
+ 1. <Name>
81
+ 2. <Name>
82
+ Which pipeline would you like to work with?
83
+ ```
84
+ - **Fail (no records):** "No DevOps Center pipeline found. Create a project and pipeline in DevOps Center before using the DevOps Testing Skills."
85
+ - **Fail (unsupported object):** "DevOps Center does not appear to be installed on `<doce-org-alias>`. Check that you're pointing at the correct org."
86
+
87
+ ---
88
+
89
+ ## Prerequisite 5 — Pipeline stage identified (conditional)
90
+
91
+ Run **only** when the operation targets a specific stage (e.g. configuring a quality gate).
92
+
93
+ If the user's message already names a stage (e.g. "Integration", "Staging", "Production"), use that name directly — do NOT ask again. Look up its Id:
94
+
95
+ ```bash
96
+ sf data query \
97
+ --query "SELECT Id, Name FROM DevopsPipelineStage WHERE DevopsPipelineId = '<pipelineId>' AND Name = '<stageName>'" \
98
+ --target-org <doce-org-alias> --json
99
+ ```
100
+
101
+ Only if no stage is mentioned, fetch the full list and ask which one:
102
+
103
+ ```bash
104
+ sf data query \
105
+ --query "SELECT Id, Name FROM DevopsPipelineStage WHERE DevopsPipelineId = '<pipelineId>' ORDER BY Name ASC" \
106
+ --target-org <doce-org-alias> --json
107
+ ```
108
+
109
+ Then ask: "Which pipeline stage are we working with?" — do NOT ask for an org alias; stages are resolved by name from the pipeline.
110
+
111
+ - **Pass:** stage Id and Name confirmed
112
+ - **Deferred:** not required until the operation needs it
@@ -0,0 +1,69 @@
1
+ # Mode B — Sync a Configured Provider
2
+
3
+ Re-syncs an already-*Configured* test provider on a DevOps Center pipeline so that suites added to the provider since it was last configured become available for assignment to stages.
4
+
5
+ **Confirmation required:** Yes — explicit confirmation before the sync is triggered.
6
+
7
+ ## Inputs
8
+
9
+ | Variable | Source |
10
+ |---|---|
11
+ | `doce-org-alias` | Prerequisite 1 |
12
+ | `pipelineId` | Prerequisite 4 (pipeline selection) |
13
+ | `testProviderId` | Resolved by fetching the pipeline's test providers (Step 1 below) |
14
+
15
+ Prerequisite 5 (stage) is **not** required — providers are synced at the pipeline level.
16
+
17
+ ---
18
+
19
+ ## Step 1 — Fetch test providers to resolve the provider ID
20
+
21
+ ```bash
22
+ sf api request rest \
23
+ "/services/data/v67.0/connect/devopstesting/pipeline/<pipelineId>/testProviders?status=all" \
24
+ --target-org <doce-org-alias>
25
+ ```
26
+
27
+ Each provider entry includes `testProviderId`, `testProviderName`, and a status (Configured vs. Available). Present a short summary grouped by status (same format as Mode A).
28
+
29
+ - **Only a Configured provider can be synced.** If the user names an *Available* (not-yet-configured) provider, explain it must be configured first — use **Mode A** (`references/configuring-test-provider.md`).
30
+ - If the pipeline has no configured providers, report that and stop — do NOT fabricate a provider or ID.
31
+
32
+ ## Step 2 — Confirmation gate
33
+
34
+ **Required — do not call the API before the user confirms.**
35
+
36
+ > "I'll re-sync `<testProviderName>` on the `<pipelineName>` pipeline to pick up any new suites. Confirm?"
37
+
38
+ Do not proceed until the user gives an affirmative response.
39
+
40
+ ## Step 3 — Trigger the sync
41
+
42
+ On confirmation, call the sync endpoint with the provider ID(s) and pipeline ID:
43
+
44
+ ```bash
45
+ sf api request rest \
46
+ "/services/data/v67.0/connect/devops/sync" \
47
+ --method POST \
48
+ --body '{
49
+ "testProviderIds": ["<testProviderId>"],
50
+ "pipelineId": "<pipelineId>"
51
+ }' \
52
+ --target-org <doce-org-alias>
53
+ ```
54
+
55
+ `testProviderIds` is a list — multiple configured providers can be synced in one call.
56
+
57
+ ## On success
58
+
59
+ > "Provider `<testProviderName>` sync started. The operation is running asynchronously — new suites will be available shortly."
60
+
61
+ The sync runs asynchronously; newly synced suites can then be assigned to stages with `dx-devops-test-suite-assignments-configure`.
62
+
63
+ ---
64
+
65
+ ## Critical gotcha
66
+
67
+ **Do NOT use** `POST /connect/devops/pipeline/<pipelineId>/testProvider` to sync — that endpoint **creates a new provider configuration** and will result in duplicate `DevopsPipelineTestProvider` records. Sync only via `POST /connect/devops/sync`. See `references/gotchas.md`.
68
+
69
+ See `references/error-handling.md` for status-code responses.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: dx-devops-test-suite-assignments-configure
3
+ description: "Recommends and manages DevOps Center test suite assignments for pipeline stages. Mode A analyzes a commit diff against assigned suite metadata to recommend relevant existing suites and flag coverage gaps (pure reasoning). Modes B-D assign a single suite, bulk-map multiple suites with a mandatory impact preview, or add/remove test classes with governance rules, via the testSuiteStages Connect API. Use this skill to recommend suites for a commit, assign or map suites to stages, or add/remove tests in a suite. TRIGGER when: the user asks which suites to run for a commit/diff or what covers their changes; a suite is unlinked and the user wants it assigned; the user wants to configure suite-to-stage mappings, assign multiple suites, or add/remove/sync tests in a suite. DO NOT TRIGGER when: configuring or syncing a test provider (use dx-devops-test-pipeline-configure), running suites (use dx-devops-test-suite-run), or authoring/running tests directly (use platform-apex-test-generate or platform-apex-test-run)."
4
+ metadata:
5
+ version: "1.0"
6
+ minApiVersion: "67.0"
7
+ ---
8
+
9
+ # Configure DevOps Center Suite Assignments
10
+
11
+ Recommends which existing test suites to run for a change, and manages how suites are assigned and mapped to pipeline stages. These operations share the same suite-stage metadata: a recommendation surfaces relevant suites and flags gaps, and those gaps lead directly into assignment.
12
+
13
+ > **API version:** All DevOps testing system calls target Salesforce API **v67.0** (minimum required).
14
+
15
+ **Important:** All DevOps Center data lives in the Salesforce org — NOT the local repo. Never search the filesystem for suite configuration. Always query the org with `sf data query` or `sf api request rest`.
16
+
17
+ ---
18
+
19
+ ## Step 1 — Run prerequisites first (always)
20
+
21
+ Run the prerequisite checks in `references/prerequisite-checks.md` before any query or system call. On any failure, surface the plain-language message and stop.
22
+
23
+ - **Mode A (recommend):** Prerequisites 1–4 (org login, plugin, DevOps Center org auth, pipeline identified). No stage required — recommendation reads the pipeline-level Review trigger.
24
+ - **Modes B–D (assign/map/classes):** Prerequisites 1–4 **and** Prerequisite 5 (stage). You need `doce-org-alias`, `pipelineId`, and `stageId`.
25
+
26
+ ---
27
+
28
+ ## Step 2 — Select the mode
29
+
30
+ | If the user wants to… | Mode | Follow |
31
+ |---|---|---|
32
+ | Know **which suites to run** for a commit/diff, or what covers their changes | **A — Recommend suites** | `references/recommendation-logic.md` |
33
+ | Assign **one** suite to a stage as a one-off | **B — Assign a single suite** | `references/suite-assignment-modes.md` |
34
+ | **Bulk-map** multiple suites to a stage as a testing strategy | **C — Map multiple suites** | `references/suite-assignment-modes.md` |
35
+ | **Add/remove** individual test classes within a suite assignment | **D — Add/remove classes** | `references/suite-assignment-modes.md` |
36
+
37
+ Mode A is pure reasoning (no writes). Modes B–D mutate org state via the same `testSuiteStages` endpoint (`references/api-endpoint.md`).
38
+
39
+ **How A feeds B–D:** When recommendation flags a relevant suite that is *not assigned* to the stage, that gap is the input to Mode B/C. When it flags a *new method with no suite coverage*, direct the developer to author tests manually (v1 constraint — never suggest generating tests here).
40
+
41
+ ---
42
+
43
+ ## Step 3 — Governance & confirmation (Modes B–D)
44
+
45
+ Modes B–D **must** confirm before any write:
46
+
47
+ - **Mode B** — single confirmation prompt naming the suite, stage, and event.
48
+ - **Mode C** — a **mandatory impact-preview table** (Suite / Stage / Event / Action) before the confirmation gate.
49
+ - **Mode D** — re-present the final test list before confirming. **Rejected tests must be EXCLUDED from the payload.** If tests were modified during review, re-present the final list before requesting confirmation. Never call without explicit approval.
50
+
51
+ Do not call the API until the user gives an affirmative response. If the user declines, stop without writing. Full wording for each gate is in `references/suite-assignment-modes.md`.
52
+
53
+ Mode A (recommendation) makes no writes and needs no confirmation gate.
54
+
55
+ ---
56
+
57
+ ## Step 4 — Execute and report
58
+
59
+ Follow the chosen reference file:
60
+
61
+ - `references/recommendation-logic.md` — Mode A: diff classification, provider matching, ranking, gap flagging, output format.
62
+ - `references/suite-assignment-modes.md` — Modes B–D: inputs, confirmation wording, success messages.
63
+ - `references/api-endpoint.md` — the shared `testSuiteStages` POST payload schema (Modes B–D).
64
+ - `references/error-handling.md` — status-code → plain-language tables.
65
+
66
+ Never expose raw API errors, stack traces, or JSON to the user.
67
+
68
+ ---
69
+
70
+ ## Related skills
71
+
72
+ - **`dx-devops-test-pipeline-configure`** — if the suite you want to assign doesn't appear yet, configure or re-sync the provider; also configures quality gates on a stage after mapping.
73
+ - **`dx-devops-test-suite-run`** — execute a recommended/assigned suite on a stage.
74
+ - **`dx-devops-test-failures-analyze`** — analyze failures and improvement suggestions for the tests within a suite.
@@ -0,0 +1,30 @@
1
+ # API Endpoint — testSuiteStages (Modes B–D)
2
+
3
+ All three assignment modes (B, C, D) use the same Connect API endpoint. Substitute all `<placeholder>` values before executing.
4
+
5
+ ```bash
6
+ sf api request rest "/services/data/v67.0/connect/devopstesting/pipeline/<pipelineId>/testSuiteStages" --method POST --body '{"pipelineStageId":"<stageId>","event":"<event>","assignments":[{"testSuiteId":"<id>","action":"add|remove"}]}' --target-org <doce-org-alias>
7
+ ```
8
+
9
+ ## Full payload schema
10
+
11
+ ```json
12
+ {
13
+ "pipelineStageId": "<stageId>",
14
+ "event": "<event>",
15
+ "assignments": [
16
+ {"testSuiteId": "<suiteId1>", "action": "add"},
17
+ {"testSuiteId": "<suiteId2>", "action": "remove"}
18
+ ]
19
+ }
20
+ ```
21
+
22
+ | Field | Type | Description |
23
+ |---|---|---|
24
+ | `pipelineStageId` | string | The pipeline stage ID (from Prerequisite 5) |
25
+ | `event` | string | `Pre-Promote`, `Post-Promote`, or `Review` |
26
+ | `assignments` | array | One or more `{testSuiteId, action}` entries — `action` is `add` or `remove` |
27
+
28
+ - **Mode B** sends a single `add` assignment.
29
+ - **Mode C** sends multiple `add`/`remove` entries in one call (bulk mapping).
30
+ - **Mode D** sends `add`/`remove` entries for the classes/suites being synced — rejected tests excluded.
@@ -0,0 +1,14 @@
1
+ # Error Handling — Suite Assignments (Modes B–D)
2
+
3
+ Never expose raw API error messages, stack traces, or JSON payloads to the user. Map response status codes to plain-language messages.
4
+
5
+ | Status | User-facing message |
6
+ |---|---|
7
+ | 400 | "The request was invalid. Check that all suite and stage IDs are correct and the event type is valid." |
8
+ | 403 | "You don't have permission to modify suite assignments on this pipeline." |
9
+ | 404 | "The pipeline or stage was not found." |
10
+ | 500 | "A server error occurred. Try again in a few minutes." |
11
+
12
+ ## Mode A (recommendation) errors
13
+
14
+ Mode A makes only read queries. If a `sf data query` fails, report the problem in plain language and stop — do NOT fabricate suite names, recommendations, or coverage data. If no suites are assigned to the Review trigger, state that explicitly ("No test suites are currently assigned to the Review trigger for this pipeline").
@@ -0,0 +1,112 @@
1
+ # Prerequisite Checks — Shared DevOps Center Gate
2
+
3
+ Shared environment gate for every DevOps Center testing skill. Run these checks **before** any query or system call. On any failure, surface the plain-language message and stop until the user resolves it — never proceed to a write with an unverified environment.
4
+
5
+ > **API version:** All DevOps testing system calls target Salesforce API **v67.0** (minimum required).
6
+
7
+ **Important:** All DevOps Center data (pipelines, stages, test suites, executions) lives in the Salesforce org — NOT in the local repository. Never search the filesystem for pipeline configuration. Always query the org using `sf data query` or `sf api request rest`.
8
+
9
+ **Object model — use the STANDARD objects, never the `sf_devops__` managed package:** DevOps Center testing data lives in standard platform objects — `DevopsPipeline`, `DevopsPipelineStage`, `DevopsPipelineStageTrigger`, `DevopsTestSuite`, `DevopsTestSuiteStage`, `DevopsTestSuiteExecution`, `DevopsProject`, `WorkItem`. Do **NOT** query the legacy managed-package objects (`sf_devops__Pipeline__c`, `sf_devops__Pipeline_Stage__c`, etc.) and do **NOT** gate on a `PackageLicense` / namespace check for `sf_devops`. "DevOps Center installed" is determined **solely** by whether `DevopsPipeline` is queryable and returns records (Prerequisite 4) — never by the presence of the `sf_devops__` namespace. If a `sf_devops__*` object is missing, that is expected and is NOT evidence that DevOps Center is uninstalled.
10
+
11
+ ## How skills use this
12
+
13
+ Run Prerequisites 1–4 in order. Prerequisite 5 (stage) is run **only** when the operation targets a specific pipeline stage (configuring a gate, running/retriggering a suite, mapping a suite). Carry forward the resolved `doce-org-alias`, `pipelineId`, and (when applicable) `stageId`.
14
+
15
+ Resolve the **DevOps Center org alias** without asking the user unless genuinely ambiguous:
16
+ 1. If the user named an org alias in their message, use it.
17
+ 2. Otherwise, use the default org (`sf org display --json`, no `--target-org`).
18
+ 3. Only if the default org has no `DevopsPipeline` records (Prereq 4 fails), ask: "Which org alias is your DevOps Center org?"
19
+
20
+ ---
21
+
22
+ ## Prerequisite 1 — Salesforce org: active login
23
+
24
+ ```bash
25
+ sf org list --json
26
+ ```
27
+
28
+ Look for at least one entry in `result.nonScratchOrgs`, `result.scratchOrgs`, or `result.sandboxes` with `"connectedStatus": "Connected"`.
29
+
30
+ - **Pass:** at least one org is Connected
31
+ - **Fail:** no orgs listed, or all show a non-connected status
32
+
33
+ **On fail:** "No authenticated Salesforce org found. Run `sf org login web --alias <your-alias>` in your terminal, then come back."
34
+
35
+ ---
36
+
37
+ ## Prerequisite 2 — Agentforce DX plugin installed
38
+
39
+ ```bash
40
+ sf plugins --json
41
+ ```
42
+
43
+ Look for a plugin entry whose `name` contains `plugin-agent`, `agentforce`, or `einstein` (case-insensitive).
44
+
45
+ - **Pass:** plugin found
46
+ - **Fail:** no matching entry
47
+
48
+ **On fail:** "The Agentforce DX Plugin is not installed. Run `sf plugins install @salesforce/plugin-agent`, then restart the IDE and try again."
49
+
50
+ ---
51
+
52
+ ## Prerequisite 3 — DevOps Center org authenticated
53
+
54
+ ```bash
55
+ sf org display --target-org <doce-org-alias> --json
56
+ ```
57
+
58
+ Check that `"connectedStatus"` is `"Connected"`.
59
+
60
+ - **Pass:** Connected
61
+ - **Fail:** expired session or error
62
+
63
+ **On fail:** "Your DevOps Center org session has expired. Run `sf org login web --alias <doce-org-alias>` to re-authenticate."
64
+
65
+ ---
66
+
67
+ ## Prerequisite 4 — Pipeline identified
68
+
69
+ ```bash
70
+ sf data query \
71
+ --query "SELECT Id, Name, CreatedDate FROM DevopsPipeline ORDER BY Name ASC" \
72
+ --target-org <doce-org-alias> \
73
+ --json
74
+ ```
75
+
76
+ - **Pass (exactly one):** use it automatically — do NOT ask.
77
+ - **Pass (multiple):** if the user already named a pipeline, match by name. Otherwise display a numbered list and ask:
78
+ ```text
79
+ Found <N> pipelines:
80
+ 1. <Name>
81
+ 2. <Name>
82
+ Which pipeline would you like to work with?
83
+ ```
84
+ - **Fail (no records):** "No DevOps Center pipeline found. Create a project and pipeline in DevOps Center before using the DevOps Testing Skills."
85
+ - **Fail (unsupported object):** "DevOps Center does not appear to be installed on `<doce-org-alias>`. Check that you're pointing at the correct org."
86
+
87
+ ---
88
+
89
+ ## Prerequisite 5 — Pipeline stage identified (conditional)
90
+
91
+ Run **only** when the operation targets a specific stage (e.g. configuring a quality gate).
92
+
93
+ If the user's message already names a stage (e.g. "Integration", "Staging", "Production"), use that name directly — do NOT ask again. Look up its Id:
94
+
95
+ ```bash
96
+ sf data query \
97
+ --query "SELECT Id, Name FROM DevopsPipelineStage WHERE DevopsPipelineId = '<pipelineId>' AND Name = '<stageName>'" \
98
+ --target-org <doce-org-alias> --json
99
+ ```
100
+
101
+ Only if no stage is mentioned, fetch the full list and ask which one:
102
+
103
+ ```bash
104
+ sf data query \
105
+ --query "SELECT Id, Name FROM DevopsPipelineStage WHERE DevopsPipelineId = '<pipelineId>' ORDER BY Name ASC" \
106
+ --target-org <doce-org-alias> --json
107
+ ```
108
+
109
+ Then ask: "Which pipeline stage are we working with?" — do NOT ask for an org alias; stages are resolved by name from the pipeline.
110
+
111
+ - **Pass:** stage Id and Name confirmed
112
+ - **Deferred:** not required until the operation needs it
@@ -1,28 +1,18 @@
1
- ---
2
- name: recommending-devops-tests
3
- description: "Analyzes a commit diff and available DevOps Center test suite metadata to recommend the most relevant existing test suites, then flags coverage gaps where no suite covers a new method — via pure reasoning, no system calls beyond the prerequisite queries. Use this skill when a developer wants to know which test suites to run for a specific commit or diff, what tests cover their changes, or wants suite recommendations at commit time. TRIGGER when: the user asks which test suites to run for a commit/diff, asks what tests cover their changes, or asks for suite recommendations before promoting. DO NOT TRIGGER when: authoring new tests (use platform-apex-test-generate) or running sf apex run test directly (use platform-apex-test-run)."
4
- metadata:
5
- version: "1.0"
6
- minApiVersion: "67.0"
7
- ---
8
-
9
- # Recommending DevOps Tests
1
+ # Mode A — Recommend Suites for a Commit/Diff
10
2
 
11
- **Type:** Pure reasoning — no system calls beyond the prerequisite data-fetch queries documented below.
3
+ **Type:** Pure reasoning — no system calls beyond the prerequisite data-fetch queries documented below. No writes.
12
4
 
13
5
  **What it does:** Analyzes the commit diff and available suite metadata to recommend the most relevant existing test suites assigned to the Review pipeline stage. Flags coverage gaps where no suite covers a new method.
14
6
 
15
- ---
16
-
17
7
  ## Prerequisites
18
8
 
19
- Load and follow the `checking-devops-prerequisites` skill first (Prerequisites 1–4). This skill needs a confirmed DevOps Center org alias and pipeline Id before it can proceed.
9
+ Run Prerequisites 1–4 (`references/prerequisite-checks.md`). A confirmed DevOps Center org alias and `pipelineId` are required before proceeding. No stage prompt — recommendation reads the pipeline-level Review trigger.
20
10
 
21
11
  ---
22
12
 
23
13
  ## Step 1 — Fetch suite metadata
24
14
 
25
- Before reasoning can begin, fetch the test suite metadata assigned to the Review pipeline stage. This requires two queries.
15
+ Two queries are required before reasoning.
26
16
 
27
17
  **1a — Find the Review pipeline stage trigger:**
28
18
 
@@ -48,9 +38,7 @@ Each row provides: `TestSuiteId`, `TestSuite.Name`, `IsQualityGateEnabled`, and
48
38
 
49
39
  > Note: Do NOT use the beta `/connect/devops/.../testSuites` endpoint — it returns empty results. Query `DevopsTestSuiteStage` directly as shown above.
50
40
 
51
- Never expose raw API errors or raw JSON to the user. If a query fails, report the problem in plain language and stop.
52
-
53
- The commit diff comes from the user or surrounding context.
41
+ Never expose raw API errors or raw JSON to the user. If a query fails, report the problem in plain language and stop. The commit diff comes from the user or surrounding context.
54
42
 
55
43
  ---
56
44
 
@@ -58,8 +46,6 @@ The commit diff comes from the user or surrounding context.
58
46
 
59
47
  ### 1 — Classify the diff by change type
60
48
 
61
- Parse the diff file extensions and paths to determine what types of changes were made:
62
-
63
49
  | File pattern | Change type |
64
50
  |---|---|
65
51
  | `*.cls`, `*.trigger` | Apex |
@@ -71,7 +57,7 @@ A single commit may contain multiple change types. Identify all of them.
71
57
 
72
58
  ### 2 — Map change types to test providers
73
59
 
74
- For each change type identified, match against the `testProviderName` of the fetched suites:
60
+ For each change type, match against the `testProviderName` of the fetched suites:
75
61
 
76
62
  | Change type | Match suites whose `testProviderName` contains |
77
63
  |---|---|
@@ -81,7 +67,7 @@ For each change type identified, match against the `testProviderName` of the fet
81
67
  | LWC / JavaScript | `LWC` or `JavaScript` |
82
68
  | Code Analyzer (any) | `Code Analyzer` — then sub-filter by suite name convention: `recommended` → Apex/general rules (suggest for Apex and Java changes), `html` → suggest for HTML/LWC template changes, `css` → suggest for CSS changes. If no suite name matches the convention, suggest all Code Analyzer suites and note the ambiguity. |
83
69
 
84
- Only recommend suites whose provider matches at least one change type in the diff. Suites from non-matching providers are excluded from the recommendation.
70
+ Only recommend suites whose provider matches at least one change type in the diff. Suites from non-matching providers are excluded.
85
71
 
86
72
  ### 3 — Rank matched suites
87
73
 
@@ -129,9 +115,7 @@ Coverage gaps (new methods — manual authoring required):
129
115
 
130
116
  Only recommend existing suites. Never suggest generating new tests. If gaps exist, direct the developer to author tests manually and explain exactly which methods need coverage.
131
117
 
132
- ---
133
-
134
- ## Related skills
118
+ ## How recommendations feed assignment
135
119
 
136
- - To analyze failures from a run, use `analyzing-test-failures`.
137
- - To actually execute a recommended suite, use `running-devops-test-suite`.
120
+ - A relevant suite that exists but is **not assigned** to the stage → use **Mode B/C** (`references/suite-assignment-modes.md`) to assign it.
121
+ - To actually execute a recommended suite, use **`dx-devops-test-suite-run`**.