browse 0.9.2 → 0.9.3-alpha-2f5e085
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 +3 -3
- package/dist/commands/snapshot.js +10 -4
- package/dist/lib/driver/commands/snapshot.js +9 -10
- package/oclif.manifest.json +679 -673
- package/package.json +2 -2
- package/skills/browse/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ npm install -g browse
|
|
|
33
33
|
npm install -g browse
|
|
34
34
|
|
|
35
35
|
browse open https://example.com
|
|
36
|
-
browse snapshot
|
|
36
|
+
browse snapshot
|
|
37
37
|
browse click @0-12
|
|
38
38
|
browse fill @0-8 "hello"
|
|
39
39
|
browse get title
|
|
@@ -89,8 +89,8 @@ browse forward # Navigate forward
|
|
|
89
89
|
The accessibility snapshot is the recommended way for agents to discover elements. It prints a tree of refs like `@0-12` that the element commands accept directly.
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
|
-
browse snapshot # Accessibility
|
|
93
|
-
browse snapshot --
|
|
92
|
+
browse snapshot # Accessibility tree + cached refs (lean by default)
|
|
93
|
+
browse snapshot --full # Also include the ref maps (xpathMap, urlMap)
|
|
94
94
|
browse snapshot --filter submit # Filter lines by text or /regex/, keeping ancestors
|
|
95
95
|
browse snapshot --max-depth 4 # Trim output deeper than this depth
|
|
96
96
|
```
|
|
@@ -2,17 +2,20 @@ import { Flags } from "@oclif/core";
|
|
|
2
2
|
import { BrowseCommand } from "../base.js";
|
|
3
3
|
import { driverCommandFlags, runDriverCommandFromFlags, } from "../lib/driver/command-cli.js";
|
|
4
4
|
export default class Snapshot extends BrowseCommand {
|
|
5
|
-
static description = "Print the active page accessibility snapshot and cache refs for element commands.";
|
|
5
|
+
static description = "Print the active page accessibility snapshot and cache refs for element commands. Pass --full to also include the ref maps (xpathMap, urlMap).";
|
|
6
6
|
static examples = [
|
|
7
7
|
"browse snapshot",
|
|
8
|
-
"browse snapshot --
|
|
8
|
+
"browse snapshot --full",
|
|
9
9
|
"browse snapshot --filter submit",
|
|
10
10
|
"browse snapshot --max-depth 4",
|
|
11
11
|
];
|
|
12
12
|
static flags = {
|
|
13
13
|
...driverCommandFlags,
|
|
14
|
+
full: Flags.boolean({
|
|
15
|
+
description: "Also include the ref maps (xpathMap, urlMap).",
|
|
16
|
+
}),
|
|
14
17
|
compact: Flags.boolean({
|
|
15
|
-
description: "
|
|
18
|
+
description: "Deprecated and has no effect; use --full to include the ref maps.",
|
|
16
19
|
}),
|
|
17
20
|
filter: Flags.string({
|
|
18
21
|
description: "Filter output lines by text or /regex/ while preserving matching ancestors.",
|
|
@@ -25,8 +28,11 @@ export default class Snapshot extends BrowseCommand {
|
|
|
25
28
|
};
|
|
26
29
|
async run() {
|
|
27
30
|
const { flags } = await this.parse(Snapshot);
|
|
31
|
+
if (flags.compact && process.stderr.isTTY) {
|
|
32
|
+
this.warn("`--compact` is deprecated and has no effect; use `--full` to include the ref maps.");
|
|
33
|
+
}
|
|
28
34
|
await runDriverCommandFromFlags("snapshot", {
|
|
29
|
-
|
|
35
|
+
full: flags.full,
|
|
30
36
|
filter: flags.filter,
|
|
31
37
|
maxDepth: flags["max-depth"],
|
|
32
38
|
}, flags);
|
|
@@ -2,9 +2,9 @@ import { z } from "zod";
|
|
|
2
2
|
import { formatSnapshotTree } from "./snapshot-format.js";
|
|
3
3
|
export const snapshotHandlers = {
|
|
4
4
|
async snapshot(manager, params) {
|
|
5
|
-
const {
|
|
5
|
+
const { full, filter, maxDepth } = z
|
|
6
6
|
.object({
|
|
7
|
-
|
|
7
|
+
full: z.boolean().optional(),
|
|
8
8
|
filter: z.string().optional(),
|
|
9
9
|
maxDepth: z.number().int().nonnegative().optional(),
|
|
10
10
|
})
|
|
@@ -16,17 +16,16 @@ export const snapshotHandlers = {
|
|
|
16
16
|
xpathMap: snapshot.xpathMap ?? {},
|
|
17
17
|
});
|
|
18
18
|
const tree = formatSnapshotTree(snapshot.formattedTree, {
|
|
19
|
-
compact,
|
|
20
19
|
filter,
|
|
21
20
|
maxDepth,
|
|
22
21
|
});
|
|
23
|
-
if (
|
|
24
|
-
return {
|
|
22
|
+
if (full) {
|
|
23
|
+
return {
|
|
24
|
+
tree,
|
|
25
|
+
urlMap: snapshot.urlMap,
|
|
26
|
+
xpathMap: snapshot.xpathMap,
|
|
27
|
+
};
|
|
25
28
|
}
|
|
26
|
-
return {
|
|
27
|
-
tree,
|
|
28
|
-
urlMap: snapshot.urlMap,
|
|
29
|
-
xpathMap: snapshot.xpathMap,
|
|
30
|
-
};
|
|
29
|
+
return { tree };
|
|
31
30
|
},
|
|
32
31
|
};
|