@trawlme/cli 2.0.0 → 2.1.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/README.md +2 -1
- package/dist/commands/create.js +16 -2
- package/docs/agent-quickstart.md +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,8 @@ All commands accept a global `--debug` flag to show full error stack traces on f
|
|
|
37
37
|
### Core commands (agent + human)
|
|
38
38
|
|
|
39
39
|
```
|
|
40
|
-
trawl create <url> --prompt <goal> [--no-autofix] [--json]
|
|
40
|
+
trawl create <url> --prompt <goal> [--no-autofix] [--json] # url also accepted as --url <url> (#116)
|
|
41
|
+
Create a persistent, self-healing scrap from a URL + a goal (AI-generated)
|
|
41
42
|
trawl run <id> [--watch] [--json] Run a scrap
|
|
42
43
|
trawl list|ls [--json] [--status <success|failure|never|running|regression>] [--limit <n>] [--page <n>]
|
|
43
44
|
trawl get <id> [--json] Get scrap details
|
package/dist/commands/create.js
CHANGED
|
@@ -4,6 +4,7 @@ import { oraPromise } from 'ora';
|
|
|
4
4
|
import { api, LONG_RUN_TIMEOUT_MS, NetworkError } from '../lib/api.js';
|
|
5
5
|
import { json } from '../lib/format.js';
|
|
6
6
|
import { requireUrl, requireString } from '../lib/validate.js';
|
|
7
|
+
import { UsageError } from '../lib/errors.js';
|
|
7
8
|
/** Best-effort, honest first-run summary — never claims a background retry
|
|
8
9
|
* happened when auto-fix was disabled for this call, and never claims a
|
|
9
10
|
* scrap was persisted when the response carries none (#114-F3 — a hard
|
|
@@ -51,15 +52,28 @@ function scheduleLabel(scrap) {
|
|
|
51
52
|
}
|
|
52
53
|
export const create = new Command('create')
|
|
53
54
|
.description('Create a persistent, self-healing scrap from a URL + a goal (AI-generated)')
|
|
54
|
-
.argument('
|
|
55
|
+
.argument('[url]', 'Target public URL (http/https)')
|
|
55
56
|
.requiredOption('--prompt <goal>', 'What to extract/scrape, in plain language')
|
|
57
|
+
.option('--url <url>', 'Target public URL — alias of the positional argument (#116)')
|
|
56
58
|
.option('--no-autofix', 'Disable AI auto-fix on first-run failure (default: on)')
|
|
57
59
|
.option('--json', 'Output the raw API payload')
|
|
58
60
|
.action(async (rawUrl, opts) => {
|
|
59
61
|
// Fast, local usage-errors (exit 2) — never a round-trip to the server
|
|
60
62
|
// for something we can already tell is bad. Same fail-fast pattern the
|
|
61
63
|
// former `fetch` command used for its URL argument.
|
|
62
|
-
|
|
64
|
+
//
|
|
65
|
+
// #116 — the url is accepted BOTH as the positional argument (agent
|
|
66
|
+
// one-liner) and as `--url` (muscle memory from `scraps create` and the
|
|
67
|
+
// API body {url, goal}). Exactly one is required; both are fine only
|
|
68
|
+
// when identical — two DIFFERENT urls is ambiguous, refuse loudly
|
|
69
|
+
// rather than silently picking one.
|
|
70
|
+
if (rawUrl === undefined && opts.url === undefined) {
|
|
71
|
+
throw new UsageError("missing required argument 'url' (positional, or --url <url>)");
|
|
72
|
+
}
|
|
73
|
+
if (rawUrl !== undefined && opts.url !== undefined && rawUrl !== opts.url) {
|
|
74
|
+
throw new UsageError(`conflicting urls: positional "${rawUrl}" vs --url "${opts.url}" — pass only one`);
|
|
75
|
+
}
|
|
76
|
+
const url = requireUrl(rawUrl ?? opts.url, 'url');
|
|
63
77
|
const goal = requireString(opts.prompt, '--prompt');
|
|
64
78
|
const body = {
|
|
65
79
|
url,
|
package/docs/agent-quickstart.md
CHANGED
|
@@ -25,7 +25,8 @@ first-class on every one, and none of them ever blocks on a prompt (see
|
|
|
25
25
|
[Non-interactive contract](#non-interactive-contract) below):
|
|
26
26
|
|
|
27
27
|
```
|
|
28
|
-
trawl create <url> --prompt <goal> [--no-autofix] [--json]
|
|
28
|
+
trawl create <url> --prompt <goal> [--no-autofix] [--json] # url also accepted as --url <url> (#116)
|
|
29
|
+
Create a persistent, self-healing scrap from a URL + a goal (AI-generated)
|
|
29
30
|
trawl run <id> [--watch] [--json] Run a scrap
|
|
30
31
|
trawl list|ls [--json] [--status <s>] [--limit <n>] [--page <n>] List all scraps
|
|
31
32
|
trawl get <id> [--json] Get scrap details
|