aavegotchi-cli 0.2.0 → 0.2.2

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/dist/output.js CHANGED
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildHelpText = buildHelpText;
3
4
  exports.outputSuccess = outputSuccess;
4
5
  exports.outputError = outputError;
5
6
  exports.outputHelp = outputHelp;
7
+ const args_1 = require("./args");
8
+ const abi_1 = require("./abi");
9
+ const command_catalog_1 = require("./command-catalog");
10
+ const mapped_1 = require("./commands/mapped");
11
+ const stubs_1 = require("./commands/stubs");
6
12
  function stringifyWithBigInt(input) {
7
13
  return JSON.stringify(input, (_, value) => {
8
14
  if (typeof value === "bigint") {
@@ -17,6 +23,397 @@ function buildMeta(mode) {
17
23
  mode,
18
24
  };
19
25
  }
26
+ function toLines(items, prefix = " ") {
27
+ if (items.length === 0) {
28
+ return `${prefix}(none)`;
29
+ }
30
+ return items.map((item) => `${prefix}${item}`).join("\n");
31
+ }
32
+ function buildGlobalHelpText() {
33
+ return `
34
+ Aavegotchi CLI (agent-first foundation)
35
+
36
+ Usage:
37
+ ag <command> [options]
38
+ ag <command> --help
39
+ ag help <command>
40
+
41
+ Core commands:
42
+ bootstrap
43
+ profile list|show|use|export
44
+ signer check
45
+ signer keychain list|import|remove
46
+ policy list|show|upsert
47
+ rpc check
48
+
49
+ Tx commands:
50
+ tx send|status|resume|watch
51
+
52
+ Automation commands:
53
+ batch run --file plan.yaml
54
+
55
+ Power-user commands:
56
+ onchain call|send
57
+ subgraph list|check|query
58
+
59
+ Subgraph wrappers:
60
+ baazaar listing get|active|mine
61
+ auction get|active|mine|bids|bids-mine
62
+
63
+ Domain namespaces:
64
+ gotchi, portal, wearables, items, inventory, baazaar, auction, lending, staking, gotchi-points, realm, alchemica, forge, token
65
+ (many write flows are mapped aliases that route through onchain send)
66
+
67
+ Global flags:
68
+ --mode <agent|human> Agent mode implies --json --yes
69
+ --json, -j Emit JSON envelope output
70
+ --yes, -y Skip prompts
71
+ --profile NAME Select profile globally
72
+ --help, -h Show command-specific help
73
+
74
+ Examples:
75
+ ag bootstrap --profile prod --chain base --signer readonly --json
76
+ ag tx send --profile prod --to 0xabc... --value-wei 0 --dry-run --json
77
+ ag onchain send --profile prod --abi-file ./abi.json --address 0xabc... --function approve --args-json '["0xdef...", "1"]' --dry-run --json
78
+ BANKR_API_KEY=... ag bootstrap --profile bankr --chain base --signer bankr --json
79
+ ag baazaar buy-now --help
80
+ ag help tx send
81
+ `;
82
+ }
83
+ const STATIC_HELP = {
84
+ bootstrap: `
85
+ Usage:
86
+ ag bootstrap --profile <name> [--chain <base|base-sepolia|id>] [--rpc-url <url>] [--signer <config>] [--policy <name>] [--skip-signer-check] [--json]
87
+
88
+ Required:
89
+ --profile <name>
90
+
91
+ Signer formats:
92
+ readonly
93
+ env:ENV_VAR
94
+ keychain:ACCOUNT_ID
95
+ ledger[:DERIVATION_PATH|ADDRESS|BRIDGE_ENV_VAR]
96
+ remote:URL|ADDRESS|AUTH_ENV_VAR
97
+ bankr[:ADDRESS|API_KEY_ENV|API_URL]
98
+ `,
99
+ profile: `
100
+ Usage:
101
+ ag profile list [--json]
102
+ ag profile show [--profile <name>] [--json]
103
+ ag profile use --profile <name> [--json]
104
+ ag profile export [--profile <name>] [--json]
105
+ `,
106
+ "profile list": `
107
+ Usage:
108
+ ag profile list [--json]
109
+ `,
110
+ "profile show": `
111
+ Usage:
112
+ ag profile show [--profile <name>] [--json]
113
+ `,
114
+ "profile use": `
115
+ Usage:
116
+ ag profile use --profile <name> [--json]
117
+ `,
118
+ "profile export": `
119
+ Usage:
120
+ ag profile export [--profile <name>] [--json]
121
+ `,
122
+ signer: `
123
+ Usage:
124
+ ag signer check [--profile <name>] [--json]
125
+ ag signer keychain list [--json]
126
+ ag signer keychain import --account-id <id> --private-key-env <ENV> [--json]
127
+ ag signer keychain remove --account-id <id> [--json]
128
+ `,
129
+ "signer check": `
130
+ Usage:
131
+ ag signer check [--profile <name>] [--json]
132
+ `,
133
+ "signer keychain": `
134
+ Usage:
135
+ ag signer keychain list [--json]
136
+ ag signer keychain import --account-id <id> --private-key-env <ENV> [--json]
137
+ ag signer keychain remove --account-id <id> [--json]
138
+ `,
139
+ "signer keychain list": `
140
+ Usage:
141
+ ag signer keychain list [--json]
142
+ `,
143
+ "signer keychain import": `
144
+ Usage:
145
+ ag signer keychain import --account-id <id> --private-key-env <ENV> [--json]
146
+ `,
147
+ "signer keychain remove": `
148
+ Usage:
149
+ ag signer keychain remove --account-id <id> [--json]
150
+ `,
151
+ policy: `
152
+ Usage:
153
+ ag policy list [--json]
154
+ ag policy show --policy <name> [--json]
155
+ ag policy upsert --policy <name> [--max-value-wei <wei>] [--max-gas-limit <gas>] [--max-fee-per-gas-wei <wei>] [--max-priority-fee-per-gas-wei <wei>] [--allowed-to <0x...,0x...>] [--json]
156
+ `,
157
+ "policy list": `
158
+ Usage:
159
+ ag policy list [--json]
160
+ `,
161
+ "policy show": `
162
+ Usage:
163
+ ag policy show --policy <name> [--json]
164
+ `,
165
+ "policy upsert": `
166
+ Usage:
167
+ ag policy upsert --policy <name> [policy flags...] [--json]
168
+ `,
169
+ rpc: `
170
+ Usage:
171
+ ag rpc check [--profile <name>] [--rpc-url <url>] [--json]
172
+ `,
173
+ "rpc check": `
174
+ Usage:
175
+ ag rpc check [--profile <name>] [--rpc-url <url>] [--json]
176
+ `,
177
+ tx: `
178
+ Usage:
179
+ ag tx send --to <0x...> [--value-wei <wei>] [--data <0x...>] [--profile <name>] [--nonce-policy <safe|replace|manual>] [--nonce <n>] [--dry-run] [--wait|--confirm] [--timeout-ms <ms>] [--json]
180
+ ag tx status [--idempotency-key <key> | --tx-hash <0x...> | --limit <n>] [--json]
181
+ ag tx resume --idempotency-key <key> [--profile <name>] [--timeout-ms <ms>] [--json]
182
+ ag tx watch --idempotency-key <key> [--interval-ms <ms>] [--timeout-ms <ms>] [--json]
183
+
184
+ Notes:
185
+ --dry-run cannot be combined with --wait/--confirm.
186
+ `,
187
+ "tx send": `
188
+ Usage:
189
+ ag tx send --to <0x...> [--value-wei <wei>] [--data <0x...>] [--profile <name>] [--dry-run] [--wait|--confirm] [--json]
190
+ `,
191
+ "tx status": `
192
+ Usage:
193
+ ag tx status [--idempotency-key <key> | --tx-hash <0x...> | --limit <n>] [--json]
194
+ `,
195
+ "tx resume": `
196
+ Usage:
197
+ ag tx resume --idempotency-key <key> [--profile <name>] [--timeout-ms <ms>] [--json]
198
+ `,
199
+ "tx watch": `
200
+ Usage:
201
+ ag tx watch --idempotency-key <key> [--interval-ms <ms>] [--timeout-ms <ms>] [--json]
202
+ `,
203
+ onchain: `
204
+ Usage:
205
+ ag onchain call --profile <name> --abi-file <path> --address <0x...> --function <name> [--args-json '[...]'] [--json]
206
+ ag onchain send --profile <name> --abi-file <path> --address <0x...> --function <name> [--args-json '[...]'] [--value-wei <wei>] [--nonce-policy <safe|replace|manual>] [--nonce <n>] [--dry-run] [--wait] [--json]
207
+ `,
208
+ "onchain call": `
209
+ Usage:
210
+ ag onchain call --profile <name> --abi-file <path> --address <0x...> --function <name> [--args-json '[...]'] [--json]
211
+ `,
212
+ "onchain send": `
213
+ Usage:
214
+ ag onchain send --profile <name> --abi-file <path> --address <0x...> --function <name> [--args-json '[...]'] [--value-wei <wei>] [--nonce-policy <safe|replace|manual>] [--nonce <n>] [--dry-run] [--wait] [--json]
215
+
216
+ Required:
217
+ --abi-file
218
+ --address
219
+ --function
220
+ --profile (or active profile)
221
+
222
+ Notes:
223
+ --dry-run cannot be combined with --wait.
224
+ `,
225
+ subgraph: `
226
+ Usage:
227
+ ag subgraph list [--json]
228
+ ag subgraph check --source <core-base|gbm-base> [--timeout-ms <ms>] [--raw] [--json]
229
+ ag subgraph query --source <core-base|gbm-base> (--query <graphql> | --query-file <path>) [--variables-json '{...}'] [--timeout-ms <ms>] [--raw] [--json]
230
+ `,
231
+ "subgraph list": `
232
+ Usage:
233
+ ag subgraph list [--json]
234
+ `,
235
+ "subgraph check": `
236
+ Usage:
237
+ ag subgraph check --source <core-base|gbm-base> [--timeout-ms <ms>] [--raw] [--json]
238
+ `,
239
+ "subgraph query": `
240
+ Usage:
241
+ ag subgraph query --source <core-base|gbm-base> (--query <graphql> | --query-file <path>) [--variables-json '{...}'] [--timeout-ms <ms>] [--raw] [--json]
242
+ `,
243
+ batch: `
244
+ Usage:
245
+ ag batch run --file <plan.yaml> [--json]
246
+ `,
247
+ "batch run": `
248
+ Usage:
249
+ ag batch run --file <plan.yaml> [--json]
250
+ `,
251
+ baazaar: `
252
+ Usage:
253
+ ag baazaar listing get --kind <erc721|erc1155> --id <listingId> [--verify-onchain] [--json]
254
+ ag baazaar listing active --kind <erc721|erc1155> [--first <n>] [--skip <n>] [--json]
255
+ ag baazaar listing mine --kind <erc721|erc1155> --seller <0x...> [--first <n>] [--skip <n>] [--json]
256
+ ag baazaar <mapped-write> --help
257
+ `,
258
+ "baazaar listing": `
259
+ Usage:
260
+ ag baazaar listing get --kind <erc721|erc1155> --id <listingId> [--verify-onchain] [--json]
261
+ ag baazaar listing active --kind <erc721|erc1155> [--first <n>] [--skip <n>] [--json]
262
+ ag baazaar listing mine --kind <erc721|erc1155> --seller <0x...> [--first <n>] [--skip <n>] [--json]
263
+ `,
264
+ "baazaar listing get": `
265
+ Usage:
266
+ ag baazaar listing get --kind <erc721|erc1155> --id <listingId> [--verify-onchain] [--json]
267
+ `,
268
+ "baazaar listing active": `
269
+ Usage:
270
+ ag baazaar listing active --kind <erc721|erc1155> [--first <n>] [--skip <n>] [--json]
271
+ `,
272
+ "baazaar listing mine": `
273
+ Usage:
274
+ ag baazaar listing mine --kind <erc721|erc1155> --seller <0x...> [--first <n>] [--skip <n>] [--json]
275
+ `,
276
+ auction: `
277
+ Usage:
278
+ ag auction get --id <auctionId> [--verify-onchain] [--json]
279
+ ag auction active [--first <n>] [--skip <n>] [--at-time <unixSec>] [--json]
280
+ ag auction mine --seller <0x...> [--first <n>] [--skip <n>] [--at-time <unixSec>] [--json]
281
+ ag auction bids --auction-id <auctionId> [--first <n>] [--skip <n>] [--json]
282
+ ag auction bids-mine --bidder <0x...> [--first <n>] [--skip <n>] [--json]
283
+ ag auction <mapped-write> --help
284
+ `,
285
+ "auction get": `
286
+ Usage:
287
+ ag auction get --id <auctionId> [--verify-onchain] [--json]
288
+ `,
289
+ "auction active": `
290
+ Usage:
291
+ ag auction active [--first <n>] [--skip <n>] [--at-time <unixSec>] [--json]
292
+ `,
293
+ "auction mine": `
294
+ Usage:
295
+ ag auction mine --seller <0x...> [--first <n>] [--skip <n>] [--at-time <unixSec>] [--json]
296
+ `,
297
+ "auction bids": `
298
+ Usage:
299
+ ag auction bids --auction-id <auctionId> [--first <n>] [--skip <n>] [--json]
300
+ `,
301
+ "auction bids-mine": `
302
+ Usage:
303
+ ag auction bids-mine --bidder <0x...> [--first <n>] [--skip <n>] [--json]
304
+ `,
305
+ };
306
+ function buildDomainRootHelp(root) {
307
+ const mapped = (0, mapped_1.listMappedCommandsForRoot)(root);
308
+ return `
309
+ Usage:
310
+ ag ${root} read --profile <name> --abi-file <path> --address <0x...> --function <name> [--args-json '[...]'] [--json]
311
+ ag ${root} <mapped-write> --help
312
+
313
+ Mapped writes for '${root}':
314
+ ${toLines(mapped)}
315
+ `;
316
+ }
317
+ function buildMappedCommandHelp(commandPath, flags) {
318
+ const command = commandPath.join(" ");
319
+ const method = (0, mapped_1.findMappedFunction)(commandPath);
320
+ if (!method) {
321
+ return "";
322
+ }
323
+ const abiFile = (0, args_1.getFlagString)(flags, "abi-file");
324
+ const signatureLines = [];
325
+ const inputLines = [];
326
+ if (abiFile) {
327
+ try {
328
+ const abi = (0, abi_1.parseAbiFile)(abiFile);
329
+ const entries = (0, abi_1.getAbiFunctionEntries)(abi, method);
330
+ if (entries.length === 0) {
331
+ signatureLines.push(`No function named '${method}' found in '${abiFile}'.`);
332
+ }
333
+ else {
334
+ for (const entry of entries) {
335
+ signatureLines.push((0, abi_1.formatAbiFunctionSignature)(entry));
336
+ inputLines.push(...(0, abi_1.formatAbiFunctionInputs)(entry));
337
+ }
338
+ }
339
+ }
340
+ catch (error) {
341
+ const message = error instanceof Error ? error.message : "Unable to parse ABI file.";
342
+ signatureLines.push(`Could not inspect ABI file '${abiFile}': ${message}`);
343
+ }
344
+ }
345
+ else {
346
+ signatureLines.push("Pass --abi-file <path> with --help to print exact ABI-derived signature and input names.");
347
+ }
348
+ return `
349
+ Usage:
350
+ ag ${command} --profile <name> --abi-file <path> --address <0x...> --args-json '[...]' [--value-wei <wei>] [--nonce-policy <safe|replace|manual>] [--nonce <n>] [--dry-run] [--wait] [--json]
351
+
352
+ Mapped to onchain function:
353
+ ${method}
354
+
355
+ Required flags:
356
+ --abi-file
357
+ --address
358
+ --args-json
359
+ --profile (or active profile)
360
+
361
+ Dry-run example:
362
+ ag ${command} --profile prod --abi-file ./abi.json --address 0xabc... --args-json '[<arg0>,<arg1>]' --dry-run --json
363
+
364
+ ABI signature info:
365
+ ${toLines(signatureLines)}
366
+
367
+ ABI inputs:
368
+ ${toLines(inputLines)}
369
+ `;
370
+ }
371
+ function buildUnknownHelpText(commandPath) {
372
+ const command = commandPath.join(" ");
373
+ const suggestions = (0, command_catalog_1.suggestCommands)(command);
374
+ const suggestionBlock = suggestions.length
375
+ ? `\nSuggested commands:\n${toLines(suggestions)}`
376
+ : "";
377
+ return `No command-specific help found for '${command}'.${suggestionBlock}
378
+
379
+ Use 'ag help' for the full command surface.
380
+ `;
381
+ }
382
+ function normalizeHelpPath(commandPath) {
383
+ return commandPath.map((part) => part.trim()).filter(Boolean);
384
+ }
385
+ function buildHelpText(commandPath = [], flags = {}) {
386
+ const target = normalizeHelpPath(commandPath);
387
+ if (target.length === 0) {
388
+ return buildGlobalHelpText().trim();
389
+ }
390
+ const mappedHelp = buildMappedCommandHelp(target, flags);
391
+ if (mappedHelp) {
392
+ return mappedHelp.trim();
393
+ }
394
+ const key = target.join(" ");
395
+ if (STATIC_HELP[key]) {
396
+ return STATIC_HELP[key].trim();
397
+ }
398
+ if (target.length === 1 && (0, stubs_1.isDomainStubRoot)(target[0])) {
399
+ return buildDomainRootHelp(target[0]).trim();
400
+ }
401
+ if (target.length > 1 && (0, stubs_1.isDomainStubRoot)(target[0])) {
402
+ const root = target[0];
403
+ const mapped = (0, mapped_1.listMappedCommandsForRoot)(root);
404
+ return `
405
+ No direct help entry for '${key}'.
406
+
407
+ Mapped writes under '${root}':
408
+ ${toLines(mapped)}
409
+
410
+ Try:
411
+ ag ${root} --help
412
+ ag ${root} read --help
413
+ `.trim();
414
+ }
415
+ return buildUnknownHelpText(target).trim();
416
+ }
20
417
  function outputSuccess(command, data, globals) {
21
418
  if (globals.json) {
22
419
  const envelope = {
@@ -53,69 +450,6 @@ function outputError(command, error, globals) {
53
450
  console.error(stringifyWithBigInt(error.details));
54
451
  }
55
452
  }
56
- function outputHelp() {
57
- console.log(`
58
- Aavegotchi CLI (agent-first foundation)
59
-
60
- Usage:
61
- ag <command> [options]
62
-
63
- Core commands:
64
- bootstrap Create/update and activate a profile with RPC/signer preflight
65
- profile list|show|use|export Manage profiles
66
- signer check Verify active profile signer backend and account readiness
67
- signer keychain list|import|remove
68
- policy list|show|upsert Manage transaction policies
69
- rpc check Verify RPC connectivity + signer backend health
70
-
71
- Tx commands:
72
- tx send Send a raw EVM transaction with simulation + policy checks + journaling
73
- tx status Read tx status by idempotency key/hash or list recent
74
- tx resume Resume waiting for a previously submitted tx
75
- tx watch Poll journal until tx is confirmed
76
-
77
- Automation commands:
78
- batch run --file plan.yaml Run a YAML execution plan (dependency-aware)
79
-
80
- Power-user commands:
81
- onchain call Call any ABI function from --abi-file
82
- onchain send Send any ABI function as a transaction
83
- subgraph list|check|query List/check/query canonical Goldsky subgraphs
84
-
85
- Domain namespaces:
86
- gotchi, portal, wearables, items, inventory, baazaar, auction, lending, staking, gotchi-points, realm, alchemica, forge, token
87
- (many write flows are mapped to onchain send aliases; unmatched commands return typed not-implemented)
88
-
89
- Subgraph wrappers:
90
- baazaar listing get|active|mine Read Baazaar listing data from core-base subgraph
91
- auction get|active|mine|bids|bids-mine
92
- Read GBM auction/bid data from gbm-base subgraph
93
-
94
- Global flags:
95
- --mode <agent|human> Agent mode implies --json --yes
96
- --json, -j Emit JSON envelope output
97
- --yes, -y Skip prompts (write commands assume explicit flags)
98
- --profile NAME Select profile globally
99
-
100
- Bootstrap flags:
101
- --profile NAME Profile to create or update (required)
102
- --chain base|base-sepolia|<id> Chain key or numeric chain id (default: base)
103
- --rpc-url URL RPC endpoint (optional when chain preset exists)
104
- --signer readonly|env:VAR|keychain:<id>|ledger[:path|address|bridgeEnv]|remote:<url|address|authEnv>
105
- --signer-address 0x... Optional override for remote/ledger signer address
106
- --signer-auth-env-var ENV_VAR Optional remote signer bearer token env var
107
- --signer-bridge-env-var ENV_VAR Optional ledger bridge command env var name
108
- --policy NAME Policy label (default: default)
109
- --skip-signer-check Persist signer config without backend validation
110
-
111
- Examples:
112
- ag bootstrap --mode agent --profile prod --chain base --signer env:AGCLI_PRIVATE_KEY --json
113
- AGCLI_KEYCHAIN_PASSPHRASE=... AGCLI_PRIVATE_KEY=0x... ag signer keychain import --account-id bot --private-key-env AGCLI_PRIVATE_KEY --json
114
- ag tx send --profile prod --to 0xabc... --value-wei 1000000000000000 --wait --json
115
- ag subgraph check --source core-base --json
116
- ag baazaar listing active --kind erc721 --first 20 --json
117
- ag auction active --first 20 --json
118
- ag lending create --profile prod --abi-file ./abis/GotchiLendingFacet.json --address 0xabc... --args-json '[...]' --json
119
- ag batch run --file ./plan.yaml --json
120
- `);
453
+ function outputHelp(commandPath = [], flags = {}) {
454
+ console.log(buildHelpText(commandPath, flags));
121
455
  }
package/dist/schemas.js CHANGED
@@ -22,6 +22,12 @@ exports.signerSchema = zod_1.z.discriminatedUnion("type", [
22
22
  address: addressSchema.optional(),
23
23
  authEnvVar: zod_1.z.string().regex(/^[A-Z_][A-Z0-9_]*$/).optional(),
24
24
  }),
25
+ zod_1.z.object({
26
+ type: zod_1.z.literal("bankr"),
27
+ address: addressSchema.optional(),
28
+ apiKeyEnvVar: zod_1.z.string().regex(/^[A-Z_][A-Z0-9_]*$/).optional(),
29
+ apiUrl: zod_1.z.string().url().optional(),
30
+ }),
25
31
  ]);
26
32
  exports.policySchema = zod_1.z.object({
27
33
  name: zod_1.z.string().min(1),