ax-grep 0.0.0 → 0.1.1
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/LICENSE +21 -0
- package/README.md +106 -1
- package/dist/browser.d.ts +11 -0
- package/dist/browser.js +12 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunk-HPZ32BKV.js +612 -0
- package/dist/chunk-HPZ32BKV.js.map +1 -0
- package/dist/chunk-ZXTURCRT.js +925 -0
- package/dist/chunk-ZXTURCRT.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +22364 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +436 -0
- package/dist/index.js.map +1 -0
- package/dist/static.d.ts +6 -0
- package/dist/static.js +8 -0
- package/dist/static.js.map +1 -0
- package/dist/types-gwHWhYmw.d.ts +3660 -0
- package/docs/README.md +19 -0
- package/docs/agent-handoff.md +95 -0
- package/docs/agent-readiness.md +38 -0
- package/docs/assets/ax-grep-benchmark.png +0 -0
- package/docs/assets/ax-grep-og.png +0 -0
- package/docs/assets/ax-grep-search.png +0 -0
- package/docs/benchmarks.md +123 -0
- package/docs/cli-agent.md +194 -0
- package/docs/comparison-baseline.md +625 -0
- package/docs/features.md +28 -0
- package/docs/library-api.md +211 -0
- package/docs/progress.md +1306 -0
- package/package.json +92 -6
- package/skills/ax-grep-cli/SKILL.md +89 -0
- package/skills.sh +24 -0
- package/index.js +0 -1
package/docs/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Documentation
|
|
2
|
+
|
|
3
|
+
Start here when README is too small for the detail you need.
|
|
4
|
+
|
|
5
|
+
| Goal | File |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| Install the Codex skill prompt | [../skills/ax-grep-cli/SKILL.md](../skills/ax-grep-cli/SKILL.md) |
|
|
8
|
+
| Use CLI search and `--agent` output | [cli-agent.md](./cli-agent.md) |
|
|
9
|
+
| Build a minimal agent handoff loop | [agent-handoff.md](./agent-handoff.md) |
|
|
10
|
+
| Use as a server/library package | [library-api.md](./library-api.md) |
|
|
11
|
+
| Inject into WebViews or browser pages | [library-api.md](./library-api.md#browser-injection) |
|
|
12
|
+
| Check readiness before promotion | [agent-readiness.md](./agent-readiness.md) |
|
|
13
|
+
| Track current progress and next work | [progress.md](./progress.md) |
|
|
14
|
+
| Review feature details | [features.md](./features.md) |
|
|
15
|
+
| Run benchmarks and comparisons | [benchmarks.md](./benchmarks.md) |
|
|
16
|
+
| Read current `agent-browser` comparison notes | [comparison-baseline.md](./comparison-baseline.md) |
|
|
17
|
+
|
|
18
|
+
The root README should stay short: skill install first, server library usage
|
|
19
|
+
second, WebView/browser usage third, then links.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Agent Handoff Loop
|
|
2
|
+
|
|
3
|
+
`--agent` returns compact JSON with `agent.executor`, `agent.handoff`, `agent.next`,
|
|
4
|
+
`pageCheck`, `verification`, and source evidence. Executors can usually switch
|
|
5
|
+
only on `agent.executor.decision`.
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
| Decision | Meaning |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `return` | Read the named payload path and answer from current evidence. |
|
|
12
|
+
| `execute` | Run `commandArgs` and inspect the next `ax-grep` payload. |
|
|
13
|
+
| `browser` | Open the URL in a live browser and optionally rerun with captured HTML. |
|
|
14
|
+
| `stop` | Stop because the page or query cannot be usefully advanced. |
|
|
15
|
+
|
|
16
|
+
`commandArgs` always starts with `ax-grep`. Callers using `execFile` can pass
|
|
17
|
+
`commandArgs.slice(1)` back to the binary.
|
|
18
|
+
|
|
19
|
+
## Resource Safety
|
|
20
|
+
|
|
21
|
+
Run executor loops sequentially. Do not fan out `ax-grep`, comparison, or
|
|
22
|
+
browser-backed checks. Before and after browser work, run `pnpm check:processes`
|
|
23
|
+
and clean up any project-owned `agent-browser` or Chromium process.
|
|
24
|
+
|
|
25
|
+
## Minimal Executor
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { execFile } from "node:child_process";
|
|
29
|
+
import { promisify } from "node:util";
|
|
30
|
+
import type { AgentExecutorStep, AgentJsonEnvelope } from "ax-grep";
|
|
31
|
+
|
|
32
|
+
const execFileAsync = promisify(execFile);
|
|
33
|
+
|
|
34
|
+
async function runAxGrep(args: string[]): Promise<AgentJsonEnvelope> {
|
|
35
|
+
const { stdout } = await execFileAsync("ax-grep", args);
|
|
36
|
+
return JSON.parse(stdout);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function inspectWithAxGrep(urlOrQuery: string) {
|
|
40
|
+
let payload = await runAxGrep([urlOrQuery, "--agent"]);
|
|
41
|
+
|
|
42
|
+
for (let iteration = 0; iteration < 4; iteration += 1) {
|
|
43
|
+
const step: AgentExecutorStep = payload.agent.executor;
|
|
44
|
+
|
|
45
|
+
if (step.decision === "return") {
|
|
46
|
+
return step.readValue?.value ?? payload;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (step.decision === "stop") return payload;
|
|
50
|
+
|
|
51
|
+
if (step.decision === "execute" && step.commandArgs) {
|
|
52
|
+
payload = await runAxGrep(step.commandArgs.slice(1));
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (step.decision === "browser") {
|
|
57
|
+
return openInAgentBrowser(step.url);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
throw new Error(step.reason);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return payload;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Output Shape
|
|
68
|
+
|
|
69
|
+
The full JSON is intentionally compact but can still be large. Read these
|
|
70
|
+
fields first:
|
|
71
|
+
|
|
72
|
+
- `agent.handoff`: shortest next-step instruction.
|
|
73
|
+
- `agent.executor`: single-field executor step with command, read, or browser fields.
|
|
74
|
+
- `agent.next`: canonical loop payload with command, read target, or browser step.
|
|
75
|
+
- `verification`: quickest answer for `--find` checks.
|
|
76
|
+
- `pageCheck`: title, evidence, actions, barriers, forms, sources, and metadata.
|
|
77
|
+
- `agent.citations` and `agent.answerEvidence`: evidence ready for final answers.
|
|
78
|
+
|
|
79
|
+
`--agent-brief` keeps `agent.executor` and `agent.handoff` as the primary loop
|
|
80
|
+
surface and omits larger planning fields. When there are alternate search
|
|
81
|
+
results or source links, brief mode places executable choices on
|
|
82
|
+
`agent.handoff.resultChoices` and `agent.handoff.sourceChoices`; each choice
|
|
83
|
+
uses raw `commandArgs` so callers can run it without rebuilding a command.
|
|
84
|
+
Search choices keep snippets, answer handoffs keep selected evidence text, and
|
|
85
|
+
form/action-target read handoffs keep URL templates, fields, selectors, and
|
|
86
|
+
methods. Browser-interaction targets keep barrier `path`/`text` and selector
|
|
87
|
+
when available. Source-link actions keep `sourceLinkRef` back to
|
|
88
|
+
`pageCheck.sourceLinks[n]`.
|
|
89
|
+
|
|
90
|
+
For browser-rendered pages, capture HTML in the agent browser and rerun:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
ax-grep https://example.com --html-file captured.html --agent
|
|
94
|
+
cat captured.html | ax-grep https://example.com --stdin --agent
|
|
95
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Agent Readiness Matrix
|
|
2
|
+
|
|
3
|
+
This project goal is not just raw accessibility-tree parity. `ax-grep` should
|
|
4
|
+
let subagents search, inspect pages, decide the next step, and recover from thin
|
|
5
|
+
or blocked pages with less guesswork than an `agent-browser snapshot` alone.
|
|
6
|
+
|
|
7
|
+
## Evidence Map
|
|
8
|
+
|
|
9
|
+
| Requirement | Current evidence | Completion note |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| CLI agent usefulness stays above the readiness floor for every gate-included target. | `averageCliAgentScore` and `minCliAgentScore` must stay at or above `0.8`; `averageAgentExecutorScore` and `minAgentExecutorScore` must stay at or above `0.995`; raw accessibility overlap metrics remain diagnostic only. | Covered by `compare:gate` and comparison-gate tests. |
|
|
12
|
+
| Search agents can open the best or alternate result without rebuilding commands. | `agent.resultChoices`, `openResult`, `commandArgs`; covered by `tests/cli.test.ts` and `averageSearchResultActionScore`. | Covered by focused tests and comparison gate metrics. |
|
|
13
|
+
| Page-check agents can read structured evidence instead of raw tree text. | `pageCheck.contentEvidence`, citations, `agent.readTargets`, `bestReadTarget`; covered by read-target, citation, answer-plan, evidence metadata, readability reason, and consistency gates. | Covered by tests and static comparison scoring. |
|
|
14
|
+
| Source-link follow-up keeps a stable pointer back to the source array. | `sourceLinkRef` on actions, compact actions, page steps, and text output; covered by CLI and public type tests. | Covered for JSON and text output. |
|
|
15
|
+
| Brief handoff remains executable for subagent loops. | `agent.executor`, `agent.handoff`, `commandArgs`, `readValue`, `resultChoices`, `sourceChoices`; covered by brief executor/handoff tests and gates. | Covered for common search, page, source, form, action-target, and diagnostic cases. |
|
|
16
|
+
| Thin, blocked, or browser-needed pages expose why browser capture is needed. | `needsBrowserHtml`, `browserHtml`, `signals`, `qualityGates`, barriers, and browser retry actions; covered by browser-need, browser-html, signal, and quality-gate scores. | Covered by non-browser fixtures and comparison scoring. |
|
|
17
|
+
| Hidden page signals that are absent from accessibility trees stay discoverable. | Hydration, API, config, policy, schema, resource, media, citation, code-block, and action-target summaries are scored through hidden-signal, hidden-command, response-metadata, count, consistency, and read-target gates. | Covered by static extraction tests; real browser parity still depends on comparison runs. |
|
|
18
|
+
| A minimal real page can use static agent handoff without browser capture. | `pnpm readiness:real-page-smoke` checks `https://example.com` with `--agent-brief`, `canUseFetchedHtml=true`, `needsBrowserHtml=false`, and named semantic roles. | Covered as a smoke gate; broader real-page and `agent-browser` comparison remains. |
|
|
19
|
+
| A minimal `agent-browser` comparison set has stable named-role overlap. | `pnpm readiness:agent-browser-smoke` checks `https://example.com` for exact overlap, `https://books.toscrape.com/` for catalog-page floors, `https://news.ycombinator.com` for link-heavy listing floors, and `https://www.gov.uk/foreign-travel-advice` for government index/search-page floors. | Covered as a four-target smoke gate; broader `agent-browser` comparison remains. |
|
|
20
|
+
| Text-heavy documents separate structural readiness from raw StaticText volume. | `pnpm readiness:agent-browser-text-heavy-smoke` checks Korean Wikipedia with structural content, action, navigation, and text-recall fields. | Covered as a separate smoke gate; not part of the main overlap gate. |
|
|
21
|
+
| Operational safety prevents host overload during validation. | `AGENTS.md`, `vitest.config.ts`, `docs/benchmarks.md`, `docs/comparison-baseline.md`, the `agent-browser` comparison lock, and finally-based session close helpers in browser comparison scripts. | Commands must still be run one at a time, with `pnpm check:processes` before and after risky browser-backed runs. |
|
|
22
|
+
|
|
23
|
+
## Completion Gate
|
|
24
|
+
|
|
25
|
+
Do not call this objective complete from unit tests alone. A completion audit
|
|
26
|
+
must inspect:
|
|
27
|
+
|
|
28
|
+
- `pnpm exec tsc --noEmit`
|
|
29
|
+
- `pnpm readiness:audit`
|
|
30
|
+
- `pnpm readiness:real-page-smoke`
|
|
31
|
+
- `pnpm readiness:agent-browser-smoke`
|
|
32
|
+
- focused non-browser Vitest coverage for changed contracts
|
|
33
|
+
- `pnpm compare:gate <latest comparison report>` for saved comparison output
|
|
34
|
+
- process cleanup before and after browser-backed comparison commands
|
|
35
|
+
- current docs proving README details remain split into `docs/`
|
|
36
|
+
|
|
37
|
+
Browser-backed comparison suites must run sequentially. If the host is already
|
|
38
|
+
under browser load, postpone them rather than starting another comparison.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Benchmarks and Comparison Gates
|
|
2
|
+
|
|
3
|
+
Resource safety:
|
|
4
|
+
|
|
5
|
+
- Run these commands one at a time. Do not parallelize `compare:static*`,
|
|
6
|
+
`compare:tokens*`, or browser-backed tests.
|
|
7
|
+
- `compare:static*` may launch `agent-browser` and Chromium. Check for existing
|
|
8
|
+
browser work before starting, and confirm processes are cleaned up afterward.
|
|
9
|
+
- Use `pnpm readiness:audit` before claiming the agent-readiness objective is
|
|
10
|
+
complete. It checks that the single-worker validation rules, fixture gate,
|
|
11
|
+
comparison gate, process checker, and README/docs split are still wired in.
|
|
12
|
+
- Use `pnpm readiness:real-page-smoke` for the smallest real-page check. It
|
|
13
|
+
fetches `https://example.com` with `--agent-brief` and does not launch
|
|
14
|
+
Puppeteer or `agent-browser`.
|
|
15
|
+
- Use `pnpm readiness:search-smoke` for the smallest real search check. It
|
|
16
|
+
runs `--search "ax-grep npm" --engine auto --agent-brief`, verifies engine
|
|
17
|
+
attempts, and does not launch Puppeteer or `agent-browser`.
|
|
18
|
+
- Use `pnpm readiness:agent-browser-smoke` for the smallest `agent-browser`
|
|
19
|
+
comparison set. It checks `https://example.com` and
|
|
20
|
+
`https://books.toscrape.com/`, `https://news.ycombinator.com`, and
|
|
21
|
+
`https://www.gov.uk/foreign-travel-advice`; run `pnpm check:processes`
|
|
22
|
+
before and after it.
|
|
23
|
+
- Use `pnpm readiness:agent-browser-text-heavy-smoke` only when checking the
|
|
24
|
+
text-heavy document policy. It checks Korean Wikipedia separately from the
|
|
25
|
+
main smoke because strict StaticText overlap is tracked apart from structural
|
|
26
|
+
content readiness.
|
|
27
|
+
- Use `pnpm check:processes` before and after browser-backed comparison runs.
|
|
28
|
+
- If several target sets are needed, run them sequentially and save each output
|
|
29
|
+
separately.
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pnpm benchmark:agent-cost
|
|
33
|
+
pnpm compare:sample
|
|
34
|
+
pnpm compare:static:fixtures
|
|
35
|
+
pnpm compare:static:fixtures:gate
|
|
36
|
+
pnpm readiness:audit
|
|
37
|
+
pnpm readiness:real-page-smoke
|
|
38
|
+
pnpm readiness:search-smoke
|
|
39
|
+
pnpm readiness:agent-browser-smoke
|
|
40
|
+
pnpm readiness:agent-browser-text-heavy-smoke
|
|
41
|
+
pnpm check:processes
|
|
42
|
+
pnpm compare:static https://example.com https://news.ycombinator.com
|
|
43
|
+
pnpm compare:tokens https://example.com https://news.ycombinator.com
|
|
44
|
+
pnpm compare:static:agent
|
|
45
|
+
pnpm compare:static:korea-social
|
|
46
|
+
pnpm compare:tokens:korea-social
|
|
47
|
+
pnpm compare:static:china-japan
|
|
48
|
+
pnpm compare:tokens:china-japan
|
|
49
|
+
pnpm compare:gate /tmp/ax-grep-agent.json /tmp/ax-grep-tokens.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The comparison scripts compare `ax-grep` output with `agent-browser snapshot`
|
|
53
|
+
output and score the CLI `--agent` summary. The score covers `agent`,
|
|
54
|
+
`pageCheck`, `searchResults`, structured evidence, readability, source link
|
|
55
|
+
quality, verification status, recommended actions, and next steps.
|
|
56
|
+
|
|
57
|
+
Token comparisons estimate prompt cost for compact tree text and agent JSON
|
|
58
|
+
payloads. See [comparison-baseline.md](./comparison-baseline.md) for the current
|
|
59
|
+
baseline run.
|
|
60
|
+
|
|
61
|
+
## Agent Cost Benchmark
|
|
62
|
+
|
|
63
|
+
`pnpm benchmark:agent-cost` compares `ax-grep --agent-brief` with
|
|
64
|
+
`agent-browser snapshot --compact` on local fixture pages. It runs cases
|
|
65
|
+
sequentially, writes `tmp/benchmarks/agent-cost.json`, and closes the browser
|
|
66
|
+
session after each case.
|
|
67
|
+
|
|
68
|
+
Latest local run:
|
|
69
|
+
|
|
70
|
+
| Case | ax-grep peak RSS | agent-browser peak RSS | RAM multiple | ax-grep decision tokens | agent-browser tokens | Token multiple |
|
|
71
|
+
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
|
|
72
|
+
| content-page | 80.0 MB | 906.4 MB | 11.3x | 631 | 1,903 | 3.0x |
|
|
73
|
+
| challenge-page | 72.1 MB | 1,404.7 MB | 19.5x | 910 | 241 | 0.3x |
|
|
74
|
+
|
|
75
|
+
Summary: average RAM reduction was 15.4x. The content fixture used 3.0x fewer
|
|
76
|
+
decision tokens when the agent reads the compact handoff instead of a browser
|
|
77
|
+
snapshot. The challenge fixture is primarily a memory/browser-avoidance win:
|
|
78
|
+
`ax-grep` detects hCaptcha markers and returns an explicit browser handoff
|
|
79
|
+
without launching Chromium.
|
|
80
|
+
|
|
81
|
+
Search, social, challenge, and volatile targets may be diagnostic-only and
|
|
82
|
+
excluded from gate averages. Check each run's `included` and `excluded` counts
|
|
83
|
+
before treating an average as release-gating coverage.
|
|
84
|
+
|
|
85
|
+
`compare:static:fixtures:gate` is the non-browser smoke gate: it uses synthetic
|
|
86
|
+
HTML fixtures only, so it should not fetch remote pages or launch
|
|
87
|
+
`agent-browser`. Use `compare:static:fixtures` when you need the JSON report.
|
|
88
|
+
|
|
89
|
+
`readiness:real-page-smoke` is the smallest remote-page gate. It checks that
|
|
90
|
+
`--agent-brief` can use fetched HTML on `https://example.com` without requesting
|
|
91
|
+
browser capture.
|
|
92
|
+
|
|
93
|
+
`readiness:agent-browser-smoke` is the smallest browser-backed comparison gate.
|
|
94
|
+
It runs `pnpm compare` for `https://example.com` and
|
|
95
|
+
`https://books.toscrape.com/`, `https://news.ycombinator.com`, and
|
|
96
|
+
`https://www.gov.uk/foreign-travel-advice`, requires `agent-browser`
|
|
97
|
+
snapshots, and enforces per-target overlap/readiness floors. Treat it like
|
|
98
|
+
other browser-backed work: one command at a time, with process checks before
|
|
99
|
+
and after.
|
|
100
|
+
|
|
101
|
+
`readiness:agent-browser-text-heavy-smoke` is a separate browser-backed
|
|
102
|
+
comparison for text-heavy document pages. It requires Korean Wikipedia to keep
|
|
103
|
+
usable action/navigation/structural-content recall while still reporting strict
|
|
104
|
+
text recall separately.
|
|
105
|
+
|
|
106
|
+
`compare:gate` checks saved JSON output from `compare:static*` and
|
|
107
|
+
`compare:tokens*`. Static gates require executor, handoff, browser-advantage,
|
|
108
|
+
search/page decision, and action-list scores to stay near 1.0 with no
|
|
109
|
+
gate-included challenge, shell, or over-collected classifications. Token gates
|
|
110
|
+
require the compact agent payload average to stay cheaper than the browser
|
|
111
|
+
reference after thin browser snapshots are excluded.
|
|
112
|
+
|
|
113
|
+
Current suites include:
|
|
114
|
+
|
|
115
|
+
- static HTML vs browser snapshots
|
|
116
|
+
- fixture-only agent readiness smoke checks
|
|
117
|
+
- agent executor regression targets for `averageAgentExecutorScore`
|
|
118
|
+
- fixture-backed search open, search refine, and browser HTML retry recovery
|
|
119
|
+
- CLI agent summary scoring for `pageCheck`, sources, readability, and actions
|
|
120
|
+
- token-cost comparison for compact tree prompts and agent JSON prompts
|
|
121
|
+
- Korean forum/search/social targets
|
|
122
|
+
- Chinese and Japanese wiki/news/forum/search targets
|
|
123
|
+
- challenge and volatile-page diagnostics
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# CLI and Agent Mode
|
|
2
|
+
|
|
3
|
+
`ax-grep` fetches a URL, extracts a semantic page summary, and prints compact
|
|
4
|
+
text by default.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
ax-grep https://example.com
|
|
8
|
+
ax-grep https://example.com --json
|
|
9
|
+
ax-grep https://example.com --json --summary
|
|
10
|
+
ax-grep https://example.com --links-only
|
|
11
|
+
ax-grep https://example.com --max-tree-lines 80
|
|
12
|
+
ax-grep https://example.com --mode interactive --exclude-boilerplate
|
|
13
|
+
ax-grep https://example.com --timeout 30000 --user-agent "my-agent/1.0"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
By default the CLI fetches static HTML with `impit`, which uses browser-like
|
|
17
|
+
HTTP/TLS fingerprints. If `impit` cannot load or the request fails before a
|
|
18
|
+
response is returned, ax-grep falls back to Node's built-in fetch. Pass
|
|
19
|
+
`--fetcher node` to force the built-in fetch path.
|
|
20
|
+
|
|
21
|
+
If fetched HTML shows hCaptcha, reCAPTCHA, or Cloudflare challenge markers, the
|
|
22
|
+
agent payload reports `needs-browser` with a provider-specific
|
|
23
|
+
`browserHtmlReasonCode` and a browser-capture follow-up command.
|
|
24
|
+
|
|
25
|
+
## Search
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
ax-grep --search "agent browser accessibility tree"
|
|
29
|
+
ax-grep --search "ax-grep npm" --engine bing --links-only
|
|
30
|
+
ax-grep --search "ax-grep npm" --engine bing --lang en --region US
|
|
31
|
+
ax-grep --search "ax-grep npm" --open-result best --json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- `--search` tries DuckDuckGo, Bing, and StartPage by default.
|
|
35
|
+
- `--engine <name>` forces one search engine.
|
|
36
|
+
- `--open-result <n|best>` fetches a ranked result in the same command.
|
|
37
|
+
- `--lang` and `--region` make locale-specific searches reproducible.
|
|
38
|
+
|
|
39
|
+
## Agent Routing
|
|
40
|
+
|
|
41
|
+
Use `--agent` when another program needs the next step instead of raw tree text.
|
|
42
|
+
The response includes compact `agent`, `pageCheck`, `verification`, search, and
|
|
43
|
+
warning fields.
|
|
44
|
+
|
|
45
|
+
Read these first:
|
|
46
|
+
|
|
47
|
+
- `agent.status`: `ready`, `choose-result`, `verify`, `needs-browser`, or `error`.
|
|
48
|
+
- `agent.staticReadiness*`: fetched-HTML usability status, machine-readable
|
|
49
|
+
reason code, prose reason, and the static path to read first.
|
|
50
|
+
- `agent.executor`: one-field executor step with decision, command/read/browser fields.
|
|
51
|
+
- `agent.executorActionName`, `agent.executorOperation`, and related `executor*`
|
|
52
|
+
shortcuts: top-level mirror of the next executable step, loop decision, and
|
|
53
|
+
target, terminal/continue flags.
|
|
54
|
+
- `agent.handoff`: the shortest executor handoff for the next step.
|
|
55
|
+
- `agent.handoffActionName`, `agent.handoffOperation`, and related `handoff*`
|
|
56
|
+
shortcuts: top-level mirror of the brief handoff contract, loop decision, and
|
|
57
|
+
target, terminal/continue flags.
|
|
58
|
+
- `agent.runbook*`: top-level loop reason, mode, confidence, answer status, and
|
|
59
|
+
iteration shortcuts for `--agent-brief` routing without expanding `runbook`.
|
|
60
|
+
- `agent.next`: canonical loop payload with command, read target, or browser step.
|
|
61
|
+
- `agent.next*`: canonical next-step action, execution, command, read, and URL shortcuts.
|
|
62
|
+
- `agent.page*`: title, canonical URL, language, author, dates, and structured-data type shortcuts.
|
|
63
|
+
- `agent.expectedOutcome*` and `agent.executionPlan*`: top-level success
|
|
64
|
+
condition and execution-plan shortcuts for fast routing without expanding
|
|
65
|
+
nested objects.
|
|
66
|
+
- `agent.sourceSearch*`: opened-result query, locale, verification queries, engine,
|
|
67
|
+
selected/alternate result, and command shortcuts.
|
|
68
|
+
- `agent.searchDecision*` and `agent.pageDecision*`: top-level routing decisions and command/read pointers.
|
|
69
|
+
- `agent.answerPlan`, `agent.citations`, and `agent.answerEvidence`: final answer evidence.
|
|
70
|
+
- `agent.answerPlanStatus`, `agent.answerPlanConfidence`, and related `answer*`
|
|
71
|
+
shortcuts: top-level answer readiness, next action, command, and citation routing.
|
|
72
|
+
- `agent.topCitation*`: first citation item for fast source quality checks.
|
|
73
|
+
- `agent.topAnswerEvidence*`: first answer evidence item for fast citation/read routing.
|
|
74
|
+
- `agent.topVerificationFoundQuery` and `agent.topVerificationMissingQuery`: first
|
|
75
|
+
matched or missing `--find` query for fast verification routing.
|
|
76
|
+
- `agent.readTargets`, `agent.topReadTarget*`, and `agent.bestReadTarget*`: ranked paths to inspect and the
|
|
77
|
+
best path's count/primary flags.
|
|
78
|
+
- `agent.bestHiddenReadTarget*`: best hidden metadata path to inspect first.
|
|
79
|
+
- `agent.topHiddenSignal*`: first hidden metadata/API/config/provenance signal.
|
|
80
|
+
- `agent.semantic*`: compact semantic tree counts and direct paths to top
|
|
81
|
+
heading/landmark/named role/interactive/focusable/link/button/image/table/list/form-field/description/value/relation/choice/state/unavailable entries.
|
|
82
|
+
`semanticOutline` and `semanticTopOutline*` preserve heading/landmark page flow
|
|
83
|
+
plus parent landmark context for fast structural routing. `semanticKeyboardShortcut*` exposes keyboard shortcut,
|
|
84
|
+
access key, and tabindex hints. Field shortcuts include placeholder/autocomplete/inputmode
|
|
85
|
+
and aria label/description references. `semanticTopInPageLink*` exposes skip
|
|
86
|
+
links and same-page anchors. Relation shortcuts include resolved target role/selector when available.
|
|
87
|
+
State shortcuts also expose parsed top-state fields such as `semanticTopStateCurrent`,
|
|
88
|
+
`semanticTopStateControls`, `semanticTopStateHaspopup`, and `semanticTopStateInvalid`.
|
|
89
|
+
- `agent.barrierCount` and `agent.topBarrier*`: primary login, paywall,
|
|
90
|
+
challenge, consent, age, or geo barrier details for browser routing.
|
|
91
|
+
- `agent.dataTableCount`, `agent.faqCount`, `agent.codeBlockCount`,
|
|
92
|
+
`agent.resourceCount`, `agent.mediaCount`, `agent.sectionCount`,
|
|
93
|
+
`agent.breadcrumbCount`, `agent.paginationCount`, `agent.tocCount`,
|
|
94
|
+
`agent.embedCount`, `agent.transcriptCount`, `agent.authorLinkCount`,
|
|
95
|
+
`agent.provenanceCount`, `agent.offerCount`, `agent.datasetCount`,
|
|
96
|
+
`agent.identityCount`, `agent.timelineCount`, `agent.contactPointCount`, and
|
|
97
|
+
matching `top*` fields: first structured page item shortcuts with direct paths/selectors when available.
|
|
98
|
+
- `agent.bestStructuredReadTarget*`: highest-priority structured content path to
|
|
99
|
+
read before scanning all `readTargets`.
|
|
100
|
+
- `agent.resultChoices` and `agent.sourceChoices`: ranked links to open.
|
|
101
|
+
- `agent.topResultChoice*`: first search-result candidate with URL, rank,
|
|
102
|
+
command args, source quality, freshness/relevance, match, and sitelink hints.
|
|
103
|
+
- `agent.topSourceChoice*`: first source-link candidate with URL, command args, source type, source hints, and source score.
|
|
104
|
+
- `agent.topFormChoice*` and `agent.topActionTargetChoice*`: first executable
|
|
105
|
+
form/action target templates, query inputs, submit text, and first-field hints.
|
|
106
|
+
- `agent.topChoice*`: first executable result, source, form, or action-target choice.
|
|
107
|
+
- `agent.topAction*`: first action candidate with execution, priority, command/read, and URL shortcuts.
|
|
108
|
+
- `agent.primarySourceLinkRef`: primary source-link action's `pageCheck.sourceLinks[n]`.
|
|
109
|
+
- `agent.alternativeAction*`: first non-primary action candidate, including source,
|
|
110
|
+
execution mode, command args, URL, and source-link reference when available.
|
|
111
|
+
- `agent.recommended*`: selected search result metadata and command args.
|
|
112
|
+
- `agent.signals` and `agent.qualityGates`: compact diagnostics.
|
|
113
|
+
- `agent.topSignal*` and `agent.topQualityGate*`: first quality signal and gate
|
|
114
|
+
shortcuts for fast accept/block routing.
|
|
115
|
+
- `agent.problemSignal*` and `agent.failingQualityGate*`: first blocking or
|
|
116
|
+
warning reason, severity, and score without scanning diagnostic arrays.
|
|
117
|
+
- `agent.topDiagnostic*`: first diagnostic code, severity, and message.
|
|
118
|
+
|
|
119
|
+
In `--agent-brief`, the stable executor surface is `agent.executor` plus
|
|
120
|
+
`agent.handoff`. Brief handoff keeps loop metadata, target URL, priority,
|
|
121
|
+
reason, and executable `resultChoices` or `sourceChoices` when alternates are
|
|
122
|
+
available. It also keeps the details needed to act without reopening the full
|
|
123
|
+
payload: search snippets, selected answer evidence text, form/action URL
|
|
124
|
+
templates, field selectors, methods, browser barrier targets, and source-link
|
|
125
|
+
`sourceLinkRef` pointers.
|
|
126
|
+
|
|
127
|
+
Agent actions use an `execution` discriminator:
|
|
128
|
+
|
|
129
|
+
- `run-command`: execute `commandArgs` with `execFile`-style argument passing.
|
|
130
|
+
- `read-current`: read the current payload path named by `readFrom`.
|
|
131
|
+
- `interact-browser`: use a live browser, then optionally rerun with captured HTML.
|
|
132
|
+
|
|
133
|
+
Generated commands preserve fetch and search context such as `--lang`,
|
|
134
|
+
`--region`, `--find`, `--timeout`, `--user-agent`, `--fetcher`, and `--agent`.
|
|
135
|
+
Text output also prints `executor*` lines for the same next-step fields.
|
|
136
|
+
|
|
137
|
+
## Find and Verification
|
|
138
|
+
|
|
139
|
+
Use repeatable `--find <text>` with any page or search result page to verify a
|
|
140
|
+
term or phrase.
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
ax-grep https://example.com --agent --find "documentation examples"
|
|
144
|
+
ax-grep --search "OpenAI API docs" --find "Responses API" --agent
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
JSON output adds `finds` and `verification`. `verification.status` is the
|
|
148
|
+
quickest page-check answer:
|
|
149
|
+
|
|
150
|
+
- `matched`: every requested phrase was found.
|
|
151
|
+
- `partial`: some phrases were found.
|
|
152
|
+
- `missing`: none were found.
|
|
153
|
+
- `not-requested`: no `--find` query was supplied.
|
|
154
|
+
|
|
155
|
+
When evidence is missing, `verification.recommendedAction` points to the next
|
|
156
|
+
useful move, such as opening a source link, opening an alternate original SERP
|
|
157
|
+
result, retrying with browser-captured HTML, or broadening the search.
|
|
158
|
+
|
|
159
|
+
## Browser-Captured HTML
|
|
160
|
+
|
|
161
|
+
The default URL path uses `impit` with Node fetch fallback. It does not execute
|
|
162
|
+
page JavaScript.
|
|
163
|
+
When a page is challenged, logged-in, or JavaScript-rendered, let a browser
|
|
164
|
+
controller capture the HTML and pass it back through the same CLI.
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
ax-grep https://example.com --html-file captured.html --agent
|
|
168
|
+
cat captured.html | ax-grep https://example.com --stdin --agent
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
If fetched HTML has no inspectable content, JSON mode returns a structured error
|
|
172
|
+
and warning. Use `--html-file` or `--stdin` for rendered fallback HTML.
|
|
173
|
+
|
|
174
|
+
## Page Summary Fields
|
|
175
|
+
|
|
176
|
+
`kind` classifies the page as `search-results`, `content-page`,
|
|
177
|
+
`interactive-page`, `blocked-page`, `empty`, or `page`.
|
|
178
|
+
|
|
179
|
+
`pageCheck` is the higher-level inspection summary agents should read before the
|
|
180
|
+
raw tree. It includes title, canonical URL, main heading, content evidence,
|
|
181
|
+
source-like external links, actions, confidence, readability, and follow-up
|
|
182
|
+
actions.
|
|
183
|
+
|
|
184
|
+
Useful `pageCheck` groups include:
|
|
185
|
+
|
|
186
|
+
- Content and verification: `contentEvidence`, `dataTables`, `sections`, `toc`, `codeBlocks`, `citations`, `faqs`, and `breadcrumbs`.
|
|
187
|
+
- Interaction and recovery: `barriers`, `forms`, `actionTargets`, `pagination`, `recommendedAction`, and `nextSteps`.
|
|
188
|
+
- Hidden app/page state: `hydration`, `apiEndpoints`, `clientState`, `runtime`, `config`, `appHints`, and `mobileHints`.
|
|
189
|
+
- Metadata and provenance: `topics`, `keyValues`, `metaFacts`, `provenance`, `httpPolicies`, `schemaFacts`, `offers`, `identities`, `datasets`, `timeline`, `contactPoints`, and `authorLinks`.
|
|
190
|
+
- Media and resources: `media`, `resources`, `embeds`, and `transcripts`.
|
|
191
|
+
|
|
192
|
+
These fields expose details often absent from an accessibility tree, including
|
|
193
|
+
JSON-LD facts, head metadata, API endpoints, app configuration, policy
|
|
194
|
+
directives, feed/license/resource links, and mobile app-link hints.
|