@trawlme/skills 1.3.3 → 1.4.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.
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@ If the user gets `Session expired or invalid. Run: trawl login`, their stored JW
|
|
|
39
39
|
CI-relevant env vars. The first three are per-invocation session overrides — they take precedence over stored config without writing to disk (for normal commands; note `trawl login` itself still persists a token even when `TRAWL_TOKEN` is set):
|
|
40
40
|
- `TRAWL_TOKEN` — session JWT, takes precedence over `trawl login`'s stored token
|
|
41
41
|
- `TRAWL_API_URL` — API base URL, takes precedence over `trawl login --url`
|
|
42
|
-
- `TRAWL_TIMEOUT` — per-request fetch timeout in ms (default 30000)
|
|
42
|
+
- `TRAWL_TIMEOUT` — per-request fetch timeout in ms (default 30000; 300000 for `scraps run`, `data --fresh`, `trigger --wait` since CLI 1.18.4, and `create` since 2.0.0 — these hit the server-side scrap-execute/AI-wizard paths, which legitimately run 30-250s; this env var still overrides that longer default too, higher or lower — beware: a low global value clamps `create` and triggers the duplicate-on-retry trap described below)
|
|
43
43
|
- `DEBUG` — any truthy value prints the full error stack trace to stderr, same effect as the global `--debug` flag
|
|
44
44
|
|
|
45
45
|
`TRAWL_CONFIG_DIR` is different — it **redirects where the CLI reads and writes** its config file (so `trawl login` persists there). Point it at an ephemeral dir for hermetic runs, e.g. `TRAWL_CONFIG_DIR=$(mktemp -d)`.
|
|
@@ -48,6 +48,22 @@ CI-relevant env vars. The first three are per-invocation session overrides — t
|
|
|
48
48
|
|
|
49
49
|
All commands accept `--json` (where listed) for machine-readable or pipeable output.
|
|
50
50
|
|
|
51
|
+
Since CLI **v2.0.0** the agent-facing verbs are also top-level: `trawl list / get / run / data / history / run-info / trigger / whoami / ping / create` (the `trawl scraps <verb>` paths below still work as aliases — zero breaking change, except `trawl fetch`, removed in 2.0.0, see the AI-wizard `create` below which replaced it).
|
|
52
|
+
|
|
53
|
+
### Create a scrap from a URL + a prompt (AI wizard — the flagship)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
trawl create https://example.com/products --prompt "track product prices" [--no-autofix] [--json]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
One call: the server generates the extraction code (AI), creates a **persistent, self-healing scrap**, and triggers its first run (auto-fix on failure by default). Requires an api-key scoped `trawl:scraps:create` (or a session JWT). Response: `{ success, scrap, historyId }`.
|
|
60
|
+
|
|
61
|
+
Critical semantics for agents:
|
|
62
|
+
- **NOT idempotent + not instant** — generation + first run legitimately takes 30-250s (the CLI already uses the 300s long-run timeout; a global `TRAWL_TIMEOUT` override clamps it). On a client-side timeout the scrap **may still have been created server-side**: run `trawl list` before retrying — a retry creates a DUPLICATE scrap and burns quota.
|
|
63
|
+
- **Daily schedule by default** — a wizard scrap is created with a daily cron (07:00 UTC); it re-runs and meters every day until you change it (`trawl scraps update <id> --cron <expr>` or `--no-cron`).
|
|
64
|
+
- **`success:false` (exit 1) ≠ retry** — the scrap EXISTS and auto-fix is retrying in the background: poll `trawl data <id>` / `trawl run-info <historyId>`, never re-run `create`.
|
|
65
|
+
- Distinct from `trawl scraps create` below (raw Puppeteer script, no AI).
|
|
66
|
+
|
|
51
67
|
### List scraps
|
|
52
68
|
|
|
53
69
|
```bash
|
|
@@ -57,13 +73,14 @@ trawl scraps list --status failure # filter by last-run status
|
|
|
57
73
|
trawl scraps list --status success
|
|
58
74
|
trawl scraps list --status never # never run
|
|
59
75
|
trawl scraps list --status running # run currently executing (status: null)
|
|
76
|
+
trawl scraps list --status regression # last run succeeded but item count regressed vs baseline
|
|
60
77
|
trawl scraps list --limit 10 # cap output client-side
|
|
61
78
|
trawl scraps list --page 2 # single-page mode (one 50-row page)
|
|
62
79
|
```
|
|
63
80
|
|
|
64
81
|
> **Pagination:** `list` fetches **all** scraps by default (it auto-paginates internally at 200/page until a short page). `--page N` switches to single-page mode — one 50-row page, no auto-pagination. `--limit N` caps the output client-side. `--limit` and `--page` are mutually exclusive (usage error, exit 2). **Since CLI 1.18.3**, a non-numeric `--limit`/`--page` value (e.g. `abc`) is also a usage error, exit `2` — before 1.18.3 it silently became `NaN`, which truncated results to 0 rows or sent a bare `?page=NaN` to the server with no warning. Because the default fetches everything, a `jq`-by-title lookup over `list --json` sees every scrap — no page-1 blind spot.
|
|
65
82
|
|
|
66
|
-
**Since CLI 1.18.3**, a scrap whose last run is still executing (`status: null` server-side) renders as `running` — a cyan `↻` in the table, matched by `--status running`. Previously an in-flight run had no distinct state anywhere in `list`.
|
|
83
|
+
**Since CLI 1.18.3**, a scrap whose last run is still executing (`status: null` server-side) renders as `running` — a cyan `↻` in the table, matched by `--status running`. Previously an in-flight run had no distinct state anywhere in `list`. **Since CLI 1.18.4**, a run whose item count regressed vs baseline (`statusDetail: 'regression'`) renders as `regression` — an amber `▼`, matched by `--status regression` — distinct from the red `✗` a genuine failure gets (the write actually succeeded; only the count dropped). `doctor` shows the same distinction as its own amber `● regression` badge instead of bucketing it under `● failed`.
|
|
67
84
|
|
|
68
85
|
### Inspect a single scrap
|
|
69
86
|
|
|
@@ -91,6 +108,8 @@ trawl scraps data <id> --json # last run output (the scraped data)
|
|
|
91
108
|
|
|
92
109
|
Before 1.18.2 the zero-item/never-run/failed/aged-out states collapsed into the same `[]` / "No data yet." Before 1.18.3, a run still in progress fell through to the misleading "aged out of retention" message (status `null` isn't `false`, so it skipped the failure check, then found no persisted payload yet), and a regression row was misclassified as `run_failed` — hiding real, already-persisted items behind an error. Never assume "no data" from an empty result without checking the exit code and `kind`.
|
|
93
110
|
|
|
111
|
+
**`--fresh` regression warning (since CLI 1.18.5):** the table above (regression row) already applied to the default persisted-data path; `data --fresh` now gets the same treatment — after the live run finishes, the CLI does a follow-up `GET /api/scraps/:id` and prints a stderr warning pointing at `scraps doctor <id>` if the finalized run regressed vs baseline. It still prints the real items on stdout either way (exit `0`) — the check is best-effort and never gates the actual output. Before 1.18.5, `--fresh` rendered items with no regression check at all, because the `load()` response's own embedded `scrap.history[0]` can't be trusted for this. (Ordering caveat: the standalone `GET /api/scraps/:id` read — the one the output-shape section describes — returns `history` newest-first, so `history[0]` is the latest run there. The `load()` *response* embed is the exception: node appends the just-finished run onto the *end* of that array, and the regression flip lands via a raw DB patch issued after the response was already built, so `load()`'s echoed `history[0]` is both stale and not-newest. That's exactly why the CLI issues a fresh `GET` rather than reading `load()`'s embed.)
|
|
112
|
+
|
|
94
113
|
### Create a scrap
|
|
95
114
|
|
|
96
115
|
```bash
|
|
@@ -139,12 +158,19 @@ trawl scraps update <id> --tier tier2 --json # full scrap JSON, o
|
|
|
139
158
|
|
|
140
159
|
### Run / trigger / watch
|
|
141
160
|
|
|
142
|
-
- `trawl scraps run <id>` — synchronous run via the load endpoint, blocks until done
|
|
143
|
-
- `trawl scraps run <id> --watch` — same
|
|
161
|
+
- `trawl scraps run <id>` — synchronous run via the load endpoint, blocks until done. Arms a 300s timeout (since CLI 1.18.4 — see `TRAWL_TIMEOUT` above) instead of the generic 30s default, because this endpoint legitimately runs 30-250s server-side.
|
|
162
|
+
- `trawl scraps run <id> --watch` — same, then polls for progress (since CLI 1.18.4 — see below; it does **not** stream)
|
|
144
163
|
- `trawl scraps trigger <id>` — **async by default**: queues the worker run and returns immediately (no waiting on the 30-250s run)
|
|
145
|
-
- `trawl scraps trigger <id> --wait` — synchronous: block until the run completes (legacy behaviour)
|
|
146
|
-
- `trawl scraps trigger <id> --watch` — queue, then
|
|
147
|
-
- `trawl scraps watch <id>` — attach to an in-progress run's activity stream
|
|
164
|
+
- `trawl scraps trigger <id> --wait` — synchronous: block until the run completes (legacy behaviour). Same 300s timeout as `run`, since CLI 1.18.4.
|
|
165
|
+
- `trawl scraps trigger <id> --watch` — queue, then poll for progress (since CLI 1.18.4 — see below; it does **not** stream)
|
|
166
|
+
- `trawl scraps watch <id>` — the standalone command: attach to an in-progress run's activity stream over SSE. **Unchanged** by any of the above — this is the one that actually streams.
|
|
167
|
+
|
|
168
|
+
**`--watch` is poll-based, not a live stream (since CLI 1.18.4):** `scraps run --watch` and `scraps trigger --watch` used to open the activities SSE stream after launching the run — but that showed nothing either way: the activities SSE endpoint has no backlog, so by the time a *synchronous* run had already finished there was nothing left to emit, and for the default *async* `trigger` the run executes in a separate cron-consumer pod whose events never reach the API pod holding the SSE connection at all. Both flags now instead poll two Mongo-backed REST reads every 2s, up to 300s: `GET /api/scraps/:id` for terminal status, and the activities list endpoint for new lines — printing each new activity line as it appears, then the terminal status. Before doing so they print this notice:
|
|
169
|
+
> Live activity streaming has no signal for this run (async/cross-pod) — polling for progress instead…
|
|
170
|
+
|
|
171
|
+
Control flow depends on the path: for a **synchronous** run (`run`, or `trigger --wait`) the CLI first blocks on the run request itself (now with the 300s long-run timeout), and the poll runs *afterward* — so it's a one-pass replay of the recorded activity for a run that has already finished, not live-during-execution progress. For the default **async** `trigger` (`?wait=false`, returns immediately), the poll runs *concurrently* while a separate cron pod executes the run, so there the lines appear as the run progresses. Either way, a run that never reaches a terminal status within the 300s poll window prints an honest timeout notice pointing at `scraps doctor <id>`, instead of hanging silently or lying about completion. **Since CLI 1.18.5**, this poll also correctly tracks a `trigger --watch` call that deduped onto an already-in-flight worker job (i.e. the scrap was triggered again while a run was still executing) — before 1.18.5 that case could falsely time out waiting for a history id that would never change, because the dedup reuses the existing row instead of creating a new one. `--watch` is now safe to use on retry or concurrent `trigger` calls.
|
|
172
|
+
|
|
173
|
+
`scraps watch <id>` (the standalone command above) is a separate code path and is unaffected by any of this — it still opens the live SSE stream directly.
|
|
148
174
|
|
|
149
175
|
### Inspect past runs
|
|
150
176
|
|
|
@@ -177,20 +203,24 @@ For per-scrap authentication, see the `trawl-scrap-account` skill. CLI commands:
|
|
|
177
203
|
The session JWT authenticates two different ways depending on the endpoint:
|
|
178
204
|
|
|
179
205
|
```bash
|
|
206
|
+
TOKEN=$(trawl token)
|
|
207
|
+
|
|
180
208
|
# MCP endpoint — accepts the session JWT as a Bearer token. This is a real,
|
|
181
209
|
# runnable JSON-RPC 2.0 call (tools/list) against the Streamable HTTP
|
|
182
210
|
# transport — verified against trawl_node's mcp.controller.js:
|
|
183
|
-
curl -X POST https://api.trawl.me/api/mcp \
|
|
184
|
-
-H "Authorization: Bearer $
|
|
211
|
+
curl --fail-with-body -X POST https://api.trawl.me/api/mcp \
|
|
212
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
185
213
|
-H "Content-Type: application/json" \
|
|
186
214
|
-H "Accept: application/json, text/event-stream" \
|
|
187
215
|
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
|
|
188
216
|
|
|
189
217
|
# Raw REST (/api/scraps, etc.) — the JWT strategy is COOKIE-ONLY (reads the TOKEN cookie).
|
|
190
218
|
# Bearer is NOT accepted here; pass the JWT as the TOKEN cookie instead:
|
|
191
|
-
curl -H "Cookie: TOKEN=$
|
|
219
|
+
curl --fail-with-body -H "Cookie: TOKEN=$TOKEN" https://api.trawl.me/api/scraps
|
|
192
220
|
```
|
|
193
221
|
|
|
222
|
+
Capture `$(trawl token)` into `TOKEN` once and reuse it — inlining the substitution separately into each curl call can leave a call running with a silently empty token if the substitution fails. `--fail-with-body` makes curl exit non-zero on an HTTP error response (e.g. an empty/expired token → 401) while still printing the response body, instead of a `curl` that "succeeds" (exit 0) against an error page.
|
|
223
|
+
|
|
194
224
|
`/api/mcp` only accepts `POST`. `GET` (and `DELETE`) return a JSON-RPC-shaped `405` — this server runs the stateless Streamable HTTP transport, which has no use for the SSE-resume/session-close semantics those methods exist for elsewhere in the spec. Always POST a JSON-RPC envelope. The `Accept` header must list **both** `application/json` and `text/event-stream` — the SDK transport rejects a POST with either one missing as `406 Not Acceptable` (`Client must accept both application/json and text/event-stream`), regardless of auth.
|
|
195
225
|
|
|
196
226
|
## Common patterns
|
|
@@ -213,10 +243,13 @@ trawl scraps autofix <id> --json # raw autofix JSON
|
|
|
213
243
|
trawl scraps data <id> --errors # failure diagnostics inline with the data command
|
|
214
244
|
trawl scraps snapshot <id> --error -o /tmp/error.html # download the error-path HTML
|
|
215
245
|
trawl scraps snapshot <id> -o /tmp/page.html # download the captured page HTML
|
|
246
|
+
trawl scraps snapshot <id> --json # {"status":"no_runs"} exit 0 if never run — since CLI 1.18.4
|
|
216
247
|
```
|
|
217
248
|
Note: the CLI surfaces the abstract proxy Tier (0–4) + diagnostics + autofix, but **not** cost or proxy nature/IP/vendor — those are admin-only by design.
|
|
218
249
|
|
|
219
|
-
**No-runs shape, unified across commands:** `doctor --json`, `autofix --json`,
|
|
250
|
+
**No-runs shape, unified across commands:** `doctor --json`, `autofix --json`, `data --errors --json` (**since CLI 1.18.3**), and `snapshot --json` (**since CLI 1.18.4**) all return `{"status":"no_runs"}` (exit `0`) for a scrap that has **never run** — `doctor` had this shape since CLI 1.18.0; `autofix`/`data --errors` joined it in 1.18.3 (both used to return a bare `null`, indistinguishable from any other absent-payload state); `snapshot` joined it in 1.18.4 (it had no `--json` mode at all before then — a never-run scrap without `-o` just printed "No runs yet." to stdout and exited `0`, no machine-readable signal). Don't confuse it with `autofix --json`'s bare `null`, which means a run *did* happen but had no auto-fix attempt on it — genuinely "no data", a different state from "never ran at all". A run still **in progress** shows a `running` badge on `doctor`/`data --errors` (human mode) — never `failed` (**since CLI 1.18.3**).
|
|
251
|
+
|
|
252
|
+
**`snapshot -o <file>` on a never-run scrap (since CLI 1.18.4):** without `--json`, this now exits `4` (`not_found`) instead of silently exiting `0` with nothing written — before 1.18.4 a script checking only the exit code couldn't tell "no file was produced" from success. `--json` takes priority when both flags are passed together.
|
|
220
253
|
|
|
221
254
|
**"Create a job that runs every morning"**
|
|
222
255
|
```bash
|
|
@@ -232,7 +265,7 @@ trawl scraps run <id> --watch
|
|
|
232
265
|
|
|
233
266
|
## Other commands
|
|
234
267
|
|
|
235
|
-
- `trawl scraps banner <id> -f <path>` — upload a banner image (jpg/
|
|
268
|
+
- `trawl scraps banner <id> -f <path>` — upload a banner image (png/jpg/jpeg/webp) for a scrap; see the `trawl-scrap-banner` skill for the full generate + upload pipeline. **Since CLI 1.18.4**, any other extension is a usage error, exit `2` (e.g. `Unsupported image type ".gif" — use png, jpg, or webp.`) — before 1.18.4 an unrecognized extension silently uploaded under a fabricated `image/png` Content-Type instead of being refused.
|
|
236
269
|
- `trawl logout` — clear stored credentials
|
|
237
270
|
- `trawl skills list/install/uninstall/update` — manage the bundled Claude Code skills (this package)
|
|
238
271
|
- `trawl telemetry` — inspect/toggle usage telemetry (`TRAWL_TELEMETRY=0` / `DO_NOT_TRACK=1` env overrides also work)
|
|
@@ -300,9 +333,9 @@ Every command uses these exit codes — check `$?` instead of parsing stderr tex
|
|
|
300
333
|
|---|---|
|
|
301
334
|
| `0` | success |
|
|
302
335
|
| `1` | unmapped API error (HTTP status other than 401/404) or an unhandled bug — also `scraps data`'s "last run failed" (kind `run_failed`) and "run in progress" (kind `in_progress`, **since CLI 1.18.3**) states, and a refused tier override (kind `unknown`) |
|
|
303
|
-
| `2` | usage error — invalid flag/value or malformed input (bad ObjectId, invalid `--tier` value, malformed `-p` JSON, missing file, `--limit`+`--page` conflict, **since CLI 1.18.3 a non-numeric `--limit`/`--page` value**) **and, since CLI 1.18.2, commander parse errors** (unknown option/command, missing required arg — previously exit `1`) |
|
|
336
|
+
| `2` | usage error — invalid flag/value or malformed input (bad ObjectId, invalid `--tier` value, malformed `-p` JSON, missing file, `--limit`+`--page` conflict, **since CLI 1.18.3 a non-numeric `--limit`/`--page` value**, **since CLI 1.18.4 an unsupported `banner -f` file extension**) **and, since CLI 1.18.2, commander parse errors** (unknown option/command, missing required arg — previously exit `1`) |
|
|
304
337
|
| `3` | auth error — server **401** (token expired/invalid) **or no stored token at all** (since CLI 1.18.2 — previously exit `1`, kind `unknown`) |
|
|
305
|
-
| `4` | not found — 404, or (for `scraps data`) never-ran / retention-aged-out |
|
|
338
|
+
| `4` | not found — 404, or (for `scraps data`) never-ran / retention-aged-out, or (for `scraps snapshot -o <file>` without `--json`, since CLI 1.18.4) never-ran |
|
|
306
339
|
| `5` | network error (unreachable API, timeout) |
|
|
307
340
|
|
|
308
341
|
Edges to know:
|
|
@@ -101,7 +101,7 @@ Requires an authenticated CLI session first — `trawl login` (or `TRAWL_TOKEN`
|
|
|
101
101
|
trawl scraps banner ${scrapId} -f /tmp/${siteName}-banner.png
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
`-f/--file` also accepts `.jpg` and `.webp`, not just `.png` — webp gives smaller uploads for the same visual quality if size matters.
|
|
104
|
+
`-f/--file` also accepts `.jpg` and `.webp`, not just `.png` — webp gives smaller uploads for the same visual quality if size matters. Since CLI 1.18.4, any other extension is rejected with a usage error (exit 2) rather than uploaded mislabeled — png/jpg/jpeg/webp only.
|
|
105
105
|
|
|
106
106
|
CLI confirms upload. Banner is immediately visible on trawl.me.
|
|
107
107
|
|
|
@@ -91,6 +91,6 @@ Each run gets one `history` row with `status` (tri-state `true`/`false`/`null`)
|
|
|
91
91
|
- **`success`** — `returnData(arr)` called with at least one item.
|
|
92
92
|
- **`empty`** — an explicit `returnData([])` — ran clean but returned zero items. Usually means a selector broke; see `references/anti-patterns.md`. Never calling `returnData` at all is NOT `empty`: the run persists as `success` with a `null` payload, which `trawl scraps data` later reports as a `not_found` error (it looks like the payload aged out of retention). Always call `returnData`, even with `[]`.
|
|
93
93
|
- **`error`** — the script threw. Throw only for structural failures (see the Resilience section in `SKILL.md`) — a per-field `try/catch` that degrades a field to `null` does NOT produce `error`, it stays `success` with that field `null`.
|
|
94
|
-
- **`regression`** — item count dropped sharply vs. recent history, computed server-side after a successful run. This is a degraded *success*, not a failure: the items DID persist. `trawl scraps data <id>` (CLI 1.18.3+) returns those real items on stdout, exit `0`, with a stderr warning pointing at `trawl scraps doctor <id>` for diagnosis — it never collapses a regression row into the failure path. Use `doctor <id>` to see the baseline count vs. the actual count and decide whether the drop is a real site change or a broken selector.
|
|
94
|
+
- **`regression`** — item count dropped sharply vs. recent history, computed server-side after a successful run. This is a degraded *success*, not a failure: the items DID persist. `trawl scraps data <id>` (CLI 1.18.3+) returns those real items on stdout, exit `0`, with a stderr warning pointing at `trawl scraps doctor <id>` for diagnosis — it never collapses a regression row into the failure path. `data --fresh` (CLI 1.18.5+) gets the same stderr warning for a live run that regresses. Use `doctor <id>` to see the baseline count vs. the actual count and decide whether the drop is a real site change or a broken selector.
|
|
95
95
|
|
|
96
96
|
Ragged objects (an omitted key on some items) don't get their own status — they just make the returned array inconsistent for whatever consumes it downstream. Keep every item's key set identical (`null` for absent values) so `success` runs are actually usable.
|