@apmantza/greedysearch-pi 1.4.2 → 1.5.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/CHANGELOG.md +34 -0
- package/README.md +236 -219
- package/cdp.mjs +1002 -797
- package/coding-task.mjs +392 -369
- package/extractors/bing-copilot.mjs +167 -195
- package/extractors/common.mjs +237 -0
- package/extractors/consent.mjs +273 -255
- package/extractors/gemini.mjs +142 -180
- package/extractors/google-ai.mjs +156 -162
- package/extractors/perplexity.mjs +126 -181
- package/extractors/selectors.mjs +43 -43
- package/index.ts +230 -93
- package/launch.mjs +283 -161
- package/package.json +26 -26
- package/search.mjs +1219 -997
- package/skills/greedy-search/SKILL.md +38 -109
- package/newfeaturesideas.md +0 -105
- package/test.sh +0 -298
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v1.5.1 (2026-03-29)
|
|
4
|
+
|
|
5
|
+
- **Fixed npm package** — added `.pi-lens/` and test files to `.npmignore` to reduce package size
|
|
6
|
+
|
|
7
|
+
## v1.5.0 (2026-03-29)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
- **Code extraction fixed** — `coding_task` now uses clipboard interception to preserve markdown code blocks (was losing them via DOM scraping)
|
|
11
|
+
- **Chrome targeting hardened** — all tools now consistently target the dedicated GreedySearch Chrome via `CDP_PROFILE_DIR`, preventing fallback to user's main Chrome session
|
|
12
|
+
- **Shared utilities** — extracted ~220 lines of duplicate code from extractors into `common.mjs` (cdp wrapper, tab management, clipboard interception)
|
|
13
|
+
- **Documentation leaner** — skill documentation reduced 61% (180 → 70 lines) while preserving all decision-making info
|
|
14
|
+
|
|
15
|
+
### Notable
|
|
16
|
+
- **NO API KEYS** — updated messaging to emphasize this works via browser automation, no API keys needed
|
|
17
|
+
|
|
18
|
+
## v1.4.2 (2026-03-25)
|
|
19
|
+
|
|
20
|
+
- **Fresh isolated tabs** — each search now always creates a new `about:blank` tab via `Target.createTarget` and refreshes the CDP page cache immediately after, preventing SPA navigation failures and stale DOM state from prior queries
|
|
21
|
+
- **Regex-based citation extraction** — all extractors (Perplexity, Bing, Gemini) now parse sources from clipboard Markdown links (`[title](url)`) instead of DOM selectors that break on UI updates
|
|
22
|
+
- **Relaxed verification detection** — `consent.mjs` now uses broad keyword matching (`includes('verify')`, `includes('human')`) instead of anchored regexes, correctly catching button text variants like "Verify you are human" across Cloudflare, Microsoft, and generic modals
|
|
23
|
+
|
|
24
|
+
## v1.4.1
|
|
25
|
+
|
|
26
|
+
- **Fixed parallel synthesis** — multiple `greedy_search` calls with `synthesize: true` now run safely in parallel. Each search creates a fresh Gemini tab that gets cleaned up after synthesis, preventing tab conflicts and "Uncaught" errors.
|
|
27
|
+
|
|
28
|
+
## v1.4.0
|
|
29
|
+
|
|
30
|
+
- **Grounded synthesis** — Gemini now receives a normalized source registry with stable source IDs, agreement summaries, caveats, and cited claims
|
|
31
|
+
- **Real deep research** — top sources are fetched before synthesis so deep research answers are grounded in fetched evidence, not just engine summaries
|
|
32
|
+
- **Richer source metadata** — source output now includes canonical URLs, domains, source types, per-engine attribution, and confidence metadata
|
|
33
|
+
- **Cleaner tab lifecycle** — temporary Perplexity, Bing, and Google tabs are closed after each fan-out search, and synthesis finishes on the Gemini tab
|
|
34
|
+
- **Isolated Chrome targeting** — GreedySearch now refuses to fall back to your normal Chrome session, preventing stray remote-debugging prompts
|
package/README.md
CHANGED
|
@@ -1,219 +1,236 @@
|
|
|
1
|
-
# GreedySearch for Pi
|
|
2
|
-
|
|
3
|
-
Pi extension that adds
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pi install
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
|
39
|
-
|
|
40
|
-
| `
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
**
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
greedy_search({ query: "
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
**
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
greedy_search({ query: "
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
**
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
greedy_search({ query: "
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
node ~/.pi/agent/git/GreedySearch-pi/launch.mjs
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
node ~/.pi/agent/git/GreedySearch-pi/launch.mjs --
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
- `
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
- **
|
|
212
|
-
- **
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
1
|
+
# GreedySearch for Pi
|
|
2
|
+
|
|
3
|
+
Pi extension that adds `greedy_search`, `deep_research`, and `coding_task` tools — multi-engine AI search via browser automation. **NO API KEYS needed.**
|
|
4
|
+
|
|
5
|
+
Fans out queries to Perplexity, Bing Copilot, and Google AI simultaneously. Returns AI-synthesized answers with deduped sources. Streams progress as each engine completes.
|
|
6
|
+
|
|
7
|
+
Forked from [GreedySearch-claude](https://github.com/apmantza/GreedySearch-claude).
|
|
8
|
+
|
|
9
|
+
## Quick Note
|
|
10
|
+
|
|
11
|
+
**No API keys required** — this tool uses Chrome DevTools Protocol (CDP) to interact with search engines directly through a browser. It launches its own isolated Chrome instance, so it won't interfere with your main browser session.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pi install npm:@apmantza/greedysearch-pi
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or directly from git:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pi install git:github.com/apmantza/GreedySearch-pi
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
Once installed, Pi gains a `greedy_search` tool. The model will use it automatically for questions about current libraries, error messages, version-specific docs, etc.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
greedy_search({ query: "What's new in React 19?", engine: "all" })
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Parameters
|
|
34
|
+
|
|
35
|
+
| Parameter | Type | Default | Description |
|
|
36
|
+
|-----------|------|---------|-------------|
|
|
37
|
+
| `query` | string | required | The search question |
|
|
38
|
+
| `engine` | string | `"all"` | Engine to use (see below) |
|
|
39
|
+
| `synthesize` | boolean | `false` | Synthesize results into one answer via Gemini |
|
|
40
|
+
| `fullAnswer` | boolean | `false` | Return complete answer (~3000+ chars) vs truncated preview (~300 chars) |
|
|
41
|
+
|
|
42
|
+
## Engines
|
|
43
|
+
|
|
44
|
+
| Engine | Alias | Latency | Best for |
|
|
45
|
+
|--------|-------|---------|----------|
|
|
46
|
+
| `all` | — | 30-90s | Highest confidence — all 3 engines in parallel (default) |
|
|
47
|
+
| `perplexity` | `p` | 15-30s | Technical Q&A, code explanations, documentation |
|
|
48
|
+
| `bing` | `b` | 15-30s | Recent news, Microsoft ecosystem |
|
|
49
|
+
| `google` | `g` | 15-30s | Broad coverage, multiple perspectives |
|
|
50
|
+
| `gemini` | `gem` | 15-30s | Google's AI with different training data |
|
|
51
|
+
|
|
52
|
+
## Streaming Progress
|
|
53
|
+
|
|
54
|
+
When using `engine: "all"`, the tool streams progress as each engine completes:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
**Searching...** ⏳ perplexity · ⏳ bing · ⏳ google
|
|
58
|
+
**Searching...** ✅ perplexity done · ⏳ bing · ⏳ google
|
|
59
|
+
**Searching...** ✅ perplexity done · ✅ bing done · ⏳ google
|
|
60
|
+
**Searching...** ✅ perplexity done · ✅ bing done · ✅ google done
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Synthesis Mode
|
|
64
|
+
|
|
65
|
+
For complex research questions, use `synthesize: true` with `engine: "all"`:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
greedy_search({ query: "best auth patterns for SaaS in 2026", engine: "all", synthesize: true })
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This deduplicates sources across engines, builds a normalized source registry, and feeds that context to Gemini for one clean synthesized answer. Adds ~30s but returns agreement summaries, caveats, key claims, and better-labeled top sources.
|
|
72
|
+
|
|
73
|
+
**Use synthesis when:**
|
|
74
|
+
- You need one definitive answer, not multiple perspectives
|
|
75
|
+
- You're researching a topic to write about or make a decision
|
|
76
|
+
- Token efficiency matters (one answer vs three)
|
|
77
|
+
|
|
78
|
+
**Skip synthesis when:**
|
|
79
|
+
- You want to see where engines disagree
|
|
80
|
+
- Speed matters
|
|
81
|
+
|
|
82
|
+
## Full vs Short Answers
|
|
83
|
+
|
|
84
|
+
Default mode returns ~300 char summaries to save tokens. Use `fullAnswer: true` for complete responses:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
greedy_search({ query: "explain the React compiler", engine: "perplexity", fullAnswer: true })
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Examples
|
|
91
|
+
|
|
92
|
+
**Quick technical lookup:**
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
greedy_search({ query: "How to use async await in Python", engine: "perplexity" })
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Compare tools (see where engines agree/disagree):**
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
greedy_search({ query: "Prisma vs Drizzle in 2026", engine: "all" })
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Research with synthesis:**
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
greedy_search({ query: "Best practices for monorepo structure", engine: "all", synthesize: true })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Debug an error:**
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
greedy_search({ query: "Error: Cannot find module 'react-dom/client' Next.js 15", engine: "all" })
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Requirements
|
|
117
|
+
|
|
118
|
+
- **Chrome** — must be installed. The extension auto-launches a dedicated Chrome instance on port 9222 with its own isolated profile and DevTools port file, separate from your main browser session.
|
|
119
|
+
- **Node.js 22+** — for built-in `fetch` and WebSocket support.
|
|
120
|
+
|
|
121
|
+
## Setup (first time)
|
|
122
|
+
|
|
123
|
+
To pre-launch the dedicated GreedySearch Chrome instance:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
node ~/.pi/agent/git/GreedySearch-pi/launch.mjs
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Stop it when done:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
node ~/.pi/agent/git/GreedySearch-pi/launch.mjs --kill
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Check status:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
node ~/.pi/agent/git/GreedySearch-pi/launch.mjs --status
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Testing
|
|
142
|
+
|
|
143
|
+
Run the test suite to verify everything works:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
./test.sh # full suite (~3-4 min)
|
|
147
|
+
./test.sh quick # skip parallel tests (~1 min)
|
|
148
|
+
./test.sh parallel # parallel race condition tests only
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Tests verify:
|
|
152
|
+
- Single engine mode (perplexity, bing, google)
|
|
153
|
+
- Sequential "all" mode searches
|
|
154
|
+
- Parallel "all" mode (5 concurrent searches) — detects tab race conditions
|
|
155
|
+
- Synthesis mode with Gemini
|
|
156
|
+
|
|
157
|
+
## Troubleshooting
|
|
158
|
+
|
|
159
|
+
### "Chrome not found"
|
|
160
|
+
|
|
161
|
+
Set the path explicitly:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
export CHROME_PATH="/path/to/chrome"
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### "CDP timeout" or "Chrome may have crashed"
|
|
168
|
+
|
|
169
|
+
Restart GreedySearch Chrome:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
node ~/.pi/agent/git/GreedySearch-pi/launch.mjs --kill
|
|
173
|
+
node ~/.pi/agent/git/GreedySearch-pi/launch.mjs
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Google / Bing "verify you're human"
|
|
177
|
+
|
|
178
|
+
The extension auto-clicks verification buttons and Cloudflare Turnstile challenges using broad keyword matching — resilient to variations like "Verify you are human" or localised button text. For hard CAPTCHAs (image puzzles), solve manually in the Chrome window that opens.
|
|
179
|
+
|
|
180
|
+
### Parallel searches failing
|
|
181
|
+
|
|
182
|
+
Each search creates a fresh isolated browser tab that is closed after completion, allowing safe parallel execution without tab state conflicts.
|
|
183
|
+
|
|
184
|
+
### Search hangs
|
|
185
|
+
|
|
186
|
+
Chrome may be unresponsive. Restart it with `launch.mjs --kill` then `launch.mjs`.
|
|
187
|
+
|
|
188
|
+
### Sources are empty or junk links
|
|
189
|
+
|
|
190
|
+
Sources are now extracted by regex-parsing Markdown links (`[title](url)`) from the clipboard text captured after each engine responds — not from DOM selectors that break when the engine's UI updates. If sources are empty, the engine's clipboard copy didn't include formatted links (Bing Copilot currently falls into this category).
|
|
191
|
+
|
|
192
|
+
## How It Works
|
|
193
|
+
|
|
194
|
+
- `index.ts` — Pi extension, registers `greedy_search` tool with streaming progress
|
|
195
|
+
- `search.mjs` — CLI runner, spawns extractors in parallel, emits `PROGRESS:` events to stderr
|
|
196
|
+
- `launch.mjs` — launches dedicated Chrome on port 9222 with isolated profile
|
|
197
|
+
- `extractors/` — per-engine CDP scrapers (Perplexity, Bing Copilot, Google AI, Gemini)
|
|
198
|
+
- `cdp.mjs` — Chrome DevTools Protocol CLI for browser automation
|
|
199
|
+
- `skills/greedy-search/SKILL.md` — skill file that guides the model on when/how to use greedy_search
|
|
200
|
+
|
|
201
|
+
## Changelog
|
|
202
|
+
|
|
203
|
+
### v1.5.1 (2026-03-29)
|
|
204
|
+
- Fixed npm package — added `.pi-lens/` and test files to `.npmignore`
|
|
205
|
+
|
|
206
|
+
### v1.5.0 (2026-03-29)
|
|
207
|
+
|
|
208
|
+
- **Code extraction fixed** — `coding_task` now uses clipboard interception to preserve markdown code blocks (was losing them via DOM scraping)
|
|
209
|
+
- **Chrome targeting hardened** — all tools now consistently target the dedicated GreedySearch Chrome via `CDP_PROFILE_DIR`, preventing fallback to user's main Chrome session
|
|
210
|
+
- **Shared utilities** — extracted ~220 lines of duplicate code from extractors into `common.mjs` (cdp wrapper, tab management, clipboard interception)
|
|
211
|
+
- **Documentation leaner** — skill documentation reduced 61% (180 → 70 lines) while preserving all decision-making info
|
|
212
|
+
- **NO API KEYS** — updated messaging to emphasize this works via browser automation, no API keys needed
|
|
213
|
+
|
|
214
|
+
### v1.4.2 (2026-03-25)
|
|
215
|
+
|
|
216
|
+
- **Fresh isolated tabs** — each search now always creates a new `about:blank` tab via `Target.createTarget` and refreshes the CDP page cache immediately after, preventing SPA navigation failures and stale DOM state from prior queries
|
|
217
|
+
- **Regex-based citation extraction** — all extractors (Perplexity, Bing, Gemini) now parse sources from clipboard Markdown links (`[title](url)`) instead of DOM selectors that break on UI updates
|
|
218
|
+
- **Relaxed verification detection** — `consent.mjs` now uses broad keyword matching (`includes('verify')`, `includes('human')`) instead of anchored regexes, correctly catching button text variants like "Verify you are human" across Cloudflare, Microsoft, and generic modals
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### v1.4.1
|
|
223
|
+
|
|
224
|
+
- **Fixed parallel synthesis** — multiple `greedy_search` calls with `synthesize: true` now run safely in parallel. Each search creates a fresh Gemini tab that gets cleaned up after synthesis, preventing tab conflicts and "Uncaught" errors.
|
|
225
|
+
|
|
226
|
+
### v1.4.0
|
|
227
|
+
|
|
228
|
+
- **Grounded synthesis** — Gemini now receives a normalized source registry with stable source IDs, agreement summaries, caveats, and cited claims
|
|
229
|
+
- **Real deep research** — top sources are fetched before synthesis so deep research answers are grounded in fetched evidence, not just engine summaries
|
|
230
|
+
- **Richer source metadata** — source output now includes canonical URLs, domains, source types, per-engine attribution, and confidence metadata
|
|
231
|
+
- **Cleaner tab lifecycle** — temporary Perplexity, Bing, and Google tabs are closed after each fan-out search, and synthesis finishes on the Gemini tab
|
|
232
|
+
- **Isolated Chrome targeting** — GreedySearch now refuses to fall back to your normal Chrome session, preventing stray remote-debugging prompts
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
MIT
|