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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hmmhmmhm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,109 @@
1
+ <div align="center">
2
+
1
3
  # ax-grep
2
4
 
3
- Reserved package name for an accessibility tree extraction utility.
5
+ [![npm version](https://img.shields.io/npm/v/ax-grep.svg)](https://www.npmjs.com/package/ax-grep)
6
+ [![coverage: 100%](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](./tests)
7
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
8
+ [![agent ready](https://img.shields.io/badge/agent-ready-0b7f3a.svg)](./docs/agent-handoff.md)
9
+ [![Codex skill](https://img.shields.io/badge/Codex-skill-111111.svg)](./skills/ax-grep-cli/SKILL.md)
10
+ [![Claude compatible](https://img.shields.io/badge/Claude-compatible-5b4b8a.svg)](./docs/cli-agent.md)
11
+ [![Gemini ready](https://img.shields.io/badge/Gemini-ready-1a73e8.svg)](./docs/cli-agent.md)
12
+
13
+ <img src="./docs/assets/ax-grep-og.png" alt="ax-grep promo image" width="920">
14
+
15
+ <img src="./docs/assets/ax-grep-benchmark.png" alt="ax-grep benchmark comparison image" width="920">
16
+
17
+ <img src="./docs/assets/ax-grep-search.png" alt="ax-grep auto search comparison image" width="920">
18
+
19
+ Compact semantic trees and agent-ready page checks from HTML, URLs, WebViews, and live browser pages.
20
+ It approximates the accessibility tree browsers expose, but can do it from
21
+ static HTML before launching browser automation.
22
+
23
+ The CLI defaults to `impit` for browser-like HTTP/2/TLS static fetches, detects
24
+ hCaptcha, reCAPTCHA, and Cloudflare challenge markers, then tells agents when a
25
+ browser is actually needed. In the local benchmark, the decision handoff used
26
+ 15.4x less peak RAM on average and 3.0x fewer decision tokens on the content
27
+ fixture than `agent-browser snapshot`.
28
+
29
+ `--search` auto mode tries DuckDuckGo, Bing, and StartPage, records every
30
+ engine attempt, and hands ranked source choices back to the agent.
31
+
32
+ </div>
33
+
34
+ ## 1. Try With A Prompt
35
+
36
+ Paste this into a Codex session or subagent prompt before opening a browser:
37
+
38
+ ```md
39
+ Before opening a browser, inspect pages with ax-grep when possible.
40
+
41
+ Run:
42
+ npx --yes ax-grep@latest <url> --agent-brief
43
+
44
+ Read agent.executor, agent.handoff, agent.readTargets, pageCheck, and
45
+ verification first. Open a browser only when the payload says static HTML is
46
+ not enough.
47
+ ```
48
+
49
+ ## 2. Install The CLI Skill
50
+
51
+ ```sh
52
+ curl -fsSL https://raw.githubusercontent.com/hmmhmmhm/ax-grep/main/skills.sh | sh
53
+ ```
54
+
55
+ This installs the Codex skill prompt only. Restart Codex if the new skill is not listed immediately.
56
+
57
+ ## 3. Try The CLI
58
+
59
+ ```sh
60
+ npx --yes ax-grep@latest https://example.com --agent-brief
61
+ ```
62
+
63
+ If you installed the binary globally, use `ax-grep` directly.
64
+ Agents should read `agent.executor`, `agent.handoff`, `agent.readTargets`,
65
+ `pageCheck`, and `verification` first. Open a browser only when the handoff
66
+ fields say static HTML is not enough.
67
+
68
+ ## 4. Use From A Server
69
+
70
+ Use this inside agent services built with Codex SDK, OpenRouter, or similar
71
+ LLM routing stacks to turn fetched HTML into compact source evidence before
72
+ spending tokens or memory on browser automation.
73
+
74
+ ```sh
75
+ npm install ax-grep
76
+ ```
77
+
78
+ ```ts
79
+ import { extract, formatSemanticTreeText } from "ax-grep";
80
+
81
+ const html = await fetch("https://example.com").then((r) => r.text());
82
+ const tree = extract(html);
83
+ const promptText = formatSemanticTreeText(tree);
84
+ ```
85
+
86
+ `ax-grep` is ESM-only and requires Node 18 or newer. CommonJS services can use `const { extract } = await import("ax-grep")`.
87
+
88
+ ## 5. Use In WebViews Or Pages
89
+
90
+ In mobile apps, WebViews, and in-page agents, inject the extractor to create an
91
+ accessibility-style structure immediately from the current page. It is useful
92
+ for local sLLM web search, local web parsing, and instant agent-ready page
93
+ summaries without leaving the app.
94
+
95
+ ```ts
96
+ import { createExtractorScript } from "ax-grep";
97
+
98
+ const script = createExtractorScript({ format: "text" });
99
+ const text = await page.evaluate(script);
100
+ // iOS/Android WebView: evaluateJavaScript(script) returns the same text value.
101
+ ```
4
102
 
103
+ ## Docs
104
+ - [Documentation index](./docs/README.md)
105
+ - [CLI skill prompt](./skills/ax-grep-cli/SKILL.md)
106
+ - [CLI and agent mode](./docs/cli-agent.md)
107
+ - [Agent handoff loop](./docs/agent-handoff.md)
108
+ - [Benchmarks](./docs/benchmarks.md)
109
+ - [Library API](./docs/library-api.md)
@@ -0,0 +1,11 @@
1
+ import { a as SemanticTreeOptions, S as SemanticNode, aE as SemanticTreeChange, aF as SemanticTreeObserverOptions } from './types-gwHWhYmw.js';
2
+
3
+ declare function extractSemanticTree(options?: SemanticTreeOptions): SemanticNode;
4
+
5
+ declare function formatSemanticTreeText(node: SemanticNode): string;
6
+ declare function observeSemanticTree(onChange: (change: SemanticTreeChange) => void, options?: SemanticTreeObserverOptions): {
7
+ disconnect: () => void;
8
+ snapshot: () => SemanticNode;
9
+ };
10
+
11
+ export { extractSemanticTree as extract, extractSemanticTree, formatSemanticTreeText, observeSemanticTree };
@@ -0,0 +1,12 @@
1
+ import {
2
+ extractSemanticTree,
3
+ formatSemanticTreeText,
4
+ observeSemanticTree
5
+ } from "./chunk-HPZ32BKV.js";
6
+ export {
7
+ extractSemanticTree as extract,
8
+ extractSemanticTree,
9
+ formatSemanticTreeText,
10
+ observeSemanticTree
11
+ };
12
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}