@http-forge/cli 0.2.1 → 0.2.11
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.
- package/README.md +88 -328
- package/dist/ai/providers.d.ts +34 -0
- package/dist/ai/providers.d.ts.map +1 -0
- package/dist/ai/providers.js +98 -0
- package/dist/ai/providers.js.map +1 -0
- package/dist/commands/env.d.ts +14 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +165 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/generate-collection.d.ts +11 -0
- package/dist/commands/generate-collection.d.ts.map +1 -0
- package/dist/commands/generate-collection.js +301 -0
- package/dist/commands/generate-collection.js.map +1 -0
- package/dist/commands/launch.d.ts +2 -0
- package/dist/commands/launch.d.ts.map +1 -0
- package/dist/commands/launch.js +96 -0
- package/dist/commands/launch.js.map +1 -0
- package/dist/commands/list.d.ts +12 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +170 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/mcp.d.ts +19 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +211 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/run.d.ts +35 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +589 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/schedule.d.ts +11 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +237 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/suggest-env.d.ts +12 -0
- package/dist/commands/suggest-env.d.ts.map +1 -0
- package/dist/commands/suggest-env.js +205 -0
- package/dist/commands/suggest-env.js.map +1 -0
- package/dist/commands.d.ts +15 -7
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +30 -436
- package/dist/commands.js.map +1 -1
- package/dist/curl-parser.d.ts +51 -0
- package/dist/curl-parser.d.ts.map +1 -0
- package/dist/curl-parser.js +365 -0
- package/dist/curl-parser.js.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +175 -87
- package/dist/index.js.map +1 -1
- package/dist/output/format.d.ts +63 -0
- package/dist/output/format.d.ts.map +1 -0
- package/dist/output/format.js +280 -0
- package/dist/output/format.js.map +1 -0
- package/package.json +28 -4
- package/scripts/http-forge.bat +157 -0
- package/scripts/http-forge.sh +167 -0
package/README.md
CHANGED
|
@@ -1,381 +1,141 @@
|
|
|
1
1
|
# HTTP Forge CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@http-forge/cli)
|
|
4
|
+
[](https://www.npmjs.com/package/@http-forge/cli)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://www.npmjs.com/package/@http-forge/cli)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
The standalone launcher, terminal, and automation CLI for HTTP Forge.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
cd http-forge.cli
|
|
9
|
-
npm install
|
|
10
|
-
npm run build
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
### 1. Show Help
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
http-forge --help
|
|
19
|
-
http-forge -h
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### 2. Run a Single Request
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
http-forge run-request \
|
|
26
|
-
--collection my-api \
|
|
27
|
-
--request get-users \
|
|
28
|
-
--environment production \
|
|
29
|
-
--output json
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
http-forge run-request --collection my-api --request get-users --include tests --include report
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
**Required:**
|
|
37
|
-
- `--collection <id>` — Collection ID
|
|
38
|
-
- `--request <id>` — Request ID
|
|
39
|
-
|
|
40
|
-
**Optional:**
|
|
41
|
-
- `--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`)
|
|
46
|
-
|
|
47
|
-
### 3. Run a Collection
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
http-forge run-collection \
|
|
51
|
-
--collection my-api \
|
|
52
|
-
--environment dev \
|
|
53
|
-
--include perRequest \
|
|
54
|
-
--output json
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**Required:**
|
|
58
|
-
- `--collection <id>` — Collection ID
|
|
59
|
-
|
|
60
|
-
**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)
|
|
64
|
-
- `--iterations <num>` — Number of iterations (default: 1)
|
|
65
|
-
- `--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`)
|
|
69
|
-
|
|
70
|
-
### 4. Run a Test Suite
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
http-forge run-suite \
|
|
74
|
-
--suite smoke-tests \
|
|
75
|
-
--iterations 3 \
|
|
76
|
-
--include failedOnly \
|
|
77
|
-
--include report \
|
|
78
|
-
--output json
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**Required:**
|
|
82
|
-
- `--suite <id>` — Suite ID
|
|
83
|
-
|
|
84
|
-
**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)
|
|
88
|
-
- `--iterations <num>` — Number of iterations
|
|
89
|
-
- `--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`)
|
|
93
|
-
|
|
94
|
-
### 5. Manage MCP Server
|
|
95
|
-
|
|
96
|
-
Start, stop, or check the status of an embedded MCP (Model Context Protocol) server for AI agent integration:
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
http-forge mcp-server start --port 3100
|
|
100
|
-
http-forge mcp-server status --workspace .
|
|
101
|
-
http-forge mcp-server stop --workspace .
|
|
102
|
-
```
|
|
103
|
-
|
|
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
|
|
108
|
-
|
|
109
|
-
**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)
|
|
113
|
-
|
|
114
|
-
### MCP JSON-RPC Usage
|
|
115
|
-
|
|
116
|
-
After starting the server with `http-forge mcp-server start`, call the MCP endpoint at `POST /`.
|
|
117
|
-
|
|
118
|
-
JSON-RPC request shape:
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
interface JsonRpcRequest {
|
|
122
|
-
jsonrpc: '2.0';
|
|
123
|
-
id: string | number | null;
|
|
124
|
-
method: string;
|
|
125
|
-
params?: Record<string, unknown>;
|
|
126
|
-
}
|
|
127
|
-
```
|
|
10
|
+
Start HTTP Forge in UI mode from terminal, run API collections and suites in CI/CD, manage MCP server lifecycle, and generate JUnit/HTML reports for pipelines.
|
|
128
11
|
|
|
129
|
-
|
|
12
|
+
Postman alternative for local-first, Git-friendly API workflows in both UI and CLI modes.
|
|
130
13
|
|
|
131
|
-
|
|
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
|
-
}'
|
|
140
|
-
```
|
|
14
|
+
## Who It Is For
|
|
141
15
|
|
|
142
|
-
|
|
16
|
+
- Developers who want to launch standalone HTTP Forge from terminal.
|
|
17
|
+
- Developers who want to run API collections from terminal.
|
|
18
|
+
- QA teams who need repeatable suite runs and JUnit reports.
|
|
19
|
+
- CI/CD pipelines that need API test gating without a GUI.
|
|
20
|
+
- Agent workflows that need MCP server lifecycle commands.
|
|
143
21
|
|
|
144
|
-
|
|
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
|
-
}'
|
|
152
|
-
```
|
|
22
|
+
## Why HTTP Forge CLI
|
|
153
23
|
|
|
154
|
-
|
|
24
|
+
- Launch HTTP Forge in standalone UI mode with one command.
|
|
25
|
+
- Run API tests in CI/CD without a GUI.
|
|
26
|
+
- Use the same HTTP Forge workspace in editor and terminal.
|
|
27
|
+
- Generate JUnit and HTML reports for team visibility.
|
|
28
|
+
- Manage MCP server lifecycle for agent workflows.
|
|
29
|
+
- Work with OpenAPI, environments, and Postman-style scripts in one toolchain.
|
|
155
30
|
|
|
156
|
-
|
|
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
|
-
}'
|
|
171
|
-
```
|
|
31
|
+
## Works With
|
|
172
32
|
|
|
173
|
-
|
|
33
|
+
- HTTP Forge workspaces and collections
|
|
34
|
+
- OpenAPI specs
|
|
35
|
+
- Postman imports
|
|
36
|
+
- GitHub Actions, Jenkins, GitLab CI, and other pipelines
|
|
174
37
|
|
|
175
|
-
|
|
176
|
-
curl http://127.0.0.1:3100/health
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
#### Legacy compatibility endpoint
|
|
180
|
-
|
|
181
|
-
For non-MCP clients, a compatibility endpoint is also available:
|
|
38
|
+
## 1-Minute Quickstart
|
|
182
39
|
|
|
183
40
|
```bash
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
-d '{
|
|
187
|
-
"name": "request__my-api__get-users",
|
|
188
|
-
"args": { "environment": "dev" }
|
|
189
|
-
}'
|
|
190
|
-
```
|
|
41
|
+
# 1) Install
|
|
42
|
+
npm install --global @http-forge/cli
|
|
191
43
|
|
|
192
|
-
|
|
193
|
-
-
|
|
194
|
-
- `-32603` Internal error (dispatch/runtime failures, including unknown method)
|
|
44
|
+
# 2) Launch standalone HTTP Forge UI
|
|
45
|
+
http-forge launch
|
|
195
46
|
|
|
196
|
-
|
|
47
|
+
# 3) Run a collection
|
|
48
|
+
http-forge run collection "my-api" --env dev --exit-code
|
|
197
49
|
|
|
198
|
-
|
|
199
|
-
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
## Environment Variables
|
|
203
|
-
|
|
204
|
-
- `HTTP_FORGE_WORKSPACE` — Override default workspace folder
|
|
205
|
-
|
|
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
|
|
212
|
-
|
|
213
|
-
## Secret Providers
|
|
214
|
-
|
|
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.
|
|
216
|
-
|
|
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.
|
|
218
|
-
|
|
219
|
-
## Examples
|
|
220
|
-
|
|
221
|
-
### Run smoke tests on staging
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
http-forge run-suite \
|
|
225
|
-
--suite smoke-tests \
|
|
226
|
-
--environment staging \
|
|
227
|
-
--stop-on-error
|
|
50
|
+
# 4) Run a suite with JUnit report for CI
|
|
51
|
+
http-forge run suite "smoke-tests" --env staging \
|
|
52
|
+
--reporter junit:results/junit.xml --exit-code
|
|
228
53
|
```
|
|
229
54
|
|
|
230
|
-
|
|
55
|
+
## Install
|
|
231
56
|
|
|
232
57
|
```bash
|
|
233
|
-
|
|
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
|
|
58
|
+
npm install --global @http-forge/cli
|
|
246
59
|
```
|
|
247
60
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
Variables from the shell environment are automatically available as template variables in your requests:
|
|
251
|
-
|
|
252
|
-
```yaml
|
|
253
|
-
- name: Run API tests
|
|
254
|
-
run: |
|
|
255
|
-
http-forge run-suite \
|
|
256
|
-
--suite smoke-tests \
|
|
257
|
-
--environment staging \
|
|
258
|
-
--stop-on-error \
|
|
259
|
-
--include report \
|
|
260
|
-
--output json
|
|
261
|
-
env:
|
|
262
|
-
API_KEY: ${{ secrets.API_KEY }}
|
|
263
|
-
BASE_URL: ${{ vars.STAGING_BASE_URL }}
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
You can also pass secrets explicitly with `--var` to override environment file values:
|
|
267
|
-
|
|
268
|
-
```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 }}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### Execute collection with custom variables
|
|
61
|
+
From monorepo:
|
|
279
62
|
|
|
280
63
|
```bash
|
|
281
|
-
http-forge
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
--var BASE_URL=http://localhost:3000
|
|
64
|
+
cd http-forge.cli
|
|
65
|
+
npm install
|
|
66
|
+
npm run build
|
|
285
67
|
```
|
|
286
68
|
|
|
287
|
-
|
|
69
|
+
## Core Commands
|
|
288
70
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
71
|
+
| Command | Purpose |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `http-forge launch` | Launch standalone HTTP Forge UI (`--test`, `--dev`, `--both`) |
|
|
74
|
+
| `http-forge run ...` | Run a request, folder, collection, or suite |
|
|
75
|
+
| `http-forge mcp ...` | Start/stop/status for MCP server |
|
|
76
|
+
| `http-forge list ...` | List collections, suites, requests, folders, environments |
|
|
77
|
+
| `http-forge env ...` | Get/set/unset environment variables |
|
|
78
|
+
| `http-forge generate-collection ...` | Create collection from curl, Postman, or OpenAPI |
|
|
79
|
+
| `http-forge suggest-env ...` | Detect hardcoded values and suggest env vars |
|
|
80
|
+
| `http-forge schedule ...` | Generate scheduled CI workflow/cron config |
|
|
81
|
+
| `http-forge copy-as ...` | Export request as curl/fetch/python snippet |
|
|
296
82
|
|
|
297
|
-
|
|
83
|
+
## Launch Modes
|
|
298
84
|
|
|
299
85
|
```bash
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
--request login \
|
|
303
|
-
--output json | jq '.allPassed'
|
|
304
|
-
```
|
|
86
|
+
# Default: standalone HTTP Forge profile
|
|
87
|
+
http-forge launch
|
|
305
88
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
### JSON Format (default)
|
|
309
|
-
|
|
310
|
-
```json
|
|
311
|
-
{
|
|
312
|
-
"request": "Get Users",
|
|
313
|
-
"status": 200,
|
|
314
|
-
"ok": true,
|
|
315
|
-
"duration": "145ms",
|
|
316
|
-
"allPassed": true,
|
|
317
|
-
"assertions": [
|
|
318
|
-
{
|
|
319
|
-
"name": "Status is 200",
|
|
320
|
-
"passed": true
|
|
321
|
-
}
|
|
322
|
-
]
|
|
323
|
-
}
|
|
324
|
-
```
|
|
89
|
+
# Use your normal VS Code profile
|
|
90
|
+
http-forge launch --dev
|
|
325
91
|
|
|
326
|
-
|
|
92
|
+
# Open both test and dev profiles
|
|
93
|
+
http-forge launch --both
|
|
327
94
|
|
|
95
|
+
# Open a workspace path
|
|
96
|
+
http-forge launch --dev /path/to/workspace
|
|
328
97
|
```
|
|
329
|
-
Request: Get Users
|
|
330
|
-
Status: 200
|
|
331
|
-
OK: true
|
|
332
|
-
Time: 145ms
|
|
333
|
-
Tests: ✅ All passed
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## Error Handling
|
|
337
|
-
|
|
338
|
-
All errors are written to stderr with detailed messages:
|
|
339
98
|
|
|
340
|
-
|
|
341
|
-
$ http-forge run-request --collection missing --request test 2>&1
|
|
342
|
-
Error: Collection "missing" not found
|
|
343
|
-
```
|
|
99
|
+
Use `http-forge launch` when you want the standalone HTTP Forge UI from terminal.
|
|
344
100
|
|
|
345
|
-
|
|
101
|
+
The launcher auto-detects OS/shell and uses the matching script:
|
|
102
|
+
- Linux/macOS: `scripts/http-forge.sh`
|
|
103
|
+
- Windows: `scripts/http-forge.bat`
|
|
346
104
|
|
|
347
|
-
|
|
105
|
+
## Common Run Patterns
|
|
348
106
|
|
|
349
107
|
```bash
|
|
350
|
-
|
|
351
|
-
|
|
108
|
+
# Collection
|
|
109
|
+
http-forge run collection "my-api" --env dev --include perRequest
|
|
352
110
|
|
|
353
|
-
|
|
111
|
+
# Suite
|
|
112
|
+
http-forge run suite "smoke-tests" --env staging --exit-code
|
|
354
113
|
|
|
355
|
-
|
|
114
|
+
# Request
|
|
115
|
+
http-forge run request "Get Users" --collection "my-api" --env dev
|
|
356
116
|
|
|
357
|
-
|
|
358
|
-
|
|
117
|
+
# Folder
|
|
118
|
+
http-forge run folder "Auth/Login" --collection "my-api" --env dev
|
|
359
119
|
```
|
|
360
120
|
|
|
361
|
-
|
|
121
|
+
## CI/CD Example
|
|
362
122
|
|
|
363
123
|
```bash
|
|
364
|
-
|
|
124
|
+
http-forge run suite "smoke-tests" \
|
|
125
|
+
--env staging \
|
|
126
|
+
--reporter junit:results/junit.xml \
|
|
127
|
+
--exit-code
|
|
365
128
|
```
|
|
366
129
|
|
|
367
|
-
|
|
130
|
+
Use this in CI to fail the pipeline on assertion failures and publish JUnit artifacts.
|
|
368
131
|
|
|
369
|
-
|
|
370
|
-
npm run clean
|
|
371
|
-
```
|
|
132
|
+
## Detailed Docs
|
|
372
133
|
|
|
373
|
-
|
|
134
|
+
- Full CLI reference: `docs/cli-reference.md`
|
|
135
|
+
- CI guide: `docs/ci-guide.md`
|
|
136
|
+
- Example workflow: `docs/ci-example.yml`
|
|
137
|
+
- HTTP Forge docs: https://github.com/hsl1230/http-forge/tree/main/docs/user-guide
|
|
374
138
|
|
|
375
|
-
|
|
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
|
|
139
|
+
## License
|
|
380
140
|
|
|
381
|
-
|
|
141
|
+
MIT
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI AI Providers
|
|
3
|
+
*
|
|
4
|
+
* Lightweight IAiProvider implementations for the CLI.
|
|
5
|
+
* Both use native fetch (Node 20+) — no SDK dependency required.
|
|
6
|
+
*
|
|
7
|
+
* Auto-detection order (createCliAiProvider):
|
|
8
|
+
* 1. OPENAI_API_KEY → OpenAiProvider (model: gpt-4o-mini by default)
|
|
9
|
+
* 2. ANTHROPIC_API_KEY → AnthropicProvider (model: claude-3-5-haiku-20241022)
|
|
10
|
+
*/
|
|
11
|
+
import type { IAiProvider } from '@http-forge/core';
|
|
12
|
+
export declare class OpenAiProvider implements IAiProvider {
|
|
13
|
+
private readonly apiKey;
|
|
14
|
+
private readonly model;
|
|
15
|
+
constructor(apiKey: string, model?: string);
|
|
16
|
+
complete(prompt: string): Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
export declare class AnthropicProvider implements IAiProvider {
|
|
19
|
+
private readonly apiKey;
|
|
20
|
+
private readonly model;
|
|
21
|
+
constructor(apiKey: string, model?: string);
|
|
22
|
+
complete(prompt: string): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create the best available AI provider from environment variables.
|
|
26
|
+
* Returns null if no provider is configured.
|
|
27
|
+
*
|
|
28
|
+
* Respects:
|
|
29
|
+
* OPENAI_API_KEY → OpenAI (override model with OPENAI_MODEL)
|
|
30
|
+
* ANTHROPIC_API_KEY → Anthropic (override model with ANTHROPIC_MODEL)
|
|
31
|
+
* HTTP_FORGE_AI_PROVIDER=openai|anthropic to force a specific provider
|
|
32
|
+
*/
|
|
33
|
+
export declare function createCliAiProvider(): IAiProvider | null;
|
|
34
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/ai/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,qBAAa,cAAe,YAAW,WAAW;IAE9C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,MAAM,EAAE,MAAM,EACd,KAAK,SAAgB;IAGlC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBhD;AAID,qBAAa,iBAAkB,YAAW,WAAW;IAEjD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,MAAM,EAAE,MAAM,EACd,KAAK,SAA8B;IAGhD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAuBhD;AAID;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,GAAG,IAAI,CAkBxD"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI AI Providers
|
|
4
|
+
*
|
|
5
|
+
* Lightweight IAiProvider implementations for the CLI.
|
|
6
|
+
* Both use native fetch (Node 20+) — no SDK dependency required.
|
|
7
|
+
*
|
|
8
|
+
* Auto-detection order (createCliAiProvider):
|
|
9
|
+
* 1. OPENAI_API_KEY → OpenAiProvider (model: gpt-4o-mini by default)
|
|
10
|
+
* 2. ANTHROPIC_API_KEY → AnthropicProvider (model: claude-3-5-haiku-20241022)
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AnthropicProvider = exports.OpenAiProvider = void 0;
|
|
14
|
+
exports.createCliAiProvider = createCliAiProvider;
|
|
15
|
+
// ─── OpenAI ───────────────────────────────────────────────────────────────────
|
|
16
|
+
class OpenAiProvider {
|
|
17
|
+
constructor(apiKey, model = 'gpt-4o-mini') {
|
|
18
|
+
this.apiKey = apiKey;
|
|
19
|
+
this.model = model;
|
|
20
|
+
}
|
|
21
|
+
async complete(prompt) {
|
|
22
|
+
const res = await fetch('https://api.openai.com/v1/chat/completions', {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
model: this.model,
|
|
30
|
+
messages: [{ role: 'user', content: prompt }],
|
|
31
|
+
temperature: 0,
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
const body = await res.text();
|
|
36
|
+
throw new Error(`OpenAI API error ${res.status}: ${body}`);
|
|
37
|
+
}
|
|
38
|
+
const data = await res.json();
|
|
39
|
+
return data.choices[0].message.content;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.OpenAiProvider = OpenAiProvider;
|
|
43
|
+
// ─── Anthropic ────────────────────────────────────────────────────────────────
|
|
44
|
+
class AnthropicProvider {
|
|
45
|
+
constructor(apiKey, model = 'claude-3-5-haiku-20241022') {
|
|
46
|
+
this.apiKey = apiKey;
|
|
47
|
+
this.model = model;
|
|
48
|
+
}
|
|
49
|
+
async complete(prompt) {
|
|
50
|
+
const res = await fetch('https://api.anthropic.com/v1/messages', {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: {
|
|
53
|
+
'Content-Type': 'application/json',
|
|
54
|
+
'x-api-key': this.apiKey,
|
|
55
|
+
'anthropic-version': '2023-06-01',
|
|
56
|
+
},
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
model: this.model,
|
|
59
|
+
max_tokens: 4096,
|
|
60
|
+
messages: [{ role: 'user', content: prompt }],
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
if (!res.ok) {
|
|
64
|
+
const body = await res.text();
|
|
65
|
+
throw new Error(`Anthropic API error ${res.status}: ${body}`);
|
|
66
|
+
}
|
|
67
|
+
const data = await res.json();
|
|
68
|
+
return data.content[0].text;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.AnthropicProvider = AnthropicProvider;
|
|
72
|
+
// ─── Factory ──────────────────────────────────────────────────────────────────
|
|
73
|
+
/**
|
|
74
|
+
* Create the best available AI provider from environment variables.
|
|
75
|
+
* Returns null if no provider is configured.
|
|
76
|
+
*
|
|
77
|
+
* Respects:
|
|
78
|
+
* OPENAI_API_KEY → OpenAI (override model with OPENAI_MODEL)
|
|
79
|
+
* ANTHROPIC_API_KEY → Anthropic (override model with ANTHROPIC_MODEL)
|
|
80
|
+
* HTTP_FORGE_AI_PROVIDER=openai|anthropic to force a specific provider
|
|
81
|
+
*/
|
|
82
|
+
function createCliAiProvider() {
|
|
83
|
+
const forced = process.env.HTTP_FORGE_AI_PROVIDER?.toLowerCase();
|
|
84
|
+
if (forced === 'anthropic' || (!forced && process.env.ANTHROPIC_API_KEY && !process.env.OPENAI_API_KEY)) {
|
|
85
|
+
const key = process.env.ANTHROPIC_API_KEY;
|
|
86
|
+
if (!key)
|
|
87
|
+
return null;
|
|
88
|
+
return new AnthropicProvider(key, process.env.ANTHROPIC_MODEL);
|
|
89
|
+
}
|
|
90
|
+
if (process.env.OPENAI_API_KEY) {
|
|
91
|
+
return new OpenAiProvider(process.env.OPENAI_API_KEY, process.env.OPENAI_MODEL);
|
|
92
|
+
}
|
|
93
|
+
if (process.env.ANTHROPIC_API_KEY) {
|
|
94
|
+
return new AnthropicProvider(process.env.ANTHROPIC_API_KEY, process.env.ANTHROPIC_MODEL);
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/ai/providers.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Env command — read and write environment variables in the workspace config.
|
|
3
|
+
*
|
|
4
|
+
* http-forge env list
|
|
5
|
+
* http-forge env get <name> [--output table] [--no-values]
|
|
6
|
+
* http-forge env set <env> <key> <value>
|
|
7
|
+
* http-forge env set <env> <key>=<value>
|
|
8
|
+
* http-forge env unset <env> <key>
|
|
9
|
+
* http-forge env select <name>
|
|
10
|
+
*
|
|
11
|
+
* All subcommands support --workspace and --json / --output.
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleEnv(args: string[]): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/commands/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmJ7D"}
|