@trawlme/cli 1.21.0 → 1.22.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 +44 -35
- package/dist/commands/scraps.d.ts +29 -0
- package/dist/commands/scraps.js +413 -392
- package/dist/index.d.ts +8 -0
- package/dist/index.js +45 -7
- package/docs/agent-quickstart.md +103 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,14 @@ import { Command } from 'commander';
|
|
|
15
15
|
* chain — matching the pre-existing convention that a direct child of the
|
|
16
16
|
* root (e.g. `scraps list`, `telemetry on`) is named relative to its
|
|
17
17
|
* immediate group, never prefixed with the program name.
|
|
18
|
+
*
|
|
19
|
+
* #108 note: promoting a verb to a top-level command (see `createProgram`
|
|
20
|
+
* below) renamed ITS resolved telemetry name from `scraps <verb>` to
|
|
21
|
+
* `<verb>` — the canonical top-level attach and the legacy hidden
|
|
22
|
+
* `scraps <verb>` attach are two separate Command instances (scraps.ts's
|
|
23
|
+
* double-attach factories), each with its own parent chain, so they
|
|
24
|
+
* resolve to two different names here even though they run the same
|
|
25
|
+
* handler. Intentional (the canonical command IS now `<verb>`), not a bug.
|
|
18
26
|
*/
|
|
19
27
|
export declare function resolveCommandName(actionCommand: Command | undefined): string;
|
|
20
28
|
/**
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { readFileSync, realpathSync } from 'node:fs';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
import { login, logout } from './commands/login.js';
|
|
7
|
-
import { scraps } from './commands/scraps.js';
|
|
7
|
+
import { scraps, attachListCommand, attachGetCommand, attachRunCommand, attachDataCommand, attachHistoryCommand, attachRunInfoCommand, attachTriggerCommand, } from './commands/scraps.js';
|
|
8
8
|
import { skills } from './commands/skills.js';
|
|
9
9
|
import { telemetry } from './commands/telemetry.js';
|
|
10
10
|
import { token } from './commands/token.js';
|
|
@@ -32,6 +32,14 @@ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8
|
|
|
32
32
|
* chain — matching the pre-existing convention that a direct child of the
|
|
33
33
|
* root (e.g. `scraps list`, `telemetry on`) is named relative to its
|
|
34
34
|
* immediate group, never prefixed with the program name.
|
|
35
|
+
*
|
|
36
|
+
* #108 note: promoting a verb to a top-level command (see `createProgram`
|
|
37
|
+
* below) renamed ITS resolved telemetry name from `scraps <verb>` to
|
|
38
|
+
* `<verb>` — the canonical top-level attach and the legacy hidden
|
|
39
|
+
* `scraps <verb>` attach are two separate Command instances (scraps.ts's
|
|
40
|
+
* double-attach factories), each with its own parent chain, so they
|
|
41
|
+
* resolve to two different names here even though they run the same
|
|
42
|
+
* handler. Intentional (the canonical command IS now `<verb>`), not a bug.
|
|
35
43
|
*/
|
|
36
44
|
export function resolveCommandName(actionCommand) {
|
|
37
45
|
if (!actionCommand)
|
|
@@ -63,21 +71,51 @@ export function collectCommandNames(root) {
|
|
|
63
71
|
walk(root);
|
|
64
72
|
return names;
|
|
65
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* #108 — surface reorg into two `trawl --help` tiers. Core verbs are
|
|
76
|
+
* agent+human, `--json` first-class, non-interactive; Management is the
|
|
77
|
+
* existing human/CI surface, kept but grouped so top-level help reads
|
|
78
|
+
* simple. Commander v14's native per-command help group (`.commandsGroup()`
|
|
79
|
+
* sets the default a subsequently-registered command inherits via
|
|
80
|
+
* `.helpGroup()`) drives the section headings — group ORDER in the printed
|
|
81
|
+
* help follows first-seen insertion order into `program.commands`, so every
|
|
82
|
+
* Core command is registered below before any Management one.
|
|
83
|
+
*/
|
|
84
|
+
const CORE_GROUP = 'Core commands (agent + human):';
|
|
85
|
+
const MANAGEMENT_GROUP = 'Management commands (human/CI):';
|
|
66
86
|
export function createProgram() {
|
|
67
87
|
const program = new Command()
|
|
68
88
|
.name('trawl')
|
|
69
89
|
.description('Trawl CLI — manage scraps from the terminal')
|
|
70
90
|
.version(pkg.version)
|
|
71
91
|
.option('--debug', 'Show full error stack traces');
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
// Core verbs (#108) — promoted/listed first: fetch, run, list, get, data,
|
|
93
|
+
// history, run-info, trigger, whoami, ping. `list`/`get`/`run`/`data`/
|
|
94
|
+
// `history`/`run-info`/`trigger` are built via scraps.ts's exported
|
|
95
|
+
// attachXCommand() factories — the SAME definition also stays wired
|
|
96
|
+
// (hidden) under `scraps` there, so every pre-#108 `trawl scraps <verb>`
|
|
97
|
+
// invocation keeps resolving (no breaking change).
|
|
98
|
+
program.commandsGroup(CORE_GROUP);
|
|
78
99
|
program.addCommand(fetchUrl);
|
|
100
|
+
attachRunCommand(program);
|
|
101
|
+
attachListCommand(program);
|
|
102
|
+
attachGetCommand(program);
|
|
103
|
+
attachDataCommand(program);
|
|
104
|
+
attachHistoryCommand(program);
|
|
105
|
+
attachRunInfoCommand(program);
|
|
106
|
+
attachTriggerCommand(program);
|
|
79
107
|
program.addCommand(whoami);
|
|
80
108
|
program.addCommand(ping);
|
|
109
|
+
// Management (#108) — human/CI surface, grouped below. `scraps` still
|
|
110
|
+
// holds every pre-#108 management command (create/update/delete/banner/
|
|
111
|
+
// watch/account.*/session.*/doctor/autofix/snapshot) exactly as before.
|
|
112
|
+
program.commandsGroup(MANAGEMENT_GROUP);
|
|
113
|
+
program.addCommand(scraps);
|
|
114
|
+
program.addCommand(skills);
|
|
115
|
+
program.addCommand(login);
|
|
116
|
+
program.addCommand(logout);
|
|
117
|
+
program.addCommand(token);
|
|
118
|
+
program.addCommand(telemetry);
|
|
81
119
|
return program;
|
|
82
120
|
}
|
|
83
121
|
/**
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Trawl CLI — Agent Quickstart
|
|
2
|
+
|
|
3
|
+
The minimal surface an AI agent needs to drive `@trawlme/cli` non-interactively.
|
|
4
|
+
For the full command reference (management surface, Claude Code skills,
|
|
5
|
+
telemetry, etc.) see the [main README](../README.md) — the human/CI guide.
|
|
6
|
+
|
|
7
|
+
## Auth — zero prompts
|
|
8
|
+
|
|
9
|
+
Set `TRAWL_TOKEN` and every command authenticates without ever touching a
|
|
10
|
+
prompt:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
export TRAWL_TOKEN=<jwt>
|
|
14
|
+
trawl whoami --json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
(Interactive `trawl login` and the `--url`/config-file flow are documented in
|
|
18
|
+
the README's [Authentication](../README.md#authentication) section — an
|
|
19
|
+
agent should never need them.)
|
|
20
|
+
|
|
21
|
+
## Core commands (agent + human)
|
|
22
|
+
|
|
23
|
+
These ten commands are the CLI's agent+human surface — `--json` is
|
|
24
|
+
first-class on every one, and none of them ever blocks on a prompt (see
|
|
25
|
+
[Non-interactive contract](#non-interactive-contract) below):
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
trawl fetch <url> [--json] [--reason <text>] One-shot fetch + extract readable content from a public URL (no scrap needed)
|
|
29
|
+
trawl run <id> [--watch] [--json] Run a scrap
|
|
30
|
+
trawl list|ls [--json] [--status <s>] [--limit <n>] [--page <n>] List all scraps
|
|
31
|
+
trawl get <id> [--json] Get scrap details
|
|
32
|
+
trawl data <id> [--json] [--fresh] [--errors] Get scrap data (last persisted run, or --fresh to launch one)
|
|
33
|
+
trawl history <id> [--json] [-n <limit>] List past runs for a scrap
|
|
34
|
+
trawl run-info <hid> [--json] Show details of a single run
|
|
35
|
+
trawl trigger <id> [--watch] [--wait] [--json] Launch a scrap as a background worker
|
|
36
|
+
trawl whoami [--json] Show the authenticated user's identity
|
|
37
|
+
trawl ping [--json] Health/version handshake against the Trawl API
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`trawl fetch` is the one command with no persisted scrap behind it — a
|
|
41
|
+
one-shot fetch + extract for any public URL, the closest primitive to
|
|
42
|
+
"just get me this page's content." It's the REST counterpart of the MCP
|
|
43
|
+
`trawl_fetch_url` tool (same shared engine): `status` is an honest outcome
|
|
44
|
+
(`completed`/`failed`/`empty`/`blocked`), not "did the HTTP call succeed" — a
|
|
45
|
+
failed fetch is still a 200 response with `status:'failed'` + `error`, and
|
|
46
|
+
the CLI exits `1` in that case even though `--json` always prints the raw
|
|
47
|
+
payload verbatim.
|
|
48
|
+
|
|
49
|
+
> **No breaking change:** every verb above is also still reachable under its
|
|
50
|
+
> pre-reorg path, `trawl scraps <verb>` (e.g. `trawl scraps list`) — kept as
|
|
51
|
+
> a hidden alias. Prefer the bare top-level form above; it's what
|
|
52
|
+
> `trawl --help` now shows.
|
|
53
|
+
|
|
54
|
+
For the full flag reference (tier overrides on `create`/`update`, the
|
|
55
|
+
`--watch` polling mechanics, retention/regression semantics on `data`, …)
|
|
56
|
+
see the README's [Core commands](../README.md#core-commands-agent--human) section
|
|
57
|
+
— this doc intentionally stays minimal.
|
|
58
|
+
|
|
59
|
+
## `--json` contract
|
|
60
|
+
|
|
61
|
+
Every command above supports `--json`: a single structured payload on
|
|
62
|
+
stdout, nothing else. Two narrow exceptions carried over from the human
|
|
63
|
+
surface: a `--watch` poll emits exactly one final NDJSON line once the run
|
|
64
|
+
reaches a terminal state (not the whole progress stream), and there is no
|
|
65
|
+
JSON form of an HTML page (irrelevant to the core verbs above — that only
|
|
66
|
+
applies to the management-only `scraps snapshot`).
|
|
67
|
+
|
|
68
|
+
On failure, `--json` emits a single error envelope on stdout instead of
|
|
69
|
+
prose — `{"error":{"message","status?","kind"}}` — and the human-readable
|
|
70
|
+
line goes to stderr, never stdout. `kind` is the machine-readable
|
|
71
|
+
discriminant (`"usage"`/`"auth"`/`"not_found"`/`"network"`/`"api"`/
|
|
72
|
+
`"refused"`/`"unknown"`) a script should switch on.
|
|
73
|
+
|
|
74
|
+
## Non-interactive contract
|
|
75
|
+
|
|
76
|
+
No core verb ever blocks waiting for a prompt. When stdin/stdout isn't a
|
|
77
|
+
real TTY (any subprocess-driven invocation) — or `--json` is set — any
|
|
78
|
+
command that would otherwise ask a `[y/N]` confirmation or a missing value
|
|
79
|
+
instead fails fast with a structured usage error (exit `2`) rather than
|
|
80
|
+
hanging. Full rule + rationale: README's
|
|
81
|
+
[Non-interactive rule](../README.md#non-interactive-rule).
|
|
82
|
+
|
|
83
|
+
## Exit codes
|
|
84
|
+
|
|
85
|
+
| Code | Meaning |
|
|
86
|
+
|------|---------|
|
|
87
|
+
| `0` | Success |
|
|
88
|
+
| `1` | Unknown/generic error, or a business-logic outcome (e.g. `fetch`'s honest `status:'failed'`/`'blocked'`, `data`'s `run_failed`/`in_progress`) |
|
|
89
|
+
| `2` | Usage error (bad flag/value, invalid ID, missing required argument, or the non-interactive guard refusing to prompt) |
|
|
90
|
+
| `3` | Auth error (not logged in, or the session token is expired/invalid) |
|
|
91
|
+
| `4` | Not found (no such resource, or no persisted payload to read) |
|
|
92
|
+
| `5` | Network error (API host unreachable, DNS/connection/TLS failure, or timeout) |
|
|
93
|
+
|
|
94
|
+
This table is the stable contract; per-command nuance and overloads (e.g.
|
|
95
|
+
`fetch`'s domain-level failure sharing exit `1` with an unmapped bug) are
|
|
96
|
+
documented once, in the README's [Exit codes](../README.md#exit-codes)
|
|
97
|
+
section — treat that as canonical if the two ever seem to disagree.
|
|
98
|
+
|
|
99
|
+
## Minimal example
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
TRAWL_TOKEN=<jwt> trawl fetch https://example.com --json
|
|
103
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trawlme/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Trawl CLI — manage scraps from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
|
+
"docs",
|
|
11
12
|
"README.md",
|
|
12
13
|
"LICENSE"
|
|
13
14
|
],
|