@trawlme/skills 1.3.1 → 1.3.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/README.md +2 -1
- package/package.json +1 -1
- package/skills/trawl-cli/SKILL.md +95 -28
- package/skills/trawl-scrap-banner/SKILL.md +2 -2
- package/skills/trawl-scrap-design/SKILL.md +3 -3
- package/skills/trawl-scrap-design/references/returndata-shapes.md +11 -6
- package/skills/trawl-scrap-local-test/references/headed-debug.md +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ Follows the [Anthropic Agent Skills](https://github.com/anthropics/skills) layou
|
|
|
15
15
|
| `trawl-scrap-design` | Best practices for writing the Puppeteer script body — selectors, returnData shape, params, validation, anti-patterns. |
|
|
16
16
|
| `trawl-scrap-account` | Authentication — Trawl-managed credentials, BYO-cookies (embedded and persisted flavours), session reuse. |
|
|
17
17
|
| `trawl-scrap-local-test` | Run a scrap locally with headed Chrome before publishing, mirroring the worker entry contract. |
|
|
18
|
+
| `trawl-scrap-banner` | Generate + upload a brand-aware 1200x630 banner image for a scrap. |
|
|
18
19
|
|
|
19
20
|
## Install
|
|
20
21
|
|
|
@@ -51,7 +52,7 @@ The CLI bundles the skills and keeps them in sync with the CLI version.
|
|
|
51
52
|
|
|
52
53
|
## Migrating from v0.1.x
|
|
53
54
|
|
|
54
|
-
In v0.1.x there was a single skill named `trawl`. v0.2.0
|
|
55
|
+
In v0.1.x there was a single skill named `trawl`. v0.2.0 split it into four focused skills; `trawl-scrap-banner` was added later, bringing the total to the five listed in the bundled skills table above. When you run `npx @trawlme/skills install` (or `update`), the installer detects the legacy `~/.claude/skills/trawl/` directory and removes it before installing the current set. No manual cleanup needed.
|
|
55
56
|
|
|
56
57
|
Restart Claude Code after the install for the new skills to be picked up.
|
|
57
58
|
|
package/package.json
CHANGED
|
@@ -25,11 +25,12 @@ The user must have `@trawlme/cli` installed:
|
|
|
25
25
|
npm install -g @trawlme/cli
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
And be authenticated.
|
|
28
|
+
And be authenticated. Auth paths:
|
|
29
29
|
|
|
30
|
-
1. **Interactive** — `trawl login` (prompts email/password, stores JWT
|
|
31
|
-
2. **Env var** — `export TRAWL_TOKEN=<jwt>` (overrides stored token, ideal for CI)
|
|
30
|
+
1. **Interactive** — `trawl login` (prompts email/password, stores JWT via `conf`; on macOS that's `~/Library/Preferences/trawl-cli-nodejs/`, **not** `~/.config/trawl-cli/` — Conf's `env-paths` dependency hardcodes `Library/Preferences` and ignores XDG. Override the location with `TRAWL_CONFIG_DIR`.)
|
|
31
|
+
2. **Env var** — `export TRAWL_TOKEN=<jwt>` (overrides stored token, ideal for CI; `trawl token` also resolves it — see MCP bridge below)
|
|
32
32
|
3. **Token flag** — `trawl login --token <jwt>`
|
|
33
|
+
4. **Email/password flags** — `trawl login -e <email> -p <password>` (non-interactive; `-p` on the command line is visible in process list/shell history — CI only, prefer the interactive password prompt otherwise)
|
|
33
34
|
|
|
34
35
|
Custom API base: `trawl login --url https://self-hosted.example.com`. Default is `https://api.trawl.me`.
|
|
35
36
|
|
|
@@ -39,6 +40,7 @@ CI-relevant env vars. The first three are per-invocation session overrides — t
|
|
|
39
40
|
- `TRAWL_TOKEN` — session JWT, takes precedence over `trawl login`'s stored token
|
|
40
41
|
- `TRAWL_API_URL` — API base URL, takes precedence over `trawl login --url`
|
|
41
42
|
- `TRAWL_TIMEOUT` — per-request fetch timeout in ms (default 30000)
|
|
43
|
+
- `DEBUG` — any truthy value prints the full error stack trace to stderr, same effect as the global `--debug` flag
|
|
42
44
|
|
|
43
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)`.
|
|
44
46
|
|
|
@@ -54,11 +56,14 @@ trawl scraps list --json # JSON array
|
|
|
54
56
|
trawl scraps list --status failure # filter by last-run status
|
|
55
57
|
trawl scraps list --status success
|
|
56
58
|
trawl scraps list --status never # never run
|
|
59
|
+
trawl scraps list --status running # run currently executing (status: null)
|
|
57
60
|
trawl scraps list --limit 10 # cap output client-side
|
|
58
61
|
trawl scraps list --page 2 # single-page mode (one 50-row page)
|
|
59
62
|
```
|
|
60
63
|
|
|
61
|
-
> **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). Because the default fetches everything, a `jq`-by-title lookup over `list --json` sees every scrap — no page-1 blind spot.
|
|
64
|
+
> **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
|
+
|
|
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`.
|
|
62
67
|
|
|
63
68
|
### Inspect a single scrap
|
|
64
69
|
|
|
@@ -73,6 +78,19 @@ trawl scraps data <id> --json # last run output (the scraped data)
|
|
|
73
78
|
- `--errors` — show failure diagnostics inline when the last run failed.
|
|
74
79
|
- `--json` — machine-readable output.
|
|
75
80
|
|
|
81
|
+
**Honest data states (since CLI 1.18.2, extended 1.18.3):** `[]` is reserved for a genuine zero-item run. Every other outcome is a distinct error envelope instead of a silent empty array — except a regression, which is a degraded *success*, not an error:
|
|
82
|
+
|
|
83
|
+
| State | Result |
|
|
84
|
+
|---|---|
|
|
85
|
+
| Genuine zero-item run (incl. a run with `statusDetail: 'empty'`) | `[]`, exit `0` |
|
|
86
|
+
| Run in progress (`status: null` — the run is still executing, node persists `{status:null, statusDetail:null, inFlight:true}` the instant a run starts) | error, exit `1`, kind `in_progress` — "Run in progress — retry shortly"; never suggests `--fresh` (the run already holds the server-side lock, so `--fresh` would just 429 against it) — **since CLI 1.18.3** |
|
|
87
|
+
| Item count regressed vs baseline (`statusDetail: 'regression'`) | the **real, non-empty items** on stdout, exit `0` — plus a stderr warning pointing at `trawl scraps doctor <id>` for diagnosis. The write persisted before the regression was flagged, so treating it as a failure would hide genuine data behind a false negative — **since CLI 1.18.3** |
|
|
88
|
+
| Scrap has never run | error, exit `4`, kind `not_found` — "Run it first... or pass --fresh" |
|
|
89
|
+
| Last run failed (`status: false`, not `empty`, not `regression`) | error, exit `1`, kind `run_failed` — points to `--errors` |
|
|
90
|
+
| Payload aged out of retention (server keeps only the newest row per scrap+status bucket) — **including an aged-out regression row**, which gets this same envelope instead of fabricated items | error, exit `4`, kind `not_found` |
|
|
91
|
+
|
|
92
|
+
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
|
+
|
|
76
94
|
### Create a scrap
|
|
77
95
|
|
|
78
96
|
```bash
|
|
@@ -87,6 +105,7 @@ Flags:
|
|
|
87
105
|
- `-d, --description` — what the scrap does (used by wizard few-shot examples + future marketplace listing)
|
|
88
106
|
- `-r, --request` — the Puppeteer script body (must call `returnData(arr)`)
|
|
89
107
|
- `--tier tier0..tier4` — request a starting proxy tier (see Proxy tiers below)
|
|
108
|
+
- `--json` — output the full scrap object as JSON; a refused tier returns the standard error envelope + exit `1` instead (see Proxy tiers below)
|
|
90
109
|
|
|
91
110
|
For the script body, see the `trawl-scrap-design` skill.
|
|
92
111
|
|
|
@@ -104,15 +123,19 @@ trawl scraps update <id> -p '[{"TRAWL.page":"2"}]' # runtime params: JS
|
|
|
104
123
|
trawl scraps update <id> --params-file ./params.json # bulk params from file (same array shape)
|
|
105
124
|
trawl scraps update <id> --tier tier2 # request a proxy tier
|
|
106
125
|
trawl scraps update <id> --force-tier tier4 # raise the tier CEILING past the auto-cap
|
|
126
|
+
trawl scraps update <id> --tier tier2 --json # full scrap JSON, or error envelope + exit 1 on refusal
|
|
107
127
|
```
|
|
108
128
|
|
|
109
129
|
> **GTM seed scraps:** always run `trawl scraps update <id> --autofix --cron '0 0 * * 0'` post-create (weekly schedule + AI Fix enabled).
|
|
110
130
|
|
|
111
131
|
### Proxy tiers
|
|
112
132
|
|
|
113
|
-
- `--tier tier0..tier4` (create + update) — requests a starting proxy tier. It's **clamped to tier3** if the target domain isn't allow-listed for tier4, even though the flag accepts `tier4` without error.
|
|
114
|
-
-
|
|
115
|
-
-
|
|
133
|
+
- `--tier tier0..tier4` (create + update) — requests a starting proxy tier. It's **clamped to tier3** if the target domain isn't allow-listed for tier4, even though the flag accepts `tier4` without error.
|
|
134
|
+
- Since CLI 1.18.2, **both `create` and `update`** read `_tierOverride` back from the server and render the same honest truth (previously only `update` echoed the clamp; `create` was silent): a clamp (`⚠ proxyTier requested tier4 → applied tier3`), an allowed ceiling raise (+ spend warning if any), or a refusal.
|
|
135
|
+
- **Old-server fallback (since CLI 1.18.2):** if a tier was requested but the response carries no `_tierOverride` at all, the CLI no longer echoes the requested value as if it were applied — it prints `⚠ Server did not confirm the tier change (older server) — verify with: trawl scraps get <id>` instead. Never assume the requested tier was honored on an unconfirmed response. **Since CLI 1.18.3**, `--json` carries the same signal in machine-readable form: the emitted scrap object gets `"_tierUnconfirmed": true` under exactly this condition (tier requested, no `_tierOverride` in the response) — the counterpart to the stderr warning, since a `--json` caller has no reliable reason to read stderr. Never present when `_tierOverride` came back, never fabricated otherwise.
|
|
136
|
+
- `--force-tier tier0..tier4` (update only) — raises the tier **ceiling** past that auto-cap. History-gated: the server may refuse it (the CLI prints `✗ tier ceiling override refused: <reason>` and exits `1`) or it may cost more, depending on the scrap's run history.
|
|
137
|
+
- `--json` (create + update, since CLI 1.18.2): success returns the full scrap object; when a tier was requested it carries **either** `_tierOverride` (the server confirmed — inspect it for the applied/clamped/refused truth) **or** `_tierUnconfirmed: true` (old server, unconfirmed — see the fallback bullet above), never both, and neither when no tier was requested. A refused tier returns the standard error envelope on stdout and exits `1` — same outcome as human mode, just machine-readable.
|
|
138
|
+
- Either way, verify what tier a run actually used with `trawl scraps history <id>` / `trawl scraps run-info <hid>` (on servers released before mid-July 2026 the `history` list shows these columns blank — `run-info` always has them) — don't assume the requested tier was honored.
|
|
116
139
|
|
|
117
140
|
### Run / trigger / watch
|
|
118
141
|
|
|
@@ -133,35 +156,43 @@ trawl scraps run-info <hid> # one run's detail by its history id
|
|
|
133
156
|
trawl scraps run-info <hid> --json
|
|
134
157
|
```
|
|
135
158
|
|
|
136
|
-
`doctor`/`autofix` (below) inspect the **last** run; `history` + `run-info` reach **any** run: list with `history`, then pass a run's `hid` to `run-info` for the full diagnosis. `run-info` hits `/api/historys/:hid`, which returns the proxy tier + `failureKind` to the scrap owner
|
|
159
|
+
`doctor`/`autofix` (below) inspect the **last** run; `history` + `run-info` reach **any** run: list with `history`, then pass a run's `hid` to `run-info` for the full diagnosis. `run-info` hits `/api/historys/:hid`, which returns the proxy tier + `failureKind` to the scrap owner, plus the error snapshot (`errorMessage`/selector context) that `history`'s embedded list never carries. (On servers released before mid-July 2026, `history` also shows the tier/failureKind columns blank — `run-info` always has them.)
|
|
137
160
|
|
|
138
161
|
### Delete
|
|
139
162
|
|
|
140
163
|
```bash
|
|
141
|
-
trawl scraps
|
|
142
|
-
trawl scraps
|
|
143
|
-
trawl scraps
|
|
164
|
+
trawl scraps delete <id> # prompts for confirmation
|
|
165
|
+
trawl scraps delete <id> --force # no prompt, useful in scripts
|
|
166
|
+
trawl scraps rm <id> # `rm` is an alias for `delete`, same flags
|
|
144
167
|
```
|
|
145
168
|
|
|
146
169
|
## Scrap accounts
|
|
147
170
|
|
|
148
|
-
For per-scrap authentication, see the `trawl-scrap-account` skill. CLI commands: `trawl scraps account set/status/clear-session/delete
|
|
171
|
+
For per-scrap authentication, see the `trawl-scrap-account` skill. CLI commands: `trawl scraps account set/status/clear-session/delete`, plus `trawl scraps account session set <id>` (upload BYO-cookies).
|
|
149
172
|
|
|
150
173
|
## MCP bridge
|
|
151
174
|
|
|
152
|
-
`trawl token` prints the stored session JWT to **stdout** (any advisory text, e.g. expiry, goes to stderr — safe to capture stdout alone).
|
|
175
|
+
`trawl token` prints the stored session JWT to **stdout** (any advisory text, e.g. expiry, goes to stderr — safe to capture stdout alone). Since CLI 1.18.2 it resolves `TRAWL_TOKEN` before the stored config token (same precedence every other token consumer uses), so it works headless in CI/agents without a prior `trawl login`: `TRAWL_TOKEN=<jwt> trawl token` prints straight through. A missing or expired token now exits `3` with kind `auth` (previously exit `1`, kind `unknown` — indistinguishable from an arbitrary bug).
|
|
153
176
|
|
|
154
177
|
The session JWT authenticates two different ways depending on the endpoint:
|
|
155
178
|
|
|
156
179
|
```bash
|
|
157
|
-
# MCP endpoint — accepts the session JWT as a Bearer token
|
|
158
|
-
|
|
180
|
+
# MCP endpoint — accepts the session JWT as a Bearer token. This is a real,
|
|
181
|
+
# runnable JSON-RPC 2.0 call (tools/list) against the Streamable HTTP
|
|
182
|
+
# transport — verified against trawl_node's mcp.controller.js:
|
|
183
|
+
curl -X POST https://api.trawl.me/api/mcp \
|
|
184
|
+
-H "Authorization: Bearer $(trawl token)" \
|
|
185
|
+
-H "Content-Type: application/json" \
|
|
186
|
+
-H "Accept: application/json, text/event-stream" \
|
|
187
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
|
|
159
188
|
|
|
160
189
|
# Raw REST (/api/scraps, etc.) — the JWT strategy is COOKIE-ONLY (reads the TOKEN cookie).
|
|
161
190
|
# Bearer is NOT accepted here; pass the JWT as the TOKEN cookie instead:
|
|
162
191
|
curl -H "Cookie: TOKEN=$(trawl token)" https://api.trawl.me/api/scraps
|
|
163
192
|
```
|
|
164
193
|
|
|
194
|
+
`/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
|
+
|
|
165
196
|
## Common patterns
|
|
166
197
|
|
|
167
198
|
**"Run my X scrap and show me the result"**
|
|
@@ -185,6 +216,8 @@ trawl scraps snapshot <id> -o /tmp/page.html # download the captured page H
|
|
|
185
216
|
```
|
|
186
217
|
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.
|
|
187
218
|
|
|
219
|
+
**No-runs shape, unified across commands:** `doctor --json`, `autofix --json`, and (**since CLI 1.18.3**) `data --errors --json` 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). 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**).
|
|
220
|
+
|
|
188
221
|
**"Create a job that runs every morning"**
|
|
189
222
|
```bash
|
|
190
223
|
trawl scraps create -t "Morning crawl" -u "https://..." -d "Daily crawl at 8am" -r '...'
|
|
@@ -199,6 +232,7 @@ trawl scraps run <id> --watch
|
|
|
199
232
|
|
|
200
233
|
## Other commands
|
|
201
234
|
|
|
235
|
+
- `trawl scraps banner <id> -f <path>` — upload a banner image (jpg/png/webp) for a scrap; see the `trawl-scrap-banner` skill for the full generate + upload pipeline
|
|
202
236
|
- `trawl logout` — clear stored credentials
|
|
203
237
|
- `trawl skills list/install/uninstall/update` — manage the bundled Claude Code skills (this package)
|
|
204
238
|
- `trawl telemetry` — inspect/toggle usage telemetry (`TRAWL_TELEMETRY=0` / `DO_NOT_TRACK=1` env overrides also work)
|
|
@@ -215,15 +249,38 @@ Scrap object shape:
|
|
|
215
249
|
"url": "https://...",
|
|
216
250
|
"request": "var page = ...",
|
|
217
251
|
"scrapper": "puppeteer",
|
|
218
|
-
"cron": "0 9 * * *"
|
|
252
|
+
"cron": "0 9 * * *",
|
|
253
|
+
"autoFix": false,
|
|
219
254
|
"params": [{"TRAWL.paramName": "value"}],
|
|
220
|
-
"
|
|
255
|
+
"history": [
|
|
256
|
+
{
|
|
257
|
+
"_id": "...",
|
|
258
|
+
"status": true,
|
|
259
|
+
"statusDetail": "success",
|
|
260
|
+
"time": 4200,
|
|
261
|
+
"proxyTier": "tier1",
|
|
262
|
+
"failureKind": null,
|
|
263
|
+
"blockType": null,
|
|
264
|
+
"createdAt": "..."
|
|
265
|
+
}
|
|
266
|
+
],
|
|
221
267
|
"createdAt": "...",
|
|
222
|
-
"updatedAt": "..."
|
|
268
|
+
"updatedAt": "...",
|
|
269
|
+
"_tierOverride": { "requestedMaxTier": "tier4", "effectiveMaxTier": "tier3", "refused": false, "reason": "...", "provider": "...", "warning": null }
|
|
223
270
|
}
|
|
224
271
|
```
|
|
225
272
|
|
|
226
|
-
`
|
|
273
|
+
There is **no `lastRun` field** — that never existed. Last-run status/timing/error all derive from `history[0]` (newest first). The embedded row shape differs by command:
|
|
274
|
+
- `trawl scraps get <id>` — up to 100 rows, each with `status`, `statusDetail`, `time`, `proxyTier`, `failureKind`, `blockType`, `createdAt`
|
|
275
|
+
- `trawl scraps list` — only the single newest row per scrap, with just `status` / `statusDetail` / `createdAt` (no `time`/`proxyTier`/`failureKind`/`blockType` — those come back `undefined`, not `null`); fetch `get <id>` if you need the triage fields
|
|
276
|
+
- `status` — tri-state: `true` (success) / `false` (failure) / `null` (in-flight, no result yet)
|
|
277
|
+
- `statusDetail` — `'success' | 'error' | 'empty' | 'regression' | null` — the fine-grained outcome (`empty` = ran clean but returned 0 items; `regression` = item count dropped sharply vs. history)
|
|
278
|
+
- `proxyTier` / `failureKind` / `blockType` — owner-safe triage fields (not stripped like the admin-only proxy vendor/cost internals), present on `get`'s rows (and therefore on `history`, which reads the same endpoint); never on `list`'s rows. Servers released before mid-July 2026 leave them blank — `run-info <hid>` is always authoritative
|
|
279
|
+
- Full error detail (`errorSnapshot`: `errorMessage`, `selector`, `emptyContext`) is **not** embedded on either — fetch it via `trawl scraps run-info <hid>` or `trawl scraps doctor <id>`
|
|
280
|
+
|
|
281
|
+
`_tierOverride` is present only on `create`/`update` responses when a tier was requested (see Proxy tiers above) — absent otherwise.
|
|
282
|
+
|
|
283
|
+
`trawl scraps data <id> --json` returns the array passed to `returnData(...)` — see the honest data states above for what a non-array outcome means.
|
|
227
284
|
|
|
228
285
|
## Errors to recognize
|
|
229
286
|
|
|
@@ -232,6 +289,8 @@ Scrap object shape:
|
|
|
232
289
|
- HTTP 403 → user doesn't own the scrap
|
|
233
290
|
- HTTP 404 → wrong scrap ID
|
|
234
291
|
- HTTP 422 on create/update → missing required field or invalid cron expression
|
|
292
|
+
- HTTP 402 → quota/billing limit hit; message may carry `— upgrade: <url>` when the server provides one (since CLI 1.18.0)
|
|
293
|
+
- HTTP 429 → rate-limited; message may carry `(retry after <N>s)` when the server sends a `Retry-After` header (since CLI 1.18.0)
|
|
235
294
|
|
|
236
295
|
### Exit codes
|
|
237
296
|
|
|
@@ -240,15 +299,16 @@ Every command uses these exit codes — check `$?` instead of parsing stderr tex
|
|
|
240
299
|
| Code | Meaning |
|
|
241
300
|
|---|---|
|
|
242
301
|
| `0` | success |
|
|
243
|
-
| `1` | API error (
|
|
244
|
-
| `2` | usage error — invalid flag
|
|
245
|
-
| `3` | auth error
|
|
246
|
-
| `4` | not found
|
|
302
|
+
| `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`) |
|
|
304
|
+
| `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 |
|
|
247
306
|
| `5` | network error (unreachable API, timeout) |
|
|
248
307
|
|
|
249
|
-
|
|
250
|
-
- **No stored token at all** exits `
|
|
251
|
-
- **Unknown flags / missing required args**
|
|
308
|
+
Edges to know:
|
|
309
|
+
- **No stored token at all** now exits `3` with kind `auth` (`Not logged in. Run: trawl login`) — the same path a real 401 takes. Before CLI 1.18.2 this was a generic exit `1`, kind `unknown`, indistinguishable from an arbitrary bug. `trawl token` follows the same rule.
|
|
310
|
+
- **Unknown flags / missing required args** now exit `2` (usage), same bucket as bad flag *values* — before CLI 1.18.2 commander caught these before the command ran and they fell through to exit `1`.
|
|
311
|
+
- **Local auth failures never carry `status:401` (since CLI 1.18.3):** "no stored token" and `trawl token`'s own "locally-decoded expired token" check both fail entirely client-side — no HTTP call was made, so the `--json` envelope is `{"error":{"message":"...","kind":"auth"}}` with **no `status` field**. Only a real server-issued 401 response carries `status:401`. Exit code and `kind` are unchanged (still `3` / `auth`) — only the envelope shape differs. Before 1.18.3 the local case fabricated `status:401` as if the server had said so.
|
|
252
312
|
|
|
253
313
|
### `--json` failure envelope
|
|
254
314
|
|
|
@@ -258,12 +318,19 @@ When a command fails **after argument parsing** with `--json` set, the error goe
|
|
|
258
318
|
{"error":{"message":"Session expired or invalid. Run: trawl login","kind":"auth","status":401}}
|
|
259
319
|
```
|
|
260
320
|
|
|
261
|
-
|
|
321
|
+
A local auth failure (no token / expired-token check with no HTTP round trip — see the edge above) omits `status` entirely:
|
|
322
|
+
|
|
323
|
+
```json
|
|
324
|
+
{"error":{"message":"Not logged in. Run: trawl login","kind":"auth"}}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
`kind` is one of `auth` / `not_found` / `api` / `network` / `usage` / `unknown`, plus `run_failed` and `in_progress` (both `scraps data`-specific, not part of the shared classifier). `status` is only present for real HTTP-backed errors.
|
|
262
328
|
|
|
263
|
-
|
|
329
|
+
Since CLI 1.18.2, commander-level parse errors (unknown flag, missing required arg) **also** emit the envelope — `{"error":{"message":"...","kind":"usage"}}` (no `status` field) — whenever `--json` appears anywhere on the command line (scanned from raw argv, since parsing fails before any command's own `--json` flag can be read). Exit code `2`. Before 1.18.2 these always bypassed the envelope: empty stdout, a plain-text error on stderr, exit `1`. **Since CLI 1.18.3**, that argv scan stops at the first bare `--` (end-of-options): `scraps list -- --json` no longer triggers the envelope, because everything after a literal `--` is a positional argument to commander, not a flag — even one that reads `--json`. Before 1.18.3 an unscoped `argv.includes('--json')` still matched it and wrongly emitted a JSON envelope for a plain usage error that never actually requested `--json`.
|
|
264
330
|
|
|
265
331
|
## What this skill does NOT do
|
|
266
332
|
|
|
267
333
|
- Script body → `trawl-scrap-design`
|
|
268
334
|
- Authentication / session injection → `trawl-scrap-account`
|
|
269
335
|
- Local debugging runs → `trawl-scrap-local-test`
|
|
336
|
+
- Banner image generation + composition pipeline → `trawl-scrap-banner` (this skill only lists the raw `trawl scraps banner` upload command)
|
|
@@ -95,7 +95,7 @@ Linux / CI: replace with `google-chrome` or `chromium-browser` (same flags). On
|
|
|
95
95
|
|
|
96
96
|
### 5. Upload
|
|
97
97
|
|
|
98
|
-
Requires an authenticated CLI session first — `trawl login` (or `TRAWL_TOKEN` env / `trawl login --token <jwt>`). Not logged in at all → exit `
|
|
98
|
+
Requires an authenticated CLI session first — `trawl login` (or `TRAWL_TOKEN` env / `trawl login --token <jwt>`). Not logged in at all → exit `3` (kind `auth`, since CLI 1.18.2 — was exit `1`); an expired/invalid token → also exit `3` (server 401).
|
|
99
99
|
|
|
100
100
|
```bash
|
|
101
101
|
trawl scraps banner ${scrapId} -f /tmp/${siteName}-banner.png
|
|
@@ -105,7 +105,7 @@ trawl scraps banner ${scrapId} -f /tmp/${siteName}-banner.png
|
|
|
105
105
|
|
|
106
106
|
CLI confirms upload. Banner is immediately visible on trawl.me.
|
|
107
107
|
|
|
108
|
-
**Failure detection:** `banner` has **no `--json` mode** — the exit code is the only machine-readable signal. `0` = uploaded; non-zero = failed: `1`
|
|
108
|
+
**Failure detection:** `banner` has **no `--json` mode** — the exit code is the only machine-readable signal. `0` = uploaded; non-zero = failed: `1` other/unmapped error, `2` malformed `scrapId` (not a 24-char hex ObjectId — usage error), `3` not logged in / expired-or-invalid token (401), `4` wrong `scrapId` (404), `5` network. Check `$?`, don't parse stdout for success/failure.
|
|
109
109
|
|
|
110
110
|
## Conventions
|
|
111
111
|
|
|
@@ -9,7 +9,7 @@ Use when writing the Puppeteer script body that runs on a Trawl worker.
|
|
|
9
9
|
|
|
10
10
|
## The worker boundary
|
|
11
11
|
|
|
12
|
-
The worker handles fingerprinting, proxy escalation, AI Fix, and
|
|
12
|
+
The worker handles fingerprinting, proxy escalation, AI Fix, and run-outcome classification (`statusDetail`: success/error/empty/regression). Your script handles selectors, returnData shape, params, and graceful failure. See `references/anti-patterns.md`.
|
|
13
13
|
|
|
14
14
|
> **Don't add stealth in your script.** Trawl's worker handles fingerprinting, proxy rotation, and bot-detection countermeasures centrally. Adding stealth plugins, UA spoofing, viewport randomisation, or aggressive jitter in your script duplicates worker policy and causes drift. The worker's policy evolves; your script's hardcoded tricks won't.
|
|
15
15
|
|
|
@@ -122,7 +122,7 @@ try {
|
|
|
122
122
|
|
|
123
123
|
The platform auto-escalates proxy tiers when a run comes back empty — you usually don't manage tiers at all. For a site you *know* is heavily protected, there are two CLI knobs (see the `trawl-cli` skill for full flag docs):
|
|
124
124
|
|
|
125
|
-
- `trawl scraps update <id> --tier tier0..tier4` — requests a starting tier so the first run doesn't waste a cycle. **It's clamped to tier3 for domains that aren't allow-listed for tier4** — requesting `tier4` does not error, it just gets capped.
|
|
125
|
+
- `trawl scraps update <id> --tier tier0..tier4` — requests a starting tier so the first run doesn't waste a cycle. **It's clamped to tier3 for domains that aren't allow-listed for tier4** — requesting `tier4` does not error, it just gets capped. Since CLI 1.18.2, both `create` and `update` echo the clamp (`⚠ proxyTier requested tier4 → applied tier3`); on an older server that doesn't confirm the change, the CLI warns instead of pretending the request was applied.
|
|
126
126
|
- `trawl scraps update <id> --force-tier tier0..tier4` — raises the tier **ceiling** past that auto-cap. History-gated: the server may refuse it (CLI exits `1`) or it may cost more, depending on the scrap's run history.
|
|
127
127
|
|
|
128
128
|
Don't assume the requested tier was honored — verify with `trawl scraps history <id>` / `trawl scraps run-info <hid>` after a run. Don't try to outsmart protection in your script — return what you can and let the platform escalate.
|
|
@@ -147,7 +147,7 @@ Some pages hide data behind real UI interactions — scroll, hover, click, form
|
|
|
147
147
|
|
|
148
148
|
- *Trawl Scraping docs (in-app help center)* — selector basics, `returnData`, scrap lifecycle.
|
|
149
149
|
- *Trawl Scraping Advanced docs* — proxy tiers, escalation triggers, rate-limit guidance.
|
|
150
|
-
- *Trawl Data Quality docs* — `
|
|
150
|
+
- *Trawl Data Quality docs* — reading run outcomes: `history[].status` is tri-state (`true`/`false`/`null`); `history[].statusDetail` is the fine-grained enum `success` / `error` / `empty` / `regression` (`empty` = ran clean but `returnData([])`; `regression` = item count dropped sharply vs. prior runs). There is no `validation_failed` status — schema validation (`checkSchema`) was decommissioned.
|
|
151
151
|
- *Trawl AI Features docs* — AI Fix quotas, how selector comments improve AI Fix accuracy.
|
|
152
152
|
- *Trawl Schedule + Parameters docs* — `TRAWL.<custom>` params, `RANDOM(...)` and `DATE(...)` helpers.
|
|
153
153
|
|
|
@@ -28,13 +28,13 @@ Return a flat object per item. Nest only when source data is genuinely nested
|
|
|
28
28
|
|
|
29
29
|
## null vs omission
|
|
30
30
|
|
|
31
|
-
Return `null` for absent optional fields. Never omit the key —
|
|
31
|
+
Return `null` for absent optional fields. Never omit the key — downstream consumers (the frontend table, exports, any consumer script) expect every item to carry the same key set; omitting a key produces ragged objects that silently break column-based rendering.
|
|
32
32
|
|
|
33
33
|
```js
|
|
34
34
|
// Good
|
|
35
35
|
{ title: 'Widget Pro', discount_pct: null, badge: null }
|
|
36
36
|
|
|
37
|
-
// Bad — key omitted,
|
|
37
|
+
// Bad — key omitted, produces a ragged object across the returned array
|
|
38
38
|
{ title: 'Widget Pro' }
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -84,8 +84,13 @@ returnData(allItems); // single call with all pages merged
|
|
|
84
84
|
|
|
85
85
|
---
|
|
86
86
|
|
|
87
|
-
##
|
|
87
|
+
## How returnData shape affects the run outcome
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
-
|
|
89
|
+
Each run gets one `history` row with `status` (tri-state `true`/`false`/`null`) and a finer `statusDetail` enum: `success` / `error` / `empty` / `regression`. There is no schema-validation status — the platform does not enforce a JSON Schema against your items, so a "wrong shape" (missing key, wrong type) never fails the run on its own. What actually flips `statusDetail`:
|
|
90
|
+
|
|
91
|
+
- **`success`** — `returnData(arr)` called with at least one item.
|
|
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
|
+
- **`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.
|
|
95
|
+
|
|
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.
|
|
@@ -33,7 +33,7 @@ Log in manually in that Chrome window (complete MFA, solve CAPTCHA, etc.). Then
|
|
|
33
33
|
node run-local.mjs scrap.js --remote
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
The harness calls `puppeteer.connect({ browserURL: 'http://127.0.0.1:9222' })`
|
|
36
|
+
The harness only calls `puppeteer.connect({ browserURL: 'http://127.0.0.1:9222' })` when `--remote` is passed (otherwise it launches a fresh browser). Only `browser` is injected as a global — not `page` — so the script body itself is responsible for calling `browser.newPage()`. Under `--remote` the harness calls `browser.disconnect()` when done instead of `browser.close()`, so the manually-launched Chrome instance stays open.
|
|
37
37
|
|
|
38
38
|
## Intermediate snapshots
|
|
39
39
|
|