refactor: complete pi-web rename in paths and env vars
- Config path: ~/.pi/pi-search/config.json -> ~/.pi/pi-web/config.json - Env vars: PI_SEARCH_PROVIDER -> PI_WEB_PROVIDER, PI_SEARCH_SEARXNG_URL -> PI_WEB_SEARXNG_URL - README + flake.nix description updated to match.
This commit is contained in:
@@ -18,7 +18,7 @@ For raw HTTP responses, non-text content, or simple API calls, the LLM is steere
|
|||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
Drop a JSON file at `~/.pi/pi-search/config.json`:
|
Drop a JSON file at `~/.pi/pi-web/config.json`:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -35,10 +35,10 @@ Drop a JSON file at `~/.pi/pi-search/config.json`:
|
|||||||
### Env Var Overrides
|
### Env Var Overrides
|
||||||
|
|
||||||
| Variable | Overrides |
|
| Variable | Overrides |
|
||||||
| ----------------------- | ----------------- |
|
| --------------------- | ----------------- |
|
||||||
| `PI_SEARCH_PROVIDER` | `provider` |
|
| `PI_WEB_PROVIDER` | `provider` |
|
||||||
| `KAGI_TOKEN` | `kagi.token` |
|
| `KAGI_TOKEN` | `kagi.token` |
|
||||||
| `PI_SEARCH_SEARXNG_URL` | `searxng.baseUrl` |
|
| `PI_WEB_SEARXNG_URL` | `searxng.baseUrl` |
|
||||||
|
|
||||||
### Getting A Kagi Session Token
|
### Getting A Kagi Session Token
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
description = "pi-search extension development environment";
|
description = "pi-web extension development environment";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
||||||
|
|||||||
2
index.ts
2
index.ts
@@ -1,6 +1,6 @@
|
|||||||
// Pi-Web Extension - Registers `web_search` and `web_fetch` tools backed by
|
// Pi-Web Extension - Registers `web_search` and `web_fetch` tools backed by
|
||||||
// a shared headless Firefox session. Provider config lives in
|
// a shared headless Firefox session. Provider config lives in
|
||||||
// ~/.pi/pi-search/config.json (env overrides supported).
|
// ~/.pi/pi-web/config.json (env overrides supported).
|
||||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||||
import { Type } from "typebox";
|
import { Type } from "typebox";
|
||||||
import { ConfigError, loadConfig, resolveSettings } from "./src/config.ts";
|
import { ConfigError, loadConfig, resolveSettings } from "./src/config.ts";
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class ConfigError extends Error {
|
|||||||
export function defaultConfigPath(
|
export function defaultConfigPath(
|
||||||
env: NodeJS.ProcessEnv = process.env,
|
env: NodeJS.ProcessEnv = process.env,
|
||||||
): string {
|
): string {
|
||||||
return join(env.HOME ?? homedir(), ".pi", "pi-search", "config.json");
|
return join(env.HOME ?? homedir(), ".pi", "pi-web", "config.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
function isObject(value: unknown): value is Record<string, unknown> {
|
function isObject(value: unknown): value is Record<string, unknown> {
|
||||||
@@ -85,15 +85,15 @@ export function resolveSettings(
|
|||||||
config: PiSearchConfig,
|
config: PiSearchConfig,
|
||||||
env: NodeJS.ProcessEnv = process.env,
|
env: NodeJS.ProcessEnv = process.env,
|
||||||
): ResolvedSettings {
|
): ResolvedSettings {
|
||||||
const provider = (env.PI_SEARCH_PROVIDER as Provider) ?? config.provider;
|
const provider = (env.PI_WEB_PROVIDER as Provider) ?? config.provider;
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
throw new ConfigError(
|
throw new ConfigError(
|
||||||
"no provider configured. Set provider in ~/.pi/pi-search/config.json or PI_SEARCH_PROVIDER env.",
|
"no provider configured. Set provider in ~/.pi/pi-web/config.json or PI_WEB_PROVIDER env.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
provider,
|
provider,
|
||||||
kagiToken: env.KAGI_TOKEN ?? config.kagi?.token,
|
kagiToken: env.KAGI_TOKEN ?? config.kagi?.token,
|
||||||
searxngBaseUrl: env.PI_SEARCH_SEARXNG_URL ?? config.searxng?.baseUrl,
|
searxngBaseUrl: env.PI_WEB_SEARXNG_URL ?? config.searxng?.baseUrl,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export async function searchSearxng({
|
|||||||
if (!baseUrl) {
|
if (!baseUrl) {
|
||||||
throw new SearchError(
|
throw new SearchError(
|
||||||
"SEARXNG_URL_REQUIRED",
|
"SEARXNG_URL_REQUIRED",
|
||||||
"SearXNG search requires a base URL. Set searxng.baseUrl in config or PI_SEARCH_SEARXNG_URL env.",
|
"SearXNG search requires a base URL. Set searxng.baseUrl in config or PI_WEB_SEARXNG_URL env.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user