@secondlayer/cli 12.1.0 → 13.0.0

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.
Files changed (4) hide show
  1. package/README.md +69 -17
  2. package/dist/cli.js +2520 -509
  3. package/dist/cli.js.map +40 -33
  4. package/package.json +8 -6
package/README.md CHANGED
@@ -26,15 +26,29 @@ export SL_API_KEY=<INSTANCE_TOKEN>
26
26
 
27
27
  ```bash
28
28
  bun add -g @secondlayer/cli
29
- secondlayer init --network mainnet
30
- secondlayer start --print
31
- # docker compose -f docker/oss/docker-compose.yml up -d
29
+ secondlayer setup
32
30
 
33
31
  secondlayer subgraphs scaffold SP1234ABCD.my-contract -o subgraphs/my-contract.ts
34
32
  secondlayer subgraphs deploy subgraphs/my-contract.ts --start-block <recent-block>
35
33
  secondlayer subgraphs query my-contract <table> --sort _block_height --order desc
36
34
  ```
37
35
 
36
+ `secondlayer setup` is a guided wizard: it picks network + node mode (with the
37
+ RAM/disk floor shown live), generates secrets, writes `docker-compose.yml` and
38
+ `.env` into a target directory, brings the stack up, prints the observer
39
+ stanza for an external node, and restores + verifies history from the
40
+ archive — the one-command replacement for `init` → hand-copy secrets →
41
+ `docker compose up` → `observer` → `bootstrap` → `verify`. Without a TTY (or
42
+ with `--yes`), it skips the interactive prompts and runs from flags instead;
43
+ `--network` and `--node-mode` are then required, and `--against` is required
44
+ unless you pass `--skip-bootstrap`:
45
+
46
+ ```bash
47
+ secondlayer setup --yes \
48
+ --network mainnet --node-mode external \
49
+ --against https://archive.secondlayer.tools/latest.json
50
+ ```
51
+
38
52
  `secondlayer subgraphs scaffold` writes the definition file, creates/updates
39
53
  `package.json`, and runs `bun install` (pass `--no-install` to skip).
40
54
 
@@ -46,12 +60,50 @@ No account. Writes `.env.local`, restores history, prints the Stacks observer st
46
60
 
47
61
  | Command | What it does |
48
62
  |---|---|
63
+ | `secondlayer setup [--network …] [--node-mode external\|stacks\|full] [--api-port <spec>] [--dir <path>] [--against <manifest>] [--skip-bootstrap] [--skip-verify] [--yes] [--force]` | Guided self-host onboarding — secrets, compose + `.env`, docker up, observer stanza, bootstrap, verify. TUI when interactive; flags-only (no prompts) with `--yes` or no TTY |
49
64
  | `secondlayer init [--network mainnet\|testnet\|devnet] [--api-url <url>] [--force]` | Write `.env.local` (token, secrets key, webhook signing key). Idempotent |
50
65
  | `secondlayer start [--print]` | Validate one-box config and print `docker compose up` |
51
66
  | `secondlayer bootstrap --against <manifest> [--to-block <n>] [--public-key <pem>] [-y] [--json]` | Restore chain history from a verified archive into an empty database. Exit `0` restored, `1` diverged, `2` refused |
52
67
  | `secondlayer observer [--mode indexer\|signer-shared] [--endpoint host:port] [--recovery journal\|archive] [--network …]` | Print the `[[events_observer]]` stanza. Signer-shared requires `--recovery` |
53
68
  | `secondlayer verify [all\|raw\|decode:<name>\|subgraph:<name>] --against <manifest> [--quick\|--deep\|--anchor]` | Compare local data to a signed archive. Default target `raw`. Exit `0` clean, `1` diverged, `2` unanchored |
54
- | `secondlayer repair --against <archive> [--apply]` | Plan (default) or apply an archive repair |
69
+ | `secondlayer repair --against <archive> [--apply] [-y]` | Plan (default) or apply an archive repair |
70
+
71
+ Bootstrap and repair against the official hosted archive (`archive.secondlayer.tools`)
72
+ are metered per partition; against any other manifest (a mirror, a teammate's
73
+ box, a local file) they are free. See [Metered fetches](#metered-fetches).
74
+
75
+ ### Metered fetches
76
+
77
+ `secondlayer bootstrap` and `secondlayer repair` pull partitions from the
78
+ signed archive instead of replaying the chain, and that pull costs money only
79
+ when it targets the official hosted archive. Point `--against` at a mirror or
80
+ a local manifest and nothing is charged, nothing is even contacted beyond
81
+ that manifest, because self-hosting the archive is a supported way to use
82
+ these commands, not a workaround.
83
+
84
+ Against the official host, both commands quote before they charge:
85
+
86
+ 1. The manifest's partition list is priced with a free, no-write call
87
+ (`POST /api/archive/quote`).
88
+ 2. The quote prints into the existing plan output, for example
89
+ `metered: 528 partitions ≈ $44.00 · balance $50.00`, or for `repair`
90
+ inside its monthly allowance, `metered: free (4 of 6 monthly repair
91
+ fetches remaining)`.
92
+ 3. You confirm, or pass `-y` to skip the prompt. `-y` never skips the quote
93
+ or the balance check: if the balance is short, the command exits before
94
+ any partition is fetched and prints the shortfall and
95
+ `secondlayer credits buy`.
96
+ 4. Only then does the command fetch, and only the partitions it actually
97
+ reads are charged.
98
+
99
+ A partition already charged in the last 24 hours re-presigns for free, so a
100
+ resumed or retried bootstrap never pays twice for the same bytes. `repair`
101
+ gets 6 free range-bundles a month; `bootstrap` does not, since it is the
102
+ whole-chain operation the free tier exists to not subsidize.
103
+
104
+ `secondlayer verify` is unaffected: it reads manifests and digests, never
105
+ partition bytes, and stays free and anonymous no matter which archive it
106
+ points at.
55
107
 
56
108
  ### Subgraphs
57
109
 
@@ -59,22 +111,22 @@ No account. Writes `.env.local`, restores history, prints the Stacks observer st
59
111
  |---|---|
60
112
  | `secondlayer subgraphs create <name>` | Scaffold a definition file |
61
113
  | `secondlayer subgraphs scaffold <SP...::contract> [-o <path>] [--no-install]` | Generate a subgraph from a deployed contract |
62
- | `secondlayer subgraphs deploy <file> [--start-block <n>] [--visibility public\|private]` | Deploy; `--start-block` overrides the definition. Deploys default `public` |
114
+ | `secondlayer subgraphs deploy <file> [--start-block <n>]` | Deploy; `--start-block` overrides the definition |
63
115
  | `secondlayer subgraphs list` | List deployments (`ls` alias) |
64
116
  | `secondlayer subgraphs dev <file>` | Watch + hot-redeploy |
65
117
  | `secondlayer subgraphs query <name> <table>` | Query a table with filters, sort, pagination |
66
118
  | `secondlayer subgraphs status <name>` / `gaps <name>` | Inspect a deployment |
67
119
  | `secondlayer subgraphs spec <nameOrFile> [--format openapi\|agent\|markdown]` | Export API docs for a deployed subgraph or a local definition file |
68
- | `secondlayer subgraphs codegen <file> --target prisma\|drizzle [-o <path>]` | Generate a typed ORM schema for the subgraph's tables |
69
- | `secondlayer subgraphs client <name> -o <path>` | Generate a typed query client for a deployed subgraph |
70
- | `secondlayer subgraphs reindex/backfill/cancel/delete <name>` | Manage processing |
120
+ | `secondlayer codegen subgraph <file> --target kysely\|prisma\|drizzle [-o <path>]` | Generate a typed ORM schema for the subgraph's tables |
121
+ | `secondlayer codegen client <name> -o <path>` | Generate a typed query client for a deployed subgraph |
122
+ | `secondlayer subgraphs reindex/backfill/stop/delete <name>` | Manage processing |
71
123
 
72
124
  ### Data products (reads)
73
125
 
74
126
  | Command | What it does |
75
127
  |---|---|
76
128
  | `secondlayer index ft-transfers` / `nft-transfers` / `events --event-type <t>` / `contract-calls` | Decoded Index layer. Anonymous reads OK |
77
- | `secondlayer streams tip` / `events` / `consume` / `reorgs` / `canonical <h>` / `pull` | Raw chain event firehose. **Requires `SL_API_KEY`** |
129
+ | `secondlayer streams tip` / `events` / `consume` / `reorgs` / `canonical <h>` / `dumps` | Raw chain event firehose. **Requires `SL_API_KEY`** |
78
130
 
79
131
  Reads emit JSON to stdout (`--json` accepted across all read commands); `-o/--output` is a file path, not a format.
80
132
 
@@ -107,7 +159,7 @@ operates on both kinds.
107
159
 
108
160
  | Command | What it does |
109
161
  |---|---|
110
- | `secondlayer contracts generate [files...]` (alias `gen`) | Generate TS interfaces from Clarity contracts |
162
+ | `secondlayer codegen contracts [files...]` | Generate TS interfaces from Clarity contracts |
111
163
  | `secondlayer context` | Instance snapshot — Streams + Index tips, subgraphs, subscriptions |
112
164
  | `secondlayer doctor` / `secondlayer status` | Reachability + health checks |
113
165
  | `secondlayer config get/set/reset/delete` | Inspect or reset local config |
@@ -120,26 +172,26 @@ operates on both kinds.
120
172
  | `SL_API_URL` | Instance API. Default `http://127.0.0.1:3800` |
121
173
  | `SL_PLATFORM_API_URL` | Alias of `SL_API_URL` |
122
174
  | `STACKS_NETWORK` | Default network (also via `--network <local\|testnet\|mainnet>`) |
123
- | `HIRO_API_KEY` | Used by `secondlayer contracts generate` for remote contract fetches |
175
+ | `HIRO_API_KEY` | Used by `secondlayer codegen contracts` for remote contract fetches |
124
176
 
125
- ## Code generation (`secondlayer contracts generate`)
177
+ ## Code generation (`secondlayer codegen contracts`)
126
178
 
127
179
  Generate type-safe interfaces, functions, and optional React hooks from Clarity
128
180
  contracts — local `.clar` files, deployed contracts (network inferred from
129
181
  address prefix), or globs.
130
182
 
131
183
  ```bash
132
- secondlayer contracts generate ./contracts/token.clar -o ./src/generated.ts
133
- secondlayer contracts generate SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.alex-vault -o ./src/generated.ts
134
- secondlayer contracts generate "./contracts/*.clar" -o ./src/generated.ts
135
- secondlayer contracts generate --watch # regenerate on .clar / config / Clarinet.toml changes
184
+ secondlayer codegen contracts ./contracts/token.clar -o ./src/generated.ts
185
+ secondlayer codegen contracts SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.alex-vault -o ./src/generated.ts
186
+ secondlayer codegen contracts "./contracts/*.clar" -o ./src/generated.ts
187
+ secondlayer codegen contracts --watch # regenerate on .clar / config / Clarinet.toml changes
136
188
  ```
137
189
 
138
190
  Config-driven:
139
191
 
140
192
  ```bash
141
193
  # write a secondlayer.config.ts, then:
142
- secondlayer contracts generate # regenerates from the config
194
+ secondlayer codegen contracts # regenerates from the config
143
195
  ```
144
196
 
145
197
  ```typescript