@yiaany/ghostapi 0.1.5 → 0.1.7

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/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to GhostAPI will be documented in this file.
4
4
 
5
5
  The format follows the spirit of [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses semantic versioning once public releases begin.
6
6
 
7
+ ## 0.1.7 - 2026-07-18
8
+
9
+ ### Changed
10
+
11
+ - Set npm package `homepage` link to the landing repository `yiaany/ghostweb` so npm cards point to the public site instead of repository code.
12
+
13
+ ## 0.1.6 - 2026-07-18
14
+
15
+ ### Fixed
16
+
17
+ - Updated npm package repository, bugs, and homepage URLs to point to `yiaany/ghostapi` instead of broken legacy links.
18
+ - Replaced custom CI badge with live GitHub Actions workflow status badge (`yiaany/ghostapi/actions/workflows/ci.yml/badge.svg`).
19
+
7
20
  ## 0.1.5 - 2026-07-18
8
21
 
9
22
  ### Fixed
package/README.md CHANGED
@@ -1,33 +1,92 @@
1
- # GhostAPI
2
-
3
- **The local internet for AI coding agents.**
4
-
5
- GhostAPI runs a local API sandbox on `http://127.0.0.1:8080` so coding agents can build and test Stripe, OpenAI, Twilio, Resend, GitHub, Discord, and REST integrations without touching production.
1
+ <p align="center">
2
+ <img src="docs/assets/ghostapi-avatar.png" alt="GhostAPI" width="104" height="104">
3
+ </p>
4
+
5
+ <h1 align="center">GhostAPI</h1>
6
+
7
+ <p align="center">
8
+ <strong>The local internet for AI coding agents.</strong>
9
+ </p>
10
+
11
+ <p align="center">
12
+ A local API sandbox, dashboard, and MCP control plane for building third-party integrations without touching production.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/@yiaany/ghostapi"><img alt="npm" src="https://img.shields.io/npm/v/@yiaany/ghostapi?color=0f172a&label=npm"></a>
17
+ <a href="https://github.com/yiaany/ghostapi/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-0f172a"></a>
18
+ <a href="https://github.com/yiaany/ghostapi/actions/workflows/ci.yml"><img alt="ci" src="https://github.com/yiaany/ghostapi/actions/workflows/ci.yml/badge.svg"></a>
19
+ <img alt="node" src="https://img.shields.io/badge/node-%3E%3D20-0f172a">
20
+ <img alt="mcp" src="https://img.shields.io/badge/MCP-enabled-0f172a">
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="#quickstart">Quickstart</a> ·
25
+ <a href="#mcp-setup">MCP Setup</a> ·
26
+ <a href="#how-it-works">How It Works</a> ·
27
+ <a href="#sdk-recipes">SDK Recipes</a> ·
28
+ <a href="#contributing">Contributing</a>
29
+ </p>
6
30
 
7
31
  ```bash
8
32
  npx @yiaany/ghostapi start --open
9
33
  ```
10
34
 
11
- ```text
12
- Your app or agent -> http://127.0.0.1:8080 -> GhostAPI -> dashboard, local state, scenarios, MCP tools
13
- ```
35
+ <p align="center">
36
+ <img src="docs/assets/dashboard.png" alt="GhostAPI dashboard showing local API traffic">
37
+ </p>
38
+
39
+ ## The Problem
40
+
41
+ AI coding agents are now strong enough to write Stripe checkouts, OpenAI workflows, GitHub automations, Twilio messaging, and email integrations. The dangerous part is that they also run the code they write.
42
+
43
+ That creates a bad default loop:
44
+
45
+ | Agent action | Production risk |
46
+ | --- | --- |
47
+ | Tests a Stripe flow | Real money movement or broken payment state. |
48
+ | Tests Twilio or Resend | Real SMS or email sent to real people. |
49
+ | Tests GitHub automation | Real issues, branches, releases, or repo mutations. |
50
+ | Tests OpenAI calls | Real token spend and possible prompt/data leakage. |
51
+ | Logs request/response payloads | Secrets leak into terminals, prompts, screenshots, or cache. |
52
+
53
+ GhostAPI gives agents a local universe where integrations behave like real providers, but every request stays on your machine.
54
+
55
+ ## What GhostAPI Does
14
56
 
15
- ## Install
57
+ GhostAPI is a local API control layer for agent-driven development.
16
58
 
17
- Run without installing:
59
+ <table>
60
+ <tr>
61
+ <td><strong>Local API Sandbox</strong><br>Run provider-shaped APIs on <code>127.0.0.1:8080</code> instead of live Stripe, OpenAI, Twilio, Resend, GitHub, Discord, or random REST services.</td>
62
+ <td><strong>Live Dashboard</strong><br>Watch every request, inspect request and response bodies, replay scenarios, generate setup snippets, and verify what your agent actually did.</td>
63
+ </tr>
64
+ <tr>
65
+ <td><strong>MCP Control Plane</strong><br>Let agents inspect state, read traffic logs, force deterministic responses, and toggle Chaos Mode through MCP tools.</td>
66
+ <td><strong>Safe Failure Testing</strong><br>Force card declines, rate limits, upstream errors, latency, and provider-shaped edge cases without waiting for real APIs to fail.</td>
67
+ </tr>
68
+ <tr>
69
+ <td><strong>Secret Masking</strong><br>Mask secret-looking headers, query params, bodies, cache keys, dashboard payloads, events, and prompt inputs.</td>
70
+ <td><strong>Repo Setup Generator</strong><br>Generate MCP config, agent instructions, environment snippets, and SDK patches for the current project.</td>
71
+ </tr>
72
+ </table>
73
+
74
+ ## Quickstart
75
+
76
+ Run GhostAPI instantly:
18
77
 
19
78
  ```bash
20
79
  npx @yiaany/ghostapi start --open
21
80
  ```
22
81
 
23
- Or install globally:
82
+ Install globally:
24
83
 
25
84
  ```bash
26
85
  npm i -g @yiaany/ghostapi
27
86
  ghostapi start --open
28
87
  ```
29
88
 
30
- Dashboard:
89
+ Open the dashboard:
31
90
 
32
91
  ```text
33
92
  http://127.0.0.1:8080/dashboard
@@ -39,15 +98,15 @@ Health check:
39
98
  curl http://127.0.0.1:8080/health
40
99
  ```
41
100
 
42
- ## 30 Second Win
101
+ ## 30 Second Demo
43
102
 
44
- Start GhostAPI:
103
+ Start the local API world:
45
104
 
46
105
  ```bash
47
106
  npx @yiaany/ghostapi start --open
48
107
  ```
49
108
 
50
- Send a local API request:
109
+ Send a Stripe-shaped request locally:
51
110
 
52
111
  ```bash
53
112
  curl -X POST http://127.0.0.1:8080/v1/customers \
@@ -56,12 +115,30 @@ curl -X POST http://127.0.0.1:8080/v1/customers \
56
115
  -d '{"email":"ada@example.com","name":"Ada Lovelace"}'
57
116
  ```
58
117
 
59
- Open the dashboard and inspect the captured request:
118
+ Inspect the captured request in the dashboard:
60
119
 
61
120
  ```text
62
121
  http://127.0.0.1:8080/dashboard
63
122
  ```
64
123
 
124
+ ## One-Command Repo Setup
125
+
126
+ Run setup inside any project:
127
+
128
+ ```bash
129
+ npx @yiaany/ghostapi setup --write
130
+ ```
131
+
132
+ This generates local setup assets for agent workflows:
133
+
134
+ | Output | Why it matters |
135
+ | --- | --- |
136
+ | Agent instructions | Tell coding agents to keep provider calls local. |
137
+ | MCP snippets | Configure Cursor, Claude, Cline, Aider, Codex, OpenCode, Gemini CLI, Goose, OpenClaw, Hermes, and generic MCP clients. |
138
+ | Environment snippets | Point SDKs at `http://127.0.0.1:8080`. |
139
+ | SDK patches | Show how to route Stripe and OpenAI SDKs into GhostAPI. |
140
+ | Safety guidance | Warn before live providers or live-looking keys enter the loop. |
141
+
65
142
  ## MCP Setup
66
143
 
67
144
  Start the MCP server:
@@ -70,7 +147,7 @@ Start the MCP server:
70
147
  npx @yiaany/ghostapi mcp
71
148
  ```
72
149
 
73
- Universal stdio MCP config:
150
+ Universal MCP config:
74
151
 
75
152
  ```json
76
153
  {
@@ -83,30 +160,50 @@ Universal stdio MCP config:
83
160
  }
84
161
  ```
85
162
 
86
- Generate repo-specific setup snippets for Cursor, Claude, Cline, Aider, Codex, OpenCode, Gemini CLI, Goose, OpenClaw, Hermes Desktop, and generic MCP clients:
163
+ Agent prompt:
87
164
 
88
- ```bash
89
- npx @yiaany/ghostapi setup --write
165
+ ```text
166
+ Use the GhostAPI MCP server.
167
+
168
+ Keep all third-party API calls local on http://127.0.0.1:8080.
169
+ Do not call real providers.
170
+
171
+ Use GhostAPI MCP tools to inspect state, read traffic logs, configure deterministic responses, and test failure scenarios.
90
172
  ```
91
173
 
92
- ## MCP Tools
174
+ MCP tools:
93
175
 
94
176
  | Tool | Purpose |
95
177
  | --- | --- |
96
178
  | `inspect_state` | Read local API objects from `.ghostapi/state.json`. |
97
179
  | `get_traffic_logs` | Inspect recent local traffic. |
98
- | `set_api_behavior` | Force a deterministic response for `method + path`. |
99
- | `toggle_chaos_mode` | Enable local latency and error injection. |
100
-
101
- ## Stripe Locally
180
+ | `set_api_behavior` | Force deterministic responses for `method + path`. |
181
+ | `toggle_chaos_mode` | Enable local latency and provider-shaped errors. |
102
182
 
103
- Install Stripe:
183
+ ## How It Works
104
184
 
105
- ```bash
106
- npm install stripe
185
+ ```text
186
+ Your app or agent
187
+ -> http://127.0.0.1:8080
188
+ -> GhostAPI proxy
189
+ -> provider detection
190
+ -> local state / scenarios / deterministic behavior
191
+ -> dashboard + MCP inspection
107
192
  ```
108
193
 
109
- Point the Stripe SDK at GhostAPI:
194
+ GhostAPI does five things in the loop:
195
+
196
+ | Step | What happens |
197
+ | --- | --- |
198
+ | Detect | It infers the provider from routes, headers, SDK shapes, and request bodies. |
199
+ | Normalize | It converts requests into safe, inspectable local events. |
200
+ | Mask | It strips secret-looking values before logs, cache, dashboard, and prompts. |
201
+ | Respond | It returns provider-shaped mock responses, errors, or saved state. |
202
+ | Control | MCP and dashboard tools let agents force behavior and replay flows. |
203
+
204
+ ## SDK Recipes
205
+
206
+ Stripe:
110
207
 
111
208
  ```ts
112
209
  import Stripe from "stripe";
@@ -118,21 +215,7 @@ export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? "stripe_test_g
118
215
  });
119
216
  ```
120
217
 
121
- Now Stripe-shaped calls go to GhostAPI instead of real Stripe:
122
-
123
- ```text
124
- POST http://127.0.0.1:8080/v1/payment_intents
125
- ```
126
-
127
- ## OpenAI Locally
128
-
129
- Install OpenAI:
130
-
131
- ```bash
132
- npm install openai
133
- ```
134
-
135
- Point the OpenAI SDK at GhostAPI:
218
+ OpenAI:
136
219
 
137
220
  ```ts
138
221
  import OpenAI from "openai";
@@ -143,18 +226,43 @@ export const openai = new OpenAI({
143
226
  });
144
227
  ```
145
228
 
146
- ## Agent Prompt
229
+ Generic REST:
147
230
 
148
- ```text
149
- Use the GhostAPI MCP server.
231
+ ```bash
232
+ curl -X POST http://127.0.0.1:8080/tasks \
233
+ -H "content-type: application/json" \
234
+ -d '{"title":"Write integration tests","status":"open"}'
235
+ ```
150
236
 
151
- Keep all third-party API calls local on http://127.0.0.1:8080.
152
- Do not call real providers.
237
+ ## Built For
153
238
 
154
- Use GhostAPI MCP tools to inspect state, read traffic logs, configure deterministic responses, and test failure scenarios.
155
- ```
239
+ | Audience | Use GhostAPI to |
240
+ | --- | --- |
241
+ | AI coding agents | Build integrations without accidentally touching production. |
242
+ | SaaS developers | Test provider happy paths and failure paths locally. |
243
+ | API-heavy teams | Turn captured traffic into repeatable scenarios and tests. |
244
+ | Open-source maintainers | Give contributors safe examples that do not require live provider accounts. |
245
+
246
+ ## Safety Model
247
+
248
+ - No real provider calls by default.
249
+ - Keep SDKs pointed at `http://127.0.0.1:8080`.
250
+ - Use fake local keys like `stripe_test_ghostapi` and `sk-ghostapi`.
251
+ - Secrets are masked before logs, cache, dashboard, events, and prompts.
252
+ - Chaos Mode is opt-in.
253
+ - Local state lives under `.ghostapi/` and is gitignored.
254
+
255
+ ## Local Files
256
+
257
+ | Path | Purpose |
258
+ | --- | --- |
259
+ | `.ghostapi/config.json` | Local GhostAPI config. |
260
+ | `.ghostapi/state.json` | Simulated API object state. |
261
+ | `.ghostapi/events.jsonl` | Captured local request events. |
262
+ | `.ghostapi/behaviors.json` | Deterministic behavior overrides. |
263
+ | `.ghostapi/cache/` | Local response cache. |
156
264
 
157
- ## Common Commands
265
+ ## CLI Reference
158
266
 
159
267
  ```bash
160
268
  npx @yiaany/ghostapi start --open
@@ -168,23 +276,42 @@ npx @yiaany/ghostapi providers list
168
276
  npx @yiaany/ghostapi providers inspect stripe
169
277
  ```
170
278
 
171
- ## Why
279
+ ## Repository About
172
280
 
173
- AI agents are great at writing integration code. They also run that code. GhostAPI gives them a safe local world where failures are realistic, traffic is visible, scenarios are replayable, and production keys never need to be used.
281
+ Use this for the GitHub repository description:
174
282
 
175
- ## Safety
283
+ ```text
284
+ The local internet for AI coding agents. Simulate Stripe, OpenAI, Twilio, Resend, GitHub, Discord, and REST APIs locally with a dashboard, MCP tools, scenarios, and secret masking.
285
+ ```
176
286
 
177
- - No real provider calls by default.
178
- - Keep SDKs pointed at `http://127.0.0.1:8080`.
179
- - Use fake local keys like `stripe_test_ghostapi` and `sk-ghostapi`.
180
- - Secrets are masked before logs, cache, dashboard, events, and prompts.
181
- - Chaos Mode is opt-in.
287
+ Recommended topics:
288
+
289
+ ```text
290
+ mcp, ai-agents, stripe, openai, mock-server, api-testing, sandbox, proxy, local-development, typescript, cursor
291
+ ```
182
292
 
183
293
  ## Docs
184
294
 
185
- - GitHub: https://github.com/ghostapi/ghostapi
186
- - Issues: https://github.com/ghostapi/ghostapi/issues
295
+ - [MCP setup](docs/mcp.md)
296
+ - [Usage guide](docs/usage.md)
297
+ - [Release checklist](docs/release-checklist.md)
298
+ - [Contributing](CONTRIBUTING.md)
299
+ - [Security policy](SECURITY.md)
300
+
301
+ ## Contributing
302
+
303
+ Contributions are welcome. GhostAPI should stay local-first, safe by default, and useful for real agent workflows.
304
+
305
+ Before opening a pull request:
306
+
307
+ ```bash
308
+ npm run typecheck
309
+ npm test
310
+ npm run build
311
+ ```
312
+
313
+ Do not add tests or examples that call live providers by default. See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
187
314
 
188
315
  ## License
189
316
 
190
- MIT
317
+ MIT. See [LICENSE](LICENSE).
Binary file
Binary file
package/docs/mcp.md ADDED
@@ -0,0 +1,50 @@
1
+ # GhostAPI MCP Setup
2
+
3
+ GhostAPI ships with a local stdio MCP server so coding agents can inspect and control the local API world.
4
+
5
+ ## Start MCP
6
+
7
+ ```bash
8
+ npx @yiaany/ghostapi mcp
9
+ ```
10
+
11
+ ## Universal Config
12
+
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "ghostapi": {
17
+ "command": "npx",
18
+ "args": ["-y", "@yiaany/ghostapi", "mcp"]
19
+ }
20
+ }
21
+ }
22
+ ```
23
+
24
+ ## Generate Client Snippets
25
+
26
+ ```bash
27
+ npx @yiaany/ghostapi setup --write
28
+ ```
29
+
30
+ This writes copy-ready local snippets under `.ghostapi/agent-configs/` and project instructions for supported agent clients.
31
+
32
+ ## Tools
33
+
34
+ | Tool | Purpose |
35
+ | --- | --- |
36
+ | `inspect_state` | Read local API objects from `.ghostapi/state.json`. |
37
+ | `get_traffic_logs` | Inspect recent captured API traffic. |
38
+ | `set_api_behavior` | Force a deterministic local response for `method + path`. |
39
+ | `toggle_chaos_mode` | Enable or disable local latency and error injection. |
40
+
41
+ ## Agent Prompt
42
+
43
+ ```text
44
+ Use the GhostAPI MCP server.
45
+
46
+ Keep all third-party API calls local on http://127.0.0.1:8080.
47
+ Do not call real providers.
48
+
49
+ Use GhostAPI MCP tools to inspect state, read traffic logs, configure deterministic responses, and test failure scenarios.
50
+ ```
package/docs/usage.md ADDED
@@ -0,0 +1,57 @@
1
+ # GhostAPI Usage Guide
2
+
3
+ ## Start The Local API
4
+
5
+ ```bash
6
+ npx @yiaany/ghostapi start --open
7
+ ```
8
+
9
+ GhostAPI listens on:
10
+
11
+ ```text
12
+ http://127.0.0.1:8080
13
+ ```
14
+
15
+ Dashboard:
16
+
17
+ ```text
18
+ http://127.0.0.1:8080/dashboard
19
+ ```
20
+
21
+ ## Send A Local Request
22
+
23
+ ```bash
24
+ curl -X POST http://127.0.0.1:8080/v1/customers \
25
+ -H "content-type: application/json" \
26
+ -H "authorization: Bearer stripe_test_ghostapi" \
27
+ -d '{"email":"ada@example.com","name":"Ada Lovelace"}'
28
+ ```
29
+
30
+ ## Stripe SDK
31
+
32
+ ```ts
33
+ import Stripe from "stripe";
34
+
35
+ export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? "stripe_test_ghostapi", {
36
+ host: process.env.GHOSTAPI_HOST ?? "127.0.0.1",
37
+ port: Number(process.env.GHOSTAPI_PORT ?? "8080"),
38
+ protocol: process.env.GHOSTAPI_PROTOCOL ?? "http"
39
+ });
40
+ ```
41
+
42
+ ## OpenAI SDK
43
+
44
+ ```ts
45
+ import OpenAI from "openai";
46
+
47
+ export const openai = new OpenAI({
48
+ apiKey: process.env.OPENAI_API_KEY ?? "sk-ghostapi",
49
+ baseURL: process.env.GHOSTAPI_OPENAI_BASE_URL ?? "http://127.0.0.1:8080/v1"
50
+ });
51
+ ```
52
+
53
+ ## Failure Scenarios
54
+
55
+ Use MCP or the dashboard to force deterministic responses such as Stripe card declines, rate limits, upstream errors, and latency.
56
+
57
+ The goal is to make failure handling repeatable instead of relying on live provider behavior.
@@ -15,7 +15,7 @@ Create a customer:
15
15
  ```bash
16
16
  curl -X POST http://localhost:8080/v1/customers \
17
17
  -H "content-type: application/json" \
18
- -H "authorization: Bearer sk_test_local_only" \
18
+ -H "authorization: Bearer stripe_test_local_only" \
19
19
  -d '{"email":"ada@example.com","name":"Ada Lovelace","metadata":{"source":"ghostapi-example"}}'
20
20
  ```
21
21
 
@@ -23,7 +23,7 @@ Copy the returned `id`, then fetch it:
23
23
 
24
24
  ```bash
25
25
  curl http://localhost:8080/v1/customers/cus_mock_example \
26
- -H "authorization: Bearer sk_test_local_only"
26
+ -H "authorization: Bearer stripe_test_local_only"
27
27
  ```
28
28
 
29
29
  GhostAPI detects Stripe from the `/v1/customers` path and keeps the created object in `.ghostapi/state.json`.
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@yiaany/ghostapi",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "The local internet for AI coding agents.",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/ghostapi/ghostapi.git"
8
+ "url": "git+https://github.com/yiaany/ghostapi.git"
9
9
  },
10
10
  "bugs": {
11
- "url": "https://github.com/ghostapi/ghostapi/issues"
11
+ "url": "https://github.com/yiaany/ghostapi/issues"
12
12
  },
13
- "homepage": "https://github.com/ghostapi/ghostapi#readme",
13
+ "homepage": "https://github.com/yiaany/ghostweb#readme",
14
14
  "bin": {
15
15
  "ghostapi": "dist/cli/index.js"
16
16
  },