omnisearch-cli 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +181 -0
  2. package/dist/index.js +8 -4
  3. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # omnisearch-cli
2
+
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
+ ## 🔑 Providing API Keys
37
+
38
+ The CLI supports 3 ways to provide API keys:
39
+
40
+ ### 1. Automatic `.env` File (Recommended)
41
+ Place a `.env` file in your current working directory. The CLI will automatically detect and load it on startup without requiring any flags or external dependencies:
42
+
43
+ ```env
44
+ # .env template — Fill only the providers you want to use:
45
+
46
+ # Brave Search
47
+ BRAVE_API_KEY=
48
+
49
+ # Tavily AI Search
50
+ TAVILY_API_KEY=
51
+
52
+ # Google Custom Search (Requires both)
53
+ GOOGLE_API_KEY=
54
+ GOOGLE_CX=
55
+
56
+ # Azure Bing Web Search
57
+ BING_API_KEY=
58
+
59
+ # You.com Search
60
+ YOU_API_KEY=
61
+
62
+ # Exa Neural Search
63
+ EXA_API_KEY=
64
+
65
+ # Perplexity AI
66
+ PERPLEXITY_API_KEY=
67
+
68
+ # Parallel Search
69
+ PARALLEL_API_KEY=
70
+
71
+ # SerpAPI
72
+ SERPAPI_KEY=
73
+
74
+ # Self-Hosted SearXNG Instance
75
+ SEARXNG_URL=
76
+
77
+ # GitHub (Optional, increases rate limit)
78
+ GITHUB_TOKEN=
79
+
80
+ # Semantic Scholar (Optional, increases rate limit)
81
+ SEMANTIC_SCHOLAR_API_KEY=
82
+
83
+ # PubMed / NCBI (Optional, increases rate limit)
84
+ PUBMED_API_KEY=
85
+ ```
86
+
87
+ Then simply run:
88
+ ```bash
89
+ npx omnisearch-cli "latest AI research"
90
+ ```
91
+
92
+ ### 2. Inline Environment Variable (One-off / CI)
93
+ Pass keys directly on the command line:
94
+
95
+ * **macOS / Linux / WSL / Git Bash:**
96
+ ```bash
97
+ BRAVE_API_KEY="your_key" npx omnisearch-cli "deep learning" -p brave
98
+ ```
99
+ * **Windows PowerShell:**
100
+ ```powershell
101
+ $env:BRAVE_API_KEY="your_key"; npx omnisearch-cli "deep learning" -p brave
102
+ ```
103
+
104
+ ### 3. Persistent Shell Profile
105
+ Export your keys in your `~/.bashrc`, `~/.zshrc`, or Windows Environment Variables:
106
+ ```bash
107
+ export BRAVE_API_KEY="your_key"
108
+ export TAVILY_API_KEY="your_key"
109
+ ```
110
+
111
+ > **Zero-Key Mode:** If no API keys are configured, `omnisearch-cli` automatically runs using free public providers (**DuckDuckGo**, **PubMed**, **Arxiv**, and **Semantic Scholar**) with no signup required.
112
+
113
+ ---
114
+
115
+ ## 🛠 Command-Line Options
116
+
117
+ ```text
118
+ Usage:
119
+ omnisearch "<query>" [options]
120
+
121
+ Options:
122
+ -p, --provider <name> Search provider to use (default: auto-detect)
123
+ -f, --freshness <period> Filter by recency: day, week, month, year
124
+ -s, --strategy <mode> Execution mode: parallel, fallback, race (default: parallel)
125
+ -n, --max-results <num> Maximum results to return (default: 10)
126
+ --type <type> Search type: web, news (default: web)
127
+ --dedupe Enable canonical URL deduplication
128
+ --json Output raw JSON (ideal for scripting and jq)
129
+ -h, --help Show help message
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 🌐 Supported Providers
135
+
136
+ The CLI automatically detects providers based on available environment variables:
137
+
138
+ | Provider Flag | Engine | Requires API Key? | Environment Variables |
139
+ | :--- | :--- | :--- | :--- |
140
+ | `-p duckduckgo` | DuckDuckGo | **No** (Zero-config) | None |
141
+ | `-p pubmed` | PubMed / NCBI | **No** (Zero-config) | None |
142
+ | `-p arxiv` | Arxiv Preprints | **No** (Zero-config) | None |
143
+ | `-p semanticscholar` | Semantic Scholar | **No** (Zero-config) | None |
144
+ | `-p github` | GitHub Search | **Optional** | `GITHUB_TOKEN` |
145
+ | `-p brave` | Brave Search | **Yes** | `BRAVE_API_KEY` |
146
+ | `-p google` | Google Search | **Yes** | `GOOGLE_API_KEY`, `GOOGLE_CX` |
147
+ | `-p bing` | Bing Web Search | **Yes** | `BING_API_KEY` |
148
+ | `-p you` | You.com Search | **Yes** | `YOU_API_KEY` |
149
+ | `-p tavily` | Tavily Search | **Yes** | `TAVILY_API_KEY` |
150
+ | `-p exa` | Exa Neural Search | **Yes** | `EXA_API_KEY` |
151
+ | `-p perplexity` | Perplexity AI | **Yes** | `PERPLEXITY_API_KEY` |
152
+ | `-p parallel` | Parallel Search | **Yes** | `PARALLEL_API_KEY` |
153
+ | `-p serpapi` | SerpAPI | **Yes** | `SERPAPI_API_KEY` |
154
+ | `-p searxng` | SearXNG | **Yes** | `SEARXNG_BASE_URL` |
155
+
156
+ ---
157
+
158
+ ## 💡 Examples
159
+
160
+ ### 1. Multi-Engine Cascading Fallback
161
+ Try Brave first; if rate-limited or unavailable, gracefully fall back to DuckDuckGo:
162
+ ```bash
163
+ omnisearch "TypeScript 6 release date" --strategy fallback
164
+ ```
165
+
166
+ ### 2. Live Shell Scripting with `jq`
167
+ Fetch the top 3 URLs in JSON:
168
+ ```bash
169
+ omnisearch "Rust memory safety" --json | jq '.[].url'
170
+ ```
171
+
172
+ ### 3. Academic Paper Discovery
173
+ ```bash
174
+ omnisearch "transformer architecture attention is all you need" -p arxiv -n 3
175
+ ```
176
+
177
+ ---
178
+
179
+ ## 📄 License
180
+
181
+ MIT © [OmniSearch SDK Contributors](https://github.com/gbks121/omnisearch-sdk)
package/dist/index.js CHANGED
@@ -20,6 +20,10 @@ import {
20
20
  createYouProvider,
21
21
  webSearch
22
22
  } from "omnisearch-sdk";
23
+ try {
24
+ process.loadEnvFile();
25
+ } catch {
26
+ }
23
27
  function showHelp() {
24
28
  console.log(`
25
29
  OmniSearch CLI - High-performance multi-provider search
@@ -48,7 +52,7 @@ function resolveProviders(providerName) {
48
52
  const registry = {
49
53
  duckduckgo: () => createDuckDuckGoProvider(),
50
54
  arxiv: () => createArxivProvider(),
51
- pubmed: () => createPubMedProvider(),
55
+ pubmed: () => createPubMedProvider({ apiKey: env.PUBMED_API_KEY }),
52
56
  github: () => createGitHubProvider({ apiKey: env.GITHUB_TOKEN || env.GITHUB_API_KEY }),
53
57
  brave: () => env.BRAVE_API_KEY || env.BRAVE_SEARCH_API_KEY ? createBraveProvider({ apiKey: env.BRAVE_API_KEY || env.BRAVE_SEARCH_API_KEY }) : null,
54
58
  google: () => env.GOOGLE_API_KEY && env.GOOGLE_CX ? createGoogleProvider({ apiKey: env.GOOGLE_API_KEY, cx: env.GOOGLE_CX }) : null,
@@ -58,9 +62,9 @@ function resolveProviders(providerName) {
58
62
  bing: () => env.BING_API_KEY ? createBingProvider({ apiKey: env.BING_API_KEY }) : null,
59
63
  you: () => env.YOU_API_KEY ? createYouProvider({ apiKey: env.YOU_API_KEY }) : null,
60
64
  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()
65
+ serpapi: () => env.SERPAPI_KEY || env.SERPAPI_API_KEY ? createSerpApiProvider({ apiKey: env.SERPAPI_KEY || env.SERPAPI_API_KEY }) : null,
66
+ searxng: () => env.SEARXNG_URL || env.SEARXNG_BASE_URL ? createSearXNGProvider({ baseUrl: env.SEARXNG_URL || env.SEARXNG_BASE_URL }) : null,
67
+ semanticscholar: () => createSemanticScholarProvider({ apiKey: env.SEMANTIC_SCHOLAR_API_KEY })
64
68
  };
65
69
  if (name) {
66
70
  const factory = registry[name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnisearch-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Command-line interface for OmniSearch SDK",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -15,7 +15,7 @@
15
15
  "node": ">=24.0.0"
16
16
  },
17
17
  "dependencies": {
18
- "omnisearch-sdk": "5.0.1"
18
+ "omnisearch-sdk": "5.1.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "tsup": "^8.5.1",