x402-engineer 0.1.2 → 0.1.3
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 +1 -1
- package/skills/x402-init/SKILL.md +92 -4
package/package.json
CHANGED
|
@@ -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,94 @@ 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 --
|
|
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
|
+
## Step 8 -- Summary
|
|
165
251
|
|
|
166
252
|
Count the files created during this run and output:
|
|
167
253
|
|
|
@@ -170,18 +256,20 @@ Count the files created during this run and output:
|
|
|
170
256
|
List each file with its relative path from the project root, for example:
|
|
171
257
|
|
|
172
258
|
```
|
|
173
|
-
x402 initialized. Created
|
|
259
|
+
x402 initialized. Created 4 files:
|
|
174
260
|
- lib/x402/config.ts
|
|
175
261
|
- lib/x402/server.ts
|
|
176
262
|
- .env.example
|
|
263
|
+
- .env.local
|
|
177
264
|
```
|
|
178
265
|
|
|
179
266
|
For Fastify projects, the adapter file is also listed:
|
|
180
267
|
|
|
181
268
|
```
|
|
182
|
-
x402 initialized. Created
|
|
269
|
+
x402 initialized. Created 5 files:
|
|
183
270
|
- lib/x402/config.ts
|
|
184
271
|
- lib/x402/server.ts
|
|
185
272
|
- lib/x402/adapter.ts
|
|
186
273
|
- .env.example
|
|
274
|
+
- .env.local
|
|
187
275
|
```
|