opensteer 0.8.13 → 0.8.15

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.
@@ -1,261 +1,118 @@
1
1
  # Opensteer CLI Reference
2
2
 
3
- This covers DOM exploration and browser administration. For request capture workflows, see the [Request Workflow](request-workflow.md) reference.
4
-
5
- Use the CLI when you need a fast JSON-first loop against a repo-local workspace browser.
6
-
7
- ## Sections
8
-
9
- - [Quickstart](#quickstart)
10
- - [Snapshot Output — What To Read](#snapshot-output--what-to-read)
11
- - [End-to-End Example](#end-to-end-example)
12
- - [Browser Lifecycle And Profile Cloning](#browser-lifecycle-and-profile-cloning)
13
- - [Browser Modes](#browser-modes)
14
- - [Advanced Semantic Operations](#advanced-semantic-operations)
15
- - [Extraction Schema And Array Auto-Generalization](#extraction-schema-and-array-auto-generalization)
3
+ Use the CLI for fast exploration before writing SDK code.
16
4
 
17
5
  ## Quickstart
18
6
 
19
7
  ```bash
20
8
  opensteer open https://example.com --workspace demo
21
9
  opensteer snapshot action --workspace demo
22
- # Read the "html" field in the JSON output. Find elements by their c="N" attributes.
23
- # Example: <input c="5" placeholder="Search"> means element 5 is the search input.
24
- # Example: <button c="7">Search</button> means element 7 is the search button.
25
-
26
- # Act on elements AND persist their paths with human-readable descriptions
27
- opensteer run dom.input --workspace demo \
28
- --input-json '{"target":{"kind":"element","element":5},"text":"search term","persistAsDescription":"search input"}'
29
- opensteer run dom.click --workspace demo \
30
- --input-json '{"target":{"kind":"element","element":7},"persistAsDescription":"search button"}'
31
-
32
- # Re-snapshot after navigation, then persist an extraction descriptor
10
+ opensteer input 5 laptop --workspace demo --persist "search input" --capture-network search
11
+ opensteer click 7 --workspace demo --persist "search button" --capture-network search
33
12
  opensteer snapshot extraction --workspace demo
34
- opensteer extract --workspace demo \
35
- --description "page summary" \
36
- --schema-json '{"title":{"element":3},"url":{"source":"current_url"}}'
37
-
38
- # Replay later with just descriptions — no snapshot needed
39
- opensteer click --workspace demo --description "search button"
40
- opensteer extract --workspace demo --description "page summary"
13
+ opensteer extract '{"items":[{"name":{"element":13},"price":{"element":14}},{"name":{"element":22},"price":{"element":23}}]}' \
14
+ --workspace demo --persist "search results"
41
15
  opensteer close --workspace demo
42
16
  ```
43
17
 
44
- - Stateful CLI commands currently require `--workspace <id>`.
45
- - Use `snapshot action` to discover page elements during exploration.
46
- - Use `opensteer run dom.*` with `persistAsDescription` to cache element paths under descriptions.
47
- - Replay cached actions with `--description` alone — no snapshot needed.
48
- - `extract --description --schema-json` writes a persisted extraction descriptor.
49
- - `extract --description` replays the stored extraction.
50
- - Persisted network history (`network.query`, `network.tag`, and `network.clear`) is SQLite-backed and initializes on first use.
51
- - Generic workspace and browser commands do not require SQLite capability unless they touch network history persistence.
18
+ ## What To Read From Snapshots
52
19
 
53
- ## Snapshot Output What To Read
20
+ `snapshot action` and `snapshot extraction` return filtered HTML in the `html` field.
54
21
 
55
- `snapshot action` and `snapshot extraction` both return JSON:
22
+ - Read the `html` string.
23
+ - Find `c="N"` markers in that HTML.
24
+ - Use those numbers as positional `element` ids in CLI commands and extraction schemas.
25
+ - Re-snapshot after navigation before using new element numbers.
56
26
 
57
- ```json
58
- {
59
- "url": "https://example.com/search?q=airpods",
60
- "title": "Search Results",
61
- "mode": "extraction",
62
- "html": "<span c=\"12\">$549.99</span>\n<a c=\"15\" href=\"/p/product-1\">\n <div c=\"16\">Apple AirPods Max</div>\n</a>\n<a c=\"18\" href=\"/b/apple\">Apple</a>...",
63
- "counters": [{"element":12,"tagName":"SPAN","pathHint":"span",...}, ...]
64
- }
65
- ```
27
+ ## Core Commands
66
28
 
67
- **Read the `html` field.** It is a clean, filtered DOM. Hidden elements, scripts, and styles are already removed. Every element has a `c="N"` attribute.
68
-
69
- - `c="N"` in the HTML = `element: N` in commands and extraction schemas
70
- - `snapshot action` keeps interactive elements (buttons, inputs, links) for clicking/typing
71
- - `snapshot extraction` keeps all visible content (text, prices, titles) for data extraction
72
- - Do NOT parse the `counters` array to find elements — it is verbose metadata. Read the HTML string, find the `c="N"` values, and use those numbers.
73
-
74
- ## End-to-End Example
75
-
76
- Goal: go to a site, search for a product, extract all results.
29
+ ### Session and Pages
77
30
 
78
31
  ```bash
79
- # 1. Open the page
80
32
  opensteer open https://example.com --workspace demo
81
-
82
- # 2. Snapshot to discover elements
33
+ opensteer goto https://example.com/search --workspace demo --capture-network page-load
83
34
  opensteer snapshot action --workspace demo
84
- # Read html field. Find: <input c="5" placeholder="Search"> and <button c="7">Search</button>
85
-
86
- # 3. Type search term and persist the element path
87
- opensteer run dom.input --workspace demo \
88
- --input-json '{"target":{"kind":"element","element":5},"text":"airpods","pressEnter":true,"persistAsDescription":"search input"}'
89
-
90
- # 4. Re-snapshot the results page (always re-snapshot after navigation!)
91
35
  opensteer snapshot extraction --workspace demo
92
- # Read html field. Find product items with their c="N" values:
93
- # <div c="13">Apple AirPods Max</div> <span c="14">$549.99</span>
94
- # <div c="22">Apple AirPods Pro</div> <span c="23">$249.99</span>
95
-
96
- # 5. Extract all results — array auto-generalizes from template rows
97
- opensteer extract --workspace demo \
98
- --description "search results" \
99
- --schema-json '{"items":[{"name":{"element":13},"price":{"element":14}},{"name":{"element":22},"price":{"element":23}}]}'
100
- # Returns ALL matching rows on the page, not just the 2 templates.
101
-
102
- # 6. Close
36
+ opensteer tab list --workspace demo
37
+ opensteer tab 2 --workspace demo
38
+ opensteer tab close 2 --workspace demo
103
39
  opensteer close --workspace demo
104
40
  ```
105
41
 
106
- Total: 6 commands.
107
-
108
- ## Browser Lifecycle And Profile Cloning
109
-
110
- ```bash
111
- opensteer browser clone --workspace github-sync \
112
- --source-user-data-dir "$HOME/Library/Application Support/Google/Chrome" \
113
- --source-profile-directory Default
114
- opensteer open https://github.com --workspace github-sync
115
- opensteer browser status --workspace github-sync
116
- opensteer close --workspace github-sync
117
- opensteer browser reset --workspace github-sync
118
- opensteer browser delete --workspace github-sync
119
- ```
120
-
121
- - `browser clone`, `browser reset`, and `browser delete` require a persistent workspace browser.
122
- - `browser clone` copies a local Chromium profile into `.opensteer/workspaces/<id>/browser/user-data`.
123
- - `close` stops the active session/browser but keeps the workspace registry, traces, artifacts, and cloned browser data.
124
-
125
- ## Browser Modes
126
-
127
- - `persistent`: default with `--workspace`. Browser state lives in the workspace.
128
- - `temporary`: isolated browser state for the current run.
129
- - `attach`: connect to a running Chromium browser.
130
-
131
- ```bash
132
- opensteer open https://example.com --workspace demo --browser temporary
133
- opensteer browser discover
134
- opensteer browser inspect --attach-endpoint ws://127.0.0.1:9222/devtools/browser/abc
135
- opensteer open https://example.com --workspace demo --browser attach --attach-endpoint ws://127.0.0.1:9222/devtools/browser/abc
136
- ```
137
-
138
- Common options:
139
-
140
- - `--headless true|false`
141
- - `--executable-path <path>`
142
- - `--arg <value>` repeatable
143
- - `--timeout-ms <ms>`
144
- - `--context-json <json>`
145
- - `--fresh-tab true|false` for `--browser attach`
146
-
147
- ## Advanced Semantic Operations
148
-
149
- The short CLI only special-cases a small set of commands. For advanced operations and fields not exposed by shorthand parsing, use:
42
+ ### DOM Actions
150
43
 
151
44
  ```bash
152
- opensteer run <semantic-operation> --workspace <id> --input-json <json>
153
- ```
154
-
155
- Examples:
156
-
157
- ```bash
158
- opensteer run dom.click --workspace demo \
159
- --input-json '{"target":{"kind":"selector","selector":"button.primary"},"persistAsDescription":"primary button","captureNetwork":"load-products"}'
160
-
161
- opensteer run page.goto --workspace demo \
162
- --input-json '{"url":"https://example.com/products","captureNetwork":"page-load"}'
163
-
164
- opensteer run network.query --workspace demo \
165
- --input-json '{"capture":"load-products","includeBodies":true,"limit":20}'
166
-
167
- opensteer run request-plan.infer --workspace demo \
168
- --input-json '{"recordId":"rec_123","key":"products.search","version":"v1"}'
169
-
170
- opensteer run request-plan.infer --workspace demo \
171
- --input-json '{"recordId":"rec_123","key":"products.search.portable","version":"v1","transport":"direct-http"}'
172
-
173
- opensteer run request.execute --workspace demo \
174
- --input-json '{"key":"products.search","query":{"q":"laptop"}}'
45
+ opensteer click 7 --workspace demo --persist "primary button"
46
+ opensteer hover 7 --workspace demo --persist "primary button"
47
+ opensteer input 5 "search term" --workspace demo --persist "search input" --press-enter
48
+ opensteer scroll down 400 --workspace demo
49
+ opensteer scroll down 400 --workspace demo --element 12 --persist "results list"
50
+ opensteer extract '{"title":{"element":3},"url":{"source":"current_url"}}' --workspace demo \
51
+ --persist "page summary"
175
52
  ```
176
53
 
177
- - Command aliases such as `network query` and `request-plan infer` still exist, but they usually depend on `--input-json` for nontrivial inputs.
178
- - Use `run page.goto` when you need `captureNetwork` on navigation. The short `goto` form only parses the URL positional.
179
- - Use `run dom.click` / `run dom.input` / `run dom.hover` / `run dom.scroll` when you need `persistAsDescription`.
180
-
181
- ## Extraction Schema
182
-
183
- Always run `snapshot extraction` before building a schema — you need the `c="N"` counter values from the HTML.
54
+ Rules:
184
55
 
185
- Schemas are **literal**: each `element` reference points to one specific DOM element, and you get back exactly the values you asked for. The schema is not a prompt or pattern — it is a precise specification.
56
+ - `--persist` caches reusable DOM targets and extraction descriptors by persist key.
57
+ - `extract <schema> [--persist <key>]` accepts the schema positionally and optionally saves it for replay.
58
+ - There is no CLI `--selector`, `--description` target flag, `--text`, or `--input-json`.
186
59
 
187
- Flat field bindings:
60
+ ### Network Discovery
188
61
 
189
62
  ```bash
190
- opensteer extract --workspace demo \
191
- --description "page summary" \
192
- --schema-json '{"title":{"element":3},"price":{"element":7}}'
193
-
194
- opensteer extract --workspace demo \
195
- --description "links" \
196
- --schema-json '{"url":{"selector":"a.primary","attribute":"href"},"pageUrl":{"source":"current_url"}}'
63
+ opensteer network query --workspace demo --capture search
64
+ opensteer network query --workspace demo --hostname api.example.com --limit 20
65
+ opensteer network detail rec_123 --workspace demo
66
+ opensteer replay rec_123 --workspace demo
67
+ opensteer replay rec_123 --workspace demo --query keyword=headphones --query count=10
68
+ opensteer fetch https://api.example.com/search --workspace demo --query keyword=laptop
197
69
  ```
198
70
 
199
- ## Array Extraction (Two-Step Process)
71
+ `network query` is intentionally short:
200
72
 
201
- Extracting lists of items (product rows, search results, etc.) is a two-step process:
73
+ - one compact block per record
74
+ - record id
75
+ - method and status
76
+ - resource type
77
+ - URL
78
+ - request and response body summaries when useful
202
79
 
203
- **Step 1 Teach the pattern (schema + description):**
80
+ Use `network detail` when you need headers, cookies sent, request body previews, response body previews, GraphQL metadata, or redirect chains.
204
81
 
205
- Provide 2 structurally similar rows as templates. The extractor returns exactly those rows (literal), but behind the scenes consolidates the templates into a generalized selector and saves it as a descriptor.
82
+ ### Browser State
206
83
 
207
84
  ```bash
208
- opensteer extract --workspace demo \
209
- --description "product list" \
210
- --schema-json '{"items":[{"name":{"element":13},"price":{"element":14}},{"name":{"element":22},"price":{"element":23}}]}'
211
- ```
212
-
213
- Returns exactly 2 rows (the literal template values):
214
- ```json
215
- {
216
- "items": [
217
- {"name": "Apple AirPods Max", "price": "$549.99"},
218
- {"name": "Apple AirPods Pro", "price": "$249.99"}
219
- ]
220
- }
85
+ opensteer cookies --workspace demo
86
+ opensteer cookies example.com --workspace demo
87
+ opensteer storage example.com --workspace demo
88
+ opensteer state example.com --workspace demo
221
89
  ```
222
90
 
223
- **Step 2 Replay to get all rows (description only, no schema):**
91
+ Use these when replay needs cookies, storage-backed tokens, hidden fields, or globals.
224
92
 
225
- Replay the saved descriptor. The generalized selector finds ALL matching rows on the page:
93
+ ### Browser Admin
226
94
 
227
95
  ```bash
228
- opensteer extract --workspace demo --description "product list"
229
- ```
230
-
231
- Returns all matching rows:
232
- ```json
233
- {
234
- "items": [
235
- {"name": "Apple AirPods Max", "price": "$549.99"},
236
- {"name": "Apple AirPods Pro", "price": "$249.99"},
237
- {"name": "Apple AirPods 4", "price": "$129.99"},
238
- {"name": "Apple AirPods 4 (ANC)", "price": "$179.99"}
239
- ]
240
- }
96
+ opensteer browser status --workspace demo
97
+ opensteer browser clone --workspace github-sync --source-user-data-dir "$HOME/Library/Application Support/Google/Chrome" --source-profile-directory Default
98
+ opensteer browser reset --workspace github-sync
99
+ opensteer browser delete --workspace github-sync
100
+ opensteer record https://example.com --workspace demo
241
101
  ```
242
102
 
243
- This replay is deterministic and works across page updates, pagination, and different page states.
244
-
245
- Rules:
103
+ ## Recommended Exploration Loop
246
104
 
247
- - Build the exact JSON shape you want. The extractor does not accept `"string"` or prompt-style schemas.
248
- - Each leaf must be `{ element: N }`, `{ selector: "..." }`, optional `attribute`, or `{ source: "current_url" }`.
249
- - Use `element` fields during CLI exploration with a fresh snapshot. Deterministic scripts use `description`.
250
- - For arrays, provide 2 representative objects from different positions in the list. This gives the consolidator enough structural signal to generalize. Add more when rows have structural variants.
251
- - Nested arrays are not supported.
252
- - Do NOT expect the initial `extract --schema-json` call to return all rows. It returns exactly the template rows. Use description-only replay for the full list.
105
+ 1. `opensteer open`
106
+ 2. `opensteer goto ... --capture-network <label>` or a DOM action with `--capture-network`
107
+ 3. `opensteer network query`
108
+ 4. `opensteer network detail <recordId>`
109
+ 5. `opensteer replay <recordId>`
110
+ 6. `opensteer cookies` / `storage` / `state` if needed
111
+ 7. `opensteer close`
253
112
 
254
- ## What NOT To Do
113
+ ## Common Mistakes
255
114
 
256
- - Do NOT use `page.evaluate()` to scrape DOM data. Use `extract()` with element-based schemas.
257
- - Do NOT parse the `counters` array to find elements. Read the `html` string and find `c="N"` values.
258
- - Do NOT use CSS selectors in reusable scripts. Use `description` from cached descriptors.
259
- - Do NOT write loops to enumerate list items. Use array extraction: provide 2 template rows in the schema, then replay with description only to get all rows.
260
- - Do NOT expect `extract --schema-json` with array templates to return all rows. It returns exactly the templates. Replay with `--description` alone for the full list.
261
- - Do NOT skip re-snapshot after navigation. Always re-snapshot before targeting new elements.
115
+ - Starting API discovery with `snapshot` instead of `captureNetwork`.
116
+ - Parsing the old `counters` metadata instead of reading the `html` string.
117
+ - Trying to use removed surfaces such as `opensteer run`, `--input-json`, `--selector`, or `--description` target flags.
118
+ - Forgetting to re-snapshot after navigation.