Skip to content

Commit 925f8f2

Browse files
committed
feat: Add grep and websearch tools
Introduces two new tools: `grep` for filtering text/files by regex, and `websearch` for querying the web using LLM models. Updates package version.
1 parent 4d5c999 commit 925f8f2

15 files changed

Lines changed: 287 additions & 1 deletion

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ Basic toolset for [Tune](https://github.com/iovdin/tune).
1313
- [sh](#sh) execute shell command
1414
- [cmd](#cmd) execute Windows cmd command
1515
- [powershell](#powershell) execute PowerShell command
16+
- [grep](#grep) search for patterns in text or files
1617
- [osa](#osa) manage reminders/notes/calendar (AppleScript/macOS)
1718
- [jina_r](#jina_r) fetch webpage content
19+
- [websearch](#websearch) search the web with web-enabled llms
1820
- [list](#list) keep list of tasks todo (loops for LLM)
1921
- [sqlite](#sqlite) execute sqlite queries
2022
- [py](#py) run python code
@@ -175,6 +177,22 @@ TotalPhysicalMemory : 17179869184
175177
CsProcessors : {Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz}
176178
```
177179

180+
### `grep`
181+
Search for patterns in text or files using regular expressions
182+
```chat
183+
user: @grep
184+
find all lines containing "TODO" in myfile.js
185+
tool_call: grep {"filename":"myfile.js","regex":"TODO"}
186+
tool_result:
187+
// TODO: refactor this function
188+
// TODO: add error handling
189+
190+
system:
191+
TODOS:
192+
@{ myfile.js | proc grep regex=TODO }
193+
194+
```
195+
178196
### `osa`
179197
AppleScript tool, manage reminders, notes, calendar etc on osx
180198
```chat
@@ -219,7 +237,25 @@ Tune is a versatile toolkit designed for developers and users to effectively int
219237
<cut for brevity>
220238
```
221239

240+
### `websearch`
241+
Search the web with web enabled llms
242+
Supports search with `perplexity/sonar`, `perplexity/sonar-pro`, `gpt-4o-search-preview`, `gpt-4o-mini-search-preview` models via the `model` parameter (defaults to `perplexity/sonar`).
243+
244+
```chat
245+
user: @websearch
246+
latest ai news
247+
248+
assistant:
249+
250+
tool_call: websearch {"model":"perplexity/sonar"}
251+
latest AI news
252+
tool_result:
253+
The latest AI news in October 2025 highlights significant investments, new projects, policy developments, and advances across various sectors:
254+
255+
- Major companies including Microsoft, Google, Nvidia, OpenAI, Salesforce, and CoreWeave have pledged over £31 billion in capital expenditure focused on AI data centers and infrastructure upgrades[1].
256+
```
222257

258+
The websearch tool provides up-to-date information by querying the web through AI-powered search models. You can specify different Perplexity models like `perplexity/sonar-pro` for more advanced searches.
223259

224260
### `list`
225261
Keep list of tasks to do

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tune-basic-toolset",
3-
"version": "0.1.10",
3+
"version": "0.1.11",
44
"description": "Basic toolset for tune",
55
"main": "src/index.js",
66
"files": [

src/grep.schema.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"description": "filter lines with regex",
3+
"parameters": {
4+
"type": "object",
5+
"properties": {
6+
"text": {
7+
"type": "string",
8+
"description": "Text to be filtered"
9+
},
10+
"filename": {
11+
"type": "string",
12+
"description": "if text is not set, filename will be read and filtered"
13+
},
14+
"regex": {
15+
"type": "string",
16+
"description": "js regex to filter lines in file or text. passed as first arguments to new RegExp "
17+
},
18+
"regex_flags": {
19+
"type": "string",
20+
"description": "flags to be passed to new RegExp constructor"
21+
}
22+
},
23+
"required": ["regex"]
24+
}
25+
}

src/grep.tool.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = async function grep({filename, text, regex, regex_flags}, ctx) {
2+
if (!text && filename) {
3+
const n = await ctx.resolve(filename)
4+
if (!n)
5+
return `${filename} not found`
6+
7+
text = await n.read()
8+
}
9+
10+
if (!text) {
11+
return "content is empty"
12+
}
13+
14+
const r = new RegExp(regex, regex_flags)
15+
return text.split(/\r?\n/).filter(line => r.test(line)).join("\n").replaceAll("@", "\\@")
16+
}

src/websearch.schema.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"description": "Does a websearch using llm",
3+
"parameters": {
4+
"type": "object",
5+
"properties": {
6+
"text": {
7+
"type": "string",
8+
"description": "web search query"
9+
},
10+
"model": {
11+
"type": "string",
12+
"enum": [
13+
"perplexity/sonar",
14+
"perplexity/sonar-pro",
15+
"gpt-4o-search-preview",
16+
"gpt-4o-mini-search-preview"
17+
],
18+
"description": "model to do websearch, default is perplexity/sonar"
19+
}
20+
},
21+
"required": ["text"]
22+
}
23+
}

src/websearch.tool.chat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
user:
2+
@{ model | init perplexity/sonar | resolve }
3+
@text

test/p05.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
a
2+
b
3+
c
4+
-------------------------------
5+
<<<<<<< ORIGINAL
6+
a
7+
b
8+
c
9+
=======
10+
d
11+
e
12+
f
13+
>>>>>>> UPDATED
14+
-------------------------------
15+
d
16+
e
17+
f

test/p06.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
x
2+
(aif user.mangopayId
3+
(a (href: (+ "https://dashboard.mangopay.com/User/" it "/Details") target:"_blank")
4+
"Mangopay wallet"))
5+
y
6+
-------------------------------
7+
<<<<<<< ORIGINAL
8+
(aif user.mangopayId
9+
(a (href: (+ "https://dashboard.mangopay.com/User/" it "/Details") target:"_blank")
10+
"Mangopay wallet"))
11+
=======
12+
(aif user.mangopayId
13+
(span "Mangopay: " it))
14+
>>>>>> UPDATED
15+
-------------------------------
16+
x
17+
(aif user.mangopayId
18+
(span "Mangopay: " it))
19+
y

test/p07.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
foo
2+
bar
3+
baz
4+
-------------------------------
5+
<<<<<<<< ORIGINAL
6+
bar
7+
=======
8+
BAR
9+
>>>>>>>> UPDATED
10+
-------------------------------
11+
foo
12+
BAR
13+
baz

test/p08.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
a
2+
b
3+
c
4+
-------------------------------
5+
<<<<<<< ORIGINAL
6+
b
7+
=======
8+
B
9+
>>>>>> UPDATED
10+
-------------------------------
11+
a
12+
B
13+
c

0 commit comments

Comments
 (0)