@bacnh85/pi-web 0.1.2 → 0.2.1

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 CHANGED
@@ -33,8 +33,8 @@ Environment lookup order:
33
33
  1. Process environment
34
34
  2. Current working directory `.env.local`
35
35
  3. Current working directory `.env`
36
- 4. Pi global config `.env.local` (`$PI_CODING_AGENT_DIR/.env.local` when set; otherwise `~/.pi/agent/.env.local` then `~/.pi/agents/.env.local`)
37
- 5. Pi global config `.env` (`$PI_CODING_AGENT_DIR/.env` when set; otherwise `~/.pi/agent/.env` then `~/.pi/agents/.env`)
36
+ 4. Pi global config `.env.local` (`$PI_CODING_AGENT_DIR/.env.local` when set; otherwise `~/.pi/agent/.env.local`)
37
+ 5. Pi global config `.env` (`$PI_CODING_AGENT_DIR/.env` when set; otherwise `~/.pi/agent/.env`)
38
38
 
39
39
  Variables:
40
40
 
@@ -51,7 +51,10 @@ Secrets are never printed; status reports only show presence/source.
51
51
  Brave:
52
52
 
53
53
  - `brave_search` — search web results, optionally fetch readable result content.
54
- - `brave_content` — fetch a URL and extract readable markdown.
54
+
55
+ Web Content:
56
+
57
+ - `web_content` — fetch a URL and extract readable markdown (formerly `brave_content`; renamed in v0.2.0 because it does not use the Brave API).
55
58
 
56
59
  SearXNG:
57
60
 
@@ -69,11 +72,43 @@ Utility:
69
72
  - `web_status` — show configured provider status without secrets.
70
73
  - `/web-status` — command version of the status check.
71
74
 
75
+ ## Library structure
76
+
77
+ The extension is split into `lib/` modules:
78
+
79
+ | Module | Contents |
80
+ |--------|----------|
81
+ | `lib/config.ts` | Environment loading, config helpers for all providers |
82
+ | `lib/format.ts` | Text sanitization, truncation, search/scrape result formatting |
83
+ | `lib/content.ts` | Readable content extraction (JSDOM + Readability + Turndown) |
84
+ | `lib/retry.ts` | Retry with exponential backoff for transient HTTP failures |
85
+ | `lib/brave.ts` | Brave Search API fetch client |
86
+ | `lib/searxng.ts` | SearXNG metasearch fetch client |
87
+ | `lib/firecrawl.ts` | Firecrawl API fetch client with v2→v1 fallback |
88
+
89
+ ## Retry behavior
90
+
91
+ All HTTP-backed tools (`brave_search`, `searxng_search`, `firecrawl_*`) use a `withRetry` wrapper with exponential backoff (up to 2 retries, ~1s initial delay). Non-transient errors (auth, validation, not found) are never retried.
92
+
93
+ ## Migration from 0.1.x
94
+
95
+ - `brave_content` has been renamed to `web_content`. Update any agent instructions or skills that reference `brave_content` to use `web_content` instead. The tool API and behavior are unchanged.
96
+
97
+ ## Development
98
+
99
+ ```bash
100
+ # Run all tests
101
+ npm test
102
+
103
+ # Run only unit tests
104
+ npm run test:unit
105
+ ```
106
+
72
107
  ## Practical Guidance
73
108
 
74
109
  - Use `searxng_search` first for general web search, docs lookup, current facts, and source discovery; it is fast, self-hosted, and avoids hosted API costs/rate limits.
75
110
  - Use `brave_search` as a fast hosted fallback when SearXNG results are weak/unavailable, or when an independent search index is useful. Use `include_content` sparingly.
76
- - Use `brave_content` for fast known-URL article/docs extraction when simple readable markdown is enough.
111
+ - Use `web_content` for fast known-URL article/docs extraction when simple readable markdown is enough.
77
112
  - Use `firecrawl_search` when SearXNG/Brave are unavailable, when Firecrawl search is preferred, or when search results should include scraped markdown.
78
113
  - Use `firecrawl_scrape` for known URLs when extraction quality matters, pages are dynamic, links are needed, or structured JSON extraction is requested.
79
114
  - Use `firecrawl_map` before crawling to discover candidate URLs and keep crawls targeted.