omnisearch-cli 0.0.0-stage → 1.0.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 +101 -2
- package/dist/index.js +153 -0
- package/package.json +25 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OmniSearch SDK Contributors
|
|
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,3 +1,102 @@
|
|
|
1
|
-
#
|
|
1
|
+
# omnisearch-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> High-performance command-line interface for multi-provider web search retrieval, powered by [`omnisearch-sdk`](https://www.npmjs.com/package/omnisearch-sdk).
|
|
4
|
+
|
|
5
|
+
Search across Google, Brave, Bing, DuckDuckGo, Tavily, Perplexity, PubMed, Arxiv, GitHub, and more directly from your terminal or shell scripts.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ⚡ Quick Start
|
|
10
|
+
|
|
11
|
+
Run directly with `npx` (no installation required):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Basic web search (auto-detects configured providers or falls back to DuckDuckGo)
|
|
15
|
+
npx omnisearch-cli "autonomous AI agents"
|
|
16
|
+
|
|
17
|
+
# Search specific engine (e.g. Brave, PubMed, GitHub)
|
|
18
|
+
npx omnisearch-cli "CRISPR gene editing" -p pubmed -n 5
|
|
19
|
+
|
|
20
|
+
# Recent news (past 24h) with JSON output for piping to jq
|
|
21
|
+
npx omnisearch-cli "latest AI models" -p brave -f day --type news --json
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install globally:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g omnisearch-cli
|
|
28
|
+
# or
|
|
29
|
+
pnpm add -g omnisearch-cli
|
|
30
|
+
|
|
31
|
+
omnisearch "quantum computing" -n 5
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🛠 Command-Line Options
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
Usage:
|
|
40
|
+
omnisearch "<query>" [options]
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
-p, --provider <name> Search provider to use (default: auto-detect)
|
|
44
|
+
-f, --freshness <period> Filter by recency: day, week, month, year
|
|
45
|
+
-s, --strategy <mode> Execution mode: parallel, fallback, race (default: parallel)
|
|
46
|
+
-n, --max-results <num> Maximum results to return (default: 10)
|
|
47
|
+
--type <type> Search type: web, news (default: web)
|
|
48
|
+
--dedupe Enable canonical URL deduplication
|
|
49
|
+
--json Output raw JSON (ideal for scripting and jq)
|
|
50
|
+
-h, --help Show help message
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🌐 Supported Providers
|
|
56
|
+
|
|
57
|
+
The CLI automatically detects providers based on available environment variables:
|
|
58
|
+
|
|
59
|
+
| Provider Flag | Engine | Requires API Key? | Environment Variables |
|
|
60
|
+
| :--- | :--- | :--- | :--- |
|
|
61
|
+
| `-p duckduckgo` | DuckDuckGo | **No** (Zero-config) | None |
|
|
62
|
+
| `-p pubmed` | PubMed / NCBI | **No** (Zero-config) | None |
|
|
63
|
+
| `-p arxiv` | Arxiv Preprints | **No** (Zero-config) | None |
|
|
64
|
+
| `-p semanticscholar` | Semantic Scholar | **No** (Zero-config) | None |
|
|
65
|
+
| `-p github` | GitHub Search | **Optional** | `GITHUB_TOKEN` |
|
|
66
|
+
| `-p brave` | Brave Search | **Yes** | `BRAVE_API_KEY` |
|
|
67
|
+
| `-p google` | Google Search | **Yes** | `GOOGLE_API_KEY`, `GOOGLE_CX` |
|
|
68
|
+
| `-p bing` | Bing Web Search | **Yes** | `BING_API_KEY` |
|
|
69
|
+
| `-p you` | You.com Search | **Yes** | `YOU_API_KEY` |
|
|
70
|
+
| `-p tavily` | Tavily Search | **Yes** | `TAVILY_API_KEY` |
|
|
71
|
+
| `-p exa` | Exa Neural Search | **Yes** | `EXA_API_KEY` |
|
|
72
|
+
| `-p perplexity` | Perplexity AI | **Yes** | `PERPLEXITY_API_KEY` |
|
|
73
|
+
| `-p parallel` | Parallel Search | **Yes** | `PARALLEL_API_KEY` |
|
|
74
|
+
| `-p serpapi` | SerpAPI | **Yes** | `SERPAPI_API_KEY` |
|
|
75
|
+
| `-p searxng` | SearXNG | **Yes** | `SEARXNG_BASE_URL` |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 💡 Examples
|
|
80
|
+
|
|
81
|
+
### 1. Multi-Engine Cascading Fallback
|
|
82
|
+
Try Brave first; if rate-limited or unavailable, gracefully fall back to DuckDuckGo:
|
|
83
|
+
```bash
|
|
84
|
+
omnisearch "TypeScript 6 release date" --strategy fallback
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 2. Live Shell Scripting with `jq`
|
|
88
|
+
Fetch the top 3 URLs in JSON:
|
|
89
|
+
```bash
|
|
90
|
+
omnisearch "Rust memory safety" --json | jq '.[].url'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3. Academic Paper Discovery
|
|
94
|
+
```bash
|
|
95
|
+
omnisearch "transformer architecture attention is all you need" -p arxiv -n 3
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 📄 License
|
|
101
|
+
|
|
102
|
+
MIT © [OmniSearch SDK Contributors](https://github.com/gbks121/omnisearch-sdk)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { parseArgs } from "util";
|
|
5
|
+
import {
|
|
6
|
+
createArxivProvider,
|
|
7
|
+
createBingProvider,
|
|
8
|
+
createBraveProvider,
|
|
9
|
+
createDuckDuckGoProvider,
|
|
10
|
+
createExaProvider,
|
|
11
|
+
createGitHubProvider,
|
|
12
|
+
createGoogleProvider,
|
|
13
|
+
createParallelProvider,
|
|
14
|
+
createPerplexityProvider,
|
|
15
|
+
createPubMedProvider,
|
|
16
|
+
createSearXNGProvider,
|
|
17
|
+
createSemanticScholarProvider,
|
|
18
|
+
createSerpApiProvider,
|
|
19
|
+
createTavilyProvider,
|
|
20
|
+
createYouProvider,
|
|
21
|
+
webSearch
|
|
22
|
+
} from "omnisearch-sdk";
|
|
23
|
+
function showHelp() {
|
|
24
|
+
console.log(`
|
|
25
|
+
OmniSearch CLI - High-performance multi-provider search
|
|
26
|
+
|
|
27
|
+
Usage:
|
|
28
|
+
omnisearch "<query>" [options]
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
-p, --provider <name> Provider to use (brave, google, duckduckgo, etc.) Default: auto
|
|
32
|
+
-f, --freshness <period> Freshness filter (day, week, month, year)
|
|
33
|
+
-s, --strategy <mode> Execution strategy (parallel, fallback, race) Default: parallel
|
|
34
|
+
-n, --max-results <num> Maximum results to return. Default: 10
|
|
35
|
+
--type <type> Search type (web, news). Default: web
|
|
36
|
+
--dedupe Enable canonical URL deduplication
|
|
37
|
+
--json Output raw JSON results
|
|
38
|
+
-h, --help Show this help message
|
|
39
|
+
|
|
40
|
+
Environment Variables:
|
|
41
|
+
BRAVE_API_KEY, GOOGLE_API_KEY, GOOGLE_CX, TAVILY_API_KEY, EXA_API_KEY,
|
|
42
|
+
PERPLEXITY_API_KEY, BING_API_KEY, YOU_API_KEY, PARALLEL_API_KEY, SERPAPI_API_KEY
|
|
43
|
+
`);
|
|
44
|
+
}
|
|
45
|
+
function resolveProviders(providerName) {
|
|
46
|
+
const env = process.env;
|
|
47
|
+
const name = providerName?.toLowerCase();
|
|
48
|
+
const registry = {
|
|
49
|
+
duckduckgo: () => createDuckDuckGoProvider(),
|
|
50
|
+
arxiv: () => createArxivProvider(),
|
|
51
|
+
pubmed: () => createPubMedProvider(),
|
|
52
|
+
github: () => createGitHubProvider({ apiKey: env.GITHUB_TOKEN || env.GITHUB_API_KEY }),
|
|
53
|
+
brave: () => env.BRAVE_API_KEY || env.BRAVE_SEARCH_API_KEY ? createBraveProvider({ apiKey: env.BRAVE_API_KEY || env.BRAVE_SEARCH_API_KEY }) : null,
|
|
54
|
+
google: () => env.GOOGLE_API_KEY && env.GOOGLE_CX ? createGoogleProvider({ apiKey: env.GOOGLE_API_KEY, cx: env.GOOGLE_CX }) : null,
|
|
55
|
+
tavily: () => env.TAVILY_API_KEY ? createTavilyProvider({ apiKey: env.TAVILY_API_KEY }) : null,
|
|
56
|
+
exa: () => env.EXA_API_KEY ? createExaProvider({ apiKey: env.EXA_API_KEY }) : null,
|
|
57
|
+
perplexity: () => env.PERPLEXITY_API_KEY ? createPerplexityProvider({ apiKey: env.PERPLEXITY_API_KEY }) : null,
|
|
58
|
+
bing: () => env.BING_API_KEY ? createBingProvider({ apiKey: env.BING_API_KEY }) : null,
|
|
59
|
+
you: () => env.YOU_API_KEY ? createYouProvider({ apiKey: env.YOU_API_KEY }) : null,
|
|
60
|
+
parallel: () => env.PARALLEL_API_KEY ? createParallelProvider({ apiKey: env.PARALLEL_API_KEY }) : null,
|
|
61
|
+
serpapi: () => env.SERPAPI_API_KEY ? createSerpApiProvider({ apiKey: env.SERPAPI_API_KEY }) : null,
|
|
62
|
+
searxng: () => env.SEARXNG_BASE_URL ? createSearXNGProvider({ baseUrl: env.SEARXNG_BASE_URL }) : null,
|
|
63
|
+
semanticscholar: () => createSemanticScholarProvider()
|
|
64
|
+
};
|
|
65
|
+
if (name) {
|
|
66
|
+
const factory = registry[name];
|
|
67
|
+
if (!factory) {
|
|
68
|
+
console.error(`Unknown provider: ${name}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
const instance = factory();
|
|
72
|
+
if (!instance) {
|
|
73
|
+
console.error(`Missing required environment variables/API keys for provider: ${name}`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
return [instance];
|
|
77
|
+
}
|
|
78
|
+
const available = [];
|
|
79
|
+
for (const [_, factory] of Object.entries(registry)) {
|
|
80
|
+
const inst = factory();
|
|
81
|
+
if (inst) available.push(inst);
|
|
82
|
+
}
|
|
83
|
+
if (available.length === 0) {
|
|
84
|
+
available.push(createDuckDuckGoProvider());
|
|
85
|
+
}
|
|
86
|
+
return available;
|
|
87
|
+
}
|
|
88
|
+
async function runCli() {
|
|
89
|
+
const { values, positionals } = parseArgs({
|
|
90
|
+
args: process.argv.slice(2),
|
|
91
|
+
options: {
|
|
92
|
+
provider: { type: "string", short: "p" },
|
|
93
|
+
freshness: { type: "string", short: "f" },
|
|
94
|
+
strategy: { type: "string", short: "s", default: "parallel" },
|
|
95
|
+
"max-results": { type: "string", short: "n", default: "10" },
|
|
96
|
+
type: { type: "string", default: "web" },
|
|
97
|
+
dedupe: { type: "boolean", default: false },
|
|
98
|
+
json: { type: "boolean", default: false },
|
|
99
|
+
help: { type: "boolean", short: "h", default: false }
|
|
100
|
+
},
|
|
101
|
+
allowPositionals: true
|
|
102
|
+
});
|
|
103
|
+
if (values.help || positionals.length === 0) {
|
|
104
|
+
showHelp();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const query = positionals.join(" ").trim();
|
|
108
|
+
const providers = resolveProviders(values.provider);
|
|
109
|
+
const maxResults = Number.parseInt(values["max-results"] ?? "10", 10);
|
|
110
|
+
const strategy = values.strategy;
|
|
111
|
+
const freshness = values.freshness;
|
|
112
|
+
const searchType = values.type;
|
|
113
|
+
try {
|
|
114
|
+
const results = await webSearch({
|
|
115
|
+
query,
|
|
116
|
+
provider: providers,
|
|
117
|
+
maxResults,
|
|
118
|
+
strategy,
|
|
119
|
+
freshness,
|
|
120
|
+
searchType,
|
|
121
|
+
deduplicate: values.dedupe
|
|
122
|
+
});
|
|
123
|
+
if (values.json) {
|
|
124
|
+
console.log(JSON.stringify(results, null, 2));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (results.length === 0) {
|
|
128
|
+
console.log(`No results found for "${query}".`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
console.log(`
|
|
132
|
+
Found ${results.length} results for "${query}":
|
|
133
|
+
`);
|
|
134
|
+
results.forEach((item, idx) => {
|
|
135
|
+
console.log(`${idx + 1}. [${item.provider}] ${item.title}`);
|
|
136
|
+
console.log(` ${item.url}`);
|
|
137
|
+
if (item.snippet) {
|
|
138
|
+
console.log(` ${item.snippet.slice(0, 160)}${item.snippet.length > 160 ? "..." : ""}`);
|
|
139
|
+
}
|
|
140
|
+
if (item.publishedDate) {
|
|
141
|
+
console.log(` Published: ${item.publishedDate}`);
|
|
142
|
+
}
|
|
143
|
+
console.log("");
|
|
144
|
+
});
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error("Search error:", error instanceof Error ? error.message : String(error));
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
runCli();
|
|
151
|
+
export {
|
|
152
|
+
runCli
|
|
153
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnisearch-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Command-line interface for OmniSearch SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"omnisearch": "./dist/index.js",
|
|
9
|
+
"omnisearch-cli": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=24.0.0"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"omnisearch-sdk": "5.0.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"tsup": "^8.5.1",
|
|
22
|
+
"typescript": "~6.0.3"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch"
|
|
27
|
+
}
|
|
6
28
|
}
|