Compare commits

...

2 Commits

Author SHA1 Message Date
3f8b60be44 bump 2026-06-10 16:29:11 -04:00
19ae7504b5 migrate to settings.json 2026-06-10 16:28:49 -04:00
4 changed files with 64 additions and 28 deletions

View File

@@ -79,21 +79,36 @@ Research Flow:
## Configuration
Deep Research reads Firecrawl configuration from `~/.pi/agent/settings.json`:
Deep Research reads Firecrawl configuration from pi's settings.json files, with the following resolution order (later wins):
1. Environment variables (`FIRECRAWL_BASE_URL`, `FIRECRAWL_API_KEY`)
2. Global settings (`$agentDir/settings.json`) → `firecrawl.*`
3. Project settings (`.pi/settings.json`) → `firecrawl.*`
4. Default `http://localhost:3002` (if nothing else sets baseUrl)
The agent directory (`$agentDir`) defaults to `~/.pi/agent` and respects the `PI_CODING_AGENT_DIR` environment variable.
**Global settings** (`~/.pi/agent/settings.json`):
```json
{
"firecrawl": {
"baseUrl": "http://localhost:3002",
}
}
```
**Project settings** (`.pi/settings.json` — overrides global):
```json
{
"firecrawl": {
"baseUrl": "https://firecrawl.team.internal"
"apiKey": "your-api-key"
}
}
```
Environment variables are also supported:
- `FIRECRAWL_BASE_URL` — overrides the Firecrawl endpoint (default: `http://localhost:3002`)
- `FIRECRAWL_API_KEY` — API key for authenticated Firecrawl instances
### Session startup check
On `session_start`, the extension checks whether the Firecrawl endpoint is reachable. If not, it shows a warning notification so you know searches will fail before you try to use it.

View File

@@ -585,7 +585,7 @@ export default function (pi: ExtensionAPI) {
const reachable = await isFirecrawlReachable();
if (!reachable) {
ctx.ui.notify(
"Deep Research: Firecrawl endpoint unreachable — searches will fail. Check FIRECRAWL_BASE_URL in settings.json or env.",
"Deep Research: Firecrawl endpoint unreachable — searches will fail. Set firecrawl.baseUrl in settings.json (global or project) or the FIRECRAWL_BASE_URL env var.",
"warning",
);
}

View File

@@ -1,6 +1,6 @@
{
"name": "@mikefreno/deepi-research",
"version": "0.1.1",
"version": "0.1.2",
"description": "Deep research extension for pi — parallel web research via Firecrawl with iterative query refinement",
"keywords": [
"pi-package",

View File

@@ -6,32 +6,53 @@
*/
import * as fs from "node:fs";
import * as path from "node:path";
import * as os from "node:os";
import type { SearchResult, EnrichedSearchResult, ContentType } from "./types";
import { getAgentDir } from "@earendil-works/pi-coding-agent";
/* ── Config ──────────────────────────────────────────────────────── */
/**
* Read and merge Firecrawl settings from pi's settings.json files.
*
* Resolution order (later wins):
* 1. env vars FIRECRAWL_BASE_URL / FIRECRAWL_API_KEY
* 2. global ~/.pi/agent/settings.json → firecrawl.*
* 3. project .pi/settings.json → firecrawl.*
* 4. default http://localhost:3002 (if no baseUrl configured)
*/
function loadFirecrawlConfig() {
const settingsPath = path.join(os.homedir(), ".pi", "agent", "settings.json");
try {
const settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
const fc = settings.firecrawl ?? {};
return {
baseUrl: (
fc.baseUrl ??
process.env.FIRECRAWL_BASE_URL ??
"http://localhost:3002"
).replace(/\/+$/, ""),
apiKey: fc.apiKey ?? process.env.FIRECRAWL_API_KEY,
};
} catch {
return {
baseUrl: (
process.env.FIRECRAWL_BASE_URL ?? "http://localhost:3002"
).replace(/\/+$/, ""),
apiKey: process.env.FIRECRAWL_API_KEY,
};
}
// Start with env var defaults
let baseUrl = process.env.FIRECRAWL_BASE_URL ?? "http://localhost:3002";
let apiKey = process.env.FIRECRAWL_API_KEY;
const agentDir = getAgentDir();
// Helper: read a settings.json and merge its firecrawl.* keys
const tryReadSettings = (settingsPath: string): void => {
try {
const raw = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
const fc: Record<string, string | undefined> = raw.firecrawl ?? {};
if (typeof fc.baseUrl === "string" && fc.baseUrl.length > 0) {
baseUrl = fc.baseUrl;
}
if (typeof fc.apiKey === "string" && fc.apiKey.length > 0) {
apiKey = fc.apiKey;
}
} catch {
// File missing or unparseable — skip
}
};
// 1. Global settings
tryReadSettings(path.join(agentDir, "settings.json"));
// 2. Project settings (override global)
tryReadSettings(path.join(process.cwd(), ".pi", "settings.json"));
return {
baseUrl: baseUrl.replace(/\/+$/, ""),
apiKey,
};
}
const { baseUrl: BASE_URL, apiKey: API_KEY } = loadFirecrawlConfig();