@apmantza/greedysearch-pi 1.7.0 → 1.7.2

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,52 +1,52 @@
1
- // extractors/selectors.mjs
2
- // Centralized CSS selectors for all engines.
3
- // Update selectors here when a site changes its UI.
4
-
5
- export const SELECTORS = {
6
- // ──────────────────────────────────────────────
7
- // Perplexity (perplexity.ai)
8
- // ──────────────────────────────────────────────
9
- perplexity: {
10
- input: "#ask-input",
11
- copyButton: 'button[aria-label="Copy"]',
12
- sourceItem: "[data-pplx-citation-url]",
13
- sourceLink: "a",
14
- consent: "#onetrust-accept-btn-handler",
15
- },
16
-
17
- // ──────────────────────────────────────────────
18
- // Bing Copilot (copilot.microsoft.com)
19
- // ──────────────────────────────────────────────
20
- bing: {
21
- input: "#userInput",
22
- copyButton: 'button[data-testid="copy-ai-message-button"]',
23
- sourceLink: 'a[href^="http"][target="_blank"]',
24
- sourceExclude: "copilot.microsoft.com",
25
- consent: "#onetrust-accept-btn-handler",
26
- },
27
-
28
- // ──────────────────────────────────────────────
29
- // Google AI Mode (google.com/search?udm=50)
30
- // ──────────────────────────────────────────────
31
- google: {
32
- answerContainer: ".pWvJNd",
33
- sourceLink: 'a[href^="http"]',
34
- sourceExclude: ["google.", "gstatic", "googleapis"],
35
- sourceHeadingParent: "[data-snhf]",
36
- consent: '#L2AGLb, button[jsname="b3VHJd"], .tHlp8d',
37
- },
38
-
39
- // ──────────────────────────────────────────────
40
- // Gemini (gemini.google.com/app)
41
- // ──────────────────────────────────────────────
42
- gemini: {
43
- input: "rich-textarea .ql-editor",
44
- copyButton: 'button[aria-label="Copy"]',
45
- sendButton: 'button[aria-label*="Send"]',
46
- sourcesSidebarButton: "button.legacy-sources-sidebar-button",
47
- sourcesExclude: ["gemini.google", "gstatic", "google.com/search"],
48
- citationButtonPattern: 'button[aria-label*="citation from"]',
49
- // For parsing citation aria-labels: "View source details for citation from {name}. Opens side panel."
50
- citationNameRegex: /from\s+(.+?)\.\s/,
51
- },
52
- };
1
+ // extractors/selectors.mjs
2
+ // Centralized CSS selectors for all engines.
3
+ // Update selectors here when a site changes its UI.
4
+
5
+ export const SELECTORS = {
6
+ // ──────────────────────────────────────────────
7
+ // Perplexity (perplexity.ai)
8
+ // ──────────────────────────────────────────────
9
+ perplexity: {
10
+ input: "#ask-input",
11
+ copyButton: 'button[aria-label="Copy"]',
12
+ sourceItem: "[data-pplx-citation-url]",
13
+ sourceLink: "a",
14
+ consent: "#onetrust-accept-btn-handler",
15
+ },
16
+
17
+ // ──────────────────────────────────────────────
18
+ // Bing Copilot (copilot.microsoft.com)
19
+ // ──────────────────────────────────────────────
20
+ bing: {
21
+ input: "#userInput",
22
+ copyButton: 'button[data-testid="copy-ai-message-button"]',
23
+ sourceLink: 'a[href^="http"][target="_blank"]',
24
+ sourceExclude: "copilot.microsoft.com",
25
+ consent: "#onetrust-accept-btn-handler",
26
+ },
27
+
28
+ // ──────────────────────────────────────────────
29
+ // Google AI Mode (google.com/search?udm=50)
30
+ // ──────────────────────────────────────────────
31
+ google: {
32
+ answerContainer: ".pWvJNd",
33
+ sourceLink: 'a[href^="http"]',
34
+ sourceExclude: ["google.", "gstatic", "googleapis"],
35
+ sourceHeadingParent: "[data-snhf]",
36
+ consent: '#L2AGLb, button[jsname="b3VHJd"], .tHlp8d',
37
+ },
38
+
39
+ // ──────────────────────────────────────────────
40
+ // Gemini (gemini.google.com/app)
41
+ // ──────────────────────────────────────────────
42
+ gemini: {
43
+ input: "rich-textarea .ql-editor",
44
+ copyButton: 'button[aria-label="Copy"]',
45
+ sendButton: 'button[aria-label*="Send"]',
46
+ sourcesSidebarButton: "button.legacy-sources-sidebar-button",
47
+ sourcesExclude: ["gemini.google", "gstatic", "google.com/search"],
48
+ citationButtonPattern: 'button[aria-label*="citation from"]',
49
+ // For parsing citation aria-labels: "View source details for citation from {name}. Opens side panel."
50
+ citationNameRegex: /from\s+(.+?)\.\s/,
51
+ },
52
+ };
package/index.ts CHANGED
@@ -23,9 +23,9 @@ const __dir = dirname(fileURLToPath(import.meta.url));
23
23
 
24
24
  const ALL_ENGINES = ["perplexity", "bing", "google"] as const;
25
25
 
26
- function cdpAvailable(): boolean {
27
- return existsSync(join(__dir, "cdp.mjs"));
28
- }
26
+ function cdpAvailable(): boolean {
27
+ return existsSync(join(__dir, "bin", "cdp.mjs"));
28
+ }
29
29
 
30
30
  function runSearch(
31
31
  engine: string,
@@ -34,14 +34,14 @@ function runSearch(
34
34
  signal?: AbortSignal,
35
35
  onProgress?: (engine: string, status: "done" | "error") => void,
36
36
  ): Promise<Record<string, unknown>> {
37
- return new Promise((resolve, reject) => {
38
- const proc = spawn(
39
- "node",
40
- [`${__dir}/search.mjs`, engine, "--inline", ...flags, query],
41
- {
42
- stdio: ["ignore", "pipe", "pipe"],
43
- },
44
- );
37
+ return new Promise((resolve, reject) => {
38
+ const proc = spawn(
39
+ "node",
40
+ [join(__dir, "bin", "search.mjs"), engine, "--inline", ...flags, query],
41
+ {
42
+ stdio: ["ignore", "pipe", "pipe"],
43
+ },
44
+ );
45
45
  let out = "";
46
46
  let err = "";
47
47
 
@@ -355,13 +355,13 @@ export default function greedySearchExtension(pi: ExtensionAPI) {
355
355
 
356
356
  const data = await new Promise<Record<string, unknown>>(
357
357
  (resolve, reject) => {
358
- const proc = spawn(
359
- "node",
360
- [`${__dir}/coding-task.mjs`, task, ...flags],
361
- {
362
- stdio: ["ignore", "pipe", "pipe"],
363
- },
364
- );
358
+ const proc = spawn(
359
+ "node",
360
+ [join(__dir, "bin", "coding-task.mjs"), task, ...flags],
361
+ {
362
+ stdio: ["ignore", "pipe", "pipe"],
363
+ },
364
+ );
365
365
  let out = "";
366
366
  let err = "";
367
367
 
package/package.json CHANGED
@@ -1,49 +1,46 @@
1
- {
2
- "name": "@apmantza/greedysearch-pi",
3
- "version": "1.7.0",
4
- "description": "Pi extension: multi-engine AI search (Perplexity, Bing Copilot, Google AI) via browser automation -- NO API KEYS needed. Extracts answers with sources, optional Gemini synthesis. Grounded AI answers from real browser interactions.",
5
- "type": "module",
6
- "keywords": [
7
- "pi-package"
8
- ],
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/apmantza/GreedySearch-pi.git"
12
- },
13
- "author": "Apostolos Mantzaris",
14
- "license": "MIT",
15
- "scripts": {
16
- "test": "./test.sh",
17
- "test:quick": "./test.sh quick",
18
- "test:smoke": "./test.sh smoke"
19
- },
20
- "files": [
21
- "index.ts",
22
- "src/",
23
- "skills/",
24
- "extractors/",
25
- "cdp.mjs",
26
- "search.mjs",
27
- "launch.mjs",
28
- "coding-task.mjs",
29
- "CHANGELOG.md",
30
- "README.md"
31
- ],
32
- "pi": {
33
- "extensions": [
34
- "./index.ts"
35
- ],
36
- "skills": [
37
- "./skills"
38
- ]
39
- },
40
- "dependencies": {
41
- "jsdom": "^24.0.0",
42
- "@mozilla/readability": "^0.5.0",
43
- "turndown": "^7.1.2"
44
- },
45
- "peerDependencies": {
46
- "@mariozechner/pi-coding-agent": "*",
47
- "@sinclair/typebox": "*"
48
- }
49
- }
1
+ {
2
+ "name": "@apmantza/greedysearch-pi",
3
+ "version": "1.7.2",
4
+ "description": "Pi extension: multi-engine AI search (Perplexity, Bing Copilot, Google AI) via browser automation -- NO API KEYS needed. Extracts answers with sources, optional Gemini synthesis. Grounded AI answers from real browser interactions.",
5
+ "type": "module",
6
+ "keywords": [
7
+ "pi-package"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/apmantza/GreedySearch-pi.git"
12
+ },
13
+ "author": "Apostolos Mantzaris",
14
+ "license": "MIT",
15
+ "scripts": {
16
+ "test": "./test.sh",
17
+ "test:quick": "./test.sh quick",
18
+ "test:smoke": "./test.sh smoke"
19
+ },
20
+ "files": [
21
+ "index.ts",
22
+ "bin/",
23
+ "src/",
24
+ "skills/",
25
+ "extractors/",
26
+ "CHANGELOG.md",
27
+ "README.md"
28
+ ],
29
+ "pi": {
30
+ "extensions": [
31
+ "./index.ts"
32
+ ],
33
+ "skills": [
34
+ "./skills"
35
+ ]
36
+ },
37
+ "dependencies": {
38
+ "jsdom": "^24.0.0",
39
+ "@mozilla/readability": "^0.5.0",
40
+ "turndown": "^7.1.2"
41
+ },
42
+ "peerDependencies": {
43
+ "@mariozechner/pi-coding-agent": "*",
44
+ "@sinclair/typebox": "*"
45
+ }
46
+ }
@@ -1,117 +1,117 @@
1
- ---
2
- name: greedy-search
3
- description: Multi-engine AI **WEB SEARCH** tool — NOT for codebase search. Use greedy_search for high-quality web research where training data may be stale or single-engine results are insufficient. Searches Perplexity, Bing, Google via browser automation. NO API KEYS needed.
4
- ---
5
-
6
- # ⚠️ WEB SEARCH ONLY — NOT CODEBASE SEARCH
7
-
8
- **`greedy_search` searches the live web**, not your local codebase.
9
-
10
- | Tool | Searches |
11
- |------|----------|
12
- | `greedy_search` | **Live web** (Perplexity, Bing, Google) |
13
- | `ast_grep_search` | **Local codebase** — use this for code patterns |
14
- | `bash` with `grep/rg` | **Local codebase** — use this for text search |
15
-
16
- **DO NOT use `greedy_search` for:**
17
- - Finding functions in your codebase
18
- - Searching local files
19
- - Code review of your project
20
- - Understanding project structure
21
-
22
- **DO use `greedy_search` for:**
23
- - Library documentation
24
- - Recent framework changes
25
- - Error message explanations
26
- - Best practices research
27
- - Current events/news
28
-
29
- # GreedySearch Tools
30
-
31
- | Tool | Speed | Use For |
32
- |------|-------|---------|
33
- | `greedy_search` | 15-180s | Multi-engine search with depth levels |
34
- | `coding_task` | 60-180s | Debug, review, plan modes for hard problems |
35
-
36
- ## greedy_search
37
-
38
- Multi-engine AI search (Perplexity, Bing, Google) with three depth levels.
39
-
40
- ```greedy_search({ query: "React 19 changes", depth: "standard" })```
41
-
42
- | Parameter | Type | Default | Description |
43
- |-----------|------|---------|-------------|
44
- | `query` | string | required | Search question |
45
- | `engine` | string | `"all"` | `all`, `perplexity`, `bing`, `google`, `gemini` |
46
- | `depth` | string | `"standard"` | `fast`, `standard`, `deep` — see below |
47
- | `fullAnswer` | boolean | `false` | Complete vs ~300 char summary |
48
-
49
- ### Depth Levels
50
-
51
- | Depth | Engines | Synthesis | Source Fetch | Time | Use When |
52
- |-------|---------|-----------|--------------|------|----------|
53
- | `fast` | 1 | ❌ | ❌ | 15-30s | Quick lookup, single perspective |
54
- | `standard` | 3 | ✅ | ❌ | 30-90s | Default — balanced speed/quality |
55
- | `deep` | 3 | ✅ | ✅ (top 5) | 60-180s | Research that matters — architecture decisions |
56
-
57
- **Standard** (default): Runs 3 engines, deduplicates sources, synthesizes via Gemini.
58
- **Deep**: Same + fetches content from top sources for grounded synthesis + confidence scores.
59
-
60
- ### Engine Selection (for fast mode)
61
-
62
- ```greedy_search({ query: "...", engine: "perplexity", depth: "fast" })```
63
-
64
- - `perplexity`: Technical Q&A, citations
65
- - `bing`: Recent news, Microsoft ecosystem
66
- - `google`: Broad coverage
67
- - `gemini`: Different training data
68
-
69
- ### Examples — Web Research Only
70
-
71
- **✅ GOOD — Web research:**
72
- ```greedy_search({ query: "what changed in React 19", depth: "fast" })```
73
- ```greedy_search({ query: "best auth patterns for SaaS", depth: "deep" })```
74
- ```greedy_search({ query: "Prisma vs Drizzle 2026", depth: "standard", fullAnswer: true })```
75
-
76
- **❌ WRONG — Don't use for codebase search:**
77
- ```javascript
78
- // DON'T: Searching your own codebase
79
- // greedy_search({ query: "find UserService class" }) // ❌ Won't find it!
80
-
81
- // DO: Use these instead for codebase search:
82
- // ast_grep_search({ pattern: "class UserService", lang: "typescript" })
83
- // bash({ command: "rg 'class UserService' --type ts" })
84
- ```
85
-
86
- ### Legacy
87
-
88
- `deep_research` tool still works — aliases to `greedy_search` with `depth: "deep"`.
89
-
90
- ## coding_task
91
-
92
- Browser-based coding assistant via Gemini/Copilot.
93
-
94
- ```coding_task({ task: "debug race condition", mode: "debug", engine: "gemini" })```
95
-
96
- | Parameter | Type | Default | Description |
97
- |-----------|------|---------|-------------|
98
- | `task` | string | required | Coding task/question |
99
- | `engine` | string | `"gemini"` | `gemini`, `copilot`, `all` |
100
- | `mode` | string | `"code"` | `debug`, `plan`, `review`, `test`, `code` |
101
- | `context` | string | — | Code snippet to include |
102
-
103
- **Modes:**
104
- - `debug`: Tricky bugs — fresh eyes catch different failure modes
105
- - `plan`: Big refactor — plays devil's advocate on risks
106
- - `review`: High-stakes code review before merge
107
- - `test`: Edge cases the author missed
108
- - `code`: Simple generation (but you're probably faster)
109
-
110
- **When to use:** Second opinions on hard problems. Skip for simple code.
111
-
112
- ## Result Interpretation
113
-
114
- - **All 3 engines agree** → High confidence, present as fact
115
- - **2 agree, 1 differs** → Likely correct, note dissent
116
- - **Sources [3/3] or [2/3]** → Multiple engines cite, higher confidence
117
- - **Deep research confidence scores** → Structured confidence metadata
1
+ ---
2
+ name: greedy-search
3
+ description: Multi-engine AI **WEB SEARCH** tool — NOT for codebase search. Use greedy_search for high-quality web research where training data may be stale or single-engine results are insufficient. Searches Perplexity, Bing, Google via browser automation. NO API KEYS needed.
4
+ ---
5
+
6
+ # ⚠️ WEB SEARCH ONLY — NOT CODEBASE SEARCH
7
+
8
+ **`greedy_search` searches the live web**, not your local codebase.
9
+
10
+ | Tool | Searches |
11
+ |------|----------|
12
+ | `greedy_search` | **Live web** (Perplexity, Bing, Google) |
13
+ | `ast_grep_search` | **Local codebase** — use this for code patterns |
14
+ | `bash` with `grep/rg` | **Local codebase** — use this for text search |
15
+
16
+ **DO NOT use `greedy_search` for:**
17
+ - Finding functions in your codebase
18
+ - Searching local files
19
+ - Code review of your project
20
+ - Understanding project structure
21
+
22
+ **DO use `greedy_search` for:**
23
+ - Library documentation
24
+ - Recent framework changes
25
+ - Error message explanations
26
+ - Best practices research
27
+ - Current events/news
28
+
29
+ # GreedySearch Tools
30
+
31
+ | Tool | Speed | Use For |
32
+ |------|-------|---------|
33
+ | `greedy_search` | 15-180s | Multi-engine search with depth levels |
34
+ | `coding_task` | 60-180s | Debug, review, plan modes for hard problems |
35
+
36
+ ## greedy_search
37
+
38
+ Multi-engine AI search (Perplexity, Bing, Google) with three depth levels.
39
+
40
+ ```greedy_search({ query: "React 19 changes", depth: "standard" })```
41
+
42
+ | Parameter | Type | Default | Description |
43
+ |-----------|------|---------|-------------|
44
+ | `query` | string | required | Search question |
45
+ | `engine` | string | `"all"` | `all`, `perplexity`, `bing`, `google`, `gemini` |
46
+ | `depth` | string | `"standard"` | `fast`, `standard`, `deep` — see below |
47
+ | `fullAnswer` | boolean | `false` | Complete vs ~300 char summary |
48
+
49
+ ### Depth Levels
50
+
51
+ | Depth | Engines | Synthesis | Source Fetch | Time | Use When |
52
+ |-------|---------|-----------|--------------|------|----------|
53
+ | `fast` | 1 | ❌ | ❌ | 15-30s | Quick lookup, single perspective |
54
+ | `standard` | 3 | ✅ | ❌ | 30-90s | Default — balanced speed/quality |
55
+ | `deep` | 3 | ✅ | ✅ (top 5) | 60-180s | Research that matters — architecture decisions |
56
+
57
+ **Standard** (default): Runs 3 engines, deduplicates sources, synthesizes via Gemini.
58
+ **Deep**: Same + fetches content from top sources for grounded synthesis + confidence scores.
59
+
60
+ ### Engine Selection (for fast mode)
61
+
62
+ ```greedy_search({ query: "...", engine: "perplexity", depth: "fast" })```
63
+
64
+ - `perplexity`: Technical Q&A, citations
65
+ - `bing`: Recent news, Microsoft ecosystem
66
+ - `google`: Broad coverage
67
+ - `gemini`: Different training data
68
+
69
+ ### Examples — Web Research Only
70
+
71
+ **✅ GOOD — Web research:**
72
+ ```greedy_search({ query: "what changed in React 19", depth: "fast" })```
73
+ ```greedy_search({ query: "best auth patterns for SaaS", depth: "deep" })```
74
+ ```greedy_search({ query: "Prisma vs Drizzle 2026", depth: "standard", fullAnswer: true })```
75
+
76
+ **❌ WRONG — Don't use for codebase search:**
77
+ ```javascript
78
+ // DON'T: Searching your own codebase
79
+ // greedy_search({ query: "find UserService class" }) // ❌ Won't find it!
80
+
81
+ // DO: Use these instead for codebase search:
82
+ // ast_grep_search({ pattern: "class UserService", lang: "typescript" })
83
+ // bash({ command: "rg 'class UserService' --type ts" })
84
+ ```
85
+
86
+ ### Legacy
87
+
88
+ `deep_research` tool still works — aliases to `greedy_search` with `depth: "deep"`.
89
+
90
+ ## coding_task
91
+
92
+ Browser-based coding assistant via Gemini/Copilot.
93
+
94
+ ```coding_task({ task: "debug race condition", mode: "debug", engine: "gemini" })```
95
+
96
+ | Parameter | Type | Default | Description |
97
+ |-----------|------|---------|-------------|
98
+ | `task` | string | required | Coding task/question |
99
+ | `engine` | string | `"gemini"` | `gemini`, `copilot`, `all` |
100
+ | `mode` | string | `"code"` | `debug`, `plan`, `review`, `test`, `code` |
101
+ | `context` | string | — | Code snippet to include |
102
+
103
+ **Modes:**
104
+ - `debug`: Tricky bugs — fresh eyes catch different failure modes
105
+ - `plan`: Big refactor — plays devil's advocate on risks
106
+ - `review`: High-stakes code review before merge
107
+ - `test`: Edge cases the author missed
108
+ - `code`: Simple generation (but you're probably faster)
109
+
110
+ **When to use:** Second opinions on hard problems. Skip for simple code.
111
+
112
+ ## Result Interpretation
113
+
114
+ - **All 3 engines agree** → High confidence, present as fact
115
+ - **2 agree, 1 differs** → Likely correct, note dissent
116
+ - **Sources [3/3] or [2/3]** → Multiple engines cite, higher confidence
117
+ - **Deep research confidence scores** → Structured confidence metadata