x402-engineer 0.1.2 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x402-engineer",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Claude Code skill pack for adding x402 micropayments to any API endpoint",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -148,7 +148,6 @@ Run the framework-specific install command via Bash:
148
148
  6. Check if `.env.example` already exists at the project root:
149
149
  - If it does NOT exist: create `.env.example` with the template content
150
150
  - If it DOES exist: check if it already contains `SERVER_STELLAR_ADDRESS`. If not, append the x402 section to the existing file
151
- 7. Output: `"Created .env.example with required variables. Copy to .env.local and fill in your values."`
152
151
 
153
152
  ## Step 6 -- Scaffold Server/Middleware Files
154
153
 
@@ -161,7 +160,102 @@ Run the framework-specific install command via Bash:
161
160
  5. Extract the TypeScript code from the template's fenced code block
162
161
  6. Write to `{base_dir}/x402/adapter.ts`
163
162
 
164
- ## Step 7 -- Summary
163
+ ## Step 7 -- Configure Environment (Interactive)
164
+
165
+ Guide the user through setting up `.env.local` with the required values. Check if `.env.local` already exists and has values before prompting.
166
+
167
+ ### 7a -- Check existing .env.local
168
+
169
+ 1. Use Read to check if `.env.local` exists
170
+ 2. If it exists and already contains `SERVER_STELLAR_ADDRESS` with a non-empty value, output:
171
+ `"Environment already configured in .env.local. Skipping setup."`
172
+ Skip to Step 8.
173
+
174
+ ### 7b -- SERVER_STELLAR_ADDRESS
175
+
176
+ Output the following explanation:
177
+
178
+ ```
179
+ To receive payments, you need a Stellar account address.
180
+ This is a public key that starts with "G" (56 characters).
181
+
182
+ How to get one:
183
+ 1. Go to https://laboratory.stellar.org/#account-creator?network=test
184
+ 2. Click "Generate Keypair"
185
+ 3. Save both keys -- you'll use the Public Key (G...) here
186
+ 4. Click "Fund account on testnet" to get test XLM
187
+
188
+ If you already have a Stellar address, paste it below.
189
+ ```
190
+
191
+ Ask the user for the value. Accept any input that:
192
+ - Starts with `G` and is 56 characters long
193
+ - OR is empty (user wants to skip for now)
194
+
195
+ If the user provides an invalid format, warn once: `"Stellar addresses start with G and are 56 characters. This doesn't look right, but I'll use it anyway."` and proceed.
196
+
197
+ If the user skips (empty), set `SERVER_STELLAR_ADDRESS=` (empty value).
198
+
199
+ ### 7c -- FACILITATOR_API_KEY
200
+
201
+ Output the following explanation:
202
+
203
+ ```
204
+ The facilitator is a service (by OpenZeppelin) that verifies and settles
205
+ x402 payments on your behalf. You need an API key to use it.
206
+
207
+ How to get one:
208
+ 1. Go to https://channels.openzeppelin.com/testnet/gen
209
+ 2. Generate a new API key
210
+ 3. Paste it below
211
+
212
+ This takes ~30 seconds. I'll wait.
213
+ ```
214
+
215
+ Ask the user for the value. Accept any non-empty string, or empty to skip.
216
+
217
+ If the user skips (empty), set `FACILITATOR_API_KEY=` (empty value).
218
+
219
+ ### 7d -- Write .env.local
220
+
221
+ Write `.env.local` with the collected values:
222
+
223
+ ```env
224
+ # x402 Payment Configuration
225
+
226
+ # Stellar public key (G...) that receives USDC payments
227
+ SERVER_STELLAR_ADDRESS={collected_value}
228
+
229
+ # OpenZeppelin facilitator endpoint
230
+ FACILITATOR_URL=https://channels.openzeppelin.com/x402/testnet
231
+
232
+ # API key from https://channels.openzeppelin.com/testnet/gen
233
+ FACILITATOR_API_KEY={collected_value}
234
+ ```
235
+
236
+ **Rules:**
237
+ - Always set `FACILITATOR_URL` to the testnet endpoint (no need to ask -- testnet is the right default for init)
238
+ - If `.env.local` already exists with OTHER variables (not x402-related), append the x402 section. Do not overwrite existing content.
239
+ - Add `.env.local` to `.gitignore` if not already present (check first for idempotency)
240
+
241
+ ### 7e -- Report status
242
+
243
+ If both values were provided:
244
+ `"Environment configured. .env.local is ready."`
245
+
246
+ If one or both were skipped:
247
+ `"Created .env.local with partial configuration. Fill in the missing values before testing:"`
248
+ Then list which variables are still empty.
249
+
250
+ ### 7f -- Env Loading Guidance (Brownfield Only)
251
+
252
+ If this is a brownfield project (Step 0 was skipped because a framework was already in `package.json`), output:
253
+
254
+ `"Note: Make sure your dev script loads .env.local. For tsx or Node.js 20+, add --env-file=.env.local to your dev command. Example: \"tsx watch --env-file=.env.local src/server.ts\""`
255
+
256
+ This is advisory only -- do NOT modify the user's `package.json` scripts automatically.
257
+
258
+ ## Step 8 -- Summary
165
259
 
166
260
  Count the files created during this run and output:
167
261
 
@@ -170,18 +264,20 @@ Count the files created during this run and output:
170
264
  List each file with its relative path from the project root, for example:
171
265
 
172
266
  ```
173
- x402 initialized. Created 3 files:
267
+ x402 initialized. Created 4 files:
174
268
  - lib/x402/config.ts
175
269
  - lib/x402/server.ts
176
270
  - .env.example
271
+ - .env.local
177
272
  ```
178
273
 
179
274
  For Fastify projects, the adapter file is also listed:
180
275
 
181
276
  ```
182
- x402 initialized. Created 4 files:
277
+ x402 initialized. Created 5 files:
183
278
  - lib/x402/config.ts
184
279
  - lib/x402/server.ts
185
280
  - lib/x402/adapter.ts
186
281
  - .env.example
282
+ - .env.local
187
283
  ```
@@ -8,7 +8,7 @@ Minimal package.json for a new Express + TypeScript project.
8
8
  "version": "0.1.0",
9
9
  "type": "module",
10
10
  "scripts": {
11
- "dev": "tsx watch src/server.ts",
11
+ "dev": "tsx watch --env-file=.env.local src/server.ts",
12
12
  "build": "tsc",
13
13
  "start": "node dist/server.js"
14
14
  },
@@ -8,7 +8,7 @@ Minimal package.json for a new Fastify + TypeScript project.
8
8
  "version": "0.1.0",
9
9
  "type": "module",
10
10
  "scripts": {
11
- "dev": "tsx watch src/server.ts",
11
+ "dev": "tsx watch --env-file=.env.local src/server.ts",
12
12
  "build": "tsc",
13
13
  "start": "node dist/server.js"
14
14
  },
@@ -8,7 +8,7 @@ Minimal package.json for a new Hono + TypeScript project.
8
8
  "version": "0.1.0",
9
9
  "type": "module",
10
10
  "scripts": {
11
- "dev": "tsx watch src/server.ts",
11
+ "dev": "tsx watch --env-file=.env.local src/server.ts",
12
12
  "build": "tsc",
13
13
  "start": "node dist/server.js"
14
14
  },
@@ -54,7 +54,7 @@ If no project exists, scaffold with Express (the only framework with official x4
54
54
  ### Step 2 — Install Dependencies
55
55
 
56
56
  ```bash
57
- npm install @x402/express @x402/stellar @x402/core @stellar/stellar-sdk dotenv
57
+ npm install @x402/express @x402/stellar @x402/core @stellar/stellar-sdk
58
58
  ```
59
59
 
60
60
  For TypeScript projects, also install:
@@ -9,8 +9,6 @@ import express from "express";
9
9
  import { paymentMiddleware, x402ResourceServer } from "@x402/express";
10
10
  import { ExactStellarScheme } from "@x402/stellar/exact/server";
11
11
  import { HTTPFacilitatorClient } from "@x402/core/server";
12
- import "dotenv/config";
13
-
14
12
  // 1. Create the facilitator client with auth headers
15
13
  const facilitatorClient = new HTTPFacilitatorClient({
16
14
  url: process.env.FACILITATOR_URL || "https://channels.openzeppelin.com/x402/testnet",
@@ -83,8 +81,6 @@ app.listen(PORT, () => {
83
81
  import { createEd25519Signer } from "@x402/stellar";
84
82
  import { ExactStellarScheme } from "@x402/stellar/exact/client";
85
83
  import { x402Client, x402HTTPClient } from "@x402/core/client";
86
- import "dotenv/config";
87
-
88
84
  const SERVER_URL = process.env.SERVER_URL || "http://localhost:3000";
89
85
 
90
86
  // 1. Create the signer from the client's secret key