sxng-cli 1.0.7 β 1.0.8
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/README.md +173 -145
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -1,131 +1,182 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
# π SXNG CLI
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<b>A powerful command-line interface for <a href="https://github.com/searxng/searxng">SearXNG</a></b><br>
|
|
5
|
+
Privacy-respecting web search from your terminal
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/sxng-cli">
|
|
10
|
+
<img src="https://img.shields.io/npm/v/sxng-cli?style=flat-square&color=cb3837" alt="npm version">
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/sxng-cli">
|
|
13
|
+
<img src="https://img.shields.io/npm/dm/sxng-cli?style=flat-square&color=cb3837" alt="npm downloads">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://github.com/hkwuks/sxng-cli/blob/main/LICENSE">
|
|
16
|
+
<img src="https://img.shields.io/github/license/hkwuks/sxng-cli?style=flat-square&color=green" alt="license">
|
|
17
|
+
</a>
|
|
18
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen?style=flat-square" alt="node version">
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
## β¨ Features
|
|
22
|
+
|
|
23
|
+
- π **Multi-Engine Search** β Search across Google, Bing, DuckDuckGo, GitHub, StackOverflow, and 30+ engines simultaneously
|
|
24
|
+
- π **Dynamic Discovery** β Auto-fetches available engines and categories from your SearXNG server
|
|
25
|
+
- π **Multiple Formats** β Markdown (LLM-optimized), JSON, CSV, or HTML output
|
|
26
|
+
- π§ **Deep Search** β Multi-round iterative research with session accumulation and knowledge graph
|
|
27
|
+
- π **Content Extraction** β Extract full article content from search results
|
|
28
|
+
- ποΈ **Session Management** β Accumulate search results across multiple rounds with deduplication
|
|
29
|
+
- πΈοΈ **Knowledge Graph** β Build semantic graphs of entities and relationships
|
|
30
|
+
- β‘ **Fast & Lightweight** β Built with TypeScript, minimal dependencies
|
|
31
|
+
- π§ **Flexible Config** β Environment variables, config file, or interactive setup
|
|
32
|
+
- π₯ **Health Check** β Verify server connectivity instantly
|
|
33
|
+
- π **Proxy Support** β HTTP/HTTPS proxy configuration
|
|
34
|
+
|
|
35
|
+
## π¦ Installation
|
|
6
36
|
|
|
7
37
|
```bash
|
|
8
38
|
npm install -g sxng-cli
|
|
9
|
-
# or
|
|
10
|
-
pnpm add -g sxng-cli
|
|
11
|
-
# or
|
|
12
|
-
yarn global add sxng-cli
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Quick Start
|
|
16
|
-
|
|
17
|
-
1. Set up a SearXNG server:
|
|
18
|
-
```bash
|
|
19
|
-
docker run -d --name searxng -p 8080:8080 searxng/searxng
|
|
20
39
|
```
|
|
21
40
|
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
cp searxng.config.example.json searxng.config.json
|
|
25
|
-
# Edit the file with your settings
|
|
26
|
-
```
|
|
41
|
+
Or from source:
|
|
27
42
|
|
|
28
|
-
3. Run a search:
|
|
29
43
|
```bash
|
|
30
|
-
|
|
44
|
+
git clone https://github.com/hkwuks/sxng-cli.git
|
|
45
|
+
cd sxng-cli/cli
|
|
46
|
+
npm install
|
|
47
|
+
npm run build
|
|
48
|
+
npm link
|
|
31
49
|
```
|
|
32
50
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
## π Quick Start
|
|
52
|
+
|
|
53
|
+
1. **Configure the CLI:**
|
|
54
|
+
```bash
|
|
55
|
+
sxng init
|
|
56
|
+
```
|
|
57
|
+
Or set environment variable:
|
|
58
|
+
```bash
|
|
59
|
+
export SEARXNG_BASE_URL=http://your-searxng-instance:8080
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. **Perform a search:**
|
|
63
|
+
```bash
|
|
64
|
+
sxng "TypeScript tutorial"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## π Usage
|
|
68
|
+
|
|
69
|
+
### Commands
|
|
70
|
+
|
|
71
|
+
| Command | Description |
|
|
72
|
+
|---------|-------------|
|
|
73
|
+
| `sxng init` | Interactive configuration setup |
|
|
74
|
+
| `sxng <query>` | Perform a web search |
|
|
75
|
+
| `sxng --queries "q1,q2"` | Multi-query search with RRF fusion |
|
|
76
|
+
| `sxng extract --urls <urls>` | Extract content from web pages |
|
|
77
|
+
| `sxng --session new` | Create deep search session |
|
|
78
|
+
| `sxng session-list` | List all sessions |
|
|
79
|
+
| `sxng session-delete <session-name>` | Delete a session |
|
|
80
|
+
| `sxng graph-add <session>` | Add entities to knowledge graph |
|
|
81
|
+
| `sxng query-graph <session>` | Query knowledge graph |
|
|
82
|
+
| `sxng --health` | Check SearXNG server health |
|
|
83
|
+
| `sxng --engines-list` | List available search engines from server |
|
|
84
|
+
| `sxng --categories-list` | List available categories from server |
|
|
85
|
+
|
|
86
|
+
### Search Options
|
|
87
|
+
|
|
88
|
+
| Option | Description |
|
|
89
|
+
|--------|-------------|
|
|
90
|
+
| `-e, --engines <list>` | Comma-separated list of search engines (e.g., `google,github`) |
|
|
91
|
+
| `-c, --categories <list>` | Comma-separated list of categories (e.g., `it,science`) |
|
|
92
|
+
| `-l, --limit <n>` | Maximum number of results (default: 10) |
|
|
93
|
+
| `-p, --page <n>` | Page number for pagination |
|
|
94
|
+
| `--lang <code>` | Language code (e.g., `en`, `zh`, `ja`) |
|
|
95
|
+
| `--time <range>` | Time range: `day`, `week`, `month`, `year`, `all` |
|
|
96
|
+
| `-f, --format <fmt>` | Output format: `md`, `json`, `csv`, `html` (default: md) |
|
|
97
|
+
| `--queries <list>` | Multi-query with RRF fusion (e.g., `q1,q2,q3`) |
|
|
98
|
+
| `--session <session-name>` | Session directory or `new` for deep search |
|
|
99
|
+
| `--owner <session-name>` | Session owner identifier |
|
|
100
|
+
| `--desc <text>` | Session description |
|
|
101
|
+
|
|
102
|
+
### Examples
|
|
45
103
|
|
|
46
104
|
```bash
|
|
47
|
-
#
|
|
48
|
-
sxng "
|
|
105
|
+
# Basic search (outputs Markdown by default)
|
|
106
|
+
sxng "machine learning"
|
|
49
107
|
|
|
50
|
-
#
|
|
51
|
-
sxng "
|
|
52
|
-
|
|
53
|
-
# Use specific engines
|
|
54
|
-
sxng --engines google,github "react hooks"
|
|
108
|
+
# Output as JSON
|
|
109
|
+
sxng --format json "machine learning"
|
|
55
110
|
|
|
56
|
-
# Search
|
|
57
|
-
sxng --
|
|
111
|
+
# Search with specific engines
|
|
112
|
+
sxng --engines google,duckduckgo "privacy tools"
|
|
58
113
|
|
|
59
|
-
#
|
|
60
|
-
sxng --
|
|
114
|
+
# Search IT and Science categories
|
|
115
|
+
sxng --categories it,science "kubernetes tutorial"
|
|
61
116
|
|
|
62
|
-
#
|
|
63
|
-
sxng
|
|
117
|
+
# Limit results and filter by time
|
|
118
|
+
sxng --limit 5 --time week "latest AI news"
|
|
64
119
|
|
|
65
|
-
#
|
|
66
|
-
sxng --
|
|
120
|
+
# Multi-query search with RRF fusion
|
|
121
|
+
sxng --queries "tokio tutorial,rust async basics,async-std guide"
|
|
67
122
|
|
|
68
|
-
# List available engines
|
|
123
|
+
# List available engines (fetched from server)
|
|
69
124
|
sxng --engines-list
|
|
70
|
-
|
|
71
|
-
# List available categories
|
|
72
|
-
sxng --categories-list
|
|
73
125
|
```
|
|
74
126
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Run multiple queries with RRF (Reciprocal Rank Fusion) result fusion and deduplication:
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
sxng --queries "tokio tutorial,rust async basics,tokio vs async-std"
|
|
81
|
-
```
|
|
127
|
+
## βοΈ Configuration
|
|
82
128
|
|
|
83
|
-
|
|
129
|
+
Configuration priority (highest to lowest):
|
|
130
|
+
1. Environment variables
|
|
131
|
+
2. Local config file (`./sxng.config.json`)
|
|
132
|
+
3. Global config file (`~/sxng-cli/sxng.config.json`)
|
|
133
|
+
4. Default values
|
|
84
134
|
|
|
85
|
-
|
|
135
|
+
### Environment Variables
|
|
86
136
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
137
|
+
| Variable | Description | Default |
|
|
138
|
+
|----------|-------------|---------|
|
|
139
|
+
| `SEARXNG_BASE_URL` | SearXNG server URL | *(required)* |
|
|
140
|
+
| `SEARXNG_DEFAULT_ENGINE` | Default search engine | *(none)* |
|
|
141
|
+
| `SEARXNG_ALLOWED_ENGINES` | Comma-separated allowed engines | *(all)* |
|
|
142
|
+
| `SEARXNG_DEFAULT_LIMIT` | Default result limit | `10` |
|
|
143
|
+
| `SEARXNG_DEFAULT_FORMAT` | Default output format (`md`, `json`, `csv`, `html`) | `md` |
|
|
144
|
+
| `SEARXNG_USE_PROXY` | Use proxy (`true`/`false`) | `false` |
|
|
145
|
+
| `SEARXNG_PROXY_URL` | Proxy URL | *(none)* |
|
|
146
|
+
| `SEARXNG_TIMEOUT` | Request timeout in ms | `10000` |
|
|
90
147
|
|
|
91
|
-
|
|
92
|
-
|
|
148
|
+
### Config File
|
|
149
|
+
|
|
150
|
+
Create `sxng.config.json`:
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"baseUrl": "http://localhost:8080",
|
|
155
|
+
"defaultEngine": "",
|
|
156
|
+
"allowedEngines": [],
|
|
157
|
+
"defaultLimit": 10,
|
|
158
|
+
"defaultFormat": "md",
|
|
159
|
+
"useProxy": false,
|
|
160
|
+
"proxyUrl": "",
|
|
161
|
+
"timeout": 10000
|
|
162
|
+
}
|
|
93
163
|
```
|
|
94
164
|
|
|
95
|
-
## Deep Search
|
|
165
|
+
## π§ Deep Search
|
|
96
166
|
|
|
97
167
|
Deep search enables multi-round iterative research with session accumulation and knowledge graph building.
|
|
98
168
|
|
|
99
|
-
###
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
# Create a new session with auto-generated name
|
|
103
|
-
sxng --session new --owner "research-agent" --desc "Rust async research" "rust async ecosystem"
|
|
104
|
-
|
|
105
|
-
# List all sessions
|
|
106
|
-
sxng session-list
|
|
107
|
-
|
|
108
|
-
# Delete a specific session
|
|
109
|
-
sxng session-delete <session-name>
|
|
110
|
-
|
|
111
|
-
# Delete sessions older than N hours
|
|
112
|
-
sxng session-delete --older 24
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Deep Search Workflow
|
|
116
|
-
|
|
117
|
-
The deep search flow follows an iterative loop: search β extract β analyze β build graph β decide.
|
|
169
|
+
### Quick Example
|
|
118
170
|
|
|
119
171
|
```bash
|
|
120
|
-
#
|
|
121
|
-
sxng --session new --owner "
|
|
122
|
-
# Note the returned session path, e.g., ~/.sxng/sessions/<session-name>
|
|
172
|
+
# Create a session and search
|
|
173
|
+
sxng --session new --owner "researcher" --desc "Rust async study" "rust async ecosystem"
|
|
123
174
|
|
|
124
175
|
# Extract content from results
|
|
125
|
-
sxng extract --session
|
|
176
|
+
sxng extract --session <session-name>
|
|
126
177
|
|
|
127
|
-
# Add
|
|
128
|
-
sxng graph-add
|
|
178
|
+
# Add knowledge graph entities
|
|
179
|
+
sxng graph-add <session-name> --data '{
|
|
129
180
|
"entities": [
|
|
130
181
|
{"label": "tokio", "entityType": "runtime", "score": 0.95},
|
|
131
182
|
{"label": "async-std", "entityType": "runtime", "score": 0.85}
|
|
@@ -135,67 +186,44 @@ sxng graph-add ~/.sxng/sessions/<session-name> --data '{
|
|
|
135
186
|
]
|
|
136
187
|
}'
|
|
137
188
|
|
|
138
|
-
# Query the
|
|
139
|
-
sxng query-graph
|
|
140
|
-
|
|
141
|
-
# Round 2: Search with multiple queries (results accumulate in session)
|
|
142
|
-
sxng --session ~/.sxng/sessions/<session-name> --queries "tokio vs async-std comparison,rust async benchmark 2024"
|
|
189
|
+
# Query the graph
|
|
190
|
+
sxng query-graph <session-name> --seeds "tokio" --depth 2
|
|
143
191
|
|
|
144
|
-
#
|
|
192
|
+
# Continue research (results accumulate)
|
|
193
|
+
sxng --session <session-name> --queries "tokio vs async-std,benchmark 2024"
|
|
145
194
|
```
|
|
146
195
|
|
|
147
|
-
### Session
|
|
196
|
+
### Session Management
|
|
148
197
|
|
|
149
|
-
|
|
198
|
+
| Command | Description |
|
|
199
|
+
|---------|-------------|
|
|
200
|
+
| `sxng --session new` | Create new auto-named session |
|
|
201
|
+
| `sxng --session <session-name>` | Use session by name |
|
|
202
|
+
| `sxng session-list` | List all sessions with stats |
|
|
203
|
+
| `sxng session-delete <session-name>` | Delete specific session |
|
|
204
|
+
| `sxng session-delete --older <hours>` | Delete old sessions |
|
|
150
205
|
|
|
151
|
-
|
|
152
|
-
-
|
|
153
|
-
-
|
|
206
|
+
**Session Path Resolution:**
|
|
207
|
+
- Pure name (e.g., `my-session`) β `~/.sxng/sessions/my-session`
|
|
208
|
+
- Full path (e.g., `/custom/path/session`) β used as-is
|
|
209
|
+
- `new` β auto-generate unique name under `~/.sxng/sessions/`
|
|
154
210
|
|
|
155
211
|
### Knowledge Graph
|
|
156
212
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
| Node type | Prefix | Attributes |
|
|
162
|
-
|-----------|--------|------------|
|
|
163
|
-
| query | `q:` | label, query, round |
|
|
164
|
-
| result | `r:` | label, url, title, rank |
|
|
165
|
-
| domain | `d:` | label, domain |
|
|
166
|
-
|
|
167
|
-
**Semantic Layer** (added via `graph-add`):
|
|
168
|
-
|
|
169
|
-
| Node type | Prefix | Attributes |
|
|
170
|
-
|-----------|--------|------------|
|
|
171
|
-
| entity | `e:` | label, entityType, score |
|
|
172
|
-
|
|
173
|
-
## Options Reference
|
|
213
|
+
**Structural Layer** (auto-built):
|
|
214
|
+
- `q:` β Query nodes
|
|
215
|
+
- `r:` β Result nodes
|
|
216
|
+
- `d:` β Domain nodes
|
|
174
217
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
| `--limit` | `-l` | Max results | `-l 20` |
|
|
178
|
-
| `--engines` | `-e` | Specific search engines | `-e google,github` |
|
|
179
|
-
| `--categories` | `-c` | Filter by category | `-c it,science` |
|
|
180
|
-
| `--page` | `-p` | Pagination | `-p 2` |
|
|
181
|
-
| `--lang` | | Result language | `--lang zh` |
|
|
182
|
-
| `--time` | | Time filter | `--time week` |
|
|
183
|
-
| `--format` | `-f` | Output format | `-f json` |
|
|
184
|
-
| `--queries` | | Multi-query with RRF fusion | `--queries "q1,q2,q3"` |
|
|
185
|
-
| `--session` | | Session directory or "new" | `--session new` |
|
|
186
|
-
| `--owner` | | Session owner identifier | `--owner "agent-1"` |
|
|
187
|
-
| `--desc` | | Session description | `--desc "research topic"` |
|
|
218
|
+
**Semantic Layer** (via `graph-add`):
|
|
219
|
+
- `e:` β Entity nodes with type and score
|
|
188
220
|
|
|
189
|
-
##
|
|
221
|
+
## π Links
|
|
190
222
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
| `SEARXNG_DEFAULT_LIMIT` | Default result limit | `10` |
|
|
195
|
-
| `SEARXNG_TIMEOUT` | Request timeout in ms | `10000` |
|
|
196
|
-
| `SEARXNG_USE_PROXY` | Use proxy (`true`/`false`) | `false` |
|
|
197
|
-
| `SEARXNG_PROXY_URL` | Proxy URL | (none) |
|
|
223
|
+
- **GitHub:** https://github.com/hkwuks/sxng-cli
|
|
224
|
+
- **npm:** https://www.npmjs.com/package/sxng-cli
|
|
225
|
+
- **SearXNG:** https://github.com/searxng/searxng
|
|
198
226
|
|
|
199
|
-
## License
|
|
227
|
+
## π License
|
|
200
228
|
|
|
201
|
-
MIT
|
|
229
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sxng-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "SearXNG CLI - Web Search Tool",
|
|
5
|
+
"homepage": "https://github.com/hkwuks/sxng-cli#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/hkwuks/sxng-cli.git",
|
|
9
|
+
"directory": "cli"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/hkwuks/sxng-cli/issues"
|
|
13
|
+
},
|
|
5
14
|
"type": "module",
|
|
6
15
|
"main": "dist/index.js",
|
|
7
16
|
"types": "dist/index.d.ts",
|