@react-grab/cli 0.1.38 → 0.1.40

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-grab/cli",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "bin": {
5
5
  "react-grab": "./bin/cli.js"
6
6
  },
@@ -6,31 +6,67 @@ description: >-
6
6
  copy-paste or manual handoff. Triggers: "watch react grab", "monitor my
7
7
  grabs", "auto-process react grab", "watch my clipboard for grabs". Not for a
8
8
  one-off paste of a single grab; this is the continuous, always-on loop.
9
- disable-model-invocation: true
10
9
  ---
11
10
 
12
11
  # React Grab
13
12
 
14
- The user selects UI elements in their browser and copies them with React Grab.
15
- `npx grab watch` blocks until the next grab lands on the clipboard, prints it as
16
- one line of JSON, and exits. Run it, act on the grab, run it again: that is the
17
- whole loop. No background process, no notifications, no polling, just a blocking
18
- command you keep re-running until the user says stop.
13
+ The user selects UI elements in their browser and copies them with React Grab. A
14
+ background daemon captures each grab to `./.react-grab/history.jsonl`; you pull
15
+ them with `grab read`. Nothing blocks the agent: the daemon runs detached and
16
+ `read` returns promptly, so the loop survives shell-command timeouts.
17
+
18
+ ## Start the daemon (once)
19
+
20
+ ```bash
21
+ npx grab@latest watch
22
+ ```
23
+
24
+ This launches a detached daemon that watches the clipboard. It is idempotent per
25
+ dir — re-running it while a daemon is already watching this project is a no-op —
26
+ so it is safe to run at the start of every session. `--dir <path>` relocates the
27
+ capture dir; `--text-only` skips the native clipboard reader.
19
28
 
20
29
  ## The loop
21
30
 
22
- 1. Run `npx grab watch` in the foreground. It blocks until the user grabs
23
- something, then prints the grab JSON and exits 0.
24
- 2. Act on the grab (below).
25
- 3. Repeat.
31
+ Repeat until the user says stop:
32
+
33
+ 1. Pull the next grabs (blocks up to 20s for one to arrive, then returns):
34
+
35
+ ```bash
36
+ npx grab read --wait 20000
37
+ ```
38
+
39
+ Each line of stdout is one grab as JSON. Empty output means nothing new yet —
40
+ just run it again.
26
41
 
27
- Each grab is also appended to `./.react-grab/history.jsonl` as a durable record;
28
- the command drops a `.gitignore` there so it never lands in git. `--dir <path>`
29
- relocates it, `--text-only` skips the native clipboard reader.
42
+ 2. Act on each grab (below).
43
+ 3. Go back to step 1.
44
+
45
+ `read` advances a cursor (`./.react-grab/cursor.txt`), so each grab is delivered
46
+ exactly once across calls. Add `--all` to replay the whole history from the start.
47
+
48
+ ## Gotchas
49
+
50
+ - **Empty `read` output is not an error** — it just means no grab landed yet.
51
+ Re-run it; never treat empty output as the daemon being dead or the loop being
52
+ done. Only the user saying "stop" ends the loop.
53
+ - **The daemon reads the clipboard on the machine it runs on.** Over SSH, in a
54
+ container, or on a cloud host while the browser is on the user's laptop, grabs
55
+ never arrive. The daemon must run on the same machine as the browser.
56
+ - **Run one `read` at a time.** Concurrent reads share `cursor.txt` and can
57
+ double-deliver or skip grabs — keep the loop sequential.
58
+ - **`read --all` replays the whole history without consuming it** — it does not
59
+ advance the cursor, so use it only to inspect history; the loop's plain `read`
60
+ is what delivers each grab exactly once.
61
+ - **If grabs never arrive even though the user is grabbing**, the daemon may not
62
+ be staying up. A healthy daemon makes `npx grab@latest watch` report
63
+ `already watching`; if it keeps reporting `started`, the daemon is dying on
64
+ startup — usually no clipboard reader. Try `npx grab watch --text-only`, or run
65
+ `npx grab watch --foreground` once to see the startup error directly.
30
66
 
31
67
  ## Acting on a grab
32
68
 
33
- The grab JSON has `content` (the element's source references) and, in prompt
69
+ Each grab JSON has `content` (the element's source references) and, in prompt
34
70
  mode, `prompt` (the user's typed instruction):
35
71
 
36
72
  - **`prompt` present** → that comment IS the task. Execute it against the grabbed
@@ -45,5 +81,10 @@ inline.
45
81
 
46
82
  ## Stopping
47
83
 
48
- When the user says stop, interrupt the command if it is still blocking and do not
49
- run it again. Confirm the loop has stopped.
84
+ When the user says stop, stop the daemon and do not read again:
85
+
86
+ ```bash
87
+ npx grab@latest watch --stop
88
+ ```
89
+
90
+ Confirm the loop has stopped.