Skip to content

Commit c62c6ca

Browse files
authored
Merge pull request #117 from ProvarTesting/develop
Develop
2 parents 37213d9 + 329fb21 commit c62c6ca

43 files changed

Lines changed: 6718 additions & 612 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.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

.gitignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@ mochawesome-report
5656
.env.*.local
5757

5858
# Claude
59-
.claude/skills
60-
CLAUDE.md
59+
.claude/
60+
61+
# NitroX schema files — do not commit until IP/licensing confirmed with Provar team
62+
# See: src/mcp/tools/nitroXTools.ts and plan notes
63+
src/mcp/rules/FactComponent.schema.json
64+
src/mcp/rules/FactPackage.schema.json
65+
FactComponent.schema
66+
FactPackage.schema

CLAUDE.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Claude Code — Project Instructions
2+
3+
This file is read automatically by Claude Code at the start of every session. Follow these rules when working in this repo.
4+
5+
---
6+
7+
## Documentation Requirements
8+
9+
**Every PR that adds, modifies, or removes an MCP tool must update documentation.** The full set of places to update:
10+
11+
| What changed | Where to update |
12+
|---|---|
13+
| New MCP tool | `docs/mcp.md` (add tool entry with schema + example), `docs/mcp-pilot-guide.md` (add evaluation scenario if user-facing), `README.md` (update tool count if referenced) |
14+
| Modified tool description / parameters / errors | `docs/mcp.md` (update the relevant tool section) |
15+
| Removed tool | `docs/mcp.md`, `docs/mcp-pilot-guide.md`, `README.md` |
16+
| New error code or suggestion field | `docs/mcp.md` (Troubleshooting or Error Codes section) |
17+
| Security model change (path policy, licence, transport) | `docs/mcp.md` (Security Model section), `docs/mcp-pilot-guide.md` (Security Model section) |
18+
| New NitroX tool or schema rule | `docs/mcp.md` (NitroX section), `docs/mcp-pilot-guide.md` (Scenario 7) |
19+
| Smoke test count change | Update `TOTAL_EXPECTED` in `scripts/mcp-smoke.cjs` |
20+
21+
**External / customer-facing docs** (`docs/provar-mcp-public-docs.md`, `docs/university-of-provar-mcp-course.md`) are maintained separately by the Provar team — flag changes that affect public-facing behaviour in your PR description so those can be updated manually.
22+
23+
---
24+
25+
## Test Coverage Requirements
26+
27+
Every PR must include tests for new or changed behaviour:
28+
29+
- **New MCP tool** → unit tests in `test/unit/mcp/<toolGroup>Tools.test.ts` covering: happy path, path policy rejection, missing required fields, and any tool-specific error codes
30+
- **Modified error handling** → at least one positive test (error path fires) and one negative test (does not fire for non-matching input)
31+
- **New validation rule** → test that the rule fires correctly and that a valid input passes
32+
- **Smoke test** → add an entry in `scripts/mcp-smoke.cjs` for each new tool; update `TOTAL_EXPECTED`
33+
34+
Run before every commit:
35+
```sh
36+
yarn test:only # unit tests — must all pass
37+
node scripts/mcp-smoke.cjs 2>/dev/null # smoke — must show all PASS
38+
yarn compile # TypeScript — must be clean
39+
```
40+
41+
---
42+
43+
## MCP Tool Authoring Standards
44+
45+
### Tool description quality
46+
47+
Every tool description must answer these questions for an AI agent reading it cold:
48+
49+
1. **What does it do?** (one sentence)
50+
2. **What prerequisite tools must run first?** (e.g. `config.load` before `metadata.download`)
51+
3. **What are the correct flags / parameters?** Include a concrete example in the `flags` field description when flags are free-form
52+
4. **What does a failure mean?** If a known error pattern exists (e.g. `[DOWNLOAD_ERROR]` = auth failure), say so in the description or return a `details.suggestion`
53+
54+
### Field descriptions
55+
56+
- Fields that accept a **string key or password** must say "string value, NOT a file path" if there is any risk of confusion with a path
57+
- Fields that accept a **file path** must note if the path must be within `--allowed-paths`
58+
- Optional fields that have a dangerous default (e.g. overwriting existing files) must call that out
59+
60+
### Error responses
61+
62+
- Return `details: { suggestion: '...' }` when a known error pattern maps to a common root cause and there is an actionable fix
63+
- Never pass `details: {}` — omit `details` entirely when there is nothing extra to say (keeps the response shape stable)
64+
- Error codes follow `SCREAMING_SNAKE_CASE`; document new codes in `docs/mcp.md`
65+
66+
### Path safety
67+
68+
- Call `assertPathAllowed(path, config.allowedPaths)` on **every** path input before any file operation — not just the output path
69+
- Use `path.resolve()` before `fs.existsSync` / `fs.readFileSync` / `fs.writeFileSync`
70+
- Never construct shell commands from user input; use `spawnSync` with an args array
71+
72+
---
73+
74+
## Branch and PR Conventions
75+
76+
- Feature branches off `develop`: `feature/<description>`
77+
- Bug/fix branches off `develop`: `fix/<description>`
78+
- Release branches off `develop`: `release-v<semver>`
79+
- PRs target `develop`; releases are merged develop → main
80+
- Version in `package.json` follows `<major>.<minor>.<patch>-beta.<n>` on develop
81+
- Bump the beta suffix (`beta.N → beta.N+1`) on any PR that triggers a publish
82+
83+
---
84+
85+
## Lint
86+
87+
The project uses ESLint with `@typescript-eslint` strict rules. Common gotchas:
88+
89+
- `complexity` max is **20** — extract helpers if a function grows past that
90+
- `no-unsafe-assignment` / `no-unsafe-call` — cast through `unknown` not `any`
91+
- `no-unnecessary-type-assertion` — TypeScript narrows after `typeof x === 'string'` checks; remove the redundant cast
92+
- `camelcase``nitroX` is valid camelCase (capital X starts the next word)
93+
94+
CI runs lint as part of `sf-prepack` — do not skip with `--no-verify` on the final merge commit.

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, and validate every level of the test hierarchy with quality scores that match the Provar Quality Hub API.
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):

0 commit comments

Comments
 (0)