@http-forge/core 0.6.26 → 0.6.28

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.
@@ -46,9 +46,22 @@ export declare class FolderCollectionStore implements ICollectionStore {
46
46
  */
47
47
  getIdBySlug(slug: string): string | undefined;
48
48
  /**
49
- * Ensure collections directory exists
49
+ * Ensure collections directory exists, and write AGENTS.md to the forge root
50
+ * (.http-forge/) on first initialisation so AI agents can discover the workspace
51
+ * schema without needing MCP tools.
50
52
  */
51
53
  private ensureDirectory;
54
+ /**
55
+ * Write .http-forge/AGENTS.md the first time a workspace is initialised.
56
+ * The file teaches AI assistants (GitHub Copilot, Claude, Cursor, …) the
57
+ * folder layout and schema URLs so they can author collections by editing
58
+ * files directly — without consuming MCP tool tokens.
59
+ *
60
+ * collectionsDir = {forgeRoot}/collections → forgeRoot = parent dir
61
+ * forgeRoot lives inside .http-forge/assets/ in the extension, so we walk
62
+ * two levels up to land in .http-forge/.
63
+ */
64
+ private ensureAgentsMd;
52
65
  /**
53
66
  * Read and parse a JSON metadata file, tolerating transient partial/empty reads.
54
67
  *
@@ -72,6 +72,24 @@ export interface ScriptsConfig {
72
72
  */
73
73
  timeout?: number;
74
74
  }
75
+ /**
76
+ * HTML report generation options.
77
+ */
78
+ export interface ReportConfig {
79
+ /**
80
+ * Maximum characters of a single request/response body embedded in the HTML
81
+ * report. Larger bodies are truncated (the full body stays in the on-disk
82
+ * result file). Guards against multi-GB reports on big collections.
83
+ */
84
+ maxBodyChars: number;
85
+ /**
86
+ * Which requests get their request/response bodies embedded in the report:
87
+ * - 'all' — every request (largest reports)
88
+ * - 'failed' — only failed requests (default; passed requests show a note)
89
+ * - 'none' — no bodies embedded
90
+ */
91
+ embedBodies: 'all' | 'failed' | 'none';
92
+ }
75
93
  /**
76
94
  * Runner configuration
77
95
  */
@@ -82,6 +100,8 @@ export interface RunnerConfig {
82
100
  indexPageSize: number;
83
101
  /** Maximum number of recent errors to track */
84
102
  recentErrorsLimit: number;
103
+ /** HTML report generation options */
104
+ report: ReportConfig;
85
105
  }
86
106
  /**
87
107
  * Environments configuration
@@ -117,8 +137,13 @@ export interface McpCorsConfig {
117
137
  * useful for tiny, stable collections or external automation that relies on
118
138
  * exact generated tool names. **Avoid for workspaces with >100 requests** —
119
139
  * the tool list will bloat the AI context window and degrade tool-selection accuracy.
140
+ * - `execution-only`: exposes only tools that require the HTTP Forge runtime
141
+ * (run, poll results, AI analysis). Discovery and collection-management tools
142
+ * are omitted because AI agents with file-system access can read/write the
143
+ * plain-JSON collection files directly. Best token-budget option for local
144
+ * VS Code / CLI setups where the agent also has workspace file access.
120
145
  */
121
- export type McpToolMode = 'flat' | 'drilldown' | 'auto';
146
+ export type McpToolMode = 'flat' | 'drilldown' | 'auto' | 'execution-only';
122
147
  /**
123
148
  * MCP Server project-level configuration (stored in http-forge.config.json)
124
149
  */
@@ -21,16 +21,27 @@ import { HttpRequest, HttpResponse, RequestSettings } from '../../types/types';
21
21
  * Same as plugin's DEFAULT_REQUEST_SETTINGS from shared/constants.ts
22
22
  */
23
23
  export declare const DEFAULT_REQUEST_SETTINGS: Required<RequestSettings>;
24
+ /**
25
+ * Source of default request settings for {@link NodeHttpClient}.
26
+ *
27
+ * Pass a plain object for static settings, or a provider function to resolve
28
+ * settings lazily on every request. The provider form lets live configuration
29
+ * changes (e.g. newly added host certificates) take effect without recreating
30
+ * the client instance.
31
+ */
32
+ export type RequestSettingsSource = Partial<RequestSettings> | (() => Partial<RequestSettings> | undefined);
24
33
  /**
25
34
  * Native HTTP client using Node.js http/https modules
26
35
  *
27
36
  * Implementation extracted 100% from plugin's HttpRequestService.executeInternal
28
37
  */
29
38
  export declare class NodeHttpClient implements IHttpClient {
30
- private settings;
39
+ private readonly resolveDefaults;
31
40
  private version;
32
41
  private readonly basePath;
33
- constructor(defaultSettings?: Partial<RequestSettings>, basePath?: string);
42
+ constructor(defaultSettings?: RequestSettingsSource, basePath?: string);
43
+ /** Current default settings, resolved fresh from the configured source. */
44
+ private get settings();
34
45
  /**
35
46
  * Send an HTTP request
36
47
  */
@@ -13,9 +13,21 @@
13
13
  * - Console output (if any)
14
14
  * - Error message (if any)
15
15
  */
16
+ /** Options controlling how much request/response data the report embeds. */
17
+ export interface HtmlReportOptions {
18
+ /** Max characters per embedded request/response body. */
19
+ maxBodyChars: number;
20
+ /** Which requests embed their bodies: all, only failed, or none. */
21
+ embedBodies: 'all' | 'failed' | 'none';
22
+ }
16
23
  export declare class HtmlReportGenerator {
17
24
  private readonly basePath;
18
- constructor(basePath: string);
25
+ private readonly options;
26
+ constructor(basePath: string, options?: Partial<HtmlReportOptions>);
27
+ /** Whether a request with the given pass state should embed its bodies. */
28
+ private shouldEmbedBody;
29
+ /** Placeholder shown where a body was intentionally not embedded. */
30
+ private bodyOmittedNote;
19
31
  /**
20
32
  * Generate an HTML report for the given run.
21
33
  * @returns absolute path to the written report.html
@@ -31,10 +31,12 @@ export interface ResultSummary {
31
31
  d: number;
32
32
  /** Passed (p) */
33
33
  p: boolean;
34
- /** Assertions passed count (ap) */
34
+ /** Assertions passed count — excludes skipped (ap) */
35
35
  ap: number;
36
36
  /** Assertions failed count (af) */
37
37
  af: number;
38
+ /** Assertions skipped via pm.test.skip() (as) — omitted when 0 */
39
+ as?: number;
38
40
  /** Request ID (r) - used to rebuild filename */
39
41
  r: string;
40
42
  /** Error message if failed (e) - null if passed */
@@ -230,6 +232,8 @@ export interface FullResultDetails {
230
232
  name: string;
231
233
  passed: boolean;
232
234
  message: string | null;
235
+ /** True when explicitly skipped via pm.test.skip() */
236
+ skipped?: boolean;
233
237
  }>;
234
238
  /** Error message */
235
239
  error: string | null;
@@ -35,6 +35,13 @@ export interface McpRunCallbacks {
35
35
  runCollection: (col: Collection, args: Record<string, unknown>) => Promise<unknown>;
36
36
  runSuite: (suiteId: string, suiteName: string, args: Record<string, unknown>) => Promise<unknown>;
37
37
  }
38
+ /**
39
+ * Post-process a run result before returning it to the AI:
40
+ * - truncates `result.body` (run_request)
41
+ * - truncates `result.failedRequests[N].body` (run_collection / run_folder / run_suite / get_run_summary)
42
+ * No-op when `include` contains `'fullBody'` or when the result has no body fields.
43
+ */
44
+ export declare function applyMcpBodyTruncation(result: unknown, include: string[]): unknown;
38
45
  /** Tools that write to disk and should bust the MCP tool-list cache after execution. */
39
46
  export declare const CACHE_BUSTING_TOOLS: Set<string>;
40
47
  /**
@@ -31,5 +31,11 @@ export declare function decodeCursor(cursor: string | undefined): number;
31
31
  *
32
32
  * The caller is responsible for applying exclusion filters before passing the
33
33
  * arrays here. This function is pure — it reads no disk state.
34
+ *
35
+ * @param workspaceFolder - Optional path to the workspace root. When supplied
36
+ * and `toolMode` is `auto`, the function checks whether `.http-forge/AGENTS.md`
37
+ * exists. If it does, the workspace has been prepared for AI file-based editing
38
+ * and `execution-only` is used instead of `drilldown`, saving ~60 % of tool-list
39
+ * tokens without any manual configuration.
34
40
  */
35
- export declare function buildMcpToolList(collections: Collection[], suites: TestSuite[], config: McpConfig): McpTool[];
41
+ export declare function buildMcpToolList(collections: Collection[], suites: TestSuite[], config: McpConfig, workspaceFolder?: string): McpTool[];
@@ -43,9 +43,9 @@ export declare const REQUEST_INPUT_SCHEMA: {
43
43
  readonly type: "array";
44
44
  readonly items: {
45
45
  readonly type: "string";
46
- readonly enum: readonly ["headers", "cookies", "tests", "consoleOutput", "report"];
46
+ readonly enum: readonly ["headers", "cookies", "tests", "consoleOutput", "report", "fullBody"];
47
47
  };
48
- readonly description: "Extra fields to include in the response (default: status, ok, body, allPassed)";
48
+ readonly description: "Extra fields to include in the response (default: status, ok, body, allPassed). Use fullBody to disable the 4KB body truncation.";
49
49
  };
50
50
  };
51
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@http-forge/core",
3
- "version": "0.6.26",
3
+ "version": "0.6.28",
4
4
  "description": "Headless Postman-compatible API testing engine for Node.js, CI/CD, OpenAPI workflows, and HTTP Forge automation",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",