@http-forge/cli 0.2.1 → 0.2.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.
Files changed (50) hide show
  1. package/README.md +447 -232
  2. package/dist/ai/providers.d.ts +34 -0
  3. package/dist/ai/providers.d.ts.map +1 -0
  4. package/dist/ai/providers.js +98 -0
  5. package/dist/ai/providers.js.map +1 -0
  6. package/dist/commands/env.d.ts +14 -0
  7. package/dist/commands/env.d.ts.map +1 -0
  8. package/dist/commands/env.js +165 -0
  9. package/dist/commands/env.js.map +1 -0
  10. package/dist/commands/generate-collection.d.ts +11 -0
  11. package/dist/commands/generate-collection.d.ts.map +1 -0
  12. package/dist/commands/generate-collection.js +301 -0
  13. package/dist/commands/generate-collection.js.map +1 -0
  14. package/dist/commands/list.d.ts +12 -0
  15. package/dist/commands/list.d.ts.map +1 -0
  16. package/dist/commands/list.js +170 -0
  17. package/dist/commands/list.js.map +1 -0
  18. package/dist/commands/mcp.d.ts +19 -0
  19. package/dist/commands/mcp.d.ts.map +1 -0
  20. package/dist/commands/mcp.js +211 -0
  21. package/dist/commands/mcp.js.map +1 -0
  22. package/dist/commands/run.d.ts +35 -0
  23. package/dist/commands/run.d.ts.map +1 -0
  24. package/dist/commands/run.js +589 -0
  25. package/dist/commands/run.js.map +1 -0
  26. package/dist/commands/schedule.d.ts +11 -0
  27. package/dist/commands/schedule.d.ts.map +1 -0
  28. package/dist/commands/schedule.js +237 -0
  29. package/dist/commands/schedule.js.map +1 -0
  30. package/dist/commands/suggest-env.d.ts +12 -0
  31. package/dist/commands/suggest-env.d.ts.map +1 -0
  32. package/dist/commands/suggest-env.js +205 -0
  33. package/dist/commands/suggest-env.js.map +1 -0
  34. package/dist/commands.d.ts +14 -7
  35. package/dist/commands.d.ts.map +1 -1
  36. package/dist/commands.js +28 -436
  37. package/dist/commands.js.map +1 -1
  38. package/dist/curl-parser.d.ts +51 -0
  39. package/dist/curl-parser.d.ts.map +1 -0
  40. package/dist/curl-parser.js +365 -0
  41. package/dist/curl-parser.js.map +1 -0
  42. package/dist/index.d.ts +7 -6
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +162 -87
  45. package/dist/index.js.map +1 -1
  46. package/dist/output/format.d.ts +63 -0
  47. package/dist/output/format.d.ts.map +1 -0
  48. package/dist/output/format.js +280 -0
  49. package/dist/output/format.js.map +1 -0
  50. package/package.json +2 -2
package/README.md CHANGED
@@ -1,381 +1,596 @@
1
1
  # HTTP Forge CLI
2
2
 
3
- Command-line interface for executing HTTP Forge collections, test suites, and MCP server operations.
3
+ Command-line interface for executing HTTP Forge collections, test suites, and MCP server operations — with built-in CI/CD support including JUnit and HTML reports.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Commands](#commands)
9
+ - [run](#run-command)
10
+ - [generate-collection](#generate-collection)
11
+ - [suggest-env](#suggest-env)
12
+ - [schedule](#schedule)
13
+ - [mcp](#5-manage-mcp-server)
14
+ - [copy-as](#6-copy-as-code-snippet)
15
+ - [list](#7-list-workspace-resources)
16
+ - [env](#8-manage-environment-variables)
17
+ - [Reporters](#reporters)
18
+ - [CI/CD Integration](#cicd-integration)
19
+ - [Variables & Secrets](#variables--secrets)
20
+ - [Environment Variables](#environment-variables)
21
+ - [Exit Codes](#exit-codes)
22
+ - [Output Format](#output-format)
23
+
24
+ ---
4
25
 
5
26
  ## Installation
6
27
 
28
+ ```bash
29
+ npm install --global @http-forge/cli
30
+ ```
31
+
32
+ Or use directly from the monorepo:
33
+
7
34
  ```bash
8
35
  cd http-forge.cli
9
36
  npm install
10
37
  npm run build
11
38
  ```
12
39
 
13
- ## Usage
40
+ ---
41
+
42
+ ## Commands
14
43
 
15
- ### 1. Show Help
44
+ ### `run` command
45
+
46
+ Execute requests using the positional form `http-forge run <type> <name>`:
16
47
 
17
48
  ```bash
18
- http-forge --help
19
- http-forge -h
49
+ # Run a collection by name
50
+ http-forge run collection "Auth Flow" --env staging
51
+
52
+ # Run a test suite by name or id
53
+ http-forge run suite "Regression" --env prod --stop-on-error --exit-code
54
+
55
+ # Run a single request (needs --collection)
56
+ http-forge run request "Login" --collection "Auth" --env dev
57
+
58
+ # Run all requests under a folder (needs --collection)
59
+ http-forge run folder "Auth/Login" --collection "Auth" --env dev
20
60
  ```
21
61
 
22
- ### 2. Run a Single Request
62
+ `--env` is a short form of `--environment`. Both default to `$HTTP_FORGE_ENV` when not set.
63
+
64
+ #### Path-based dispatch
65
+
66
+ You can also pass a workspace-relative **file path** instead of a type + name pair. HTTP Forge detects the run type from the target file:
23
67
 
24
68
  ```bash
25
- http-forge run-request \
26
- --collection my-api \
27
- --request get-users \
28
- --environment production \
29
- --output json
69
+ # Run by pointing at the collection directory (contains collection.json)
70
+ http-forge run collections/auth-flow --env staging
71
+
72
+ # Run a specific suite file
73
+ http-forge run suites/regression.json --env prod --exit-code
74
+
75
+ # Run a folder — collection is resolved automatically from the ancestor collection.json
76
+ http-forge run collections/auth-flow/Login --env dev
77
+
78
+ # Run a single request — collection is resolved automatically
79
+ http-forge run collections/auth-flow/Login/get-token --env dev
30
80
  ```
31
81
 
82
+ | Target file found | Equivalent command |
83
+ |---|---|
84
+ | `suite.json` | `run suite <name>` |
85
+ | `collection.json` | `run collection <name>` |
86
+ | `folder.json` (or directory inside a collection) | `run folder <path>` |
87
+ | `request.json` | `run request <name>` |
88
+
89
+ Path-based dispatch is useful when navigating a workspace in a terminal — `cd` into a folder and pass its relative path directly.
90
+
91
+ ---
92
+
93
+ ### 1. `run request`
94
+
32
95
  ```bash
33
- http-forge run-request --collection my-api --request get-users --include tests --include report
96
+ http-forge run request "get-users" \
97
+ --collection my-api \
98
+ --environment production
34
99
  ```
35
100
 
36
101
  **Required:**
37
- - `--collection <id>` — Collection ID
38
- - `--request <id>` — Request ID
102
+ - `--collection <ref>` — Collection id, slug, or display name
103
+ - First positional arg — Request id, slug, or display name
39
104
 
40
105
  **Optional:**
106
+ - `--folder <path>` — Scope resolution to a sub-folder (slash-separated)
41
107
  - `--workspace <path>` — Workspace folder (default: current directory)
42
- - `--environment <name>` — Environment to use
43
- - `--var <KEY=VALUE>` — Override a variable (repeatable; takes highest priority)
44
- - `--include <field>` — Include extra fields (repeatable): `headers`, `cookies`, `tests`, `consoleOutput`, `report`
45
- - `--output <fmt>` — Output format: `json` or `table` (default: `json`)
108
+ - `--environment <name>` — Environment to activate
109
+ - `--var <KEY=VALUE>` — Override a variable (repeatable; highest priority)
110
+ - `--include <field>` — Extra response fields: `headers`, `cookies`, `tests`, `consoleOutput`
111
+ - `--reporter <spec>` — Generate a report (see [Reporters](#reporters))
112
+ - `--exit-code` — Exit 1 when any assertion fails
113
+ - `--output <fmt>` — `json` (default) or `table`
46
114
 
47
- ### 3. Run a Collection
115
+ ### 2. `run collection`
48
116
 
49
117
  ```bash
50
- http-forge run-collection \
51
- --collection my-api \
118
+ http-forge run collection my-api \
52
119
  --environment dev \
53
- --include perRequest \
54
- --output json
120
+ --include perRequest
55
121
  ```
56
122
 
57
123
  **Required:**
58
- - `--collection <id>` — Collection ID
124
+ - First positional arg — Collection id, slug, or display name
59
125
 
60
126
  **Optional:**
61
- - `--workspace <path>` — Workspace folder (default: current directory)
62
- - `--environment <name>` — Environment to use
63
- - `--var <KEY=VALUE>` — Override a variable (repeatable; takes highest priority)
127
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
128
+ - `--environment <name>` — Environment to activate (default: `$HTTP_FORGE_ENV`)
129
+ - `--env <name>` — Short form of `--environment`
130
+ - `--var <KEY=VALUE>` — Override a variable (repeatable)
64
131
  - `--iterations <num>` — Number of iterations (default: 1)
132
+ - `--concurrency <num>` — Parallel virtual users (default: 1)
65
133
  - `--stop-on-error` — Stop on first failure
66
- - `--delay <ms>` — Delay between requests (milliseconds)
67
- - `--include <field>` — Include extra fields (repeatable): `perRequest`, `failedOnly`, `consoleOutput`, `report`
68
- - `--output <fmt>` — Output format: `json` or `table` (default: `json`)
134
+ - `--delay <ms>` — Delay between requests in milliseconds
135
+ - `--include <field>` — Extra fields: `perRequest`, `failedOnly`, `consoleOutput`
136
+ - `--reporter <spec>` — Generate a report (see [Reporters](#reporters))
137
+ - `--exit-code` — Exit 1 when any assertion fails
138
+ - `--output <fmt>` — `json` or `table`
69
139
 
70
- ### 4. Run a Test Suite
140
+ ### 3. `run folder`
141
+
142
+ Run all requests under a specific folder within a collection.
71
143
 
72
144
  ```bash
73
- http-forge run-suite \
74
- --suite smoke-tests \
75
- --iterations 3 \
76
- --include failedOnly \
77
- --include report \
78
- --output json
145
+ http-forge run folder "Auth/Login" \
146
+ --collection my-api \
147
+ --environment staging
79
148
  ```
80
149
 
81
150
  **Required:**
82
- - `--suite <id>` — Suite ID
151
+ - First positional arg — Folder path (slash-separated, e.g. `"Auth/Login"`)
152
+ - `--collection <ref>` — Collection id, slug, or display name
83
153
 
84
154
  **Optional:**
85
- - `--workspace <path>` — Workspace folder (default: current directory)
86
- - `--environment <name>` — Environment to use
87
- - `--var <KEY=VALUE>` — Override a variable (repeatable; takes highest priority)
155
+ - `--no-recursive` — Run only direct children of the folder (default includes sub-folders)
156
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
157
+ - `--environment <name>` — Environment to activate (default: `$HTTP_FORGE_ENV`)
158
+ - `--env <name>` — Short form of `--environment`
159
+ - `--var <KEY=VALUE>` — Override a variable (repeatable)
160
+ - `--iterations <num>` — Number of iterations (default: 1)
161
+ - `--concurrency <num>` — Parallel virtual users (default: 1)
162
+ - `--stop-on-error` — Stop on first failure
163
+ - `--delay <ms>` — Delay between requests in milliseconds
164
+ - `--include <field>` — Extra fields: `perRequest`, `failedOnly`, `consoleOutput`
165
+ - `--reporter <spec>` — Generate a report (see [Reporters](#reporters))
166
+ - `--exit-code` — Exit 1 when any assertion fails
167
+ - `--output <fmt>` — `json` or `table`
168
+
169
+ ```bash
170
+ http-forge run suite smoke-tests \
171
+ --environment staging \
172
+ --reporter junit:results/junit.xml \
173
+ --exit-code
174
+ ```
175
+
176
+ **Required:**
177
+ - First positional arg — Suite name or id (case-insensitive name matching supported)
178
+
179
+ **Optional:**
180
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
181
+ - `--environment <name>` — Environment to activate (default: `$HTTP_FORGE_ENV`)
182
+ - `--env <name>` — Short form of `--environment`
183
+ - `--var <KEY=VALUE>` — Override a variable (repeatable)
88
184
  - `--iterations <num>` — Number of iterations
185
+ - `--concurrency <num>` — Parallel virtual users (default: 1)
89
186
  - `--stop-on-error` — Stop on first failure
90
- - `--delay <ms>` — Delay between requests (milliseconds)
91
- - `--include <field>` — Include extra fields (repeatable): `perRequest`, `failedOnly`, `consoleOutput`, `report`
92
- - `--output <fmt>` — Output format: `json` or `table` (default: `json`)
187
+ - `--delay <ms>` — Delay between requests in milliseconds
188
+ - `--include <field>` — Extra fields: `perRequest`, `failedOnly`, `consoleOutput`
189
+ - `--reporter <spec>` — Generate a report (see [Reporters](#reporters))
190
+ - `--exit-code` — Exit 1 when any assertion fails
191
+ - `--output <fmt>` — `json` or `table`
93
192
 
94
- ### 5. Manage MCP Server
193
+ ---
95
194
 
96
- Start, stop, or check the status of an embedded MCP (Model Context Protocol) server for AI agent integration:
195
+ ### `generate-collection`
196
+
197
+ Create an HTTP Forge collection from a **curl command**, a **Postman Collection** export, or an **OpenAPI spec**. Optionally enhance the resulting collection with AI.
97
198
 
98
199
  ```bash
99
- http-forge mcp-server start --port 3100
100
- http-forge mcp-server status --workspace .
101
- http-forge mcp-server stop --workspace .
200
+ # From a curl command
201
+ http-forge generate-collection --curl "curl -X POST https://api.example.com/users \
202
+ -H 'Authorization: Bearer sk-abc123' \
203
+ -d '{\"name\":\"Alice\"}'" \
204
+ --env dev
205
+
206
+ # From a Postman Collection v2.x export
207
+ http-forge generate-collection --postman ./MyApi.postman_collection.json
208
+
209
+ # From an OpenAPI spec — creates a collection and an environment from server URLs
210
+ http-forge generate-collection --openapi ./openapi.yaml \
211
+ --name "Payments API" --create-envs --env staging
212
+
213
+ # Any source + AI enhancement (requires OPENAI_API_KEY or ANTHROPIC_API_KEY)
214
+ http-forge generate-collection --postman ./MyApi.postman_collection.json --ai
215
+ http-forge generate-collection --openapi ./openapi.yaml --create-envs --ai
102
216
  ```
103
217
 
104
- **Actions:**
105
- - `start` — Start MCP server (default)
106
- - `stop` — Stop MCP server for the workspace
107
- - `status` — Show MCP server status for the workspace
218
+ **Sources (exactly one required):**
219
+ - `--curl <cmd>` — curl command string (quote the whole thing)
220
+ - `--postman <file>` — Postman Collection v2.x JSON file
221
+ - `--openapi <file>` — OpenAPI 3.0 spec (`.json`, `.yaml`, `.yml`)
108
222
 
109
223
  **Options:**
110
- - `--port <num>` — Port to listen on (default: 3100)
111
- - `--host <addr>` — Host to bind to (default: 127.0.0.1)
112
- - `--workspace <path>` — Workspace folder (default: current directory)
224
+ - `--name <name>` — Collection name (default: derived from source)
225
+ - `--env <name>` — `curl`: write detected vars to this env · `openapi`: create env from server URLs
226
+ - `--create-envs` — `openapi`: create environments from all server URLs
227
+ - `--ai` — Enhance the collection with AI after import (writes realistic example bodies and `pm.test()` assertions).
228
+ Requires `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`. Override model via `OPENAI_MODEL` / `ANTHROPIC_MODEL`. Force provider with `HTTP_FORGE_AI_PROVIDER=openai|anthropic`.
229
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
230
+ - `--output json|table` — Output format (default: `json`)
113
231
 
114
- ### MCP JSON-RPC Usage
232
+ ---
115
233
 
116
- After starting the server with `http-forge mcp-server start`, call the MCP endpoint at `POST /`.
234
+ ### `suggest-env`
117
235
 
118
- JSON-RPC request shape:
236
+ Scan a collection for hardcoded values (API keys, base URLs, tokens, IDs) and suggest replacing them with `{{ENV_VAR}}` placeholders. Runs dry-run by default; add `--apply` to write changes.
119
237
 
120
- ```typescript
121
- interface JsonRpcRequest {
122
- jsonrpc: '2.0';
123
- id: string | number | null;
124
- method: string;
125
- params?: Record<string, unknown>;
126
- }
238
+ ```bash
239
+ # Dry-run (heuristic rules) — see what would be replaced
240
+ http-forge suggest-env --collection my-api --output table
241
+
242
+ # Dry-run with AI detection (better recall for complex collections)
243
+ OPENAI_API_KEY=sk-... http-forge suggest-env --collection my-api --ai --output table
244
+
245
+ # Apply: replace in collection and write original values to "staging" env
246
+ http-forge suggest-env --collection my-api --apply --env staging
247
+
248
+ # Apply with AI detection
249
+ http-forge suggest-env --collection my-api --ai --apply --env staging
250
+
251
+ # Only flag values appearing in 3+ requests
252
+ http-forge suggest-env --collection my-api --min-occurrences 3 --output table
127
253
  ```
128
254
 
129
- #### Initialize
255
+ **Required:**
256
+ - `--collection <ref>` — Collection name, slug, or id
257
+
258
+ **Options:**
259
+ - `--apply` — Replace hardcoded values in the collection and write originals to the target env
260
+ - `--env <name>` — Target environment for `--apply` (default: active env)
261
+ - `--ai` — Use AI for detection instead of heuristic rules.
262
+ Requires `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`. Ignores `--min-occurrences` (AI determines relevance).
263
+ - `--min-occurrences <n>` — Only suggest values appearing in ≥ N request locations (default: 1; heuristic mode only)
264
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
265
+ - `--output json|table` — Output format (default: `json`)
266
+
267
+ ---
268
+
269
+ ### `schedule`
270
+
271
+ Generate a CI schedule configuration for running an HTTP Forge suite automatically. Outputs a **GitHub Actions workflow** file, a **cron entry**, or both — no daemon required.
130
272
 
131
273
  ```bash
132
- curl -X POST http://127.0.0.1:3100 \
133
- -H "Content-Type: application/json" \
134
- -d '{
135
- "jsonrpc": "2.0",
136
- "id": 1,
137
- "method": "initialize",
138
- "params": {}
139
- }'
274
+ # GitHub Actions workflow (default) — runs on push + every 6 hours
275
+ http-forge schedule --suite smoke-tests --env staging
276
+
277
+ # Custom cron schedule and output path
278
+ http-forge schedule --suite regression --env prod \
279
+ --cron "0 2 * * *" --output .github/workflows/nightly.yml
280
+
281
+ # Generate both a GitHub Actions workflow and a cron entry
282
+ http-forge schedule --suite smoke-tests --env staging --format both
283
+
284
+ # Print a cron entry only (no file written)
285
+ http-forge schedule --suite smoke-tests --print-cron
286
+
287
+ # Custom reporter path
288
+ http-forge schedule --suite e2e --reporter "junit:test-results/e2e.xml"
140
289
  ```
141
290
 
142
- #### List tools
291
+ **Required:**
292
+ - `--suite <name>` — Test suite name, slug, or id
293
+
294
+ **Options:**
295
+ - `--env <name>` — Environment to pass to the suite run
296
+ - `--cron <expr>` — Cron schedule expression (default: `"0 */6 * * *"` — every 6 hours)
297
+ - `--output <path>` — Output file path (default: `.github/workflows/http-forge-<suite>.yml`)
298
+ - `--reporter <spec>` — Reporter spec, e.g. `junit:results/junit.xml` (default: `junit`)
299
+ - `--no-exit-code` — Do not fail the CI job on assertion failures
300
+ - `--format github-actions|cron|both` — Output format (default: `github-actions`)
301
+ - `--print-cron` — Print a cron entry to stdout (alias for `--format cron`)
302
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
303
+
304
+ The generated GitHub Actions workflow includes: Node 20 setup, `npm install -g @http-forge/cli`, the run step with configurable reporter and exit-code gate, artifact upload (30-day retention), and an optional JUnit publish step.
305
+
306
+ ---
307
+
308
+ ### 5. Manage MCP Server
309
+
310
+ Start, stop, or check the status of an embedded MCP (Model Context Protocol) server for AI agent integration:
143
311
 
144
312
  ```bash
145
- curl -X POST http://127.0.0.1:3100 \
146
- -H "Content-Type: application/json" \
147
- -d '{
148
- "jsonrpc": "2.0",
149
- "id": 2,
150
- "method": "tools/list"
151
- }'
313
+ http-forge mcp start --port 3100
314
+ http-forge mcp status
315
+ http-forge mcp stop
152
316
  ```
153
317
 
154
- #### Call a tool
318
+ **Actions:** `start` | `stop` | `status`
319
+
320
+ **Options:**
321
+ - `--port <num>` — Port to listen on (default: 3100)
322
+ - `--host <addr>` — Host to bind to (default: 127.0.0.1)
323
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
324
+
325
+ ---
326
+
327
+ ### 6. Copy-as Code Snippet
328
+
329
+ Generate a ready-to-run code snippet for a request in cURL, JavaScript fetch, or Python:
155
330
 
156
331
  ```bash
157
- curl -X POST http://127.0.0.1:3100 \
158
- -H "Content-Type: application/json" \
159
- -d '{
160
- "jsonrpc": "2.0",
161
- "id": 3,
162
- "method": "tools/call",
163
- "params": {
164
- "name": "request__my-api__get-users",
165
- "arguments": {
166
- "environment": "dev",
167
- "include": ["tests", "report"]
168
- }
169
- }
170
- }'
332
+ http-forge copy-as \
333
+ --collection my-api \
334
+ --request get-users \
335
+ --lang curl
336
+
337
+ http-forge copy-as \
338
+ --collection my-api \
339
+ --request "Create User" \
340
+ --lang python \
341
+ --environment staging
171
342
  ```
172
343
 
173
- #### Health check
344
+ **Required:**
345
+ - `--collection <ref>` — Collection id, slug, or display name
346
+ - `--request <ref>` — Request id, slug, or display name
347
+ - `--lang <name>` — Target language: `curl`, `fetch`, `python`
348
+
349
+ **Optional:**
350
+ - `--folder <path>` — Scope resolution to a sub-folder
351
+ - `--workspace <path>` — Workspace folder (default: current directory)
352
+ - `--environment <name>` — Environment to resolve variables against
353
+
354
+ ---
355
+
356
+ ### 7. List Workspace Resources
357
+
358
+ Inspect collections, suites, environments, and requests without starting a run:
174
359
 
175
360
  ```bash
176
- curl http://127.0.0.1:3100/health
361
+ http-forge list collections
362
+ http-forge list suites --output table
363
+ http-forge list environments --workspace /path/to/project
364
+ http-forge list requests --collection my-api
365
+ http-forge list requests --collection my-api --folder Auth --output table
366
+ http-forge list folders --collection my-api
367
+ http-forge list folders --collection my-api --folder Auth
177
368
  ```
178
369
 
179
- #### Legacy compatibility endpoint
370
+ **Subcommands:** `collections` | `suites` | `environments` | `requests` | `folders`
371
+
372
+ **Options:**
373
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
374
+ - `--collection <ref>` — Required for `requests` and `folders` subcommands
375
+ - `--folder <path>` — Scope to a sub-folder (for `requests` and `folders`)
376
+ - `--output <fmt>` — `json` (default) or `table`
377
+
378
+ ---
180
379
 
181
- For non-MCP clients, a compatibility endpoint is also available:
380
+ ### 8. Manage Environment Variables
381
+
382
+ Read and write environment variables stored in the workspace config files:
182
383
 
183
384
  ```bash
184
- curl -X POST http://127.0.0.1:3100/tools/execute \
185
- -H "Content-Type: application/json" \
186
- -d '{
187
- "name": "request__my-api__get-users",
188
- "args": { "environment": "dev" }
189
- }'
190
- ```
385
+ # List all environments
386
+ http-forge env list
191
387
 
192
- Common JSON-RPC error codes:
193
- - `-32700` Parse error (invalid JSON)
194
- - `-32603` Internal error (dispatch/runtime failures, including unknown method)
388
+ # Inspect a specific environment
389
+ http-forge env get staging
390
+ http-forge env env get staging --output table
391
+ http-forge env get staging --no-values # show keys only
195
392
 
196
- ## Exit Codes
393
+ # Set a variable permanently (writes to the JSON env file)
394
+ http-forge env set staging BASE_URL https://staging.example.com
395
+ http-forge env set staging API_KEY=my-secret-key # key=value syntax
197
396
 
198
- - `0` — Success
199
- - `1` — Execution error (request failed, assertions failed, etc.)
200
- - `2` — Invalid arguments or missing required options
397
+ # Remove a variable
398
+ http-forge env unset staging OLD_VAR
399
+ ```
201
400
 
202
- ## Environment Variables
401
+ **Subcommands:** `list` | `get <name>` | `set <env> <key> <value>` | `unset <env> <key>`
203
402
 
204
- - `HTTP_FORGE_WORKSPACE` — Override default workspace folder
403
+ **Options:**
404
+ - `--workspace <path>` — Workspace folder (default: `$HTTP_FORGE_WORKSPACE` or cwd)
405
+ - `--output <fmt>` — `json` (default) or `table` (for `list` and `get`)
406
+ - `--no-values` — Show only key names, not values (for `get`)
205
407
 
206
- > **Variable priority (highest → lowest)**
207
- > 1. `--var KEY=VALUE` flags on the command line
208
- > 2. `process.env` (CI environment variables, shell exports)
209
- > 3. `<env>.local.json` credential overrides (gitignored)
210
- > 4. `<env>.json` environment file values
211
- > 5. `_global.json` / `_global.local.json` globals
408
+ > **Note:** `env set` writes permanently to the env JSON file on disk. Changes are picked up immediately by subsequent CLI runs in the same workspace.
409
+ >
410
+ > To set the active environment for a session, use the `HTTP_FORGE_ENV` environment variable instead of a CLI subcommand (e.g. `export HTTP_FORGE_ENV=staging`).
212
411
 
213
- ## Secret Providers
412
+ ---
214
413
 
215
- Reference secrets from AWS Secrets Manager, Azure Key Vault, Google Secret Manager, HashiCorp Vault, 1Password, or Doppler directly in requests using `{{secret:alias/path}}`. Credentials come from the environment (env vars, cloud identity, CLI session) — never from config. Install the relevant cloud SDK (`optionalDependencies`) for AWS/Azure/GCP; Vault/Doppler/1Password need none.
414
+ ## Reporters
216
415
 
217
- See the [Secret Providers guide](https://github.com/hsl1230/http-forge/blob/main/docs/user-guide/secret-providers.md) for setup, configuration, and CI/CD usage.
416
+ Reporters generate machine-readable or human-readable files from a run. Pass `--reporter` once per format; use the `name:path` syntax to set an explicit output path.
218
417
 
219
- ## Examples
418
+ | Spec | Effect |
419
+ |---|---|
420
+ | `--reporter html` | HTML report to the default cache location |
421
+ | `--reporter html:reports/run.html` | HTML report copied to `reports/run.html` |
422
+ | `--reporter junit` | JUnit XML to the default cache location |
423
+ | `--reporter junit:results/junit.xml` | JUnit XML copied to `results/junit.xml` |
220
424
 
221
- ### Run smoke tests on staging
425
+ Reporters are **composable** — pass multiple to produce all formats in one run:
222
426
 
223
427
  ```bash
224
- http-forge run-suite \
225
- --suite smoke-tests \
226
- --environment staging \
227
- --stop-on-error
428
+ http-forge run suite smoke-tests \
429
+ --reporter html:reports/run.html \
430
+ --reporter junit:results/junit.xml \
431
+ --exit-code
228
432
  ```
229
433
 
230
- ### Override variables at runtime
434
+ **Notes:**
435
+ - HTML reports require successful requests to produce content. Use `--reporter html` or the legacy `--include report` / `HTTP_FORGE_GENERATE_REPORTS=true` env var.
436
+ - JUnit XML is always produced when `--reporter junit` is set, even for runs with all failures (so CI tools can parse and display the failures).
437
+ - `--out <path>` is a deprecated alias for `--reporter junit:<path>` and still works but prints a warning.
231
438
 
232
- ```bash
233
- # Inject a single variable
234
- http-forge run-request \
235
- --collection my-api \
236
- --request create-user \
237
- --var BASE_URL=https://api.staging.example.com \
238
- --var API_KEY=my-secret-key
239
-
240
- # Multiple --var flags are supported
241
- http-forge run-suite \
242
- --suite smoke-tests \
243
- --environment prod \
244
- --var TIMEOUT=30000 \
245
- --var RETRY_COUNT=3
246
- ```
439
+ ---
247
440
 
248
- ### GitHub Actions / CI integration
441
+ ## CI/CD Integration
249
442
 
250
- Variables from the shell environment are automatically available as template variables in your requests:
443
+ > For a complete step-by-step guide with examples for GitHub Actions, Docker, and bare npm, see **[docs/ci-guide.md](docs/ci-guide.md)**.
444
+ >
445
+ > For **AI-driven failure analysis** (Claude automatically diagnoses failures and posts results as a PR comment), see [Option E — AI-driven analysis](docs/ci-guide.md#option-e--ai-driven-analysis-mcp--claude) in the CI guide.
446
+
447
+ ### Quick start — GitHub Actions
251
448
 
252
449
  ```yaml
253
450
  - name: Run API tests
254
451
  run: |
255
- http-forge run-suite \
256
- --suite smoke-tests \
452
+ http-forge run suite smoke-tests \
453
+ --workspace ./http-forge-assets \
257
454
  --environment staging \
258
- --stop-on-error \
259
- --include report \
260
- --output json
455
+ --reporter junit:test-results/junit.xml \
456
+ --exit-code
261
457
  env:
262
458
  API_KEY: ${{ secrets.API_KEY }}
263
- BASE_URL: ${{ vars.STAGING_BASE_URL }}
459
+
460
+ - name: Upload results
461
+ if: always()
462
+ uses: actions/upload-artifact@v4
463
+ with:
464
+ name: api-test-results
465
+ path: test-results/junit.xml
264
466
  ```
265
467
 
266
- You can also pass secrets explicitly with `--var` to override environment file values:
468
+ ### Using the composite action
267
469
 
268
470
  ```yaml
269
- - name: Run integration tests
270
- run: |
271
- http-forge run-collection \
272
- --collection my-api \
273
- --environment prod \
274
- --var API_KEY=${{ secrets.PROD_API_KEY }} \
275
- --var DB_HOST=${{ secrets.DB_HOST }}
471
+ - uses: http-forge/http-forge.cli@main
472
+ with:
473
+ suite: smoke-tests
474
+ workspace: ./http-forge-assets
475
+ environment: staging
476
+ reporters: 'junit:test-results/junit.xml'
477
+ extra_args: '--var API_KEY=${{ secrets.API_KEY }}'
276
478
  ```
277
479
 
278
- ### Execute collection with custom variables
480
+ ### Using Docker
279
481
 
280
482
  ```bash
281
- http-forge run-collection \
282
- --collection my-api \
283
- --environment dev \
284
- --var BASE_URL=http://localhost:3000
483
+ docker run --rm \
484
+ -v "$PWD/http-forge-assets:/workspace" \
485
+ -v "$PWD/results:/results" \
486
+ ghcr.io/http-forge/cli:latest \
487
+ run suite smoke-tests \
488
+ --reporter junit:/results/junit.xml \
489
+ --exit-code
285
490
  ```
286
491
 
287
- ### Run same test 5 times with delays
492
+ ---
288
493
 
289
- ```bash
290
- http-forge run-collection \
291
- --collection my-api \
292
- --iterations 5 \
293
- --delay 1000 \
294
- --stop-on-error
295
- ```
494
+ ## Variables & Secrets
495
+
496
+ **Priority (highest → lowest):**
497
+ 1. `--var KEY=VALUE` CLI flags
498
+ 2. `process.env` (CI env vars, shell exports)
499
+ 3. `<env>.local.json` credential overrides (gitignored)
500
+ 4. `<env>.json` environment file
501
+ 5. `_global.json` / `_global.local.json` globals
296
502
 
297
- ### Get JSON output for scripting
503
+ **Injecting secrets at runtime:**
298
504
 
299
505
  ```bash
300
- http-forge run-request \
301
- --collection api \
302
- --request login \
303
- --output json | jq '.allPassed'
506
+ http-forge run suite smoke-tests \
507
+ --var API_KEY=$CI_API_KEY \
508
+ --var BASE_URL=https://staging.example.com
304
509
  ```
305
510
 
511
+ **Secret providers** — reference secrets from AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, HashiCorp Vault, 1Password, or Doppler using `{{secret:alias/path}}`. Credentials come from the environment (env vars, cloud identity, CLI session) — never hardcoded.
512
+
513
+ ---
514
+
515
+ ## Exit Codes
516
+
517
+ | Code | Meaning |
518
+ |---|---|
519
+ | `0` | Success — all assertions passed (or `--exit-code` not set) |
520
+ | `1` | Test failures — one or more assertions failed (only when `--exit-code` is set) |
521
+ | `2` | Invalid arguments, missing required options, or runtime error |
522
+
523
+ ---
524
+
306
525
  ## Output Format
307
526
 
308
- ### JSON Format (default)
527
+ ### JSON (default)
309
528
 
310
529
  ```json
311
530
  {
312
- "request": "Get Users",
313
- "status": 200,
314
- "ok": true,
315
- "duration": "145ms",
316
- "allPassed": true,
317
- "assertions": [
531
+ "suite": "Smoke Tests",
532
+ "environment": "staging",
533
+ "summary": {
534
+ "total": 12,
535
+ "passed": 11,
536
+ "failed": 1,
537
+ "allPassed": false
538
+ },
539
+ "failedRequests": [
318
540
  {
319
- "name": "Status is 200",
320
- "passed": true
541
+ "name": "Create Order",
542
+ "status": 500,
543
+ "duration": "312ms",
544
+ "failedTests": [{ "name": "Status is 201", "message": "expected 500 to equal 201" }]
321
545
  }
322
- ]
546
+ ],
547
+ "junitReport": { "path": "/tmp/.http-forge-cache/results/smoke-tests/run-20260626-141501/junit.xml" }
323
548
  }
324
549
  ```
325
550
 
326
- ### Table Format
551
+ ### Table
327
552
 
328
553
  ```
329
- Request: Get Users
330
- Status: 200
331
- OK: true
332
- Time: 145ms
333
- Tests: ✅ All passed
554
+ Result: { suite: 'Smoke Tests', summary: { total: 12, passed: 11, failed: 1 } }
334
555
  ```
335
556
 
336
- ## Error Handling
557
+ ---
337
558
 
338
- All errors are written to stderr with detailed messages:
559
+ ## MCP Server — JSON-RPC Usage
339
560
 
340
- ```bash
341
- $ http-forge run-request --collection missing --request test 2>&1
342
- Error: Collection "missing" not found
343
- ```
344
-
345
- ## Testing
346
-
347
- Run tests to verify CLI functionality:
561
+ After starting the server with `http-forge mcp start`, call `POST /`.
348
562
 
349
563
  ```bash
350
- npm test
351
- ```
352
-
353
- ## Development
354
-
355
- ### Build
564
+ # Initialize
565
+ curl -X POST http://127.0.0.1:3100 \
566
+ -H "Content-Type: application/json" \
567
+ -d '{ "jsonrpc":"2.0","id":1,"method":"initialize" }'
356
568
 
357
- ```bash
358
- npm run build
359
- ```
569
+ # List tools
570
+ curl -X POST http://127.0.0.1:3100 \
571
+ -H "Content-Type: application/json" \
572
+ -d '{ "jsonrpc":"2.0","id":2,"method":"tools/list" }'
360
573
 
361
- ### Watch Mode
574
+ # Call a tool
575
+ curl -X POST http://127.0.0.1:3100 \
576
+ -H "Content-Type: application/json" \
577
+ -d '{
578
+ "jsonrpc":"2.0","id":3,"method":"tools/call",
579
+ "params":{
580
+ "name":"run_request",
581
+ "arguments":{ "collection":"my-api","request":"get-users","environment":"dev" }
582
+ }
583
+ }'
362
584
 
363
- ```bash
364
- npm run dev
585
+ # Health check
586
+ curl http://127.0.0.1:3100/health
365
587
  ```
366
588
 
367
- ### Clean
368
-
369
- ```bash
370
- npm run clean
371
- ```
589
+ ---
372
590
 
373
591
  ## Architecture
374
592
 
375
- The CLI delegates to HTTP Forge Core APIs:
376
- - **Direct Execution**: Uses `@http-forge/core` direct execution APIs
377
- - **Service Container**: Bootstraps Node.js-specific adapters (file I/O, secrets, etc.)
378
- - **Output Formatting**: Converts execution results to JSON or human-readable format
379
- - **Error Handling**: Consistent exit codes and error messages
593
+ The CLI delegates to `@http-forge/core` direct execution APIs. The service container bootstraps Node.js-specific adapters (file I/O, secrets). Output is formatted to JSON or table. All errors go to stderr; the machine-readable result goes to stdout only.
594
+
595
+ See [@http-forge/core README](../http-forge.core/README.md) for the full API reference.
380
596
 
381
- See [@http-forge/core README](../http-forge.core/README.md) for API documentation.