Skip to content

Commit 329fb21

Browse files
authored
Merge pull request #116 from ProvarTesting/feature/auth-and-quality-hub-api
Feature/auth and quality hub api
2 parents 7d747b5 + 1ded191 commit 329fb21

29 files changed

Lines changed: 4625 additions & 611 deletions

.github/workflows/CI_Execution.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ jobs:
124124
sf plugins link .
125125
yarn run test:nuts
126126
- name: Archive NUTS results
127+
if: always()
127128
uses: actions/upload-artifact@v4
128129
with:
129130
name: nuts-report-${{ matrix.os }}
130131
path: mochawesome-report
132+
if-no-files-found: warn

README.md

Lines changed: 137 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
[![Version](https://img.shields.io/npm/v/@provartesting/provardx-cli.svg)](https://npmjs.org/package/@provartesting/provardx-cli)
44
[![Downloads/week](https://img.shields.io/npm/dw/@provartesting/provardx-cli.svg)](https://npmjs.org/package/@provartesting/provardx-cli)
55
[![License](https://img.shields.io/npm/l/@provartesting/provardx-cli.svg)](https://github.com/ProvarTesting/provardx-cli/blob/main/LICENSE.md)
6+
[![Get Access](https://img.shields.io/badge/Quality%20Hub%20API-Get%20Access-blue)](https://aqqlrlhga7.execute-api.us-east-1.amazonaws.com/dev/auth/request-access)
67

78
# What is the ProvarDX CLI?
89

910
The Provar DX CLI is a Salesforce CLI plugin for Provar customers who want to automate the execution of tests using Provar Automation, and the reporting of test results and other quality-related metrics to Provar Quality Hub.
1011

1112
# Installation, Update, and Uninstall
1213

14+
**Requires Node.js 18–24 (LTS 22 recommended).** Node 25+ is not yet supported due to a breaking change in a transitive dependency. Check with `node --version`.
15+
1316
Install the plugin
1417

1518
```sh-session
16-
$ sf plugins install @provartesting/provardx-cli
19+
$ sf plugins install @provartesting/provardx-cli@beta
1720
```
1821

1922
Update plugins
@@ -30,33 +33,56 @@ $ sf plugins uninstall @provartesting/provardx-cli
3033

3134
# MCP Server (AI-Assisted Quality)
3235

33-
The Provar DX CLI includes a built-in **Model Context Protocol (MCP) server** that connects AI assistants (Claude Desktop, Claude Code, Cursor) directly to your Provar project. Once connected, an AI agent can inspect your project structure, generate Page Objects and test cases, validate every level of the test hierarchy with quality scores that match the Provar Quality Hub API, and work with NitroX (Hybrid Model) component page objects for LWC, Screen Flow, Industry Components, Experience Cloud, and HTML5.
36+
The Provar DX CLI includes a built-in **Model Context Protocol (MCP) server** that connects AI assistants (Claude Desktop, Claude Code, Cursor) directly to your Provar project. Once connected, an AI agent can inspect your project structure, generate Page Objects and test cases, validate every level of the test hierarchy with quality scores, and work with NitroX (Hybrid Model) component page objects for LWC, Screen Flow, Industry Components, Experience Cloud, and HTML5.
37+
38+
Validation runs in two modes: **local only** (structural rules, no key required) or **Quality Hub API** (170+ rules, quality scoring — requires a `pv_k_` API key). Don't have an account? **[Request access](https://aqqlrlhga7.execute-api.us-east-1.amazonaws.com/dev/auth/request-access)**.
39+
40+
## Quick setup
41+
42+
**Requires:** Provar Automation IDE installed with an activated license.
3443

3544
```sh
36-
sf provar mcp start --allowed-paths /path/to/your/provar/project
45+
# 1. Install the plugin (if not already installed)
46+
sf plugins install @provartesting/provardx-cli@beta
47+
48+
# 2. (Optional) Authenticate for full 170+ rule validation
49+
sf provar auth login
3750
```
3851

39-
📖 **See [docs/mcp.md](https://github.com/ProvarTesting/provardx-cli/blob/main/docs/mcp.md) for full setup and tool documentation.**
52+
**Claude Code** — run once to register the server:
4053

41-
## License Validation
54+
```sh
55+
claude mcp add provar -s user -- sf provar mcp start --allowed-paths /path/to/your/provar/project
56+
```
4257

43-
The MCP server verifies your Provar license before accepting any connections. Validation is automatic — no extra flags are required for standard usage.
58+
**Claude Desktop** — add to your config file and restart the app:
4459

45-
**How it works:**
60+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
61+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
4662

47-
1. **Auto-detection** — the server reads `~/Provar/.licenses/*.properties` (the same files written by Provar's IDE plugins). If a valid, activated license is found the server starts immediately.
48-
2. **Cache** — successful validations are cached at `~/Provar/.licenses/.mcp-license-cache.json` (2 h TTL). Subsequent starts within the TTL window skip the disk scan.
49-
3. **Grace fallback** — if the IDE license files cannot be found or read and the cache is stale (but ≤ 48 h old), the server starts with a warning on stderr using the cached result so CI pipelines are not broken by transient local file-access issues.
50-
4. **Fail closed** — if no valid license is detected the command exits with a non-zero exit code and a clear error message.
63+
```json
64+
{
65+
"mcpServers": {
66+
"provar": {
67+
"command": "sf",
68+
"args": ["provar", "mcp", "start", "--allowed-paths", "/path/to/your/provar/project"]
69+
}
70+
}
71+
}
72+
```
5173

52-
**`NODE_ENV=test` fast-path:**
74+
> **Windows (Claude Desktop):** Use `sf.cmd` instead of `sf` if the server fails to start.
5375
54-
When `NODE_ENV=test` the validation step is skipped entirely. This is intended only for the plugin's own unit-test suite.
76+
📖 **[docs/mcp.md](https://github.com/ProvarTesting/provardx-cli/blob/main/docs/mcp.md) — full setup, all 35+ tools, troubleshooting.**
5577

5678
---
5779

5880
# Commands
5981

82+
- [`sf provar auth login`](#sf-provar-auth-login)
83+
- [`sf provar auth rotate`](#sf-provar-auth-rotate)
84+
- [`sf provar auth status`](#sf-provar-auth-status)
85+
- [`sf provar auth clear`](#sf-provar-auth-clear)
6086
- [`sf provar mcp start`](#sf-provar-mcp-start)
6187
- [`sf provar config get`](#sf-provar-config-get)
6288
- [`sf provar config set`](#sf-provar-config-set)
@@ -84,6 +110,99 @@ When `NODE_ENV=test` the validation step is skipped entirely. This is intended o
84110
- [`sf provar manager test run report`](#sf-provar-manager-test-run-report) _(deprecated — use `sf provar quality-hub test run report`)_
85111
- [`sf provar manager test run abort`](#sf-provar-manager-test-run-abort) _(deprecated — use `sf provar quality-hub test run abort`)_
86112

113+
## `sf provar auth login`
114+
115+
Log in to Provar Quality Hub and store your API key.
116+
117+
```
118+
USAGE
119+
$ sf provar auth login [--url <value>]
120+
121+
FLAGS
122+
--url=<value> Override the Quality Hub API base URL (for non-production environments).
123+
124+
DESCRIPTION
125+
Opens a browser to the Provar login page. After you authenticate, your API key is
126+
stored at ~/.provar/credentials.json and used automatically by the Provar MCP tools
127+
and CI/CD integrations. The key is valid for approximately 90 days.
128+
129+
For CI/CD pipelines (GitHub Actions, Jenkins, etc.) where a browser cannot open:
130+
run sf provar auth login once on your local machine, copy the api_key value from
131+
~/.provar/credentials.json, and store it as the PROVAR_API_KEY environment variable
132+
or secret in your pipeline. Rotate the secret every ~90 days when the key expires.
133+
134+
Don't have an account? Request access at:
135+
https://aqqlrlhga7.execute-api.us-east-1.amazonaws.com/dev/auth/request-access
136+
137+
EXAMPLES
138+
Log in interactively:
139+
140+
$ sf provar auth login
141+
142+
Log in against a staging environment:
143+
144+
$ sf provar auth login --url https://dev.api.example.com
145+
```
146+
147+
## `sf provar auth rotate`
148+
149+
Rotate your stored API key without re-authenticating via browser.
150+
151+
```
152+
USAGE
153+
$ sf provar auth rotate
154+
155+
DESCRIPTION
156+
Exchanges your current pv_k_ key for a new one atomically. The old key is
157+
invalidated immediately. The new key is written to ~/.provar/credentials.json.
158+
159+
Use this to rotate your key on a regular schedule (~every 90 days) without
160+
going through the browser login flow. If your current key is already expired,
161+
run sf provar auth login instead.
162+
163+
EXAMPLES
164+
Rotate the stored API key:
165+
166+
$ sf provar auth rotate
167+
```
168+
169+
## `sf provar auth status`
170+
171+
Show the current API key configuration and validate it against Quality Hub.
172+
173+
```
174+
USAGE
175+
$ sf provar auth status
176+
177+
DESCRIPTION
178+
Reports whether an API key is configured, where it came from (environment variable
179+
or credentials file), and performs a live check against the Quality Hub API to
180+
confirm the key is still valid.
181+
182+
EXAMPLES
183+
Check auth status:
184+
185+
$ sf provar auth status
186+
```
187+
188+
## `sf provar auth clear`
189+
190+
Remove the stored API key.
191+
192+
```
193+
USAGE
194+
$ sf provar auth clear
195+
196+
DESCRIPTION
197+
Deletes ~/.provar/credentials.json and revokes the key server-side. After clearing,
198+
the MCP tools fall back to local validation mode. Has no effect if no key is stored.
199+
200+
EXAMPLES
201+
Remove the stored key:
202+
203+
$ sf provar auth clear
204+
```
205+
87206
## `sf provar mcp start`
88207

89208
Start a local MCP server for Provar tools over stdio transport.
@@ -136,6 +255,11 @@ TOOLS EXPOSED
136255
provar.testplan.add-instance — wire a test case into a plan suite by writing a .testinstance file
137256
provar.testplan.create-suite — create a new test suite directory with .planitem inside a plan
138257
provar.testplan.remove-instance — remove a .testinstance file from a plan suite
258+
provar.nitrox.discover — discover projects containing NitroX (Hybrid Model) page objects
259+
provar.nitrox.read — read NitroX .po.json files and return parsed content
260+
provar.nitrox.validate — validate a NitroX .po.json against schema rules
261+
provar.nitrox.generate — generate a new NitroX .po.json from a component description
262+
provar.nitrox.patch — apply a JSON merge-patch to an existing NitroX .po.json file
139263
140264
EXAMPLES
141265
Start MCP server (accepts stdio connections from Claude Desktop / Cursor):

docs/mcp-pilot-guide.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ The server runs **locally on your machine**. It does not phone home, transmit yo
2525
| --------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------- |
2626
| Provar Automation IDE | ≥ 2.x | Must be installed with an **activated licence** on the same machine. The MCP server reads the licence from `~/Provar/.licenses/`. |
2727
| Salesforce CLI (`sf`) | ≥ 2.x | `npm install -g @salesforce/cli` |
28-
| Provar DX CLI plugin | ≥ 1.5.0 | `sf plugins install @provartesting/provardx-cli` |
28+
| Provar DX CLI plugin | ≥ 1.5.0 | `sf plugins install @provartesting/provardx-cli@beta` |
2929
| An MCP-compatible AI client || Claude Desktop, Claude Code, or Cursor |
30-
| Node.js | ≥ 18 | Installed automatically with the SF CLI |
30+
| Node.js | 18–24 | Installed automatically with the SF CLI. **Node 25+ is not supported** — a transitive dependency crashes on startup. Use Node 22 LTS. |
3131

3232
---
3333

@@ -48,7 +48,7 @@ sf --version
4848
### 2. Install the Provar DX CLI plugin
4949

5050
```sh
51-
sf plugins install @provartesting/provardx-cli
51+
sf plugins install @provartesting/provardx-cli@beta
5252
```
5353

5454
Verify:
@@ -165,6 +165,9 @@ Prompt your AI assistant:
165165
- `validity_score` and `quality_score` both returned (0–100)
166166
- Specific rule violations called out (e.g. TC_010 missing test case ID, TC_001 missing XML declaration)
167167
- Best-practices suggestions (e.g. hardcoded credentials, missing step descriptions)
168+
- `validation_source: "local"` if no API key is configured, `"quality_hub"` if authenticated
169+
170+
> **Tip:** Run `sf provar auth login` before this scenario to unlock Quality Hub API validation (170+ rules). Without a key the tool still returns useful results using local rules only.
168171
169172
---
170173

@@ -226,6 +229,24 @@ Pre-requisite: `sf org login web -a MyQHOrg` then `sf provar quality-hub connect
226229

227230
---
228231

232+
### Scenario 8: Quality Hub API Validation
233+
234+
**Goal:** Confirm that `provar.testcase.validate` upgrades from local rules to the full Quality Hub API ruleset when an API key is present.
235+
236+
**Setup:** Run `sf provar auth login` and complete the browser login, then confirm with `sf provar auth status`.
237+
238+
> "Validate the test case at `/path/to/project/tests/LoginTest.testcase` and tell me what validation_source was used."
239+
240+
**What to look for:**
241+
242+
- `validation_source: "quality_hub"` in the response — confirms the API path is active
243+
- `quality_score` reflecting the full 170+ rule evaluation
244+
- If the API is unreachable, `validation_source: "local_fallback"` and a `validation_warning` field explaining why
245+
246+
**To reset and test the fallback:** run `sf provar auth clear`, repeat the prompt, and verify `validation_source` reverts to `"local"`.
247+
248+
---
249+
229250
### Scenario 7: NitroX (Hybrid Model) Page Object Generation
230251

231252
**Goal:** Have the AI discover, understand, and generate NitroX component page objects.
@@ -323,7 +344,9 @@ The MCP server uses **stdio transport** exclusively. Communication travels over
323344

324345
### Credential handling
325346

326-
The Quality Hub and Automation tools invoke `sf` subprocesses. Salesforce org credentials are managed entirely by the Salesforce CLI and stored in its own credential store. The Provar MCP server never reads, parses, or transmits those credentials.
347+
**Salesforce org credentials** — the Quality Hub and Automation tools invoke `sf` subprocesses. Salesforce org credentials are managed entirely by the Salesforce CLI and stored in its own credential store (`~/.sf/`). The Provar MCP server never reads, parses, or transmits those credentials.
348+
349+
**Provar API key** — the `provar.testcase.validate` tool optionally reads a `pv_k_` API key to enable Quality Hub API validation. The key is stored at `~/.provar/credentials.json` (written by `sf provar auth login`) or read from the `PROVAR_API_KEY` environment variable. The key is sent to the Provar Quality Hub API only when a validation request is made — it is never logged or written anywhere other than `~/.provar/credentials.json`.
327350

328351
### Path policy enforcement
329352

@@ -393,7 +416,7 @@ After editing `claude_desktop_config.json`, you must fully restart Claude Deskto
393416

394417
**Server starts but immediately exits**
395418

396-
Check that the SF CLI plugin is installed: `sf plugins | grep provardx`. If missing, run `sf plugins install @provartesting/provardx-cli`.
419+
Check that the SF CLI plugin is installed: `sf plugins | grep provardx`. If missing, run `sf plugins install @provartesting/provardx-cli@beta`.
397420

398421
---
399422

0 commit comments

Comments
 (0)