feat: add web_search tool

This commit is contained in:
alex wiesner
2026-04-09 11:13:21 +01:00
parent 7db96b025b
commit c2d7cd53ce
4 changed files with 155 additions and 7 deletions

View File

@@ -922,7 +922,7 @@ git -C /home/alex/dotfiles commit -m "test: add web tool output formatting"
- Create: `/home/alex/dotfiles/.pi/agent/extensions/web-search/src/tools/web-search.ts`
- Test: `/home/alex/dotfiles/.pi/agent/extensions/web-search/src/tools/web-search.test.ts`
- [ ] **Step 1: Write the failing `web_search` tool tests**
- [x] **Step 1: Write the failing `web_search` tool tests**
Create `/home/alex/dotfiles/.pi/agent/extensions/web-search/src/tools/web-search.test.ts` with this content:
@@ -981,7 +981,7 @@ test("web_search rejects a blank query before resolving a provider", async () =>
});
```
- [ ] **Step 2: Run the `web_search` tests to verify they fail**
- [x] **Step 2: Run the `web_search` tests to verify they fail**
Run:
@@ -992,7 +992,7 @@ npx tsx --test src/tools/web-search.test.ts
Expected: `FAIL` with an `ERR_MODULE_NOT_FOUND` error for `./web-search.ts`.
- [ ] **Step 3: Write the minimal `web_search` tool implementation**
- [x] **Step 3: Write the minimal `web_search` tool implementation**
Create `/home/alex/dotfiles/.pi/agent/extensions/web-search/src/tools/web-search.ts` with this content:
@@ -1066,7 +1066,7 @@ export function createWebSearchTool({ resolveProvider }: SearchToolDeps) {
}
```
- [ ] **Step 4: Run the `web_search` tests to verify they pass**
- [x] **Step 4: Run the `web_search` tests to verify they pass**
Run:
@@ -1077,7 +1077,7 @@ npx tsx --test src/tools/web-search.test.ts
Expected: `PASS` for both tests.
- [ ] **Step 5: Create a real Exa config file for the live smoke test**
- [x] **Step 5: Create a real Exa config file for the live smoke test**
Run:
@@ -1106,7 +1106,7 @@ unset EXA_KEY
Expected: `/home/alex/.pi/agent/web-search.json` exists with mode `600`.
- [ ] **Step 6: Add a temporary entrypoint that registers `web_search` and manually verify it live**
- [x] **Step 6: Add a temporary entrypoint that registers `web_search` and manually verify it live**
Create `/home/alex/dotfiles/.pi/agent/extensions/web-search/index.ts` with this content:
@@ -1162,7 +1162,7 @@ Expected manual checks:
- the result contains metadata-only output, not fetched page text
- at least one result includes `https://exa.ai/docs`
- [ ] **Step 7: Commit the `web_search` tool**
- [x] **Step 7: Commit the `web_search` tool**
Run: