feat: add fastCRW search request, mapping and error handling #12

Merged
haylan merged 1 commits from feat/search into main 2026-10-03 17:26:11 +00:00
Owner

Step 2 (part 2) of the build order in docs/spec.md: src/search.ts with tests, written test-first.

  • search(config, query, signal, fetchFn?, timeoutMs?): POST {baseURL}/v1/search, Bearer only when a key exists, lang/tbs omitted when unset
  • Accepts data as an array or data.results; maps to { url, title, content: snippet || description, time: {} }; drops entries without a url
  • Errors: fastCRW <status> <error_code>: <error> (also for HTTP 200 with success:false), hints for 401 and 503 search_disabled, non-JSON, unreachable (cause kept), internal 30 s timeout, caller abort rethrown untouched; the token never appears in a message
  • fetch and the timeout are parameters so tests need no server; 15 new tests (26 total); npm run check passes

🤖 Generated with Claude Code

Step 2 (part 2) of the build order in `docs/spec.md`: `src/search.ts` with tests, written test-first. - `search(config, query, signal, fetchFn?, timeoutMs?)`: `POST {baseURL}/v1/search`, Bearer only when a key exists, `lang`/`tbs` omitted when unset - Accepts `data` as an array or `data.results`; maps to `{ url, title, content: snippet || description, time: {} }`; drops entries without a url - Errors: `fastCRW <status> <error_code>: <error>` (also for HTTP 200 with `success:false`), hints for 401 and 503 `search_disabled`, non-JSON, unreachable (cause kept), internal 30 s timeout, caller abort rethrown untouched; the token never appears in a message - `fetch` and the timeout are parameters so tests need no server; 15 new tests (26 total); `npm run check` passes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
haylan added 1 commit 2026-10-03 17:10:44 +00:00
haylan merged commit bdac7ddf17 into main 2026-10-03 17:26:11 +00:00
haylan deleted branch feat/search 2026-10-03 17:26:11 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: haylan/fastcrw-opencode-websearch#12