@salesforce/afv-skills 1.17.0 → 1.19.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 (40) hide show
  1. package/package.json +1 -1
  2. package/skills/analyzing-test-failures/SKILL.md +159 -0
  3. package/skills/building-sf-integrations/SKILL.md +1 -1
  4. package/skills/checking-devops-prerequisites/SKILL.md +141 -0
  5. package/skills/configuring-code-analyzer/SKILL.md +482 -0
  6. package/skills/configuring-code-analyzer/examples/apex-project-config.yml +41 -0
  7. package/skills/configuring-code-analyzer/examples/ci-github-actions.yml +96 -0
  8. package/skills/configuring-code-analyzer/examples/fullstack-project-config.yml +46 -0
  9. package/skills/configuring-code-analyzer/examples/lwc-project-config.yml +26 -0
  10. package/skills/configuring-code-analyzer/references/ci-cd-templates.md +648 -0
  11. package/skills/configuring-code-analyzer/references/config-schema.md +257 -0
  12. package/skills/configuring-code-analyzer/references/diagnostic-flow.md +70 -0
  13. package/skills/configuring-code-analyzer/references/engine-prerequisites.md +276 -0
  14. package/skills/configuring-code-analyzer/references/rule-name-resolution.md +67 -0
  15. package/skills/configuring-code-analyzer/references/troubleshooting.md +298 -0
  16. package/skills/configuring-code-analyzer/scripts/check-prerequisites.sh +189 -0
  17. package/skills/configuring-code-analyzer/scripts/generate-config.sh +143 -0
  18. package/skills/configuring-code-analyzer/scripts/validate-config.sh +153 -0
  19. package/skills/configuring-quality-gate/SKILL.md +120 -0
  20. package/skills/configuring-test-provider/SKILL.md +113 -0
  21. package/skills/creating-fix-work-item/SKILL.md +66 -0
  22. package/skills/managing-cdc-enablement/SKILL.md +164 -0
  23. package/skills/managing-cdc-enablement/assets/PlatformEventChannel-template.xml +5 -0
  24. package/skills/managing-cdc-enablement/assets/PlatformEventChannelMember-template.xml +11 -0
  25. package/skills/managing-cdc-enablement/references/deploy-troubleshooting.md +73 -0
  26. package/skills/managing-cdc-enablement/references/filter-expressions.md +93 -0
  27. package/skills/managing-suite-assignments/SKILL.md +161 -0
  28. package/skills/polling-test-results/SKILL.md +72 -0
  29. package/skills/recommending-devops-tests/SKILL.md +137 -0
  30. package/skills/running-code-analyzer/SKILL.md +264 -267
  31. package/skills/running-code-analyzer/references/post-scan-workflows.md +286 -0
  32. package/skills/running-code-analyzer/scripts/describe-rule.js +382 -0
  33. package/skills/running-code-analyzer/scripts/list-rules.js +260 -0
  34. package/skills/running-code-analyzer/scripts/query-results.js +230 -0
  35. package/skills/running-devops-test-suite/SKILL.md +144 -0
  36. package/skills/syncing-test-providers/SKILL.md +108 -0
  37. package/skills/using-salesforce-archive/SKILL.md +121 -0
  38. package/skills/using-salesforce-archive/examples/monitor-failed-jobs.md +47 -0
  39. package/skills/using-salesforce-archive/references/archive-activity-entity.md +59 -0
  40. package/skills/using-salesforce-archive/references/connect-api-operations.md +157 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/afv-skills",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "description": "Salesforce skills for Agentforce Vibes",
5
5
  "license": "CC-BY-NC-4.0",
6
6
  "files": [
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: analyzing-test-failures
3
+ description: "Parses a DevOps Center test-failure or Code Analyzer violation payload and explains it in plain language — failure category, offending file/class/method/line, rule violated, and fix direction — then gives prioritized test-improvement suggestions (distinguishing test-code from production-code fixes). Pure reasoning: no system calls or code authoring. TRIGGER when: a test run failed and the user wants root cause; a quality gate failure needs explaining; Code Analyzer violations need translating to plain language; the user shares a failure payload and asks how to address it; tests keep failing and the user wants suggestions; or the user wants to close coverage gaps, strengthen assertions, or fix flaky/weak tests. DO NOT TRIGGER when: the user wants fix code written (use generating-apex) or new test classes authored (use generating-apex-test)."
4
+ metadata:
5
+ version: "1.0"
6
+ minApiVersion: "67.0"
7
+ ---
8
+
9
+ # analyzing-test-failures
10
+
11
+ **Type:** Pure reasoning — no system calls, no code authoring.
12
+
13
+ **What it does:** Parses a test failure or Code Analyzer violation payload and produces a plain-language explanation, then follows up with concrete, prioritized improvement suggestions per failed test — including whether each fix belongs in the test or in production code. Never exposes raw JSON, stack traces, or API error bodies to the user.
14
+
15
+ ---
16
+
17
+ ## Prerequisites
18
+
19
+ If you need to fetch the failure payload yourself rather than receiving it, load `checking-devops-prerequisites` first, then use `polling-test-results` to obtain the execution result. If the payload is already in context, no prerequisites are needed — this is pure reasoning.
20
+
21
+ ---
22
+
23
+ ## Inputs
24
+
25
+ - JSON failure payload provided by the `polling-test-results` skill, or pasted directly into context from a test run or Code Analyzer execution. Specifically required per failed test:
26
+ - Test method name
27
+ - Failure message (the assertion error or exception text)
28
+ - Failure category (assertion failure, unhandled exception, timeout, compile error)
29
+
30
+ ---
31
+
32
+ ## Empty-org / no-data case
33
+
34
+ If the payload contains no failures or violations, report that clearly (e.g. "No failures found in the provided execution results.") and stop. Do NOT fabricate failures, violations, or improvement suggestions when none are present.
35
+
36
+ ---
37
+
38
+ ## Reasoning steps
39
+
40
+ 1. Determine the failure category:
41
+
42
+ | Category | Description |
43
+ |---|---|
44
+ | **Assertion failure** | A test assertion failed (expected vs actual mismatch) |
45
+ | **Exception** | An unhandled exception was thrown |
46
+ | **Code Analyzer violation** | A static analysis rule was violated (e.g. `ApexCRUDViolation`, `ApexSharingViolations`) |
47
+ | **Timeout** | Test exceeded execution time limit |
48
+ | **Compile error** | Class failed to compile |
49
+
50
+ 2. For each failure, extract and translate to plain language:
51
+ - Offending file and class name
52
+ - Method name
53
+ - Line number
54
+ - What rule or assertion was violated, in plain language
55
+ - Suggested fix direction (without writing code)
56
+
57
+ 3. Group failures by category if more than one.
58
+
59
+ ---
60
+
61
+ ## Output format
62
+
63
+ ```text
64
+ Test failure summary:
65
+
66
+ <N> failure(s) found:
67
+
68
+ 1. [<Category>] `<ClassName>.cls` — `<methodName>()` at line <N>
69
+ What happened: <plain-language description>
70
+ Rule violated: <ruleName or assertion description>
71
+ Fix direction: <plain-language suggestion>
72
+
73
+ 2. [<Category>] `<ClassName2>.cls` — `<methodName2>()` at line <N>
74
+ ...
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Code Analyzer violations
80
+
81
+ For violations, always include:
82
+ - The rule name translated to plain English (e.g. "ApexCRUDViolation" → "A SOQL query was made without checking object-level permissions first")
83
+ - The exact line number
84
+ - The fix direction (e.g. "Add a `Schema.sObjectType.Account.isAccessible()` check before the query")
85
+
86
+ ---
87
+
88
+ ## Plain-language rule
89
+
90
+ Never paste raw stack traces, JSON payloads, or internal Salesforce error codes into the output. Always translate to file name, method, line, and plain description.
91
+
92
+ ---
93
+
94
+ ## Suggesting improvements
95
+
96
+ Invoke this section **after test execution completes with failures**, not on static source code. The failure message is the primary signal — it describes what the test expected vs. what actually happened, which directly informs what the test needs to handle better.
97
+
98
+ ### 1 — Read each failure message
99
+
100
+ For each failed test in the execution result, extract:
101
+ - Test method name
102
+ - Failure message (the assertion error or exception message)
103
+ - Failure category (assertion failure, unhandled exception, timeout, compile error)
104
+
105
+ ### 2 — Infer what the test is not handling
106
+
107
+ Reason over the failure message to identify the root cause pattern:
108
+
109
+ | Failure pattern | Improvement suggestion |
110
+ |---|---|
111
+ | `NullPointerException` | The test is not handling null input — add a null check or a test setup that ensures the data exists |
112
+ | `Assertion failed: expected X but was Y` | The expected value in the assertion is wrong or the test data setup does not produce the right state |
113
+ | `List has no rows for assignment` | The test is querying for data that doesn't exist — test setup is incomplete |
114
+ | `System.LimitException: Too many SOQL queries` | The test is hitting governor limits — the code under test or test setup is making too many queries |
115
+ | `Insufficient access rights on cross-reference id` | The test user lacks the required permissions — the test needs to run as a user with appropriate profile/permission set |
116
+ | `DML currently not allowed` | The test is performing DML inside a method called from a context that doesn't allow it |
117
+ | Code Analyzer violation message | The production code violates a specific rule — the test exposed it but the fix is in the production code, not the test |
118
+
119
+ ### 3 — Produce actionable suggestions
120
+
121
+ For each failure, describe in plain language:
122
+ - What the failure reveals about what the test is not handling
123
+ - What specifically should be added or changed to make the test robust
124
+ - Whether the fix is in the **test** (assertion, setup, permissions) or in the **production code** (the test is correct but the code under test is broken)
125
+
126
+ Do not rewrite the test. Only describe what needs to change and why.
127
+
128
+ ### Output format for improvements
129
+
130
+ ```text
131
+ Test improvement suggestions based on execution results:
132
+
133
+ `<testMethodName>()` — [Assertion Failure / Exception / etc.]
134
+ Failure: "<failure message>"
135
+ What this reveals: <plain-language explanation>
136
+ Suggestion: <specific, actionable recommendation>
137
+ Fix location: Test | Production code
138
+
139
+ `<testMethodName2>()` — [NullPointerException]
140
+ Failure: "Attempt to de-reference a null object"
141
+ What this reveals: The test is calling the method without setting up the required input data
142
+ Suggestion: Add test data setup for <object/field> before calling the method
143
+ Fix location: Test
144
+
145
+ Overall: <N> improvement(s) across <M> failed test(s).
146
+ ```
147
+
148
+ ### Test fix vs. production-code fix
149
+
150
+ Suggestions flagged as **Fix location: Production code** indicate a code defect exposed by the test — the test logic itself is sound. These should not block suite promotion on the grounds of test quality; they should be tracked separately as production defects.
151
+
152
+ Suggestions flagged as **Fix location: Test** indicate the test needs to be hardened — missing setup, wrong assertions, inadequate coverage of edge cases (null inputs, bulk record volumes, mixed permission contexts, governor-limit boundaries).
153
+
154
+ ---
155
+
156
+ ## Related skills
157
+
158
+ - **`polling-test-results`** — obtains the failure payload that feeds into this skill.
159
+ - **`creating-fix-work-item`** — use to create a tracked fix item from the analysis output or to track an approved improvement suggestion as a work item once the user decides to act on it.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: building-sf-integrations
3
- description: "Salesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data)."
3
+ description: "Salesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), data import/export (use handling-sf-data), or CDC channel-membership metadata such as PlatformEventChannel, PlatformEventChannelMember, or EnrichedField (use managing-cdc-enablement)."
4
4
  metadata:
5
5
  version: "1.1"
6
6
  ---
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: checking-devops-prerequisites
3
+ description: "Validate the environment before any DevOps Center pipeline testing action: confirms an authenticated Salesforce org, the Agentforce DX plugin, an authenticated DevOps Center org, and an identified pipeline (and optionally a pipeline stage). Use this FIRST, internally, from any DevOps testing skill (running a test suite, polling results, syncing tests, configuring or retriggering a quality gate, assigning/mapping suites, creating fix work items, recommending tests, explaining coverage, analyzing failures). TRIGGER when another DevOps testing skill needs to confirm org/pipeline context before a query or system call. DO NOT TRIGGER for non-DevOps-Center work."
4
+ metadata:
5
+ version: "1.0"
6
+ minApiVersion: "67.0"
7
+ ---
8
+
9
+ # Checking DevOps Prerequisites
10
+
11
+ Shared 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.
12
+
13
+ > **API version:** All DevOps testing system calls target Salesforce API **v67.0** (minimum required).
14
+
15
+ **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`.
16
+
17
+ ## How other skills use this
18
+
19
+ Every DevOps testing skill loads this skill first and runs Prerequisites 1–4 in order. Prerequisite 5 (stage) is run **only** when the calling skill operates on a specific pipeline stage (running/retriggering a suite, syncing, configuring a gate, mapping a suite). The calling skill passes back the resolved `doce-org-alias`, `pipelineId`, and (when applicable) `stageId` to use in its own commands.
20
+
21
+ Resolve the **DevOps Center org alias** without asking the user unless genuinely ambiguous:
22
+ 1. If the user named an org alias in their message, use it.
23
+ 2. Otherwise, use the default org (`sf org display --json`, no `--target-org`).
24
+ 3. Only if the default org has no `DevopsPipeline` records (Prereq 4 fails), ask: "Which org alias is your DevOps Center org?"
25
+
26
+ ---
27
+
28
+ ## Prerequisite 1 — Salesforce org: active login
29
+
30
+ ```bash
31
+ sf org list --json
32
+ ```
33
+
34
+ Look for at least one entry in `result.nonScratchOrgs`, `result.scratchOrgs`, or `result.sandboxes` with `"connectedStatus": "Connected"`.
35
+
36
+ - **Pass:** at least one org is Connected
37
+ - **Fail:** no orgs listed, or all show a non-connected status
38
+
39
+ **On fail:** "No authenticated Salesforce org found. Run `sf org login web --alias <your-alias>` in your terminal, then come back."
40
+
41
+ ---
42
+
43
+ ## Prerequisite 2 — Agentforce DX plugin installed
44
+
45
+ ```bash
46
+ sf plugins --json
47
+ ```
48
+
49
+ Look for a plugin entry whose `name` contains `plugin-agent`, `agentforce`, or `einstein` (case-insensitive).
50
+
51
+ - **Pass:** plugin found
52
+ - **Fail:** no matching entry
53
+
54
+ **On fail:** "The Agentforce DX Plugin is not installed. Run `sf plugins install @salesforce/plugin-agent`, then restart the IDE and try again."
55
+
56
+ ---
57
+
58
+ ## Prerequisite 3 — DevOps Center org authenticated
59
+
60
+ ```bash
61
+ sf org display --target-org <doce-org-alias> --json
62
+ ```
63
+
64
+ Check that `"connectedStatus"` is `"Connected"`.
65
+
66
+ - **Pass:** Connected
67
+ - **Fail:** expired session or error
68
+
69
+ **On fail:** "Your DevOps Center org session has expired. Run `sf org login web --alias <doce-org-alias>` to re-authenticate."
70
+
71
+ ---
72
+
73
+ ## Prerequisite 4 — Pipeline identified
74
+
75
+ ```bash
76
+ sf data query \
77
+ --query "SELECT Id, Name, CreatedDate FROM DevopsPipeline ORDER BY Name ASC" \
78
+ --target-org <doce-org-alias> \
79
+ --json
80
+ ```
81
+
82
+ - **Pass (exactly one):** use it automatically — do NOT ask.
83
+ - **Pass (multiple):** if the user already named a pipeline, match by name. Otherwise display a numbered list and ask:
84
+ ```text
85
+ Found <N> pipelines:
86
+ 1. <Name>
87
+ 2. <Name>
88
+ Which pipeline would you like to work with?
89
+ ```
90
+ - **Fail (no records):** "No DevOps Center pipeline found. Create a project and pipeline in DevOps Center before using the DevOps Testing Skills."
91
+ - **Fail (unsupported object):** "DevOps Center does not appear to be installed on `<doce-org-alias>`. Check that you're pointing at the correct org."
92
+
93
+ ---
94
+
95
+ ## Prerequisite 5 — Pipeline stage identified (conditional)
96
+
97
+ Run **only** when the calling skill operates on a specific stage.
98
+
99
+ 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:
100
+
101
+ ```bash
102
+ sf data query \
103
+ --query "SELECT Id, Name FROM DevopsPipelineStage WHERE DevopsPipelineId = '<pipelineId>' AND Name = '<stageName>'" \
104
+ --target-org <doce-org-alias> --json
105
+ ```
106
+
107
+ Only if no stage is mentioned, fetch the full list and ask which one:
108
+
109
+ ```bash
110
+ sf data query \
111
+ --query "SELECT Id, Name FROM DevopsPipelineStage WHERE DevopsPipelineId = '<pipelineId>' ORDER BY Name ASC" \
112
+ --target-org <doce-org-alias> --json
113
+ ```
114
+
115
+ Then ask: "Which pipeline stage are we working with?" — do NOT ask for an org alias; stages are resolved by name from the pipeline.
116
+
117
+ - **Pass:** stage Id and Name confirmed
118
+ - **Deferred:** not required until a calling skill needs it
119
+
120
+ ---
121
+
122
+ ## Error Handling
123
+
124
+ | Error condition | Response |
125
+ |---|---|
126
+ | `sf org list` fails entirely | "Could not reach the Salesforce CLI. Make sure `sf` is installed and on your PATH." |
127
+ | `sf org display` returns auth error | Surface plain-language re-auth instructions. Do not expose the raw error. |
128
+ | `DevopsPipeline` query fails with 5xx | "The DevOps Center org is returning a server error. Try again in a few minutes." |
129
+ | 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." |
130
+
131
+ Never expose raw API errors, stack traces, or JSON error payloads to the user.
132
+
133
+ ## Gotchas
134
+
135
+ | Issue | Resolution |
136
+ |---|---|
137
+ | `DevopsPipeline` query returns empty | DevOps Center not installed on the target org, or wrong org alias — ask the user to verify |
138
+ | `DevopsWorkItem` sObject not supported | Use `WorkItem` (no namespace) — the correct API name for this org version |
139
+ | Review trigger is pipeline-level, not stage-level | Query `DevopsPipelineStageTrigger` where `TriggerType = 'Review'` and `RelatedRecordId = <pipelineId>` |
140
+ | Connect API `testSuites` returns empty with `?stageId=` | Use `?triggerId=<reviewTriggerId>` — `stageId` only works for stage-level triggers |
141
+ | `sf plugins` doesn't match `agentforce` | The installed plugin is `@salesforce/plugin-agent` — match on `plugin-agent` too |