@http-forge/core 1.0.2 → 1.0.3

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.
@@ -14,7 +14,7 @@
14
14
  * user customizations are never silently lost.
15
15
  */
16
16
  /** Current template version. Bump when `buildAgentsMdContent()` changes. */
17
- export declare const AGENTS_MD_VERSION = 4;
17
+ export declare const AGENTS_MD_VERSION = 5;
18
18
  export declare const AGENTS_MD_FILENAME = "AGENTS.md";
19
19
  export declare const AGENTS_MD_BACKUP_FILENAME = "AGENTS.md.bak";
20
20
  /** Absolute path of the guide inside a `.http-forge/` directory. */
@@ -51,6 +51,11 @@ export declare function refreshAgentsMd(forgeDir: string): AgentsMdRefreshResult
51
51
  * file was created, false when it already existed (never overwrites).
52
52
  */
53
53
  export declare function ensureAgentsMdFile(forgeDir: string): boolean;
54
+ /**
55
+ * Ensure the supporting files that make a `.http-forge` workspace usable from
56
+ * VS Code are present. This is write-once: existing files are never overwritten.
57
+ */
58
+ export declare function ensureForgeWorkspaceFiles(forgeDir: string): void;
54
59
  /**
55
60
  * Build the current `.http-forge/AGENTS.md` template. The file teaches AI
56
61
  * assistants (GitHub Copilot, Claude, Cursor, …) the folder layout and schema
@@ -30,6 +30,11 @@ export type ConsoleOutputCallback = (output: string[], source: ConsoleOutputSour
30
30
  * pre-request/post-response script chain support.
31
31
  */
32
32
  export interface ICollectionRequestExecutor {
33
+ /**
34
+ * Set the current data-file row for a data-driven run. Exposed to scripts
35
+ * as `pm.iterationData` and the legacy `data` object.
36
+ */
37
+ setIterationData(iterationData: Record<string, any>): void;
33
38
  /**
34
39
  * Execute a request with full Postman parity.
35
40
  *
@@ -39,6 +39,19 @@ export declare class CollectionRequestExecutor implements ICollectionRequestExec
39
39
  private readonly webSocketClient?;
40
40
  private readonly socketIoClient?;
41
41
  constructor(httpService: IHttpRequestService, scriptExecutor: IScriptExecutor, envConfigService: IEnvironmentConfigService, requestPreparer: IRequestPreparer, environment: string, cookieJar?: ICookieJar | undefined, collectionScripts?: RequestScripts | undefined, folderScriptsChain?: (RequestScripts | RequestScripts[]) | undefined, onConsoleOutput?: ConsoleOutputCallback | undefined, collectionName?: string | undefined, collectionAuth?: RequestAuth | undefined, iteration?: number | undefined, iterationCount?: number | undefined, webSocketClient?: IWebSocketClient | undefined, socketIoClient?: ISocketIoClient | undefined);
42
+ private collectionVariables;
43
+ private iterationData;
44
+ /**
45
+ * Seed the `pm.collectionVariables` scope for this execution. Callers that
46
+ * own a collection should pass the collection file values plus any runtime
47
+ * locals so scripts can read them and unsets can be detected.
48
+ */
49
+ setCollectionVariables(collectionVariables: Record<string, string>): void;
50
+ /**
51
+ * Seed the `pm.iterationData` scope for data-driven runs. The row is the
52
+ * raw data-file row (Postman-compatible), not the merged variable context.
53
+ */
54
+ setIterationData(iterationData: Record<string, any>): void;
42
55
  /**
43
56
  * Execute a request with full Postman parity.
44
57
  */
@@ -106,7 +106,9 @@ export interface PreRequestScriptResult {
106
106
  * Globals are excluded because they are tracked separately via runtimeGlobals in createResolver,
107
107
  * and including the session snapshot would risk shadowing a fresh value from a previous request.
108
108
  */
109
- localVariables?: Record<string, string>;
109
+ nonGlobalVariables?: Record<string, string>;
110
+ /** Only the request-local `pm.variables` scope writes from this script phase. */
111
+ requestLocalWrites?: Record<string, string>;
110
112
  modifiedCollectionVariables?: Record<string, string>;
111
113
  modifiedGlobals?: Record<string, string>;
112
114
  modifiedEnvironmentVariables?: Record<string, string>;
@@ -123,7 +125,9 @@ export interface PostResponseScriptResult {
123
125
  testResults: TestAssertion[];
124
126
  consoleOutput?: string[];
125
127
  modifiedVariables?: Record<string, string>;
126
- localVariables?: Record<string, string>;
128
+ nonGlobalVariables?: Record<string, string>;
129
+ /** Only the request-local `pm.variables` scope writes from this script phase. */
130
+ requestLocalWrites?: Record<string, string>;
127
131
  modifiedEnvironmentVariables?: Record<string, string>;
128
132
  modifiedGlobals?: Record<string, string>;
129
133
  modifiedCollectionVariables?: Record<string, string>;
@@ -154,6 +158,18 @@ export interface IScriptExecutor {
154
158
  * (Postman-compatible behavior)
155
159
  */
156
160
  createRequestSession(context: PreRequestScriptContext): IRequestScriptSession;
161
+ /**
162
+ * Start a run-scoped module refresh boundary.
163
+ *
164
+ * Custom module files (and their local dependencies) are re-read from disk
165
+ * for the first request of a run, then cached for the remainder of that run
166
+ * so all requests in the run use one consistent version.
167
+ */
168
+ beginRun?(): void;
169
+ /**
170
+ * End a run-scoped module refresh boundary.
171
+ */
172
+ endRun?(): void;
157
173
  }
158
174
  /**
159
175
  * Request Script Session Interface
@@ -99,7 +99,7 @@ export declare class ModuleLoader {
99
99
  hasCustomModules(): boolean;
100
100
  /** Get list of available module names (built-ins + workspace) */
101
101
  getAvailableModules(): string[];
102
- /** Clear module cache */
102
+ /** Clear module cache and the Node require cache for this module directory */
103
103
  clearCache(): void;
104
104
  /** Get cache statistics */
105
105
  getCacheStats(): {
@@ -39,13 +39,14 @@ export declare class RequestScriptSession implements IRequestScriptSession {
39
39
  private modifiedRequest;
40
40
  private assertions;
41
41
  private consoleMessages;
42
- private _variables;
43
- private _collectionVariables;
44
- private _globals;
45
- private _environmentVariables;
46
- private _liveEnvironmentScope;
47
- private _liveGlobalsScope;
48
- private _liveCollectionScope;
42
+ private _initialVariables;
43
+ private _initialCollectionVariables;
44
+ private _initialGlobals;
45
+ private _initialEnvironment;
46
+ private _runtimeEnvironment;
47
+ private _runtimeGlobals;
48
+ private _runtimeCollectionVariables;
49
+ private _runtimeVariables;
49
50
  private _nextRequest;
50
51
  private _skipRequest;
51
52
  private _visualizerData;
@@ -27,9 +27,23 @@ export declare class ScriptExecutor implements IScriptExecutor {
27
27
  private readonly secretRegistry?;
28
28
  private readonly scopeMode;
29
29
  private readonly scriptTimeoutMs;
30
- private readonly moduleLoader;
30
+ private readonly baseModuleLoader;
31
+ private runModuleLoader;
32
+ private runDepth;
33
+ private readonly modulePaths;
31
34
  private readonly variableScopes;
32
35
  constructor(httpService?: IHttpRequestService | undefined, modulePaths?: string[], secretRegistry?: SecretResolverRegistry | undefined, scopeMode?: 'shared' | 'isolated', scriptTimeoutMs?: number);
36
+ /**
37
+ * Start a run-scoped module loader. The first beginRun() in a run creates a
38
+ * fresh loader (and clears cached local module files); nested calls reuse it.
39
+ */
40
+ beginRun(): void;
41
+ /**
42
+ * End a run-scoped module loader. When the outermost run finishes, the next
43
+ * beginRun() will create a fresh loader.
44
+ */
45
+ endRun(): void;
46
+ private get moduleLoader();
33
47
  /**
34
48
  * Create a request execution session
35
49
  * Factory method implementing IScriptExecutor
@@ -108,10 +108,14 @@ export interface SuiteConfig {
108
108
  delayBetweenRequests: number;
109
109
  /** Stop execution on first error */
110
110
  stopOnError: boolean;
111
- /** Read variables from shared session */
112
- readFromSharedSession: boolean;
113
- /** Write variables to shared session */
114
- writeToSharedSession: boolean;
111
+ /** @deprecated Use `loadPersistedEnvironmentValues`. Kept for backward compatibility. */
112
+ readFromSharedSession?: boolean;
113
+ /** @deprecated Use `usePersistentCookieJar`. Kept for backward compatibility. */
114
+ writeToSharedSession?: boolean;
115
+ /** Load persisted environment Current Values from previous runs */
116
+ loadPersistedEnvironmentValues?: boolean;
117
+ /** Use the persistent cookie jar across runs */
118
+ usePersistentCookieJar?: boolean;
115
119
  /** Data file path for variable injection */
116
120
  dataFilePath?: string;
117
121
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Documentation tool handlers — list and fetch HTTP Forge documentation.
3
+ *
4
+ * Lets MCP-connected AI agents discover and read the user-guide docs on demand.
5
+ */
6
+ import type { McpToolHandler } from './types';
7
+ export declare const documentationHandlers: McpToolHandler[];
@@ -15,6 +15,8 @@ export interface McpDispatchServices {
15
15
  environmentConfig: import('../../types/environment-config').IEnvironmentConfigService;
16
16
  /** Absolute path to the workspace folder — used by AI-native tools. */
17
17
  workspaceFolder?: string;
18
+ /** Absolute path to bundled documentation (e.g. extension resources/docs) — used by documentation tools. */
19
+ docsPath?: string;
18
20
  /**
19
21
  * Optional AI provider. When supplied, AI-flavoured tools (e.g. assertion
20
22
  * suggestion, failure explanation) call a real LLM and fall back to their
@@ -254,6 +254,8 @@ export declare const GENERIC_TOOL_NAMES: {
254
254
  readonly unsetEnvironmentVariable: "unset_environment_variable";
255
255
  readonly setGlobalVariable: "set_global_variable";
256
256
  readonly getGlobals: "get_globals";
257
+ readonly listDocumentation: "list_documentation";
258
+ readonly getDocumentation: "get_documentation";
257
259
  readonly scaffoldCollectionFromOpenApi: "scaffold_collection_from_openapi";
258
260
  readonly suggestAssertions: "suggest_assertions";
259
261
  readonly explainFailure: "explain_failure";
@@ -0,0 +1,313 @@
1
+ <!-- http-forge-agents-md-version: {{VERSION}} -->
2
+ # HTTP Forge — AI Agent Guide
3
+
4
+ This folder is the **HTTP Forge workspace root**. Do not create a nested `.http-forge/`.
5
+
6
+ > **Copilot tip:** Add `See .http-forge/AGENTS.md for the HTTP Forge AI guide.` to `.github/copilot-instructions.md`.
7
+ > **Refresh:** `http-forge refresh-agents-md --apply` (backs up to `AGENTS.md.bak`).
8
+
9
+ ---
10
+
11
+ ## Quick Reference
12
+
13
+ ### Most-used commands
14
+ ```
15
+ http-forge run collection <name> --env <env> --json
16
+ http-forge run suite <name> --json
17
+ http-forge run request <name> --collection <ref> --json
18
+ http-forge discover --path <project> --output json
19
+ http-forge generate-suite --path <project> --collection <ref> [--run]
20
+ http-forge architect "intent" --apply
21
+ http-forge qa --path <project> --collection <ref> --base-url <url>
22
+ http-forge drift --path <project>
23
+ ```
24
+
25
+ ### Key paths
26
+ ```
27
+ assets/collections/{slug}/request.json — request definition
28
+ assets/collections/{slug}/scripts/post-response.js — assertions (pm.test)
29
+ assets/environments/{env}.json — environment variables
30
+ assets/suites/{name}.suite.json — test suite
31
+ .http-forge/knowledge/**/*.md — business context for AI
32
+ ```
33
+
34
+ ### Template syntax
35
+ ```
36
+ {{variableName}} — variable
37
+ {{variable | upper | trim}} — filter chain
38
+ {{$guid}} / {{$timestamp}} — dynamic variable
39
+ {{variable | date:'YYYY-MM-DD'}} — filter with argument
40
+ ```
41
+
42
+ ### Script globals
43
+ `pm` (also `ctx`, `hf`), `request`, `response`, `responseBody`, `tests`, `postman`, `CryptoJS`, `moment`, `_` (lodash), `querystring`, `require`, `console`, `Buffer`, `URL`, `atob`/`btoa`
44
+
45
+ ---
46
+
47
+ ## Decision Tree
48
+
49
+ | Task | Approach |
50
+ |---|---|
51
+ | Discover structure | Read JSON files directly (zero token cost) |
52
+ | Execute request/collection/suite | CLI if installed (`http-forge run ...`), else MCP (`run_request`, etc.) |
53
+ | Async/long-running execution | MCP with `async: true`, poll `get_run_status` |
54
+ | Diagnose failures / suggest assertions | MCP `explain_failure`, `suggest_assertions` |
55
+ | Design new API from intent | CLI `http-forge architect` or MCP `design_api_from_intent` |
56
+ | Verify existing backend E2E | CLI `http-forge qa` or MCP `qa_api` |
57
+ | Discover endpoints from source | CLI `http-forge discover` or MCP `create_request_from_endpoint` |
58
+
59
+ **Rule:** Never use MCP/CLI to discover structure — read the JSON files directly.
60
+
61
+ ---
62
+
63
+ ## Workflow: Design → Discover → Generate → Edit → Run → Report → Fix
64
+
65
+ 1. **Design** — create API manually or from intent: `http-forge architect "..." --apply` / MCP `design_api_from_intent`
66
+ 2. **Discover** — scan backend source: `http-forge discover --path <project>` / MCP `create_request_from_endpoint`
67
+ 3. **Generate** — endpoints → requests/suites/flows: `http-forge generate-suite --path <project> --collection <ref>` / MCP `generate_test_suite`
68
+ 4. **Edit** — refine requests, bodies, assertions, environments (direct file edit, zero token cost)
69
+ 5. **Run** — execute: `http-forge run collection <name> --env <env> --json` / MCP `run_collection`
70
+ 6. **Report** — inspect results: `--include report` (HTML) / MCP `get_run_summary`, `explain_failure`
71
+ 7. **Fix** — heal assertions (`heal_assertions`), regenerate stale suites (`propose_update`), re-run
72
+
73
+ ---
74
+
75
+ ## Folder Structure
76
+
77
+ ```
78
+ assets/
79
+ collections/{slug}/
80
+ collection.json (id, name, variables, auth, order)
81
+ scripts/ (pre-request.js, post-response.js)
82
+ {folder-slug}/
83
+ folder.json
84
+ {request-slug}/
85
+ request.json (method, url, headers, auth, body, scripts…)
86
+ body.json / body.txt / body.graphql
87
+ doc.md (business docs, fed to AI)
88
+ scripts/ (pre-request.js, post-response.js)
89
+ environments/
90
+ _global.json (global vars + defaultHeaders)
91
+ {env}.json (per-env vars)
92
+ {env}.local.json (gitignored overrides)
93
+ suites/
94
+ {name}.suite.json (test suite with control-flow nodes)
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Business Knowledge (`.http-forge/knowledge/`)
100
+
101
+ Drop markdown files into `.http-forge/knowledge/` (any depth). All `*.md` files are loaded and included in AI prompts, along with `README.md` and `AGENTS.md`. Per-request docs can live as `doc.md` next to `request.json`.
102
+
103
+ ---
104
+
105
+ ## Code & Docs in Same Workspace
106
+
107
+ Before generating tests, read the workspace for requirements:
108
+ 1. `README.md`, `docs/**`, `openapi.*` — contracts and ACs.
109
+ 2. `.http-forge/knowledge/**/*.md`, `doc.md` — Confluence exports, Jira ACs, ADRs.
110
+ 3. API source code — route/controller files, DTOs, auth middleware (ground truth for paths, methods, status codes, validation rules).
111
+ 4. Derive tests from what you read; name sources (file + AC id) in request descriptions.
112
+ 5. When code and docs disagree, prefer implementation but flag drift to user.
113
+
114
+ ---
115
+
116
+ ## JSON Schemas
117
+
118
+ Every file has a `$schema` field. Schema base: `https://raw.githubusercontent.com/hsl1230/http-forge/main/resources/`
119
+ Files: `collection.schema.json`, `folder.schema.json`, `request.schema.json`, `environment.schema.json`, `global-environment.schema.json`, `suite.schema.json`
120
+
121
+ ---
122
+
123
+ ## Authoring by Direct File Editing
124
+
125
+ - **Create request:** create dir `assets/collections/{slug}/{folder}/{request}/`, write `request.json`, add slug to parent `order`.
126
+ - **Edit request:** read `request.json`, modify, write back. Variables: `{{name}}`. Filters: `{{value | upper}}`.
127
+ - **Bulk update:** find-and-replace across `assets/collections/`.
128
+ - **Environment:** edit `assets/environments/{env}.json`.
129
+ - **Suite:** write/edit `assets/suites/{name}.suite.json` (nodes: request, block, if/elseif/else, for, while, switch, script).
130
+
131
+ ---
132
+
133
+ ## Test Generation Best Practices
134
+
135
+ ### Collection requests (smoke)
136
+ - 1-2 assertions: status code + schema shape. Keep bodies minimal.
137
+ - Assert status first, then Content-Type, then top-level fields. No volatile fields (timestamps, IDs).
138
+
139
+ ### Test suites (integration/E2E/acceptance/regression)
140
+ - Suites reference requests by `collectionId` + `requestId` (no duplication).
141
+ - **Integration/E2E (CRUD):** request nodes in sequence, pass IDs via `pm.variables`/`pm.environment`, always cleanup + verify 404.
142
+ - **Acceptance:** one request node per AC, full assertions on status/body/error shapes, AC ID in test name.
143
+ - **Regression:** block/if nodes gating by env/flag; for/while for pagination.
144
+ - **Sanity:** minimal status + Content-Type, health-check endpoints, <1s.
145
+ - **Data-driven:** iterations + CSV/JSON data file; read via `pm.iterationData.toObject()`.
146
+
147
+ ### Assertion depth
148
+ - Collection request: status + top-level schema.
149
+ - Suite node: full AC verification (field values, error messages, headers).
150
+ - Use `pm.response.to.have.jsonSchema(...)` for contract checks.
151
+
152
+ ### Naming & traceability
153
+ - Requests: `GET /users/:id`. Suite nodes: `1. Create user`, `2. Get user`.
154
+ - Store AC IDs in `description` or `doc.md`. Mark generated suites with `ai_generated: true` + `derived_from`.
155
+
156
+ ---
157
+
158
+ ## AI Test Generation
159
+
160
+ ### Auto-inferable (do not ask)
161
+ Endpoints, schemas, auth, params, env vars, base URL, business rules (from code/docs/knowledge), test data.
162
+
163
+ ### Must ask user
164
+ Test types, ACs (if not in code), edge-case scope, target environment, auth credentials, CI/CD context, iteration data file, scope (all or subset).
165
+
166
+ ### Prompt template
167
+ ```
168
+ Generate tests for [endpoint or "all discovered endpoints"].
169
+ Infer from code/docs: endpoints, schemas, auth, business context.
170
+ Confirm: 1) test types 2) environment 3) auth 4) edge cases 5) ACs 6) data file
171
+ Constraints: collection requests = smoke only; suites = full AC verification; mark ai_generated: true; use pm.* API only
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Scripts & Assertions
177
+
178
+ ### Template
179
+ ```javascript
180
+ pm.test('Status is 200', () => pm.response.to.have.status(200));
181
+ pm.test('Content-Type is JSON', () => pm.response.to.have.header('Content-Type', /application\/json/));
182
+ pm.test('Has required fields', () => {
183
+ const json = pm.response.json();
184
+ pm.expect(json).to.have.property('id');
185
+ pm.expect(json).to.have.property('name');
186
+ });
187
+ ```
188
+
189
+ ### Expect chain reference
190
+ - `pm.response.to.have.status(code)` — HTTP status
191
+ - `pm.response.to.have.header(name, value?)` — header exists/equals
192
+ - `pm.response.to.have.body(value?)` / `.jsonBody(value?)` / `.jsonSchema(schema)`
193
+ - `pm.response.to.be.ok / .success / .error / .clientError / .serverError`
194
+ - `pm.expect(v).to.equal(x)` / `.eql(x)` / `.have.property(n, v?)` / `.have.jsonSchema(s)`
195
+ - `pm.expect(v).to.be.ok / .true / .false / .null / .empty` / `.to.not...`
196
+ - `pm.response.responseTime` (ms), `.json()`, `.text()`, `.getHeader(name)`
197
+ - `pm.response.cookies.get(name)` / `.one(name)` / `.has(name)` / `.toObject()`
198
+ - `pm.execution.setNextRequest(name)` / `.skipRequest()` / `.runRequest(target, cb?)`
199
+ - `pm.visualizer.set(template, data)` / `.clear()`
200
+ - `pm.test(name, fn)` / `.skip()` / `.fail()` / `.index()`
201
+ - `pm.setNextRequest(name)` (top-level alias)
202
+
203
+ ### Auth & variables
204
+ - `pm.environment.get/set/has/unset/clear/toObject/replaceIn`
205
+ - `pm.globals.*`, `pm.collectionVariables.*`, `pm.variables.*` (merged), `pm.iterationData`
206
+ - `pm.cookies.get/set/has/list/toObject/jar`
207
+ - `pm.request` (method, url, body, headers), `pm.response` (code, status, body, headers, cookies, responseTime)
208
+ - Legacy: `postman.setGlobalVariable()`, `postman.setEnvironmentVariable()`, `postman.getResponseHeader()`
209
+
210
+ ### Template syntax
211
+ - `{{variableName}}` — variable
212
+ - `{{value | upper | trim}}` — filter chain
213
+ - `{{$guid}}`, `{{$timestamp}}` — dynamic variables
214
+ - `{{variable | date:'YYYY-MM-DD'}}` — filter with argument
215
+
216
+ ---
217
+
218
+ ## Recipes (step-by-step)
219
+
220
+ ### Generate a collection from an OpenAPI spec
221
+ 1. `http-forge import openapi spec.yaml --collection "My API"` (or MCP `scaffold_collection_from_openapi`)
222
+ 2. Review generated requests in `assets/collections/{slug}/`
223
+ 3. Run: `http-forge run collection "My API" --env dev --json`
224
+
225
+ ### Generate tests for a discovered backend
226
+ 1. `http-forge discover --path ./backend --output json` (see endpoints)
227
+ 2. `http-forge qa --path ./backend --collection "My API" --base-url http://localhost:3000` (one-shot: discover → generate → run → report)
228
+ 3. Or step by step: `http-forge generate-suite --path ./backend --collection "My API" --run`
229
+ 4. Review generated suites in `assets/suites/`, refine assertions
230
+
231
+ ### Generate a collection from natural language (AI)
232
+ 1. MCP: `design_api_from_intent(intent: "I need a shopping cart with products and checkout")`
233
+ 2. Review the designed OpenAPI spec + collection + suite
234
+ 3. Pass `apply: true` to persist the suite and byproducts
235
+ 4. Or CLI: `http-forge architect "I need a shopping cart" --apply`
236
+
237
+ ### Create an environment
238
+ 1. Create `assets/environments/dev.json` with `{ "name": "dev", "variables": { "baseUrl": "http://localhost:3000" } }`
239
+ 2. Or use MCP: `create_environment(name: "dev")` then `set_environment_variable`
240
+ 3. Use `{{baseUrl}}` in requests; reference with `--env dev`
241
+
242
+ ### Write assertions for a request
243
+ 1. Use MCP `suggest_assertions(collection, request)` for AI-generated assertions
244
+ 2. Or write manually in `post-response.js`:
245
+ ```javascript
246
+ pm.test('Status is 200', () => pm.response.to.have.status(200));
247
+ pm.test('Has id', () => pm.expect(pm.response.json()).to.have.property('id'));
248
+ ```
249
+ 3. Use `pm.response.json()` to parse, `pm.expect().to.equal()` for values
250
+
251
+ ### Fix a failing request
252
+ 1. Run: `http-forge run request <name> --collection <ref> --json`
253
+ 2. Check status, headers, body in output
254
+ 3. MCP: `explain_failure` for AI root-cause analysis
255
+ 4. MCP: `heal_assertions` to auto-fix broken assertions
256
+ 5. Fix and re-run
257
+
258
+ ### Generate a test suite from discovered endpoints
259
+ 1. `http-forge generate-suite --path ./backend --collection "My API"`
260
+ 2. Review `assets/suites/{name}.suite.json`
261
+ 3. Run: `http-forge run suite <name> --json`
262
+ 4. Add assertions to request `post-response.js` files
263
+
264
+ ---
265
+
266
+ ## How AI Should Run Tests
267
+
268
+ ### Decision: CLI vs MCP
269
+
270
+ | Situation | Use |
271
+ |---|---|
272
+ | CLI installed + shell access | CLI (lower token cost) |
273
+ | No CLI or no shell | MCP tools |
274
+ | Async / long-running | MCP with `async: true`, poll `get_run_status` |
275
+ | Failure diagnosis / assertions | MCP `explain_failure`, `suggest_assertions` |
276
+
277
+ **Rule:** Never use MCP/CLI to discover structure — read JSON files directly.
278
+
279
+ ### CLI commands
280
+ ```
281
+ http-forge run collection <name> --env <env> --json
282
+ http-forge run suite <name> --json
283
+ http-forge run request <name> --collection <ref> --json
284
+ http-forge run folder <path> --collection <ref> --json
285
+ http-forge discover --path <project> --output json
286
+ http-forge generate-suite --path <project> --collection <ref> [--run]
287
+ http-forge architect "intent" --apply
288
+ http-forge qa --path <project> --collection <ref> --base-url <url>
289
+ http-forge drift --path <project>
290
+ http-forge refresh-agents-md --apply
291
+ ```
292
+ Add `--include report` for HTML report. Add `--exit-code` for CI.
293
+
294
+ ### MCP tools
295
+ - **Execution:** `run_request`, `run_folder`, `run_collection`, `run_suite` (add `async: true`)
296
+ - **Polling:** `get_run_status`, `get_run_summary`, `get_failed_requests`, `get_request_result`, `cancel_run`
297
+ - **Analysis:** `explain_failure`, `suggest_assertions`, `analyze_coverage`, `ai_analyze_coverage`
298
+ - **Discovery:** `create_request_from_endpoint`, `generate_test_suite`, `suggest_workflow`, `generate_workflow`, `check_drift`, `propose_update`
299
+ - **QA:** `qa_api`
300
+ - **Design:** `design_api_from_intent`
301
+ - **Management:** `list_collections`, `list_requests`, `get_request`, `create_request`, `update_request`, `create_suite`, `add_suite_requests`
302
+
303
+ ### Reports
304
+ - CLI: `--include report` (HTML) or `--reporter junit` (JUnit XML)
305
+ - MCP: pass `include: ["report"]`, open `report.uri`
306
+
307
+ ---
308
+
309
+ ## Documentation
310
+
311
+ Key docs: https://github.com/hsl1230/http-forge/tree/main/docs/user-guide
312
+ Script API types: `.http-forge/assets/http-forge-globals.d.ts`
313
+ `;