@http-forge/core 0.6.0 → 0.6.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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * AI Provider Interface
3
+ *
4
+ * Platform-agnostic abstraction for text-completion AI.
5
+ * Implementations:
6
+ * - VS Code extension: CopilotAiProvider (wraps vscode.lm)
7
+ * - CLI: OpenAiProvider / AnthropicProvider (plain HTTP)
8
+ */
9
+ /** Minimal interface required by all AI-powered core utilities. */
10
+ export interface IAiProvider {
11
+ /**
12
+ * Send a single user prompt and return the full completion text.
13
+ * Implementations should throw on hard failures; the caller handles retries.
14
+ */
15
+ complete(prompt: string): Promise<string>;
16
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * AI Environment Variable Suggester (platform-agnostic)
3
+ *
4
+ * Uses any IAiProvider to scan a collection for hardcoded values and produce
5
+ * EnvSuggestion objects — the same shape returned by the rule-based suggester
6
+ * in env-suggester.ts, so apply logic is shared.
7
+ *
8
+ * Platform-independent: no Node.js or VS Code dependency.
9
+ */
10
+ import type { Collection } from '../../types/collection';
11
+ import type { IAiProvider } from '../ai/ai-provider';
12
+ import type { EnvSuggestion } from './env-suggester';
13
+ /**
14
+ * Ask the AI to scan a collection for hardcoded values that should become
15
+ * environment variables. Returns suggestions in the same `EnvSuggestion` shape
16
+ * used by the rule-based detector so `applyEnvSuggestionsToItems` works for both.
17
+ *
18
+ * @param collection The collection to scan.
19
+ * @param aiProvider Any IAiProvider (Copilot, OpenAI, Anthropic, …).
20
+ * @returns Suggestions sorted by occurrence count descending.
21
+ */
22
+ export declare function scanCollectionForEnvVarsWithAi(collection: Collection, aiProvider: IAiProvider): Promise<EnvSuggestion[]>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * AI Collection Enhancer
3
+ *
4
+ * Post-import pass that uses an IAiProvider to:
5
+ * 1. Generate realistic request body examples (replacing schema-inferred placeholders)
6
+ * 2. Write a postResponse test script for each request (status checks + schema assertions)
7
+ *
8
+ * Platform-independent — no VS Code or Node.js-specific dependency.
9
+ * The caller supplies the AI provider implementation.
10
+ */
11
+ import type { Collection, ICollectionService } from '../../types/collection';
12
+ import type { IAiProvider } from '../ai/ai-provider';
13
+ /** Progress callback: (message, percentIncrement) */
14
+ export type EnhanceProgressCallback = (message: string, increment: number) => void;
15
+ /**
16
+ * Enhance a collection with AI-generated body examples and test scripts.
17
+ *
18
+ * @param collection The collection to enhance (mutated in place, then saved).
19
+ * @param collectionService Service used to persist the collection after enhancement.
20
+ * @param aiProvider AI backend to use (Copilot, OpenAI, Anthropic, …).
21
+ * @param onProgress Optional progress callback fired once per batch.
22
+ */
23
+ export declare function enhanceCollection(collection: Collection, collectionService: ICollectionService, aiProvider: IAiProvider, onProgress?: EnhanceProgressCallback): Promise<void>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Environment Variable Suggester (rule-based)
3
+ *
4
+ * Scans an HTTP Forge collection for hardcoded values (auth tokens, API keys,
5
+ * shared base URLs, …) and suggests replacing them with environment variable
6
+ * placeholders (`{{VAR_NAME}}`).
7
+ *
8
+ * No AI dependency — detection is entirely heuristic:
9
+ * 1. `Authorization` header values (Bearer / Basic / Token / Digest)
10
+ * 2. Common sensitive header names (X-API-Key, X-Auth-Token, …)
11
+ * 3. Common sensitive query-param keys (api_key, access_token, …)
12
+ * 4. Shared base URL across ≥ 2 requests → BASE_URL
13
+ * 5. Long opaque strings (≥ 20 chars) in any header value
14
+ *
15
+ * Platform-independent (no Node.js or VS Code dependency).
16
+ */
17
+ import type { Collection, CollectionItem } from '../../types/collection';
18
+ /** A single detected hardcoded-value candidate. */
19
+ export interface EnvSuggestion {
20
+ /** Suggested variable name (e.g. `BEARER_TOKEN`). */
21
+ varName: string;
22
+ /** The hardcoded value found in the collection. */
23
+ value: string;
24
+ /** Human-readable explanation of why this was flagged. */
25
+ reason: string;
26
+ /** Every location where this value appears. */
27
+ occurrences: Array<{
28
+ requestId: string;
29
+ requestName: string;
30
+ field: string;
31
+ }>;
32
+ }
33
+ /**
34
+ * Scan a collection and return suggestions for replacing hardcoded values with
35
+ * environment variables.
36
+ *
37
+ * @param collection The collection to analyse.
38
+ * @param minOccurrences Only return suggestions seen in at least this many
39
+ * request locations (default: 1).
40
+ */
41
+ export declare function detectEnvSuggestions(collection: Collection, minOccurrences?: number): EnvSuggestion[];
42
+ /**
43
+ * Apply env-variable replacements to a collection's items in-place.
44
+ *
45
+ * For each suggestion, the hardcoded value is replaced with `{{VAR_NAME}}` in:
46
+ * - request URLs
47
+ * - header values (auth prefix like "Bearer " is preserved)
48
+ * - query-param values
49
+ *
50
+ * @param items The mutable `CollectionItem[]` to modify.
51
+ * @param suggestions Which replacements to apply.
52
+ * @returns Map of `varName → replacement count`.
53
+ */
54
+ export declare function applyEnvSuggestionsToItems(items: CollectionItem[], suggestions: Array<{
55
+ varName: string;
56
+ value: string;
57
+ }>): Record<string, number>;
@@ -13,6 +13,7 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
13
13
  private configService;
14
14
  private fileWatcherFactory?;
15
15
  private secretStore?;
16
+ private persistOverrides;
16
17
  private environmentsPath;
17
18
  private sharedConfigPath;
18
19
  private localConfigPath;
@@ -35,7 +36,7 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
35
36
  * Set by the extension host to refresh tree views and panels.
36
37
  */
37
38
  onEnvironmentsChanged?: () => void;
38
- constructor(workspaceFolder: string, workspaceStore: IKeyValueStore, configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined, secretStore?: ISecretStore | undefined);
39
+ constructor(workspaceFolder: string, workspaceStore: IKeyValueStore | undefined, configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined, secretStore?: ISecretStore | undefined, persistOverrides?: boolean);
39
40
  private setupFileWatcher;
40
41
  dispose(): void;
41
42
  getWorkspaceFolder(): string;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Curl Command Parser (rule-based)
3
+ *
4
+ * Parses a curl command string into a structured HTTP request definition.
5
+ * No AI dependency — works entirely with shell tokenization and flag matching.
6
+ * Platform-independent (no Node.js dependency).
7
+ *
8
+ * Supported curl flags:
9
+ * -X / --request HTTP method
10
+ * -H / --header Request headers
11
+ * -d / --data / --data-raw / --data-binary / --data-ascii Request body
12
+ * --json JSON body (also sets Content-Type: application/json)
13
+ * -u / --user Basic auth (user:pass → Authorization: Basic …)
14
+ * -b / --cookie Cookie string (added as Cookie header)
15
+ * --url Explicit URL
16
+ * -G / --get Force GET method
17
+ * -F / --form Form-data fields
18
+ * --data-urlencode URL-encoded body field
19
+ * -A / --user-agent User-Agent header
20
+ * -e / --referer Referer header
21
+ * Backslash-newline continuation is normalised to spaces before parsing.
22
+ */
23
+ /** Structured representation of a parsed curl command. */
24
+ export interface ParsedCurlRequest {
25
+ /** Suggested request name derived from the URL path segment. */
26
+ name: string;
27
+ method: string;
28
+ url: string;
29
+ /** Headers without curl-internal additions (Content-Type from --json, etc. are still included). */
30
+ headers: Array<{
31
+ key: string;
32
+ value: string;
33
+ enabled: boolean;
34
+ }>;
35
+ queryParams: Array<{
36
+ key: string;
37
+ value: string;
38
+ enabled: boolean;
39
+ }>;
40
+ /** Parsed body, or null when no body is present. */
41
+ body: {
42
+ type: 'raw';
43
+ format: 'json' | 'text';
44
+ content: string;
45
+ } | null;
46
+ /**
47
+ * Detected hardcoded values (tokens, API keys, base URLs) that are good
48
+ * environment-variable candidates.
49
+ */
50
+ suggestedVars: Array<{
51
+ key: string;
52
+ value: string;
53
+ }>;
54
+ }
55
+ /**
56
+ * Parse a curl command string into a structured HTTP request definition.
57
+ *
58
+ * @param cmd - Full curl command including the `curl` prefix (e.g. `"curl -X POST ..."`)
59
+ * @returns Parsed request with headers, query params, body, and suggested env variables.
60
+ */
61
+ export declare function parseCurlCommand(cmd: string): ParsedCurlRequest;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * JUnit XML Report Generator for Test Suite Results
3
+ *
4
+ * Reads the same persisted run artifacts as {@link HtmlReportGenerator}
5
+ * (manifest + index pages + per-result files produced by ResultStorageService)
6
+ * and emits a JUnit-compatible XML report that CI systems (GitHub Actions,
7
+ * GitLab CI, Jenkins, etc.) can parse and display.
8
+ *
9
+ * Output: {basePath}/{suiteId}/{runId}/junit.xml
10
+ *
11
+ * Mapping:
12
+ * <testsuites> aggregate across the whole run
13
+ * <testsuite> one per (collection + folder path) group
14
+ * <testcase> one per request execution (per iteration)
15
+ * <failure> present when assertions failed
16
+ * <error> present when the request itself errored
17
+ * <system-out> console output, when captured
18
+ */
19
+ export declare class JUnitReportGenerator {
20
+ private readonly basePath;
21
+ constructor(basePath: string);
22
+ /**
23
+ * Generate a JUnit XML report for the given run.
24
+ * @returns absolute path to the written junit.xml
25
+ */
26
+ generate(suiteId: string, runId: string): Promise<string>;
27
+ private loadAllSummaries;
28
+ /** Load detail files (for per-assertion failure messages and console output). */
29
+ private loadAllDetails;
30
+ /**
31
+ * Group request executions by (collection + folder path), preserving
32
+ * execution order. Iteration is folded into the test case name when the run
33
+ * has more than one iteration.
34
+ */
35
+ private buildGroups;
36
+ private buildXml;
37
+ }
@@ -114,6 +114,12 @@ export interface RunStats {
114
114
  minDuration: number;
115
115
  /** Maximum duration */
116
116
  maxDuration: number;
117
+ /** 50th percentile latency across all requests */
118
+ p50?: number;
119
+ /** 95th percentile latency across all requests */
120
+ p95?: number;
121
+ /** 99th percentile latency across all requests */
122
+ p99?: number;
117
123
  }
118
124
  /**
119
125
  * Run configuration stored in manifest
@@ -21,6 +21,8 @@ export interface McpDispatchServices {
21
21
  collection: ICollectionService;
22
22
  testSuite: ITestSuiteService;
23
23
  environmentConfig: IEnvironmentConfigService;
24
+ /** Absolute path to the workspace folder — used by AI-native tools. */
25
+ workspaceFolder?: string;
24
26
  }
25
27
  /**
26
28
  * Callbacks for the four execution tools that differ between server
@@ -0,0 +1,39 @@
1
+ /**
2
+ * MCP Prompts — pre-defined analysis prompts that leverage the calling LLM.
3
+ *
4
+ * When an MCP client (Copilot, Claude Code, etc.) invokes a prompt, the server
5
+ * fetches workspace data, assembles a rich structured message, and returns it
6
+ * to the client. The client feeds this message to its already-connected LLM,
7
+ * which produces AI-quality analysis without any extra configuration.
8
+ *
9
+ * Available prompts:
10
+ * analyze-test-failure — diagnose failures from a completed run
11
+ * suggest-assertions — write pm.test() scripts for a request
12
+ * review-collection — structural review of a collection
13
+ */
14
+ import type { ICollectionService } from '../types/collection';
15
+ import type { McpRunStore } from './mcp-run-store';
16
+ export interface McpPromptArg {
17
+ name: string;
18
+ description: string;
19
+ required: boolean;
20
+ }
21
+ export interface McpPromptDef {
22
+ name: string;
23
+ description: string;
24
+ arguments: McpPromptArg[];
25
+ }
26
+ export declare const MCP_PROMPTS: McpPromptDef[];
27
+ interface PromptMessage {
28
+ role: 'user' | 'assistant';
29
+ content: {
30
+ type: 'text';
31
+ text: string;
32
+ };
33
+ }
34
+ export interface PromptResult {
35
+ description: string;
36
+ messages: PromptMessage[];
37
+ }
38
+ export declare function buildPromptResult(name: string, args: Record<string, string>, collectionService: ICollectionService, runStore: McpRunStore): Promise<PromptResult>;
39
+ export {};
@@ -8,7 +8,7 @@
8
8
  */
9
9
  export interface McpRunRecord {
10
10
  id: string;
11
- status: 'running' | 'completed' | 'failed';
11
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
12
12
  suiteName: string;
13
13
  startedAt: number;
14
14
  completedAt?: number;
@@ -26,6 +26,8 @@ export interface McpRunRecord {
26
26
  allResults: object[];
27
27
  reportPath: string | null;
28
28
  error?: string;
29
+ /** Request names (unique) that ran without any pm.test() assertion */
30
+ noAssertionExamples?: string[];
29
31
  }
30
32
  export declare class McpRunStore {
31
33
  private readonly store;
@@ -40,4 +42,14 @@ export declare class McpRunStore {
40
42
  require(runId: unknown): McpRunRecord;
41
43
  /** Remove records older than the TTL. Called automatically before each create(). */
42
44
  prune(): void;
45
+ /** Iterate all stored run records (non-expired). */
46
+ values(): IterableIterator<McpRunRecord>;
47
+ /**
48
+ * Best-effort cancellation: mark a running run as 'cancelled' so that the
49
+ * execution loop can detect it and skip remaining requests.
50
+ *
51
+ * Returns `true` when the status was changed; `false` if the run doesn't
52
+ * exist, has already finished, or is in an unmodifiable state.
53
+ */
54
+ cancel(id: string): boolean;
43
55
  }
@@ -13,6 +13,12 @@ export interface McpTool {
13
13
  name: string;
14
14
  description: string;
15
15
  inputSchema: object;
16
+ annotations?: {
17
+ readOnlyHint?: boolean;
18
+ destructiveHint?: boolean;
19
+ idempotentHint?: boolean;
20
+ openWorldHint?: boolean;
21
+ };
16
22
  }
17
23
  /** Remove tools that share an identical name, keeping the first occurrence. */
18
24
  export declare function dedupeToolsByName(tools: McpTool[]): McpTool[];
@@ -67,6 +67,10 @@ export declare const COLLECTION_INPUT_SCHEMA: {
67
67
  readonly type: "number";
68
68
  readonly description: "Number of iterations (default: 1)";
69
69
  };
70
+ readonly concurrency: {
71
+ readonly type: "number";
72
+ readonly description: "Number of parallel virtual users (1–50, default: 1). Each VU runs the full request sequence independently, preserving inter-request dependencies.";
73
+ };
70
74
  readonly stopOnError: {
71
75
  readonly type: "boolean";
72
76
  readonly description: "Stop on first failure";
@@ -107,6 +111,10 @@ export declare const FOLDER_INPUT_SCHEMA: {
107
111
  readonly type: "number";
108
112
  readonly description: "Number of iterations (default: 1)";
109
113
  };
114
+ readonly concurrency: {
115
+ readonly type: "number";
116
+ readonly description: "Number of parallel virtual users (1–50, default: 1). Each VU runs the full request sequence independently.";
117
+ };
110
118
  readonly stopOnError: {
111
119
  readonly type: "boolean";
112
120
  readonly description: "Stop on first failure";
@@ -144,6 +152,10 @@ export declare const SUITE_INPUT_SCHEMA: {
144
152
  readonly type: "number";
145
153
  readonly description: "Number of iterations (overrides suite default)";
146
154
  };
155
+ readonly concurrency: {
156
+ readonly type: "number";
157
+ readonly description: "Number of parallel virtual users (1–50, default: 1). Each VU runs the full request sequence independently.";
158
+ };
147
159
  readonly stopOnError: {
148
160
  readonly type: "boolean";
149
161
  readonly description: "Stop on first failure";
@@ -195,6 +207,7 @@ export declare const GENERIC_TOOL_NAMES: {
195
207
  readonly getRunSummary: "get_run_summary";
196
208
  readonly getFailedRequests: "get_failed_requests";
197
209
  readonly getRequestResult: "get_request_result";
210
+ readonly cancelRun: "cancel_run";
198
211
  readonly setVariable: "set_variable";
199
212
  readonly createCollection: "create_collection";
200
213
  readonly renameCollection: "rename_collection";
@@ -202,6 +215,7 @@ export declare const GENERIC_TOOL_NAMES: {
202
215
  readonly duplicateCollection: "duplicate_collection";
203
216
  readonly createFolder: "create_folder";
204
217
  readonly deleteFolder: "delete_folder";
218
+ readonly getRequest: "get_request";
205
219
  readonly createRequest: "create_request";
206
220
  readonly updateRequest: "update_request";
207
221
  readonly deleteRequest: "delete_request";
@@ -226,12 +240,40 @@ export declare const GENERIC_TOOL_NAMES: {
226
240
  readonly unsetEnvironmentVariable: "unset_environment_variable";
227
241
  readonly setGlobalVariable: "set_global_variable";
228
242
  readonly getGlobals: "get_globals";
243
+ readonly scaffoldCollectionFromOpenApi: "scaffold_collection_from_openapi";
244
+ readonly suggestAssertions: "suggest_assertions";
245
+ readonly explainFailure: "explain_failure";
246
+ readonly suggestEnvVars: "suggest_env_vars";
247
+ readonly applyEnvVars: "apply_env_vars";
248
+ readonly getRequestsForEnhancement: "get_requests_for_enhancement";
249
+ readonly applyRequestEnhancements: "apply_request_enhancements";
250
+ readonly aiSuggestEnvVars: "ai_suggest_env_vars";
251
+ readonly aiEnhanceCollection: "ai_enhance_collection";
252
+ readonly analyzeCoverage: "analyze_coverage";
253
+ readonly aiAnalyzeCoverage: "ai_analyze_coverage";
254
+ readonly generateRequestFromIntent: "generate_request_from_intent";
255
+ readonly validateAgainstSpec: "validate_against_spec";
256
+ readonly generateScenarios: "generate_scenarios";
257
+ readonly healAssertions: "heal_assertions";
258
+ readonly generateIterationData: "generate_iteration_data";
229
259
  };
230
260
  export type GenericToolName = (typeof GENERIC_TOOL_NAMES)[keyof typeof GENERIC_TOOL_NAMES];
261
+ /** MCP 2025-11 tool annotations — surface hints to AI clients about safety and idempotency. */
262
+ interface ToolAnnotations {
263
+ /** true = no side-effects (safe to call freely) */
264
+ readOnlyHint?: boolean;
265
+ /** true = irreversible side-effect (client should confirm before calling) */
266
+ destructiveHint?: boolean;
267
+ /** true = safe to retry without unintended side-effects */
268
+ idempotentHint?: boolean;
269
+ /** true = may interact with external systems; false = workspace-local only */
270
+ openWorldHint?: boolean;
271
+ }
231
272
  interface GenericToolDef {
232
273
  name: string;
233
274
  description: string;
234
275
  inputSchema: Record<string, unknown>;
276
+ annotations?: ToolAnnotations;
235
277
  }
236
278
  /**
237
279
  * Build the generic drill-down tool definitions. `collectionLabels` and
@@ -81,6 +81,8 @@ export interface RunRequestOptions {
81
81
  body?: string;
82
82
  /** Extra response fields to include: headers, cookies, tests, consoleOutput, report */
83
83
  include?: string[];
84
+ /** Additional machine-readable reports to generate, e.g. ['junit'] */
85
+ reporters?: string[];
84
86
  }
85
87
  /**
86
88
  * Options for directly executing all requests in a collection without MCP.
@@ -114,6 +116,17 @@ export interface RunCollectionOptions {
114
116
  delay?: number;
115
117
  /** Extra response fields to include: perRequest, failedOnly, consoleOutput */
116
118
  include?: string[];
119
+ /** Additional machine-readable reports to generate, e.g. ['junit'] */
120
+ reporters?: string[];
121
+ /**
122
+ * Maximum number of iterations to execute in parallel (default: 1 = sequential).
123
+ * Each iteration runs the full request sequence in order so that inter-request
124
+ * dependencies (e.g. login → use token → call protected endpoint) are always
125
+ * preserved within an iteration. Concurrency means N independent virtual users
126
+ * running the same flow simultaneously, not requests within one flow running in
127
+ * parallel. Max: 50.
128
+ */
129
+ concurrency?: number;
117
130
  /**
118
131
  * Restrict execution to requests under this folder path (slash-separated
119
132
  * folder names, e.g. "Auth/Login"). When omitted, the whole collection runs.
@@ -147,6 +160,13 @@ export interface RunSuiteOptions {
147
160
  requestFilter?: string[];
148
161
  /** Extra response fields to include: perRequest, failedOnly, consoleOutput */
149
162
  include?: string[];
163
+ /** Additional machine-readable reports to generate, e.g. ['junit'] */
164
+ reporters?: string[];
165
+ /**
166
+ * Maximum number of iterations to execute in parallel (default: 1 = sequential).
167
+ * Each iteration runs the full request sequence in order. Max: 50.
168
+ */
169
+ concurrency?: number;
150
170
  }
151
171
  /**
152
172
  * Execute a single request directly without MCP server.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@http-forge/core",
3
- "version": "0.6.0",
3
+ "version": "0.6.5",
4
4
  "description": "Headless HTTP testing engine with Postman collection support, dynamic variables, and script-based automation.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",